Skip to content

Commit

Permalink
初始化逻辑优化, Discord获取凭证逻辑优化
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Jan 17, 2022
1 parent 6a364eb commit adbce0a
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 76 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Release
'on': workflow_dispatch
'on':
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
Expand All @@ -15,9 +18,11 @@ jobs:
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: v4.1.13-beta
name: 4.1.13-beta
body: '- 部分功能优化'
tag_name: v4.1.14-beta
name: 4.1.14-beta
body: |-
- 初始化逻辑优化
- Discord获取凭证逻辑优化
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.user.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions dist/auto-task-v4.compatibility.user.js

Large diffs are not rendered by default.

37 changes: 23 additions & 14 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.13-beta
// @version 4.1.14-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 @@ -1323,6 +1323,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
joiningDiscordServer: '正在加入Discord服务器',
leavingDiscordServer: '正在退出Discord服务器',
gettingDiscordGuild: '正在获取Discord服务器Id',
getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
users: '用户',
loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
insBanned: '您的Instagram账户已被封禁',
Expand Down Expand Up @@ -1567,6 +1568,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
joiningDiscordServer: 'Joining Discord Server',
leavingDiscordServer: 'Leaving Discord Server',
gettingDiscordGuild: 'Getting Discord server Id',
getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
users: 'User',
loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
insBanned: 'Your Instagram account has been banned',
Expand Down Expand Up @@ -6171,49 +6173,49 @@ ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\
const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
if (tasks.discord) {
const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasDiscord && !this.socialInitialized.discord && !this.social.discord) {
if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
this.social.discord = new social_Discord();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
}
}
if (tasks.instagram) {
const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasInstagram && !this.socialInitialized.instagram && !this.social.instagram) {
if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
this.social.instagram = new social_Instagram();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
}
}
if (tasks.reddit) {
const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasReddit && !this.socialInitialized.reddit && !this.social.reddit) {
if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
this.social.reddit = new social_Reddit();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
}
}
if (tasks.twitch) {
const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasTwitch && !this.socialInitialized.twitch && !this.social.twitch) {
if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
this.social.twitch = new social_Twitch();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
}
}
if (tasks.twitter) {
const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasTwitter && !this.socialInitialized.twitter && !this.social.twitter) {
if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
this.social.twitter = new social_Twitter();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
}
}
if (tasks.vk) {
const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasVk && !this.socialInitialized.vk && !this.social.vk) {
if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
this.social.vk = new social_Vk();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
}
}
if (tasks.youtube) {
const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasYoutube && !this.socialInitialized.youtube && !this.social.youtube) {
if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
this.social.youtube = new Youtube();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
}
Expand Down Expand Up @@ -10467,12 +10469,19 @@ ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\
if (window.location.hostname === 'discord.com') {
var _window$localStorage, _window$localStorage$;
const discordAuth = (_window$localStorage = window.localStorage) === null || _window$localStorage === void 0 ? void 0 : (_window$localStorage$ = _window$localStorage.getItem('token')) === null || _window$localStorage$ === void 0 ? void 0 : _window$localStorage$.replace(/^"|"$/g, '');
GM_setValue('discordAuth', {
auth: discordAuth
});
if (discordAuth && window.location.hash === '#auth') {
window.close();
external_Swal_default().fire('', i18n('closePageNotice'));
if (discordAuth && /^mfa\./.test(discordAuth)) {
GM_setValue('discordAuth', {
auth: discordAuth
});
if (window.location.hash === '#auth') {
window.close();
external_Swal_default().fire('', i18n('closePageNotice'));
}
} else {
external_Swal_default().fire({
text: i18n('getDiscordAuthFailed'),
icon: 'error'
});
}
}
const loadScript = async () => {
Expand Down
7 changes: 7 additions & 0 deletions doc/docs/logs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ lang: zh-CN

## V4.1

### V4.1.14-beta

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

- 初始化逻辑优化
- Discord获取凭证逻辑优化

### V4.1.13-beta

[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.1.13-beta)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "auto-task-v4",
"version": "4.1.13-beta",
"version": "4.1.14-beta",
"change": [
"部分功能优化"
"初始化逻辑优化",
"Discord获取凭证逻辑优化"
],
"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.

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

Large diffs are not rendered by default.

37 changes: 23 additions & 14 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.13-beta
// @version 4.1.14-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 @@ -1323,6 +1323,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
joiningDiscordServer: '正在加入Discord服务器',
leavingDiscordServer: '正在退出Discord服务器',
gettingDiscordGuild: '正在获取Discord服务器Id',
getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
users: '用户',
loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
insBanned: '您的Instagram账户已被封禁',
Expand Down Expand Up @@ -1567,6 +1568,7 @@ console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
joiningDiscordServer: 'Joining Discord Server',
leavingDiscordServer: 'Leaving Discord Server',
gettingDiscordGuild: 'Getting Discord server Id',
getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
users: 'User',
loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
insBanned: 'Your Instagram account has been banned',
Expand Down Expand Up @@ -6171,49 +6173,49 @@ ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\
const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
if (tasks.discord) {
const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasDiscord && !this.socialInitialized.discord && !this.social.discord) {
if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
this.social.discord = new social_Discord();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
}
}
if (tasks.instagram) {
const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasInstagram && !this.socialInitialized.instagram && !this.social.instagram) {
if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
this.social.instagram = new social_Instagram();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
}
}
if (tasks.reddit) {
const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasReddit && !this.socialInitialized.reddit && !this.social.reddit) {
if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
this.social.reddit = new social_Reddit();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
}
}
if (tasks.twitch) {
const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasTwitch && !this.socialInitialized.twitch && !this.social.twitch) {
if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
this.social.twitch = new social_Twitch();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
}
}
if (tasks.twitter) {
const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasTwitter && !this.socialInitialized.twitter && !this.social.twitter) {
if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
this.social.twitter = new social_Twitter();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
}
}
if (tasks.vk) {
const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasVk && !this.socialInitialized.vk && !this.social.vk) {
if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
this.social.vk = new social_Vk();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
}
}
if (tasks.youtube) {
const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
if (hasYoutube && !this.socialInitialized.youtube && !this.social.youtube) {
if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
this.social.youtube = new Youtube();
pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
}
Expand Down Expand Up @@ -10467,12 +10469,19 @@ ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\
if (window.location.hostname === 'discord.com') {
var _window$localStorage, _window$localStorage$;
const discordAuth = (_window$localStorage = window.localStorage) === null || _window$localStorage === void 0 ? void 0 : (_window$localStorage$ = _window$localStorage.getItem('token')) === null || _window$localStorage$ === void 0 ? void 0 : _window$localStorage$.replace(/^"|"$/g, '');
GM_setValue('discordAuth', {
auth: discordAuth
});
if (discordAuth && window.location.hash === '#auth') {
window.close();
external_Swal_default().fire('', i18n('closePageNotice'));
if (discordAuth && /^mfa\./.test(discordAuth)) {
GM_setValue('discordAuth', {
auth: discordAuth
});
if (window.location.hash === '#auth') {
window.close();
external_Swal_default().fire('', i18n('closePageNotice'));
}
} else {
external_Swal_default().fire({
text: i18n('getDiscordAuthFailed'),
icon: 'error'
});
}
}
const loadScript = async () => {
Expand Down
5 changes: 3 additions & 2 deletions page/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "auto-task-v4",
"version": "4.1.13-beta",
"version": "4.1.14-beta",
"change": [
"部分功能优化"
"初始化逻辑优化",
"Discord获取凭证逻辑优化"
],
"description": "赠Key站自动任务脚本",
"main": "package.json",
Expand Down
7 changes: 6 additions & 1 deletion release.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author : HCLonely
* @Date : 2022-01-16 19:03:01
* @LastEditTime : 2022-01-16 19:46:57
* @LastEditTime : 2022-01-17 11:04:05
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/release.js
* @Description : 自动发布Release
Expand Down Expand Up @@ -31,6 +31,11 @@ if (version === releaseStep.with.name) {
console.log(`Version ${chalk.yellow.bold('not be changed')}!`);
return console.log(`Release action changed ${chalk.green.bold('successfully')}!`);
}
settings.on = {
push: {
branches: ['main']
}
};
options.prerelease = version.includes('-');
options.tag_name = `v${version}`;
options.name = version;
Expand Down
17 changes: 12 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author : HCLonely
* @Date : 2021-10-26 15:44:54
* @LastEditTime : 2022-01-16 13:42:04
* @LastEditTime : 2022-01-17 10:45:01
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/src/index.ts
* @Description : 入口文件
Expand Down Expand Up @@ -30,10 +30,17 @@ declare const commonOptions: {

if (window.location.hostname === 'discord.com') {
const discordAuth = window.localStorage?.getItem('token')?.replace(/^"|"$/g, '');
GM_setValue('discordAuth', { auth: discordAuth });
if (discordAuth && window.location.hash === '#auth') {
window.close();
Swal.fire('', __('closePageNotice'));
if (discordAuth && /^mfa\./.test(discordAuth)) {
GM_setValue('discordAuth', { auth: discordAuth });
if (window.location.hash === '#auth') {
window.close();
Swal.fire('', __('closePageNotice'));
}
} else {
Swal.fire({
text: __('getDiscordAuthFailed'),
icon: 'error'
});
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/locales/en-US.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author : HCLonely
* @Date : 2021-12-30 17:08:27
* @LastEditTime : 2022-01-13 11:50:06
* @LastEditTime : 2022-01-17 10:46:18
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/src/locales/en-US.js
* @Description : i18n英文
Expand Down Expand Up @@ -216,6 +216,7 @@ const data = {
joiningDiscordServer: 'Joining Discord Server',
leavingDiscordServer: 'Leaving Discord Server',
gettingDiscordGuild: 'Getting Discord server Id',
getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',

// Instagram
users: 'User',
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh-CN.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author : HCLonely
* @Date : 2021-11-20 19:38:41
* @LastEditTime : 2022-01-13 11:49:47
* @LastEditTime : 2022-01-17 10:44:54
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/src/locales/zh-CN.js
* @Description : i18n中文
Expand Down Expand Up @@ -200,6 +200,7 @@ const data = {
joiningDiscordServer: '正在加入Discord服务器',
leavingDiscordServer: '正在退出Discord服务器',
gettingDiscordGuild: '正在获取Discord服务器Id',
getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',

// Instagram
users: '用户',
Expand Down
Loading

1 comment on commit adbce0a

@vercel
Copy link

@vercel vercel bot commented on adbce0a Jan 17, 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.