NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name YouTube-Related-Video-Suggestions-Only // @icon https://www.google.com/s2/favicons?domain=youtube.com // @namespace https://wis.am/ // @version 0.1 // @description remove distracting video suggestion on YouTube! // @author Wis Sa // @licence MIT // @match http*://*.youtube.com/* // @grant none // ==/UserScript== (function () { 'use strict'; window.addEventListener('load', function () { function eventFire(el, etype) { if (el.fireEvent) { el.fireEvent('on' + etype); } else { var evObj = document.createEvent('Events'); evObj.initEvent(etype, true, false); el.dispatchEvent(evObj); } } let intervalID = window.setInterval(findAndClick, 600); function findAndClick() { var relatedEl = [...document.getElementsByClassName('yt-chip-cloud-chip-renderer')] .find(e => e.textContent === 'Related'); if (relatedEl) { eventFire(relatedEl, 'click'); window.clearInterval(intervalID); } } // select the target node var target = document.querySelector('title'); // create an observer instance var observer = new MutationObserver(function (mutations) { // We need only first event and only new value of the title console.log(mutations[0].target.nodeValue); window.clearInterval(intervalID); intervalID = window.setInterval(findAndClick, 600); }); // configuration of the observer: var config = { attributes: true, childList: true, subtree: true }; // pass in the target node, as well as the observer options observer.observe(target, config); }, false); })();