Advertisement
Guest User

JS to Block Memeflaggot OPs from /pol/ v2.0

a guest
Jun 26th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Block Memeflaggot OPs on /pol/
  3. // @namespace 4chan
  4. // @match https://boards.4chan.org/pol/catalog
  5. // @grant none
  6. // ==/UserScript==
  7.  
  8. const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
  9. // const sticky_posts = ["124205675", "143684145"];
  10. // const memeflaggots = ["Anarcho-Capitalist", "Anarchist", "Black Nationalist", "Confederate", "Communist", "Catalonia", "Democrat", "European", "Fascist", "Gadsden", "Gay", "Jihadi", "Kekistani", "Muslim", "National Bolshevik", "Nazi", "Hippie", "Pirate", "Republican", "Templar", "Tree Hugger", "United Nations", "White Supremacist", "LGBT", "Black Lives Matter", "Commie", "DEUS VULT"];
  11.  
  12. const delete_memeflaggot_threads = async() => {
  13.   let thread_nodes = [...document.querySelectorAll("div.thread")];
  14.  
  15.   while(thread_nodes.length != 201) {
  16.     await sleep(500);
  17.     thread_nodes = [...document.querySelectorAll("div.thread")];
  18.   }
  19.  
  20.   let tt = document.createElement("tt");
  21.   document.body.appendChild(tt);
  22.   tt.outerHTML = `<div style="position: fixed; top: 50px; right: 50px; display: block;" id="mm-tooltip">
  23.                       <div class="tooltip-inner" style="transition: opacity .1s ease; opacity: .95; max-width: 200px; white-space: pre-wrap!important; overflow: hidden; text-overflow: ellipsis; padding: 6px 11px; border-radius: 4px; color: #fff; text-align: center; text-decoration: none; background-color: #14171a">Purging cancer...</div>
  24.                   </div>`;
  25.   tt = document.querySelector("div#mm-tooltip");
  26.   thread_nodes.splice(0, 2);
  27.   let counter = 0;
  28.  
  29.   for(let i = 0; i < thread_nodes.length; i++) {
  30.     let thread_id = thread_nodes[i].id.replace("thread-", "");
  31.     let res = await fetch(`https://a.4cdn.org/pol/thread/${thread_id}.json`, {"credentials":"omit","referrer":"https://boards.4chan.org/","referrerPolicy":"origin","body":null,"method":"GET","mode":"cors"});
  32.     let obj = await res.json();
  33.     if(obj.posts[0].hasOwnProperty("troll_country")) {
  34.       thread_nodes[i].parentElement.removeChild(thread_nodes[i]);
  35.       counter++;
  36.     }
  37.     tt.children[0].innerText = `Purging cancer...(${i}/202)`;
  38.   }
  39.  
  40.  
  41.   tt.parentElement.removeChild(tt);
  42.  
  43.   console.log(`Memeflaggots thread clean count: ${counter}`);
  44. };
  45.  
  46. delete_memeflaggot_threads();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement