Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

Bookmarklet to switch between HackerNews and HackerWeb

This bookmarklet toggles between HackerNews pages and Cheeuan's HackerWeb interface. If you're not on either then it acts a a bookmark to HackerWeb.

The code

If you edit this, use something like bookmarkleter to convert it into a bookmarklet.

if ( /https?:\/\/news\.ycombinator\.com\/item\?id=(\d+)/.test(location) ) {
   location = '' + RegExp.$1;
else if ( /http:\/\/cheeaun\.github\.io\/hackerweb\/#\/item\/(\d+)/.test(location) ) {
   location = '' + RegExp.$1;
else {
   location = '';

The bookmarklet

Create a bookmark to HackerNews then edit it and paste the following into the URL/address field:


This comment has been minimized.

Copy link

gbrayut commented Mar 28, 2017

Domain has changed from to To avoid the redirect the bookmarklet should be:

javascript:(function(){if(/https%3F:\/\/news\.ycombinator\.com\/item\%3Fid=(\d+)/.test(location)){location=''+RegExp.$1;}else if(/https:\/\/app\.hackerwebapp\.com\/%23\/item\/(\d+)/.test(location)){location=''+RegExp.$1;}else{location='';}})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.