From 69dec59a4c3a0ac12a07c39d58ae235b26d0b0e9 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 25 Dec 2022 02:35:05 +0100 Subject: [PATCH] Move code into own function --- sn_translator/sn-translator.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sn_translator/sn-translator.js b/sn_translator/sn-translator.js index 1c3110d..0557781 100644 --- a/sn_translator/sn-translator.js +++ b/sn_translator/sn-translator.js @@ -45,8 +45,7 @@ function translate(text, source, target) { const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); -(async function () { - await sleep(1000); +function addButtons() { console.log("sn-translator: Adding button to every comment ..."); const commentSection = document.querySelector(".item_comments__cN57K"); const comments = commentSection.querySelectorAll(".comment_comment__5uvl3"); @@ -68,4 +67,9 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); topBar.appendChild(btn); } console.log("Done"); +} + +(async function () { + await sleep(1000); + addButtons(); })();