-
Notifications
You must be signed in to change notification settings - Fork 0
/
reddit_AIO.js
61 lines (51 loc) · 2.4 KB
/
reddit_AIO.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// ==UserScript==
// @name reddit_AIO
// @version 0.0
// @description Hides all posts from a subreddit by name (not case sensitive) or by regex, removes custom subreddit css, and force old reddit.
// @author khlam
// @match http://*.reddit.com/*
// @match https://*.reddit.com/*
// @license MIT
// @require https://gist.githubusercontent.com/khlam/f85ee658005a45a99ba0147124c09c38/raw/704f92f52d7c4c1ed8e71f2c9311b46c2e6ea3cc/jQuery.v3.6.0
/* globals jQuery, $ */
// @run-at document-end
// @grant none
// ==/UserScript==
const regex = [] // put your regex block here, comma seperated. See example:
// const regex = [/news/, /meme/] // <--- will block /r/worldnews, /r/news, /r/meme, and /r/memes
const blacklisted_subs = [] // put your specific subreddits to never show posts here, comma separated. See example:
// const blacklisted_subs = ["worldnews"] // <--- will block all posts from /r/worldnews, not case sensitive
let blacklisted_subs_lower = blacklisted_subs.map(e => { return e.toLowerCase() }) // all blacklisted subreddits to lowercase
let all_threads = document.querySelectorAll("[data-subreddit]")
all_threads.forEach(thread => {
let this_sub = thread.getAttribute('data-subreddit').toLowerCase() // post's subreddit to lowercase
// if subreddit is in blacklist or if subreddit matches regex then hide it
if ((blacklisted_subs_lower.includes(this_sub) === true) || regex.some(function(r) { return r.test(this_sub)}) === true) {
console.log("HIDING", thread)
//thread.innerHTML = `Content from ${this_sub} hidden.`
thread.style.display = "none"
}
})
// force old reddit | by: /u/101743
var url = window.location.host;
if (url.match("old.reddit.com") === null) {
url = window.location.href;
if (url.match("//www.reddit") !== null){
url = url.replace("//www.reddit", "//old.reddit");
} else {
return;
}
//console.log(url);
window.location.replace(url);
}
// remove subreddit custom css
(function() {
'use strict';
$('link[rel=stylesheet][title="applied_subreddit_stylesheet"]').remove()
})();
// remove signup banner
let signup_banner = document.getElementsByClassName("listingsignupbar infobar")[0]
signup_banner.style.display = "none"
// remove right column premium banner
let premium_banner = document.getElementsByClassName("premium-banner-outer")[0]
premium_banner.style.display = "none"