Greasy Fork is available in English.

YouTube show channel name in title

Insert YouTube channel name in title

// ==UserScript==
// @name         YouTube show channel name in title
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Insert YouTube channel name in title
// @icon         https://www.youtube.com/favicon.ico
// @author       Fifv
// @match        https://www.youtube.com/*
// @license      GNU GPLv3
// @grant        none
// ==/UserScript==

(function () {
    'use strict'

    setInterval(function () {
        if (location.pathname === '/watch') {
            const channelName = document.querySelector('#channel-name #text').textContent
            const stringInsertToTitle = ' - ' + channelName
            if (channelName && !document.title.includes(stringInsertToTitle)) {
                document.title = document.title.replace(' - YouTube', stringInsertToTitle + ' - YouTube')
                console.log('[Youtube show channel name in title] insert channel name to title:', stringInsertToTitle)
            }
        }
    }, 5000)



})()