ao3 hide some tags

Auto hide some tags you don't like to see

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        ao3 hide some tags
// @description Auto hide some tags you don't like to see
// @namespace   ao3
// @include     http*://archiveofourown.org/*
// @grant       none
// @version     1.1
// ==/UserScript==


(function($) {


/**** CONFIG ********************/

    var tagsToHide = ["camel spiders", "*worms", "ticks"]; // use * for wildcard
    var buttonLabel = "~";

/********************************/




    $('.blurb ul.tags, .meta .tags ul').each(function() {
        var $list = $(this);
        $list.find('a.tag').each(function() {        
            var $tag = $(this);
            var text = $tag.text();
            
            for (var i = 0, len = tagsToHide.length; i < len; i++) {
                if (termsMatch(text, tagsToHide[i])) {
                    hideTagsList($list);
                    return false;
                }
            }
        });
    });

    function hideTagsList($list) {
        $list.hide();
        $('<button>').addClass('hide-some-tags-userscript').text(buttonLabel).click(function() {
            $(this).next('ul').toggle();
        }).insertBefore($list);
    }
    
    function termsMatch(testTerm, listTerm) {
        testTerm = testTerm.toLowerCase();
        listTerm = listTerm.toLowerCase();
        if (testTerm == listTerm) { return true; }

        if (listTerm.indexOf('*') == -1) return false;
        
        var parts = listTerm.split('*'),
            prevPartIndex = 0,
            firstPart,
            lastPart;

        for (var i = 0, part, len = parts.length; i < len; i++) {
            part = parts[i];
            partIndex = testTerm.indexOf(part);
            if (part && partIndex < prevPartIndex) {
                return false;
            }
            prevPartIndex = partIndex + part.length;
        }
        
        firstPart = parts[0];
        lastPart = parts[parts.length-1];

        return !(
            firstPart && testTerm.indexOf(firstPart) != 0 ||
            lastPart && testTerm.indexOf(lastPart)+lastPart.length != testTerm.length
        );
    }

})(window.jQuery);