Popup Video

Popup online video out of the website

目前为 2014-08-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Popup Video
  3. // @homepageURL https://github.com/archion/videopop
  4. // @namespace https://github.com/archion/
  5. // @version 0.1.3
  6. // @description Popup online video out of the website
  7. // @match http://*/*
  8. // @match https://*/*
  9. // @copyright 2014+, archion
  10. // ==/UserScript==
  11. if (window.top != window.self) //don't run on frames or iframes
  12. {
  13. return;
  14. }
  15. var ck=document.createElement("div");
  16. ck.setAttribute("style","position: fixed; bottom: 20px; right: 20px;z-index: 999999;background: #000; opacity: 0.6;font-size: 8pt;text-align: center;color:#fff;padding: 4px");
  17. ck.innerHTML="<a href='#non' style='color:#fff;text-decoration:none;'>Popup</a>";
  18. document.body.appendChild(ck);
  19. ck.addEventListener('click', function() {
  20. //var flash=document.querySelectorAll("object[type='application/x-shockwave-flash']");
  21. //var flash=document.querySelectorAll("object[type='application/x-shockwave-flash']");
  22. //var pa=document.createElement("param");
  23. //pa.setAttribute("name","wmode");
  24. //pa.setAttribute("value","opaque");
  25. //for (var i=0, len=flash.length; i<len ;i++){
  26. //flash[i].setAttribute("wmode","opaque");
  27. //flash[i].innerHTML='<param name="wmode" value="opaque"/>';
  28. //flash[i].appendChild(pa)
  29. //}
  30. //debugger;
  31. var ntf=document.createElement("div");
  32. ntf.id="topntf";
  33. ntf.setAttribute("style","position: absolute; top: 0px; left: 0px;z-index: 2147483647; background: #000; opacity: 0.8;font-size: 50pt;line-height: 50pt;text-align: center;color:#fff; "+"width: "+document.body.offsetWidth+"px; "+"height: "+document.body.offsetHeight+"px; "+"padding-top: "+document.body.scrollTop+"px;");
  34. ntf.innerHTML="please click the element to pop out<br> 请点击需要弹出的元素";
  35. document.body.appendChild(ntf);
  36. document.addEventListener('mousedown', function(e) {
  37. if (document.getElementById("topntf")){
  38. document.body.removeChild(document.getElementById("topntf"));
  39. //document.body.removeChild(ntf);
  40. //e = e || window.event;
  41. //var target = e.target || e.srcElement;
  42. //var target = e.target.cloneNode(true)
  43. //var target = document.elementFromPoint(e.clientX,e.clientY).parentNode.cloneNode(true);
  44. var target = document.elementFromPoint(e.clientX,e.clientY).cloneNode(true);
  45. var w=window.open("about:blank","","width=520,height=325");
  46. if(!w){
  47. window.alert("Please set to allow pop-up windows(请设置允许弹出窗口)");
  48. }else{
  49. //window.onload doesn't work fine on chrome, so try setTimeout
  50. //w.window.onload=function(){
  51. w.window.onload=setTimeout(function(){
  52. w.document.documentElement.replaceChild(document.head.cloneNode(true),w.document.head);
  53. //w.document.documentElement.replaceChild(document.body.cloneNode(true),w.document.body);
  54. //var s = document.createElement('style');
  55. //s.type = 'text/css';
  56. //s.innerHTML = 'div { display: none; }';
  57. //w.document.head.appendChild(s);
  58. //target.setAttribute("style","height: 100%; width: 100%; left: 0px; top: 0px;")
  59. target.style.height="100%";
  60. target.style.width="100%";
  61. target.style.top="0px";
  62. target.style.left="0px";
  63. target.style.margin="0px";
  64. target.style.padding="0px";
  65. w.document.body.setAttribute("style","height: 100%; width: 100%;margin: 0px;min-width:90%;min-height:90%; left: 0px; top: 0px;");
  66. //w.document.body.removeAttribute("class");
  67. //var d=document.createElement("div");
  68. //d.setAttribute("style","height: 100%; width: 100%; left: 0px; top: 0px;display: block;");
  69. //d.appendChild(target);
  70. ////var js=document.querySelectorAll("script");
  71. ////for (var i=0, len=js.length; i<len ;i++){
  72. ////d.appendChild(js[i]);
  73. ////}
  74. //w.document.body.appendChild(d);
  75. w.document.body.appendChild(target);
  76. //}
  77. },500);
  78. }
  79. }
  80. }, false);
  81. }, false);
  82.