Skip to content

Instantly share code, notes, and snippets.

@gBasil
Created April 17, 2022 05:27
Show Gist options
  • Save gBasil/adebecf1023e4900ef6fbe8af9a65173 to your computer and use it in GitHub Desktop.
Save gBasil/adebecf1023e4900ef6fbe8af9a65173 to your computer and use it in GitHub Desktop.
Evangelize yarn! A userscript to swap the npm install snippet with yarn.
// ==UserScript==
// @name Yarnify
// @namespace http://gbasil.dev/
// @version 1.0
// @description Evangelize yarn! Replace the npm install with yarn, and affix --dev to type definitions.
// @author Basil
// @match https://www.npmjs.com/package/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=npmjs.com
// @grant none
// ==/UserScript==
// Install with yarn
document.querySelector('[tabindex="0"]').childNodes[0].textContent = 'yarn add ';
// Install types as dev dependencies
if (
document.querySelector('[tabindex="0"]').childNodes[2].textContent.startsWith('@types/')
) document.querySelector('[tabindex="0"]').childNodes[2].textContent += ' --dev';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment