fixed bug stuck when element not avaible

This commit is contained in:
Jonathan Wyss 2024-03-18 21:46:02 +01:00
parent 901ead6691
commit ac86ac4bd9
2 changed files with 13 additions and 1 deletions

View File

@ -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")
{

View File

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