User:A930913/vada/plugin/commoncopy.js

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('');

}

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);

}