我正在尝试制作一个可自动从网站下载某些图片的扩展程序。我尝试使用here此代码中的示例:
chrome.devtools.network.onRequestFinished.addListener(function(request) {
if (request.response.bodySize > 40*1024)
chrome.experimental.devtools.console.addMessage(
chrome.experimental.devtools.console.Severity.Warning,
"Large image: " + request.request.url);
});
这是我的manifest.json
"name": "image downloader",
"version": "1.0",
"description": "potaot",
"manifest_version": 2,
"browser_action": {
"default_icon": "icon.png",
"default_popup": "testpopup.html"
},
"author": "me",
"content_scripts": [
{
"matches" : [ "http://www.free-pictures-photos.com/landscapes/*" ],
"js": ["contentscript.js"]
}
],
"web_accessible_resources": ["script.js"]
如果有人能提供帮助,我们将非常感激。 这是contentscript.js:
var s = document.createElement('script');
s.src = chrome.extension.getURL("script.js");
s.onload = function() {
this.parentNode.removeChild(this);
};
(document.head||document.documentElement).appendChild(s);