Skip to content

Instantly share code, notes, and snippets.

@crashmax-dev
Created April 9, 2026 12:39
Show Gist options
  • Select an option

  • Save crashmax-dev/75c9c89cb598c6c9dfd391f38abcc773 to your computer and use it in GitHub Desktop.

Select an option

Save crashmax-dev/75c9c89cb598c6c9dfd391f38abcc773 to your computer and use it in GitHub Desktop.
npmjs to npmx redirect
// ==UserScript==
// @name npmjs to npmx redirect
// @match https://www.npmjs.com/package/*
// @match https://npmjs.com/package/*
// @icon https://npmx.dev/favicon.svg
// @grant none
// @version 0.1
// @run-at document-start
// ==/UserScript==
const match = location.pathname.match(/^\/package\/([^\/?#]+)/);
if (match) {
const packageName = match[1];
const url = `https://npmx.dev/package/${packageName}${location.search}${location.hash}`;
if (location.href !== url) {
location.replace(url);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment