Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name SpamBot
- // @namespace Violentmonkey Scripts
- // @grant none
- // @include *.e-sim.org/composeMessage.html*
- // ==/UserScript==
- //
- //
- 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]';
- var titlePL = 'Nowy serwer wystartowal!';
- 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]';
- var titleENG = 'Invitation';
- var minLvl = 6;
- // DO NOT CHANGE
- var id;
- var interval;
- var working = false;
- $(document).ready(function() {
- id = getLatestPlayerId();
- addDomElements();
- $('#spambotBtn').click(function() {
- if(working)
- {
- stop();
- }
- else
- {
- start();
- }
- });
- });
- var msgHandler = function() {
- clearInterval(interval);
- var playerInfo = getPlayerInfo(id--);
- if (playerInfo.status == "active" && playerInfo.level > minLvl) {
- if (playerInfo.citizenshipId == 1) {
- sendMessage(playerInfo.login, titlePL, msgBodyPL);
- } else {
- sendMessage(playerInfo.login, titleENG, msgBodyENG);
- }
- console.info("Timeout set: 10s");
- setTimeout(msgHandler, 10000)
- } else {
- interval = setInterval(msgHandler, 300);
- }
- };
- function start(){
- console.info("Spambot started");
- working = true;
- $('#spambotBtn').text("Stop!");
- interval = setInterval(msgHandler, 300);
- }
- function stop(){
- console.info("Spambot stopped");
- working = false;
- $('#spambotBtn').text("Start!");
- clearInterval(interval);
- }
- function addDomElements() {
- 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>');
- $('body').append(backgroundDiv);
- backgroundDiv.append('<button type="button" id="spambotBtn" value="Spambot" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">Start!</button>');
- }
- function getPlayerInfo(id) {
- var userInfo;
- $.ajax({type: "GET", dataType: "json", async: false, url: "/apiCitizenById.html?id=" + id, success: function(data) {
- userInfo = data;
- }
- });
- console.info("Checking: " + userInfo.login + ", citizenshipId: " + userInfo.citizenshipId + ", id: " + id + ", level: " + userInfo.level);
- return userInfo;
- }
- function sendMessage(name, title, body) {
- $.post('/composeMessage.html', {
- receiverName: name,
- title: title,
- body: body,
- action: 'REPLY'
- }).done(function() {
- console.info("Message sent to: " + name);
- });
- }
- /*
- * UNUSED
- */
- function sleep(ms) {
- var unixtime_ms = new Date().getTime();
- while (new Date().getTime() < unixtime_ms + ms) {}
- }
- function getLatestPlayerId() {
- var pageContent;
- $.ajax({type: "GET", dataType: "html", async: false, url: "/newCitizens.html?countryId=0", success: function(html) {
- pageContent = html;
- }
- });
- var domElements = $.parseHTML(pageContent);
- var rows = $("[class*='dataTable'] tr", domElements);
- rows = rows.slice(1, rows.length);
- var cell = $("td", rows[0]);
- return parseInt($('a', cell[0]).attr('href').replace('profile.html?id=', ''));
- }
Advertisement
Add Comment
Please, Sign In to add comment