Skip to content

Commit 2dd1b7e

Browse files
committed
Update APIscript.user.js
up
1 parent 12c4247 commit 2dd1b7e

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

APIscript/APIscript.user.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
// ==UserScript==
22
// @name APIscript
33
// @namespace detail.setup
4-
// @description win.TShop._TMD_Config
4+
// @description win.TShop.cfg()
55
// @include http://detail1.pre.tmall.com/item.htm*
66
// @include http://detail2.pre.tmall.com/item.htm*
77
// @include http://detail.daily.tmall.net/item.htm*
88
// @include http://detail.tmall.com/item.htm*
9+
// @include http://detail.tmall.com/venus/spu_detail.htm*
910
// @version 1
1011
// ==/UserScript==
1112

1213
// 推荐使用unsafeWindow代替window
1314

14-
var win = window;
15+
var win = unsafeWindow || window;
1516
function matchNode(xpath, context) {
1617
return document.evaluate(context ? (xpath.indexOf('.') == 0 ? xpath : '.'
1718
+ xpath) : xpath, context || document, null,
@@ -20,7 +21,8 @@ function matchNode(xpath, context) {
2021

2122
// 监听事件触发时执行
2223
var checkDetail = function(){
23-
winAlert('已加载!');
24+
25+
2426
// 关注公共变量window.* 如:window.g_config
2527
var ks = win.KISSY,T;
2628
T = win.TShop;
@@ -33,7 +35,7 @@ var checkDetail = function(){
3335
// 吊顶用户名位置
3436
var nickname = matchNode('//p[@id = "login-info"]/a/text()').snapshotItem(0);
3537
// TMD_config
36-
var config = T._TMD_Config;
38+
var config = T.cfg();
3739
// 若支持taobaoBuy,则不展示购物车(tradeType:1 集市交易;2天猫交易)
3840
var tradeType = config.tradeType;
3941

@@ -83,11 +85,27 @@ var checkDetail = function(){
8385
txt+="URL: " + url + "\n"
8486
txt+="行:" + l + "\n\n"
8587
txt+="点击“ok”继续。\n\n"
86-
if (document.readyState == "complete") {
88+
8789
winAlert(txt);
88-
}
90+
8991
//throw new Error("1111")
9092
}
93+
94+
var wanren = new win.KISSY.IO({
95+
url: win.TShop.cfg().initApi,
96+
dataType: "jsonp",
97+
success: function(d) {
98+
//tmall新店铺优惠需求
99+
tuan = d;
100+
console.info(tuan.defaultModel.itemPriceResultDO.tmallShopProm);
101+
var sw = win.TShop.cfg().initExtensionApi.substring(104,122)
102+
if(sw.search("showShopProm") == -1){
103+
var index = win.TShop.cfg().initExtensionApi.search("showShopProm");
104+
sw = win.TShop.cfg().initExtensionApi.substring(index,index+18)
105+
}
106+
console.info("查是否请求老店铺优惠:",sw)
107+
}
108+
});
91109

92110
// };
93111
//最后清除监听器
@@ -101,12 +119,21 @@ window.addEventListener('load', checkDetail , true);
101119
// var setValue = function(n,v){var gmv=GM_setValue(n,v);};
102120
// GM_deleteValue('tradeType')
103121

122+
104123
// 重写alert方法
105124
function winAlert(msg){
106-
if (typeof jAlert != "undefined")
125+
126+
if (typeof win.jAlert != "undefined")
107127
{
108128
win.jAlert(msg,"警告!");
109129
}else{
110130
alert(msg);
111131
}
132+
112133
}
134+
135+
136+
var now = new Date("Jul 23,2013 09:14:10");
137+
138+
console.log(now.getTime())
139+

0 commit comments

Comments
 (0)