Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Reddit - Hide posts
- // @namespace null
- // @description Hide posts based on user prefs.
- // @match http://reddit.com/*
- // @match https://reddit.com/*
- // @match http://*.reddit.com/*
- // @match https://*.reddit.com/*
- // @include http://reddit.com/*
- // @include https://reddit.com/*
- // @include http://*.reddit.com/*
- // @include https://*.reddit.com/*
- // @version 1.00
- // ==/UserScript==
- // Add subreddits which this script will run on followed by a comma (except the last entry).
- var subs = [
- "gameswap"
- ];
- // Check to see if URL matches chosen subs. If so then proceed.
- function init() {
- var loc = window.location.href;
- for(var i=0;i<=subs.length-1;i++){
- if(loc.match(subs[i])){
- hidePosts();
- }
- }
- }
- // Hide posts which match 'Includes' but not 'Excludes'.
- function hidePosts() {
- var matches = [];
- // Grab all instances of posts.
- var s = document.querySelectorAll('div#siteTable div.entry a.title');
- // Add words to look for in the title to hide.
- var matchIncludes = [
- /360/i
- ];
- // Add words to look for in the title NOT to hide if they also appear with 'Includes'.
- var matchExcludes = [
- /PS3/i,
- /Playstation 3/i
- ];
- // Loop through all the posts to search for a match and hide that post.
- for(var i=0;i<=s.length-1;i++) {
- for(j=0,len=matchIncludes.length;j<=len-1;j++){
- if(s[i].innerHTML.match(matchIncludes[j])){
- matches.push(s[i]);
- }
- }
- }
- for(var t=0;t<=matchExcludes.length-1;t++){
- for(var n in matches){
- if(matches[n].innerHTML.match(matchExcludes[t])){
- matches[n].parentNode.parentNode.parentNode.setAttribute('style', 'display:none !important');
- }
- }
- }
- }
- init();
Add Comment
Please, Sign In to add comment