@@ -3,16 +3,15 @@ chrome.tabs.query({ active: true, currentWindow: true }).then(([tab]) => {
3
3
{
4
4
target : { tabId : tab . id } ,
5
5
func : ( ) => {
6
- return { isPDF : document . contentType === " application/pdf" } ;
6
+ return { isPDF : document . contentType === ' application/pdf' } ;
7
7
} ,
8
8
} ,
9
9
( tab ) => {
10
- preferencesHeader . textContent =
11
- chrome . i18n . getMessage ( "preferencesHeader" ) ;
12
- autoOpenLabel . textContent = chrome . i18n . getMessage ( "autoOpenLabel" ) ;
10
+ preferencesHeader . textContent = chrome . i18n . getMessage ( 'preferencesHeader' ) ;
11
+ autoOpenLabel . textContent = chrome . i18n . getMessage ( 'autoOpenLabel' ) ;
13
12
14
13
if ( ! tab ) {
15
- openEditorButton . textContent = chrome . i18n . getMessage ( " openEditor" ) ;
14
+ openEditorButton . textContent = chrome . i18n . getMessage ( ' openEditor' ) ;
16
15
return ;
17
16
}
18
17
@@ -23,8 +22,8 @@ chrome.tabs.query({ active: true, currentWindow: true }).then(([tab]) => {
23
22
] = tab ;
24
23
25
24
openEditorButton . textContent = isPDF
26
- ? chrome . i18n . getMessage ( " editWithSimplePDF" )
27
- : chrome . i18n . getMessage ( " openEditor" ) ;
25
+ ? chrome . i18n . getMessage ( ' editWithSimplePDF' )
26
+ : chrome . i18n . getMessage ( ' openEditor' ) ;
28
27
} ,
29
28
) ;
30
29
} ) ;
@@ -33,7 +32,7 @@ async function handleOpenEditor() {
33
32
const openEditor = ( ) => {
34
33
const currentURL = document . location . href ;
35
34
36
- const isPDF = document . contentType === " application/pdf" ;
35
+ const isPDF = document . contentType === ' application/pdf' ;
37
36
38
37
const href = isPDF ? currentURL : null ;
39
38
@@ -49,7 +48,7 @@ async function handleOpenEditor() {
49
48
await chrome . scripting . executeScript (
50
49
{
51
50
target : { tabId : tab . id } ,
52
- files : [ " ./node_modules/@simplepdf/web-embed-pdf/dist/index.js" ] ,
51
+ files : [ ' ./node_modules/@simplepdf/web-embed-pdf/dist/index.js' ] ,
53
52
} ,
54
53
( ) => {
55
54
if ( chrome . runtime . lastError ) {
@@ -64,7 +63,7 @@ async function handleOpenEditor() {
64
63
}
65
64
66
65
window . simplePDF . setConfig ( {
67
- companyIdentifier : " chrome" ,
66
+ companyIdentifier : ' chrome' ,
68
67
} ) ;
69
68
} ,
70
69
} ) ;
@@ -78,25 +77,22 @@ async function handleOpenEditor() {
78
77
79
78
window . close ( ) ;
80
79
} catch ( e ) {
81
- chrome . tabs . create ( { url : "https://simplePDF.com/editor" , active : false } ) ;
82
- openEditorButton . style . display = "none" ;
83
- errorDetails . textContent = chrome . i18n . getMessage (
84
- "unableToOpenInCurrentTab" ,
85
- ) ;
86
- errorMessage . textContent = chrome . i18n . getMessage ( "openedInOtherTab" ) ;
80
+ chrome . tabs . create ( { url : 'https://simplePDF.com/editor' , active : false } ) ;
81
+ openEditorButton . style . display = 'none' ;
82
+ errorDetails . textContent = chrome . i18n . getMessage ( 'unableToOpenInCurrentTab' ) ;
83
+ errorMessage . textContent = chrome . i18n . getMessage ( 'openedInOtherTab' ) ;
87
84
88
- await fetch ( " https://chrome.simplePDF.com/graphql" , {
89
- method : " POST" ,
85
+ await fetch ( ' https://chrome.simplePDF.com/graphql' , {
86
+ method : ' POST' ,
90
87
headers : {
91
- " Content-Type" : " application/json" ,
88
+ ' Content-Type' : ' application/json' ,
92
89
} ,
93
90
body : JSON . stringify ( {
94
- query :
95
- "mutation Track($input: TrackEventInput!) { track(input: $input) }" ,
91
+ query : 'mutation Track($input: TrackEventInput!) { track(input: $input) }' ,
96
92
variables : {
97
93
input : {
98
- type : " ERROR" ,
99
- name : " Chrome extension error" ,
94
+ type : ' ERROR' ,
95
+ name : ' Chrome extension error' ,
100
96
data : JSON . stringify ( { name : e . name , message : e . message } ) ,
101
97
} ,
102
98
} ,
@@ -105,10 +101,9 @@ async function handleOpenEditor() {
105
101
}
106
102
}
107
103
108
- document . addEventListener ( "DOMContentLoaded" , ( ) => {
109
- chrome . storage . local . get ( "userPreferences" , ( { userPreferences } ) => {
110
- const isAutoOpenedDefined =
111
- userPreferences && typeof userPreferences . autoOpen !== "undefined" ;
104
+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
105
+ chrome . storage . local . get ( 'userPreferences' , ( { userPreferences } ) => {
106
+ const isAutoOpenedDefined = userPreferences && typeof userPreferences . autoOpen !== 'undefined' ;
112
107
113
108
if ( isAutoOpenedDefined ) {
114
109
autoOpenRadio . checked = userPreferences . autoOpen ;
@@ -119,7 +114,7 @@ document.addEventListener("DOMContentLoaded", () => {
119
114
} ) ;
120
115
121
116
setTimeout ( ( ) => {
122
- toggle . classList . add ( " withTransition" ) ;
117
+ toggle . classList . add ( ' withTransition' ) ;
123
118
} , 200 ) ;
124
119
} ) ;
125
120
@@ -130,5 +125,5 @@ const handleChangeAutoOpenPreferences = (e) => {
130
125
chrome . storage . local . set ( { userPreferences : preferences } ) ;
131
126
} ;
132
127
133
- openEditorButton . addEventListener ( " click" , handleOpenEditor ) ;
134
- autoOpenRadio . addEventListener ( " change" , handleChangeAutoOpenPreferences ) ;
128
+ openEditorButton . addEventListener ( ' click' , handleOpenEditor ) ;
129
+ autoOpenRadio . addEventListener ( ' change' , handleChangeAutoOpenPreferences ) ;
0 commit comments