File size: 875 Bytes
19c8b95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict"


const postStartFn = (window, data) => {
    window.appLogger.log("postStartFn")

    const button = document.createElement("button")
    button.innerHTML = "Custom event"
    // Style the button with the current game's colour
    button.style.background = `#${window.currentGame[1]}`

    adv_opts.children[1].appendChild(button)

    button.addEventListener("click", () => {

        fetch(`http://localhost:8008/customEvent`, {
            method: "Post",
            body: JSON.stringify({
                pluginId: "eg_custom_event",
                data1: "some data",
                data2: "some more data",
                // ....
            })
        }).then(r=>r.text()).then(() => {
            window.appLogger.log("custom event finished")
            console.log("custom event finished")
        })
    })

}


exports.postStartFn = postStartFn