@@ -8,8 +8,9 @@ const getCurrentUser = () => $(".js-menu-target img").attr("alt").slice(1) || ""
8
8
const isPrivate = ( ) => $ ( ".label-private" ) . length > 0 ;
9
9
let statsScope = "repo" ;
10
10
11
- const githubURLBase = window . location . hostname === 'github.com' ? 'api.github.com' : `${ window . location . hostname } /api/v3` ;
12
- const githubURL = `https://${ githubURLBase } `
11
+ const isEnterprise = window . location . hostname !== 'github.com' ;
12
+ const githubURLBase = isEnterprise ? `${ window . location . hostname } /api/v3` : 'api.github.com' ;
13
+ const githubURL = `https://${ githubURLBase } ` ;
13
14
14
15
function getContributor ( ) {
15
16
let $contributor = $ ( ".timeline-comment-wrapper .timeline-comment-header-text strong a" ) ;
@@ -333,11 +334,15 @@ function update({ contributor, repoPath, currentNum, user }) {
333
334
if ( storageRes . prs || storageRes . issues ) {
334
335
updateTextNodes ( appendPRText ( currentNum , storageRes ) ) ;
335
336
} else {
336
- getSyncStorage ( { "access_token" : null } )
337
+ const token = isEnterprise ? "enterprise_access_token" : "access_token" ;
338
+
339
+ getSyncStorage ( { [ token ] : null } )
337
340
. then ( ( res ) => {
341
+ const access_token = isEnterprise ? res . enterprise_access_token : res . access_token ;
342
+
338
343
Promise . all ( [
339
- contributorCount ( { old : storageRes , user, access_token : res . access_token , type : "pr" , contributor, repoPath} ) ,
340
- contributorCount ( { old : storageRes , user, access_token : res . access_token , type : "issue" , contributor, repoPath} )
344
+ contributorCount ( { old : storageRes , user, access_token, type : "pr" , contributor, repoPath} ) ,
345
+ contributorCount ( { old : storageRes , user, access_token, type : "issue" , contributor, repoPath} )
341
346
] )
342
347
. then ( ( [ prInfo , issueInfo ] ) => {
343
348
let repoInfo = Object . assign ( prInfo , issueInfo ) ;
0 commit comments