FA Rating Filter

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

2017-05-03 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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