Last active
July 4, 2021 10:32
-
-
Save fabianmossberg/d4b59f87da38f9ce8b0e06641c3a4ead to your computer and use it in GitHub Desktop.
Make npmjs.com suggest pnpm as installer instead of npm
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 Make npmjs.org suggest pnpm. | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Making npmjs use pnpm in the suggested code. | |
// @author Fabian Mossberg | |
// @match https://www.npmjs.com/ | |
// @icon https://pnpm.io/img/pnpm-no-name-with-frame.svg | |
// @grant none | |
// @since 0.2 - Adding `.shell` as a selector. | |
// @since 0.1 - First release | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// The code in the description as well as the quick copy in the sidebar. | |
document.querySelectorAll("code:not(code.db), span:not(:not(code > span))").forEach(x => {x.innerText = x.innerText.replace(/^[\b]?npm\b/, 'pnpm')} ); | |
// Lot's of extra shit, just to play around with the logo. | |
let logo_container = document.querySelector('[aria-label="Homepage"]'); | |
let logo = document.querySelector('[aria-label="Homepage"] svg'); | |
logo_container.innerHTML = ''; | |
let div = document.createElement("div"); | |
div.appendChild(logo); | |
let div2 = document.createElement("div"); | |
div2.appendChild(div); | |
let logo_npm = div2.cloneNode(true); | |
div.style="margin-left: -22px;"; | |
div2.style = "width: 19px;overflow: hidden;"; | |
let logo_p = div2.cloneNode(true); | |
let div_container = document.createElement("div"); | |
div_container.style = "display: grid;grid-template-columns: auto auto;gap: 2px;" | |
div_container.append(logo_p); | |
div_container.append(logo_npm); | |
let x = logo_container.append(div_container); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment