Lemmy Plugins and Userscripts

2124 readers
1 users here now

A general repository for user scripts and plugins used to enhance the Lemmy browsing experience.

Post (or cross-post) your favorite Lemmy enhancements here!

General posting suggestions:

Thanks!

founded 1 year ago
MODERATORS
1
 
 

Table of Contents

  1. Introduction
  2. What is a UserScript?
  3. Installing a UserScript Manager
    • Installing Tampermonkey on Chrome
    • Installing Violentmonkey on Chrome
    • Installing Tampermonkey on Firefox
    • Installing Greasemonkey on Firefox
    • Installing Violentmonkey on Firefox
  4. Adding a UserScript
  5. Conclusion

Introduction

UserScripts are an incredible way to enhance and customize your browsing experience. They allow you to alter the functionality and layout of web pages, like Lemmy UI, by executing JavaScript codes on the client side. In this guide, we'll walk you through the process of installing UserScripts in your Chrome or Firefox browser.

What is a UserScript?

UserScripts are bits of code written in JavaScript that run in your web browser. They can modify the content, layout, and behavior of web pages. The true power of UserScripts lies in their ability to tailor your browsing experience to your needs.

Installing a UserScript Manager

To run UserScripts, you'll need to install a UserScript manager extension. Two popular ones are Tampermonkey and Greasemonkey.

Installing Tampermonkey on Chrome

  1. Open the Chrome web browser.
  2. Go to the Tampermonkey page on the Chrome Web Store.
  3. Click the "Add to Chrome" button.
  4. Confirm by clicking "Add extension" in the pop-up window.

Installing Violentmonkey on Chrome

  1. Open the Chrome web browser.
  2. Go to the Violentmonkey page on the Chrome Web Store.
  3. Click the "Add to Chrome" button.
  4. Confirm by clicking "Add extension" in the pop-up window.

Installing Tampermonkey on Firefox

  1. Open the Firefox web browser.
  2. Go to the Tampermonkey page on the Firefox Add-ons site.
  3. Click the "Add to Firefox" button.
  4. Confirm by clicking "Add" in the pop-up window.

Installing Greasemonkey on Firefox

  1. Open the Firefox web browser.
  2. Go to the Greasemonkey page on the Firefox Add-ons site.
  3. Click the "Add to Firefox" button.
  4. Confirm by clicking "Add" in the pop-up window.

Installing Violentmonkey on Firefox

  1. Open the Firefox web browser.
  2. Go to the Violentmonkey page on the Firefox Add-ons site.
  3. Click the "Add to Firefox" button.
  4. Confirm by clicking "Add" in the pop-up window.

Adding a UserScript

Now that you have a UserScript manager installed, you can add your own scripts. Here's how:

  1. Click on the Tampermonkey or Greasemonkey icon in your browser toolbar.
  2. Choose "Create a new script..." from the dropdown menu.
  3. You'll be taken to a new tab with a script template. Delete this template.
  4. Copy your UserScript and paste it into the empty field.
  5. Click "File" and then "Save" in the editor menu.

That's it! Your UserScript is now installed and will run on the sites specified in its metadata.

Conclusion

UserScripts offer an incredible way to customize your web browsing experience. Whether you're using Chrome or Firefox, Tampermonkey, Greasemonkey or Violentmonkey, you can create a browsing environment that's uniquely suited to your needs. Happy scripting!

Remember, while UserScripts are powerful tools, they should be used responsibly. Don't install scripts from sources you don't trust, as they can pose security risks. Always review the code of a UserScript before installing it to ensure it doesn't contain anything malicious.

2
 
 

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.

3
 
 

cannot find this anywhere. i don't want to automatically hide everything i scroll past, or everything from an instance, just certain posts i don't want to see or engage with

4
 
 

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 :)

5
0
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

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.

6
 
 

Crossgeposted von: https://feddit.de/post/1185964

Please excuse my sub-par JavaScript, I am a backend dev.

All you need to do is paste this into Tampermonkey and enter your username and your instance url (on two locations).

This is not showing other users' scores and it doesn't make your score visible to anyone else than yourself.

So no need for karma farming. This is just for fun.

// ==UserScript==
// @name         Lemmy score
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Shows your total post/comment score at the top right.
// @author       You
// @match        ENTER INSTANCE URL HERE (leave the asterisk after the URL)*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=feddit.de
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    var USERNAME = "ENTER USERNAME HERE";
    var INSTANCE_URL = "ENTER INSTANCE URL HERE";

    var totalScore = 0;
    var currentPage = 1;

    function postResult() {
        var navbar = document.getElementsByClassName("collapse navbar-collapse")[0];
        console.log(navbar);
        var ul = document.createElement("ul");
        ul.className = "navbar-nav";
        ul.id = "karma-ul";
        var li = document.createElement("li");
        li.id = "karma-li";
        li.className = "nav-item";
        li.innerHTML = '<div id="karma-div">' + totalScore + '</div>'
        navbar.appendChild(ul);
        ul.appendChild(li);
    }
    function callPage() {
        var userRequest = new XMLHttpRequest();
        userRequest.onreadystatechange = function () {
            if (this.readyState == 4) {
                if (this.status == 200 ) {
                    var res = JSON.parse(this.responseText);
                    if (res.posts.length==0 && res.comments.length==0) {
                        postResult();
                    } else {
                        totalScore += res.posts.map(x => x.counts.score).reduce((partialSum, a) => partialSum + a, 0);
                        totalScore += res.comments.map(x => x.counts.score).reduce((partialSum, a) => partialSum + a, 0);
                        currentPage++;
                        callPage();
                    }
                }
            }
        }
        userRequest.open("GET", INSTANCE_URL + "/api/v3/user?username=" + USERNAME + "&limit=50&page=" + currentPage, true);
        userRequest.send();
    }

    setTimeout(callPage, 200);
})();

7
 
 

The developers will try to make it posible