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