User:OsamaK I/Quick-delete.js

// // Main code by en:User:Jietse Niesen, some adaption by user:pfctdayelise, cleanup by User:Alphax This version edited by OsamaK!

var now = new Date; var timestamp = now.getUTCFullYear + '/'; now.getUTCMonth < 9 ? timestamp += '0' + (now.getUTCMonth + 1) : timestamp += (now.getUTCMonth + 1); timestamp += '/'; now.getUTCDate < 10 ? timestamp += '0' + now.getUTCDate : timestamp += now.getUTCDate; nfd_datePage = nfd_delReq + "/" + timestamp; var monthsArray = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var timestamp2 = monthsArray[now.getUTCMonth] + " " + now.getUTCDate;

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("getUploader: Cannot find filehistory ... exiting"); return null; } while (el.nextSibling) { el = el.nextSibling; if (el.tagName && el.tagName.toLowerCase == 'table') break; } if (!el) { alert("getUploader: Cannot find table tag ... exiting"); return null; }

var as = el.getElementsByTagName('a');

var re1 = new RegExp((mw.config.get('wgServer') + mw.config.get('wgArticlePath').substr(0, wgArticlePath.length-2) ).replace(/\./g, '\\.') + 'User:(.*)$'); var re2 = new RegExp((wgServer + wgScript).replace(/\./g, '\\.') + '\\?title=User:([^&]*)'); var m; for (var k=0; k<as.length; k++) { m = re1.exec(as[k].href); if (m) return m[1]; m = re2.exec(as[k].href); if (m) return m[1]; } alert("getUploader: Cannot find uploader ... exiting"); return null; }

function mnx_mark(imagepage_fakeaction, usertalk_fakeaction) { var pagename = encodeURIComponent(mw.config.get('wgPageName')); var uploader = getUploader; if (!uploader) return; // Open new window for the user page openWindow(wgScript + '?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 // sorl = "source", "permission" or "license" function mnx_addTemplate(template, sorl) { // the edit summary for when you mark the image. You can change it if you want. var txt = ''; document.editform.wpTextbox1.value = txt + '\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'marking image as missing essential ' + sorl + ' information. If this is not fixed this image might be deleted after 7 days.'; document.editform.wpSave.click; }

// Add warning template to uploader's talk page function mnx_addUserWarningTemplate(imagetarget, template_type) { // If template to add is a not permission template, add if (template_type == 'mnp_mnp') var txt =  + imagetarget + ; // else, add the template else var txt =  + imagetarget + ;

// add in subst: if you want to subst these warnings document.editform.wpTextbox1.value += '\n' + txt + '' + '\n'; document.editform.wpSummary.value = "Warning: image missing source or licensing information."; // this is the edit summary for when you leave the user warning on the talk page. // you can change it if you want. document.editform.wpSave.click;       // save page }

function mnx_onload { if (wgNamespaceNumber == 6) { //NS_IMAGE var fakeaction = getParamValue('fakeaction'); var template_type = getParamValue('template_type');   // Fetch what template to add

if (fakeaction == 'mns_mns'){ mnx_addTemplate('nsd','source'); } if (fakeaction == 'mnp_mnp'){ mnx_addTemplate('npd','permission'); } if (fakeaction == 'mnl_mnl'){ mnx_addTemplate('nld','license'); } if (fakeaction == 'mnx_warn') {  // Add warning to uploader's talk page mnx_addUserWarningTemplate(decodeURIComponent(getParamValue('target')), template_type); } } addOnloadHook(mnx_onload); //No source, no permission, no license.

//