-
-
Save kennethrapp/abbbca60ec286cc73f92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Hacker News BS Detector | |
// @namespace kennethrapp1@gmail.com | |
// @include https://news.ycombinator.com/* | |
// @version 8 | |
// @grant none | |
// ==/UserScript== | |
var HackerNewsBSDetector = { | |
AffectDOMPath: function (expression, callback) { | |
var result = document.evaluate(expression, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
if (result.snapshotLength) { | |
for (i = 0; i <= result.snapshotLength - 1; i++) { | |
callback.call(this, result.snapshotItem(i)); | |
} | |
} | |
}, | |
Run: function () { | |
var dict = { | |
'disrupt': 'bullshit', | |
'growth hacking': 'marketing', | |
'rockstar': 'arrogant jerk', | |
'ninja': '2cool4u', | |
'guru': 'knowitall', | |
'lean': 'cheap', | |
'startup': 'small business', | |
'social media': 'facebook clone', | |
'FREE': 'free', | |
'beautiful':'ordinary', | |
'NSA' : 'Nazi Security Administration', | |
"PHP" : "<?php echo htmlspecialchars($_POST['SHIT SANDWICH']); ?>", | |
"Uber": "Uberstank", | |
"our network":"butt", | |
"Snowden":"Snowjob", | |
'cloud': (function () { | |
var a = [ | |
'rental servers', | |
'butt' | |
]; | |
return a[Math.floor(Math.random() * a.length)]; | |
}) () | |
}; | |
this.AffectDOMPath('//span[@class=\'comment\']', function (node) { | |
var words = node.innerHTML.split(' '); | |
if (words.length) { | |
for (var i = 0; i < words.length; i++) { | |
for (d in dict) { | |
if ((words[i].indexOf('href="') && words[i].indexOf('rel="nofollow"') == - 1)) { | |
regex = new RegExp('^'+d+'$', 'gim'); | |
words[i] = words[i].replace(regex, '<a name="rel" title="'+encodeURIComponent(words[i])+'" style="color:#31688c">'+dict[d]+'</a>'); | |
} | |
} | |
} | |
node.innerHTML = words.join(' '); | |
} | |
}); | |
} | |
}.Run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment