Guest User

Untitled

a guest
Nov 13th, 2016
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Так как меня кинул заказчик на бабки, а конкретно на 10$, я решил выложить это в паблик. Открываем консоль в браузере Ctrl + Shift + i, вставляем скрипт ниже, настраиваем, можно создавать автоматическое создание заездов и прохождение с нужной их скоростью и ошибками, в иксах чтобы заработало, нужно зайти, перезагрузить страницу и опять зайти ну или можете допилить сами. (с) un4given
  2.  
  3.  
  4.  
  5. var kg = {
  6.     isRemoveAds: false,
  7.     isAddMyPanel: false,
  8.     myPanel: document.createElement('div'),
  9.     initMyPanel: function(){
  10.         var setStyleBlock = function(block){
  11.             block.style.float = 'left';
  12.             block.style.height = '140px';
  13.             block.style.padding = '0 10px';
  14.      
  15.         };
  16.         var setStyleH4 = function(block){
  17.             block.style.width = '100%';
  18.             block.style.margin = '5px 0 0 0';
  19.             block.style.padding = '0px';
  20.             block.style.font = 'bold 14px sans-serif';
  21.             block.style.borderBottom = '1px solid #cccccc';
  22.             block.style.color = '#555';
  23.             block.style.textAlign = 'left';
  24.         };
  25.         var setStyleTextBlock = function(block, width){
  26.             block.style.width = width;
  27.             block.style.height = '24px';
  28.             block.style.font = '13px sans-serif';
  29.             block.style.color = '#000000';
  30.             block.style.lineHeight = '22px';
  31.         };
  32.         var setStyleInput = function(block, width){
  33.             block.style.width = width;
  34.             block.style.border = '1px solid #aaaaaa';
  35.             block.style.padding = '1px 2px';
  36.             block.style.margin = '0px';
  37.             block.style.font = '12px sans-serif';
  38.         };
  39.         kg.myPanel.style.background = '#ffffff';
  40.         kg.myPanel.style.width = '100%';
  41.         kg.myPanel.style.height = '120px';
  42.         var blockInf = document.createElement('div');
  43.         setStyleBlock(blockInf);   
  44.         var blockAutoType = document.createElement('div');
  45.         setStyleBlock(blockAutoType);
  46.         var enableAutoType = document.createElement('div');
  47.         setStyleTextBlock(enableAutoType, '140px');
  48.         enableAutoType.innerHTML = 'Включить <input id="kh_autotype" type="checkbox">';
  49.         var speedAutoType = document.createElement('div');
  50.         setStyleTextBlock(speedAutoType);
  51.         var inputAutoTypeStart = document.createElement('input');
  52.         inputAutoTypeStart.setAttribute('type','text');
  53.         inputAutoTypeStart.id = 'kh_autotype_speed_s';
  54.         setStyleInput(inputAutoTypeStart, '40px');
  55.         var inputAutoTypeEnd = document.createElement('input');
  56.         inputAutoTypeEnd.setAttribute('type','text');
  57.         inputAutoTypeEnd.id = 'kh_autotype_speed_e';
  58.         setStyleInput(inputAutoTypeEnd, '40px');
  59.         speedAutoType.innerHTML = 'Скорость от ';
  60.         speedAutoType.appendChild(inputAutoTypeStart);
  61.         speedAutoType.innerHTML += ' до ';
  62.         speedAutoType.appendChild(inputAutoTypeEnd);
  63.         var errorAutoType = document.createElement('div');
  64.         setStyleTextBlock(errorAutoType);
  65.         var inputAutoTypeErorrStart = document.createElement('input');
  66.         inputAutoTypeErorrStart.setAttribute('type','text');
  67.         inputAutoTypeErorrStart.id = 'kh_autotype_error_s';
  68.         setStyleInput(inputAutoTypeErorrStart, '40px');
  69.         var inputAutoTypeErorrEnd = document.createElement('input');
  70.         inputAutoTypeErorrEnd.setAttribute('type','text');
  71.         inputAutoTypeErorrEnd.id = 'kh_autotype_error_e';
  72.         setStyleInput(inputAutoTypeErorrEnd, '40px');
  73.         errorAutoType.innerHTML = 'Ошибки  &nbsp от ';
  74.         errorAutoType.appendChild(inputAutoTypeErorrStart);
  75.         errorAutoType.innerHTML += ' до  ';
  76.         errorAutoType.appendChild(inputAutoTypeErorrEnd);
  77.         var restartAutoType = document.createElement('div');
  78.         setStyleTextBlock(restartAutoType);
  79.         var startAutoType = document.createElement('div');
  80.         setStyleTextBlock(startAutoType);
  81.         blockAutoType.appendChild(enableAutoType);
  82.         blockAutoType.appendChild(speedAutoType);
  83.         blockAutoType.appendChild(errorAutoType);
  84.         blockAutoType.appendChild(startAutoType);
  85.         kg.myPanel.appendChild(blockInf);
  86.         kg.myPanel.appendChild(blockAutoType);
  87.         kg.myPanel.innerHTML += '';
  88.     },
  89.     clear: function(){
  90.         kg.isRemoveAds = false;
  91.         kg.isAddMyPanel = false;
  92.     },
  93.     removeAds: function(){
  94.         if(kh.fdoc.getElementsByClassName('ownbanner-back').length != 0){
  95.             var ownbanner = kh.fdoc.getElementsByClassName('ownbanner-back')[0];
  96.             ownbanner.innerHTML = '';
  97.             ownbanner.style.background = '#ffffff';
  98.             ownbanner.style.padding = '0px';
  99.             kg.isRemoveAds = true;
  100.         }
  101.     },
  102.     addMyPanel: function(){
  103.         if(kh.fdoc.getElementsByClassName('ownbanner-back').length != 0){
  104.             kh.fdoc.getElementsByClassName('ownbanner-back')[0].appendChild(kg.myPanel);
  105.             kg.isAddMyPanel = true;
  106.         }
  107.         if(kh.fdoc.getElementsByClassName('userpanel')[0].length != 0){
  108.             var userpanel = kh.fdoc.getElementsByClassName('userpanel')[0];
  109.             userpanel.parentNode.insertBefore(kg.myPanel, userpanel.nextSibling);
  110.             kg.isAddMyPanel = true;
  111.         }
  112.         if(kg.isAddMyPanel){
  113.             kh.fwnd.document.getElementById('kh_autotype').checked = kh.autotype.enable;
  114.             kh.fwnd.document.getElementById('kh_autotype').onchange = function(){
  115.                 kh.autotype.enable = this.checked;
  116.             };
  117.             kh.fwnd.document.getElementById('kh_autotype_speed_s').value = kh.autotype.minSpeed;
  118.             kh.fwnd.document.getElementById('kh_autotype_speed_s').onchange = function(){
  119.                 kh.autotype.minSpeed = parseInt(this.value);
  120.             };
  121.             kh.fwnd.document.getElementById('kh_autotype_speed_e').value = kh.autotype.maxSpeed;
  122.             kh.fwnd.document.getElementById('kh_autotype_speed_e').onchange = function(){
  123.                 kh.autotype.maxSpeed = parseInt(this.value);
  124.             };
  125.             kh.fwnd.document.getElementById('kh_autotype_error_s').value = kh.autotype.minError;
  126.             kh.fwnd.document.getElementById('kh_autotype_error_s').onchange = function(){
  127.                 kh.autotype.minError = parseInt(this.value);
  128.             };
  129.             kh.fwnd.document.getElementById('kh_autotype_error_e').value = kh.autotype.maxError;
  130.             kh.fwnd.document.getElementById('kh_autotype_error_e').onchange = function(){
  131.                 kh.autotype.maxError = parseInt(this.value);
  132.             };
  133.             kh.fwnd.document.getElementById('kh_autotype_autostart').checked = kh.autotype.autostart;
  134.             kh.fwnd.document.getElementById('kh_autotype_autostart').onchange = function(){
  135.                 kh.autotype.autostart = this.checked;
  136.             };
  137.            
  138.         }
  139.     }
  140. };
  141.  
  142. var kh = {
  143.     iframe: null,
  144.     fwnd: null,
  145.     fdoc: null,
  146.     oldLocation: null,
  147.     startTime: null,
  148.     hiddenIframe: null,
  149.     init: function(){
  150.         setInterval(kh.checkUnloadChange, 1000);
  151.         this.startTime = new Date();
  152.         setInterval(kh.refreshTime, 1000);
  153.         document.head.innerHTML = '';
  154.         document.body.innerHTML = '';
  155.         this.hiddenIframe = document.createElement('iframe');
  156.         this.hiddenIframe.style.display = 'none';
  157.         document.body.appendChild(this.hiddenIframe);
  158.         this.iframe = document.createElement('iframe');
  159.         this.iframe.style.width = '100%';
  160.         this.iframe.style.height = '100%';
  161.         this.iframe.style.border = 'none';
  162.         this.iframe.src = 'http://www.klavogonki.ru/gamelist/';
  163.         kg.initMyPanel();
  164.         this.iframe.onload = function(){
  165.             kh.checkLoad();
  166.             kg.clear();
  167.             clearInterval(kh.intervalID);
  168.             this.contentWindow.onbeforeunload = kh.wndUnload;
  169.         };
  170.         document.body.style.margin = '0';
  171.         document.body.style.height = '100%';
  172.         document.documentElement.style.height = '100%';
  173.         document.body.appendChild(this.iframe);
  174.     },
  175.     wndUnload: function(){
  176.         kh.oldLocation = kh.fwnd.location;
  177.         kh.intervalID = setInterval(kh.checkLoad, 100);
  178.         kh.autotype.isRace = false;
  179.         clearTimeout(kh.autotype._timer);
  180.     },
  181.     checkUnloadChange: function(){
  182.         if(kh.fwnd){
  183.             if(kh.fwnd.onbeforeunload != kh.wndUnload){
  184.                 kh.fwnd.onbeforeunload = kh.wndUnload;
  185.             }
  186.         }
  187.     },
  188.     checkLoad: function(){
  189.         kh.fwnd = kh.iframe.contentWindow;
  190.         if(kh.fwnd) kh.fdoc = kh.fwnd.document;
  191.         if(kh.fwnd.location != kh.oldLocation){
  192.             if(!kg.isRemoveAds) kg.removeAds();
  193.             if(!kg.isAddMyPanel) kg.addMyPanel();
  194.             if(!kh.autotype.isRace) kh.autotype.checkRace();
  195.         }
  196.     },
  197.     refreshTime: function(){
  198.         var tmpTime = new Date();
  199.         tmpTime = tmpTime.getTime() - kh.startTime.getTime();
  200.         var seconds = parseInt(tmpTime/1000);
  201.         while(seconds >= 60) seconds -= 60;
  202.         var minutes = parseInt(tmpTime/1000/60);
  203.         while(minutes >= 60) minutes -= 60;
  204.         var hours = parseInt(tmpTime/1000/60/60);
  205.         if(kh.fdoc && kh.fdoc.getElementById('kh_time')) {
  206.             kh.fdoc.getElementById('kh_time').innerHTML = ((hours < 10)?'0':'')+hours+':'+((minutes<10)?'0':'')+minutes+':'+((seconds<10)?'0':'')+seconds;
  207.         }
  208.     },
  209.  
  210.     autotype: {
  211.         isRace: false,
  212.         enable: true,
  213.         autostart: false,
  214.         autorestart: false,
  215.         minSpeed: 478,
  216.         maxSpeed: 503,
  217.         minError: 0,
  218.         maxError: 2,
  219.         _speedNow: -1,
  220.         _speed: -1,
  221.         _error: -1,
  222.         _i: 0,
  223.         _tspeed: 0,
  224.         _timer: null,
  225.         checkRace: function(){
  226.             if(kh.fwnd.game) {
  227.                 kh.autotype.isRace = true;
  228.                 kh.autotype.checkStart();
  229.             }
  230.         },
  231.         checkStart: function(){
  232.             if(kh.autotype.enable && kh.autotype.isRace){
  233.                 if(kh.fwnd.game.gamestatus == 'racing'){
  234.                     setTimeout(kh.autotype.start, 200);
  235.                 } else {
  236.                     if(kh.autotype.autostart && kh.fwnd.game.gamestatus == 'paused'){
  237.                         kh.fwnd.game.hostStart();
  238.                     }
  239.                     kh.autotype._timer = setTimeout(kh.autotype.checkStart, 100);
  240.                 }
  241.             }
  242.         },
  243.         start: function(){
  244.             kh.autotype._speed = kh.autotype.minSpeed + parseInt(Math.random()*(kh.autotype.maxSpeed - kh.autotype.minSpeed));
  245.             kh.autotype._error = kh.autotype.minError + parseInt(Math.random()*(kh.autotype.maxError - kh.autotype.minError));
  246.             kh.autotype._speedNow = 0;
  247.             kh.autotype._i = 0;
  248.             kh.autotype._tspeed = (60/kh.autotype._speed)*1000;
  249.             kh.autotype._startSpeed = kh.autotype._tspeed;
  250.             setTimeout(kh.autotype.loop, 100);
  251.         },
  252.         loop: function(){
  253.             if(kh.autotype._error > 0){
  254.                 kh.autotype._error--;
  255.                 kh.fdoc.getElementById("inputtext").value += "/";
  256.                 kh.fwnd.change(kh.fdoc.getElementById("inputtext"));
  257.                 kh.fwnd.change(kh.fdoc.getElementById("inputtext"));
  258.                 kh.fdoc.getElementById("inputtext").value = "";
  259.                 kh.fwnd.change(kh.fdoc.getElementById("inputtext"));
  260.                 kh.autotype._timer = setTimeout(kh.autotype.loop, 0);
  261.             } else {
  262.                 kh.fdoc.getElementById("inputtext").value += kh.fwnd.game.text[kh.autotype._i];
  263.                 kh.fwnd.change(kh.fdoc.getElementById("inputtext"));
  264.                 kh.autotype._i++;
  265.                 if(kh.autotype._i < kh.fwnd.game.text.length){
  266.                     var speednow = (new Date().getTime()) - kh.fwnd.game.begintime;
  267.                     if(kh.autotype._i < (kh.autotype._speed/60*(speednow/1000))){
  268.                         if(kh.autotype._startSpeed-10 < kh.autotype._tspeed) kh.autotype._tspeed -= 1;
  269.                     } else {
  270.                         if(kh.autotype._startSpeed+10 > kh.autotype._tspeed) kh.autotype._tspeed += 1;
  271.                     }
  272.                     kh.autotype._timer = setTimeout(kh.autotype.loop, kh.autotype._tspeed);
  273.                 }
  274.                         }
  275.                         if(player && player.info.speed){
  276.                             kh.wndUnload();
  277.                             kh.fwnd.location = '/g/'+kh.fwnd.game.id+'.replay';
  278.                         } else {
  279.                             kh.autotype._timer = setTimeout(kh.autotype.loop, 100);
  280.                         }
  281.                     }
  282.                
  283.            
  284.         },
  285.        
  286.    
  287. };
  288.  
  289. kh.init();
Advertisement
Add Comment
Please, Sign In to add comment