Skip to content

Commit

Permalink
chore: comments about chrome in executeScript (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatiusmb authored Apr 15, 2024
1 parent 7603461 commit 86c67dc
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions static/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ function courier(tabId, changed) {
// a limbo world where both `chrome` and `window` are defined
// with many unexpected and out of the ordinary behaviors, do
// minimal work here and delegate to `courier.js` in the page.
// only a subset of APIs are available in this `chrome` limbo
// - chrome.csi->f()
// - chrome.dom.{openOrClosedShadowRoot->f()}
// - chrome.extension.{ViewType, inIncognitoContext}
// - chrome.i18n
// - chrome.runtime
func: () => {
const source = chrome.runtime.getURL('/courier.js');
if (document.querySelector(`script[src="${source}"]`)) return;
Expand All @@ -72,24 +78,9 @@ function courier(tabId, changed) {
script.setAttribute('src', source);
document.head.appendChild(script);

// // TODO: reenable profiler
// if (message.type === 'bridge::ext/profiler' && message.payload) {
// // start profiler
// }

chrome.runtime.onMessage.addListener((message, sender) => {
if (sender.id !== chrome.runtime.id) return; // unexpected sender
window.postMessage(message); // relay to content script (courier.js)

// switch (message.type) {
// case 'startProfiler':
// window.sessionStorage.SvelteDevToolsProfilerEnabled = 'true';
// break;
// case 'stopProfiler':
// case 'bridge::ext/clear':
// delete window.sessionStorage.SvelteDevToolsProfilerEnabled;
// break;
// }
});

window.addEventListener('message', ({ source, data }) => {
Expand Down

0 comments on commit 86c67dc

Please sign in to comment.