Skip to content

Commit 755bf41

Browse files
committed
browser extension: finish migrating Chrome to manifest v3
1 parent d85f7ac commit 755bf41

File tree

5 files changed

+70
-21
lines changed

5 files changed

+70
-21
lines changed

README.md

+17-12
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ Here's how to send them in with a bug report:
133133

134134
Browser extension: release
135135
---
136-
Here's how to cut a new release of the browser extension and publish it [to addons.mozilla.org](https://addons.mozilla.org/en-US/firefox/addon/bridgy/) and [to the Chrome Web Store](https://chrome.google.com/webstore/detail/bridgy/lcpeamdhminbbjdfjbpmhgjgliaknflj):
136+
Here's how to cut a new release of the browser extension and publish it [to addons.mozilla.org](https://addons.mozilla.org/en-US/firefox/addon/bridgy/):
137137

138-
1. Load the extension in Firefox (`about:debugging`) and Chrome (`chrome://extensions/`, Developer mode on). Check that it works in both.
138+
1. `ln -fs manifest.firefox.json manifest.json`
139+
1. Load the extension in Firefox (`about:debugging`). Check that it works.
139140
1. Bump the version in `browser-extension/manifest.json`.
140141
1. Update the Changelog in the README.md section below this one.
141142
1. Build and sign the artifact:
@@ -156,21 +157,25 @@ Here's how to cut a new release of the browser extension and publish it [to addo
156157
...
157158
```
158159
It's usually auto-approved within minutes. [Check the public listing here.](https://addons.mozilla.org/en-US/firefox/addon/bridgy/)
159-
1. Submit it to the Chrome Web Store:
160-
1. [Open the console.](https://chrome.google.com/webstore/devconsole/)
161-
1. Open the Bridgy item. Ryan to add you if you don't see it.
162-
1. Choose _Package_ on the left.
163-
1. Click the _Upload new package_ button.
164-
1. Upload the new version's zip file from `browser-extension/web-ext-artifacts/`.
165-
1. Update the Changelog in the _Description_ box. Leave the rest unchanged.
166-
1. Click _Save draft_, then _Submit for review_.
160+
161+
Here's how to publish it [to the Chrome Web Store](https://chrome.google.com/webstore/detail/bridgy/lcpeamdhminbbjdfjbpmhgjgliaknflj):
162+
163+
1. `ln -fs manifest.chrome.json manifest.json`
164+
1. Load the extension in Chrome (`chrome://extensions/`, Developer mode on). Check that it works.
165+
1. [Open the console.](https://chrome.google.com/webstore/devconsole/)
166+
1. Open the Bridgy item. Ryan to add you if you don't see it.
167+
1. Choose _Package_ on the left.
168+
1. Click the _Upload new package_ button.
169+
1. Upload the new version's zip file from `browser-extension/web-ext-artifacts/`.
170+
1. Update the Changelog in the _Description_ box. Leave the rest unchanged.
171+
1. Click _Save draft_, then _Submit for review_.
167172

168173

169174
Browser extension: Changelog
170175
---
171-
0.6, unreleased
176+
0.6.0, 2022-09-17
172177

173-
* [Migrate from Manifest v2 to v3.](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/#man-sw) ([Ugh.](https://blog.mozilla.org/addons/2022/05/18/manifest-v3-in-firefox-recap-next-steps/))
178+
* Migrate Chrome ([but not Firefox](https://blog.mozilla.org/addons/2022/05/18/manifest-v3-in-firefox-recap-next-steps/)) [from Manifest v2 to v3](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/#man-sw).
174179

175180
0.5, 2022-07-21
176181

browser-extension/common.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,18 @@ class Silo {
312312
* @returns {String} Response body from the silo
313313
*/
314314
static async siloGet(url) {
315-
// Set up cookies. Can't use credentials: include in the fetch API because
316-
// it requires the server to support CORS, with only some values for
315+
// Set up cookies. Distinguish between browsers by checking for webRequest.
316+
//
317+
// Chrome with manifest v3
318+
// ===
319+
// We extract cookies and pass the Cookie header to fetch() directly. Didn't
320+
// work in manifest v2, but does work in v3. Requires the cookies permission
321+
// and instagram.com and facebook.com in host_permissions.
322+
//
323+
// Firefox with manifest v2
324+
// ===
325+
// Can't use credentials: include in the fetch API because it requires the
326+
// server to support CORS, with only some values for
317327
// Access-Control-Allow-Origin, specifically not *, and it also doesn't work
318328
// with Firefox Container Tabs.
319329
// https://zellwk.com/blog/handling-cookies-with-fetchs-credentials/
@@ -337,7 +347,7 @@ class Silo {
337347
}
338348

339349
const inject = this.injectCookies(cookies)
340-
if (!browser.webRequest.onBeforeSendHeaders.hasListener(inject)) {
350+
if (browser.webRequest && !browser.webRequest.onBeforeSendHeaders.hasListener(inject)) {
341351
browser.webRequest.onBeforeSendHeaders.addListener(
342352
inject,
343353
{urls: [`*://*.${this.DOMAIN}/*`]},
@@ -359,7 +369,7 @@ class Silo {
359369

360370
// Make HTTP request
361371
console.debug(`Fetching ${url}`)
362-
const headers = {'X-Bridgy': '1'}
372+
const headers = browser.webRequest ? {'X-Bridgy': '1'} : {'Cookie': cookies}
363373
Object.assign(headers, this.headers())
364374
const res = await fetch(url, {
365375
method: 'GET',

browser-extension/manifest.chrome.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
"description": "Bridgy connects your web site to social media. This extension adds Facebook and Instagram support.",
55
"homepage_url": "https://brid.gy/",
66
"manifest_version": 3,
7-
"minimum_chrome_version": "74",
7+
"minimum_chrome_version": "88",
88
"permissions": [
99
"alarms",
10-
"contextualIdentities",
1110
"cookies",
12-
"storage",
13-
"webRequest",
14-
"webRequestBlocking"
11+
"storage"
1512
],
1613
"host_permissions": [
1714
"*://*.brid.gy/*",
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "Bridgy",
3+
"version": "0.6.0",
4+
"description": "Bridgy connects your web site to social media. This extension adds Facebook and Instagram support.",
5+
"homepage_url": "https://brid.gy/",
6+
"manifest_version": 3,
7+
"minimum_chrome_version": "74",
8+
"applications": {
9+
"gecko": {
10+
11+
"strict_min_version": "67.0"
12+
}
13+
},
14+
"permissions": [
15+
"alarms",
16+
"contextualIdentities",
17+
"cookies",
18+
"storage"
19+
],
20+
"host_permissions": [
21+
"*://*.brid.gy/*",
22+
"*://*.instagram.com/*",
23+
"*://*.facebook.com/*"
24+
],
25+
"background": {
26+
"page": "background.html"
27+
},
28+
"icons": {
29+
"128": "bridgy_logo_128.jpg",
30+
"1024": "bridgy_logo_square_1024.jpg"
31+
},
32+
"options_ui": {
33+
"page": "options.html",
34+
"browser_style": true
35+
}
36+
}

browser-extension/manifest.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
manifest.firefox.v3.json

0 commit comments

Comments
 (0)