Skip to content

Commit 93187c9

Browse files
authored
Merge pull request #7 from oslabs-beta/robby/manifest-migration
Robby/manifest migration - all updates to the Manifest now compliant with V3 policies. Request for approval on Chrome Store being submitted.
2 parents 442b23f + 4ca2d61 commit 93187c9

File tree

4 files changed

+33
-47
lines changed

4 files changed

+33
-47
lines changed

src/extension/background.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Import snapshots from "../app/components/snapshots".
2-
import 'core-js';
2+
// import 'core-js';
3+
34
// Store ports in an array.
45
const portsArr = [];
56
const reloaded = {};
@@ -198,13 +199,10 @@ chrome.runtime.onConnect.addListener(port => {
198199
tabsObj[tabId].mode.persist = payload;
199200
return true;
200201
case 'launchContentScript':
201-
// !!! in Manifest Version 3 this will need to be changed to the commented out code below !!!
202-
// chrome.scripting.executeScript({
203-
// target: { tabId },
204-
// files: ['bundles/content.bundle.js'],
205-
// });
206-
// This line below will need to be removed
207-
chrome.tabs.executeScript(tabId, { file: 'bundles/content.bundle.js' });
202+
chrome.scripting.executeScript({
203+
target: { tabId },
204+
files: ['bundles/content.bundle.js'],
205+
});
208206
return true;
209207
case 'jumpToSnap':
210208
chrome.tabs.sendMessage(tabId, msg);
@@ -282,19 +280,20 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
282280
// This injects a script into the app that you're testing Reactime on,
283281
// so that Reactime's backend files can communicate with the app's DOM.
284282
case 'injectScript': {
285-
chrome.tabs.executeScript(tabId, {
286-
code: `
287-
// Function will attach script to the dom
288-
const injectScript = (file, tag) => {
289-
const htmlBody = document.getElementsByTagName(tag)[0];
290-
const script = document.createElement('script');
291-
script.setAttribute('type', 'text/javascript');
292-
script.setAttribute('src', file);
293-
document.title=${tabId} + '-' + document.title
294-
htmlBody.appendChild(script);
295-
};
296-
injectScript(chrome.runtime.getURL('bundles/backend.bundle.js'), 'body');
297-
`,
283+
const injectScript = (file, tab) => {
284+
const htmlBody = document.getElementsByTagName('body')[0];
285+
const script = document.createElement('script');
286+
script.setAttribute('type', 'text/javascript');
287+
script.setAttribute('src', file);
288+
// eslint-disable-next-line prefer-template
289+
document.title = tab + '-' + document.title;
290+
htmlBody.appendChild(script);
291+
};
292+
293+
chrome.scripting.executeScript({
294+
target: { tabId },
295+
function: injectScript,
296+
args: [chrome.runtime.getURL('bundles/backend.bundle.js'), tabId],
298297
});
299298
break;
300299
}

src/extension/build/manifest.json

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,28 @@
11
{
22
"name": "Reactime",
3-
"version": "13.0.0",
3+
"version": "14.0.0",
44
"devtools_page": "devtools.html",
55
"description": "A Chrome extension that helps debug React applications by memorizing the state of components with every render.",
6-
"manifest_version": 2,
7-
"content_security_policy": "script-src 'self' https://www.gstatic.com:* 'unsafe-eval'; object-src 'self'",
6+
"manifest_version": 3,
87
"background": {
9-
"scripts": [
10-
"bundles/background.bundle.js",
11-
"bundles/content.bundle.js"
12-
],
13-
"persistent": false
8+
"service_worker": "bundles/background.bundle.js"
149
},
1510
"icons": {
1611
"48": "assets/icon48.png",
1712
"128": "assets/icon128.png"
1813
},
1914
"content_scripts": [
2015
{
21-
"matches": [
22-
"http://localhost/*",
23-
"https://localhost/*"
24-
],
25-
"js": [
26-
"bundles/content.bundle.js"
27-
]
16+
"matches": ["<all_urls>"],
17+
"js": ["bundles/content.bundle.js"]
2818
}
2919
],
3020
"web_accessible_resources": [
31-
"bundles/backend.bundle.js"
21+
{
22+
"resources": ["bundles/backend.bundle.js"],
23+
"matches": ["<all_urls>"]
24+
}
3225
],
33-
"permissions": [
34-
"contextMenus",
35-
"tabs",
36-
"activeTab",
37-
"http://localhost/*",
38-
"https://localhost/*",
39-
"<all_urls>"
40-
]
26+
"permissions": ["contextMenus", "tabs", "activeTab", "scripting"],
27+
"host_permissions": ["<all_urls>"]
4128
}

src/extension/build/panel.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
7-
<title>Reactime 12.0</title>
7+
<title>Reactime 14.0</title>
88
</head>
99

1010
<body>
1111
<div id="root"></div>
1212
<script type="text/javascript" src="bundles/app.bundle.js"></script>
13-
<script type="text/javascript" src="https://www.gstatic.com/charts/49/loader.js"></script>
1413
</body>
1514
</html>

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const config = {
8282

8383
module.exports = (env, argv) => {
8484
if (argv.mode === 'development') {
85+
config.devtool = 'cheap-module-source-map';
8586
config.plugins.push(
8687
new ChromeExtensionReloader({
8788
entries: {

0 commit comments

Comments
 (0)