From ab46a9585413e24fc47e7cec9a811083c751b80c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=B5=D0=BD=D0=BD=D0=B0=D0=B4=D0=B8=D0=B9?= Date: Fri, 30 Oct 2026 02:11:32 +0200 Subject: [PATCH 1/3] Make CS Rating history work on new achievements pages --- manifest.json | 8 +++- scripts/community/achievements_cs2.js | 53 ++++++++++++++++++++++----- styles/achievements_cs2.css | 2 + 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/manifest.json b/manifest.json index c55b77a45..9b0dddee8 100644 --- a/manifest.json +++ b/manifest.json @@ -399,8 +399,12 @@ "run_at": "document_end", "matches": [ - "https://steamcommunity.com/id/*/stats/CSGO*", - "https://steamcommunity.com/profiles/*/stats/CSGO*" + "https://steamcommunity.com/id/*/achievements/730", + "https://steamcommunity.com/id/*/achievements/730/*", + "https://steamcommunity.com/id/*/achievements/730?*", + "https://steamcommunity.com/profiles/*/achievements/730", + "https://steamcommunity.com/profiles/*/achievements/730/*", + "https://steamcommunity.com/profiles/*/achievements/730?*" ], "js": [ diff --git a/scripts/community/achievements_cs2.js b/scripts/community/achievements_cs2.js index ae8edf801..a67d1721a 100644 --- a/scripts/community/achievements_cs2.js +++ b/scripts/community/achievements_cs2.js @@ -1,5 +1,3 @@ -/* global StartViewTransition */ - 'use strict'; const tierColors = [ @@ -352,6 +350,31 @@ const CreateCSRatingTable = ( container, rows ) => } }; +/** + * @param {ViewTransitionUpdateCallback} callback + */ +const StartViewTransition = ( callback ) => +{ + if( document.startViewTransition ) + { + document.startViewTransition( () => + { + try + { + callback(); + } + catch( e ) + { + console.error( '[SteamDB]', e ); + } + } ); + } + else + { + callback(); + } +}; + /** * @param {string} profileUrl */ @@ -407,9 +430,16 @@ const FetchCSRating = async( profileUrl ) => CreateCSRatingTable( summary, premierRows ); + const achievementsList = document.querySelector( '#CommunityTemplate .Panel:has([data-index])' ); + + if( !achievementsList ) + { + return; + } + StartViewTransition( () => { - document.querySelector( '#mainContents' ).append( summary ); + achievementsList.after( summary ); if( chart !== null ) { @@ -418,15 +448,18 @@ const FetchCSRating = async( profileUrl ) => } ); }; -/** - * @param {string} str - */ -const removeTrailingSlash = ( str ) => str.endsWith( '/' ) ? str.slice( 0, -1 ) : str; +const profilePathRegex = /^\/(?:id|profiles)\/[^/]+/; + +/** @type {HTMLAnchorElement} */ +const viewingProfileLink = document.querySelector( '#CommunityTemplate a[href$="/achievements/730"]' ); +const viewingProfile = viewingProfileLink?.pathname.match( profilePathRegex )?.[ 0 ]; -const viewingProfile = removeTrailingSlash( /** @type {HTMLAnchorElement} */ ( document.querySelector( '.pagecontent .persona_name_text_content' ) )?.pathname ?? '' ); -const myProfile = removeTrailingSlash( /** @type {HTMLAnchorElement} */ ( document.querySelector( '#global_actions .user_avatar' ) )?.pathname ?? '' ); +// Link to my account is in header dropdown menu +/** @type {HTMLAnchorElement} */ +const myProfileLink = document.querySelector( '#CommunityTemplate header [popover] a[href*="/id/"], #CommunityTemplate header [popover] a[href*="/profiles/"]' ); +const myProfile = myProfileLink?.pathname.match( profilePathRegex )?.[ 0 ]; -if( viewingProfile === myProfile ) +if( myProfile && viewingProfile === myProfile ) { FetchCSRating( myProfile ); } diff --git a/styles/achievements_cs2.css b/styles/achievements_cs2.css index 6f661924d..d3e9599de 100644 --- a/styles/achievements_cs2.css +++ b/styles/achievements_cs2.css @@ -28,10 +28,12 @@ .steamdb_achievements_csrating th { background-color: #0197cf; padding-left: 10px; + text-align: left; } .steamdb_achievements_csrating .steamdb_achievements_csrating_season { background-color: #417a9b; + text-align: center; } .steamdb_achievements_csrating td { From c62df4b18954afcfadefc3a87ff00f9988a119ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=B5=D0=BD=D0=BD=D0=B0=D0=B4=D0=B8=D0=B9?= Date: Fri, 30 Oct 2026 09:58:32 +0200 Subject: [PATCH 2/3] Use shared StartViewTransition again --- scripts/community/achievements_cs2.js | 36 +++------------------------ 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/scripts/community/achievements_cs2.js b/scripts/community/achievements_cs2.js index a67d1721a..ff075d20a 100644 --- a/scripts/community/achievements_cs2.js +++ b/scripts/community/achievements_cs2.js @@ -1,3 +1,5 @@ +/* global StartViewTransition */ + 'use strict'; const tierColors = [ @@ -350,31 +352,6 @@ const CreateCSRatingTable = ( container, rows ) => } }; -/** - * @param {ViewTransitionUpdateCallback} callback - */ -const StartViewTransition = ( callback ) => -{ - if( document.startViewTransition ) - { - document.startViewTransition( () => - { - try - { - callback(); - } - catch( e ) - { - console.error( '[SteamDB]', e ); - } - } ); - } - else - { - callback(); - } -}; - /** * @param {string} profileUrl */ @@ -430,16 +407,9 @@ const FetchCSRating = async( profileUrl ) => CreateCSRatingTable( summary, premierRows ); - const achievementsList = document.querySelector( '#CommunityTemplate .Panel:has([data-index])' ); - - if( !achievementsList ) - { - return; - } - StartViewTransition( () => { - achievementsList.after( summary ); + document.querySelector( '#CommunityTemplate .Panel:has([data-index])' ).after( summary ); if( chart !== null ) { From 1addd349bd4df5d172374824db961bc6bb5335fe Mon Sep 17 00:00:00 2001 From: ge-ku Date: Fri, 30 Oct 2026 10:06:30 +0200 Subject: [PATCH 3/3] Update manifest.json Co-authored-by: Antoine Rybacki <15911822+Lifeismana@users.noreply.github.com> --- manifest.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index 9b0dddee8..0e8fb9b82 100644 --- a/manifest.json +++ b/manifest.json @@ -399,12 +399,8 @@ "run_at": "document_end", "matches": [ - "https://steamcommunity.com/id/*/achievements/730", - "https://steamcommunity.com/id/*/achievements/730/*", - "https://steamcommunity.com/id/*/achievements/730?*", - "https://steamcommunity.com/profiles/*/achievements/730", - "https://steamcommunity.com/profiles/*/achievements/730/*", - "https://steamcommunity.com/profiles/*/achievements/730?*" + "https://steamcommunity.com/id/*/achievements/730*", + "https://steamcommunity.com/profiles/*/achievements/730*" ], "js": [