🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Google Timer Title Update

Automatically updates the title when using Google's timer

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name           Google Timer Title Update
// @namespace      org.alorel.googletimer
// @author         Alorel <[email protected]>
// @description    Automatically updates the title when using Google's timer
// @include        https://*google.*/search?*
// @version        1.0.3
// @icon           https://cdn.rawgit.com/AlorelUserscripts/google-timer-title-switcher/master/icon.png
// @run-at         document-end
// @grant          GM_info
// ==/UserScript==

//launch
(function () {
    var container;

    if (container = document.querySelector("#act-timer-section>div")) {
        var timerArea = container.querySelector("div");

        try {
            document.querySelector('link[rel="shortcut icon"]').setAttribute("href", GM_info.script.icon);
        } catch (e) {
        }

        [".srg", "#searchform", "#extrares", "#top_nav", "#navcnt", "#appbar"].forEach(function (selector) {
            setTimeout(function () {
                try {
                    var el = document.querySelector(selector);
                    el.parentNode.removeChild(el);
                } catch (e) {
                    console.error(e);
                }
            }, 0);
        });

        (new MutationObserver(function () {
            if (container.classList.contains("act-tim-paused")) {
                document.title = "PAUSED";
            } else if (container.classList.contains("act-tim-finished")) {
                document.title = "FINISHED";
            } else {
                document.title = timerArea.innerText.trim();
            }
        })).observe(timerArea, {
            childList: true,
            attributes: true,
            characterData: true,
            subtree: true
        });
    }
})();