// ==UserScript==
// @name Strip Hashtag Symbol, enhance Links Userscript
// @namespace http://example.com
// Ensure that your mastodon instance is included in the list below.
// @include https://mastodon.online/*
// @include https://mastodon.social/*
// @version 1
// @grant none
// ==/UserScript==
// Modify these options as desired
const linkColor = '#00A0E9'; // Change to your preferred color code
const makeLinksBold = true; // Set to true to make links bold, false otherwise
// Function to remove "#" from link text
function removeHashtagsFromText() {
// Get all anchor tags
const links = document.querySelectorAll('a');
// Iterate through all links
links.forEach(link => {
// Check if the text content includes "#"
if (link.textContent.includes("#")) {
// Replace "#" character in the link text
link.textContent = link.textContent.replace(/#/g, '');
}
});
}
// Function to enhance link appearance
function enhanceLinks() {
// Get all anchor tags
const links = document.querySelectorAll('a');
// Iterate through all links
links.forEach(link => {
// Set link color
link.style.color = linkColor;
// Make links bold if the option is enabled
if (makeLinksBold) {
link.style.fontWeight = 'bold';
}
});
}
// Function to observe changes in the DOM
function observeDOMChanges() {
// Create a new MutationObserver instance
const observer = new MutationObserver(() => {
// Run the function to remove hashtags from link text
removeHashtagsFromText();
// Run the function to enhance link appearance
enhanceLinks();
});
// Options for the observer
const config = {
childList: true,
subtree: true,
};
// Start observing the body of the page
observer.observe(document.body, config);
}
// Run the function to remove hashtags from link text initially
removeHashtagsFromText();
// Run the function to enhance link appearance initially
enhanceLinks();
// Run the function to observe changes in the DOM
observeDOMChanges();