This file contains hidden or 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
var callback = function(mutationsList, observer) { | |
for(let mutation of mutationsList) { | |
if (mutation.type === 'childList') { | |
mutation.addedNodes.forEach((node) => { | |
if(node instanceof Element && node.hasAttribute('href')) { | |
var href = node.getAttribute('href'); | |
if(href.match(/https\:\/\/www\.youtube\.com\/redirect\?.+/gm)) { | |
const urlParams = new URLSearchParams(href); | |
node.setAttribute('href', urlParams.get('q')); | |
} |