User:MECU/imagevio.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
//<pre><nowiki> // ImageautoCopyvio - Adds image copyright violation notice to article and adds entry to Copyright Problems (image) page // Created by Mecu, modified by AndyZ, // modified from modified autocopyvio script modified from modified AutoAFD modified from modified AutoVFD (by Korath) function imgcv_add_link(url, name){ var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; tabs.appendChild(li); } function imgcopyvio(){ //update current page document.editform.wpTextbox1.value = '{' + '{' + 'imagevio|url=}}'; document.editform.wpSummary.value += 'Image copyright violation'; var target = wgPageName; //pagename, unedited //date var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date(); var datestring = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate(); //open up WP:CV/date/Images window.open('/w/index.php?title=Wikipedia:Copyright_problems/' + datestring + '/Images&action=edit&fakeaction=imgcopyviolist&faketarget=' + target, 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); } //todo: open up user talk page of uploader? function imgautocopyvio(){ if (document.title.indexOf('Editing ') == 0){ var action = '', target = ''; if (location.search){ var l = location.search.substring(1).split('&'); for (var i = 0; i < l.length; i++){ var eq = l[i].indexOf('='); var name = l[i].substring(0, eq); if (name == 'fakeaction') action = l[i].substring(eq + 1); else if (name == 'faketarget') target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' '); } } if (action == 'imgcopyviolist'){ document.editform.wpTextbox1.value += '* {'+'{subst:Image-cv|'+target+'}} from [http://]. ~~'+'~~' document.editform.wpSummary.value += 'Possible Image copyright violation: [[' + target + ']]'; } else if (wgNamespaceNumber == 6) imgcv_add_link('javascript:imgcopyvio()', 'Image copyvio'); } } addOnloadHook(imgautocopyvio); //</nowiki></pre>