Greasy Fork is available in English.

Oscar.QBao

Oscar's QBao

Ce script ne devrait pas être installé directement. C'est une librairie créée pour d'autres scripts. Elle doit être inclus avec la commande // @require https://update.greasyfork.org/scripts/12698/79762/OscarQBao.js

// ==UserScript==
// @name        Oscar.QBao
// @namespace   Oscar.QBao
// @description Oscar's QBao
// @version     2015.10.12.04
// @author Oscar Koo
// @grant       none
// @noframes
// ==/UserScript==

(function(e,t){if(typeof ok=="undefined"||!ok.isTopWindow())return;var r=/\/([0-9]+)\.html/.exec(top.location.href);var a;if(!r||r.length<=1||!(a=parseInt(r[1],10)))return;var n="oscar_QBao";var o=n+"_Booking_btnRun";var i=n+"_Num";var d=n+"_Remark";var u=n+"_Address";var v=n+"_Cache";var l=n+"_Booking_txtStart";var s=n+"_btnServerClock";var c=n+"_txtVCode";var m=n+"_VCode";var p=ok.CreateBooking();p.create(n,20);var f=p.log;var g=p.container.serverClock;var h=t.getElementById(o);h.disabled="disabled";ok.addBefore('<div>数量: <input type="text" id="'+i+'" style="width:167px"></div>'+'<div>备注: <input type="text" id="'+d+'" style="width:167px"></div>'+'<div>地址: <select id="'+u+'" style="width:173px"></select></div>'+'<div>验证码: <input type="text" id="'+c+'" style="width:50px"><span id="'+m+'"></span></div>',h.parentElement);var y=t.getElementById(i);var k=t.getElementById(d);var I=t.getElementById(u);var B=t.getElementById(l);var x=t.getElementById(s);var _=t.getElementById(c);var T={};var b=function(){T=ok.readLocal(v);y.value=T.num||1;k.value=T.remark||""};var w=function(){T={num:parseInt(y.value,10)||1,remark:k.value.trim()||""};ok.writeLocal(v,T)};var E=function(){y.onchange=w;k.onchange=w};b();E();var S=[];var C=[];var N=function(e){t.getElementById(m).innerHTML=t.getElementById("vilidataSpan").innerHTML;ok.query("/getFixedPriceProductInfo.html",{productId:a},function(t){if(!t){top.location.href="https://passport.qbao.com/cas/qianbaoLogin";return}var r=JSON.parse(t);if(!r.data){if(r.message)f.write(r.message);return}var a=r.data.userAddress;if(!a||a.length===0){top.location.href="http://oc.qbao.com/portle/address/list.html";return}for(var n=0;n<a.length;n++){var o=a[n];var i={addr:o.provinceName+" "+o.cityName+o.countyName+" "+o.address,name:o.consignee,tel:o.phoneNum};S.push(i);C.push('<option value="'+n+'">'+i.name+"-"+i.addr+"</option>")}ok.addHtml(C.join(""),I);h.disabled="";e()})};var q=function(){var e=false;p.onResponse=function(t,r,a,n){t=JSON.parse(t);if(t.success){e=true;return true}f.write(t.message);if(t.data==95)return true;return false};p.onFinished=function(){if(e)top.location.href="http://oc.qbao.com/order/index.html";h.click()};g.onTickTock=function(e,t){if(p.isTriggered)return;if(B.value.trim()<=t){p.isTriggered=true;setTimeout(function(){x.onclick();var e={productId:a,num:y.value||1,buyerRemark:k.value,vilidataCode:_.value};p.query("/purchase.html","POST",ok.jsonToQueryString(e)+"&"+ok.jsonToQueryString(S[I.selectedIndex]))},0)}}};N(q)})(window,document);