diff --git a/manifest.json b/manifest.json index c55b77a4..0e8fb9b8 100644 --- a/manifest.json +++ b/manifest.json @@ -399,8 +399,8 @@ "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/profiles/*/achievements/730*" ], "js": [ diff --git a/scripts/community/achievements_cs2.js b/scripts/community/achievements_cs2.js index ae8edf80..ff075d20 100644 --- a/scripts/community/achievements_cs2.js +++ b/scripts/community/achievements_cs2.js @@ -409,7 +409,7 @@ const FetchCSRating = async( profileUrl ) => StartViewTransition( () => { - document.querySelector( '#mainContents' ).append( summary ); + document.querySelector( '#CommunityTemplate .Panel:has([data-index])' ).after( summary ); if( chart !== null ) { @@ -418,15 +418,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 6f661924..d3e9599d 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 {