Since injected script can't do cross domain xmlhttp requests I tried, as it is advised in the manuals to send message from injected script to background script for it to do the job. But I cannot get the messages to work.
This is my code, it is only three files, as simple extension as it could be.
config.xml
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" id="http://www.example.org/helloworld">
<name>postMessage-testcase</name>
<description>check if opera's postMessage fails</description>
</widget>
index.html
<!doctype html>
<html lang="en">
<head>
<script>
opera.extension.onmessage = function(event) {
alert("get the message!");
opera.extension.postMessage("posting reply");
};
</script>
</head>
<body></body>
</html>
includes/user.js
// ==UserScript==
// @include *apod.nasa.gov*
// ==/UserScript==
opera.extension.onmessage = function(event) {
alert("got reply !");
};
alert("yep, I'm on apod, proceeding with messages");
opera.extension.postMessage("message body");
The script should send back and forth messages when user opens apod.nasa.gov, but only one msg is send here, no messaging is taking place, also no error show up in the console.