1515// @require https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js
1616// @license GPL-3.0-or-later; https://www.gnu.org/licenses/gpl-3.0.txt
1717// @antifeature tracking When a metacritic rating is displayed, we may store the url of the current website and the metacritic url in our database. Log files are temporarily retained by our database hoster Cloudflare Workers® and contain your IP address and browser configuration.
18- // @version 105
18+ // @version 106
1919// @connect metacritic.com
2020// @connect backend.metacritic.com
2121// @connect met.acritic.workers.dev
@@ -150,7 +150,7 @@ function domParser () {
150150
151151async function versionUpdate ( ) {
152152 const version = parseInt ( await GM . getValue ( 'version' , 0 ) )
153- if ( version <= 104 ) {
153+ if ( version <= 105 ) {
154154 // Reset database
155155 await GM . setValue ( 'map' , '{}' )
156156 await GM . setValue ( 'black' , '[]' )
@@ -160,8 +160,8 @@ async function versionUpdate () {
160160 await GM . setValue ( 'searchcache' , false ) // Unused
161161 await GM . setValue ( 'autosearchcache' , false ) // Unused
162162 }
163- if ( version < 105 ) {
164- await GM . setValue ( 'version' , 105 )
163+ if ( version < 106 ) {
164+ await GM . setValue ( 'version' , 106 )
165165 }
166166}
167167
@@ -450,7 +450,7 @@ function absoluteMetaURL (url) {
450450 if ( url . startsWith ( '/' ) ) {
451451 return baseURL + url . substr ( 1 )
452452 }
453- url = url . replace ( '/game/pc/' , '/game/' ) . replace ( '/ game/playstation-4/' , '/game/' ) . replace ( '/game/xbox-one/' , '/game/' )
453+ url = url . replace ( '/game/pc/' , '/game/' ) . replace ( / \/ g a m e \ /p l a y s t a t i o n - \d \/ / , '/game/' ) . replace ( '/game/xbox-one/' , '/game/' )
454454 return baseURL + url
455455}
456456
@@ -922,16 +922,29 @@ function extractHoverFromFullPage (response) {
922922 content = doc . querySelector ( '.c-productHero_scoreInfo' ) . innerHTML
923923 }
924924
925+ // Get the current platform title:
926+ if ( doc . querySelector ( '.c-gamePlatformLogo title' ) ) {
927+ content = `<div class="mci_current_platform_title">Platform: ${ doc . querySelector ( '.c-gamePlatformLogo title' ) . textContent } </div>\n\n${ content } `
928+ }
929+
925930 // Get the game row with the other platform scores
926931 const gameRow = doc . querySelector ( '.c-PageProductGame_row' )
927932 if ( gameRow ) {
928- gameRow . querySelectorAll ( '.c-gamePlatformTile' ) . forEach ( e => {
929- const desc = e . querySelector ( '.c-gamePlatformTile-description' )
930- if ( desc . textContent . indexOf ( 'PlayStation' ) !== - 1 ) {
931- e . remove ( )
932- }
933- } )
933+ // Get the currently selected platform
934+ const latestCriticReviewsLink = doc . querySelector ( 'a.c-sectionHeader_urlLink[href*="platform="]' )
935+ let platform = null
936+ if ( latestCriticReviewsLink ) {
937+ platform = latestCriticReviewsLink . href . match ( / p l a t f o r m = ( [ ^ & ] + ) / ) [ 1 ]
938+ content += `\n\n<input type="hidden" id="mci_current_platform" value="${ platform } "/>`
939+ }
934940
941+ // Remove platforms that don't have a score
942+ gameRow . querySelectorAll ( '.c-gamePlatformTile[to]' ) . forEach ( e => e . remove ( ) )
943+ // Remove the currently selected platform
944+ if ( platform ) {
945+ gameRow . querySelectorAll ( `a.c-gamePlatformTile[href*="platform=${ platform } "]` ) . forEach ( e => e . remove ( ) )
946+ }
947+ // Replace the platform icon with the platform name
935948 gameRow . querySelectorAll ( '.c-gamePlatformTile-description' ) . forEach ( e => {
936949 e . textContent = e . querySelector ( 'svg title' ) . textContent
937950 } )
@@ -1647,7 +1660,10 @@ function showHoverInfo (response, orgMetaUrl) {
16471660 }
16481661 const titleHTML = titleA ? titleA . outerHTML : ''
16491662
1650- const image = doc . querySelector ( 'picture img' )
1663+ let image = doc . querySelector ( 'picture img' )
1664+ if ( ! image ) {
1665+ image = doc . createElement ( 'img' )
1666+ }
16511667
16521668 if ( ! image . getAttribute ( 'src' ) && doc . querySelector ( 'meta[name="twitter:image"]' ) ) {
16531669 console . log ( 'Using fallback image' , doc . querySelector ( 'meta[name="twitter:image"]' ) . content )
@@ -1727,6 +1743,7 @@ function showHoverInfo (response, orgMetaUrl) {
17271743 // For gamesshow the other platforms (Wait to show the extra data to avoid making the frame to big)
17281744 window . setTimeout ( ( ) => {
17291745 myelement . querySelectorAll ( '.game_row_5456d45' ) . forEach ( e => { e . style . display = '' } )
1746+ myelement . scrollTo ( 0 , 0 )
17301747 } , 500 )
17311748 }
17321749
@@ -1746,6 +1763,7 @@ function showHoverInfo (response, orgMetaUrl) {
17461763 } , '*' )
17471764 } else {
17481765 myelement . querySelector ( `.game_row_5456d45 a[href*="${ platformCriticsUrl } "]` ) . appendChild ( userScoreNode )
1766+ myelement . scrollTo ( 0 , 0 )
17491767 }
17501768 } )
17511769 }
@@ -1802,8 +1820,13 @@ function showHoverInfo (response, orgMetaUrl) {
18021820 } )
18031821 } ,
18041822 frame : function ( ) {
1823+ let currentPlatform = 'playstation'
1824+ if ( document . getElementById ( 'mci_current_platform' ) ) {
1825+ currentPlatform = document . getElementById ( 'mci_current_platform' ) . value
1826+ }
1827+
18051828 const platforms = Array . from ( document . querySelectorAll ( '.game_row_5456d45 a[href^="https://www.metacritic.com/game/"][href*="critic-reviews"]' ) )
1806- . filter ( a => ! a . href . includes ( ' platform=playstation' ) ) . map ( a => a . href . toString ( ) )
1829+ . filter ( a => ! a . href . includes ( ` platform=${ currentPlatform } ` ) ) . map ( a => a . href . toString ( ) )
18071830
18081831 parent . postMessage ( { mcimessage0 : true , mcimessage_platforms : platforms } , '*' ) // Loading frame content was successfull
18091832
@@ -1851,6 +1874,12 @@ function showHoverInfo (response, orgMetaUrl) {
18511874 const css = `
18521875 #hover_div_a20230915{font-family:sans-serif;color:#262626;font-size:1rem;line-height:1.625rem}#hover_div_a202309:hover15 a,#hover_div_a20230915 a:hover{text-decoration:none}#hover_div_a20230915 a:hover{color:#09f}#hover_div_a20230915 a{color:#000;text-decoration:none;}#hover_div_a20230915 a:focus{color:grey}#hover_div_a20230915 .g-border-black,#hover_div_a20230915 .g-border-gray100{border-color:#000}#hover_div_a20230915 .g-color-black,#hover_div_a20230915 .g-color-gray100{color:#000}#hover_div_a20230915 .g-border-gray98{border-color:#191919}#hover_div_a20230915 .g-color-gray98{color:#191919}#hover_div_a20230915 .g-border-gray90{border-color:#262626}#hover_div_a20230915 .g-color-gray90{color:#262626}#hover_div_a20230915 .g-border-gray80{border-color:#404040}#hover_div_a20230915 .g-color-gray80{color:#404040}#hover_div_a20230915 .g-border-gray70{border-color:#666}#hover_div_a20230915 .g-color-gray70{color:#666}#hover_div_a20230915 .g-border-gray60{border-color:grey}#hover_div_a20230915 .g-color-gray60{color:grey}#hover_div_a20230915 .g-border-gray50{border-color:#999}#hover_div_a20230915 .g-color-gray50{color:#999}#hover_div_a20230915 .g-border-gray40{border-color:#bfbfbf}#hover_div_a20230915 .g-color-gray40{color:#bfbfbf}#hover_div_a20230915 .g-border-gray30{border-color:#d8d8d8}#hover_div_a20230915 .g-color-gray30{color:#d8d8d8}#hover_div_a20230915 .g-border-gray20{border-color:#e6e6e6}#hover_div_a20230915 .g-color-gray20{color:#e6e6e6}#hover_div_a20230915 .g-border-gray10{border-color:#f2f2f2}#hover_div_a20230915 .g-color-gray10{color:#f2f2f2}#hover_div_a20230915 .g-border-gray0,#hover_div_a20230915 .g-border-white{border-color:#fff}#hover_div_a20230915 .g-color-gray0,#hover_div_a20230915 .g-color-white{color:#fff}#hover_div_a20230915 .g-border-red{border-color:#eb0036}#hover_div_a20230915 .g-color-red{color:#eb0036}#hover_div_a20230915 .g-border-green{border-color:#01b44f}#hover_div_a20230915 .g-color-green{color:#01b44f}#hover_div_a20230915 .g-width-large{width:1.5rem}#hover_div_a20230915 .g-height-large{height:1.5rem}#hover_div_a20230915 .g-width-100{width:100%}#hover_div_a20230915 .g-height-100{height:100%}#hover_div_a20230915 .g-text-large{font-size:1.5rem;line-height:2rem}#hover_div_a20230915 .g-text-xxsmall{font-size:xx-small}#hover_div_a20230915 .g-text-bold{font-weight:700}#hover_div_a20230915 .g-text-link{text-decoration:underline}#hover_div_a20230915 .u-block{display:block}#hover_div_a20230915 .u-flexbox{display:flex}#hover_div_a20230915 .u-flexbox-column{display:flex;flex-direction:column}#hover_div_a20230915 .u-flexbox-justifyCenter{justify-content:center}#hover_div_a20230915 .u-flexbox-alignCenter{align-items:center}#hover_div_a20230915 .u-grid{display:grid;grid-gap:0;grid-gap:var(--grid-gap,0)}#hover_div_a20230915 .u-grid-2column{-ms-grid-columns:50% 50%;display:grid;grid-template:auto/repeat(2,1fr)}#hover_div_a20230915 .u-grid-3column{-ms-grid-columns:33.3% 33.3% 33.3%;display:grid;grid-template:auto/repeat(3,1fr)}#hover_div_a20230915 .u-grid-4column{-ms-grid-columns:25% 25% 25% 25%;display:grid;grid-template:auto/repeat(4,1fr)}#hover_div_a20230915 .u-grid-5column{-ms-grid-columns:20% 20% 20% 20% 20%;display:grid;grid-template:auto/repeat(5,1fr)}#hover_div_a20230915 .u-grid-7column{-ms-grid-columns:14.2857% 14.2857% 14.2857% 14.2857% 14.2857% 14.2857% 14.2857%;display:grid;grid-template:auto/repeat(7,1fr)}#hover_div_a20230915 .u-grid-column-span2{grid-column-end:span 2}#hover_div_a20230915 .u-grid-column-span3{grid-column-end:span 3}#hover_div_a20230915 .u-grid-column-span4{grid-column-end:span 4}#hover_div_a20230915 .u-text-center{text-align:center}#hover_div_a20230915 .c-siteReviewScore_large{border-radius:0.5rem;height:4rem;width:4rem;font-size:2rem}#hover_div_a20230915 .c-siteReviewScore_user{border-radius:50%}#hover_div_a20230915 .c-reviewsStats{padding:1rem 0;grid-template-columns:1fr 1fr 1fr;justify-content:space-evenly;font-size:0.75rem;line-height:1.25rem}#hover_div_a20230915 div[class^=c-reviewsStats_]:first-child,#hover_div_a20230915 div[class^=c-reviewsStats_]:nth-child(2){border-right:0.0625rem solid #d8d8d8}#hover_div_a20230915 .c-ScoreCardGraph{overflow:hidden;white-space:nowrap}#hover_div_a20230915 .c-ScoreCardGraph > div{margin-left:0.25rem;padding:0 0.25rem;text-align:right;height:0.5rem;min-width:2rem;line-height:1rem}#hover_div_a20230915 .c-ScoreCardGraph > div:first-child{margin-left:0}#hover_div_a20230915 .c-ScoreCardGraph_scoreTitle{letter-spacing:0.25rem}#hover_div_a20230915 .c-ScoreCardGraph_scoreSentiment{color:#00ce7a}#hover_div_a20230915 .c-ScoreCardGraph_scoreGraphPositive{background:#00ce7a;border-radius:0.25rem 0 0 0.25rem}#hover_div_a20230915 .c-ScoreCardGraph_scoreGraphNeutral{background:#ffbd3f}#hover_div_a20230915 .c-ScoreCardGraph_scoreGraphNegative{background:#ff6874;border-radius:0 0.25rem 0.25rem 0}#hover_div_a20230915 .gray{background:#bfbfbf;height:1rem;display:inline-block}#hover_div_a20230915 .c-ScoreCard_scoreContent{display:flex;align-content:flex-start;flex-wrap:nowrap;grid-gap:10px;gap:10px;width:100%;justify-content:space-between;align-items:stretch}#hover_div_a20230915 .c-ScoreCard_scoreContent_text{line-height:normal;display:flex;flex-direction:column;justify-content:space-between}#hover_div_a20230915 .c-ScoreCard_scoreContent_number > .c-siteReviewScore_background-critic_large,#hover_div_a20230915 .c-ScoreCard_scoreContent_number > .c-siteReviewScore_background-critic_large .c-siteReviewScore_large{width:4rem;height:4rem}#hover_div_a20230915 .c-ScoreCard_scoreSentiment{font-size:1rem;line-height:1.25rem;text-transform:capitalize}#hover_div_a20230915 .c-ScoreCard_scoreTitle{letter-spacing:0.25rem}#hover_div_a20230915 .c-reviewsOverview_overviewDetails{grid-template-columns:1fr 1fr;grid-gap:1.25rem;border-top:1px solid #262626;margin-top:auto;padding:2px}#hover_div_a20230915 .c-reviewsOverview_overviewDetails:first-child{border-top:0 solid #262626}#hover_div_a20230915 .c-siteReviewScore_green{background:#00ce7a}#hover_div_a20230915 .c-siteReviewScore_yellow{background:#ffbd3f}#hover_div_a20230915 .c-siteReviewScore_red{background:#ff6874}#hover_div_a20230915 .c-siteReviewScore_grey{background:#404040}#hover_div_a20230915 .c-siteReviewScore_tbdCritic,#hover_div_a20230915 .c-siteReviewScore_tbdUser{border-width:0.125rem;border-style:solid}#hover_div_a20230915 .o-inlineScore{border-radius:0.25rem;font-size:1.25rem;font-weight:700;color:#404040;width:2.5rem;height:2.5rem;display:inline-flex;justify-content:center;align-items:center;text-decoration:none!important}#hover_div_a20230915 .o-inlineScore-green{background:#00ce7a}#hover_div_a20230915 .o-inlineScore-yellow{background:#ffbd3f}#hover_div_a20230915 .o-inlineScore-red{background:#ff6874}#hover_div_a20230915 .o-inlineScore-tbd{border:1px solid grey}#hover_div_a20230915 .u-pointer{cursor:pointer}#hover_div_a20230915 .c-siteReviewScore_green{background:#00ce7a}#hover_div_a20230915 .c-siteReviewScore_yellow{background:#ffbd3f}#hover_div_a20230915 .c-siteReviewScore_red{background:#ff6874}#hover_div_a20230915 .c-siteReviewScore_grey{background:#404040}#hover_div_a20230915 .c-siteReviewScore_tbdCritic,#hover_div_a20230915 .c-siteReviewScore_tbdUser{border-width:0.125rem;border-style:solid}#hover_div_a20230915{max-width:440px}
18531876
1877+ .mci_current_platform_title {
1878+ padding:0px;
1879+ margin: -8px 0px -5px 0px;
1880+ font-size: 12px;
1881+ }
1882+
18541883 .game_row_5456d45 .c-gamePlatformTile {
18551884 border-radius: .game_row_5456d45 .375rem;
18561885 box-shadow: 0 .1875rem .625rem rgba(0,0,0,.16);
@@ -2122,12 +2151,18 @@ function showHoverInfo (response, orgMetaUrl) {
21222151 </div>` )
21232152 frame . replaceWith ( noframe )
21242153
2125- const platforms = Array . from ( noframe [ 0 ] . querySelectorAll ( '.game_row_5456d45 a[href^="https://www.metacritic.com/game/"][href*="critic-reviews"]' ) )
2126- . filter ( a => ! a . href . includes ( 'platform=playstation' ) ) . map ( a => a . href . toString ( ) )
2154+ const frameElement = noframe [ 0 ]
2155+
2156+ let currentPlatform = 'playstation'
2157+ if ( frameElement . querySelector ( '#mci_current_platform' ) ) {
2158+ currentPlatform = frameElement . querySelector ( '#mci_current_platform' ) . value
2159+ }
2160+ const platforms = Array . from ( frameElement . querySelectorAll ( '.game_row_5456d45 a[href^="https://www.metacritic.com/game/"][href*="critic-reviews"]' ) )
2161+ . filter ( a => ! a . href . includes ( `platform=${ currentPlatform } ` ) ) . map ( a => a . href . toString ( ) )
21272162
2128- document . querySelector ( '#mcdiv123' ) . style . maxHeight = '220px '
2163+ document . querySelector ( '#mcdiv123' ) . style . maxHeight = '230px '
21292164
2130- tryToLoadMoreMetacriticDetails ( null , noframe [ 0 ] , platforms )
2165+ tryToLoadMoreMetacriticDetails ( null , frameElement , platforms )
21312166 }
21322167 } , 2000 )
21332168
0 commit comments