-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
30 lines (23 loc) · 758 Bytes
/
Copy pathbackground.js
File metadata and controls
30 lines (23 loc) · 758 Bytes
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
'use strict';
const url = 'https://www.reddit.com/r/all/';
const hiddenHTML = '<center><h2>NSFW Content Hidden by Reddit At Work :)</h2></center>';
// if on r/all
if ( document.URL === url ){
// all the divs
let divs = $('#siteTable').children().toArray();
// filter out to only the nsfw content
let nsfw = divs.filter ( div => {
return ( $(div).hasClass ('thing') );
})
.filter ( div => {
let n = $(div).children('.entry').children('.flat-list')
let firstChild = $(n).children('li')[0];
// nsfw-stamp marks the nsfw content
return ($(firstChild).children(0).hasClass('nsfw-stamp'));
});
console.log (`hiding ${nsfw.length} links(s)`);
// hide the nsfw divs
nsfw.forEach ( toHide => {
$(toHide).html(hiddenHTML);
});
}