User:Najzere/adduploadurl.js

// Author: User:Najzere // License: CC-BY-SA 3.0 - http://creativecommons.org/licenses/by-sa/3.0/ // Description: Adds image source to upload summary when uploading from URL

if (wgPageName == 'Special:Upload') { addOnloadHook(get_URL); };

function get_URL { var URL_form=document.getElementById('wpUploadFileURL'); addHandler(URL_form, 'change', insert_URL); };

function insert_URL(event) { var URL = document.getElementById('wpUploadFileURL').value; var summary = document.getElementById('wpUploadDescription'); var re = /\[http.*? Source URL\]/; if(summary.value.match(re)) { summary.value = summary.value.replace(re, '[' + URL + ' Source URL]'); } else { summary.value = summary.value + '\n\n[' + URL + ' Source URL]'; }; };