User:A930913/vada/plugin/commoncopy.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:A930913/vada/plugin/commoncopy. |
if(typeof window!="undefined"){
//inside Vada DOM
(function(){
var a930913_commoncopy={
about:{
"name":"A930913's Copy to Commons Tagger",
"description":"Prepends {{Copy to Commons}} to files",
"namespace":"a930913_commoncopy",
"userscript":"User:A930913/vada/plugin/commoncopy.js",
}
}
window.vada.loadPlugin(a930913_commoncopy);
})();
} else {
//inside Vada process
vada.plugins.a930913_commoncopy={};
vada.plugins.a930913_commoncopy.page=function(params){
var p=new vada.Page(params.page);
if(/\{\{(Copy to Commons|Already moved to Commons|bsr|c-uploaded|Convert to SVG and copy to Wikimedia Commons|Copy to Wikimedia Commons|db-f2|db-f9|db-fpcfail|db-nowcommons|db-reason|db-redundantimage|Deleted on Commons|di-dw no license|di-no license|di-no permission|di-no source|Do not move to Commons|duplicate|dyk|esoteric file|example files|ffd|file at CCI|FormerFeaturedPicture|Imagewatermark|Keep local|m-cropped|NFUR not needed|nominated for deletion on Commons|Non-free use rationale|Non-free use rationale 2|NotMovedToCommons|Now Commons|OTRS pending|out of copyright in|PD-ineligible-USonly|pp-protected|pp-template|protected generic image name|protected image|protected sister project logo|puf|ShadowsCommons|Split media|userspace file|Wikipedia screenshot|wrong-license)(\||\}\})/i.exec(p.text)!==null){
vada.dom.queue.splice(vada.dom.queue.indexOf(p),1);
vada.dom.queue.redraw();
return vada.dom.queue.next();
}
vada.dom.summarybox.setText("Tagging with {{Copy to Commons}}");
vada.dom.minorbox.uncheck();
vada.dom.load(p,"{{Copy to Commons}}\n"+p.text);
var img=vada.api({action:"query",titles:p.title,prop:"imageinfo",iiprop:"url",iiurlheight:"300"});
for(var pageid in img.query.pages)break;
vada.dom.extraInfo('<img onmouseover="this.style.position=\'fixed\';this.style.right=\'2px\';this.style.height=\'auto\';this.style.width=\'auto\';this.style.border=\'2px solid grey\';" onmouseout="this.style.position=\'\';this.style.right=\'\';this.style.height=\'\';this.style.width=\'\';this.style.border=\'\'" src="'+img.query.pages[pageid].imageinfo[0].thumburl.substr(6)+'" />');
}
vada.plugins.a930913_commoncopy.queueclick=function(params){
vada.plugins.a930913_commoncopy.page({page:params.title});
vada.dom.queue.splice(vada.dom.queue.indexOf(new vada.Page(params.title)),1);
vada.dom.queue.redraw();
}
vada.plugins.a930913_commoncopy.saveclick=function(params){
vada.dom.queue.next();
}
vada.plugins.a930913_commoncopy.start=function(){
vada.events.trigger("plugins.stop",{});
vada.events.addListener("plugins.stop",vada.plugins.a930913_commoncopy.stop);
vada.dom.menu.new([vada.dom.menu.buttons.nextq,vada.dom.menu.buttons.save]);
vada.dom.queue.builders.show();
vada.events.addListener("pagename",vada.plugins.a930913_commoncopy.page);
vada.events.addListener("queue.page.selected",vada.plugins.a930913_commoncopy.queueclick);
vada.events.addListener("save.click",vada.plugins.a930913_commoncopy.saveclick);
vada.plugins.a930913_commoncopy.running=true;
}
vada.plugins.a930913_commoncopy.stop=function(){
vada.plugins.a930913_commoncopy.running=false;
vada.dom.queue.builders.hide();
vada.events.removeListener("pagename",vada.plugins.a930913_commoncopy.page);
vada.events.removeListener("queue.page.selected",vada.plugins.a930913_commoncopy.queueclick);
vada.events.removeListener("save.click",vada.plugins.a930913_commoncopy.saveclick);
}
vada.plugins.a930913_commoncopy.running=false;
vada.plugins.a930913_commoncopy.button=(function(pl){
var button=new vada.dom.menu.Button("a930913_commoncopy_start");
button.text="A930913's Copy to Commons Tagger";
button.click=pl.start;
vada.dom.menu.buttons.vada.children.push(button);
vada.dom.menu.redraw();
return button;
})(vada.plugins.a930913_commoncopy);
}