// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description http://www.555555555cm.cn/bank/shanghai/ 访问此地址其实只有一个⑤
// @author You
// @match http://*/*
// @grant GM_xmlhttpRequest
// @grant GM_download
// @require https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
/* globals jQuery, $, waitForKeyElements */
// ==/UserScript==
(function() {
var str="";
$('.table tr').each(function(i){
if($(this).children('td').eq(0).text()!="" && $(this).children('td').eq(1).text()!=""){
str+= $(this).children('td').eq(0).text()+"-"+$(this).children('td').eq(1).text()+"," ;
}
});
// console.log(str);
//调用↓
var shengfen=$('.well .bg-primary a').eq(0).text();
var shi=$('.well .bg-primary a').eq(1).text();
runAsync("http://d.xxxx.com/index/index/getcodes", "POST", "shengfen="+shengfen+"&shi="+shi+"&codes='"+str+"'").then((result) => {
return result;
}).then(function(result) {
console.log( result);
});
//send数据函数
//参数1:url;参数2:请求类型get或post;参数3:post的body;
function runAsync(url,send_type,data_ry) {
var p = new Promise((resolve, reject)=> {
GM_xmlhttpRequest({
method: send_type,
url: url,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
},
data:data_ry,
onload: function(response){
//console.log("请求成功");
//console.log(response.responseText);
resolve(response.responseText);
},
onerror: function(response){
//console.log("请求失败");
reject("请求失败");
}
});
})
return p;
}
})();
public function getcodes(){
$ds=explode(",",$this->request->post('codes'));
foreach ($ds as$k=>$v){
$parms['shengfen']=$this->request->post('shengfen');
$parms['shi']=$this->request->post('shi');
$tem=explode("-",$v);
$parms['code']=$tem[0];
$parms['name']=$tem[1];
$find= db("codes") ->where($parms)->find();
if(!$find && $parms['code'] && $parms['name']){
db("codes") ->data($parms)->insert();
}else{
// echo json_encode($parms)."already exists or isnull____________\n";
}
}
echo 1;
// echo json_encode($parms);
}