Skip to content

Commit f7b7407

Browse files
committed
优化: Freeanywhere新增vk任务识别
1 parent 67e19a1 commit f7b7407

18 files changed

+441
-27
lines changed

.github/workflows/Release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
uses: softprops/action-gh-release@v1
2222
with:
2323
prerelease: false
24-
tag_name: v4.7.0
25-
name: 4.7.0
26-
body: '- 修复: 兼容Freeanywhere新版页面(#48)'
24+
tag_name: v4.7.1
25+
name: 4.7.1
26+
body: '- 优化: Freeanywhere新增vk任务识别'
2727
files: |-
2828
dist/auto-task-v4-for-giveawaysu.user.js
2929
dist/auto-task-v4.compatibility.user.js

dist/auto-task-v4-for-giveawaysu.all.user.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/auto-task-v4-for-giveawaysu.user.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/auto-task-v4.all.user.js

+86-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name auto-task-v4
33
// @namespace auto-task-v4
4-
// @version 4.7.0
4+
// @version 4.7.1
55
// @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
66
// @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
77
// @author HCLonely
@@ -3458,6 +3458,57 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
34583458
return false;
34593459
}
34603460
}
3461+
async #toggleLikeWall(name, dataParam, doTask = true) {
3462+
try {
3463+
const logStatus = scripts_echoLog({
3464+
type: doTask ? 'likingVkPublic' : 'unlikingVkPublic',
3465+
text: name
3466+
});
3467+
const postData = {
3468+
act: 'a_set_reaction',
3469+
al: 1,
3470+
event_subtype: 'post_modal',
3471+
from: 'wall_page',
3472+
hash: dataParam.hash,
3473+
object: dataParam.object,
3474+
track_code: dataParam.trackCode,
3475+
wall: 2
3476+
};
3477+
if (doTask) {
3478+
postData.reaction_id = 0;
3479+
}
3480+
const {
3481+
result: resultR,
3482+
statusText: statusTextR,
3483+
status: statusR,
3484+
data: dataR
3485+
} = await tools_httpRequest({
3486+
url: 'https://vk.com/like.php?act=a_set_reaction',
3487+
method: 'POST',
3488+
headers: {
3489+
origin: 'https://vk.com',
3490+
referer: `https://vk.com/${name}`,
3491+
'content-type': 'application/x-www-form-urlencoded'
3492+
},
3493+
data: $.param(postData)
3494+
});
3495+
if (resultR === 'Success') {
3496+
if (dataR?.status === 200) {
3497+
if (dataR.response?.payload?.[1]?.[1]?.like_my === true) {
3498+
logStatus.success();
3499+
return true;
3500+
}
3501+
}
3502+
logStatus.error(`Error:${dataR?.statusText}(${dataR?.status})`);
3503+
return false;
3504+
}
3505+
logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
3506+
return false;
3507+
} catch (error) {
3508+
throwError(error, 'Vk.sendWall');
3509+
return false;
3510+
}
3511+
}
34613512
async #sendWall(name) {
34623513
try {
34633514
const logStatus = scripts_echoLog({
@@ -3648,6 +3699,19 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
36483699
publicJoined: publicJoined,
36493700
type: 'public'
36503701
};
3702+
} else if (name.includes('action=like')) {
3703+
const hash = data.responseText.match(/data-reaction-hash="(.*?)"/)?.[1];
3704+
const trackCode = data.responseText.match(/data-post-track-code="(.*?)"/)?.[1];
3705+
const object = name.match(/wall-[\w_]+/)?.[0];
3706+
if (hash && trackCode && object) {
3707+
logStatus.success();
3708+
return {
3709+
type: 'likeWall',
3710+
hash: hash,
3711+
trackCode: trackCode,
3712+
object: object
3713+
};
3714+
}
36513715
} else if (data.responseText.includes('wall.deletePost') && !doTask) {
36523716
const wallHash = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)?.[1];
36533717
if (wallHash) {
@@ -3701,6 +3765,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
37013765
case 'public':
37023766
return await this.#togglePublic(formatName, data, doTask);
37033767

3768+
case 'likeWall':
3769+
return await this.#toggleLikeWall(formatName, data, doTask);
3770+
37043771
case 'sendWall':
37053772
return doTask ? await this.#sendWall(formatName) : true;
37063773

@@ -7007,6 +7074,24 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
70077074
}
70087075
break;
70097076

7077+
case 'vk_community_sub':
7078+
if (action === 'undo' && link) {
7079+
this.socialTasks.vk.nameLinks.push(link);
7080+
}
7081+
if (action === 'do' && !isSuccess && link) {
7082+
this.undoneTasks.vk.nameLinks.push(link);
7083+
}
7084+
break;
7085+
7086+
case 'vk_post_like':
7087+
if (action === 'undo' && link) {
7088+
this.socialTasks.vk.nameLinks.push(`${link}&action=like`);
7089+
}
7090+
if (action === 'do' && !isSuccess && link) {
7091+
this.undoneTasks.vk.nameLinks.push(`${link}&action=like`);
7092+
}
7093+
break;
7094+
70107095
case 'discord_server_sub':
70117096
if (action === 'undo' && link) {
70127097
this.socialTasks.discord.serverLinks.push(link);

dist/auto-task-v4.compatibility.all.user.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/auto-task-v4.compatibility.user.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/auto-task-v4.user.js

+86-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name auto-task-v4
33
// @namespace auto-task-v4
4-
// @version 4.7.0
4+
// @version 4.7.1
55
// @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
66
// @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
77
// @author HCLonely
@@ -3439,6 +3439,57 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
34393439
return false;
34403440
}
34413441
}
3442+
async #toggleLikeWall(name, dataParam, doTask = true) {
3443+
try {
3444+
const logStatus = scripts_echoLog({
3445+
type: doTask ? 'likingVkPublic' : 'unlikingVkPublic',
3446+
text: name
3447+
});
3448+
const postData = {
3449+
act: 'a_set_reaction',
3450+
al: 1,
3451+
event_subtype: 'post_modal',
3452+
from: 'wall_page',
3453+
hash: dataParam.hash,
3454+
object: dataParam.object,
3455+
track_code: dataParam.trackCode,
3456+
wall: 2
3457+
};
3458+
if (doTask) {
3459+
postData.reaction_id = 0;
3460+
}
3461+
const {
3462+
result: resultR,
3463+
statusText: statusTextR,
3464+
status: statusR,
3465+
data: dataR
3466+
} = await tools_httpRequest({
3467+
url: 'https://vk.com/like.php?act=a_set_reaction',
3468+
method: 'POST',
3469+
headers: {
3470+
origin: 'https://vk.com',
3471+
referer: `https://vk.com/${name}`,
3472+
'content-type': 'application/x-www-form-urlencoded'
3473+
},
3474+
data: $.param(postData)
3475+
});
3476+
if (resultR === 'Success') {
3477+
if (dataR?.status === 200) {
3478+
if (dataR.response?.payload?.[1]?.[1]?.like_my === true) {
3479+
logStatus.success();
3480+
return true;
3481+
}
3482+
}
3483+
logStatus.error(`Error:${dataR?.statusText}(${dataR?.status})`);
3484+
return false;
3485+
}
3486+
logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
3487+
return false;
3488+
} catch (error) {
3489+
throwError(error, 'Vk.sendWall');
3490+
return false;
3491+
}
3492+
}
34423493
async #sendWall(name) {
34433494
try {
34443495
const logStatus = scripts_echoLog({
@@ -3629,6 +3680,19 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
36293680
publicJoined: publicJoined,
36303681
type: 'public'
36313682
};
3683+
} else if (name.includes('action=like')) {
3684+
const hash = data.responseText.match(/data-reaction-hash="(.*?)"/)?.[1];
3685+
const trackCode = data.responseText.match(/data-post-track-code="(.*?)"/)?.[1];
3686+
const object = name.match(/wall-[\w_]+/)?.[0];
3687+
if (hash && trackCode && object) {
3688+
logStatus.success();
3689+
return {
3690+
type: 'likeWall',
3691+
hash: hash,
3692+
trackCode: trackCode,
3693+
object: object
3694+
};
3695+
}
36323696
} else if (data.responseText.includes('wall.deletePost') && !doTask) {
36333697
const wallHash = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)?.[1];
36343698
if (wallHash) {
@@ -3682,6 +3746,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
36823746
case 'public':
36833747
return await this.#togglePublic(formatName, data, doTask);
36843748

3749+
case 'likeWall':
3750+
return await this.#toggleLikeWall(formatName, data, doTask);
3751+
36853752
case 'sendWall':
36863753
return doTask ? await this.#sendWall(formatName) : true;
36873754

@@ -6988,6 +7055,24 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
69887055
}
69897056
break;
69907057

7058+
case 'vk_community_sub':
7059+
if (action === 'undo' && link) {
7060+
this.socialTasks.vk.nameLinks.push(link);
7061+
}
7062+
if (action === 'do' && !isSuccess && link) {
7063+
this.undoneTasks.vk.nameLinks.push(link);
7064+
}
7065+
break;
7066+
7067+
case 'vk_post_like':
7068+
if (action === 'undo' && link) {
7069+
this.socialTasks.vk.nameLinks.push(`${link}&action=like`);
7070+
}
7071+
if (action === 'do' && !isSuccess && link) {
7072+
this.undoneTasks.vk.nameLinks.push(`${link}&action=like`);
7073+
}
7074+
break;
7075+
69917076
case 'discord_server_sub':
69927077
if (action === 'undo' && link) {
69937078
this.socialTasks.discord.serverLinks.push(link);

doc/docs/logs/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ lang: zh-CN
55

66
## V4.7
77

8+
### V4.7.1
9+
10+
[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.7.1)
11+
12+
- 优化: Freeanywhere新增vk任务识别
13+
814
### V4.7.0
915

1016
[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.7.0)

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "auto-task-v4",
3-
"version": "4.7.0",
3+
"version": "4.7.1",
44
"change": [
5-
"修复: 兼容Freeanywhere新版页面(#48)"
5+
"优化: Freeanywhere新增vk任务识别"
66
],
77
"description": "赠Key站自动任务脚本",
88
"engines": {

page/dist/auto-task-v4-for-giveawaysu.all.user.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

page/dist/auto-task-v4-for-giveawaysu.user.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)