User:Btilm/dt.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.
function dt() {
var pro2=prompt('Enter desired title',wgTitle);
if (pro2==null || pro2==wgTitle || pro2=="") {
 alert('Aborted');
 return};
document.location=mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + wgPageName + "&action=edit&dt=" + pro2;
}

$(function() {
mw.util.addPortletLink("p-cactions","javascript:dt()","dt","ca-dt","dt","");

  if (location.href.indexOf("&action=edit&dt=") == -1) return;
  var dtRegExp = /&action=edit&dt=(.*)/;
  var dt = dtRegExp.exec(location.href)[1];
  var newdt = decodeURIComponent(dt);
  document.getElementById('wpTextbox1').value = "{{DISPLAYTITLE:" + newdt + "}}\n" + document.getElementById('wpTextbox1').value;
  document.getElementById('wpSummary').value = "added displaytitle tag";
  document.getElementById('wpMinoredit').checked = true;
  document.getElementById('editform').submit();
});