如何通过Chrome内容脚本下载文件? [英] How to download a file via a Chrome Content Script?
问题描述
这份 SO答案详细介绍了如何通过Chrome扩展程序下载文件,但我使用的是内容脚本,一个href =https://developer.chrome.com/extensions/content_scripts =nofollow noreferrer>它对Chrome API的访问权限有限。换句话说,我无法访问 chrome.downloads
对象。我也尝试过这个 vanilla JS解决方案,但它对我不起作用。有没有人有内容脚本的解决方案,或知道为什么第二个解决方案无法正常工作? 解决方案
写一个后台页面或活动页面,然后在相关答案中使用示例。使用 Chrome邮件与内容脚本进行通信。
This SO answer details how to download a file via a Chrome Extension, but I am using a Content Script, which has limited access to Chrome's APIs. In other words, I don't have access to the chrome.downloads
object. I also tried this vanilla JS solution, but it did not work for me. Does anyone have a solution for Content Scripts or know why the second solution doesn't work?
Write a background page or event page and do it from there using the example in your linked answer. Communicate from/to the content script with chrome messages.
这篇关于如何通过Chrome内容脚本下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!