我正在尝试为 Opera 编写我的第一个扩展。它的快速拨号扩展。我希望它向我显示来自网站的一些数据,但要访问这些数据,我需要登录。
我已经登录了,opera 知道 ;-) (当我在 Opera 的地址栏中输入网站地址时,一切正常。)我希望 Opera 告诉 JS,我已经登录了 ;-)
但是当我尝试在 js 中获取该网站时,我收到了一条文本,上面写着我需要登录:
r_xmlhttp.open("GET",url,true);
//r_xmlhttp.withCredentials = 'true'; //even with that on, nothing changes.
r_xmlhttp.onreadystatechange = user_func;
r_xmlhttp.send();
我的 config.xml(那是教程中的一个;-),添加了访问源和功能 Opera:share-cookies:
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" id="http://example.com/SimpleClockSD" defaultlocale="en" viewmodes="minimized">
<name short="Simple Clock">Clock Speed Dial Extension</name>
<description>This is an example Speed Dial extension showing a simple clock.</description>
<author href="http://people.opera.com/danield/">Daniel Davis</author>
<icon src="images/icon_64.png"/> <!-- Icon source: http://www.openclipart.org/detail/17552 -->
<feature name="opera:share-cookies" required="false"/>
<access origin="http://wykop.pl" subdomains="true"/>
<feature name="opera:speeddial" required="false">
<param name="url" value="http://wykop.pl"/>
</feature>
</widget>
我查看了wireshark的情况,我可以看出Opera发送了除JS之外的其他cookie,这就是JS说我没有登录的原因。但我希望JS发送与opera发送的相同的cookie,理论上它应该这样做,因为我添加了名为“opera:share-cookies”的功能,对吧?
我做错了什么?