diff options
author | Teddy Wing | 2021-02-09 01:55:38 +0100 |
---|---|---|
committer | Teddy Wing | 2021-02-09 01:55:38 +0100 |
commit | a32473a3f82e926b6a6ad73c32d485fbe27aadda (patch) | |
tree | 6a3aba941d7f6524c6223332f27486826989b5c1 | |
parent | ed11bce205dfd257a1cdb2ff3c3f96790a16e88b (diff) | |
download | extreload-a32473a3f82e926b6a6ad73c32d485fbe27aadda.tar.bz2 |
Always reload current tab after reloading an extension
A bit crude, but it covers us when extensions are in multiple Chrome
profiles. This ensures the desired tab is reloaded because all current
tabs in all profiles that have requested extensions are reloaded.
Not very intelligent, but a simple approach.
-rw-r--r-- | l/src/devtools-protocol.lisp | 3 | ||||
-rw-r--r-- | l/src/main.lisp | 23 |
2 files changed, 15 insertions, 11 deletions
diff --git a/l/src/devtools-protocol.lisp b/l/src/devtools-protocol.lisp index 41a408e..3923eaf 100644 --- a/l/src/devtools-protocol.lisp +++ b/l/src/devtools-protocol.lisp @@ -24,6 +24,9 @@ ("method" . "Runtime.evaluate") ("params" . (:obj ("expression" . ,expression)))))) +(defun runtime-evaluate-msg-p (message) + (jsown:keyp (json-obj-get message "result") "sessionId")) + (defun parse-get-targets-response (response) (let* ((result (json-obj-get response "result")) (targetInfos (json-obj-get result "targetInfos"))) diff --git a/l/src/main.lisp b/l/src/main.lisp index c2177e5..22c1d07 100644 --- a/l/src/main.lisp +++ b/l/src/main.lisp @@ -75,17 +75,18 @@ ; Response: (OBJ (id . 2) ; (result OBJ (sessionId . C24A99CA53CBD76EB68BCBD0D172A4E7))) - (when reload-current-tab + (when (and reload-current-tab + (runtime-evaluate-msg-p response)) ; (when (and (= (or (json-obj-get response "id") -1) 1) - (when (and - (= *reloaded-count* - ;; TODO: Probably want to reload on all extension reload calls - *extension-targets-count*) - - (string= (json-obj-get - (json-obj-get response "result") - "sessionId") - *last-session-id*)) + ; (when (and + ; (= *reloaded-count* + ; ;; TODO: Probably want to reload on all extension reload calls + ; *extension-targets-count*) + ; + ; (string= (json-obj-get + ; (json-obj-get response "result") + ; "sessionId") + ; *last-session-id*)) ; (let ((current-call-id (json-obj-get response "id"))) ; (when (and current-call-id ; (= current-call-id @@ -94,7 +95,7 @@ ; (sleep 1) (reload-tab (json-obj-get (json-obj-get response "result") - "sessionId")))) + "sessionId"))) ;; Failed to reload tab. (when (jsown:keyp (json-obj-get response "result") "exceptionDetails") |