1
1
// ==UserScript==
2
2
// @name APIscript
3
3
// @namespace detail.setup
4
- // @description win.TShop._TMD_Config
4
+ // @description win.TShop.cfg()
5
5
// @include http://detail1.pre.tmall.com/item.htm*
6
6
// @include http://detail2.pre.tmall.com/item.htm*
7
7
// @include http://detail.daily.tmall.net/item.htm*
8
8
// @include http://detail.tmall.com/item.htm*
9
+ // @include http://detail.tmall.com/venus/spu_detail.htm*
9
10
// @version 1
10
11
// ==/UserScript==
11
12
12
13
// 推荐使用unsafeWindow代替window
13
14
14
- var win = window ;
15
+ var win = unsafeWindow || window ;
15
16
function matchNode ( xpath , context ) {
16
17
return document . evaluate ( context ? ( xpath . indexOf ( '.' ) == 0 ? xpath : '.'
17
18
+ xpath ) : xpath , context || document , null ,
@@ -20,7 +21,8 @@ function matchNode(xpath, context) {
20
21
21
22
// 监听事件触发时执行
22
23
var checkDetail = function ( ) {
23
- winAlert ( '已加载!' ) ;
24
+
25
+
24
26
// 关注公共变量window.* 如:window.g_config
25
27
var ks = win . KISSY , T ;
26
28
T = win . TShop ;
@@ -33,7 +35,7 @@ var checkDetail = function(){
33
35
// 吊顶用户名位置
34
36
var nickname = matchNode ( '//p[@id = "login-info"]/a/text()' ) . snapshotItem ( 0 ) ;
35
37
// TMD_config
36
- var config = T . _TMD_Config ;
38
+ var config = T . cfg ( ) ;
37
39
// 若支持taobaoBuy,则不展示购物车(tradeType:1 集市交易;2天猫交易)
38
40
var tradeType = config . tradeType ;
39
41
@@ -83,11 +85,27 @@ var checkDetail = function(){
83
85
txt += "URL: " + url + "\n"
84
86
txt += "行:" + l + "\n\n"
85
87
txt += "点击“ok”继续。\n\n"
86
- if ( document . readyState == "complete" ) {
88
+
87
89
winAlert ( txt ) ;
88
- }
90
+
89
91
//throw new Error("1111")
90
92
}
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
+ } ) ;
91
109
92
110
// };
93
111
//最后清除监听器
@@ -101,12 +119,21 @@ window.addEventListener('load', checkDetail , true);
101
119
// var setValue = function(n,v){var gmv=GM_setValue(n,v);};
102
120
// GM_deleteValue('tradeType')
103
121
122
+
104
123
// 重写alert方法
105
124
function winAlert ( msg ) {
106
- if ( typeof jAlert != "undefined" )
125
+
126
+ if ( typeof win . jAlert != "undefined" )
107
127
{
108
128
win . jAlert ( msg , "警告!" ) ;
109
129
} else {
110
130
alert ( msg ) ;
111
131
}
132
+
112
133
}
134
+
135
+
136
+ var now = new Date ( "Jul 23,2013 09:14:10" ) ;
137
+
138
+ console . log ( now . getTime ( ) )
139
+
0 commit comments