User:Dipankan001/filescripts.js

//Remodified version by Dipankan001. //See User:Drilnoth/filescripts.js/doc for details

//Import freesearch.js, which is stored at Commons. if(wgCanonicalNamespace == "" || wgCanonicalNamespace == "Category"){ mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Drilnoth/freesearch.js&action=raw&ctype=text/javascript'); }

if(queryString('nowcommons')) addOnloadHook(function { nowCommons; }) function nowCommons { var txt = document.getElementById('wpTextbox1'); if(!txt) return; txt.value = txt.value.replace(/\{\{[\s\t\n\r]*(mtc|ctwc|cwc|copy[ -_]to[ -_]wikimedia[ -_]commons|needs[ -_]commons[ -_]category|tocommons|movetocommons|move[ -_]to[ -_]commons|to[ -_]commons|move[ -_]to[ -_]wikimedia[ -_]commons|copy[ -_]to[ -_]commons|move-to-commons|commons[ -_]ok)[\s\t\n\r]*\}\}/ig,''); txt.value = '{' + '{' + 'subst:ncd}}\n\n' + txt.value; document.getElementById('wpSummary').value += 'Semi-automated image tagging using FileScripts'; document.getElementById('wpSave').click; }

if(queryString('wronglicense')) addOnloadHook(function { wrongLicense; }) function wrongLicense { var txt = document.getElementById('wpTextbox1'); if(!txt) return; txt.value = '{' + '{' + 'Wrong-license}}\n\n' + txt.value; document.getElementById('wpSummary').value += 'Semi-automated image tagging using FileScripts'; document.getElementById('wpSave').click; }

importScript("User:Drilnoth/delresized/tag.js");

if(queryString('notifycommons')) addOnloadHook(function { notifyCommons; }) function notifyCommons { var txt = document.getElementById('wpTextbox1'); if(!txt) return; txt.value = txt.value + '==Uploading free images to Wikimedia Commons==' + '\n' + '{' + '{' + 'subst:un-commons}}' + ' ~' + '~' + '~' + '~'; document.getElementById('wpSummary').value += '/* Uploading free images to Wikimedia Commons */ new section (using FileScripts)'; document.getElementById('wpSave').click; }

function startFileScripts{ if(wgCanonicalNamespace == "User_talk"){ var url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit'; mw.util.addPortletLink('p-cactions', url + '&notifycommons=true','notify about commons','ca-notifycommons','Tell user about uploading images to Wikimedia Commons'); } else if(wgCanonicalNamespace == "File"){ mw.util.addPortletLink('p-tb','http://toolserver.org/~commonshelper2/?file=' + encodeURIComponent(wgTitle) + '&use_tusc=checked&remove_existing_categories=checked', 'Move file to Commons', '', 'Move image to Commons using CommonsHelper'); mw.util.addPortletLink('p-tb', 'http://toolserver.org/~commonshelper2/?file=' + encodeURIComponent(wgTitle) + '&target_file=This file was uploaded accidentally please delete it.jpg&remove_existing_categories=checked', 'Commons description', '', 'Generate a description as if moving image to Commons (useful when completing an incomplete move)'); mw.util.addPortletLink('p-tb', mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit&nowcommons=true', 'Now Commons', '', 'Click here if image is available at Commons after transfer'); mw.util.addPortletLink('p-tb', mw.config.get('wgServer') + mw.config.get('wgScript') + '?title= '+ encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit&reducesupplied=true', 'Old revs deleted', '', 'Old, oversized revisions of fair-use image have been deleted'); } }

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }  return null; } $(startFileScripts);