Skip to content
This repository has been archived by the owner on Jul 26, 2020. It is now read-only.

MS Edge compatibility #103

Open
wants to merge 6 commits into
base: 1.0
Choose a base branch
from
Open

MS Edge compatibility #103

wants to merge 6 commits into from

Conversation

mazmazz
Copy link

@mazmazz mazmazz commented Oct 1, 2018

Closes #34. Edge loads this extension with the following changes:

  • manifest.json: Add author field
  • manifest.json: Add background.persistent = false
  • background.js: Define chrome.webRequest by pointing to browser.webRequest

It sideloads and works fine in all three browsers.

Packaging and submission info is here; I haven't looked into this personally. (edit: see comment, it works)

// MS Edge support
if (!chrome.webRequest) {
chrome.webRequest = browser.webRequest;
}
Copy link
Author

@mazmazz mazmazz Oct 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the best polyfill because of this compat weirdness:

  • Edge defines window.chrome already, but not chrome.webRequest.
  • Edge defines browser.webRequest as callback-based.
  • Firefox defines chrome.webRequest as callback-based and browser.webRequest as Promise-based.
  • Chrome defines chrome.webRequest as callback-based and does NOT define browser.webRequest.

So I could not directly use browser.webRequest because Chrome does not have it and Firefox implements it differently. I also could not do the single-line chrome.webRequest = chrome.webRequest || browser.webRequest because Chrome evaluates both expressions and errors out.

"version": "1.0",
"description": "This extension will mangle your browser's requests to maximize the chances of bypassing paywalls.",
"permissions": ["webRequest", "webRequestBlocking", "*://*/*"],
"background": {
"scripts": ["background.js"]
"scripts": ["background.js"],
"persistent": false
Copy link
Author

@mazmazz mazmazz Oct 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

background.persistent is required for Edge. Chrome says to use false for background scripts (and I assume this is default).

Firefox outputs this warn message upon side-loading, but otherwise the extension works fine. It comes across as an error, but is actually a warn. See Bugzilla issue on changing this message. I don't think this affects the user install experience, but I'm unfamiliar with that process.

image

@mazmazz
Copy link
Author

mazmazz commented Oct 2, 2018

Edge extension packaging works. See test package: anti-paywall-9044fce.zip

I followed the instructions here:

For submission, you would need to provide the app icon at 44x44, 50x50, and 150x150. You would also need to sign up with Windows Dev Center and input the supplied Identity keys in the packaging step. See first link for more details.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant