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

Script doesnt apply properly. Must always refresh page or hit save. #1

Open
gfigueroap opened this issue Sep 27, 2023 · 2 comments
Open

Comments

@gfigueroap
Copy link

If you filter a new word on any lemmy page, the filter will only work in that page. If you go page 2 of the same community or use lemmy's own search for the keyword, you will still find said filtered keyword. You have to hit F5 or once again click "Save" as indicated on the guide and only then itll work for all cases described.

Naturally, having to refresh the website every time i go to the next page is not ideal. I should be able to set the specific keyword once and forget about it from then on.

@jenda69
Copy link

jenda69 commented Oct 11, 2023

I added this after filterPostsByKeywords(savedKeywords); (second to last line):

  const callback = function(mutationsList, observer) {
    filterPostsByKeywords(savedKeywords);
  };
  // Create an observer instance linked to the callback function
  const observer = new MutationObserver(callback);
  const config = { childList: true, subtree: true };
  // Start observing the target node for configured mutations
  observer.observe(document.body, config);

It most definitely is not an optimal solution, but it works and is good enough after few minutes of googling and editing.
It monitors changes in the body element and everytime there's a change, it runs the filters again.

@Zetaphor
Copy link
Owner

I can take a look at this later, I'm currently wrapped up in a few other projects.

A more ideal solution would be watching for clicks to the next and previous page buttons and then running the filter. I'm open to PR's if anyone wants to make that change.

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