Last active
September 6, 2025 01:11
-
-
Save luluwaffless/c93f8ba62757b7d0855c3060eeaec871 to your computer and use it in GitHub Desktop.
RobloxAutoJoin - A TamperMonkey extension that automatically joins an user if they're playing. You must be on a profile page for the extension to be executed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name RobloxAutoJoin | |
| // @version 1.0 | |
| // @description Automatically joins an user if they're playing. | |
| // @author luuccss | |
| // @match https://www.roblox.com/users/*/profile | |
| // ==/UserScript== | |
| (function() { | |
| const userId = Number(location.href.replace(/\D/g, "")); | |
| let main = document.createElement('div'); | |
| let notifications = false; | |
| let lastGame = null; | |
| let running = false; | |
| let autostart = []; | |
| let userName; | |
| let status; | |
| document.getElementById("profile-header-container").appendChild(main); | |
| document.cookie.split("; ").forEach(pair => { | |
| let [key, value] = pair.split("="); | |
| if (key == "autostart") { | |
| autostart = value.split(",").map(Number); | |
| }; | |
| }); | |
| function askNotificationPermission() { | |
| if (!("Notification" in window)) { | |
| console.log("This browser does not support notifications."); | |
| return false; | |
| }; | |
| if (Notification.permission === "granted") { | |
| return true; | |
| } else if (Notification.permission === "none" || Notification.permission === "default") { | |
| Notification.requestPermission().then((permission) => { | |
| if (permission === "granted") { | |
| return true; | |
| } else { | |
| return false; | |
| }; | |
| }); | |
| } else { | |
| return false; | |
| }; | |
| }; | |
| notifications = askNotificationPermission(); | |
| function setStatus(text, color) { | |
| if (!status) { | |
| status = document.createElement('span'); | |
| main.appendChild(status); | |
| }; | |
| status.innerHTML = text; | |
| status.style.color = ["#f74b52", "#00b06f", "#f7d74b", "#ffffff"][color]; | |
| }; | |
| function join() { | |
| $.ajax({ | |
| type: "POST", | |
| url: "https://presence.roblox.com/v1/presence/users", | |
| data: {"userIds": [userId]}, | |
| success: function(data) { | |
| if (data["userPresences"] && data.userPresences[0]) { | |
| if (data.userPresences[0]["userPresenceType"] && data.userPresences[0].userPresenceType === 2) { | |
| if (data.userPresences[0]["gameId"]) { | |
| if (data.userPresences[0].gameId != lastGame) { | |
| lastGame = data.userPresences[0].gameId; | |
| Roblox.GameLauncher.followPlayerIntoGame(userId); | |
| setStatus(`<a href='#' onclick='Roblox.GameLauncher.followPlayerIntoGame(userId);'>Joined ${data.userPresences[0]["lastLocation"]} (${data.userPresences[0].gameId})!</a>`, 1); | |
| if (notifications) { | |
| new Notification("Joined a game", { body: `${userName} joined ${data.userPresences[0]["lastLocation"]}.` }); | |
| } else { | |
| notifications = askNotificationPermission(); | |
| }; | |
| }; | |
| } else { | |
| setStatus(`You don't have permission to join this user!`, 0); | |
| }; | |
| } else { | |
| setStatus(`User is not playing.`, 2); | |
| if (lastGame) { | |
| lastGame = null; | |
| if (notifications) { | |
| new Notification("Left the game", { body: `${userName} left the current game.` }); | |
| } else { | |
| notifications = askNotificationPermission(); | |
| }; | |
| }; | |
| }; | |
| } else { | |
| setStatus(`Error! Check console for details.`, 0); | |
| console.warn(data); | |
| }; | |
| }, | |
| complete: function() { | |
| running ? join() : setStatus('', 3); | |
| } | |
| }); | |
| }; | |
| $.ajax({ | |
| type: "GET", | |
| url: "https://users.roblox.com/v1/users/authenticated", | |
| success: function(data) { | |
| if (data["id"]) { | |
| if (data.id != userId) { | |
| $.ajax({ | |
| type: "GET", | |
| url: `https://users.roblox.com/v1/users/${userId}`, | |
| success: function(data) { | |
| if (data["displayName"] && data["name"]) { | |
| userName = `${data.displayName} (@${data.name})`; | |
| }; | |
| } | |
| }); | |
| let joinbtn = document.createElement('button') | |
| joinbtn.type = "button" | |
| joinbtn.style = "margin-right: 15px;" | |
| joinbtn.innerHTML = "Attempt to join game" | |
| joinbtn.setAttribute("class", "btn-growth-md") | |
| joinbtn.addEventListener("click", function() { | |
| if (running) { | |
| running = false; | |
| joinbtn.type = "button" | |
| joinbtn.style = "margin-right: 15px;" | |
| joinbtn.innerHTML = "Attempt to join game" | |
| joinbtn.setAttribute("class", "btn-growth-md") | |
| } else { | |
| running = true; | |
| joinbtn.type = "button" | |
| joinbtn.style = "margin-right: 15px;" | |
| joinbtn.innerHTML = "Stop attempting to join game" | |
| joinbtn.setAttribute("class", "btn-alert-md") | |
| join(); | |
| }; | |
| }); | |
| main.appendChild(joinbtn); | |
| let addautostart = document.createElement('button') | |
| function checkifautostart() { | |
| if (autostart && autostart.includes(userId)) { | |
| addautostart.type = "button" | |
| addautostart.style = "margin-right: 15px;" | |
| addautostart.innerHTML = "Remove from autostart" | |
| addautostart.setAttribute("class", "btn-alert-md") | |
| } else { | |
| addautostart.type = "button" | |
| addautostart.style = "margin-right: 15px;" | |
| addautostart.innerHTML = "Add to autostart" | |
| addautostart.setAttribute("class", "btn-primary-md") | |
| }; | |
| }; | |
| checkifautostart(); | |
| addautostart.addEventListener("click", function() { | |
| if (autostart && autostart.includes(userId)) { | |
| autostart.splice(autostart.indexOf(userId), 1); | |
| } else { | |
| autostart.push(userId); | |
| if (!running) { | |
| running = true; | |
| joinbtn.type = "button" | |
| joinbtn.style = "margin-right: 15px;" | |
| joinbtn.innerHTML = "Stop attempting to join game" | |
| joinbtn.setAttribute("class", "btn-alert-md") | |
| join(); | |
| }; | |
| }; | |
| const date = new Date(); | |
| date.setTime(date.getTime() + 34560000000); | |
| document.cookie = `autostart=${autostart.join(',')}; expires=${date.toUTCString()}; path=/`; | |
| checkifautostart(); | |
| }); | |
| main.appendChild(addautostart); | |
| if (autostart && autostart.includes(userId)) { | |
| running = true; | |
| joinbtn.type = "button" | |
| joinbtn.style = "margin-right: 15px;" | |
| joinbtn.innerHTML = "Stop attempting to join game" | |
| joinbtn.setAttribute("class", "btn-alert-md") | |
| join(); | |
| }; | |
| } else { | |
| setStatus(`This is your profile.`, 3); | |
| }; | |
| } else { | |
| setStatus(`Error! Check console for details.`, 0); | |
| console.warn(data); | |
| }; | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment