Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
129
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.         reload();
  113.     }
  114. }
  115.  
  116. function getCredits() {
  117.     return document.querySelectorAll('span#stats_credits')[0].innerHTML.replace(/[^0-9]/g, "");
  118. }
  119.  
  120. function getUsername() {
  121.     return document.querySelectorAll('span#stats_username')[0].innerHTML;
  122. }
  123.  
  124. GM_xmlhttpRequest({
  125.     method: "GET",
  126.     url: phpUrl,
  127.     headers: {
  128.         "Content-Type": "application/x-www-form-urlencoded"
  129.     },
  130.     onload: function (res) {
  131.         if (res.responseText === 'no_pending_edits') {
  132.             return;
  133.         }
  134.  
  135.         var data = JSON.parse(res.responseText);
  136.         data.user = data.user.trim();
  137.  
  138.         var attempts = sessionStorage.getItem(data.user) || 0;
  139.         attempts = Number(attempts);
  140.  
  141.         if (attempts >= 10) {
  142.             removeFromDb(data.id, () => {
  143.                 sessionStorage.removeItem(data.user);
  144.                 reload();
  145.             });
  146.         }
  147.  
  148.         sessionStorage.setItem(data.user, attempts + 1);
  149.  
  150.        
  151.         if (data.action === 'kill-list') {
  152.             if (getCredits() < data.amount) {
  153.                 var editUrl = baseUrl + 'admin/edit-member/' + getUsername();
  154.                 if (window.location.href === editUrl) {
  155.                     add(fields.credits, 999999);
  156.                 } else {
  157.                     window.location.href = editUrl;
  158.                 }
  159.                 return;
  160.             }
  161.         }
  162.  
  163.         var urls = {
  164.             'edit': baseUrl + 'admin/edit-member/' + data.user,
  165.             'kill-list': baseUrl + 'kill-list',
  166.         };
  167.  
  168.         if (window.location.href !== urls[data.action]) {
  169.             window.location.href = urls[data.action];
  170.             return;
  171.         }
  172.  
  173.         processData(data);
  174.     }
  175. });
  176.  
  177. function edit(data) {
  178.     if (data.amount.startsWith('=')) {
  179.         setTo(fields[data.field], data.amount.substring(1));
  180.     } else if (data.amount.startsWith('-')) {
  181.         remove(fields[data.field], data.amount.substring(1));
  182.     } else {
  183.         add(fields[data.field], data.amount);
  184.     }
  185. }
  186.  
  187. function killList(data) {
  188.     kill_list_user_input.value = data.user;
  189.     kill_list_amount.value = data.amount;
  190.     document.querySelector('.submit[value="Plaats op de dodenlijst"]').click()
  191. }
  192.  
  193. function processData(data) {
  194.     removeFromDb(data.id, (res) => {
  195.         sessionStorage.removeItem(data.user);
  196.         if (!data.last_login || daysSinceLastLogin() === true || daysSinceLastLogin() > data.last_login) {
  197.             switch (data.action) {
  198.                 case 'edit':
  199.                     edit(data);
  200.                     break;
  201.  
  202.                 case 'kill-list':
  203.                     killList(data);
  204.                     break;
  205.             }
  206.         } else {
  207.             window.location.href = baseUrl;
  208.             reload();
  209.         }
  210.     });
  211. }
  212.  
  213. if (window.location.href == baseUrl + "admin/edit-member") {
  214.     var container = document.querySelector(".content_block.ad_clicks");
  215.     container.innerHTML += "<textarea id='usernames'></textarea>";
  216.  
  217.     var element = document.getElementById("usernames");
  218.  
  219.     var dropdown = document.querySelector("select[name='username']");
  220.     var usernamesElement = dropdown.querySelectorAll("option");
  221.  
  222.     var usernames = [];
  223.     for (var j = 0; j < usernamesElement.length; j++) {
  224.         usernames.push(usernamesElement[j].innerHTML);
  225.     }
  226.  
  227.     element.value = usernames.join(", ");
  228. }
  229.  
  230. function removeFromDb(id, callback) {
  231.     var datastring = "id=" + id + "&token=" + token;
  232.    
  233.     GM_xmlhttpRequest({
  234.         method: "POST",
  235.         url: phpUrl + "remove.php",
  236.         data: datastring,
  237.         headers: {
  238.             "Content-Type": "application/x-www-form-urlencoded"
  239.         },
  240.         onload: callback
  241.     });
  242. }
  243.  
  244. setTimeout(reload, 20000);
  245.  
  246. function reload() {
  247.     if (window.location.href === baseUrl) {
  248.         window.location.reload();
  249.     } else {
  250.         window.location.href = baseUrl;
  251.     }
  252. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement