Skip to content

Commit

Permalink
1. 避免GiveawaySu得到0000Key, 自动隐藏Grab
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Jan 7, 2022
1 parent e2ef763 commit ab996b3
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 36 deletions.
4 changes: 2 additions & 2 deletions dist/auto-task-v4-for-giveawaysu.user.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

38 changes: 34 additions & 4 deletions dist/auto-task-v4.user.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "auto-task-new",
"version": "4.1.5-Beta",
"version": "4.1.6-Beta",
"change": [
"反馈功能优化",
"样式优化",
"修复已知BUG"
"避免GiveawaySu得到0000Key, 自动隐藏\"Grab key\"按钮",
"更新检测优化"
],
"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.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions page/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "auto-task-new",
"version": "4.1.5-Beta",
"version": "4.1.6-Beta",
"change": [
"反馈功能优化",
"样式优化",
"修复已知BUG"
"避免GiveawaySu得到0000Key",
"更新检测优化"
],
"description": "赠Key站自动任务脚本",
"main": "package.json",
Expand Down
6 changes: 5 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-06 12:10:48
* @LastEditTime : 2022-01-07 10:09:45
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/src/locales/en-US.js
* @Description : i18n英文
Expand Down Expand Up @@ -276,6 +276,10 @@ const data = {
gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',

// GiveawaySu
gsNotice: 'In order to avoid getting the "0000-0000-0000" key, the "Grab Key" button has been hidden,' +
' please close the script when obtaining the key!',

// SweepWidget
SweepWidgetNotice: 'The task is being processed and verified. ' +
'There is an interval of 1~3s for each verification task to prevent the triggering of too fast verification warning...'
Expand Down
5 changes: 4 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-06 12:10:11
* @LastEditTime : 2022-01-07 10:03:36
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/src/locales/zh-CN.js
* @Description : i18n中文
Expand Down Expand Up @@ -262,6 +262,9 @@ const data = {
gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',

// GiveawaySu
gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',

// SweepWidget
SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
};
Expand Down
33 changes: 30 additions & 3 deletions src/scripts/updateChecker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author : HCLonely
* @Date : 2021-12-30 14:20:30
* @LastEditTime : 2022-01-03 15:28:20
* @LastEditTime : 2022-01-07 09:59:57
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/src/scripts/updateChecker.ts
* @Description : 更新检测
Expand All @@ -20,7 +20,7 @@ interface packageJson {
}
const checkUpdate = async (updateLink:string, auto: boolean): Promise<false | packageJson> => {
try {
const checkUrl = `${updateLink}package.json`;
const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
const { result, statusText, status, data } = await httpRequest({
url: checkUrl,
responseType: 'json',
Expand All @@ -46,6 +46,33 @@ const checkUpdate = async (updateLink:string, auto: boolean): Promise<false | pa
return false;
}
};
const hasNewVersion = (currentVersion: string, remoteVersion: string): boolean => {
try {
const [currentRealVersion] = currentVersion.split('-');
const [remoteRealVersion] = remoteVersion.split('-');
const [currentVersion1, currentVersion2, currentVersion3] = currentRealVersion.split('.').map((value) => parseInt(value, 10));
const [remoteVersion1, remoteVersion2, remoteVersion3] = remoteRealVersion.split('.').map((value) => parseInt(value, 10));
if (remoteVersion1 > currentVersion1) {
return true;
}
if (remoteVersion1 < currentVersion1) {
return false;
}
if (remoteVersion2 > currentVersion2) {
return true;
}
if (remoteVersion2 < currentVersion2) {
return false;
}
if (remoteVersion3 > currentVersion3) {
return true;
}
return false;
} catch (error) {
throwError(error as Error, 'compareVersion');
return false;
}
};
const updateChecker = async () => {
try {
const currentVersion = GM_info.script.version;
Expand Down Expand Up @@ -80,7 +107,7 @@ const updateChecker = async () => {
version = currentVersion;
echoLog({}).error(__('checkUpdateFailed'));
}
if (packageData && version !== currentVersion) {
if (packageData && hasNewVersion(currentVersion, version)) {
echoLog({ html: `<li><font>${__('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>` });
echoLog({ html: `<li>${__('updateText', version)}</li><ol class="update-text">${
packageData.change?.map((change) => `<li>${change}</li>`).join('')}</ol>` });
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/website/Giveawaysu.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author : HCLonely
* @Date : 2021-11-08 10:37:13
* @LastEditTime : 2022-01-02 11:07:58
* @LastEditTime : 2022-01-07 10:04:58
* @LastEditors : HCLonely
* @FilePath : /auto-task-new/src/scripts/website/Giveawaysu.ts
* @Description : https://giveaway.su/
Expand Down Expand Up @@ -70,6 +70,7 @@ class GiveawaySu extends Website {
if (!await this.#checkLeftKey()) {
echoLog({}).warning(__('checkLeftKeyFailed'));
}
echoLog({}).warning(__('gsNotice'));
} catch (error) {
throwError(error as Error, 'Giveawaysu.after');
}
Expand Down
5 changes: 5 additions & 0 deletions src/style/auto-task.scss
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,8 @@ body.auto-task-history {
margin: 0 .4em;
}
}

/* 避免GiveawaySu得到0000Key, 隐藏"Grab key"按钮 */
.giveaway-actions #getKey {
display: none !important;
}

1 comment on commit ab996b3

@vercel
Copy link

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