我很抱歉打扰了。 最近,我发现我的devtools扩展程序在最新版本的Chrome中不起作用。 它仍然可以在正常模式下工作,即打开一个选项卡,然后为该选项卡打开devtools,一切正常。 在检查Android WebView时,只有background.js执行了一些代码,但devtools.js似乎永远不会被执行。
任何人都有同样的问题或者可以指出我的解决方案吗?
我的情景是,
结果是:
- background.js
- devtools.html
- devtools.js
- 的jquery-3.1.0.min.js
- 的manifest.json
醇>
{
"name": "Har Getter",
"version": "1.1",
"minimum_chrome_version": "10.0",
"description": "Har reporter",
"devtools_page": "devtools.html",
"content_scripts": [
{
"js": ["jquery-3.1.0.min.js"],
"matches": ["http://*/*", "https://*/*"]
}
],
"background": { "scripts": ["background.js"] },
"permissions": [
"http://*/*",
"https://*/*",
"tabs"
],
"manifest_version": 2
}
chrome.devtools.panels.create("Lucas Luo Panel",
"MyPanelIcon.png",
"Panel.html",
function(panel) {
}
);
chrome.devtools.panels.elements.createSidebarPane("Lucas Luo Sidebar",
function(sidebar) {
// sidebar initialization code here
sidebar.setObject({ some_data: "Some data to show" });
});
alert("Lucas Luo");
chrome.devtools.network.onNavigated.addListener(function (url) {
alert('starting...');
});
chrome.devtools.network.onRequestFinished.addListener(function(request) {
});
function checkRequestCount2() {
if(chrome.devtools.inspectedWindow.tabId == pcTabId) {
sendPC();
}
}
function sendPC() {
chrome.devtools.inspectedWindow.eval('performance.timing.loadEventEnd',"",function(result, exceptionInfo){
chrome.devtools.network.getHAR(function(harLog) {
clearTimeout(navTime);
var loadTimeVal = (end-start) / 1000;
endTimeVal = new Date();
alert('hello');
$.ajax({
url: 'http://localhost:4567/automation/sendHar/PC',
type: 'POST',
dataType: 'json',
data: escape(JSON.stringify(harLog)),
error: function(d) {
},
success: function(d, s) {
}
});
});
});
}
alert('background lucas luo');
<!doctype html>
<html>
<head>
<title>Devtools Page</title>
<script src="jquery-3.1.0.min.js" type="text/javascript"></script>
<script src="devtools.js"></script>
<script src="./background.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
最诚挚的问候,
卢卡斯罗