Closed bennett-zhang closed 1 year ago
Thanks for the detailed write-up. Do you want to provide a fix in a pull request?
Sure! Please see #20 for my pull request. Thank you so much!
New version should be published. We only need to update the version in CookieClicker
so we can release this.
Describe the bug Cookie Monster is overriding the settings of CCSE mods.
To Reproduce The steps needed to reproduce the behavior:
Game.LoadMod("https://klattmose.github.io/CookieClicker/CCSE.js");
Game.LoadMod("https://klattmose.github.io/CookieClicker/CCSE.js");
Game.LoadMod('https://cookiemonsterteam.github.io/CookieMonster/dist/CookieMonster.js');
Game.LoadMod("https://klattmose.github.io/CookieClicker/CCSE.js");
Solution to Fix the Bug In
saveFramework.js
, there is a bug with the regular expression. On line 15, you are doing a greedy replacement. The regular expression is searching formodName
and the final semicolon in the entire save file. What you want instead is a lazy search for the next semicolon.The save file looks something like this:
cookieMonsterFramework:{\"settings\":{},\"headers\":{\"infoMenu\":1,\"optionsMenu\":1},\"favouriteSettings\":[]};CCSE:{\"version\":\"2.035\",\"Achievements\":{},\"Upgrades\":{},\"Buildings\":{},\"Buffs\":{},\"Seasons\":{},\"OtherMods\":{},\"vault\":[],\"permanentUpgrades\":[-1,-1,-1,-1,-1],\"chimeType\":\"No sound\",\"milkType\":\"Cosmic milk\",\"bgType\":\"Automatic\",\"showVersionNo\":1};
Note how it contains the data for both
cookieMonsterFramework
andCCSE
. The regular expression is incorrectly selecting the entire string, including the settings for CCSE.The fix is simple: change the regular expression from
${modName}.*(;|$)
to${modName}.*?(;|$)
. The extra question mark will perform a lazy search of the string and end at the first semicolon it encounters.Save file
Browser Chrome