MediaWiki:MastodonToRoblox.js
MediaWiki interface page
More actions
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
//MIRRORED FROM
//https://dev.miraheze.org/w/index.php?title=User:Stackd/stackdenhancements.js&action=raw&ctype=text/javascript
//CREDITS TO
//@stackd
// Select all anchor tags with href containing "mastodon.social"
const mastodonLinks = document.querySelectorAll('.profile-externalLinks a[href^="https://mastodon.social"]');
mastodonLinks.forEach(link => {
// Get the current href value
const currentHref = link.getAttribute('href');
// Extract the username from the URL (assuming the username is the last part of the URL after the last "/")
const username = currentHref.split('/').pop();
// Replace "mastodon.social" with "roblox.com/users/profile?username="
const newHref = `https://www.roblox.com/users/profile?username=${username}`;
// Set the new href to the anchor tag
link.setAttribute('href', newHref);
});
const twitterLinks = document.querySelectorAll('.profile-externalLinks a[href^="https://x.com"]');
twitterLinks.forEach(link => {
// Get the current href value
const currentHref = link.getAttribute('href');
// Extract the username from the URL (assuming the username is the last part of the URL after the last "/")
const username = currentHref.split('/').pop();
// Make it a damn tooltip
link.setAttribute('data-username', username);
});
function lifeIsRoblox() {
// Select all anchor tags with href starting with "https://www.roblox.com/users/profile?username="
const robloxLinks = document.querySelectorAll('.profile-externalLinks a[href^="https://www.roblox.com/users/profile?username="]');
robloxLinks.forEach(link => {
// Get the username from the href
const currentHref = link.getAttribute('href');
const username = new URL(currentHref).searchParams.get('username');
// Set data-username attribute for the link (to use in ::after content)
link.setAttribute('data-username', username);
// Create a new style element for each new link
const styleElement = document.createElement('style');
styleElement.textContent = `
.profile-externalLinks a[href^="https://www.roblox.com/users/profile?username=${username}"]:hover::after,
.profile-externalLinks a[href^="https://x.com"]:hover::after{
content: attr(data-username); color: var(--color-base)!important
}
`;
// Append the style element to the head of the document
document.head.appendChild(styleElement);
});
}
// Call the function to copy styles and apply to the new links
lifeIsRoblox();