this post was submitted on 18 Jun 2023
39 points (100.0% liked)

Kbin Userstyles and Userscripts

15 readers
1 users here now

Custom CSS and JS to help improve your Kbin experience! ### Userscripts Greasy Fork ### Stylesheets UserStyles.world ### Userscript managers

founded 1 year ago
 

Download it from greasyfork

This userscript for kbin enhances the comment section adjusting the layout and adding a line to the left of each comment and its replies that lets you collapse them. The design is inspired by some custom subreddit stylesheets, and new reddit surprisingly enough (you know what they say about broken clocks)

Personally, I think this is the best way to handle collapsing comments here's a screenshot.

A video of it in action

If you don't have a userscript manager extension installed, you can install Tampermonkey, and then open the greasyfork link.

top 48 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 1 year ago* (last edited 1 year ago) (1 children)

Sorry for triple posting, but just wanted to test this out real quick. The script seems to basically work, but I've found a couple issues; After my second post it showed the line only on the first post. The second post didn't get a collapse line until I collapsed/uncollapsed the first post.
Second, when I edited a comment it removed the collapse line from that post until I edited a second time. This doesn't seem to be consistent.
Third, and this might just be on my end, at some point while editing the posts, the second post is now on the far right of the comments window, instead of just slightly to the right of its parent comment.

I don't think these issues will be a huge deal, and I'm still looking forward to using this. Thanks for making it!

EDIT: Should also mention I'm on Firefox as well, incase that matters.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

Thanks for the feedback! I'll see what I can do about fixing those issues. I think I might have partially fixed the first one, but the new comment isn't nesting properly.

Edit: this is a test to see if editing is working
Edit 2: my change didn't fix that, I'm on it

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

Perfect, thank you!

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

Edit: Already fixed, Thank you very much.
This is how it looks to me.
im on firefox kbin.social with kbin enhancement script an the optins for Show collapse comment Show collapse replies off

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

I think I know what the issue with that is, should be an easy fix!

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

I fixed the issue, try updating! Apparently Firefox doesn't support the experimental :has() selector by default

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

it worked, thank you very much

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

I love this, thanks so much for your hard work in making this, it's a huge UX improvement.

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

Yes. This script is amazing!

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

Ahhhhhhh that's so much better now. Thanks so much!!!!

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

After the fix, this is amazing!
Awesome work artillect!

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

Yessssssss. This one is how I wanted it to be.

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

For configuration, instead of the new button I think you should integrate them into the Kbin sidebar like is done by the kbin enhancement script.

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

I like the way that kbin enhancement does its config, but I plan on releasing the configuration for this script as a library that everyone can use in their userscripts, to make configs easy (and work cross-platform). I just need to finish it up and separate it into its own script

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

Edit: The issue was resolved, so please ignore this message. Thanks u/artillect!

There was an issue where the parent comment was in a column on the left side and its children were all on the right, but I adjusted the CSS:

   .entry-comment .children {
        /* grid-area: children; */ /* disable or delete this */
        display: flex;
        flex-direction: column;
    }

   .entry-comment .comment-level--2:first-child {
        margin-top: 3rem; /* Edit: If the child comment is long then the text will get cut off, so setting the margin and/or parent height conditionally could work*/
   }

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

What browser are you using?

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

Glad to see it was just the issue with Firefox, lemme know if you run into any other issues!

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

I'm having an issue where clicking anywhere on the comment will collapse it; Not just the line on the left. I couldn't figure out why myself, looking in the code, and it seems no-one else is having the issue?

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

That's a feature I added a bit later on, you should be able to disable it in the settings menu in the top right. However, this userscript is no longer supported, and has been added to KES (which you can install here), with some more config options added as well.

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

Perfect, thank you; Hadn't heard about KES yet

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

Test Comment, Plz Collapse

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

Test Nested Comment, Plz Ignore

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

@artillect @ernest

So, I have been using this script for a couple of weeks, and I can honestly say at this point that I cannot fathom using kbin without it. I really hope this gets rolled into core in some way.

Thank you @artillect !

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

Love it! I've noticed a single issue with themes though. Thread lines have set colors, which wouldn't be a problem unless you are using the solarized dark theme, then the first thread line is really hard to see.
What I did to fix that is simply set it the same border the first thread line uses normally (which is just the section border) that covers the background .comment-level--1 > .expando .threadLine { border: var(--kbin-section-border); border-width: 2px; }. It also fixes inconsistency between default kbin themes and custom-made ones.
Before and after

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

Another issue I've noticed: you can't select text in replies, the post collapses immediately after you select text and stop holding left click

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

Great idea for the change to the color so it respects the color scheme better.

For now, I've added an option that lets you disable "clicking anywhere on a comment to collapse", you can change it by clicking on your username in the top right, then clicking "Userscript Settings", and it'll be the only option in the menu that pops up

Edit: I just fixed the issue with highlighting text making comments collapse in 1.3.1

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

@artillect I found a weird bug/interaction! When you have the script (v1.2.1) as-is and enable media previews in the sidebar settings, a bunch of comments begin collapsed. It happens in this thread so it can be used for testing. Most of your comments are auto-collapsed.

The click handler on comments is triggered, as shown by this modification:

    // Add event listener to comment
    comments[i].addEventListener('click', function(){console.log("CLICK on comment " + i); toggleReplies(event, comments[i], expando)});

It spams a bunch of log lines in the console. I'm guessing the auto media preview is implemented by simulating clicks on comments, but I haven't checked the code.

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

I also found a fix: listen for 'mouseup' instead of 'click'. However, this still collapses comments when you try to select text so that's still not good.

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

Sorry, just noticed 1.3 is out, doh.
With fulltoggle off, the bug is solved, but it remains when it is enabled.

I also couldn't find the config menu anywhere and added openConfigMenu() to to async function to actually change the setting. Hm.

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

Hmm, I'll see what I can do about fixing the bug with enable media previews. I just fixed the issue with comments collapsing when you try to highlight text, try updating to 1.3.1. The config should be accessible in your user menu in the top right, I think I might move it into its own icon in the menu so it's more visible

Edit: It wasn't actually fixed in 1.3.1, but I have fixed it properly now

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

I feel like an idiot because I can't seem to get this working. Here is the error I'm getting in the source editor:
error

What the heck am I doing wrong here?

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

Try removing the highlighted lines and adding:

// @grant         GM.registerMenuCommand

I think this issue is caused by differences between the userscript managers we're using, this change should work

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

I still get that the grant method isn't supported with that command. I'm running Userscripts in Safari. No worries, I was able to get another one working - it's not as nice as the one you made but it's getting the job done for now.

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

If you remove all of the @grant lines, as well as this code (from lines 328 to 342), it should work:

    let gmc = new GM_config({
        'id': 'improved-collapsible-comments',
        'title': 'Improved Collapsible Comments',
        'fields': {
            'headerToggle': {
                'label': 'Toggle replies by clicking header (WIP, not functional)',
                'type': 'checkbox',
                'default': true
            }
        }
    });

    GM_registerMenuCommand('Settings', () => {
        gmc.open();
    });

I'll have to figure out a way to get configuration to work with Userscripts for safari once I start adding that

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

I just updated it to remove all of the stuff that's incompatible with Userscripts for safari, I'll have to figure out another method for configuration

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

It works great! Thanks so much

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

The only way to identify which comments are from OP are the dotted red line to the left of the comment, this script removes that so it is impossible to tell who OP is. Is there a way you could readd that or make some other differentiator so we know who OP is?

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

I just updated it to add an indicator for the OP and some other changes

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

No problem! Lemme know if you have any other suggestions :)

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

Thank you so much for this script ! Improves readability and clarity so much !
Hope it inspires ernest to build something similar natively.

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

This script hides the "expand message" thingy that appears on long messages like on this one: https://kbin.social/m/kbinStyles/t/12515/Share-your-CSS-and-JS-snippets-here#entry-comment-52434

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

I just released an update that adds that back, thanks for pointing that out

load more comments
view more: next ›