Skip to content

Instantly share code, notes, and snippets.

@andfinally
Last active July 8, 2022 13:54
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 andfinally/18a6d45b973cf74a0f7ae8b8831a8b14 to your computer and use it in GitHub Desktop.
Save andfinally/18a6d45b973cf74a0f7ae8b8831a8b14 to your computer and use it in GitHub Desktop.
Greasemonkey script – adds $ and $$ aliases for querySelector and querySelectorAll
// ==UserScript==
// @name Make $ and $$ aliases for document.querySelector and document.querySelectorAll
// @version 1
// @description Creates aliases for document.querySelector and document.querySelectorAll
// @author andfinally
// @match https://github.com/*
// @match https://woocommerce.test/*
// @match https://*.woocommerce.com/*
// @grant none
// ==/UserScript==
function $( selector ) {
return document.querySelector( selector );
}
function $$( selector ) {
return document.querySelectorAll( selector );
}
unsafeWindow.$ = exportFunction( $, unsafeWindow );
unsafeWindow.$$ = exportFunction( $$, unsafeWindow );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment