Popup Video

Popup online video out of the webpage

  1. // ==UserScript==
  2. // @name Popup Video
  3. // @homepageURL https://github.com/archion/videopop
  4. // @namespace https://github.com/archion/
  5. // @version 0.1.13
  6. // @description Popup online video out of the webpage
  7. // @match http://*/*
  8. // @match https://*/*
  9. // @copyright 2014+, archion
  10. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAQAAAC0NkA6AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAJcEhZcwABEJAAARCQAYms0rgAAAL2SURBVFjD1dg/aBNRHMDxby6nxmiLaKVSW6GCcRC1eoM6FOvgn8GAdKmKSBGp2EkHhy4SFAd1kDoJUpUsooOIdVBa8A8OCgkWq1hOpLXVakopWttiNSQOuV7u0svdexcz+Fvy3vFePvd+l3t/EkAoNFhNnO2EUMR6kCXDLN95yjlVsAukqSAs3BoCBAkT5jDZoFiPGpjmA00sk2DmokocgSEGaPTBBAWRrznmI+99MIogUhITEEZKYGQQ/0wg96FJjR/YQxe1oo1VG1FNhDqWzNEFt/OKPrOWYlr8jlSTiNBKlHrCjgT00mOWN3OD9RLp0gAUWogRcWnXQxtDFmKrTG5z00obF6ksFwEKsJcL5SRAoYoOlpeTAJUD7LDU++lmmIz58NP0MlwaASrNLDRrj2hnsEjLBrr8EaCyxSyPE8sRSUsDrWQi90zmQuddOQhQyK+NU/yxE0ZsKo3AfcXWAKq4UhqBwLagmV1S3zjGN1kkyO4ic5lzfOE4rXySQ0KskiBGaaebx5ywM15IWmJKH+UkDwAKGS9kloQ0MY/xfvB3zWlFnLAzGW/kDWeZlCOSeWYImHVFjMZxzrgyVqKadTbmGH289RhJEiDLdRfGSqykkybbDT4hyhHPdHkwduIqLfm3ymA+owvs6pNoOQYuF6yghcRBx3SLnTbM0Zxi1HJZp82NyIfg+cQYzU36Oco2KpjgOXEGRAhhxGAgQYJKQswwZbm+z40QTJc9w0wylicAWOzeU/w4h+OCJhQSI/Ef/xGS9UKylrKP0Ap7OoAKv8xyNRWyxyGj9RoL4bDIqYyYR4YI+7nl49RVT9QszzDihDwzkUWcBx7yUwJYwAZibDTrg+hOyG2aWWHUarmGToqMMLKUiGUPCt2k5jcKaCqdtMtmqEjoRNHnv7QKaS7x8p8Qk8SckgXBGvhBggbxA3ORmKCDOFmnySdYA5Cil4WslfqryRq/ecFp7jgTEDB/siqNHGIndYQkNqZpxnnNPe4zDsWm0L9cDt3NATPl2QAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNC0wOC0yNVQwODo0Mjo0NyswODowMOtq9NIAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTQtMDgtMjVUMDg6NDI6NDcrMDg6MDCaN0xuAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAABJRU5ErkJggg==
  11. // ==/UserScript==
  12. if (window.top != window.self) { return; } //don't run on frames or iframes
  13. var ck=document.createElement("div");
  14. ck.setAttribute("style","position: fixed; bottom: 5px; right: 10px;z-index: 2147483646;background: #000; opacity: 0.5;color:#fff;font-size: 1em;cursor: pointer;text-align: center;color:#fff;padding: 4px");
  15. ck.innerHTML="Popup";
  16. document.body.appendChild(ck);
  17. ck.addEventListener('click', function() {
  18. //debugger;
  19. var ff=!window.chrome;
  20. if(ff){
  21. var flash=document.querySelectorAll("[type='application/x-shockwave-flash']");
  22. for (var i=0, len=flash.length; i<len ;i++){
  23. flash[i].setAttribute("wmode","opaque");
  24. flash[i].style.display="none";
  25. }
  26. setTimeout(function(){
  27. for (var i=0, len=flash.length; i<len ;i++){
  28. flash[i].style.display="";
  29. }
  30. },100*flash.length);
  31. }
  32. //var flash=document.querySelectorAll("iframe");
  33. //for (var i=0, len=flash.length; i<len ;i++){
  34. //flash[i].setAttribute("wmode","opaque");
  35. //}
  36. var ntf=document.createElement("div");
  37. ntf.id="topntf";
  38. var pw=document.documentElement.scrollWidth||document.body.scrollWidth;
  39. var ph=document.documentElement.scrollHeight||document.body.scrollHeight;
  40. var ptop=document.documentElement.scrollTop||document.body.scrollTop;
  41. ntf.setAttribute("style","position: absolute; top: 0px; left: 0px;z-index: 2147483647; background-color: #000; opacity: 0.8;font-size: 50pt;line-height: 50pt;text-align: center;color:#fff; "+"width: "+pw+"px; "+"height: "+ph+"px; "+"padding-top: "+ptop+"px;");
  42. ntf.innerHTML="please click the element to pop out<br> 请点击需要弹出的元素";
  43. document.body.appendChild(ntf);
  44. document.addEventListener('mousedown', function(e) {
  45. if (document.getElementById("topntf")){
  46. document.body.removeChild(document.getElementById("topntf"));
  47. //document.body.removeChild(ntf);
  48. //e = e || window.event;
  49. //var target = e.target || e.srcElement;
  50. //var target = e.target.cloneNode(true)
  51. //var target = document.elementFromPoint(e.clientX,e.clientY).parentNode.cloneNode(true);
  52. var target = document.elementFromPoint(e.clientX,e.clientY);
  53. var ch=window.getComputedStyle(target,null).getPropertyValue("height");
  54. var cw=window.getComputedStyle(target,null).getPropertyValue("width");
  55. var ptarget=target;
  56. var player = ptarget.cloneNode(true);
  57. var cst="width:100% !important;height:100% !important;max-width:100% !important;margin:0px !important;padding:0px !important;top:0px !important;left:0px !important;z-index: 2147483646 !important;overflow:hidden !important;position:fixed !important;display: block !important;visibility: visible !important;";
  58. player.setAttribute("style",cst);
  59. while(window.getComputedStyle(target.parentNode,null).getPropertyValue("height")==ch&&window.getComputedStyle(target.parentNode,null).getPropertyValue("width")==cw) {
  60. ptarget=target.parentNode.cloneNode(true);
  61. ptarget.replaceChild(player.cloneNode(true),ptarget.childNodes[Array.prototype.indexOf.call(target.parentNode.childNodes,target)]);
  62. ptarget.setAttribute("style",cst);
  63. player=ptarget;
  64. target=target.parentNode;
  65. }
  66. var wurl=window.location.href;
  67. if(ff){
  68. wurl="about:blank";
  69. }
  70. //var w=window.open(wurl,"","width=520,height=325");
  71. var w=window.open(wurl,"","width=520,height=325,left="+(screen.availWidth-525)+",top="+(screen.availHeight-385));
  72. if(!w){
  73. window.alert("Please set to allow pop-up windows(请设置允许弹出窗口)");
  74. }else{
  75. //w.window.location.href=window.location.href;
  76. var id=window.setInterval(function(){
  77. if(w.document.body.childElementCount>0||wurl=="about:blank"){
  78. window.clearInterval(id);
  79. //w.document.write('<script type="text/undefined">');
  80. //w.document.documentElement.replaceChild(document.head.cloneNode(true),w.document.head);
  81. w.document.documentElement.innerHTML=" ";
  82. w.document.documentElement.replaceChild(document.head.cloneNode(true),w.document.head);
  83. //w.document.head.parentNode.appendChild(document.createElement("body"));
  84. //w.document.head.parentNode.removeChild(w.document.body);
  85. //w.document.head.parentNode.appendChild(document.createElement("body"));
  86. //w.document.documentElement.replaceChild(document.body.cloneNode(true),w.document.body);
  87. //w.document.documentElement.replaceChild(document.head.cloneNode(true),w.document.head);
  88. //var hd=document.head.cloneNode(true).querySelectorAll(":not(script)");
  89. //for (var i=0, len=hd.length; i<len ;i++){
  90. //w.document.head.appendChild(hd[i]);
  91. //}
  92. //var s = document.createElement('style');
  93. //s.type = 'text/css';
  94. //s.innerHTML = '* { height: 100% !important; width: 100%!important; }';
  95. //w.document.head.appendChild(s);
  96. //target.setAttribute("style","height: 100%; width: 100%; left: 0px; top: 0px;")
  97. //target.style.height="100%";
  98. //target.style.width="100%";
  99. //target.style.top="0px";
  100. //target.style.left="0px";
  101. //target.style.margin="0px";
  102. //target.style.padding="0px";
  103. //w.document.body.removeAttribute("class");
  104. //target.id="video_box";
  105. //target.className="video_box";
  106. //w.document.body.className="popupvideo";
  107. w.document.body.setAttribute("style",cst);
  108. //var d=document.createElement("div");
  109. //d.setAttribute("style","height: 100%; width: 100%; left: 0px; top: 0px;display: block;");
  110. //d.appendChild(target);
  111. //var js=document.querySelectorAll("script");
  112. //for (var i=0, len=js.length; i<len ;i++){
  113. //d.appendChild(js[i]);
  114. //}
  115. //w.document.body.appendChild(d);
  116. w.document.body.appendChild(player);
  117. var rt=document.createElement('script');
  118. rt.type = "text/javascript";
  119. rt.innerHTML='var ck=document.createElement("div"); ck.setAttribute("style","position: fixed; top: 5px; right: 10px;z-index: 2147483647;background: #000; opacity: 0.3;color:#fff;font-size: 8pt;cursor: pointer;text-align: center;color:#fff;padding: 4px"); ck.innerHTML="return"; ck.onclick=function() { window.open("'+window.location.href+'"); window.close(); };document.body.appendChild(ck);';
  120. w.document.body.appendChild(rt);
  121. //if (confirm("close original window?\n关闭原始窗口?") == true) {
  122. //window.close();
  123. //}
  124. }
  125. },100);
  126. }
  127. }
  128. }, false);
  129. }, false);