1

私はクローム拡張機能の開発に非常に慣れていません。私はグーグルのチュートリアルから基本的なアイデアを得ました、そしてここでのこの質問からのいくつかの助け は私がこれまでにしたことです

background.html

    <html>
    <head>
        <script>
            chrome.browserAction.onClicked.addListener(function(tab) {
                chrome.tabs.executeScript(null, 
                {file:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/ui-lightness/jquery-ui.css", 
                    runAt:"document_start"}, 
                function() { alert('Added css'); });
                chrome.tabs.executeScript(null, 
                {file:"http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js", 
                    runAt:"document_start"}, 
                function () {
                    alert("loaded js");
                    chrome.tabs.executeScript(null, 
                    {file:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"}, 
                    function () {
                        alert("loaded js2");
                        chrome.tabs.executeScript(null, {file:"popup.js"}, function() {alert("did it pop up yet?");});
                    });
                });
            });


        </script>
    </head>
</html>

Manifest.jsonファイル

{
"name": "demo",
"version": "2.0",
"description": "Jquery Dialog in Chrome",
"browser_action": {
"default_icon": "favicon.ico",
"default_title": "Dialog Box"
},
"background_page": "background.html",
"content_scripts": [
    {
      "matches": ["http://*/*","http://jquery.com/*"],
      "js": ["jquery.js","popup.js"]
    }
  ],
"permissions": [
 "tabs","http://localhost/","http://*/*"
]
}

そして、私のUIダイアログがあるpopup.jsファイル

$(function() {
    alert('in popup');
var NewDialog = $('<div id="MenuDialog"><p>This is your dialog content, which can be multiline and dynamic.</p></div>');
NewDialog.dialog({
modal: true,
title: "title",
show: 'clip',
hide: 'clip',
buttons: [
    {text: "Submit", click: function() {doSomething()}},
    {text: "Cancel", click: function() {$(this).dialog("close")}}
]
});
NewDialog.dialog("open");
});

background.htmlからアラートを受け取りますが、popup.jsからは受け取りません。jqueryuiダイアログも表示されません。デバッグしてみました

Gmailを開いて拡張コンソールをクリックすると、4つのエラーが表示されます>

Error during tabs.executeScript: Cannot access contents of url "https://mail.google.com/mail/u/0/?shva=1#inbox". Extension manifest must request permission to access this host.
4

1 に答える 1

3

エラーメッセージは非常に明確だと思います。mail.google.comonhttpsプロトコルの権限がありません。または を
追加して、アクセス許可へのアクセスを広げます。https://mail.google.com/**://*.google.com/*

于 2012-09-27T08:03:39.477 に答える