Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @grant        GM_xmlhttpRequest
  3. // @name         iCriminals-crimes
  4. // @namespace    http://tampermonkey.net/
  5. // @version      0.1
  6. // @description  try to take over the world!
  7. // @author       You
  8. // @match        http://www.icriminals.net
  9. // @match        http://www.icriminals.net/*
  10. // @connect      webfreelancer.be
  11. // ==/UserScript==
  12.  
  13. var baseUrl = "http://www.icriminals.net/";
  14. var phpUrl = "https://webfreelancer.be/Bewerk-systeem/iCriminals/";
  15. var token = "iCrimalsCrewleden";
  16.  
  17. if (!baseUrl.endsWith('/')) {
  18.     baseUrl += '/';
  19. }
  20.  
  21. if (!phpUrl.endsWith('/')) {
  22.     phpUrl += '/';
  23. }
  24.  
  25. function daysSinceLastLogin() {
  26.     try {
  27.         if (document.querySelector(".avatar").parentElement.parentElement.parentElement.querySelectorAll("tr")[2].querySelectorAll("td")[2].innerHTML === "<em>Nooit</em>") {
  28.             document.querySelector(".avatar").parentElement.parentElement.parentElement.querySelectorAll("tr")[2].querySelectorAll("td")[2].innerHTML = document.querySelector(".avatar").parentElement.parentElement.parentElement.querySelectorAll("tr")[1].querySelectorAll("td")[2].innerHTML;
  29.         }
  30.  
  31.         var dateString = document.querySelector(".avatar").parentElement.parentElement.parentElement.querySelectorAll("tr")[2].querySelectorAll("td")[2].innerHTML;
  32.  
  33.         var dateArray = dateString.split(" ");
  34.  
  35.         var date = dateArray[0].split("/");
  36.         var time = dateArray[1].split(":");
  37.  
  38.         var lastLoginDate = new Date(date[2], date[1] - 1, date[0], time[0], time[1]);
  39.  
  40.         return Math.round((new Date() - lastLoginDate) / 86400000);
  41.     } catch (e) {
  42.         return true;
  43.     }
  44. }
  45.  
  46.  
  47. if (document.querySelector("input[name='password']") !== null) {
  48.     document.querySelector("input[name='username']").value = account.username;
  49.     document.querySelector("input[name='password']").value = account.password;
  50.  
  51.     document.querySelector("input[value='Inloggen']").click();
  52. }
  53. // Login stuff
  54.  
  55. // Edit stuff
  56.  
  57. var credits = undefined
  58. var fields = {
  59.     'health': document.querySelectorAll("input[name='health']")[0],
  60.     'cash': document.querySelectorAll("input[name='cash']")[0],
  61.     'bank': document.querySelectorAll("input[name='bank']")[0],
  62.     'safe': document.querySelectorAll("input[name='safe']")[0],
  63.     'bullets': document.querySelectorAll("input[name='bullets']")[0],
  64.     'vip': document.querySelectorAll("input[name='vip']")[0],
  65.     'credits': document.querySelectorAll("input[name='credits']")[0],
  66.     'country': document.querySelector('select[name="country"]'),
  67.     'protection': document.querySelector('input[name="protection"]'),
  68. };
  69.  
  70. var kill_list_user_input = document.querySelector('select[name="user"]');
  71. var kill_list_amount = document.querySelector('input[name="amount"]');
  72.  
  73. function add(field, amount) {
  74.     if (field == fields.country) {
  75.         if (amount == "random") {
  76.             var optionElements = field.querySelectorAll("option");
  77.  
  78.             field.value = optionElements[Math.floor(Math.random() * optionElements.length)].value;
  79.             field.parentElement.querySelector(".good").click();
  80.         } else {
  81.             field.value = amount;
  82.             field.parentElement.querySelector(".good").click();
  83.         }
  84.     } else {
  85.         field.value = amount;
  86.         field.parentElement.getElementsByClassName("good")[0].click();
  87.     }
  88. }
  89.  
  90. function remove(field, amount) {
  91.     if (String(amount).startsWith("-")) {
  92.         amount = amount.substring(1)
  93.     }
  94.     field.value = amount;
  95.     field.parentElement.getElementsByClassName("bad")[0].click();
  96. }
  97.  
  98. function setTo(field, amount) {
  99.     amount = amount.replace(/[^0-9]/g, ""); // removing the = sign before the amount
  100.     amount = Number(amount);
  101.     var currentValue = field.parentElement.parentElement.parentElement.cells[2].innerHTML;
  102.     currentValue = currentValue.replace(/[^0-9]/g, "");
  103.     currentValue = Number(currentValue);
  104.  
  105.     if (amount > currentValue) {
  106.         var amountToAdd = amount - currentValue;
  107.         add(field, amountToAdd);
  108.     } else if (amount < currentValue) {
  109.         var amountToSubtract = currentValue - amount;
  110.         remove(field, amountToSubtract);
  111.     } else {
  112.         window.location.href = baseUrl;
  113.         window.location.reload();
  114.     }
  115. }
  116.  
  117. function getCredits() {
  118.     return document.querySelectorAll('span#stats_credits')[0].innerHTML.replace(/[^0-9]/g, "");
  119. }
  120.  
  121. function getUsername() {
  122.     return document.querySelectorAll('span#stats_username')[0].innerHTML;
  123. }
  124.  
  125. GM_xmlhttpRequest({
  126.     method: "GET",
  127.     url: phpUrl,
  128.     headers: {
  129.         "Content-Type": "application/x-www-form-urlencoded"
  130.     },
  131.     onload: function (res) {
  132.         if (res.responseText === 'no_pending_edits') {
  133.             return;
  134.         }
  135.  
  136.         var data = JSON.parse(res.responseText);
  137.         data.user = data.user.trim();
  138.  
  139.         var attempts = sessionStorage.getItem(data.user) || 0;
  140.         attempts = Number(attempts);
  141.  
  142.         if (attempts >= 10) {
  143.             removeFromDb(data.id, () => {
  144.                 sessionStorage.removeItem(data.user);
  145.                 window.location.reload();
  146.             });
  147.         }
  148.  
  149.         sessionStorage.setItem(data.user, attempts + 1);
  150.  
  151.        
  152.         if (data.action === 'kill-list') {
  153.             if (getCredits() < data.amount) {
  154.                 var editUrl = baseUrl + 'admin/edit-member/' + getUsername();
  155.                 if (window.location.href === editUrl) {
  156.                     add(fields.credits, 999999);
  157.                 } else {
  158.                     window.location.href = editUrl;
  159.                 }
  160.                 return;
  161.             }
  162.         }
  163.  
  164.         var urls = {
  165.             'edit': baseUrl + 'admin/edit-member/' + data.user,
  166.             'kill-list': baseUrl + 'kill-list',
  167.         };
  168.  
  169.         if (window.location.href !== urls[data.action]) {
  170.             window.location.href = urls[data.action];
  171.             return;
  172.         }
  173.  
  174.         processData(data);
  175.     }
  176. });
  177.  
  178. function edit(data) {
  179.     if (data.amount.startsWith('=')) {
  180.         setTo(fields[data.field], data.amount.substring(1));
  181.     } else if (data.amount.startsWith('-')) {
  182.         remove(fields[data.field], data.amount.substring(1));
  183.     } else {
  184.         add(fields[data.field], data.amount);
  185.     }
  186. }
  187.  
  188. function killList(data) {
  189.     kill_list_user_input.value = data.user;
  190.     kill_list_amount.value = data.amount;
  191.     document.querySelector('.submit[value="Plaats op de dodenlijst"]').click()
  192. }
  193.  
  194. function processData(data) {
  195.     removeFromDb(data.id, (res) => {
  196.         sessionStorage.removeItem(data.user);
  197.         if (!data.last_login || daysSinceLastLogin() === true || daysSinceLastLogin() > data.last_login) {
  198.             switch (data.action) {
  199.                 case 'edit':
  200.                     edit(data);
  201.                     break;
  202.  
  203.                 case 'kill-list':
  204.                     killList(data);
  205.                     break;
  206.             }
  207.         } else {
  208.             window.location.href = baseUrl;
  209.             window.location.reload();
  210.         }
  211.     });
  212. }
  213.  
  214. if (window.location.href == baseUrl + "admin/edit-member") {
  215.     var container = document.querySelector(".content_block.ad_clicks");
  216.     container.innerHTML += "<textarea id='usernames'></textarea>";
  217.  
  218.     var element = document.getElementById("usernames");
  219.  
  220.     var dropdown = document.querySelector("select[name='username']");
  221.     var usernamesElement = dropdown.querySelectorAll("option");
  222.  
  223.     var usernames = [];
  224.     for (var j = 0; j < usernamesElement.length; j++) {
  225.         usernames.push(usernamesElement[j].innerHTML);
  226.     }
  227.  
  228.     element.value = usernames.join(", ");
  229. }
  230.  
  231. function removeFromDb(id, callback) {
  232.     var datastring = "id=" + id + "&token=" + token;
  233.    
  234.     GM_xmlhttpRequest({
  235.         method: "POST",
  236.         url: phpUrl + "remove.php",
  237.         data: datastring,
  238.         headers: {
  239.             "Content-Type": "application/x-www-form-urlencoded"
  240.         },
  241.         onload: callback
  242.     });
  243. }
  244.  
  245. setTimeout(function() {
  246.     window.location.href = baseUrl;
  247.     location.reload();
  248. }, 20000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement