我已經開發了一個擴展的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;
}
我在這裏猜測,但在我看來,這可能與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