Skip to content

Commit

Permalink
修复: Keylol存在多个ASF激活代码时识别错误(#40);
Browse files Browse the repository at this point in the history
优化: Steam任务完成后的换区逻辑(#41);
优化: 使用ASF完成愿望单/关注游戏的逻辑
  • Loading branch information
HCLonely committed Dec 19, 2024
1 parent 26f1ed1 commit adbbbed
Show file tree
Hide file tree
Showing 20 changed files with 349 additions and 71 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ jobs:
uses: softprops/action-gh-release@v1
with:
prerelease: false
tag_name: v4.5.5
name: 4.5.5
body: '- 优化: opquests任务无法完成时跳过(#38)'
tag_name: v4.5.6
name: 4.5.6
body: |-
- 修复: Keylol存在多个ASF激活代码时识别错误(#40)
- 优化: Steam任务完成后的换区逻辑(#41)
- 优化: 使用ASF完成愿望单/关注游戏的逻辑
files: |-
dist/auto-task-v4-for-giveawaysu.user.js
dist/auto-task-v4.compatibility.user.js
Expand Down
4 changes: 2 additions & 2 deletions dist/auto-task-v4-for-giveawaysu.all.user.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/auto-task-v4-for-giveawaysu.user.js

Large diffs are not rendered by default.

68 changes: 59 additions & 9 deletions dist/auto-task-v4.all.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name auto-task-v4
// @namespace auto-task-v4
// @version 4.5.5
// @version 4.5.6
// @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
// @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
// @author HCLonely
Expand Down Expand Up @@ -1379,7 +1379,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
noAnotherArea: '请检测是否开启正确开启代理',
gettingAreaInfo: '正在获取Steam地区信息...',
changeAreaNotice: '疑似锁区游戏,尝试换区执行',
steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回%s',
gettingSubid: '正在获取游戏subid',
addingFreeLicense: '正在入库',
missParams: '缺少参数',
Expand Down Expand Up @@ -1664,7 +1664,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
noAnotherArea: 'Please check whether the proxy is turned on correctly',
gettingAreaInfo: 'Getting Steam area information...',
changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to %s',
gettingSubid: 'Getting subid',
addingFreeLicense: 'Adding free license',
missParams: 'Missing parameters',
Expand Down Expand Up @@ -4324,6 +4324,10 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
type: 'addingToWishlist',
text: gameId
});
if ((await this.#checkGame(gameId)).wishlist === true) {
logStatus.success();
return true;
}
const {
result,
statusText,
Expand Down Expand Up @@ -4356,6 +4360,10 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
type: 'removingFromWishlist',
text: gameId
});
if ((await this.#checkGame(gameId)).wishlist === false) {
logStatus.success();
return true;
}
const {
result,
statusText,
Expand Down Expand Up @@ -4388,6 +4396,10 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
type: `${doTask ? '' : 'un'}followingGame`,
text: gameId
});
if (doTask && (await this.#checkGame(gameId)).followed === true || !doTask && (await this.#checkGame(gameId)).followed === false) {
logStatus.success();
return true;
}
const {
result,
statusText,
Expand All @@ -4414,6 +4426,36 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
return false;
}
}
async #checkGame(gameId) {
try {
const {
result,
data
} = await tools_httpRequest({
...this.#asfOptions,
data: JSON.stringify({
Command: `!CHECK ${this.#botName} ${gameId}`
})
});
if (result === 'Success') {
if (data?.status === 200 && data.response?.Result?.includes(gameId)) {
const matchedResult = data.response.Result.split('\n').find(result => result.includes(gameId))?.split('|');
if (matchedResult?.length > 3) {
return {
wishlist: matchedResult.at(-3).trim() === '√' || matchedResult.at(-2).trim() === '√',
followed: matchedResult.at(-1).trim() === '√'
};
}
return {};
}
return {};
}
return {};
} catch (error) {
throwError(error, 'SteamASF.checkGame');
return {};
}
}
async toggleCurator(curatorId, doTask = true) {
try {
const logStatus = scripts_echoLog({
Expand Down Expand Up @@ -4568,6 +4610,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
#storeInitialized = false;
#communityInitialized = false;
#area = 'CN';
#oldArea;
#areaStatus = 'end';
#ASF;
constructor() {
Expand Down Expand Up @@ -5051,6 +5094,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
const {
currentArea
} = await this.#getAreaInfo();
if (!this.#oldArea && currentArea) {
this.#oldArea = currentArea;
}
if (currentArea === aimedArea) {
this.#areaStatus = 'success';
logStatus.success();
Expand Down Expand Up @@ -6497,9 +6543,13 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
text: 'steam.licenses'
});
} else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
for (const id of licenseLinks) {
prom.push(this.#addLicense(id));
await delay(1e3);
for (const ids of licenseLinks) {
const [ type, idsStr ] = ids.split('-');
const idsArr = idsStr.split(',');
for (const id of idsArr) {
prom.push(this.#addLicense(`${type}-${id}`));
await delay(1e3);
}
}
}
if (doTask && !globalOptions.doTask.steam.playtests) {
Expand All @@ -6517,9 +6567,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
return Promise.all(prom).then(async () => {
if (this.#area !== 'CN') {
scripts_echoLog({}).warning(i18n('steamFinishNotice'));
await this.#changeArea('CN');
if (this.#area !== this.#oldArea) {
scripts_echoLog({}).warning(i18n('steamFinishNotice', this.#oldArea));
await this.#changeArea(this.#oldArea);
}
return true;
});
Expand Down
6 changes: 3 additions & 3 deletions dist/auto-task-v4.compatibility.all.user.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/auto-task-v4.compatibility.user.js

Large diffs are not rendered by default.

68 changes: 59 additions & 9 deletions dist/auto-task-v4.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name auto-task-v4
// @namespace auto-task-v4
// @version 4.5.5
// @version 4.5.6
// @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
// @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
// @author HCLonely
Expand Down Expand Up @@ -1360,7 +1360,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
noAnotherArea: '请检测是否开启正确开启代理',
gettingAreaInfo: '正在获取Steam地区信息...',
changeAreaNotice: '疑似锁区游戏,尝试换区执行',
steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回%s',
gettingSubid: '正在获取游戏subid',
addingFreeLicense: '正在入库',
missParams: '缺少参数',
Expand Down Expand Up @@ -1645,7 +1645,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
noAnotherArea: 'Please check whether the proxy is turned on correctly',
gettingAreaInfo: 'Getting Steam area information...',
changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to %s',
gettingSubid: 'Getting subid',
addingFreeLicense: 'Adding free license',
missParams: 'Missing parameters',
Expand Down Expand Up @@ -4305,6 +4305,10 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
type: 'addingToWishlist',
text: gameId
});
if ((await this.#checkGame(gameId)).wishlist === true) {
logStatus.success();
return true;
}
const {
result,
statusText,
Expand Down Expand Up @@ -4337,6 +4341,10 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
type: 'removingFromWishlist',
text: gameId
});
if ((await this.#checkGame(gameId)).wishlist === false) {
logStatus.success();
return true;
}
const {
result,
statusText,
Expand Down Expand Up @@ -4369,6 +4377,10 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
type: `${doTask ? '' : 'un'}followingGame`,
text: gameId
});
if (doTask && (await this.#checkGame(gameId)).followed === true || !doTask && (await this.#checkGame(gameId)).followed === false) {
logStatus.success();
return true;
}
const {
result,
statusText,
Expand All @@ -4395,6 +4407,36 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
return false;
}
}
async #checkGame(gameId) {
try {
const {
result,
data
} = await tools_httpRequest({
...this.#asfOptions,
data: JSON.stringify({
Command: `!CHECK ${this.#botName} ${gameId}`
})
});
if (result === 'Success') {
if (data?.status === 200 && data.response?.Result?.includes(gameId)) {
const matchedResult = data.response.Result.split('\n').find(result => result.includes(gameId))?.split('|');
if (matchedResult?.length > 3) {
return {
wishlist: matchedResult.at(-3).trim() === '√' || matchedResult.at(-2).trim() === '√',
followed: matchedResult.at(-1).trim() === '√'
};
}
return {};
}
return {};
}
return {};
} catch (error) {
throwError(error, 'SteamASF.checkGame');
return {};
}
}
async toggleCurator(curatorId, doTask = true) {
try {
const logStatus = scripts_echoLog({
Expand Down Expand Up @@ -4549,6 +4591,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
#storeInitialized = false;
#communityInitialized = false;
#area = 'CN';
#oldArea;
#areaStatus = 'end';
#ASF;
constructor() {
Expand Down Expand Up @@ -5032,6 +5075,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
const {
currentArea
} = await this.#getAreaInfo();
if (!this.#oldArea && currentArea) {
this.#oldArea = currentArea;
}
if (currentArea === aimedArea) {
this.#areaStatus = 'success';
logStatus.success();
Expand Down Expand Up @@ -6478,9 +6524,13 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
text: 'steam.licenses'
});
} else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
for (const id of licenseLinks) {
prom.push(this.#addLicense(id));
await delay(1e3);
for (const ids of licenseLinks) {
const [ type, idsStr ] = ids.split('-');
const idsArr = idsStr.split(',');
for (const id of idsArr) {
prom.push(this.#addLicense(`${type}-${id}`));
await delay(1e3);
}
}
}
if (doTask && !globalOptions.doTask.steam.playtests) {
Expand All @@ -6498,9 +6548,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
return Promise.all(prom).then(async () => {
if (this.#area !== 'CN') {
scripts_echoLog({}).warning(i18n('steamFinishNotice'));
await this.#changeArea('CN');
if (this.#area !== this.#oldArea) {
scripts_echoLog({}).warning(i18n('steamFinishNotice', this.#oldArea));
await this.#changeArea(this.#oldArea);
}
return true;
});
Expand Down
8 changes: 8 additions & 0 deletions doc/docs/logs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ lang: zh-CN

## V4.5

### V4.5.6

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

- 修复: Keylol存在多个ASF激活代码时识别错误([#40](https://github.com/HCLonely/auto-task-v4/issues/40))
- 优化: Steam任务完成后的换区逻辑([#41](https://github.com/HCLonely/auto-task-v4/issues/41))
- 优化: 使用ASF完成愿望单/关注游戏的逻辑

### V4.5.5

[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.5.5)
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "auto-task-v4",
"version": "4.5.5",
"version": "4.5.6",
"change": [
"优化: opquests任务无法完成时跳过(#38)"
"修复: Keylol存在多个ASF激活代码时识别错误(#40)",
"优化: Steam任务完成后的换区逻辑(#41)",
"优化: 使用ASF完成愿望单/关注游戏的逻辑"
],
"description": "赠Key站自动任务脚本",
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions page/dist/auto-task-v4-for-giveawaysu.all.user.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions page/dist/auto-task-v4-for-giveawaysu.user.js

Large diffs are not rendered by default.

Loading

0 comments on commit adbbbed

Please sign in to comment.