Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name DeleteXoxohthSpamPosts
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Remove annoying spam posts.
- // @match *://xoxohth.com/thread.php*
- // @match *://autoadmit.com/thread.php*
- // @icon http://xoxohth.com/favicon.ico
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- const spamPostsContent = ["It's not a dysphoria. I see it in the positive way of working toward something, rather than away from something.",
- "legal efforts to overturn the 2020 election; and three offenses relating to Trump’s unlawful possession of government records at Mar-a-Lago",
- "America is in the midst of the Cold War. The masculine fire and fury of World War II has given way to a period of cooling",
- "Go to the link, and look at that woman. Look at that face. She never expressed any remorse over",
- "destroyed the Ancien Regime in Europe, was an economic and scientific golden era, but politically it was a mess"
- ]
- const posts = document.getElementsByTagName('table');
- function removeSpamPosts() {
- var postsToRemove = [];
- var previewPosts = new Map();
- for (let i = 1; i < posts.length; i++) {
- if (spamPostsContent.some(spamPostsContent => posts[i].textContent.includes(spamPostsContent)) && posts[i].outerHTML.includes("post.php?parent_message_id=") && !posts[i].baseURI.includes("5324124")) {
- //console.log("Identified spam post");
- //posts[i].remove();
- postsToRemove.push(posts[i])
- } else if ((posts[i].innerHTML.includes("imgs/ReplyArrow.gif") || posts[i].outerHTML.includes("imgs/MessageOld.gif")) && !posts[i].outerHTML.includes('imgs/Back.gif') && posts[i].parentElement.localName != "font") {
- //console.log("Identified preview post");
- //console.log(posts[i].getElementsByTagName('a')[0].getAttribute("href"));
- var previewPostId = posts[i].getElementsByTagName('a')[0].getAttribute("href");
- previewPosts.set(previewPostId, posts[i]);
- }
- }
- postsToRemove.forEach(function(e) {
- var postId = e.parentElement.name;
- e.parentElement.parentElement.remove();
- previewPosts.get('#' + postId).parentElement.parentElement.remove();
- });
- }
- removeSpamPosts();
- })();
Advertisement
Add Comment
Please, Sign In to add comment