Skip to content

Commit

Permalink
add taobao
Browse files Browse the repository at this point in the history
  • Loading branch information
fayland committed May 10, 2014
1 parent 19b171b commit 0c70342
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ qiandao_chrome_extension

Chrome 插件 自动签到


[https://chrome.google.com/webstore/detail/%E8%87%AA%E5%8A%A8%E7%AD%BE%E5%88%B0/gphhmijanbcbckphcjkfkoccofhmjhdn](https://chrome.google.com/webstore/detail/%E8%87%AA%E5%8A%A8%E7%AD%BE%E5%88%B0/gphhmijanbcbckphcjkfkoccofhmjhdn)

访问一些可以签到的网站如一号店,点评,苏宁,虾米等,如果已登录该插件可以自动签到挣取积分。
访问一些可以签到的网站如淘宝,一号店,点评,苏宁,虾米等,如果已登录该插件可以自动签到挣取积分。
18 changes: 18 additions & 0 deletions js/qiandao/taobao.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
!function(win, doc, $){

$(doc).ready(function() {
chrome.runtime.sendMessage({method: "getLocalStorage", key: "taobao_status"}, function(res) {
var status = res.data;
var today = (new Date()).toDateString();
if (! (status && today === status)) {
// need cookie
chrome.runtime.sendMessage({method: "taobao_qiandao"}, function(res) {
console.log(res);
});
} else {
console.log('[qiandao][taobao] already signIn today.');
}
});
});

}(window, document, Zepto);
2 changes: 1 addition & 1 deletion js/qiandao/xiami.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
url : 'http://www.xiami.com/task/signin',
dataType : 'html',
success : function(data) {
if (data === '1') {
if (parseInt(data) === 1) {
chrome.runtime.sendMessage({
method: "setLocalStorage", key: "xiami_status", val: today
}, function(res) {});
Expand Down
7 changes: 6 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
"short_name": "签到",
"version": "0.0.2",
"manifest_version": 2,
"description": "登陆访问时自动在点评,一号店,苏宁,虾米等网站签到。",
"description": "登陆访问时自动在淘宝,点评,一号店,苏宁,虾米等网站签到。",
"homepage_url": "http://fayland.me/",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png"
},
"default_locale": "en",
"content_scripts": [
{
"matches": [ "http://*.taobao.com/*" ],
"js": [ "js/zepto.min.js", "js/qiandao/taobao.js" ],
"run_at": "document_end"
},
{
"matches": [ "http://*.yhd.com/*" ],
"js": [ "js/zepto.min.js", "js/qiandao/yhd.js" ],
Expand Down
29 changes: 28 additions & 1 deletion src/bg/background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
!function(win, doc, $){
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.method == "getLocalStorage") {
if (request.method == 'taobao_qiandao') {
chrome.cookies.getAll({domain:"taobao.com"}, function (cookies){
var token;
for (var i in cookies) {
if (cookies[i].name == '_tb_token_') {
token = cookies[i].value;
}
}
if (token) {
var timestamp = (new Date()).getTime();
var url = 'http://vip.taobao.com/home/grant_everyday_coin.htm?checkCode=null&t=' + timestamp + '&_tb_token_=' + token;
$.ajax({
type : "GET",
url : url,
dataType : 'json',
success : function(data) {
// {"login":"true","currentLevel":"v5","nextLevel":"v6","nextMaxCoin":40,"code":1,"coinOld":9145,"coinNew":9155,"daysTomorrow":2,"coinTomorrow":"15","auth":true,"isTake":"false","takeAmount":"","friendNum":"0","switcher":"true"}
if (data.code == 1 || data.code == 2) { // 1 is OK, 2 is already done
var today = (new Date()).toDateString();
localStorage.setItem('taobao_status', today);
localStorage.setItem('taobao_points', data.coinNew);
}
}
});
}
});
} else if (request.method == "getLocalStorage") {
sendResponse({data: localStorage[request.key]});
} else if (request.method == "setLocalStorage") {
localStorage.setItem(request.key, request.val);
Expand All @@ -9,4 +35,5 @@
sendResponse({}); // snub them.
}
});

}(window, document, Zepto);
5 changes: 5 additions & 0 deletions src/browser_action/browser_action.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

<table border='0'>
<tr><th>网站</th><th>最后签到时间</th><th>点数</th><th>-</th></tr>

<tr>
<td>淘宝</td><td id='taobao_status'></td><td id='taobao_points'>-</td>
<td><a href='http://vip.taobao.com/vip_home.htm' target='_blank'>访问</a></td>
</tr>
<tr>
<td>一号店</td><td id='yhd_status'></td><td id='yhd_points'>-</td>
<td><a href='http://vip.yhd.com/' target='_blank'>访问</a></td>
Expand Down
7 changes: 6 additions & 1 deletion src/browser_action/browser_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
text: ""
});

var ele = ['yhd_status', 'dianping_status', 'suning_status', 'suning_points', 'xiami_status'];
var ele = [
'taobao_status', 'taobao_points',
'yhd_status', 'dianping_status',
'suning_status', 'suning_points',
'xiami_status'
];
$.each(ele, function(i, v) {
$('#' + v).text(localStorage.getItem(v));
});
Expand Down

0 comments on commit 0c70342

Please sign in to comment.