Created
May 31, 2022 08:27
-
-
Save Vanawy/193879c52cd396644779871e57625e67 to your computer and use it in GitHub Desktop.
Youtube title changer (match video chapter) | Custom script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Title Changer | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.youtube.com/watch* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setInterval(main, 1000); | |
})(); | |
function main() | |
{ | |
let els = document.querySelector('.ytp-chapter-title-content'); | |
if (!els) return; | |
let title = els.textContent; | |
if (!title) return | |
if (window.document.title === title) return; | |
window.document.title = title; | |
if ('mediaSession' in navigator) { | |
navigator.mediaSession.metadata = new MediaMetadata({ | |
title: title, | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment