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

Support for Mastodon v4 #77

Closed
austinhuang0131 opened this issue Nov 5, 2022 · 15 comments · Fixed by #82, #84 or #87
Closed

Support for Mastodon v4 #77

austinhuang0131 opened this issue Nov 5, 2022 · 15 comments · Fixed by #82, #84 or #87
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@austinhuang0131
Copy link
Contributor

Background

Mastodon removed links to interact remotely and now asks you to just copy the link to the search box (which in my opinion greatly discourages decentralization).

Proposed solution

Inject HTML to rewrite the buttons...?

Alternatives

Right click menu...?

Additional context

@austinhuang0131 austinhuang0131 added the enhancement New feature or request label Nov 5, 2022
@rugk
Copy link
Owner

rugk commented Nov 7, 2022

Is this live on mastodon.social?

If so that is uff, as it changes the whole way this extension works. It now cannot just intercept URLs, but indeed needs to rely on injection.

@rugk rugk added the help wanted Extra attention is needed label Nov 7, 2022
@rugk rugk pinned this issue Nov 7, 2022
@StormPooper
Copy link

Is this live on mastodon.social?

Yes, mastodon.social is running v4.0.0rc1.

@austinhuang0131
Copy link
Contributor Author

Also, the interface link is now https://example.instance/@[email protected]/103810871178820703 without the /web/ anymore

@veale
Copy link

veale commented Nov 12, 2022

There is also this relevant new issue on the Mastodon page mastodon/mastodon#20296 which flags that new Web APIs are available that can register websites as handlers for other types of links. This seems like the longer term solution but no idea if it will get takeup.

@hueyy
Copy link
Contributor

hueyy commented Nov 13, 2022

I think HTML injection can only be done via a content script, in which case there are 2 ways to go about this:

  1. By running a content script on all URLs that checks if the page is a Mastodon v4 page, and then injects the appropriate HTML. This has the downside of requiring permission to run a content script on all URLs.
  2. By programmatically running a content script in either the active tab or all tabs. The content script then injects the appropriate HTML. I think this can be done with the existing set of permissions.

In both cases, the content script locates the follow button and adds an eventListener that redirects on click to https://example.instance/authorize_interaction?uri=@[email protected], and then preventsDefault and further propagation of the event. And analogous injections for the interaction buttons too (i.e. reply, boost, and favourite).

If this makes sense, I'm happy to send in a PR implementing it. But since it appears to quite different from how the extension currently operates and this would also be my first contribution to the repo, I'd appreciate @rugk's thoughts on this.

Edit: I have since opened a draft PR (#82)

@StormPooper
Copy link

StormPooper commented Nov 14, 2022

Just wanted to mention that https://github.com/mastodon/mastodon/releases/tag/v4.0.0 has just been officially released, so we'll start to see more servers stop working with the extension soon. hueyy's second proposal sounds like a decent plan to me.

@atomicwrites
Copy link

Yeah I joined mastodon yesterday, and all the servers I have tested are on v4 and don't work with the extension.

@rugk
Copy link
Owner

rugk commented Nov 17, 2022

@atomicwrites We're at it, thanks again to @hueyy who works on that in #82.

@RodriMora
Copy link

@atomicwrites We're at it, thanks again to @hueyy who works on that in #82.

seems like the fix is already g2g, when should we expect to have an update on the extension? Thanks a lot!

@2rs2ts
Copy link

2rs2ts commented Nov 23, 2022

I would like to share that another extension has popped up that apparently handles the Mastodon 4 redirection. I haven't tested it since it also requests all site data and has no reviews, and I don't know if it'll play nice with Pleroma etc., but it might be worth taking a peek at how they accomplish it.

@rugk rugk closed this as completed in #82 Nov 23, 2022
@DiThi
Copy link

DiThi commented Nov 27, 2022

All of the instances I've tried it with are v4, so I think the currently published version is broken for most people. I made a little userscript to use until the fixed version is published (replace example.com by your instance, then use with F2).

// ==UserScript==
// @name         Go to my mastodon instance
// @match        *://*/*
// @grant        none
// ==/UserScript==

// PUT YOUR INSTANCE BELOW
const INSTANCE = 'example.com';

addEventListener('keydown', (e)=>{
    if(e.key === 'F2' && document.body.firstElementChild.id === 'mastodon'){
        e.preventDefault();
        let parts = location.href.split('/').splice(0,4);
        if(parts[3].indexOf('@',1) === -1) parts[3] += '@'+parts[2];
        parts[2] = INSTANCE;
        location.href = parts.join('/');
    }
})

@stefandesu
Copy link

@DiThi I just built myself a similar UserScript (although yours is so much simpler), but my instance will only show a spinner for accounts it hasn't yet interacted with. As soon as I open the profile once (e.g. through my instance's search), the URL will work. For now, I'm using the /authorize_interaction?uri= endpoint which works well.

@evmcl
Copy link

evmcl commented Dec 9, 2022

Will there be a new release of the extension any time soon so we can reap the benefits of this fix?

@DiThi
Copy link

DiThi commented Dec 13, 2022

Yeah I think an imperfect addon that can only follow people and maybe fav/boost sometimes is much better than an outdated that can't do even that. I used this addon a few times, but very rarely because so few instances I encounter are v3 now.

@rugk
Copy link
Owner

rugk commented Dec 13, 2022

BTW, after long struggles and many fixes after fixing, we've got a version that works (as far as we tested) reliably and thus I've published it as a release: https://github.com/rugk/mastodon-simplified-federation/releases/tag/v2.0

I hope that helps you all and thanks a lot for being patient.

As an additional thing, I could also solve #74, i.e. we've got an updated logo, too! 😊 (Though I've also stumbled across weird rendering bugs there hehe: #90)

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