forked from chavyleung/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b87791b
commit f06e6cd
Showing
2 changed files
with
29 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
const cookieName = '百度贴吧' | ||
const cookieKey = 'chavy_cookie_tieba' | ||
const cookieVal = $request.headers['Cookie'] | ||
const cookieName = "百度贴吧"; | ||
const cookieKey = "chavy_cookie_tieba"; | ||
const cookieVal = $request.headers["Cookie"]; | ||
|
||
if (cookieVal) { | ||
let cookie = $prefs.setValueForKey(cookieVal, cookieKey) | ||
let cookie = $prefs.setValueForKey(cookieVal, cookieKey); | ||
if (cookie) { | ||
let msg = `Cookie [${cookieName}] 写入成功!` | ||
$notify(msg, '', '详见日志') | ||
let msg = `Cookie [${cookieName}] 写入成功!`; | ||
$notify(msg, "", "详见日志"); | ||
} | ||
} | ||
|
||
$done({}) | ||
$done({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,42 @@ | ||
const cookieName = '百度贴吧' | ||
const cookieKey = 'chavy_cookie_tieba' | ||
const cookieVal = $prefs.valueForKey(cookieKey) | ||
const cookieName = "百度贴吧"; | ||
const cookieKey = "chavy_cookie_tieba"; | ||
const cookieVal = $prefs.valueForKey(cookieKey); | ||
|
||
function sign() { | ||
let url = { | ||
url: `http://tieba.baidu.com/f/like/mylike`, | ||
headers: { | ||
Cookie: cookieVal | ||
} | ||
} | ||
$task.fetch(url).then((response) => { | ||
let data = response.body | ||
let regex = /\/f\?kw=([^{'"}]*)/g | ||
}; | ||
$task.fetch(url).then(response => { | ||
let data = response.body; | ||
let regex = /\/f\?kw=([^{'"}]*)/g; | ||
let cnt = 0; | ||
for (const bar of data.matchAll(regex)) { | ||
signBar(bar) | ||
cnt += 1; | ||
setTimeout(() => signBar(bar), cnt * 500); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
function signBar(bar) { | ||
let url = { | ||
url: `http://tieba.baidu.com/sign/add?ie=utf-8&kw=${bar[1]}`, | ||
method: "POST", | ||
headers: { Cookie: cookieVal } | ||
} | ||
$task.fetch(url).then((response) => { | ||
let data = response.body | ||
let result = JSON.parse(data) | ||
}; | ||
$task.fetch(url).then(response => { | ||
let data = response.body; | ||
let result = JSON.parse(data); | ||
if (result.no == 0) { | ||
console.log(`正在签到: ${bar[1]}, 签到成功`) | ||
console.log(`正在签到: ${bar[1]}, 签到成功`); | ||
} else { | ||
console.log(`正在签到: ${bar[1]}, 错误编码: ${result.no}, 错误原因: ${result.error}`) | ||
console.log( | ||
`正在签到: ${bar[1]}, 错误编码: ${result.no}, 错误原因: ${result.error}` | ||
); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
sign() | ||
sign(); |