Skip to content

Commit b783152

Browse files
committed
修复:Tampermonkey更新导致Steam凭证刷新失败(#16)
1 parent 584da46 commit b783152

18 files changed

+338
-118
lines changed

.github/workflows/Release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
uses: softprops/action-gh-release@v1
2222
with:
2323
prerelease: false
24-
tag_name: v4.3.3
25-
name: 4.3.3
26-
body: '- 移除:Opquests验证任务功能(#17)'
24+
tag_name: v4.4.2
25+
name: 4.4.2
26+
body: '- 修复:Tampermonkey更新导致Steam凭证刷新失败(#16)'
2727
files: |-
2828
dist/auto-task-v4-for-giveawaysu.user.js
2929
dist/auto-task-v4.compatibility.user.js

dist/auto-task-v4-for-giveawaysu.all.user.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/auto-task-v4-for-giveawaysu.user.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/auto-task-v4.all.user.js

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name auto-task-v4
33
// @namespace auto-task-v4
4-
// @version 4.3.3
4+
// @version 4.4.2
55
// @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
66
// @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
77
// @author HCLonely
@@ -4589,13 +4589,17 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
45894589
return false;
45904590
}
45914591
}
4592-
async #refreshStoreToken() {
4592+
async #refreshToken(type = 'steamStore') {
45934593
try {
4594+
const host = {
4595+
steamStore: 'store.steampowered.com',
4596+
steamCommunity: 'steamcommunity.com'
4597+
};
45944598
const logStatus = scripts_echoLog({
4595-
text: i18n('refreshingToken', i18n('steamStore'))
4599+
text: i18n('refreshingToken', i18n(type))
45964600
});
45974601
const formData = new FormData();
4598-
formData.append('redir', 'https://store.steampowered.com/');
4602+
formData.append('redir', `https://${host[type]}/`);
45994603
const {
46004604
result,
46014605
statusText,
@@ -4607,14 +4611,14 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46074611
responseType: 'json',
46084612
headers: {
46094613
Host: 'login.steampowered.com',
4610-
Origin: 'https://store.steampowered.com',
4611-
Referer: 'https://store.steampowered.com/'
4614+
Origin: `https://${host[type]}`,
4615+
Referer: `https://${host[type]}/`
46124616
},
46134617
data: formData
46144618
});
46154619
if (result === 'Success') {
46164620
if (data?.response?.success) {
4617-
if (await this.#setStoreToken(data.response)) {
4621+
if (await this.#setStoreToken(data.response, type)) {
46184622
logStatus.success();
46194623
return true;
46204624
}
@@ -4627,14 +4631,18 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46274631
logStatus.error(`${result}:${statusText}(${status})`);
46284632
return false;
46294633
} catch (error) {
4630-
throwError(error, 'Steam.refreshStoreToken');
4634+
throwError(error, 'Steam.refreshToken');
46314635
return false;
46324636
}
46334637
}
4634-
async #setStoreToken(param) {
4638+
async #setStoreToken(param, type) {
46354639
try {
4640+
const host = {
4641+
steamStore: 'store.steampowered.com',
4642+
steamCommunity: 'steamcommunity.com'
4643+
};
46364644
const logStatus = scripts_echoLog({
4637-
text: i18n('settingToken', i18n('steamStore'))
4645+
text: i18n('settingToken', i18n(type))
46384646
});
46394647
const formData = new FormData();
46404648
formData.append('steamID', param.steamID);
@@ -4647,13 +4655,12 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46474655
status,
46484656
data
46494657
} = await tools_httpRequest({
4650-
url: 'https://store.steampowered.com/login/settoken',
4658+
url: `https://${host[type]}/login/settoken`,
46514659
method: 'POST',
46524660
headers: {
46534661
Accept: 'application/json, text/plain, */*',
4654-
Host: 'store.steampowered.com',
4655-
Origin: 'https://store.steampowered.com',
4656-
Referer: 'https://store.steampowered.com/login'
4662+
Host: host[type],
4663+
Origin: `https://${host[type]}`
46574664
},
46584665
data: formData
46594666
});
@@ -4672,7 +4679,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46724679
return false;
46734680
}
46744681
}
4675-
async #updateStoreAuth() {
4682+
async #updateStoreAuth(retry = false) {
46764683
try {
46774684
const logStatus = scripts_echoLog({
46784685
text: i18n('updatingAuth', i18n('steamStore'))
@@ -4691,12 +4698,21 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46914698
'Sec-Fetch-Dest': 'document',
46924699
'Sec-Fetch-Mode': 'navigate',
46934700
'Upgrade-Insecure-Requests': '1'
4694-
}
4701+
},
4702+
fetch: false,
4703+
redirect: 'manual'
46954704
});
46964705
if (result === 'Success') {
46974706
if (data?.status === 200) {
46984707
if (!data.responseText.includes('data-miniprofile=')) {
4699-
await this.#refreshStoreToken();
4708+
if (await this.#refreshToken('steamStore')) {
4709+
logStatus.warning(i18n('retry'));
4710+
if (retry) {
4711+
logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
4712+
return false;
4713+
}
4714+
return this.#updateStoreAuth(true);
4715+
}
47004716
logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
47014717
return false;
47024718
}
@@ -4712,14 +4728,26 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
47124728
logStatus.error(`Error:${data?.statusText}(${data?.status})`);
47134729
return false;
47144730
}
4731+
if (data?.status === 302) {
4732+
if (await this.#refreshToken('steamStore')) {
4733+
logStatus.warning(i18n('retry'));
4734+
if (retry) {
4735+
logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
4736+
return false;
4737+
}
4738+
return this.#updateStoreAuth(true);
4739+
}
4740+
logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
4741+
return false;
4742+
}
47154743
logStatus.error(`${result}:${statusText}(${status})`);
47164744
return false;
47174745
} catch (error) {
47184746
throwError(error, 'Steam.updateStoreAuth');
47194747
return false;
47204748
}
47214749
}
4722-
async #updateCommunityAuth() {
4750+
async #updateCommunityAuth(retry = false) {
47234751
try {
47244752
const logStatus = scripts_echoLog({
47254753
text: i18n('updatingAuth', i18n('steamCommunity'))
@@ -4738,7 +4766,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
47384766
'Sec-Fetch-Dest': 'document',
47394767
'Sec-Fetch-Mode': 'navigate',
47404768
'Upgrade-Insecure-Requests': '1'
4741-
}
4769+
},
4770+
fetch: false,
4771+
redirect: 'manual'
47424772
});
47434773
if (result === 'Success') {
47444774
if (data?.status === 200) {
@@ -4766,6 +4796,18 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
47664796
logStatus.error(`Error:${data?.statusText}(${data?.status})`);
47674797
return false;
47684798
}
4799+
if (data?.status === 302) {
4800+
if (await this.#refreshToken('steamCommunity')) {
4801+
logStatus.warning(i18n('retry'));
4802+
if (retry) {
4803+
logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
4804+
return false;
4805+
}
4806+
return this.#updateCommunityAuth(true);
4807+
}
4808+
logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
4809+
return false;
4810+
}
47694811
logStatus.error(`${result}:${statusText}(${status})`);
47704812
return false;
47714813
} catch (error) {

dist/auto-task-v4.compatibility.all.user.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/auto-task-v4.compatibility.user.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/auto-task-v4.user.js

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name auto-task-v4
33
// @namespace auto-task-v4
4-
// @version 4.3.3
4+
// @version 4.4.2
55
// @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
66
// @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
77
// @author HCLonely
@@ -4570,13 +4570,17 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
45704570
return false;
45714571
}
45724572
}
4573-
async #refreshStoreToken() {
4573+
async #refreshToken(type = 'steamStore') {
45744574
try {
4575+
const host = {
4576+
steamStore: 'store.steampowered.com',
4577+
steamCommunity: 'steamcommunity.com'
4578+
};
45754579
const logStatus = scripts_echoLog({
4576-
text: i18n('refreshingToken', i18n('steamStore'))
4580+
text: i18n('refreshingToken', i18n(type))
45774581
});
45784582
const formData = new FormData();
4579-
formData.append('redir', 'https://store.steampowered.com/');
4583+
formData.append('redir', `https://${host[type]}/`);
45804584
const {
45814585
result,
45824586
statusText,
@@ -4588,14 +4592,14 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
45884592
responseType: 'json',
45894593
headers: {
45904594
Host: 'login.steampowered.com',
4591-
Origin: 'https://store.steampowered.com',
4592-
Referer: 'https://store.steampowered.com/'
4595+
Origin: `https://${host[type]}`,
4596+
Referer: `https://${host[type]}/`
45934597
},
45944598
data: formData
45954599
});
45964600
if (result === 'Success') {
45974601
if (data?.response?.success) {
4598-
if (await this.#setStoreToken(data.response)) {
4602+
if (await this.#setStoreToken(data.response, type)) {
45994603
logStatus.success();
46004604
return true;
46014605
}
@@ -4608,14 +4612,18 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46084612
logStatus.error(`${result}:${statusText}(${status})`);
46094613
return false;
46104614
} catch (error) {
4611-
throwError(error, 'Steam.refreshStoreToken');
4615+
throwError(error, 'Steam.refreshToken');
46124616
return false;
46134617
}
46144618
}
4615-
async #setStoreToken(param) {
4619+
async #setStoreToken(param, type) {
46164620
try {
4621+
const host = {
4622+
steamStore: 'store.steampowered.com',
4623+
steamCommunity: 'steamcommunity.com'
4624+
};
46174625
const logStatus = scripts_echoLog({
4618-
text: i18n('settingToken', i18n('steamStore'))
4626+
text: i18n('settingToken', i18n(type))
46194627
});
46204628
const formData = new FormData();
46214629
formData.append('steamID', param.steamID);
@@ -4628,13 +4636,12 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46284636
status,
46294637
data
46304638
} = await tools_httpRequest({
4631-
url: 'https://store.steampowered.com/login/settoken',
4639+
url: `https://${host[type]}/login/settoken`,
46324640
method: 'POST',
46334641
headers: {
46344642
Accept: 'application/json, text/plain, */*',
4635-
Host: 'store.steampowered.com',
4636-
Origin: 'https://store.steampowered.com',
4637-
Referer: 'https://store.steampowered.com/login'
4643+
Host: host[type],
4644+
Origin: `https://${host[type]}`
46384645
},
46394646
data: formData
46404647
});
@@ -4653,7 +4660,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46534660
return false;
46544661
}
46554662
}
4656-
async #updateStoreAuth() {
4663+
async #updateStoreAuth(retry = false) {
46574664
try {
46584665
const logStatus = scripts_echoLog({
46594666
text: i18n('updatingAuth', i18n('steamStore'))
@@ -4672,12 +4679,21 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46724679
'Sec-Fetch-Dest': 'document',
46734680
'Sec-Fetch-Mode': 'navigate',
46744681
'Upgrade-Insecure-Requests': '1'
4675-
}
4682+
},
4683+
fetch: false,
4684+
redirect: 'manual'
46764685
});
46774686
if (result === 'Success') {
46784687
if (data?.status === 200) {
46794688
if (!data.responseText.includes('data-miniprofile=')) {
4680-
await this.#refreshStoreToken();
4689+
if (await this.#refreshToken('steamStore')) {
4690+
logStatus.warning(i18n('retry'));
4691+
if (retry) {
4692+
logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
4693+
return false;
4694+
}
4695+
return this.#updateStoreAuth(true);
4696+
}
46814697
logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
46824698
return false;
46834699
}
@@ -4693,14 +4709,26 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
46934709
logStatus.error(`Error:${data?.statusText}(${data?.status})`);
46944710
return false;
46954711
}
4712+
if (data?.status === 302) {
4713+
if (await this.#refreshToken('steamStore')) {
4714+
logStatus.warning(i18n('retry'));
4715+
if (retry) {
4716+
logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
4717+
return false;
4718+
}
4719+
return this.#updateStoreAuth(true);
4720+
}
4721+
logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
4722+
return false;
4723+
}
46964724
logStatus.error(`${result}:${statusText}(${status})`);
46974725
return false;
46984726
} catch (error) {
46994727
throwError(error, 'Steam.updateStoreAuth');
47004728
return false;
47014729
}
47024730
}
4703-
async #updateCommunityAuth() {
4731+
async #updateCommunityAuth(retry = false) {
47044732
try {
47054733
const logStatus = scripts_echoLog({
47064734
text: i18n('updatingAuth', i18n('steamCommunity'))
@@ -4719,7 +4747,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
47194747
'Sec-Fetch-Dest': 'document',
47204748
'Sec-Fetch-Mode': 'navigate',
47214749
'Upgrade-Insecure-Requests': '1'
4722-
}
4750+
},
4751+
fetch: false,
4752+
redirect: 'manual'
47234753
});
47244754
if (result === 'Success') {
47254755
if (data?.status === 200) {
@@ -4747,6 +4777,18 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
47474777
logStatus.error(`Error:${data?.statusText}(${data?.status})`);
47484778
return false;
47494779
}
4780+
if (data?.status === 302) {
4781+
if (await this.#refreshToken('steamCommunity')) {
4782+
logStatus.warning(i18n('retry'));
4783+
if (retry) {
4784+
logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
4785+
return false;
4786+
}
4787+
return this.#updateCommunityAuth(true);
4788+
}
4789+
logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
4790+
return false;
4791+
}
47504792
logStatus.error(`${result}:${statusText}(${status})`);
47514793
return false;
47524794
} catch (error) {

doc/docs/logs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ title: 更新日志
33
lang: zh-CN
44
---
55

6+
## V4.4
7+
8+
### V4.4.2
9+
10+
[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.4.2)
11+
12+
- 修复:Steam凭证刷新失败([#16](https://github.com/HCLonely/auto-task-v4/issues/16))
13+
614
## V4.3
715

816
### V4.3.3

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "auto-task-v4",
3-
"version": "4.3.3",
3+
"version": "4.4.2",
44
"change": [
5-
"移除:Opquests验证任务功能(#17)"
5+
"修复:Tampermonkey更新导致Steam凭证刷新失败(#16)"
66
],
77
"description": "赠Key站自动任务脚本",
88
"main": "package.json",

0 commit comments

Comments
 (0)