Facebook
From Buff Plover, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 133
  1. // ==UserScript==
  2. // @name         Tribalwars sniper
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Tribalwars sniper
  6. // @author       Doomness
  7. // @match        *.plemiona.pl/game.php?village=*&screen=place&try=confirm
  8. // @grant        none
  9. // @require      http://code.jquery.com/jquery-latest.js
  10. // @require      http://cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js
  11. // @run-at       document-end
  12. // ==/UserScript==
  13.  
  14. $(document).ready(function(){
  15.  
  16.         $("head").append('<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.css">')
  17.         $($("table.vis")[0]).append(
  18.                 '<p style="margin-top:5px; margin-bottom:0px;">Time of arrival:</p>' +
  19.                 '<input class="timepicker" style="margin-top:5px; font-size: 13px;">'+
  20.                 '<input type="text" class="milidelay" placeholder="miliseconds delay" style="margin-top:5px; font-size: 13px;">'+
  21.                 '<input id="snipebtn" type="button" class="btn" value="Snipe" style="width:100px; margin-top:3px;">'
  22.         );
  23.  
  24.         $("input.timepicker").timepicker(
  25.                 {
  26.                         timeFormat: 'HH:mm:ss',
  27.                         minTime: '00:00:00',
  28.                         maxTime: '23:59:59',
  29.                         defaultTime: '00:00:00',
  30.                         dynamic: false,
  31.                         dropdown: false,
  32.                         scrollbar: false
  33.                 });
  34.         $("input#snipebtn").click(function(){
  35.                 console.log('Snipe timed at: '+ $("input.timepicker").val() +':'+ parseInt($("input.milidelay").val()));
  36.                 $("input#snipebtn").parent().append('<p style="margin-bottom:0px; font-size:13px;"> Snipe time set: ' + $("input.timepicker").val() +':'+ parseInt($("input.milidelay").val()) +'</p>');
  37.                 snipeTimer()
  38.         });
  39.         $("input.troop_confirm_go").on('click', () => {storeTime();});
  40. })
  41.  
  42. function snipeTimer(){
  43.         if($("span.relative_time").text().indexOf($("input.timepicker").val()) >= 0){
  44.                 setTimeout(function() {
  45.                         $("input.troop_confirm_go").click();
  46.                 }, parseInt($("input.milidelay").val()));
  47.         } else {
  48.                 setTimeout(snipeTimer, 10);
  49.         }
  50. }
  51.  
  52. function storeTime(){
  53.         var orders = JSON.parse(sessionStorage.getItem("storedTime"));
  54.         if(orders == null){
  55.                 orders = [];
  56.         }
  57.         var orderObject = {
  58.                 startCoords : $("#menu_row2").find("b.nowrap").text(),
  59.                 startTime : $("span#serverTime").text(),
  60.                 endTime : $("span.relative_time").text().substring($("span.relative_time").text().length - 9, 8),
  61.                 destination : $("span.village_anchor.contexted").find("a").first().text()
  62.         }
  63.         orders.push(orderObject);
  64.         sessionStorage.setItem("storedTime", JSON.stringify(orders));
  65. }