-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhncleanse.user.js
178 lines (164 loc) · 4.91 KB
/
hncleanse.user.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// ==UserScript==
// @name HNCleanse
// @namespace com.example.hncleanse
// @description Remove items from Hacker News I'm probably not gonna like.
// @include https://news.ycombinator.com/new*
// @include https://news.ycombinator.com/
// @version 1.2
// @grant none
// ==/UserScript==
var annoyingSites = [
'aeon.co', // too fluffy
'bbc.com', // biased american reporting
'brookings.edu', //political
'dailydot.com', // more often bad than good
'dailymail.co.uk', // low quality
'daringfireball.net', // no use for this whatsoever
'gizmodo.com', // gawker
'icracked.com', // irrelevant
'iflscience', // low quality
'io9.com', // gawker
'jalopnik.com', // gawker
'medium.com', // low quality
'modelviewculture.com', // activist
'nautil.us', // factoids
'newyorker.com', // not that bad but still not interested
'npr.org', // depressing
'nytimes.com', // will probably annoy me
'polygon.com', // clickbait, low-quality
'qz.com', // really bad more often than really good
'reason.com', // libertarian/outrage-porn
'salon.com', // clickbait,outrage porn
'techdirt.com', // outrage-porn, usually low-quality
'ted.com', // TED
'theatlantic.com', // more often bad than good
'theguardian.com', // will probably annoy me
'themarysue.com', // way too snarky
'theverge.com', // clickbait, low-quality editorials
'truthvoice.com', // activist
'vice.com', // more annoying than good
'vox.com', // everything
'washingtonpost.com', // more often annoying than good
'whitehouse.gov', // never interesting
'xkcd.com' // if it's any good i'll hear about it from someone else
];
var newsSites = [
'ap.org',
'bbc.co.uk',
'bbc.com',
'cnn.com',
'dailymail.co.uk',
'npr.org',
'nytimes.com',
'pbs.org',
'theguardian.com',
'washingtonpost.com',
'wsj.com'
];
var techSites = [
'cnet.com',
'techcrunch.com'
];
var businessSites = [
'bloomberg.com',
'businessinsider.com',
'forbes.com',
'fortune.com',
'techcrunch.com',
'wsj.com'
];
//flamebait
var crapTerms = [
'aaron swartz',
'accused',
'airport security',
'apple watch',
'basic income','mincome',
'boycott','boycotting',
'bully','bullying',
'ceo','cfo','cto','coo',
'cispa',
'code of conduct',
'culture','cultural',
'democracy', 'democratic', //may be too general
'dick costolo',
'feminism','feminist',
'free speech','freedom of speech',
'gamergate','blocklist','randi harper','zoe quinn','brianna wu',
'gawker',
'gentrification','gentrify','gentrified',
'harass','harassing','harassment',
'hbd','iq','neoreactionary','curtis yarvin','mencius moldbug',
'hate speech',
'h1b','h1-b','h-1b',
'immigration','immigrant', 'undocumented immigrants',
'impostor syndrome',
'interview','interviews','interviewing',
'japan', 'japanese', //these are ALWAYS crap
'mark pincus','zynga',
'marijuana',
'mental illness','mental illnesses',
'mongodb',
'obama',"obama's",
'paul krugman',
'police','law enforcement',
'politics',
'racist','racism','racial',
'reddit',
'right to be forgotten','right-to-be-forgotten',
'riots','rioting',
'san francisco','san franciscan',
'snowden','greenwald','poitras','intelligence service','nsa','fbi','surveillance','doj','subpoena','mi6',
'sex','sexism','sexist','sexual',
'suicide','suicides','suicidal',
'supreme court',
'systemd',
'tech industry',
'treaty',
'ttip',
'trolls','trolling','troll', //may be too general
'uber',
'war on drugs',
'women'
];
var crapStr = '\\b(?:' + crapTerms.join('|') + ')\\b';
crapRegex = new RegExp(crapStr, 'i');
function isCrap(testStr) {
var crap = crapRegex.exec(testStr);
return crap;
}
function shouldRemoveSite(siteName) {
return (annoyingSites.indexOf(sitebit) >= 0) ||
(newsSites.indexOf(sitebit) >= 0) ||
(techSites.indexOf(sitebit) >= 0) ||
(businessSites.indexOf(sitebit) >= 0);
}
var result =
document.evaluate("//tr[@class='athing']//span[@class='sitebit comhead']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var i=0;
while ((elem = result.snapshotItem(i)) != null) {
var athing = elem.parentNode.parentNode;
var sitebit = athing.querySelector('span[class="sitestr"]').innerHTML;
var title = athing.querySelector('td[class="title"] a').innerHTML;
var crap = null;
var shouldRemove = shouldRemoveSite(sitebit);
if (!shouldRemove) {
crap = isCrap(title);
if (crap != null) { crap = crap.join(); }
}
if (shouldRemove || crap != null) {
var reason = shouldRemove?('site '+sitebit):('terms '+crap);
console.log(reason+': '+title);
var subtext = athing.nextSibling;
subtext.parentNode.removeChild(subtext);
var breakElem = false;
while (!breakElem) {
delElem = athing.nextSibling;
if (!delElem || delElem.className=='athing') break;
if (delElem.className=='spacer') breakElem = true;
delElem.parentNode.removeChild(delElem);
}
athing.parentNode.removeChild(athing);
}
i++;
}