Melvor Sort By Type

Overrides melvor's item sort algorithm to something more logical

  1. // ==UserScript==
  2. // @name Melvor Sort By Type
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.01/SVN?1354
  5. // @description Overrides melvor's item sort algorithm to something more logical
  6. // @author mootykins
  7. // @match https://*.melvoridle.com/*
  8. // @exclude https://wiki.melvoridle.com*
  9. // @exclude https://*.melvoridle.com/index.php
  10. // @noframes
  11. // @license unlicense
  12. // @grant none
  13. // ==/UserScript==
  14. // Loading code by GMiclotte
  15. function sortScript() {
  16. if (window.SortScript !== undefined) {
  17. console.error('SortBank is already loaded!');
  18. } else {
  19. loadSortScript();
  20. }
  21.  
  22. function loadSortScript(){
  23. window.SortScript = {}
  24. sortBank = function() {
  25. bank.sort((a,b) => {
  26. let a_full = items[a.id];
  27. let b_full = items[b.id];
  28. if(a_full.category == b_full.category){
  29. if(a_full.type == b_full.type){
  30. if(typeof(a_full.tier) !== 'undefined' && typeof(b_full.tier) !== 'undefined'){
  31. if(a_full.tier == b_full.tier){
  32. return a.sellsFor < b.sellsFor;
  33. }else{
  34. return a_full.tier < b_full.tier;
  35. }
  36. }else{
  37. return a.sellsFor < b.sellsFor;
  38. }
  39. }else{
  40. return a_full.type < b_full.type;
  41. }
  42. }else{
  43. return a_full.category < b_full.category;
  44. }
  45. });
  46. loadBank();
  47. }
  48. }
  49. }
  50.  
  51. // inject the script
  52. (function () {
  53. function injectScript(main) {
  54. const sortScriptElement = document.createElement('script');
  55. sortScriptElement.textContent = `try {(${main})();} catch (e) {console.log(e);}`;
  56. document.body.appendChild(sortScriptElement).parentNode.removeChild(sortScriptElement);
  57. }
  58.  
  59. function loadScript() {
  60. if (typeof(confirmedLoaded) !== 'undefined' && confirmedLoaded) {
  61. // Only load script after game has opened
  62. clearInterval(sortScriptLoader);
  63. injectScript(sortScript);
  64. }
  65. }
  66.  
  67. const sortScriptLoader = setInterval(loadScript, 200);
  68. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址