Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: access browser.*/messenger.* inside template script #289

Closed
endedasende opened this issue Mar 11, 2022 · 6 comments
Closed

Comments

@endedasende
Copy link

Greetings,
firstly many thanks to author and to maintainer of quicktext!

I am using this extension for simple but effective ticket managment.
I respond to new email with a template, that calls script, which adds ticket number to subject and also opens new compose window with ticket number in subject.

This worked just fine, but now i cannot open new compose window anymore...

var url = encodeURI('mailto:?Subject='+s[0]);

//this no longer works
this.mWindow.open(url, '_self');

//this no longer works
var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance();
messenger = messenger.QueryInterface(Components.interfaces.nsIMessenger);
messenger.launchExternalURL(url, '_self');

After some searching i see 2 solutions, either browser.windows.openDefaultBrowser(url) or browser.compose.beginNew()
but i cannot access browser.* from inside template scripts.

I have naively tried adding quicktext.js as background script and adding browser via init function, but this is not ok...

  "background": {
    "scripts": [
      "/chrome/content/scripts/preferences.js", 
      "background.js",
      "/chrome/content/quicktext.js"
    ]
  },

//add browser var
gQuicktextVar.init(window,browser);

So how do i tackle this problem?

Having full browser.* (or restricted) support available from template scripts would be great.

@Alfred-Peters
Copy link

This worked just fine, but now i cannot open new compose window anymore...

var url = encodeURI('mailto:?Subject='+s[0]);

//this no longer works
this.mWindow.open(url, '_self');

It seems that only one parameter is missing there. This one works here:

var url = encodeURI('mailto:?Subject='+this.mVariables[0]);
this.mWindow.open(url,'_self',
    "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");

@SamuelPlentz
Copy link
Contributor

Can confirm the code working within a community skript. Should be closed.

@jobisoft
Copy link
Owner

jobisoft commented Jul 2, 2022

I keep it open, because using webExt API is indeed something which could be useful, as it is easier.

@SamuelPlentz
Copy link
Contributor

Added the community script: OpenComposeWindow.

@endedasende
Copy link
Author

Wow time flies...
Thanks everyone for support, open compose window works again!

@jobisoft
Copy link
Owner

Closing in favor of #371.
Please give feedback regarding the planned modifications for script support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants