trying to add a default recipient to "Email This Page" extension
I'm trying to use the "Email This Page" example at http://code.google.com/chrome/extensions/samples.html as a base and make my own first Chrome Extension.
What I want to do is simple enough: I want to add a default email address for the recipient.
Unfortunately I cannot seem to find a description of the Chrome Email API.
Anyway, my attempts to add another JSON object/parameter to the additionalInfo variable have included several variations on:
var additionalInfo = 开发者_开发技巧{
"title": document.title,
"selection": window.getSelection().toString(),
"mailto": 'foo@foobar.com' // my code
};
chrome.extension.connect().postMessage(additionalInfo);
I have also tried playing around in the "options.html" file trying to find a 'mailto' call to edit, but again no luck.
I'm beginning to wonder if the API used isn't an external one - perhaps I'm looking in the wrong places for the answer.
anyway - help would be nice. b
You just need to modify the background page:
function executeMailto(tab_id, subject, body, selection, mailto) {
var default_handler = customMailtoUrl().length == 0;
var action_url = "mailto:" + mailto + "?";
...
}
...
chrome.extension.onConnect.addListener(function(port) {
...
executeMailto(tab.id, info.title, tab.url, info.selection, info.mailto);
...
});
精彩评论