-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelisticator.js
108 lines (72 loc) · 3.78 KB
/
delisticator.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
/*
* BuzzFeed Delisticator for Chrome
* Kills listicles dead!
* Copyright 2013, Jason Lefkowitz <[email protected]>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var re = /\s*\d+\s*/;
var bullshitListicleTaunts = [
"Someone sat down and wrote this. Think about that. AN ACTUAL PERSON SAT DOWN AND WROTE THIS.",
"More Internet pollution! Oh goodie.",
"DEAR LORD MAKE IT STOP",
"Somewhere in an impoverished nation, a twelve-year-old child worked all day to pull this out of the listicle mines.",
"If you click this link, you will become dumber than you were before you clicked it. YOU HAVE BEEN WARNED.",
"DID YOU KNOW? 'Listicle' is the Chinese word for 'five minutes you'll never get back.'",
"Listicles: the Natty Light of online publishing.",
"The listicles will continue until morale improves.",
"If your mother knew you read listicles, she would be so disappointed.",
"If you want to save some time, you could skip this listicle and I'll just hit you on the head with a hammer.",
"Did they warn you when you borrowed $250,000 for that sociology degree that you'd end up writing these?"
]
jQuery('div.col1 li.grid-posts__item, div.col1 li.partner-area, div.col2 li.lede--stacked').each(function(index, element) {
hideIfBullshit(element);
});
hideIfBullshitInSplash(jQuery('div#splash-container'));
var observer = new MutationSummary({
callback: handleArticleChanges,
queries: [
{ element: 'article'} ]
});
function handleArticleChanges(summaries) {
var newArticles = summaries[0].added;
newArticles.forEach(function(element, index, array) {
hideIfBullshit(element);
});
}
function hideIfBullshitInSplash(splash) {
var headline = jQuery(splash).find('splash-desc');
var headlineText = headline.html();
if (re.test(headlineText)) {
var randomTaunt = bullshitListicleTaunts[Math.floor(Math.random() * bullshitListicleTaunts.length)];
jQuery(splash).find('label').html('Another bullshit listicle');
headline.html(randomTaunt);
jQuery(splash).addClass('bullshit-listicle');
}
}
function hideIfBullshit(article) {
var headline = jQuery(article).find('h2.lede__title a.lede__link');
var headlineText = headline.html();
if (re.test(headlineText)) {
headline.html('Another bullshit listicle');
jQuery(article).addClass('bullshit-listicle');
var randomTaunt = bullshitListicleTaunts[Math.floor(Math.random() * bullshitListicleTaunts.length)];
var originalHeadline = '<p class="bullshit-listicle-original-headline"><i>Original clickbait headline: ' + headlineText + '</i></p>';
jQuery(article).find(':header').after(originalHeadline);
jQuery(article).find('p.lede__kicker').html(randomTaunt);
jQuery(article).find('h3').after('<hr class="bullshit-listicle-clear">');
var headlineMargin = jQuery(article).find('h3').css('margin-left');
jQuery(article).find('p.bullshit-listicle-original-headline').css('margin-left', headlineMargin);
}
}