2011-11-08 61 views
3

我正在尝试为Opera编写我的第一个扩展。它的快速延伸。 我希望它向我展示一些来自网站的数据,但要访问这些数据我需要登录。如何在opera扩展中共享cookie?

我已登录,并且歌剧知道它;-)(当我在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(that`s一个从教程;-),添加ACCES起源和特性歌剧:股饼干:

<?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,我可以告诉大家,歌剧发送其他饼干比JS,这就是为什么JS说我没有登录。但我想JS发送相同的cookie是歌剧发送,理论上它应该这样做,因为我添加了名为“opera:share-cookies”的功能,对吧?

我该怎么做?

回答

1

应该工作,但是,对于最初的开发,尝试设置访问起源*,然后尝试。此外,请尽量关注访问来源(www和没有www的域名)。现在,尝试将访问原点设置为*,并查看它是否有效。 (在制作中,版主可能不会允许版主使用)。

0

有同样的问题,你的扩展很可能工作,但由于某种原因,不在开发人员模式。当你压缩它,重命名为.oex并作为正常的扩展名安装,它可能会工作。