User:Yonidebest/monobook.js/quickdelete.js

// // From en:User:Lupin/autoedit.js, edited by User:Yonidebest

// String constants nc_text = "NowCommons"; nc_tooltip = "Mark NowCommons"; nci_text = "NowCommons + Image"; nci_tooltip = "Mark NowCommons + Diff image name"; sd_text = "Speedy delete"; sd_tooltip = "סמן תמונה זו למחיקה מהירה";

// Site info scriptPath = "/w/index.php";

function openWindow(url) { var res = window.open(url, '_blank'); if (!res) alert("openWindow: window.open returned null"); }

function getUploader { // Get uploader from first point in the list under "File history" // Uploader is stored in second A tag in UL tag under "File history" // Returns title of user page (without name space) in URL form var el = document.getElementById('filehistory') if (!el) { alert("תקלה: לא נמצאה היסטורית העלאה ... משימה נכשלה"); return null; } while (el.nextSibling) { el = el.nextSibling; if (el.tagName && el.tagName.toLowerCase == 'ul') break; } if (!el) { alert("תקלה: לא הצלחתי למצוא רשימת מעלים ... נטשתי אותך, ביי!"); return null; } var lis = el.getElementsByTagName('li'); if (lis && lis.length == 1) { var li = lis[0]; } else { var answer = prompt('Which version (1 - top one, a - buttom one)?', ''); if (!answer) answer = '1'; if (answer == 'a') { var li = lis[lis.length - 1]; } else { var li = lis[answer - 1]; } }  if (!li) { alert("לא הצלחתי למצוא את הפריט הדרוש לי ברשימה ... הפסקתי את המשימה"); return null; } var as = li.getElementsByTagName('a');

var re1 = new RegExp('Blockip/(.*)$'); var m; for (var k=0; k<as.length; k++) { m = re1.exec(as[k].title); if (m) return m[1]; } alert("תקלה: לא נמצא מעלה ... משימה נכשלה"); return null; }

// Function that help idenfity what action must be taken function mnx_mark(imagepage_fakeaction, usertalk_fakeaction) {

if (imagepage_fakeaction != 'nc_temp' && imagepage_fakeaction != 'nci_temp' && imagepage_fakeaction != 'sd_temp') { var pagename = encodeURIComponent(mw.config.get('wgPageName')); var uploader = getUploader; if (!uploader) return; // Open new window for the user talk page openWindow(scriptPath + '?title=User_talk:' + uploader + '&action=edit&fakeaction=' + usertalk_fakeaction + '&target=' + pagename + '&template_type=' + imagepage_fakeaction); } var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href; document.location = editlk + '&fakeaction=' + imagepage_fakeaction; }

// Add template to image description page function mnx_addTemplate(template) { var comment = "NowCommons"; if (template == 'nc_temp') template = 'subst:ncd'; // nowcommons if (template == 'nci_temp') { // nowcommons with image name var answer = prompt('Image name (without "Image:"):', ''); if (!answer || answer == '') { template = 'subst:ncd'; } else { template = 'subst:ncd|Image:' + answer; comment += ': Image:' + answer; } }  if (template == 'sd_temp') { // speedy delete comment = 'Speedy delete'; var answer = prompt('Reason?', ''); if (!answer || answer == '') { template = 'speedydelete'; } else { template = 'speedydelete|' + answer; } }  var txt = ''; document.editform.wpTextbox1.value += '\n' + txt; document.editform.wpSummary.value = comment; document.editform.wpSave.click; }

// Add warning template to uploader's talk page function mnx_addUserWarningTemplate(imagetarget, template_type) { var imageName = imagetarget.substring(6,imagetarget.length); var txt = '==' + imageName + '==\n'; var comment = ''; if (template_type == 'ns_temp') { // no source txt += ''; // תוכן הדף comment = 'חסר מקור'; } document.editform.wpTextbox1.value += '\n' + txt + '' + '\n'; document.editform.wpSummary.value = comment; document.editform.wpSave.click; }

function mnx_onload { if (wgNamespaceNumber == 6) { // image name space addLink('p-tb', 'javascript:mnx_mark(\'nc_temp\', \'no_warn\')', nc_text, 'mark-nowcommons', nc_tooltip, null, null); addLink('p-tb', 'javascript:mnx_mark(\'nci_temp\', \'no_warn\')', nci_text, 'mark-nowcommonsimage', nci_tooltip, null, null); addLink('p-tb', 'javascript:mnx_mark(\'sd_temp\', \'no_warn\')', sd_text, 'mark-speedy-delete', sd_tooltip, null, null); } var fakeaction = queryArray['fakeaction']; var template_type = queryArray['template_type'];  // Fetch what template to add

if (fakeaction == 'nc_temp'){ // NowCommons mnx_addTemplate('nc_temp'); } if (fakeaction == 'nci_temp'){ // NowCommons with Image name mnx_addTemplate('nci_temp'); } if (fakeaction == 'sd_temp'){ mnx_addTemplate('sd_temp'); } if (fakeaction == 'warn') { mnx_addUserWarningTemplate(decodeURIComponent(queryArray['target']), template_type); } }

$(mnx_onload); //