From 706fb7231e14edd33159be91ac7a785702dd32ac Mon Sep 17 00:00:00 2001 From: steven nguyen <58114641+icecream17@users.noreply.github.com> Date: Sun, 5 Jul 2020 10:50:19 -0500 Subject: [PATCH 1/2] Window.eval()? Var? --- README.md | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c142a8f..efba84a 100644 --- a/README.md +++ b/README.md @@ -82,16 +82,14 @@ If you'd rather use the addon as a script via per example *Greasemonkey* or *Tam // @grant none // ==/UserScript== -var code = "(" + (function() { - var checkReady = setInterval(function() { - if (typeof Game.ready !== 'undefined' && Game.ready) { - Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonster.js'); - clearInterval(checkReady); - } - }, 1000); -}).toString() + ")()"; +'use strict'; -window.eval(code); +let checkReady = setInterval(function() { + if (typeof Game.ready !== 'undefined' && Game.ready) { + Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonster.js'); + clearInterval(checkReady); + } +}, 1000); ``` If you are using the beta, use this instead: @@ -105,16 +103,14 @@ If you are using the beta, use this instead: // @grant none // ==/UserScript== -var code = "(" + (function() { - var checkReady = setInterval(function() { - if (typeof Game.ready !== 'undefined' && Game.ready) { - Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonsterBeta.js'); - clearInterval(checkReady); - } - }, 1000); -}).toString() + ")()"; +'use strict'; -window.eval(code); +let checkReady = setInterval(function() { + if (typeof Game.ready !== 'undefined' && Game.ready) { + Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonsterBeta.js'); + clearInterval(checkReady); + } +}, 1000); ``` # Bugs and suggestions From dc6d643f7d9aa12e42bc24d184d612430885bae1 Mon Sep 17 00:00:00 2001 From: steven nguyen <58114641+icecream17@users.noreply.github.com> Date: Sun, 5 Jul 2020 10:58:17 -0500 Subject: [PATCH 2/2] scoping of variables. --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index efba84a..570bff9 100644 --- a/README.md +++ b/README.md @@ -82,14 +82,14 @@ If you'd rather use the addon as a script via per example *Greasemonkey* or *Tam // @grant none // ==/UserScript== -'use strict'; - -let checkReady = setInterval(function() { - if (typeof Game.ready !== 'undefined' && Game.ready) { - Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonster.js'); - clearInterval(checkReady); - } -}, 1000); +(function() { + const checkReady = setInterval(function() { + if (typeof Game.ready !== 'undefined' && Game.ready) { + Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonster.js'); + clearInterval(checkReady); + } + }, 1000); +})(); ``` If you are using the beta, use this instead: @@ -103,14 +103,14 @@ If you are using the beta, use this instead: // @grant none // ==/UserScript== -'use strict'; - -let checkReady = setInterval(function() { - if (typeof Game.ready !== 'undefined' && Game.ready) { - Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonsterBeta.js'); - clearInterval(checkReady); - } -}, 1000); +(function() { + const checkReady = setInterval(function() { + if (typeof Game.ready !== 'undefined' && Game.ready) { + Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonsterBeta.js'); + clearInterval(checkReady); + } + }, 1000); +})(); ``` # Bugs and suggestions