-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (56 loc) · 2 KB
/
script.js
File metadata and controls
61 lines (56 loc) · 2 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const currentUrl = window.location.href
const urlParams = new URLSearchParams(window.location.search)
const options = { // Setup all possible actions and specify require arguments
followPlayerIntoGame: ['followUserId'],
editGameInStudio: ['editPlaceId'],
joinGameInstance: [{param: 'placeId', regex: /\/games\/(\d+)/}, 'gameId'],
joinPrivateGame: [{param: 'privatePlaceId', regex: /\/games\/(\d+)/}, ['privateId'], ['code']],
joinMultiplayerGame: ['placeId']
}
const minimumParams = {
joinPrivateGame: 2
}
if (!urlParams.get('page')) { // Don't run if Roblox analytics headers are present (ref #5)
for (const action in options) { // Iterate actions
const data = options[action]
const input = []
for (const key of data) { // Fetches required parameters into table
const optional = Array.isArray(key)
let paramKey = optional ? key[0] : key
if (!optional && typeof key === 'object') {
if (key.regex) {
const result = key.regex.exec(currentUrl)
if (result) {
input.push(result[1])
continue
}
}
paramKey = key.param
}
if (!paramKey) continue
const value = urlParams.get(paramKey)
if (value != null) { input.push(value)
} else if (optional) { input.push(null)
}
}
if (input.length !== data.length) continue // Not enough values, check next action
if (minimumParams[action]) {
let nonNullParams = 0
for (const param of input) if (param != null) nonNullParams += 1
if (nonNullParams < minimumParams[action]) continue // Not enough values, check next action
}
let attempt = 0
const interval = setInterval(() => {
attempt += 1
try {
Roblox.GameLauncher[action](...input) // Execute
clearInterval(interval)
if (!urlParams.get('dontClose')) document.body.classList.add('RBLX_URL_LAUNCHER_OPENED')
} catch(e) {
console.log("Couldn't run the game - ", e)
}
if (attempt > 3) clearInterval(interval) // Stop if exceeded the limit of attempts
}, 1000)
break
}
}