FA Rating Filter

On furaffinity.net, hides thumbnails according to desired rating(s).

Version vom 03.05.2017. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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         FA Rating Filter
// @namespace    FurAffinity
// @version      1.0
// @description  On furaffinity.net, hides thumbnails according to desired rating(s).
// @author       Toboe
// @grant        none
// @run-at       document-end
// @match        *://*.furaffinity.net/*
// @require      https://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function() {
        'use strict';

        console.log("FA Rating Filter");

        var $ = jQuery;

        var itemIdPrefix = 'figure.r-';
        var generalControl = '#generalControl';
        var generalKey = 'faFilterGeneral';
        var matureControl = '#matureControl';
        var matureKey = 'faFilterMature';
        var adultControl = '#adultControl';
        var adultKey = 'faFilterAdult';

        var isGeneralOn = true;
        var isMatureOn = true;
        var isAdultOn = true;

        var toggleViewFromFilter = function(isOn, item) {
            item.toggle(isOn);
        };

        var updateFilteredView = function() {
            $(itemIdPrefix + 'general').each(function(){
                    toggleViewFromFilter(isGeneralOn, $(this));
               }
            );
            $(itemIdPrefix + 'mature').each(function(){
                    toggleViewFromFilter(isMatureOn, $(this));
                }
            );
            $(itemIdPrefix + 'adult').each(function(){
                    toggleViewFromFilter(isAdultOn, $(this));
                }
            );
        };

        var attachPoint = $("body");
        if (attachPoint.length) {
            attachPoint.prepend(`
<input type="checkbox" id="generalControl" checked /> <strong>General</strong>
<input type="checkbox" id="matureControl" checked /> <strong>Mature</strong>
<input type="checkbox" id="adultControl" checked /> <strong>Adult</strong>
            `);
        }

        var checkboxChanged = function(control, key) {
            var isOn = $(control).prop('checked');
            if(key === generalKey) {
                isGeneralOn = isOn;
            }
            else if(key === matureKey) {
                isMatureOn = isOn;
            }
            else if(key === adultKey) {
                isAdultOn = isOn;
            }
            updateFilteredView();
        };

        $(generalControl).click(function() { checkboxChanged(generalControl, generalKey); });
        $(matureControl).click(function() { checkboxChanged(matureControl, matureKey); });
        $(adultControl).click(function() { checkboxChanged(adultControl, adultKey); });

        updateFilteredView();
    }
)();