User:Giorgi Eufshi/sandbox.js
Jump to navigation
Jump to search
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
function insertSamePunctutation(){
var oldText = $(this).clone().text().substr(0, 1);
var $clone = $(this).clone().text(oldText);
return $clone;
}
function replaceWithFirstLetter(){
return this.textContent.substr(0, 1);
}
function linkifyString(){
var name = $(this).text();
name = name.substr(1, name.length - 2);
var link = "/wiki/" + name;
return $("<a>").attr("href", link).css("color", "#0b0080").text(name);
}
$(".nb:contains('require')+span+.s2")
.add(".n:contains('loadData')+span+.s2")
.add(".n:contains('loadData')+span+.s1")
.add(".nb:contains('require')+span+.s1").filter(function(){
return /^("Module:[A-Za-z0-9 \-/]+"|'Module:[A-Za-z0-9 /]+')$/.test($(this).text());
})
.after(insertSamePunctutation)
.after(linkifyString)
.html(replaceWithFirstLetter);
$(".nx:contains('importScript')+span+.s1,.nx:contains('importScript')+span+.s2").filter(function(){
return /^(".*"|'.*')$/.test($(this).text());
})
.after(insertSamePunctutation)
.after(linkifyString)
.html(replaceWithFirstLetter);