-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
47 lines (46 loc) · 1.89 KB
/
script.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
if (document.URL.includes("games/")) {
console.log("game page detected")
var headerParse = document.URL.split("/")
//console.warn(headerParse)
var gid = headerParse[4]
console.log("gid: " + gid)
var req = new XMLHttpRequest();
if (gid != null) {
chrome.runtime.sendMessage({game_id: gid}, null, function(response) {})
}
}
chrome.runtime.onMessage.addListener(function (request, sender, sendFunc){
// filtered servers
console.log(request)
var json = JSON.parse(request)
// we have servers
// add buttons
var parent = document.getElementById("game-instances")
var titleNode = document.createElement("H1")
var titleText = document.createTextNode("SLS Server List")
titleNode.appendChild(titleText)
var titlebreak1 = document.createElement("br")
var titlebreak2 = document.createElement("br")
parent.appendChild(titlebreak1)
parent.appendChild(titleNode)
parent.appendChild(titlebreak2)
if (json.length == 0) {
console.log("empty server list")
var notifyNode = document.createElement("H3")
var notifyText = document.createTextNode("No servers are currently running or this game does not use SLS or is not in the repository.")
notifyNode.appendChild(notifyText)
parent.appendChild(notifyNode)
} else {
for (var index = 0; index < json.length; index++) {
var element = json[index];
console.log(element)
var button = document.createElement("button")
button.setAttribute("OnClick", "Roblox.GameLauncher.joinGameInstance(" + element.placeId + ", \"" + element.serverId + "\")")
var linebreak = document.createElement("br")
var text = document.createTextNode("Press to join server! (amount of players: " + element.registeredPlayerCount + ")")
button.appendChild(text)
parent.appendChild(button)
parent.appendChild(linebreak)
}
}
})