function waitForElementToDisplay(selector, callback, checkFrequencyInMs, timeoutInMs) {
let startTimeInMs = Date.now();
(function loopSearch() {
if (document.querySelector(selector) !== null) {
callback();
return;
}
else {
setTimeout(function () {
if (timeoutInMs && Date.now() - startTimeInMs > timeoutInMs)
return;
loopSearch();
}, checkFrequencyInMs);
}
})();
},