Advertisement
Guest User

Post Randomizer v2

a guest
Apr 9th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const stringArray = ["jan paweł 2", "tomasz terka","twój stary", "kosior", "testo"];
  2.  
  3. const button = document.createElement("button");
  4. button.innerHTML = "Losuj";
  5. button.classList.add("ladda-button");
  6. button.setAttribute('type', 'button');
  7.  
  8. const fastForm = document.querySelector("#fastReplyButtons-tr");
  9. fastForm.appendChild(button);
  10.  
  11. const textArea = document.querySelector(".blockquoteReply div textarea");
  12.  
  13. const randomize = (event) => {
  14.   const randomText = stringArray[Math.floor(Math.random()*stringArray.length)];
  15.   const target = event.target || event.srcElement;
  16.   textArea.value += randomText || target.innerText;
  17. };
  18.  
  19. button.addEventListener ("click", function() {
  20.   randomize(event);
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement