-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathKillWindowlessFlash.user.js
More file actions
66 lines (61 loc) · 2.3 KB
/
KillWindowlessFlash.user.js
File metadata and controls
66 lines (61 loc) · 2.3 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ==UserScript==
// @name Kill Windowless Flash
// @namespace http://www.jantrid.net/axSGrease/
// @description Makes windowless (transparent or opaque) Adobe Flash objects windowed so they have a chance of being accessible.
// @description:es Incluye en una ventana los objetos Adobe Flash (transparentes u opacos) que no tienen ventana, de modo que eventualmente puedan ser accesibles.
// @author James Teh <jamie@jantrid.net>
// @copyright 2011-2012 James Teh
// @license GNU General Public License version 2.0
// @version 0.20120724.01
// @include *
// ==/UserScript==
function reloadFlash(elm) {
// We need to remove the node from the document and add it again to reload Flash.
// In some cases, it's not sufficient to simply replace with the same node,
// as this seems to get optimised and does nothing.
// Therefore, use a clone of the node.
elm.parentNode.replaceChild(elm.cloneNode(), elm);
}
function killWindowlessFlash(target) {
// First, deal with embed elements.
var elms = target.getElementsByTagName("embed");
for (var i = 0; i < elms.length; ++i) {
var elm = elms[i];
if (elm.getAttribute("type") != "application/x-shockwave-flash")
continue;
if (elm.getAttribute("wmode") == "window")
continue;
elm.setAttribute("wmode", "window");
// Parameters are only read when Flash is loaded.
reloadFlash(elm);
}
// Now, deal with object elements.
var elms = target.getElementsByTagName("object");
for (var i = 0; i < elms.length; ++i) {
var elm = elms[i];
if (elm.getAttribute("type") != "application/x-shockwave-flash")
continue;
var params = elm.getElementsByTagName("param");
for (var j = 0; j < params.length; ++j) {
var param = params[j];
if (param.getAttribute("name") != "wmode")
continue;
if (param.getAttribute("value") == "window")
continue;
param.setAttribute("value", "window");
// Parameters are only read when Flash is loaded.
reloadFlash(elm);
break;
}
}
}
function onLoad(evt) {
killWindowlessFlash(document);
}
window.addEventListener("load", onLoad);
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
killWindowlessFlash(mutation.target);
});
});
observer.observe(document, {childList: true, subtree: true});