Open fl0wc0ntr0l opened 7 years ago
With unsafeWindow.gamePage
the gamePage variable can be read.
(https://wiki.greasespot.net/UnsafeWindow)
Still no joy in getting it to work by modifying loadTest like so:
var loadTest = function() {
if (typeof unsafeWindow.gamePage === 'undefined') {
// Test if kittens game is already loaded or wait 2s and try again
setTimeout(function(){
loadTest();
}, 2000);
} else {
// Kittens loaded, run Kitten Scientist's Automation Engine
game = unsafeWindow.gamePage;
run();
}
}
A solution is to wrap the script in a window.eval call.
Add var code = "(" + (function() {
just after // ==/UserScript==
and add
}).toString() + ")()";
window.eval(code);
at the end.
Using Firefox v57.0 and Greasemonkey 4.0, Kitten Scientists does not start successfully.
The problem lies in the loadTest function. For some reason, when the loadTest check is performed,
typeof gamePage
will always returnundefined
, despite gamePage being defined. Testing using the Firefox JS console confirms thattypeof gamePage
returnsobject
correctly.My guess here is that the function is recursive in a manner, always utilizing the undefined gamePage that "existed" when the script started, and never successfully updates. That is total speculation, though, and I have not found a way to get it to successfully recognize the actual gamePage.