Skip to content

Commit

Permalink
修复:Steam用户名为中文时无法更新社区凭证(#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Nov 11, 2024
1 parent 22141f0 commit 17d5c16
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 135 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.4.15
name: 4.4.15
body: '- 修复:更新Steam社区凭证问题(#26)'
tag_name: v4.4.16
name: 4.4.16
body: '- 修复:Steam用户名为中文时无法更新社区凭证(#26)'
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.

42 changes: 20 additions & 22 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.4.15
// @version 4.4.16
// @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 @@ -1380,6 +1380,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
gettingUserLink: '正在获取Steam用户社区链接...',
retry: '重试',
owned: '已拥有',
redirect: '重定向',
initingASF: '正在初始化ASF...',
servers: '服务器',
joiningDiscordServer: '正在加入Discord服务器',
Expand Down Expand Up @@ -1661,6 +1662,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
gettingUserLink: 'Getting steam user community link...',
retry: 'Retry',
owned: 'Owned',
redirect: 'Redirect',
initingASF: 'Initing ASF...',
servers: 'Server',
joiningDiscordServer: 'Joining Discord Server',
Expand Down Expand Up @@ -4813,13 +4815,13 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
});
return await new Promise(resolve => {
const newTab = window.open('https://steamcommunity.com/my', 'mozillaWindow', 'pop=1;');
GM_setValue('steamCommunityAuth', 'update');
GM_setValue('steamCommunityAuthProcess', 'update');
const listenerId = GM_addValueChangeListener('steamCommunityAuth', (key, oldValue, newValue, remote) => {
GM_deleteValue('steamCommunityAuthProcess');
GM_removeValueChangeListener(listenerId);
newTab?.close();
if (newValue && JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
this.#auth.steam64Id = newValue.steam64Id;
this.#auth.userName = newValue.userName;
this.#auth.communitySessionID = newValue.communitySessionID;
logStatus.success();
resolve(true);
Expand Down Expand Up @@ -4849,7 +4851,6 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
method: 'GET',
headers: {
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Cache-Control': 'max-age=0',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Upgrade-Insecure-Requests': '1'
Expand All @@ -4864,13 +4865,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
const steam64Id = data.responseText.match(/g_steamID = "(.+?)";/)?.[1];
const communitySessionID = data.responseText.match(/g_sessionID = "(.+?)";/)?.[1];
const userName = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)?.[1];
if (steam64Id) {
this.#auth.steam64Id = steam64Id;
}
if (userName) {
this.#auth.userName = userName;
}
if (communitySessionID) {
this.#auth.communitySessionID = communitySessionID;
logStatus.success();
Expand All @@ -4897,10 +4894,18 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
logStatus.success();
return await this.#updateCommunityAuth(location);
}
if (location?.includes('https://steamcommunity.com/login/home')) {
if (location?.includes('steamcommunity.com/login/home')) {
logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
return false;
}
if (location?.includes('steamcommunity.com/my')) {
if (retry) {
logStatus.error(`Error:${i18n('redirect')}`, true);
return false;
}
logStatus.warning(i18n('retry'));
return await this.#getUserLink(true);
}
logStatus.error(`Error: 301 (${location})`, true);
return false;
}
Expand Down Expand Up @@ -4940,13 +4945,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
const steam64Id = data.responseText.match(/g_steamID = "(.+?)";/)?.[1];
const communitySessionID = data.responseText.match(/g_sessionID = "(.+?)";/)?.[1];
const userName = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)?.[1];
if (steam64Id) {
this.#auth.steam64Id = steam64Id;
}
if (userName) {
this.#auth.userName = userName;
}
if (communitySessionID) {
this.#auth.communitySessionID = communitySessionID;
logStatus.success();
Expand Down Expand Up @@ -5193,7 +5194,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
url: `https://steamcommunity.com/profiles/${this.#auth.steam64Id}/home_process`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
Expand Down Expand Up @@ -5335,7 +5336,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
url: `https://steamcommunity.com/profiles/${this.#auth.steam64Id}/home_process`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
Expand Down Expand Up @@ -10896,7 +10897,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if ($('[data-miniprofile]').length === 0) {
return;
}
window.onbeforeunload = function(event) {
window.onbeforeunload = function() {
GM_setValue('steamStoreAuth', null);
return null;
};
Expand All @@ -10910,24 +10911,21 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
});
} else if (window.opener && window.location.host === 'steamcommunity.com') {
$(() => {
window.onbeforeunload = function(event) {
window.onbeforeunload = function() {
GM_setValue('steamCommunityAuth', null);
return null;
};
const steam64Id = document.body.innerHTML.match(/g_steamID = "(.+?)";/)?.[1];
const communitySessionID = document.body.innerHTML.match(/g_sessionID = "(.+?)";/)?.[1];
const userName = document.body.innerHTML.match(/steamcommunity.com\/id\/(.+?)\//)?.[1];
const data = {};
if (steam64Id) {
data.steam64Id = steam64Id;
}
if (userName) {
data.userName = userName;
}
if (communitySessionID) {
data.communitySessionID = communitySessionID;
GM_setValue('steamCommunityAuth', data);
if (GM_getValue('steamCommunityAuth') === 'update') {
if (GM_getValue('steamCommunityAuthProcess') === 'update') {
GM_deleteValue('steamCommunityAuthProcess');
window.close();
}
}
Expand Down
8 changes: 4 additions & 4 deletions dist/auto-task-v4.compatibility.all.user.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

42 changes: 20 additions & 22 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.4.15
// @version 4.4.16
// @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 @@ -1361,6 +1361,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
gettingUserLink: '正在获取Steam用户社区链接...',
retry: '重试',
owned: '已拥有',
redirect: '重定向',
initingASF: '正在初始化ASF...',
servers: '服务器',
joiningDiscordServer: '正在加入Discord服务器',
Expand Down Expand Up @@ -1642,6 +1643,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
gettingUserLink: 'Getting steam user community link...',
retry: 'Retry',
owned: 'Owned',
redirect: 'Redirect',
initingASF: 'Initing ASF...',
servers: 'Server',
joiningDiscordServer: 'Joining Discord Server',
Expand Down Expand Up @@ -4794,13 +4796,13 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
});
return await new Promise(resolve => {
const newTab = window.open('https://steamcommunity.com/my', 'mozillaWindow', 'pop=1;');
GM_setValue('steamCommunityAuth', 'update');
GM_setValue('steamCommunityAuthProcess', 'update');
const listenerId = GM_addValueChangeListener('steamCommunityAuth', (key, oldValue, newValue, remote) => {
GM_deleteValue('steamCommunityAuthProcess');
GM_removeValueChangeListener(listenerId);
newTab?.close();
if (newValue && JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
this.#auth.steam64Id = newValue.steam64Id;
this.#auth.userName = newValue.userName;
this.#auth.communitySessionID = newValue.communitySessionID;
logStatus.success();
resolve(true);
Expand Down Expand Up @@ -4830,7 +4832,6 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
method: 'GET',
headers: {
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Cache-Control': 'max-age=0',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Upgrade-Insecure-Requests': '1'
Expand All @@ -4845,13 +4846,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
const steam64Id = data.responseText.match(/g_steamID = "(.+?)";/)?.[1];
const communitySessionID = data.responseText.match(/g_sessionID = "(.+?)";/)?.[1];
const userName = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)?.[1];
if (steam64Id) {
this.#auth.steam64Id = steam64Id;
}
if (userName) {
this.#auth.userName = userName;
}
if (communitySessionID) {
this.#auth.communitySessionID = communitySessionID;
logStatus.success();
Expand All @@ -4878,10 +4875,18 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
logStatus.success();
return await this.#updateCommunityAuth(location);
}
if (location?.includes('https://steamcommunity.com/login/home')) {
if (location?.includes('steamcommunity.com/login/home')) {
logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
return false;
}
if (location?.includes('steamcommunity.com/my')) {
if (retry) {
logStatus.error(`Error:${i18n('redirect')}`, true);
return false;
}
logStatus.warning(i18n('retry'));
return await this.#getUserLink(true);
}
logStatus.error(`Error: 301 (${location})`, true);
return false;
}
Expand Down Expand Up @@ -4921,13 +4926,9 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
}
const steam64Id = data.responseText.match(/g_steamID = "(.+?)";/)?.[1];
const communitySessionID = data.responseText.match(/g_sessionID = "(.+?)";/)?.[1];
const userName = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)?.[1];
if (steam64Id) {
this.#auth.steam64Id = steam64Id;
}
if (userName) {
this.#auth.userName = userName;
}
if (communitySessionID) {
this.#auth.communitySessionID = communitySessionID;
logStatus.success();
Expand Down Expand Up @@ -5174,7 +5175,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
url: `https://steamcommunity.com/profiles/${this.#auth.steam64Id}/home_process`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
Expand Down Expand Up @@ -5316,7 +5317,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
status,
data
} = await tools_httpRequest({
url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
url: `https://steamcommunity.com/profiles/${this.#auth.steam64Id}/home_process`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
Expand Down Expand Up @@ -10877,7 +10878,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if ($('[data-miniprofile]').length === 0) {
return;
}
window.onbeforeunload = function(event) {
window.onbeforeunload = function() {
GM_setValue('steamStoreAuth', null);
return null;
};
Expand All @@ -10891,24 +10892,21 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
});
} else if (window.opener && window.location.host === 'steamcommunity.com') {
$(() => {
window.onbeforeunload = function(event) {
window.onbeforeunload = function() {
GM_setValue('steamCommunityAuth', null);
return null;
};
const steam64Id = document.body.innerHTML.match(/g_steamID = "(.+?)";/)?.[1];
const communitySessionID = document.body.innerHTML.match(/g_sessionID = "(.+?)";/)?.[1];
const userName = document.body.innerHTML.match(/steamcommunity.com\/id\/(.+?)\//)?.[1];
const data = {};
if (steam64Id) {
data.steam64Id = steam64Id;
}
if (userName) {
data.userName = userName;
}
if (communitySessionID) {
data.communitySessionID = communitySessionID;
GM_setValue('steamCommunityAuth', data);
if (GM_getValue('steamCommunityAuth') === 'update') {
if (GM_getValue('steamCommunityAuthProcess') === 'update') {
GM_deleteValue('steamCommunityAuthProcess');
window.close();
}
}
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.4

### V4.4.16

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

- 修复:Steam用户名为中文时无法更新社区凭证([#26](https://github.com/HCLonely/auto-task-v4/issues/26))

### V4.4.15

[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.4.15)
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.4.15",
"version": "4.4.16",
"change": [
"修复:更新Steam社区凭证问题(#26)"
"修复:Steam用户名为中文时无法更新社区凭证(#26)"
],
"description": "赠Key站自动任务脚本",
"main": "package.json",
Expand Down
Loading

0 comments on commit 17d5c16

Please sign in to comment.