Lemmy federates code blocks with additional <span> tags added in on each line which /kbin just treats as plaintext (it should really strip them out or treat them as tags, not plaintext).

See this comment for an example

This userscript for kbin.social tries to remove those tags and make Lemmy code blocks actually readable.

Edit: Latest version supports infinite comments and turbo mode.

  • shazbot@kbin.social
    link
    fedilink
    arrow-up
    2
    ·
    8 months ago

    Thanks, this was helpful. By design, Greasemonkey scripts necessarily trigger on page load. However, KES initializes its own mutation observer and watches for events that change the DOM, but does so in a granular fashion so that only those of relevance (changes to the thread index and comments) are propagated. It looks like when turbo mode is enabled, the entire DOM up to the HTML tag is replaced at once, so our more granular approach is missing this change. We need to watch for basically all mutations now and filter them accordingly.

    After making the necessary changes, it seems to be working again as intended, but some additional refactoring is needed, and I haven’t checked the implication of this on specific scripts/add-ons yet. It looks like it should be easy enough, since the majority of functionality I looked at was working again when using a more permissive observer.