Skip to content

Commit

Permalink
修复: 弹窗关闭后无法返回原标签页;
Browse files Browse the repository at this point in the history
修复: 关注/取关Steam限区游戏时动作错误;
优化: Steam社区凭证更新逻辑
  • Loading branch information
HCLonely committed Nov 25, 2024
1 parent dc23ca9 commit 4469bdc
Show file tree
Hide file tree
Showing 28 changed files with 148 additions and 524 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ jobs:
uses: softprops/action-gh-release@v1
with:
prerelease: false
tag_name: v4.5.1
name: 4.5.1
body: '- 修复: Steam社区凭证无法更新(#34,#24)'
tag_name: v4.5.2
name: 4.5.2
body: |-
- 修复: 弹窗关闭后无法返回原标签页
- 修复: 关注/取关Steam限区游戏时动作错误
- 优化: Steam社区凭证更新逻辑
files: |-
dist/auto-task-v4-for-giveawaysu.user.js
dist/auto-task-v4.compatibility.user.js
Expand Down
6 changes: 3 additions & 3 deletions dist/auto-task-v4-for-giveawaysu.all.user.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/auto-task-v4-for-giveawaysu.user.js

Large diffs are not rendered by default.

114 changes: 19 additions & 95 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.5.1
// @version 4.5.2
// @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 @@ -54,6 +54,7 @@
// @grant unsafeWindow
// @grant window.close
// @grant window.localStorage
// @grant window.focus

// @connect cdn.jsdelivr.net
// @connect store.steampowered.com
Expand Down Expand Up @@ -581,6 +582,10 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
var external_Cookies_default = __webpack_require__.n(external_Cookies_namespaceObject);
var auto_task = __webpack_require__(675);
var javascript_utils_umd_min = __webpack_require__(991);
const getFinalUrl = (responseHeaders, finalUrl) => {
const realFinalUrl = responseHeaders?.split('\n')?.find(header => header.includes('location') ? header.replace('loctation:', '').trim() : null);
return realFinalUrl || finalUrl;
};
const httpRequest = async (options, times = 0) => {
if (window.TRACE) {
console.trace('%cAuto-Task[Debug]:', 'color:blue');
Expand Down Expand Up @@ -621,6 +626,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
});
},
onload(data) {
data.finalUrl = getFinalUrl(data.responseHeaders, data.finalUrl);
if (options.responseType === 'json' && data?.response && typeof data.response !== 'object') {
try {
data.response = JSON.parse(data.responseText);
Expand Down Expand Up @@ -4617,7 +4623,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (this.#communityInitialized) {
return true;
}
let communityInitialized = await this.#getUserLink();
let communityInitialized = await this.#updateCommunityAuth();
if (!communityInitialized) {
communityInitialized = await this.#updateCommunityAuthTab();
GM_setValue('steamCommunityAuth', null);
Expand Down Expand Up @@ -4811,6 +4817,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
GM_removeValueChangeListener(listenerId);
GM_deleteValue('ATv4_updateStoreAuth');
newTab?.close();
window.focus();
if (newValue && JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
this.#auth.storeSessionID = newValue.storeSessionID;
logStatus.success();
Expand Down Expand Up @@ -4846,6 +4853,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
GM_removeValueChangeListener(listenerId);
GM_deleteValue('ATv4_updateCommunityAuth');
newTab?.close();
window.focus();
if (newValue && JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
this.#auth.steam64Id = newValue.steam64Id;
this.#auth.communitySessionID = newValue.communitySessionID;
Expand All @@ -4865,7 +4873,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
return false;
}
}
async #getUserLink(retry = false) {
async #updateCommunityAuth() {
try {
const logStatus = scripts_echoLog({
text: i18n('gettingUserLink')
Expand All @@ -4879,13 +4887,12 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
url: 'https://steamcommunity.com/my',
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',
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
Host: 'steamcommunity.com',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Upgrade-Insecure-Requests': '1'
'Sec-Fetch-Mode': 'navigate'
},
fetch: false,
redirect: 'manual'
fetch: false
});
if (data?.status === 200) {
if (data.finalUrl.includes('https://steamcommunity.com/login/home')) {
Expand All @@ -4894,100 +4901,15 @@ 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];
if (steam64Id) {
if (steam64Id && communitySessionID) {
this.#auth.steam64Id = steam64Id;
}
if (communitySessionID) {
this.#auth.communitySessionID = communitySessionID;
logStatus.success();
return true;
}
logStatus.error('Error: Get "sessionID" failed');
return false;
}
if (data?.status === 302) {
if (await this.#refreshToken('steamCommunity')) {
if (retry) {
logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
return false;
}
logStatus.warning(i18n('retry'));
return this.#getUserLink(true);
}
logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
return false;
}
const location = data?.finalUrl || data?.responseHeaders?.split('\n')?.find(header => header.includes('location') ? header.replace('loctation:', '').trim() : null);
if (data?.status === 301) {
if (location?.includes('steamcommunity.com/id')) {
logStatus.success();
return await this.#updateCommunityAuth(location);
}
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;
}
logStatus.error(`${result}:${statusText}(${status})`);
return false;
} catch (error) {
throwError(error, 'Steam.updateCommunityAuth');
return false;
}
}
async #updateCommunityAuth(url) {
try {
const logStatus = scripts_echoLog({
text: i18n('updatingAuth', i18n('steamCommunity'))
});
const {
result,
statusText,
status,
data
} = await tools_httpRequest({
url: url,
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'
}
});
if (result === 'Success') {
if (data?.status === 200) {
if (data.finalUrl.includes('https://steamcommunity.com/login/home')) {
logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
return false;
}
const steam64Id = data.responseText.match(/g_steamID = "(.+?)";/)?.[1];
const communitySessionID = data.responseText.match(/g_sessionID = "(.+?)";/)?.[1];
if (steam64Id) {
this.#auth.steam64Id = steam64Id;
}
if (communitySessionID) {
this.#auth.communitySessionID = communitySessionID;
logStatus.success();
return true;
}
logStatus.error('Error: Get "sessionID" failed');
return false;
}
logStatus.error(`Error:${data?.statusText}(${data?.status})`);
return false;
}
logStatus.error(`${result}:${statusText}(${status})`);
return false;
} catch (error) {
Expand Down Expand Up @@ -5651,7 +5573,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
if (!await this.#changeArea()) {
return false;
}
return await this.#removeFromWishlist(gameId);
return await this.#toggleFollowGame(gameId, doTask);
}
if (doTask === followed) {
logStatus.success();
Expand Down Expand Up @@ -8284,6 +8206,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
this.socialTasks = GM_getValue(`gcTasks-${this.giveawayId}`)?.tasks || Giveawaysu_defaultTasks;
return true;
}
this.undoneTasks = Giveawaysu_defaultTasks;
const pro = [];
const tasks = $('.event-actions tr');
for (const task of tasks) {
Expand Down Expand Up @@ -9597,6 +9520,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
});
await delay(1e3);
newTab?.close();
window.focus();
}
await delay(3e3);
unsafeWindow.$hookTimer?.setSpeed(1);
Expand Down
7 changes: 4 additions & 3 deletions dist/auto-task-v4.compatibility.all.user.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

Loading

0 comments on commit 4469bdc

Please sign in to comment.