From aa83e7b10cb1bb405bc41e45b2d31e4764f87194 Mon Sep 17 00:00:00 2001 From: KyoMarketing <356647576+KyoMarketing@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:32:55 +0100 Subject: [PATCH 1/3] Add rejoin previous server button --- public/Assets/locales/en.json | 4 + src/content/core/settings/settingConfig.js | 11 +++ .../features/games/rejoinServerButton.js | 97 +++++++++++++++++++ .../games/serverlist/recentservers.js | 2 +- src/content/index.js | 2 + .../features/games/rejoin_server_button.scss | 25 +++++ src/css/main.scss | 1 + 7 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 src/content/features/games/rejoinServerButton.js create mode 100644 src/css/features/games/rejoin_server_button.scss diff --git a/public/Assets/locales/en.json b/public/Assets/locales/en.json index 91241eac9..c01d6c38d 100644 --- a/public/Assets/locales/en.json +++ b/public/Assets/locales/en.json @@ -1680,6 +1680,10 @@ "playerCountUnknownTooltip": "Player count is unknown, this is a Roblox limitation. The thumbnails are not representative of the people in game.", "playerCountUnknownLabel": "Player count unknown" }, + "rejoinServer": { + "tooltip": "Rejoin previous server", + "closed": "Your previous server is no longer available." + }, "recentServers": { "title": "Recent Servers", "refresh": "Refresh", diff --git a/src/content/core/settings/settingConfig.js b/src/content/core/settings/settingConfig.js index 4ef06a8ce..b0c7548eb 100644 --- a/src/content/core/settings/settingConfig.js +++ b/src/content/core/settings/settingConfig.js @@ -699,6 +699,17 @@ export const SETTINGS_CONFIG = { type: 'checkbox', default: true, storageKey: 'rovalra_server_history', + childSettings: { + rejoinServerButtonEnabled: { + label: 'Rejoin Previous Server Button', + description: [ + 'Adds a button next to the Play button that joins the last server you were in for that experience.', + ], + type: 'checkbox', + default: true, + contributors: ['4975603156'], + }, + }, }, TotalServersEnabled: { label: 'Total Servers', diff --git a/src/content/features/games/rejoinServerButton.js b/src/content/features/games/rejoinServerButton.js new file mode 100644 index 000000000..823f96821 --- /dev/null +++ b/src/content/features/games/rejoinServerButton.js @@ -0,0 +1,97 @@ +import { observeElement } from '../../core/observer.js'; +import { getPlaceIdFromUrl } from '../../core/idExtractor.js'; +import { settings } from '../../core/settings/getSettings.js'; +import { launchGame } from '../../core/utils/launcher.js'; +import { addTooltip } from '../../core/ui/tooltip.js'; +import { showSystemAlert } from '../../core/ui/roblox/alert.js'; +import { ts } from '../../core/locale/i18n.js'; +import { checkServerIsActive } from './serverlist/recentservers.js'; + +const CONTAINER_SELECTOR = '#game-details-play-button-container'; +const PLAY_BUTTON_SELECTOR = 'button[data-testid="play-button"]'; +const BUTTON_ID = 'rovalra-rejoin-server-button'; +const ICON_PATH = + 'M13 3a9 9 0 0 0-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.954 8.954 0 0 0 13 21a9 9 0 0 0 0-18m-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8z'; + +let listening = false; + +async function getLastServer(placeId) { + const { rovalra_server_history: history = {} } = + await chrome.storage.local.get({ rovalra_server_history: {} }); + return history[placeId]?.[0]?.presence || null; +} + +function createIcon() { + const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + svg.setAttribute('width', '26'); + svg.setAttribute('height', '26'); + svg.setAttribute('viewBox', '0 0 24 24'); + const path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + path.setAttribute('d', ICON_PATH); + svg.append(path); + return svg; +} + +async function rejoin(button, placeId) { + if (button.disabled) return; + button.disabled = true; + try { + const server = await getLastServer(placeId); + if ( + !server?.gameId || + !(await checkServerIsActive(placeId, server.gameId)) + ) { + showSystemAlert(ts('rejoinServer.closed'), 'warning'); + return; + } + launchGame(server.rootPlaceId || placeId, server.gameId); + } finally { + button.disabled = false; + } +} + +async function processContainer(container) { + const placeId = getPlaceIdFromUrl(); + if (!placeId || !container.querySelector(PLAY_BUTTON_SELECTOR)) return; + + const server = await getLastServer(placeId); + const existing = document.getElementById(BUTTON_ID); + if (!server?.gameId) { + existing?.remove(); + return; + } + if (existing) return; + + const button = document.createElement('button'); + button.type = 'button'; + button.id = BUTTON_ID; + button.className = 'btn-primary-md rovalra-rejoin-server-button'; + button.setAttribute('aria-label', ts('rejoinServer.tooltip')); + button.append(createIcon()); + button.addEventListener('click', (event) => { + event.stopPropagation(); + rejoin(button, placeId); + }); + + container.append(button); + addTooltip(button, ts('rejoinServer.tooltip'), { position: 'top' }); +} + +export async function init() { + if ( + !(await settings.recentServersEnabled) || + (await settings.rejoinServerButtonEnabled) === false + ) { + return; + } + + observeElement(CONTAINER_SELECTOR, processContainer); + + if (listening) return; + listening = true; + chrome.storage.onChanged.addListener((changes, namespace) => { + if (namespace !== 'local' || !changes.rovalra_server_history) return; + const container = document.querySelector(CONTAINER_SELECTOR); + if (container) processContainer(container); + }); +} diff --git a/src/content/features/games/serverlist/recentservers.js b/src/content/features/games/serverlist/recentservers.js index 0bee26a3e..6b3d4bc8b 100644 --- a/src/content/features/games/serverlist/recentservers.js +++ b/src/content/features/games/serverlist/recentservers.js @@ -159,7 +159,7 @@ function createModernServerItem(serverData, userThumbnailUrl, userId) { return serverItem; } -async function checkServerIsActive(placeId, gameId) { +export async function checkServerIsActive(placeId, gameId) { try { const info = await callRobloxApiJson({ subdomain: 'gamejoin', diff --git a/src/content/index.js b/src/content/index.js index 41dbd93a1..e090f7754 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -117,6 +117,7 @@ import { init as initFreeBadgeQuota } from './features/games/freeBadgeQuota.js'; import { init as initServerList } from './features/games/serverlist/serverlist.js'; import { initRecentServers } from './features/games/serverlist/recentservers.js'; import { init as initRegionPlayButton } from './features/games/RegionPlayButton.js'; +import { init as initRejoinServerButton } from './features/games/rejoinServerButton.js'; import { init as initSubplaces } from './features/games/tab/Subplaces.js'; import { initServerIdExtraction } from './core/games/servers/serverids.js'; import { init as initGameTrailers } from './features/games/thumbnails/gametrailers.js'; @@ -419,6 +420,7 @@ const featureRoutes = [ initBotDetector, initServerList, initRegionPlayButton, + initRejoinServerButton, bannertest, initGameTrailers, quickOutfits, diff --git a/src/css/features/games/rejoin_server_button.scss b/src/css/features/games/rejoin_server_button.scss new file mode 100644 index 000000000..3017a8007 --- /dev/null +++ b/src/css/features/games/rejoin_server_button.scss @@ -0,0 +1,25 @@ +.rovalra-rejoin-server-button { + display: flex !important; + align-items: center; + justify-content: center; + align-self: stretch; + aspect-ratio: 1; + flex-shrink: 0; + margin-left: 5px !important; + padding: 0 !important; + border: none !important; + border-radius: 12px; + background-color: var(--rovalra-playbutton-color) !important; + color: white !important; + cursor: pointer; + order: 6 !important; + + svg path { + fill: white; + } + + &:disabled { + opacity: 0.6; + cursor: default; + } +} diff --git a/src/css/main.scss b/src/css/main.scss index afdbf02fd..45438152a 100644 --- a/src/css/main.scss +++ b/src/css/main.scss @@ -94,3 +94,4 @@ @use 'features/avatar/game_outfits.scss'; @use 'components/dropdown.scss'; @use 'components/user_card_tooltip.scss'; +@use 'features/games/rejoin_server_button.scss'; From 53079f250d6b77620a53f3c81e0d8f2a100723eb Mon Sep 17 00:00:00 2001 From: KyoMarketing <356647576+KyoMarketing@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:34:53 +0100 Subject: [PATCH 2/3] Match rejoin button size to play button --- src/content/features/games/rejoinServerButton.js | 10 +++++++++- src/css/features/games/rejoin_server_button.scss | 2 -- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/content/features/games/rejoinServerButton.js b/src/content/features/games/rejoinServerButton.js index 823f96821..35e57adb5 100644 --- a/src/content/features/games/rejoinServerButton.js +++ b/src/content/features/games/rejoinServerButton.js @@ -1,4 +1,4 @@ -import { observeElement } from '../../core/observer.js'; +import { observeElement, observeResize } from '../../core/observer.js'; import { getPlaceIdFromUrl } from '../../core/idExtractor.js'; import { settings } from '../../core/settings/getSettings.js'; import { launchGame } from '../../core/utils/launcher.js'; @@ -74,6 +74,14 @@ async function processContainer(container) { }); container.append(button); + const playButton = container.querySelector(PLAY_BUTTON_SELECTOR); + const syncSize = () => { + const { height } = playButton.getBoundingClientRect(); + if (height > 0) + button.style.width = button.style.height = `${height}px`; + }; + syncSize(); + observeResize(playButton, syncSize); addTooltip(button, ts('rejoinServer.tooltip'), { position: 'top' }); } diff --git a/src/css/features/games/rejoin_server_button.scss b/src/css/features/games/rejoin_server_button.scss index 3017a8007..6eeaab473 100644 --- a/src/css/features/games/rejoin_server_button.scss +++ b/src/css/features/games/rejoin_server_button.scss @@ -2,8 +2,6 @@ display: flex !important; align-items: center; justify-content: center; - align-self: stretch; - aspect-ratio: 1; flex-shrink: 0; margin-left: 5px !important; padding: 0 !important; From c89d233e2df1a557eb495e8f05665e9a42893fe4 Mon Sep 17 00:00:00 2001 From: KyoMarketing <356647576+KyoMarketing@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:36:31 +0100 Subject: [PATCH 3/3] Re-add rejoin button when the play button renders late --- .../features/games/rejoinServerButton.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/content/features/games/rejoinServerButton.js b/src/content/features/games/rejoinServerButton.js index 35e57adb5..6df72546c 100644 --- a/src/content/features/games/rejoinServerButton.js +++ b/src/content/features/games/rejoinServerButton.js @@ -14,6 +14,7 @@ const ICON_PATH = 'M13 3a9 9 0 0 0-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.954 8.954 0 0 0 13 21a9 9 0 0 0 0-18m-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8z'; let listening = false; +let processing = false; async function getLastServer(placeId) { const { rovalra_server_history: history = {} } = @@ -53,7 +54,17 @@ async function rejoin(button, placeId) { async function processContainer(container) { const placeId = getPlaceIdFromUrl(); if (!placeId || !container.querySelector(PLAY_BUTTON_SELECTOR)) return; + if (processing) return; + processing = true; + try { + await renderButton(container, placeId); + } finally { + processing = false; + } +} + +async function renderButton(container, placeId) { const server = await getLastServer(placeId); const existing = document.getElementById(BUTTON_ID); if (!server?.gameId) { @@ -94,6 +105,14 @@ export async function init() { } observeElement(CONTAINER_SELECTOR, processContainer); + observeElement( + `${CONTAINER_SELECTOR} button`, + (button) => { + const container = button.closest(CONTAINER_SELECTOR); + if (container) processContainer(container); + }, + { multiple: true }, + ); if (listening) return; listening = true;