File size: 1,430 Bytes
f37379e |
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
function () {
function onAttributeChange(target, attribute, callback) {
const observerCallback = (mutationsList) => {
for (let mutation of mutationsList) {
if (mutation.type === 'attributes' && mutation.attributeName === attribute) {
callback(mutation.target);
}
}
};
const observer = new MutationObserver(observerCallback);
const config = { attributes: true };
observer.observe(target, config);
console.log("Start observing.");
}
function waitForElementToAppear(selector, callback) {
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();
setTimeout(() => callback(element), 500);
}
});
observer.observe(targetNode, config);
}
const speech = document.querySelector("#speech");
if (speech) {
if (speech.textContent.trim() === "Record") {
speech.textContent = "Send";
const record = document.querySelector(".record-button");
record.click()
} else {
const stop = document.querySelector(".stop-button");
stop.click();
speech.textContent = "Processing";
speech.disabled= true
waitForElementToAppear(".record-button", (button) => {
speech.disabled= false
speech.textContent = "Record";
});
}
}
} |