Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump.
This code will be executed when previewing this page.
This code will be executed when previewing this page.
Documentation for this user script can be added at User:Sam Sailor/Scripts/BoldMyName.
/**
* Script Name: BoldMyName
* Description: Highlights your own username in bold and color (default: bright blue)
* on revision history pages, Recent Changes, Recent Changes Linked,
* and your Watchlist. This makes it easier to spot your own contributions
* or actions at a glance.
* Customization:
* To change the color, add the following line to your common.js file, replacing
* '#F0A000' with your preferred hexadecimal color code (e.g., #00AA00 for green):
* window.historyBoldingColor = '#F0A000';
* Installation:
* To install this script, add the following line to your personal common.js page
* (e.g., User:YOURNAME/common.js) and bypass your browser cache:
* importScript('User:Sam_Sailor/Scripts/BoldMyName.js');
* */
$(function() {
var boldingColor = window.historyBoldingColor || '#0000FF';
// Define the list of page types where the script should run
var allowedActions = ['history'];
var allowedSpecialPages = ['Recentchanges', 'Recentchangeslinked', 'Watchlist'];
var currentPageAction = mw.config.get('wgAction');
var currentPageSpecialPage = mw.config.get('wgCanonicalSpecialPageName');
// Check if the current page is one of the allowed action pages or special pages
// $.inArray returns -1 if the item is not found in the array.
if (
$.inArray(currentPageAction, allowedActions) === -1 &&
$.inArray(currentPageSpecialPage, allowedSpecialPages) === -1
) {
return; // Exit if the page is not in the allowed list
}
// Ensure mediawiki.util is loaded before trying to add CSS
mw.loader.using(['mediawiki.util'], function() {
// Define the CSS style
var css = 'a.history-bolding { color: ' + boldingColor + ' !important; font-weight: bold; background-color: transparent; }';
mw.util.addCSS(css);
// Apply the style to the current user's links
$('.mw-userlink').each(function() {
var $this = $(this);
// Compare the link text (username) to the current user's name
if ($this.text() == mw.config.get('wgUserName'))
$this.addClass('history-bolding');
});
});
});