Daveriser
Apr 2nd, 2024
58
0
Never
This is comment for paste Warpcast qoutes raffle script
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Constants for configurable values
  2. const MAX_ELEMENTS = 100;
  3. const REMOVAL_TEXT = "@daveriser";
  4.  
  5. // Array to store text
  6. var textArray = [];
  7.  
  8. // Select all elements with the class .shrink
  9. var shrinkElements = document.querySelectorAll('.shrink');
  10.  
  11. // Iterate over each element
  12. shrinkElements.forEach(function(element) {
  13. // Get the second <span> element within the current element
  14. var secondSpan = element.children[1];
  15.  
  16. // Check if secondSpan exists and contains an <a> tag
  17. if (secondSpan && secondSpan.querySelector('a')) {
  18. // Get the text content inside the <a> tag inside the second <span>
  19. var text = secondSpan.querySelector('a').textContent;
  20.  
  21. // Remove certain element based on text content
  22. if (text !== REMOVAL_TEXT) {
  23. // Add text to array if it's not already present
  24. if (!textArray.includes(text)) {
  25. textArray.push(text);
  26. }
  27. } else {
  28. // Remove the element from the DOM
  29. element.remove();
  30. }
  31. }
  32. });
  33.  
  34. // Remove duplicates by converting array to set and back to array
  35. textArray = Array.from(new Set(textArray));
  36.  
  37. // Shuffle the array
  38. textArray.sort(() => Math.random() - 0.5);
  39.  
  40. // Keep only the first MAX_ELEMENTS elements if there are more than MAX_ELEMENTS
  41. textArray = textArray.slice(0, MAX_ELEMENTS);
  42.  
  43. // If there are less than MAX_ELEMENTS elements, continue adding unique elements until it reaches MAX_ELEMENTS
  44. while (textArray.length < MAX_ELEMENTS) {
  45. var uniqueText = getRandomUniqueText();
  46. if (!textArray.includes(uniqueText)) {
  47. textArray.push(uniqueText);
  48. }
  49. }
  50.  
  51. // Function to generate a random unique text
  52. function getRandomUniqueText() {
  53. // Example: Generate a random string
  54. return "RandomUniqueText" + Math.floor(Math.random() * 100000);
  55. }
  56.  
  57. // Combine all texts together with space
  58. var combinedText = textArray.join(' ');
  59.  
  60. // Output the combined text
  61. console.log(combinedText);
  62.  
Advertisement
Add Comment
Please, Sign In to add comment