rugk / mastodon-simplified-federation

Simplifies following and interacting with remote users on other Mastodon instances.
https://addons.mozilla.org/firefox/addon/mastodon-simplified-federation/?utm_source=github.com&utm_medium=github&utm_content=github-url-description&campaign=github-url-description
Other
253 stars 20 forks source link

Add PeerTube support #112

Open jeena opened 1 year ago

jeena commented 1 year ago

Background

This extension solves the problem for Mastodon, the same problem we have for PeerTube too.

Proposed solution

Extend it with support for PeerTube.

Alternatives

I tried to fork it and to rewrite it but once I did I realized that it's very big and I would need to understand a lot of details to be able to do it so after two days of trying I gave up for now.

Another alternative would be to rewrite it into a framework with plugin support so people could write simple plugins to make it work with other software like PixelFed, Lemmy, PeerTube, /kbin and all other fediverse apps which have similar problems.

Additional context

rugk commented 12 months ago

The thing is we have a dropdown again, no tab opening, so it technically needs a content script just like new Mastodon.

the abo button: grafik

the comment field click triggers this: grafik

(from https://video.blender.org/)

So some UX thoughts need to be done here in any case.

rugk commented 12 months ago

I tried to fork it and to rewrite it but once I did I realized that it's very big and I would need to understand a lot of details to be able to do it so after two days of trying I gave up for now.

Ah in any case thanks for trying to contribute. If you have any questions feel free to ask.

Basically you may need to register a new type and handler for your Fediverse site and add it here to the others: https://github.com/rugk/mastodon-simplified-federation/blob/1c54aec0381d959239d458c8f81383c6ad9b2588/src/background/modules/AutoRemoteFollow.js#L31

That detect handler does all the detection work and is called automatically, just use the existing ones as a reference: https://github.com/rugk/mastodon-simplified-federation/blob/main/src/background/modules/Detect/Friendica.js

That, however, is only for catching URL redirections. Now the tricky part is just ahead…

The tricky part is then to have a content script like https://github.com/rugk/mastodon-simplified-federation/blob/main/src/content_script/mastodonInject.js that intercepts the button clicks or whatever you actually want. You then need to add this to be injected into each tab here: https://github.com/rugk/mastodon-simplified-federation/blob/1c54aec0381d959239d458c8f81383c6ad9b2588/src/background/modules/AutoRemoteFollow.js#L157

The thing is to make sure you cause no false-positives (properly detect the website is an instance of the service) striking a balance between it being constrained enough like that, but also being flexible enough so that a website/slightly-modified or differently configured instance or an instance that may be running a more recent/upgraded software version still works. Sounds complicated but well, you'll see that and if there happens to be a breaking change in the Fediverse software then well… this add-on needs to be fixed again and upgraded.

The aim of all that content script currently just is to trigger opening a window/popup so the URL catching/detection you implemented earlier triggers. See here e.g.: https://github.com/rugk/mastodon-simplified-federation/blob/1c54aec0381d959239d458c8f81383c6ad9b2588/src/content_script/mastodonInject.js#L37

See https://github.com/rugk/mastodon-simplified-federation/issues/86 when that changes. But for now, this is the basic way.

rugk commented 12 months ago

As that is a good basic explanation to get started, I just dumped it to https://github.com/rugk/mastodon-simplified-federation/wiki/Development, though GitHub does not do inline code citations there unfortunately.