Last active
April 7, 2022 16:38
-
-
Save say2joe/a017753e9876f1d696d0 to your computer and use it in GitHub Desktop.
Bookmarklet Helpers & JavaScript One-Liners
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
/** Assorted 1-liners that are very useful to eliminate repetition **/ | |
const siblings = (ele) => [].slice.call(ele.parentNode.children).filter((child) => child !== ele); | |
/** | |
CanIUse.com Helper - prompt for a keyword then display the correct caniuse.com page. | |
Save this as a bookmark in the Bookmark Bar for quick access to CanIUse.com pages. | |
NOTE: Use the minified version below for the URL of the bookmark. | |
**/ | |
/** Minified: | |
* javascript:q=prompt("Search CanIUse.com for?")||0;q&&(location=encodeURI("http://caniuse.com/#search="+q)); | |
**/ | |
var query = window.prompt('Search CanIUse.com for?') || false; | |
if (query) location.href = 'http://caniuse.com/#search=' + encodeURIComponent(query); | |
/** | |
MDN Helper - prompt for a keyword then display the correct mdn page. | |
NOTE: Use the minified version below for the URL of the bookmark. | |
**/ | |
/** Minified: | |
* javascript:q=prompt("Search MDN for?")||0;q&&(location=encodeURI("https://developer.mozilla.org/en-US/search?q="+q)); | |
**/ | |
var query = window.prompt('Search MDN for?') || false; | |
if (query) location.href = 'https://developer.mozilla.org/en-US/search?q=' + encodeURIComponent(query); | |
/** | |
DevDocs Helper - prompt for a keyword then display the correct devdeocs page. | |
You should have already set a bookmark for DevDocs and selected documentation. | |
NOTE: Use the minified version below for the URL of the bookmark. | |
**/ | |
/** Minified: | |
* javascript:q=prompt("Search DevDocs for?")||0;q&&(location=encodeURI("http://devdocs.io/#q="+q)); | |
**/ | |
var query = window.prompt('Search DevDocs for?') || false; | |
if (query) location.href = 'http://devdocs.io/#q=' + encodeURIComponent(query); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment