Popup Video

Popup online video out of the website

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

  1. // ==UserScript==
  2. // @name Popup Video
  3. // @homepageURL https://github.com/archion/videopop
  4. // @namespace https://github.com/archion/
  5. // @version 0.1.1
  6. // @description Popup online video out of the website
  7. // @match http://*/*
  8. // @match https://*/*
  9. // @copyright 2014+, archion
  10. // ==/UserScript==
  11. var ck=document.createElement("div");
  12. 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");
  13. ck.innerHTML="<a href='#non' style='color:#fff;text-decoration:none;'>Popup</a>";
  14. document.body.appendChild(ck);
  15. ck.addEventListener('click', function() {
  16. var ntf=document.createElement("div");
  17. ntf.id="topntf";
  18. 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;");
  19. ntf.innerHTML="please click the element to pop out<br> 请点击需要弹出的元素";
  20. document.body.appendChild(ntf);
  21. document.addEventListener('mousedown', function(e) {
  22. if (document.getElementById("topntf")){
  23. document.body.removeChild(document.getElementById("topntf"));
  24. //debugger;
  25. //document.body.removeChild(ntf);
  26. //e = e || window.event;
  27. //var target = e.target || e.srcElement;
  28. //var target = e.target.cloneNode(true)
  29. //var target = document.elementFromPoint(e.clientX,e.clientY).parentNode.cloneNode(true);
  30. var target = document.elementFromPoint(e.clientX,e.clientY).cloneNode(true);
  31. //var w=window.open(""+window.location.href,"","width=520,height=325");
  32. var w=window.open("about:blank","","width=520,height=325");
  33. if(!w){
  34. window.alert("Please set to allow pop-up windows(请设置允许弹出窗口)");
  35. }
  36. //window.setTimeout(function () {
  37. //w.window.location.hostname=window.location.hostname
  38. //w.stop;
  39. w.document.documentElement.replaceChild(document.head.cloneNode(true),w.document.head);
  40. //w.document.documentElement.replaceChild(document.body.cloneNode(true),w.document.body);
  41. //var s = document.createElement('style');
  42. //s.type = 'text/css';
  43. //s.innerHTML = 'div { display: none; }';
  44. //w.document.head.appendChild(s);
  45. //target.setAttribute("style","height: 100%; width: 100%; left: 0px; top: 0px;")
  46. target.style.height="100%";
  47. target.style.width="100%";
  48. target.style.margin="0px";
  49. target.style.padding="0px";
  50. //target.style.display="block";
  51. w.document.body.setAttribute("style","height: 100%; width: 100%;margin: 0px;min-width:90%;min-height:90%; left: 0px; top: 0px;");
  52. //w.document.body.removeAttribute("class");
  53. //var d=document.createElement("div");
  54. //d.setAttribute("style","height: 100%; width: 100%; left: 0px; top: 0px;display: block;");
  55. //d.appendChild(target);
  56. ////var js=document.querySelectorAll("script");
  57. ////for (var i=0, len=js.length; i<len ;i++){
  58. ////d.appendChild(js[i]);
  59. ////}
  60. //w.document.body.appendChild(d);
  61. w.document.body.appendChild(target);
  62. //},1000);
  63. }
  64. }, false);
  65. }, false);
  66.