I've been working on developing a Chrome extension with a feature that will display information from an external server, such as today's weather, in a popup within Gmail.
Methods attempted:
- Initially, I tried including the necessary JavaScript directly in the extension. However, making AJAX calls to my server violated the same-origin policy, rendering this method ineffective.
- Subsequently, I attempted to host the JavaScript file on the server and load it upon page load instead.
The content of my manifest.json file is as follows:
{
"name": "cvnosnvsdionfois",
"version": "0.1.0",
"manifest_version": 2,
"description": "sldnfksdngsdngods",
"browser_action": {
"default_icon": "images/icon.png"
},
"permissions": [
"http://api.flickr.com/", "webRequest",
"tabs",
"http://*localhost:8080*"
],
"content_scripts": [
{
"matches": ["https://mail.google.com/*"],
"js": ["http://localhost:8080/static/response.js"]
}
]
}
It has come to my attention that content scripts cannot be sourced from an external URL, which suggests that this approach may not work. Therefore, I am seeking advice on the correct strategy. How can I implement JavaScript code that runs directly within Gmail and communicates with my server? For instance, how does Smartr handle this?