| 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(); | |
| }); | |
| } |