/** * Parses a string for all of the numbers and * returns them as an integer. * * @param num The string that should be parsed * @returns The number extracted from the string */ export function toInt(num: string): number { return parseInt(num.replace(/^0-9/g, "")); } export function hasDirectText(element: HTMLElement): boolean { const deep = element.cloneNode(true) as HTMLElement; const children = deep.children; // removes all children from the element node for (let j = children.length; j--;) { deep.removeChild(children[j]) } // check if content contains text data const textContent = deep.innerText ? deep.innerText : deep.textContent; //Return nothing if there is no text inside activeElement excluding children return !(!textContent || !(textContent.trim().length)); } // Observe DOM for changes in the HTML Dom export const observeDOM = (obj: Node, callback: any) => { const validTags = ["HTML", "IFRAME"]; // Observe for IFRAME const filter = (event: MutationEvent | Event) => { if (validTags.includes((event.target as Element).tagName)) { callback(); } } obj.addEventListener('DOMNodeInserted', filter, false) }