Guest User

sitelock.light.user.js

a guest
Mar 17th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name sitelock.light
  3. // @author dbqp
  4. // @license GNU GPL
  5. // @version 0.1
  6. // ==/UserScript==
  7.  
  8. if (getCookie("thissiteblocked")=="true") lock();
  9. window.onmousemove=function(e) {
  10.     if (e.clientX<=10 && e.clientY<=10) {
  11.         var date=new Date();
  12.         if (!window.currenttime) window.currenttime=date.getTime();
  13.         if ((date.getTime()-window.currenttime)>=5000) {
  14.             window.currenttime=false;
  15.             if (getCookie("thissiteblocked")!="true") {
  16.                 if (window.pagelocked) {
  17.                     setCookie("thissiteblocked",null);
  18.                     unlock();
  19.                    
  20.                 } else {
  21.                     setCookie("thissiteblocked","true");
  22.                     lock();
  23.                 }
  24.                
  25.             } else {
  26.                 setCookie("thissiteblocked",null);
  27.                 unlock();
  28.                
  29.             }
  30.         }
  31.     }
  32.    
  33. }
  34.  
  35. function lock() {
  36.     window.pagelocked=true;
  37.     window.bodystyle=document.getElementsByTagName("BODY")[0].getAttribute("style");
  38.     window.titletext=document.getElementsByTagName("TITLE")[0].innerHTML;
  39.     document.getElementsByTagName("TITLE")[0].innerHTML="Доступ заблокирован";
  40.     document.getElementsByTagName("BODY")[0].setAttribute("style", "overflow: hidden");
  41.     var screen=document.createElement("div");
  42.     screen.setAttribute("style","display: block; position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; background-color: black;z-index: 9999; text-align: center;padding-top: 30%; font-size: 40px; font-family: Verdana; color: #fff; 0px 4px 3px rgba(0,0,0,0.4),0px 8px 13px rgba(0,0,0,0.1),0px 18px 23px rgba(0,0,0,0.1);");
  43.     screen.setAttribute("id","divblockforlock");
  44.     screen.innerHTML="Заблокировано";
  45.     document.querySelector("body").appendChild(screen);
  46. }
  47. function unlock() {
  48.     window.pagelocked=false;
  49.     block=document.getElementById("divblockforlock");
  50.     block.parentNode.removeChild(block);
  51.     document.getElementsByTagName("TITLE")[0].innerHTML=window.titletext;
  52.     document.getElementsByTagName("BODY")[0].setAttribute("style", window.bodystyle);
  53.    
  54. }
  55. function setCookie (name, value, expires, path, domain, secure) {
  56.       document.cookie=name+"="+escape(value)+"; expires=Sat 31-12-2020";
  57. }
  58. function getCookie(name) {
  59.     var cookie=" "+document.cookie;
  60.     var search=" "+name+"=";
  61.     var setStr=null;
  62.     var offset=0;
  63.     var end=0;
  64.     if (cookie.length>0) {
  65.         offset=cookie.indexOf(search);
  66.         if (offset!=-1) {
  67.             offset+=search.length;
  68.             end=cookie.indexOf(";", offset)
  69.             if (end==-1) end=cookie.length;
  70.             setStr=unescape(cookie.substring(offset, end));
  71.         }
  72.     }
  73.     return(setStr);
  74. }
Advertisement
Add Comment
Please, Sign In to add comment