Pixiv Top Rankings enhancer

Adds a filter for Pixiv top rankings

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Pixiv Top Rankings enhancer
// @namespace    https://greasyfork.org/en/users/3372-nixxquality
// @description  Adds a filter for Pixiv top rankings
// @version      1.1.0
// @author       nixx quality <[email protected]>
// @match        http://www.pixiv.net/ranking.php*
// ==/UserScript==

(function() {
    'use strict';

    var optionsList = document.getElementsByClassName("options")[0];
    var showOnlyList = document.createElement("select");

    var options = [["", "Show only..."], ["lo", "未成年"], ["furry", "ケモノ"], ["bl", "男性同性愛"], ["yuri", "女性同性愛"]];
    for (var i = 0; i < options.length; i++) {
        var option = document.createElement("option");
        option.value = options[i][0];
        option.text = options[i][1];
        showOnlyList.appendChild(option);
    }

    var oldupdate = pixiv.ranking.attrFilter.update;
    function updateShowOnly() {
        oldupdate.apply(pixiv.ranking.attrFilter);
        [].forEach.call(document.getElementsByClassName("ranking-item"), function (element) {
            if (!element.dataset.attr.includes(showOnlyList.value)) {
                element.className = "ranking-item _attr-filter-hidden";
            }
        });
    }

    pixiv.ranking.attrFilter.update = updateShowOnly;
    showOnlyList.addEventListener("change", updateShowOnly);

    optionsList.appendChild(showOnlyList);
})();