I was trying to develop a chrome extension but I occurred in a problem.
I need to list the entries of a directory inside of the extension itself, but, when I try to implement the chrome.runtime.getPackageDirectoryEntry(function(root) {}
the console notifies me with a chrome.runtime.getPackageDirectoryEntry is not a function.
function getImage(callback) {
chrome.runtime.getPackageDirectoryEntry(function(root) {
root.getDirectory("images", {create: false}, function(localesdir) {
var reader = localesdir.createReader();
// Assumes that there are fewer than 100 locales; otherwise see DirectoryReader docs
reader.readEntries(function(results) {
callback(results.map(function(de){return de.name;}).sort());
});
});
});
}
getImages(function(data){console.log(data);});
I post the manifest.json too
{
"name": "My ext",
"version":"1.1",
"manifest_version":3,
"content_scripts": [
{
"matches": [
"*://mysite.dev:*/*"
],
"css": ["content.css"],
"js": ["content.js"]
}
],
"web_accessible_resources": ["images/*.png","images/*.gif"]
}
Could anyone help me?