Melvor Sort By Type

Overrides melvor's item sort algorithm to something more logical

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name		Melvor Sort By Type
// @namespace	http://tampermonkey.net/
// @version		0.01/SVN?1354
// @description Overrides melvor's item sort algorithm to something more logical
// @author		mootykins
// @match		https://*.melvoridle.com/*
// @exclude		https://wiki.melvoridle.com*
// @exclude		https://*.melvoridle.com/index.php
// @noframes
// @license unlicense
// @grant		none
// ==/UserScript==
// Loading code by GMiclotte
function sortScript() {
    if (window.SortScript !== undefined) {
        console.error('SortBank is already loaded!');
    } else {
        loadSortScript();
    }

    function loadSortScript(){
      window.SortScript = {}
      sortBank = function() {
        bank.sort((a,b) => {
          let a_full = items[a.id];
          let b_full = items[b.id];
          if(a_full.category == b_full.category){
            if(a_full.type == b_full.type){
              if(typeof(a_full.tier) !== 'undefined' && typeof(b_full.tier) !== 'undefined'){
                if(a_full.tier == b_full.tier){
                  return a.sellsFor < b.sellsFor;                  
                }else{
                  return a_full.tier < b_full.tier;
                }
              }else{
                return a.sellsFor < b.sellsFor;
              }
            }else{
              return a_full.type < b_full.type;
            }
          }else{
            return a_full.category < b_full.category;
          }
        });
        loadBank();
      }
    }
}

// inject the script
(function () {
    function injectScript(main) {
        const sortScriptElement = document.createElement('script');
        sortScriptElement.textContent = `try {(${main})();} catch (e) {console.log(e);}`;
        document.body.appendChild(sortScriptElement).parentNode.removeChild(sortScriptElement);
    }

    function loadScript() {
        if (typeof(confirmedLoaded) !== 'undefined' && confirmedLoaded) {
            // Only load script after game has opened
            clearInterval(sortScriptLoader);
            injectScript(sortScript);
        }
    }

    const sortScriptLoader = setInterval(loadScript, 200);
})();