srtoslim / Ojooo Auto Clicker

// ==UserScript==
// @name        	Ojooo Auto Clicker
// @namespace		http://wad.ojooo.com/register.php?ref=srtoslim
// @version     	2.1
// @date        	2016-08-26
// @author      	SRToslim
// @author email    srtoslim@gmail.com
// @grant       	none
// @icon		    http://wad.ojooo.com/favicon.ico
// @include		    http://wad.ojooo.com/ads.php
// @include		    http://wad.ojooo.com/cks.php*
// @include		    http://wad.ojooo.com/errors.php?err=*
// ==/UserScript==
(function(w){
function autoview(){
if(w.parent.location.href.indexOf("cks.php")>0){
	var el=function(i){return document.getElementById(i);}
	var fr=el("pgl"),src=fr.src,fd=false;fr.src="about:blank";fr.setAttribute("sandbox","");/*fr.src=src;*/document.querySelector(".cks").style.height="150px";
	fr=document.querySelectorAll("head script");
	for(i=0;i<fr.length;i++){if(fr[i].src.indexOf("js/jquery.motionCaptcha.0.2.js")>0){src=fr[i].src;fd=true;break;}}
	if(!fd){alert("Обнаружено изменение капчи! Ждите инфо о новой версии скрипта в офф. группе https://vk.com/very.many.money");return;}
	fr=function(c){jQuery('#logo').append('<iframe id="cpt" src="'+src+'" style="display:none;" />');jQuery('iframe#cpt').load(function(){c(this);});}
	if(!localStorage.getItem('moddate')){
		fr(function(){localStorage.setItem('moddate',el("cpt").contentDocument.lastModified);});
	}
	fr(function(){sessionStorage.setItem('moddate',el("cpt").contentDocument.lastModified);});
	fd=function(n){var a='azertyupqsdfghjkmwxcvbn23456789AZERTYUPQSDFGHJKMWXCVBN_-#@',p='',z='';for(i=0;i<n;i++){z=Math.round(Math.random()*a.length);p+=a.substring(z,z+1);}return p;}
	fr=function(f){var h=document.querySelector('head'),o=el('lastLoadedCmds');if(o)h.removeChild(o);var s=document.createElement('script');s.src=f;s.type='text/javascript';s.defer=true;s.id='lastLoadedCmds';void(h.appendChild(s));}
	src=w.setInterval(
		function(){
			if(localStorage.getItem('moddate')==sessionStorage.getItem('moddate')){
					if(el("captcha").style.display=="block"){
						w.clearInterval(src);
						w.setTimeout(
							function(){
								var ssss=Math.floor(Math.random()*4);
								var _inp=jQuery('<input>',{name:fd(32),value:fd(7),type:'hidden'});
								el("mc-form").appendChild(_inp[0]);
								sessionStorage.removeItem(w.parent.location.href.substring(35,w.parent.location.href.length-10));
								$.post('conf3.php',{action:'qaptcha',bad_draw:0,image:ssss,nn:'1',qaptcha_key:_inp.attr('name')},function(data){if(!data.error){el('captcha').style.display='none';el('timer_sukces').style.display="block";el('sukces').style.display="block";el('timer_sukces').style.width="100%";_inp.val('');fr("cmp.php?complete&amp;");}},'json');
								var _in=w.setInterval(function(){if(el('sukces').style.display=="block"){w.clearInterval(_in);w.setTimeout(function(){w.parent.close();},Math.floor(Math.random()*2000)+2000);}},1000)
							},Math.floor(Math.random()*5000)+2000
						);
					}
				}else{w.clearInterval(src);alert("Обнаружено изменение скрипта! Даты "+sessionStorage.getItem('moddate')+" не совпадают! Обратитесь за новой версией к разрабу!!!");return;}
		},2000
	);
}else if(w.parent.location.href.indexOf("ads.php")>0){
	if(document.querySelector('.top_join_icon').nextElementSibling.querySelector('a').href.indexOf('register.php')!=-1) return;
	var sec=Math.floor(Math.random()*5000)+2000,prm=document.querySelectorAll("#adspremium"),cheat=document.querySelectorAll("div[style='display:none']");
	for(var m=0,l=prm.length;m<l;m++){prm[m].style.display="none";}for(var i=0,l=cheat.length;i<l;i++)cheat[i].parentNode.removeChild(cheat[i]);
	cheat=['CHEAT',"DON'T CLICK","DON'T VISIT",'DO NOT CLICK','DO NOT VISIT','BANNED','WARNING','SUSPEND'];
	var advs=document.querySelectorAll("#content .category .surf:not(#adspremium) div.adname"),lnk='',key='';
	if(advs.length){
		for(m=0;m<advs.length;m++){
			if(advs[m].style.display!="none"&&advs[m].parentNode.style.display!="none"&&advs[m].parentNode.parentNode.style.display!="none"){
				lnk=advs[m].querySelector('a');key=lnk.href.substring(35,lnk.href.length-10);
				for(l=0;l<cheat.length;l++){
					if(advs[m].innerHTML.toUpperCase().indexOf(cheat[l])!=-1){
						sessionStorage.setItem(key,lnk.innerHTML);
						break;
					}
				}
				if(sessionStorage.getItem(key)&&sessionStorage.getItem(key)==lnk.innerHTML){
					if(m==advs.length-1){window.setTimeout(function(){window.location.reload(true);},Math.floor(Math.random()*50000)+50000);}
					else{continue;}
				}else
					if(sessionStorage.getItem(key)&&sessionStorage.getItem(key)!=lnk.innerHTML){
						window.setTimeout(function(){lnk.click();sessionStorage.removeItem(key);sessionStorage.setItem(key,lnk.innerHTML);},sec);
						window.setTimeout(function(){window.location.reload(true);},Math.floor(Math.random()*50000)+80000);
						break;
					}else{
						window.setTimeout(function(){lnk.click();sessionStorage.setItem(key,lnk.innerHTML);},sec);
						window.setTimeout(function(){window.location.reload(true);},Math.floor(Math.random()*50000)+80000);
						break;
					}
			}else{alert("Обнаружена античит ссылка");return;}
		}
		}else{window.setTimeout(function(){window.location.reload(true);},Math.floor(Math.random()*50000)+50000);}
	}
	if(w.location.href.indexOf("errors.php")>0){w.close();w.parent.opener.location.reload();}
}
if(document.addEventListener)document.addEventListener('DOMContentLoaded',autoview,false);else w.addEventListener('load',autoview,false);
})(window);