Created
August 10, 2023 09:30
-
-
Save hyrious/b0fd899654db1f6be64ff7bae4e44f11 to your computer and use it in GitHub Desktop.
Replace npm code tab with NPM Browser
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 Read the code in NPM Browser | |
// @namespace goto-npm-browser.hyrious.me | |
// @match https://www.npmjs.com/package/* | |
// @grant none | |
// @version 1.0 | |
// @author hyrious | |
// @description Change the Code tab to goto https://hyrious.me/npm-browser | |
// ==/UserScript== | |
void function() { | |
"use strict" | |
setTimeout(() => { | |
var a = document.querySelector('[href="?activeTab=code"]') | |
if (a != null) { | |
a.href = 'javascript:void 0' | |
a.onclick = function jump(ev) { | |
ev.stopPropagation() | |
ev.preventDefault() | |
var spec = location.pathname.split('/').slice(2).join('/').replace(/\/v\/([^/]+)/, '@$1') | |
location.href = 'https://hyrious.me/npm-browser/?q=' + spec | |
} | |
} | |
}) | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment