Skip to content

Commit

Permalink
优化:twitch完整性检查
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Jan 19, 2023
1 parent 9d2f458 commit ddfa8c9
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
uses: softprops/action-gh-release@v1
with:
prerelease: false
tag_name: v4.2.30
name: 4.2.30
body: '- 优化:当 Discord 服务器任务全部设置为''false''时不再弹出相关提醒'
tag_name: v4.2.31
name: 4.2.31
body: '- 优化:twitch完整性检查'
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.

19 changes: 12 additions & 7 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.2.30
// @version 4.2.31
// @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 @@ -2584,7 +2584,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
return false;
}
const isVerified = await this.#verifyAuth();
const isVerified = await this.#verifyAuth(true);
if (isVerified) {
scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
this.#initialized = true;
Expand All @@ -2603,7 +2603,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
return false;
}
}
async #verifyAuth() {
async #verifyAuth(isFirst) {
try {
const logStatus = scripts_echoLog({
text: i18n('verifyingAuth', 'Twitch')
Expand All @@ -2626,7 +2626,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (result === 'Success') {
var _data$response, _data$response$, _data$response$$data;
if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response = data.response) !== null && _data$response !== void 0 && (_data$response$ = _data$response[0]) !== null && _data$response$ !== void 0 && (_data$response$$data = _data$response$.data) !== null && _data$response$$data !== void 0 && _data$response$$data.currentUser) {
await this.#integrity();
await this.#integrity(isFirst);
logStatus.success();
return true;
}
Expand All @@ -2641,11 +2641,15 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
async #integrity() {
let ct = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
let ct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
try {
const logStatus = scripts_echoLog({
text: i18n('checkingTwitchIntegrity')
});
if (isFirst && (!this.#auth.authToken || !this.#auth.clientId || !this.#auth.clientVersion || !this.#auth.deviceId || !this.#auth.clientSessionId)) {
return await this.#updateAuth(false);
}
const {
result,
statusText,
Expand All @@ -2670,7 +2674,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (result === 'Success') {
var _data$responseHeaders, _data$response2;
if (!ct && data !== null && data !== void 0 && (_data$responseHeaders = data.responseHeaders) !== null && _data$responseHeaders !== void 0 && _data$responseHeaders['x-kpsdk-ct']) {
return await this.#integrity(data.responseHeaders['x-kpsdk-ct']);
return await this.#integrity(isFirst, data.responseHeaders['x-kpsdk-ct']);
}
if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.token) {
this.#integrityToken = data.response.token;
Expand All @@ -2688,6 +2692,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
async #updateAuth() {
let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
try {
const logStatus = scripts_echoLog({
text: i18n('updatingAuth', 'Twitch')
Expand All @@ -2703,7 +2708,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (auth) {
this.#auth = auth;
logStatus.success();
resolve(await this.#verifyAuth());
resolve(await this.#verifyAuth(isFirst));
} else {
logStatus.error('Error: Update twitch auth failed!');
resolve(false);
Expand Down
4 changes: 2 additions & 2 deletions dist/auto-task-v4.compatibility.all.user.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

19 changes: 12 additions & 7 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.2.30
// @version 4.2.31
// @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 @@ -2565,7 +2565,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
return false;
}
const isVerified = await this.#verifyAuth();
const isVerified = await this.#verifyAuth(true);
if (isVerified) {
scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
this.#initialized = true;
Expand All @@ -2584,7 +2584,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
return false;
}
}
async #verifyAuth() {
async #verifyAuth(isFirst) {
try {
const logStatus = scripts_echoLog({
text: i18n('verifyingAuth', 'Twitch')
Expand All @@ -2607,7 +2607,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (result === 'Success') {
var _data$response, _data$response$, _data$response$$data;
if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response = data.response) !== null && _data$response !== void 0 && (_data$response$ = _data$response[0]) !== null && _data$response$ !== void 0 && (_data$response$$data = _data$response$.data) !== null && _data$response$$data !== void 0 && _data$response$$data.currentUser) {
await this.#integrity();
await this.#integrity(isFirst);
logStatus.success();
return true;
}
Expand All @@ -2622,11 +2622,15 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
async #integrity() {
let ct = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
let ct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
try {
const logStatus = scripts_echoLog({
text: i18n('checkingTwitchIntegrity')
});
if (isFirst && (!this.#auth.authToken || !this.#auth.clientId || !this.#auth.clientVersion || !this.#auth.deviceId || !this.#auth.clientSessionId)) {
return await this.#updateAuth(false);
}
const {
result,
statusText,
Expand All @@ -2651,7 +2655,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (result === 'Success') {
var _data$responseHeaders, _data$response2;
if (!ct && data !== null && data !== void 0 && (_data$responseHeaders = data.responseHeaders) !== null && _data$responseHeaders !== void 0 && _data$responseHeaders['x-kpsdk-ct']) {
return await this.#integrity(data.responseHeaders['x-kpsdk-ct']);
return await this.#integrity(isFirst, data.responseHeaders['x-kpsdk-ct']);
}
if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.token) {
this.#integrityToken = data.response.token;
Expand All @@ -2669,6 +2673,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
async #updateAuth() {
let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
try {
const logStatus = scripts_echoLog({
text: i18n('updatingAuth', 'Twitch')
Expand All @@ -2684,7 +2689,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (auth) {
this.#auth = auth;
logStatus.success();
resolve(await this.#verifyAuth());
resolve(await this.#verifyAuth(isFirst));
} else {
logStatus.error('Error: Update twitch auth failed!');
resolve(false);
Expand Down
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.2

### V4.2.31

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

- 优化:twitch完整性检查

### V4.2.30

[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.2.30)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "auto-task-v4",
"version": "4.2.30",
"version": "4.2.31",
"change": [
"优化:当 Discord 服务器任务全部设置为'false'时不再弹出相关提醒"
"优化:twitch完整性检查"
],
"description": "赠Key站自动任务脚本",
"main": "package.json",
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.

19 changes: 12 additions & 7 deletions page/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.2.30
// @version 4.2.31
// @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 @@ -2584,7 +2584,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
return false;
}
const isVerified = await this.#verifyAuth();
const isVerified = await this.#verifyAuth(true);
if (isVerified) {
scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
this.#initialized = true;
Expand All @@ -2603,7 +2603,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
return false;
}
}
async #verifyAuth() {
async #verifyAuth(isFirst) {
try {
const logStatus = scripts_echoLog({
text: i18n('verifyingAuth', 'Twitch')
Expand All @@ -2626,7 +2626,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (result === 'Success') {
var _data$response, _data$response$, _data$response$$data;
if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response = data.response) !== null && _data$response !== void 0 && (_data$response$ = _data$response[0]) !== null && _data$response$ !== void 0 && (_data$response$$data = _data$response$.data) !== null && _data$response$$data !== void 0 && _data$response$$data.currentUser) {
await this.#integrity();
await this.#integrity(isFirst);
logStatus.success();
return true;
}
Expand All @@ -2641,11 +2641,15 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
async #integrity() {
let ct = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
let ct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
try {
const logStatus = scripts_echoLog({
text: i18n('checkingTwitchIntegrity')
});
if (isFirst && (!this.#auth.authToken || !this.#auth.clientId || !this.#auth.clientVersion || !this.#auth.deviceId || !this.#auth.clientSessionId)) {
return await this.#updateAuth(false);
}
const {
result,
statusText,
Expand All @@ -2670,7 +2674,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (result === 'Success') {
var _data$responseHeaders, _data$response2;
if (!ct && data !== null && data !== void 0 && (_data$responseHeaders = data.responseHeaders) !== null && _data$responseHeaders !== void 0 && _data$responseHeaders['x-kpsdk-ct']) {
return await this.#integrity(data.responseHeaders['x-kpsdk-ct']);
return await this.#integrity(isFirst, data.responseHeaders['x-kpsdk-ct']);
}
if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.token) {
this.#integrityToken = data.response.token;
Expand All @@ -2688,6 +2692,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
async #updateAuth() {
let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
try {
const logStatus = scripts_echoLog({
text: i18n('updatingAuth', 'Twitch')
Expand All @@ -2703,7 +2708,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (auth) {
this.#auth = auth;
logStatus.success();
resolve(await this.#verifyAuth());
resolve(await this.#verifyAuth(isFirst));
} else {
logStatus.error('Error: Update twitch auth failed!');
resolve(false);
Expand Down
4 changes: 2 additions & 2 deletions page/dist/auto-task-v4.compatibility.all.user.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

19 changes: 12 additions & 7 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.2.30
// @version 4.2.31
// @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 @@ -2565,7 +2565,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
return false;
}
const isVerified = await this.#verifyAuth();
const isVerified = await this.#verifyAuth(true);
if (isVerified) {
scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
this.#initialized = true;
Expand All @@ -2584,7 +2584,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
return false;
}
}
async #verifyAuth() {
async #verifyAuth(isFirst) {
try {
const logStatus = scripts_echoLog({
text: i18n('verifyingAuth', 'Twitch')
Expand All @@ -2607,7 +2607,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (result === 'Success') {
var _data$response, _data$response$, _data$response$$data;
if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response = data.response) !== null && _data$response !== void 0 && (_data$response$ = _data$response[0]) !== null && _data$response$ !== void 0 && (_data$response$$data = _data$response$.data) !== null && _data$response$$data !== void 0 && _data$response$$data.currentUser) {
await this.#integrity();
await this.#integrity(isFirst);
logStatus.success();
return true;
}
Expand All @@ -2622,11 +2622,15 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
async #integrity() {
let ct = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
let ct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
try {
const logStatus = scripts_echoLog({
text: i18n('checkingTwitchIntegrity')
});
if (isFirst && (!this.#auth.authToken || !this.#auth.clientId || !this.#auth.clientVersion || !this.#auth.deviceId || !this.#auth.clientSessionId)) {
return await this.#updateAuth(false);
}
const {
result,
statusText,
Expand All @@ -2651,7 +2655,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (result === 'Success') {
var _data$responseHeaders, _data$response2;
if (!ct && data !== null && data !== void 0 && (_data$responseHeaders = data.responseHeaders) !== null && _data$responseHeaders !== void 0 && _data$responseHeaders['x-kpsdk-ct']) {
return await this.#integrity(data.responseHeaders['x-kpsdk-ct']);
return await this.#integrity(isFirst, data.responseHeaders['x-kpsdk-ct']);
}
if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.token) {
this.#integrityToken = data.response.token;
Expand All @@ -2669,6 +2673,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
}
async #updateAuth() {
let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
try {
const logStatus = scripts_echoLog({
text: i18n('updatingAuth', 'Twitch')
Expand All @@ -2684,7 +2689,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (auth) {
this.#auth = auth;
logStatus.success();
resolve(await this.#verifyAuth());
resolve(await this.#verifyAuth(isFirst));
} else {
logStatus.error('Error: Update twitch auth failed!');
resolve(false);
Expand Down
4 changes: 2 additions & 2 deletions page/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "auto-task-v4",
"version": "4.2.30",
"version": "4.2.31",
"change": [
"优化:当 Discord 服务器任务全部设置为'false'时不再弹出相关提醒"
"优化:twitch完整性检查"
],
"description": "赠Key站自动任务脚本",
"main": "package.json",
Expand Down
Loading

1 comment on commit ddfa8c9

@vercel
Copy link

@vercel vercel bot commented on ddfa8c9 Jan 19, 2023

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.