Skip to content

Instantly share code, notes, and snippets.

@roryokane
Last active December 5, 2022 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roryokane/559608e9fd0a5c529831cdd9bee47bd5 to your computer and use it in GitHub Desktop.
Save roryokane/559608e9fd0a5c529831cdd9bee47bd5 to your computer and use it in GitHub Desktop.
Jerry Lawson Google Doodle enhancement – ‘R’ to restart

Jerry Lawson Google Doodle enhancement – ‘R’ to restart

Background

This bit of JavaScript code extends the game built into the 2022-12-01 Google Doodle for Gerald "Jerry" Lawson's 82nd Birthday.

To use the script after installing it

Press the ‘R’ key on your keyboard while a level is running to restart the level. This is equivalent to clicking the Pause button and then clicking Restart very quickly.

Why this script was created

This script saves time and effort because it allows you to keep your hands on the keyboard while playing a level that requires many restarts. A level might require restarts if it softlocks you upon failure or if you are practicing speedrunning it from the beginning.

To install the script

  1. Open just the game, not the whole Google Doodle page.

    • If you are playing the built-in levels or a level you developed, you can just visit https://www.google.com/logos/2022/lawson/r11292/lawson.html.
    • If you opened a link to a level, load the URL of the iframe within the link. If you don’t know how to do this, these steps will also work:
      1. Find the value of the doodle query parameter within the URL you arrived at. If the URL you are at contains …?doodle=THIS_PART&platform=…, you want THIS_PART.
        • Example: https://g.co/doodle/rhahnjh leads to a URL whose doodle value to copy is 207425764-GpYBCpEBjZCJrgIxCEVvVOxgR1q3SYz__4duy3txOtGkLkXKSUgLF0oZYYwJCFM4NGDM4NFiDkFAxAJLrLDGBt86XZH7SDH_yMqPSru3PV_-h96nNINL8boNlDe1v9dxMDkanFTOJheTaxU3lT-T_0pIs8BMxIN7WjoGL4p658kTxY8At7m8GZy81cv25cIxPdC5TpunBxgB
      2. Copy this base URL and paste it into the address bar: https://www.google.com/logos/2022/lawson/r1201/lawson.html?hl=en&sdoodles=1&doodle=
      3. Paste the doodle value at the end of that link, then press Enter/Return to visit the URL.
  2. Copy the JavaScript code within install-restart-hotkey.js in this Gist.

  3. Switch to the game tab.

  4. Open the Web Console of the current page in your browser.

  5. Paste the copied code into the Console.

  6. Press Enter/Return to run the code.

document.addEventListener('keyup', (event) => {
if (event.key === 'r') {
const gameRoot = document.querySelector('ddl-ui-root');
gameRoot.dispatchEvent(new Event('restart-cartridge'));
}
});

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment