Skip to content

Instantly share code, notes, and snippets.

@notpushkin
Last active April 6, 2021 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save notpushkin/a54cb3599220cb876cf8f0355e118cb2 to your computer and use it in GitHub Desktop.
Save notpushkin/a54cb3599220cb876cf8f0355e118cb2 to your computer and use it in GitHub Desktop.
Redirect from npm's Explore link to https://unpkg.com/browse/*/, which is available for all ✨
// ==UserScript==
// @name npmjs.com Explore → unpkg.com Browse
// @author Alexander Pushkov <alexander@notpushk.in>
// @version 2
// @grant none
// @include http://npmjs.com/package/*
// @include https://npmjs.com/package/*
// @include http://www.npmjs.com/package/*
// @include https://www.npmjs.com/package/*
// ==/UserScript==
const oldExploreLink = document.querySelector('a[href="?activeTab=explore"]');
if (oldExploreLink) {
const exploreLink = oldExploreLink.cloneNode(true);
const packageName = location.pathname.split("/").slice(-1)[0];
exploreLink.href = `https://unpkg.com/browse/${packageName}/`;
exploreLink.target = "_blank";
setTimeout(() => {
oldExploreLink.style.display = "none";
oldExploreLink.parentNode.appendChild(exploreLink);
}, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment