Last Updated: February 25, 2016
· ashnur

Bookmarklet to open package's npm link

So there is this awesome site:
It's fast, has rating, can search on author or keywords. Then when you click the link to check the package it shows you the github page. Which is a good idea I think, but sometimes I am interested in stuff which can be seen only the npm site. Like dependents for example. Not to mention that the github README display fails on my small screen, so I need wrapping. Which has. Then I either have to type the site, or google search and click... not too much, but I got tired of it anyway.

So here is a bookmarklet for you which reads the package.json file, gets the name of the package and opens the<packagename> link in a new tab:

javascript:(function(){ var''); var r=document.createElement('script'); r.textContent = 'var x=new XMLHttpRequest;x.onload = function(){window.location.href=\'\'+JSON.parse(atob(JSON.parse(x.responseText).content.replace(/\\n/g,\'\'))).name};\'GET\',(\''+window.location.pathname+'/contents/package.json\').replace(/([^:])[\/][\/]+/g,\'$1/\'));x.send()'; w.document.body.appendChild(r) }())



Oh. Forgot to mention that due to this bug it only works in webkit things (and some older firefox versions probably)

And that I would've given up one step into it without the help of
Thanks Adam!