WhatsApp Web Spammer

Spam people with this beautiful WhatsApp Web spammer.

  1. // ==UserScript==
  2. // @name WhatsApp Web Spammer
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.55
  5. // @description Spam people with this beautiful WhatsApp Web spammer.
  6. // @author Dan6erbond
  7. // @match https://web.whatsapp.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. var repeatingSpamFunction = null;
  12. var repeatingCreateSpamButtonFunction = null;
  13. var message = '';
  14.  
  15. function getElementByXpath(path) {
  16. return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  17. }
  18.  
  19. document.onclick = function(){
  20. createSpamButton();
  21. };
  22.  
  23. function createSpamButton () {
  24. if(document.getElementById('spamButton') != null)
  25. return;
  26. var composeBar = getElementByXpath("//*[@id=\"main\"]/footer/div[1]");
  27. if(composeBar == null)
  28. return;
  29. composeBar.oninput = function(){
  30. editSpamButton();
  31. };
  32. var spamButton = document.createElement('button');
  33. spamButton.setAttribute("id", "spamButton");
  34. spamButton.innerHTML = 'SPAM';
  35. spamButton.style.fontSize = '100%';
  36. spamButton.style.padding = '0px 0px 10px 10px';
  37. composeBar.append(spamButton);
  38. editSpamButton();
  39. }
  40.  
  41. function sendMessage () {
  42. var evt = new Event('input', {
  43. bubbles: true
  44. });
  45.  
  46. var input = getElementByXpath("//*[@id=\"main\"]/footer/div[1]/div[2]/div/div[2]");
  47. input.innerHTML = message;
  48. input.dispatchEvent(evt);
  49.  
  50. getElementByXpath("//*[@id=\"main\"]/footer/div[1]/div[3]/button").click();
  51. }
  52.  
  53. function doSpam(element) {
  54. if(element.innerHTML == 'SPAM'){
  55. var input = getElementByXpath("//*[@id=\"main\"]/footer/div[1]/div[2]/div/div[2]");
  56. if(input.innerHTML == '' || input.innerHTML == null){
  57. window.alert('Please Enter a Text to be spammed before using the spam button.');
  58. return;
  59. }
  60. element.innerHTML = 'STOP';
  61. message = input.innerHTML;
  62. var interval = parseInt (prompt('Please enter spam-interval:', '500'));
  63. repeatingSpamFunction = window.setInterval(function(){
  64. sendMessage();
  65. }, interval);
  66. } else {
  67. element.innerHTML = 'SPAM';
  68. window.clearInterval(repeatingSpamFunction);
  69. }
  70. editSpamButton();
  71. }
  72.  
  73. function editSpamButton(){
  74. var spamButton = document.getElementById('spamButton');
  75. var input = getElementByXpath("//*[@id=\"main\"]/footer/div[1]/div[2]/div/div[2]");
  76. if(input.innerHTML == '' || input.innerHTML == null){
  77. spamButton.style.cursor = 'not-allowed';
  78. spamButton.style.color = '#D3D3D3';
  79. spamButton.onclick = null;
  80. } else {
  81. spamButton.style.cursor = 'pointer';
  82. spamButton.style.color = '#039be5';
  83. spamButton.onclick = function(){
  84. doSpam(this);
  85. };
  86. }
  87. }