Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tballas/3f0574ae722a5aacf1b91c739d16d27a to your computer and use it in GitHub Desktop.
Save tballas/3f0574ae722a5aacf1b91c739d16d27a to your computer and use it in GitHub Desktop.
// ==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