English 中文(简体)
Opera extensions (widgets): dynamic config file
原标题:

I have an Opera 11 extension, which has a background process and an injected script. These communicate very frequently with a remote server (not the webpage the user s viewing), using the background script s cross-site XMLHttpRequest capabilities.

I would like the URL of the server to be a preference, so that it can be modified by the user without editing the package. The config.xml file would good, for it accepts <preference name="serverUri" value="..." />. However, I would like the script to be able to update itself directly from the server (not through Opera s site), which can be achieved using <update-description href="http://myserver.com/client/update" />.

So what I would like to do is have the href attribute of the update-description element to be dependent on the value of the preference serverUri. I would imagine some syntax like this:

<update-description href="{$serverUri}" />

But I could not find any references to this kind of functionality. Is there some way to solve this?

问题回答

It s not possible to use variables in the config.xml file as you ve written and I don t think there are plans to add this.

I m sure you know that preferences can be set not just with the preference element in config.xml but also using widget.setPreferenceForKey(value, key), but I don t think that solves your problem in this case.

The only workaround I can think of is if you have all your logic in an external script on your server and in your extension s local files (background script or injected script), just have a very simple couple of lines that reference your external script. Something like:

var script = document.createElement( script );
script.src =  http://www.example.com/script.js ;
document.body.appendChild(script);

You could then make the script s URL editable by the user and store it in widget.preferences.

EDIT by hallvors: This solution has serious drawbacks, see my comment below.

As far as I know this is not currently possible. It seems like a bit of an unusual use case, which could potentially be risky to implement, so it would be interesting to hear more about why you want to do this.





相关问题
How to Wrap unspaces word for Opera Browser

I am currently testing this function in all browser using php. <style> #preview_desc{ text-wrap: suppress; word-break: break-all; word-wrap: break-word; /* IE>=5.5 */ white-...

Opera, custom context menu, picking up the right click

I want to implement a custom context menu on a site that I am working on. I have used document.oncontextmenu which works with all, except Opera, the main browsers that I am developing for. How would ...

Disable Opera s autocomplete

Opera s autocomplete function draws a yellow border around text inputs where it saved data. Is there any way to disable it programmatically? Here s a picture to illustrate it: opera autocomplete http:...

Access to 127.0.0.1 by default in Opera 10?

Unlike other browsers (IE, FF, Chrome) Opera 10 doesn t allow websites to access content from localhost. Only when 127.0.0.1 is explicitly added to the trusted websites list in Opera does this work - ...

sifr: Opera-Bug: Flash Object too wide

I have used sifr to replace the fonts for headlines. It works fine in Firefox and IE. http://design.speak-friend.com/ In Opera however, the headlines of the articles (object-tag within a-tag with-in ...

Font rendering differently in Opera 9

The font is rendering as a serif in Opera 9, image here in case you re curious and don t have Opera 9: image I ve looked around but can t seem to find why Opera 9 wouldn t listen to the CSS for font-...

热门标签