joelekstrom / fastmate

A native Fastmail-wrapper for Mac.
MIT License
193 stars 12 forks source link

User scripts: seeking more background ("handholding?") #62

Closed johnnyutahh closed 2 years ago

johnnyutahh commented 2 years ago

Can someone share more background on the intriguing user-scripts feature?

Some exploratory questions:

  1. what are some typical benefits/applications/outcomes/scenarios?
  2. eg: can a user-script add an additional keyboard-shortcut-based command to do something that Fastmate/Fastmail does not already provide in their UX (but does offer via their JMAP, or whatever API is used for their server(s))? Something like this is the first kind of thing I would seek.
  3. can you provide an example implementation, even if it's "hello world" simple?

The README.txt in the .../userscripts dir is light on details in v1.8.0.

I briefly browsed the master branch head and did not see anything that immediately answered my questions. I did not look that hard. ;-)

Also: I have little to no javascript/Swift/Objective-C experience, but being multi-lingual in similar languages I have historically "figured stuff out" in similar situations without too much fuss for small changes/updates.

joelekstrom commented 2 years ago

Hi, yes I agree that it should be documented a lot better, with examples etc! I will think about improving it. For now you can think about it being sort of like Greasemonkey.

It simply runs javascript files for the current web page. Anything you can do with Greasemonkey you can add to Fastmate to customize your Fastmail experience within the app. No Swift/ObjC knowledge is required for this, it's purely a Javascript extension API.

To answer the questions more specifically:

  1. For example, creating custom themes, adding or removing functionality
  2. Yes, you can add shortcuts. This is actually what Fastmate already does to interface with Fastmail, take a look at https://github.com/joelekstrom/fastmate/blob/master/Fastmate/Fastmate.js for examples. You can call these functions directly from your userscripts too, for example Fastmate.focusSearch().
  3. An example would be something like this in the userscripts folder and restarting the app:
// helloworld.js
alert("Hello! I'm an alert within Fastmate!");
Notification("a fastmate desktop notification", {})
Skärmavbild 2022-02-01 kl  08 26 29 Skärmavbild 2022-02-01 kl  08 26 35