ge-ku / AutoJoin-for-SteamGifts

Automatically enters giveaways from Steamgifts.com
https://chrome.google.com/webstore/detail/autojoin-for-steamgifts/bchhlccjhoedhhegglilngpbnldfcidc
GNU General Public License v2.0
105 stars 22 forks source link

Background auto join doesnt seem to be working #71

Open Enissay opened 1 month ago

Enissay commented 1 month ago

As the title says, it used to work months ago, but since I have to manually click the button to do it, then come back later to do the same :<

Running:

Here's my config: image

ge-ku commented 1 month ago

Please check if there are any errors when you go to extension page (Extensions > Manage Extensions > Details or paste chrome://extensions/?id=bchhlccjhoedhhegglilngpbnldfcidc into address bar). Enable Developer mode in top right corner.

You'll then see: Inspect views service worker html/offscreen.html

Click on both of these and if you see errors or some kind of logs, send them.

banjorae commented 1 month ago

neither is working for me for months, keeping the page open or background it just won't join anything, have been using it for years its due recent updates that stopped working

ge-ku commented 1 month ago

neither is working for me for months, keeping the page open or background it just won't join anything, have been using it for years its due recent updates that stopped working

Recent updates were made because Chrome dropped manifest v2 extension support, so it had to be updated. Check reply above for logs you can send, perhaps we'll be able to fix it (as it works for me as it is right now, I can't reproduce your issue).

sn-o-w commented 3 weeks ago

@ge-ku I just noticed this on my side, too.

I have 400 points, and it looks like it doesn't join any giveaways. 🤔

sn-o-w commented 2 weeks ago

@ge-ku Maybe an issue is that the service worker is... inactive?!

Screenshot_30

sn-o-w commented 2 weeks ago

@ge-ku I remember than uBlock Origin dev said the following: "ABP 4.1 uses such trick to keep its service worker alive and ready to act: the service worker is force-restarted each time it is terminated by the browser, so every 30 seconds when the browser is idle."

Maybe you need to implement a similar trick for your extension to keep the service worker alive? 🤔

ge-ku commented 2 weeks ago

@ge-ku I remember than uBlock Origin dev said the following: "ABP 4.1 uses such trick to keep its service worker alive and ready to act: the service worker is force-restarted each time it is terminated by the browser, so every 30 seconds when the browser is idle."

Maybe you need to implement a similar trick for your extension to keep the service worker alive? 🤔

This shouldn't be an issue as it uses alarms API and doesn't store anything in memory that is needed next time alarm is fired. And alarms successfuly work on my end (and yes, it becomes "inactive" between runs).

Please check if there are any errors when you go to extension page (Extensions > Manage Extensions > Details or paste chrome://extensions/?id=bchhlccjhoedhhegglilngpbnldfcidc into address bar). Enable Developer mode in top right corner.

You'll then see: Inspect views service worker html/offscreen.html

Click on both of these and if you see errors or some kind of logs, send them.

Can you try this and see if there's anything logged?

sn-o-w commented 2 weeks ago

@ge-ku I remember than uBlock Origin dev said the following: "ABP 4.1 uses such trick to keep its service worker alive and ready to act: the service worker is force-restarted each time it is terminated by the browser, so every 30 seconds when the browser is idle." Maybe you need to implement a similar trick for your extension to keep the service worker alive? 🤔

This shouldn't be an issue as it uses alarms API and doesn't store anything in memory that is needed next time alarm is fired. And alarms successfuly work on my end (and yes, it becomes "inactive" between runs).

Please check if there are any errors when you go to extension page (Extensions > Manage Extensions > Details or paste chrome://extensions/?id=bchhlccjhoedhhegglilngpbnldfcidc into address bar). Enable Developer mode in top right corner. You'll then see: Inspect views service worker html/offscreen.html Click on both of these and if you see errors or some kind of logs, send them.

Can you try this and see if there's anything logged?

I didn't see any errors logged. By the way, I use Chrome Beta. 🤔

sn-o-w commented 2 weeks ago

@ge-ku Have a look.

Screenshot_42 Screenshot_43

sn-o-w commented 2 weeks ago

@ge-ku Do I have to keep that window open?! It started to work...

Screenshot_45

ge-ku commented 2 weeks ago

@ge-ku Do I have to keep that window open?! It started to work...

Nope, it should work the same with or without the window, strange.

sn-o-w commented 2 weeks ago

@ge-ku Do I have to keep that window open?! It started to work...

Nope, it should work the same with or without the window, strange.

Maybe you can replicate the issue on Chrome Beta? 🤔

sn-o-w commented 2 weeks ago

@ge-ku I have found a solution: https://stackoverflow.com/a/66618269/10438142

See "Offscreen API in Chrome 109+".

I made the changes suggested there and now the service worker stays active. 😎

You are likely more adept at implementing those suggestions than I am. 😆

I just wanted to see if that works, and from my initial tests I made 30 mins ago, it seems it does. 🥰

sn-o-w commented 2 weeks ago

Also, background autojoin works as well:

sn-o-w commented 2 weeks ago

@ge-ku I've created a PR that will fix this issue. 👍

ge-ku commented 2 weeks ago

@sn-o-w thanks! Sorry for the late reply, I don't have access to my usual computer right now. I'll take a closer look at your PR later but at first glance I'm not a fan of sending message every 20 seconds to be honest. Maybe we could use chrome.runtime.onStartup for creating alarms instead?

sn-o-w commented 2 weeks ago

@sn-o-w thanks! Sorry for the late reply, I don't have access to my usual computer right now. I'll take a closer look at your PR later but at first glance I'm not a fan of sending message every 20 seconds to be honest. Maybe we could use chrome.runtime.onStartup for creating alarms instead?

Hmmm, not sure if that would work. 🤔

You can find other solutions suggested here: https://stackoverflow.com/a/66618269/10438142

sn-o-w commented 1 week ago

@Enissay Can you test a modified extension to see if it works for you? In my case it works as expected now.

If the answer is yes, download the following file: autojoin-modified-snow.zip

1) Extract all files into a local folder. 2) In Google Chrome open extensions page ( chrome://extensions/ ) and enable Developer mode. 3) Afterwards drag and drop CRX file into extensions page and confirm the installation. 4) Run chrome-autojoin-add-registry.reg and press Yes. 5) Restart Google Chrome.

At this point the modified extension should be enabled, so you can test. 🤔

If you want to remove the modified extension, remove it via extensions page ( chrome://extensions/ ) + run chrome-autojoin-remove-registry.reg and press Yes. My modified extension has ID jlaclmfphjcokefbnjddobielincpjjf.

P.S.: I only added 3 new lines to backgroundpage.js thanks to this: https://stackoverflow.com/a/66618269/10438142 (see "// background.js, keep running forever")

sn-o-w commented 1 week ago

@banjorae You can also test the modified extension if you want to. 🤔 Hope you use Google Chrome. 🤔