AO3: [Wrangling] Rainbow Home Page

adds CSS classes .rainbow0 through .rainbow5, updates dynamically when filters are applied

目前為 2022-05-31 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         AO3: [Wrangling] Rainbow Home Page
// @namespace    https://greasyfork.org/en/users/906106-escctrl
// @description  adds CSS classes .rainbow0 through .rainbow5, updates dynamically when filters are applied
// @author       escctrl
// @version      1.0
// @match        *://*.archiveofourown.org/tag_wranglers/*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @license      MIT
// ==/UserScript==

(function($) {
    'use strict';

    function resetRainbow() {
        $('.assigned tbody tr').removeClass('rainbow0 rainbow1 rainbow2 rainbow3 rainbow4 rainbow5');
        $('.assigned tbody tr:visible').each( function(it, row) {
            $(row).addClass('rainbow'+it%6);
        });
    }

    // wait for document to finish loading (seems to be required - events only work properly after other scripts finished writing the filtering links)
    $(document).ready(function(){
        // executes on page load for initial coloring
        resetRainbow();

        // add events for dynamic updates of the CSS classes when filters are applied
        // Redux
        $('#filter-fandoms a').on("click", resetRainbow);
        // N-in-1
        $('#media-filter a').on("click", resetRainbow);
        $('#fandom-filter a').on("click", resetRainbow);
        $('#setup-filter a').on("click", resetRainbow);
        // Standard (doesn't specify a p#id so we have to assume it's the second p)
        $('.assigned p:nth-of-type(2)').not('#filter-fandoms, #media-filter, #fandom-filter, #setup-filter, #fandom_search').children('a').on("click", resetRainbow);

        // Search
        $('#fandom_search').on('keyup', resetRainbow);

    });

})(jQuery);