- Place div over Flash object with userscript
- var myDiv= document.createElement("div");
- myDiv.style.background = "red";
- myDiv.style.width = "30px";
- myDiv.style.height = "30px";
- myDiv.style.position = "absolute";
- myDiv.style.top = "0";
- myDiv.style.left = "0";
- document.body.appendChild(myDiv);
- // code which apparently does nothing:
- myDiv.style.zIndex = "999";
- var swf_div = document.getElementById("swf_div");
- if (swf_div) {
- swf_div.style.zIndex = "-999";
- }
- <body>
- ...
- <div id="client_div" style="width: 1680px; left: 0pt;">
- <object id="swf_div" width="100%" height="100%" type="application/x-shockwave-flash" data="http://c1.glitch.bz/swf/Boot_78793.swf" style="visibility: visible;">
- <param name="allowscriptaccess" value="always">
- <param name="allownetworking" value="all">
- <param name="wmode" value="direct">
- <param name="flashvars" value="--- auth tokens, omitted ---">
- </object>
- </div>
- ...
- </body>
- // code to create and style myDiv, see original question
- document.addEventListener("DOMNodeInserted", nodeInserted, false);
- function nodeInserted(e) {
- if (e.target.id == "swf_div") {
- var found = false;
- var params = e.target.getElementsByTagName("param");
- for (var i = 0; i < params.length; i++) {
- if (params[i].getAttribute("name") == "wmode") {
- var clone = params[i].cloneNode(true);
- clone.setAttribute("value", "opaque");
- params[i].parentNode.replaceChild(clone, params[i]);
- found = true;
- break;
- }
- }
- // in case swf_div doesn't already have a wmode param
- if (!found) {
- var clone = e.target.cloneNode(true);
- var param = document.createElement("param");
- param.setAttribute("name", "wmode");
- param.setAttribute("value", "opaque");
- clone.appendChild(param);
- e.target.parentNode.replaceChild(clone, e.target);
- }
- continueScript();
- }
- }
- function continueScript() {
- document.body.appendChild(myDiv);
- // do wonderful things
- }