Skip to content

Instantly share code, notes, and snippets.

@linktohack
Last active August 29, 2015 14:14
Show Gist options
  • Save linktohack/2bf96649b33f6dbbba00 to your computer and use it in GitHub Desktop.
Save linktohack/2bf96649b33f6dbbba00 to your computer and use it in GitHub Desktop.
HackerWeb (bookmarklet) redirect for HackerNews frontend
javascript:(function hackerWeb (len) {
if (window.location.href.match('https://news.ycombinator.com')) {
window.location.href = window.location.href.replace('https://news.ycombinator.com/item?id=', 'http://cheeaun.github.io/hackerweb/#/item/');
} else {
var a = document.querySelectorAll('a');
if (len != a.length) {
Array.prototype.forEach.call(a, function(e) {
var href = e.getAttribute('href');
href && e.setAttribute('href', href.replace('https://news.ycombinator.com/item?id=', 'http://cheeaun.github.io/hackerweb/#/item/'));
});
}
window.setTimeout((function (len) {
return function () {
hackerWeb(len)
};
})(a.length), 500);
}
})(0);
javascript:!function t(e){if(window.location.href.match("https://news.ycombinator.com"))window.location.href=window.location.href.replace("https://news.ycombinator.com/item?id=","http://cheeaun.github.io/hackerweb/#/item/");else{var o=document.querySelectorAll("a");e!=o.length&&Array.prototype.forEach.call(o,function(t){var e=t.getAttribute("href");e&&t.setAttribute("href",e.replace("https://news.ycombinator.com/item?id=","http://cheeaun.github.io/hackerweb/#/item/"))}),window.setTimeout(function(e){return function(){t(e)}}(o.length),500)}}(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment