-
-
Save shawwn/2dae1d9bc796c158139952b4678d96be to your computer and use it in GitHub Desktop.
HN Ignorance Is Bliss
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 HN Ignorance Is Bliss | |
// @description Hide your comment scores and karma counters. Installation instructions at https://news.ycombinator.com/item?id=14456203 | |
// @author sillysaurus3 | |
// @version 1.0 | |
// @match *://news.ycombinator.com/* | |
// @grant none | |
// @downloadURL https://gist.githubusercontent.com/sillysaurus/4d917e925548e4c7ec6f6bb96c94ef5c/raw | |
// @updateURL https://gist.githubusercontent.com/sillysaurus/4d917e925548e4c7ec6f6bb96c94ef5c/raw | |
// ==/UserScript== | |
// | |
// See https://news.ycombinator.com/item?id=14456203 for installation instructions. | |
// | |
(function() { | |
var map1 = function (f, l, o) { | |
o = o || {}; | |
var r = []; | |
var more = true; | |
var done = function(x) { r = x; more = false; }; | |
for (var k in l) { | |
var i = (k.search(/^[-]?[0-9]+$/) < 0 ? null : parseInt(k)); | |
var x = f(l[k], {index: i, key: (i ? null : k), input: l, output: r, return: done}); | |
if (!more) { return r; } | |
if (o.nulls || (x != null)) { | |
r[k === i ? k : r.length] = x; | |
} | |
} | |
return r; | |
}; | |
var scramble = function (s) { return s.replace(/[0-9]/g, '9'); }; | |
// Scramble the topbar karma counter. | |
const counter = document.querySelector('#karma'); | |
if (counter) { | |
counter.innerHTML = scramble(counter.innerHTML) | |
} | |
// Hide comment scores. | |
const scores = document.querySelectorAll('.comhead .score'); | |
for (var i = 0; i < scores.length; i++) { | |
scores[i].innerHTML = ''; | |
} | |
// Build a table of HN properties. | |
hnKeys = []; | |
map1(function (x,o) { | |
if (o.index !== null && x.children.length === 2) { | |
var k = x.children[0].innerHTML; | |
var v = x.children[1]; | |
hnKeys[k.length <= 0 ? hnKeys.length : k] = v; | |
} | |
}, document.querySelector('#hnmain tbody').lastElementChild.querySelectorAll('tr:not([class]) table tr')); | |
// Get the logged-in user. | |
hnUser = null; | |
map1( function (n, o) { | |
if (o.index && o.index > 0 && n.innerHTML === 'logout') { | |
hnUser = o.input[o.index-1]; | |
o.return(); | |
} | |
}, document.querySelectorAll('.pagetop a')); | |
if (hnUser) { | |
// Scramble the profile karma counter. | |
if (hnKeys['user:'] && hnKeys['karma:'] && hnKeys['user:'].firstChild.innerHTML === hnUser.innerHTML) { | |
hnKeys['karma:'].innerHTML = scramble(hnKeys['karma:'].innerHTML); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment