File size: 673 Bytes
943acb7 da44018 ae3adbe da44018 943acb7 da44018 ae3adbe da44018 943acb7 da44018 ae3adbe da44018 943acb7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
function () {
function waitForElementToAppear(selector, callback) {
const element = document.querySelector(selector);
if (element) {
callback(element);
return;
}
const targetNode = document.body;
const config = { childList: true, subtree: true };
const observer = new MutationObserver((mutationsList, observer) => {
const element = document.querySelector(selector);
if (element) {
observer.disconnect();
callback(element);
}
});
observer.observe(targetNode, config);
}
console.log("Start");
waitForElementToAppear("#player audio", (button) => {
console.log("Play!");
button.play();
});
} |