Noitidart / Chrome-Store-Foxified

Point and click to install extensions into your browser from the AMO, Chrome Web Store, Microsoft Store, or Opera Addons websites.
https://addons.mozilla.org/en-US/firefox/addon/chrome-store-foxified/?src=github
Mozilla Public License 2.0
363 stars 54 forks source link

Potential solution for communicating with AMO #126

Closed stevennyman closed 5 years ago

stevennyman commented 5 years ago

One potential solution for the CORS problem (#113, #107, #117, #122, etc.) might be to inject a content script onto any AMO page running in an invisible iframe with a specific URL such as https://addons.mozilla.org/en-US/firefox/null/ with "run_at": "document_start" and "all_frames": true. Then, fetch requests would be run from that page, and their results would be returned by monitoring the webRequest API for responses. (An example of the webrequest API can be found at https://github.com/mdn/webextensions-examples/tree/master/http-response.) Otherwise, response objects could be transferred via content script to background script communication methods such as messaging. Code can be injected to run as if it was on the page by including the following in the content script:

const script = document.createElement('script');
script.textContent = `[JavaScript to inject]`;
document.documentElement.appendChild(script);
script.remove();

(partially borrowed from https://stackoverflow.com/questions/55270830/intercepted-xhr-run-function-before-raising-load)

This should theoretically fix te extension without anyone having to invest in hosting servers and the like.

I'm not sure if I will have the time to implement something like this, so @Noitidart or someone else might want to look into it.

stoically commented 5 years ago

Firefox doesn't allow content scripts on restricted domains (such as AMO), so this won't work.

Noitidart commented 5 years ago

Thanks for brainstorming this! I missed this!

Noitidart commented 5 years ago

The solution by @stoically here seems the way to go - https://github.com/Noitidart/Chrome-Store-Foxified/issues/122#issuecomment-468782495 - if I get some time I'll prototype this out.

Noitidart commented 5 years ago

@stoically is there an issue with the domain fronter and having cookies?

stoically commented 5 years ago

@Noitidart Not sure, never used domain fronting myself, but looking at the CRXViewer code it seems that only specific request headers are modified, which should leave cookie headers intact.

stevennyman commented 5 years ago

I'm glad to see this extension gaining forward momentum again! :)

Noitidart commented 5 years ago

It's all thanks to the community!

On Mon, May 20, 2019 at 5:09 PM stevennyman notifications@github.com wrote:

I'm glad to see this extension gaining forward momentum again! :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Noitidart/Chrome-Store-Foxified/issues/126?email_source=notifications&email_token=ABQTZCJUVZV3U2U32CBSLSDPWM4VLA5CNFSM4HAVLYYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV2MPZY#issuecomment-494192615, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQTZCKIZJQCOAE77WK74N3PWM4VLANCNFSM4HAVLYYA .