Created
September 17, 2022 05:50
-
-
Save tballas/3f0574ae722a5aacf1b91c739d16d27a to your computer and use it in GitHub Desktop.
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 Video CrossOrigin set to anonymous to fix CORS error with video screenshot type Javascript, mainly for Twitch, may be useful for other sites | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description try to take over the world! | |
// @author @tim1986 | |
// @match *://*.twitch.tv/* | |
// @exclude http://clips.twitch.tv/* | |
// @exclude https://clips.twitch.tv/* | |
// @exclude https://www.twitch.tv/*/clip/* | |
// @run-at document-start | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let bodyElem = document.querySelector('body'); | |
let observer = new MutationObserver(mutations => { | |
for(let mutation of mutations) { | |
for(let node of mutation.addedNodes) { | |
// For only video elements, skip other nodes | |
if (node instanceof HTMLVideoElement) { | |
node.crossOrigin = "anonymous"; | |
console.log('[Video CrossOrigin set to anonymous] Done.', node); | |
} | |
} | |
} | |
}); | |
observer.observe(bodyElem, {childList: true, subtree: true}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment