filter_patches

Parses patch JSON and displays only owned titles

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         filter_patches
// @namespace    https://greasyfork.org/users/577497
// @version      1.1
// @description  Parses patch JSON and displays only owned titles
// @author       Glenugie
// @match        http://tinfoil.media/repo/db/versions.json
// @grant        none
// ==/UserScript==

// Set the titles you're interested in tracking here
var titles = {
    "01006F8002326000": "Animal Crossing: New Horizons",
    "0100000000010000": "Super Mario Odyssey",
    "01007EF00011E000": "Legend of Zelda: Breath of the Wild"
};



// Below function adapted from w3schools: https://www.w3schools.com/howto/howto_js_sort_table.asp
function sortTable(n) {
    var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
    table = document.getElementById("patchTable");
    switching = true;
    dir = "asc";
    while (switching) {
        switching = false;
        rows = table.rows;
        for (i = 1; i < (rows.length - 1); i++) {
            shouldSwitch = false;
            x = rows[i].getElementsByTagName("TD")[n];
            var xComp = x.innerHTML.toLowerCase(); if (xComp == "unknown (v0)") { xComp = "0";}
            y = rows[i + 1].getElementsByTagName("TD")[n];
            var yComp = y.innerHTML.toLowerCase(); if (yComp == "unknown (v0)") { yComp = "0";}
            if (dir == "asc") {
                if (xComp > yComp) {
                    shouldSwitch = true;
                    break;
                }
            } else if (dir == "desc") {
                if (xComp < yComp) {
                    shouldSwitch = true;
                    break;
                }
            }
        }
        if (shouldSwitch) {
            rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
            switching = true;
            switchcount ++;
        } else {
            if (switchcount == 0 && dir == "asc") {
                dir = "desc";
                switching = true;
            }
        }
    }
}

(function() {

    var bodyElement = document.getElementsByTagName("body")[0];
    var jsonElement = document.getElementsByTagName("pre")[0];
    var jsonTextContent = jsonElement.innerHTML;
    var jsonContent = JSON.parse(jsonTextContent);
    var newContent = "";

    for (var t in titles) {
        var tmp = jsonContent[t.toLowerCase()];
        var title = titles[t];

        var latestP = ""
        var latestId = 0
        var pCount = 0;
        for (var p in tmp) {
            if (p > latestId) {
                latestId = p
                latestP = tmp[p]
            }
            pCount += 1;
        }
        if (latestP == "") { latestP = "Unknown";}

        newContent += "<tr><td>"+title+"</td><td>"+latestP+" (v"+pCount+")</td></tr>";
    }

    bodyElement.innerHTML = "<div align=center><table id=patchTable cellpadding=10 border=1><tr><th>Title</th><th>Last Patch</th></tr>"+newContent+"</table></div><hr>"+bodyElement.innerHTML;
    sortTable(1);
    sortTable(1);
})();