Как использовать jQuery в скрипте контента в расширении Firefox Mobile (Fennec)? - PullRequest
3 голосов
/ 04 декабря 2011

Я занимаюсь разработкой расширения для Firefox Mobile (Fennec) и хочу использовать jQuery в скрипте контента. Каков наилучший способ сделать это?

Я тестирую настольную версию Firefox Mobile 4

1 Ответ

2 голосов
/ 07 декабря 2011

overlay.js

window.addEventListener("load", function (aEvent){
    document.getElementById("browsers").addEventListener("DOMContentLoaded", function onWindowLoad(aEvent){
        window.messageManager.loadFrameScript("chrome://myExtension/content/jquery.js", true);
        window.messageManager.loadFrameScript("chrome://myExtension/content/content.js", true);
}, false);

jquery.js

addEventListener('DOMContentLoaded', function(event) {
    with(content){
        /* jQuery core code goes here */
    }
}, true);

содержимое.js

addEventListener('DOMContentLoaded', function(aEvent) { // on page load
    with(content) {
         if (aEvent.originalTarget.location.href != null) {
             if (aEvent.originalTarget.location.href == document.location.href && document.location.href != 'about:home') {
                //alert(jQuery(document).attr('title') + '\n' + jQuery(location).attr('href'));
             }
         }
    }
}, true);
...