隐藏标题/安全标题/Title SFW

避免上班摸鱼的时候网页标题过于“炸裂”导致社死

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         隐藏标题/安全标题/Title SFW
// @namespace    http://tampermonkey.net/
// @version      2.0.0
// @description  避免上班摸鱼的时候网页标题过于“炸裂”导致社死
// @author       You
// @match        *://*/*
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';
    // 定义自定义标题列表
    const titles = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"];
    // 随机从列表中选择四个标题
    const customTitles = [];
    for (let i = 0; i < 6; i++) {
        customTitles.push(titles[Math.floor(Math.random() * titles.length)]);
    }

    // 将四个随机标题组合成一个字符串
    const customTitle = customTitles.join('、');


    // 随机从列表中选择一个标题
    // const customTitle = titles[Math.floor(Math.random() * titles.length)];
    document.title = customTitle + "|" + document.title;

    // Optional: Prevent future changes to the title
    const observer = new MutationObserver(() => {
        // if (document.title !== customTitle) {
        //     document.title = customTitle;
        // }
        document.title = customTitle + document.title
    });

    observer.observe(document.querySelector('title'), { childList: true });
})();