User:Kameraad Pjotr/monobook.js/duplicate.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// <nowiki>
// add Dupe-template using a parameter parsed from the current URL 
$(function() {
    var parts = /&dupeimage=([^&]*)/(location.href);
    if (!parts) return;
    var dupe = decodeURIComponent(parts[1]);
    var editform = document.forms["editform"];
    if (!editform) return;
    var wpTextbox1 = editform.elements["wpTextbox1"];
    var wpSave     = editform.elements["wpSave"];
    wpTextbox1.value = "{{Dupe|Image:" + dupe + "}}" + "\n" + wpTextbox1.value;
    document.editform.wpSummary.value = "{{[[Template:Dupe|Dupe]]}}";
    wpSave.click();
});

 document.write('<script type="text/javascript" src="'
            + 'http://commons.wikimedia.org/w/index.php?title=User:Polarlys/quickbar.js'
            + '&action=raw&ctype=text/javascript&dontcountme=s"><\/script>');
//User:Polarlys/quickbar.js

// From en:User:Lupin/autoedit.js
function getParamValue(paramName) {
  var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
  var h=document.location;
  var m=cmdRe.exec(h);
  if (m) {
  try {
    return decodeURIComponent(m[1]);
  } catch (someError) {}
  }
  return null;
}
// </nowiki>