Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name TRAVIAN
  3. // @version 0.01
  4. // @description Этот скрипт будет пиликать об атаках!
  5. // @include http://*.travian.*/*
  6. // ==/UserScript==
  7. var timer, dOn, dOff, div = document.createElement('div'), audio = new Audio() , color = "green" ;
  8. audio.preload = 'auto';
  9. audio.loop = "loop" ;
  10. audio.src = 'http://svecha.orthoschool.ru/mirrai.ogg' ;
  11. //div.style.color = "gray" ;
  12. div.style.backgroundColor = color ;
  13. div.style.cursor = "pointer" ;
  14. div.style.position = 'absolute' ;
  15. div.style.width = "50px" ;
  16. div.style.height = "50px" ;
  17. div.style.top = '5px' ;
  18. div.style.right = '5px' ;
  19. div.style.fontWeight = 'bold' ;
  20. div.style.fontSize = '2em' ;
  21. div.style.borderRadius = "5px" ;
  22. div.addEventListener('mouseover', function(e) {
  23.         e = e.target ;
  24.         e.style.backgroundColor = (color == "red") ? "green" : "red" ;
  25.         e.style.borderColor = color ;
  26. }, false) ;
  27. div.addEventListener('mouseout', function(e) {
  28.         e = e.target ;
  29.         e.style.backgroundColor = color ;
  30.         e.style.borderColor = (color == "red") ? "green" : "red" ;
  31. }, false) ;
  32. document.body.appendChild(div) ;
  33. dOn = function() {
  34.         var cId, newCookie = "travian=", isMove, cookie, arrC, l, matches, attaks = document.querySelectorAll("li.attack") ;
  35.         if(l = attaks.length) {
  36.             cookie = (matches = document.cookie.match(new RegExp("(?:^|; )" + "travian".replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"))) ? decodeURIComponent(matches[1]) : undefined ;
  37.             arrC = !cookie ? [] : coockie.split(".") ;
  38.             for(var i = 0; i < l; i++) {
  39.                 cId = +attaks[i].querySelectorAll("a")[0].search.replace(/\D+/g,"") ;
  40.                 newCookie += cId + "." ;
  41.                 isMove = false ;
  42.                 for(var j = 0; j < arrC.length; j++) {
  43.                     if(cId == arrC[j])
  44.                         isMove = true ;
  45.                 } ;
  46.                 if(!isMove)
  47.                     audio.play() ;
  48.             } ;
  49.             if((newCookie = newCookie.slice(0, -1)) != "travian")
  50.                 document.cookie = newCookie + "; path=/" ;
  51.         } ;
  52.         timer = setInterval(function() {
  53.                 location.reload();
  54.         }, 30000) ;
  55.         div.style.backgroundColor = 'green' ;
  56.         color = "green" ;
  57.         div.style.border = "3px solid red" ;
  58.         div.addEventListener("click", dOff, false) ;
  59.         div.removeEventListener("click", dOn, false) ;
  60. } ;
  61. dOff = function() {
  62.         audio.pause() ;
  63. } ;
  64. dOn() ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement