WME Install Popularity

Displays the place in the top 100 installed WME scripts

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);
})();