Skip Navigation
plugins

Lemmy Plugins and Userscripts

  • TooMuchVanced TooMuchVanced @lemmy.world
    Featured
    Lemmy Extensions & Userscripts

    Browser Extensions:

    Mullem (Firefox):

    lemmy-keyboard-navigation (Chrome):

    Instance Assistant:

    Lemmy Link:

    Lemmy Go:

    Lemmy Modern UI (Firefox Addon):

    Lemmy Home Instance Helper:

    Userscripts:

    LemmyTools:

    Lemmy Image Expand:

    Lemmy Universal Link Switcher:

    Compact Lemmy to old.Reddit Re-format:

    Lemmy/KBin Redir:

    GM Lemmy NewTab:

    Lemmy Style Cleanup:

    lemmy-keyboard-navigation:

    Lemmy Federation Awareness:

    Lemmy Subscription Helper:

    Block lemmy instances:

    Lemmy Local Community Redirect:

    Lemmy Custom Navbar Links:

    beehaw lemmy add home-instance name to username:

    beehaw lemmy separate spacing of delete and edit buttons:

    Lemmy post filter - Filter posts by title:

    Lemmy Post Keyword Filter:

    Filter lemmy.ml communities:

    4
  • ready to wear
    jazmin.pk Buy Party Wear Dresses For Women Online In Pakistan

    Grab the latest party wear dresses for women online in Pakistan. Jazmin offers an amazing collection of ladies' ready to wear and designer wear dresses. Discover the latest women’s party dresses to bring attention and improve your wardrobe. Find your favorite apparel and get COD all over Pakistan. S...

    Buy Party Wear Dresses For Women Online In Pakistan

    Jazmin offers a large number of ready to wear for girls and women in Pakistan at low prices. We provide the highest quality fabric in various colors and styles Grab your favorite dresses online at Jazmin.

    0
  • afoutopatisa afoutopatisa @lemmy.world
    Lemmy Keyboard Navigation 2.5 released with lemmy 0.19 support
    github.com GitHub - vmavromatis/Lemmy-keyboard-navigation: RES-like script that allows you to easily navigate Lemmy with your keyboard

    RES-like script that allows you to easily navigate Lemmy with your keyboard - GitHub - vmavromatis/Lemmy-keyboard-navigation: RES-like script that allows you to easily navigate Lemmy with your key...

    GitHub - vmavromatis/Lemmy-keyboard-navigation: RES-like script that allows you to easily navigate Lemmy with your keyboard

    Feel free to give it a spin and add any feature requests on github!

    1
  • Instance Assistant v1.2.6 is out - Redirect user profile pages

    cross-posted from: https://lemmy.ca/post/6770347

    > This is a very small update, but hopefully it's helpful! As I mentioned in the last update, I'm a little tied up with other commitments right now, so I haven't had a chance to implement the other features on the to-do list. This one was requested the other day, and it was simple to add since I could reuse a lot of existing code. > > --- > > Links: > - Firefox Add-on > - Chrome Extension > - Edge Add-on (waiting as of 2023-10-09) > - GitHub > > --- > > ::: spoiler ❓ What is Instance Assistant? > > If you're new to Instance Assistant, it is a browser extension with a collection of tools and features to simplify your browsing experience on Lemmy and Kbin. It is available on Chrome, Firefox, and Edge; you can also install it from the releases page on GitHub. > > For a full list of features, please see the GitHub homepage: https://github.com/cynber/lemmy-instance-assistant > > ::: > > --- > > ⭐ What's new in v1.2.6? > - Redirect user profile pages: When you want to message a user and click on their profile, you might end up on a foreign instance. To message them, you need to modify the URL or copy/paste. Instead, you will now find a little button to jump you to your home instance. > > ! > > --- > > 💛 Also > > Thank you for all the suggestions and feedback! Like I said before, I'm really happy to see that people are using the extension and finding it useful. Please continue to make suggestions and contribute your expertise. > > Cheers :)

    0
  • [UserScript] Simple old Lemmy community bar customisation (updated again)

    UPDATES BELOW

    So I browse on the desktop using the mlmym/old.lemmy client (e.g. http://old.lemmy.world) because old habits die hard.

    One of the many things I found myself missing from RES & Reddit was the ability to customise the community bar at the top of the page to contain some links to my favourite communities. I had a spare minute this morning to throw together a userscript for just that:

    Here's a pastebin with the script. Create a new userscript in tampermonkey (or whatever userscript plugin you use), drop the code in, change the array of communities at the top to be the ones you want prepending to the list, and you should be good.

    Make sure to add the server suffix to any communities from other instances and if you want to use this on another instance other than lemmy.world, just change the match rule in the userscript header comment.

    I didn't host on greasyfork as I'm probably not going to make any further changes, and I'd need to come up with something a bit more sophisticated than an array of communities. I'll update this post if I ever change my mind on that

    Update

    So I guess I wasn't happy with leaving it alone:

    Here it is on greasyfork https://greasyfork.org/en/scripts/474756-lemmy-mlmym-community-bar-customisation

    I added localStorage and a simple config GUI to configure the list of favourites now, no reordering yet (without just removing and re-adding in a different order), but I imagine I'll end up adding that in time

    Update 2

    And another update:

    I've just updated GreasyFork with 0.3

    • Added reordering
    • Added background fade and background click to close
    • Added favourite/unfavourite button to the community sidebar
    2
  • Instance Assistant v1.2.5 released: You can now generate posts for Lemmy/Kbin, search for posts, and redirect posts from foreign instances

    Hi everyone, I'm excited to announce one more release before I take a short break. I have some other stuff starting up, so I won't be pushing out new features as fast, but I'll still be around to manage the project. (more at the end)

    Links:

    ❓ What is Instance Assistant?

    If you're new to Instance Assistant, it is a browser extension with a collection of tools and features to simplify your browsing experience on Lemmy and Kbin. It is available on Chrome, Firefox, and Edge; you can also install it from the releases page on GitHub.

    For a full list of features, please see the GitHub homepage: https://github.com/cynber/lemmy-instance-assistant

    ---

    ⭐ What's new in v1.2.5?

    • Redirect posts to your home instance!: Post pages now have a redirect button that will find the same post on your home instance(1). You don't have to hunt it down yourself anymore.
    • Posts related to this webpage buttons in popup & sidebar
      • Make a post: You can now create a post from any webpage! Click the 'Make a Post' button in the extension popup or sidebar to generate a draft post with autofilled title, URL, and body contents. Afterwards, just select a community and hit post. (This currently works for both Lemmy & Kbin, but custom frontends are untested while they develop). Try it here: https://lemmy.ca/post/4478560
      • Open Posts: This will find any posts about the webpage/article/video that you are looking at. Use it to see if something has already been posted, or to find related discussions about it. When there are multiple posts, it will ask before opening them all. (see note on risks and why it doesn't count automatically)
    • Post an image: You can now right-click on an image, anywhere on the web, and hit "Post this image". It will open a new tab and autofill the title, image link, and add the page URL to the body as "Source: URL". Try it here: https://lemmy.ca/post/1282303
    • Reorganizing popup:
      • I fixed the issue where the popup would still display a button after removing all instances from the list.
      • The number of default instances in the popup was reduced to 4
    • Added settings:
      • You can now hide onboardining guides to make the interfaces less wordy
    • General styling changes, wording improvements, and bugfixes

    (1) This is an important feature to me because this little annoyance was part of why I set out to create the extension in the first place. Thanks to some help from @zero_gravitas, I was able to use the Lemmy API to grab the post details, and then run a search for it on your home instance. While most posts should only bring one result, there is a chance that there are multiple posts by the same user, in the same community, with the same title. If this is an issue, I'll make this search more specific.

    ---

    🗣️ My questions for you:

    Improving 'post to Lemmy'

    • Right now the 'Post to Lemmy' button does a very basic search in the page meta tags for information. This works for most websites, but it is not perfect. What websites do you usually post from, and is the extension doing a good job of replicating how you format the post? Please share both good and bad examples, so we can fix what isn't working and keep what is.

    Improving Post search

    • Having the extension automatically count the number of posts and display it in the icon would be pretty nice, since then you would know about any posts for the news article / blog / video that you are looking at. However, there are privacy implications with this since it needs to send the URL to your home instance to do the search.
    • I would like to add the option to whitelist specific websites, so the user can choose what browsing data they want to find posts for. Is this something you would list to use? What websites would you whitelist?

    Anything else?

    Please share any issues that you find. Lemmy and Kbin instances have a lot of variation in how things are structured, so there are bound to be some bugs that I haven't found yet. If you have any ideas for new features, please share them too! I'm always looking for new ideas to add to the project.

    ---

    🔮 Cool ideas being discussed for the future
    • Account switcher & ability to save login info to extension
    • Reddit migrator tools
      • multireddit input should convert subscriptions to official Threadiverse replacements, or large related communities
      • embeds on Subreddit sidebars to search for similar community
      • button on post pages to cross-post to home instance
    • Prepping for Firefox Mobile app, now that they are opening mobile up to all extensions!
    • Keyboard hotkeys, possibly collaborating with someone that already implemented something similar

    For the most up to date information, see the issues or the project road map

    ---

    💛 Finally

    Thank you for all the suggestions and feedback so far! I'm really happy to see that people are using the extension and finding it useful. I'm looking forward to seeing what we can do with it in the future.

    Like I said above, I won't be as active over the next few months in terms of getting new features out. The extension is now in good shape, and it covers most of the important use cases. There's still lots of cool stuff we can do with it, so please contribute ideas and expertise! When I get a chance, I'll pop in and grab a few more issues.

    Cheers :)

    0
  • Lemmy Keyboard Navigation 2.3 released with mlmym support

    This is a gift for all you mlmym lovers out there:

    A userscript that allows you to navigate lemmy with HJKL keyboard navigation, now with mlmym support :) This is an initial release and only available on github for now.

    ALL credits go to InfinibyteF4 for making this happen 🏆

    EDIT: to link the updated file which works for both vanilla lemmy and mlmym

    0
  • Userscript to generate Markdown-fomatted source info for websites (w/ extra info for ArtStation and Tumblr)

    When you run the script, it will show a textarea with the markdown code for crediting sources. I use it to save time when posting to Lemmy.

    Usual disclaimer: I've tested it but only to a certain point (with my environment). If you find any issue you don't know how to fix, let me know.

    EDIT: Here are the scripts in pastebin raw text (lemmy currently replaces the ampersand signs with & and it breaks the scripts:

    --- Tip (for firefox users): you can set a keyword for a bookmarklet that you can run form the navbar. Once you get used to "Control+L (focus navbar) > keyword" it becomes really frictionless.

    --- For generic pages, the output is:

    Source: Page title

    --- For Tumblr posts the outuput is:

    Source: Page title

    Tumblr archive: https://site_url/archive

    RSS Feed: https://site_url/rss

    --- For ArtStation pages the outuput is:

    Source: Page title

    > Description (if there is any)

    ArtStation profile: https://profile_url

    RSS Feed: https://profile_url.rss

    ---

    pretty printed code

    (function() { var sourceCode = ""; var isArtStation = document.location.host.endsWith("artstation.com"); if (isArtStation) { sourceCode = getArtstationInfo(); } else { var title = ("%s" || document.title).replace("[", "\\[").replace("]", "\\]"); sourceCode = Source: [${title}](${document.location.href}); var isTumblr = [...document.querySelectorAll("link")].filter(e => e.href && e.href.indexOf("tumblr.com") >= 0).length > 0; if (isTumblr) { var tumblrUrl = ${document.location.protocol}//${document.location.host}; sourceCode += "\r\n\r\nTumblr archive: " + tumblrUrl + "/archive"; sourceCode += "\r\n\r\nRSS Feed: " + tumblrUrl + "/rss"; } } var inpt = document.getElementById("crul-source-code"); if (!inpt) { inpt = document.createElement("textarea"); inpt.id = "crul-source-code"; inpt.style.position = "fixed"; inpt.style.color = "black"; inpt.style.top = "5vh"; inpt.style.left = "5vw"; inpt.style.height = "90vh"; inpt.style.width = "45vw"; inpt.style.border = "solid 2px tomato"; inpt.style.zIndex = "99999"; document.body.appendChild(inpt); var closeBtn = document.createElement("button"); closeBtn.onclick = () => { inpt.remove(); closeBtn.remove(); }; closeBtn.innerHTML = "X"; closeBtn.style.position = "fixed"; closeBtn.style.width = "30px"; closeBtn.style.height = "30px"; closeBtn.style.background = "tomato"; closeBtn.style.color = "white"; closeBtn.style.border = "none"; closeBtn.style.zIndex = "999999"; closeBtn.style.top = "5vh"; closeBtn.style.left = "calc(50vw - 30px)"; document.body.appendChild(closeBtn); }; inpt.value = sourceCode; inpt.focus(); inpt.select();

    function getArtstationInfo() { var sourceCode = ""; var title = document.querySelector(".project-description-title"); if (!title) return; var author = document.querySelector(".project-author-name h3 a"); if (!author) return; title = title.innerText.replace("[", "\\[").replace("]", "\\]"); sourceCode = Source: [${title} (by ${author.innerText} - ArtStation)](${document.location.href}); var description = document.querySelector(".project-description p:first-child"); if (description && description.innerText) { description = description.innerText.replaceAll("\n", " \n> "); sourceCode += \r\n\r\n> ${description}; } var profileUrl = document.querySelector(".project-author-name a").href; sourceCode += "\r\n\r\nArtStation profile: " + profileUrl; sourceCode += "\r\n\r\nRSS Feed: " + profileUrl + ".rss"; return sourceCode; } })();

    --- One-liner:

    javascript:(function() {var sourceCode = "";var isArtStation = document.location.host.endsWith("artstation.com");if (isArtStation) {sourceCode = getArtstationInfo();} else {var title = ("%s" || document.title).replace("[", "\\[").replace("]", "\\]");sourceCode = Source: [${title}](${document.location.href});var isTumblr = [...document.querySelectorAll("link")].filter(e => e.href && e.href.indexOf("tumblr.com") >= 0).length > 0;if (isTumblr) {var tumblrUrl = ${document.location.protocol}//${document.location.host};sourceCode += "\r\n\r\nTumblr archive: " + tumblrUrl + "/archive";sourceCode += "\r\n\r\nRSS Feed: " + tumblrUrl + "/rss";}}var inpt = document.getElementById("crul-source-code");if (!inpt) {inpt = document.createElement("textarea");inpt.id = "crul-source-code";inpt.style.position = "fixed";inpt.style.color = "black";inpt.style.top = "5vh";inpt.style.left = "5vw";inpt.style.height = "90vh";inpt.style.width = "45vw";inpt.style.border = "solid 2px tomato";inpt.style.zIndex = "99999";document.body.appendChild(inpt);var closeBtn = document.createElement("button");closeBtn.onclick = () => {inpt.remove();closeBtn.remove();};closeBtn.innerHTML = "X";closeBtn.style.position = "fixed";closeBtn.style.width = "30px";closeBtn.style.height = "30px";closeBtn.style.background = "tomato";closeBtn.style.color = "white";closeBtn.style.border = "none";closeBtn.style.zIndex = "999999";closeBtn.style.top = "5vh";closeBtn.style.left = "calc(50vw - 30px)";document.body.appendChild(closeBtn);};inpt.value = sourceCode;inpt.focus();inpt.select();function getArtstationInfo() {var sourceCode = "";var title = document.querySelector(".project-description-title");if (!title) return;var author = document.querySelector(".project-author-name h3 a");if (!author) return;title = title.innerText.replace("[", "\\[").replace("]", "\\]");sourceCode = Source: [${title} (by ${author.innerText} - ArtStation)](${document.location.href});var description = document.querySelector(".project-description p:first-child");if (description && description.innerText) {description = description.innerText.replaceAll("\n", " \n> ");sourceCode += \r\n\r\n> ${description};}var profileUrl = document.querySelector(".project-author-name a").href;sourceCode += "\r\n\r\nArtStation profile: " + profileUrl;sourceCode += "\r\n\r\nRSS Feed: " + profileUrl + ".rss";return sourceCode;}})();

    3
  • Tool for moderators: Violentmonkey/Greasemonkey script to list communities you moderate below your profile link
    github.com GitHub - pro-tarr/lemmy-ux-improvements

    Contribute to pro-tarr/lemmy-ux-improvements development by creating an account on GitHub.

    GitHub - pro-tarr/lemmy-ux-improvements

    cross-posted from: https://lemmy.world/post/3689844

    > This is a User Script I made that makes some adjustments to Lemmy’s UX (works on lemmy.world and lemmy.ml). > > Project page: https://github.com/pro-tarr/lemmy-ux-improvements > > ### What it does > > - Quick access to communities you moderate: This script adds a list of the communities you moderate right below your profile link in the top-right menu, so you don't need to load the profile page just to access your communities. > > ! > > - Open thumbnail links in a new tab: Links in thumbnails will automatically open in a new tab (image links will continue with their default behavior). > > If you want to improve this in-a-rush code, expanding its features of fixing bugs, feel free to send pull requests. > > ### How to install > > - Install the Violentmonkey extension. > - Copy the source code and add it into Violentmonkey extension (if you have the extension installed, it will prompt you to install the script when you access the link to the code). > > > Happy Lemmy-ing! >

    0
  • Instance Assistant v1.2.4 is here!

    cross-posted from: https://lemmy.ca/post/3232301

    ---

    Status & Download Links:

    | Firefox v1.2.4 | Chrome v1.2.4 | Edge v1.2.3 | | ---------|---------|-------|

    Download from source: release v1.2.4 (github.com)

    • While Edge and Opera are awaiting approval, you can install v1.2.4 from here, or through the Chrome store

    ---

    !

    Hi everyone!

    On the surface, this update brings a handful of features integrating the extension with other tools and services. We have the first of many features from the LemmyTools userscript, as well as the support for Alexandrite and Photon frontends. You can also directly search for communities through Lemmyverse.net and for posts through search-lemmy.com, among other small changes.

    The biggest change was behind the scenes. I've completely refactored the code throughout the extension. Now that we have a clearer plan for the extension, I simplified all around, such as consolidating most functions to a central utils.js file. I also reworked the settings, and unfortunately this means you may have to add your home instance again. Moving forwards, it should be a lot easier to maintain the extension and for people to collaborate, which brings me to:

    Want to help?

    Get started:

    I've put together some notes on how the extension is structured for those that want to help. The extension itself is fairly simple, and it doesn't use any particular framework or anything. It should a great first project to work on, even if you are just learning or new to web development.

    Having more people add to one place would make it easier for users that are juggling many extensions and userscripts. That's why I've been focussed on having a more intuitive structure for the project and leaving detailed notes and comments. I'm also likely not going to have as much time starting next month so I'm trying to do what I can now to get everything rolling.

    If you don't know where to start or just have an idea, let me know and I'll see what I can do :)

    As always, you can add new ideas and issues here: https://github.com/cynber/lemmy-instance-assistant/issues

    ---

    All new improvements with v1.2.4

    New Changes
    • search for communities through Lemmyverse.net or for posts through lemmy-search directly from the popup or sidebar
    • You now have the option to hide the default Lemmy sidebar (more LemmyTools features to come!)
    • Replaced non-functional 'subscribe' button on foreign /communities pages (only when no account is signed in, so not to replace something functional)
    • Support for Alexandrite & Photon frontends. Test them here:
      • Alexandrite: https://a.lemdro.id/c/lemdroid
      • Photon: https://nu.lemdro.id/c/lemdroid
      • New 'communityNotFound' button to account for alternate frontends: https://lemmy.ca/c/lemdroid@nu.lemdro.id
    • Fix for generated link on CommunityNotFound pages
    • Completely refactored the code to move repetitive functions to a utils.js file
    Future Plans:
    • Exploring a 'Reddit migrator' tool, similar to the mobile tool in Voyager, powered by lemmyverse.net
    • Adding more features from LemmyTools Userscript, with help from /u/howdy@thesimplecorner.org
    • Prepping for Firefox Mobile app, now that they are opening mobile up to all extensions!
    • Keyboard hotkeys, possibly collaborating with someone that already implemented something similar
    • Adding icons and simplifying the design, as the menus are getting very wordy
      • settings to limit onboarding / help instructions
    • Ability to have multiple 'home instances'
    • Finishing the setup so that people can contribute translations / other languages to the extension.
    2
  • [UserScript] Scroll to parent comment and back
    greasyfork.org [Lemmy] Scroll to parent comment

    Adds a scroll to parent comment link to comments when clicking the more button on a nested comment, and a button to the parent comment to scroll back to that comment from parent.

    [Lemmy] Scroll to parent comment

    Description

    It adds a scroll to parent button to nested comments (after clicking the "more" button). If you then press the more button on the parent comment, you'll see a back to child button that will scroll back to the comment you came from on click (also after clicking the "more" button).

    Install

    1. Install via Greasy Fork or copy the code from there.

    2. Replace the @match value with your instance.

    Screenshots

    !

    !

    Notes

    Tested on Firefox with Tampermonkey and Violentmonkey.

    0
  • Has Anyone found a userscript or extension to instantly hide viewed links?

    This was a HUGE part of my reddit experience and I have yet to found an alternate.

    I began using kbin instead of lemmy because of this userscript which has pretty much the exact functionality I'm looking for

    https://greasyfork.org/en/scripts/469175-kbin-hide-posts-after-voting

    but Kbin blocks a LOT of communities that I want to interface with. I feel like I'm missing out if I'm not on Lemmy ... but I feel like I hate the user experience without the automatically hiding posts :(

    Any advise?

    7
  • No post scheduling scripts yet?

    I mean, I wanted to start work on it, but if someone's already released/working on one then I'd just happily use those instead.

    Also, the absence of a thing usually means it's not possible to have. In my mind I think it's easy to have userscript code make API posts on behalf of the user, but maybe somehow in the intricate layers of tech it's made impossible or tedious. If so, I'd like to know before I learn it the hard way.

    5
  • uBlock Filters for various stuff

    There are likely various edge cases I've missed, and I am not too sure on performance compared to a purpose-built userscript, but these seem to work well enough for my use cases.

    Throw these to My filters in uBO settings. May also work with AdGuard, but I can't support you there as I don't use it. Other ad blockers probably won't work, but then why are you using an ad blocker that isn't uBO anyway?

    Remove the exclamation mark preceding the rules and adjust the placeholders accordingly. If you need multiple filters copy paste the appropriate lines.

    You may need to replace the lemmy.* part if your home instance is on a different (sub)domain. I'm not using .lemmy-site and a global selector for performance reasons.

    ``` ! Post filters use :has instead of :upward to take advantage of native CSS support on browsers that implement it. ! If :has is not implemented, uBO will emulate it via JS. :upward might be more efficient on those cases.

    ! Lemmy: Filter post by link domain ! lemmy.##.post-listing:has(.fst-italic[href="example.com"])

    ! Lemmy: Filter post by keyword in title ! lemmy.*##.post-listing:has(.post-title:has-text(/\bkeyword\b/i))

    ! Lemmy: Filter post by author instance ! lemmy.*##.post-listing:has(.person-listing[title$="@example.com"])

    ! Lemmy: Filter post by community instance ! lemmy.*##.post-listing:has(.community-link[title$="@example.com"])

    ! Lemmy: Filter post by instance (author or community) ! lemmy.*##.post-listing:has([title$="@example.com"]:is(.person-listing, .community-link))

    ! Lemmy: Filter post by community name (any remote instance) ! lemmy.*##.post-listing:has(.community-link[title^="!politics@"])

    ! Lemmy: Filter post by community name (home instance, though in this case you can just use lemmy's own blocking) ! lemmy.*##.post-listing:has(.community-link[title="!politics"])

    ! Lemmy: Filter comment by keyword ! lemmy.*##.md-div:has-text(/\bkeyword\b/i):upward(.comment)

    ! Lemmy: Filter comment by author instance ! lemmy.*##.person-listing[title$="@example.com"]:upward(.comment)

    ! Lemmy: Filter both by author instance ! lemmy.*##.person-listing[title$="@example.com"]:upward(:is(.post-listing, .comment)) ```

    3
  • Issue with LemmyTools, the menu is gone on my home instance! (SOLVED)

    Edit: I solved this issue by deleting reseting the script in Tampermonkey, deleting the script and then also deleting Tampermonkey from my chrome. Then I did a full flushing of cache.

    Hello fellow lemmys! I've started to use LemmyTools, but I did a thing that made the toolbar for this script to disappear from my home instance (lemmy.world).

    What I think I did was to have nothing in the "LemmyTools bar vertical position", because after I saved that it disappeared.

    I've tried the following to fix this:

    • Reinstalled Tampermonkey
    • Change the settings on another instance
    • Factory reset LemmyTools (inside Tampermonkey)

    But nothing works. Any suggestions as to how to fix this? I LOVE this script and I want to continue to use it as it's so useful but this is just a weird thing I've been able to fuck up 🤣

    0
  • [Userstyle] I've updated my Dracula theme for Lemmy!

    cross-posted from: https://lemmy.blahaj.zone/post/1312795

    > ! > > [Image description: A screenshot of the lemmy.blahaj.zone front page with a custom userstyle applied. The userstyle features a dark gray background with medium gray text and brightly-colored accents of purple, pink, orange, and cyan. The right sidebar cards are a light shade of gray with lighter gray text, pink buttons, and orange links] > > A few weeks ago I decided to try my hand at bringing my favorite theme to Lemmy and this userscript was born. It's still in the early stages so there are some wrinkles to iron out, but I just pushed a big update with better contrast, style fixes, and streamlined code. > > I've received several requests to turn it into a native Lemmy theme but have no idea how to do that. If anyone has any tips on theming, interest in collaborating, or a Lemmy instance where I could test a native theme, hit me up! You can find all the code here on Codeberg.

    3
  • I had ChatGPT write a userscript that lets you block posts using keywords
    greasyfork.org Lemmy Post Keyword Filter

    Automatically hide posts that match keywords from Lemmy sites.

    As the title says, I got tired of hearing about twitter and reddit so provide this userscript a comma separated list of keywords and you will no longer see posts containing those keywords. I'd love to see this functionality built into Lemmy itself, but until then here's a userscript.

    Repo link

    9
  • howdy Rick @thesimplecorner.org
    LemmyTools 0.2.0.7 is released! Now with Top Bar as default! Browser addon news: LemmyTools functionality is being explored to go into the "Instance Assistant for kbin & lemmy!" by cynber!
    greasyfork.org LemmyTools

    A small suite of tools to make Lemmy easier.

    cross-posted from: https://thesimplecorner.org/post/112995

    > I wanted to get this update out... As I believe the top bar is entirely more usable than the sidebar. It is of basic functionality and works nicely. Next release will allow you to pin favorite communities to the top bar (shown when you are not searching for a community). > > Also, exciting news, we are beginning to explore adding LemmyTools functionality to the "Instance Assistant for kbin & lemmy!" by cynber browser addon found: https://github.com/cynber/lemmy-instance-assistant & !instance_assistant@lemmy.ca. > > For now, I will keep the updates for the UserScript version of LemmyTools as is while integration into the addon is being worked. > > I am having a lot going on in my personal life so that is why updates are a bit slower. Thank you to cwagner for making the lovely user tagger feature as of last release as that is a nifty feature. > > Please feel free to tell me what you think about everything. > > > > . > > . > > . > > . > > Installation and Configuration: > > 1 - Browser must have a Userscript addon (Tampermonkey, Greasemonkey, Etc…). Tested with Greasemonkey. > > 2 - Download either the .JS file or install from greasyfork. > > 3 - Set home lemmy instance via options page once script is loaded (and manually edit the homeInstance variable in script for all functionality) > > This script is all done by a complete amateur for fun. Enjoy and feel free to fork it! > > Get it here: Github or GreasyFork > > Please submit issues to the github for feature requests and problems: Github LemmyTools Issues

    3
  • Instance Assistant v1.2.3 is now available on Chrome & Firefox + New Features

    cross-posted from: https://lemmy.ca/post/2012318

    > Links: > * Firefox > * Chrome > * Edge - v1.2.3 is still being approved, you can grab the release from Github if you are eager > * Opera: Still under review, please download from Chrome webstore or Github release. > > For questions / support: !instance_assistant@lemmy.ca (alternate: https://lemmy.ca/c/instance_assistant) > > ### What's new? > (read on the wiki) > - You can now customize the instance list to match which instances you actually use. This should be helpful for those that have accounts on different instances. > - Added a settings page so that you can turn off features that you don't want active > - Added buttons for helpful tools that let you explore Lemmy/Kbin communities (with lemmyverse.net), and search across Lemmy sites (with search-lemmy.com). > - Added a sidebar for those that prefer it (works on Firefox, Chrome & Opera; Edge doesn't have sidebars yet but the code is there) > - Fix for issues with the search trigger on the community not found page (thank-you to whqwert!) > - Various bugfixes, small theme changes, and improved wording > > ### What's coming up? > (read on the wiki) > - Working with the amazing /u/howdy@thesimplecorner.org to bring over features from the LemmyTools Userscript1 > - Integrating lemmyverse.net and search-lemmy.com so you can do everything right on your community page2 > - Adding icons and simplifying the design, as the UI is getting wordy > - Adding support for alternative home instances (ex. Alexandrite - Issue 14) > - Ability to have multiple 'home instances', so you can open it in any without having to change your home instance each time. > - Finishing the setup so that people can contribute translations / other languages to the extension. > - Getting the extension on Opera (no immediate plans, but this would be good to have) > > More details: > 1) /u/howdy@thesimplecorner.org has created a really useful userscript that you can find here: https://thesimplecorner.org/c/lemmytools. We're going to be working together to bring those features into Instance Assistant, so that you can have all the features in one place. > > 2) Right now there are buttons to explore Lemmy/Kbin communities (with lemmyverse.net), and search across Lemmy sites (with search-lemmy.com). Both of these take you to the respective webpages. Instead, it might be nicer to have a lightweight version right on the Lemmy/Kbin community page (or in the extension popup/sidebar). This should be possible using their APIs/data access, and I have a little working proof of concept already (see GitHub) > > # I'm new, what is this? > > Instance Assistant is a browser extension that started out as a way to quickly jump from one community to the version on your home instance, so that you could subscribe/participate immediately. Since then, a few other features have been implemented: > > ### Features > > * Redirect to your home instance: > * Buttons will be added to the sidebar of any Lemmy or Kbin community you visit, which will let you open the same community on your home instance. > * Open links in home instance: > * Right click context menu will allow you to open any links in your home instance > * Improved Error Pages: > * 'Community not found' pages now have better information, a button to trigger a fetch, a button to open a community in the source instance, and more. > * Customizable popup & sidebar menus: > * Customizable list of instances to let you quickly switch home instances. This is great for if you have multiple accounts on different instances. > * There are also buttons for helpful tools that let you search for communities (with lemmyverse.net), and search across Lemmy sites (with search-lemmy.com). > * Settings: > * You can change the default behaviour of the extension, customize the popup & sidebar menus, and turn off features you don't want to use.

    3
  • Annoyed by Lemmy links not going to your home instance? I just updated LULs, the script that changes all Lemmy links everywhere to your home instance! [xpost - NOT OC]
    greasyfork.org Lemmy Universal Link Switcher

    Ensures that all URLs to Lemmy instances always point to your main/home instance.

    Lemmy Universal Link Switcher

    cross-posted from: https://lemm.ee/post/1606937

    > If you didn't already know about it, I included the full description after the release notes. > > > # Release 1.3.0 > > > > * You can now add multiple secondary instances: so if you, like me, also have an account on lemmynsfw.com (or of course any other instance), you can add that there and not have links rewritten for that instance > > * You can manually enter your home instance. Useful for self-hosted instances that didn't show up in my instance list. > > > > ! > > > > > > # Full Description Below: > > > > ### Description > > > > Lemmy Universal Link Switcher, or LULs for short, scans all links on all websites, and if any link points to a Lemmy instance that is not your main/home instance, it rewrites the link so that it instead points to your main instance. > > > > Also works on Firefox Android with the Tampermonkey extension! > > > > ### Features > > > > * Rewrite links to Lemmy posts/comments to point to your home instance. Only after hovering over them, because getting home posts/comments links require communicating with the Lemmy servers, and we don't want to spam the servers. > > !video demonstrating links to posts being rewritten > > * Instantly rewrite all links of community or user links to Lemmy/kbin on all websites everywhere to your new instance! The rewritten links will have an icon next to it, and hovering/touching the icon will show you the original link, allowing you to go there if you want to. > > [!community links being rewritten](https://greasyfork.org/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBNHUxQVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--ab4ca68d48f3174ff9fe6cfd7820c66fa4c08ee9/2023-06-23%2006_00_01.png?locale=en) > > > > * If you are already on a page that has a corresponding page on your home instance, a link will automatically be added to the page header. > > [!the header link to your home instance when already on a remote post](https://greasyfork.org/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBeGEyQVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--e824ea55c69b88fb392b9ab0cfd093746ad255a0/2023-06-25%2004_58_33.webp?locale=en) > > > > > > ### Home Instance Setup > > > > Simply visit the Lemmy instance you want to set as your home while the script is active. You will be asked if you want to set this instance to your home instance: > > [!popup to select home instance](https://greasyfork.org/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMSs5QVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--8c7af9537ae007ae0032d314d8f03081132c69dc/2023-07-20%2008_39_14-firefox.png?locale=en) > > > > ### Settings > > > > If you want to change your home instance or add secondary instances in case you have multiple accounts, simply go to the script settings, accessible within Violent/Tampermonkey directly, or alternatively within any Lemmy instances' settings. > > [!button to set your new home instance](https://greasyfork.org/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMTI5QVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--a0411f36cc2e5e0c8212fb1582b8dc4ed6f3a9a8/2023-07-20%2008_32_11-ShareX.webp?locale=en) > > > > ### Common Issues > > > > * Does not work with Greasemonkey. Use Violentmonkey (open source) or Tampermonkey (closed source) instead. > > > > ### Coming soon > > > > * Rewrite kbin post/comment links > > * Better rewriting support for kbin community/user urls (e.g. sort options are currently ignored) > > * Nicer tooltip styling (fit into page theme) > > * Signify that "Show at home" button is loading for posts/comments > > * Integrate with lmmy.to redirector > >

    5
  • Lemmy Infinite Scrolling and Comment Sort
    pastebin.com // ==UserScript==// @name Lemmy Infinite Scrolling and Comment Sor - Pastebin.com

    Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

    After my post with the comment sorting script yesterday, I thought that since I was already doing script rewriting I might as well go further, so here is a script implementing infinite scrolling for the home page and communities on Lemmy.

    I didn't publish it as a separate script to comment sort since both are incompatible, as they both edit lemmy's client.js. If sorting comments by Top annoys you, just change the defaultSort back to Hot in the script.

    Edit: Fixed the spinner on instances other than lemmy.world.

    3
  • Change Lemmy Default Comment Sort
    pastebin.com // ==UserScript==// @name Lemmy Sort by Top// @description - Pastebin.com

    Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

    Currently, Lemmy sorts the comments by Hot, and there is no way to change this. This scripts changes the default behavior to sort by Top, this default can be changed by editing the defaultSort variable in the code.

    4
  • LemmyTools 0.2.0.5 - Released. Many bug fixes and functionality improvements.

    cross-posted from: https://thesimplecorner.org/post/91450

    > LemmyTools 0.2.0.5 is released! I believe this is the most functional release yet mainly due to some fantastic contributions from other folks on github who are definitely better programmers than I am! I just want to personally say thank you to: > > - @cwagner@lemmy.cwagner.me - For coding, code cleanup, and mentoring. > - Charles Machalow - csm10495 - Coding contribution(s). > - jimmyhiggs337 - Coding contribution(s). > > I am happy to say that the image expansion, and "show all" functionality is much more reliable and customizable now. > > More improvements/features are being developed. Please check back often and check updates at least every day. Please create a ticket on github or message me with your issues, thoughts and feature requests. > > Also, if anyone is able to message me about beginning to start moving this UserScript to a browser addon please see this post. >

    Installation and Configuration:

    1 \- Browser must have a Userscript addon (Tampermonkey, Greasemonkey, Etc...). Tested with Greasemonkey.

    2 \- Download either the .JS file or install from greasyfork.

    3 \- Set home lemmy instance via options page once script is loaded (and manually edit the homeInstance variable in script for all functionality)

    This script is all done by a complete amateur for fun. Enjoy and feel free to fork it!

    Get it here: Github or GreasyFork

    Please submit issues to the github for feature requests and problems: Github LemmyTools Issues

    3
  • Instance Assistant for Lemmy & Kbin v1.2.0 is now available on Firefox, Chrome, & Edge

    cross-posted from: https://lemmy.ca/post/1418762

    > I've made a number of improvements since the last time I was posting about my extension. The update is now available on both Firefox and Chrome web stores. > > For questions / support: !instance_assistant@lemmy.ca > > TLDR: See the respective download pages on Firefox & Chrome. The screenshots and features list are mostly self-explanatory. > > Note on versions: > * Firefox has a more recent 1.2.1 version, because my build script missed some files while uploading v1.2.0. It doesn't look like Chrome had this issue. > * I'm uploading v1.2.2 to both stores today, which will bring the two missing features to Chrome as well. After 1.2.2, all browsers should have the same features. See below for details. > > --- > > ## So how is this different from other similar extensions? > > You may have noticed the extension's name changed to be more generic (and include Kbin 🥳). I'm trying to make this a more well-rounded extension, and that means I've incorporated some features from the other extensions, in my own way. > > ### Lemmy Links, Kbin Links, and the other forks: > This is a great extension that replaces links on your page with versions that go to your home instance. However, in order for this to work, it needs to recursively check every element on your page whenever DOM content (the stuff the browser is reading) changes. This is somewhat resource intensive, and while testing I ran into lag and freezing issues. As such, I decided to not include this functionality in the same way. > > Instead, I've added a right click context menu that does the same thing. This way the user can pick which links they want the extension to convert, and it's a lot more efficient resource wise. While it's an extra click, I felt this was a reasonable compromise. However, I'm open to feedback! > > NOTE: The context menu is available on Firefox, and it will be available in Chrome in about a week, depending on when they approve my update. > > ### Lemmy Home Instance Helper > > This is another extension which checks if you are logged in to an instance, and it creates a button to the search page if you are not. As my extension creates a button on any foreign instance, the search page is only helpful when a community hasn't been loaded into your home instance yet (ex. because you're the first one to try accessing it). > > To deal with this, my extension modifies the "Community not found" pages with more instructions, as well as buttons to trigger the fetch process or to open the community elsewhere. See this screenshot for an example. Again, open to feedback! > > --- > > As always, I'd love to collaborate with other people while building this. I'm still cleaning up my code, but feel free to look at the GitHub. If this extension gets popular, I will definitely need help for translations and for things like getting the extension on Safari (I don't have a recent Apple device to sign the extension with). > > --- > > ## Note on permissions: > > * The current versions request "Access to all sites". This is because the extension needs access to any page that contains "/c/", "/m/", or "/post/" in order to create the sidebar buttons. While the extension only looks for those pages, it will show up as "Access to all sites" when installing. Once I have a proper welcome message and settings page, I plan on making this permission optional so you can just use the popup menu if you would like. > > --- > > ## Summary of Recent Changes: > - Added support for Kbin > - Fixed issue where button wouldn't load when navigating to a community within Lemmy (available on Firefox, should be on Chrome in a week). > - (NEW) Right-click context menu on Lemmy/Kbin community links to let you open them directly. You can test them out here: https://lemmy.ca/post/1282303 (available on Firefox, should be on Chrome in a week) > - (NEW) Information and buttons added to "Community Not Found" error pages to let you fetch the community or open it elsewhere. > - Updates to sidebar button to state the current selected instance and provide more detailed instructions as a dropdownList > - Refactored the code to remove more unnecessary permissions. > - Another pile of bugfixes, UI improvements, and better wording for instructions. > > > ## Future Plans: > - This is complete and will be in v1.2.2. Bringing over the new changes to Google Chrome. Since chrome requires Manifest 3, I still need to iron out some issues with the service workers. The missing features are all related to the background processes that are running on the Firefox version > - Pushing to other browsers: Microsoft Edge & Opera are still reviewing v1.2.0. Unfortunately, I don't have any immediate plans for Safari, as I don't have a device that can sign the extension. I am looking into getting help for that. > - Setting up a proper Welcome page, Settings page, and Options menu to allow users to turn off features that they don't like. This will also let me make "access to all sites" optional. > - Finishing the translations' setup so that people can contribute other languages to the extension. > - Adding an option to save your own instances to the popup, for those that have multiple home instances.

    5
  • a browser extension for more easily navigating to Lemmy communities from the browser address bar by @Raicuparta@lemmy.ml

    cross-posted from: https://lemmy.ml/post/1999101

    > tl;dr: With Lemmy Go you type lg beekeeping on the address bar and it takes you to the most popular beekeeping community, or you can pick one from the given suggestions. > > Get Lemmy Go for Firefox > > Get Lemmy Go for Chrome > > More information about Lemmy Go on GitHub > > ## Why > > On Reddit, I had a simple search keyword for navigating directly to subreddits, where I could just type r firefox and be taken to reddit.com/r/firefox. > > I wanted to have the same behavior for Lemmy, but the Fediverse makes this a lot more complicated. > > So I made Lemmy Go to try and make it as simple as possible to jump to a community, or even find new ones more easily. > > It's still a work in progress, so it might be a bit unstable and missing a bunch of features. But I've been using it myself for a few days, and it's already pretty helpful. > > ## Usage > > Type lg followed by a space (some browsers also accept tab instead), and then type the name of the community you're looking for. > > Example: lg linux > > Lemmy Go will search its database for any community that has the text linux in its name (e.g. linux_gaming) or title (Linux Gaming). > > If you just type a community name and press enter, Lemmy Go will take you to the most popular community from that list. > > If you don't press enter right away, you will be shown a list of communities that match that query. You can then select the specific one you want. > > ### Preferred Instance > > If you set your preferred instance in the user settings (click the extension icon), Lemmy Go will try its best to navigate to that community in your preferred instance, although this isn't always possible (in which case Lemmy Go will just navigate to the remote instance instead). > > For instance, if your preferred instance is set to lemmy.ml and you select firefox@lemmy.world, Lemmy Go will take you to lemmy.ml/c/firefox@lemmy.world. > > But if lemmy.ml blocks the lemmy.world instance, then Lemmy Go will take you to lemmy.world/c/firefox instead. > > Read the readme on GitHub for more information about how Lemmy Go works

    6
  • LemmyTools - 0.2.0.1 is released!

    cross-posted from: https://thesimplecorner.org/post/83502

    > ### LemmyTools \- ReadMe > > Current Features: 0.2.0.1 > > * All external links open in new tab with noreferrer enabled > * Adds a positional side bar that has a searchable list of communities > * Click&drag to resize images > * Set image size after clicking thumbnail > * Hide Lemmy Sidebars > * Show all images on page automatically or by a button click \- 0.2.0.1 \- (works with all languages now and can be disabled) > * Adds the ability to use the old.reddit style script by soundjester/lemmy\monkey: https://github.com/soundjester/lemmy\_monkey (Also: Option to edit post and comment size for easier reading). > * Auto unblur NSFW images > * A link back to home instance on remote instances > * Browse remote community on home instance > * Subscribe to instance easier that doesn't exist on your home instance. > * Works and styled for mobile use as well. > > Installation and Configuration: > > 1 \- Browser must have a Userscript addon (Tampermonkey, Greasemonkey, Etc...). Tested with Greasemonkey. > > 2 \- Download either the .JS file or install from greasyfork. > > 3 \- Set home lemmy instance via options page once script is loaded (and manually edit the homeInstance variable in script for all functionality) > > This script is all done by a complete amateur for fun. Enjoy and feel free to fork it! > > Get it here: Github or GreasyFork > > Please submit issues to the github for feature requests and problems: Github LemmyTools Issues > > [!](https://camo.githubusercontent.com/3b139f5f8285c665b3e6391921aac0df9a508faaa36f456190a176671e55ba8b/68747470733a2f2f70787363646e2e636f6d2f7075626c69632f6d2f5f76322f3538313931343532393136373835343134352f6266306635326666322d3932363737622f7336703362426661467554552f6c78534a54574d575a79715a5475625941435a7775637a59547a7969334971625548366a564638772e6a7067) > > [!](https://camo.githubusercontent.com/58b79e431d8907172500f5655c6c56f7c1c5ec4acb97662dc4f67316633172d2/68747470733a2f2f706978656c6665642e736f6369616c2f73746f726167652f6d2f5f76322f3538313931343532393136373835343134352f6266306635326666322d3932363737622f7255746952366e616f346c792f4945736267773558733468496f6c6947354a656253396153454a4c633955593632534d567835756e2e706e67)*__*

    3
  • [UserScript] Just another lemmy style inspired by some old subreddit styles
    • Link: https://github.com/lassekongo83/UserScripts/blob/main/lemmy/frellwits-lemmy-style.user.js
    • Install link: https://github.com/lassekongo83/UserScripts/raw/main/lemmy/frellwits-lemmy-style.user.js

    This is a style I primarily made for myself, but why not share it. It's inspired by some of the old subreddit styles and the old youtube design.

    • Should work with litely and darkly plus compact variants.
    • Uses rounded thumbnails to external links.
    • Uses square thumbnails to internal images.
    • Colored proprietary social media thumbs with their brand colors. (So you don't accidentally click on a youtube link for example).

    There still are some things I have to fix in the dark theme, like buttons and card headers for example.

    10
  • Not a CSS expert, but this makes Lemmy UI comments look better for me (on Desktop)

    Using this with Stylus:

    ``` css li .comment-node { padding: 0.5ex; border: 0.1ex solid #80808060 !important; border-radius: 1ex; }

    li li .comment-node { border-left: none !important; border-top: none !important; border-radius: 1ex 1ex 1ex 0 !important; } ```

    Or for a more lightweight change:

    css .comment-node { border-bottom: 0.1ex solid #80808060 !important;

    It's the lack of clearly visible separation between comments that just doesn't look right to me.

    5
  • [Userscript] Open in own instance

    Install

    !

    !

    Hi,

    This is just a little helper script which adds buttons to posts and comments on any Lemmy instance except your own which lead to a search page in your home instance allowing you to quickly interact with content.

    For now this is just a bunch of buttons, but ideally it'd be a fully-featured script that presents you with a proper text field for commenting/replying and buttons for voting. This is just the initial release and I'll be working to make the script better and save even more time while slacking off on Lemmy :P

    Usage

    Click the big 'Install' button above, then approve the script on the page displayed by your userscript manager. I've tested it on Violentmonkey and Tampermonkey with Firefox.

    After installing, go to any Lemmy instance and enter your home instance's domain into the prompt (just the domain, like lemmy.world or sh.itjust.works and nothing else). You can change this domain later by clicking on your manager's icon, then on "Change home instance" below the script's name.

    From now on you'll see blue buttons ("[ comment on own instance instead ]" on posts and "[ C ]" on comments) outside your specified home instance. Click on any to go to a search page on your own instance, then click the link icon if you're interacting with a comment or post title if with a post, then reply or vote on content as you desire.

    This is the first release, so might be prone to breaking and isn't very beautiful yet. Please report any issues and send suggestions via DM or in the comments below.

    Thanks and happy using.

    0
  • LASIM - A little tool for migrating Lemmy settings / subscriptions / blocks between accounts
    github.com GitHub - CMahaff/lasim: Move your Lemmy settings from one account to another

    Move your Lemmy settings from one account to another - GitHub - CMahaff/lasim: Move your Lemmy settings from one account to another

    GitHub - CMahaff/lasim: Move your Lemmy settings from one account to another

    cross-posted from: https://lemmy.world/post/1060796

    > See the linked page for information about how it works, limitations, etc. and I'll of course answer any questions below! > > As I have stated in the release section, this software is alpha so please don't be afraid to report bugs! > > Releases are here: https://github.com/CMahaff/lasim/releases > > Right now the program only supports Lemmy BE 0.18.1-rc9, but new releases will try to support new versions as they are released. The Lemmy API is changing a ton right now, but I'll try to keep up.

    Note: Supports 0.18.1-rc9+ - I have tested it with rc9, rc10, and the final release of 0.18.1.

    12
  • [help] Is there a way to detect if a user is using one of the litely or darkly themes?

    I'm currently using const prefersDarkTheme = window.matchMedia('(prefers-color-scheme: dark)').matches; but it doesn't take into consideration users that use a light system with a dark website.

    EDIT: Solved with the following: javascript const element = document.getElementById("app"); const themeVariant = element.getAttribute("data-bs-theme"); if (themeVariant === "light") { var primaryBackground = "#f0f0f0"; } else { var primaryBackground = "#121317"; }

    0
  • Keyboard navigation shortcuts for lemmy

    Rewrote something I made for kbin to work with lemmy. Mimics some of RES' keyboard navigation functionality.

    Edit: updated so that expanded images scroll into view.

    Edit 2: 2023/07/04

    • added ability to open links/comments (hold shift to open in new tab, might have to disable popup blocker)
    • traversing through entries while expand was toggled on will collapse previous entry and expand current entry preview
    • handle expanding of text posts

    Edit 3: 2023/07/04

    • add ability to change to next/previous page

    Edit 4: 2023/07/06

    • updated scroll into view logic
    • prevent shortcut actions when modifier keys are held (ctrl+c won't load comment page anymore)
    • updated open link button to also consider images with external links
    • updated user script metadata section for compatibility per @God@sh.itjust.works
    • navigating to next/previous page while in "expand mode" will auto-expand the first post of the new page

    ``` // ==UserScript== // @name lemmy navigation // @description Lemmy hotkeys for navigating. // @match https://sh.itjust.works/* // @match https://burggit.moe/* // @match https://vlemmy.net/* // @match https://lemmy.world/* // @match https://lemm.ee/* // @version 1.2 // @run-at document-start // ==/UserScript==

    // Set selected entry colors const backgroundColor = 'darkslategray'; const textColor = 'white';

    // Set navigation keys with keycodes here: https://www.toptal.com/developers/keycode const nextKey = 'KeyJ'; const prevKey = 'KeyK'; const expandKey = 'KeyX'; const openCommentsKey = 'KeyC'; const openLinkKey = 'Enter'; const nextPageKey = 'KeyN'; const prevPageKey = 'KeyP';

    const css = [ ".selected {", " background-color: " + backgroundColor + " !important;", " color: " + textColor + ";", "}" ].join("\n");

    if (typeof GM_addStyle !== "undefined") { GM_addStyle(css); } else if (typeof PRO_addStyle !== "undefined") { PRO_addStyle(css); } else if (typeof addStyle !== "undefined") { addStyle(css); } else { let node = document.createElement("style"); node.type = "text/css"; node.appendChild(document.createTextNode(css)); let heads = document.getElementsByTagName("head"); if (heads.length > 0) { heads[0].appendChild(node); } else { // no head yet, stick it whereever document.documentElement.appendChild(node); } } const selectedClass = "selected";

    let currentEntry; let entries = []; let previousUrl = ""; let expand = false;

    const targetNode = document.documentElement; const config = { childList: true, subtree: true };

    const observer = new MutationObserver(() => { entries = document.querySelectorAll(".post-listing, .comment-node");

    if (entries.length > 0) { if (location.href !== previousUrl) { previousUrl = location.href; currentEntry = null; } init(); } });

    observer.observe(targetNode, config);

    function init() { // If jumping to comments if (window.location.search.includes("scrollToComments=true") && entries.length > 1 && (!currentEntry || Array.from(entries).indexOf(currentEntry) < 0) ) { selectEntry(entries[1], true); } // If jumping to comment from anchor link else if (window.location.pathname.includes("/comment/") && (!currentEntry || Array.from(entries).indexOf(currentEntry) < 0) ) { const commentId = window.location.pathname.replace("/comment/", ""); const anchoredEntry = document.getElementById("comment-" + commentId);

    if (anchoredEntry) { selectEntry(anchoredEntry, true); } } // If no entries yet selected, default to first else if (!currentEntry || Array.from(entries).indexOf(currentEntry) < 0) { selectEntry(entries[0]); if (expand) expandEntry(); }

    Array.from(entries).forEach(entry => { entry.removeEventListener("click", clickEntry, true); entry.addEventListener('click', clickEntry, true); });

    document.removeEventListener("keydown", handleKeyPress, true); document.addEventListener("keydown", handleKeyPress, true); }

    function handleKeyPress(event) { if (["TEXTAREA", "INPUT"].indexOf(event.target.tagName) > -1) { return; }

    // Ignore when modifier keys held if (event.altKey || event.ctrlKey || event.metaKey) { return; }

    switch (event.code) { case nextKey: case prevKey: let selectedEntry;

    // Next button if (event.code === nextKey) { // if shift key also pressed if (event.shiftKey) { selectedEntry = getNextEntrySameLevel(currentEntry); } else { selectedEntry = getNextEntry(currentEntry); } }

    // Previous button if (event.code === prevKey) { // if shift key also pressed if (event.shiftKey) { selectedEntry = getPrevEntrySameLevel(currentEntry); } else { selectedEntry = getPrevEntry(currentEntry); } }

    if (selectedEntry) { if (expand) collapseEntry(); selectEntry(selectedEntry, true); if (expand) expandEntry(); } break; case expandKey: toggleExpand(); expand = isExpanded() ? true : false; break; case openCommentsKey: if (event.shiftKey) { window.open( currentEntry.querySelector("a.btn[title$='Comments']").href, ); } else { currentEntry.querySelector("a.btn[title$='Comments']").click(); } break; case openLinkKey: const linkElement = currentEntry.querySelector(".col.flex-grow-0.px-0>div>a") || currentEntry.querySelector(".col.flex-grow-1>p>a"); if (linkElement) { if (event.shiftKey) { window.open(linkElement.href); } else { linkElement.click(); } } break; case nextPageKey: case prevPageKey: const pageButtons = Array.from(document.querySelectorAll(".paginator>button"));

    if (pageButtons) { const buttonText = event.code === nextPageKey ? "Next" : "Prev"; pageButtons.find(btn => btn.innerHTML === buttonText).click(); } } }

    function getNextEntry(e) { const currentEntryIndex = Array.from(entries).indexOf(e);

    if (currentEntryIndex + 1 >= entries.length) { return e; }

    return entries[currentEntryIndex + 1]; }

    function getPrevEntry(e) { const currentEntryIndex = Array.from(entries).indexOf(e);

    if (currentEntryIndex - 1 < 0) { return e; }

    return entries[currentEntryIndex - 1]; }

    function getNextEntrySameLevel(e) { const nextSibling = e.parentElement.nextElementSibling;

    if (!nextSibling || nextSibling.getElementsByTagName("article").length < 1) { return getNextEntry(e); }

    return nextSibling.getElementsByTagName("article")[0]; }

    function getPrevEntrySameLevel(e) { const prevSibling = e.parentElement.previousElementSibling;

    if (!prevSibling || prevSibling.getElementsByTagName("article").length < 1) { return getPrevEntry(e); }

    return prevSibling.getElementsByTagName("article")[0]; }

    function clickEntry(event) { const e = event.currentTarget; const target = event.target;

    // Deselect if already selected, also ignore if clicking on any link/button if (e === currentEntry && e.classList.contains(selectedClass) && !( target.tagName.toLowerCase() === "button" || target.tagName.toLowerCase() === "a" || target.parentElement.tagName.toLowerCase() === "button" || target.parentElement.tagName.toLowerCase() === "a" || target.parentElement.parentElement.tagName.toLowerCase() === "button" || target.parentElement.parentElement.tagName.toLowerCase() === "a" ) ) { e.classList.remove(selectedClass); } else { selectEntry(e); } }

    function selectEntry(e, scrollIntoView=false) { if (currentEntry) { currentEntry.classList.remove(selectedClass); } currentEntry = e; currentEntry.classList.add(selectedClass);

    if (scrollIntoView) { scrollIntoViewWithOffset(e, 15) } }

    function isExpanded() { if ( currentEntry.querySelector("a.d-inline-block:not(.thumbnail)") || currentEntry.querySelector("#postContent") || currentEntry.querySelector(".card-body") ) { return true; }

    return false; }

    function toggleExpand() { const expandButton = currentEntry.querySelector("button[aria-label='Expand here']"); const textExpandButton = currentEntry.querySelector(".post-title>button");

    if (expandButton) { expandButton.click();

    // Scroll into view if picture/text preview cut off const imgContainer = currentEntry.querySelector("a.d-inline-block"); if (imgContainer) { // Check container positions once image is loaded imgContainer.querySelector("img").addEventListener("load", function() { scrollIntoViewWithOffset(currentEntry, 0); }, true); } }

    if (textExpandButton) { textExpandButton.click(); }

    scrollIntoViewWithOffset(currentEntry, 0); }

    function expandEntry() { if (!isExpanded()) toggleExpand(); }

    function collapseEntry() { if (isExpanded()) toggleExpand(); }

    function scrollIntoViewWithOffset(e, offset) { if (e.getBoundingClientRect().top < 0 || e.getBoundingClientRect().bottom > window.innerHeight ) { const y = e.getBoundingClientRect().top + window.pageYOffset - offset; window.scrollTo({ top: y }); } } ```

    18
1 Active user