How do I get access to all the files in the extension in Chrome Extension Manifest Version 3 (MV3)?

♀尐吖头ヾ 提交于 2021-02-10 14:32:35

问题


Background

I've been using the crx-hotreload package to auto-reload my chrome extensions during development because it's annoying to have to click the refresh button on the Extensions page every time you make a change; however, this package doesn't work with MV3 because it uses the chrome.runtime.getPackageDirectoryEntry method, which seems to have been removed from chrome.runtime in MV3. I can't find documentation to confirm that it was removed, but it's not there when I try to use it.

Questions

Does anyone know how to get access to all the files in the extension directory in Chrome Extension Manifest Version 3?

Or generally, is there a better way that I can hot-reload my chrome extensions during development that would work for MV3?


回答1:


This is one of many things based on DOM capabilities of background pages that are removed from ManifestV3 because service workers don't have DOM. For example, getPackageDirectoryEntry is using the old nonstandard FileSystem API in its returned value.

As to why, apparently the switch to service workers simplifies the internal source code in Chromium, even if it doesn't provide any real improvements for extension authors or users.

At this point all you can do is present a convincing use case and ask Chromium developers via https://crbug.com to implement an alternative API.



来源:https://stackoverflow.com/questions/65975659/how-do-i-get-access-to-all-the-files-in-the-extension-in-chrome-extension-manife

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!