Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ jobs:
for f in ${{ steps.changed.outputs.all_changed_files }}; do
while read host; do
[ -z "$host" ] && continue
# The game analytics button opens Rolimon's in a new tab.
[ "$host" = "www.rolimons.com" ] && continue
if ! echo "$host" | grep -qE '(^|\.)(rovalra|roblox|rbxcdn|eslint|feross|github|opencollective|paulmillr|polar|registry\.npmjs|tidelift|i18next|locize|patreon)\.(com|org|sh)$'; then
echo "::error file=$f::Disallowed link host: $host"
BAD=1
Expand Down
4 changes: 4 additions & 0 deletions public/Assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@
"games": {
"failedToLoad": "Failed to load game"
},
"rolimonsGameLink": {
"label": "Rolimons",
"tooltip": "View this game's analytics on Rolimons."
},
"gameBookmarks": {
"bookmark": "Bookmark",
"saved": "Bookmarked",
Expand Down
1 change: 1 addition & 0 deletions src/content/core/configs/userIds.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const CONTRIBUTOR_USER_IDS = [
'74884', // awkward222
'3774777796', // hhhhhhhf334
'4975603156', // KyoMarketing
'1718514709', // BagischandraK
];

export const TESTER_USER_IDS = [
Expand Down
56 changes: 56 additions & 0 deletions src/content/features/games/rolimonsGameLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { getAssets } from '../../core/assets.js';
import { getPlaceIdFromUrl } from '../../core/idExtractor.js';
import { observeElement } from '../../core/observer.js';
import { t } from '../../core/locale/i18n.js';
import { addTooltip } from '../../core/ui/tooltip.js';

const STATS_SELECTOR = '#game-details-about-tab-container .game-stat-container';
const LINK_CONTAINER_CLASS = 'rovalra-rolimons-game-link-container';

function addRolimonsLink(statsContainer, labelText, tooltipText) {
if (
statsContainer.dataset.rovalraRolimonsLink === 'true' ||
!statsContainer.isConnected
) {
return;
}

const placeId = getPlaceIdFromUrl();
if (!/^\d+$/.test(placeId || '')) return;

statsContainer.dataset.rovalraRolimonsLink = 'true';

const link = document.createElement('a');
link.className = 'btn-secondary-md rovalra-rolimons-game-link';
link.href = `https://www.rolimons.com/game/${placeId}`;
link.target = '_blank';
link.rel = 'noopener noreferrer';

const icon = document.createElement('img');
icon.src = getAssets().rolimonsIcon;
icon.alt = '';
link.appendChild(icon);

const label = document.createElement('span');
label.textContent = labelText;
link.appendChild(label);

addTooltip(link, tooltipText, { position: 'top' });

const linkContainer = document.createElement('li');
linkContainer.className = LINK_CONTAINER_CLASS;
linkContainer.appendChild(link);
statsContainer.appendChild(linkContainer);
}

export async function init() {
const [label, tooltip] = await Promise.all([
t('rolimonsGameLink.label'),
t('rolimonsGameLink.tooltip'),
]);
observeElement(
STATS_SELECTOR,
(statsContainer) => addRolimonsLink(statsContainer, label, tooltip),
{ multiple: true },
);
}
2 changes: 2 additions & 0 deletions src/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import { init as initBadgeEarnedDate } from './features/games/badgeEarnedDate.js
import { init as initBadgeSort } from './features/games/badgeSort.js';
import { init as initGameStatTimestamps } from './features/games/gameStatTimestamps.js';
import { init as initFreeBadgeQuota } from './features/games/freeBadgeQuota.js';
import { init as initRolimonsGameLink } from './features/games/rolimonsGameLink.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';
Expand Down Expand Up @@ -432,6 +433,7 @@ const featureRoutes = [
initCatalogExplorer,
initUnderReviewPill,
initGameStatTimestamps,
initRolimonsGameLink,
],
},
// private games and game pages
Expand Down
37 changes: 37 additions & 0 deletions src/css/features/games/rolimonsGameLink.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#game-details-about-tab-container
ul.game-stat-container[data-rovalra-rolimons-link='true'] {
display: flex;
flex-wrap: wrap;
height: auto;
}

#game-details-about-tab-container li.rovalra-rolimons-game-link-container {
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 100%;
width: 100%;
box-sizing: border-box;
margin: 8px 0 0;
}

#game-details-about-tab-container a.rovalra-rolimons-game-link {
display: inline-flex;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 8px;
min-width: 120px;
height: 40px;
padding: 0 12px;
box-sizing: border-box;
white-space: nowrap;

img {
display: block;
width: 14px;
height: 19px;
object-fit: contain;
filter: grayscale(1) brightness(0) invert(0.82);
}
}
1 change: 1 addition & 0 deletions src/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
@use 'features/games/gameBookmarks.scss';
@use 'features/games/events.scss';
@use 'features/games/hiddenBadges.scss';
@use 'features/games/rolimonsGameLink.scss';
@use 'features/games/badgeLayoutToggle.scss';
@use 'features/games/badgeSort.scss';
@use 'features/groups/antibots.scss';
Expand Down