NeoFoodClub automatic betting

Automatically place bets

This script is marked as "external"
This script was commisioned by someone else, and I will not check if it works. If it breaks, contact me
Click here to install Browse More Scripts
// ==UserScript==
// @name         NeoFoodClub automatic betting
// @namespace    2f7ebe6a337e578c08fff93a48492b118a3ff34e
// @version      0.1
// @description  Automatically place bets
// @author       /u/AyrA_ch
// @match        https://foodclub.neocities.org/
// @run-at       document-end
// @grant        GM_openInTab
// @grant        unsafeWindow
// @external     true
// ==/UserScript==

(function (w) {
    'use strict';
    var f = function (demo) {
        //Get all newly added buttons
        var buttons = Array.from(w.document.querySelectorAll("#bets-table [type='submit']"));
        //Extract all links
        var links = buttons.map(function (v) {
            return v.getAttribute('onclick').match(/'([^']+)'/)[1];
        });
        if (demo) {
            console.log("Links:", links.join("\n"));
            return;
        }
        //Open each link in a new tab
        return links.forEach(function (v) {
            GM_openInTab(v);
        });
    };
    //create a button to automatically bet
    var btn = w.document.createElement("button");
    btn.appendChild(w.document.createTextNode("AUTO-BET"));
    btn.setAttribute("style", "background-color:#FF0");
    btn.addEventListener("click", function () {
        //wait for the DOM to change
        var mo = new MutationObserver(function () {
            //Stop listening for changes
            mo.disconnect();
            //Run autobet function
            f();
            //Remove button
            btn.remove();
        });
        //Wait for the contents of the betting table to change
        mo.observe(w.document.querySelector("#bets-table"), {
            childList: true,
            subtree: true
        });
        //Run calculation function
        w.calc_maxter();
    });
    var betbtn = w.document.querySelector("#maxter");
    betbtn.parentNode.insertBefore(btn, betbtn);
})(unsafeWindow);

/*
LICENSE:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The full license text can be found here: http://creativecommons.org/licenses/by-nc-sa/4.0/
The link has an easy to understand version of the license and the full license text.

DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/

Copyright © 2018 by Kevin Gut 📧 | More services | Generated for 54.236.62.49