Skip to content

Commit 5a89555

Browse files
committed
use static method to inject script
1 parent 690037a commit 5a89555

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

packages/dev/style-macro-chrome-plugin/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ If the panel isn't updating with styles, try closing the dev tools and reopening
2727

2828
If the extension doesn't appear to have the latest code, try closing the dev tools and reopening it.
2929

30+
If every tab you have open (or many of them) reload when you make local changes to the extension, then go into the extension settings and limit it to `localhost` or something appropriate.
31+
3032
## ToDos
3133

3234
- [ ] Work with RSC

packages/dev/style-macro-chrome-plugin/src/devtool.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
1-
let injectScript = () => {
2-
chrome.scripting.executeScript({
3-
target: {
4-
tabId: chrome.devtools.inspectedWindow.tabId,
5-
allFrames: true
6-
},
7-
files: chrome.runtime.getManifest().content_scripts[0].js
8-
});
9-
};
101

11-
injectScript();
12-
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
13-
if (tabId === chrome.devtools.inspectedWindow.tabId && changeInfo.status === 'complete' && tab.active) {
14-
injectScript();
15-
}
16-
});
172

183
chrome.devtools.panels.elements.createSidebarPane('Style Macros', (sidebar) => {
194
sidebar.setObject({});

packages/dev/style-macro-chrome-plugin/src/manifest.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"devtools_page": "devtools.html",
66
"content_scripts": [{
77
"matches": ["*://*/*"],
8-
"js": ["content-script.js"]
8+
"js": ["content-script.js"],
9+
"all_frames": true,
10+
"run_at": "document_start"
911
}]
1012
}

0 commit comments

Comments
 (0)