Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name FascistUpvoterForReddit
- // @namespace http://tampermonkey.net/
- // @version 0.2
- // @description Up votes ukranian fascists on Reddit
- // @author APorechaev
- // @license MIT
- // @match https://www.reddit.com/r/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com
- // @homepageURL https://pastebin.com/raw/uURnmb25
- // @downloadURL https://pastebin.com/raw/uURnmb25
- // @updateURL https://pastebin.com/raw/uURnmb25
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- console.log('FascistUpvoterForReddit has started');
- function upvoteFascists(document) {
- [...document.querySelectorAll('[data-testid=comment]')]
- .filter((elm) => elm.innerText.match(/(slava ukrain)|(слава украине)|(glory to ukraine)/gi))
- .forEach((fascistComment) => {
- const fascistName = fascistComment.parentElement.querySelector('a[data-testid=comment_author_link]');
- console.log(`a fascist has been found ${fascistName}`);
- fascistComment.parentElement.querySelectorAll('button[aria-label=upvote][aria-pressed=false]')
- .forEach((btn) => {
- console.log(`upvoting a fascist ${fascistName} for ${fascistComment}`);
- btn.click();
- })
- });
- }
- var targetNode = document.body;
- if (targetNode) {
- var config = { childList: true, subtree: true };
- // Callback function to execute when mutations are observed
- var callback = function(mutationsList, observer) {
- for(var mutation of mutationsList) {
- if (mutation.type == 'childList') {
- for(var node of mutation.addedNodes) {
- if (node instanceof Element) {
- upvoteFascists(node);
- }
- }
- }
- }
- };
- // Create an observer instance linked to the callback function
- var observer = new MutationObserver(callback);
- // Start observing the target node for configured mutations
- observer.observe(targetNode, config);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement