F95zone > threads > HTML <title> rearrangement

F95zone threads pages - HTML <title> rearrangement - moving labels from the beginning of the title to after the developer name.

目前為 2025-03-28 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        F95zone > threads > HTML <title> rearrangement
// @namespace   Violentmonkey Scripts
// @match       *://f95zone.to/threads/*
// @grant       none
// @version     0.1.12
// #timestamp   2025-03-28 18:39:11
// @author      BtDt
// @license     MIT
// @description F95zone threads pages - HTML <title> rearrangement - moving labels from the beginning of the title to after the developer name.
// ==/UserScript==

(function() {
    'use strict'; 

    function XPathEvalAndIter(
      xpath,
      ctxNode,
      callback = (subnode) => {})
    {
        const result = document.evaluate(
          xpath,
          ctxNode,
          null,
          XPathResult.ORDERED_NODE_ITERATOR_TYPE,
          null);
        let node = result.iterateNext();
        while (node) {
            callback(node);
            node = result.iterateNext();
        }
    }
    
    let title = '';
    let labels = '';
    
    function ProcessTitle(subnode) {
        XPathEvalAndIter(
           "text()",
           subnode,
           (subnode) => { title += subnode.textContent; });
        XPathEvalAndIter(
           "a[@class='labelLink']/span",
           subnode,
           (subnode) => { labels += ` #${subnode.textContent}`; });
    }
    
    XPathEvalAndIter(
      "//h1[@class='p-title-value']",
      document,
      ProcessTitle);
    document.title = `${title} ${labels} | F95zone`;

})();