Pixiv Top Rankings enhancer

Adds a filter for Pixiv top rankings

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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