MediaWiki:Gadget-titleparenthesis.js
Jump to navigation
Jump to search
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.
$(function () {
var conf = mw.config.get([
'wgNamespaceNumber',
'wgTitle',
'wgAction'
]);
if (conf.wgNamespaceNumber !== 0 || conf.wgTitle.lastIndexOf('(') < 0 ||
conf.wgAction !== 'view' || $('.no-parenthesis-style').length) {
return;
}
// use the title in the DOM so this respects DISPLAYTITLE
var title = $('h1#firstHeading').text(),
start = title.lastIndexOf('('),
end = title.substring(start, title.length).lastIndexOf(')');
// add offset here
end += start + 1;
$('h1#firstHeading')
.empty()
.append(
title.substring(0, start),
$('<span>')
.addClass('title-parenthesis')
.text(title.substring(start, end)),
title.substring(end, title.length)
);
});