From 346de4af58942fb5554bf3af465c46d3e5cd4cc5 Mon Sep 17 00:00:00 2001 From: HCLonely Date: Sun, 9 Jun 2024 17:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E8=A6=81:4.4.0=E4=BB=A5=E5=90=8E?= =?UTF-8?q?=E7=89=88=E6=9C=AC*=E9=9C=80TamperMonkey=20>=3D=205.2.0?= =?UTF-8?q?=E6=88=96TamperMonkey=20>=3D=205.2.6196);=20=E9=87=8D=E8=A6=81:?= =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=8F=96=E6=B6=88=E5=AF=B9Violentmonkey?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81(#20);=20=E4=BF=AE=E5=A4=8D:OpiumPul?= =?UTF-8?q?ses=E7=BD=91=E7=AB=99=E5=8A=A0=E5=85=A5=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=8E=B7=E5=8F=96=E9=94=99=E8=AF=AF(#21);=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3:=E6=9B=B4=E6=96=B0=E9=83=A8=E5=88=86?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=E6=96=87=E6=A1=A3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Release.yml | 18 +++++++----------- README.md | 1 - dist/auto-task-v4-for-giveawaysu.all.user.js | 2 +- dist/auto-task-v4-for-giveawaysu.user.js | 2 +- dist/auto-task-v4.all.user.js | 19 +++++++++++++++---- dist/auto-task-v4.compatibility.all.user.js | 4 ++-- dist/auto-task-v4.compatibility.user.js | 4 ++-- dist/auto-task-v4.user.js | 19 +++++++++++++++---- doc/docs/en/guide/README.md | 2 +- doc/docs/guide/README.md | 2 +- doc/docs/logs/README.md | 7 +++++++ package.json | 10 +++++----- .../auto-task-v4-for-giveawaysu.all.user.js | 2 +- page/dist/auto-task-v4-for-giveawaysu.user.js | 2 +- page/dist/auto-task-v4.all.user.js | 19 +++++++++++++++---- .../auto-task-v4.compatibility.all.user.js | 4 ++-- page/dist/auto-task-v4.compatibility.user.js | 4 ++-- page/dist/auto-task-v4.user.js | 19 +++++++++++++++---- page/package.json | 10 +++++----- src/global.d.ts | 1 + src/scripts/website/OpiumPulses.ts | 12 +++++++++--- 21 files changed, 108 insertions(+), 55 deletions(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 92d46f4..0d615bf 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -21,17 +21,13 @@ jobs: uses: softprops/action-gh-release@v1 with: prerelease: false - tag_name: v4.4.0 - name: 4.4.0 - body: >- - - 修复:Twitter/X域名更改导致部分功能不可用(#18) - - - 修复:配置跳过Discord任务时无效(#19) - - - 优化:Twitter/X凭证获取方式(*需TamperMonkey >= 5.2.0或TamperMonkey >= - 5.2.6196) - - - 优化:Youtube凭证获取方式(*需TamperMonkey >= 5.2.0或TamperMonkey >= 5.2.6196) + tag_name: v4.4.1 + name: 4.4.1 + body: |- + - 重要:4.4.0以后版本*需TamperMonkey >= 5.2.0或TamperMonkey >= 5.2.6196) + - 重要:暂时取消对Violentmonkey的支持(#20) + - 修复:OpiumPulses网站加入抽奖状态获取错误(#21) + - 文档:更新部分说明文档 files: |- dist/auto-task-v4-for-giveawaysu.user.js dist/auto-task-v4.compatibility.user.js diff --git a/README.md b/README.md index 6c15963..1871fb8 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ - [x] 添加更新源 - [x] 添加更新日志 - [x] 添加 giveaway.su 专版 -- [ ] TM版本检查 ## 感谢以下开源项目 diff --git a/dist/auto-task-v4-for-giveawaysu.all.user.js b/dist/auto-task-v4-for-giveawaysu.all.user.js index 18f28ec..9073978 100644 --- a/dist/auto-task-v4-for-giveawaysu.all.user.js +++ b/dist/auto-task-v4-for-giveawaysu.all.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4-for-giveawaysu // @namespace auto-task-v4-for-giveawaysu -// @version 4.4.0 +// @version 4.4.1 // @description 赠Key站自动任务 // @author HCLonely // @license MIT diff --git a/dist/auto-task-v4-for-giveawaysu.user.js b/dist/auto-task-v4-for-giveawaysu.user.js index 6dca40d..2e2cc73 100644 --- a/dist/auto-task-v4-for-giveawaysu.user.js +++ b/dist/auto-task-v4-for-giveawaysu.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4-for-giveawaysu // @namespace auto-task-v4-for-giveawaysu -// @version 4.4.0 +// @version 4.4.1 // @description 赠Key站自动任务 // @author HCLonely // @license MIT diff --git a/dist/auto-task-v4.all.user.js b/dist/auto-task-v4.all.user.js index e0abf99..6b488b7 100644 --- a/dist/auto-task-v4.all.user.js +++ b/dist/auto-task-v4.all.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4 // @namespace auto-task-v4 -// @version 4.4.0 +// @version 4.4.1 // @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 @@ -8517,14 +8517,25 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载'); method: 'GET' }); if (result === 'Success') { - if (data?.responseText && /You've entered this giveaway/gim.test(data.responseText)) { + const { + result: result0, + statusText: statusText0, + status: status0, + data: data0 + } = await tools_httpRequest({ + url: data?.finalUrl, + method: 'GET' + }); + if (data0?.responseText && /You've entered this giveaway/gim.test(data0.responseText)) { logStatus.success(); - const points = data.responseText.match(/Points:[\s]*?([\d]+)/)?.[1]; + const points = data0.responseText.match(/Points:[\s]*?([\d]+)/)?.[1]; if (type === 'points' && points) { this.myPoints = parseInt(points, 10); } + } else if (data0?.responseText && /You're not eligible to enter/gim.test(data0.responseText)) { + logStatus.error('You\'re not eligible to enter'); } else { - logStatus.error(`Error:${data?.statusText}(${data?.status})`); + logStatus.error(`${result0}:${statusText0}(${status0})`); } } else { logStatus.error(`${result}:${statusText}(${status})`); diff --git a/dist/auto-task-v4.compatibility.all.user.js b/dist/auto-task-v4.compatibility.all.user.js index 3660e26..dc455a3 100644 --- a/dist/auto-task-v4.compatibility.all.user.js +++ b/dist/auto-task-v4.compatibility.all.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4.compatibility // @namespace auto-task-v4.compatibility -// @version 4.4.0 +// @version 4.4.1 // @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 @@ -137,7 +137,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载'); 执行日志: [code]${$.makeArray($("#auto-task-info>li")).map(element=>element.innerText).join("\n")}[/code]`,GM_setClipboard(text),external_Swal_default().fire({title:i18n("copySuccess"),icon:"success",confirmButtonText:i18n("ok")}).then(()=>{window.open("https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450","_blank")}))}),console.log("%c%s","color:white;background:red",`Auto-Task[Error]: ${name} -`+error.stack)}var dataSync=class{tasks;getRealParams(name,links,doTask,link2param){try{let realParams=[];return 0link2param(link)).filter(link=>link)]),!doTask&&0!!isConfirmed||!!isDenied&&(GM_setValue("dontRemindDiscordAgain",!0),!0)))return this.#initialized=!1,"skip";return GM_getValue("dontRemindDiscordAgain")||"do"===action&&!globalOptions.doTask.discord.servers||"undo"===action&&!globalOptions.undoTask.discord.servers?(this.#initialized=!1,"skip"):!!this.#initialized||(this.#auth.auth?await this.#verifyAuth()?(scripts_echoLog({}).success(i18n("initSuccess","Discord")),this.#initialized=!0):(GM_setValue("discordAuth",{auth:null}),await this.#updateAuth()?(scripts_echoLog({}).success(i18n("initSuccess","Discord")),this.#initialized=!0):(scripts_echoLog({}).error(i18n("initFailed","Discord")),!1)):!!await this.#updateAuth()&&(this.#initialized=!0))}catch(error){return throwError(error,"Discord.init"),!1}}async#verifyAuth(){try{const logStatus=scripts_echoLog({text:i18n("verifyingAuth","Discord")});var{result,statusText,status,data}=await tools_httpRequest({url:"https://discord.com/api/v6/users/@me",method:"HEAD",headers:{authorization:this.#auth.auth}});return"Success"===result?200===data?.status?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Discord.verifyAuth"),!1}}async#updateAuth(){try{const logStatus=scripts_echoLog({text:i18n("updatingAuth","Discord")});return await new Promise(resolve=>{const newTab=GM_openInTab("https://discord.com/channels/@me#auth",{active:!0,insert:!0,setParent:!0});newTab.onclose=async()=>{var auth=GM_getValue("discordAuth")?.auth;auth?(this.#auth={auth:auth},logStatus.success(),resolve(await this.#verifyAuth())):(logStatus.error("Error: Update discord auth failed!"),resolve(!1))}})}catch(error){return throwError(error,"Discord.updateAuth"),!1}}async#joinServer(inviteId){try{const logStatus=scripts_echoLog({type:"joiningDiscordServer",text:inviteId});var{result,statusText,status,data}=await tools_httpRequest({url:"https://discord.com/api/v9/invites/"+inviteId,method:"POST",dataType:"json",headers:{authorization:this.#auth.auth,origin:"https://discord.com",referer:"https://discord.com/invite/"+inviteId}});if("Success"!==result||200!==data?.status)return logStatus.error(result+`:${statusText}(${status})`),!1;logStatus.success();var guild=String(data.response?.guild?.id);return guild&&(this.#setCache(inviteId,guild),this.tasks.servers=unique([...this.tasks.servers,inviteId])),!0}catch(error){return throwError(error,"Discord.joinServer"),!1}}async#leaveServer(inviteId){try{if(this.whiteList.servers.includes(inviteId))return scripts_echoLog({type:"whiteList",text:"Discord.leaveServer",id:inviteId}),!0;var guild=await this.#getGuild(inviteId);if(!guild)return!1;const logStatus=scripts_echoLog({type:"leavingDiscordServer",text:guild});var{result,statusText,status,data}=await tools_httpRequest({url:"https://discord.com/api/v9/users/@me/guilds/"+guild,method:"DELETE",headers:{authorization:this.#auth.auth}});return"Success"===result&&204===data?.status?(logStatus.success(),!0):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Discord.leaveServer"),!1}}async#getGuild(inviteId){try{const logStatus=scripts_echoLog({type:"gettingDiscordGuild",text:inviteId});var guild=this.#cache[inviteId];if(guild)return logStatus.success(),guild;var{result,statusText,status,data}=await tools_httpRequest({url:"https://discord.com/api/v9/invites/"+inviteId,responseType:"json",method:"GET"});if("Success"!==result||200!==data?.status)return logStatus.error(result+`:${statusText}(${status})`),!1;{const guild=data.response?.guild?.id;return guild?(logStatus.success(),this.#setCache(inviteId,guild),guild):(logStatus.error(result+`:${statusText}(${status})`),!1)}}catch(error){return throwError(error,"Discord.getGuild"),!1}}async toggle({doTask=!0,serverLinks=[]}){try{if(!this.#initialized)return scripts_echoLog({text:i18n("needInit")}),!1;const prom=[];if(doTask&&!globalOptions.doTask.discord.servers||!doTask&&!globalOptions.undoTask.discord.servers)scripts_echoLog({type:"globalOptionsSkip",text:"discord.servers"});else{var realServers=this.getRealParams("servers",serverLinks,doTask,link=>link.match(/invite\/(.+)/)?.[1]);if(0!0)}catch(error){return throwError(error,"Discord.toggleServers"),!1}}#setCache(inviteId,guild){try{this.#cache[inviteId]=guild,GM_setValue("discordCache",this.#cache)}catch(error){throwError(error,"Discord.setCache")}}};const social_Instagram=class extends dataSync{tasks;whiteList;#cache=GM_getValue("instagramCache")||{};#auth={};#initialized=!1;constructor(){super();var defaultTasksTemplate={users:[]};this.tasks=defaultTasksTemplate,this.whiteList={...defaultTasksTemplate,...GM_getValue("whiteList")?.instagram||{}}}async init(){try{return this.#initialized?!0:await this.#getUserInfo()?(scripts_echoLog({}).success(i18n("initSuccess","Instagram")),this.#initialized=!0):(scripts_echoLog({}).error(i18n("initFailed","Instagram")),!1)}catch(error){return throwError(error,"Instagram.init"),!1}}async#getUserInfo(name="instagram"){try{const logStatus=scripts_echoLog({type:"instagram"===name?"verifyingInsAuth":"gettingInsUserId",text:name});var userId=this.#cache[name];if(userId&&"instagram"!==name)return logStatus.success(),userId;const{result,statusText,status,data}=await tools_httpRequest({url:`https://www.instagram.com/${name}/`,method:"GET"});if("Success"!==result)return!1;if(data?.finalUrl.includes("accounts/login"))return logStatus.error("Error:"+i18n("loginIns"),!0),!1;if(data?.finalUrl.includes("www.instagram.com/challenge"))return logStatus.error("Error:"+i18n("insBanned")),!1;if(200!==data?.status)return logStatus.error(result+`:${statusText}(${status})`),!1;var csrftoken=data.responseText.match(/"csrf_token":"(.+?)"/)?.[1],hash=data.responseText.match(/"rollout_hash":"(.+?)"/)?.[1];if("instagram"===name)return!(!csrftoken||!hash)&&(this.#auth={csrftoken:csrftoken,hash:hash},!0);var id=data.responseText.match(/"profilePage_([\d]+?)"/)?.[1];return id?(this.#setCache(name,id),logStatus.success(),id):(logStatus.error("Error: Get ins data error!"),!1)}catch(error){return throwError(error,"Instagram.getUserInfo"),!1}}async#followUser(name){try{var id=await this.#getUserInfo(name);if(!id)return!1;const logStatus=scripts_echoLog({type:"followingIns",text:name});var{result,statusText,status,data}=await tools_httpRequest({url:`https://www.instagram.com/web/friendships/${id}/follow/`,method:"POST",dataType:"json",headers:{"x-csrftoken":this.#auth.csrftoken,origin:"https://www.instagram.com",referer:`https://www.instagram.com/${name}/`,"content-type":"application/x-www-form-urlencoded","sec-fetch-site":"same-origin","x-instagram-ajax":this.#auth.hash}});return"Success"===result?200===data?.status&&"following"===data.response?.result?(logStatus.success(),this.tasks.users=unique([...this.tasks.users,name]),!0):(logStatus.error("Error:"+(data?.response?.feedback_message||data?.statusText+`(${data?.status})`)),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Instagram.followUser"),!1}}async#unfollowUser(name){try{if(this.whiteList.users.includes(name))return scripts_echoLog({type:"whiteList",text:"Instagram.unfollowUser",id:name}),!0;var id=await this.#getUserInfo(name);if(!id)return!1;const logStatus=scripts_echoLog({type:"unfollowingIns",text:name});var{result,statusText,status,data}=await tools_httpRequest({url:`https://www.instagram.com/web/friendships/${id}/unfollow/`,method:"POST",dataType:"json",headers:{"x-csrftoken":this.#auth.csrftoken,origin:"https://www.instagram.com",referer:`https://www.instagram.com/${name}/`,"content-type":"application/x-www-form-urlencoded","sec-fetch-site":"same-origin","x-instagram-ajax":this.#auth.hash}});return"Success"===result?200===data?.status&&"ok"===data.response?.status?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Instagram.unfollowUser"),!1}}async toggle({doTask=!0,userLinks=[]}){try{if(!this.#initialized)return scripts_echoLog({text:i18n("needInit")}),!1;const prom=[];if(doTask&&!globalOptions.doTask.instagram.users||!doTask&&!globalOptions.undoTask.instagram.users)scripts_echoLog({type:"globalOptionsSkip",text:"instagram.users"});else{var realUsers=this.getRealParams("users",userLinks,doTask,link=>link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)?.[1]);if(0!0)}catch(error){return throwError(error,"Instagram.toggleUsers"),!1}}#setCache(name,id){try{this.#cache[name]=id,GM_setValue("instagramCache",this.#cache)}catch(error){throwError(error,"Instagram.setCache")}}};const social_Reddit=class extends dataSync{tasks;whiteList;#auth;#initialized=!1;constructor(){super();var defaultTasksTemplate={reddits:[]};this.tasks=defaultTasksTemplate,this.whiteList={...defaultTasksTemplate,...GM_getValue("whiteList")?.reddit||{}}}async init(){try{return this.#initialized?!0:await this.#updateAuth()?(scripts_echoLog({}).success(i18n("initSuccess","Reddit")),this.#initialized=!0):(scripts_echoLog({}).error(i18n("initFailed","Reddit")),!1)}catch(error){return throwError(error,"Reddit.init"),!1}}async#useBeta(){try{const logStatus=scripts_echoLog({text:i18n("changingRedditVersion")});return GM_setValue("redditAuth",null),await new Promise(resolve=>{const newTab=GM_openInTab("https://www.reddit.com/#auth",{active:!0,insert:!0,setParent:!0});newTab.onclose=async()=>{logStatus.success(),resolve(await this.#updateAuth(!0))}})}catch(error){return throwError(error,"Reddit.useBeta"),!1}}async#updateAuth(beta=!1){try{const logStatus=scripts_echoLog({text:i18n("updatingAuth","Reddit")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://www.reddit.com/",method:"GET",nochche:!0,headers:{"Cache-Control":"no-cache"}});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(data?.responseText.includes("www.reddit.com/login/"))return logStatus.error("Error:"+i18n("loginReddit"),!0),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;if(data.responseText.includes("redesign-beta-optin-btn")&&!beta)return await this.#useBeta();var accessToken=data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)?.[1];return accessToken?(this.#auth={token:accessToken},logStatus.success(),!0):(logStatus.error('Error: Parameter "accessToken" not found!'),!1)}catch(error){return throwError(error,"Reddit.updateAuth"),!1}}async toggleTask({name,doTask=!0}){try{if(!doTask&&this.whiteList.reddits.includes(name))return scripts_echoLog({type:"whiteList",text:"Reddit.undoTask",id:name}),!0;let type=doTask?"joiningReddit":"leavingReddit";/^u_/.test(name)&&(type=doTask?"followingRedditUser":"unfollowingRedditUser");const logStatus=scripts_echoLog({type:type,text:name});var{result,statusText,status,data}=await tools_httpRequest({url:"https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1",method:"POST",headers:{authorization:"Bearer "+this.#auth.token,"content-type":"application/x-www-form-urlencoded"},data:$.param({action:doTask?"sub":"unsub",sr_name:name,api_type:"json"})});return"Success"===result?200===data?.status?(logStatus.success(),doTask&&(this.tasks.reddits=unique([...this.tasks.reddits,name])),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Reddit.toggleTask"),!1}}async toggle({doTask=!0,redditLinks=[]}){try{if(!this.#initialized)return scripts_echoLog({text:i18n("needInit")}),!1;const prom=[];if(doTask&&!globalOptions.doTask.reddit.reddits||!doTask&&!globalOptions.undoTask.reddit.reddits)scripts_echoLog({type:"globalOptionsSkip",text:"reddit.reddits"});else{var realReddits=this.getRealParams("reddits",redditLinks,doTask,userName=>{var name=userName.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)?.[1],userName=userName.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)?.[1];return userName?name||userName:name});if(0!0)}catch(error){return throwError(error,"Reddit.toggle"),!1}}};const social_Twitch=class extends dataSync{tasks;whiteList;#auth=GM_getValue("twitchAuth")||{};#cache=GM_getValue("twitchCache")||{};#initialized=!1;#integrityToken;constructor(){super();var defaultTasksTemplate={channels:[]};this.tasks=defaultTasksTemplate,this.whiteList={...defaultTasksTemplate,...GM_getValue("whiteList")?.twitch||{}}}async init(){try{return this.#initialized?!0:this.#auth.authToken&&this.#auth.clientId&&this.#auth.clientVersion&&this.#auth.deviceId&&this.#auth.clientSessionId?await this.#verifyAuth(!0)?(scripts_echoLog({}).success(i18n("initSuccess","Twitch")),this.#initialized=!0):(GM_setValue("twitchAuth",null),await this.#updateAuth()?(scripts_echoLog({}).success(i18n("initSuccess","Twitch")),this.#initialized=!0):(scripts_echoLog({}).error(i18n("initFailed","Twitch")),!1)):!!await this.#updateAuth()&&(this.#initialized=!0)}catch(error){return throwError(error,"Twitch.init"),!1}}async#verifyAuth(isFirst){try{const logStatus=scripts_echoLog({text:i18n("verifyingAuth","Twitch")});var{result,statusText,status,data}=await tools_httpRequest({url:"https://gql.twitch.tv/gql",method:"POST",dataType:"json",headers:{Authorization:"OAuth "+this.#auth.authToken,"Client-Id":this.#auth.clientId},data:'[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'});return"Success"===result?200===data?.status&&data.response?.[0]?.data?.currentUser?(await this.#integrity(isFirst),logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Twitch.verifyAuth"),!1}}async#integrity(isFirst=!0,ct=""){try{const logStatus=scripts_echoLog({text:i18n("checkingTwitchIntegrity")});if(isFirst&&(!this.#auth.authToken||!this.#auth.clientId||!this.#auth.clientVersion||!this.#auth.deviceId||!this.#auth.clientSessionId))return await this.#updateAuth(!1);var{result,statusText,status,data}=await tools_httpRequest({url:"https://gql.twitch.tv/integrity",method:"POST",dataType:"json",anonymous:!0,headers:{Origin:"https://www.twitch.tv",Referer:"https://www.twitch.tv/",Authorization:"OAuth "+this.#auth.authToken,"Client-Id":this.#auth.clientId,"Client-Version":this.#auth.clientVersion,"X-Device-Id":this.#auth.deviceId,"Client-Session-Id":this.#auth.clientSessionId,"x-kpsdk-ct":ct}});return"Success"===result?!ct&&data?.responseHeaders?.["x-kpsdk-ct"]?await this.#integrity(isFirst,data.responseHeaders["x-kpsdk-ct"]):200===data?.status&&data.response?.token?(this.#integrityToken=data.response.token,logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Twitch.integrity"),!1}}async#updateAuth(isFirst=!0){try{const logStatus=scripts_echoLog({text:i18n("updatingAuth","Twitch")});return await new Promise(resolve=>{const newTab=GM_openInTab("https://www.twitch.tv/#auth",{active:!0,insert:!0,setParent:!0});newTab.onclose=async()=>{var auth=GM_getValue("twitchAuth");auth?(this.#auth=auth,logStatus.success(),resolve(await this.#verifyAuth(isFirst))):(logStatus.error("Error: Update twitch auth failed!"),resolve(!1))}})}catch(error){return throwError(error,"Twitch.updateAuth"),!1}}async#toggleChannel({name,doTask=!0}){try{if(!doTask&&this.whiteList.channels.includes(name))return scripts_echoLog({type:"whiteList",text:"Twitch.unfollowChannel",id:name}),!0;var channelId=await this.#getChannelId(name);if(!channelId)return!1;const logStatus=scripts_echoLog({type:`${doTask?"":"un"}followingTwitchChannel`,text:name});var followData='[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"'+channelId+'"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"800e7346bdf7e5278a3c1d3f21b2b56e2639928f86815677a7126b093b2fdd08"}}}]',unfollowData=`[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},`+'"extensions":{"persistedQuery":{"version":1,"sha256Hash":"f7dae976ebf41c755ae2d758546bfd176b4eeb856656098bb40e0a672ca0d880"}}}]',{result,statusText,status,data}=await tools_httpRequest({url:"https://gql.twitch.tv/gql",method:"POST",dataType:"json",anonymous:!0,headers:{Origin:"https://www.twitch.tv",Referer:"https://www.twitch.tv/",Authorization:"OAuth "+this.#auth.authToken,"Client-Id":this.#auth.clientId,"Client-Version":this.#auth.clientVersion,"X-Device-Id":this.#auth.deviceId,"Client-Session-Id":this.#auth.clientSessionId,"Client-Integrity":this.#integrityToken},data:doTask?followData:unfollowData});return"Success"===result?200===data?.status&&data.response?.[0]&&!data.response[0].errors?(logStatus.success(),doTask&&(this.tasks.channels=unique([...this.tasks.channels,name])),!0):(logStatus.error("Error:"+(data?.response?.[0].errors?.[0]?.message||data?.statusText+`(${data?.status})`)),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Twitch.toggleChannel"),!1}}async#getChannelId(name){try{const logStatus=scripts_echoLog({type:"gettingTwitchChannelId",text:name});var channelId=this.#cache[name];if(channelId)return logStatus.success(),channelId;var{result,statusText,status,data}=await tools_httpRequest({url:"https://gql.twitch.tv/gql",method:"POST",headers:{Authorization:"OAuth "+this.#auth.authToken,"Client-Id":this.#auth.clientId},responseType:"json",data:`[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},`+'"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{const channelId=data.response?.[0]?.data?.user?.id;return channelId?(this.#setCache(name,String(channelId)),logStatus.success(),channelId):(logStatus.error(`Error:${data.statusText}(${data.status})`),!1)}}catch(error){return throwError(error,"Twitch.getChannelId"),!1}}async toggle({doTask=!0,channelLinks=[]}){try{if(!this.#initialized)return scripts_echoLog({text:i18n("needInit")}),!1;const prom=[];if(doTask&&!globalOptions.doTask.twitch.channels||!doTask&&!globalOptions.undoTask.twitch.channels)scripts_echoLog({type:"globalOptionsSkip",text:"twitch.channels"});else{var realChannels=this.getRealParams("channels",channelLinks,doTask,link=>link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)?.[2]);if(0!0)}catch(error){return throwError(error,"Twitch.toggle"),!1}}#setCache(name,id){try{this.#cache[name]=id,GM_setValue("twitchCache",this.#cache)}catch(error){throwError(error,"Twitch.setCache")}}};const social_Twitter=class extends dataSync{tasks;whiteList;#verifyId=globalOptions.other.twitterVerifyId;#auth=GM_getValue("twitterAuth")||{};#cache=GM_getValue("twitterCache")||{};#initialized=!1;constructor(){super();var defaultTasksTemplate={users:[],retweets:[],likes:[]};this.tasks=defaultTasksTemplate,this.whiteList={...defaultTasksTemplate,...GM_getValue("whiteList")?.twitter||{}}}async init(){try{return this.#initialized?!0:this.#auth.ct0?await this.#verifyAuth()?(scripts_echoLog({}).success(i18n("initSuccess","Twitter")),this.#initialized=!0):(GM_setValue("twitterAuth",null),await this.#updateAuth()?(scripts_echoLog({}).success(i18n("initSuccess","Twitter")),this.#initialized=!0):(scripts_echoLog({}).error(i18n("initFailed","Twitter")),!1)):!!await this.#updateAuth()&&(this.#initialized=!0)}catch(error){return throwError(error,"Twitter.init"),!1}}async#verifyAuth(){try{return await this.#toggleUser({name:"verify",doTask:!0,verify:!0})}catch(error){return throwError(error,"Twitter.verifyAuth"),!1}}async#updateAuth(){try{const logStatus=scripts_echoLog({text:i18n("updatingAuth","Twitter")});return await new Promise(resolve=>{GM_cookie.list({url:"https://x.com/settings/account"},async(isLogin,ct0)=>{ct0?(logStatus.error("Error: Update twitter auth failed!"),resolve(!1)):([ct0,isLogin]=isLogin.map(cookie=>["ct0","twid"].includes(cookie.name)?cookie.value:null).filter(cookie=>cookie),isLogin&&ct0?(GM_setValue("twitterAuth",{ct0:ct0}),this.#auth={ct0:ct0},logStatus.success(),resolve(await this.#verifyAuth())):(logStatus.error(i18n("needLogin")),resolve(!1)))})})}catch(error){return throwError(error,"Twitter.updateToken"),!1}}async#toggleUser({name,doTask=!0,verify=!1}){try{if(!doTask&&!verify&&this.whiteList.users.includes(name))return scripts_echoLog({type:"whiteList",text:"Twitter.unfollowUser",id:name}),!0;var userId=verify?this.#verifyId:await this.userName2id(name);if(!userId)return!1;const logStatus=verify?scripts_echoLog({text:i18n("verifyingAuth","Twitter")}):scripts_echoLog({type:`${doTask?"":"un"}followingTwitterUser`,text:name});var{result,statusText,status,data}=await tools_httpRequest({url:`https://x.com/i/api/1.1/friendships/${doTask?"create":"destroy"}.json`,method:"POST",headers:{authorization:"Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA","Content-Type":"application/x-www-form-urlencoded","x-csrf-token":this.#auth.ct0},responseType:"json",data:$.param({include_profile_interstitial_type:1,include_blocking:1,include_blocked_by:1,include_followed_by:1,include_want_retweets:1,include_mute_edge:1,include_can_dm:1,include_can_media_tag:1,skip_status:1,id:userId})});return"Success"===result?200===data?.status?(logStatus.success(),doTask&&!verify&&(this.tasks.users=unique([...this.tasks.users,name])),!0):verify&&403===data?.status&&158===data.response?.errors?.[0]?.code?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Twitter.toggleUser"),!1}}async userName2id(name){try{const logStatus=scripts_echoLog({type:"gettingTwitterUserId",text:name});var userId=this.#cache[name];if(userId)return logStatus.success(),userId;var{result,statusText,status,data}=await tools_httpRequest({url:"https://x.com/i/api/graphql/mCbpQvZAw6zu_4PvuAUVVQ/UserByScreenName"+`?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D`,method:"GET",headers:{authorization:"Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA","content-type":"application/json",referer:"https://x.com/"+name,"x-csrf-token":this.#auth.ct0},responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{let response=data.response||("object"==typeof data.responseText?data.responseText:null);if(!response)try{response=JSON.parse(data.responseText)}catch(error){response=null}const userId=String(response?.data?.user?.result?.rest_id);return userId?(this.#setCache(name,userId),logStatus.success(),userId):(logStatus.error(`Error:${data.statusText}(${data.status})`),!1)}}catch(error){return throwError(error,"Twitter.getUserId"),!1}}async#toggleRetweet({retweetId,doTask=!0}){try{if(!doTask&&this.whiteList.retweets.includes(retweetId))return scripts_echoLog({type:"whiteList",text:"Twitter.unretweet",id:retweetId}),!0;const logStatus=scripts_echoLog({type:`${doTask?"":"un"}retweetting`,text:retweetId});var{result,statusText,status,data}=await tools_httpRequest({url:`https://x.com/i/api/1.1/statuses/${doTask?"":"un"}retweet.json`,method:"POST",headers:{authorization:"Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA","Content-Type":"application/x-www-form-urlencoded","x-csrf-token":this.#auth.ct0},data:$.param({tweet_mode:"extended",id:retweetId}),responseType:"json"});return"Success"===result?200===data?.status||403===data?.status&&327===data.response?.errors?.[0]?.code?(logStatus.success(),doTask&&(this.tasks.retweets=unique([...this.tasks.retweets,retweetId])),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Twitter.toggleRetweet"),!1}}async toggle({doTask=!0,userLinks=[],retweetLinks=[]}){try{if(!this.#initialized)return scripts_echoLog({text:i18n("needInit")}),!1;const prom=[];if(doTask&&!globalOptions.doTask.twitter.users||!doTask&&!globalOptions.undoTask.twitter.users)scripts_echoLog({type:"globalOptionsSkip",text:"twitter.users"});else{var realUsers=this.getRealParams("users",userLinks,doTask,link=>link.match(/https:\/\/x\.com\/(.+)/)?.[1]);if(0link.match(/https:\/\/x\.com\/.*?\/status\/([\d]+)/)?.[1]);if(0!0)}catch(error){return throwError(error,"Twitter.toggle"),!1}}#setCache(name,id){try{this.#cache[name]=id,GM_setValue("twitterCache",this.#cache)}catch(error){throwError(error,"Twitter.setCache")}}};const social_Vk=class extends dataSync{tasks;whiteList;#username="";#cache=GM_getValue("vkCache")||{};#initialized=!1;constructor(){super();var defaultTasksTemplate={names:[]};this.tasks=defaultTasksTemplate,this.whiteList={...defaultTasksTemplate,...GM_getValue("whiteList")?.vk||{}}}async init(){try{return this.#initialized?!0:await this.#verifyAuth()?(scripts_echoLog({}).success(i18n("initSuccess","Vk")),this.#initialized=!0):(scripts_echoLog({}).error(i18n("initFailed","Vk")),!1)}catch(error){return throwError(error,"Vk.init"),!1}}async#verifyAuth(){try{const logStatus=scripts_echoLog({text:i18n("verifyAuth","Vk")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://vk.com/im",method:"GET"});return"Success"===result?data?.finalUrl.includes("vk.com/login")?(logStatus.error("Error:"+i18n("loginVk"),!0),!1):200===data?.status?(this.#username=data.responseText.match(/TopNavBtn__profileLink" href="\/(.*?)"/)?.[1]||"",logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Vk.verifyAuth"),!1}}async#toggleGroup(name,dataParam,doTask=!0){try{const logStatus=scripts_echoLog({type:doTask?"joiningVkGroup":"leavingVkGroup",text:name});if("enter"===dataParam.groupAct&&!doTask||"leave"===dataParam.groupAct&&doTask)return logStatus.success(),!0;const reqData={act:doTask?"enter":"leave",al:1,gid:dataParam.groupId,hash:dataParam.groupHash};doTask&&(reqData.context="_");var{result,statusText,status,data}=await tools_httpRequest({url:"https://vk.com/al_groups.php",method:"POST",headers:{origin:"https://vk.com",referer:"https://vk.com/"+name,"content-type":"application/x-www-form-urlencoded"},data:$.param(reqData)});return"Success"===result?200===data?.status?(logStatus.success(),doTask&&(this.tasks.names=unique([...this.tasks.names,name])),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Vk.toggleGroup"),!1}}async#togglePublic(name,dataParam,doTask=!0){try{const logStatus=scripts_echoLog({type:doTask?"joiningVkPublic":"leavingVkPublic",text:name});if(dataParam.publicJoined&&doTask||!dataParam.publicJoined&&!doTask)return logStatus.success(),!0;var{result,statusText,status,data}=await tools_httpRequest({url:"https://vk.com/al_public.php",method:"POST",headers:{origin:"https://vk.com",referer:"https://vk.com/"+name,"content-type":"application/x-www-form-urlencoded"},data:$.param({act:doTask?"a_enter":"a_leave",al:1,pid:dataParam.publicPid,hash:dataParam.publicHash})});return"Success"===result?200===data?.status?(logStatus.success(),doTask&&(this.tasks.names=unique([...this.tasks.names,name])),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Vk.togglePublic"),!1}}async#sendWall(name){try{const logStatus=scripts_echoLog({type:"sendingVkWall",text:name}),{result,statusText,status,data}=await tools_httpRequest({url:"https://vk.com/like.php",method:"POST",headers:{origin:"https://vk.com",referer:"https://vk.com/"+name,"content-type":"application/x-www-form-urlencoded"},data:$.param({act:"publish_box",al:1,object:name})});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;var hash=data.responseText.match(/shHash:[\s]*'(.*?)'/)?.[1];if(hash){const{result:resultR,statusText:statusTextR,status:statusR,data:dataR}=await tools_httpRequest({url:"https://vk.com/like.php",method:"POST",headers:{origin:"https://vk.com",referer:"https://vk.com/"+name,"content-type":"application/x-www-form-urlencoded"},data:$.param({Message:"",act:"a_do_publish",al:1,close_comments:0,friends_only:0,from:"box",hash:hash,list:"",mark_as_ads:0,mute_notifications:0,object:name,ret_data:1,to:0})});if("Success"!==resultR)return logStatus.error(resultR+`:${statusTextR}(${statusR})`),!1;if(200===dataR?.status){var jsonData=JSON.parse(dataR.responseText?.replace("\x3c!--","")||"{}");if(!0===jsonData?.payload?.[1]?.[1]?.share_my){logStatus.success();var postId=String(jsonData?.payload?.[1]?.[1]?.post_id),ownerId=String(jsonData?.payload?.[1]?.[1]?.owner_id);return postId&&ownerId&&this.#setCache(name,ownerId+"_"+postId),this.tasks.names=unique([...this.tasks.names,name]),!0}}return logStatus.error(`Error:${dataR?.statusText}(${dataR?.status})`),!1}return logStatus.error('Error: Get "hash" failed'),!1}catch(error){return throwError(error,"Vk.sendWall"),!1}}async#deleteWall(name,dataParams){try{const logStatus=scripts_echoLog({type:"deletingVkWall",text:name}),{result,statusText,status,data}=await tools_httpRequest({url:"https://vk.com/al_wall.php?act=delete",method:"POST",headers:{origin:"https://vk.com",referer:`https://vk.com/${this.#username}?w=wall${this.#cache[name]}%2Fall`,"content-type":"application/x-www-form-urlencoded"},data:$.param({act:"delete",al:1,confirm:0,from:"wkview",hash:dataParams.wallHash,post:this.#cache[name]})});return"Success"===result?200===data?.status&&JSON.parse(data.responseText?.replace("\x3c!--","")||"{}")?.payload?.[1]?.[1]?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Vk.deleteWall"),!1}}async#getId(name,doTask){try{let url="https://vk.com/"+name;if(/^wall-/.test(name)){if(doTask)return{type:"sendWall"};if(!this.#cache[name])return{type:"unSupport"};url=`https://vk.com/${this.#username}?w=wall`+this.#cache[name]}const logStatus=scripts_echoLog({type:"gettingVkId",text:name}),{result,statusText,status,data}=await tools_httpRequest({url:url,method:"GET"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;var[,groupAct,groupId,,groupHash]=data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), ('|')(.*?)('|')/)||[],publicHash=data.responseText.match(/"enterHash":"(.*?)"/)?.[1],publicPid=data.responseText.match(/"public_id":([\d]+?),/)?.[1],publicJoined=!data.responseText.includes("Public.subscribe");if(groupAct&&groupId&&groupHash)return logStatus.success(),{groupAct:groupAct,groupId:groupId,groupHash:groupHash,type:"group"};if(publicHash&&publicPid)return logStatus.success(),{publicHash:publicHash,publicPid:publicPid,publicJoined:publicJoined,type:"public"};if(data.responseText.includes("wall.deletePost")&&!doTask){var wallHash=data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)?.[1];if(wallHash)return logStatus.success(),{type:"deleteWall",wallHash:wallHash}}else if(name.includes("wall")&&doTask)return logStatus.success(),{type:"sendWall"};return logStatus.error("Error: Parameters not found!"),!1}catch(error){return throwError(error,"Vk.getId"),!1}}async#toggleVk({name,doTask=!0}){try{if(!doTask&&this.whiteList.names.includes(name))return scripts_echoLog({type:"whiteList",text:"Vk.undoTask",id:name}),!0;var formatName=name.replace(/\/$/,""),data=await this.#getId(formatName,doTask);if(!data)return!1;switch(data.type){case"group":return await this.#toggleGroup(formatName,data,doTask);case"public":return await this.#togglePublic(formatName,data,doTask);case"sendWall":return!doTask||await this.#sendWall(formatName);case"deleteWall":return!!doTask||await this.#deleteWall(formatName,data);default:return!1}}catch(error){return throwError(error,"Vk.toggleVk"),!1}}async toggle({doTask=!0,nameLinks=[]}){try{if(!this.#initialized)return scripts_echoLog({text:i18n("needInit")}),!1;const prom=[];if(doTask&&!globalOptions.doTask.vk.names||!doTask&&!globalOptions.undoTask.vk.names)scripts_echoLog({type:"globalOptionsSkip",text:"vk.names"});else{var realNames=this.getRealParams("names",nameLinks,doTask,link=>link.match(/https:\/\/vk\.com\/([^/]+)/)?.[1]);if(0!0)}catch(error){return throwError(error,"Vk.toggle"),!1}}#setCache(name,postId){try{this.#cache[name]=postId,GM_setValue("vkCache",this.#cache)}catch(error){throwError(error,"Vk.setCache")}}},getInfo=async function(link,type){try{const logStatus=scripts_echoLog({text:i18n("gettingYtbToken")}),{result,statusText,status,data}=await tools_httpRequest({url:link,method:"GET"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),{};if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),{};{if(data.responseText.includes("accounts.google.com/ServiceLogin?service=youtube"))return logStatus.error("Error:"+i18n("loginYtb"),!0),{needLogin:!0};var apiKey=data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)?.[1],context=(data.responseText.match(/\(\{"INNERTUBE_CONTEXT":([\w\W]*?)\}\)/)||data.responseText.match(/"INNERTUBE_CONTEXT":([\w\W]*?\}),"INNERTUBE/))?.[1]||"{}";const{client,request}=JSON.parse(context);if(apiKey&&client&&request){if(client.hl="en","channel"===type){var channelId=data.responseText.match(/"channelId":"(.+?)"/)?.[1];return channelId?(logStatus.success(),{params:{apiKey:apiKey,client:client,request:request,channelId:channelId}}):(logStatus.error('Error: Get "channelId" failed!'),{})}if("likeVideo"!==type)return logStatus.error("Error: Unknown type"),{};var videoId=data.responseText.match(//)?.[1],likeParams=data.responseText.match(/"likeParams":"(.*?)"/)?.[1];return videoId?(logStatus.success(),{params:{apiKey:apiKey,client:client,request:request,videoId:videoId,likeParams:likeParams}}):(logStatus.error('Error: Get "videoId" failed!'),{})}return logStatus.error('Error: Parameter "apiKey" not found!'),{}}}catch(error){return throwError(error,"Youtube.getInfo"),{}}};class Youtube extends dataSync{tasks;whiteList;#auth=GM_getValue("youtubeAuth")||{};#initialized=!1;#verifyChannel="https://www.youtube.com/channel/"+globalOptions.other.youtubeVerifyChannel;constructor(){super();var defaultTasksTemplate={channels:[],likes:[]};this.tasks=defaultTasksTemplate,this.whiteList={...defaultTasksTemplate,...GM_getValue("whiteList")?.youtube||{}}}async init(){try{return this.#initialized?!0:this.#auth.PAPISID?await this.#verifyAuth()?(scripts_echoLog({}).success(i18n("initSuccess","Youtube")),this.#initialized=!0):(GM_setValue("youtubeAuth",null),await this.#updateAuth()?(scripts_echoLog({}).success(i18n("initSuccess","Youtube")),this.#initialized=!0):(scripts_echoLog({}).error(i18n("initFailed","Youtube")),!1)):!!await this.#updateAuth()&&(this.#initialized=!0)}catch(error){return throwError(error,"Youtube.init"),!1}}async#verifyAuth(){try{return await this.#toggleChannel({link:this.#verifyChannel,doTask:!0,verify:!0})}catch(error){return throwError(error,"Youtube.verifyAuth"),!1}}async#updateAuth(){try{const logStatus=scripts_echoLog({text:i18n("updatingAuth","Youtube")});return await new Promise(resolve=>{GM_cookie.list({url:"https://www.youtube.com/@YouTube"},async(PAPISID,error)=>{error?(logStatus.error("Error: Update youtube auth failed!"),resolve(!1)):(PAPISID=PAPISID.find(cookie=>"__Secure-3PAPISID"===cookie.name)?.value)?(GM_setValue("youtubeAuth",{PAPISID:PAPISID}),this.#auth={PAPISID:PAPISID},logStatus.success(),resolve(await this.#verifyAuth())):(logStatus.error(i18n("needLogin")),resolve(!1))})})}catch(error){return throwError(error,"Youtube.updateAuth"),!1}}#getInfo(link,type){return getInfo(link,type)}async#toggleChannel({link,doTask=!0,verify=!1}){try{var{params,needLogin}=await this.#getInfo(link,"channel"),{apiKey,client,request,channelId}=params||{};if(needLogin)return scripts_echoLog({html:i18n("loginYtb")}),!1;if(!(apiKey&&client&&request&&channelId))return scripts_echoLog({text:'"getYtbToken" failed'}),!1;if(!doTask&&!verify&&this.whiteList.channels.includes(channelId))return scripts_echoLog({type:"whiteList",text:"Youtube.unfollowChannel",id:channelId}),!0;const logStatus=verify?scripts_echoLog({text:i18n("verifyingAuth","Youtube")}):scripts_echoLog({type:doTask?"followingYtbChannel":"unfollowingYtbChannel",text:channelId});var nowTime=parseInt(String((new Date).getTime()/1e3),10);const{result,statusText,status,data}=await tools_httpRequest({url:`https://www.youtube.com/youtubei/v1/subscription/${doTask?"":"un"}subscribe?key=${apiKey}&prettyPrint=false`,method:"POST",headers:{origin:"https://www.youtube.com",referer:"https://www.youtube.com/channel/"+channelId,"content-type":"application/json","x-goog-authuser":"0","x-goog-visitor-id":client?.visitorData,"x-origin":"https://www.youtube.com",authorization:`SAPISIDHASH ${nowTime}_`+sha1(`${nowTime} ${this.#auth.PAPISID} https://www.youtube.com`)},data:JSON.stringify({context:{client:client,request:{sessionId:request?.sessionId,internalExperimentFlags:[],consistencyTokenJars:[]},user:{}},channelIds:[channelId],params:doTask?"EgIIAhgA":"CgIIAhgA"})});return"Success"===result?200===data?.status?doTask&&(/"subscribed":true/.test(data.responseText)||data.responseText.includes("The subscription already exists"))||!doTask&&/"subscribed":false/.test(data.responseText)?(logStatus.success(),doTask&&!verify&&(this.tasks.channels=unique([...this.tasks.channels,link])),!0):verify&&data.responseText.includes("You may not subscribe to yourself")?(logStatus.success(),!0):(logStatus.error(i18n("tryUpdateYtbAuth"),!0),!1):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Youtube.toggleChannel"),!1}}async#toggleLikeVideo({link,doTask=!0}){try{var{params,needLogin}=await this.#getInfo(link,"likeVideo"),{apiKey,client,request,videoId,likeParams}=params||{};if(needLogin)return scripts_echoLog({html:""+i18n("loginYtb")}),!1;if(!(apiKey&&client&&request&&videoId&&likeParams))return scripts_echoLog({text:'"getYtbToken" failed'}),!1;if(!doTask&&this.whiteList.likes.includes(videoId))return scripts_echoLog({type:"whiteList",text:"Youtube.unlikeVideo",id:videoId}),!0;const logStatus=scripts_echoLog({type:doTask?"likingYtbVideo":"unlikingYtbVideo",text:videoId});var nowTime=parseInt(String((new Date).getTime()/1e3),10);const likeVideoData={context:{client:client,request:{sessionId:request.sessionId,internalExperimentFlags:[],consistencyTokenJars:[]},user:{}},target:{videoId:videoId}};if(doTask){if(!likeParams)return logStatus.error("Empty likeParams"),!1;likeVideoData.params=likeParams}const{result,statusText,status,data}=await tools_httpRequest({url:`https://www.youtube.com/youtubei/v1/like/${doTask?"":"remove"}like?key=`+apiKey,method:"POST",headers:{origin:"https://www.youtube.com",referer:"https://www.youtube.com/watch?v="+videoId,"content-type":"application/json","x-goog-authuser":"0","x-goog-visitor-id":client.visitorData,"x-origin":"https://www.youtube.com",authorization:`SAPISIDHASH ${nowTime}_`+sha1(`${nowTime} ${this.#auth.PAPISID} https://www.youtube.com`)},data:JSON.stringify(likeVideoData)});return"Success"===result?200===data?.status?doTask&&data.responseText.includes("Added to Liked videos")||!doTask&&(data.responseText.includes("Removed from Liked videos")||data.responseText.includes("Dislike removed"))?(logStatus.success(),doTask&&(this.tasks.likes=unique([...this.tasks.likes,link])),!0):(logStatus.error(i18n("tryUpdateYtbAuth"),!0),!1):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Youtube.toggleLikeVideo"),!1}}async toggle({doTask=!0,channelLinks=[],videoLinks=[]}){try{if(!this.#initialized)return scripts_echoLog({text:i18n("needInit")}),!1;const prom=[];if(doTask&&!globalOptions.doTask.youtube.channels||!doTask&&!globalOptions.undoTask.youtube.channels)scripts_echoLog({type:"globalOptionsSkip",text:"youtube.channels"});else{var realChannels=this.getRealParams("channels",channelLinks,doTask,link=>/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)?link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)?.[1]:link);if(0/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)?link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)?.[1]:link);if(0!0)}catch(error){return throwError(error,"Youtube.toggle"),!1}}}const social_SteamASF=class{#asfOptions;#botName="asf";#groupInfo;async init(){try{var asfCommandsUrl=new URL("/Api/Command/",globalOptions.ASF.AsfIpcUrl);this.#asfOptions={url:asfCommandsUrl.href,method:"POST",responseType:"json",headers:{accept:"application/json","Content-Type":"application/json",Host:asfCommandsUrl.host,Origin:asfCommandsUrl.origin,Referer:asfCommandsUrl.href,Authentication:globalOptions.ASF.AsfIpcPassword}},globalOptions.ASF.AsfBotname&&(this.#botName=globalOptions.ASF.AsfBotname);const logStatus=scripts_echoLog({text:i18n("initingASF")});var{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:'{"Command":"!stats"}'});return"Success"===result?!0===data?.response?.Success&&"OK"===data.response.Message&&data.response.Result?(logStatus.success(),!0):(data?.response?.Result||data?.response?.Message?logStatus.error(data?.response?.Result||data.response.Message):logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"SteamASF.init"),!1}}async joinGroup(groupName){try{const logStatus=scripts_echoLog({type:"joiningSteamGroup",text:groupName}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!JOINGROUP ${this.#botName} `+groupName})});return"Success"===result?200===data?.status&&["已加入","已申请","Joined","Applied","Присоединился","costs"].find(text=>data.response?.Result?.includes(text))?(logStatus.success(),!0):(logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"SteamASF.joinGroup"),!1}}async leaveGroup(groupName){try{if(!this.#groupInfo&&!await this.#getGroupId())return!1;var groupId=await this.#groupInfo[groupName];if(!groupId)return!1;const logStatus=scripts_echoLog({type:"leavingSteamGroup",text:groupName}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!LEAVEGROUP ${this.#botName} `+groupId})});return"Success"===result?200===data?.status&&["成功","Success","Успех"].find(text=>data.response?.Result?.includes(text))?(logStatus.success(),!0):(logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"SteamASF.leaveGroup"),!1}}async#getGroupId(){try{const logStatus=scripts_echoLog({type:"gettingSteamGroupId",text:"All"}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:"!GROUPLIST "+this.#botName})});return"Success"===result?200===data?.status&&data.response?.Result?.includes("|")?(this.#groupInfo=Object.fromEntries(data.response.Result.split("\n").map(id=>{var[,name,id]=id.trim().split("|");return name&&id?[name,id]:null}).filter(ele=>ele)),logStatus.success(),!0):(logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"SteamASF.getGroupID"),!1}}async addToWishlist(gameId){try{const logStatus=scripts_echoLog({type:"addingToWishlist",text:gameId}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!ADDWISHLIST ${this.#botName} `+gameId})});return"Success"===result?200===data?.status&&["成功","Success","Успех"].find(text=>data.response?.Result?.includes(text))?(logStatus.success(),!0):(logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"SteamASF.addToWishlist"),!1}}async removeFromWishlist(gameId){try{const logStatus=scripts_echoLog({type:"removingFromWishlist",text:gameId}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!REMOVEWISHLIST ${this.#botName} `+gameId})});return"Success"===result?200===data?.status&&["成功","Success","Успех"].find(text=>data.response?.Result?.includes(text))?(logStatus.success(),!0):(logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"SteamASF.removeFromWishlist"),!1}}async toggleFollowGame(gameId,doTask){try{const logStatus=scripts_echoLog({type:`${doTask?"":"un"}followingGame`,text:gameId}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!${doTask?"":"UN"}FOLLOWGAME ${this.#botName} `+gameId})});return"Success"===result?200===data?.status&&["成功","Success","Успех"].find(text=>data.response?.Result?.includes(text))?(logStatus.success(),!0):(logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"SteamASF.toggleFollowGame"),!1}}async toggleCurator(curatorId,doTask=!0){try{const logStatus=scripts_echoLog({type:doTask?"followingCurator":"unfollowingCurator",text:curatorId}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!${doTask?"":"UN"}FOLLOWCURATOR ${this.#botName} `+curatorId})});return"Success"===result?200===data?.status&&["成功","Success","Успех"].find(text=>data.response?.Result?.includes(text))?(logStatus.success(),!0):(logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.toggleCurator"),!1}}async addLicense(id){try{const[type,ids]=id.split("-");if("appid"===type){const logStatus=scripts_echoLog({type:"addingFreeLicense",text:ids}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!addlicense ${this.#botName} app/`+ids})});return"Success"===result?200===data?.status&&["AlreadyPurchased","OK"].find(text=>data.response?.Result?.includes(text))?(logStatus.success(),!0):(logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}if("subid"!==type)return!1;{const idsArr=ids.split(","),logStatus=scripts_echoLog({type:"addingFreeLicenseSubid",text:ids}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!addlicense ${this.#botName} `+idsArr.map(id=>"sub/"+id).join(",")})});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200===data?.status&&data.response?.Result){const resultLines=data.response.Result.split("\n");return idsArr.forEach(subid=>{const targetLine=resultLines.find(text=>text.includes(subid));targetLine&&["成功","Success","Успех"].find(text=>targetLine.includes(text))?scripts_echoLog({}).success(targetLine):scripts_echoLog({}).error(targetLine)}),!0}return logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1}}catch(error){return throwError(error,"SteamASF.addLicense"),!1}}async requestPlayTestAccess(id){try{const logStatus=scripts_echoLog({type:"requestingPlayTestAccess",text:id}),{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!REQUESTACCESS ${this.#botName} `+id})});return"Success"===result?200===data?.status&&["成功","Success","Успех"].find(text=>data.response?.Result?.includes(text))?(logStatus.success(),!0):(logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.requestPlayTestAccess"),!1}}};const social_Steam=class extends dataSync{tasks;whiteList;#cache={group:{},officialGroup:{},forum:{},workshop:{},curator:{},...GM_getValue("steamCache")};#auth={};#storeInitialized=!1;#communityInitialized=!1;#area="CN";#areaStatus="end";#ASF;constructor(){super();var defaultTasksTemplate={groups:[],officialGroups:[],wishlists:[],follows:[],forums:[],workshops:[],workshopVotes:[],curators:[],curatorLikes:[],announcements:[],licenses:[],playtests:[]};this.tasks=defaultTasksTemplate,this.whiteList={...defaultTasksTemplate,...GM_getValue("whiteList")?.steam||{}}}async init(type="all"){try{return globalOptions.ASF.AsfEnabled&&globalOptions.ASF.AsfIpcUrl&&globalOptions.ASF.AsfIpcPassword?(this.#ASF=new social_SteamASF,!!await this.#ASF.init()&&(this.#storeInitialized=!0,this.#communityInitialized=!0)):"store"===type?!!this.#storeInitialized||(this.#storeInitialized=await this.#updateStoreAuth(),this.#storeInitialized?(scripts_echoLog({}).success(i18n("initSuccess","SteamStore")),!0):(scripts_echoLog({}).error(i18n("initFailed","Steam")),!1)):"community"===type?!!this.#communityInitialized||(this.#communityInitialized=await this.#updateCommunityAuth(),this.#communityInitialized?(scripts_echoLog({}).success(i18n("initSuccess","SteamCommunity")),!0):(scripts_echoLog({}).error(i18n("initFailed","Steam")),!1)):(this.#storeInitialized=await this.#updateStoreAuth(),this.#communityInitialized=await this.#updateCommunityAuth(),this.#storeInitialized&&this.#communityInitialized?(scripts_echoLog({}).success(i18n("initSuccess","Steam")),!0):(scripts_echoLog({}).error(i18n("initFailed","Steam")),!1))}catch(error){return throwError(error,"Steam.init"),!1}}async#refreshStoreToken(){try{const logStatus=scripts_echoLog({text:i18n("refreshingToken",i18n("steamStore"))}),formData=new FormData;formData.append("redir","https://store.steampowered.com/");var{result,statusText,status,data}=await tools_httpRequest({url:"https://login.steampowered.com/jwt/ajaxrefresh",method:"POST",responseType:"json",headers:{Host:"login.steampowered.com",Origin:"https://store.steampowered.com",Referer:"https://store.steampowered.com/"},data:formData});return"Success"===result?data?.response?.success?await this.#setStoreToken(data.response)?(logStatus.success(),!0):(logStatus.error("Error"),!1):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.refreshStoreToken"),!1}}async#setStoreToken(param){try{const logStatus=scripts_echoLog({text:i18n("settingToken",i18n("steamStore"))}),formData=new FormData;formData.append("steamID",param.steamID),formData.append("nonce",param.nonce),formData.append("redir",param.redir),formData.append("auth",param.auth);var{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/login/settoken",method:"POST",headers:{Accept:"application/json, text/plain, */*",Host:"store.steampowered.com",Origin:"https://store.steampowered.com",Referer:"https://store.steampowered.com/login"},data:formData});return"Success"===result?200===data?.status?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.setStoreToken"),!1}}async#updateStoreAuth(){try{const logStatus=scripts_echoLog({text:i18n("updatingAuth",i18n("steamStore"))}),{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/",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("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;if(!data.responseText.includes("data-miniprofile="))return await this.#refreshStoreToken(),logStatus.error("Error:"+i18n("needLoginSteamStore"),!0),!1;var storeSessionID=data.responseText.match(/g_sessionID = "(.+?)";/)?.[1];return storeSessionID?(this.#auth.storeSessionID=storeSessionID,logStatus.success(),!0):(logStatus.error('Error: Get "sessionID" failed'),!1)}catch(error){return throwError(error,"Steam.updateStoreAuth"),!1}}async#updateCommunityAuth(){try{const logStatus=scripts_echoLog({text:i18n("updatingAuth",i18n("steamCommunity"))}),{result,statusText,status,data}=await tools_httpRequest({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","Cache-Control":"max-age=0","Sec-Fetch-Dest":"document","Sec-Fetch-Mode":"navigate","Upgrade-Insecure-Requests":"1"}});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;if(data.finalUrl.includes("https://steamcommunity.com/login/home"))return logStatus.error("Error:"+i18n("needLoginSteamCommunity"),!0),!1;var steam64Id=data.responseText.match(/g_steamID = "(.+?)";/)?.[1],communitySessionID=data.responseText.match(/g_sessionID = "(.+?)";/)?.[1],userName=data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)?.[1];return(steam64Id&&(this.#auth.steam64Id=steam64Id),userName&&(this.#auth.userName=userName),communitySessionID)?(this.#auth.communitySessionID=communitySessionID,logStatus.success(),!0):(logStatus.error('Error: Get "sessionID" failed'),!1)}catch(error){return throwError(error,"Steam.updateCommunityAuth"),!1}}async#getAreaInfo(){try{const logStatus=scripts_echoLog({text:i18n("gettingAreaInfo")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/cart/",method:"GET"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),{};if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),{};{var cartConfigRaw=data.responseText.match(/data-cart_config="(.*?)"/)?.[1];const temp=document.createElement("div");temp.innerHTML=cartConfigRaw||"{}";var cartConfigStr=temp.textContent||temp.innerText;let cartConfig;try{cartConfig=JSON.parse(cartConfigStr)}catch(error){return logStatus.error("Error: get country info filed"),console.error(error),{}}if(!cartConfig.rgUserCountryOptions)return logStatus.warning("Warning: Area cannot be changed"),{};var userInfoRaw=data.responseText.match(/data-userinfo="(.*?)"/)?.[1];const temp1=document.createElement("div");temp1.innerHTML=userInfoRaw||"{}";var userInfoStr=temp1.textContent||temp1.innerText;let userInfo;try{userInfo=JSON.parse(userInfoStr)}catch(error){return logStatus.error("Error: get country info filed"),console.error(error),{}}var currentArea=userInfo.country_code,areas=Object.keys(cartConfig.rgUserCountryOptions).filter(area=>"help"!==area);return currentArea&&0{const checker=setInterval(()=>{"waiting"!==this.#areaStatus&&(clearInterval(checker),resolve(!0))})}),this.#area===area||!area&&"CN"!==this.#area)return!0;this.#areaStatus="waiting";let aimedArea=area;if(!aimedArea){const{currentArea,areas}=await this.#getAreaInfo();if(!currentArea||!areas)return!(this.#areaStatus="error");if("CN"!==currentArea)return this.#areaStatus="skip",scripts_echoLog({text:"notNeededChangeArea"}),"skip";var anotherArea=areas.filter(area=>area&&"CN"!==area);if(!anotherArea||0===anotherArea.length)return this.#areaStatus="noAnotherArea",scripts_echoLog({text:"noAnotherArea"}),!1;[aimedArea]=anotherArea}const logStatus=scripts_echoLog({text:i18n("changingArea",aimedArea)});var{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/country/setcountry",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({cc:aimedArea,sessionid:this.#auth.storeSessionID})});if("Success"!==result)return this.#areaStatus="error",logStatus.error(result+`:${statusText}(${status})`),"CN";if(200!==data?.status||"true"!==data.responseText)return this.#areaStatus="error",logStatus.error(`Error:${data?.statusText}(${data?.status})`),"CN";var currentArea=(await this.#getAreaInfo())["currentArea"];return currentArea===aimedArea?(this.#areaStatus="success",logStatus.success(),currentArea):(this.#areaStatus="error",logStatus.error("Error: change country filed"),"CN")}catch(error){return this.#areaStatus="error",throwError(error,"Steam.changeArea"),!1}}async#joinGroup(groupName){try{if(this.#ASF)return!!await this.#ASF.joinGroup(groupName)&&(this.tasks.groups=unique([...this.tasks.groups,groupName]),!0);const logStatus=scripts_echoLog({type:"joiningSteamGroup",text:groupName}),{result,statusText,status,data}=await tools_httpRequest({url:"https://steamcommunity.com/groups/"+groupName,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({action:"join",sessionID:this.#auth.communitySessionID})});return"Success"===result?200!==data?.status||data.responseText.includes("grouppage_join_area")?(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.success(),this.tasks.groups=unique([...this.tasks.groups,groupName]),!0):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.joinGroup"),!1}}async#leaveGroup(groupName){try{if(this.whiteList.groups.includes(groupName))return scripts_echoLog({type:"whiteList",text:"Steam.leaveGroup",id:groupName}),!0;if(this.#ASF)return await this.#ASF.leaveGroup(groupName);var groupId=await this.#getGroupId(groupName);if(!groupId)return!1;const logStatus=scripts_echoLog({type:"leavingSteamGroup",text:groupName}),{result,statusText,status,data}=await tools_httpRequest({url:`https://steamcommunity.com/id/${this.#auth.userName}/home_process`,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({sessionID:this.#auth.communitySessionID,action:"leaveGroup",groupId:groupId})});return"Success"===result?200===data?.status&&data.finalUrl.includes("groups")&&0===$(data.responseText.replace(//g,"").toLowerCase()).find(`a[href='https://steamcommunity.com/groups/${groupName.toLowerCase()}']`).length?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.leaveGroup"),!1}}async#getGroupId(groupName){try{const logStatus=scripts_echoLog({type:"gettingSteamGroupId",text:groupName});var groupId=this.#cache.group[groupName];if(groupId)return logStatus.success(),groupId;const{result,statusText,status,data}=await tools_httpRequest({url:"https://steamcommunity.com/groups/"+groupName,method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{const groupId=data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)?.[1];return groupId?(this.#setCache("group",groupName,groupId),logStatus.success(),groupId):(logStatus.error(`Error:${data.statusText}(${data.status})`),!1)}}catch(error){return throwError(error,"Steam.getGroupID"),!1}}async#joinOfficialGroup(gameId){try{if(this.#ASF)return!!await this.#ASF.joinGroup(gameId)&&(this.tasks.officialGroups=unique([...this.tasks.officialGroups,gameId]),!0);const logStatus=scripts_echoLog({type:"joiningSteamOfficialGroup",text:gameId}),{result,statusText,status,data}=await tools_httpRequest({url:`https://steamcommunity.com/games/${gameId}?action=join&sessionID=`+this.#auth.communitySessionID,method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status||data.responseText.includes('id="publicGroupJoin"'))return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;logStatus.success(),this.tasks.officialGroups=unique([...this.tasks.officialGroups,gameId]);var groupId=data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)?.[1];return groupId&&this.#setCache("officialGroup",gameId,groupId),!0}catch(error){return throwError(error,"Steam.joinOfficialGroup"),!1}}async#leaveOfficialGroup(gameId){try{if(this.whiteList.officialGroups.includes(gameId))return scripts_echoLog({type:"whiteList",text:"Steam.leaveOfficialGroup",id:gameId}),!0;if(this.#ASF)return await this.#ASF.leaveGroup(gameId);var groupId=await this.#getOfficialGroupId(gameId);if(!groupId)return!1;const logStatus=scripts_echoLog({type:"leavingSteamOfficialGroup",text:gameId});var{result,statusText,status,data}=await tools_httpRequest({url:`https://steamcommunity.com/id/${this.#auth.userName}/home_process`,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({sessionID:this.#auth.communitySessionID,action:"leaveGroup",groupId:groupId})});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{const{result:resultR,statusText:statusTextR,status:statusR,data:dataR}=await tools_httpRequest({url:"https://steamcommunity.com/games/"+gameId,method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});return"Success"===resultR?200===dataR?.status&&dataR.responseText.includes('id="publicGroupJoin"')?(logStatus.success(),!0):(logStatus.error(`Error:${dataR?.statusText}(${dataR?.status})`),!1):(logStatus.error(resultR+`:${statusTextR}(${statusR})`),!1)}}catch(error){return throwError(error,"Steam.leaveOfficialGroup"),!1}}async#getOfficialGroupId(gameId){try{const logStatus=scripts_echoLog({type:"gettingSteamOfficialGroupId",text:gameId});var groupId=this.#cache.officialGroup[gameId];if(groupId)return logStatus.success(),groupId;const{result,statusText,status,data}=await tools_httpRequest({url:"https://steamcommunity.com/games/"+gameId,method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{const groupId=data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)?.[1];return groupId?(this.#setCache("officialGroup",gameId,groupId),logStatus.success(),groupId):(logStatus.error(`Error:${data.statusText}(${data.status})`),!1)}}catch(error){return throwError(error,"Steam.getGroupID"),!1}}async#addToWishlist(gameId){try{if(this.#ASF)return!!await this.#ASF.addToWishlist(gameId)&&(this.tasks.wishlists=unique([...this.tasks.wishlists,gameId]),!0);const logStatus=scripts_echoLog({type:"addingToWishlist",text:gameId});var{result,data}=await tools_httpRequest({url:"https://store.steampowered.com/api/addtowishlist",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({sessionid:this.#auth.storeSessionID,appid:gameId}),dataType:"json"});if("Success"===result&&200===data?.status&&!0===data.response?.success)return logStatus.success(),this.tasks.wishlists=unique([...this.tasks.wishlists,gameId]),!0;const{result:resultR,statusText:statusTextR,status:statusR,data:dataR}=await tools_httpRequest({url:"https://store.steampowered.com/app/"+gameId,method:"GET"});return"Success"===resultR?200===dataR?.status?"CN"===this.#area&&dataR.responseText.includes('id="error_box"')?(logStatus.warning(i18n("changeAreaNotice")),!!await this.#changeArea()&&await this.#addToWishlist(gameId)):(!dataR.responseText.includes('class="queue_actions_ctn"')||!dataR.responseText.includes('class="already_in_library"'))&&(dataR.responseText.includes('class="queue_actions_ctn"')&&dataR.responseText.includes('id="add_to_wishlist_area_success" style="display: none;')||!dataR.responseText.includes('class="queue_actions_ctn"'))?(logStatus.error(`Error:${dataR.statusText}(${dataR.status})`),!1):(logStatus.success(),this.tasks.wishlists=unique([...this.tasks.wishlists,gameId]),!0):(logStatus.error(`Error:${dataR?.statusText}(${dataR?.status})`),!1):(logStatus.error(resultR+`:${statusTextR}(${statusR})`),!1)}catch(error){return throwError(error,"Steam.addToWishlist"),!1}}async#removeFromWishlist(gameId){try{if(this.whiteList.wishlists.includes(gameId))return scripts_echoLog({type:"whiteList",text:"Steam.removeFromWishlist",id:gameId}),!0;if(this.#ASF)return await this.#ASF.removeFromWishlist(gameId);const logStatus=scripts_echoLog({type:"removingFromWishlist",text:gameId});var{result,data}=await tools_httpRequest({url:"https://store.steampowered.com/api/removefromwishlist",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({sessionid:this.#auth.storeSessionID,appid:gameId}),dataType:"json"});if("Success"===result&&200===data?.status&&!0===data.response?.success)return logStatus.success(),!0;const{result:resultR,statusText:statusTextR,status:statusR,data:dataR}=await tools_httpRequest({url:"https://store.steampowered.com/app/"+gameId,method:"GET"});if("Success"!==resultR)return logStatus.error(resultR+`:${statusTextR}(${statusR})`),!1;if(200!==dataR?.status)return logStatus.error(`Error:${dataR?.statusText}(${dataR?.status})`),!1;if("CN"===this.#area&&dataR.responseText.includes('id="error_box"')){logStatus.warning(i18n("changeAreaNotice"));const result=await this.#changeArea();return result&&"CN"!==result&&"skip"!==result?await this.#removeFromWishlist(gameId):!1}return dataR.responseText.includes('class="queue_actions_ctn"')&&(dataR.responseText.includes("ds_owned_flag ds_flag")||dataR.responseText.includes("add_to_wishlist_area"))?(logStatus.success(),!0):(logStatus.error(`Error:${dataR.statusText}(${dataR.status})`),!1)}catch(error){return throwError(error,"Steam.removeFromWishlist"),!1}}async#toggleFollowGame(gameId,doTask){try{if(!doTask&&this.whiteList.follows.includes(gameId))return scripts_echoLog({type:"whiteList",text:"Steam.unfollowGame",id:gameId}),!0;if(this.#ASF)return!!await this.#ASF.toggleFollowGame(gameId,doTask)&&(doTask&&(this.tasks.follows=unique([...this.tasks.follows,gameId])),!0);const logStatus=scripts_echoLog({type:`${doTask?"":"un"}followingGame`,text:gameId}),requestData={sessionid:this.#auth.storeSessionID,appid:gameId};doTask||(requestData.unfollow="1");var{result,data}=await tools_httpRequest({url:"https://store.steampowered.com/explore/followgame/",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param(requestData)});if("Success"===result&&200===data?.status&&"true"===data.responseText)return logStatus.success(),!0;var followed=await this.#isFollowedGame(gameId);return"CN"===this.#area&&"areaLocked"===followed?(logStatus.warning(i18n("changeAreaNotice")),!!await this.#changeArea()&&await this.#removeFromWishlist(gameId)):doTask===followed?(logStatus.success(),doTask&&(this.tasks.follows=unique([...this.tasks.follows,gameId])),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1)}catch(error){return throwError(error,"Steam.toggleFollowGame"),!1}}async#isFollowedGame(gameId){try{const{result,data}=await tools_httpRequest({url:"https://store.steampowered.com/app/"+gameId,method:"GET"});return"Success"===result?200===data?.status&&("CN"===this.#area&&data.responseText.includes('id="error_box"')?"areaLocked":"none"!==$(data.responseText.replace(//g,"")).find(".queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active").css("display")):!1}catch(error){return throwError(error,"Steam.isFollowedGame"),!1}}async#toggleForum(gameId,doTask=!0){try{if(!doTask&&this.whiteList.forums.includes(gameId))return scripts_echoLog({type:"whiteList",text:"Steam.unsubscribeForum",id:gameId}),!0;const forumId=await this.#getForumId(gameId);if(!forumId)return!1;const logStatus=scripts_echoLog({type:`${doTask?"":"un"}subscribingForum`,text:gameId});var[id,feature]=forumId.split("_"),{result,statusText,status,data}=await tools_httpRequest({url:`https://steamcommunity.com/forum/${id}/General/${doTask?"":"un"}subscribe/${feature||"0"}/`,method:"POST",responseType:"json",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({sessionid:this.#auth.communitySessionID})});return"Success"===result?(200!==data?.status||1!==data.response?.success&&29!==data.response?.success?logStatus.error(`Error:${data?.statusText}(${data?.status})`):(doTask&&(this.tasks.forums=unique([...this.tasks.forums,gameId])),logStatus.success()),!0):(logStatus.error(result+`:${statusText}(${status})`),!0)}catch(error){return throwError(error,"Steam.toggleForum"),!0}}async#getForumId(gameId){try{const logStatus=scripts_echoLog({type:"gettingForumId",text:gameId});var forumId=this.#cache.forum[gameId];if(forumId)return logStatus.success(),forumId;const{result,statusText,status,data}=await tools_httpRequest({url:`https://steamcommunity.com/app/${gameId}/discussions/`,method:"GET"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{const forumId=data.responseText?.match(/General_([\d]+(_[\d]+)?)/)?.[1];return forumId?(this.#setCache("forum",gameId,forumId),logStatus.success(),forumId):(logStatus.error(`Error:${data.statusText}(${data.status})`),!1)}}catch(error){return throwError(error,"Steam.getForumId"),!1}}async#toggleFavoriteWorkshop(id,doTask=!0){try{if(!doTask&&this.whiteList.workshops.includes(id))return scripts_echoLog({type:"whiteList",text:"Steam.unfavoriteWorkshop",id:id}),!0;var appid=await this.#getWorkshopAppId(id);if(!appid)return!1;const logStatus=scripts_echoLog({type:doTask?"favoritingWorkshop":"unfavoritingWorkshop",text:id});var{result,statusText,status,data}=await tools_httpRequest({url:`https://steamcommunity.com/sharedfiles/${doTask?"":"un"}favorite`,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({id:id,appid:appid,sessionid:this.#auth.communitySessionID})});return"Success"===result?200!==data?.status||data.responseText?(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(doTask&&(this.tasks.workshops=unique([...this.tasks.workshops,id])),logStatus.success(),!0):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.toggleFavoriteWorkshop"),!1}}async#getWorkshopAppId(id){try{const logStatus=scripts_echoLog({type:"gettingWorkshopAppId",text:id});var appId=this.#cache.workshop[id];if(appId)return logStatus.success(),appId;const{result,statusText,status,data}=await tools_httpRequest({url:"https://steamcommunity.com/sharedfiles/filedetails/?id="+id,method:"GET"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{const appId=data.responseText.match(//)?.[1];return appId?(this.#setCache("workshop",id,appId),logStatus.success(),appId):(logStatus.error("Error: getWorkshopAppId failed"),!1)}}catch(error){return throwError(error,"Steam.getWorkshopAppId"),!1}}async#voteUpWorkshop(id){try{const logStatus=scripts_echoLog({type:"votingUpWorkshop",text:id});var{result,statusText,status,data}=await tools_httpRequest({url:"https://steamcommunity.com/sharedfiles/voteup",method:"POST",responseType:"json",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({id:id,sessionid:this.#auth.communitySessionID})});return"Success"===result?(200===data?.status&&1===data.response?.success?logStatus.success():logStatus.error(`Error:${data?.statusText}(${data?.status})`),!0):(logStatus.error(result+`:${statusText}(${status})`),!0)}catch(error){return throwError(error,"Steam.voteupWorkshop"),!0}}async#toggleCurator(curatorId,doTask=!0){try{if(!doTask&&this.whiteList.curators.includes(curatorId))return scripts_echoLog({type:"whiteList",text:"Steam.unfollowCurator",id:curatorId}),!0;if(this.#ASF)return await this.#ASF.toggleCurator(curatorId,doTask);const logStatus=scripts_echoLog({type:doTask?"followingCurator":"unfollowingCurator",text:curatorId});var{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/curators/ajaxfollow",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},data:$.param({clanid:curatorId,sessionid:this.#auth.storeSessionID,follow:doTask}),dataType:"json"});return"Success"===result?200===data?.status&&1===data.response?.success?.success?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(`+data?.response?.success||data?.status+")"),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.toggleCurator"),!1}}async getCuratorId(path,name){try{const logStatus=scripts_echoLog({type:"gettingCuratorId",text:path+"/"+name});var curatorId=this.#cache.curator[path+"/"+name];if(curatorId)return logStatus.success(),curatorId;const{result,statusText,status,data}=await tools_httpRequest({url:`https://store.steampowered.com/${path}/`+name,method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{const curatorId=data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)?.[1];return curatorId?(this.#setCache("curator",path+"/"+name,curatorId),logStatus.success(),curatorId):(logStatus.error(`Error:${data.statusText}(${data.status})`),!1)}}catch(error){return throwError(error,"Steam.getCuratorID"),!1}}async#toggleCuratorLike(link,doTask=!0){try{var[path,name]=link.split("/");if(!path||!name)return scripts_echoLog({text:i18n("errorLink",link)}),!1;var curatorId=await this.getCuratorId(path,name);return curatorId?await this.#toggleCurator(curatorId,doTask):!1}catch(error){return throwError(error,"Steam.toggleCuratorLike"),!1}}async#getAnnouncementParams(appId,viewId){try{const logStatus=scripts_echoLog({type:"gettingAnnouncementParams",text:appId,id:viewId});var{result,statusText,status,data}=await tools_httpRequest({url:`https://store.steampowered.com/events/ajaxgetpartnerevent?appid=${appId}&announcement_gid=${viewId}&lang_list=6_0&last_modified_time=0&origin=https:%2F%2Fstore.steampowered.com&for_edit=false`,method:"GET",responseType:"json",headers:{Host:"store.steampowered.com",Referer:`https://store.steampowered.com/news/app/${appId}/view/`+viewId}});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),{};if(200!==data?.status||1!==data?.response?.success)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),{};var{clanid,gid}=data.response.event?.announcement_body||{};return clanid?(logStatus.success(),{clanId:clanid,gid:gid}):(logStatus.error(`Error:${data.statusText}(${data.status})`),{})}catch(error){return throwError(error,"Steam.likeAnnouncement"),{}}}async#likeAnnouncement(id){try{var[appId,viewId]=id.split("/");if(!appId||!viewId)return scripts_echoLog({}).error(i18n("missParams")+"(id)"),!1;var{clanId,gid}=await this.#getAnnouncementParams(appId,viewId);if(!clanId)return!1;const logStatus=scripts_echoLog({type:"likingAnnouncement",text:appId,id:viewId});var{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/updated/ajaxrateupdate/"+(gid||viewId),method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",Host:"store.steampowered.com",Origin:"https://store.steampowered.com",Referer:`https://store.steampowered.com/news/app/${appId}/view/`+viewId},data:$.param({sessionid:this.#auth.storeSessionID,voteup:1,clanid:clanId,ajax:1}),dataType:"json"});return"Success"===result?200===data?.status&&1===data.response.success?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.likeAnnouncement"),!1}}async#appid2subid(id){try{const logStatus=scripts_echoLog({type:"gettingSubid",text:id}),{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/app/"+id,method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;if("CN"===this.#area&&data.responseText.includes('id="error_box"')){logStatus.warning(i18n("changeAreaNotice"));const result=await this.#changeArea();return result&&"CN"!==result&&"skip"!==result?await this.#appid2subid(id):!1}var subid=data.responseText.match(/name="subid" value="([\d]+?)"/)?.[1];return subid?(logStatus.success(),subid):(logStatus.error(`Error:${data.statusText}(${data.status})`),!1)}catch(error){return throwError(error,"Steam.appid2subid"),!1}}async#getLicenses(){try{const logStatus=scripts_echoLog({text:i18n("gettingLicenses")});var{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/dynamicstore/userdata/?t="+(new Date).getTime(),method:"GET",responseType:"json"});return"Success"===result?200===data?.status?(logStatus.success(),data.response?.rgOwnedPackages):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.getLicenses"),!1}}async#addLicense(id){try{if(this.#ASF)return await this.#ASF.addLicense(id);const[type,ids]=id.split("-");if("appid"===type){var subid=await this.#appid2subid(ids);if(!subid)return!1;const logStatus=scripts_echoLog({type:"addingFreeLicense",text:ids});if(!await this.#addFreeLicense(subid,logStatus))return!1;const{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/app/"+ids,method:"GET"});return"Success"===result?200===data?.status?data.responseText.includes("ds_owned_flag ds_flag")||data.responseText.includes('class="already_in_library"')?(logStatus.success(),!0):(logStatus.error(`Error:${data.statusText}(${data.status})`),!1):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}if("subid"!==type)return!1;{"CN"===this.#area&&(scripts_echoLog({}).success(i18n("tryChangeAreaNotice")),await this.#changeArea());const logStatusArr={};var idsArr=ids.split(",");for(const subid of idsArr){var logStatus=scripts_echoLog({type:"addingFreeLicenseSubid",text:subid});if(!await this.#addFreeLicense(subid,logStatus))return!1;logStatusArr[subid]=logStatus}const licenses=await this.#getLicenses();if(!licenses)return!1;for(const subid of idsArr)licenses.includes(parseInt(subid,10))?logStatusArr[subid].success():logStatusArr[subid].error();return!0}}catch(error){return throwError(error,"Steam.addLicense"),!1}}async#addFreeLicense(id,logStatusPre){try{const logStatus=logStatusPre||scripts_echoLog({type:"addingFreeLicenseSubid",text:id}),{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/checkout/addfreelicense",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",Host:"store.steampowered.com",Origin:"https://store.steampowered.com",Referer:"https://store.steampowered.com/account/licenses/"},data:$.param({action:"add_to_cart",sessionid:this.#auth.storeSessionID,subid:id}),dataType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;if("CN"===this.#area&&data.responseText.includes('id="error_box"')){logStatus.warning(i18n("changeAreaNotice"));const result=await this.#changeArea();return result&&"CN"!==result?await this.#addFreeLicense(id):!1}return logStatus.success(),!0}catch(error){return throwError(error,"Steam.addFreeLicense"),!1}}async#requestPlayTestAccess(id){try{if(this.#ASF)return await this.#ASF.requestPlayTestAccess(id);const logStatus=scripts_echoLog({type:"requestingPlayTestAccess",text:id});var{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/ajaxrequestplaytestaccess/"+id,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",Host:"store.steampowered.com",Origin:"https://store.steampowered.com",Referer:"https://store.steampowered.com/app/"+id},data:$.param({sessionid:this.#auth.storeSessionID}),dataType:"json"});return"Success"===result?200===data?.status&&1===data?.response?.success?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.requestPlayTestAccess"),!1}}async toggle({doTask=!0,groupLinks=[],officialGroupLinks=[],wishlistLinks=[],followLinks=[],forumLinks=[],workshopLinks=[],workshopVoteLinks=[],curatorLinks=[],curatorLikeLinks=[],announcementLinks=[],licenseLinks=[],playtestLinks=[]}){try{if(0<[...groupLinks,...officialGroupLinks,...forumLinks,...workshopLinks,...workshopVoteLinks].length&&!this.#communityInitialized)return scripts_echoLog({text:i18n("needInit")}),!1;if(0<[...wishlistLinks,...followLinks,...curatorLinks,...curatorLikeLinks,...announcementLinks,...licenseLinks,...playtestLinks].length&&!this.#storeInitialized)return scripts_echoLog({text:i18n("needInit")}),!1;const prom=[];if(doTask&&!globalOptions.doTask.steam.groups||!doTask&&!globalOptions.undoTask.steam.groups)scripts_echoLog({type:"globalOptionsSkip",text:"steam.groups"});else{var realGroups=this.getRealParams("groups",groupLinks,doTask,link=>link.match(/groups\/(.+)\/?/)?.[1]);if(0link.match(/games\/(.+)\/?/)?.[1]);if(0link.match(/app\/([\d]+)/)?.[1]);if(0link.match(/app\/([\d]+)/)?.[1]);if(0link.match(/app\/([\d]+)/)?.[1]);if(0link.match(/\?id=([\d]+)/)?.[1]);if(0link.match(/\?id=([\d]+)/)?.[1]);if(doTask&&0link.match(/curator\/([\d]+)/)?.[1]),realCuratorLikes=this.getRealParams("curatorLikes",curatorLikeLinks,doTask,link=>link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)?.slice(1,3).join("/"));if(0(link.includes("store.steampowered.com")?link.match(/store\.steampowered\.com\/news\/app\/([\d]+)\/view\/([\d]+)/):link.match(/steamcommunity\.com\/games\/([\d]+)\/announcements\/detail\/([\d]+)/))?.slice(1,3).join("/"));if(doTask&&0link.match(/app\/([\d]+)/)?.[1]);if(doTask&&globalOptions.doTask.steam.playtests&&0("CN"!==this.#area&&(scripts_echoLog({}).warning(i18n("steamFinishNotice")),await this.#changeArea("CN")),!0))}catch(error){return throwError(error,"Steam.toggle"),!1}}#setCache(type,name,id){try{this.#cache[type][name]=id,GM_setValue("steamCache",this.#cache)}catch(error){throwError(error,"Steam.setCache")}}};var website_Website=class{undoneTasks;socialTasks;giveawayId;socialInitialized={discord:!1,instagram:!1,reddit:!1,twitch:!1,twitter:!1,vk:!1,youtube:!1,steamStore:!1,steamCommunity:!1};initialized=!1;social={};async#bind(name,init){try{return{name:name,result:await init}}catch(error){return throwError(error,"Website.bind"),{name:name,result:!1}}}async initSocial(action){try{const pro=[],tasks="do"===action?this.undoneTasks:this.socialTasks;var steamLength,steamCommunityLength;return tasks.discord&&(!(0[...total,...arr]).length)||this.socialInitialized.discord&&this.social.discord||(this.social.discord=new social_Discord,pro.push(this.#bind("discord",this.social.discord.init(action))))),tasks.instagram&&(!(0[...total,...arr]).length)||this.socialInitialized.instagram&&this.social.instagram||(this.social.instagram=new social_Instagram,pro.push(this.#bind("instagram",this.social.instagram.init())))),tasks.reddit&&(!(0[...total,...arr]).length)||this.socialInitialized.reddit&&this.social.reddit||(this.social.reddit=new social_Reddit,pro.push(this.#bind("reddit",this.social.reddit.init())))),tasks.twitch&&(!(0[...total,...arr]).length)||this.socialInitialized.twitch&&this.social.twitch||(this.social.twitch=new social_Twitch,pro.push(this.#bind("twitch",this.social.twitch.init())))),tasks.twitter&&(!(0[...total,...arr]).length)||this.socialInitialized.twitter&&this.social.twitter||(this.social.twitter=new social_Twitter,pro.push(this.#bind("twitter",this.social.twitter.init())))),tasks.vk&&(!(0[...total,...arr]).length)||this.socialInitialized.vk&&this.social.vk||(this.social.vk=new social_Vk,pro.push(this.#bind("vk",this.social.vk.init())))),tasks.youtube&&(!(0[...total,...arr]).length)||this.socialInitialized.youtube&&this.social.youtube||(this.social.youtube=new Youtube,pro.push(this.#bind("youtube",this.social.youtube.init())))),!tasks.steam||0<(steamLength=Object.values(tasks.steam).reduce((total,arr)=>[...total,...arr]).length)&&(this.social.steam||(this.social.steam=new social_Steam),0["groupLinks","officialGroupLinks","forumLinks","workshopLinks","workshopVoteLinks"].includes(type)&&tasks.steam?.[type]?.length||0).reduce((total,number)=>total+number,0))&&!this.socialInitialized.steamStore&&pro.push(this.#bind("steamStore",this.social.steam.init("store"))),0{let checked=!0;for(const data of result)data.result?this.socialInitialized[data.name]=data.result:checked=!1;return checked})}catch(error){return throwError(error,"Website.initSocial"),!1}}uniqueTasks(allTasks){const result={};for(var[social,types]of Object.entries(allTasks)){result[social]={};for(var[type,tasks]of Object.entries(types))result[social][type]=unique(tasks)}return result}async toggleTask(action){try{if(!this.initialized&&!this.init())return!1;if(!await this.classifyTask(action))return!1;if(!await this.initSocial(action))return!1;const pro=[];var doTask="do"===action,tasks=doTask?this.undoneTasks:this.socialTasks;if("skip"!==this.socialInitialized.discord&&this.social.discord&&pro.push(this.social.discord.toggle({doTask:doTask,...tasks.discord})),this.social.instagram&&pro.push(this.social.instagram.toggle({doTask:doTask,...tasks.instagram})),this.social.reddit&&pro.push(this.social.reddit.toggle({doTask:doTask,...tasks.reddit})),this.social.twitch&&pro.push(this.social.twitch.toggle({doTask:doTask,...tasks.twitch})),this.social.twitter&&pro.push(this.social.twitter.toggle({doTask:doTask,...tasks.twitter})),this.social.vk&&pro.push(this.social.vk.toggle({doTask:doTask,...tasks.vk})),this.social.youtube&&pro.push(this.social.youtube.toggle({doTask:doTask,...tasks.youtube})),this.social.steam&&pro.push(this.social.steam.toggle({doTask:doTask,...tasks.steam})),this.social.visitLink&&tasks.links&&doTask)for(const link of tasks.links)pro.push(this.social.visitLink(link));return doTask&&tasks.extra&&this.extraDoTask&&0[...total,...arr]).length&&pro.push(this.extraDoTask(tasks.extra)),await Promise.all(pro),scripts_echoLog({}).success(i18n("allTasksComplete")),!0}catch(error){return throwError(error,"Website.toggleTask"),!1}}async doTask(){try{return await this.toggleTask("do")}catch(error){return throwError(error,"Website.doTask"),!1}}async undoTask(){try{return await this.toggleTask("undo")}catch(error){return throwError(error,"Website.undoTask"),!1}}};const defaultTasks=JSON.stringify({steam:{groupLinks:[],wishlistLinks:[],curatorLinks:[],followLinks:[]},vk:{nameLinks:[]}});var Freeanywhere=class extends website_Website{name="FreeAnyWhere";tasks=[];socialTasks=JSON.parse(defaultTasks);undoneTasks=JSON.parse(defaultTasks);buttons=["doTask","undoTask","verifyTask","getKey"];static test(){return"freeanywhere.net"===window.location.host}async init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});if(0<$('a[href="#/login"]').length)return window.open("/#/login","_self"),logStatus.warning(i18n("needLogin")),!1;if(window.location.href.includes("/login"))return logStatus.warning(i18n("needLogin")),!1;if(!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)){var id=window.location.href.match(/https?:\/\/freeanywhere\.net\/.*?#\/giveaway\/([\d]+)/)?.[1];if(!id)return logStatus.error(i18n("getFailed","Id")),!1;window.location.href="https://freeanywhere.net/#/giveaway/"+id}return this.#getGiveawayId()?(await this.#checkLeftKey()||scripts_echoLog({}).warning(i18n("checkLeftKeyFailed")),this.initialized=!0,logStatus.success(),!0):!1}catch(error){return throwError(error,"Freeanywhere.init"),!1}}async classifyTask(action){try{const logStatus=scripts_echoLog({text:i18n("getTasksInfo")});"undo"===action&&(this.socialTasks=GM_getValue("fawTasks-"+this.giveawayId)?.tasks||JSON.parse(defaultTasks));var{result,statusText,status,data}=await tools_httpRequest({url:`https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,method:"GET",headers:{authorization:"Token "+window.localStorage.getItem("token"),"x-csrftoken":external_Cookies_namespaceObject.get("csrftoken")},responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;var tasks=data?.response?.challenges;if(tasks){"verify"===action&&(this.tasks=[]);for(const task of tasks){var type=task.challenge,social=task.challenge_provider;const taskInfo={id:task.id,title:task.title};if("verify"!==action||task.is_success)switch(social){case"steam":switch(taskInfo.social="steam",type){case"WL":"undo"===action&&this.socialTasks.steam.wishlistLinks.push(task.link),"do"!==action||task.is_success||this.undoneTasks.steam.wishlistLinks.push(task.link);break;case"JTG":"undo"===action&&this.socialTasks.steam.groupLinks.push(task.link),"do"!==action||task.is_success||this.undoneTasks.steam.groupLinks.push(task.link);break;case"STC":"undo"===action&&this.socialTasks.steam.curatorLinks.push(task.link),"do"!==action||task.is_success||this.undoneTasks.steam.curatorLinks.push(task.link);break;case"GF":"undo"===action&&this.socialTasks.steam.followLinks.push(task.link),"do"!==action||task.is_success||this.undoneTasks.steam.followLinks.push(task.link)}break;case"vk-oauth2":"undo"===action&&this.socialTasks.vk.nameLinks.push(task.link),"do"!==action||task.is_success||this.undoneTasks.vk.nameLinks.push(task.link);break;case"website":break;default:scripts_echoLog({}).warning(i18n("unKnownTaskType")+": "+social)}else this.tasks.push(taskInfo)}return logStatus.success(),this.undoneTasks=this.uniqueTasks(this.undoneTasks),this.socialTasks=this.uniqueTasks(this.socialTasks),window.DEBUG&&console.log("%cAuto-Task[Debug]:","color:blue",JSON.stringify(this)),GM_setValue("fawTasks-"+this.giveawayId,{tasks:this.socialTasks,time:(new Date).getTime()}),!0}return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1}catch(error){return throwError(error,"Freeanywhere.classifyTask"),!1}}async verifyTask(){try{if(!this.initialized&&!this.init())return!1;if(0===this.tasks.length&&!await this.classifyTask("verify"))return!1;const pro=[];for(const task of this.tasks)pro.push(this.#verify(task)),await delay(1e3);return await Promise.all(pro),scripts_echoLog({}).success(i18n("allTasksComplete")),!!await this.getKey(!0)}catch(error){return throwError(error,"Freeanywhere.verifyTask"),!1}}async getKey(initialized){try{if(!initialized&&!this.initialized&&!this.init())return!1;const logStatus=scripts_echoLog({text:i18n("gettingKey")});var{result,statusText,status,data}=await tools_httpRequest({url:`https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,method:"GET",dataType:"json",headers:{authorization:"Token "+window.localStorage.getItem("token")}});return"Success"===result?data?.response?.reward?(logStatus.success(),scripts_echoLog({}).success(data.response.reward),data.response.reward):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"FreeAnyWhere.getGiveawayId"),!1}}#getGiveawayId(){try{var giveawayId=window.location.href.match(/\/giveaway\/([\d]+)/)?.[1];return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({}).error(i18n("getFailed","GiveawayId")),!1)}catch(error){throwError(error,"FreeAnyWhere.getGiveawayId")}}async#verify(task){try{const logStatus=scripts_echoLog({html:`
  • ${i18n("verifyingTask")}${task.title.trim()}...
  • `});var{result,statusText,status,data}=await tools_httpRequest({url:`https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,method:"GET",dataType:"json",headers:{authorization:"Token "+window.localStorage.getItem("token"),"x-csrftoken":external_Cookies_namespaceObject.get("csrftoken")}});return"Success"===result?data?.response?.status?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Freeanywhere.verify"),!1}}async#checkLeftKey(){try{if(!globalOptions.other.checkLeftKey)return!0;const data=(await tools_httpRequest({url:"https://freeanywhere.net/api/v1/widget/?format=json",method:"GET",dataType:"json",headers:{authorization:"Token "+window.localStorage.getItem("token")}}))["data"];return data?.response?.giveaways.find(giveaway=>""+giveaway?.id===this.giveawayId)?!0:(await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("noKeysLeft"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0)}catch(error){return throwError(error,"Giveawaysu.checkLeftKey"),!1}}};const Giveawaysu_defaultTasks={steam:{groupLinks:[],wishlistLinks:[],curatorLinks:[],curatorLikeLinks:[],followLinks:[],forumLinks:[],announcementLinks:[],workshopVoteLinks:[],playtestLinks:[]},discord:{serverLinks:[]},instagram:{userLinks:[]},vk:{nameLinks:[]},twitch:{channelLinks:[]},reddit:{redditLinks:[]},youtube:{channelLinks:[],likeLinks:[]},twitter:{userLinks:[],retweetLinks:[]}};var website_Indiedb=class{name="Indiedb";buttons=["doTask"];static test(){return"www.indiedb.com"===window.location.host}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed")),await this.#checkLeftKey()||scripts_echoLog({}).warning(i18n("checkLeftKeyFailed"))}catch(error){throwError(error,"Indiedb.after")}}async doTask(){try{return await this.#join()?await this.#do():!1}catch(error){return throwError(error,"Indiedb.doTask"),!1}}async#join(){try{if(0<$("a.buttonenter:contains(Register to join)").length)return scripts_echoLog({}).error(i18n("needLogin")),!1;const currentoption=$("a.buttonenter.buttongiveaway");if(/join giveaway/gim.test(currentoption.text())){const logStatus=scripts_echoLog({text:i18n("joiningGiveaway")+"..."});var{result,statusText,status,data}=await tools_httpRequest({url:currentoption.attr("href"),method:"POST",data:"ajax=t",dataType:"json",headers:{"content-type":"application/x-www-form-urlencoded; charset=UTF-8",accept:"application/json, text/javascript, */*; q=0.01",origin:window.location.origin}});return"Success"===result?200===data?.status?data.response?.success?(currentoption.addClass("buttonentered").text("Success - Giveaway joined"),$("#giveawaysjoined").slideDown(),$("#giveawaysrecommend").slideDown(),logStatus.success("Success"+(data.response?.text?":"+data.response?.text:"")),!0):(logStatus.error("Error"+(data.response?.text?":"+data.response?.text:"")),!1):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}return/success/gim.test($("a.buttonenter.buttongiveaway").text())?!0:(scripts_echoLog({}).warning(i18n("needJoinGiveaway")),!1)}catch(error){return throwError(error,"Indiedb.init"),!1}}async#do(){try{const id=$("script").map((index,script)=>/\$\(document\)/gim.test(script.innerHTML)?[script.innerHTML.match(/"\/[\d]+"/gim)?.[0]?.match(/[\d]+/)?.[0],script.innerHTML.match(/"\/newsletter\/ajax\/subscribeprofile\/optin\/[\d]+"/gim)?.[0]?.match(/[\d]+/)?.[0]]:null);if(2!==id.length)return scripts_echoLog({}).error(i18n("getFailed","TaskId")),!1;{const pro=[];for(const task of $("#giveawaysjoined a[class*=promo]")){const promo=$(task);if(!promo.hasClass("buttonentered")){const status=scripts_echoLog({text:`${i18n("doing")}:${promo.parents("p").text()}...`});if(/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)){let text="";text=promo.hasClass("facebookpromo")?"facebookpromo":promo.hasClass("twitterpromo")?"twitterpromo":"visitpromo",pro.push(new Promise(resolve=>{$.ajax({type:"POST",url:urlPath(`/giveaways/ajax/${text}/`+id[0]),timeout:6e4,dataType:"json",data:{ajax:"t"},error(response,error,exception){window.DEBUG&&console.log("%cAuto-Task[Debug]:","color:red",{response:response,error:error,exception:exception}),status.error("Error:An error has occurred performing the action requested. Please try again shortly."),resolve(!0)},success(response){response.success?(status.success("Success:"+response.text),promo.addClass("buttonentered").closest("p").html(promo.closest("p").find("span").html())):status.error("Error:"+response.text),resolve(!0)}})}))}else promo.hasClass("emailoptinpromo")?pro.push(new Promise(resolve=>{$.ajax({type:"POST",url:urlPath("/newsletter/ajax/subscribeprofile/optin/"+id[1]),timeout:6e4,dataType:"json",data:{ajax:"t",emailsystoggle:4},error(response,error,exception){window.DEBUG&&console.log("%cAuto-Task[Debug]:","color:red",{response:response,error:error,exception:exception}),status.error("Error:An error has occurred performing the action requested. Please try again shortly."),resolve(!0)},success(response){response.success?(status.success("Success:"+response.text),promo.toggleClass("buttonentered").closest("p").html(promo.closest("p").find("span").html())):status.error("Error:"+response.text),resolve(!0)}})})):promo.hasClass("watchingpromo")?pro.push(new Promise(resolve=>{const data=(url=>{try{const query={};return url?url.includes("?")&&url.split("?")[1].replace(/([^?&=]+)=([^&]+)/g,(str,key,value)=>(query[key]=value,str)):window.location.search.replace(/([^?&=]+)=([^&]+)/g,(str,key,value)=>(query[key]=value,str)),query}catch(error){return throwError(error,"getUrlQuery"),{}}})(promo.attr("href"));data.ajax="t",$.ajax({type:"POST",url:urlPath(promo.attr("href")?.split(/[?#]/)[0]),timeout:6e4,dataType:"json",data:data,error(response,error,exception){window.DEBUG&&console.log("%cAuto-Task[Debug]:","color:red",{response:response,error:error,exception:exception}),status.error("Error:An error has occurred performing the action requested. Please try again shortly."),resolve(!0)},success(response){response.success?(status.success("Success:"+response.text),promo.toggleClass("buttonentered").closest("p").html(promo.closest("p").find("span").html())):status.error("Error:"+response.text),resolve(!0)}})})):/the-challenge-of-adblock/gim.test(promo.attr("href"))?status.error("Error:"+i18n("unKnownTaskType")):pro.push(new Promise(resolve=>{$.ajax({type:"POST",url:urlPath(promo.attr("href")),timeout:6e4,dataType:"json",data:{ajax:"t"},error(response,error,exception){window.DEBUG&&console.log("%cAuto-Task[Debug]:","color:red",{response:response,error:error,exception:exception}),status.error("Error:An error has occurred performing the action requested. Please try again shortly."),resolve(!0)},success(response){response.success?(status.success("Success:"+response.text),promo.toggleClass("buttonentered").closest("p").html(promo.closest("p").find("span").html())):status.error("Error:"+response.text),resolve(!0)}})}))}}return await Promise.all(pro),scripts_echoLog({}).success(i18n("allTasksComplete")),!0}}catch(error){return throwError(error,"Indiedb.classifyTask"),!1}}#checkLogin(){try{return globalOptions.other.checkLogin?(0<$("a.buttonenter:contains(Register to join)").length&&window.open("/members/login","_self"),!0):!0}catch(error){return throwError(error,"Indiedb.checkLogin"),!1}}async#checkLeftKey(){try{return globalOptions.other.checkLeftKey?(0<$('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayEnded"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0):!0}catch(error){return throwError(error,"Indiedb.checkLeftKey"),!1}}};const Keyhub_defaultTasks=JSON.stringify({steam:{groupLinks:[],officialGroupLinks:[],wishlistLinks:[],curatorLinks:[]},discord:{serverLinks:[]},extra:{videoTasks:[]},links:[]});var website_Keyhub=class extends website_Website{name="Keyhub";socialTasks=JSON.parse(Keyhub_defaultTasks);undoneTasks=JSON.parse(Keyhub_defaultTasks);buttons=["doTask","undoTask"];static test(){return"key-hub.eu"===window.location.host}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed")),await this.#checkLeftKey()||scripts_echoLog({}).warning(i18n("checkLeftKeyFailed")),$(".NSFW").hide()}catch(error){throwError(error,"Keyhub.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return 0<$('a[href*="/connect/steam"]').length?(window.open("/connect/steam","_self"),logStatus.warning(i18n("needLogin")),!1):!!this.#getGiveawayId()&&($("#VPNoverlay").hide(),$("#mainArticleSection").show(),this.initialized=!0,logStatus.success(),!0)}catch(error){return throwError(error,"Keyhub.init"),!1}}async classifyTask(action){try{const logStatus=scripts_echoLog({text:i18n("getTasksInfo")});"undo"===action&&(this.socialTasks=GM_getValue("khTasks-"+this.giveawayId)?.tasks||JSON.parse(Keyhub_defaultTasks));for(const task of $('.task:not(".googleads")').filter((index,element)=>"do"!==action||0===$(element).find("i.fa-check-circle:visible").length).find("a")){let link=$(task).attr("href");var taskData,taskDes=$(task).text().trim();link&&((/\/away\?data=/.test(link)||/steamcommunity\.com\/gid\//.test(link))&&(link=await getRedirectLink(link)||link),/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)?window.open(link,"_blank"):/steamcommunity\.com\/groups\//.test(link)?("undo"===action&&this.socialTasks.steam.groupLinks.push(link),"do"===action&&this.undoneTasks.steam.groupLinks.push(link)):/steamcommunity\.com\/games\/[\d]+/.test(link)?("undo"===action&&this.socialTasks.steam.officialGroupLinks.push(link),"do"===action&&this.undoneTasks.steam.officialGroupLinks.push(link)):/store\.steampowered\.com\/app\//.test(link)&&/wishlist/gim.test(taskDes)?("undo"===action&&this.socialTasks.steam.wishlistLinks.push(link),"do"===action&&this.undoneTasks.steam.wishlistLinks.push(link)):/store\.steampowered\.com\/curator\//.test(link)?("undo"===action&&this.socialTasks.steam.curatorLinks.push(link),"do"===action&&this.undoneTasks.steam.curatorLinks.push(link)):/^https?:\/\/discord\.com\/invite\//.test(link)?("undo"===action&&this.socialTasks.discord.serverLinks.push(link),"do"===action&&this.undoneTasks.discord.serverLinks.push(link)):/^javascript:videoTask.+/.test(link)?"do"!==action||(taskData=link.match(/javascript:videoTask\('.+?','(.+?)'/)?.[1])&&this.undoneTasks.extra.videoTasks.push(taskData):/^https?:\/\/www\.instagram\.com\/.*/.test(link)||/^https?:\/\/twitter\.com\/.*/.test(link)||/^https?:\/\/www\.twitch\.tv\/.*/.test(link)||/^https?:\/\/www\.facebook\.com\/.*/.test(link)||/^https?:\/\/www\.youtube\.com\/.*/.test(link)||/^https?:\/\/store\.steampowered\.com\/developer\//.test(link)||/^https?:\/\/.*?\.itch\.io\/.*/.test(link)||/^https?:\/\/key-hub\.eu.*/.test(link)||/^https?:\/\/store\.steampowered\.com\/app\/.*/.test(link)||/^https?:\/\/qr\.streamelements\.com\/.*/.test(link)||/^https?:\/\/store\.steampowered\.com\/news\/app\/.*/.test(link)||scripts_echoLog({}).warning(`${i18n("unKnownTaskType")}: ${taskDes}(${link})`))}return logStatus.success(),this.undoneTasks=this.uniqueTasks(this.undoneTasks),this.socialTasks=this.uniqueTasks(this.socialTasks),window.DEBUG&&console.log("%cAuto-Task[Debug]:","color:blue",JSON.stringify(this)),GM_setValue("khTasks-"+this.giveawayId,{tasks:this.socialTasks,time:(new Date).getTime()}),!0}catch(error){return throwError(error,"Keyhub.classifyTask"),!1}}async#doScriptTask(data){try{const logStatus=scripts_echoLog({text:i18n("doingKeyhubTask")});var{result,statusText,status,data:response}=await tools_httpRequest({url:"/away?data="+data,method:"GET",headers:{origin:"https://key-hub.eu",referer:"https://key-hub.eu/"}});return"Success"===result?200===response?.status?(logStatus.success(),!0):(logStatus.error(`Error:${response?.statusText}(${response?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Keyhub.doScriptTask"),!1}}async extraDoTask({videoTasks}){try{const pro=[];for(const data of videoTasks)pro.push(this.#doScriptTask(data));return Promise.all(pro).then(()=>!0)}catch(error){return throwError(error,"Keyhub.extraDoTask"),!1}}#getGiveawayId(){try{var giveawayId=window.location.href.match(/giveaway\/([\d]+)/)?.[1];return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({}).error(i18n("getFailed","GiveawayId")),!1)}catch(error){return throwError(error,"Keyhub.getGiveawayId"),!1}}async#checkLeftKey(){try{return globalOptions.other.checkLeftKey?("0"===$("#keysleft").text().trim()&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("noKeysLeft"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0):!0}catch(error){return throwError(error,"Keyhub.checkLeftKey"),!1}}#checkLogin(){try{return globalOptions.other.checkLogin?(0<$('a[href*="/connect/steam"]').length&&window.open("/connect/steam","_self"),!0):!0}catch(error){return throwError(error,"Keyhub.checkLogin"),!1}}};const Givekey_defaultTasks=JSON.stringify({steam:{groupLinks:[],wishlistLinks:[],curatorLinks:[],curatorLikeLinks:[]},twitter:{userLinks:[]},vk:{nameLinks:[]},discord:{serverLinks:[]}});var website_Givekey=class extends website_Website{name="Givekey";tasks=[];socialTasks=JSON.parse(Givekey_defaultTasks);undoneTasks=JSON.parse(Givekey_defaultTasks);userId;buttons=["doTask","undoTask","verifyTask"];static test(){return"givekey.ru"===window.location.host}async after(){try{await new Promise(resolve=>{const checker=setInterval(()=>{0<$("#navbarDropdown").length&&(clearInterval(checker),resolve(!0))})}),await this.#checkLeftKey()||scripts_echoLog({}).warning(i18n("checkLeftKeyFailed"))}catch(error){return throwError(error,"Givekey.after"),!1}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});if(0<$('a[href*="/auth/steam"]').length)return window.open("/auth/steam","_self"),logStatus.warning(i18n("needLogin")),!1;if(!this.#getGiveawayId())return!1;var userId=$('meta[name="user-id"]').attr("content");return userId?(this.userId=userId,this.initialized=!0,logStatus.success(),!0):(logStatus.error(i18n("getFailed",i18n("userId"))),!1)}catch(error){return throwError(error,"Givekey.init"),!1}}async classifyTask(action){try{const logStatus=scripts_echoLog({text:i18n("getTasksInfo")});"undo"===action&&(this.socialTasks=GM_getValue("gkTasks-"+this.giveawayId)?.tasks||JSON.parse(Givekey_defaultTasks));for(const task of $('.card-body:has("button") .row')){const taskEle=$(task);var isSuccess=/Complete/i.test(taskEle.find("button").text().trim());if(!isSuccess||"undo"===action){const checkButton=taskEle.find("#task_check");var taskId=checkButton.attr("data-id");if(taskId&&this.tasks.push(taskId),"verify"!==action){let href=taskEle.find("a").attr("href")||null;var text=taskEle.find("a").text().trim();const icon=taskEle.find("i");href&&text&&(/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)&&(href=await getRedirectLink(href)),href&&(/^https?:\/\/vk\.com\//.test(href)?(this.socialTasks.vk.nameLinks.push(href),"do"!==action||isSuccess||this.undoneTasks.vk.nameLinks.push(href)):/^https?:\/\/steamcommunity\.com\/groups/.test(href)?(this.socialTasks.steam.groupLinks.push(href),"do"!==action||isSuccess||this.undoneTasks.steam.groupLinks.push(href)):/^https?:\/\/store\.steampowered\.com\/app\//.test(href)?(this.socialTasks.steam.wishlistLinks.push(href),"do"!==action||isSuccess||this.undoneTasks.steam.wishlistLinks.push(href)):/Subscribe/gi.test(text)&&icon.hasClass("fa-steam-square")?/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)?(this.socialTasks.steam.curatorLinks.push(href),"do"!==action||isSuccess||this.undoneTasks.steam.curatorLinks.push(href)):(this.socialTasks.steam.curatorLikeLinks.push(href),"do"!==action||isSuccess||this.undoneTasks.steam.curatorLikeLinks.push(href)):/^https?:\/\/twitter\.com\//.test(href)&&/Subscribe/gi.test(text)?(this.socialTasks.twitter.userLinks.push(href),"do"!==action||isSuccess||this.undoneTasks.twitter.userLinks.push(href)):icon.hasClass("fa-discord")||/^https?:\/\/discord\.com\/invite\//.test(href)?(this.socialTasks.discord.serverLinks.push(href),"do"!==action||isSuccess||this.undoneTasks.discord.serverLinks.push(href)):scripts_echoLog({}).warning(`${i18n("unKnownTaskType")}: ${text}(${href})`)))}}}return logStatus.success(),this.tasks=unique(this.tasks),this.undoneTasks=this.uniqueTasks(this.undoneTasks),this.socialTasks=this.uniqueTasks(this.socialTasks),window.DEBUG&&console.log("%cAuto-Task[Debug]:","color:blue",JSON.stringify(this)),GM_setValue("gkTasks-"+this.giveawayId,{tasks:this.socialTasks,time:(new Date).getTime()}),!0}catch(error){return throwError(error,"Givekey.classifyTask"),!1}}async verifyTask(){try{if(!this.initialized&&!this.init())return!1;if(0===this.tasks.length&&!await this.classifyTask("verify"))return!1;scripts_echoLog({}).warning(i18n("giveKeyNoticeBefore"));var taskLength=this.tasks.length;for(let i=0;i${i18n("giveKeyNoticeAfter")}`}),!0}catch(error){return throwError(error,"Givekey.verifyTask"),!1}}async#verify(task){try{const logStatus=scripts_echoLog({html:`
  • ${i18n("verifyingTask")}${task}...
  • `});return await new Promise(resolve=>{$.ajax({url:"https://givekey.ru/giveaway/task",method:"POST",data:`id=${task}&user_id=`+this.userId,dataType:"json",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},success:data=>{data.btn&&$(`button[data-id=${this.userId}]`).html(data.btn),"ok"===data.status?($(".task_check_"+data.id).html(``),logStatus.success(),resolve(!0)):"end"===data.status?(logStatus.success(),scripts_echoLog({}).success(data.key),resolve(!0)):(logStatus.error("Error:"+data.msg),resolve(!1))},error:xhr=>{logStatus.error(`Error:${xhr.statusText}(${xhr.status})`),resolve(!1)}})})}catch(error){return throwError(error,"Givekey.verify"),!1}}#getGiveawayId(){try{var giveawayId=window.location.href.match(/giveaway\/([\d]+)/)?.[1];return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Givekey.getGiveawayId"),!1}}async#checkLeftKey(){try{return globalOptions.other.checkLeftKey?($("#keys_count").text()||await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("noKeysLeft"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0):!0}catch(error){return throwError(error,"Givekey.checkLeftKey"),!1}}};const GiveawaySu_defaultTasks={steam:{groupLinks:[],wishlistLinks:[],curatorLinks:[],curatorLikeLinks:[],followLinks:[],forumLinks:[],announcementLinks:[],workshopVoteLinks:[],playtestLinks:[]},discord:{serverLinks:[]},instagram:{userLinks:[]},vk:{nameLinks:[]},twitch:{channelLinks:[]},reddit:{redditLinks:[]},youtube:{channelLinks:[],likeLinks:[]},twitter:{userLinks:[],retweetLinks:[]}};class GiveawaySu_GiveawaySu extends website_Website{name="GiveawaySu";socialTasks=GiveawaySu_defaultTasks;undoneTasks=GiveawaySu_defaultTasks;buttons=["doTask","undoTask"];static test(){return/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed")),await this.#checkLeftKey()||scripts_echoLog({}).warning(i18n("checkLeftKeyFailed")),scripts_echoLog({}).warning(i18n("gsNotice"))}catch(error){throwError(error,"Giveawaysu.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return 0<$("a.steam-login").length?(window.open("/steam/redirect","_self"),logStatus.warning(i18n("needLogin")),!1):!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0)}catch(error){return throwError(error,"Giveawaysu.init"),!1}}async classifyTask(action){try{const logStatus=scripts_echoLog({text:i18n("getTasksInfo")});if("undo"===action)return this.socialTasks=GM_getValue("gasTasks-"+this.giveawayId)?.tasks||GiveawaySu_defaultTasks,!0;const pro=[];var tasks=$("#actions tr");$("div.bind-discord").is(":visible")&&$("div.bind-discord a")[0].click(),$("div.bind-twitch").is(":visible")&&$("div.bind-twitch a")[0].click();for(const task of tasks)pro.push(new Promise(resolve=>{const td=$(task).find('td:not(".hidden")');var colorfulTask=td.eq(1).find('a:not([data-trigger="link"])'),colorlessTask=td.eq(2).find('a:not([data-trigger="link"])');const taskDes=0taskLink?(taskIcon.includes("steam")&&/join/gi.test(taskName)?this.undoneTasks.steam.groupLinks.push(taskLink):/like.*announcement/gi.test(taskName)?this.undoneTasks.steam.announcementLinks.push(taskLink):/(follow|subscribe).*curator/gim.test(taskName)&&/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)?this.undoneTasks.steam.curatorLinks.push(taskLink):taskIcon.includes("steam")&&/follow|subscribe/gim.test(taskName)?this.undoneTasks.steam.curatorLikeLinks.push(taskLink):/subscribe.*steam.*forum/gim.test(taskName)?this.undoneTasks.steam.forumLinks.push(taskLink):taskIcon.includes("thumbs-up")&&/^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)?this.undoneTasks.steam.workshopVoteLinks.push(taskLink):taskIcon.includes("plus")&&/request.*playtest/gim.test(taskName)?this.undoneTasks.steam.playtestLinks.push(taskLink):taskIcon.includes("discord")||/join.*discord/gim.test(taskName)?this.undoneTasks.discord.serverLinks.push(taskLink):taskIcon.includes("instagram")||/follow.*instagram/gim.test(taskName)?this.undoneTasks.instagram.userLinks.push(taskLink):taskIcon.includes("twitch")||/follow.*twitch.*channel/gim.test(taskName)?this.undoneTasks.twitch.channelLinks.push(taskLink):taskIcon.includes("reddit")||/subscribe.*subreddit/gim.test(taskName)||/follow.*reddit/gim.test(taskName)?this.undoneTasks.reddit.redditLinks.push(taskLink):/watch.*art/gim.test(taskName)?this.undoneTasks.steam.workshopVoteLinks.push(taskLink):/subscribe.*youtube.*channel/gim.test(taskName)?this.undoneTasks.youtube.channelLinks.push(taskLink):/(watch|like).*youtube.*video/gim.test(taskName)||(taskIcon.includes("youtube")||taskIcon.includes("thumbs-up"))&&/(watch|like).*video/gim.test(taskName)?this.undoneTasks.youtube.likeLinks.push(taskLink):taskIcon.includes("vk")||/join.*vk.*group/gim.test(taskName)?this.undoneTasks.vk.nameLinks.push(taskLink):/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)||(/wishlist.*game|add.*wishlist/gim.test(taskName)&&this.undoneTasks.steam.wishlistLinks.push(taskLink),/follow.*button/gim.test(taskName)&&this.undoneTasks.steam.followLinks.push(taskLink)),void resolve(!0)):resolve(!1)).catch(error=>(throwError(error,"Giveawaysu.classifyTask->getRedirectLink"),!1))}));return await Promise.all(pro),logStatus.success(),this.undoneTasks=this.uniqueTasks(this.undoneTasks),this.socialTasks=this.undoneTasks,window.DEBUG&&console.log("%cAuto-Task[Debug]:","color:blue",JSON.stringify(this)),GM_setValue("gasTasks-"+this.giveawayId,{tasks:this.socialTasks,time:(new Date).getTime()}),!0}catch(error){return throwError(error,"Giveawaysu.classifyTask"),!1}}#checkLogin(){try{return globalOptions.other.checkLogin?(0<$("a.steam-login").length&&window.open("/steam/redirect","_self"),!0):!0}catch(error){return throwError(error,"Giveawaysu.checkLogin"),!1}}async#checkLeftKey(){try{return globalOptions.other.checkLeftKey?(0<$(".giveaway-ended").length&&0===$(".giveaway-key").length&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("noKeysLeft"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0):!0}catch(error){return throwError(error,"Giveawaysu.checkLeftKey"),!1}}#getGiveawayId(){var giveawayId=window.location.href.match(/\/view\/([\d]+)/)?.[1];return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}}var website_GiveeClub=class extends GiveawaySu_GiveawaySu{name="GiveeClub";buttons=["doTask","undoTask","verifyTask"];static test(){return/^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed")),await this.#checkLeftKey()||scripts_echoLog({}).warning(i18n("checkLeftKeyFailed"))}catch(error){throwError(error,"GiveeClub.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return this.#checkLogin()?!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0):(logStatus.warning(i18n("needLogin")),!1)}catch(error){return throwError(error,"GiveeClub.init"),!1}}async classifyTask(action){try{const logStatus=scripts_echoLog({text:i18n("getTasksInfo")});if("undo"===action)return this.socialTasks=GM_getValue("gcTasks-"+this.giveawayId)?.tasks||GiveawaySu_defaultTasks,!0;const pro=[];for(const task of $(".event-actions tr"))pro.push(new Promise(resolve=>{const taskDes=$(task).find(".event-action-label a"),taskIcon=$(task).find(".event-action-icon i").attr("class")||"",taskName=taskDes.text().trim(),taskType=$(task).find("button[data-type]")?.attr("data-type");var taskFinished=$(task).find(".event-action-buttons .btn-success")?.length;if(taskIcon.includes("ban")||/AdBlock/i.test(taskName)||taskIcon.includes("envelope")||taskFinished)return resolve(!0);getRedirectLink(taskDes.attr("href")).then(taskLink=>taskLink?("steam.group.join"===taskType&&/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)?this.undoneTasks.steam.groupLinks.push(taskLink):/like.*announcement/gi.test(taskName)?this.undoneTasks.steam.announcementLinks.push(taskLink):"steam.game.wishlist"===taskType&&/^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)?this.undoneTasks.steam.wishlistLinks.push(taskLink):"steam.game.wishlist"===taskType&&taskDes.attr("data-steam-wishlist-appid")?this.undoneTasks.steam.wishlistLinks.push("https://store.steampowered.com/app/"+taskDes.attr("data-steam-wishlist-appid")):"steam.game.follow"===taskType&&/^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)?this.undoneTasks.steam.followLinks.push(taskLink):/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)?this.undoneTasks.steam.curatorLinks.push(taskLink):taskIcon.includes("steam")&&/follow|subscribe/gim.test(taskName)?this.undoneTasks.steam.curatorLikeLinks.push(taskLink):/subscribe.*steam.*forum/gim.test(taskName)?this.undoneTasks.steam.forumLinks.push(taskLink):taskIcon.includes("discord")?this.undoneTasks.discord.serverLinks.push(taskLink):taskIcon.includes("instagram")?this.undoneTasks.instagram.userLinks.push(taskLink):taskIcon.includes("twitch")?this.undoneTasks.twitch.channelLinks.push(taskLink):taskIcon.includes("reddit")?this.undoneTasks.reddit.redditLinks.push(taskLink):/watch.*art/gim.test(taskName)?this.undoneTasks.steam.workshopVoteLinks.push(taskLink):/subscribe.*youtube.*channel/gim.test(taskName)?this.undoneTasks.youtube.channelLinks.push(taskLink):/(watch|like).*youtube.*video/gim.test(taskName)||(taskIcon.includes("youtube")||taskIcon.includes("thumbs-up"))&&/(watch|like).*video/gim.test(taskName)?this.undoneTasks.youtube.likeLinks.push(taskLink):taskIcon.includes("vk")||/join.*vk.*group/gim.test(taskName)?this.undoneTasks.vk.nameLinks.push(taskLink):taskIcon.includes("twitter")?/https?:\/\/twitter\.com\/[^/]+\/?$/gim.test(taskLink)?this.undoneTasks.twitter.userLinks.push(taskLink):/https?:\/\/twitter\.com\/[^/]+?\/status\/[\d]+/gim.test(taskLink)&&this.undoneTasks.twitter.retweetLinks.push(taskLink):/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)||/follow.*button/gim.test(taskName)&&this.undoneTasks.steam.followLinks.push(taskLink),void resolve(!0)):resolve(!1)).catch(error=>(throwError(error,"GiveeClub.classifyTask->getRedirectLink"),!1))}));return await Promise.all(pro),logStatus.success(),this.undoneTasks=this.uniqueTasks(this.undoneTasks),this.socialTasks=this.undoneTasks,window.DEBUG&&console.log("%cAuto-Task[Debug]:","color:blue",JSON.stringify(this)),GM_setValue("gcTasks-"+this.giveawayId,{tasks:this.socialTasks,time:(new Date).getTime()}),!0}catch(error){return throwError(error,"GiveeClub.classifyTask"),!1}}async verifyTask(){try{const logStatus=scripts_echoLog({text:i18n("giveeClubVerifyNotice")});for(const button of $(".event-actions tr button").has("i.glyphicon-refresh").not('[data-type="user.adblock"]'))button.click(),"steam.game.wishlist"!==$(button).attr("data-type")&&await delay(1e3);return logStatus.warning(i18n("giveeClubVerifyFinished")),!0}catch(error){return throwError(error,"Givekey.verifyTask"),!1}}#checkLogin(){try{return globalOptions.other.checkLogin?(0<$('a[href*="/account/auth"]').length&&window.open($('a[href*="/account/auth"]').attr("href"),"_self"),!0):!0}catch(error){return throwError(error,"GiveeClub.checkLogin"),!1}}#getGiveawayId(){var giveawayId=window.location.href.match(/\/event\/([\d]+)/)?.[1];return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}async#checkLeftKey(){try{return globalOptions.other.checkLeftKey?(0<$(".event-ended").length&&0===$(".event-winner").length&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayEnded"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0):!0}catch(error){return throwError(error,"Giveawaysu.checkLeftKey"),!1}}};var website_OpiumPulses=class{name="OpiumPulses";options={maxPoint:"99999999",...GM_getValue("OpiumPulsesOptions")};maxPoints=99999999;myPoints=0;buttons=["doFreeTask","doPointTask"];static test(){return"www.opiumpulses.com"===window.location.host}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed")),this.maxPoints=parseInt(this.options.maxPoint,10)}catch(error){throwError(error,"OpiumPulses.after")}}async doFreeTask(){try{this.#toggleTask("FREE")}catch(error){throwError(error,"OpiumPulses.doFreeTask")}}async doPointTask(){try{this.myPoints=parseInt($(".page-header__nav-func-user-nav-items.points-items").text().match(/[\d]+/gim)?.[0]||"0",10),this.#toggleTask("points")}catch(error){throwError(error,"OpiumPulses.doPointTask")}}async#toggleTask(type){try{for(const item of $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`)){var giveawayId,points,needPoints=parseInt($(item).find(".giveaways-page-item-header-points").text().match(/[\d]+/gim)?.[0]||"999999",10),name=$(item).find(".giveaways-page-item-footer-name").text().trim();if("points"===type&&needPoints>this.myPoints)scripts_echoLog({}).warning(i18n("noPoints")+": "+name);else if("points"!==type||needPoints){if(!("points"===type&&needPoints>this.maxPoints)){const logStatus=scripts_echoLog({text:`${i18n("joiningLottery")}${name}...`}),aElement=$(item).find("a.giveaways-page-item-img-btn-enter:contains('enter')");if(!aElement?.attr("onclick")?.includes("checkUser")||(giveawayId=aElement.attr("onclick")?.match(/[\d]+/)?.[0])&&checkUser(giveawayId),aElement.attr("href")){const{result,statusText,status,data}=await tools_httpRequest({url:aElement.attr("href"),method:"GET"});"Success"===result?data?.responseText&&/You've entered this giveaway/gim.test(data.responseText)?(logStatus.success(),points=data.responseText.match(/Points:[\s]*?([\d]+)/)?.[1],"points"===type&&points&&(this.myPoints=parseInt(points,10))):logStatus.error(`Error:${data?.statusText}(${data?.status})`):logStatus.error(result+`:${statusText}(${status})`)}else logStatus.error('Error: No "href".')}}else scripts_echoLog({}).warning(i18n("getNeedPointsFailed")+": "+name)}scripts_echoLog({text:"-----END-----"})}catch(error){throwError(error,"OpiumPulses.toggleTask")}}init(){return!0}classifyTask(){return!0}#checkLogin(){try{return globalOptions.other.checkLogin?(1<$('a[href*="/site/login"]').length&&window.open("/site/login","_self"),!0):!0}catch(error){return throwError(error,"OpiumPulses.checkLogin"),!1}}},dayjs_min=__webpack_require__(722),dayjs_min_default=__webpack_require__.n(dayjs_min);const website_leftKeyChecker={async classify(link){try{return/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)?await this.giveawaySu(link):/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)?await this.giveeClub(link):/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)?await this.gleam(link):/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)?await this.indieDb(link):/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)?await this.keyhub(link):/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)?await this.opquests(link):!!/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)&&await this.itch(link)}catch(error){return throwError(error,"leftKeyChecker.classify"),!1}},async giveawaySu(link){try{const{result,data}=await tools_httpRequest({url:link,method:"GET"});return"Success"===result&&200===data?.status?!data.responseText.includes('class="steam-login"')&&(data.responseText.includes('class="giveaway-ended"')?"Ended":"Active"):!1}catch(error){return throwError(error,"leftKeyChecker.giveawaySu"),!1}},async giveeClub(link){try{const{result,data}=await tools_httpRequest({url:link,method:"GET"});return"Success"===result&&200===data?.status?data.responseText.includes('class="event-winner"')?"Won":data.responseText.includes('class="event-ended"')?"Ended":"Active":!1}catch(error){return throwError(error,"leftKeyChecker.giveeClub"),!1}},async gleam(link){try{const{result,data}=await tools_httpRequest({url:link,method:"GET"});if("Success"!==result||200!==data?.status)return!1;if(/incentives":{"[\d]+?":\[".+?"\]/.test(data.responseText))return"Won";var campaignDiv=data.responseText.match(/