Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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