violentmonkey icon indicating copy to clipboard operation
violentmonkey copied to clipboard

[Feature] Sync with local directory

Open tomodachi94 opened this issue 1 year ago • 7 comments

Motivation I keep my dotfiles in a local directory on my filesystem, using Git to version-control them. I would like to include my userscripts in that local directory and have them synced to/from Violentmonkey.

Proposed Solution An additional "Sync to" option that supports syncing to a directory on the local filesystem.

Use Cases Mentioned above.

tomodachi94 avatar Jun 23 '24 04:06 tomodachi94

Extensions can't access local files in Firefox directly. In Chrome it requires either granting the extension access to the entire file system, which is unsafe, or using the new API. Both methods don't have an API to watch for changes, so we would have to poll the directory regularly, which is ineffective.

The only sane current workaround is nativeMessaging API and an external app that uses the system's built-in API to watch file changes, which is a complication we didn't want to add for such edge cases.

tophf avatar Jun 23 '24 05:06 tophf

AFAIK, you can use a local WebDAV server for this task.

tophf avatar Jun 23 '24 05:06 tophf

Yes, that would work, but running a WebDAV server comes with extra overhead. With the File System API, browsers can read and write to the local filesystem without needing an intermediary (like a local WebDAV server).

tomodachi94 avatar Jun 23 '24 05:06 tomodachi94

We won't use the native File System API, see what I wrote in my comment:

Both methods don't have an API to watch for changes, so we would have to poll the directory regularly, which is ineffective.

tophf avatar Jun 23 '24 05:06 tophf

We won't use the native File System API, see what I wrote in my comment:

My bad, I opened the GitHub notification and it obscured your first comment.

tomodachi94 avatar Jun 23 '24 06:06 tomodachi94

I'm bad at reading too. I thought you wanted to have a direct link between local files and scripts the way it's imitated in Tampermonkey via @require file://

We can certainly add a new method to our sync, which you will trigger manually or on schedule.

tophf avatar Jun 23 '24 06:06 tophf

This would be fantastically useful.

AJolly avatar Nov 20 '24 23:11 AJolly