FA Rating Filter

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

Από την 03/05/2017. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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