From ac86ac4bd92097bcd099265d3fe002e5cc633681 Mon Sep 17 00:00:00 2001 From: Jonathan Wyss Date: Mon, 18 Mar 2024 21:46:02 +0100 Subject: [PATCH] fixed bug stuck when element not avaible --- background.js | 1 + spawn.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index 77aa1d6..8d9c684 100644 --- a/background.js +++ b/background.js @@ -49,6 +49,7 @@ function handleMessages(message,sender,sendResponse,tab,data){ { browser.tabs.sendMessage(tab.id,data.subscriptions[i].url); } + console.log(i); } else if(message === "finished") { diff --git a/spawn.js b/spawn.js index 07f570a..71c761d 100644 --- a/spawn.js +++ b/spawn.js @@ -31,7 +31,18 @@ function worker(message) setTimeout(() => { if(message != "Init")//on init only load page { - document.getElementsByClassName("yt-spec-button-shape-next yt-spec-button-shape-next--filled yt-spec-button-shape-next--mono yt-spec-button-shape-next--size-m")[0].click(); + let element = document.getElementsByClassName("yt-spec-button-shape-next yt-spec-button-shape-next--filled yt-spec-button-shape-next--mono yt-spec-button-shape-next--size-m")[0]; + if (element != null) + { + element.click(); + console.log("elements found"); + } + else + { + console.log("element not found, already in Abo"); + } + + console.log(message); }