@@ -8,7 +8,11 @@ chrome.action.onClicked.addListener(async (tab) => {
8
8
: { '16' : '/images/icon16.png' , '48' : '/images/icon48.png' , '128' : '/images/icon128.png' } ;
9
9
chrome . action . setIcon ( { path : iconPath } ) ;
10
10
11
- await chrome . scripting . unregisterContentScripts ( { ids : [ 'project-id-content-script' ] } ) . catch ( ( ) => { } ) ;
11
+ try {
12
+ await chrome . scripting . unregisterContentScripts ( { ids : [ 'project-id-content-script' ] } ) ;
13
+ } catch ( error ) {
14
+ console . log ( error ) ;
15
+ }
12
16
13
17
let projectIDMap = { } ;
14
18
@@ -30,20 +34,23 @@ chrome.action.onClicked.addListener(async (tab) => {
30
34
url . toString ( ) ;
31
35
auth_url += url ;
32
36
33
- let token = await new Promise ( ( resolve , reject ) => {
34
- chrome . identity . launchWebAuthFlow ( { url : auth_url , interactive : true } , function ( responseUrl ) {
35
- if ( chrome . runtime . lastError ) {
36
- // If there's an error, reject the promise
37
- reject ( chrome . runtime . lastError ) ;
38
- } else {
39
- let url = new URL ( responseUrl ) ;
40
- let params = new URLSearchParams ( url . hash . substring ( 1 ) ) ; // remove the '#' at the start
41
- resolve ( params . get ( 'access_token' ) ) ;
42
- }
37
+ let token ;
38
+ try {
39
+ token = await new Promise ( ( resolve , reject ) => {
40
+ chrome . identity . launchWebAuthFlow ( { url : auth_url , interactive : true } , function ( responseUrl ) {
41
+ if ( chrome . runtime . lastError ) {
42
+ // If there's an error, reject the promise
43
+ reject ( chrome . runtime . lastError ) ;
44
+ } else {
45
+ let url = new URL ( responseUrl ) ;
46
+ let params = new URLSearchParams ( url . hash . substring ( 1 ) ) ; // remove the '#' at the start
47
+ resolve ( params . get ( 'access_token' ) ) ;
48
+ }
49
+ } ) ;
43
50
} ) ;
44
- } ) . catch ( error => {
51
+ } catch ( error ) {
45
52
console . log ( error ) ;
46
- } ) ;
53
+ }
47
54
48
55
49
56
const gcp_url = new URL ( 'https://cloudresourcemanager.googleapis.com/v1/projects' )
@@ -75,7 +82,11 @@ chrome.action.onClicked.addListener(async (tab) => {
75
82
76
83
const execOpts = enabled ? { files : [ 'src/contentScript.js' ] } : { } ;
77
84
78
- chrome . scripting . executeScript ( { target : { tabId : tab . id } , ...execOpts } )
79
- . catch ( ( ) => { } ) ;
85
+
86
+ try {
87
+ await chrome . scripting . executeScript ( { target : { tabId : tab . id } , ...execOpts } ) ;
88
+ } catch ( error ) {
89
+ console . log ( error ) ;
90
+ }
80
91
}
81
92
} ) ;
0 commit comments