http://js.do/blog/bookmarklets/
https://caiorss.github.io/bookmarklet-maker/
or manually
Web Console Helpers
https://firefox-source-docs.mozilla.org/devtools-user/web_console/helpers/index.html
https://www.tutorialspoint.com/prototype/prototype_utility_methods.htm
querySelector examples
previousSibling ++
firstElementChild document ( can do firstElementChild.click() )
getElementsByTagName document
getElementsByClassName document
getElementById
querySelectorAll document
getElementsByName
childElementCount document
children document
Node.childNodes
Node.nodeType
Node.parentNode (optimize to parentNode.parentNode but better use closest)
Node.parentElement
Element.closest
HTMLElement.offsetParent (explained)
--
reference
https://bobbyhadz.com/blog/javascript-loop-through-all-dom-elements
HTMLCollection vs. NodeList Explained
Immediately-Invoked Function Expression (IIFE)
Visual Reference to CSS Selectors
https://fffuel.co/css-selectors/
https://caiorss.github.io/bookmarklet-maker/
or manually
- remove all comments
- copy and paste the code into chrome address bar. chrome will paste it as a single line.
- copy it back from address bar
- prepend javascript: to turn it into javascript:<copied_single_line_code>
Web Console Helpers
https://firefox-source-docs.mozilla.org/devtools-user/web_console/helpers/index.html
https://www.tutorialspoint.com/prototype/prototype_utility_methods.htm
querySelector examples
previousSibling ++
firstElementChild document ( can do firstElementChild.click() )
getElementsByTagName document
getElementsByClassName document
getElementById
querySelectorAll document
getElementsByName
childElementCount document
children document
Node.childNodes
Node.nodeType
Node.parentNode (optimize to parentNode.parentNode but better use closest)
Node.parentElement
Element.closest
HTMLElement.offsetParent (explained)
--
JavaScript:
var allElements = document.getElementsByTagName('*'); --HTMLCollection is LIVE
var x = document.getElementsByClassName('red test'); --HTMLCollection
var x = document.getElementById('para'); --NodeList is STATIC
x.childNodes -- is LIVE
var allElements = document.querySelectorAll('body > *'); --NodeList
allElements.childNodes --is LIVE
var x = document.getElementsByName('name_prop_value'); --NodeList
x[0].childNodes --is LIVE
console.log(allElements.childNodes[1]);
reference
https://bobbyhadz.com/blog/javascript-loop-through-all-dom-elements
HTMLCollection vs. NodeList Explained
Immediately-Invoked Function Expression (IIFE)
JavaScript:
//https://stackoverflow.com/a/42489450
//https://benalman.com/news/2010/11/immediately-invoked-function-expression/
//when not IIFE - every function, when invoked, creates a new execution context.
(function(d) {
...
}(document));
Visual Reference to CSS Selectors
https://fffuel.co/css-selectors/