NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name EcolifeDiary
// @namespace Mingo
// @version 0.1
// @description enter something useful
// @author You
// @match http://ecolifepanel.epa.gov.tw/eButler.aspx
// @grant none
// ==/UserScript==
var month=12;
var colOffset=0;
$("#workspace-content .eButler").remove();
$("#workspace-content").append($('<input/>')
.attr({id:'liField', type:'text',value:"里"})
.click(function(){$(this).select();})
).append($('<input/>')
.attr({type:'button', value:"查詢"})
.click(function(){doAll();})
).append($("<table/>")
.attr({id:"modifiedTable",class:'list-table'})
.css({'text-align':'center'})
.html('<tr> <th>里</th> <th>巡檢日誌</th> <th>清理日誌</th> <th>發起活動</th>'));// <th>改志工</th></tr>'));
function doAll(){
var liArr=$("#liField").val().split(" ");
var liIdArr=Array(liArr.length);
for(var i in liArr){
$("#ctl00_cphMain_ucSidebar_divBlogList a").each(function(){
if(this.title.indexOf(liArr[i])!=-1){
liIdArr[i]=this.href.slice(25,this.href.lastIndexOf("'"));
return false;
}
});
}
for(var i in liIdArr){
var id=liIdArr[i];
//if(id=='491329'){
addRow(liArr[i]);
doIt(id);
console.log(liArr[i]+'done');
//}
}
}
function addRow(li){
$("#modifiedTable tr:last").after($("<tr> <td>"+li+"</td> <td></td> <td></td> <td></td> </tr>"));
}
function doIt(id){
$.ajax({
url: 'http://ecolifepanel.epa.gov.tw/blog/setup.aspx?bid='+id,
async: false,
success: function(res){
doList('inspectlist',2);
doList('clearlist',3);
doList('actionlist',4);
//doLabor();
}
});
}
function doLabor(){
$.ajax({
url: 'http://ecolifepanel.epa.gov.tw/map/area.aspx',
async: false,
success: function(res){
$(res).find(".cell-large-actions").find("input:first").each(function(){
var id=this.onclick.toString();
id=id.slice(40,id.lastIndexOf("'"));
var done=false;
while(!done){
done=tryOneLabor(id);
}
});
}
});
}
function tryOneLabor(id){
$.ajax({
url: 'http://ecolifepanel.epa.gov.tw/map/areaform.aspx?key='+id+'&tab=0',
async: false,
success: function(res){
$(res).find(".cell-large-actions").find("input:first").each(function(){
var id=this.onclick.toString();
id=id.slice(40,id.lastIndexOf("'"));
var done=false;
while(!done){
done=tryOneLabor(id);
}
});
}
});
}
function doList(urlAffix,offset){
$.ajax({
url: 'http://ecolifepanel.epa.gov.tw/journal/'+urlAffix+'.aspx',
async: false,
success: function(res){
m=$(res).find(".list-table tr:nth-child(5) td.cell-date").html();
m=m.slice(5,m.lastIndexOf('/'));
if(m==month)
$("#modifiedTable tr:last td:nth-child("+(colOffset+offset)+")").html("o");
else
$("#modifiedTable tr:last td:nth-child("+(colOffset+offset)+")").html("x");
}
});
}
//a=toDisplayShiftList.toString();var fun=new Function(a.slice(30,65)+'function(res){console.log(res)}, null);')