奇怪的Firefox,Safari浏览器 - 铬 - IE8 +扩展问题与jQuery
问题描述:
我已经开发了一个扩展的Firefox 和谷歌铬,野生动物园和IE8 +。它在google邮件界面插入一个按钮。该按钮应该在电子邮件页脚中插入一些自定义文本。如果我访问标准谷歌邮件地址(您可以手表它here和here),它可以正常工作。奇怪的Firefox,Safari浏览器 - 铬 - IE8 +扩展问题与jQuery
取而代之的是,如果我通过谷歌应用访问Gmail,它几乎都会失败。唯一的插件帽子效果很好,就是谷歌Chrome浏览器。在所有其他,按钮被正确添加,但是当我点击它,这不会添加任何东西到电子邮件页脚并产生以下错误。
在Firefox中,我得到以下的jQuery错误控制台:
Error: Permission denied to access property 'ownerDocument' Source File: chrome://sendsecurefree/content/jquery.js Line: 16
在Firebug:
uncaught exception: [Exception... "Security Manager vetoed action" nsresult: "0x80570027 (NS_ERROR_XPC_SECURITY_MANAGER_VETO)" location: "JS frame :: chrome://sendsecurefree/content/jquery.js :: anonymous :: line 16" data: no] Line 0
此外,在Safari:
ReferenceError: Can't find variable: toggleEncryptFooter
在Internet Explorer中仅构成邮件作品,转发和回复不。
下面是注入的Gmail网页我的jQuery代码:
function toggleEncryptFooter() {
var canvasBody = getGmailCanvasBody();
// get the button element
var documentul = getGmailCanvasDoc();
divul = jQuery(".dX.J-Jw", documentul);
var encryptButton = divul.find("#encrypt");
//first, check if we already have an encrypt footer
var encryptFooter = jQuery("#encrypt_footer", canvasBody);
if(encryptFooter.length != 0) {
//we have the footer inserted, delete it
encryptFooter.remove();
// style the button to no footer
encryptButton.html('Enable Encryption');
encryptButton.removeClass('downer');
encryptButton.addClass('upper');
} else {
//add the footer
var doc = document;
var head = jQuery('head', doc);
var textul = head.find("div#textul",head);
// text was inserted in injectScript/gmailadder.js into head of canvas_frame
getGmailCanvasBody().append('<div id="encrypt_footer">' + textul.html() + '</div>');
// style the button to footer added
encryptButton.html('Disable Encryption');
encryptButton.removeClass('upper');
encryptButton.addClass('downer');
}
}
// gets the head element of the document
function getGmailHead(){
var doc = document;
var body = jQuery('head', doc);
return body;
}
// gets the body element of the document
function getGmailCanvasBody() {
var doc = document;
gmailInst = jQuery("iframe", doc);
if(gmailInst.length==0) {
//exit now, we are not on compose
return null;
}
return gmailInst.contents().find('body');
}
// get the document object
function getGmailCanvasDoc() {
var doc = document;
var body = jQuery('body', doc);
var canvas_frame = jQuery('iframe#canvas_frame', body);
if(canvas_frame.length==0) {
//exit now, we are not on gmail
return null;
}
var canvas_doc = canvas_frame[0].contentDocument;
return canvas_doc;
}
答
我曾与
gmailInst = jQuery("iframe.Am.Al", doc);
if(gmailInst.length==0) {
//exit now, we are not on compose
return null;
}
看来,在正常的谷歌邮件界面存在的iframe里面只有一个子iframe中我的工作中,以取代
gmailInst = jQuery("iframe", doc);
if(gmailInst.length==0) {
//exit now, we are not on compose
return null;
}
,所以只要条件保持,gmailInst = jQuery(“iframe”,doc)就会完成它的工作。
如果我激活了与I帧实现了几个实验室小玩意,然后gmailInst =的jQuery(“IFRAME”,DOC)通过在列表中的第一子IFRAME这可能不是一个我正在寻找所以我必须使用额外的过滤:在这种情况下,我正在搜索的子iframe的类名称。
假设是变相的恶魔。
答
我解决了这个问题。不知何故!
似乎Google Apps中的实验室标签禁用了Google日历工具似乎可以胜任。现在一切正常。希望这会帮助别人。
我在这里猜测,但在我看来,这可能与XSS /同源策略有关。 Google Apps邮件网址可能与Gmail网址不同。 – 2011-02-28 21:43:28
没有。如果我访问相同链接[link] https://mail.google.com/mail/?shva=1#compose:标准界面有效,那么通过谷歌应用访问的链接不会在Firefox和safari上。但谷歌的Chrome浏览器扩展适用于所有的人都 – alex 2011-02-28 21:51:50
希望我不会松动1周的这个问题衰弱! – alex 2011-02-28 21:53:35