MediaWiki:RemoveUploadedFromWikipedia.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.
/*
  Quick helper script for removing {{Uploaded from Persian Wikipedia}}.
*/
var text = document.querySelector('#wpTextbox1');

// Remove tag
text.value = text.value.replace(/\{\{[Uu]ploaded[ _]from[ _]Persian[ _]Wikipedia\}\}/g, "");
// Remove any whitespace from beginning and end
text.value = text.value.trim();
// Remove the three blank lines in the Iranian media files
text.value = text.value.replace(/\n{3,}/g,'\n\n');

// Set edit summary
const summarytext = "Removed [[Template:Uploaded from Persian Wikipedia|{{Uploaded from Persian Wikipedia}}]]";
var summary = document.querySelector('#wpSummary');
summary.value = summarytext;

// Tick minor edit indicator	
document.editform.wpMinoredit.checked = true;
//save page
document.editform.submit();