Skip to content

Commit

Permalink
Givekey任务识别优化;修复Discord退组失败的BUG;数据同步功能优化
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Jan 26, 2022
1 parent fef869b commit 587887f
Show file tree
Hide file tree
Showing 23 changed files with 548 additions and 165 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ jobs:
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: v4.1.19-beta
name: 4.1.19-beta
body: '- 更新反馈模板'
tag_name: v4.1.20-beta
name: 4.1.20-beta
body: |-
- Givekey任务识别优化
- 修复Discord退组失败的BUG
- 数据同步功能优化
files: |-
dist/auto-task-v4-for-giveawaysu.user.js
dist/auto-task-v4.compatibility.user.js
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.history
node_modules
stats.json
6 changes: 3 additions & 3 deletions dist/auto-task-v4-for-giveawaysu.user.js

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions dist/auto-task-v4.compatibility.user.js

Large diffs are not rendered by default.

43 changes: 33 additions & 10 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.19-beta
// @version 4.1.20-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 @@ -1287,6 +1287,8 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
Banned: '已封禁',
Paused: '已暂停',
notStart: '未开始',
noRemoteData: '检测到远程无数据',
errorRemoteDataFormat: '远程数据格式错误',
groups: '组',
wishlists: '愿望单',
follows: '游戏关注',
Expand Down Expand Up @@ -1536,6 +1538,8 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
Banned: 'Banned',
Paused: 'Paused',
notStart: 'notStart',
noRemoteData: 'No data remotely',
errorRemoteDataFormat: 'Remote data has wrong format',
groups: 'Group',
wishlists: 'Wishlist',
follows: 'Follow Game',
Expand Down Expand Up @@ -1983,7 +1987,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://discord.com/api/v6/invites/${inviteId}`,
url: `https://discord.com/api/v9/invites/${inviteId}`,
method: 'POST',
dataType: 'json',
headers: {
Expand Down Expand Up @@ -2031,7 +2035,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
method: 'DELETE',
headers: {
authorization: _classPrivateFieldGet(this, _auth).auth
Expand Down Expand Up @@ -2065,12 +2069,13 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://discord.com/invite/${inviteId}`,
url: `https://discord.com/api/v9/invites/${inviteId}`,
responseType: 'json',
method: 'GET'
});
if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
var _data$responseText$ma;
const guild = (_data$responseText$ma = data.responseText.match(/https?:\/\/cdn\.discordapp\.com\/icons\/([\d]+?)\//)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
var _data$response2, _data$response2$guild;
const guild = (_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$guild = _data$response2.guild) === null || _data$response2$guild === void 0 ? void 0 : _data$response2$guild.id;
if (guild) {
logStatus.success();
_classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
Expand All @@ -2094,6 +2099,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
throwError(error, 'Discord.setCache');
}
}
unsafeWindow.Discord = Discord;
const social_Discord = Discord;
function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
Instagram_checkPrivateRedeclaration(obj, privateSet);
Expand Down Expand Up @@ -7840,7 +7846,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
if (action === 'do' && !isSuccess) {
this.undoneTasks.twitter.userLinks.push(href);
}
} else if (icon.hasClass('fa-discord')) {
} else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
this.socialTasks.discord.serverLinks.push(href);
if (action === 'do' && !isSuccess) {
this.undoneTasks.discord.serverLinks.push(href);
Expand Down Expand Up @@ -9952,7 +9958,8 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
return false;
}
};
const getGistData = async (token, gistId, fileName) => {
const getGistData = async function(token, gistId, fileName) {
let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
try {
const logStatus = scripts_echoLog({
text: i18n('gettingData')
Expand All @@ -9975,8 +9982,24 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
if (result === 'Success') {
if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
var _data$response, _data$response$files2, _data$response$files3;
const content = (_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$files2 = _data$response.files) === null || _data$response$files2 === void 0 ? void 0 : (_data$response$files3 = _data$response$files2[fileName]) === null || _data$response$files3 === void 0 ? void 0 : _data$response$files3.content;
let formatedContent;
if (!content) {
logStatus.error(`Error:${i18n('noRemoteData')}`);
return false;
}
if (test) {
logStatus.success();
return true;
}
try {
formatedContent = JSON.parse(content);
} catch (error) {
logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
return false;
}
logStatus.success();
return JSON.parse(((_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$files2 = _data$response.files) === null || _data$response$files2 === void 0 ? void 0 : (_data$response$files3 = _data$response$files2[fileName]) === null || _data$response$files3 === void 0 ? void 0 : _data$response$files3.content) || null);
return formatedContent;
}
logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
return false;
Expand Down Expand Up @@ -10020,7 +10043,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
FILE_NAME: fileName,
SYNC_HISTORY: syncHistory
});
return await getGistData(token, gistId, fileName);
return await getGistData(token, gistId, fileName, true);
},
allowOutsideClick: () => !external_Swal_default().isLoading(),
confirmButtonText: i18n('saveAndTest'),
Expand Down
38 changes: 38 additions & 0 deletions doc/docs/.vuepress/public/report.html

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions doc/docs/dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ lang: zh-CN
5. 运行`npm test`无报错
6. 提交 PR

## 目录结构
## 依赖关系图

更新中...
<a href="/report.html" target="_blank">查看原页面</a>

<iframe src="/report.html" style="width: 100%;height: 500px;"></iframe>
6 changes: 4 additions & 2 deletions doc/docs/en/dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ The content of this page is translated through Google translation. If the descri
5. Run `npm test` without error
6. Submit PR

## Directory tree
## Dependency Graph

Editting...
<a href="/report.html" target="_blank">Original page</a>

<iframe src="/report.html" style="width: 100%;height: 500px;"></iframe>
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.1

### V4.1.20-beta

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

- Givekey任务识别优化
- 修复Discord退组失败的BUG
- 数据同步功能优化

### V4.1.19-beta

[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.1.19-beta)
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"name": "auto-task-v4",
"version": "4.1.19-beta",
"version": "4.1.20-beta",
"change": [
"更新反馈模板"
"Givekey任务识别优化",
"修复Discord退组失败的BUG",
"数据同步功能优化"
],
"description": "赠Key站自动任务脚本",
"main": "package.json",
"scripts": {
"test": "eslint",
"tsc": "tsc",
"gs": "webpack --config webpack.giveawaysu.config.js",
"dev": "webpack --config webpack.config.js",
"dev": "webpack --config webpack.dev.config.js",
"analyze": "webpack-bundle-analyzer ./dist/stats.json",
"build": "webpack --config webpack.config.js && webpack --config webpack.compatibility.config.js && webpack --config webpack.giveawaysu.config.js && node copy.js && node doc-sync.js && node release.js"
},
"author": "HCLonely <h1606051253@gmail.com>",
Expand Down Expand Up @@ -44,6 +47,7 @@
"typescript": "^4.4.4",
"uglify-js": "^3.14.5",
"webpack": "^5.60.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.1",
"webpackbar": "^5.0.2"
}
Expand Down
6 changes: 3 additions & 3 deletions page/dist/auto-task-v4-for-giveawaysu.user.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

43 changes: 33 additions & 10 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.19-beta
// @version 4.1.20-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 @@ -1287,6 +1287,8 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
Banned: '已封禁',
Paused: '已暂停',
notStart: '未开始',
noRemoteData: '检测到远程无数据',
errorRemoteDataFormat: '远程数据格式错误',
groups: '组',
wishlists: '愿望单',
follows: '游戏关注',
Expand Down Expand Up @@ -1536,6 +1538,8 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
Banned: 'Banned',
Paused: 'Paused',
notStart: 'notStart',
noRemoteData: 'No data remotely',
errorRemoteDataFormat: 'Remote data has wrong format',
groups: 'Group',
wishlists: 'Wishlist',
follows: 'Follow Game',
Expand Down Expand Up @@ -1983,7 +1987,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://discord.com/api/v6/invites/${inviteId}`,
url: `https://discord.com/api/v9/invites/${inviteId}`,
method: 'POST',
dataType: 'json',
headers: {
Expand Down Expand Up @@ -2031,7 +2035,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
method: 'DELETE',
headers: {
authorization: _classPrivateFieldGet(this, _auth).auth
Expand Down Expand Up @@ -2065,12 +2069,13 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://discord.com/invite/${inviteId}`,
url: `https://discord.com/api/v9/invites/${inviteId}`,
responseType: 'json',
method: 'GET'
});
if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
var _data$responseText$ma;
const guild = (_data$responseText$ma = data.responseText.match(/https?:\/\/cdn\.discordapp\.com\/icons\/([\d]+?)\//)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
var _data$response2, _data$response2$guild;
const guild = (_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$guild = _data$response2.guild) === null || _data$response2$guild === void 0 ? void 0 : _data$response2$guild.id;
if (guild) {
logStatus.success();
_classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
Expand All @@ -2094,6 +2099,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
throwError(error, 'Discord.setCache');
}
}
unsafeWindow.Discord = Discord;
const social_Discord = Discord;
function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
Instagram_checkPrivateRedeclaration(obj, privateSet);
Expand Down Expand Up @@ -7840,7 +7846,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
if (action === 'do' && !isSuccess) {
this.undoneTasks.twitter.userLinks.push(href);
}
} else if (icon.hasClass('fa-discord')) {
} else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
this.socialTasks.discord.serverLinks.push(href);
if (action === 'do' && !isSuccess) {
this.undoneTasks.discord.serverLinks.push(href);
Expand Down Expand Up @@ -9952,7 +9958,8 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
return false;
}
};
const getGistData = async (token, gistId, fileName) => {
const getGistData = async function(token, gistId, fileName) {
let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
try {
const logStatus = scripts_echoLog({
text: i18n('gettingData')
Expand All @@ -9975,8 +9982,24 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
if (result === 'Success') {
if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
var _data$response, _data$response$files2, _data$response$files3;
const content = (_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$files2 = _data$response.files) === null || _data$response$files2 === void 0 ? void 0 : (_data$response$files3 = _data$response$files2[fileName]) === null || _data$response$files3 === void 0 ? void 0 : _data$response$files3.content;
let formatedContent;
if (!content) {
logStatus.error(`Error:${i18n('noRemoteData')}`);
return false;
}
if (test) {
logStatus.success();
return true;
}
try {
formatedContent = JSON.parse(content);
} catch (error) {
logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
return false;
}
logStatus.success();
return JSON.parse(((_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$files2 = _data$response.files) === null || _data$response$files2 === void 0 ? void 0 : (_data$response$files3 = _data$response$files2[fileName]) === null || _data$response$files3 === void 0 ? void 0 : _data$response$files3.content) || null);
return formatedContent;
}
logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
return false;
Expand Down Expand Up @@ -10020,7 +10043,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
FILE_NAME: fileName,
SYNC_HISTORY: syncHistory
});
return await getGistData(token, gistId, fileName);
return await getGistData(token, gistId, fileName, true);
},
allowOutsideClick: () => !external_Swal_default().isLoading(),
confirmButtonText: i18n('saveAndTest'),
Expand Down
10 changes: 7 additions & 3 deletions page/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"name": "auto-task-v4",
"version": "4.1.19-beta",
"version": "4.1.20-beta",
"change": [
"更新反馈模板"
"Givekey任务识别优化",
"修复Discord退组失败的BUG",
"数据同步功能优化"
],
"description": "赠Key站自动任务脚本",
"main": "package.json",
"scripts": {
"test": "eslint",
"tsc": "tsc",
"gs": "webpack --config webpack.giveawaysu.config.js",
"dev": "webpack --config webpack.config.js",
"dev": "webpack --config webpack.dev.config.js",
"analyze": "webpack-bundle-analyzer ./dist/stats.json",
"build": "webpack --config webpack.config.js && webpack --config webpack.compatibility.config.js && webpack --config webpack.giveawaysu.config.js && node copy.js && node doc-sync.js && node release.js"
},
"author": "HCLonely <h1606051253@gmail.com>",
Expand Down Expand Up @@ -44,6 +47,7 @@
"typescript": "^4.4.4",
"uglify-js": "^3.14.5",
"webpack": "^5.60.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.1",
"webpackbar": "^5.0.2"
}
Expand Down
Loading

1 comment on commit 587887f

@vercel
Copy link

@vercel vercel bot commented on 587887f Jan 26, 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.