Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox 57 / Greasemonkey 4 userscript #153

Closed
Pantalaim0n opened this issue Nov 17, 2017 · 6 comments
Closed

Firefox 57 / Greasemonkey 4 userscript #153

Pantalaim0n opened this issue Nov 17, 2017 · 6 comments
Assignees
Labels

Comments

@Pantalaim0n
Copy link

The Greasemonkey userscript stopped working for me today after upgrading to firefox 57 (Quantum) / Greasemonkey 4

I made some changes to get it to work again:

// ==UserScript==
// @name Cookie Monster
// @namespace Cookie
// @include http://orteil.dashnet.org/cookieclicker/
// @version 1
// @grant none
// ==/UserScript==

javascript:(function() {
    var checkReady = setInterval(function() {
        if (typeof unsafeWindow.Game.ready !== 'undefined' && unsafeWindow.Game.ready) {
            unsafeWindow.Game.LoadMod('http://aktanusa.github.io/CookieMonster/CookieMonster.js');
            clearInterval(checkReady);
        }
    }, 1000);
}());

The Game object is undefined, but with the prefix unsafeWindow it works again.

@Aktanusa
Copy link
Collaborator

Hmm, interesting. Do you know if it works fine with other browsers with your changes like Google Chrome?

@Aktanusa Aktanusa self-assigned this Nov 18, 2017
@Pantalaim0n
Copy link
Author

It works in Chrome / Tampermonkey if I remove the line // @grant none.
Removing the same line in FireFox makes no difference, it works in both cases.

@Aktanusa
Copy link
Collaborator

Thanks for the research. I'll take a look if there is another way instead of using unsafeWindow since apparently it is not recommended to use it.

@Aktanusa Aktanusa added the Bug label Nov 29, 2017
@cpeter256
Copy link

I've been using the following script successfully-- window.eval appears to be the recommended way to run code inside the security context of the page, instead of greasemonkey's context

var code = "(" + (function() {
  var checkReady = setInterval(function() {
    if (typeof Game.ready !== 'undefined' && Game.ready) {
      Game.LoadMod('http://aktanusa.github.io/CookieMonster/CookieMonster.js');
      clearInterval(checkReady);
    }
  }, 1000);
}).toString() + ")()";

window.eval(code);

@Aktanusa
Copy link
Collaborator

Aktanusa commented Feb 28, 2018

Thanks! I'll will probably use that instead of unsafeWindow. Should be updated when I updated CM to latest CC.

Aktanusa added a commit that referenced this issue Mar 4, 2018
…r the suggestion with the use of unsafeWindow but I rather use @cpeter256 version with window.eval instead.
@Aktanusa
Copy link
Collaborator

Aktanusa commented Mar 4, 2018

Fixed in version 2.0045.1

@Aktanusa Aktanusa closed this as completed Mar 4, 2018
redthefed added a commit to redthefed/CookieMonster that referenced this issue Mar 6, 2018
* Add TLS to HTTP links

Please use HTTPS wherever it is supported.
It is just good practise, you know.

This follows up commit 98924bc.

* Update README to use HTTPS instead of HTTP

HTTPS is good to push for wherever possible,
even if the Cookie Clicker site itself does not support it now.

(cherry picked from commit 98924bc)

* Fixed Issues CookieMonsterTeam#153 and CookieMonsterTeam#158.  Thanks to @Pantalaim0n and @CrackedP0t for the suggestion with the use of unsafeWindow but I rather use @cpeter256 version with window.eval instead.

* Change to Version 2.0045.1

* Forgot CookieMonster.js again...

* Fix for Version 2.0045 of Cookie Clicker (Issue CookieMonsterTeam#161)

* Fixed typo, which ended in a bug

* Format the line better and also fixed the source file that was fixed in Issue CookieMonsterTeam#166

* Undo some of the merge changes that was unwanted

* Fix brainfart undo https
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants