gpt4 book ai didi

jquery - Chrome 扩展程序 : Opening Jquery Ui Dialog

转载 作者:行者123 更新时间:2023-12-01 08:12:31 27 4
gpt4 key购买 nike

我对 Chrome 扩展开发非常陌生。我从 google 的教程中获得了基本想法,并从 this question 获得了一些帮助。这是我到目前为止所做的

背景.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 收到警报,jquery ui 对话框也没有出现。我尝试调试它

我打开 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.

最佳答案

我认为错误消息非常清楚。您没有 mail.google.com https 协议(protocol)的权限。
https://mail.google.com/* 或更广泛的访问权限添加到您的权限中 *://*.google.com/*

关于jquery - Chrome 扩展程序 : Opening Jquery Ui Dialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12616607/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com