Allow access to file URLs for Web Extensions

Hello,

Is it possible to "Allow access to file URLs" on a Web Extension?
I'm trying to convert an existing extension to Safari 14 and so far it's working great but I cannot figure out how to enable the extension on file:// URLs.

I've disabled "Local File Restrictions" from the "Develop" menu but the content script is still not loaded on a file:// URLs.
In my manifest.json, I've declared:

Code Block json
  "content_scripts": [
  {
   "matches": [
    "*://*/*.ad",
    "*://*/*.ad?*",
    "*://*/*.ad.*",
    "*://*/*.adoc",
    "*://*/*.adoc?*",
    "*://*/*.adoc.*",
    "*://*/*.asc",
    "*://*/*.asc?*",
    "*://*/*.asc.*",
    "*://*/*.asciidoc",
    "*://*/*.asciidoc?*",
    "*://*/*.asciidoc.*",
    "*://*/*.txt",
    "*://*/*.txt?*",
    "*://*/*.txt.*",
    "file://*/*.ad",
    "file://*/*.ad?*",
    "file://*/*.ad.*",
    "file://*/*.adoc",
    "file://*/*.adoc?*",
    "file://*/*.adoc.*",
    "file://*/*.asc",
    "file://*/*.asc?*",
    "file://*/*.asc.*",
    "file://*/*.asciidoc",
    "file://*/*.asciidoc?*",
    "file://*/*.asciidoc.*",
    "file://*/*.txt",
    "file://*/*.txt?*",
    "file://*/*.txt.*"
   ],


With the following permissions:

Code Block json
  "permissions": [
  "storage",
  "tabs",
  "activeTab",
  "*://*/*.ad",
  "*://*/*.ad?*",
  "*://*/*.ad.*",
  "*://*/*.adoc",
  "*://*/*.adoc?*",
  "*://*/*.adoc.*",
  "*://*/*.asc",
  "*://*/*.asc?*",
  "*://*/*.asc.*",
  "*://*/*.asciidoc",
  "*://*/*.asciidoc?*",
  "*://*/*.asciidoc.*",
  "*://*/*.txt",
  "*://*/*.txt?*",
  "*://*/*.txt.*",
  "contextMenus"
 ],


The file URL is: file:///Applications/README.txt.

Thanks for your help.
Guillaume
I don't think it's currently possible and I doubt it will ever be.

What you can do is have a companion app to read the local files (will require user's permission) and communicate with the extension via native messaging.
File URLs are not supported currently. If this is something you would like to see, please send us feedback via Feedback Assistant with your use cases for wanting local file access. Thanks!

What you can do is have a companion app to read the local files (will require user's permission) and communicate with the extension via native messaging.

Thanks for your reply!
Not sure how it's gonna work as I want to read the "current" file and periodically read the content again (to watch changes).
For instance, the user will type file:///path/to/README.txt (written using AsciiDoc lightweight markup) and the extension will convert the AsciiDoc document to HTML 5 and display the result.
If the user edit the file /path/to/README.txt, then the extension will display the updated version.

File URLs are not supported currently. If this is something you would like to see, please send us feedback via Feedback Assistant with your use cases for wanting local file access. Thanks!

Ok I will do, thanks Timothy.
In my opinion, file:// URLs are particularly useful to render local files written using lightweight markup (Markdown, AsciiDoc...).


Allow access to file URLs for Web Extensions
 
 
Q