this post was submitted on 15 Jun 2023
31 points (100.0% liked)

Fedia Discussions

31 readers
2 users here now

founded 1 year ago
MODERATORS
 

Just a quick and dirty userscript to add some features I feel are super important. I'll probably look into creating some real PRs, but I figure the devs are probably in "put out fires" mode right now.

top 6 comments
sorted by: hot top controversial new old
[–] [email protected] 8 points 1 year ago (1 children)

Added a few more features:

Add domains to magazines and users for federated content
Collapse comments
Collapse replies
Replies start collapsed
Move comment box to top

All features can be toggled on and off

[–] [email protected] 2 points 1 year ago

It's like you can read my mind and know what I want, SirPsychoMantis

[–] [email protected] 3 points 1 year ago

Hi there, thanks for the userscript!

Using your code as base, I created for myself a function to add blur image to the nsfw thumbnails.

It works with posts already marked as +18 and also the ones that are from the nsfw domain, but has been coming to the feed without the +18 tag (and because of that, it ignores the preference setting about not showing nsfw content).

The code is probably bad, but if you like the idea, feel free to use/modify

  function thumbBlur(article) {
    article.querySelectorAll("figure > a > img").forEach(el => {
        applyBlur(el, 10);
      el.addEventListener('mouseover', function hover() {
        applyBlur(el, 0, 0.5);
      });
      el.addEventListener('mouseleave', function leave() {
        applyBlur(el, 10, 0.5);
      });
    });
  }

  function applyBlur(el, value, transition = 0) {
    if(transition != 0 ) {
      el.style.transitionDuration  = transition+"s";
    }
    el.style.webkitFilter = "blur("+value+"px)";
  }

  function addBlurNsfw() {
    document.querySelectorAll("article.subject").forEach(article => {
      article.querySelectorAll("small.danger").forEach(small => {
        if( small.textContent == "+18" ) {
          thumbBlur(article);
        }
      });
      article.querySelectorAll(".magazine-inline, .user-inline").forEach(link => {
        const parts = link.title.split("@");
        if( parts[2] == "lemmynsfw.com" ) {
          thumbBlur(article);
        }
      });
    });
  }
  addBlurNsfw();

[–] [email protected] 2 points 1 year ago (1 children)

Amazing! Thank you for your hard work, I can't wait to see the life this takes.

[–] [email protected] 3 points 1 year ago

Current outlook is hopefully a pipeline for PRs into the main code base, just figured we're in a golden opportunity of growth, so its more about speed than pretty / robust code.

[–] [email protected] 2 points 1 year ago

Thank youuuu