Skip to content

Commit

Permalink
fix: execute sensor script on unloaded (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatiusmb authored Dec 8, 2023
1 parent 9940b81 commit 27b14ad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions static/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function courier(tabId, changed) {
// because `detail` in the dispatched custom events is `null`
const script = document.createElement('script');
script.setAttribute('src', source);
document.documentElement.appendChild(script);
document.head.appendChild(script);

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

chrome.tabs.onActivated.addListener(({ tabId }) => sensor(tabId));
chrome.tabs.onUpdated.addListener(
(tabId, changed) => changed.status === 'loading' && sensor(tabId),
(tabId, changed) => changed.status === 'unloaded' && sensor(tabId),
);

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

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

0 comments on commit 27b14ad

Please sign in to comment.