Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name sitelock.light
- // @author dbqp
- // @license GNU GPL
- // @version 0.1
- // ==/UserScript==
- if (getCookie("thissiteblocked")=="true") lock();
- window.onmousemove=function(e) {
- if (e.clientX<=10 && e.clientY<=10) {
- var date=new Date();
- if (!window.currenttime) window.currenttime=date.getTime();
- if ((date.getTime()-window.currenttime)>=5000) {
- window.currenttime=false;
- if (getCookie("thissiteblocked")!="true") {
- if (window.pagelocked) {
- setCookie("thissiteblocked",null);
- unlock();
- } else {
- setCookie("thissiteblocked","true");
- lock();
- }
- } else {
- setCookie("thissiteblocked",null);
- unlock();
- }
- }
- }
- }
- function lock() {
- window.pagelocked=true;
- window.bodystyle=document.getElementsByTagName("BODY")[0].getAttribute("style");
- window.titletext=document.getElementsByTagName("TITLE")[0].innerHTML;
- document.getElementsByTagName("TITLE")[0].innerHTML="Доступ заблокирован";
- document.getElementsByTagName("BODY")[0].setAttribute("style", "overflow: hidden");
- var screen=document.createElement("div");
- 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);");
- screen.setAttribute("id","divblockforlock");
- screen.innerHTML="Заблокировано";
- document.querySelector("body").appendChild(screen);
- }
- function unlock() {
- window.pagelocked=false;
- block=document.getElementById("divblockforlock");
- block.parentNode.removeChild(block);
- document.getElementsByTagName("TITLE")[0].innerHTML=window.titletext;
- document.getElementsByTagName("BODY")[0].setAttribute("style", window.bodystyle);
- }
- function setCookie (name, value, expires, path, domain, secure) {
- document.cookie=name+"="+escape(value)+"; expires=Sat 31-12-2020";
- }
- function getCookie(name) {
- var cookie=" "+document.cookie;
- var search=" "+name+"=";
- var setStr=null;
- var offset=0;
- var end=0;
- if (cookie.length>0) {
- offset=cookie.indexOf(search);
- if (offset!=-1) {
- offset+=search.length;
- end=cookie.indexOf(";", offset)
- if (end==-1) end=cookie.length;
- setStr=unescape(cookie.substring(offset, end));
- }
- }
- return(setStr);
- }
Advertisement
Add Comment
Please, Sign In to add comment