Skip to content

Instantly share code, notes, and snippets.

@glued
Last active January 9, 2022 02:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glued/683fbfb663a9199d03da4adac4b80d99 to your computer and use it in GitHub Desktop.
Save glued/683fbfb663a9199d03da4adac4b80d99 to your computer and use it in GitHub Desktop.
Gas Pump Golf Perfect score (https://gaspumpgolf.github.io/)
// 1. https://gaspumpgolf.github.io/
// 2. Click play
// 3. Open console
// 4. Paste code and press enter
const down = new MouseEvent("mousedown", { bubbles: true, cancelable: true, view: window });
const up = new MouseEvent("mouseup", { bubbles: true, cancelable: true, view: window });
const btn = document.querySelector('#content > button');
const target = document.querySelector('#content > p:nth-child(3) > mark > strong');
const sale = document.querySelector('#content > p:nth-child(5) > strong');
const observer = new MutationObserver((val)=>{
const saleValue = val[0].target.data;
const targetValue = document.querySelector('#content > p:nth-child(3) > mark > strong').textContent.substr(1);
if(saleValue === targetValue) btn.dispatchEvent(up);
})
observer.observe(sale, {characterData: true, childList: true, subtree: true});
const btnObserver = new MutationObserver((val)=>{
if(!btn.disabled) btn.dispatchEvent(down);
});
btnObserver.observe(btn, {attributes:true})
btn.dispatchEvent(down);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment