Skip to content

Instantly share code, notes, and snippets.

@alexyorke
Forked from notpushkin/npmjs-explore.user.js
Last active April 6, 2021 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexyorke/cb851feeed140ae0a8cc385cc18333dd to your computer and use it in GitHub Desktop.
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 ✨
// ==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