Google chrome 在下载文件时获取文件Url 我目前的工作
Manifest.jsonGoogle chrome 在下载文件时获取文件Url 我目前的工作,google-chrome,google-chrome-extension,google-chrome-devtools,Google Chrome,Google Chrome Extension,Google Chrome Devtools,Manifest.json { "manifest_version": 2, "name": "Extension For PyIDM", "version": "0.1", "description": " An Open Source Alternative Of IDM", "icons":
{
"manifest_version": 2,
"name": "Extension For PyIDM",
"version": "0.1",
"description": " An Open Source Alternative Of IDM",
"icons": {
"16": "icons/favicon-16x16.png",
"48": "icons/android-icon-48x48.png",
"120": "icons/apple-icon-120x120.png"
},
"author" : ["Harshil Pandey","@PyIDM"],
"permissions": [
"<all_urls>",
"downloads"
],
"background": {
"scripts": ["background.js","pyidm_extension.js","webextension.js"]
}}
问题
如何获取要下载的文件的Url
和文件名
我用什么来知道文件是否要下载:chrome.downloads.onCreated查看for onCreated事件:它有一个包含所有信息的参数。嘿!正如您所说,我看到了文档,但当我尝试chrome.downloads.finalur()时,我无法获得Plz帮助,这不是我的评论所说的。仔细阅读。当您在“文档”页面上单击该参数时,将详细描述该参数,并将其引导。您还应该修复代码以实际使用该参数,因此
function()
应该变成function(info)
嘿,您能告诉我应该在哪里修复代码吗?嘿!我将chrome.downloads.onCreated.addListener(function(){更改为chrome.downloads.onCreated.addListener(function)(DownloadItem,finalUrl){您是否在谈论这个问题,但在应用于参数后如何使用它?
chrome.runtime.onInstalled.addListener(function() {
//window.open("install.html")
window.open('install.html','height=480,width=640', false);
});
chrome.downloads.onCreated.addListener(function() {
var r = confirm("Do you Want To Download"+ File + " Using PyIDM");
if (r == true) {
var final = chrome.downloads.onCreated.finalUrl;
alert(final + " I Am working");
//alert("You pressed OK!");
} else {
//alert("You pressed Cancel!");
}
}
)