YouTube Title Formatter Artist - Title

Change the window title on YouTube based on the channel name and video title

当前为 2025-02-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         YouTube Title Formatter Artist - Title
// @description  Change the window title on YouTube based on the channel name and video title
// @version      0.1
// @namespace	 itsafeature.org
// @license      unlicense
// @author       Geoffrey De Belie (Smile4ever)
// @match        https://www.youtube.com/watch?v=*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to update the title
    function updateTitle() {
        // Get the channel name from the anchor element
        const channelElement = document.querySelector('a.yt-simple-endpoint.style-scope.yt-formatted-string');
        // Get the video title
        const videoTitleElement = document.querySelector('#above-the-fold #title');

        if (channelElement && videoTitleElement) {
            const channelName = channelElement.innerText.split(' - ')[0];
            const videoTitle = videoTitleElement.innerText;
            // Set the window title to "Channel Name - Video Title - YouTube"
            document.title = `${channelName} - ${videoTitle} - YouTube`;
        }
    }

    // Wait for the page content to load before running the updateTitle function
    window.addEventListener('load', updateTitle);

    // Optionally, observe changes in the page if the title might update after load
    const observer = new MutationObserver(updateTitle);
    observer.observe(document.body, { childList: true, subtree: true });
})();

QingJ © 2025

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