@@ -18,13 +18,13 @@ fetch("data.json")
18
18
key : zeuz_key ,
19
19
nodeId : zeuz_node_id ,
20
20
} ,
21
- function ( ) {
22
- console . log ( "Logged in successfully!" ) ;
23
- } ) ;
21
+ function ( ) {
22
+ console . log ( "Logged in successfully!" ) ;
23
+ } ) ;
24
24
} ) ;
25
25
26
26
function logout ( ) {
27
- browserAppData . storage . local . remove ( [ 'key' ] , function ( ) {
27
+ browserAppData . storage . local . remove ( [ 'key' ] , function ( ) {
28
28
alert ( "Logged out successfully!" ) ;
29
29
} ) ;
30
30
}
@@ -40,11 +40,11 @@ const inspect = {
40
40
// files: [inspectFile]
41
41
// });
42
42
browserAppData . tabs . sendMessage ( id , {
43
- action : type
44
- } ) . then ( ( response ) => {
45
- console . log ( "Message from the content script:" ) ;
46
- console . log ( response ) ;
47
- } )
43
+ action : type
44
+ } ) . then ( ( response ) => {
45
+ console . log ( "Message from the content script:" ) ;
46
+ console . log ( response ) ;
47
+ } )
48
48
. catch ( ( error ) => {
49
49
console . error ( `Error: ${ error } ` )
50
50
} ) ;
@@ -77,7 +77,7 @@ function toggle(tab) {
77
77
78
78
if ( ! isSupportedProtocolAndFileType ( tab . url ) ) return ;
79
79
80
- if ( ! tabs [ tab . id ] ) {
80
+ if ( ! tabs [ tab . id ] ) {
81
81
tabs [ tab . id ] = Object . create ( inspect ) ;
82
82
inspect . toggleActivate ( tab . id , 'activate' , activeIcon ) ;
83
83
}
@@ -128,42 +128,56 @@ browserAppData.commands.onCommand.addListener(command => {
128
128
browserAppData . tabs . onUpdated . addListener ( getActiveTab ) ;
129
129
browserAppData . action . onClicked . addListener ( toggle ) ;
130
130
console . log ( navigator . userAgentData . platform ) ;
131
- if ( navigator . userAgentData . platform . toLowerCase ( ) . includes ( 'mac' ) ) {
132
- browserAppData . action . setTitle ( {
133
- title : "Cmd + Shift + X"
134
- } ) ;
131
+ if ( navigator . userAgentData . platform . toLowerCase ( ) . includes ( 'mac' ) ) {
132
+ browserAppData . action . setTitle ( {
133
+ title : "Cmd + Shift + X"
134
+ } ) ;
135
135
}
136
136
browserAppData . runtime . onMessage . addListener (
137
- function ( request , sender , sendResponse ) {
138
- if ( request . apiName == 'ai_record_single_action' ) {
139
- var url = `${ zeuz_url } /ai_record_single_action/`
140
- fetch ( url , {
141
- method : "POST" ,
142
- headers : {
143
- // "Content-Type": "application/json",
144
- "X-Api-Key" : zeuz_key ,
145
- } ,
146
- body : request . data ,
147
- } )
148
- . then ( response => response . json ( ) )
149
- . then ( text => { console . log ( text ) ; sendResponse ( text ) ; } )
150
-
151
- var url = `${ zeuz_url } /node_ai_contents/`
152
- fetch ( url , {
153
- method : "POST" ,
154
- headers : {
155
- // "Content-Type": "application/json",
156
- "X-Api-Key" : zeuz_key ,
157
- } ,
158
- body : JSON . stringify ( {
159
- "dom_web" : { "dom" : request . html } ,
160
- "node_id" : zeuz_node_id
161
- } ) ,
162
- } )
163
- . then ( response => response . json ( ) )
164
- . then ( text => { console . log ( text ) ; sendResponse ( text ) ; } )
165
-
166
- return true ; // Will respond asynchronously.
167
- }
137
+ function ( request , sender , sendResponse ) {
138
+ if ( request . apiName == 'ai_record_single_action' ) {
139
+ var url = `${ zeuz_url } /ai_record_single_action/`
140
+ fetch ( url , {
141
+ method : "POST" ,
142
+ headers : {
143
+ // "Content-Type": "application/json",
144
+ "X-Api-Key" : zeuz_key ,
145
+ } ,
146
+ body : request . data ,
147
+ } )
148
+ . then ( response => response . json ( ) )
149
+ . then ( text => { console . log ( text ) ; sendResponse ( text ) ; } )
150
+
151
+ var url = `${ zeuz_url } /node_ai_contents/`
152
+ fetch ( url , {
153
+ method : "POST" ,
154
+ headers : {
155
+ // "Content-Type": "application/json",
156
+ "X-Api-Key" : zeuz_key ,
157
+ } ,
158
+ body : JSON . stringify ( {
159
+ "dom_web" : { "dom" : request . html } ,
160
+ "node_id" : zeuz_node_id
161
+ } ) ,
162
+ } )
163
+ . then ( response => response . json ( ) )
164
+ . then ( text => { console . log ( text ) ; sendResponse ( text ) ; } )
165
+
166
+ return true ; // Will respond asynchronously.
167
+ } else if ( request . apiName == 'node_ai_contents' ) {
168
+ fetch ( url , {
169
+ method : "POST" ,
170
+ headers : {
171
+ // "Content-Type": "application/json",
172
+ "X-Api-Key" : zeuz_key ,
173
+ } ,
174
+ body : JSON . stringify ( {
175
+ "dom_web" : { "dom" : request . dom } ,
176
+ "node_id" : zeuz_node_id
177
+ } ) ,
178
+ } )
179
+ . then ( response => response . json ( ) )
180
+ . then ( text => { console . log ( text ) ; sendResponse ( text ) ; } )
181
+ }
168
182
}
169
- ) ;
183
+ ) ;
0 commit comments