SAMP browser plugin? Re: SAMP and HTTPS workaround?
Zorba, Sonia
sonia.zorba at inaf.it
Thu Oct 17 15:17:51 CEST 2019
Dear all,
I'm not completely sure you received my previous mail (I wasn't in the
apps-samp list yet). Anyway, I would just like to share some results
I've found.
I did a couple of experiments and I was able to perform an http call
from an https page using a Browser Extension (same code for Firefox
and Chrome).
Indeed the docs specify that extensions can obtain extra permissions:
«XMLHttpRequest and fetch access to those origins without cross-origin
restrictions» (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions)
To achieve this it is necessary to add the specific permission in the
manifest.json:
"permissions": [
"*://localhost/*"
]
Browser Extensions have 2 kinds of scripts: content script and
background script.
Firefox allows the cross-origin call from both the scripts, Chrome
only from the background script (solvable passing from the content
script to the background script: https://stackoverflow.com/a/55215898)
Trying to do the call from the content script Chrome blocks the
request due to CORB (another recent thing to consider together with
CORS, https://www.chromium.org/Home/chromium-security/corb-for-developers)
I didn't receive any "mixed content" error.
A custom event can be used to call the extension content script from a
page script:
document.dispatchEvent(new CustomEvent('eventToSampExtension', {
detail: data }));
So, the flow could be something like: page script --(event)->
extension content script --(extension API)-> extension background
script --(http)-> SAMP hub
I hope to be able to share some working code in the next weeks.
Cheers,
Sonia
Il giorno gio 17 ott 2019 alle ore 11:07 Thomas Boch
<thomas.boch at astro.unistra.fr> ha scritto:
>
> Mark,
>
> Le 14/10/2019 à 18:33, Mark Taylor a écrit :
> > I think the only way to take this forward is to experiment and
> > try it out, so we'd need some volunteers to try to write plugins
> > for different browsers. Writing browser plugins is far from
> > my area of expertise, so I'm not volunteering. Sonia Zorba
> > suggested in Groningen that she might be willing to have a go,
> > and Thomas's "quite like the idea of developing a plugin" sounds
> > like it could be an offer too...
>
> Yes indeed, that's something I'm willing to experiment with.
>
> Thomas
More information about the apps-samp
mailing list