User:Btilm/displaytitle.js

From Wikipedia, the free encyclopedia
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.
// <nowiki>
//created by btilm
function adt() {
var pro = prompt('Enter wanted title.',wgTitle);
if ( pro==null || pro=="" || pro==wgTitle) {
alert('Aborted');
return}
document.editform.wpTextbox1.value = '{{DISPLAYTITLE:' + pro + '}}\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'added displaytitle tag';
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
 
addOnloadHook(function() {
if (document.editform) {
mw.util.addPortletLink("p-cactions", "javascript:adt()", "adt", "ca-adt", "Add Display Title", "");
}
});
 
function rdt() {
  var txt = document.editform.wpTextbox1;
  txt.value = txt.value.replace(/{{DISPLAYTITLE.*}}\n/gim, "");
document.editform.wpSummary.value = 'removed displaytitle tag';
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
 
addOnloadHook(function() {
if (document.editform) {
mw.util.addPortletLink("p-cactions", "javascript:rdt()", "rdt", "ca-rdt", "Remove Display Title", "");
}
});
// </nowiki>