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

onMessageExternal API to allow NextPlease to be invoked from other addons #18

Open
marklieberman opened this issue Jun 15, 2018 · 2 comments

Comments

@marklieberman
Copy link

marklieberman commented Jun 15, 2018

I have Foxy Gestures user who would like to invoke NextPlease commands via gestures. As I understand, in the pre-FF57 era (when FireGestures still worked) people used to dispatch key events to invoke NextPlease via shortcuts as demonstrated by the script in this issue. However, this doesn't work with web extensions. I don't believe that commands defined in manifest.json will respond to untrusted events dispatched from user scripts.

I've had other addons add or investigate support for an onMessageExternal API such as in: marklieberman/foxygestures#223 and marklieberman/foxygestures#146. In this way I can invoke NextPlease commands using code like runtime.sendMessage(*NextPlease-Extension-ID*, { command: ... }). Would you consider adding support for this type of API or taking a PR?

@alexeyr
Copy link
Owner

alexeyr commented Jun 19, 2018

I'll happily take a PR. Adding it myself would have to wait until I am not under stress.

@gaberad
Copy link

gaberad commented Jan 25, 2020

This is the most simple solution, all you need to do is add this to nextplease_background.js

browser.runtime.onMessageExternal.addListener(function(message, sender) {
	nextplease.sendMessageToActiveTab({ direction: message.direction });
});

then in FoxyGestures, the userscript will look like this

browser.runtime.sendMessage('{57B65ABB-F4E3-4358-8472-15AEE0833E11}', {
    direction: 'Next'
});

'direction' being either Next, Prev, First, or Last.

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

3 participants