Greasy Fork

Greasy Fork is available in English.

ao3 hide crossovers

hides works with too many fandom tags

当前为 2016-04-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

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

(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(){
        $('.show').click(function() {
            var work = $(this).parents('li')[0];
            $('[style$="display: none;"]', work).removeAttr('style');
            $(this).parents('.hide').remove();
        });
    });
})(window.jQuery);