Advertisement
Guest User

Untitled

a guest
Oct 31st, 2022
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. // ==UserScript==
  2. // @name FascistUpvoterForReddit
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Up votes ukranian fascists on Reddit
  6. // @author APorechaev
  7. // @license MIT
  8. // @match https://www.reddit.com/r/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com
  10. // @homepageURL https://pastebin.com/raw/uURnmb25
  11. // @downloadURL https://pastebin.com/raw/uURnmb25
  12. // @updateURL https://pastebin.com/raw/uURnmb25
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18. console.log('FascistUpvoterForReddit has started');
  19. function upvoteFascists(document) {
  20. [...document.querySelectorAll('[data-testid=comment]')]
  21. .filter((elm) => elm.innerText.match(/(slava ukrain)|(слава украине)|(glory to ukraine)/gi))
  22. .forEach((fascistComment) => {
  23. const fascistName = fascistComment.parentElement.querySelector('a[data-testid=comment_author_link]');
  24. console.log(`a fascist has been found ${fascistName}`);
  25. fascistComment.parentElement.querySelectorAll('button[aria-label=upvote][aria-pressed=false]')
  26. .forEach((btn) => {
  27. console.log(`upvoting a fascist ${fascistName} for ${fascistComment}`);
  28. btn.click();
  29. })
  30. });
  31. }
  32.  
  33. var targetNode = document.body;
  34. if (targetNode) {
  35. var config = { childList: true, subtree: true };
  36. // Callback function to execute when mutations are observed
  37. var callback = function(mutationsList, observer) {
  38. for(var mutation of mutationsList) {
  39. if (mutation.type == 'childList') {
  40. for(var node of mutation.addedNodes) {
  41. if (node instanceof Element) {
  42. upvoteFascists(node);
  43. }
  44. }
  45. }
  46.  
  47. }
  48. };
  49.  
  50. // Create an observer instance linked to the callback function
  51. var observer = new MutationObserver(callback);
  52.  
  53. // Start observing the target node for configured mutations
  54. observer.observe(targetNode, config);
  55. }
  56.  
  57.  
  58. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement