Change player.twitch.tv Title

Changes tabs title on load with channels username on player.twitch.tv pages.

目前为 2023-08-10 提交的版本。查看 最新版本

// ==UserScript==
// @name            Change player.twitch.tv Title
// @description     Changes tabs title on load with channels username on player.twitch.tv pages.
// @version         1.1
// @author          yungsamd17
// @namespace       https://github.com/yungsamd17/Twitch-Addons
// @license         MIT License
// @icon            https://raw.githubusercontent.com/yungsamd17/Twitch-Addons/main/chrome/src/icons/favicon.ico
// @match           https://player.twitch.tv/*
// @grant           none
// @run-at          document-end
// ==/UserScript==

(function() {
    'use strict';

    // Change tab's title temp.
    // Check if the current URL matches
    if (window.location.href.startsWith("https://player.twitch.tv/?channel=")) {
        // Extract the username from URL
        const urlParams = new URLSearchParams(window.location.search);
        const username = urlParams.get("channel");
        // Update title
        document.title = `${username} - Twitch Player`;
    }

    window.onload = function() {
        // Second update title to get full case-censite channel username
        // Find the element and update the title
        function findElementAndUpdateTitle() {
            // Find the element with the specified attribute
            const element = document.querySelector('[data-test-selector="stream-info-card-component__title-link"]');

            if (element) {
                // Extract the username from element's text
                const username = element.textContent.trim();
                // Update title
                document.title = `${username} - Twitch Player`;
            }
        }

        // Call the function to execute your code
        findElementAndUpdateTitle();
}})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址