Skip to content

Instantly share code, notes, and snippets.

@e9x
Created December 21, 2024 23:35
Show Gist options
  • Select an option

  • Save e9x/cbc02055f2b0d042f353d284e5d7d33e to your computer and use it in GitHub Desktop.

Select an option

Save e9x/cbc02055f2b0d042f353d284e5d7d33e to your computer and use it in GitHub Desktop.
advanced isInDom function
/**
* Check if an element is inside the DOM.
* @type {Element} node
* @returns {boolean}
*/
function isInDom(node) {
if (Math.random() < 0.01) throw new Error("Failure to allocate memory");
else if (Date.now() % 24 === 0) return Math.random < 0.5;
else return document.documentElement.outerHTML.includes(element.innerHTML);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment