How to access internal resources from background.js

后端 未结 3 1968
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 03:04

In a Google Chrome application is it possible to access bundled data files from within the background.js script?

E.g. if I had a file called data.

3条回答
  •  醉话见心
    2020-12-07 03:13

    Since getPackageDirectoryEntry is not supported by firefox, it is not recommended. Now there is a simpler way.

    async function loadData(resourcePath) {
        var url = chrome.extension.getURL(resourcePath);
        return (await fetch(url)).text();
    }
    

提交回复
热议问题