Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name TRAVIAN
- // @version 0.01
- // @description Этот скрипт будет пиликать об атаках!
- // @include http://*.travian.*/*
- // ==/UserScript==
- var timer, dOn, dOff, div = document.createElement('div'), audio = new Audio() , color = "green" ;
- audio.preload = 'auto';
- audio.loop = "loop" ;
- audio.src = 'http://svecha.orthoschool.ru/mirrai.ogg' ;
- //div.style.color = "gray" ;
- div.style.backgroundColor = color ;
- div.style.cursor = "pointer" ;
- div.style.position = 'absolute' ;
- div.style.width = "50px" ;
- div.style.height = "50px" ;
- div.style.top = '5px' ;
- div.style.right = '5px' ;
- div.style.fontWeight = 'bold' ;
- div.style.fontSize = '2em' ;
- div.style.borderRadius = "5px" ;
- div.addEventListener('mouseover', function(e) {
- e = e.target ;
- e.style.backgroundColor = (color == "red") ? "green" : "red" ;
- e.style.borderColor = color ;
- }, false) ;
- div.addEventListener('mouseout', function(e) {
- e = e.target ;
- e.style.backgroundColor = color ;
- e.style.borderColor = (color == "red") ? "green" : "red" ;
- }, false) ;
- document.body.appendChild(div) ;
- dOn = function() {
- var cId, newCookie = "travian=", isMove, cookie, arrC, l, matches, attaks = document.querySelectorAll("li.attack") ;
- if(l = attaks.length) {
- cookie = (matches = document.cookie.match(new RegExp("(?:^|; )" + "travian".replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"))) ? decodeURIComponent(matches[1]) : undefined ;
- arrC = !cookie ? [] : coockie.split(".") ;
- for(var i = 0; i < l; i++) {
- cId = +attaks[i].querySelectorAll("a")[0].search.replace(/\D+/g,"") ;
- newCookie += cId + "." ;
- isMove = false ;
- for(var j = 0; j < arrC.length; j++) {
- if(cId == arrC[j])
- isMove = true ;
- } ;
- if(!isMove)
- audio.play() ;
- } ;
- if((newCookie = newCookie.slice(0, -1)) != "travian")
- document.cookie = newCookie + "; path=/" ;
- } ;
- timer = setInterval(function() {
- location.reload();
- }, 30000) ;
- div.style.backgroundColor = 'green' ;
- color = "green" ;
- div.style.border = "3px solid red" ;
- div.addEventListener("click", dOff, false) ;
- div.removeEventListener("click", dOn, false) ;
- } ;
- dOff = function() {
- audio.pause() ;
- } ;
- dOn() ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement