Skip to content

Commit 27b14ad

Browse files
authored
fix: execute sensor script on unloaded (#180)
1 parent 9940b81 commit 27b14ad

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

static/background.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function courier(tabId, changed) {
7070
// because `detail` in the dispatched custom events is `null`
7171
const script = document.createElement('script');
7272
script.setAttribute('src', source);
73-
document.documentElement.appendChild(script);
73+
document.head.appendChild(script);
7474

7575
// // TODO: reenable profiler
7676
// if (message.type === 'bridge::ext/profiler' && message.payload) {
@@ -108,7 +108,7 @@ function courier(tabId, changed) {
108108

109109
chrome.tabs.onActivated.addListener(({ tabId }) => sensor(tabId));
110110
chrome.tabs.onUpdated.addListener(
111-
(tabId, changed) => changed.status === 'loading' && sensor(tabId),
111+
(tabId, changed) => changed.status === 'unloaded' && sensor(tabId),
112112
);
113113

114114
/** @param {number} tabId */
@@ -122,7 +122,7 @@ async function sensor(tabId) {
122122
document.querySelector(`script[src="${source}"]`)?.remove();
123123
const script = document.createElement('script');
124124
script.setAttribute('src', source);
125-
document.documentElement.appendChild(script);
125+
document.head.appendChild(script);
126126

127127
document.addEventListener('SvelteDevTools', ({ detail }) => {
128128
chrome.runtime.sendMessage(detail);

0 commit comments

Comments
 (0)