//<source lang="javascript">
// From [[en:User:Lupin/autoedit.js]], translated by [[user:ערן]], edited by [[User:Yonidebest]]
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;
}
// String constants
mns_text = "No source";
mns_tooltip = "סמן תמונה זו כחסרה מקור";
mnl_text = "No license";
mnl_tooltip = "סמן תמונה זו כחסרה פרטי רישיון";
mnd_text = "Derivative";
mnd_tooltip = "סמן תמונה זו כנגזרת המפרה זכויות יוצרים";
mnc_text = "Copyvio";
mnc_tooltip = "סמן תמונה זו כמפרה זכויות יוצרים";
mnfu_text = "Fair use";
mnfu_tooltip = "סמן תמונה זו כשימוש הוגן";
mnow_text = "Own work";
mnow_tooltip = "סמן תמונה זו כיצירה עצמית";
mnsd_text = "Speedy delete";
mnsd_tooltip = "סמן תמונה זו למחיקה מהירה";
mnpr_text = "Private";
mnpr_tooltip = "סמן תמונה זו למחיקה מהירה כיוון שהיא תמונה אישית";
// Site info
scriptPath = "/w/index.php";
prettyPath = "/wiki/";
wikiHostname = "commons.wikimedia.org";
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('Contributions/(.*)$');
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) {
var pagename = encodeURIComponent(mw.config.get('wgPageName'));
var uploader = getUploader();
if (!uploader) return;
// Open new window for the user page
if (usertalk_fakeaction == 'mnx_warn') {
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
// sorl = "License", "Sourse" or "Source and License"
function mnx_addTemplate(template) {
var comment = 'Problematic image';
if (template == 'nsd') { // no source
comment = 'No source';
template = 'subst:nsd';
}
if (template == 'nld') { // no license
comment = 'No license';
template = 'subst:nld';
}
if (template == 'der') { // derivative
comment = 'Derivative';
template = 'derivative';
}
if (template == 'fui') { // fair use
comment = 'Fair use';
template = 'fair use';
}
if (template == 'owi') { // own work
comment = 'Own work';
template = 'Own work';
}
if (template == 'prv') { // private work
comment = 'not relevent to project scope';
template = 'speedydelete|project scope';
}
if (template == 'cov') { // copyvio
comment = 'Copyvio';
var answer = prompt('Reason?', '');
if (!answer || answer == '') {
template = 'copyvio';
} else {
template = 'copyvio|' + answer;
}
}
if (template == 'spd') { // speedy delete
comment = 'Speedy delete';
var answer = prompt('Reason?', '');
if (!answer || answer == '') {
template = 'speedydelete';
} else {
template = 'speedydelete|' + answer;
}
}
var txt = '{{' + template + '}}';
document.editform.wpTextbox1.value = txt + '\n' + document.editform.wpTextbox1.value;
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 comment = '';
if (template_type == 'mns_mns') { // source
var txt = '{{subst' + ':image source|Image:' + imageName + '}} ';
comment = 'no source';
}
if (template_type == 'mnl_mnl') { // license
var txt = '{{subst' + ':image source|Image:' + imageName + '}} ';
comment = 'no license';
}
if (template_type == 'mnd_mnd') { // derivative
var txt = '{{subst' + ':copyvionote|Image:' + imageName + '}} ';
comment = 'derivative vio';
}
if (template_type == 'mnc_mnc') { // copyvio
var txt = '{{subst' + ':copyvionote|Image:' + imageName + '}} ';
comment = 'copyvio';
}
if (template_type == 'mnfu_mnfu') { // fair use
var txt = '{{subst' + ':copyvionote|Image:' + imageName + '}} ';
comment = 'fair use';
}
if (template_type == 'mnow_mnow') { // own work
var txt = '==[[:Image:' + imageName + '|' + imageName + ']]==\n';
txt += '{{subst' + ':OwnWorkBoilerPlate}} ';
comment = 'own work';
}
if (template_type == 'mnpr_mnpr') { // private work
var txt = '{{subst' + ':project scope|Image:' + imageName + '}} ';
comment = 'Commons has a specific scope';
}
document.editform.wpTextbox1.value += '\n' + txt + '~~' + '~~\n';
document.editform.wpSummary.value = comment;
document.editform.wpSave.click();
}
function mnx_onload() {
if (wgNamespaceNumber == 6) { //NS_IMAGE
addLink('p-tb', 'javascript:mnx_mark(\'mnl_mnl\', \'mnx_warn\')', mnl_text, 'mark-no-license', mnl_tooltip, null, null);
addLink('p-tb', 'javascript:mnx_mark(\'mns_mns\', \'mnx_warn\')', mns_text, 'mark-no-source', mns_tooltip, null, null);
addLink('p-tb', 'javascript:mnx_mark(\'mnd_mnd\', \'mnx_warn\')', mnd_text, 'mark-derivative', mnd_tooltip, null, null);
addLink('p-tb', 'javascript:mnx_mark(\'mnc_mnc\', \'mnx_warn\')', mnc_text, 'mark-copyvio', mnc_tooltip, null, null);
addLink('p-tb', 'javascript:mnx_mark(\'mnpr_mnpr\', \'mnx_warn\')', mnpr_text, 'mark-private', mnpr_tooltip, null, null);
addLink('p-tb', 'javascript:mnx_mark(\'mnfu_mnfu\', \'mnx_warn\')', mnfu_text, 'mark-fair-use', mnfu_tooltip, null, null);
addLink('p-tb', 'javascript:mnx_mark(\'mnsd_mnsd\', \'no_warn\')', mnsd_text, 'mark-speedy-delete', mnsd_tooltip, null, null);
addLink('p-tb', 'javascript:mnx_mark(\'mnow_mnow\', \'mnx_warn\')', mnow_text, 'mark-own-work', mnow_tooltip, null, null);
}
var fakeaction = getParamValue('fakeaction');
var template_type = getParamValue('template_type'); // Fetch what template to add
if (fakeaction == 'mns_mns'){
mnx_addTemplate('nsd');
}
if (fakeaction == 'mnd_mnd'){
mnx_addTemplate('der');
}
if (fakeaction == 'mnl_mnl'){
mnx_addTemplate('nld');
}
if (fakeaction == 'mnc_mnc'){
mnx_addTemplate('cov');
}
if (fakeaction == 'mnfu_mnfu'){
mnx_addTemplate('fui');
}
if (fakeaction == 'mnow_mnow'){
mnx_addTemplate('owi');
}
if (fakeaction == 'mnsd_mnsd'){
mnx_addTemplate('spd');
}
if (fakeaction == 'mnpr_mnpr'){
mnx_addTemplate('prv');
}
if (fakeaction == 'mnx_warn') {
mnx_addUserWarningTemplate(decodeURIComponent(getParamValue('target')), template_type);
}
}
$(mnx_onload);
////</source>