Discord Message Prepender

By: Sam Kimak

04/16/2024

Categories: Project Tags: Extension

Message Prepender is a Firefox extension that types a string of your choice at the start of every message you write. I made it for Discord so my messages would always open with the same icon, but nothing in it is Discord-specific. It works on any site, as long as you tell it which text box to watch.

Setting it up

Click the extension’s toolbar button to open its popup, which has two fields:

The popup title updates as you type, so you can preview what your messages will start with.

How it works

A content script listens for clicks and key presses on the page. When the element you’re focused on matches the saved selector for that site and the box is still empty, the extension inserts your string with document.execCommand("insertText"). Inserting it this way, rather than setting the box’s value directly, means editors like Discord’s register it as if you had typed it yourself. Once the box has text in it, the extension leaves it alone until you send the message and the box is empty again.

Source

The code is on GitHub: Skimak/msgprepender


This project is not affiliated with or endorsed by Discord.

>> Home