CookieMonsterTeam / CookieMonster

Addon for Cookie Clicker that offers a wide range of tools and statistics to enhance the game
MIT License
500 stars 206 forks source link

Check if mod is already running and then abort attempt to run a second time #252

Closed climatebrad closed 3 years ago

climatebrad commented 5 years ago

If Cookie Monster is already active, choosing the bookmarklet again causes Cookie Clicker to freeze. (Chrome)

to replicate: start Cookie Clicker run the Cookie Monster bookmarklet run the Cookie Monster bookmarklet again

Aktanusa commented 5 years ago

Makes sense, not something I would try to detect or fix. The solution is not run it twice, IMO. I mean I could add a check, but it be very very low on the list of things to add.

DanielNoord commented 3 years ago

Paging @Aktanusa as this is something that he needs to decide on as well.

After reading up on javascript 'kill'-functions it seems to me that the only solution would be to wrap every src/ document in a Main() function. For example, MainCMDisp() and MainCMMain(). That way we can stop any execution of the code if a variable (say CM.isRunning) is defined. This might also make implementation of #32 possible. The current problem is that we can't stop execution of line 5 of the Header CM = {};, which breaks everything

However, as this touches the core design of the code I do not want to make a decision on my own. So, @Aktanusa, @bitsandbytes1708 and any others please chime in!

DanielNoord commented 3 years ago

This has been implemented with #393

Aktanusa commented 3 years ago

I'm a bit late, lol. I mean honestly this is a silly thing for someone to do and can be easily fixed by not running it twice. But then again, the implementation was very simple, so oh well. It works, it works. Thanks for bringing this to my attention.

DanielNoord commented 3 years ago

Yeah I have implemented another fix which was much easier. However, #32 might be more difficult to implement.