Last active
November 27, 2016 18:43
-
-
Save Chunjee/922bed7acd5e1686a3a22568e720a03d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Industrial Grade Cat Remover | |
// @version 0.2.9 | |
// @description Hide cat posts from SA's Star Citizen thread | |
// @match *://forums.somethingawful.com/* | |
// @grant none | |
// @namespace http://github.com/Chunjee | |
// @updateURL https://gist.githubusercontent.com/Chunjee/922bed7acd5e1686a3a22568e720a03d/raw/Industrial-Grade-Cat-Remover.user.js | |
// @author Chunjee | |
// ==/UserScript== | |
//change this to true if you want cat posts hidden in all threads, not just Star Citizen ones | |
var HideCatsAllSA = false; | |
$(document).ready((function() { | |
'use strict'; | |
//Check the forum title | |
var SubForum = $(".up:contains('Citizen')"); | |
var ThreadTitle = $(".bclast:contains('Citizen')"); | |
//If this is a Star Citizen thread OR HideCatsAllSA is set to true | |
if (SubForum.length > 0 || ThreadTitle.length > 0 || HideCatsAllSA) { | |
//build an array of words we do not want displayed | |
var blacklist_array = ['cat','cattax','cat tax','catte','edit: tax','e: tax','taxxe','cutte','catgifpage','dogge','puppy','pupper','bunbun','bunnie','paid tax']; | |
//append any one-offs to the array | |
blacklist_array.push('cattepic'); | |
//each blacklist item | |
for (var i = blacklist_array.length - 1; i >= 0; i--) { | |
var iterate = blacklist_array[i]; | |
var regex = new RegExp("(" + iterate + "[\\W])|(" + iterate + "[s ]+)", "gi"); | |
//hide any post that matches the blacklisted item regex | |
$(".postbody").each( function() { | |
//console.log(this.innerHTML); | |
var ignore_bool = regex.test(this.innerHTML); | |
if (ignore_bool === true) { | |
$(this).closest('table').hide(); | |
} | |
}); | |
} | |
//unhide any post that may have been caught in the crossfire; gfycat.com images could have a funny gif of commando t-posing | |
$(".postbody:contains('gfycat')").closest('table').show(); //catastrophic | |
//log after completed | |
console.log( GM_info.script.name + " - v" + GM_info.script.version + ": Finished hiding cat posts"); | |
} else { | |
//Do nothing | |
} | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment