Last active
April 6, 2021 21:21
-
-
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 ✨
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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