Feature Description
Empower the use of OPFS of the extension.
UserScript authors can utilize the API to store, update, write, ...
Just like GM_setValue GM_getValue series
-
Add GM.opfs
-
GM.opfs() returns navigator.storage.getDirectory().getDirectoryHandle("scripts").getDirectoryHandle(script_storage_namespace, { create: true }); of the ScriptCat's extension.
-
It provides getDirectoryHandle(...) and getDirectoryHandle(...) in the same or similar API signature
-
It provides removeEntry(..., {recursive: ...}) in the same or similar API signature
-
It provides getPathHandle(...) by just using xxx/xxx/xxx for connivence.
-
It provides listFolders() and listFiles() for convenience
-
All file & folder entries records are saved using DAO as well. (just name, filesize, and lastModified)
-
Content/Inject.js - GMFileSystemDirectoryHandle & GMFileSystemFileHandle
How
- Scripting/SW - Read - Get the file blob, create Blob URL, Scripting to read Blob URL -> to the Blob -> to the File -> dataTransfer = new DataTransfer() -> dataTransfer.items.add(file) -> new DragEvent("...", { dataTransfer: dataTransfer, ... }) -> let content/inject to read the "File" object.
- GMFileSystemFileHandle.getFile() -> "File"
Extra
- All files shall be compressed by Compression Stream APIs (deflate/gzip ?? ) for long term storage in ScriptCat.
Use Case
In what situations is this feature needed? (e.g., when processing specific websites, improving operational efficiency, etc.)
- UserScripts which need to save/download the files. Don't need to let users download but the script can keep the files.
- Foreground and Background Scripts sharing the same storage_namespace.
Additional Information
(Optional) Supplementary screenshots, sample code, or other reference information
Feature Description
Empower the use of OPFS of the extension.
UserScript authors can utilize the API to store, update, write, ...
Just like GM_setValue GM_getValue series
Add
GM.opfsGM.opfs()returnsnavigator.storage.getDirectory().getDirectoryHandle("scripts").getDirectoryHandle(script_storage_namespace, { create: true });of the ScriptCat's extension.It provides getDirectoryHandle(...) and getDirectoryHandle(...) in the same or similar API signature
It provides removeEntry(..., {recursive: ...}) in the same or similar API signature
It provides getPathHandle(...) by just using
xxx/xxx/xxxfor connivence.It provides
listFolders()andlistFiles()for convenienceAll file & folder entries records are saved using DAO as well. (just name, filesize, and lastModified)
Content/Inject.js -
GMFileSystemDirectoryHandle&GMFileSystemFileHandleHow
Extra
Use Case
In what situations is this feature needed? (e.g., when processing specific websites, improving operational efficiency, etc.)
Additional Information
(Optional) Supplementary screenshots, sample code, or other reference information