ao3 hide crossovers

hides works with too many fandom tags

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ao3 hide crossovers
// @namespace    https://greasyfork.org/en/users/36620
// @version      0.3.1
// @description  hides works with too many fandom tags
// @author       scriptfairy
// @include      http://archiveofourown.org/*works*
// @include      https://archiveofourown.org/*works*
// @grant        none
// ==/UserScript==

/* CONFIG */

var max = 2;
// this is the maximum number of fandoms a work can have before being hidden

/* END CONFIG */

(function($) {
    $('<style>').text(
        '.hide .hideleft {width:85%;float:left;} .hide .hideright {float:right;padding-top:5px;}'
    ).appendTo($('head'));
    var works = $('ol.index li.blurb');
    for (i=0;i<works.length;i++){
        var fandoms = $('.header .fandoms a', works[i]);
        if (fandoms.length > max) {
            var button = document.createElement('div');
            button.setAttribute('class','hide');
            button.innerHTML = '<div class="hideleft">This work is tagged' + $('.header .fandoms', works[i])[0].innerHTML + 'and may be a crossover, fusion, or multi-fandom collection.</div><div class="hideright"><button type="button" class="show">Click to Show</button></div>';
            works[i].appendChild(button);
            $(works[i]).children(':not(".hide")').css('display','none');
        }
    }

    $(document).ready(function(){
        $('.hide button').click(function() {
            var work = $(this).parents('li')[0];
            if ($(this).hasClass("show")) {
                $(work).children(':not(".hide")').show();
                $(work).find('.hideleft').css('visibility', 'hidden');
                $(this).text("Click to Hide");
                $(this).removeClass("show").addClass("shown");
            }
            else {
                $(work).children(':not(".hide")').hide();
                $(work).find('.hideleft').css('visibility', 'visible');
                $(this).text("Click to Show");
                $(this).removeClass("shown").addClass("show");
            }
        });
    });
})(window.jQuery);