Skip to content

Commit

Permalink
Sub入库功能优化
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Jan 29, 2022
1 parent 587887f commit c33817d
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 80 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ jobs:
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: v4.1.20-beta
name: 4.1.20-beta
body: |-
- Givekey任务识别优化
- 修复Discord退组失败的BUG
- 数据同步功能优化
tag_name: v4.1.21-beta
name: 4.1.21-beta
body: '- Sub入库功能优化'
files: |-
dist/auto-task-v4-for-giveawaysu.user.js
dist/auto-task-v4.compatibility.user.js
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

[![License](https://img.shields.io/github/license/HCLonely/auto-task-v4?label=License)](https://github.com/HCLonely/auto-task-v4/blob/main/LICENSE)
[![Release](https://img.shields.io/github/v/release/HCLonely/auto-task-v4?include_prereleases)](https://github.com/HCLonely/auto-task-v4/releases)
[![Checks](https://badgen.net/github/checks/HCLonely/auto-task-v4)](https://github.com/HCLonely/auto-task-v4/actions)
[![Status](https://badgen.net/github/status/HCLonely/auto-task-v4)](https://github.com/HCLonely/auto-task-v4/actions)

[![GitHub file size in bytes](https://img.shields.io/github/size/HCLonely/auto-task-v4/dist/auto-task-v4.user.js?label=auto-task-v4.user.js)](https://github.com/HCLonely/auto-task-v4/raw/main/dist/auto-task-v4.user.js)
[![GitHub file size in bytes](https://img.shields.io/github/size/HCLonely/auto-task-v4/dist/auto-task-v4.compatibility.user.js?label=auto-task-v4.compatibility.user.js)](https://github.com/HCLonely/auto-task-v4/raw/main/dist/auto-task-v4.compatibility.user.js)
[![GitHub file size in bytes](https://img.shields.io/github/size/HCLonely/auto-task-v4/dist/auto-task-v4-for-giveawaysu.user.js?label=auto-task-v4-for-giveawaysu.user.js)](https://github.com/HCLonely/auto-task-v4/raw/main/dist/auto-task-v4-for-giveawaysu.user.js)

自动完成 Key 站任务。

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

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions dist/auto-task-v4.compatibility.user.js

Large diffs are not rendered by default.

37 changes: 32 additions & 5 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.1.20-beta
// @version 4.1.21-beta
// @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 @@ -6169,8 +6169,12 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
return false;
}
}
async function _addFreeLicense2(id, logStatus) {
async function _addFreeLicense2(id, logStatusPre) {
try {
const logStatus = logStatusPre || scripts_echoLog({
type: 'addingFreeLicenseSubid',
text: id
});
const {
result,
statusText,
Expand All @@ -6194,6 +6198,15 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
});
if (result === 'Success') {
if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
logStatus.warning(i18n('changeAreaNotice'));
const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
if (!result || result === 'CN') {
return false;
}
return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
}
logStatus.success();
return true;
}
logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
Expand All @@ -6202,7 +6215,6 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
logStatus.error(`${result}:${statusText}(${status})`);
return false;
} catch (error) {
logStatus.error();
throwError(error, 'Steam.addFreeLicense');
return false;
}
Expand Down Expand Up @@ -8661,8 +8673,8 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
}
static test() {
var _$$eq$attr;
return window.location.host === 'keylol.com' && !!((_$$eq$attr = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr !== void 0 && _$$eq$attr.includes('319'));
var _$$eq$attr, _$$eq$attr2;
return window.location.host === 'keylol.com' && (!!((_$$eq$attr = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr !== void 0 && _$$eq$attr.includes('319')) || !!((_$$eq$attr2 = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr2 !== void 0 && _$$eq$attr2.includes('234')));
}
init() {
return true;
Expand Down Expand Up @@ -8811,6 +8823,21 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(`a[href="${link}"]`).after('<span style="color: #ccc; margin: 0 -5px 0 5px"> | </span>').next()[0], 'steam', 'licenseLinks', `appid-${link.replace('#asf', '')}`);
}
}
const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]');
if (subLinks.length > 0) {
for (const subLink of subLinks) {
var _link$match;
const link = $(subLink).attr('href');
if (!link) {
continue;
}
const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
if (!subid) {
continue;
}
Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
}
}
const asfLinks2 = mainPost.find('.blockcode:contains("addlicense")');
if (asfLinks2.length > 0) {
for (const asfLink of asfLinks2) {
Expand Down
4 changes: 2 additions & 2 deletions doc/docs/.vuepress/public/report.html

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions doc/docs/logs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ lang: zh-CN

## V4.1

### V4.1.21-beta

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

- Sub入库功能优化

### V4.1.20-beta

[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.1.20-beta)
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"name": "auto-task-v4",
"version": "4.1.20-beta",
"version": "4.1.21-beta",
"change": [
"Givekey任务识别优化",
"修复Discord退组失败的BUG",
"数据同步功能优化"
"Sub入库功能优化"
],
"description": "赠Key站自动任务脚本",
"main": "package.json",
Expand Down
4 changes: 2 additions & 2 deletions page/dist/auto-task-v4-for-giveawaysu.user.js

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions page/dist/auto-task-v4.compatibility.user.js

Large diffs are not rendered by default.

37 changes: 32 additions & 5 deletions page/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.1.20-beta
// @version 4.1.21-beta
// @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 @@ -6169,8 +6169,12 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
return false;
}
}
async function _addFreeLicense2(id, logStatus) {
async function _addFreeLicense2(id, logStatusPre) {
try {
const logStatus = logStatusPre || scripts_echoLog({
type: 'addingFreeLicenseSubid',
text: id
});
const {
result,
statusText,
Expand All @@ -6194,6 +6198,15 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
});
if (result === 'Success') {
if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
logStatus.warning(i18n('changeAreaNotice'));
const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
if (!result || result === 'CN') {
return false;
}
return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
}
logStatus.success();
return true;
}
logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
Expand All @@ -6202,7 +6215,6 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
logStatus.error(`${result}:${statusText}(${status})`);
return false;
} catch (error) {
logStatus.error();
throwError(error, 'Steam.addFreeLicense');
return false;
}
Expand Down Expand Up @@ -8661,8 +8673,8 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
}
static test() {
var _$$eq$attr;
return window.location.host === 'keylol.com' && !!((_$$eq$attr = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr !== void 0 && _$$eq$attr.includes('319'));
var _$$eq$attr, _$$eq$attr2;
return window.location.host === 'keylol.com' && (!!((_$$eq$attr = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr !== void 0 && _$$eq$attr.includes('319')) || !!((_$$eq$attr2 = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr2 !== void 0 && _$$eq$attr2.includes('234')));
}
init() {
return true;
Expand Down Expand Up @@ -8811,6 +8823,21 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(`a[href="${link}"]`).after('<span style="color: #ccc; margin: 0 -5px 0 5px"> | </span>').next()[0], 'steam', 'licenseLinks', `appid-${link.replace('#asf', '')}`);
}
}
const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]');
if (subLinks.length > 0) {
for (const subLink of subLinks) {
var _link$match;
const link = $(subLink).attr('href');
if (!link) {
continue;
}
const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
if (!subid) {
continue;
}
Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
}
}
const asfLinks2 = mainPost.find('.blockcode:contains("addlicense")');
if (asfLinks2.length > 0) {
for (const asfLink of asfLinks2) {
Expand Down
6 changes: 2 additions & 4 deletions page/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"name": "auto-task-v4",
"version": "4.1.20-beta",
"version": "4.1.21-beta",
"change": [
"Givekey任务识别优化",
"修复Discord退组失败的BUG",
"数据同步功能优化"
"Sub入库功能优化"
],
"description": "赠Key站自动任务脚本",
"main": "package.json",
Expand Down
13 changes: 10 additions & 3 deletions src/scripts/social/Steam.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author : HCLonely
* @Date : 2021-10-04 16:07:55
* @LastEditTime : 2022-01-20 17:32:52
* @LastEditTime : 2022-01-29 10:28:25
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/src/scripts/social/Steam.ts
* @Description : steam相关功能
Expand Down Expand Up @@ -1056,14 +1056,15 @@ class Steam extends Social {
return false;
}
}
async #addFreeLicense(id: string, logStatus: logStatus): Promise<boolean> {
async #addFreeLicense(id: string, logStatusPre?: logStatus): Promise<boolean> {
/**
* @internal
* @description 入库免费游戏
* @param id Steam游戏subid
* @return true: 成功 | false: 失败
*/
try {
const logStatus = logStatusPre || echoLog({ type: 'addingFreeLicenseSubid', text: id });
const { result, statusText, status, data } = await httpRequest({
url: 'https://store.steampowered.com/checkout/addfreelicense',
method: 'POST',
Expand All @@ -1082,6 +1083,13 @@ class Steam extends Social {
});
if (result === 'Success') {
if (data?.status === 200) {
if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
logStatus.warning(__('changeAreaNotice'));
const result = await this.#changeArea();
if (!result || result === 'CN') return false;
return await this.#addFreeLicense(id);
}
logStatus.success();
return true;
}
logStatus.error(`Error:${data?.statusText}(${data?.status})`);
Expand All @@ -1090,7 +1098,6 @@ class Steam extends Social {
logStatus.error(`${result}:${statusText}(${status})`);
return false;
} catch (error) {
logStatus.error();
throwError(error as Error, 'Steam.addFreeLicense');
return false;
}
Expand Down
19 changes: 16 additions & 3 deletions src/scripts/website/Keylol.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author : HCLonely
* @Date : 2021-11-15 13:58:41
* @LastEditTime : 2022-01-20 17:37:21
* @LastEditTime : 2022-01-29 09:56:30
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/src/scripts/website/Keylol.ts
* @Description : https://keylol.com/f319-1
Expand Down Expand Up @@ -65,9 +65,12 @@ class Keylol extends Website {
];

static test() {
return window.location.host === 'keylol.com' && !!$('.subforum_left_title_left_up a').eq(3)
return window.location.host === 'keylol.com' && (!!$('.subforum_left_title_left_up a').eq(3)
.attr('href')
?.includes('319');
?.includes('319') ||
!!$('.subforum_left_title_left_up a').eq(3)
.attr('href')
?.includes('234'));
}
init() {
return true;
Expand Down Expand Up @@ -197,6 +200,16 @@ class Keylol extends Website {
.next()[0], 'steam', 'licenseLinks', `appid-${link.replace('#asf', '')}`);
}
}
const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]');
if (subLinks.length > 0) {
for (const subLink of subLinks) {
const link = $(subLink).attr('href');
if (!link) continue;
const subid = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)?.[1];
if (!subid) continue;
this.#addBtn(subLink, 'steam', 'licenseLinks', `subid-${subid}`);
}
}
const asfLinks2 = mainPost.find('.blockcode:contains("addlicense")');
if (asfLinks2.length > 0) {
for (const asfLink of asfLinks2) {
Expand Down

1 comment on commit c33817d

@vercel
Copy link

@vercel vercel bot commented on c33817d Jan 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.