Search code examples
google-chromemeteorxssbrowser-extensionddp

Can I use meteor in a Google Chrome web extension content script?


I have found tutorials, videos, and SO questions that explain how to use meteor.js in a Chrome extension. The pattern they use is to do all the meteor stuff (usually via DDP) in the background script. Then the content script that is injected into the user's web page talks to the background script using the runtime.sendMessage or similar from the Chrome API.

I don't like having this extra layer of messaging; I'd like to interact with the meteor db directly from the content script.

I have a vague feeling that that would be impossible due to security policies (cross-site stuff?) but am not sure. I'll probably just try and do it, but can anyone save me some time by explaining why this is impossible or imprudent?


Solution

  • Yes, I can, it turns out. It's working fine, and the code is at https://github.com/foobarbecue/gottafixit/ . The only problem I've run into so far is displaying the facebook login popup because content scripts don't have access to chrome.tabs.create() .