From 26f1ed147ce449feb991a6bffdc0f5ade356fd43 Mon Sep 17 00:00:00 2001 From: HCLonely Date: Sun, 8 Dec 2024 11:10:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96:=20opquests=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=97=A0=E6=B3=95=E5=AE=8C=E6=88=90=E6=97=B6=E8=B7=B3?= =?UTF-8?q?=E8=BF=87(#38)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Release.yml | 6 +++--- 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 | 4 +++- dist/auto-task-v4.compatibility.all.user.js | 4 ++-- dist/auto-task-v4.compatibility.user.js | 4 ++-- dist/auto-task-v4.user.js | 4 +++- doc/docs/logs/README.md | 6 ++++++ package.json | 4 ++-- page/dist/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 | 4 +++- page/dist/auto-task-v4.compatibility.all.user.js | 4 ++-- page/dist/auto-task-v4.compatibility.user.js | 4 ++-- page/dist/auto-task-v4.user.js | 4 +++- page/package.json | 4 ++-- src/scripts/website/Opquests.ts | 2 ++ 17 files changed, 39 insertions(+), 23 deletions(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 3a71316..2e3cdf5 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -21,9 +21,9 @@ jobs: uses: softprops/action-gh-release@v1 with: prerelease: false - tag_name: v4.5.4 - name: 4.5.4 - body: '- 优化: 未安装TimerHooker脚本时不再弹出空白页面(#36)' + tag_name: v4.5.5 + name: 4.5.5 + body: '- 优化: opquests任务无法完成时跳过(#38)' files: |- dist/auto-task-v4-for-giveawaysu.user.js dist/auto-task-v4.compatibility.user.js diff --git a/dist/auto-task-v4-for-giveawaysu.all.user.js b/dist/auto-task-v4-for-giveawaysu.all.user.js index 1e8e7b9..d4a842a 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.5.4 +// @version 4.5.5 // @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 174c1c9..b5103ea 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.5.4 +// @version 4.5.5 // @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 01e0034..1a30f2f 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.5.4 +// @version 4.5.5 // @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 @@ -9037,6 +9037,8 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载'); verifyBtn.click(); return; } + this.before(); + return; } if (GM_getValue('opquestsVerifyTasks')) { GM_deleteValue('opquestsVerifyTasks'); diff --git a/dist/auto-task-v4.compatibility.all.user.js b/dist/auto-task-v4.compatibility.all.user.js index 71ae912..3069426 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.5.4 +// @version 4.5.5 // @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 @@ -141,7 +141,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(isConfirmed),external_Swal_default().fire({title:i18n("copySuccess"),icon:"success",confirmButtonText:i18n("ok")}).then(()=>{GM_openInTab("https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450",{active:!0})}))}),console.log("%c%s","color:white;background:red",`Auto-Task[Error]: ${name} -`+error.stack)}userDefinedGlobalOptions=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()||(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{var logStatus=scripts_echoLog({text:i18n("verifyingAuth","Discord")}),{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{let logStatus=scripts_echoLog({text:i18n("updatingAuth","Discord")});return await new Promise(resolve=>{var newTab=GM_openInTab("https://discord.com/channels/@me",{active:!0,insert:!0,setParent:!0});newTab.name="ATv4_discordAuth",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{var guild,logStatus=scripts_echoLog({type:"joiningDiscordServer",text:inviteId}),{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}});return"Success"===result&&200===data?.status?(logStatus.success(),(guild=String(data.response?.guild?.id))&&(this.#setCache(inviteId,guild),this.tasks.servers=unique([...this.tasks.servers,inviteId])),!0):(logStatus.error(result+`:${statusText}(${status})`),!1)}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){var logStatus=scripts_echoLog({type:"leavingDiscordServer",text:guild}),{result,statusText,status,data}=await tools_httpRequest({url:"https://discord.com/api/v9/users/@me/guilds/"+guild,method:"DELETE",headers:{authorization:this.#auth.auth}});if("Success"===result&&204===data?.status)return logStatus.success(),!0;logStatus.error(result+`:${statusText}(${status})`)}return!1}catch(error){return throwError(error,"Discord.leaveServer"),!1}}async#getGuild(inviteId){try{var logStatus=scripts_echoLog({type:"gettingDiscordGuild",text:inviteId}),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;{let 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;var 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")}}}let social_Discord=Discord;class Instagram extends userDefinedGlobalOptions{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{var logStatus=scripts_echoLog({type:"instagram"===name?"verifyingInsAuth":"gettingInsUserId",text:name}),userId=this.#cache[name];if(userId&&"instagram"!==name)return logStatus.success(),userId;var csrftoken,hash,id,{result,statusText,status,data}=await tools_httpRequest({url:`https://www.instagram.com/${name}/`,method:"GET"});if("Success"===result)if(data?.finalUrl.includes("accounts/login"))logStatus.error("Error:"+i18n("loginIns"),!0);else if(data?.finalUrl.includes("www.instagram.com/challenge"))logStatus.error("Error:"+i18n("insBanned"));else{if(200===data?.status)return csrftoken=data.responseText.match(/"csrf_token":"(.+?)"/)?.[1],hash=data.responseText.match(/"rollout_hash":"(.+?)"/)?.[1],"instagram"===name?!(!csrftoken||!hash||(this.#auth={csrftoken:csrftoken,hash:hash},0)):(id=data.responseText.match(/"profilePage_([\d]+?)"/)?.[1])?(this.#setCache(name,id),logStatus.success(),id):(logStatus.error("Error: Get ins data error!"),!1);logStatus.error(result+`:${statusText}(${status})`)}return!1}catch(error){return throwError(error,"Instagram.getUserInfo"),!1}}async#followUser(name){try{var id=await this.#getUserInfo(name);if(id){var logStatus=scripts_echoLog({type:"followingIns",text:name}),{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}});if("Success"===result)return 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})`)}return!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){var logStatus=scripts_echoLog({type:"unfollowingIns",text:name}),{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}});if("Success"===result)return 200===data?.status&&"ok"===data.response?.status?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1);logStatus.error(result+`:${statusText}(${status})`)}return!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;var 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")}}}let social_Instagram=Instagram;class Reddit extends userDefinedGlobalOptions{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{let logStatus=scripts_echoLog({text:i18n("changingRedditVersion")});return await new Promise(resolve=>{var newTab=GM_openInTab("https://www.reddit.com/",{active:!0,insert:!0,setParent:!0});newTab.name="ATv4_redditAuth",newTab.onclose=async()=>{logStatus.success(),resolve(await this.#updateAuth(!0))}})}catch(error){return throwError(error,"Reddit.useBeta"),!1}}async#updateAuth(beta=!1){try{var accessToken,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)if(data?.responseText.includes("www.reddit.com/login/"))logStatus.error("Error:"+i18n("loginReddit"),!0);else{if(200===data?.status)return data.responseText.includes("redesign-beta-optin-btn")&&!beta?await this.#useBeta():(accessToken=data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)?.[1])?(this.#auth={token:accessToken},logStatus.success(),!0):(logStatus.error('Error: Parameter "accessToken" not found!'),!1);logStatus.error(`Error:${data?.statusText}(${data?.status})`)}else logStatus.error(result+`:${statusText}(${status})`);return!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");var logStatus=scripts_echoLog({type:type,text:name}),{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;var 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,link=>{var name=link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)?.[1],link=link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)?.[1];return link?name||link:name});if(0!0)}catch(error){return throwError(error,"Reddit.toggle"),!1}}}let social_Reddit=Reddit;class Twitch extends userDefinedGlobalOptions{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)||(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{var logStatus=scripts_echoLog({text:i18n("verifyingAuth","Twitch")}),{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{var result,statusText,status,data,logStatus=scripts_echoLog({text:i18n("checkingTwitchIntegrity")});return!isFirst||this.#auth.authToken&&this.#auth.clientId&&this.#auth.clientVersion&&this.#auth.deviceId&&this.#auth.clientSessionId?({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}}),"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)):await this.#updateAuth(!1)}catch(error){return throwError(error,"Twitch.integrity"),!1}}async#updateAuth(isFirst=!0){try{let logStatus=scripts_echoLog({text:i18n("updatingAuth","Twitch")});return await new Promise(resolve=>{var newTab=GM_openInTab("https://www.twitch.tv/",{active:!0,insert:!0,setParent:!0});newTab.name="ATv4_twitchAuth",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){var logStatus=scripts_echoLog({type:`${doTask?"":"un"}followingTwitchChannel`,text:name}),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});if("Success"===result)return 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})`)}return!1}catch(error){return throwError(error,"Twitch.toggleChannel"),!1}}async#getChannelId(name){try{var logStatus=scripts_echoLog({type:"gettingTwitchChannelId",text:name}),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;{let 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;var 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")}}}let social_Twitch=Twitch;class Twitter extends userDefinedGlobalOptions{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()||(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{let logStatus=scripts_echoLog({text:i18n("updatingAuth","Twitter")});return await new Promise(resolve=>{GM_cookie.list({url:"https://x.com/settings/account"},async(cookies,error)=>{error?(logStatus.error("Error: Update twitter auth failed!"),resolve(!1)):([error,cookies]=cookies.map(cookie=>["ct0","twid"].includes(cookie.name)?cookie.value:null).filter(cookie=>cookie),cookies&&error?(GM_setValue("twitterAuth",{ct0:error}),this.#auth={ct0:error},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){var logStatus=verify?scripts_echoLog({text:i18n("verifyingAuth","Twitter")}):scripts_echoLog({type:`${doTask?"":"un"}followingTwitterUser`,text:name}),{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})});if("Success"===result)return 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})`)}return!1}catch(error){return throwError(error,"Twitter.toggleUser"),!1}}async userName2id(name){try{var logStatus=scripts_echoLog({type:"gettingTwitterUserId",text:name}),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}let 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{var logStatus,result,statusText,status,data;return!doTask&&this.whiteList.retweets.includes(retweetId)?(scripts_echoLog({type:"whiteList",text:"Twitter.unretweet",id:retweetId}),!0):(logStatus=scripts_echoLog({type:`${doTask?"":"un"}retweetting`,text:retweetId}),{result,statusText,status,data}=await tools_httpRequest({url:"https://x.com/i/api/graphql/"+(doTask?"ojPdsZsimiJrUGLR1sjUtA/CreateRetweet":"iQtK4dl5hBmXewYZuEOKVw/DeleteRetweet"),method:"POST",headers:{authorization:"Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA","Content-Type":"application/json","x-csrf-token":this.#auth.ct0},data:`{"variables":{"tweet_id":"${retweetId}","dark_request":false},"queryId":"${doTask?"ojPdsZsimiJrUGLR1sjUtA":"iQtK4dl5hBmXewYZuEOKVw"}"}`,responseType:"json"}),"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;var 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]||link.match(/https:\/\/twitter\.com\/(.+)/)?.[1]);if(0link.match(/https:\/\/x\.com\/.*?\/status\/([\d]+)/)?.[1]||link.match(/https:\/\/twitter\.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")}}}let social_Twitter=Twitter;class Vk extends userDefinedGlobalOptions{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{var logStatus=scripts_echoLog({text:i18n("verifyAuth","Vk")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://vk.com/im",method:"GET"});if("Success"===result)if(data?.finalUrl.includes("vk.com/login"))logStatus.error("Error:"+i18n("loginVk"),!0);else{if(200===data?.status)return this.#username=data.responseText.match(/TopNavBtn__profileLink" href="\/(.*?)"/)?.[1]||"",logStatus.success(),!0;logStatus.error(`Error:${data?.statusText}(${data?.status})`)}else logStatus.error(result+`:${statusText}(${status})`);return!1}catch(error){return throwError(error,"Vk.verifyAuth"),!1}}async#toggleGroup(name,dataParam,doTask=!0){try{var reqData,result,statusText,status,data,logStatus=scripts_echoLog({type:doTask?"joiningVkGroup":"leavingVkGroup",text:name});return"enter"===dataParam.groupAct&&!doTask||"leave"===dataParam.groupAct&&doTask?(logStatus.success(),!0):(reqData={act:doTask?"enter":"leave",al:1,gid:dataParam.groupId,hash:dataParam.groupHash},{result,statusText,status,data}=(doTask&&(reqData.context="_"),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)})),"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{var result,statusText,status,data,logStatus=scripts_echoLog({type:doTask?"joiningVkPublic":"leavingVkPublic",text:name});return dataParam.publicJoined&&doTask||!dataParam.publicJoined&&!doTask?(logStatus.success(),!0):({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})}),"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{var 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)if(200===data?.status){var hash=data.responseText.match(/shHash:[\s]*'(.*?)'/)?.[1];if(hash){var{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){if(200===dataR?.status){var postId,ownerId,jsonData=JSON.parse(dataR.responseText?.replace("\x3c!--","")||"{}");if(!0===jsonData?.payload?.[1]?.[1]?.share_my)return logStatus.success(),postId=String(jsonData?.payload?.[1]?.[1]?.post_id),ownerId=String(jsonData?.payload?.[1]?.[1]?.owner_id),postId&&ownerId&&this.#setCache(name,ownerId+"_"+postId),this.tasks.names=unique([...this.tasks.names,name]),!0}logStatus.error(`Error:${dataR?.statusText}(${dataR?.status})`)}else logStatus.error(resultR+`:${statusTextR}(${statusR})`)}else logStatus.error('Error: Get "hash" failed')}else logStatus.error(`Error:${data?.statusText}(${data?.status})`);else logStatus.error(result+`:${statusText}(${status})`);return!1}catch(error){return throwError(error,"Vk.sendWall"),!1}}async#deleteWall(name,dataParams){try{var 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]}var logStatus=scripts_echoLog({type:"gettingVkId",text:name}),{result,statusText,status,data}=await tools_httpRequest({url:url,method:"GET"});if("Success"===result)if(200===data?.status){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"};logStatus.error("Error: Parameters not found!")}else logStatus.error(`Error:${data?.statusText}(${data?.status})`);else logStatus.error(result+`:${statusText}(${status})`);return!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;var 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")}}}let social_Vk=Vk,getInfo=async function(link,type){try{var apiKey,context,client,request,channelId,videoId,likeParams,logStatus=scripts_echoLog({text:i18n("gettingYtbToken")}),{result,statusText,status,data}=await tools_httpRequest({url:link,method:"GET"});return"Success"===result?200===data?.status?data.responseText.includes("accounts.google.com/ServiceLogin?service=youtube")?(logStatus.error("Error:"+i18n("loginYtb"),!0),{needLogin:!0}):(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]||"{}",{client,request}=JSON.parse(context),apiKey&&client&&request?(client.hl="en","channel"===type?(channelId=data.responseText.match(/"channelId":"(.+?)"/)?.[1])?(logStatus.success(),{params:{apiKey:apiKey,client:client,request:request,channelId:channelId}}):(logStatus.error('Error: Get "channelId" failed!'),{}):"likeVideo"===type?(videoId=data.responseText.match(//)?.[1],likeParams=data.responseText.match(/"likeParams":"(.*?)"/)?.[1],videoId?(logStatus.success(),{params:{apiKey:apiKey,client:client,request:request,videoId:videoId,likeParams:likeParams}}):(logStatus.error('Error: Get "videoId" failed!'),{})):(logStatus.error("Error: Unknown type"),{})):(logStatus.error('Error: Parameter "apiKey" not found!'),{})):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),{}):(logStatus.error(result+`:${statusText}(${status})`),{})}catch(error){return throwError(error,"Youtube.getInfo"),{}}};class Youtube extends userDefinedGlobalOptions{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()||(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{let logStatus=scripts_echoLog({text:i18n("updatingAuth","Youtube")});return await new Promise(resolve=>{GM_cookie.list({url:"https://www.youtube.com/@YouTube"},async(cookies,error)=>{error?(logStatus.error("Error: Update youtube auth failed!"),resolve(!1)):(error=cookies.find(cookie=>"__Secure-3PAPISID"===cookie.name)?.value)?(GM_setValue("youtubeAuth",{PAPISID:error}),this.#auth={PAPISID:error},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)scripts_echoLog({html:i18n("loginYtb")});else if(apiKey&&client&&request&&channelId){if(!doTask&&!verify&&this.whiteList.channels.includes(channelId))return scripts_echoLog({type:"whiteList",text:"Youtube.unfollowChannel",id:channelId}),!0;var logStatus=verify?scripts_echoLog({text:i18n("verifyingAuth","Youtube")}):scripts_echoLog({type:doTask?"followingYtbChannel":"unfollowingYtbChannel",text:channelId}),nowTime=parseInt(String((new Date).getTime()/1e3),10),{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"})});if("Success"===result)return 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})`)}else scripts_echoLog({text:'"getYtbToken" failed'});return!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)scripts_echoLog({html:""+i18n("loginYtb")});else if(apiKey&&client&&request&&videoId&&likeParams){if(!doTask&&this.whiteList.likes.includes(videoId))return scripts_echoLog({type:"whiteList",text:"Youtube.unlikeVideo",id:videoId}),!0;var logStatus=scripts_echoLog({type:doTask?"likingYtbVideo":"unlikingYtbVideo",text:videoId}),nowTime=parseInt(String((new Date).getTime()/1e3),10),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}var{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)});if("Success"===result)return 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})`)}else scripts_echoLog({text:'"getYtbToken" failed'});return!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;var 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}}}let social_SteamASF=class{#asfOptions;#botName="asf";#groupInfo;async init(){try{var asfCommandsUrl=new URL("/Api/Command/",globalOptions.ASF.AsfIpcUrl),logStatus=(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),scripts_echoLog({text:i18n("initingASF")})),{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{var logStatus=scripts_echoLog({type:"joiningSteamGroup",text:groupName});let{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()){var groupId=await this.#groupInfo[groupName];if(groupId){var logStatus=scripts_echoLog({type:"leavingSteamGroup",text:groupName});let{result,statusText,status,data}=await tools_httpRequest({...this.#asfOptions,data:JSON.stringify({Command:`!LEAVEGROUP ${this.#botName} `+groupId})});if("Success"===result)return 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})`)}}return!1}catch(error){return throwError(error,"SteamASF.leaveGroup"),!1}}async#getGroupId(){try{var 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(line=>{var[,line,id]=line.trim().split("|");return line&&id?[line,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{var logStatus=scripts_echoLog({type:"addingToWishlist",text:gameId});let{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{var logStatus=scripts_echoLog({type:"removingFromWishlist",text:gameId});let{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{var logStatus=scripts_echoLog({type:`${doTask?"":"un"}followingGame`,text:gameId});let{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{var logStatus=scripts_echoLog({type:doTask?"followingCurator":"unfollowingCurator",text:curatorId});let{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{var[type,ids]=id.split("-");if("appid"===type){var logStatus=scripts_echoLog({type:"addingFreeLicense",text:ids});let{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){var idsArr=ids.split(",");let logStatus=scripts_echoLog({type:"addingFreeLicenseSubid",text:ids});var{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){if(200===data?.status&&data.response?.Result){let resultLines=data.response.Result.split("\n");return idsArr.forEach(subid=>{let targetLine=resultLines.find(text=>text.includes(subid));targetLine&&["成功","Success","Успех"].find(text=>targetLine.includes(text))?scripts_echoLog({}).success(targetLine):scripts_echoLog({}).error(targetLine)}),!0}logStatus.error(`Error:${data?.response?.Result||data?.response?.Message||data?.statusText}(${data?.status})`)}else logStatus.error(result+`:${statusText}(${status})`)}return!1}catch(error){return throwError(error,"SteamASF.addLicense"),!1}}async requestPlayTestAccess(id){try{var logStatus=scripts_echoLog({type:"requestingPlayTestAccess",text:id});let{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}}};class Steam extends userDefinedGlobalOptions{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{if(globalOptions.ASF.AsfEnabled&&globalOptions.ASF.AsfIpcUrl&&globalOptions.ASF.AsfIpcPassword)return this.#ASF=new social_SteamASF,!!await this.#ASF.init()&&(this.#storeInitialized=!0,this.#communityInitialized=!0);if("store"===type){if(!this.#storeInitialized){let storeInitialized=await this.#updateStoreAuth();if(storeInitialized=storeInitialized||await this.#updateStoreAuthTab(),this.#storeInitialized=storeInitialized,!this.#storeInitialized)return scripts_echoLog({}).error(i18n("initFailed","Steam")),!1;scripts_echoLog({}).success(i18n("initSuccess","SteamStore"))}}else{if("community"!==type)return this.#storeInitialized&&this.#communityInitialized?(scripts_echoLog({}).success(i18n("initSuccess","Steam")),!0):(scripts_echoLog({}).error(i18n("initFailed","Steam")),!1);if(!this.#communityInitialized){let communityInitialized=await this.#updateCommunityAuth();if(communityInitialized||(communityInitialized=await this.#updateCommunityAuthTab(),GM_setValue("steamCommunityAuth",null)),this.#communityInitialized=communityInitialized,!this.#communityInitialized)return scripts_echoLog({}).error(i18n("initFailed","Steam")),!1;scripts_echoLog({}).success(i18n("initSuccess","SteamCommunity"))}}return!0}catch(error){return throwError(error,"Steam.init"),!1}}async#refreshToken(type="steamStore"){try{var host={steamStore:"store.steampowered.com",steamCommunity:"steamcommunity.com"},logStatus=scripts_echoLog({text:i18n("refreshingToken",i18n(type))}),formData=new FormData,{result,statusText,status,data}=(formData.append("redir",`https://${host[type]}/`),await tools_httpRequest({url:"https://login.steampowered.com/jwt/ajaxrefresh",method:"POST",responseType:"json",headers:{Host:"login.steampowered.com",Origin:"https://"+host[type],Referer:`https://${host[type]}/`},data:formData}));return"Success"===result?data?.response?.success?await this.#setStoreToken(data.response,type)?(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.refreshToken"),!1}}async#setStoreToken(param,type){try{var host={steamStore:"store.steampowered.com",steamCommunity:"steamcommunity.com"},logStatus=scripts_echoLog({text:i18n("settingToken",i18n(type))}),formData=new FormData,{result,statusText,status,data}=(formData.append("steamID",param.steamID),formData.append("nonce",param.nonce),formData.append("redir",param.redir),formData.append("auth",param.auth),await tools_httpRequest({url:`https://${host[type]}/login/settoken`,method:"POST",headers:{Accept:"application/json, text/plain, */*",Host:host[type],Origin:"https://"+host[type]},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(retry=!1){try{var storeSessionID,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","Sec-Fetch-Dest":"document","Sec-Fetch-Mode":"navigate","Upgrade-Insecure-Requests":"1"},fetch:!1,redirect:"manual"});return 200===data?.status?data.responseText.includes("data-miniprofile=")?(storeSessionID=data.responseText.match(/g_sessionID = "(.+?)";/)?.[1])?(this.#auth.storeSessionID=storeSessionID,logStatus.success(),!0):(logStatus.error('Error: Get "sessionID" failed'),!1):!await this.#refreshToken("steamStore")||(logStatus.warning(i18n("retry")),retry)?(logStatus.error("Error:"+i18n("needLoginSteamStore"),!0),!1):this.#updateStoreAuth(!0):[301,302].includes(data?.status)?!await this.#refreshToken("steamStore")||(logStatus.warning(i18n("retry")),retry)?(logStatus.error("Error:"+i18n("needLoginSteamStore"),!0),!1):this.#updateStoreAuth(!0):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"Steam.updateStoreAuth"),!1}}async#updateStoreAuthTab(){try{let logStatus=scripts_echoLog({text:i18n("updatingAuth",i18n("steamStoreTab"))});return await new Promise(resolve=>{GM_deleteValue("steamStoreAuth"),GM_setValue("ATv4_updateStoreAuth",!0);let newTab=GM_openInTab("https://store.steampowered.com/",{active:!0,setParent:!0}),listenerId=(newTab.name="ATv4_updateStoreAuth",GM_addValueChangeListener("steamStoreAuth",(key,oldValue,newValue)=>{GM_removeValueChangeListener(listenerId),GM_deleteValue("ATv4_updateStoreAuth"),newTab?.close(),window.focus(),newValue&&JSON.stringify(newValue)!==JSON.stringify(oldValue)?(this.#auth.storeSessionID=newValue.storeSessionID,logStatus.success(),resolve(!0)):(logStatus.error("Failed"),resolve(!1))}));newTab.onclose=()=>{GM_deleteValue("ATv4_updateStoreAuth")}})}catch(error){return throwError(error,"Steam.updateStoreAuthTab"),!1}}async#updateCommunityAuthTab(){try{let logStatus=scripts_echoLog({text:i18n("updatingAuth",i18n("steamCommunityTab"))});return await new Promise(resolve=>{GM_deleteValue("steamCommunityAuth"),GM_setValue("ATv4_updateCommunityAuth",!0);let newTab=GM_openInTab("https://steamcommunity.com/my",{active:!0,setParent:!0}),listenerId=(newTab.name="ATv4_updateCommunityAuth",GM_addValueChangeListener("steamCommunityAuth",(key,oldValue,newValue)=>{GM_removeValueChangeListener(listenerId),GM_deleteValue("ATv4_updateCommunityAuth"),newTab?.close(),window.focus(),newValue&&JSON.stringify(newValue)!==JSON.stringify(oldValue)?(this.#auth.steam64Id=newValue.steam64Id,this.#auth.communitySessionID=newValue.communitySessionID,logStatus.success(),resolve(!0)):(logStatus.error("Failed"),resolve(!1))}));newTab.onclose=()=>{GM_deleteValue("ATv4_updateCommunityAuth")}})}catch(error){return throwError(error,"Steam.updateCommunityAuthTab"),!1}}async#updateCommunityAuth(){try{var logStatus=scripts_echoLog({text:i18n("gettingUserLink")}),{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/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",Host:"steamcommunity.com","Sec-Fetch-Dest":"document","Sec-Fetch-Mode":"navigate"},fetch:!1});if(200===data?.status)if(data.finalUrl.includes("https://steamcommunity.com/login/home"))logStatus.error("Error:"+i18n("needLoginSteamCommunity"),!0);else{var steam64Id=data.responseText.match(/g_steamID = "(.+?)";/)?.[1],communitySessionID=data.responseText.match(/g_sessionID = "(.+?)";/)?.[1];if(steam64Id&&communitySessionID)return this.#auth.steam64Id=steam64Id,this.#auth.communitySessionID=communitySessionID,logStatus.success(),!0;logStatus.error('Error: Get "sessionID" failed')}else logStatus.error(result+`:${statusText}(${status})`);return!1}catch(error){return throwError(error,"Steam.updateCommunityAuth"),!1}}async#getAreaInfo(){try{var logStatus=scripts_echoLog({text:i18n("gettingAreaInfo")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/cart/",method:"GET"});if("Success"===result)if(200===data?.status){var cartConfigRaw=data.responseText.match(/data-cart_config="(.*?)"/)?.[1],temp=document.createElement("div"),cartConfigStr=(temp.innerHTML=cartConfigRaw||"{}",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){var userInfoRaw=data.responseText.match(/data-userinfo="(.*?)"/)?.[1],temp1=document.createElement("div"),userInfoStr=(temp1.innerHTML=userInfoRaw||"{}",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);if(currentArea&&0{let 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){var{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}var logStatus=scripts_echoLog({text:i18n("changingArea",aimedArea)}),{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";{let 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{var logStatus,result,statusText,status,data;return this.#ASF?!!await this.#ASF.joinGroup(groupName)&&(this.tasks.groups=unique([...this.tasks.groups,groupName]),!0):(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})}),"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){var logStatus=scripts_echoLog({type:"leavingSteamGroup",text:groupName}),{result,statusText,status,data}=await tools_httpRequest({url:`https://steamcommunity.com/profiles/${this.#auth.steam64Id}/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 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})`)}return!1}catch(error){return throwError(error,"Steam.leaveGroup"),!1}}async#getGroupId(groupName){try{var logStatus=scripts_echoLog({type:"gettingSteamGroupId",text:groupName}),groupId=this.#cache.group[groupName];if(groupId)return logStatus.success(),groupId;var{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;{let 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{var logStatus,result,statusText,status,data,groupId;return this.#ASF?!!await this.#ASF.joinGroup(gameId)&&(this.tasks.officialGroups=unique([...this.tasks.officialGroups,gameId]),!0):(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"}}),"Success"===result?200!==data?.status||data.responseText.includes('id="publicGroupJoin"')?(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.success(),this.tasks.officialGroups=unique([...this.tasks.officialGroups,gameId]),(groupId=data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)?.[1])&&this.#setCache("officialGroup",gameId,groupId),!0):(logStatus.error(result+`:${statusText}(${status})`),!1))}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){var resultR,statusTextR,statusR,dataR,logStatus=scripts_echoLog({type:"leavingSteamOfficialGroup",text:gameId}),{result,statusText,status,data}=await tools_httpRequest({url:`https://steamcommunity.com/profiles/${this.#auth.steam64Id}/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 200===data?.status?({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"}}),"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)):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1);logStatus.error(result+`:${statusText}(${status})`)}return!1}catch(error){return throwError(error,"Steam.leaveOfficialGroup"),!1}}async#getOfficialGroupId(gameId){try{var logStatus=scripts_echoLog({type:"gettingSteamOfficialGroupId",text:gameId}),groupId=this.#cache.officialGroup[gameId];if(groupId)return logStatus.success(),groupId;var{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;{let 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);var logStatus=scripts_echoLog({type:"addingToWishlist",text:gameId}),{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){var{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"'))return logStatus.warning(i18n("changeAreaNotice")),!!await this.#changeArea()&&await this.#addToWishlist(gameId);if((!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"')))return logStatus.error(`Error:${dataR.statusText}(${dataR.status})`),!1}return logStatus.success(),this.tasks.wishlists=unique([...this.tasks.wishlists,gameId]),!0}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);var logStatus=scripts_echoLog({type:"removingFromWishlist",text:gameId}),{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;var{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"));let 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{var logStatus,requestData,result,data,followed;return!doTask&&this.whiteList.follows.includes(gameId)?(scripts_echoLog({type:"whiteList",text:"Steam.unfollowGame",id:gameId}),!0):this.#ASF?!!await this.#ASF.toggleFollowGame(gameId,doTask)&&(doTask&&(this.tasks.follows=unique([...this.tasks.follows,gameId])),!0):(logStatus=scripts_echoLog({type:`${doTask?"":"un"}followingGame`,text:gameId}),requestData={sessionid:this.#auth.storeSessionID,appid:gameId},{result,data}=(doTask||(requestData.unfollow="1"),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)})),"Success"===result&&200===data?.status&&"true"===data.responseText?(logStatus.success(),!0):(followed=await this.#isFollowedGame(gameId),"CN"===this.#area&&"areaLocked"===followed?(logStatus.warning(i18n("changeAreaNotice")),!!await this.#changeArea()&&await this.#toggleFollowGame(gameId,doTask)):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{var{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))scripts_echoLog({type:"whiteList",text:"Steam.unsubscribeForum",id:gameId});else{var forumId=await this.#getForumId(gameId);if(!forumId)return!1;var logStatus=scripts_echoLog({type:`${doTask?"":"un"}subscribingForum`,text:gameId}),[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})});"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()):logStatus.error(result+`:${statusText}(${status})`)}return!0}catch(error){return throwError(error,"Steam.toggleForum"),!0}}async#getForumId(gameId){try{var logStatus=scripts_echoLog({type:"gettingForumId",text:gameId}),forumId=this.#cache.forum[gameId];if(forumId)return logStatus.success(),forumId;var{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;{let 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){var logStatus=scripts_echoLog({type:doTask?"favoritingWorkshop":"unfavoritingWorkshop",text:id}),{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})});if("Success"===result)return 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})`)}return!1}catch(error){return throwError(error,"Steam.toggleFavoriteWorkshop"),!1}}async#getWorkshopAppId(id){try{var logStatus=scripts_echoLog({type:"gettingWorkshopAppId",text:id}),appId=this.#cache.workshop[id];if(appId)return logStatus.success(),appId;var{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;{let 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{var logStatus=scripts_echoLog({type:"votingUpWorkshop",text:id}),{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})`):logStatus.error(result+`:${statusText}(${status})`),!0}catch(error){return throwError(error,"Steam.voteupWorkshop"),!0}}async#toggleCurator(curatorId,doTask=!0){try{var logStatus,result,statusText,status,data;return!doTask&&this.whiteList.curators.includes(curatorId)?(scripts_echoLog({type:"whiteList",text:"Steam.unfollowCurator",id:curatorId}),!0):this.#ASF?await this.#ASF.toggleCurator(curatorId,doTask):(logStatus=scripts_echoLog({type:doTask?"followingCurator":"unfollowingCurator",text:curatorId}),{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"}),"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{var logStatus=scripts_echoLog({type:"gettingCuratorId",text:path+"/"+name}),curatorId=this.#cache.curator[path+"/"+name];if(curatorId)return logStatus.success(),curatorId;var{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;{let 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 curatorId,[path,name]=link.split("/");return path&&name?!!(curatorId=await this.getCuratorId(path,name))&&await this.#toggleCurator(curatorId,doTask):(scripts_echoLog({text:i18n("errorLink",link)}),!1)}catch(error){return throwError(error,"Steam.toggleCuratorLike"),!1}}async#getAnnouncementParams(appId,viewId){try{var clanid,gid,logStatus=scripts_echoLog({type:"gettingAnnouncementParams",text:appId,id:viewId}),{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}});return"Success"===result?200===data?.status&&1===data?.response?.success?({clanid,gid}=data.response.event?.announcement_body||{},clanid?(logStatus.success(),{clanId:clanid,gid:gid}):(logStatus.error(`Error:${data.statusText}(${data.status})`),{})):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),{}):(logStatus.error(result+`:${statusText}(${status})`),{})}catch(error){return throwError(error,"Steam.likeAnnouncement"),{}}}async#likeAnnouncement(id){try{var[appId,viewId]=id.split("/");if(appId&&viewId){var{clanId,gid}=await this.#getAnnouncementParams(appId,viewId);if(clanId){var logStatus=scripts_echoLog({type:"likingAnnouncement",text:appId,id:viewId}),{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"});if("Success"===result)return 200===data?.status&&1===data.response.success?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1);logStatus.error(result+`:${statusText}(${status})`)}}else scripts_echoLog({}).error(i18n("missParams")+"(id)");return!1}catch(error){return throwError(error,"Steam.likeAnnouncement"),!1}}async#appid2subid(id){try{var 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)if(200===data?.status)if(data.responseText.includes("ds_owned_flag ds_flag")||data.responseText.includes('class="already_in_library"'))logStatus.success(i18n("owned"));else{if("CN"===this.#area&&data.responseText.includes('id="error_box"')){logStatus.warning(i18n("changeAreaNotice"));let 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];if(subid)return logStatus.success(),subid;if(subid=data.responseText.match(/AddFreeLicense\(\s*(\d+)/)?.[1])return logStatus.success(),subid;logStatus.error(`Error:${data.statusText}(${data.status})`)}else logStatus.error(`Error:${data?.statusText}(${data?.status})`);else logStatus.error(result+`:${statusText}(${status})`);return!1}catch(error){return throwError(error,"Steam.appid2subid"),!1}}async#getLicenses(){try{var logStatus=scripts_echoLog({text:i18n("gettingLicenses")}),{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);var[type,ids]=id.split("-");if("appid"===type){var subid=await this.#appid2subid(ids);if(subid){var logStatus=scripts_echoLog({type:"addingFreeLicense",text:ids});if(await this.#addFreeLicense(subid,logStatus)){var{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/app/"+ids,method:"GET"});if("Success"===result)return 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})`)}}return!1}if("subid"!==type)return!1;"CN"===this.#area&&(scripts_echoLog({}).success(i18n("tryChangeAreaNotice")),await this.#changeArea());var logStatusArr={},idsArr=ids.split(",");for(let subid of idsArr){let logStatus=scripts_echoLog({type:"addingFreeLicenseSubid",text:subid});if(!await this.#addFreeLicense(subid,logStatus))return!1;logStatusArr[subid]=logStatus}var licenses=await this.#getLicenses();if(!licenses)return!1;for(let 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{var logStatus=logStatusPre||scripts_echoLog({type:"addingFreeLicenseSubid",text:id}),{result,statusText,status,data}=await tools_httpRequest({url:"https://store.steampowered.com/freelicense/addfreelicense/"+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/account/licenses/"},data:$.param({ajax:!0,sessionid:this.#auth.storeSessionID}),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"));let 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{var logStatus,result,statusText,status,data;return this.#ASF?await this.#ASF.requestPlayTestAccess(id):(logStatus=scripts_echoLog({type:"requestingPlayTestAccess",text:id}),{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"}),"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;var 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")}}}let social_Steam=Steam,defaultTasks=(userDefinedGlobalOptions=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{var steamLength,steamCommunityLength,pro=[];let tasks="do"===action?this.undoneTasks:this.socialTasks;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(var 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){try{var social,types,result={};for([social,types]of Object.entries(allTasks)){result[social]={};for(var[type,tasks]of Object.entries(types))result[social][type]=unique(tasks)}return result}catch(error){return throwError(error,"Website.uniqueTasks"),allTasks}}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;var pro=[],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(var 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}}},JSON.stringify({steam:{groupLinks:[],wishlistLinks:[],curatorLinks:[],followLinks:[]},vk:{nameLinks:[]}}));class FreeAnyWhere extends userDefinedGlobalOptions{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{var 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{var logStatus=scripts_echoLog({text:i18n("getTasksInfo")}),{result,statusText,status,data}=("undo"===action&&(this.socialTasks=GM_getValue("fawTasks-"+this.giveawayId)?.tasks||JSON.parse(defaultTasks)),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_default().get("csrftoken")},responseType:"json"}));if("Success"===result){var tasks=data?.response?.challenges;if(tasks){"verify"===action&&(this.tasks=[]);for(var task of tasks){var type=task.challenge,social=task.challenge_provider,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}logStatus.error(`Error:${data?.statusText}(${data?.status})`)}else logStatus.error(result+`:${statusText}(${status})`);return!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;var task,pro=[];for(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()){var logStatus=scripts_echoLog({text:i18n("gettingKey")}),{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")}});if("Success"===result)return data?.response?.reward?(logStatus.success(),scripts_echoLog({}).success(data.response.reward),data.response.reward):(!1===data?.response?.completed?logStatus.error(i18n("tasksNotCompleted")):(!0===data?.response?.completed&&await this.#checkLeftKey(),logStatus.error(`Error:${data?.statusText}(${data?.status})`)),!1);logStatus.error(result+`:${statusText}(${status})`)}return!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){return throwError(error,"FreeAnyWhere.getGiveawayId"),!1}}async#verify(task){try{var logStatus=scripts_echoLog({html:`
  • ${i18n("verifyingTask")}${task.title.trim()}...
  • `}),{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_default().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{var data;return globalOptions.other.checkLeftKey&&(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,data?.response?.giveaways.find(giveaway=>""+giveaway?.id===this.giveawayId)||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}}}var Freeanywhere=FreeAnyWhere;let 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 extends userDefinedGlobalOptions{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{var 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{var logStatus=scripts_echoLog({text:i18n("getTasksInfo")});if("undo"===action)this.socialTasks=GM_getValue("gasTasks-"+this.giveawayId)?.tasks||Giveawaysu_defaultTasks;else{var pro=[],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(let task of tasks)pro.push(new Promise(resolve=>{var td=$(task).find('td:not(".hidden")'),colorfulTask=td.eq(1).find('a:not([data-trigger="link"])'),colorlessTask=td.eq(2).find('a:not([data-trigger="link"])'),colorfulTask=0{if(!taskLink)return resolve(!1);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)),resolve(!0)}).catch(error=>(throwError(error,"Giveawaysu.classifyTask->getRedirectLink"),!1))}));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()})}return!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}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}catch(error){return throwError(error,"Giveawaysu.checkLeftKey"),!1}}#getGiveawayId(){try{var giveawayId=window.location.href.match(/\/view\/([\d]+)/)?.[1];return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Giveawaysu.getGiveawayId"),!1}}}class Indiedb{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)scripts_echoLog({}).error(i18n("needLogin"));else{var logStatus,result,statusText,status,data,currentoption=$("a.buttonenter.buttongiveaway");if(/join giveaway/gim.test(currentoption.text()))return logStatus=scripts_echoLog({text:i18n("joiningGiveaway")+"..."}),{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}}),"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);if(/success/gim.test($("a.buttonenter.buttongiveaway").text()))return!0;scripts_echoLog({}).warning(i18n("needJoinGiveaway"))}return!1}catch(error){return throwError(error,"Indiedb.init"),!1}}async#do(){try{let 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;var task,pro=[];for(task of $("#giveawaysjoined a[class*=promo]")){let promo=$(task);if(!promo.hasClass("buttonentered")){let 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=>{var data=(url=>{try{let 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}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}catch(error){return throwError(error,"Indiedb.checkLeftKey"),!1}}}var website_Indiedb=Indiedb;let Keyhub_defaultTasks=JSON.stringify({steam:{groupLinks:[],officialGroupLinks:[],wishlistLinks:[],curatorLinks:[]},discord:{serverLinks:[]},extra:{videoTasks:[]},links:[]});class Keyhub extends userDefinedGlobalOptions{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{var 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{var task,logStatus=scripts_echoLog({text:i18n("getTasksInfo")}),tasks=("undo"===action&&(this.socialTasks=GM_getValue("khTasks-"+this.giveawayId)?.tasks||JSON.parse(Keyhub_defaultTasks)),$('.task:not(".googleads")').filter((index,element)=>"do"!==action||0===$(element).find("i.fa-check-circle:visible").length).find("a"));for(task of tasks){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)?GM_openInTab(link,{active:!0}):/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{var logStatus=scripts_echoLog({text:i18n("doingKeyhubTask")}),{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{var data,pro=[];for(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}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}catch(error){return throwError(error,"Keyhub.checkLogin"),!1}}}var website_Keyhub=Keyhub;let Givekey_defaultTasks=JSON.stringify({steam:{groupLinks:[],wishlistLinks:[],curatorLinks:[],curatorLikeLinks:[]},twitter:{userLinks:[]},vk:{nameLinks:[]},discord:{serverLinks:[]}});class Givekey extends userDefinedGlobalOptions{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=>{let checker=setInterval(()=>{0<$("#navbarDropdown").length&&(clearInterval(checker),resolve(!0))},500)}),await this.#checkLeftKey()||scripts_echoLog({}).warning(i18n("checkLeftKeyFailed"))}catch(error){throwError(error,"Givekey.after")}}init(){try{var userId,logStatus=scripts_echoLog({text:i18n("initing")});return 0<$('a[href*="/auth/steam"]').length?(window.open("/auth/steam","_self"),logStatus.warning(i18n("needLogin")),!1):!!this.#getGiveawayId()&&((userId=$('meta[name="user-id"]').attr("content"))?(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{var task,logStatus=scripts_echoLog({text:i18n("getTasksInfo")}),tasks=("undo"===action&&(this.socialTasks=GM_getValue("gkTasks-"+this.giveawayId)?.tasks||JSON.parse(Givekey_defaultTasks)),$('.card-body:has("button") .row'));for(task of tasks){var taskEle=$(task),isSuccess=/Complete/i.test(taskEle.find("button").text().trim());if(!isSuccess||"undo"===action){var taskId=taskEle.find("#task_check").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(),icon=taskEle.find("i");href&&text&&(href=/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(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{let 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}catch(error){return throwError(error,"Givekey.checkLeftKey"),!1}}}var website_Givekey=Givekey;class GiveeClub extends 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{var 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{var logStatus=scripts_echoLog({text:i18n("getTasksInfo")});if("undo"===action)this.socialTasks=GM_getValue("gcTasks-"+this.giveawayId)?.tasks||Giveawaysu_defaultTasks;else{this.undoneTasks=Giveawaysu_defaultTasks;var pro=[];for(let task of $(".event-actions tr"))pro.push(new Promise(resolve=>{let 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=>{if(!taskLink)return resolve(!1);"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),resolve(!0)}).catch(error=>(throwError(error,"GiveeClub.classifyTask->getRedirectLink"),!1))}));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()})}return!0}catch(error){return throwError(error,"GiveeClub.classifyTask"),!1}}async verifyTask(){try{var button,logStatus=scripts_echoLog({text:i18n("giveeClubVerifyNotice")});for(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}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}catch(error){return throwError(error,"Giveawaysu.checkLeftKey"),!1}}}var website_GiveeClub=GiveeClub,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{var item;for(item of $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`)){var logStatus,aElement,giveawayId,result,statusText,status,data,result0,statusText0,status0,data0,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();"points"===type&&needPoints>this.myPoints?scripts_echoLog({}).warning(i18n("noPoints")+": "+name):"points"!==type||needPoints?"points"===type&&needPoints>this.maxPoints||(logStatus=scripts_echoLog({text:`${i18n("joiningLottery")}${name}...`}),(aElement=$(item).find("a.giveaways-page-item-img-btn-enter:contains('enter')"))?.attr("onclick")?.includes("checkUser")&&(giveawayId=aElement.attr("onclick")?.match(/[\d]+/)?.[0])&&checkUser(giveawayId),aElement.attr("href")?({result,statusText,status,data}=await tools_httpRequest({url:aElement.attr("href"),method:"GET"}),"Success"===result?({result:result0,statusText:statusText0,status:status0,data:data0}=await tools_httpRequest({url:data?.finalUrl,method:"GET"}),data0?.responseText&&/You've entered this giveaway/gim.test(data0.responseText)?(logStatus.success(),points=data0.responseText.match(/Points:[\s]*?([\d]+)/)?.[1],"points"===type&&points&&(this.myPoints=parseInt(points,10))):data0?.responseText&&/You're not eligible to enter/gim.test(data0.responseText)?logStatus.error("You're not eligible to enter"):logStatus.error(result0+`:${statusText0}(${status0})`)):logStatus.error(result+`:${statusText}(${status})`)):logStatus.error('Error: No "href".')):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}catch(error){return throwError(error,"OpiumPulses.checkLogin"),!1}}},dayjs_min=__webpack_require__(353),dayjs_min_default=__webpack_require__.n(dayjs_min);let 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{var{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{var{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{var campaignDiv,campaignString,campaign,{result,data}=await tools_httpRequest({url:link,method:"GET"});return"Success"===result&&200===data?.status?/incentives":{"[\d]+?":\[".+?"\]/.test(data.responseText)?"Won":!!(campaignDiv=data.responseText.match(/