From 1f9d7b2a708b0bc7501fffa5060f3333b2c07ecc Mon Sep 17 00:00:00 2001 From: HCLonely Date: Fri, 6 Sep 2024 16:43:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:Gleam=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E6=97=B6=E6=8A=A5=E9=94=99(#29)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Release.yml | 8 +++---- 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 | 22 ++++++++++--------- dist/auto-task-v4.compatibility.all.user.js | 4 ++-- dist/auto-task-v4.compatibility.user.js | 4 ++-- dist/auto-task-v4.user.js | 22 ++++++++++--------- doc/docs/logs/README.md | 6 +++++ package.json | 5 ++--- .../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 | 22 ++++++++++--------- .../auto-task-v4.compatibility.all.user.js | 4 ++-- page/dist/auto-task-v4.compatibility.user.js | 4 ++-- page/dist/auto-task-v4.user.js | 22 ++++++++++--------- page/package.json | 7 +++--- src/scripts/website/Gleam.ts | 16 ++++++++------ 17 files changed, 83 insertions(+), 71 deletions(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 82d43c6..4d16245 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -21,11 +21,9 @@ jobs: uses: softprops/action-gh-release@v1 with: prerelease: false - tag_name: v4.4.9 - name: 4.4.9 - body: |- - - 新增:自动完成Gleam输入框任务 - - 优化:增加Gleam可识别任务 + tag_name: v4.4.10 + name: 4.4.10 + body: '- 修复:Gleam没有输入框时报错(#29)' 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 d151d8b..219c705 100644 --- a/dist/auto-task-v4-for-giveawaysu.all.user.js +++ b/dist/auto-task-v4-for-giveawaysu.all.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4-for-giveawaysu // @namespace auto-task-v4-for-giveawaysu -// @version 4.4.9 +// @version 4.4.10 // @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 1788a09..fa093b6 100644 --- a/dist/auto-task-v4-for-giveawaysu.user.js +++ b/dist/auto-task-v4-for-giveawaysu.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4-for-giveawaysu // @namespace auto-task-v4-for-giveawaysu -// @version 4.4.9 +// @version 4.4.10 // @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 e42757f..3a82f1d 100644 --- a/dist/auto-task-v4.all.user.js +++ b/dist/auto-task-v4.all.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4 // @namespace auto-task-v4 -// @version 4.4.9 +// @version 4.4.10 // @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 @@ -9518,15 +9518,17 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载'); unsafeWindow.$hookTimer?.setSpeed(1); const expandInfo = $task.find('.expandable'); const input = expandInfo.find('input')[0]; - const evt = new Event('input', { - bubbles: true, - cancelable: true, - composed: true - }); - const valuelimit = [ ...expandInfo.text().matchAll(/"(.+?)"/g) ].at(-1)?.[1]; - input.value = valuelimit || 'vloot'; - input.dispatchEvent(evt); - await delay(1e3); + if (input) { + const evt = new Event('input', { + bubbles: true, + cancelable: true, + composed: true + }); + const valuelimit = [ ...expandInfo.text().matchAll(/"(.+?)"/g) ].at(-1)?.[1]; + input.value = valuelimit || 'vloot'; + input.dispatchEvent(evt); + await delay(1e3); + } await this.#checkSync(); const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)'); for (const button of continueBtn) { diff --git a/dist/auto-task-v4.compatibility.all.user.js b/dist/auto-task-v4.compatibility.all.user.js index 5e51340..e952faf 100644 --- a/dist/auto-task-v4.compatibility.all.user.js +++ b/dist/auto-task-v4.compatibility.all.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4.compatibility // @namespace auto-task-v4.compatibility -// @version 4.4.9 +// @version 4.4.10 // @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 @@ -146,7 +146,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');

在下方填写白名单,每行一个

`,inputValue:whiteList[social][type].join("\n"),showConfirmButton:!0,confirmButtonText:i18n("save"),showCancelButton:!0,cancelButtonText:i18n("close"),showDenyButton:!0,denyButtonText:i18n("return")}).then(({isDenied,isConfirmed,value})=>{isDenied?"swal"===showType&&whiteListOptions(showType):isConfirmed&&(whiteList[social][type]=value.split("\n"),GM_setValue("whiteList",whiteList),external_Swal_default().fire({title:i18n("changeWhiteListSuccess"),icon:"success"}))}),$("#link2id").on("click",async function(){var type=$(this).attr("data-type");$("#socialLink").val(await async function(type){try{const link=$("#socialLink").val();let id="";switch(type){case"discord.servers":id=link.match(/invite\/(.+)/)?.[1]||"";break;case"instagram.users":id=link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)?.[1]||"";break;case"twitch.channels":id=link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)?.[2]||"";break;case"twitter.users":id=link.match(/https:\/\/twitter\.com\/(.+)/)?.[1]||"";break;case"twitter.retweets":id=link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)?.[1]||"";break;case"vk.names":id=link.match(/https:\/\/vk\.com\/([^/]+)/)?.[1]||"";break;case"youtube.channels":id=(await getInfo(link,"channel"))?.params?.channelId||"";break;case"youtube.likes":id=(await getInfo(link,"likeVideo"))?.params?.videoId||"";break;case"reddit.reddits":id=link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)?.[1]||link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)?.[1]||"";break;case"steam.groups":id=link.match(/groups\/(.+)\/?/)?.[1]||"";break;case"steam.wishlists":case"steam.follows":case"steam.forums":id=link.match(/app\/([\d]+)/)?.[1]||"";break;case"steam.workshops":id=link.match(/\?id=([\d]+)/)?.[1]||"";break;case"steam.curators":if(link.includes("curator"))id=link.match(/curator\/([\d]+)/)?.[1]||"";else{var param=link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)?.slice(1,3);if(!param||2!==param.length)break;const steam=new social_Steam;await steam.init()&&(id=await steam.getCuratorId(param[0],param[1])||"")}}return id}catch(error){return throwError(error,"link2id"),i18n("getFailed","id")}}(type))})):scripts_echoLog({}).warning(i18n("whiteListNotFound",value))}})}catch(error){throwError(error,"whiteListOptions")}}const defaultWhiteList={discord:{servers:[]},instagram:{users:[]},twitch:{channels:[]},twitter:{users:[],retweets:[],likes:[]},vk:{names:[]},youtube:{channels:[],likes:[]},reddit:{reddits:[]},steam:{groups:[],officialGroups:[],wishlists:[],follows:[],forums:[],workshops:[],curators:[],workshopVotes:[],curatorLikes:[],announcements:[],licenses:[],playtests:[]}},disabledType={steam:["workshopVotes","curatorLikes","announcements"],twitter:["likes"]},whiteList=whiteListOptions,getGistData=async(token,gistId,fileName,test=!1)=>{try{const logStatus=scripts_echoLog({text:i18n("gettingData")});var{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},responseType:"json",method:"GET",timeout:3e4});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{var content=data.response?.files?.[fileName]?.content;let formatedContent;if(!content)return logStatus.error("Error:"+i18n("noRemoteData")),!1;if(test)return logStatus.success(),!0;try{formatedContent=JSON.parse(content)}catch(error){return logStatus.error("Error:"+i18n("errorRemoteDataFormat")),!1}return logStatus.success(),formatedContent}}catch(error){return throwError(error,"getGistData"),!1}},syncOptions=()=>{try{var{TOKEN,GIST_ID,FILE_NAME,SYNC_HISTORY}=GM_getValue("gistOptions")||{TOKEN:"",GIST_ID:"",FILE_NAME:"",SYNC_HISTORY:!0};external_Swal_default().fire({title:i18n("gistOptions"),html:`

Github Token

`+`

Gist ID

`+`

${i18n("fileName")}

`+'

`+`

`+`

`,focusConfirm:!1,showLoaderOnConfirm:!0,footer:`${i18n("help")}`,preConfirm:async()=>{var token=$("#github-token").val(),gistId=$("#gist-id").val(),fileName=$("#file-name").val(),syncHistory=$("#sync-history").prop("checked");return GM_setValue("gistOptions",{TOKEN:token,GIST_ID:gistId,FILE_NAME:fileName,SYNC_HISTORY:syncHistory}),getGistData(token,gistId,fileName,!0)},allowOutsideClick:()=>!external_Swal_default().isLoading(),confirmButtonText:i18n("saveAndTest"),showCancelButton:!0,cancelButtonText:i18n("close")}).then(({value})=>{value?external_Swal_default().fire({icon:"success",title:i18n("testSuccess")}).then(syncOptions):void 0!==value&&external_Swal_default().fire({icon:"error",title:i18n("testFailed")}).then(syncOptions)}),$("#upload-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&FILE_NAME))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("processingData")});const data={};var names=GM_listValues(),SYNC_HISTORY=$("#sync-history").prop("checked");for(const name of names)"gistOptions"===name||/^[\w]+?Auth$/.test(name)||!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||(data[name]=GM_getValue(name));external_Swal_default().update({icon:"info",title:i18n("updatingData")}),await(async(token,gistId,fileName,content)=>{try{const logStatus=scripts_echoLog({text:i18n("settingData")});var contentData=JSON.stringify({files:{[fileName]:{content:JSON.stringify(content)}}}),{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},data:contentData,responseType:"json",method:"POST",timeout:3e4});return"Success"===result?200===data?.status&&data.response.files?.[fileName]?.content===JSON.stringify(content)?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"setGistData"),!1}})(TOKEN,GIST_ID,FILE_NAME,data)?external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")}):external_Swal_default().fire({icon:"error",title:i18n("syncDataFailed")})}),$("#download-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME:data}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&data))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("downloadingData")});data=await getGistData(TOKEN,GIST_ID,data);if(!data)return external_Swal_default().fire({icon:"error",title:i18n("checkedNoData")}).then(syncOptions);external_Swal_default().update({icon:"info",title:i18n("savingData")});var name,value,SYNC_HISTORY=$("#sync-history").prop("checked");for([name,value]of Object.entries(data))!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||GM_setValue(name,value);external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")})})}catch(error){throwError(error,"syncOptions")}};dataSync=syncOptions;const Websites=[Freeanywhere,GiveawaySu,website_Indiedb,website_Keyhub,website_Givekey,website_GiveeClub,website_OpiumPulses,loadScript,website_Opquests,class extends website_Website{name="Gleam";undoneTasks=JSON.parse(Gleam_defaultTasks);socialTasks=JSON.parse(Gleam_defaultTasks);buttons=["doTask","undoTask","verifyTask"];static test(){return"gleam.io"===window.location.host}before(){unsafeWindow.confirm=()=>{},unsafeWindow.alert=()=>{},unsafeWindow.prompt=()=>{}}async after(){try{if(window.location.search.includes("8b07d23f4bfa65f9")){const checkComplete=setInterval(()=>{0<$(".entry-content .entry-method i.fa-check").length&&(clearInterval(checkComplete),window.close())});for(const task of $(".entry-content .entry-method")){const taskInfo=$(task).find(".user-links"),expandInfo=$(task).find(".expandable");var aElements=expandInfo.find("a.btn,a:contains(Continue),button:contains(Continue)");if(0!0)}catch(error){return throwError(error,"Gleam.extraDoTask"),!1}}async verifyTask(){try{scripts_echoLog({text:i18n("verifyingTask")+"..."});var tasks=$(".entry-content .entry-method");unsafeWindow._OxA="_OxA";for(const task of tasks){if(0<$('[campaign-key="campaign.key"]').length)return scripts_echoLog({text:i18n("campaign")});const $task=$(task);if(0!==$task.find("i.fa-question").length){const taskInfo=$task.find(".user-links");taskInfo[0].click(),unsafeWindow.$hookTimer?.setSpeed(1e3),await delay(3e3),unsafeWindow.$hookTimer?.setSpeed(1);const expandInfo=$task.find(".expandable"),input=expandInfo.find("input")[0];var evt=new Event("input",{bubbles:!0,cancelable:!0,composed:!0}),valuelimit=[...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1];input.value=valuelimit||"vloot",input.dispatchEvent(evt),await delay(1e3),await this.#checkSync();for(const button of $task.find(".expandable").find("span:contains(Continue),button:contains(Continue)"))button.click(),await delay(500),await this.#checkSync()}}scripts_echoLog({text:i18n("verifiedGleamTasks")})}catch(error){return throwError(error,"Gleam.verifyTask"),!1}}async#checkSync(){try{return await new Promise(resolve=>{const checker=setInterval(()=>{0===$(".entry-content .entry-method i.fa-sync").length&&(clearInterval(checker),resolve(!0))},500)})}catch(error){return throwError(error,"Gleam.checkSync"),!1}}async#doGleamTask(link){try{const logStatus=scripts_echoLog({text:i18n("doingGleamTask")});return await new Promise(resolve=>{GM_openInTab(link+"?8b07d23f4bfa65f9",{active:!0,insert:!0,setParent:!0}).onclose=()=>{logStatus.success(),resolve(!0)}})}catch(error){return throwError(error,"Gleam.doGleamTask"),!1}}#getGiveawayId(){try{var giveawayId=window.location.pathname;return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Gleam.getGiveawayId"),!1}}async#getGleamLink(title){try{const logStatus=scripts_echoLog({text:i18n("gettingGleamLink")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://www.vloot.io/api/v1/giveaways",method:"GET",responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200===data?.status&&!0===data?.response?.Success&&data?.response?.Data){var link=(data.response.Data.find(giveaway=>title.replace(/[\s]/g,"").toLowerCase().includes(giveaway.title.replace(/[\s]/g,"").toLowerCase()))||{})["link"];return link?(logStatus.success(),link):(logStatus.error("Error:"+i18n("getLinkFailed")),!1)}return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1}catch(error){return throwError(error,"Gleam.getGleamLink"),!1}}async#checkLeftKey(){try{if(!globalOptions.other.checkLeftKey)return!0;var campaignString=$("div.popup-blocks-container").attr("ng-init")?.match(/initCampaign\(([\w\W]+?)\)$/)?.[1];if(!campaignString)return!1;var{campaign,incentive}=JSON.parse(campaignString),controllerString=$("div.campaign.reward").attr("ng-init")?.match(/initContestant\(([\w\W]+?)\);/)?.[1];let ownedKey=!1;return controllerString&&JSON.parse(controllerString).contestant?.claims?.incentives?.[incentive.id]?.length&&(ownedKey=!0),(campaign.banned||campaign.finished&&!ownedKey||campaign.paused||(new Date).getTime()<1e3*campaign.starts_at)&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayNotWork"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0}catch(error){return throwError(error,"Gleam.checkLeftKey"),!1}}},class extends website_Website{name="SweepWidget";options={username:"",email:"",...GM_getValue("SweepWidgetOptions")};buttons=["doTask"];static test(){return/^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed"))}catch(error){throwError(error,"SweepWidget.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return this.#checkLogin()?!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0):(logStatus.warning(i18n("needLogin")),!1)}catch(error){return throwError(error,"SweepWidget.init"),!1}}classifyTask(){return!0}async doTask(){try{if(0===$("#unlock_rewards_main_wrapper").length&&(0<$('input[name="sw__login_name"]:visible').length&&$('input[name="sw__login_name"]').val(this.options.username),0<$('input[name="sw__login_email"]:visible').length&&$('input[name="sw__login_email"]').val(this.options.email),0<$("#sw_login_button:visible").length&&$("#sw_login_button")[0].click(),!await this.#checkEnter()))return!1;const logStatus=scripts_echoLog({text:i18n("SweepWidgetNotice")});for(const task of $("#sw_inner_entry_methods_l2_wrapper>div.sw_entry")){const $task=$(task);if(!(0<$task.find("i.fa-check:visible").length)){const title=$task.find(".sw_text_inner");title[0].click();const aElement=$task.find("a.sw_link");var link=aElement.attr("href");aElement.attr("href","#a").attr("target","_self"),aElement[0]?.click(),await delay(300),aElement.attr("href",link).attr("target","_blank"),$task.find('input[type="text"]').val("test");const verifyBtn=$task.find("input.sw_verify");!0===verifyBtn.prop("disabled")&&(title[0].click(),await delay(300),title[0].click(),await delay(300)),$task.find("input.sw_verify").removeAttr("disabled")[0]?.click(),await this.#checkFinish($task),await delay(parseInt(""+(2001*Math.random()+1e3),10))}}return logStatus.success(),!0}catch(error){return throwError(error,"SweepWidget.doTask"),!1}}#checkLogin(){try{return 0<$("#twitter_login_button").length&&$("#twitter_login_button")[0].click(),!0}catch(error){return throwError(error,"SweepWidget.checkLogin"),!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,"SweepWidget.getGiveawayId"),!1}}async#checkEnter(){try{return new Promise(resolve=>{const checker=setInterval(()=>{0<$("#unlock_rewards_main_wrapper").length&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkEnter"),!1}}async#checkFinish($task){try{return new Promise(resolve=>{const checker=setInterval(()=>{(0<$task.find("i.fa-check:visible").length||0===$task.find(".sw_entry_input:visible").length)&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkFinish"),!1}}},class{name="Setting";buttons=["saveGlobalOptions","syncData","tasksHistory"];syncData=dataSync;tasksHistory(){window.open("https://auto-task-v4.hclonely.com/history.html","_blank")}static test(){return"auto-task-v4.hclonely.com"===window.location.host&&"/setting.html"===window.location.pathname}before(){$("body").html("").addClass("auto-task-options")}after(){try{this.#environment(),changeGlobalOptions("page"),whiteList("page"),$('input[name="other.twitterVerifyId"]').after(``),$("#getTwitterUserId").on("click",()=>{this.#getId("twitterUser")}),$('input[name="other.youtubeVerifyChannel"]').after(``),$("#getYoutubeChannelId").on("click",()=>{this.#getId("youtubeChannel")}),$('input[name^="position"]').on("input",function(){switch($(this).attr("name").replace("position.","")){case"buttonSideX":case"buttonSideY":case"buttonDistance":{const distance=$('input[name="position.buttonDistance"]').val();var sideX=$('input[name="position.buttonSideX"]').val(),sideY=$('input[name="position.buttonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;var distanceArr=distance.split(",");$("#auto-task-buttons").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"showButtonSideX":case"showButtonSideY":case"showButtonDistance":{const distance=$('input[name="position.showButtonDistance"]').val(),sideX=$('input[name="position.showButtonSideX"]').val(),sideY=$('input[name="position.showButtonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("div.show-button-div").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"logSideX":case"logSideY":case"logDistance":{const distance=$('input[name="position.logDistance"]').val(),sideX=$('input[name="position.logSideX"]').val(),sideY=$('input[name="position.logSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("#auto-task-info").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}}}),$('input[name^="hotKey"]').attr("readonly","readonly").off("keydown").on("keydown",function(event){let functionKey="";event.altKey?functionKey+="alt + ":event.ctrlKey?functionKey+="ctrl + ":event.shiftKey&&(functionKey+="shift + "),$(this).val(functionKey+(1===event.key.length?event.key.toLowerCase():""))})}catch(error){throwError(error,"Setting.after")}}saveGlobalOptions(){saveData()}#getId(social){try{external_Swal_default().fire({title:i18n("getId",i18n(social)),html:` + ${i18n("downloadFromGist")}

`,focusConfirm:!1,showLoaderOnConfirm:!0,footer:`${i18n("help")}`,preConfirm:async()=>{var token=$("#github-token").val(),gistId=$("#gist-id").val(),fileName=$("#file-name").val(),syncHistory=$("#sync-history").prop("checked");return GM_setValue("gistOptions",{TOKEN:token,GIST_ID:gistId,FILE_NAME:fileName,SYNC_HISTORY:syncHistory}),getGistData(token,gistId,fileName,!0)},allowOutsideClick:()=>!external_Swal_default().isLoading(),confirmButtonText:i18n("saveAndTest"),showCancelButton:!0,cancelButtonText:i18n("close")}).then(({value})=>{value?external_Swal_default().fire({icon:"success",title:i18n("testSuccess")}).then(syncOptions):void 0!==value&&external_Swal_default().fire({icon:"error",title:i18n("testFailed")}).then(syncOptions)}),$("#upload-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&FILE_NAME))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("processingData")});const data={};var names=GM_listValues(),SYNC_HISTORY=$("#sync-history").prop("checked");for(const name of names)"gistOptions"===name||/^[\w]+?Auth$/.test(name)||!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||(data[name]=GM_getValue(name));external_Swal_default().update({icon:"info",title:i18n("updatingData")}),await(async(token,gistId,fileName,content)=>{try{const logStatus=scripts_echoLog({text:i18n("settingData")});var contentData=JSON.stringify({files:{[fileName]:{content:JSON.stringify(content)}}}),{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},data:contentData,responseType:"json",method:"POST",timeout:3e4});return"Success"===result?200===data?.status&&data.response.files?.[fileName]?.content===JSON.stringify(content)?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"setGistData"),!1}})(TOKEN,GIST_ID,FILE_NAME,data)?external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")}):external_Swal_default().fire({icon:"error",title:i18n("syncDataFailed")})}),$("#download-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME:data}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&data))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("downloadingData")});data=await getGistData(TOKEN,GIST_ID,data);if(!data)return external_Swal_default().fire({icon:"error",title:i18n("checkedNoData")}).then(syncOptions);external_Swal_default().update({icon:"info",title:i18n("savingData")});var name,value,SYNC_HISTORY=$("#sync-history").prop("checked");for([name,value]of Object.entries(data))!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||GM_setValue(name,value);external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")})})}catch(error){throwError(error,"syncOptions")}};dataSync=syncOptions;const Websites=[Freeanywhere,GiveawaySu,website_Indiedb,website_Keyhub,website_Givekey,website_GiveeClub,website_OpiumPulses,loadScript,website_Opquests,class extends website_Website{name="Gleam";undoneTasks=JSON.parse(Gleam_defaultTasks);socialTasks=JSON.parse(Gleam_defaultTasks);buttons=["doTask","undoTask","verifyTask"];static test(){return"gleam.io"===window.location.host}before(){unsafeWindow.confirm=()=>{},unsafeWindow.alert=()=>{},unsafeWindow.prompt=()=>{}}async after(){try{if(window.location.search.includes("8b07d23f4bfa65f9")){const checkComplete=setInterval(()=>{0<$(".entry-content .entry-method i.fa-check").length&&(clearInterval(checkComplete),window.close())});for(const task of $(".entry-content .entry-method")){const taskInfo=$(task).find(".user-links"),expandInfo=$(task).find(".expandable");var aElements=expandInfo.find("a.btn,a:contains(Continue),button:contains(Continue)");if(0!0)}catch(error){return throwError(error,"Gleam.extraDoTask"),!1}}async verifyTask(){try{scripts_echoLog({text:i18n("verifyingTask")+"..."});var evt,valuelimit,tasks=$(".entry-content .entry-method");unsafeWindow._OxA="_OxA";for(const task of tasks){if(0<$('[campaign-key="campaign.key"]').length)return scripts_echoLog({text:i18n("campaign")});const $task=$(task);if(0!==$task.find("i.fa-question").length){const taskInfo=$task.find(".user-links");taskInfo[0].click(),unsafeWindow.$hookTimer?.setSpeed(1e3),await delay(3e3),unsafeWindow.$hookTimer?.setSpeed(1);const expandInfo=$task.find(".expandable"),input=expandInfo.find("input")[0];input&&(evt=new Event("input",{bubbles:!0,cancelable:!0,composed:!0}),valuelimit=[...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1],input.value=valuelimit||"vloot",input.dispatchEvent(evt),await delay(1e3)),await this.#checkSync();for(const button of $task.find(".expandable").find("span:contains(Continue),button:contains(Continue)"))button.click(),await delay(500),await this.#checkSync()}}scripts_echoLog({text:i18n("verifiedGleamTasks")})}catch(error){return throwError(error,"Gleam.verifyTask"),!1}}async#checkSync(){try{return await new Promise(resolve=>{const checker=setInterval(()=>{0===$(".entry-content .entry-method i.fa-sync").length&&(clearInterval(checker),resolve(!0))},500)})}catch(error){return throwError(error,"Gleam.checkSync"),!1}}async#doGleamTask(link){try{const logStatus=scripts_echoLog({text:i18n("doingGleamTask")});return await new Promise(resolve=>{GM_openInTab(link+"?8b07d23f4bfa65f9",{active:!0,insert:!0,setParent:!0}).onclose=()=>{logStatus.success(),resolve(!0)}})}catch(error){return throwError(error,"Gleam.doGleamTask"),!1}}#getGiveawayId(){try{var giveawayId=window.location.pathname;return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Gleam.getGiveawayId"),!1}}async#getGleamLink(title){try{const logStatus=scripts_echoLog({text:i18n("gettingGleamLink")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://www.vloot.io/api/v1/giveaways",method:"GET",responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200===data?.status&&!0===data?.response?.Success&&data?.response?.Data){var link=(data.response.Data.find(giveaway=>title.replace(/[\s]/g,"").toLowerCase().includes(giveaway.title.replace(/[\s]/g,"").toLowerCase()))||{})["link"];return link?(logStatus.success(),link):(logStatus.error("Error:"+i18n("getLinkFailed")),!1)}return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1}catch(error){return throwError(error,"Gleam.getGleamLink"),!1}}async#checkLeftKey(){try{if(!globalOptions.other.checkLeftKey)return!0;var campaignString=$("div.popup-blocks-container").attr("ng-init")?.match(/initCampaign\(([\w\W]+?)\)$/)?.[1];if(!campaignString)return!1;var{campaign,incentive}=JSON.parse(campaignString),controllerString=$("div.campaign.reward").attr("ng-init")?.match(/initContestant\(([\w\W]+?)\);/)?.[1];let ownedKey=!1;return controllerString&&JSON.parse(controllerString).contestant?.claims?.incentives?.[incentive.id]?.length&&(ownedKey=!0),(campaign.banned||campaign.finished&&!ownedKey||campaign.paused||(new Date).getTime()<1e3*campaign.starts_at)&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayNotWork"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0}catch(error){return throwError(error,"Gleam.checkLeftKey"),!1}}},class extends website_Website{name="SweepWidget";options={username:"",email:"",...GM_getValue("SweepWidgetOptions")};buttons=["doTask"];static test(){return/^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed"))}catch(error){throwError(error,"SweepWidget.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return this.#checkLogin()?!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0):(logStatus.warning(i18n("needLogin")),!1)}catch(error){return throwError(error,"SweepWidget.init"),!1}}classifyTask(){return!0}async doTask(){try{if(0===$("#unlock_rewards_main_wrapper").length&&(0<$('input[name="sw__login_name"]:visible').length&&$('input[name="sw__login_name"]').val(this.options.username),0<$('input[name="sw__login_email"]:visible').length&&$('input[name="sw__login_email"]').val(this.options.email),0<$("#sw_login_button:visible").length&&$("#sw_login_button")[0].click(),!await this.#checkEnter()))return!1;const logStatus=scripts_echoLog({text:i18n("SweepWidgetNotice")});for(const task of $("#sw_inner_entry_methods_l2_wrapper>div.sw_entry")){const $task=$(task);if(!(0<$task.find("i.fa-check:visible").length)){const title=$task.find(".sw_text_inner");title[0].click();const aElement=$task.find("a.sw_link");var link=aElement.attr("href");aElement.attr("href","#a").attr("target","_self"),aElement[0]?.click(),await delay(300),aElement.attr("href",link).attr("target","_blank"),$task.find('input[type="text"]').val("test");const verifyBtn=$task.find("input.sw_verify");!0===verifyBtn.prop("disabled")&&(title[0].click(),await delay(300),title[0].click(),await delay(300)),$task.find("input.sw_verify").removeAttr("disabled")[0]?.click(),await this.#checkFinish($task),await delay(parseInt(""+(2001*Math.random()+1e3),10))}}return logStatus.success(),!0}catch(error){return throwError(error,"SweepWidget.doTask"),!1}}#checkLogin(){try{return 0<$("#twitter_login_button").length&&$("#twitter_login_button")[0].click(),!0}catch(error){return throwError(error,"SweepWidget.checkLogin"),!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,"SweepWidget.getGiveawayId"),!1}}async#checkEnter(){try{return new Promise(resolve=>{const checker=setInterval(()=>{0<$("#unlock_rewards_main_wrapper").length&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkEnter"),!1}}async#checkFinish($task){try{return new Promise(resolve=>{const checker=setInterval(()=>{(0<$task.find("i.fa-check:visible").length||0===$task.find(".sw_entry_input:visible").length)&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkFinish"),!1}}},class{name="Setting";buttons=["saveGlobalOptions","syncData","tasksHistory"];syncData=dataSync;tasksHistory(){window.open("https://auto-task-v4.hclonely.com/history.html","_blank")}static test(){return"auto-task-v4.hclonely.com"===window.location.host&&"/setting.html"===window.location.pathname}before(){$("body").html("").addClass("auto-task-options")}after(){try{this.#environment(),changeGlobalOptions("page"),whiteList("page"),$('input[name="other.twitterVerifyId"]').after(``),$("#getTwitterUserId").on("click",()=>{this.#getId("twitterUser")}),$('input[name="other.youtubeVerifyChannel"]').after(``),$("#getYoutubeChannelId").on("click",()=>{this.#getId("youtubeChannel")}),$('input[name^="position"]').on("input",function(){switch($(this).attr("name").replace("position.","")){case"buttonSideX":case"buttonSideY":case"buttonDistance":{const distance=$('input[name="position.buttonDistance"]').val();var sideX=$('input[name="position.buttonSideX"]').val(),sideY=$('input[name="position.buttonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;var distanceArr=distance.split(",");$("#auto-task-buttons").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"showButtonSideX":case"showButtonSideY":case"showButtonDistance":{const distance=$('input[name="position.showButtonDistance"]').val(),sideX=$('input[name="position.showButtonSideX"]').val(),sideY=$('input[name="position.showButtonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("div.show-button-div").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"logSideX":case"logSideY":case"logDistance":{const distance=$('input[name="position.logDistance"]').val(),sideX=$('input[name="position.logSideX"]').val(),sideY=$('input[name="position.logSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("#auto-task-info").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}}}),$('input[name^="hotKey"]').attr("readonly","readonly").off("keydown").on("keydown",function(event){let functionKey="";event.altKey?functionKey+="alt + ":event.ctrlKey?functionKey+="ctrl + ":event.shiftKey&&(functionKey+="shift + "),$(this).val(functionKey+(1===event.key.length?event.key.toLowerCase():""))})}catch(error){throwError(error,"Setting.after")}}saveGlobalOptions(){saveData()}#getId(social){try{external_Swal_default().fire({title:i18n("getId",i18n(social)),html:` `,showCancelButton:!0,cancelButtonText:i18n("close"),showConfirmButton:!1}),$("#link2id").on("click",async function(){const link=$("#socialLink").val();if(link){var type=$(this).attr("data-type");if("twitterUser"===type){var name=link.match(/https:\/\/twitter\.com\/(.+)/)?.[1]||link;$("#socialLink").val(await(new social_Twitter).userName2id(name)||"")}else if("youtubeChannel"===type){const name=/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www.youtube.com\/.*/.test(link)?link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)?.[1]:link;$("#socialLink").val((await getInfo(name,"channel"))?.params?.channelId||"")}}})}catch(error){throwError(error,"Setting.getId")}}#environment(){try{var userAgent=(0,javascript_utils_umd_min.ua)(),environmentForm=`
diff --git a/dist/auto-task-v4.compatibility.user.js b/dist/auto-task-v4.compatibility.user.js index fce35d1..0de5ee5 100644 --- a/dist/auto-task-v4.compatibility.user.js +++ b/dist/auto-task-v4.compatibility.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4.compatibility // @namespace auto-task-v4.compatibility -// @version 4.4.9 +// @version 4.4.10 // @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 @@ -127,7 +127,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');

在下方填写白名单,每行一个

`,inputValue:whiteList[social][type].join("\n"),showConfirmButton:!0,confirmButtonText:i18n("save"),showCancelButton:!0,cancelButtonText:i18n("close"),showDenyButton:!0,denyButtonText:i18n("return")}).then(({isDenied,isConfirmed,value})=>{isDenied?"swal"===showType&&whiteListOptions(showType):isConfirmed&&(whiteList[social][type]=value.split("\n"),GM_setValue("whiteList",whiteList),external_Swal_default().fire({title:i18n("changeWhiteListSuccess"),icon:"success"}))}),$("#link2id").on("click",async function(){var type=$(this).attr("data-type");$("#socialLink").val(await async function(type){try{const link=$("#socialLink").val();let id="";switch(type){case"discord.servers":id=link.match(/invite\/(.+)/)?.[1]||"";break;case"instagram.users":id=link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)?.[1]||"";break;case"twitch.channels":id=link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)?.[2]||"";break;case"twitter.users":id=link.match(/https:\/\/twitter\.com\/(.+)/)?.[1]||"";break;case"twitter.retweets":id=link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)?.[1]||"";break;case"vk.names":id=link.match(/https:\/\/vk\.com\/([^/]+)/)?.[1]||"";break;case"youtube.channels":id=(await getInfo(link,"channel"))?.params?.channelId||"";break;case"youtube.likes":id=(await getInfo(link,"likeVideo"))?.params?.videoId||"";break;case"reddit.reddits":id=link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)?.[1]||link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)?.[1]||"";break;case"steam.groups":id=link.match(/groups\/(.+)\/?/)?.[1]||"";break;case"steam.wishlists":case"steam.follows":case"steam.forums":id=link.match(/app\/([\d]+)/)?.[1]||"";break;case"steam.workshops":id=link.match(/\?id=([\d]+)/)?.[1]||"";break;case"steam.curators":if(link.includes("curator"))id=link.match(/curator\/([\d]+)/)?.[1]||"";else{var param=link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)?.slice(1,3);if(!param||2!==param.length)break;const steam=new social_Steam;await steam.init()&&(id=await steam.getCuratorId(param[0],param[1])||"")}}return id}catch(error){return throwError(error,"link2id"),i18n("getFailed","id")}}(type))})):scripts_echoLog({}).warning(i18n("whiteListNotFound",value))}})}catch(error){throwError(error,"whiteListOptions")}}const defaultWhiteList={discord:{servers:[]},instagram:{users:[]},twitch:{channels:[]},twitter:{users:[],retweets:[],likes:[]},vk:{names:[]},youtube:{channels:[],likes:[]},reddit:{reddits:[]},steam:{groups:[],officialGroups:[],wishlists:[],follows:[],forums:[],workshops:[],curators:[],workshopVotes:[],curatorLikes:[],announcements:[],licenses:[],playtests:[]}},disabledType={steam:["workshopVotes","curatorLikes","announcements"],twitter:["likes"]},whiteList=whiteListOptions,getGistData=async(token,gistId,fileName,test=!1)=>{try{const logStatus=scripts_echoLog({text:i18n("gettingData")});var{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},responseType:"json",method:"GET",timeout:3e4});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{var content=data.response?.files?.[fileName]?.content;let formatedContent;if(!content)return logStatus.error("Error:"+i18n("noRemoteData")),!1;if(test)return logStatus.success(),!0;try{formatedContent=JSON.parse(content)}catch(error){return logStatus.error("Error:"+i18n("errorRemoteDataFormat")),!1}return logStatus.success(),formatedContent}}catch(error){return throwError(error,"getGistData"),!1}},syncOptions=()=>{try{var{TOKEN,GIST_ID,FILE_NAME,SYNC_HISTORY}=GM_getValue("gistOptions")||{TOKEN:"",GIST_ID:"",FILE_NAME:"",SYNC_HISTORY:!0};external_Swal_default().fire({title:i18n("gistOptions"),html:`

Github Token

`+`

Gist ID

`+`

${i18n("fileName")}

`+'

`+`

`+`

`,focusConfirm:!1,showLoaderOnConfirm:!0,footer:`${i18n("help")}`,preConfirm:async()=>{var token=$("#github-token").val(),gistId=$("#gist-id").val(),fileName=$("#file-name").val(),syncHistory=$("#sync-history").prop("checked");return GM_setValue("gistOptions",{TOKEN:token,GIST_ID:gistId,FILE_NAME:fileName,SYNC_HISTORY:syncHistory}),getGistData(token,gistId,fileName,!0)},allowOutsideClick:()=>!external_Swal_default().isLoading(),confirmButtonText:i18n("saveAndTest"),showCancelButton:!0,cancelButtonText:i18n("close")}).then(({value})=>{value?external_Swal_default().fire({icon:"success",title:i18n("testSuccess")}).then(syncOptions):void 0!==value&&external_Swal_default().fire({icon:"error",title:i18n("testFailed")}).then(syncOptions)}),$("#upload-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&FILE_NAME))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("processingData")});const data={};var names=GM_listValues(),SYNC_HISTORY=$("#sync-history").prop("checked");for(const name of names)"gistOptions"===name||/^[\w]+?Auth$/.test(name)||!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||(data[name]=GM_getValue(name));external_Swal_default().update({icon:"info",title:i18n("updatingData")}),await(async(token,gistId,fileName,content)=>{try{const logStatus=scripts_echoLog({text:i18n("settingData")});var contentData=JSON.stringify({files:{[fileName]:{content:JSON.stringify(content)}}}),{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},data:contentData,responseType:"json",method:"POST",timeout:3e4});return"Success"===result?200===data?.status&&data.response.files?.[fileName]?.content===JSON.stringify(content)?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"setGistData"),!1}})(TOKEN,GIST_ID,FILE_NAME,data)?external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")}):external_Swal_default().fire({icon:"error",title:i18n("syncDataFailed")})}),$("#download-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME:data}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&data))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("downloadingData")});data=await getGistData(TOKEN,GIST_ID,data);if(!data)return external_Swal_default().fire({icon:"error",title:i18n("checkedNoData")}).then(syncOptions);external_Swal_default().update({icon:"info",title:i18n("savingData")});var name,value,SYNC_HISTORY=$("#sync-history").prop("checked");for([name,value]of Object.entries(data))!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||GM_setValue(name,value);external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")})})}catch(error){throwError(error,"syncOptions")}};dataSync=syncOptions;const Websites=[Freeanywhere,GiveawaySu,website_Indiedb,website_Keyhub,website_Givekey,website_GiveeClub,website_OpiumPulses,loadScript,website_Opquests,class extends website_Website{name="Gleam";undoneTasks=JSON.parse(Gleam_defaultTasks);socialTasks=JSON.parse(Gleam_defaultTasks);buttons=["doTask","undoTask","verifyTask"];static test(){return"gleam.io"===window.location.host}before(){unsafeWindow.confirm=()=>{},unsafeWindow.alert=()=>{},unsafeWindow.prompt=()=>{}}async after(){try{if(window.location.search.includes("8b07d23f4bfa65f9")){const checkComplete=setInterval(()=>{0<$(".entry-content .entry-method i.fa-check").length&&(clearInterval(checkComplete),window.close())});for(const task of $(".entry-content .entry-method")){const taskInfo=$(task).find(".user-links"),expandInfo=$(task).find(".expandable");var aElements=expandInfo.find("a.btn,a:contains(Continue),button:contains(Continue)");if(0!0)}catch(error){return throwError(error,"Gleam.extraDoTask"),!1}}async verifyTask(){try{scripts_echoLog({text:i18n("verifyingTask")+"..."});var tasks=$(".entry-content .entry-method");unsafeWindow._OxA="_OxA";for(const task of tasks){if(0<$('[campaign-key="campaign.key"]').length)return scripts_echoLog({text:i18n("campaign")});const $task=$(task);if(0!==$task.find("i.fa-question").length){const taskInfo=$task.find(".user-links");taskInfo[0].click(),unsafeWindow.$hookTimer?.setSpeed(1e3),await delay(3e3),unsafeWindow.$hookTimer?.setSpeed(1);const expandInfo=$task.find(".expandable"),input=expandInfo.find("input")[0];var evt=new Event("input",{bubbles:!0,cancelable:!0,composed:!0}),valuelimit=[...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1];input.value=valuelimit||"vloot",input.dispatchEvent(evt),await delay(1e3),await this.#checkSync();for(const button of $task.find(".expandable").find("span:contains(Continue),button:contains(Continue)"))button.click(),await delay(500),await this.#checkSync()}}scripts_echoLog({text:i18n("verifiedGleamTasks")})}catch(error){return throwError(error,"Gleam.verifyTask"),!1}}async#checkSync(){try{return await new Promise(resolve=>{const checker=setInterval(()=>{0===$(".entry-content .entry-method i.fa-sync").length&&(clearInterval(checker),resolve(!0))},500)})}catch(error){return throwError(error,"Gleam.checkSync"),!1}}async#doGleamTask(link){try{const logStatus=scripts_echoLog({text:i18n("doingGleamTask")});return await new Promise(resolve=>{GM_openInTab(link+"?8b07d23f4bfa65f9",{active:!0,insert:!0,setParent:!0}).onclose=()=>{logStatus.success(),resolve(!0)}})}catch(error){return throwError(error,"Gleam.doGleamTask"),!1}}#getGiveawayId(){try{var giveawayId=window.location.pathname;return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Gleam.getGiveawayId"),!1}}async#getGleamLink(title){try{const logStatus=scripts_echoLog({text:i18n("gettingGleamLink")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://www.vloot.io/api/v1/giveaways",method:"GET",responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200===data?.status&&!0===data?.response?.Success&&data?.response?.Data){var link=(data.response.Data.find(giveaway=>title.replace(/[\s]/g,"").toLowerCase().includes(giveaway.title.replace(/[\s]/g,"").toLowerCase()))||{})["link"];return link?(logStatus.success(),link):(logStatus.error("Error:"+i18n("getLinkFailed")),!1)}return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1}catch(error){return throwError(error,"Gleam.getGleamLink"),!1}}async#checkLeftKey(){try{if(!globalOptions.other.checkLeftKey)return!0;var campaignString=$("div.popup-blocks-container").attr("ng-init")?.match(/initCampaign\(([\w\W]+?)\)$/)?.[1];if(!campaignString)return!1;var{campaign,incentive}=JSON.parse(campaignString),controllerString=$("div.campaign.reward").attr("ng-init")?.match(/initContestant\(([\w\W]+?)\);/)?.[1];let ownedKey=!1;return controllerString&&JSON.parse(controllerString).contestant?.claims?.incentives?.[incentive.id]?.length&&(ownedKey=!0),(campaign.banned||campaign.finished&&!ownedKey||campaign.paused||(new Date).getTime()<1e3*campaign.starts_at)&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayNotWork"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0}catch(error){return throwError(error,"Gleam.checkLeftKey"),!1}}},class extends website_Website{name="SweepWidget";options={username:"",email:"",...GM_getValue("SweepWidgetOptions")};buttons=["doTask"];static test(){return/^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed"))}catch(error){throwError(error,"SweepWidget.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return this.#checkLogin()?!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0):(logStatus.warning(i18n("needLogin")),!1)}catch(error){return throwError(error,"SweepWidget.init"),!1}}classifyTask(){return!0}async doTask(){try{if(0===$("#unlock_rewards_main_wrapper").length&&(0<$('input[name="sw__login_name"]:visible').length&&$('input[name="sw__login_name"]').val(this.options.username),0<$('input[name="sw__login_email"]:visible').length&&$('input[name="sw__login_email"]').val(this.options.email),0<$("#sw_login_button:visible").length&&$("#sw_login_button")[0].click(),!await this.#checkEnter()))return!1;const logStatus=scripts_echoLog({text:i18n("SweepWidgetNotice")});for(const task of $("#sw_inner_entry_methods_l2_wrapper>div.sw_entry")){const $task=$(task);if(!(0<$task.find("i.fa-check:visible").length)){const title=$task.find(".sw_text_inner");title[0].click();const aElement=$task.find("a.sw_link");var link=aElement.attr("href");aElement.attr("href","#a").attr("target","_self"),aElement[0]?.click(),await delay(300),aElement.attr("href",link).attr("target","_blank"),$task.find('input[type="text"]').val("test");const verifyBtn=$task.find("input.sw_verify");!0===verifyBtn.prop("disabled")&&(title[0].click(),await delay(300),title[0].click(),await delay(300)),$task.find("input.sw_verify").removeAttr("disabled")[0]?.click(),await this.#checkFinish($task),await delay(parseInt(""+(2001*Math.random()+1e3),10))}}return logStatus.success(),!0}catch(error){return throwError(error,"SweepWidget.doTask"),!1}}#checkLogin(){try{return 0<$("#twitter_login_button").length&&$("#twitter_login_button")[0].click(),!0}catch(error){return throwError(error,"SweepWidget.checkLogin"),!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,"SweepWidget.getGiveawayId"),!1}}async#checkEnter(){try{return new Promise(resolve=>{const checker=setInterval(()=>{0<$("#unlock_rewards_main_wrapper").length&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkEnter"),!1}}async#checkFinish($task){try{return new Promise(resolve=>{const checker=setInterval(()=>{(0<$task.find("i.fa-check:visible").length||0===$task.find(".sw_entry_input:visible").length)&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkFinish"),!1}}},class{name="Setting";buttons=["saveGlobalOptions","syncData","tasksHistory"];syncData=dataSync;tasksHistory(){window.open("https://auto-task-v4.hclonely.com/history.html","_blank")}static test(){return"auto-task-v4.hclonely.com"===window.location.host&&"/setting.html"===window.location.pathname}before(){$("body").html("").addClass("auto-task-options")}after(){try{this.#environment(),changeGlobalOptions("page"),whiteList("page"),$('input[name="other.twitterVerifyId"]').after(``),$("#getTwitterUserId").on("click",()=>{this.#getId("twitterUser")}),$('input[name="other.youtubeVerifyChannel"]').after(``),$("#getYoutubeChannelId").on("click",()=>{this.#getId("youtubeChannel")}),$('input[name^="position"]').on("input",function(){switch($(this).attr("name").replace("position.","")){case"buttonSideX":case"buttonSideY":case"buttonDistance":{const distance=$('input[name="position.buttonDistance"]').val();var sideX=$('input[name="position.buttonSideX"]').val(),sideY=$('input[name="position.buttonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;var distanceArr=distance.split(",");$("#auto-task-buttons").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"showButtonSideX":case"showButtonSideY":case"showButtonDistance":{const distance=$('input[name="position.showButtonDistance"]').val(),sideX=$('input[name="position.showButtonSideX"]').val(),sideY=$('input[name="position.showButtonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("div.show-button-div").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"logSideX":case"logSideY":case"logDistance":{const distance=$('input[name="position.logDistance"]').val(),sideX=$('input[name="position.logSideX"]').val(),sideY=$('input[name="position.logSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("#auto-task-info").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}}}),$('input[name^="hotKey"]').attr("readonly","readonly").off("keydown").on("keydown",function(event){let functionKey="";event.altKey?functionKey+="alt + ":event.ctrlKey?functionKey+="ctrl + ":event.shiftKey&&(functionKey+="shift + "),$(this).val(functionKey+(1===event.key.length?event.key.toLowerCase():""))})}catch(error){throwError(error,"Setting.after")}}saveGlobalOptions(){saveData()}#getId(social){try{external_Swal_default().fire({title:i18n("getId",i18n(social)),html:` + ${i18n("downloadFromGist")}

`,focusConfirm:!1,showLoaderOnConfirm:!0,footer:`${i18n("help")}`,preConfirm:async()=>{var token=$("#github-token").val(),gistId=$("#gist-id").val(),fileName=$("#file-name").val(),syncHistory=$("#sync-history").prop("checked");return GM_setValue("gistOptions",{TOKEN:token,GIST_ID:gistId,FILE_NAME:fileName,SYNC_HISTORY:syncHistory}),getGistData(token,gistId,fileName,!0)},allowOutsideClick:()=>!external_Swal_default().isLoading(),confirmButtonText:i18n("saveAndTest"),showCancelButton:!0,cancelButtonText:i18n("close")}).then(({value})=>{value?external_Swal_default().fire({icon:"success",title:i18n("testSuccess")}).then(syncOptions):void 0!==value&&external_Swal_default().fire({icon:"error",title:i18n("testFailed")}).then(syncOptions)}),$("#upload-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&FILE_NAME))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("processingData")});const data={};var names=GM_listValues(),SYNC_HISTORY=$("#sync-history").prop("checked");for(const name of names)"gistOptions"===name||/^[\w]+?Auth$/.test(name)||!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||(data[name]=GM_getValue(name));external_Swal_default().update({icon:"info",title:i18n("updatingData")}),await(async(token,gistId,fileName,content)=>{try{const logStatus=scripts_echoLog({text:i18n("settingData")});var contentData=JSON.stringify({files:{[fileName]:{content:JSON.stringify(content)}}}),{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},data:contentData,responseType:"json",method:"POST",timeout:3e4});return"Success"===result?200===data?.status&&data.response.files?.[fileName]?.content===JSON.stringify(content)?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"setGistData"),!1}})(TOKEN,GIST_ID,FILE_NAME,data)?external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")}):external_Swal_default().fire({icon:"error",title:i18n("syncDataFailed")})}),$("#download-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME:data}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&data))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("downloadingData")});data=await getGistData(TOKEN,GIST_ID,data);if(!data)return external_Swal_default().fire({icon:"error",title:i18n("checkedNoData")}).then(syncOptions);external_Swal_default().update({icon:"info",title:i18n("savingData")});var name,value,SYNC_HISTORY=$("#sync-history").prop("checked");for([name,value]of Object.entries(data))!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||GM_setValue(name,value);external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")})})}catch(error){throwError(error,"syncOptions")}};dataSync=syncOptions;const Websites=[Freeanywhere,GiveawaySu,website_Indiedb,website_Keyhub,website_Givekey,website_GiveeClub,website_OpiumPulses,loadScript,website_Opquests,class extends website_Website{name="Gleam";undoneTasks=JSON.parse(Gleam_defaultTasks);socialTasks=JSON.parse(Gleam_defaultTasks);buttons=["doTask","undoTask","verifyTask"];static test(){return"gleam.io"===window.location.host}before(){unsafeWindow.confirm=()=>{},unsafeWindow.alert=()=>{},unsafeWindow.prompt=()=>{}}async after(){try{if(window.location.search.includes("8b07d23f4bfa65f9")){const checkComplete=setInterval(()=>{0<$(".entry-content .entry-method i.fa-check").length&&(clearInterval(checkComplete),window.close())});for(const task of $(".entry-content .entry-method")){const taskInfo=$(task).find(".user-links"),expandInfo=$(task).find(".expandable");var aElements=expandInfo.find("a.btn,a:contains(Continue),button:contains(Continue)");if(0!0)}catch(error){return throwError(error,"Gleam.extraDoTask"),!1}}async verifyTask(){try{scripts_echoLog({text:i18n("verifyingTask")+"..."});var evt,valuelimit,tasks=$(".entry-content .entry-method");unsafeWindow._OxA="_OxA";for(const task of tasks){if(0<$('[campaign-key="campaign.key"]').length)return scripts_echoLog({text:i18n("campaign")});const $task=$(task);if(0!==$task.find("i.fa-question").length){const taskInfo=$task.find(".user-links");taskInfo[0].click(),unsafeWindow.$hookTimer?.setSpeed(1e3),await delay(3e3),unsafeWindow.$hookTimer?.setSpeed(1);const expandInfo=$task.find(".expandable"),input=expandInfo.find("input")[0];input&&(evt=new Event("input",{bubbles:!0,cancelable:!0,composed:!0}),valuelimit=[...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1],input.value=valuelimit||"vloot",input.dispatchEvent(evt),await delay(1e3)),await this.#checkSync();for(const button of $task.find(".expandable").find("span:contains(Continue),button:contains(Continue)"))button.click(),await delay(500),await this.#checkSync()}}scripts_echoLog({text:i18n("verifiedGleamTasks")})}catch(error){return throwError(error,"Gleam.verifyTask"),!1}}async#checkSync(){try{return await new Promise(resolve=>{const checker=setInterval(()=>{0===$(".entry-content .entry-method i.fa-sync").length&&(clearInterval(checker),resolve(!0))},500)})}catch(error){return throwError(error,"Gleam.checkSync"),!1}}async#doGleamTask(link){try{const logStatus=scripts_echoLog({text:i18n("doingGleamTask")});return await new Promise(resolve=>{GM_openInTab(link+"?8b07d23f4bfa65f9",{active:!0,insert:!0,setParent:!0}).onclose=()=>{logStatus.success(),resolve(!0)}})}catch(error){return throwError(error,"Gleam.doGleamTask"),!1}}#getGiveawayId(){try{var giveawayId=window.location.pathname;return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Gleam.getGiveawayId"),!1}}async#getGleamLink(title){try{const logStatus=scripts_echoLog({text:i18n("gettingGleamLink")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://www.vloot.io/api/v1/giveaways",method:"GET",responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200===data?.status&&!0===data?.response?.Success&&data?.response?.Data){var link=(data.response.Data.find(giveaway=>title.replace(/[\s]/g,"").toLowerCase().includes(giveaway.title.replace(/[\s]/g,"").toLowerCase()))||{})["link"];return link?(logStatus.success(),link):(logStatus.error("Error:"+i18n("getLinkFailed")),!1)}return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1}catch(error){return throwError(error,"Gleam.getGleamLink"),!1}}async#checkLeftKey(){try{if(!globalOptions.other.checkLeftKey)return!0;var campaignString=$("div.popup-blocks-container").attr("ng-init")?.match(/initCampaign\(([\w\W]+?)\)$/)?.[1];if(!campaignString)return!1;var{campaign,incentive}=JSON.parse(campaignString),controllerString=$("div.campaign.reward").attr("ng-init")?.match(/initContestant\(([\w\W]+?)\);/)?.[1];let ownedKey=!1;return controllerString&&JSON.parse(controllerString).contestant?.claims?.incentives?.[incentive.id]?.length&&(ownedKey=!0),(campaign.banned||campaign.finished&&!ownedKey||campaign.paused||(new Date).getTime()<1e3*campaign.starts_at)&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayNotWork"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0}catch(error){return throwError(error,"Gleam.checkLeftKey"),!1}}},class extends website_Website{name="SweepWidget";options={username:"",email:"",...GM_getValue("SweepWidgetOptions")};buttons=["doTask"];static test(){return/^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed"))}catch(error){throwError(error,"SweepWidget.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return this.#checkLogin()?!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0):(logStatus.warning(i18n("needLogin")),!1)}catch(error){return throwError(error,"SweepWidget.init"),!1}}classifyTask(){return!0}async doTask(){try{if(0===$("#unlock_rewards_main_wrapper").length&&(0<$('input[name="sw__login_name"]:visible').length&&$('input[name="sw__login_name"]').val(this.options.username),0<$('input[name="sw__login_email"]:visible').length&&$('input[name="sw__login_email"]').val(this.options.email),0<$("#sw_login_button:visible").length&&$("#sw_login_button")[0].click(),!await this.#checkEnter()))return!1;const logStatus=scripts_echoLog({text:i18n("SweepWidgetNotice")});for(const task of $("#sw_inner_entry_methods_l2_wrapper>div.sw_entry")){const $task=$(task);if(!(0<$task.find("i.fa-check:visible").length)){const title=$task.find(".sw_text_inner");title[0].click();const aElement=$task.find("a.sw_link");var link=aElement.attr("href");aElement.attr("href","#a").attr("target","_self"),aElement[0]?.click(),await delay(300),aElement.attr("href",link).attr("target","_blank"),$task.find('input[type="text"]').val("test");const verifyBtn=$task.find("input.sw_verify");!0===verifyBtn.prop("disabled")&&(title[0].click(),await delay(300),title[0].click(),await delay(300)),$task.find("input.sw_verify").removeAttr("disabled")[0]?.click(),await this.#checkFinish($task),await delay(parseInt(""+(2001*Math.random()+1e3),10))}}return logStatus.success(),!0}catch(error){return throwError(error,"SweepWidget.doTask"),!1}}#checkLogin(){try{return 0<$("#twitter_login_button").length&&$("#twitter_login_button")[0].click(),!0}catch(error){return throwError(error,"SweepWidget.checkLogin"),!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,"SweepWidget.getGiveawayId"),!1}}async#checkEnter(){try{return new Promise(resolve=>{const checker=setInterval(()=>{0<$("#unlock_rewards_main_wrapper").length&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkEnter"),!1}}async#checkFinish($task){try{return new Promise(resolve=>{const checker=setInterval(()=>{(0<$task.find("i.fa-check:visible").length||0===$task.find(".sw_entry_input:visible").length)&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkFinish"),!1}}},class{name="Setting";buttons=["saveGlobalOptions","syncData","tasksHistory"];syncData=dataSync;tasksHistory(){window.open("https://auto-task-v4.hclonely.com/history.html","_blank")}static test(){return"auto-task-v4.hclonely.com"===window.location.host&&"/setting.html"===window.location.pathname}before(){$("body").html("").addClass("auto-task-options")}after(){try{this.#environment(),changeGlobalOptions("page"),whiteList("page"),$('input[name="other.twitterVerifyId"]').after(``),$("#getTwitterUserId").on("click",()=>{this.#getId("twitterUser")}),$('input[name="other.youtubeVerifyChannel"]').after(``),$("#getYoutubeChannelId").on("click",()=>{this.#getId("youtubeChannel")}),$('input[name^="position"]').on("input",function(){switch($(this).attr("name").replace("position.","")){case"buttonSideX":case"buttonSideY":case"buttonDistance":{const distance=$('input[name="position.buttonDistance"]').val();var sideX=$('input[name="position.buttonSideX"]').val(),sideY=$('input[name="position.buttonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;var distanceArr=distance.split(",");$("#auto-task-buttons").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"showButtonSideX":case"showButtonSideY":case"showButtonDistance":{const distance=$('input[name="position.showButtonDistance"]').val(),sideX=$('input[name="position.showButtonSideX"]').val(),sideY=$('input[name="position.showButtonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("div.show-button-div").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"logSideX":case"logSideY":case"logDistance":{const distance=$('input[name="position.logDistance"]').val(),sideX=$('input[name="position.logSideX"]').val(),sideY=$('input[name="position.logSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("#auto-task-info").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}}}),$('input[name^="hotKey"]').attr("readonly","readonly").off("keydown").on("keydown",function(event){let functionKey="";event.altKey?functionKey+="alt + ":event.ctrlKey?functionKey+="ctrl + ":event.shiftKey&&(functionKey+="shift + "),$(this).val(functionKey+(1===event.key.length?event.key.toLowerCase():""))})}catch(error){throwError(error,"Setting.after")}}saveGlobalOptions(){saveData()}#getId(social){try{external_Swal_default().fire({title:i18n("getId",i18n(social)),html:` `,showCancelButton:!0,cancelButtonText:i18n("close"),showConfirmButton:!1}),$("#link2id").on("click",async function(){const link=$("#socialLink").val();if(link){var type=$(this).attr("data-type");if("twitterUser"===type){var name=link.match(/https:\/\/twitter\.com\/(.+)/)?.[1]||link;$("#socialLink").val(await(new social_Twitter).userName2id(name)||"")}else if("youtubeChannel"===type){const name=/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www.youtube.com\/.*/.test(link)?link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)?.[1]:link;$("#socialLink").val((await getInfo(name,"channel"))?.params?.channelId||"")}}})}catch(error){throwError(error,"Setting.getId")}}#environment(){try{var userAgent=(0,javascript_utils_umd_min.ua)(),environmentForm=`
${i18n("type")}${i18n("name")}${i18n("version")}
${i18n("os")}${userAgent.os}${userAgent.osVersion}
diff --git a/dist/auto-task-v4.user.js b/dist/auto-task-v4.user.js index f67d65a..c000b0a 100644 --- a/dist/auto-task-v4.user.js +++ b/dist/auto-task-v4.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4 // @namespace auto-task-v4 -// @version 4.4.9 +// @version 4.4.10 // @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 @@ -9499,15 +9499,17 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载'); unsafeWindow.$hookTimer?.setSpeed(1); const expandInfo = $task.find('.expandable'); const input = expandInfo.find('input')[0]; - const evt = new Event('input', { - bubbles: true, - cancelable: true, - composed: true - }); - const valuelimit = [ ...expandInfo.text().matchAll(/"(.+?)"/g) ].at(-1)?.[1]; - input.value = valuelimit || 'vloot'; - input.dispatchEvent(evt); - await delay(1e3); + if (input) { + const evt = new Event('input', { + bubbles: true, + cancelable: true, + composed: true + }); + const valuelimit = [ ...expandInfo.text().matchAll(/"(.+?)"/g) ].at(-1)?.[1]; + input.value = valuelimit || 'vloot'; + input.dispatchEvent(evt); + await delay(1e3); + } await this.#checkSync(); const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)'); for (const button of continueBtn) { diff --git a/doc/docs/logs/README.md b/doc/docs/logs/README.md index cf2e076..b978e2f 100644 --- a/doc/docs/logs/README.md +++ b/doc/docs/logs/README.md @@ -5,6 +5,12 @@ lang: zh-CN ## V4.4 +### V4.4.10 + +[Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.4.10) + +- 修复:Gleam没有输入框时报错([#29](https://github.com/HCLonely/auto-task-v4/issues/29)) + ### V4.4.9 [Release](https://github.com/HCLonely/auto-task-v4/releases/tag/v4.4.9) diff --git a/package.json b/package.json index 4e2183d..fb10f84 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,8 @@ { "name": "auto-task-v4", - "version": "4.4.9", + "version": "4.4.10", "change": [ - "新增:自动完成Gleam输入框任务", - "优化:增加Gleam可识别任务" + "修复:Gleam没有输入框时报错(#29)" ], "description": "赠Key站自动任务脚本", "main": "package.json", diff --git a/page/dist/auto-task-v4-for-giveawaysu.all.user.js b/page/dist/auto-task-v4-for-giveawaysu.all.user.js index d151d8b..219c705 100644 --- a/page/dist/auto-task-v4-for-giveawaysu.all.user.js +++ b/page/dist/auto-task-v4-for-giveawaysu.all.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4-for-giveawaysu // @namespace auto-task-v4-for-giveawaysu -// @version 4.4.9 +// @version 4.4.10 // @description 赠Key站自动任务 // @author HCLonely // @license MIT diff --git a/page/dist/auto-task-v4-for-giveawaysu.user.js b/page/dist/auto-task-v4-for-giveawaysu.user.js index 1788a09..fa093b6 100644 --- a/page/dist/auto-task-v4-for-giveawaysu.user.js +++ b/page/dist/auto-task-v4-for-giveawaysu.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4-for-giveawaysu // @namespace auto-task-v4-for-giveawaysu -// @version 4.4.9 +// @version 4.4.10 // @description 赠Key站自动任务 // @author HCLonely // @license MIT diff --git a/page/dist/auto-task-v4.all.user.js b/page/dist/auto-task-v4.all.user.js index e42757f..3a82f1d 100644 --- a/page/dist/auto-task-v4.all.user.js +++ b/page/dist/auto-task-v4.all.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4 // @namespace auto-task-v4 -// @version 4.4.9 +// @version 4.4.10 // @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 @@ -9518,15 +9518,17 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载'); unsafeWindow.$hookTimer?.setSpeed(1); const expandInfo = $task.find('.expandable'); const input = expandInfo.find('input')[0]; - const evt = new Event('input', { - bubbles: true, - cancelable: true, - composed: true - }); - const valuelimit = [ ...expandInfo.text().matchAll(/"(.+?)"/g) ].at(-1)?.[1]; - input.value = valuelimit || 'vloot'; - input.dispatchEvent(evt); - await delay(1e3); + if (input) { + const evt = new Event('input', { + bubbles: true, + cancelable: true, + composed: true + }); + const valuelimit = [ ...expandInfo.text().matchAll(/"(.+?)"/g) ].at(-1)?.[1]; + input.value = valuelimit || 'vloot'; + input.dispatchEvent(evt); + await delay(1e3); + } await this.#checkSync(); const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)'); for (const button of continueBtn) { diff --git a/page/dist/auto-task-v4.compatibility.all.user.js b/page/dist/auto-task-v4.compatibility.all.user.js index 5e51340..e952faf 100644 --- a/page/dist/auto-task-v4.compatibility.all.user.js +++ b/page/dist/auto-task-v4.compatibility.all.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4.compatibility // @namespace auto-task-v4.compatibility -// @version 4.4.9 +// @version 4.4.10 // @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 @@ -146,7 +146,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');

在下方填写白名单,每行一个

`,inputValue:whiteList[social][type].join("\n"),showConfirmButton:!0,confirmButtonText:i18n("save"),showCancelButton:!0,cancelButtonText:i18n("close"),showDenyButton:!0,denyButtonText:i18n("return")}).then(({isDenied,isConfirmed,value})=>{isDenied?"swal"===showType&&whiteListOptions(showType):isConfirmed&&(whiteList[social][type]=value.split("\n"),GM_setValue("whiteList",whiteList),external_Swal_default().fire({title:i18n("changeWhiteListSuccess"),icon:"success"}))}),$("#link2id").on("click",async function(){var type=$(this).attr("data-type");$("#socialLink").val(await async function(type){try{const link=$("#socialLink").val();let id="";switch(type){case"discord.servers":id=link.match(/invite\/(.+)/)?.[1]||"";break;case"instagram.users":id=link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)?.[1]||"";break;case"twitch.channels":id=link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)?.[2]||"";break;case"twitter.users":id=link.match(/https:\/\/twitter\.com\/(.+)/)?.[1]||"";break;case"twitter.retweets":id=link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)?.[1]||"";break;case"vk.names":id=link.match(/https:\/\/vk\.com\/([^/]+)/)?.[1]||"";break;case"youtube.channels":id=(await getInfo(link,"channel"))?.params?.channelId||"";break;case"youtube.likes":id=(await getInfo(link,"likeVideo"))?.params?.videoId||"";break;case"reddit.reddits":id=link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)?.[1]||link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)?.[1]||"";break;case"steam.groups":id=link.match(/groups\/(.+)\/?/)?.[1]||"";break;case"steam.wishlists":case"steam.follows":case"steam.forums":id=link.match(/app\/([\d]+)/)?.[1]||"";break;case"steam.workshops":id=link.match(/\?id=([\d]+)/)?.[1]||"";break;case"steam.curators":if(link.includes("curator"))id=link.match(/curator\/([\d]+)/)?.[1]||"";else{var param=link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)?.slice(1,3);if(!param||2!==param.length)break;const steam=new social_Steam;await steam.init()&&(id=await steam.getCuratorId(param[0],param[1])||"")}}return id}catch(error){return throwError(error,"link2id"),i18n("getFailed","id")}}(type))})):scripts_echoLog({}).warning(i18n("whiteListNotFound",value))}})}catch(error){throwError(error,"whiteListOptions")}}const defaultWhiteList={discord:{servers:[]},instagram:{users:[]},twitch:{channels:[]},twitter:{users:[],retweets:[],likes:[]},vk:{names:[]},youtube:{channels:[],likes:[]},reddit:{reddits:[]},steam:{groups:[],officialGroups:[],wishlists:[],follows:[],forums:[],workshops:[],curators:[],workshopVotes:[],curatorLikes:[],announcements:[],licenses:[],playtests:[]}},disabledType={steam:["workshopVotes","curatorLikes","announcements"],twitter:["likes"]},whiteList=whiteListOptions,getGistData=async(token,gistId,fileName,test=!1)=>{try{const logStatus=scripts_echoLog({text:i18n("gettingData")});var{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},responseType:"json",method:"GET",timeout:3e4});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{var content=data.response?.files?.[fileName]?.content;let formatedContent;if(!content)return logStatus.error("Error:"+i18n("noRemoteData")),!1;if(test)return logStatus.success(),!0;try{formatedContent=JSON.parse(content)}catch(error){return logStatus.error("Error:"+i18n("errorRemoteDataFormat")),!1}return logStatus.success(),formatedContent}}catch(error){return throwError(error,"getGistData"),!1}},syncOptions=()=>{try{var{TOKEN,GIST_ID,FILE_NAME,SYNC_HISTORY}=GM_getValue("gistOptions")||{TOKEN:"",GIST_ID:"",FILE_NAME:"",SYNC_HISTORY:!0};external_Swal_default().fire({title:i18n("gistOptions"),html:`

Github Token

`+`

Gist ID

`+`

${i18n("fileName")}

`+'

`+`

`+`

`,focusConfirm:!1,showLoaderOnConfirm:!0,footer:`${i18n("help")}`,preConfirm:async()=>{var token=$("#github-token").val(),gistId=$("#gist-id").val(),fileName=$("#file-name").val(),syncHistory=$("#sync-history").prop("checked");return GM_setValue("gistOptions",{TOKEN:token,GIST_ID:gistId,FILE_NAME:fileName,SYNC_HISTORY:syncHistory}),getGistData(token,gistId,fileName,!0)},allowOutsideClick:()=>!external_Swal_default().isLoading(),confirmButtonText:i18n("saveAndTest"),showCancelButton:!0,cancelButtonText:i18n("close")}).then(({value})=>{value?external_Swal_default().fire({icon:"success",title:i18n("testSuccess")}).then(syncOptions):void 0!==value&&external_Swal_default().fire({icon:"error",title:i18n("testFailed")}).then(syncOptions)}),$("#upload-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&FILE_NAME))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("processingData")});const data={};var names=GM_listValues(),SYNC_HISTORY=$("#sync-history").prop("checked");for(const name of names)"gistOptions"===name||/^[\w]+?Auth$/.test(name)||!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||(data[name]=GM_getValue(name));external_Swal_default().update({icon:"info",title:i18n("updatingData")}),await(async(token,gistId,fileName,content)=>{try{const logStatus=scripts_echoLog({text:i18n("settingData")});var contentData=JSON.stringify({files:{[fileName]:{content:JSON.stringify(content)}}}),{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},data:contentData,responseType:"json",method:"POST",timeout:3e4});return"Success"===result?200===data?.status&&data.response.files?.[fileName]?.content===JSON.stringify(content)?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"setGistData"),!1}})(TOKEN,GIST_ID,FILE_NAME,data)?external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")}):external_Swal_default().fire({icon:"error",title:i18n("syncDataFailed")})}),$("#download-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME:data}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&data))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("downloadingData")});data=await getGistData(TOKEN,GIST_ID,data);if(!data)return external_Swal_default().fire({icon:"error",title:i18n("checkedNoData")}).then(syncOptions);external_Swal_default().update({icon:"info",title:i18n("savingData")});var name,value,SYNC_HISTORY=$("#sync-history").prop("checked");for([name,value]of Object.entries(data))!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||GM_setValue(name,value);external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")})})}catch(error){throwError(error,"syncOptions")}};dataSync=syncOptions;const Websites=[Freeanywhere,GiveawaySu,website_Indiedb,website_Keyhub,website_Givekey,website_GiveeClub,website_OpiumPulses,loadScript,website_Opquests,class extends website_Website{name="Gleam";undoneTasks=JSON.parse(Gleam_defaultTasks);socialTasks=JSON.parse(Gleam_defaultTasks);buttons=["doTask","undoTask","verifyTask"];static test(){return"gleam.io"===window.location.host}before(){unsafeWindow.confirm=()=>{},unsafeWindow.alert=()=>{},unsafeWindow.prompt=()=>{}}async after(){try{if(window.location.search.includes("8b07d23f4bfa65f9")){const checkComplete=setInterval(()=>{0<$(".entry-content .entry-method i.fa-check").length&&(clearInterval(checkComplete),window.close())});for(const task of $(".entry-content .entry-method")){const taskInfo=$(task).find(".user-links"),expandInfo=$(task).find(".expandable");var aElements=expandInfo.find("a.btn,a:contains(Continue),button:contains(Continue)");if(0!0)}catch(error){return throwError(error,"Gleam.extraDoTask"),!1}}async verifyTask(){try{scripts_echoLog({text:i18n("verifyingTask")+"..."});var tasks=$(".entry-content .entry-method");unsafeWindow._OxA="_OxA";for(const task of tasks){if(0<$('[campaign-key="campaign.key"]').length)return scripts_echoLog({text:i18n("campaign")});const $task=$(task);if(0!==$task.find("i.fa-question").length){const taskInfo=$task.find(".user-links");taskInfo[0].click(),unsafeWindow.$hookTimer?.setSpeed(1e3),await delay(3e3),unsafeWindow.$hookTimer?.setSpeed(1);const expandInfo=$task.find(".expandable"),input=expandInfo.find("input")[0];var evt=new Event("input",{bubbles:!0,cancelable:!0,composed:!0}),valuelimit=[...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1];input.value=valuelimit||"vloot",input.dispatchEvent(evt),await delay(1e3),await this.#checkSync();for(const button of $task.find(".expandable").find("span:contains(Continue),button:contains(Continue)"))button.click(),await delay(500),await this.#checkSync()}}scripts_echoLog({text:i18n("verifiedGleamTasks")})}catch(error){return throwError(error,"Gleam.verifyTask"),!1}}async#checkSync(){try{return await new Promise(resolve=>{const checker=setInterval(()=>{0===$(".entry-content .entry-method i.fa-sync").length&&(clearInterval(checker),resolve(!0))},500)})}catch(error){return throwError(error,"Gleam.checkSync"),!1}}async#doGleamTask(link){try{const logStatus=scripts_echoLog({text:i18n("doingGleamTask")});return await new Promise(resolve=>{GM_openInTab(link+"?8b07d23f4bfa65f9",{active:!0,insert:!0,setParent:!0}).onclose=()=>{logStatus.success(),resolve(!0)}})}catch(error){return throwError(error,"Gleam.doGleamTask"),!1}}#getGiveawayId(){try{var giveawayId=window.location.pathname;return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Gleam.getGiveawayId"),!1}}async#getGleamLink(title){try{const logStatus=scripts_echoLog({text:i18n("gettingGleamLink")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://www.vloot.io/api/v1/giveaways",method:"GET",responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200===data?.status&&!0===data?.response?.Success&&data?.response?.Data){var link=(data.response.Data.find(giveaway=>title.replace(/[\s]/g,"").toLowerCase().includes(giveaway.title.replace(/[\s]/g,"").toLowerCase()))||{})["link"];return link?(logStatus.success(),link):(logStatus.error("Error:"+i18n("getLinkFailed")),!1)}return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1}catch(error){return throwError(error,"Gleam.getGleamLink"),!1}}async#checkLeftKey(){try{if(!globalOptions.other.checkLeftKey)return!0;var campaignString=$("div.popup-blocks-container").attr("ng-init")?.match(/initCampaign\(([\w\W]+?)\)$/)?.[1];if(!campaignString)return!1;var{campaign,incentive}=JSON.parse(campaignString),controllerString=$("div.campaign.reward").attr("ng-init")?.match(/initContestant\(([\w\W]+?)\);/)?.[1];let ownedKey=!1;return controllerString&&JSON.parse(controllerString).contestant?.claims?.incentives?.[incentive.id]?.length&&(ownedKey=!0),(campaign.banned||campaign.finished&&!ownedKey||campaign.paused||(new Date).getTime()<1e3*campaign.starts_at)&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayNotWork"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0}catch(error){return throwError(error,"Gleam.checkLeftKey"),!1}}},class extends website_Website{name="SweepWidget";options={username:"",email:"",...GM_getValue("SweepWidgetOptions")};buttons=["doTask"];static test(){return/^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed"))}catch(error){throwError(error,"SweepWidget.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return this.#checkLogin()?!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0):(logStatus.warning(i18n("needLogin")),!1)}catch(error){return throwError(error,"SweepWidget.init"),!1}}classifyTask(){return!0}async doTask(){try{if(0===$("#unlock_rewards_main_wrapper").length&&(0<$('input[name="sw__login_name"]:visible').length&&$('input[name="sw__login_name"]').val(this.options.username),0<$('input[name="sw__login_email"]:visible').length&&$('input[name="sw__login_email"]').val(this.options.email),0<$("#sw_login_button:visible").length&&$("#sw_login_button")[0].click(),!await this.#checkEnter()))return!1;const logStatus=scripts_echoLog({text:i18n("SweepWidgetNotice")});for(const task of $("#sw_inner_entry_methods_l2_wrapper>div.sw_entry")){const $task=$(task);if(!(0<$task.find("i.fa-check:visible").length)){const title=$task.find(".sw_text_inner");title[0].click();const aElement=$task.find("a.sw_link");var link=aElement.attr("href");aElement.attr("href","#a").attr("target","_self"),aElement[0]?.click(),await delay(300),aElement.attr("href",link).attr("target","_blank"),$task.find('input[type="text"]').val("test");const verifyBtn=$task.find("input.sw_verify");!0===verifyBtn.prop("disabled")&&(title[0].click(),await delay(300),title[0].click(),await delay(300)),$task.find("input.sw_verify").removeAttr("disabled")[0]?.click(),await this.#checkFinish($task),await delay(parseInt(""+(2001*Math.random()+1e3),10))}}return logStatus.success(),!0}catch(error){return throwError(error,"SweepWidget.doTask"),!1}}#checkLogin(){try{return 0<$("#twitter_login_button").length&&$("#twitter_login_button")[0].click(),!0}catch(error){return throwError(error,"SweepWidget.checkLogin"),!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,"SweepWidget.getGiveawayId"),!1}}async#checkEnter(){try{return new Promise(resolve=>{const checker=setInterval(()=>{0<$("#unlock_rewards_main_wrapper").length&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkEnter"),!1}}async#checkFinish($task){try{return new Promise(resolve=>{const checker=setInterval(()=>{(0<$task.find("i.fa-check:visible").length||0===$task.find(".sw_entry_input:visible").length)&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkFinish"),!1}}},class{name="Setting";buttons=["saveGlobalOptions","syncData","tasksHistory"];syncData=dataSync;tasksHistory(){window.open("https://auto-task-v4.hclonely.com/history.html","_blank")}static test(){return"auto-task-v4.hclonely.com"===window.location.host&&"/setting.html"===window.location.pathname}before(){$("body").html("").addClass("auto-task-options")}after(){try{this.#environment(),changeGlobalOptions("page"),whiteList("page"),$('input[name="other.twitterVerifyId"]').after(``),$("#getTwitterUserId").on("click",()=>{this.#getId("twitterUser")}),$('input[name="other.youtubeVerifyChannel"]').after(``),$("#getYoutubeChannelId").on("click",()=>{this.#getId("youtubeChannel")}),$('input[name^="position"]').on("input",function(){switch($(this).attr("name").replace("position.","")){case"buttonSideX":case"buttonSideY":case"buttonDistance":{const distance=$('input[name="position.buttonDistance"]').val();var sideX=$('input[name="position.buttonSideX"]').val(),sideY=$('input[name="position.buttonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;var distanceArr=distance.split(",");$("#auto-task-buttons").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"showButtonSideX":case"showButtonSideY":case"showButtonDistance":{const distance=$('input[name="position.showButtonDistance"]').val(),sideX=$('input[name="position.showButtonSideX"]').val(),sideY=$('input[name="position.showButtonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("div.show-button-div").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"logSideX":case"logSideY":case"logDistance":{const distance=$('input[name="position.logDistance"]').val(),sideX=$('input[name="position.logSideX"]').val(),sideY=$('input[name="position.logSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("#auto-task-info").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}}}),$('input[name^="hotKey"]').attr("readonly","readonly").off("keydown").on("keydown",function(event){let functionKey="";event.altKey?functionKey+="alt + ":event.ctrlKey?functionKey+="ctrl + ":event.shiftKey&&(functionKey+="shift + "),$(this).val(functionKey+(1===event.key.length?event.key.toLowerCase():""))})}catch(error){throwError(error,"Setting.after")}}saveGlobalOptions(){saveData()}#getId(social){try{external_Swal_default().fire({title:i18n("getId",i18n(social)),html:` + ${i18n("downloadFromGist")}

`,focusConfirm:!1,showLoaderOnConfirm:!0,footer:`${i18n("help")}`,preConfirm:async()=>{var token=$("#github-token").val(),gistId=$("#gist-id").val(),fileName=$("#file-name").val(),syncHistory=$("#sync-history").prop("checked");return GM_setValue("gistOptions",{TOKEN:token,GIST_ID:gistId,FILE_NAME:fileName,SYNC_HISTORY:syncHistory}),getGistData(token,gistId,fileName,!0)},allowOutsideClick:()=>!external_Swal_default().isLoading(),confirmButtonText:i18n("saveAndTest"),showCancelButton:!0,cancelButtonText:i18n("close")}).then(({value})=>{value?external_Swal_default().fire({icon:"success",title:i18n("testSuccess")}).then(syncOptions):void 0!==value&&external_Swal_default().fire({icon:"error",title:i18n("testFailed")}).then(syncOptions)}),$("#upload-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&FILE_NAME))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("processingData")});const data={};var names=GM_listValues(),SYNC_HISTORY=$("#sync-history").prop("checked");for(const name of names)"gistOptions"===name||/^[\w]+?Auth$/.test(name)||!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||(data[name]=GM_getValue(name));external_Swal_default().update({icon:"info",title:i18n("updatingData")}),await(async(token,gistId,fileName,content)=>{try{const logStatus=scripts_echoLog({text:i18n("settingData")});var contentData=JSON.stringify({files:{[fileName]:{content:JSON.stringify(content)}}}),{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},data:contentData,responseType:"json",method:"POST",timeout:3e4});return"Success"===result?200===data?.status&&data.response.files?.[fileName]?.content===JSON.stringify(content)?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"setGistData"),!1}})(TOKEN,GIST_ID,FILE_NAME,data)?external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")}):external_Swal_default().fire({icon:"error",title:i18n("syncDataFailed")})}),$("#download-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME:data}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&data))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("downloadingData")});data=await getGistData(TOKEN,GIST_ID,data);if(!data)return external_Swal_default().fire({icon:"error",title:i18n("checkedNoData")}).then(syncOptions);external_Swal_default().update({icon:"info",title:i18n("savingData")});var name,value,SYNC_HISTORY=$("#sync-history").prop("checked");for([name,value]of Object.entries(data))!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||GM_setValue(name,value);external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")})})}catch(error){throwError(error,"syncOptions")}};dataSync=syncOptions;const Websites=[Freeanywhere,GiveawaySu,website_Indiedb,website_Keyhub,website_Givekey,website_GiveeClub,website_OpiumPulses,loadScript,website_Opquests,class extends website_Website{name="Gleam";undoneTasks=JSON.parse(Gleam_defaultTasks);socialTasks=JSON.parse(Gleam_defaultTasks);buttons=["doTask","undoTask","verifyTask"];static test(){return"gleam.io"===window.location.host}before(){unsafeWindow.confirm=()=>{},unsafeWindow.alert=()=>{},unsafeWindow.prompt=()=>{}}async after(){try{if(window.location.search.includes("8b07d23f4bfa65f9")){const checkComplete=setInterval(()=>{0<$(".entry-content .entry-method i.fa-check").length&&(clearInterval(checkComplete),window.close())});for(const task of $(".entry-content .entry-method")){const taskInfo=$(task).find(".user-links"),expandInfo=$(task).find(".expandable");var aElements=expandInfo.find("a.btn,a:contains(Continue),button:contains(Continue)");if(0!0)}catch(error){return throwError(error,"Gleam.extraDoTask"),!1}}async verifyTask(){try{scripts_echoLog({text:i18n("verifyingTask")+"..."});var evt,valuelimit,tasks=$(".entry-content .entry-method");unsafeWindow._OxA="_OxA";for(const task of tasks){if(0<$('[campaign-key="campaign.key"]').length)return scripts_echoLog({text:i18n("campaign")});const $task=$(task);if(0!==$task.find("i.fa-question").length){const taskInfo=$task.find(".user-links");taskInfo[0].click(),unsafeWindow.$hookTimer?.setSpeed(1e3),await delay(3e3),unsafeWindow.$hookTimer?.setSpeed(1);const expandInfo=$task.find(".expandable"),input=expandInfo.find("input")[0];input&&(evt=new Event("input",{bubbles:!0,cancelable:!0,composed:!0}),valuelimit=[...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1],input.value=valuelimit||"vloot",input.dispatchEvent(evt),await delay(1e3)),await this.#checkSync();for(const button of $task.find(".expandable").find("span:contains(Continue),button:contains(Continue)"))button.click(),await delay(500),await this.#checkSync()}}scripts_echoLog({text:i18n("verifiedGleamTasks")})}catch(error){return throwError(error,"Gleam.verifyTask"),!1}}async#checkSync(){try{return await new Promise(resolve=>{const checker=setInterval(()=>{0===$(".entry-content .entry-method i.fa-sync").length&&(clearInterval(checker),resolve(!0))},500)})}catch(error){return throwError(error,"Gleam.checkSync"),!1}}async#doGleamTask(link){try{const logStatus=scripts_echoLog({text:i18n("doingGleamTask")});return await new Promise(resolve=>{GM_openInTab(link+"?8b07d23f4bfa65f9",{active:!0,insert:!0,setParent:!0}).onclose=()=>{logStatus.success(),resolve(!0)}})}catch(error){return throwError(error,"Gleam.doGleamTask"),!1}}#getGiveawayId(){try{var giveawayId=window.location.pathname;return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Gleam.getGiveawayId"),!1}}async#getGleamLink(title){try{const logStatus=scripts_echoLog({text:i18n("gettingGleamLink")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://www.vloot.io/api/v1/giveaways",method:"GET",responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200===data?.status&&!0===data?.response?.Success&&data?.response?.Data){var link=(data.response.Data.find(giveaway=>title.replace(/[\s]/g,"").toLowerCase().includes(giveaway.title.replace(/[\s]/g,"").toLowerCase()))||{})["link"];return link?(logStatus.success(),link):(logStatus.error("Error:"+i18n("getLinkFailed")),!1)}return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1}catch(error){return throwError(error,"Gleam.getGleamLink"),!1}}async#checkLeftKey(){try{if(!globalOptions.other.checkLeftKey)return!0;var campaignString=$("div.popup-blocks-container").attr("ng-init")?.match(/initCampaign\(([\w\W]+?)\)$/)?.[1];if(!campaignString)return!1;var{campaign,incentive}=JSON.parse(campaignString),controllerString=$("div.campaign.reward").attr("ng-init")?.match(/initContestant\(([\w\W]+?)\);/)?.[1];let ownedKey=!1;return controllerString&&JSON.parse(controllerString).contestant?.claims?.incentives?.[incentive.id]?.length&&(ownedKey=!0),(campaign.banned||campaign.finished&&!ownedKey||campaign.paused||(new Date).getTime()<1e3*campaign.starts_at)&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayNotWork"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0}catch(error){return throwError(error,"Gleam.checkLeftKey"),!1}}},class extends website_Website{name="SweepWidget";options={username:"",email:"",...GM_getValue("SweepWidgetOptions")};buttons=["doTask"];static test(){return/^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed"))}catch(error){throwError(error,"SweepWidget.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return this.#checkLogin()?!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0):(logStatus.warning(i18n("needLogin")),!1)}catch(error){return throwError(error,"SweepWidget.init"),!1}}classifyTask(){return!0}async doTask(){try{if(0===$("#unlock_rewards_main_wrapper").length&&(0<$('input[name="sw__login_name"]:visible').length&&$('input[name="sw__login_name"]').val(this.options.username),0<$('input[name="sw__login_email"]:visible').length&&$('input[name="sw__login_email"]').val(this.options.email),0<$("#sw_login_button:visible").length&&$("#sw_login_button")[0].click(),!await this.#checkEnter()))return!1;const logStatus=scripts_echoLog({text:i18n("SweepWidgetNotice")});for(const task of $("#sw_inner_entry_methods_l2_wrapper>div.sw_entry")){const $task=$(task);if(!(0<$task.find("i.fa-check:visible").length)){const title=$task.find(".sw_text_inner");title[0].click();const aElement=$task.find("a.sw_link");var link=aElement.attr("href");aElement.attr("href","#a").attr("target","_self"),aElement[0]?.click(),await delay(300),aElement.attr("href",link).attr("target","_blank"),$task.find('input[type="text"]').val("test");const verifyBtn=$task.find("input.sw_verify");!0===verifyBtn.prop("disabled")&&(title[0].click(),await delay(300),title[0].click(),await delay(300)),$task.find("input.sw_verify").removeAttr("disabled")[0]?.click(),await this.#checkFinish($task),await delay(parseInt(""+(2001*Math.random()+1e3),10))}}return logStatus.success(),!0}catch(error){return throwError(error,"SweepWidget.doTask"),!1}}#checkLogin(){try{return 0<$("#twitter_login_button").length&&$("#twitter_login_button")[0].click(),!0}catch(error){return throwError(error,"SweepWidget.checkLogin"),!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,"SweepWidget.getGiveawayId"),!1}}async#checkEnter(){try{return new Promise(resolve=>{const checker=setInterval(()=>{0<$("#unlock_rewards_main_wrapper").length&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkEnter"),!1}}async#checkFinish($task){try{return new Promise(resolve=>{const checker=setInterval(()=>{(0<$task.find("i.fa-check:visible").length||0===$task.find(".sw_entry_input:visible").length)&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkFinish"),!1}}},class{name="Setting";buttons=["saveGlobalOptions","syncData","tasksHistory"];syncData=dataSync;tasksHistory(){window.open("https://auto-task-v4.hclonely.com/history.html","_blank")}static test(){return"auto-task-v4.hclonely.com"===window.location.host&&"/setting.html"===window.location.pathname}before(){$("body").html("").addClass("auto-task-options")}after(){try{this.#environment(),changeGlobalOptions("page"),whiteList("page"),$('input[name="other.twitterVerifyId"]').after(``),$("#getTwitterUserId").on("click",()=>{this.#getId("twitterUser")}),$('input[name="other.youtubeVerifyChannel"]').after(``),$("#getYoutubeChannelId").on("click",()=>{this.#getId("youtubeChannel")}),$('input[name^="position"]').on("input",function(){switch($(this).attr("name").replace("position.","")){case"buttonSideX":case"buttonSideY":case"buttonDistance":{const distance=$('input[name="position.buttonDistance"]').val();var sideX=$('input[name="position.buttonSideX"]').val(),sideY=$('input[name="position.buttonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;var distanceArr=distance.split(",");$("#auto-task-buttons").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"showButtonSideX":case"showButtonSideY":case"showButtonDistance":{const distance=$('input[name="position.showButtonDistance"]').val(),sideX=$('input[name="position.showButtonSideX"]').val(),sideY=$('input[name="position.showButtonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("div.show-button-div").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"logSideX":case"logSideY":case"logDistance":{const distance=$('input[name="position.logDistance"]').val(),sideX=$('input[name="position.logSideX"]').val(),sideY=$('input[name="position.logSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("#auto-task-info").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}}}),$('input[name^="hotKey"]').attr("readonly","readonly").off("keydown").on("keydown",function(event){let functionKey="";event.altKey?functionKey+="alt + ":event.ctrlKey?functionKey+="ctrl + ":event.shiftKey&&(functionKey+="shift + "),$(this).val(functionKey+(1===event.key.length?event.key.toLowerCase():""))})}catch(error){throwError(error,"Setting.after")}}saveGlobalOptions(){saveData()}#getId(social){try{external_Swal_default().fire({title:i18n("getId",i18n(social)),html:` `,showCancelButton:!0,cancelButtonText:i18n("close"),showConfirmButton:!1}),$("#link2id").on("click",async function(){const link=$("#socialLink").val();if(link){var type=$(this).attr("data-type");if("twitterUser"===type){var name=link.match(/https:\/\/twitter\.com\/(.+)/)?.[1]||link;$("#socialLink").val(await(new social_Twitter).userName2id(name)||"")}else if("youtubeChannel"===type){const name=/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www.youtube.com\/.*/.test(link)?link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)?.[1]:link;$("#socialLink").val((await getInfo(name,"channel"))?.params?.channelId||"")}}})}catch(error){throwError(error,"Setting.getId")}}#environment(){try{var userAgent=(0,javascript_utils_umd_min.ua)(),environmentForm=`
${i18n("type")}${i18n("name")}${i18n("version")}
${i18n("os")}${userAgent.os}${userAgent.osVersion}
diff --git a/page/dist/auto-task-v4.compatibility.user.js b/page/dist/auto-task-v4.compatibility.user.js index fce35d1..0de5ee5 100644 --- a/page/dist/auto-task-v4.compatibility.user.js +++ b/page/dist/auto-task-v4.compatibility.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4.compatibility // @namespace auto-task-v4.compatibility -// @version 4.4.9 +// @version 4.4.10 // @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 @@ -127,7 +127,7 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');

在下方填写白名单,每行一个

`,inputValue:whiteList[social][type].join("\n"),showConfirmButton:!0,confirmButtonText:i18n("save"),showCancelButton:!0,cancelButtonText:i18n("close"),showDenyButton:!0,denyButtonText:i18n("return")}).then(({isDenied,isConfirmed,value})=>{isDenied?"swal"===showType&&whiteListOptions(showType):isConfirmed&&(whiteList[social][type]=value.split("\n"),GM_setValue("whiteList",whiteList),external_Swal_default().fire({title:i18n("changeWhiteListSuccess"),icon:"success"}))}),$("#link2id").on("click",async function(){var type=$(this).attr("data-type");$("#socialLink").val(await async function(type){try{const link=$("#socialLink").val();let id="";switch(type){case"discord.servers":id=link.match(/invite\/(.+)/)?.[1]||"";break;case"instagram.users":id=link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)?.[1]||"";break;case"twitch.channels":id=link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)?.[2]||"";break;case"twitter.users":id=link.match(/https:\/\/twitter\.com\/(.+)/)?.[1]||"";break;case"twitter.retweets":id=link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)?.[1]||"";break;case"vk.names":id=link.match(/https:\/\/vk\.com\/([^/]+)/)?.[1]||"";break;case"youtube.channels":id=(await getInfo(link,"channel"))?.params?.channelId||"";break;case"youtube.likes":id=(await getInfo(link,"likeVideo"))?.params?.videoId||"";break;case"reddit.reddits":id=link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)?.[1]||link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)?.[1]||"";break;case"steam.groups":id=link.match(/groups\/(.+)\/?/)?.[1]||"";break;case"steam.wishlists":case"steam.follows":case"steam.forums":id=link.match(/app\/([\d]+)/)?.[1]||"";break;case"steam.workshops":id=link.match(/\?id=([\d]+)/)?.[1]||"";break;case"steam.curators":if(link.includes("curator"))id=link.match(/curator\/([\d]+)/)?.[1]||"";else{var param=link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)?.slice(1,3);if(!param||2!==param.length)break;const steam=new social_Steam;await steam.init()&&(id=await steam.getCuratorId(param[0],param[1])||"")}}return id}catch(error){return throwError(error,"link2id"),i18n("getFailed","id")}}(type))})):scripts_echoLog({}).warning(i18n("whiteListNotFound",value))}})}catch(error){throwError(error,"whiteListOptions")}}const defaultWhiteList={discord:{servers:[]},instagram:{users:[]},twitch:{channels:[]},twitter:{users:[],retweets:[],likes:[]},vk:{names:[]},youtube:{channels:[],likes:[]},reddit:{reddits:[]},steam:{groups:[],officialGroups:[],wishlists:[],follows:[],forums:[],workshops:[],curators:[],workshopVotes:[],curatorLikes:[],announcements:[],licenses:[],playtests:[]}},disabledType={steam:["workshopVotes","curatorLikes","announcements"],twitter:["likes"]},whiteList=whiteListOptions,getGistData=async(token,gistId,fileName,test=!1)=>{try{const logStatus=scripts_echoLog({text:i18n("gettingData")});var{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},responseType:"json",method:"GET",timeout:3e4});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200!==data?.status)return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1;{var content=data.response?.files?.[fileName]?.content;let formatedContent;if(!content)return logStatus.error("Error:"+i18n("noRemoteData")),!1;if(test)return logStatus.success(),!0;try{formatedContent=JSON.parse(content)}catch(error){return logStatus.error("Error:"+i18n("errorRemoteDataFormat")),!1}return logStatus.success(),formatedContent}}catch(error){return throwError(error,"getGistData"),!1}},syncOptions=()=>{try{var{TOKEN,GIST_ID,FILE_NAME,SYNC_HISTORY}=GM_getValue("gistOptions")||{TOKEN:"",GIST_ID:"",FILE_NAME:"",SYNC_HISTORY:!0};external_Swal_default().fire({title:i18n("gistOptions"),html:`

Github Token

`+`

Gist ID

`+`

${i18n("fileName")}

`+'

`+`

`+`

`,focusConfirm:!1,showLoaderOnConfirm:!0,footer:`${i18n("help")}`,preConfirm:async()=>{var token=$("#github-token").val(),gistId=$("#gist-id").val(),fileName=$("#file-name").val(),syncHistory=$("#sync-history").prop("checked");return GM_setValue("gistOptions",{TOKEN:token,GIST_ID:gistId,FILE_NAME:fileName,SYNC_HISTORY:syncHistory}),getGistData(token,gistId,fileName,!0)},allowOutsideClick:()=>!external_Swal_default().isLoading(),confirmButtonText:i18n("saveAndTest"),showCancelButton:!0,cancelButtonText:i18n("close")}).then(({value})=>{value?external_Swal_default().fire({icon:"success",title:i18n("testSuccess")}).then(syncOptions):void 0!==value&&external_Swal_default().fire({icon:"error",title:i18n("testFailed")}).then(syncOptions)}),$("#upload-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&FILE_NAME))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("processingData")});const data={};var names=GM_listValues(),SYNC_HISTORY=$("#sync-history").prop("checked");for(const name of names)"gistOptions"===name||/^[\w]+?Auth$/.test(name)||!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||(data[name]=GM_getValue(name));external_Swal_default().update({icon:"info",title:i18n("updatingData")}),await(async(token,gistId,fileName,content)=>{try{const logStatus=scripts_echoLog({text:i18n("settingData")});var contentData=JSON.stringify({files:{[fileName]:{content:JSON.stringify(content)}}}),{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},data:contentData,responseType:"json",method:"POST",timeout:3e4});return"Success"===result?200===data?.status&&data.response.files?.[fileName]?.content===JSON.stringify(content)?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"setGistData"),!1}})(TOKEN,GIST_ID,FILE_NAME,data)?external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")}):external_Swal_default().fire({icon:"error",title:i18n("syncDataFailed")})}),$("#download-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME:data}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&data))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("downloadingData")});data=await getGistData(TOKEN,GIST_ID,data);if(!data)return external_Swal_default().fire({icon:"error",title:i18n("checkedNoData")}).then(syncOptions);external_Swal_default().update({icon:"info",title:i18n("savingData")});var name,value,SYNC_HISTORY=$("#sync-history").prop("checked");for([name,value]of Object.entries(data))!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||GM_setValue(name,value);external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")})})}catch(error){throwError(error,"syncOptions")}};dataSync=syncOptions;const Websites=[Freeanywhere,GiveawaySu,website_Indiedb,website_Keyhub,website_Givekey,website_GiveeClub,website_OpiumPulses,loadScript,website_Opquests,class extends website_Website{name="Gleam";undoneTasks=JSON.parse(Gleam_defaultTasks);socialTasks=JSON.parse(Gleam_defaultTasks);buttons=["doTask","undoTask","verifyTask"];static test(){return"gleam.io"===window.location.host}before(){unsafeWindow.confirm=()=>{},unsafeWindow.alert=()=>{},unsafeWindow.prompt=()=>{}}async after(){try{if(window.location.search.includes("8b07d23f4bfa65f9")){const checkComplete=setInterval(()=>{0<$(".entry-content .entry-method i.fa-check").length&&(clearInterval(checkComplete),window.close())});for(const task of $(".entry-content .entry-method")){const taskInfo=$(task).find(".user-links"),expandInfo=$(task).find(".expandable");var aElements=expandInfo.find("a.btn,a:contains(Continue),button:contains(Continue)");if(0!0)}catch(error){return throwError(error,"Gleam.extraDoTask"),!1}}async verifyTask(){try{scripts_echoLog({text:i18n("verifyingTask")+"..."});var tasks=$(".entry-content .entry-method");unsafeWindow._OxA="_OxA";for(const task of tasks){if(0<$('[campaign-key="campaign.key"]').length)return scripts_echoLog({text:i18n("campaign")});const $task=$(task);if(0!==$task.find("i.fa-question").length){const taskInfo=$task.find(".user-links");taskInfo[0].click(),unsafeWindow.$hookTimer?.setSpeed(1e3),await delay(3e3),unsafeWindow.$hookTimer?.setSpeed(1);const expandInfo=$task.find(".expandable"),input=expandInfo.find("input")[0];var evt=new Event("input",{bubbles:!0,cancelable:!0,composed:!0}),valuelimit=[...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1];input.value=valuelimit||"vloot",input.dispatchEvent(evt),await delay(1e3),await this.#checkSync();for(const button of $task.find(".expandable").find("span:contains(Continue),button:contains(Continue)"))button.click(),await delay(500),await this.#checkSync()}}scripts_echoLog({text:i18n("verifiedGleamTasks")})}catch(error){return throwError(error,"Gleam.verifyTask"),!1}}async#checkSync(){try{return await new Promise(resolve=>{const checker=setInterval(()=>{0===$(".entry-content .entry-method i.fa-sync").length&&(clearInterval(checker),resolve(!0))},500)})}catch(error){return throwError(error,"Gleam.checkSync"),!1}}async#doGleamTask(link){try{const logStatus=scripts_echoLog({text:i18n("doingGleamTask")});return await new Promise(resolve=>{GM_openInTab(link+"?8b07d23f4bfa65f9",{active:!0,insert:!0,setParent:!0}).onclose=()=>{logStatus.success(),resolve(!0)}})}catch(error){return throwError(error,"Gleam.doGleamTask"),!1}}#getGiveawayId(){try{var giveawayId=window.location.pathname;return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Gleam.getGiveawayId"),!1}}async#getGleamLink(title){try{const logStatus=scripts_echoLog({text:i18n("gettingGleamLink")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://www.vloot.io/api/v1/giveaways",method:"GET",responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200===data?.status&&!0===data?.response?.Success&&data?.response?.Data){var link=(data.response.Data.find(giveaway=>title.replace(/[\s]/g,"").toLowerCase().includes(giveaway.title.replace(/[\s]/g,"").toLowerCase()))||{})["link"];return link?(logStatus.success(),link):(logStatus.error("Error:"+i18n("getLinkFailed")),!1)}return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1}catch(error){return throwError(error,"Gleam.getGleamLink"),!1}}async#checkLeftKey(){try{if(!globalOptions.other.checkLeftKey)return!0;var campaignString=$("div.popup-blocks-container").attr("ng-init")?.match(/initCampaign\(([\w\W]+?)\)$/)?.[1];if(!campaignString)return!1;var{campaign,incentive}=JSON.parse(campaignString),controllerString=$("div.campaign.reward").attr("ng-init")?.match(/initContestant\(([\w\W]+?)\);/)?.[1];let ownedKey=!1;return controllerString&&JSON.parse(controllerString).contestant?.claims?.incentives?.[incentive.id]?.length&&(ownedKey=!0),(campaign.banned||campaign.finished&&!ownedKey||campaign.paused||(new Date).getTime()<1e3*campaign.starts_at)&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayNotWork"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0}catch(error){return throwError(error,"Gleam.checkLeftKey"),!1}}},class extends website_Website{name="SweepWidget";options={username:"",email:"",...GM_getValue("SweepWidgetOptions")};buttons=["doTask"];static test(){return/^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed"))}catch(error){throwError(error,"SweepWidget.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return this.#checkLogin()?!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0):(logStatus.warning(i18n("needLogin")),!1)}catch(error){return throwError(error,"SweepWidget.init"),!1}}classifyTask(){return!0}async doTask(){try{if(0===$("#unlock_rewards_main_wrapper").length&&(0<$('input[name="sw__login_name"]:visible').length&&$('input[name="sw__login_name"]').val(this.options.username),0<$('input[name="sw__login_email"]:visible').length&&$('input[name="sw__login_email"]').val(this.options.email),0<$("#sw_login_button:visible").length&&$("#sw_login_button")[0].click(),!await this.#checkEnter()))return!1;const logStatus=scripts_echoLog({text:i18n("SweepWidgetNotice")});for(const task of $("#sw_inner_entry_methods_l2_wrapper>div.sw_entry")){const $task=$(task);if(!(0<$task.find("i.fa-check:visible").length)){const title=$task.find(".sw_text_inner");title[0].click();const aElement=$task.find("a.sw_link");var link=aElement.attr("href");aElement.attr("href","#a").attr("target","_self"),aElement[0]?.click(),await delay(300),aElement.attr("href",link).attr("target","_blank"),$task.find('input[type="text"]').val("test");const verifyBtn=$task.find("input.sw_verify");!0===verifyBtn.prop("disabled")&&(title[0].click(),await delay(300),title[0].click(),await delay(300)),$task.find("input.sw_verify").removeAttr("disabled")[0]?.click(),await this.#checkFinish($task),await delay(parseInt(""+(2001*Math.random()+1e3),10))}}return logStatus.success(),!0}catch(error){return throwError(error,"SweepWidget.doTask"),!1}}#checkLogin(){try{return 0<$("#twitter_login_button").length&&$("#twitter_login_button")[0].click(),!0}catch(error){return throwError(error,"SweepWidget.checkLogin"),!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,"SweepWidget.getGiveawayId"),!1}}async#checkEnter(){try{return new Promise(resolve=>{const checker=setInterval(()=>{0<$("#unlock_rewards_main_wrapper").length&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkEnter"),!1}}async#checkFinish($task){try{return new Promise(resolve=>{const checker=setInterval(()=>{(0<$task.find("i.fa-check:visible").length||0===$task.find(".sw_entry_input:visible").length)&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkFinish"),!1}}},class{name="Setting";buttons=["saveGlobalOptions","syncData","tasksHistory"];syncData=dataSync;tasksHistory(){window.open("https://auto-task-v4.hclonely.com/history.html","_blank")}static test(){return"auto-task-v4.hclonely.com"===window.location.host&&"/setting.html"===window.location.pathname}before(){$("body").html("").addClass("auto-task-options")}after(){try{this.#environment(),changeGlobalOptions("page"),whiteList("page"),$('input[name="other.twitterVerifyId"]').after(``),$("#getTwitterUserId").on("click",()=>{this.#getId("twitterUser")}),$('input[name="other.youtubeVerifyChannel"]').after(``),$("#getYoutubeChannelId").on("click",()=>{this.#getId("youtubeChannel")}),$('input[name^="position"]').on("input",function(){switch($(this).attr("name").replace("position.","")){case"buttonSideX":case"buttonSideY":case"buttonDistance":{const distance=$('input[name="position.buttonDistance"]').val();var sideX=$('input[name="position.buttonSideX"]').val(),sideY=$('input[name="position.buttonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;var distanceArr=distance.split(",");$("#auto-task-buttons").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"showButtonSideX":case"showButtonSideY":case"showButtonDistance":{const distance=$('input[name="position.showButtonDistance"]').val(),sideX=$('input[name="position.showButtonSideX"]').val(),sideY=$('input[name="position.showButtonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("div.show-button-div").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"logSideX":case"logSideY":case"logDistance":{const distance=$('input[name="position.logDistance"]').val(),sideX=$('input[name="position.logSideX"]').val(),sideY=$('input[name="position.logSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("#auto-task-info").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}}}),$('input[name^="hotKey"]').attr("readonly","readonly").off("keydown").on("keydown",function(event){let functionKey="";event.altKey?functionKey+="alt + ":event.ctrlKey?functionKey+="ctrl + ":event.shiftKey&&(functionKey+="shift + "),$(this).val(functionKey+(1===event.key.length?event.key.toLowerCase():""))})}catch(error){throwError(error,"Setting.after")}}saveGlobalOptions(){saveData()}#getId(social){try{external_Swal_default().fire({title:i18n("getId",i18n(social)),html:` + ${i18n("downloadFromGist")}

`,focusConfirm:!1,showLoaderOnConfirm:!0,footer:`${i18n("help")}`,preConfirm:async()=>{var token=$("#github-token").val(),gistId=$("#gist-id").val(),fileName=$("#file-name").val(),syncHistory=$("#sync-history").prop("checked");return GM_setValue("gistOptions",{TOKEN:token,GIST_ID:gistId,FILE_NAME:fileName,SYNC_HISTORY:syncHistory}),getGistData(token,gistId,fileName,!0)},allowOutsideClick:()=>!external_Swal_default().isLoading(),confirmButtonText:i18n("saveAndTest"),showCancelButton:!0,cancelButtonText:i18n("close")}).then(({value})=>{value?external_Swal_default().fire({icon:"success",title:i18n("testSuccess")}).then(syncOptions):void 0!==value&&external_Swal_default().fire({icon:"error",title:i18n("testFailed")}).then(syncOptions)}),$("#upload-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&FILE_NAME))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("processingData")});const data={};var names=GM_listValues(),SYNC_HISTORY=$("#sync-history").prop("checked");for(const name of names)"gistOptions"===name||/^[\w]+?Auth$/.test(name)||!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||(data[name]=GM_getValue(name));external_Swal_default().update({icon:"info",title:i18n("updatingData")}),await(async(token,gistId,fileName,content)=>{try{const logStatus=scripts_echoLog({text:i18n("settingData")});var contentData=JSON.stringify({files:{[fileName]:{content:JSON.stringify(content)}}}),{result,statusText,status,data}=await tools_httpRequest({url:"https://api.github.com/gists/"+gistId,headers:{Accept:"application/vnd.github.v3+json",Authorization:"token "+token},data:contentData,responseType:"json",method:"POST",timeout:3e4});return"Success"===result?200===data?.status&&data.response.files?.[fileName]?.content===JSON.stringify(content)?(logStatus.success(),!0):(logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1):(logStatus.error(result+`:${statusText}(${status})`),!1)}catch(error){return throwError(error,"setGistData"),!1}})(TOKEN,GIST_ID,FILE_NAME,data)?external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")}):external_Swal_default().fire({icon:"error",title:i18n("syncDataFailed")})}),$("#download-data").on("click",async()=>{var{TOKEN,GIST_ID,FILE_NAME:data}=GM_getValue("gistOptions")||{};if(!(TOKEN&&GIST_ID&&data))return external_Swal_default().fire({icon:"error",title:i18n("saveAndTestNotice")}).then(syncOptions);external_Swal_default().fire({icon:"info",title:i18n("downloadingData")});data=await getGistData(TOKEN,GIST_ID,data);if(!data)return external_Swal_default().fire({icon:"error",title:i18n("checkedNoData")}).then(syncOptions);external_Swal_default().update({icon:"info",title:i18n("savingData")});var name,value,SYNC_HISTORY=$("#sync-history").prop("checked");for([name,value]of Object.entries(data))!SYNC_HISTORY&&/^[\w]+?Tasks-/.test(name)||GM_setValue(name,value);external_Swal_default().fire({icon:"success",title:i18n("syncDataSuccess")})})}catch(error){throwError(error,"syncOptions")}};dataSync=syncOptions;const Websites=[Freeanywhere,GiveawaySu,website_Indiedb,website_Keyhub,website_Givekey,website_GiveeClub,website_OpiumPulses,loadScript,website_Opquests,class extends website_Website{name="Gleam";undoneTasks=JSON.parse(Gleam_defaultTasks);socialTasks=JSON.parse(Gleam_defaultTasks);buttons=["doTask","undoTask","verifyTask"];static test(){return"gleam.io"===window.location.host}before(){unsafeWindow.confirm=()=>{},unsafeWindow.alert=()=>{},unsafeWindow.prompt=()=>{}}async after(){try{if(window.location.search.includes("8b07d23f4bfa65f9")){const checkComplete=setInterval(()=>{0<$(".entry-content .entry-method i.fa-check").length&&(clearInterval(checkComplete),window.close())});for(const task of $(".entry-content .entry-method")){const taskInfo=$(task).find(".user-links"),expandInfo=$(task).find(".expandable");var aElements=expandInfo.find("a.btn,a:contains(Continue),button:contains(Continue)");if(0!0)}catch(error){return throwError(error,"Gleam.extraDoTask"),!1}}async verifyTask(){try{scripts_echoLog({text:i18n("verifyingTask")+"..."});var evt,valuelimit,tasks=$(".entry-content .entry-method");unsafeWindow._OxA="_OxA";for(const task of tasks){if(0<$('[campaign-key="campaign.key"]').length)return scripts_echoLog({text:i18n("campaign")});const $task=$(task);if(0!==$task.find("i.fa-question").length){const taskInfo=$task.find(".user-links");taskInfo[0].click(),unsafeWindow.$hookTimer?.setSpeed(1e3),await delay(3e3),unsafeWindow.$hookTimer?.setSpeed(1);const expandInfo=$task.find(".expandable"),input=expandInfo.find("input")[0];input&&(evt=new Event("input",{bubbles:!0,cancelable:!0,composed:!0}),valuelimit=[...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1],input.value=valuelimit||"vloot",input.dispatchEvent(evt),await delay(1e3)),await this.#checkSync();for(const button of $task.find(".expandable").find("span:contains(Continue),button:contains(Continue)"))button.click(),await delay(500),await this.#checkSync()}}scripts_echoLog({text:i18n("verifiedGleamTasks")})}catch(error){return throwError(error,"Gleam.verifyTask"),!1}}async#checkSync(){try{return await new Promise(resolve=>{const checker=setInterval(()=>{0===$(".entry-content .entry-method i.fa-sync").length&&(clearInterval(checker),resolve(!0))},500)})}catch(error){return throwError(error,"Gleam.checkSync"),!1}}async#doGleamTask(link){try{const logStatus=scripts_echoLog({text:i18n("doingGleamTask")});return await new Promise(resolve=>{GM_openInTab(link+"?8b07d23f4bfa65f9",{active:!0,insert:!0,setParent:!0}).onclose=()=>{logStatus.success(),resolve(!0)}})}catch(error){return throwError(error,"Gleam.doGleamTask"),!1}}#getGiveawayId(){try{var giveawayId=window.location.pathname;return giveawayId?(this.giveawayId=giveawayId,!0):(scripts_echoLog({text:i18n("getFailed","GiveawayId")}),!1)}catch(error){return throwError(error,"Gleam.getGiveawayId"),!1}}async#getGleamLink(title){try{const logStatus=scripts_echoLog({text:i18n("gettingGleamLink")}),{result,statusText,status,data}=await tools_httpRequest({url:"https://www.vloot.io/api/v1/giveaways",method:"GET",responseType:"json"});if("Success"!==result)return logStatus.error(result+`:${statusText}(${status})`),!1;if(200===data?.status&&!0===data?.response?.Success&&data?.response?.Data){var link=(data.response.Data.find(giveaway=>title.replace(/[\s]/g,"").toLowerCase().includes(giveaway.title.replace(/[\s]/g,"").toLowerCase()))||{})["link"];return link?(logStatus.success(),link):(logStatus.error("Error:"+i18n("getLinkFailed")),!1)}return logStatus.error(`Error:${data?.statusText}(${data?.status})`),!1}catch(error){return throwError(error,"Gleam.getGleamLink"),!1}}async#checkLeftKey(){try{if(!globalOptions.other.checkLeftKey)return!0;var campaignString=$("div.popup-blocks-container").attr("ng-init")?.match(/initCampaign\(([\w\W]+?)\)$/)?.[1];if(!campaignString)return!1;var{campaign,incentive}=JSON.parse(campaignString),controllerString=$("div.campaign.reward").attr("ng-init")?.match(/initContestant\(([\w\W]+?)\);/)?.[1];let ownedKey=!1;return controllerString&&JSON.parse(controllerString).contestant?.claims?.incentives?.[incentive.id]?.length&&(ownedKey=!0),(campaign.banned||campaign.finished&&!ownedKey||campaign.paused||(new Date).getTime()<1e3*campaign.starts_at)&&await external_Swal_default().fire({icon:"warning",title:i18n("notice"),text:i18n("giveawayNotWork"),confirmButtonText:i18n("confirm"),cancelButtonText:i18n("cancel"),showCancelButton:!0}).then(({value})=>{value&&window.close()}),!0}catch(error){return throwError(error,"Gleam.checkLeftKey"),!1}}},class extends website_Website{name="SweepWidget";options={username:"",email:"",...GM_getValue("SweepWidgetOptions")};buttons=["doTask"];static test(){return/^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href)}async after(){try{this.#checkLogin()||scripts_echoLog({}).warning(i18n("checkLoginFailed"))}catch(error){throwError(error,"SweepWidget.after")}}init(){try{const logStatus=scripts_echoLog({text:i18n("initing")});return this.#checkLogin()?!!this.#getGiveawayId()&&(this.initialized=!0,logStatus.success(),!0):(logStatus.warning(i18n("needLogin")),!1)}catch(error){return throwError(error,"SweepWidget.init"),!1}}classifyTask(){return!0}async doTask(){try{if(0===$("#unlock_rewards_main_wrapper").length&&(0<$('input[name="sw__login_name"]:visible').length&&$('input[name="sw__login_name"]').val(this.options.username),0<$('input[name="sw__login_email"]:visible').length&&$('input[name="sw__login_email"]').val(this.options.email),0<$("#sw_login_button:visible").length&&$("#sw_login_button")[0].click(),!await this.#checkEnter()))return!1;const logStatus=scripts_echoLog({text:i18n("SweepWidgetNotice")});for(const task of $("#sw_inner_entry_methods_l2_wrapper>div.sw_entry")){const $task=$(task);if(!(0<$task.find("i.fa-check:visible").length)){const title=$task.find(".sw_text_inner");title[0].click();const aElement=$task.find("a.sw_link");var link=aElement.attr("href");aElement.attr("href","#a").attr("target","_self"),aElement[0]?.click(),await delay(300),aElement.attr("href",link).attr("target","_blank"),$task.find('input[type="text"]').val("test");const verifyBtn=$task.find("input.sw_verify");!0===verifyBtn.prop("disabled")&&(title[0].click(),await delay(300),title[0].click(),await delay(300)),$task.find("input.sw_verify").removeAttr("disabled")[0]?.click(),await this.#checkFinish($task),await delay(parseInt(""+(2001*Math.random()+1e3),10))}}return logStatus.success(),!0}catch(error){return throwError(error,"SweepWidget.doTask"),!1}}#checkLogin(){try{return 0<$("#twitter_login_button").length&&$("#twitter_login_button")[0].click(),!0}catch(error){return throwError(error,"SweepWidget.checkLogin"),!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,"SweepWidget.getGiveawayId"),!1}}async#checkEnter(){try{return new Promise(resolve=>{const checker=setInterval(()=>{0<$("#unlock_rewards_main_wrapper").length&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkEnter"),!1}}async#checkFinish($task){try{return new Promise(resolve=>{const checker=setInterval(()=>{(0<$task.find("i.fa-check:visible").length||0===$task.find(".sw_entry_input:visible").length)&&(clearInterval(checker),resolve(!0))})})}catch(error){return throwError(error,"SweepWidget.checkFinish"),!1}}},class{name="Setting";buttons=["saveGlobalOptions","syncData","tasksHistory"];syncData=dataSync;tasksHistory(){window.open("https://auto-task-v4.hclonely.com/history.html","_blank")}static test(){return"auto-task-v4.hclonely.com"===window.location.host&&"/setting.html"===window.location.pathname}before(){$("body").html("").addClass("auto-task-options")}after(){try{this.#environment(),changeGlobalOptions("page"),whiteList("page"),$('input[name="other.twitterVerifyId"]').after(``),$("#getTwitterUserId").on("click",()=>{this.#getId("twitterUser")}),$('input[name="other.youtubeVerifyChannel"]').after(``),$("#getYoutubeChannelId").on("click",()=>{this.#getId("youtubeChannel")}),$('input[name^="position"]').on("input",function(){switch($(this).attr("name").replace("position.","")){case"buttonSideX":case"buttonSideY":case"buttonDistance":{const distance=$('input[name="position.buttonDistance"]').val();var sideX=$('input[name="position.buttonSideX"]').val(),sideY=$('input[name="position.buttonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;var distanceArr=distance.split(",");$("#auto-task-buttons").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"showButtonSideX":case"showButtonSideY":case"showButtonDistance":{const distance=$('input[name="position.showButtonDistance"]').val(),sideX=$('input[name="position.showButtonSideX"]').val(),sideY=$('input[name="position.showButtonSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("div.show-button-div").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}case"logSideX":case"logSideY":case"logDistance":{const distance=$('input[name="position.logDistance"]').val(),sideX=$('input[name="position.logSideX"]').val(),sideY=$('input[name="position.logSideY"]').val();if(!["right","left"].includes(sideX))break;if(!["top","bottom"].includes(sideY))break;if(!/^[\d]+?,[\d]+$/.test(distance))break;const distanceArr=distance.split(",");$("#auto-task-info").css(sideX,distanceArr[0]+"px").css(sideY,distanceArr[1]+"px").css("rightleft".replace(sideX,""),"").css("topbottpm".replace(sideY,""),"");break}}}),$('input[name^="hotKey"]').attr("readonly","readonly").off("keydown").on("keydown",function(event){let functionKey="";event.altKey?functionKey+="alt + ":event.ctrlKey?functionKey+="ctrl + ":event.shiftKey&&(functionKey+="shift + "),$(this).val(functionKey+(1===event.key.length?event.key.toLowerCase():""))})}catch(error){throwError(error,"Setting.after")}}saveGlobalOptions(){saveData()}#getId(social){try{external_Swal_default().fire({title:i18n("getId",i18n(social)),html:` `,showCancelButton:!0,cancelButtonText:i18n("close"),showConfirmButton:!1}),$("#link2id").on("click",async function(){const link=$("#socialLink").val();if(link){var type=$(this).attr("data-type");if("twitterUser"===type){var name=link.match(/https:\/\/twitter\.com\/(.+)/)?.[1]||link;$("#socialLink").val(await(new social_Twitter).userName2id(name)||"")}else if("youtubeChannel"===type){const name=/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www.youtube.com\/.*/.test(link)?link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)?.[1]:link;$("#socialLink").val((await getInfo(name,"channel"))?.params?.channelId||"")}}})}catch(error){throwError(error,"Setting.getId")}}#environment(){try{var userAgent=(0,javascript_utils_umd_min.ua)(),environmentForm=`
${i18n("type")}${i18n("name")}${i18n("version")}
${i18n("os")}${userAgent.os}${userAgent.osVersion}
diff --git a/page/dist/auto-task-v4.user.js b/page/dist/auto-task-v4.user.js index f67d65a..c000b0a 100644 --- a/page/dist/auto-task-v4.user.js +++ b/page/dist/auto-task-v4.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name auto-task-v4 // @namespace auto-task-v4 -// @version 4.4.9 +// @version 4.4.10 // @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 @@ -9499,15 +9499,17 @@ console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载'); unsafeWindow.$hookTimer?.setSpeed(1); const expandInfo = $task.find('.expandable'); const input = expandInfo.find('input')[0]; - const evt = new Event('input', { - bubbles: true, - cancelable: true, - composed: true - }); - const valuelimit = [ ...expandInfo.text().matchAll(/"(.+?)"/g) ].at(-1)?.[1]; - input.value = valuelimit || 'vloot'; - input.dispatchEvent(evt); - await delay(1e3); + if (input) { + const evt = new Event('input', { + bubbles: true, + cancelable: true, + composed: true + }); + const valuelimit = [ ...expandInfo.text().matchAll(/"(.+?)"/g) ].at(-1)?.[1]; + input.value = valuelimit || 'vloot'; + input.dispatchEvent(evt); + await delay(1e3); + } await this.#checkSync(); const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)'); for (const button of continueBtn) { diff --git a/page/package.json b/page/package.json index aa1c691..fb10f84 100644 --- a/page/package.json +++ b/page/package.json @@ -1,9 +1,8 @@ { "name": "auto-task-v4", - "version": "4.4.9", + "version": "4.4.10", "change": [ - "新增:自动完成Gleam输入框任务", - "优化:增加Gleam可识别任务" + "修复:Gleam没有输入框时报错(#29)" ], "description": "赠Key站自动任务脚本", "main": "package.json", @@ -47,7 +46,7 @@ "ts-loader": "^9.2.6", "typescript": "^4.4.4", "uglify-js": "^3.14.5", - "webpack": "^5.76.0", + "webpack": "^5.94.0", "webpack-bundle-analyzer": "^4.5.0", "webpack-cli": "^4.9.1", "webpack-obfuscator": "^3.5.1", diff --git a/src/scripts/website/Gleam.ts b/src/scripts/website/Gleam.ts index fa796b1..237639e 100644 --- a/src/scripts/website/Gleam.ts +++ b/src/scripts/website/Gleam.ts @@ -1,7 +1,7 @@ /* * @Author : HCLonely * @Date : 2021-11-19 14:42:43 - * @LastEditTime : 2024-09-06 10:30:30 + * @LastEditTime : 2024-09-06 16:40:01 * @LastEditors : HCLonely * @FilePath : /auto-task-v4/src/scripts/website/Gleam.ts * @Description : https://gleam.io @@ -285,12 +285,14 @@ class Gleam extends Website { const expandInfo = $task.find('.expandable'); const input = expandInfo.find('input')[0]; - const evt = new Event("input", { bubbles: true, cancelable: true, composed: true }); - const valuelimit = [...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1]; - input.value = valuelimit || 'vloot'; - // expandInfo.find('input').val(this.options.vlootUsername); - input.dispatchEvent(evt); - await delay(1000); + if (input) { + const evt = new Event("input", { bubbles: true, cancelable: true, composed: true }); + const valuelimit = [...expandInfo.text().matchAll(/"(.+?)"/g)].at(-1)?.[1]; + input.value = valuelimit || 'vloot'; + // expandInfo.find('input').val(this.options.vlootUsername); + input.dispatchEvent(evt); + await delay(1000); + } await this.#checkSync(); const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
${i18n("type")}${i18n("name")}${i18n("version")}
${i18n("os")}${userAgent.os}${userAgent.osVersion}