Tw100

snip xpto orignil

Sep 6th, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Script Snipe
  3. // @match ://*.tribalwars.com.pt/*&screen=place*&try=confirm
  4. // @grant none
  5. // ==/UserScript==
  6.  
  7. CommandSender = {
  8. confirmButton: null,
  9. duration: null,
  10. dateNow: null,
  11. offset: null,
  12. init: function() {
  13. $($('#command-data-form').find('tbody')[0]).append('<tr><td>Chegada:</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">Confirmar</button> </td></tr>');
  14. this.confirmButton = $('#troop_confirm_go');
  15. this.duration = $('#command-data-form').find('td:contains("Duração:")').next().text().split(':').map(Number);
  16. this.offset = localStorage.getItem('CS.offset') || -250;
  17. this.dateNow = this.convertToInput(new Date());
  18. $('#CSoffset').val(this.offset);
  19. $('#CStime').val(this.dateNow);
  20. $('#CSbutton').click(function() {
  21. var offset = Number($('#CSoffset').val());
  22. var attackTime = CommandSender.getAttackTime();
  23. localStorage.setItem('CS.offset', offset);
  24. CommandSender.confirmButton.addClass('btn-disabled');
  25. setTimeout(function() {
  26. CommandSender.confirmButton.click();
  27. },attackTime-Timing.getCurrentServerTime()+offset);
  28. this.disabled = true;
  29. });
  30. },
  31. getAttackTime: function() {
  32. var d = new Date($('#CStime').val().replace('T',' '));
  33. d.setHours(d.getHours()-this.duration[0]);
  34. d.setMinutes(d.getMinutes()-this.duration[1]);
  35. d.setSeconds(d.getSeconds()-this.duration[2]);
  36. return d;
  37. },
  38. convertToInput: function(t) {
  39. t.setHours(t.getHours()+this.duration[0]);
  40. t.setMinutes(t.getMinutes()+this.duration[1]);
  41. t.setSeconds(t.getSeconds()+this.duration[2]);
  42. var a = {
  43. y: t.getFullYear(),
  44. m: t.getMonth() + 1,
  45. d: t.getDate(),
  46. time: t.toTimeString().split(' ')[0],
  47. ms: t.getMilliseconds()
  48. };
  49. if (a.m < 10) {
  50. a.m = '0' + a.m;
  51. }
  52. if (a.d < 10) {
  53. a.d = '0' + a.d;
  54. }
  55. if (a.ms < 100) {
  56. a.ms = '0' + a.ms;
  57. if (a.ms < 10) {
  58. a.ms = '0' + a.ms;
  59. }
  60. }
  61. return a.y + '-' + a.m + '-' + a.d + 'T' + a.time + '.' + a.ms;
  62. },
  63. addGlobalStyle: function(css) {
  64. var head, style;
  65. head = document.getElementsByTagName('head')[0];
  66. if (!head) { return; }
  67. style = document.createElement('style');
  68. style.type = 'text/css';
  69. style.innerHTML = css;
  70. head.appendChild(style);
  71. }
  72. };
  73. CommandSender.addGlobalStyle('#CStime, #CSoffset {font-size: 9pt;font-family: Verdana,Arial;}#CSbutton {float:right;}');
  74. var a = setInterval(function(){
  75. if (document.getElementById('command-data-form') && jQuery) {
  76. CommandSender.init();
  77. clearInterval(a);
  78. }
  79. },1); // faster load
Add Comment
Please, Sign In to add comment