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

Enable other extensions to activate ff2mpv #112

Closed
arthsmn opened this issue Jan 20, 2024 · 5 comments
Closed

Enable other extensions to activate ff2mpv #112

arthsmn opened this issue Jan 20, 2024 · 5 comments

Comments

@arthsmn
Copy link

arthsmn commented Jan 20, 2024

Is your feature request related to a problem? Please describe.
I would like to integrate ff2mpv with vimium c, as requested here. But it seems that ff2mpv doesn't have the interface to allow other extensions to activate it.

Describe the solution you'd like
A way that extensions could activate ff2mpv.

@woodruffw
Copy link
Owner

I'm not necessarily opposed to this, but I don't know how to do it. If someone were to send a patch and an explanation of how it works, I'd be happy to merge it and include it in the next release.

@DanSM-5
Copy link
Contributor

DanSM-5 commented Jan 21, 2024

I just recently added some changes in the code for migrating to mv3 that could be used for this. I'm talking specifically for the listener for runtime.onMessage https://github.com/eNV25/ff2mpv/pull/1/files#diff-d59a73ad52dc1dc2b2d687747f1225e38b14324cbd2fa3dd73b2be2b35e42d35R96.

According to the documentation runtime.sendMessage can pass a extensionId to call another extension (ff2mpv in this case). It would be a matter to support a new type of message e.g. openVideo with the url as the payload of that message from the extension that wants to call mpv.

// External extension
chrome.runtime.sendMessage(ff2mpvExtensionId, { type: 'openVideo', url }, callback);

// ff2mpv
chrome.runtime.onMessageExternal.addListener((request, _sender, sendResponse) => {
  const { type, url } = request;
  ...
  
  case 'openVideo':
    ff2mpv(url);
    return sendResponse('ok');
  ...
});

I believe that the listener could be included before merging the mv3 migration (so this works with the current version).

Update: It requires to use chrome.runtime.onMessageExternal instead of chrome.runtime.onMessage.

@DanSM-5
Copy link
Contributor

DanSM-5 commented Jan 22, 2024

I've opened a PR with the changes for this to work #113

@woodruffw
Copy link
Owner

Thank you!

@woodruffw
Copy link
Owner

Addressed by #113. Please file a new issue after that's released if you're still seeing problems here.

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

No branches or pull requests

3 participants