Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 2.14 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Place div over Flash object with userscript
  2. var myDiv= document.createElement("div");
  3. myDiv.style.background = "red";
  4. myDiv.style.width = "30px";
  5. myDiv.style.height = "30px";
  6. myDiv.style.position = "absolute";
  7. myDiv.style.top = "0";
  8. myDiv.style.left = "0";
  9. document.body.appendChild(myDiv);
  10.        
  11. // code which apparently does nothing:
  12. myDiv.style.zIndex = "999";
  13. var swf_div = document.getElementById("swf_div");
  14. if (swf_div) {
  15.     swf_div.style.zIndex = "-999";
  16. }
  17.        
  18. <body>
  19.     ...
  20.     <div id="client_div" style="width: 1680px; left: 0pt;">
  21.         <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;">
  22.             <param name="allowscriptaccess" value="always">
  23.             <param name="allownetworking" value="all">
  24.             <param name="wmode" value="direct">
  25.             <param name="flashvars" value="--- auth tokens, omitted ---">
  26.         </object>
  27.     </div>
  28.     ...
  29. </body>
  30.        
  31. // code to create and style myDiv, see original question
  32.  
  33. document.addEventListener("DOMNodeInserted", nodeInserted, false);
  34.  
  35. function nodeInserted(e) {
  36.     if (e.target.id == "swf_div") {
  37.  
  38.         var found = false;
  39.  
  40.         var params = e.target.getElementsByTagName("param");
  41.         for (var i = 0; i < params.length; i++) {
  42.             if (params[i].getAttribute("name") == "wmode") {
  43.                 var clone = params[i].cloneNode(true);
  44.                 clone.setAttribute("value", "opaque");
  45.                 params[i].parentNode.replaceChild(clone, params[i]);
  46.                 found = true;
  47.                 break;
  48.             }
  49.         }
  50.  
  51.         // in case swf_div doesn't already have a wmode param
  52.         if (!found) {
  53.             var clone = e.target.cloneNode(true);
  54.             var param = document.createElement("param");
  55.             param.setAttribute("name", "wmode");
  56.             param.setAttribute("value", "opaque");
  57.             clone.appendChild(param);        
  58.             e.target.parentNode.replaceChild(clone, e.target);
  59.         }
  60.  
  61.         continueScript();
  62.     }
  63. }
  64.  
  65. function continueScript() {
  66.     document.body.appendChild(myDiv);
  67.  
  68.     // do wonderful things
  69. }