Dzejkobini

SZPAMBOT

Jan 19th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name SpamBot
  3. // @namespace Violentmonkey Scripts
  4. // @grant none
  5. // @include *.e-sim.org/composeMessage.html*
  6. // ==/UserScript==
  7. //
  8. //
  9. var msgBodyPL = 'Mam przyjemnosc zaprosic Cie na calkiem NOWY serwer e-sim: [url=http://goo.gl/SZ7AbJ]Maxima[/url]\n\n[b]Dolacz do nas juz dzis![/b]';
  10. var titlePL = 'Nowy serwer wystartowal!';
  11.  
  12. var msgBodyENG = 'We are pleased to say that an MAXIMA SERVER has seen the light of a day! In the nearest days there is an unusual opportunity to start play e-Sim afresh!\n\n[b][url=http://goo.gl/SZ7AbJ]Join us today![/url][/b]';
  13. var titleENG = 'Invitation';
  14.  
  15. var minLvl = 6;
  16.  
  17. // DO NOT CHANGE
  18. var id;
  19. var interval;
  20. var working = false;
  21.  
  22. $(document).ready(function() {
  23.     id = getLatestPlayerId();
  24.     addDomElements();
  25.     $('#spambotBtn').click(function() {
  26.         if(working)
  27.         {
  28.             stop();
  29.         }
  30.         else
  31.         {
  32.             start();
  33.         }
  34.     });
  35. });
  36.    
  37. var msgHandler = function() {
  38.     clearInterval(interval);
  39.     var playerInfo = getPlayerInfo(id--);
  40.     if (playerInfo.status == "active" && playerInfo.level > minLvl) {
  41.         if (playerInfo.citizenshipId == 1) {
  42.             sendMessage(playerInfo.login, titlePL, msgBodyPL);
  43.         } else {
  44.             sendMessage(playerInfo.login, titleENG, msgBodyENG);
  45.         }
  46.         console.info("Timeout set: 10s");
  47.         setTimeout(msgHandler, 10000)
  48.     } else {
  49.         interval = setInterval(msgHandler, 300);
  50.     }
  51.  
  52. };
  53.  
  54. function start(){
  55.     console.info("Spambot started");
  56.     working = true;
  57.     $('#spambotBtn').text("Stop!");
  58.     interval = setInterval(msgHandler, 300);
  59. }
  60.  
  61. function stop(){
  62.     console.info("Spambot stopped");
  63.     working = false;
  64.     $('#spambotBtn').text("Start!");
  65.     clearInterval(interval);
  66. }  
  67.  
  68. function addDomElements() {
  69.     var backgroundDiv = $('<div style="position: fixed; top: 100px; right: 100px; z-index: 9999; width: 100px; height: 100px; background-color: #cacaca; border: solid 2px #717171; border-radius: 10px; text-align: center;"></div>');
  70.     $('body').append(backgroundDiv);
  71.     backgroundDiv.append('<button type="button" id="spambotBtn" value="Spambot" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">Start!</button>');
  72. }
  73.  
  74. function getPlayerInfo(id) {
  75.  
  76.     var userInfo;
  77.  
  78.     $.ajax({type: "GET", dataType: "json", async: false, url: "/apiCitizenById.html?id=" + id, success: function(data) {
  79.             userInfo = data;
  80.         }
  81.     });
  82.     console.info("Checking: " + userInfo.login + ", citizenshipId: " + userInfo.citizenshipId + ", id: " + id + ", level: " + userInfo.level);
  83.     return userInfo;
  84.  
  85. }
  86.  
  87. function sendMessage(name, title, body) {
  88.     $.post('/composeMessage.html', {
  89.         receiverName: name,
  90.         title: title,
  91.         body: body,
  92.         action: 'REPLY'
  93.     }).done(function() {
  94.         console.info("Message sent to: " + name);
  95.     });
  96. }
  97.  
  98. /*
  99. * UNUSED
  100. */
  101. function sleep(ms) {
  102.     var unixtime_ms = new Date().getTime();
  103.     while (new Date().getTime() < unixtime_ms + ms) {}
  104. }
  105.  
  106. function getLatestPlayerId() {
  107.     var pageContent;
  108.     $.ajax({type: "GET", dataType: "html", async: false, url: "/newCitizens.html?countryId=0", success: function(html)  {
  109.             pageContent = html;
  110.         }
  111.     });
  112.     var domElements = $.parseHTML(pageContent);
  113.     var rows = $("[class*='dataTable'] tr", domElements);
  114.     rows = rows.slice(1, rows.length);
  115.     var cell = $("td", rows[0]);
  116.     return parseInt($('a', cell[0]).attr('href').replace('profile.html?id=', ''));
  117. }
Advertisement
Add Comment
Please, Sign In to add comment