Jump to content

User:Ilmari Karonen/fixcopyrightedfreeuse.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.
// REPLACE [[Template:CopyrightedFreeUse]]:
addOnloadHook(function () {
    var editForm = document.forms.editform;
    if (!editForm || !window.location.search ||
        !window.location.search.match(/[?&]action=edit(&|$)/) ||
        !window.location.search.match(/[?&]fixcopyrightedfreeuse=/) ) return;

    editForm.wpTextbox1.value = editForm.wpTextbox1.value.replace(/\{\{\s*Copyrighted[_ ]?Free[_ ]?Use[|\s]*\}\}/ig, "{{NoRightsReserved}}");
    editForm.wpSummary.value = "replacing {{CopyrightedFreeUse}} with {{NoRightsReserved}} per [[Wikipedia_talk:Image_copyright_tags#Template:CopyrightedFreeUse_should_be_deprecated|discussion]]";

    editForm.wpMinoredit.checked = true;
    editForm.wpSave.click();  // I'm feeling lucky!
});
document.write('<style type="text/css">span.hiddenStructure#fixCopyrightedFreeUse {display: inline;}</style>');