Facebook
From widerr, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 222
  1. // ==UserScript==
  2. // https://www.mpcforum.pl/topic/1608138-ataki-w-ms-kliny-szukam/
  3. // @name         CommandSender
  4. // @version      0.1c
  5. // @author       Couiz
  6. // @match        https://*.plemiona.pl/*&screen=place*&try=confirm*
  7. // @grant        none
  8. // @run-at       document-start
  9. // @updateURL    https://raw.githubusercontent.com/Couiz/TribalWars/master/CommandSender/CommandSender.js
  10. // @downloadURL  https://raw.githubusercontent.com/Couiz/TribalWars/master/CommandSender/CommandSender.js
  11. // ==/UserScript==
  12.  
  13. CommandSender = {
  14.         confirmButton: null,
  15.         duration: null,
  16.         dateNow: null,
  17.         offset: null,
  18.         init: function() {
  19.                 $($('#command-data-form').find('tbody')[0]).append('<tr><td>Przybycie:</td><td> <input type="datetime-local" id="CStime" step=".001"> </td></tr><tr> <td>Offset:</td><td> <input type="number" id="CSoffset"> <button type="button" id="CSbutton" class="btn">PotwierdĹş</button> </td></tr>');
  20.                 this.confirmButton = $('#troop_confirm_go');
  21.                 this.duration = $('#command-data-form').find('td:contains("Trwanie:")').next().text().split(':').map(Number);
  22.                 this.offset = localStorage.getItem('CS.offset') || -250;
  23.                 this.dateNow = this.convertToInput(new Date());
  24.                 $('#CSoffset').val(this.offset);
  25.                 $('#CStime').val(this.dateNow);
  26.                 $('#CSbutton').click(function() {
  27.                         var offset = Number($('#CSoffset').val());
  28.                         var attackTime = CommandSender.getAttackTime();
  29.                         localStorage.setItem('CS.offset', offset);
  30.                         CommandSender.confirmButton.addClass('btn-disabled');
  31.                         setTimeout(function() {
  32.                                 CommandSender.confirmButton.click();
  33.                         },attackTime-Timing.getCurrentServerTime()+offset);
  34.                         this.disabled = true;
  35.                 });
  36.         },
  37.         getAttackTime: function() {
  38.                 var d = new Date($('#CStime').val().replace('T',' '));
  39.                 d.setHours(d.getHours()-this.duration[0]);
  40.                 d.setMinutes(d.getMinutes()-this.duration[1]);
  41.                 d.setSeconds(d.getSeconds()-this.duration[2]);
  42.                 return d;
  43.         },
  44.         convertToInput: function(t) {
  45.                 t.setHours(t.getHours()+this.duration[0]);
  46.                 t.setMinutes(t.getMinutes()+this.duration[1]);
  47.                 t.setSeconds(t.getSeconds()+this.duration[2]);
  48.                 var a = {
  49.                         y: t.getFullYear(),
  50.                         m: t.getMonth() + 1,
  51.                         d: t.getDate(),
  52.                         time: t.toTimeString().split(' ')[0],
  53.                         ms: t.getMilliseconds()
  54.                 };
  55.                 if (a.m < 10) {
  56.                         a.m = '0' + a.m;
  57.                 }
  58.                 if (a.d < 10) {
  59.                         a.d = '0' + a.d;
  60.                 }
  61.                 if (a.ms < 100) {
  62.                         a.ms = '0' + a.ms;
  63.                         if (a.ms < 10) {
  64.                                 a.ms = '0' + a.ms;
  65.                         }
  66.                 }
  67.                 return a.y + '-' + a.m + '-' + a.d + 'T' + a.time + '.' + a.ms;
  68.         },
  69.         addGlobalStyle: function(css) {
  70.                 var head, style;
  71.             head = document.getElementsByTagName('head')[0];
  72.             if (!head) { return; }
  73.             style = document.createElement('style');
  74.             style.type = 'text/css';
  75.             style.innerHTML = css;
  76.             head.appendChild(style);
  77.         }
  78. };
  79. CommandSender.addGlobalStyle('#CStime, #CSoffset {font-size: 9pt;font-family: Verdana,Arial;}#CSbutton {float:right;}');
  80. var a = setInterval(function(){
  81.         if (document.getElementById('command-data-form') && jQuery) {
  82.                 CommandSender.init();
  83.                 clearInterval(a);
  84.         }
  85. },1); // faster load
  86. document.addEventListener('DOMContentLoaded', function(){
  87.         $('.server_info').prepend('<span style="float:left" >CommandSender Coded by: Couiz ([email protected])</span>');
  88. });// ==UserScript==
  89. // @name New Script
  90. // @namespace Violentmonkey Scripts
  91. // @grant none
  92. // ==/UserScript==