Skip to content

Instantly share code, notes, and snippets.

@Vanawy
Created May 31, 2022 08:27
Show Gist options
  • Save Vanawy/193879c52cd396644779871e57625e67 to your computer and use it in GitHub Desktop.
Save Vanawy/193879c52cd396644779871e57625e67 to your computer and use it in GitHub Desktop.
Youtube title changer (match video chapter) | Custom script
// ==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