jobisoft / quicktext

An extension for Thunderbird that lets you create templates that can be easily inserted into your own emails.
Mozilla Public License 2.0
187 stars 53 forks source link

How to access clipboard in script? #326

Closed artfulrobot closed 2 years ago

artfulrobot commented 2 years ago
  1. open an email
  2. add some HTML content,
  3. copy some of that content.

Then I want to run my script which wants to tweak what's on the clipboard.

I've tried:

var im = this.mQuicktext.process_clipboard();
return im.replace('a', 'b');

and

var im = this.mQuicktext.get_clipboard();
return im.replace('a', 'b');

But they both return empty strings. Help wanted please :-)

SamuelPlentz commented 2 years ago

This is related to: #271, #320 and #328.

Try to add await like this:

process_clipboard

var im = await this.mQuicktext.process_clipboard();
return im.replace('a', 'b');

get_clipboard

var im = await this.mQuicktext.get_clipboard();
return im.replace('a', 'b');
artfulrobot commented 2 years ago

@SamuelPlentz I get this error when I use await:

There was an error in your Quicktext script: MyMessage
SyntaxError: await is only valid in async functions, async generators and modules
Line 1: var im = await this.mQuicktext.process_clipboard();

(I'm on v 4.3 released 8 Aug. Tbird says there are no updates available)

SamuelPlentz commented 2 years ago

Quicktext 5.2 and Thunderbird 102 in use here.

artfulrobot commented 2 years ago

Ah, maybe Ubuntu's Thunderbird is out of date then, I'm on Tbird 91.

artfulrobot commented 2 years ago

Confirmed working in Quicktext 5.2 and Thunderbird 102 ..