AO3: [Wrangling] Find the Tag in the Blurb

emphasise the tag in big at the top of a page in work blurbs

当前为 2021-06-24 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AO3: [Wrangling] Find the Tag in the Blurb
// @namespace    https://github.com/RhineCloud
// @version      0.2
// @author       Rhine
// @description  emphasise the tag in big at the top of a page in work blurbs
// @include      *://*archiveofourown.org/tags/*
// @include      *://*archiveofourown.org/works?*tag_id=*
// @include      *://*archiveofourown.org/bookmarks?*tag_id=*
// @exclude      *://*archiveofourown.org/tags/*/wrangle*
// @exclude      *://*archiveofourown.org/tags/*/edit
// @exclude      *://*archiveofourown.org/tags/*/comments*
// @exclude      *://*archiveofourown.org/tags/*/troubleshooting*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js
// @grant        none
// @license      GPL-3.0 <https://www.gnu.org/licenses/gpl.html>
// ==/UserScript==

(function($) {
    var page_path = window.location.pathname;
    var page_type = "";
    var tag_name = "";

    // determine if works/bookmarks/tags landing page
    if (page_path.includes("/works")) {
        page_type = "works";
    } else if (page_path.includes("/bookmarks")) {
        page_type = "bookmarks";
    } else {
        page_type = "tags";
    }

    // get the tag name in the heading
    if (page_type == "works" || page_type == "bookmarks") {
        tag_name = $("h2.heading a").text();
    } else if (page_type == "tags") {
        tag_name = $("h2.heading").text();
    }

    // find the matching tag in each blurb and make it pop in colour
    $("li.blurb a.tag").each(function(index, element) {
        if ($(this).text() == tag_name) {
            $(this).css({
                "color": "#fff",
                "background-color": "#900"
            });
        }
    });
})(jQuery);