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

Do not inject mastodon-simplified-federation-injected class on each website #95

Closed
rugk opened this issue Jan 13, 2023 · 1 comment · Fixed by #97
Closed

Do not inject mastodon-simplified-federation-injected class on each website #95

rugk opened this issue Jan 13, 2023 · 1 comment · Fixed by #97
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@rugk
Copy link
Owner

rugk commented Jan 13, 2023

Bug description

A user on AMO correctly noticed the extension always injects a class called mastodon-simplified-federation-injected onto the body of each website – even non-Mastodon websites.

Steps to reproduce

  1. Install extension.
  2. Go to any website.
  3. Look in the developer tools for .mastodon-simplified-federation-injected.

Actual behavior

mastodon-simplified-federation-injected is injected on body.

Expected behavior

This injection should at most only happen on Mastodon instances, or not at all.
It can disturb users (actually the user in question noticed this as a red flag about the extension, which arguably, it can be).

System

Browser and version: Firefox 108
Add-on version: 2.0

Possible solution

The code that causes this is here:

const MASTODON_INJECTED_CLASS = "mastodon-simplified-federation-injected";
if (document.body.classList.contains(MASTODON_INJECTED_CLASS)) {
// init has already run
return;
}
document.body.classList.add(MASTODON_INJECTED_CLASS);

As you can see, it is a simple guard to prevent the extension from running twice. It has been introduced in #84.

Maybe a solution could be to use a variable instead that is defined and if already defined not re-defined? To prevent a double-injection?

/cc @hueyy

@rugk rugk added bug Something isn't working good first issue Good for newcomers labels Jan 13, 2023
@rugk rugk added this to the v2.1 milestone Jan 13, 2023
@hueyy
Copy link
Contributor

hueyy commented Feb 4, 2023

Agreed, that definitely isn't ideal. #97 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants