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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 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] 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);