Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Block Memeflaggot OPs on /pol/
- // @namespace 4chan
- // @match https://boards.4chan.org/pol/catalog
- // @grant none
- // ==/UserScript==
- const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
- // const sticky_posts = ["124205675", "143684145"];
- // 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"];
- let running_mutex = false;
- let break_requested = false;
- const delete_memeflaggot_threads = async() => {
- if(running_mutex) {
- break_requested = true;
- while(running_mutex)
- await sleep(100);
- }
- running_mutex = true;
- let thread_nodes = [...document.querySelectorAll("div.thread")];
- while(thread_nodes.length != 201) {
- await sleep(500);
- thread_nodes = [...document.querySelectorAll("div.thread")];
- }
- let tt = document.createElement("tt");
- document.body.appendChild(tt);
- tt.outerHTML = `<div style="position: fixed; top: 50px; right: 50px; display: block;" id="mm-tooltip">
- <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>
- </div>`;
- tt = document.querySelector("div#mm-tooltip");
- thread_nodes.splice(0, 2);
- let counter = 0;
- for(let i = 0; i < thread_nodes.length; i++) {
- if(break_requested) {
- break_requested = false;
- break;
- }
- let thread_id = thread_nodes[i].id.replace("thread-", "");
- 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"});
- let obj = await res.json();
- if(obj.posts[0].hasOwnProperty("troll_country")) {
- try {
- thread_nodes[i].parentElement.removeChild(thread_nodes[i]);
- }
- catch(ex) {
- //do nothing
- }
- counter++;
- }
- tt.children[0].innerText = `Purging cancer...(${i}/202)`;
- }
- tt.parentElement.removeChild(tt);
- console.log(`Memeflaggots thread clean count: ${counter}`);
- running_mutex = false;
- };
- delete_memeflaggot_threads();
- document.querySelector("select#order-ctrl").onchange = delete_memeflaggot_threads;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement