Странная проблема расширения firefox-safari-chrome-ie8 + с Jquery - PullRequest
0 голосов
/ 01 марта 2011

Я разработал расширение для Firefox и Google Chrome , Safari и ie8 + . Он вставляет кнопку в почтовый интерфейс Google. Предполагается, что кнопка вставляет некоторый пользовательский текст в нижний колонтитул электронной почты. Он работает нормально на всех четырех, если я получаю доступ к стандартному почтовому адресу Google (вы можете смотреть это здесь и здесь ).

Вместо этого, если я получаю доступ к Gmail через Google Apps , это почти все происходит по трубопроводу. Единственная надстройка работает хорошо, это Google Chrome. Во всех остальных случаях кнопка добавляется правильно, но когда я нажимаю ее, это ничего не добавляет в нижний колонтитул электронной почты и приводит к следующим ошибкам.

В Firefox я получаю следующую консоль ошибок jquery:

 Error: Permission denied to access property 'ownerDocument' Source File: chrome://sendsecurefree/content/jquery.js Line: 16

В клопе:

 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 работает только составление почты, пересылка и ответ - нет.

Вот мой код jquery, который вставляется в веб-страницу gmail:

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;
}

Ответы [ 2 ]

1 голос
/ 04 марта 2011

Мне пришлось заменить

gmailInst = jQuery("iframe", doc);
if(gmailInst.length==0) {
    //exit now, we are not on compose
    return null;
}

на

gmailInst = jQuery("iframe.Am.Al", doc);
if(gmailInst.length==0) {
    //exit now, we are not on compose
    return null;
}

Кажется, что в обычном почтовом интерфейсе Google есть только один субфрейм внутри фрейма, в котором я работаюпоэтому gmailInst = jQuery ("iframe", doc) выполняет свою работу, пока выполняется это условие.

Если я активирую несколько лабораторных гаджетов, которые реализованы с помощью iframes, то gmailInst = jQuery ("iframe", doc) передает первый подфрейм в списке, который, вероятно, не являетсятот, который я ищу, поэтому я должен использовать дополнительную фильтрацию: в этом случае, имя класса подфрейма, который я ищу.

Предположения - скрытые дьяволы.

1 голос
/ 01 марта 2011

Я решил проблему.Каким-то образом!

Казалось, что отключение гаджета Календаря Google на вкладке "Лаборатории" в Службах Google, похоже, помогло.Теперь все работает отлично.Надеюсь, это поможет кому-то еще.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...