FA Rating Filter

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

2017-05-03 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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