-
-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathgamehub.js
More file actions
127 lines (97 loc) 路 3.63 KB
/
Copy pathgamehub.js
File metadata and controls
127 lines (97 loc) 路 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* global CurrentAppID: true */
'use strict';
GetOption( {
'button-gamehub': true,
'button-pcgw': true,
'button-protondb': true,
}, ( items ) =>
{
const container = document.querySelector( '.apphub_OtherSiteInfo' );
if( container )
{
// Are we in a hacky game group with a custom url?
if( GetCurrentAppID() === -1 )
{
/** @type {HTMLAnchorElement} */
const sectionTab = document.querySelector( '.apphub_sectionTab' );
const match = sectionTab.href.match( /\/([0-9]+)\/?/ );
CurrentAppID = CurrentAppID ? Number.parseInt( match[ 1 ], 10 ) : -1;
}
if( GetCurrentAppID() < 1 )
{
return;
}
// Make in-game number clickable
const numInApp = document.querySelector( '.apphub_NumInApp' );
if( numInApp )
{
const link = document.createElement( 'a' );
link.className = 'apphub_NumInApp';
link.href = GetHomepage() + 'app/' + GetCurrentAppID() + '/charts/';
link.title = _t( 'view_on_steamdb' );
link.textContent = numInApp.textContent;
numInApp.parentNode.replaceChild( link, numInApp );
}
if( items[ 'button-gamehub' ] )
{
const link = document.createElement( 'a' );
link.className = 'btnv6_blue_hoverfade btn_medium btn_steamdb';
link.href = GetHomepage() + 'app/' + GetCurrentAppID() + '/';
const element = document.createElement( 'span' );
element.dataset.tooltipText = _t( 'view_on_steamdb' );
link.appendChild( element );
const image = document.createElement( 'img' );
image.className = 'ico16';
image.src = GetLocalResource( 'icons/white.svg' );
element.appendChild( image );
container.insertBefore( link, container.firstChild );
const responsiveMenu = document.querySelector( '.apphub_ResponsiveMenuCtn' );
if( responsiveMenu )
{
responsiveMenu.append( link.cloneNode( true ) );
}
}
if( items[ 'button-pcgw' ] )
{
const link = document.createElement( 'a' );
link.className = 'btnv6_blue_hoverfade btn_medium btn_steamdb';
link.href = 'https://pcgamingwiki.com/api/appid.php?appid=' + GetCurrentAppID() + '&utm_source=SteamDB';
const element = document.createElement( 'span' );
element.dataset.tooltipText = _t( 'view_on_pcgamingwiki' );
link.appendChild( element );
const image = document.createElement( 'img' );
image.className = 'ico16';
image.src = GetLocalResource( 'icons/pcgamingwiki.svg' );
element.appendChild( image );
container.insertBefore( link, container.firstChild );
container.insertBefore( document.createTextNode( ' ' ), link.nextSibling );
const responsiveMenu = document.querySelector( '.apphub_ResponsiveMenuCtn' );
if( responsiveMenu )
{
responsiveMenu.append( document.createTextNode( ' ' ) );
responsiveMenu.append( link.cloneNode( true ) );
}
}
if( items[ 'button-protondb' ] )
{
const link = document.createElement( 'a' );
link.className = 'btnv6_blue_hoverfade btn_medium btn_steamdb';
link.href = 'https://www.protondb.com/app/' + GetCurrentAppID() + '?utm_source=SteamDB';
const element = document.createElement( 'span' );
element.dataset.tooltipText = _t( 'view_on_protondb' );
link.appendChild( element );
const image = document.createElement( 'img' );
image.className = 'ico16';
image.src = GetLocalResource( 'icons/protondb.svg' );
element.appendChild( image );
container.insertBefore( link, container.firstChild );
container.insertBefore( document.createTextNode( ' ' ), link.nextSibling );
const responsiveMenu = document.querySelector( '.apphub_ResponsiveMenuCtn' );
if( responsiveMenu )
{
responsiveMenu.append( document.createTextNode( ' ' ) );
responsiveMenu.append( link.cloneNode( true ) );
}
}
}
} );