-
-
Save alexyorke/cb851feeed140ae0a8cc385cc18333dd 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 Alex Yorke (credits to Alexander Pushkov <alexander@notpushk.in>) | |
// @version 2 | |
// @grant none | |
// @include https://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}/`; | |
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