aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.lisp
diff options
context:
space:
mode:
authorTeddy Wing2023-11-12 12:23:52 +0100
committerTeddy Wing2023-11-12 12:27:42 +0100
commitff7eb76be6e8a6aa1e5ee5f3cc3efac8455e9daf (patch)
tree10b405b40433e3019455c0c4bb246c93fb6879d9 /src/main.lisp
parentd2aebc157aaaac786b066fe00c2abf122d4f1f0e (diff)
downloadextreload-ff7eb76be6e8a6aa1e5ee5f3cc3efac8455e9daf.tar.bz2
Track Manifest V3 extensions in a list
I want to keep track of Manifest V3 extensions, because these must be re-attached to in order to reload the tab. We will later look at this list to find out if we need to skip reloading the extension (it's already been done), and instead proceed directly to reloading the tab.
Diffstat (limited to 'src/main.lisp')
-rw-r--r--src/main.lisp46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/main.lisp b/src/main.lisp
index 79d0a4a..3bc79c8 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -23,6 +23,8 @@
"DevTools Protocol call ID.")
(defvar *devtools-secondary-call-id* (make-instance 'call-id)
"DevTools Protocol call ID used for messages to individual target sessions.")
+(defvar *extensions* '()
+ "TODO")
(defconstant +timeout-seconds+ 5
"Global timeout. The program will exit at the end of this delay.")
@@ -70,9 +72,27 @@
(attach-extensions targets extension-ids)))
(when (target-attached-to-target-msg-p response)
- (reload-extension (json-obj-get
- (json-obj-get response "params")
- "sessionId")))
+ (track-service-worker-target response)
+
+ (reload-extension (json-obj-get
+ (json-obj-get response "params")
+ "sessionId")))
+
+ ; (format t "EXTENSIONS: ~a~%" *extensions*)
+
+ (when (and (reload-current-tab config)
+ (inspector-target-crashed-msg-p response))
+ ;; Attach to target again
+ ;; then somehow reload the tab
+ ;; And need to only do this for MV3 extensions
+
+ ;; Loop through *extensions*, if sessionId matches, then send attach message to extension
+ ;; Need to get new targets, and attach to all MV3 extensions again
+ (websocket-send
+ (ws-client *config*)
+ (target-get-targets-msg
+ (next-call-id *devtools-root-call-id*)))
+ )
(when (and (reload-current-tab config)
(runtime-evaluate-msg-p response))
@@ -161,6 +181,26 @@ the target to reload the current tab."
(filter #'extensionp targets)))
+(defun track-service-worker-target (target)
+ "TODO"
+ (let* ((params (json-obj-get target "params"))
+ (target-info (json-obj-get params "targetInfo")))
+
+ (when (string= (json-obj-get target-info "type")
+ "service_worker")
+ (push
+ (make-instance 'extension
+ :id (subseq
+ (json-obj-get target-info "url")
+
+ ;; Remove "chrome-extension://".
+ 19
+
+ ;; Extension IDs are 32 characters long.
+ (+ 19 32))
+ :session-id (json-obj-get params "sessionId"))
+ *extensions*))))
+
(defun websocket-send (client data)
"Send `data` to WebSocket `client` and increment `*wg*`."
(when (debug-output *config*)