File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # 百度贴吧
2+
3+ ## 配置
4+
5+ ``` properties
6+ [MITM]
7+ tieba.baidu.com
8+
9+ [Script]
10+ http-request ^http://tieba.baidu.com script-path =https://raw.githubusercontent.com/chavyleung/scripts/master/tieba/tieba.cookie.js
11+ cron " 10 0 0 * *" script-path =https://raw.githubusercontent.com/chavyleung/scripts/master/tieba/tieba.js
12+ ```
13+
14+ ## 说明
15+
16+ 1 . 先把` tieba.baidu.com ` 加到` [MITM] `
17+ 2 . 再把两条远程脚本放到` [Script] `
18+ 3 . 用浏览器访问下: http://tieba.baidu.com (需要登录)
19+ 4 . ` Surge ` 提示: ` Cookie [百度贴吧] 写入成功 `
20+ 5 . 最后就可以把第 1 条脚本注释掉了
21+
22+ > 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了
23+
24+ > 第 2 条脚本是签到脚本, 每天` 00:00:10 ` 执行一次.
25+
26+ ## 感谢
27+
28+ [ @NobyDa ] ( https://github.com/NobyDa )
29+
30+ [ @lhie1 ] ( https://github.com/lhie1 )
31+
32+ [ @ConnersHua ] ( https://github.com/ConnersHua )
Original file line number Diff line number Diff line change 1+ /**
2+ *
3+ * [MITM]
4+ * tieba.baidu.com
5+ *
6+ * [Script]
7+ * http-request ^http://tieba.baidu.com script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/tieba/tieba.cookie.js
8+ * cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/tieba/tieba.js
9+ *
10+ */
11+
12+ const cookieName = '百度贴吧'
13+ const cookieKey = 'chavy_cookie_tieba'
14+ let cookieVal = $request . headers [ 'Cookie' ]
15+
16+ if ( cookieVal ) {
17+ let cookie = $persistentStore . write ( cookieVal , cookieKey )
18+ if ( cookie ) {
19+ let msg = `Cookie [${ cookieName } ] 写入成功!`
20+ $notification . post ( msg , '' , '详见日志' )
21+ console . log ( msg )
22+ console . log ( cookieVal )
23+ }
24+ }
25+
26+ $done ( { } )
Original file line number Diff line number Diff line change 1+ /**
2+ *
3+ * [MITM]
4+ * tieba.baidu.com
5+ *
6+ * [Script]
7+ * http-request ^http://tieba.baidu.com script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/tieba/tieba.cookie.js
8+ * cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/tieba/tieba.js
9+ *
10+ */
11+
12+ const cookieName = '百度贴吧'
13+ const cookieKey = 'chavy_cookie_tieba'
14+ const cookieVal = $persistentStore . read ( cookieKey )
15+
16+ function sign ( ) {
17+ let url = {
18+ url : `http://tieba.baidu.com/f/like/mylike` ,
19+ headers : {
20+ Cookie : cookieVal
21+ }
22+ }
23+
24+ $httpClient . post ( url , ( error , response , data ) => {
25+ // <a href="/f?kw=surface" title="surface">surface</a>
26+ // let regex = /\/f\?kw=([^{'"}]*)/g
27+ // let regex = /\/f\?kw=([^{'"}]*).*?>([^<]*)/g
28+ let regex = / \/ f \? k w = ( [ ^ { ' " } ] * ) / g
29+ for ( const bar of data . matchAll ( regex ) ) {
30+ signBar ( bar )
31+ }
32+ } )
33+ $done ( { } )
34+ }
35+
36+ function signBar ( bar ) {
37+ let url = {
38+ url : `http://tieba.baidu.com/sign/add?ie=utf-8&kw=${ bar [ 1 ] } ` ,
39+ headers : { Cookie : cookieVal }
40+ }
41+
42+ $httpClient . post ( url , ( error , response , data ) => {
43+ let result = JSON . parse ( data )
44+ if ( result . no == 0 ) {
45+ console . log ( `正在签到: ${ bar [ 1 ] } , 签到成功` )
46+ } else {
47+ console . log (
48+ `正在签到: ${ bar [ 1 ] } , 错误编码: ${ result . no } , 错误原因: ${ result . error } `
49+ )
50+ }
51+ } )
52+ }
53+
54+ sign ( )
You can’t perform that action at this time.
0 commit comments