From 769f7f18dd2e148c887d696cf9b53dd411d7dfa9 Mon Sep 17 00:00:00 2001 From: mason1920 Date: Tue, 2 Feb 2021 05:25:42 -0500 Subject: [PATCH] Make a Userscript and Refer the README to It Tested and works with Greasemonkey, Tampermonkey, and Violentmonkey. --- README.md | 22 +--------------------- cookie-monster.user.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 21 deletions(-) create mode 100644 cookie-monster.user.js diff --git a/README.md b/README.md index 9bac6e9..32e89ab 100644 --- a/README.md +++ b/README.md @@ -51,27 +51,7 @@ If (for some reason) the above doesn't work, trying pasting everything after the ### Userscript -If you'd rather use the addon as a script via per example *Greasemonkey* or *Tampermonkey*, you can use the following script, which will automatically load *Cookie Monster* every time the original game loads. You may need to specify http://orteil.dashnet.org/cookieclicker/ when asked for a *namespace* or *includes*. For how to add an userscript to your browser, refer to your browser/plugin's documentation as the method changes for each one. - -```javascript -// ==UserScript== -// @name Cookie Monster -// @namespace Cookie -// @include http://orteil.dashnet.org/cookieclicker/ -// @include https://orteil.dashnet.org/cookieclicker/ -// @version 1 -// @grant none -// ==/UserScript== - -(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'd rather use the addon as a [userscript](https://en.wikipedia.org/wiki/Userscript) to automatically load *Cookie Monster* every time the original game loads, install the `cookie-monster.user.js` file. ## Bugs and suggestions diff --git a/cookie-monster.user.js b/cookie-monster.user.js new file mode 100644 index 0000000..a75d648 --- /dev/null +++ b/cookie-monster.user.js @@ -0,0 +1,19 @@ +// ==UserScript== +// @name Cookie Monster +// @include /https?://orteil.dashnet.org/cookieclicker/ +// ==/UserScript== + +const readyCheck = setInterval(() => { + const Game = unsafeWindow.Game; + + if ( + typeof Game !== "undefined" && + typeof Game.ready !== "undefined" && + Game.ready + ) { + Game.LoadMod( + "https://aktanusa.github.io/CookieMonster/CookieMonster.js" + ); + clearInterval(readyCheck); + } +}, 1000);