Skip to content

Instantly share code, notes, and snippets.

@hyrious
Created August 10, 2023 09:30
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 hyrious/b0fd899654db1f6be64ff7bae4e44f11 to your computer and use it in GitHub Desktop.
Save hyrious/b0fd899654db1f6be64ff7bae4e44f11 to your computer and use it in GitHub Desktop.
Replace npm code tab with NPM Browser
// ==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