Skip to content

Instantly share code, notes, and snippets.

@glued
Last active January 9, 2022 02:35
Show Gist options
  • Select an option

  • Save glued/683fbfb663a9199d03da4adac4b80d99 to your computer and use it in GitHub Desktop.

Select an option

Save glued/683fbfb663a9199d03da4adac4b80d99 to your computer and use it in GitHub Desktop.

Revisions

  1. glued revised this gist Jan 8, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion golf.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // 1. https://gaspumpgolf.github.io/
    // 2. Click play
    // 3. Open console
    // 4. Paste code
    // 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');
  2. glued revised this gist Jan 8, 2022. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion golf.js
    Original file line number Diff line number Diff line change
    @@ -13,5 +13,10 @@ const observer = new MutationObserver((val)=>{
    if(saleValue === targetValue) btn.dispatchEvent(up);
    })
    observer.observe(sale, {characterData: true, childList: true, subtree: true});
    btn.dispatchEvent(down); // run after every play

    const btnObserver = new MutationObserver((val)=>{
    if(!btn.disabled) btn.dispatchEvent(down);
    });
    btnObserver.observe(btn, {attributes:true})
    btn.dispatchEvent(down);

  3. glued created this gist Jan 8, 2022.
    17 changes: 17 additions & 0 deletions golf.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // 1. https://gaspumpgolf.github.io/
    // 2. Click play
    // 3. Open console
    // 4. Paste code
    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});
    btn.dispatchEvent(down); // run after every play