javascript - 注入的 JS 可以将点击下载的文件重定向到预定义的文件路径吗?
问题描述
我正在尝试编写一个 Chrome 扩展程序,当单击一个按钮时,它会下载一个您通常从现有站点上的另一个按钮获取的文件,而是自动将其下载到用户定义的文件路径。到目前为止,我只在文件来自的按钮上调用 click() 。我需要将该文件下载到内存文件路径中。谢谢!
popup.js:
extensionBtn.onclick = function(element) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{file: "content_script.js"});
});
};
content_script.js:
function clickGpxDownload() {
//Where I'd want the file to instead be downloaded to
var filePath = "C:/foo/bar"
//Button the file comes from
var gpxDownload = document.getElementById("ctl00_ContentBody_btnGPXDL");
gpxDownload.click();
}
clickGpxDownload();
解决方案
推荐阅读
- http - 所有uri的列表
- ios - 如果 URL 快速失败,如何为 AVPlayer 重新加载数据
- jquery - 一个简单的 jquery change() 不适用于 safari
- spring - 为什么@Autowired 可以获取FactoryBean 类型和Bean 类型?
- ruby-on-rails - 如何编写一个尊重 Capybara 块内的 RSpec 匹配器?
- c# - Unity - 如何为每个好的动作显示几秒钟的文本
- react-native - 使用 Formik 将 Props 向下传递给组件来反应本机多页表单
- ios - react native expo run-ios
- linux - 如何实现 wc 的实时版本?
- arrays - 打印数组哈希的哈希