Move code into own function

This commit is contained in:
ekzyis 2022-12-25 02:35:05 +01:00
parent b4354a9fdb
commit 69dec59a4c
1 changed files with 6 additions and 2 deletions

View File

@ -45,8 +45,7 @@ function translate(text, source, target) {
const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
(async function () { function addButtons() {
await sleep(1000);
console.log("sn-translator: Adding button to every comment ..."); console.log("sn-translator: Adding button to every comment ...");
const commentSection = document.querySelector(".item_comments__cN57K"); const commentSection = document.querySelector(".item_comments__cN57K");
const comments = commentSection.querySelectorAll(".comment_comment__5uvl3"); const comments = commentSection.querySelectorAll(".comment_comment__5uvl3");
@ -68,4 +67,9 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
topBar.appendChild(btn); topBar.appendChild(btn);
} }
console.log("Done"); console.log("Done");
}
(async function () {
await sleep(1000);
addButtons();
})(); })();