Skip to content

Instantly share code, notes, and snippets.

@livingflore
livingflore / fuckRedirects.js
Last active September 20, 2023 14:00
remove youtube redirects
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'));
}