WME Install Popularity

Displays the place in the top 100 installed WME scripts

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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             WME Install Popularity
// @namespace        https://greatest.deepsurf.us/users/30701-justins83-waze
// @version          0.3
// @description      Displays the place in the top 100 installed WME scripts
// @author           JustinS83
// @include          https://greatest.deepsurf.us/en/users/*
// @grant            none
// @contributionURL  https://github.com/WazeDev/Thank-The-Authors
// @run-at           document-end
// ==/UserScript==

/* ecmaVersion 2017 */
/* global $ */
/* eslint curly: ["warn", "multi-or-nest"] */

(function() {
    'use strict';

    function loadScript(url, callback) {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.onload = function () {
            if(callback != null)
                callback();
        };

        script.src = url;
        document.getElementsByTagName("head")[0].appendChild(script);
    }

    function init(){
        var WMESearchPageDiv = document.createElement('div');
        WMESearchPageDiv.id="results";
        WMESearchPageDiv.style.cssText = "display:none;";
        document.body.appendChild(WMESearchPageDiv);
        $('#results').load('https://greatest.deepsurf.us/en/scripts?q=WME&sort=total_installs .script-list', get2ndPage);
    }

    function get2ndPage(){
        var WMESearchPageDiv2 = document.createElement('div');
        WMESearchPageDiv2.id="results2";
        WMESearchPageDiv2.style.cssText = "display:none;";
        document.body.appendChild(WMESearchPageDiv2);
        $('#results2').load('https://greatest.deepsurf.us/en/scripts?page=2&q=WME&sort=total_installs .script-list li', parseResults);
    }

    function parseResults(){
        $('#results2 li').each(function(){
            $(this).appendTo('#results ol');
        });
        $('#results2').remove();

        $('#user-script-list li').each(function(){
            let placeModifier = 0;
            let name = $(this).attr('data-script-name');
            let author = $(this).attr('data-script-author-name');

            if(name.indexOf("WME") > -1){
                let results = $('#results .script-list li');
                for(let i=0;i< results.length; i++){
                    if($($('#results .script-list li')[i]).attr('data-script-name') !== undefined){
                        if($($('#results .script-list li')[i]).attr('data-script-name').indexOf(name) > -1 && $($('#results .script-list li')[i]).attr('data-script-author-name') === author){
                            $(this).find('dd.script-list-total-installs').after(`<dt>WME Most Installed Place</dt><dd>${i+1-placeModifier}</dd>`);
                            break;
                        }
                    }
                    else{
                        placeModifier += 1;
                    }
                }
            }
        });
    }

    loadScript("https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", init);
})();