-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallow_fullscreen_on_every_embed_youtube.user.js
39 lines (34 loc) · 1.23 KB
/
allow_fullscreen_on_every_embed_youtube.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// ==UserScript==
// @name youtube: allow fullscreen on every embed
// @namespace github.com/totalamd
// @match *://*/*
// @version 1.0.0.2
// @downloadURL https://github.com/totalamd/GM-scripts/raw/master/allow_fullscreen_on_every_embed_youtube.user.js
// @updateURL https://github.com/totalamd/GM-scripts/raw/master/allow_fullscreen_on_every_embed_youtube.user.js
// @noframes
// ==/UserScript==
"use strict";
const l = function(){}, i = function(){};
(function () {
// const l = console.log.bind(console, `${GM_info.script.name} debug:`), i = console.info.bind(console, `${GM_info.script.name} debug:`);
Array.from(document.querySelectorAll('iframe')).forEach((iframe) => {
if (iframe.src.match(/^https?:\/\/(?:www\.)?youtube\.com\/embed\//)) {
iframe.allowFullscreen = true;
}
});
const target = document.body;
const config = {
childList: true,
subtree: true
};
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
Array.from(mutation.addedNodes).forEach((node) => {
if (node.tagName === "IFRAME" && node.src.match(/^https?:\/\/(?:www\.)?youtube\.com\/embed\//)) {
node.allowFullscreen = true;
}
});
});
});
observer.observe(target, config);
})();