Popup Video

Popup online video out of the webpage

当前为 2014-08-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Popup Video
  3. // @homepageURL https://github.com/archion/videopop
  4. // @namespace https://github.com/archion/
  5. // @version 0.1.10
  6. // @description Popup online video out of the webpage
  7. // @match http://*/*
  8. // @match https://*/*
  9. // @copyright 2014+, archion
  10. // ==/UserScript==
  11. if (window.top != window.self) { return; } //don't run on frames or iframes
  12. var ck=document.createElement("div");
  13. ck.setAttribute("style","position: fixed; bottom: 5px; right: 20px;z-index: 999999;background: #000; opacity: 0.5;color:#fff;font-size: 8pt;cursor: pointer;text-align: center;color:#fff;padding: 4px");
  14. ck.innerHTML="Popup";
  15. document.body.appendChild(ck);
  16. ck.addEventListener('click', function() {
  17. //debugger;
  18. var ff=!window.chrome;
  19. if(ff){
  20. var flash=document.querySelectorAll("[type='application/x-shockwave-flash']");
  21. for (var i=0, len=flash.length; i<len ;i++){
  22. flash[i].setAttribute("wmode","opaque");
  23. flash[i].style.display="none";
  24. }
  25. setTimeout(function(){
  26. for (var i=0, len=flash.length; i<len ;i++){
  27. flash[i].style.display="";
  28. }
  29. },100*flash.length);
  30. }
  31. //var flash=document.querySelectorAll("iframe");
  32. //for (var i=0, len=flash.length; i<len ;i++){
  33. //flash[i].setAttribute("wmode","opaque");
  34. //}
  35. var ntf=document.createElement("div");
  36. ntf.id="topntf";
  37. 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: "+document.body.scrollWidth+"px; "+"height: "+document.body.scrollHeight+"px; "+"padding-top: "+document.body.scrollTop+"px;");
  38. ntf.innerHTML="please click the element to pop out<br> 请点击需要弹出的元素";
  39. document.body.appendChild(ntf);
  40. document.addEventListener('mousedown', function(e) {
  41. if (document.getElementById("topntf")){
  42. document.body.removeChild(document.getElementById("topntf"));
  43. //document.body.removeChild(ntf);
  44. //e = e || window.event;
  45. //var target = e.target || e.srcElement;
  46. //var target = e.target.cloneNode(true)
  47. //var target = document.elementFromPoint(e.clientX,e.clientY).parentNode.cloneNode(true);
  48. var target = document.elementFromPoint(e.clientX,e.clientY).cloneNode(true);
  49. var wurl=window.location.href;
  50. if(ff){
  51. wurl="about:blank";
  52. }
  53. var w=window.open(wurl,"","width=520,height=325");
  54. if(!w){
  55. window.alert("Please set to allow pop-up windows(请设置允许弹出窗口)");
  56. }else{
  57. //w.window.location.href=window.location.href;
  58. var id=window.setInterval(function(){
  59. if(w.document.body.childElementCount>1||wurl=="about:blank"){
  60. window.clearInterval(id);
  61. //w.document.write('<script type="text/undefined">');
  62. //w.document.documentElement.replaceChild(document.head.cloneNode(true),w.document.head);
  63. w.document.documentElement.innerHTML=" ";
  64. //w.document.head.parentNode.appendChild(document.createElement("body"));
  65. //w.document.head.parentNode.removeChild(w.document.body);
  66. //w.document.head.parentNode.appendChild(document.createElement("body"));
  67. //w.document.documentElement.replaceChild(document.body.cloneNode(true),w.document.body);
  68. w.document.documentElement.replaceChild(document.head.cloneNode(true),w.document.head);
  69. //var s = document.createElement('style');
  70. //s.type = 'text/css';
  71. //s.innerHTML = 'div { display: none; }';
  72. //w.document.head.appendChild(s);
  73. //target.setAttribute("style","height: 100%; width: 100%; left: 0px; top: 0px;")
  74. //target.style.height="100%";
  75. //target.style.width="100%";
  76. //target.style.top="0px";
  77. //target.style.left="0px";
  78. //target.style.margin="0px";
  79. //target.style.padding="0px";
  80. //w.document.body.removeAttribute("class");
  81. target.id="archion";
  82. target.className="archion";
  83. target.setAttribute("style","height: 100% !important; width: 100% !important;margin: 0px;min-width:90% !important;min-height:90% !important; left: 0px; top: 0px;visibility :visible !important;display :block !important");
  84. //w.document.body.className="vp";
  85. w.document.body.setAttribute("style","height: 100% !important; width: 100% !important;margin: 0px;padding: 0px;min-width:90% !important;min-height:90% !important; left: 0px; top: 0px;display :block !important");
  86. //var d=document.createElement("div");
  87. //d.setAttribute("style","height: 100%; width: 100%; left: 0px; top: 0px;display: block;");
  88. //d.appendChild(target);
  89. //var js=document.querySelectorAll("script");
  90. //for (var i=0, len=js.length; i<len ;i++){
  91. //d.appendChild(js[i]);
  92. //}
  93. //w.document.body.appendChild(d);
  94. w.document.body.appendChild(target);
  95. //var hd=document.head.cloneNode(true).querySelectorAll(":not(script)");
  96. //for (var i=0, len=hd.length; i<len ;i++){
  97. //w.document.head.appendChild(hd[i]);
  98. //}
  99. var rt=document.createElement('script');
  100. rt.type = "text/javascript";
  101. rt.innerHTML='var ck=document.createElement("div"); ck.setAttribute("style","position: fixed; top: 5px; right: 10px;z-index: 999999;background: #000; opacity: 0.5;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);';
  102. w.document.body.appendChild(rt);
  103. window.close();
  104. }
  105. },100);
  106. }
  107. }
  108. }, false);
  109. }, false);
  110.