我正在尝试创建Chrome扩展程序。 这是我的代码。 的的manifest.json
{
"name": "MyExtension",
"minimum_chrome_version": "10.0",
"version": "1.1",
"description": "Extends the Developer Tools",
"devtools_page": "devtools.html",
"manifest_version": 2,
"permissions": ["activeTab",
"<all_urls>",
"https://google.com/*"
],
"background": {
"scripts": ["bg.js"]
},
"content_scripts": [{
"matches": ["http://*/*", "https://*/*","http://maps.googleapis.com/maps/api/js?sensor=false","<all_urls>"],
"js": ["content_script.js"],
"run_at": "document_start",
"all_frames": true
}]
}
我正在通过:: chrome.devtools.panels.create 创建一个面板 在面板HTML 中,我指定了用于访问地图API的脚本。像这样::
<head>
<script src="panel.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
</head>
在某些事件的panel.js中,我正在尝试访问checkedpectedWindow 的 panel.js
chrome.devtools.inspectedWindow.eval("setRedSelectedElement($0)",{ useContentScriptContext: true });
content_script.js
var ownerdocument;
function setRedSelectedElement(el) {
ownerdocument= el.ownerDocument;
ownerDocument.body.style.backgroundColor = "**red**";
alert("style updated ");
var latlng = new google.maps.LatLng(26.449895, 74.639916);
alert("success -- "+latlng);
}
在新的google.map.LatLng执行中,扩展程序失败。 未捕获的引用错误:: google未定义 扩展如何访问谷歌API。