Created
April 9, 2026 12:39
-
-
Save crashmax-dev/75c9c89cb598c6c9dfd391f38abcc773 to your computer and use it in GitHub Desktop.
npmjs to npmx redirect
This file contains hidden or 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 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