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