0

我已經開發了一個擴展的Firefox 谷歌野生動物園IE8 +。它在google郵件界面插入一個按鈕。該按鈕應該在電子郵件頁腳中插入一些自定義文本。如果我訪問標準谷歌郵件地址(您可以手錶herehere),它可以正常工作。奇怪的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; 
} 
+1

我在這裏猜測,但在我看來,這可能與XSS /同源策略有關。 Google Apps郵件網址可能與Gmail網址不同。 – 2011-02-28 21:43:28

+0

沒有。如果我訪問相同鏈接[link] https://mail.google.com/mail/?shva=1#compose:標準界面有效,那麼通過谷歌應用訪問的鏈接不會在Firefox和safari上。但谷歌的Chrome瀏覽器擴展適用於所有的人都 – alex 2011-02-28 21:51:50

+0

希望我不會鬆動1周的這個問題衰弱! – alex 2011-02-28 21:53:35

回答

1

我曾與

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的類名稱。

假設是變相的惡魔。

1

我解決了這個問題。不知何故!

似乎Google Apps中的實驗室標籤禁用了Google日曆工具似乎可以勝任。現在一切正常。希望這會幫助別人。