Jump to content

User:PleaseStand/highlight-comments.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by PleaseStand (talk | contribs) at 02:08, 10 March 2010 (replacing addOnloadHook with its jQuery equivalent (try 2)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<pre><nowiki>
 
// highlight-comments.js - written by PleaseStand, 2010.
// Source: http://en.wikipedia.org/wiki/User:PleaseStand/highlight-comments.js
// NOTE: This script is in the public domain (not copyrighted). For details, see
// http://en.wikipedia.org/wiki/Template:PD-self
 
// DESCRIPTION: Highlights your posts to discussion pages
// (at least a significant part). This is just the JS part; you need a
// corresponding CSS line to actually affect text color. An example:
 
// .mycomment { background: #ff9; }
 
/*global document, jQuery, wgFormattedNamespaces, wgUserName*/
jQuery(document).ready(function(){
    // Lists the tags that can contain comments.
    var tagSelector = "li,dd,p";
    jQuery("a[title=" + wgFormattedNamespaces[2] + ":" +
        wgUserName + "]").closest(tagSelector).addClass("mycomment");
});
//</nowiki></pre>