function awaitElement(elem, func) {
  ensureDomLoaded(() => {
    let time = setInterval(() => {
      let element = document.querySelector(elem);
      if (element) {
        func(element);
        clearInterval(time);
      }
    }, 10);
    setInterval(() => {
      clearInterval(time);
    }, 30000);
  });
}
Will wait for an element to appear on the page and then call a function. This does depend on ensureDomLoaded to make sure it will work. This is used to prevent the script from running if the element doesn't exist.
@param {string} e - The element to check.
@param {function} f - The function to call.