FA Rating Filter

On furaffinity.net, hides thumbnails according to desired rating(s) and/or art medium.

As of 03.05.2017. See ბოლო ვერსია.

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         FA Rating Filter
// @namespace    FurAffinity
// @version      1.01
// @description  On furaffinity.net, hides thumbnails according to desired rating(s) and/or art medium.
// @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");

        const $ = jQuery;

        const artRatings = {
            general: { key: 'general', classId: 'r-general', on: true},
            mature: { key: 'mature', classId: 'r-mature', on: true},
            adult: { key: 'adult', classId: 'r-adult', on: true}
        };

        const artTypes = {
            img: { key: 'image', classId: 't-image', on: true},
            txt: { key: 'text', classId: 't-text', on: true},
            audio: { key: 'audio', classId: 't-audio', on: true}
        };

        const updateFilteredView = function() {
            for(let rating in artRatings) {
                for(let type in artTypes) {
                    let selector = 'figure.' + artRatings[rating].classId + '.' + artTypes[type].classId;
                    let figure = $(selector);
                    figure.each(function(){
                            $(this).toggle(artRatings[rating].on && artTypes[type].on);
                       }
                    );
                }
            }
        };

        const 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>
<input type="checkbox" id="imageControl" checked /> <strong>Images</strong>
<input type="checkbox" id="textControl" checked /> <strong>Writing</strong>
<input type="checkbox" id="audioControl" checked /> <strong>Music</strong>
            `);
        }

        const checkboxChanged = function(key) {
            let isOn = $('#' + key + 'Control').prop('checked');
            for(let rating in artRatings) {
                if(artRatings[rating].key === key) {
                    artRatings[rating].on = isOn;
                }
            }
            for(let type in artTypes) {
                if(artTypes[type].key === key) {
                    artTypes[type].on = isOn;
                }
            }
            updateFilteredView();
        };

        for(let rating in artRatings) {
            $('#' + artRatings[rating].key + 'Control').click(function() { checkboxChanged(artRatings[rating].key); } );
        }
        for(let type in artTypes) {
            $('#' + artTypes[type].key + 'Control').click(function() { checkboxChanged(artTypes[type].key); } );
        }

        updateFilteredView();
    }
)();