Auto Task

Automatically complete giveaway tasks

Install this script?
Author's suggested script

You may also like AuTo Redeem Steamkey.

Install this script
  1. // ==UserScript==
  2. // @name 自动任务
  3. // @name:en Auto Task
  4. // @namespace auto-task
  5. // @version 2.2.13
  6. // @description 自动完成赠key站任务
  7. // @description:en Automatically complete giveaway tasks
  8. // @author HCLonely
  9. // @license MIT
  10. // @iconURL https://cdn.jsdelivr.net/gh/HCLonely/auto-task@2.2.13/favicon.ico
  11. // @homepage https://blog.hclonely.com/posts/777c60d5/
  12. // @supportURL https://github.com/HCLonely/auto-task/issues/new/choose
  13. // @include *://giveaway.su/giveaway/view/*
  14. // @include *://marvelousga.com/*
  15. // @include *://dupedornot.com/*
  16. // @include *://www.grabfreegame.com/giveaway/*
  17. // @include *://www.bananagiveaway.com/giveaway/*
  18. // @include /https?:\/\/gamehag.com/.*?giveaway\/.*/
  19. // @include *://prys.revadike.com/giveaway/?id=*
  20. // @include *://www.indiedb.com/giveaways*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://gkey.fun/distribution/*
  23. // @include *://givekey.ru/distribution/*
  24. // @include *://takekey.ru/distribution/*
  25. // @include *://chubkeys.com/giveaway/*
  26. // @include *://giveawayhopper.com/giveaway/*
  27. // @include *://*freegamelottery.com*
  28. // @include *://gleam.io/*
  29. // @exclude *googleads*
  30. // @include https://userjs.hclonely.com/setting.html
  31. // @include https://userjs.hclonely.com/setting_en.html
  32. // @include https://userjs.hclonely.com/announcement.html
  33. // @require https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js
  34. // @require https://cdn.jsdelivr.net/npm/element-ui@2.12.0/lib/index.min.js
  35. // @require https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js
  36. // @resource css https://cdn.jsdelivr.net/gh/HCLonely/auto-task@2.2.13/auto-task.min.css
  37. // @grant GM_setValue
  38. // @grant GM_getValue
  39. // @grant GM_listValues
  40. // @grant GM_deleteValue
  41. // @grant GM_addStyle
  42. // @grant GM_xmlhttpRequest
  43. // @grant GM_getResourceText
  44. // @grant GM_registerMenuCommand
  45. // @grant GM_info
  46. // @grant GM_openInTab
  47. // @connect userjs.hclonely.com
  48. // @connect cdn.jsdelivr.net
  49. // @connect store.steampowered.com
  50. // @connect steamcommunity.com
  51. // @connect twitter.com
  52. // @connect youtube.com
  53. // @connect facebook.com
  54. // @connect instagram.com
  55. // @connect vk.com
  56. // @connect discordapp.com
  57. // @connect github.com
  58. // @connect twitch.tv
  59. // @connect *
  60. // @run-at document-end
  61. // @compatible chrome >= 58, 没有测试其他浏览器的兼容性
  62. // ==/UserScript==
  63.  
  64. /* global $,Vue,checkClick,getURLParameter,showAlert,urlPath,checkUser,Centrifuge,DashboardApp,captchaCheck */
  65.  
  66. (function () {
  67. 'use strict'
  68.  
  69. const i18n = {
  70. 'zh-cn': {
  71. language: '语言',
  72. auto: '自动',
  73. needBanana: '此key需要收集 s% 个香蕉, 是否继续?',
  74. needPoints: '此key需要收集 s% , 是否继续?',
  75. notice: '提示',
  76. confirm: '确定',
  77. cancel: '取消',
  78. canceled: '已取消',
  79. processTasksInfo: '正在处理任务信息...',
  80. processTasksUrl: '正在处理任务链接(用时取决于Steam任务数量,请耐心等待)...',
  81. getTasksInfo: '正在获取任务信息...',
  82. allTasksComplete: '所有任务已完成!',
  83. prysAllTasksComplete: '所有任务验证完成,请手动完成人机验证获取key!',
  84. verifyTasksComplete: '所有任务验证完成!',
  85. verifyingTask: '正在验证任务',
  86. noKeysLeft: '此页面已经没有剩余key了, 是否关闭?',
  87. logining: '正在登录...',
  88. needLogin: '请先登录!',
  89. fglTimeout: '正在 s% (如果长时间没反应,请打开控制台查看错误日志)...',
  90. fglComplete: '任务完成,正在刷新页面(如果页面没有自动刷新,请手动刷新查看结果)...',
  91. checkingUpdate: '正在检测更新...',
  92. checkUpdate: '检查更新',
  93. thisIsNew: '当前脚本为最新版本!',
  94. updateNow: '立即更新至 ',
  95. newVer: '检测到新版本: ',
  96. getAnnouncement: '正在获取更新公告...',
  97. visitHistory: '查看历史更新内容',
  98. close: '关闭',
  99. websiteSetting: '网站设置',
  100. updateCommunityId: '正在更新Steam社区SessionID(用于加组退组)...',
  101. updateStoreId: '正在更新Steam商店SessionID(用于添加愿望单、关注游戏、关注鉴赏家等)...',
  102. loginSteamCommunity: '请先登录<a href="https://steamcommunity.com/login/home" target="_blank">Steam社区</a>',
  103. loginSteamStore: '请先登录<a href="https://store.steampowered.com/login" target="_blank">Steam商店</a>',
  104. joinGroup: '正在加入Steam组',
  105. getGroupId: '正在获取Steam组ID',
  106. leaveGroup: '正在退出Steam组',
  107. followCurator: '正在关注鉴赏家',
  108. unfollowCurator: '正在取关鉴赏家',
  109. getDeveloperId: '正在获取开发商ID',
  110. followDeveloper: '正在关注开发商',
  111. unfollowDeveloper: '正在取关开发商',
  112. getPublisherId: '正在获取发行商ID',
  113. followPublisher: '正在关注发行商',
  114. unfollowPublisher: '正在取关发行商',
  115. addWishlist: '正在添加愿望单',
  116. removeWishlist: '正在移除愿望单',
  117. followGame: '正在关注游戏',
  118. unfollowGame: '正在取关游戏',
  119. likeAnnouncements: '正在点赞通知',
  120. visitLink: '正在访问页面',
  121. unknown: '未知操作',
  122. joinGiveaway: '正在加入赠key...',
  123. needJoinGiveaway: '请检查是否已加入此赠key!',
  124. doing: '正在做任务',
  125. unknowntype: '未知任务类型',
  126. getIdFailed: '获取任务id失败!',
  127. loadAnnouncementFailed: '加载公告失败',
  128. checkConsole: ',详情请查看控制台',
  129. setting: '设置',
  130. visitUpdateText: '查看更新内容',
  131. cleanCache: '清理缓存',
  132. feedback: '提交建议/BUG',
  133. cleaning: '正在清理缓存...',
  134. readme: '脚本说明',
  135. updateSteamInfo: '更新Steam信息',
  136. updateSteamInfoComplete: 'Steam信息更新完成',
  137. cannotRemove: '没有可以移除的任务!',
  138. joinLotteryComplete: '所有抽奖参加完成!',
  139. noPoints: '点数不足,任务中止!',
  140. getNeedPointsFailed: '获取抽奖需要点数失败,任务中止!',
  141. joinLottery: '正在参加抽奖',
  142. pointsLeft: '剩余点数: ',
  143. getPointsFailed: '获取当前拥有点数失败!',
  144. joinFreeLottery: '参加免费抽奖',
  145. joinPointLottery: '参加点数抽奖',
  146. getTaskIdFailed: '获取 s% 任务id失败!',
  147. noAutoFinish: '没有检测到可以自动完成的任务!',
  148. finishSelf: '没完成的请手动完成!',
  149. getUrlFailed: '获取任务链接失败( s% )',
  150. closeExtensions: '建议关闭脚本管理器和广告屏蔽插件再获取key!',
  151. changeLanguage: '需要将页面语言设置为"English"或"Русский"(将页面右下角的自动翻译关闭)!如果已设置,请忽视本条信息',
  152. gkrobot: '请在弹出的页面完成验证(如果有的话),然后关闭页面',
  153. connectWss: '正在连接WSS...',
  154. connectWssWait: '正在连接WSS, 请稍候!',
  155. beforeFuck: '每次点击"Fuck"按钮前请手动完成人机验证!!!',
  156. getTaskStatus: '正在获取任务完成状态(时间稍长,请耐心等待)...',
  157. wssConnected: 'WSS已连接!',
  158. wssConnectSuccess: 'WSS连接成功',
  159. wssDisconnected: 'WSS连接断开!',
  160. wssReconnect: 'WSS连接断开,正在重连...',
  161. noLogin: '您尚未登录!',
  162. accessDenied: '访问被拒绝!',
  163. notFound: '错误,找不到页面!',
  164. serverError: '服务器错误!',
  165. errorRefresh: '错误,请刷新页面!',
  166. initFirst: '请先Init再做任务!',
  167. initPlease: '请先点击Init按钮再点此按钮!',
  168. getGroupFailed: '获取Steam组信息失败!',
  169. openPage: '已打开任务页面',
  170. getTaskUrlFailed: '获取任务链接失败',
  171. notRobot: '触发人机验证,请完成验证后再点击"Verify"按钮验证任务!',
  172. getVisitTimeFailed: '获取浏览时间失败',
  173. doYourself: '请手动完成',
  174. googleVerify: '谷歌验证',
  175. getKey: '获取key',
  176. fuckBtnTitle: '一键做任务+验证',
  177. verifyBtnTitle: '一键验证任务',
  178. joinBtnTitle: '一键加组、关注鉴赏家、关注游戏、添加愿望单...',
  179. removeBtnTitle: '一键退组、取关鉴赏家、取关游戏、移除愿望单...',
  180. showLog: '显示执行日志',
  181. hideLog: '隐藏执行日志',
  182. show: '展开',
  183. hide: '收起',
  184. taskLog: '任务执行日志',
  185. saveSetting: '保存设置',
  186. saveSuccess: '保存成功',
  187. resetSetting: '重置所有设置',
  188. resetSettingNotice: '是否重置所有设置?',
  189. resetSettingSuccess: '重置成功',
  190. resetSettingFailed: '重置失败',
  191. resetSettingCancel: '已取消重置',
  192. downloadSetting: '下载设置文件',
  193. processSetting: '正在处理设置...',
  194. creatUrlFailed: '创建下载链接失败!',
  195. loadSetting: '加载设置文件',
  196. readSetting: '正在读取设置文件...',
  197. readSettingComplete: '设置文件读取完成!',
  198. readSettingFailed: '读取设置文件失败!',
  199. loadSettingComplete: '设置加载完成!',
  200. loadSettingFailed: '设置加载失败',
  201. notSupport: '当前浏览器不支持直接读取文件,已触发备用方案!',
  202. copySetting: '请将设置文件里的内容复制到下面!',
  203. loadSettingText: '正在加载设置...',
  204. jsError: '脚本执行出错,详细信息请查看控制台(红色背景部分)!',
  205. ajaxError: 'Ajax请求出错',
  206. group: '加组',
  207. curator: '关注鉴赏家',
  208. developer: '关注开发商',
  209. publisher: '关注发行商',
  210. announcement: '点赞通知',
  211. wishlist: '加愿望单',
  212. fGame: '关注游戏',
  213. visit: '访问链接',
  214. verify: '验证任务',
  215. autoLogin: '自动登录',
  216. doTask: '做任务',
  217. autoLoginDes: '自动登录,第一次需要手动登录(仅适用于freegamelottery网站)',
  218. doTaskDes: '依次做"MAIN DRAW","SURVEY DRAW","VIDEO DRAW","STACKPOT"等任务',
  219. ungroup: '退组',
  220. uncurator: '取关鉴赏家',
  221. undeveloper: '取关开发商',
  222. unpublisher: '取关发行商',
  223. unwishlist: '移除愿望单',
  224. unfGame: '取关游戏',
  225. ungroupDes: '退出steam组(Group)',
  226. uncuratorDes: '取关steam鉴赏家(Curator)',
  227. undeveloperDes: '取关steam开发商(Developer)',
  228. unpublisherDes: '取关steam发行商(Publisher)',
  229. unwishlistDes: '将游戏移除愿望单(Wishlist)',
  230. unfGameDes: '取关游戏(Followed game)',
  231. showLogs: '默认显示日志',
  232. showDetails: '输出详细日志',
  233. checkLogin: '登录检测',
  234. checkLeft: '剩余key检测',
  235. autoOpen: '自动打开任务页面',
  236. autoCheckUpdate: '自动检测更新',
  237. reCaptcha: '人机验证修复',
  238. showLogsDes: '默认显示右下角任务日志',
  239. showDetailsDes: '控制台输出详细日志',
  240. checkLoginDes: '检测是否已登录,没登录则跳转到登录页面',
  241. checkLeftDes: '检测是否有剩余key,没有剩余key则提醒',
  242. autoOpenDes: '未完成的任务自动打开任务页面手动完成(需要关闭浏览器弹窗拦截)',
  243. reCaptchaDes: '如果Gamehag网站人机验证出错,请尝试打开/关闭此选项',
  244. globalSettings: '全局设置'
  245. },
  246. en: {
  247. language: 'Language',
  248. auto: 'Auto',
  249. needBanana: 'This key needs to collect s% banana, do you want to continue?',
  250. needPoints: 'This key needs to collect s%, do you want to continue?',
  251. notice: 'Notice',
  252. confirm: 'OK',
  253. cancel: 'Cancel',
  254. cancelled: 'Cancelled',
  255. processTasksInfo: 'Processing task information...',
  256. processTasksUrl: 'Processing task link (time depends on the number of Steam tasks, please be patient)...',
  257. getTasksInfo: 'Getting task information...',
  258. allTasksComplete: 'All tasks completed!',
  259. prysAllTasksComplete: 'All tasks are verified, please complete the man-machine verification to get the key!',
  260. verifyTasksComplete: 'All tasks verified!',
  261. verifyingTask: 'Verifying task',
  262. noKeysLeft: 'This page has no remaining keys, do you want to close?',
  263. logining: 'Logining...',
  264. needLogin: 'Login please!',
  265. fglTimeout: 'Doing "s%" (If there is no response for a long time, please open the console to view the error log)...',
  266. fglComplete: 'The task is completed and the page is being refreshed (if the page does not refresh automatically, please refresh it manually to view the results)...',
  267. checkingUpdate: 'Checking for updates...',
  268. checkUpdate: 'Check for updates',
  269. thisIsNew: 'The current script is the latest version!',
  270. updateNow: 'Update to ',
  271. newVer: 'New version available: ',
  272. getAnnouncement: 'Getting update announcement...',
  273. visitHistory: 'History',
  274. close: 'Close',
  275. websiteSetting: ' website settings',
  276. updateCommunityId: 'Updating Steam Community SessionID (for joining and leaving groups)...',
  277. updateStoreId: 'Updating Steam Store SessionID (for adding to wishlist, following game, following curator, etc.)...',
  278. loginSteamCommunity: 'Please log in to the <a href="https://steamcommunity.com/login/home" target="_blank">Steam Community</a>.',
  279. loginSteamStore: 'Please log in to the <a href="https://store.steampowered.com/login" target="_blank">Steam Store</a>.',
  280. joinGroup: 'Joining the Steam group',
  281. getGroupId: 'Getting Steam group ID',
  282. leaveGroup: 'Leaving Steam group',
  283. followCurator: 'Following curator',
  284. unfollowCurator: 'Unfollowing curator',
  285. getDeveloperId: 'Getting developer ID',
  286. followDeveloper: 'Following developer',
  287. unfollowDeveloper: 'Unfollowing developer',
  288. getPublisherId: 'Getting publisher ID',
  289. followPublisher: 'Following publisher',
  290. unfollowPublisher: 'Unfollowing publisher',
  291. addWishlist: 'Adding to wishlist',
  292. removeWishlist: 'Removing from wishlist',
  293. followGame: 'Following game',
  294. unfollowGame: 'Unfollowing gema',
  295. likeAnnouncements: 'Liking announcement',
  296. visitLink: 'Visiting page',
  297. unknown: 'Unknown operation',
  298. joinGiveaway: 'Joining giveaway...',
  299. needJoinGiveaway: 'Please check if this giveaway has been joined!',
  300. doing: 'Doing task',
  301. unknowntype: 'Unknown task type',
  302. getIdFailed: 'Failed to get task id!',
  303. loadAnnouncementFailed: 'Loading announcement failed',
  304. checkConsole: ', see console for details',
  305. setting: 'Setting',
  306. visitUpdateText: 'View updates',
  307. cleanCache: 'Clear cache',
  308. feedback: 'Feedback',
  309. cleaning: 'Clearing cache...',
  310. readme: 'Script description',
  311. updateSteamInfo: 'Update Steam Information',
  312. updateSteamInfoComplete: 'Steam information update completed',
  313. cannotRemove: 'No tasks can be removed!',
  314. joinLotteryComplete: 'All giveaways have been joined!',
  315. noPoints: 'Not enough points, task aborted!',
  316. getNeedPointsFailed: 'Failed to get points for joining giveaway, task aborted!',
  317. joinLottery: 'Joining giveaway',
  318. pointsLeft: 'Points remaining: ',
  319. getPointsFailed: 'Failed to get points currently owned!',
  320. joinFreeLottery: 'Join free giveaway',
  321. joinPointLottery: 'Join points giveaway',
  322. getTaskIdFailed: 'Failed to get s% task id!',
  323. noAutoFinish: 'No tasks detected that could be done automatically!',
  324. finishSelf: 'Unfinished tasks please do it yourself!',
  325. getUrlFailed: 'Failed to get task link( s% )',
  326. closeExtensions: 'It is recommended to close the script manager and the ad blocking plugin before obtaining the key!',
  327. changeLanguage: 'Need to set the page language to "English" or "Русский" (Turn off automatic translation in the bottom right corner of the page)! If it is set to "English" or "Русский", please ignore this message.',
  328. gkrobot: 'Please complete the verification on the pop-up page (if any), and then close the page.',
  329. connectWss: 'Connecting to WSS...',
  330. connectWssWait: 'Connecting to WSS, please wait!',
  331. beforeFuck: 'Please complete the verification before clicking the "Fuck" button!!!',
  332. getTaskStatus: 'Getting task completion status (a little longer, please be patient)...',
  333. wssConnected: 'WSS is connected!',
  334. wssConnectSuccess: 'WSS connection succeeded',
  335. wssDisconnected: 'WSS is disconnected!',
  336. wssReconnect: 'WSS is disconnected, reconnecting...',
  337. noLogin: 'You have not logged in!',
  338. accessDenied: 'Access denied!',
  339. notFound: 'Error, page not found!',
  340. serverError: 'Server error!',
  341. errorRefresh: 'Error, please refresh the page!',
  342. initFirst: 'Please Init before doing the task!',
  343. initPlease: 'Please click the Init button before clicking this button!',
  344. getGroupFailed: 'Failed to get Steam group information!',
  345. openPage: 'Task page opened',
  346. getTaskUrlFailed: 'Failed to get task link',
  347. notRobot: 'Trigger human-machine verification, please complete the verification and then click the "Verify" button to verify the task',
  348. getVisitTimeFailed: 'Failed to get visit time',
  349. doYourself: 'Please complete ',
  350. googleVerify: 'Google verification',
  351. getKey: ' to get key',
  352. fuckBtnTitle: 'Complete and verify tasks',
  353. verifyBtnTitle: 'Verify tasks',
  354. joinBtnTitle: 'Join group, follow curator, follow game, add to wishlist...',
  355. removeBtnTitle: 'Leave group, unfollow curator, unfollow game, remove from wishlist...',
  356. showLog: 'Show execution log',
  357. hideLog: 'Hide execution log',
  358. show: 'Show',
  359. hide: 'Hide',
  360. taskLog: 'Task execution log',
  361. saveSetting: 'Save settings',
  362. saveSuccess: 'Saved successfully',
  363. resetSetting: 'Reset all settings',
  364. resetSettingNotice: 'Do you want to reset all settings?',
  365. resetSettingSuccess: 'Reset succeeded',
  366. resetSettingFailed: 'Reset failed',
  367. resetSettingCancel: 'Canceled reset',
  368. downloadSetting: 'Download the settings file',
  369. processSetting: 'Processing settings...',
  370. creatUrlFailed: 'Failed to create download link!',
  371. loadSetting: 'Load settings file',
  372. readSetting: 'Reading settings file...',
  373. readSettingComplete: 'Setting file read completed!',
  374. readSettingFailed: 'Failed to read the settings file!',
  375. loadSettingComplete: 'Settings are loaded!',
  376. loadSettingFailed: 'Failed to load settings',
  377. notSupport: 'The current browser does not support reading files directly, an alternative has been triggered!',
  378. copySetting: 'Please copy the contents of the settings file to the following',
  379. loadSettingText: 'Loading settings...',
  380. jsError: 'Script execution error, please see the console for details (red background part)!',
  381. ajaxError: 'Ajax request error',
  382. group: 'Join group',
  383. curator: 'Follow curator',
  384. developer: 'Follow developer',
  385. publisher: 'Follow publisher',
  386. announcement: 'Like announcement',
  387. wishlist: 'Add to wishlist',
  388. fGame: 'Follow game',
  389. visit: 'Visit link',
  390. verify: 'Verify',
  391. autoLogin: 'Auto login',
  392. doTask: 'Do the task',
  393. autoLoginDes: 'Automatic login, manual login required for the first time (only for freegamelottery website)',
  394. doTaskDes: 'Do "MAIN DRAW", "SURVEY DRAW", "VIDEO DRAW", and "STACKPOT" tasks in that order',
  395. ungroup: 'Leave group',
  396. uncurator: 'Unfollow curator',
  397. undeveloper: 'Unfollow developer',
  398. unpublisher: 'Unfollow publisher',
  399. unwishlist: 'Remove from wishlist',
  400. unfGame: 'Unfollow game',
  401. ungroupDes: 'Leave the steam group',
  402. uncuratorDes: 'Unfollow the steam curator',
  403. undeveloperDes: 'Unfollow the steam developer',
  404. unpublisherDes: 'Unfollow the steam publisher',
  405. unwishlistDes: 'Remove game from wishlist',
  406. unfGameDes: 'Unfollow game',
  407. showLogs: 'Show logs',
  408. showDetails: 'Output verbose logs',
  409. checkLogin: 'Login check',
  410. checkLeft: 'Remaining key check',
  411. autoOpen: 'Open task page automatically',
  412. autoCheckUpdate: 'Check for updates automatically',
  413. reCaptcha: 'Repair reCaptcha',
  414. showLogsDes: 'Show task log in bottom right corner by default',
  415. showDetailsDes: 'Output verbose logs to the console',
  416. checkLoginDes: 'Check if you are logged in, jump to login page if not logged in',
  417. checkLeftDes: 'Check if there are remaining keys, and remind if there are no remaining keys',
  418. autoOpenDes: 'Unfinished tasks automatically open the task page for manual completion (requires closing the browser pop-up block)',
  419. reCaptchaDes: 'If the Gamehag website has an ergonomic error, try turning this option on / off',
  420. globalSettings: 'Global Settings'
  421. }
  422. }
  423. let language = getLanguage()
  424. function getLanguage () {
  425. let lan = GM_getValue('language') || 'auto'
  426. if (lan === 'auto') {
  427. const browserLanguage = (navigator.browserLanguage || navigator.language).toLowerCase()
  428. lan = browserLanguage.includes('en') ? 'en' : 'zh-cn'
  429. }
  430. return lan
  431. }
  432. function getI18n (name, str = null) {
  433. let value = 'null'
  434. if (str) value = i18n[language][name] ? i18n[language][name].replace('s%', str) : 'null'
  435. else value = i18n[language][name] || 'null'
  436. return value
  437. }
  438.  
  439. GM_addStyle(GM_getResourceText('css'))
  440. $('body').append('<div v-cloak id="vue-ui"></div>')
  441. const vueUi = new Vue({ el: '#vue-ui' })
  442. Vue.config.errorHandler = function (err, vm, info) {
  443. setTimeout(() => {
  444. vueUi.$message({ type: 'error', duration: 0, message: getI18n('jsError'), showClose: true })
  445. }, 500)
  446. console.log('%c%s', 'color:white;background:red', 'Info:' + info + '\nError:' + err.stack)
  447. }
  448. $(document).ajaxError(function (event, xhr, options, exc) {
  449. vueUi.$message({ type: 'error', duration: 0, message: getI18n('jsError'), showClose: true })
  450. console.log('%c%s', 'color:white;background:red', getI18n('ajaxError') + ':')
  451. console.log('Event:', event)
  452. console.log('XMLHttpRequest :', xhr)
  453. console.log('Options:', options)
  454. console.log('JavaScript exception:', exc)
  455. })
  456.  
  457. try {
  458. const steamInfo = GM_getValue('steamInfo') || {
  459. userName: '',
  460. steam64Id: '',
  461. communitySessionID: '',
  462. storeSessionID: '',
  463. updateTime: 0
  464. }
  465. const defaultConf = {
  466. fuck: {
  467. group: 1,
  468. curator: 1,
  469. developer: 1,
  470. publisher: 1,
  471. announcement: 1,
  472. wishlist: 1,
  473. followGame: 1,
  474. visit: 1,
  475. verify: 1
  476. },
  477. verify: {
  478. verify: 1
  479. },
  480. join: {
  481. group: 1,
  482. curator: 1,
  483. developer: 1,
  484. publisher: 1,
  485. announcement: 1,
  486. wishlist: 1,
  487. followGame: 1,
  488. visit: 1
  489. },
  490. remove: {
  491. group: 1,
  492. curator: 1,
  493. developer: 1,
  494. publisher: 1,
  495. wishlist: 1,
  496. followGame: 1
  497. },
  498. other: {
  499. showLogs: 1,
  500. showDetails: 0,
  501. checkLogin: 1,
  502. checkLeft: 1,
  503. autoOpen: 0,
  504. reCaptcha: 0
  505. },
  506. announcement: ''
  507. }
  508. const globalConf = (GM_getValue('conf') && GM_getValue('conf').global) ? GM_getValue('conf').global : defaultConf
  509. const debug = !!globalConf.other.showDetails
  510. const fuc = {
  511. httpRequest: function (e) {
  512. const requestObj = {}
  513. requestObj.url = e.url
  514. requestObj.method = e.method.toUpperCase()
  515. requestObj.timeout = e.timeout || 30000
  516. if (e.dataType) requestObj.responseType = e.dataType
  517. if (e.headers) requestObj.headers = e.headers
  518. if (e.data) requestObj.data = e.data
  519. if (e.onload) requestObj.onload = e.onload
  520. requestObj.ontimeout = e.ontimeout || function (data) {
  521. if (debug) console.log(data)
  522. if (e.status) e.status.error('Error:Timeout(0)')
  523. if (e.r) e.r({ result: 'error', statusText: 'Timeout', status: 0, option: e })
  524. }
  525. requestObj.onabort = e.onabort || function (data) {
  526. if (debug) console.log(data)
  527. if (e.status) e.status.error('Error:Aborted(0)')
  528. if (e.r) e.r({ result: 'error', statusText: 'Aborted', status: 0, option: e })
  529. }
  530. requestObj.onerror = e.onerror || function (data) {
  531. if (debug) console.log(data)
  532. if (e.status) e.status.error('Error:Error(0)')
  533. if (e.r) e.r({ result: 'error', statusText: 'Error', status: 0, option: e })
  534. }
  535. if (debug) console.log('发送请求:', requestObj)
  536. GM_xmlhttpRequest(requestObj)
  537. },
  538. updateSteamInfo: function (r, type = 'all', update = false) {
  539. if (new Date().getTime() - steamInfo.updateTime > 10 * 60 * 1000 || update) {
  540. const pro = []
  541. if (type === 'community' || type === 'all') {
  542. pro.push(new Promise((resolve, reject) => {
  543. const status = this.echoLog({ type: 'updateSteamCommunity' })
  544. this.httpRequest({
  545. url: 'https://steamcommunity.com/my',
  546. method: 'GET',
  547. onload: (response) => {
  548. if (debug) console.log(response)
  549. if (response.status === 200) {
  550. if ($(response.responseText).find('a[href*="/login/home"]').length > 0) {
  551. status.error('Error:' + getI18n('loginSteamCommunity'), true)
  552. reject(Error('Not Login'))
  553. } else {
  554. const steam64Id = response.responseText.match(/g_steamID = "(.+?)";/)
  555. const communitySessionID = response.responseText.match(/g_sessionID = "(.+?)";/)
  556. const userName = response.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)
  557. if (steam64Id) steamInfo.steam64Id = steam64Id[1]
  558. if (communitySessionID) steamInfo.communitySessionID = communitySessionID[1]
  559. if (userName) steamInfo.userName = userName[1]
  560. status.success()
  561. resolve()
  562. }
  563. } else {
  564. status.error('Error:' + response.statusText + '(' + response.status + ')')
  565. reject(Error('Request Failed'))
  566. }
  567. },
  568. r: resolve,
  569. status
  570. })
  571. }))
  572. }
  573. if (type === 'store' || type === 'all') {
  574. pro.push(new Promise((resolve, reject) => {
  575. const status = this.echoLog({ type: 'updateSteamStore' })
  576.  
  577. this.httpRequest({
  578. url: 'https://store.steampowered.com/stats/',
  579. method: 'GET',
  580. onload: (response) => {
  581. if (debug) console.log(response)
  582. if (response.status === 200) {
  583. if ($(response.responseText).find('a[href*="/login/"]').length > 0) {
  584. status.error('Error:' + getI18n('loginSteamStore'), true)
  585. reject(Error('Not Login'))
  586. } else {
  587. const storeSessionID = response.responseText.match(/g_sessionID = "(.+?)";/)
  588. if (storeSessionID) steamInfo.storeSessionID = storeSessionID[1]
  589. status.success()
  590. resolve()
  591. }
  592. } else {
  593. status.error('Error:' + response.statusText + '(' + response.status + ')')
  594. reject(Error('Request Failed'))
  595. }
  596. },
  597. r: resolve,
  598. status
  599. })
  600. }))
  601. }
  602. Promise.all(pro).then(() => {
  603. steamInfo.updateTime = new Date().getTime()
  604. GM_setValue('steamInfo', steamInfo)
  605. r(1)
  606. }).catch(err => {
  607. console.error(err)
  608. })
  609. } else {
  610. r(1)
  611. }
  612. },
  613. joinSteamGroup: function (r, group) {
  614. const status = this.echoLog({ type: 'joinSteamGroup', text: group })
  615.  
  616. this.httpRequest({
  617. url: 'https://steamcommunity.com/groups/' + group,
  618. method: 'POST',
  619. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  620. data: $.param({ action: 'join', sessionID: steamInfo.communitySessionID }),
  621. onload: (response) => {
  622. if (debug) console.log(response)
  623. if (response.status === 200 && !response.responseText.includes('grouppage_join_area')) {
  624. status.success()
  625. r({ result: 'success', statusText: response.statusText, status: response.status })
  626. } else {
  627. status.error('Error:' + response.statusText + '(' + response.status + ')')
  628. r({ result: 'error', statusText: response.statusText, status: response.status })
  629. }
  630. },
  631. r,
  632. status
  633. })
  634. },
  635. getGroupID: function (groupName, callback) {
  636. const status = this.echoLog({ type: 'getGroupId', text: groupName })
  637. const groupNameToId = GM_getValue('groupNameToId') || {}
  638. if (groupNameToId[groupName]) {
  639. status.success()
  640. callback(groupName, groupNameToId[groupName])
  641. } else {
  642. new Promise(resolve => {
  643. this.httpRequest({
  644. url: 'https://steamcommunity.com/groups/' + groupName,
  645. method: 'GET',
  646. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  647. onload: function (response) {
  648. if (debug) console.log(response)
  649. if (response.status === 200) {
  650. const groupId = response.responseText.match(/OpenGroupChat\( '([0-9]+)'/)
  651. if (groupId === null) {
  652. status.error('Error:' + response.statusText + '(' + response.status + ')')
  653. resolve(false)
  654. } else {
  655. status.success()
  656. groupNameToId[groupName] = groupId[1]
  657. GM_setValue('groupNameToId', groupNameToId)
  658. resolve(groupId[1])
  659. }
  660. } else {
  661. status.error('Error:' + response.statusText + '(' + response.status + ')')
  662. resolve(false)
  663. }
  664. },
  665. status,
  666. r: () => {
  667. resolve(false)
  668. }
  669. })
  670. }).then(groupId => {
  671. if (groupId !== false && callback) callback(groupName, groupId)
  672. }).catch(err => {
  673. console.error(err)
  674. })
  675. }
  676. },
  677. leaveSteamGroup: function (r, groupName) {
  678. this.getGroupID(groupName, (groupName, groupId) => {
  679. const status = this.echoLog({ type: 'leaveSteamGroup', text: groupName })
  680.  
  681. this.httpRequest({
  682. url: 'https://steamcommunity.com/id/' + steamInfo.userName + '/home_process',
  683. method: 'POST',
  684. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  685. data: $.param({ sessionID: steamInfo.communitySessionID, action: 'leaveGroup', groupId: groupId }),
  686. onload: (response) => {
  687. if (debug) console.log(response)
  688. if (response.status === 200 && response.finalUrl.includes('groups') && $(response.responseText.toLowerCase()).find(`a[href='https://steamcommunity.com/groups/${groupName.toLowerCase()}']`).length === 0) {
  689. status.success()
  690. r({ result: 'success', statusText: response.statusText, status: response.status })
  691. } else {
  692. status.error('Error:' + response.statusText + '(' + response.status + ')')
  693. r({ result: 'error', statusText: response.statusText, status: response.status })
  694. }
  695. },
  696. r,
  697. status
  698. })
  699. })
  700. },
  701. followCurator: function (r, curatorId, follow = '1', status = '') {
  702. status = status || this.echoLog({ type: follow === '1' ? 'followCurator' : 'unfollowCurator', text: curatorId })
  703.  
  704. this.httpRequest({
  705. url: 'https://store.steampowered.com/curators/ajaxfollow',
  706. method: 'POST',
  707. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  708. data: $.param({ clanid: curatorId, sessionid: steamInfo.storeSessionID, follow: follow }),
  709. dataType: 'json',
  710. onload: (response) => {
  711. if (debug) console.log(response)
  712. if (response.status === 200 && response.response && response.response.success && response.response.success.success === 1) {
  713. status.success()
  714. r({ result: 'success', statusText: response.statusText, status: response.status })
  715. } else {
  716. status.error(`Error:${response.response.msg || response.statusText}(${response.response.success || response.status})`)
  717. r({ result: 'error', statusText: response.statusText, status: response.status })
  718. }
  719. },
  720. r,
  721. status
  722. })
  723. },
  724. unfollowCurator: function (r, curatorId) {
  725. this.followCurator(r, curatorId, '0')
  726. },
  727. getCuratorID: function (developerName, callback, isPublisher = 0) {
  728. const status = this.echoLog({ type: isPublisher ? 'getPublisherId' : 'getDeveloperId', text: developerName })
  729. const developerNameToId = GM_getValue('developerNameToId') || {}
  730. if (developerNameToId[developerName]) {
  731. status.success()
  732. callback(developerName, developerNameToId[developerName])
  733. } else {
  734. new Promise(resolve => {
  735. this.httpRequest({
  736. url: `https://store.steampowered.com/${isPublisher ? 'publisher' : 'developer'}/${developerName}`,
  737. method: 'GET',
  738. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  739. onload: function (response) {
  740. if (debug) console.log(response)
  741. if (response.status === 200) {
  742. const developerId = response.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)
  743. if (developerId === null) {
  744. status.error('Error:' + response.statusText + '(' + response.status + ')')
  745. resolve(false)
  746. } else {
  747. status.success()
  748. developerNameToId[developerName] = developerId[1]
  749. GM_setValue('developerNameToId', developerNameToId)
  750. resolve(developerId[1])
  751. }
  752. } else {
  753. status.error('Error:' + response.statusText + '(' + response.status + ')')
  754. resolve(false)
  755. }
  756. },
  757. status,
  758. r: () => { resolve(false) }
  759. })
  760. }).then(curatorId => {
  761. if (curatorId !== false && callback) callback(developerName, curatorId)
  762. }).catch(err => {
  763. console.error(err)
  764. })
  765. }
  766. },
  767. followDeveloper: function (r, developerName, isPublisher = 0) {
  768. this.getCuratorID(developerName, (developerName, curatorId) => {
  769. const status = this.echoLog({ type: isPublisher ? 'followPublisher' : 'followDeveloper', text: developerName })
  770. this.followCurator(r, curatorId, '1', status)
  771. }, isPublisher)
  772. },
  773. unfollowDeveloper: function (r, developerName, isPublisher = 0) {
  774. this.getCuratorID(developerName, (developerName, curatorId) => {
  775. const status = this.echoLog({ type: isPublisher ? 'unfollowPublisher' : 'unfollowDeveloper', text: developerName })
  776. this.followCurator(r, curatorId, '0', status)
  777. }, isPublisher)
  778. },
  779. followPublisher: function (r, publisherName) {
  780. this.followDeveloper(r, publisherName, 1)
  781. },
  782. unfollowPublisher: function (r, publisherName) {
  783. this.unfollowDeveloper(r, publisherName, 1)
  784. },
  785. addWishlist: function (r, gameId) {
  786. const status = this.echoLog({ type: 'addWishlist', text: gameId })
  787. new Promise(resolve => {
  788. this.httpRequest({
  789. url: 'https://store.steampowered.com/api/addtowishlist',
  790. method: 'POST',
  791. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  792. data: $.param({ sessionid: steamInfo.storeSessionID, appid: gameId }),
  793. dataType: 'json',
  794. onload: function (response) {
  795. if (debug) console.log(response)
  796. if (response.status === 200 && response.response && response.response.success === true) {
  797. status.success()
  798. resolve({ result: 'success', statusText: response.statusText, status: response.status })
  799. } else {
  800. resolve({ result: 'error', statusText: response.statusText, status: response.status })
  801. }
  802. },
  803. onabort: response => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  804. onerror: response => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  805. ontimeout: response => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  806. r: resolve,
  807. status
  808. })
  809. }).then(result => {
  810. if (result.result === 'success') {
  811. r(result)
  812. } else {
  813. this.httpRequest({
  814. url: 'https://store.steampowered.com/app/' + gameId,
  815. method: 'GET',
  816. onload: function (response) {
  817. if (debug) console.log(response)
  818. if (response.status === 200) {
  819. if (response.responseText.includes('class="queue_actions_ctn"') && response.responseText.includes('已在库中')) {
  820. status.success()
  821. r({ result: 'success', statusText: response.statusText, status: response.status, own: true })
  822. } else if ((response.responseText.includes('class="queue_actions_ctn"') && response.responseText.includes('添加至您的愿望单')) || !response.responseText.includes('class="queue_actions_ctn"')) {
  823. status.error('Error:' + result.statusText + '(' + result.status + ')')
  824. r({ result: 'error', statusText: response.statusText, status: response.status })
  825. } else {
  826. status.success()
  827. r({ result: 'success', statusText: response.statusText, status: response.status })
  828. }
  829. } else {
  830. status.error('Error:' + result.statusText + '(' + result.status + ')')
  831. r({ result: 'error', statusText: response.statusText, status: response.status })
  832. }
  833. },
  834. r,
  835. status
  836. })
  837. }
  838. }).catch(err => {
  839. console.error(err)
  840. })
  841. },
  842. removeWishlist: function (r, gameId) {
  843. const status = this.echoLog({ type: 'removeWishlist', text: gameId })
  844. new Promise(resolve => {
  845. this.httpRequest({
  846. url: 'https://store.steampowered.com/api/removefromwishlist',
  847. method: 'POST',
  848. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  849. data: $.param({ sessionid: steamInfo.storeSessionID, appid: gameId }),
  850. dataType: 'json',
  851. onload: function (response) {
  852. if (debug) console.log(response)
  853. if (response.status === 200 && response.response && response.response.success === true) {
  854. status.success()
  855. resolve({ result: 'success', statusText: response.statusText, status: response.status })
  856. } else {
  857. resolve({ result: 'error', statusText: response.statusText, status: response.status })
  858. }
  859. },
  860. onabort: (response) => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  861. onerror: (response) => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  862. ontimeout: (response) => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  863. r: resolve,
  864. status
  865. })
  866. }).then(result => {
  867. if (result.result === 'success') {
  868. r(result)
  869. } else {
  870. this.httpRequest({
  871. url: 'https://store.steampowered.com/app/' + gameId,
  872. method: 'GET',
  873. onload: function (response) {
  874. if (debug) console.log(response)
  875. if (response.status === 200) {
  876. if (response.responseText.includes('class="queue_actions_ctn"') && (response.responseText.includes('已在库中') || response.responseText.includes('添加至您的愿望单'))) {
  877. status.success()
  878. r({ result: 'success', statusText: response.statusText, status: response.status })
  879. } else {
  880. status.error('Error:' + result.statusText + '(' + result.status + ')')
  881. r({ result: 'error', statusText: response.statusText, status: response.status })
  882. }
  883. } else {
  884. status.error('Error:' + result.statusText + '(' + result.status + ')')
  885. r({ result: 'error', statusText: response.statusText, status: response.status })
  886. }
  887. },
  888. r,
  889. status
  890. })
  891. }
  892. }).catch(err => {
  893. console.error(err)
  894. })
  895. },
  896. followGame: function (r, gameId) {
  897. const status = this.echoLog({ type: 'followGame', text: gameId })
  898. new Promise(resolve => {
  899. this.httpRequest({
  900. url: 'https://store.steampowered.com/explore/followgame/',
  901. method: 'POST',
  902. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  903. data: $.param({ sessionid: steamInfo.storeSessionID, appid: gameId }),
  904. onload: function (response) {
  905. if (debug) console.log(response)
  906. if (response.status === 200 && response.responseText === 'true') {
  907. status.success()
  908. resolve({ result: 'success', statusText: response.statusText, status: response.status })
  909. } else {
  910. resolve({ result: 'error', statusText: response.statusText, status: response.status })
  911. }
  912. },
  913. onabort: (response) => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  914. onerror: (response) => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  915. ontimeout: (response) => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  916. r: resolve,
  917. status
  918. })
  919. }).then(result => {
  920. if (result.result === 'success') {
  921. r(result)
  922. } else {
  923. this.httpRequest({
  924. url: 'https://store.steampowered.com/app/' + gameId,
  925. method: 'GET',
  926. onload: function (response) {
  927. if (debug) console.log(response)
  928. if (response.status === 200) {
  929. if (response.responseText.includes('class="queue_actions_ctn"') && response.responseText.includes('class="btnv6_blue_hoverfade btn_medium queue_btn_active" style="">')) {
  930. status.success()
  931. r({ result: 'success', statusText: response.statusText, status: response.status })
  932. } else {
  933. status.error('Error:' + result.statusText + '(' + result.status + ')')
  934. r({ result: 'error', statusText: response.statusText, status: response.status })
  935. }
  936. } else {
  937. status.error('Error:' + result.statusText + '(' + result.status + ')')
  938. r({ result: 'error', statusText: response.statusText, status: response.status })
  939. }
  940. },
  941. r,
  942. status
  943. })
  944. }
  945. }).catch(err => {
  946. console.error(err)
  947. })
  948. },
  949. unfollowGame: function (r, gameId) {
  950. const status = this.echoLog({ type: 'unfollowGame', text: gameId })
  951. new Promise(resolve => {
  952. this.httpRequest({
  953. url: 'https://store.steampowered.com/explore/followgame/',
  954. method: 'POST',
  955. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  956. data: $.param({ sessionid: steamInfo.storeSessionID, appid: gameId, unfollow: '1' }),
  957. onload: function (response) {
  958. if (debug) console.log(response)
  959. if (response.status === 200 && response.responseText === 'true') {
  960. status.success()
  961. resolve({ result: 'success', statusText: response.statusText, status: response.status })
  962. } else {
  963. resolve({ result: 'error', statusText: response.statusText, status: response.status })
  964. }
  965. },
  966. onabort: (response) => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  967. onerror: (response) => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  968. ontimeout: (response) => { resolve({ result: 'error', statusText: response.statusText, status: response.status }) },
  969. r: resolve,
  970. status
  971. })
  972. }).then(result => {
  973. if (result.result === 'success') {
  974. r(result)
  975. } else {
  976. this.httpRequest({
  977. url: 'https://store.steampowered.com/app/' + gameId,
  978. method: 'GET',
  979. onload: function (response) {
  980. if (debug) console.log(response)
  981. if (response.status === 200) {
  982. if (response.responseText.includes('class="queue_actions_ctn"') && response.responseText.includes('class="btnv6_blue_hoverfade btn_medium queue_btn_active" style="">')) {
  983. status.error('Error:' + result.statusText + '(' + result.status + ')')
  984. r({ result: 'error', statusText: response.statusText, status: response.status })
  985. } else {
  986. status.success()
  987. r({ result: 'success', statusText: response.statusText, status: response.status })
  988. }
  989. } else {
  990. status.error('Error:' + result.statusText + '(' + result.status + ')')
  991. r({ result: 'error', statusText: response.statusText, status: response.status })
  992. }
  993. },
  994. r,
  995. status
  996. })
  997. }
  998. }).catch(err => {
  999. console.error(err)
  1000. })
  1001. },
  1002. likeAnnouncements: function (r, url, id) {
  1003. const status = this.echoLog({ type: 'likeAnnouncements', url, id })
  1004.  
  1005. this.httpRequest({
  1006. url: url.replace('/detail/', '/rate/'),
  1007. method: 'POST',
  1008. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  1009. data: $.param({ sessionid: steamInfo.communitySessionID, voteup: true }),
  1010. dataType: 'json',
  1011. onload: (response) => {
  1012. if (debug) console.log(response)
  1013. if (response.status === 200 && response.response && response.response.success === 1) {
  1014. status.success()
  1015. r({ result: 'success', statusText: response.statusText, status: response.status })
  1016. } else {
  1017. status.error(`Error:${response.response.msg || response.statusText}(${response.response.success || response.status})`)
  1018. r({ result: 'error', statusText: response.statusText, status: response.status })
  1019. }
  1020. },
  1021. r,
  1022. status
  1023. })
  1024. },
  1025. getFinalUrl: function (r, url, options = {}) {
  1026. const conf = {
  1027. url: options.url || url,
  1028. method: options.method || 'GET',
  1029. onload: (response) => {
  1030. r({ result: 'success', finalUrl: response.finalUrl, url })
  1031. },
  1032. r
  1033. }
  1034. if (options.headers) conf.headers = options.headers
  1035. if (options.data) conf.data = options.data
  1036. this.httpRequest(conf)
  1037. },
  1038. visitLink: function (r, url, options = {}) {
  1039. if (!options.method) options.method = 'HEAD'
  1040. const status = this.echoLog({ type: 'visitLink', text: url })
  1041. new Promise(resolve => {
  1042. this.getFinalUrl(resolve, url, options)
  1043. }).then(() => {
  1044. status.warning('Complete')
  1045. r(1)
  1046. }).catch(err => {
  1047. console.error(err)
  1048. })
  1049. },
  1050. checkUpdate: function (v, s = false) {
  1051. v.icon = 'el-icon-loading'
  1052. let status = false
  1053. if (s) status = this.echoLog({ type: 'custom', text: `<li>${getI18n('checkingUpdate')}<font></font></li>` })
  1054. this.httpRequest({
  1055. url: 'https://userjs.hclonely.com/version?t=' + new Date().getTime(),
  1056. method: 'get',
  1057. dataType: 'json',
  1058. onload: (response) => {
  1059. if (debug) console.log(response)
  1060. if (response.response && response.response.version === GM_info.script.version) {
  1061. v.icon = 'el-icon-refresh'
  1062. v.title = getI18n('checkUpdate')
  1063. if (s) status.success(getI18n('thisIsNew'))
  1064. v.hidden = true
  1065. } else if (response.response) {
  1066. v.icon = 'el-icon-download'
  1067. v.title = getI18n('updateNow') + response.response.version
  1068. v.checkUpdate = function () { window.open('https://userjs.hclonely.com/auto-task.user.js', '_blank') }
  1069. if (s) status.success(getI18n('newVer') + response.response.version)
  1070. v.hidden = false
  1071. } else {
  1072. v.icon = 'el-icon-refresh'
  1073. v.title = getI18n('checkUpdate')
  1074. if (s) status.error('Error:' + (response.statusText || response.status))
  1075. }
  1076. const conf = GM_getValue('conf') || defaultConf
  1077. if (response.response && response.response.time !== conf.announcement) {
  1078. v.announcementHidden = false
  1079. conf.announcement = response.response.time
  1080. GM_setValue('conf', conf)
  1081. }
  1082. },
  1083. ontimeout: (response) => {
  1084. if (debug) console.log(response)
  1085. v.icon = 'el-icon-refresh'
  1086. v.title = getI18n('checkUpdate')
  1087. if (s) status.error('Error:Timeout(0)')
  1088. },
  1089. onabort: (response) => {
  1090. if (debug) console.log(response)
  1091. v.icon = 'el-icon-refresh'
  1092. v.title = getI18n('checkUpdate')
  1093. if (s) status.error('Error:Abort(0)')
  1094. },
  1095. onerror: (response) => {
  1096. if (debug) console.log(response)
  1097. v.icon = 'el-icon-refresh'
  1098. v.title = getI18n('checkUpdate')
  1099. if (s) status.error('Error:Error(0)')
  1100. },
  1101. status
  1102. })
  1103. },
  1104. getAnnouncement: function (v) {
  1105. v.announcementIcon = 'el-icon-loading'
  1106. const status = this.echoLog({ type: 'custom', text: `<li>${getI18n('getAnnouncement')}<font></font></li>` })
  1107. this.httpRequest({
  1108. url: 'https://userjs.hclonely.com/new.json?t=' + new Date().getTime(),
  1109. method: 'get',
  1110. dataType: 'json',
  1111. onload: (response) => {
  1112. if (debug) console.log(response)
  1113. if (response.responseText && response.response) {
  1114. status.success()
  1115. const data = response.response
  1116. const conf = GM_getValue('conf') || defaultConf
  1117. conf.announcement = data.time
  1118. GM_setValue('conf', conf)
  1119. v.announcementHidden = true
  1120. const h = vueUi.$createElement
  1121. const hArr = []
  1122. for (const index in data.text) {
  1123. if (/^[\d]+$/.test(index)) hArr.push(h('p', null, `${parseInt(index) + 1}.${data.text[index]}`))
  1124. }
  1125. vueUi.$msgbox({
  1126. title: `V${data.version}(${fuc.dateFormat('YYYY-mm-dd HH:MM', new Date(data.time))})`,
  1127. message: h('div', null, hArr),
  1128. showCancelButton: true,
  1129. confirmButtonText: getI18n('visitHistory'),
  1130. cancelButtonText: getI18n('close')
  1131. }).then(() => {
  1132. window.open('https://userjs.hclonely.com/announcement.html', '_blank')
  1133. }).catch(() => { })
  1134. } else {
  1135. status.error('Error:' + (response.statusText || response.status))
  1136. }
  1137. v.announcementIcon = 'el-icon-document'
  1138. },
  1139. ontimeout: (response) => {
  1140. if (debug) console.log(response)
  1141. v.announcementIcon = 'el-icon-document'
  1142. status.error('Error:Timeout(0)')
  1143. },
  1144. onabort: (response) => {
  1145. if (debug) console.log(response)
  1146. v.announcementIcon = 'el-icon-document'
  1147. status.error('Error:Abort(0)')
  1148. },
  1149. onerror: (response) => {
  1150. if (debug) console.log(response)
  1151. v.announcementIcon = 'el-icon-document'
  1152. status.error('Error:Error(0)')
  1153. },
  1154. status
  1155. })
  1156. },
  1157. newTabBlock: function () {
  1158. const d = new Date()
  1159. const cookiename = 'haveVisited1'
  1160. document.cookie = cookiename + '=1; path=/'
  1161. document.cookie = cookiename + '=' + (d.getUTCMonth() + 1) + '/' + d.getUTCDate() + '/' + d.getUTCFullYear() + '; path=/'
  1162. },
  1163. creatSetting: function (settingName, header, fuckOptions, checkedFucks, removeOptions, checkedRemoves) {
  1164. new Vue({ // eslint-disable-line no-new
  1165. el: `#${settingName}`,
  1166. data: {
  1167. header: `${header} ${getI18n('websiteSetting')}`,
  1168. checked: GM_getValue('conf') ? GM_getValue('conf')[settingName] ? (!!GM_getValue('conf')[settingName].load) : false : false,
  1169. fuck: {
  1170. checkAll: fuckOptions.length === checkedFucks.length,
  1171. checkedFucks: checkedFucks,
  1172. fucks: fuckOptions,
  1173. isIndeterminate: fuckOptions.length !== checkedFucks.length
  1174. },
  1175. remove: {
  1176. checkAll: removeOptions.length === checkedRemoves.length,
  1177. checkedRemoves: checkedRemoves,
  1178. removes: removeOptions,
  1179. isIndeterminate: removeOptions.length !== checkedRemoves.length
  1180. },
  1181. openDelay: 100,
  1182. rowType: 'flex',
  1183. rowAlign: 'middle',
  1184. verify: '1'
  1185. },
  1186. methods: {
  1187. fuckHandleCheckAllChange (val) {
  1188. this.fuck.checkedFucks = val ? fuckOptions.map(e => e.name) : []
  1189. this.fuck.isIndeterminate = false
  1190. },
  1191. handleCheckedFucksChange (value) {
  1192. const checkedCount = value.length
  1193. this.fuck.checkAll = checkedCount === this.fuck.fucks.length
  1194. this.fuck.isIndeterminate = checkedCount > 0 && checkedCount < this.fuck.fucks.length
  1195. },
  1196. removeHandleCheckAllChange (val) {
  1197. this.remove.checkedRemoves = val ? removeOptions.map(e => e.name) : []
  1198. this.remove.isIndeterminate = false
  1199. },
  1200. handleCheckedRemovesChange (value) {
  1201. const checkedCount = value.length
  1202. this.remove.checkAll = checkedCount === this.remove.removes.length
  1203. this.remove.isIndeterminate = checkedCount > 0 && checkedCount < this.remove.removes.length
  1204. }
  1205. }
  1206. })
  1207. },
  1208. creatConf: function () {
  1209. const confs = {}
  1210. for (const div of $('div.setting')) {
  1211. const id = $(div).attr('id')
  1212. const conf = {}
  1213. for (const form of $(div).find('form')) {
  1214. const name = $(form).attr('name')
  1215. if (name === 'max-point') {
  1216. const value = $(form).find('input').val()
  1217. conf[name] = /^[\d]+$/.test(value) ? value : 0
  1218. } else {
  1219. const setting = {}
  1220. for (const data of $(form).serializeArray()) {
  1221. setting[data.name] = 1
  1222. }
  1223. conf[name] = setting
  1224. }
  1225. }
  1226. confs[id] = conf
  1227. }
  1228. for (const checkbox of $('.non-global input')) {
  1229. if ($(checkbox).is(':checked')) confs[$(checkbox).attr('name')].load = 1
  1230. }
  1231. const lotteryUserInfo = GM_getValue('conf') ? GM_getValue('conf').lotteryUserInfo : false
  1232. if (lotteryUserInfo) confs.lotteryUserInfo = lotteryUserInfo
  1233. const announcement = GM_getValue('conf') ? GM_getValue('conf').announcement : false
  1234. if (announcement) confs.announcement = announcement
  1235. return confs
  1236. },
  1237. echoLog: function (e) {
  1238. let ele = ''
  1239. switch (e.type) {
  1240. case 'updateSteamCommunity':
  1241. ele = $(`<li>${getI18n('updateCommunityId')}<font></font></li>`)
  1242. break
  1243. case 'updateSteamStore':
  1244. ele = $(`<li>${getI18n('updateStoreId')}<font></font></li>`)
  1245. break
  1246. case 'joinSteamGroup':
  1247. ele = $(`<li>${getI18n('joinGroup')}<a href="https://steamcommunity.com/groups/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1248. break
  1249. case 'getGroupId':
  1250. ele = $(`<li>${getI18n('getGroupId')}<a href="https://steamcommunity.com/groups/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1251. break
  1252. case 'leaveSteamGroup':
  1253. ele = $(`<li>${getI18n('leaveGroup')}<a href="https://steamcommunity.com/groups/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1254. break
  1255. case 'followCurator':
  1256. ele = $(`<li>${getI18n('followCurator')}<a href="https://store.steampowered.com/curator/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1257. break
  1258. case 'unfollowCurator':
  1259. ele = $(`<li>${getI18n('unfollowCurator')}<a href="https://store.steampowered.com/curator/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1260. break
  1261. case 'getDeveloperId':
  1262. ele = $(`<li>${getI18n('getDeveloperId')}<a href="https://store.steampowered.com/developer/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1263. break
  1264. case 'followDeveloper':
  1265. ele = $(`<li>${getI18n('followDeveloper')}<a href="https://store.steampowered.com/developer/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1266. break
  1267. case 'unfollowDeveloper':
  1268. ele = $(`<li>${getI18n('unfollowDeveloper')}<a href="https://store.steampowered.com/developer/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1269. break
  1270. case 'getPublisherId':
  1271. ele = $(`<li>${getI18n('getPublisherId')}<a href="https://store.steampowered.com/publisher/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1272. break
  1273. case 'followPublisher':
  1274. ele = $(`<li>${getI18n('followPublisher')}<a href="https://store.steampowered.com/publisher/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1275. break
  1276. case 'unfollowPublisher':
  1277. ele = $(`<li>${getI18n('unfollowPublisher')}<a href="https://store.steampowered.com/publisher/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1278. break
  1279. case 'addWishlist':
  1280. ele = $(`<li>${getI18n('addWishlist')}<a href="https://store.steampowered.com/app/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1281. break
  1282. case 'removeWishlist':
  1283. ele = $(`<li>${getI18n('removeWishlist')}<a href="https://store.steampowered.com/app/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1284. break
  1285. case 'followGame':
  1286. ele = $(`<li>${getI18n('followGame')}<a href="https://store.steampowered.com/app/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1287. break
  1288. case 'unfollowGame':
  1289. ele = $(`<li>${getI18n('unfollowGame')}<a href="https://store.steampowered.com/app/${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1290. break
  1291. case 'likeAnnouncements':
  1292. ele = $(`<li>${getI18n('likeAnnouncements')}<a href="${e.url}" target="_blank">${e.id}</a>...<font></font></li>`)
  1293. break
  1294. case 'visitLink':
  1295. ele = $(`<li>${getI18n('visitLink')}...<a href="${e.text}" target="_blank">${e.text}</a>...<font></font></li>`)
  1296. break
  1297. case 'custom':
  1298. ele = $(e.text)
  1299. break
  1300. default:
  1301. ele = $(`<li>${getI18n('unknown')}<font></font></li>`)
  1302. break
  1303. }
  1304. $('.fuck-task-logs .el-notification__content').append(ele)
  1305. ele[0].scrollIntoView()
  1306. const font = ele.find('font')
  1307. const status = {
  1308. font,
  1309. success: function (text = 'Success', html = false) {
  1310. this.font.attr('class', '').addClass('success')
  1311. html ? this.font.html(text) : this.font.text(text)
  1312. },
  1313. error: function (text = 'Error', html = false) {
  1314. this.font.attr('class', '').addClass('error')
  1315. html ? this.font.html(text) : this.font.text(text)
  1316. },
  1317. warning: function (text = 'Warning', html = false) {
  1318. this.font.attr('class', '').addClass('warning')
  1319. html ? this.font.html(text) : this.font.text(text)
  1320. },
  1321. info: function (text = 'Info', html = false) {
  1322. this.font.attr('class', '').addClass('info')
  1323. html ? this.font.html(text) : this.font.text(text)
  1324. }
  1325. }
  1326. return status
  1327. },
  1328. unique: e => [...new Set(e)],
  1329. getUrlQuery: function (url) {
  1330. const q = {}
  1331. if (url) {
  1332. if (url.includes('?')) url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (_, k, v) => { q[k] = v })
  1333. } else {
  1334. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (_, k, v) => { q[k] = v })
  1335. }
  1336. return q
  1337. },
  1338. dateFormat: function (fmt, date) {
  1339. let ret = null
  1340. const opt = {
  1341. 'Y+': date.getFullYear().toString(),
  1342. 'm+': (date.getMonth() + 1).toString(),
  1343. 'd+': date.getDate().toString(),
  1344. 'H+': date.getHours().toString(),
  1345. 'M+': date.getMinutes().toString(),
  1346. 'S+': date.getSeconds().toString()
  1347. }
  1348. for (const k in opt) {
  1349. ret = new RegExp('(' + k + ')').exec(fmt)
  1350. if (ret) {
  1351. fmt = fmt.replace(ret[1], (ret[1].length === 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, '0')))
  1352. }
  1353. }
  1354. return fmt
  1355. },
  1356. addBackground: function () {
  1357. GM_addStyle('body {background-image:url(//img.hclonely.com/www/006brDXlly1ft9lm7ns5zj31hc0u0qh3.jpg);background-position:center bottom;background-size:cover;background-attachment:fixed;background-repeat:no-repeat;}')
  1358. },
  1359. isEmptyObjArr: function (object) {
  1360. for (const value of Object.values(object)) {
  1361. if (Object.prototype.toString.call(value) === '[object Array]') {
  1362. if (value.length !== 0) return false
  1363. } else if (Object.prototype.toString.call(value) === '[object Object]') {
  1364. if (Object.keys(value).length !== 0) return false
  1365. } else if (Object.prototype.toString.call(value) === '[object String]') {
  1366. if (value !== '') return false
  1367. }
  1368. }
  1369. return true
  1370. }
  1371. }
  1372.  
  1373. const banana = {
  1374. test: () => { return (window.location.host.includes('grabfreegame') || window.location.host.includes('bananagiveaway')) },
  1375. fuck: function (vue) {
  1376. const needBanana = $("p:contains('Collect'):contains('banana')")
  1377. const needPoints = $("p:contains('Collect'):contains('point')")
  1378. let msg = ''
  1379. if (needBanana.length > 0) msg = getI18n('needBanana', needBanana.text().match(/[\d]+/gim)[0])
  1380. if (needPoints.length > 0) msg = getI18n('needPoints', needPoints.text().replace(/Collect/gi, ''))
  1381. if (needPoints.length > 0 || needBanana.length > 0) {
  1382. vue.$confirm(msg, getI18n('notice'), {
  1383. confirmButtonText: getI18n('confirm'),
  1384. cancelButtonText: getI18n('cancel'),
  1385. type: 'warning'
  1386. }).then(() => {
  1387. this.get_tasks('do_task')
  1388. }).catch(err => {
  1389. console.error(err)
  1390. })
  1391. } else {
  1392. this.get_tasks('do_task')
  1393. }
  1394. },
  1395. get_tasks: function (callback = 'do_task') {
  1396. const taskInfoHistory = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  1397. if (taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) this.taskInfo = taskInfoHistory
  1398. if (callback === 'remove' && taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) {
  1399. this.remove(true)
  1400. } else {
  1401. this.tasks = []
  1402. this.links = []
  1403. this.groups = []
  1404. this.curators = []
  1405. this.wishlists = []
  1406. this.fGames = []
  1407. this.taskIds = []
  1408.  
  1409. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('processTasksInfo')}<font></font></li>` })
  1410.  
  1411. const tasksUl = $('ul.tasks li:not(:contains(Completed))')
  1412. const pro = []
  1413. for (const task of tasksUl) { // 遍历任务信息
  1414. const taskDes = $(task).find('p')
  1415. const verifyBtn = $(task).find('button:contains(Verify)')
  1416. const taskId = verifyBtn.length > 0 ? verifyBtn.attr('onclick').match(/\?verify=([\d]+)/) : ''
  1417. if (taskId) {
  1418. this.tasks.push({ taskId: taskId[1], taskDes: taskDes.text() })
  1419. if (/join.*?steam.*?group/gim.test(taskDes.text())) {
  1420. pro.push(new Promise(res => { // eslint-disable-line
  1421. new Promise(resolve => {
  1422. fuc.getFinalUrl(resolve, window.location.origin + window.location.pathname + '?q=' + taskId[1])
  1423. }).then(r => {
  1424. if (r.result === 'success') {
  1425. const groupName = r.finalUrl.match(/groups\/(.+)\/?/)
  1426. if (groupName) {
  1427. this.groups.push(groupName[1])
  1428. this.taskInfo.groups.push(groupName[1])
  1429. } else {
  1430. this.taskIds.push(taskId[1])
  1431. }
  1432. } else {
  1433. this.taskIds.push(taskId[1])
  1434. }
  1435. res(1)
  1436. })
  1437. }))
  1438. } else if (/follow.*?curator/gim.test(taskDes.text())) {
  1439. pro.push(new Promise(res => { // eslint-disable-line
  1440. new Promise(resolve => {
  1441. fuc.getFinalUrl(resolve, window.location.origin + window.location.pathname + '?q=' + taskId[1])
  1442. }).then(r => {
  1443. if (r.result === 'success') {
  1444. const curatorId = r.finalUrl.match(/curator\/([\d]+)/)
  1445. if (curatorId) {
  1446. this.curators.push(curatorId[1])
  1447. this.taskInfo.curators.push(curatorId[1])
  1448. } else {
  1449. this.taskIds.push(taskId[1])
  1450. }
  1451. } else {
  1452. this.taskIds.push(taskId[1])
  1453. }
  1454. res(1)
  1455. })
  1456. }))
  1457. } else if (/wishlist/gim.test(taskDes.text())) {
  1458. pro.push(new Promise(res => { // eslint-disable-line
  1459. new Promise(resolve => {
  1460. fuc.getFinalUrl(resolve, window.location.origin + window.location.pathname + '?q=' + taskId[1])
  1461. }).then(r => {
  1462. if (r.result === 'success') {
  1463. const appId = r.finalUrl.match(/store.steampowered.com\/app\/([\d]+)/)
  1464. if (appId) {
  1465. this.wishlists.push(appId[1])
  1466. this.taskInfo.wishlists.push(appId[1])
  1467. } else {
  1468. this.taskIds.push(taskId[1])
  1469. }
  1470. } else {
  1471. this.taskIds.push(taskId[1])
  1472. }
  1473. res(1)
  1474. })
  1475. }))
  1476. } else {
  1477. if (/(Subscribe.*channel)|(Retweet)|(Twitter)/gim.test(taskDes.text())) {
  1478. if (!this.verifyBtn) this.verifyBtn = taskDes.parent().find('button:contains(Verify)')
  1479. if (callback === 'do_task' && globalConf.other.autoOpen) {
  1480. taskDes.parent().find('button')[0].click()
  1481. }
  1482. }
  1483. pro.push(new Promise(resolve => {
  1484. this.links.push(window.location.origin + window.location.pathname + '?q=' + taskId[1])
  1485. this.taskIds.push(taskId[1])
  1486. resolve(1)
  1487. }))
  1488. }
  1489. }
  1490. }
  1491. Promise.all(pro).finally(() => {
  1492. this.links = fuc.unique(this.links)
  1493. this.groups = fuc.unique(this.groups)
  1494. this.curators = fuc.unique(this.curators)
  1495. this.wishlists = fuc.unique(this.wishlists)
  1496. this.fGames = fuc.unique(this.fGames)
  1497. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  1498. this.taskInfo.curators = fuc.unique(this.taskInfo.curators)
  1499. this.taskInfo.wishlists = fuc.unique(this.taskInfo.wishlists)
  1500. this.taskInfo.fGames = fuc.unique(this.taskInfo.fGames)
  1501. this.taskIds = fuc.unique(this.taskIds)
  1502. this.tasks = fuc.unique(this.tasks)
  1503. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  1504. status.success()
  1505. if (debug) console.log(this)
  1506. if (callback === 'do_task') {
  1507. this.do_task()
  1508. } else if (callback === 'verify') {
  1509. this.tasks.length > 0 ? this.verify(true) : fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  1510. } else {
  1511. !fuc.isEmptyObjArr(this.taskInfo) ? this.remove(true) : fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('cannotRemove')}</font></li>` })
  1512. }
  1513. })
  1514. }
  1515. },
  1516. do_task: function () {
  1517. this.updateSteamInfo(() => {
  1518. const pro = []
  1519. const groups = fuc.unique(this.groups)
  1520. const curators = fuc.unique(this.curators)
  1521. const wishlists = fuc.unique(this.wishlists)
  1522. const fGames = fuc.unique(this.fGames)
  1523. const links = fuc.unique(this.links)
  1524. if (this.conf.fuck.group) {
  1525. for (const group of groups) {
  1526. pro.push(new Promise(resolve => {
  1527. fuc.joinSteamGroup(resolve, group)
  1528. }))
  1529. }
  1530. }
  1531. if (this.conf.fuck.curator) {
  1532. for (const curator of curators) {
  1533. pro.push(new Promise(resolve => {
  1534. fuc.followCurator(resolve, curator)
  1535. }))
  1536. }
  1537. }
  1538. if (this.conf.fuck.wishlist) {
  1539. for (const gameId of wishlists) {
  1540. pro.push(new Promise(resolve => {
  1541. fuc.addWishlist(resolve, gameId)
  1542. }))
  1543. }
  1544. }
  1545. if (this.conf.fuck.followGame) {
  1546. for (const gameId of fGames) {
  1547. pro.push(new Promise(resolve => {
  1548. fuc.followGame(resolve, gameId)
  1549. }))
  1550. }
  1551. }
  1552. if (this.conf.fuck.visit) {
  1553. for (const link of links) {
  1554. pro.push(new Promise(resolve => {
  1555. fuc.visitLink(resolve, link)
  1556. }))
  1557. }
  1558. }
  1559. Promise.all(pro).finally(() => {
  1560. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  1561. if (this.conf.fuck.verify) this.verify()
  1562. })
  1563. })
  1564. },
  1565. verify: function (verify = false) {
  1566. if (verify) {
  1567. const pro = []
  1568. for (const task of fuc.unique(this.tasks)) {
  1569. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('verifyingTask')}${task.taskDes}...<font></font></li>` })
  1570. pro.push(new Promise(resolve => {
  1571. fuc.httpRequest({
  1572. url: window.location.origin + window.location.pathname + '?verify=' + task.taskId,
  1573. method: 'GET',
  1574. onload: function (response) {
  1575. if (debug) console.log(response)
  1576. status.warning('Complete')
  1577. resolve({ result: 'success', statusText: response.statusText, status: response.status })
  1578. },
  1579. r: resolve,
  1580. status
  1581. })
  1582. }))
  1583. }
  1584. Promise.all(pro).finally(() => {
  1585. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('verifyTasksComplete')}</font></li>` })
  1586. this.verifyBtn.length > 0 ? this.verifyBtn.removeAttr('disabled')[0].click() : window.location.reload(true)
  1587. })
  1588. } else {
  1589. this.get_tasks('verify')
  1590. }
  1591. },
  1592. remove: function (remove = false) {
  1593. const pro = []
  1594. if (remove) {
  1595. this.updateSteamInfo(() => {
  1596. if (this.conf.remove.group) {
  1597. for (const group of fuc.unique(this.taskInfo.groups)) {
  1598. pro.push(new Promise(resolve => {
  1599. fuc.leaveSteamGroup(resolve, group)
  1600. }))
  1601. }
  1602. }
  1603. if (this.conf.remove.curator) {
  1604. for (const curator of fuc.unique(this.taskInfo.curators)) {
  1605. pro.push(new Promise(resolve => {
  1606. fuc.unfollowCurator(resolve, curator)
  1607. }))
  1608. }
  1609. }
  1610. if (this.conf.remove.wishlist) {
  1611. for (const gameId of fuc.unique(this.taskInfo.wishlists)) {
  1612. pro.push(new Promise(resolve => {
  1613. fuc.removeWishlist(resolve, gameId)
  1614. }))
  1615. }
  1616. }
  1617. if (this.conf.remove.unfollowGame) {
  1618. for (const gameId of fuc.unique(this.taskInfo.fGames)) {
  1619. pro.push(new Promise(resolve => {
  1620. fuc.unfollowGame(resolve, gameId)
  1621. }))
  1622. }
  1623. }
  1624. Promise.all(pro).finally(() => {
  1625. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  1626. })
  1627. })
  1628. } else {
  1629. this.get_tasks('remove')
  1630. }
  1631. },
  1632. get_giveawayId: function () {
  1633. const id = window.location.href.match(/\/giveaway\/([\w\d-]+)/)
  1634. return id ? id[1] : window.location.href
  1635. },
  1636. updateSteamInfo: function (callback) {
  1637. new Promise(resolve => {
  1638. if (this.taskInfo.groups.length > 0) {
  1639. if (this.taskInfo.curators.length > 0 || this.taskInfo.fGames.length > 0 || this.taskInfo.wishlists.length > 0) {
  1640. fuc.updateSteamInfo(resolve, 'all')
  1641. } else {
  1642. fuc.updateSteamInfo(resolve, 'community')
  1643. }
  1644. } else if (this.taskInfo.curators.length > 0 || this.taskInfo.fGames.length > 0 || this.taskInfo.wishlists.length > 0) {
  1645. fuc.updateSteamInfo(resolve, 'store')
  1646. } else {
  1647. resolve(1)
  1648. }
  1649. }).then(s => {
  1650. if (s === 1) callback()
  1651. }).catch(err => {
  1652. console.error(err)
  1653. })
  1654. },
  1655. checkLogin: function () {
  1656. if ($('a.steam[title*=team]').length > 0) window.open('/giveaway/steam/', '_self')
  1657. },
  1658. checkLeft: function (ui) {
  1659. if ($('.left b').text() === '0') {
  1660. ui.$confirm(getI18n('noKeysLeft'), getI18n('notice'), {
  1661. confirmButtonText: getI18n('confirm'),
  1662. cancelButtonText: getI18n('cancel'),
  1663. type: 'warning',
  1664. center: true
  1665. }).then(() => {
  1666. window.close()
  1667. })
  1668. }
  1669. },
  1670. verifyBtn: 0,
  1671. links: [], // 需要浏览的页面链接
  1672. groups: [], // 所有任务需要加的组
  1673. curators: [], // 所有任务需要关注的鉴赏家
  1674. wishlists: [], // 所有务需要添加愿望单的游戏
  1675. fGames: [], // 所有任务需要关注的的游戏
  1676. taskIds: [], // 处理失败的任务
  1677. taskInfo: {
  1678. groups: [], // 任务需要加的组
  1679. curators: [], // 任务需要关注的鉴赏家
  1680. wishlists: [], // 任务需要添加愿望单的游戏
  1681. fGames: []// 任务需要关注的的游戏
  1682. },
  1683. tasks: [], // 所有任务ID
  1684. setting: {
  1685. fuck: true,
  1686. verify: true,
  1687. join: false,
  1688. remove: true
  1689. },
  1690. conf: GM_getValue('conf') ? ((GM_getValue('conf').banana && GM_getValue('conf').banana.load) ? GM_getValue('conf').banana : (GM_getValue('conf').global || defaultConf)) : defaultConf
  1691. }
  1692.  
  1693. const freegamelottery = {
  1694. test: () => { return window.location.host.includes('freegamelottery') },
  1695. after: website => {
  1696. if (window.location.host === 'd.freegamelottery.com' && GM_getValue('lottery') === 1) website.draw()
  1697. },
  1698. fuck: function (vue) {
  1699. GM_setValue('lottery', 1)
  1700. if ($('a.registration-button').length > 0) {
  1701. if (this.conf.fuck.autoLogin) {
  1702. const userInfo = GM_getValue('conf').lotteryUserInfo
  1703. if (userInfo) {
  1704. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('logining')}<font></font></li>` })
  1705. fuc.httpRequest({
  1706. url: 'https://freegamelottery.com/user/login',
  1707. method: 'POST',
  1708. data: `username=${userInfo.username}&password=${userInfo.password}&rememberMe=1`,
  1709. headers: {
  1710. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  1711. },
  1712. onload: function (data) {
  1713. if (data.status === 200) {
  1714. status.success()
  1715. window.location.reload(true)
  1716. } else {
  1717. status.error('Error:' + (data.statusText || data.status))
  1718. }
  1719. },
  1720. status
  1721. })
  1722. } else {
  1723. vue.$message({ type: 'warning', message: getI18n('needLogin') })
  1724. $('a.registration-button')[0].click()
  1725. $('button[value=Login]').click(() => {
  1726. const conf = GM_getValue('conf')
  1727. conf.lotteryUserInfo = { username: $('#modal_login').val(), password: $('#modal_password').val() }
  1728. GM_setValue('conf', conf)
  1729. })
  1730. }
  1731. } else {
  1732. vue.$message({ type: 'warning', message: getI18n('needLogin') })
  1733. $('a.registration-button')[0].click()
  1734. }
  1735. } else {
  1736. this.draw()
  1737. }
  1738. },
  1739. draw: function () {
  1740. GM_setValue('lottery', 0)
  1741. if (this.conf.fuck.doTask) {
  1742. const main = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('fglTimeout', 'Visit MAIN DRAW')}<font></font></li>` })
  1743. $.post('/draw/register-visit', { drawId: DashboardApp.draws.main.actual.id })
  1744. .done(function () {
  1745. DashboardApp.draws.main.actual.haveVisited = true
  1746. main.success()
  1747. const survey = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('fglTimeout', 'Visit SURVEY DRAW')}<font></font></li>` })
  1748. $.post('/draw/register-visit', { type: 'survey', drawId: DashboardApp.draws.survey.actual.id })
  1749. .done(function () {
  1750. DashboardApp.draws.survey.actual.haveVisited = 1
  1751. survey.success()
  1752. const video = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('fglTimeout', 'Visit VIDEO DRAW')}<font></font></li>` })
  1753. $.post('/draw/register-visit', { drawId: DashboardApp.draws.video.actual.id })
  1754. .done(function () {
  1755. DashboardApp.draws.video.actual.haveVisited = true
  1756. video.success()
  1757. const stackpot = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('fglTimeout', 'Visit STACKPOT')}<font></font></li>` })
  1758. $.post('/draw/register-visit', { type: 'stackpot', drawId: DashboardApp.draws.stackpot.actual.id })
  1759. .done(function () {
  1760. DashboardApp.draws.stackpot.actual.haveVisited = 1
  1761. stackpot.success()
  1762. fuc.echoLog({ type: 'custom', text: `<li>${getI18n('fglComplete')}<font></font></li>` })
  1763. window.location.href = '/#/draw/stackpot'
  1764. window.location.reload(true)
  1765. })
  1766. })
  1767. })
  1768. })
  1769. }
  1770. },
  1771. setting: {
  1772. fuck: true,
  1773. verify: false,
  1774. join: false,
  1775. remove: false
  1776. },
  1777. conf: GM_getValue('conf') ? ((GM_getValue('conf').freegamelottery && GM_getValue('conf').freegamelottery.load) ? GM_getValue('conf').freegamelottery : (GM_getValue('conf').global || defaultConf)) : defaultConf
  1778. }
  1779.  
  1780. const gamehag = {
  1781. test: () => { return window.location.host.includes('gamehag') },
  1782. before: () => {
  1783. $('#getkey').removeAttr('disabled')
  1784. if (globalConf.other.reCaptcha) $('body').append('<script>window.bannedCountries = ["en"];window.geo ="en";window.respCaptch="";</script>')
  1785. },
  1786. fuck: function () { this.get_tasks('do_task') },
  1787. get_tasks: function (callback = 'do_task') {
  1788. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('getTasksInfo')}<font></font></li>` })
  1789. const verifyBtns = $('button[data-id]')
  1790. if (callback === 'do_task') {
  1791. const taskInfo = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  1792. if (taskInfo && !fuc.isEmptyObjArr(taskInfo)) this.taskInfo = taskInfo
  1793. this.groups = []
  1794. this.tasks = []
  1795. for (const btn of verifyBtns) {
  1796. const taskId = $(btn).attr('data-id')
  1797. const taskDes = $(btn).parent().prev().text()
  1798. if ($(btn).parents('.task-content').next().text().includes('+1')) this.tasks.push({ taskId, taskDes })
  1799. }
  1800. if ($('a.giveaway-survey').length > 0) {
  1801. const taskId = $('a.giveaway-survey').attr('data-task_id')
  1802. const taskDes = 'Complete the survey'
  1803. this.tasks.push({ taskId, taskDes })
  1804. }
  1805. this.groups = fuc.unique(this.groups)
  1806. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  1807. this.tasks = fuc.unique(this.tasks)
  1808. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  1809. if (this.tasks.length > 0) {
  1810. this.do_task()
  1811. } else {
  1812. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  1813. if (this.conf.fuck.verify) this.verify()
  1814. }
  1815. } else if (callback === 'verify') {
  1816. this.tasks = []
  1817. for (const btn of verifyBtns) {
  1818. const taskId = $(btn).attr('data-id')
  1819. const taskDes = $(btn).parent().prev().text()
  1820. if ($(btn).parents('.task-content').next().text().includes('+1')) this.tasks.push({ taskId, taskDes })
  1821. }
  1822. this.tasks = fuc.unique(this.tasks)
  1823. if (this.tasks.length > 0) {
  1824. this.verify(true)
  1825. } else {
  1826. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('verifyTasksComplete')}</font></li>` })
  1827. }
  1828. } else if (callback === 'remove') {
  1829. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('cannotRemove')}</font></li>` })
  1830. } else {
  1831. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('unknown')}!</font></li>` })
  1832. }
  1833. status.success()
  1834. if (debug) console.log(this)
  1835. },
  1836. do_task: async function () {
  1837. const pro = []
  1838. const tasks = fuc.unique(this.tasks)
  1839. for (let i = 0; i < tasks.length; i++) {
  1840. const task = tasks[i]
  1841. pro.push(new Promise((resolve) => {
  1842. fuc.visitLink(resolve, '/giveaway/click/' + task.taskId, { headers: { 'x-csrf-token': $('meta[name="csrf-token"]').attr('content') } })
  1843. }))
  1844. if (/play.*?games/gim.test(task.taskDes)) {
  1845. pro.push(new Promise((resolve) => {
  1846. fuc.visitLink(resolve, '/games', { headers: { 'x-csrf-token': $('meta[name="csrf-token"]').attr('content') } })
  1847. }))
  1848. pro.push(new Promise((resolve) => {
  1849. fuc.visitLink(resolve, '/games/war-thunder/play', { headers: { 'x-csrf-token': $('meta[name="csrf-token"]').attr('content') } })
  1850. }))
  1851. }
  1852. await new Promise(resolve => {
  1853. setTimeout(() => { resolve() }, 1000)
  1854. })
  1855. }
  1856. Promise.all(pro).finally(() => {
  1857. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  1858. if (this.conf.fuck.verify) this.verify()
  1859. })
  1860. },
  1861. verify: async function (verify = false) {
  1862. if (verify) {
  1863. const pro = []
  1864. const tasks = fuc.unique(this.tasks)
  1865. for (let i = 0; i < tasks.length; i++) {
  1866. const task = tasks[i]
  1867. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('verifyingTask')}<a href="/giveaway/click/${task.taskId}" target="_blank">${task.taskDes.trim()}</a>...<font></font></li>` })
  1868. pro.push(new Promise((resolve) => {
  1869. fuc.httpRequest({
  1870. url: '/api/v1/giveaway/sendtask',
  1871. method: 'POST',
  1872. dataType: 'json',
  1873. headers: {
  1874. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  1875. 'x-csrf-token': $('meta[name="csrf-token"]').attr('content')
  1876. },
  1877. data: 'task_id=' + task.taskId,
  1878. onload: function (response) {
  1879. if (debug) console.log(response)
  1880. if (response.response) {
  1881. if (response.response.status === 'success') {
  1882. status.success()
  1883. $(`div.task-reward[href="#task-${task.taskId}-collapse"]`).html('<svg class="nc-icon nc-align-to-text grid-24 glyph"><use xlink:href="/icons/nci-fill.svg#nc-icon-check-simple" /></svg>')
  1884. resolve({ result: 'success', statusText: response.statusText, status: response.status })
  1885. } else {
  1886. status.error('Error:' + (response.response.message || response.statusText || response.status || 'error'))
  1887. if (globalConf.other.autoOpen) window.open(`/giveaway/click/${task.taskId}`, '_blank')
  1888. resolve({ result: 'error', statusText: response.statusText, status: response.status })
  1889. }
  1890. } else {
  1891. status.error('Error:' + response.statusText)
  1892. resolve({ result: 'error', statusText: response.statusText, status: response.status })
  1893. }
  1894. },
  1895. r: resolve,
  1896. status
  1897. })
  1898. }))
  1899. await new Promise(resolve => {
  1900. setTimeout(() => { resolve() }, 1000)
  1901. })
  1902. }
  1903. Promise.all(pro).finally(() => {
  1904. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('verifyTasksComplete')}</font></li>` })
  1905. })
  1906. } else {
  1907. this.get_tasks('verify')
  1908. }
  1909. },
  1910. remove: function (remove = false) {
  1911. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('cannotRemove')}</font></li>` })
  1912. },
  1913. get_giveawayId: function () {
  1914. const id = window.location.href.match(/\/giveaway\/([\d]+)/)
  1915. return id ? id[1] : window.location.href
  1916. },
  1917. checkLeft: function (ui) {
  1918. if ($('.giveaway-counter:first .strong').text() === '0') {
  1919. ui.$confirm(getI18n('noKeysLeft'), getI18n('notice'), {
  1920. confirmButtonText: getI18n('confirm'),
  1921. cancelButtonText: getI18n('cancel'),
  1922. type: 'warning',
  1923. center: true
  1924. }).then(() => {
  1925. window.close()
  1926. })
  1927. }
  1928. },
  1929. groups: [], // 任务需要加的组
  1930. taskInfo: {
  1931. groups: []// 所有任务需要加的组
  1932. },
  1933. tasks: [], // 任务信息
  1934. setting: {
  1935. fuck: true,
  1936. verify: true,
  1937. join: false,
  1938. remove: true
  1939. },
  1940. conf: GM_getValue('conf') ? ((GM_getValue('conf').gamehag && GM_getValue('conf').gamehag.load) ? GM_getValue('conf').gamehag : (GM_getValue('conf').global || defaultConf)) : defaultConf
  1941. }
  1942.  
  1943. const giveawaysu = {
  1944. test: () => { return window.location.host.includes('giveaway.su') },
  1945. get_tasks: function (e) {
  1946. // 获取任务信息
  1947. const taskInfo = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  1948. if (taskInfo && !fuc.isEmptyObjArr(taskInfo) && e === 'remove') {
  1949. this.taskInfo = taskInfo
  1950. this.do_task('remove')
  1951. } else {
  1952. if (taskInfo && !fuc.isEmptyObjArr(taskInfo)) this.taskInfo = taskInfo
  1953. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('getTasksInfo')}<font></font></li>` })
  1954. const tasks = $('#actions tr')
  1955. for (const task of tasks) {
  1956. const taskDes = $(task).find('td').eq(1).find('a:not([data-trigger="link"])')
  1957. const taskInfo = this.which_task(taskDes)
  1958. for (const info of taskInfo) {
  1959. if (info.name !== 'nonSteam' && this.taskInfo[info.name + 's']) {
  1960. this.taskInfo[info.name + 's'].push(info.link)
  1961. this.taskInfo.links.push(info.link)
  1962. }
  1963. }
  1964. }
  1965. status.success()
  1966. this.getFinalUrl(e)
  1967. }
  1968. },
  1969. which_task: function (taskDes) {
  1970. const taskInfo = []
  1971. const taskName = taskDes.text().trim()
  1972. const link = taskDes.attr('href')
  1973. if (/disable adblock/gim.test(taskName)) {
  1974. return [{ name: 'nonSteam' }]
  1975. } else if (/join.*group/gim.test(taskName)) {
  1976. taskInfo.push({ name: 'group', link })
  1977. this.community = 1
  1978. } else if (/like.*announcement/gim.test(taskName)) {
  1979. taskInfo.push({ name: 'announcement', link })
  1980. this.community = 1
  1981. } else if (/follow.*publisher/gim.test(taskName)) {
  1982. taskInfo.push({ name: 'publisher', link })
  1983. this.store = 1
  1984. } else if (/follow.*developer/gim.test(taskName)) {
  1985. taskInfo.push({ name: 'developer', link })
  1986. this.store = 1
  1987. } else if (/follow.*curator|subscribe.*curator/gim.test(taskName)) {
  1988. taskInfo.push({ name: 'curator', link })
  1989. this.store = 1
  1990. } else {
  1991. if (/(Subscribe.*YouTube)|(Like.*YouTube)|(Follow.*Instagram)|(on twitter)|(Join.*Discord.*server)|(Follow.*on.*Facebook)/gim.test(taskName)) {
  1992. this.links.push(link)
  1993. } else {
  1994. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  1995. taskInfo.push({ name: 'wGame', link })
  1996. this.store = 1
  1997. }
  1998. if (/follow.*button/gim.test(taskName)) {
  1999. taskInfo.push({ name: 'fGame', link })
  2000. this.store = 1
  2001. }
  2002. }
  2003. if (taskInfo.length === 0) return [{ name: 'nonSteam' }]
  2004. }
  2005. return taskInfo
  2006. },
  2007. getFinalUrl: function (e) {
  2008. // 处理任务链接
  2009. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('processTasksUrl')}<font></font></li>` })
  2010. const pro = []
  2011. for (const link of this.taskInfo.links) {
  2012. pro.push(new Promise(resolve => {
  2013. if (this.taskInfo.toFinalUrl[link]) {
  2014. resolve({ result: 'success' })
  2015. } else {
  2016. fuc.getFinalUrl(resolve, link)
  2017. }
  2018. }))
  2019. }
  2020. Promise.all(pro).then(data => {
  2021. for (const r of data) {
  2022. if (r.finalUrl) {
  2023. this.taskInfo.toFinalUrl[r.url] = r.finalUrl
  2024. }
  2025. }
  2026.  
  2027. this.links = fuc.unique(this.links)
  2028. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  2029. this.taskInfo.curators = fuc.unique(this.taskInfo.curators)
  2030. this.taskInfo.publishers = fuc.unique(this.taskInfo.publishers)
  2031. this.taskInfo.developers = fuc.unique(this.taskInfo.developers)
  2032. this.taskInfo.fGames = fuc.unique(this.taskInfo.fGames)
  2033. this.taskInfo.wGames = fuc.unique(this.taskInfo.wGames)
  2034. this.taskInfo.announcements = fuc.unique(this.taskInfo.announcements)
  2035. this.taskInfo.links = fuc.unique(this.taskInfo.links)
  2036. // 任务链接处理完成
  2037. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  2038. status.success()
  2039. if (debug) console.log(this)
  2040. e === 'doTask' ? this.do_task('join') : this.do_task('remove')
  2041. }).catch(error => {
  2042. status.error()
  2043. if (debug) console.log(error)
  2044. })
  2045. },
  2046. do_task: function (act) {
  2047. if (globalConf.other.autoOpen && act === 'join' && this.links.length > 0) {
  2048. for (const link of fuc.unique(this.links)) {
  2049. window.open(link, '_blank')
  2050. }
  2051. }
  2052. if ($('div.bind-discord').is(':visible')) $('div.bind-discord a')[0].click()
  2053. if ($('div.bind-twitch').is(':visible')) $('div.bind-twitch a')[0].click()
  2054. new Promise(resolve => {
  2055. if (this.taskInfo.groups.length > 0 || this.taskInfo.announcements.length > 0) {
  2056. if (this.taskInfo.curators.length > 0 || this.taskInfo.publishers.length > 0 || this.taskInfo.developers.length > 0 || this.taskInfo.fGames.length > 0 || this.taskInfo.wGames.length > 0) {
  2057. fuc.updateSteamInfo(resolve, 'all')
  2058. } else {
  2059. fuc.updateSteamInfo(resolve, 'community')
  2060. }
  2061. } else if (this.taskInfo.curators.length > 0 || this.taskInfo.publishers.length > 0 || this.taskInfo.developers.length > 0 || this.taskInfo.fGames.length > 0 || this.taskInfo.wGames.length > 0) {
  2062. fuc.updateSteamInfo(resolve, 'store')
  2063. } else {
  2064. resolve(1)
  2065. }
  2066. }).then(s => {
  2067. if (s === 1) {
  2068. const pro = []
  2069. for (const group of fuc.unique(this.taskInfo.groups)) {
  2070. if (this.taskInfo.toFinalUrl[group]) {
  2071. const groupName = this.taskInfo.toFinalUrl[group].match(/groups\/(.+)\/?/)
  2072. if (groupName) {
  2073. pro.push(new Promise(resolve => {
  2074. if (act === 'join' && this.conf.join.group) {
  2075. fuc.joinSteamGroup(resolve, groupName[1])
  2076. } else if (act === 'remove' && this.conf.remove.group) {
  2077. fuc.leaveSteamGroup(resolve, groupName[1])
  2078. } else {
  2079. resolve(1)
  2080. }
  2081. }))
  2082. }
  2083. }
  2084. }
  2085. for (const curator of fuc.unique(this.taskInfo.curators)) {
  2086. if (this.taskInfo.toFinalUrl[curator]) {
  2087. const curatorId = this.taskInfo.toFinalUrl[curator].match(/curator\/([\d]+)/)
  2088. if (curatorId) {
  2089. pro.push(new Promise(resolve => {
  2090. if (act === 'join' && this.conf.join.curator) {
  2091. fuc.followCurator(resolve, curatorId[1])
  2092. } else if (act === 'remove' && this.conf.remove.curator) {
  2093. fuc.unfollowCurator(resolve, curatorId[1])
  2094. } else {
  2095. resolve(1)
  2096. }
  2097. }))
  2098. }
  2099. }
  2100. }
  2101. for (const publisher of fuc.unique(this.taskInfo.publishers)) {
  2102. if (this.taskInfo.toFinalUrl[publisher]) {
  2103. const publisherName = this.taskInfo.toFinalUrl[publisher].includes('publisher') ? this.taskInfo.toFinalUrl[publisher].match(/publisher\/(.+)\/?/) : this.taskInfo.toFinalUrl[publisher].match(/pub\/(.+)\/?/)
  2104. if (publisherName) {
  2105. pro.push(new Promise(resolve => {
  2106. if (act === 'join' && this.conf.join.publisher) {
  2107. fuc.followPublisher(resolve, publisherName[1])
  2108. } else if (act === 'remove' && this.conf.remove.publisher) {
  2109. fuc.unfollowPublisher(resolve, publisherName[1])
  2110. } else {
  2111. resolve(1)
  2112. }
  2113. }))
  2114. }
  2115. }
  2116. }
  2117. for (const developer of fuc.unique(this.taskInfo.developers)) {
  2118. if (this.taskInfo.toFinalUrl[developer]) {
  2119. const developerName = this.taskInfo.toFinalUrl[developer].includes('developer') ? this.taskInfo.toFinalUrl[developer].match(/developer\/(.+)\/?/) : this.taskInfo.toFinalUrl[developer].match(/dev\/(.+)\/?/)
  2120. if (developerName) {
  2121. pro.push(new Promise(resolve => {
  2122. if (act === 'join' && this.conf.join.developer) {
  2123. fuc.followDeveloper(resolve, developerName[1])
  2124. } else if (act === 'remove' && this.conf.remove.developer) {
  2125. fuc.unfollowDeveloper(resolve, developerName[1])
  2126. } else {
  2127. resolve(1)
  2128. }
  2129. }))
  2130. }
  2131. }
  2132. }
  2133. for (const game of fuc.unique(this.taskInfo.fGames)) {
  2134. if (this.taskInfo.toFinalUrl[game]) {
  2135. const gameId = this.taskInfo.toFinalUrl[game].match(/app\/([\d]+)/)
  2136. if (gameId) {
  2137. pro.push(new Promise(resolve => {
  2138. if (act === 'join' && this.conf.join.followGame) {
  2139. fuc.followGame(resolve, gameId[1])
  2140. } else if (act === 'remove' && this.conf.remove.unfollowGame) {
  2141. fuc.unfollowGame(resolve, gameId[1])
  2142. } else {
  2143. resolve(1)
  2144. }
  2145. }))
  2146. }
  2147. }
  2148. }
  2149. for (const game of fuc.unique(this.taskInfo.wGames)) {
  2150. if (this.taskInfo.toFinalUrl[game]) {
  2151. const gameId = this.taskInfo.toFinalUrl[game].match(/app\/([\d]+)/)
  2152. if (gameId) {
  2153. pro.push(new Promise(resolve => {
  2154. if (act === 'join' && this.conf.join.wishlist) {
  2155. fuc.addWishlist(resolve, gameId[1])
  2156. } else if (act === 'remove' && this.conf.remove.wishlist) {
  2157. fuc.removeWishlist(resolve, gameId[1])
  2158. } else {
  2159. resolve(1)
  2160. }
  2161. }))
  2162. }
  2163. }
  2164. }
  2165. for (const announcement of fuc.unique(this.taskInfo.announcements)) {
  2166. if (this.taskInfo.toFinalUrl[announcement]) {
  2167. const announcementUrl = this.taskInfo.toFinalUrl[announcement]
  2168. const announcementId = announcementUrl.match(/announcements\/detail\/([\d]+)/)
  2169. if (announcementId) {
  2170. if (act === 'join' && this.conf.join.announcement) {
  2171. pro.push(new Promise(resolve => {
  2172. fuc.likeAnnouncements(resolve, announcementUrl, announcementId[1])
  2173. }))
  2174. }
  2175. }
  2176. }
  2177. }
  2178. Promise.all(pro).finally(() => {
  2179. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  2180. if (act === 'join') fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('closeExtensions')}</font></li>` })
  2181. })
  2182. }
  2183. })
  2184. },
  2185. fuck: function () { },
  2186. verify: function () { },
  2187. join: function () { this.get_tasks('doTask') },
  2188. remove: function () { this.get_tasks('remove') },
  2189. get_giveawayId: function () {
  2190. const id = window.location.href.match(/view\/([\d]+)/)
  2191. return id ? id[1] : window.location.href
  2192. },
  2193. checkLogin: function () {
  2194. if ($('a.steam-login').length > 0) window.open('/steam/redirect', '_self')
  2195. },
  2196. checkLeft: function (ui) {
  2197. if ($('.giveaway-ended').length > 0) {
  2198. ui.$confirm(getI18n('noKeysLeft'), getI18n('notice'), {
  2199. confirmButtonText: getI18n('confirm'),
  2200. cancelButtonText: getI18n('cancel'),
  2201. type: 'warning',
  2202. center: true
  2203. }).then(() => {
  2204. window.close()
  2205. })
  2206. }
  2207. },
  2208. community: 0,
  2209. store: 0,
  2210. links: [], // 非steam任务
  2211. taskInfo: {
  2212. groups: [], // 任务需要加的组
  2213. curators: [], // 任务需要关注的鉴赏家
  2214. publishers: [], // 任务需要关注的发行商
  2215. developers: [], // 任务需要关注的开发商
  2216. fGames: [], // 任务需要关注的游戏
  2217. wGames: [], // 任务需要加愿望单的游戏
  2218. announcements: [], // 任务需要点赞的通知
  2219. links: [], // 原始链接
  2220. toFinalUrl: {}// 链接转换
  2221. },
  2222. setting: {
  2223. fuck: false,
  2224. verify: false,
  2225. join: true,
  2226. remove: true
  2227. },
  2228. conf: GM_getValue('conf') ? ((GM_getValue('conf').giveawaysu && GM_getValue('conf').giveawaysu.load) ? GM_getValue('conf').giveawaysu : (GM_getValue('conf').global || defaultConf)) : defaultConf
  2229. }
  2230.  
  2231. const givekey = {
  2232. test: () => { return (window.location.host.includes('gkey') || window.location.host.includes('givekey')) },
  2233. before: website => {
  2234. const init = setInterval(() => {
  2235. try {
  2236. if (typeof Centrifuge !== 'undefined') {
  2237. clearInterval(init)
  2238. website.creat_app()
  2239. }
  2240. } catch (e) { }
  2241. }, 500)
  2242. },
  2243. after: () => { $('#verify-task').addClass('is-disabled').attr('disabled', 'disabled') },
  2244. fuck: function (btnArea) {
  2245. const transBtn = $('.yt-button__icon.yt-button__icon_type_right')
  2246. if (transBtn.css('background-position') === '-68px 0px') transBtn[0].click()
  2247. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('changeLanguage')}</font></li>` })
  2248. givekey.wssApp.message = btnArea.$message({ message: getI18n('connectWss'), duration: 0 })
  2249. $(() => givekey.wssApp.init(btnArea))
  2250. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('connectWssWait')}</font></li>` })
  2251. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('beforeFuck')}</font></li>` })
  2252. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('gkrobot')}</font></li>` })
  2253. window.open($('a[id^="task_"').attr('href'), '_blank')
  2254. },
  2255. analyze_tasks: function (tasks) {
  2256. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('processTasksUrl')}<font></font></li>` })
  2257. const pro = []
  2258. this.groups = []
  2259. this.wGames = []
  2260. this.fGames = []
  2261. this.links = []
  2262. const taskInfoHistory = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  2263. if (taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) this.taskInfo = taskInfoHistory
  2264. for (const id of tasks) {
  2265. const task = $('#task_' + id)
  2266. const href = task.attr('href')
  2267. if (href.includes('vk.com')) {
  2268. } else if (href.includes('steamcommunity.com/groups')) {
  2269. this.groups.push(href.match(/groups\/(.+)/)[1])
  2270. this.taskInfo.groups.push(href.match(/groups\/(.+)/)[1])
  2271. } else if (/Add to wishlist|加入愿望单/i.test(task.text())) {
  2272. pro.push(new Promise(r => { // eslint-disable-line
  2273. new Promise(resolve => {
  2274. fuc.getFinalUrl(resolve, href)
  2275. }).then(data => {
  2276. if (data.result === 'success') {
  2277. const appId = data.finalUrl.match(/app\/([\d]+)/)
  2278. if (appId) {
  2279. this.wGames.push(appId[1])
  2280. this.taskInfo.wGames.push(appId[1])
  2281. r(1)
  2282. } else {
  2283. r(0)
  2284. }
  2285. } else {
  2286. r(0)
  2287. }
  2288. })
  2289. }))
  2290. } else if (href.includes('store.steampowered.com/app')) {
  2291. this.fGames.push(href.match(/app\/([\d]+)/)[1])
  2292. this.taskInfo.fGames.push(href.match(/app\/([\d]+)/)[1])
  2293. } else {
  2294. this.links.push(href)
  2295. }
  2296. }
  2297. Promise.all(pro).finally(() => {
  2298. this.groups = fuc.unique(this.groups)
  2299. this.wGames = fuc.unique(this.wGames)
  2300. this.fGames = fuc.unique(this.fGames)
  2301. this.links = fuc.unique(this.links)
  2302. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  2303. this.taskInfo.fGames = fuc.unique(this.taskInfo.fGames)
  2304. this.taskInfo.wGames = fuc.unique(this.taskInfo.wGames)
  2305. if (this.groups.length > 0 || this.fGames.length > 0 || this.links.length > 0 || this.wGames.length > 0) {
  2306. this.do_task()
  2307. } else {
  2308. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('noAutoFinish')}</font></li>` })
  2309. }
  2310. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  2311. status.success()
  2312. if (debug) console.log(this)
  2313. })
  2314. },
  2315. get_tasks: function () {
  2316. const taskInfoHistory = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  2317. if (taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) {
  2318. this.taskInfo = taskInfoHistory
  2319. this.remove(true)
  2320. } else {
  2321. const pro = []
  2322. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('getTasksInfo')}<font></font></li>` })
  2323.  
  2324. const tasksContainer = $('a[id^=task_]')
  2325. for (const task of tasksContainer) { // 遍历任务信息
  2326. const href = task.attr('href')
  2327. if (href.includes('vk.com')) {
  2328. } else if (href.includes('steamcommunity.com/groups/')) {
  2329. this.taskInfo.groups.push(href.match(/groups\/(.+)/)[1])
  2330. } else if (/Add to wishlist|加入愿望单/i.test(task.text())) {
  2331. pro.push(new Promise(r => { // eslint-disable-line
  2332. new Promise(resolve => {
  2333. fuc.getFinalUrl(resolve, href)
  2334. }).then(data => {
  2335. if (data.result === 'success') {
  2336. const appId = data.finalUrl.match(/app\/([\d]+)/)
  2337. if (appId) {
  2338. this.wGames.push(appId[1])
  2339. this.taskInfo.wGames.push(appId[1])
  2340. r(1)
  2341. } else {
  2342. r(0)
  2343. }
  2344. } else {
  2345. r(0)
  2346. }
  2347. })
  2348. }))
  2349. } else if (href.includes('store.steampowered.com/app/')) {
  2350. this.taskInfo.fGames.push(href.match(/app\/([\d]+)/)[1])
  2351. }
  2352. }
  2353. Promise.all(pro).finally(() => {
  2354. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  2355. this.taskInfo.curators = fuc.unique(this.taskInfo.curators)
  2356. this.taskInfo.wGames = fuc.unique(this.taskInfo.wGames)
  2357. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  2358. status.success()
  2359. if (debug) console.log(this)
  2360. if (this.taskInfo.groups.length > 0 || this.taskInfo.curators.length > 0 || this.taskInfo.wGames.length > 0) {
  2361. this.remove(true)
  2362. } else {
  2363. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('cannotRemove')}</font></li>` })
  2364. }
  2365. })
  2366. }
  2367. },
  2368. do_task: function () {
  2369. this.updateSteamInfo(() => {
  2370. const pro = []
  2371. const groups = fuc.unique(this.groups)
  2372. const fGames = fuc.unique(this.fGames)
  2373. const wGames = fuc.unique(this.wGames)
  2374. const curators = fuc.unique(this.curators)
  2375. const links = fuc.unique(this.links)
  2376. if (this.conf.fuck.group) {
  2377. for (const group of groups) {
  2378. pro.push(new Promise((resolve) => {
  2379. fuc.joinSteamGroup(resolve, group)
  2380. }))
  2381. }
  2382. }
  2383. if (this.conf.fuck.wishlist) {
  2384. for (const game of wGames) {
  2385. pro.push(new Promise(resolve => {
  2386. fuc.addWishlist(resolve, game)
  2387. }))
  2388. }
  2389. }
  2390. if (this.conf.fuck.followGame) {
  2391. for (const game of fGames) {
  2392. pro.push(new Promise((resolve) => {
  2393. fuc.followGame(resolve, game)
  2394. }))
  2395. }
  2396. }
  2397. if (this.conf.fuck.curator) {
  2398. for (const curator of curators) {
  2399. pro.push(new Promise((resolve) => {
  2400. fuc.followCurator(resolve, curator)
  2401. }))
  2402. }
  2403. }
  2404. if (this.conf.fuck.visit) {
  2405. for (const link of links) {
  2406. pro.push(new Promise((resolve) => {
  2407. fuc.visitLink(resolve, link)
  2408. }))
  2409. }
  2410. }
  2411. Promise.all(pro).finally(() => {
  2412. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  2413. })
  2414. })
  2415. },
  2416. verify: function () {
  2417. givekey.wssApp.status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('getTaskStatus')}<font></font></li>` })
  2418. givekey.wssApp.request('/distribution/check', 'post', { id: window.location.href.match(/[\d]+/)[0], g_captcha: $('[name="g-recaptcha-response"]').val() })
  2419. },
  2420. remove: function (remove = false) {
  2421. const pro = []
  2422. if (remove) {
  2423. this.updateSteamInfo(() => {
  2424. if (this.conf.remove.group) {
  2425. for (const group of fuc.unique(this.taskInfo.groups)) {
  2426. pro.push(new Promise((resolve) => {
  2427. fuc.leaveSteamGroup(resolve, group)
  2428. }))
  2429. }
  2430. }
  2431. if (this.conf.remove.unfollowGame) {
  2432. for (const game of fuc.unique(this.taskInfo.fGames)) {
  2433. pro.push(new Promise((resolve) => {
  2434. fuc.unfollowCurator(resolve, game)
  2435. }))
  2436. }
  2437. }
  2438. if (this.conf.remove.wishlist) {
  2439. for (const game of fuc.unique(this.taskInfo.wGames)) {
  2440. pro.push(new Promise((resolve) => {
  2441. fuc.removeWishlist(resolve, game)
  2442. }))
  2443. }
  2444. }
  2445. if (this.conf.remove.curator) {
  2446. for (const curator of fuc.unique(this.taskInfo.curators)) {
  2447. pro.push(new Promise((resolve) => {
  2448. fuc.unfollowCurator(resolve, curator)
  2449. }))
  2450. }
  2451. }
  2452. Promise.all(pro).finally(() => {
  2453. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  2454. })
  2455. })
  2456. } else {
  2457. this.get_tasks('remove')
  2458. }
  2459. },
  2460. creat_app: function () {
  2461. this.wssApp = {
  2462. status: {},
  2463. message: {},
  2464. loading: false,
  2465. centrifuge: new Centrifuge(/givekey.ru/.test(window.location.href) ? 'wss://app.givekey.ru/connection/websocket' : 'wss://app.gkey.fun/connection/websocket'),
  2466. uid: $('meta[name="uid"]').attr('content'),
  2467. init: function (m) {
  2468. this.centrifuge.setToken($('meta[name="cent_token"]').attr('content'))
  2469. this.centrifuge.connect()
  2470. this.centrifuge.on('connect', function (e) {
  2471. if (debug) console.log(getI18n('wssConnected'))
  2472. $('#verify-task').removeClass('is-disabled').removeAttr('disabled')
  2473. givekey.wssApp.message.close()
  2474. m.$message({ message: getI18n('wssConnectSuccess'), type: 'success' })
  2475. for (const a of $('a[id^=task_]')) {
  2476. $(a).html($(a).html().replace('Посмотреть обзор на игру', '查看游戏评论')
  2477. .replace('Подписаться на разработчика', '订阅开发商')
  2478. .replace('Подписаться на куратора', '订阅鉴赏家')
  2479. .replace('Поставить лайк', '点赞')
  2480. .replace('Подписаться на игру', '关注游戏')
  2481. .replace(/Subscribe|Подписаться/, '订阅/加组')
  2482. .replace('Сделать репост', '转发')
  2483. .replace('Добавить в список желаемого', '加入愿望单')
  2484. .replace('Сделать обзор на игру', '评论')
  2485. .replace('Посетить web-сайт', '访问页面')
  2486. )
  2487. }
  2488. })
  2489. this.centrifuge.on('disconnect', function (e) {
  2490. if (debug) console.log(`${getI18n('wssDisconnected')}\n${e.reason}`)
  2491. $('#verify-task').addClass('is-disabled').attr('disabled', 'disabled')
  2492. givekey.wssApp.message = m.$message({ message: getI18n('wssReconnect'), type: 'warning', duration: 0 })
  2493. })
  2494. if (this.uid) {
  2495. this.centrifuge.subscribe(`usr#${this.uid}`, (data) => {
  2496. if (debug) console.log(data)
  2497. givekey.wssApp.status.success()
  2498. if (data.data.js) {
  2499. const taskA = data.data.js.split(';')
  2500. if (taskA) {
  2501. const tasks = []
  2502. taskA.map((e) => {
  2503. if (e.includes('btn-danger')) tasks.push(e.match(/[\d]+/)[0])
  2504. })
  2505. givekey.analyze_tasks(tasks)
  2506. }
  2507. }
  2508. })
  2509. }
  2510. },
  2511. request: (url, type, data, page) => {
  2512. if (url) {
  2513. data = data || {}
  2514. type = type || 'post'
  2515. if (type.toLowerCase() === 'get') {
  2516. if (givekey.wssApp.loading) { return }
  2517. givekey.wssApp.loading = !0
  2518. }
  2519. $.ajax({
  2520. url: url,
  2521. type: type,
  2522. data: data,
  2523. headers: {
  2524. 'x-csrf-token': $('meta[name="csrf-token"]').attr('content')
  2525. },
  2526. success: function (data) {
  2527. if (debug) console.log(data)
  2528. if (data.msg && !data.msg.data.includes('Проверяем! Пожалуйста подождите')) givekey.wssApp.status.error(data.msg.data.replace('Вы уже участвовали в этой раздаче!', '你已经参与了此赠key!'))
  2529. },
  2530. error: function (e) {
  2531. if (debug) console.log(e)
  2532. switch (e.status) {
  2533. case 401:
  2534. givekey.wssApp.status.error(getI18n('noLogin'))
  2535. break
  2536. case 403:
  2537. givekey.wssApp.status.error(getI18n('accessDenied'))
  2538. break
  2539. case 404:
  2540. givekey.wssApp.status.error(getI18n('notFound'))
  2541. break
  2542. case 500:
  2543. givekey.wssApp.status.error(getI18n('serverError'))
  2544. break
  2545. case 503:
  2546. givekey.wssApp.status.error(getI18n('errorRefresh'))
  2547. break
  2548. default:
  2549. givekey.wssApp.status.error('Error:' + e.status)
  2550. break
  2551. }
  2552. givekey.wssApp.loading = !1
  2553. }
  2554. })
  2555. }
  2556. }
  2557. }
  2558. },
  2559. get_giveawayId: function () {
  2560. const id = window.location.href.match(/distribution\/([\d]+)/)
  2561. return id ? id[1] : window.location.href
  2562. },
  2563. updateSteamInfo: function (callback) {
  2564. new Promise(resolve => {
  2565. if (this.taskInfo.groups.length > 0) {
  2566. if (this.taskInfo.curators.length > 0 || this.taskInfo.fGames.length > 0 || this.taskInfo.wGames.length > 0) {
  2567. fuc.updateSteamInfo(resolve, 'all')
  2568. } else {
  2569. fuc.updateSteamInfo(resolve, 'community')
  2570. }
  2571. } else if (this.taskInfo.curators.length > 0 || this.taskInfo.fGames.length > 0 || this.taskInfo.wGames.length > 0) {
  2572. fuc.updateSteamInfo(resolve, 'store')
  2573. } else {
  2574. resolve(1)
  2575. }
  2576. }).then(s => {
  2577. if (s === 1) callback()
  2578. }).catch(err => {
  2579. console.error(err)
  2580. })
  2581. },
  2582. checkLogin: function () {
  2583. if ($("a[href='/auth']").length > 0) window.open('/auth/steam', '_self')
  2584. },
  2585. checkLeft: function (ui) {
  2586. if ($('#keys_count').text() === '0') {
  2587. ui.$confirm(getI18n('noKeysLeft'), getI18n('notice'), {
  2588. confirmButtonText: getI18n('confirm'),
  2589. cancelButtonText: getI18n('cancel'),
  2590. type: 'warning',
  2591. center: true
  2592. }).then(() => {
  2593. window.close()
  2594. })
  2595. }
  2596. },
  2597. groups: [], // 任务需要加的组
  2598. curators: [], // 任务需要关注的鉴赏家
  2599. fGames: [], // 任务需要关注的游戏
  2600. wGames: [], // 任务需要加愿望单的游戏
  2601. developers: [], // 任务需要关注的开发商
  2602. links: [], // 需要浏览的页面链接
  2603. taskInfo: {
  2604. groups: [], // 所有任务需要加的组
  2605. curators: [], // 所有任务需要关注的鉴赏家
  2606. developers: [], // 任务需要关注的开发商
  2607. fGames: [], // 所有任务需要关注的游戏
  2608. wGames: []// 所有任务需要加愿望单的游戏
  2609. },
  2610. tasks: [], // 任务信息
  2611. setting: {
  2612. fuck: true,
  2613. fuckText: 'Init',
  2614. fuckTitle: getI18n('initFirst'),
  2615. verify: true,
  2616. verifyText: 'Fuck',
  2617. verifyTitle: getI18n('initPlease'),
  2618. join: false,
  2619. remove: true
  2620. },
  2621. conf: GM_getValue('conf') ? ((GM_getValue('conf').givekey && GM_getValue('conf').givekey.load) ? GM_getValue('conf').givekey : (GM_getValue('conf').global || defaultConf)) : defaultConf
  2622. }
  2623.  
  2624. const gleam = {
  2625. test: () => { return window.location.host.includes('gleam.io') },
  2626. fuck: function () { this.get_tasks('do_task') },
  2627. get_tasks: function (callback = 'do_task') {
  2628. const taskInfoHistory = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  2629. if (taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) this.taskInfo = taskInfoHistory
  2630. if (callback === 'remove' && taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) {
  2631. this.remove(true)
  2632. } else {
  2633. this.twitters = []
  2634. this.facebooks = []
  2635. this.youtubes = []
  2636. this.discords = []
  2637. this.others = []
  2638. this.groups = []
  2639. this.links = []
  2640. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('getTasksInfo')}<font></font></li>` })
  2641.  
  2642. const tasksContainer = $('div.entry-content .entry-method')
  2643. for (const task of tasksContainer) { // 遍历任务信息
  2644. if ($(task).find('i.fa-question').length > 0) {
  2645. if ($(task).hasClass('visit') || $(task).find('span:contains(Visit):contains(seconds)').length > 0) {
  2646. this.links.push(task)
  2647. } else {
  2648. const icon = $(task).find('.icon-wrapper i')
  2649. if (icon.hasClass('fa-twitter')) {
  2650. this.twitters.push(task)
  2651. } else if (icon.hasClass('fa-facebook')) {
  2652. this.facebooks.push(task)
  2653. } else if (icon.hasClass('fa-youtube')) {
  2654. this.youtubes.push(task)
  2655. } else if (icon.hasClass('fa-discord')) {
  2656. this.discords.push(task)
  2657. } else if (icon.hasClass('fa-steam') || icon.hasClass('fa-steam-symbol')) {
  2658. const title = $(task).find('.entry-method-title')
  2659. if (/join.*group/gim.test(title.text())) {
  2660. const groupA = $(task).find("a[href*='steamcommunity.com/groups']:first").attr('href')
  2661. if (groupA) {
  2662. const groupName = groupA.match(/steamcommunity.com\/groups\/([\w\d\-_]*)/)[1]
  2663. this.groups.push(groupName)
  2664. this.taskInfo.groups.push(groupName)
  2665. } else {
  2666. fuc.echoLog({
  2667. type: 'custom',
  2668. text: `<li><font class="error">${getI18n('getGroupFailed')}</font></li>`
  2669. })
  2670. }
  2671. } else {
  2672. this.others.push(task)
  2673. }
  2674. } else {
  2675. this.others.push(task)
  2676. }
  2677. }
  2678. } else if (callback === 'remove') {
  2679. const icon = $(task).find('.icon-wrapper i')
  2680. if (icon.hasClass('fa-steam')) {
  2681. const title = $(task).find('.entry-method-title')
  2682. if (/join.*group/gim.test(title.text())) {
  2683. const groupA = $(task).find("a[href*='steamcommunity.com/groups']:first").attr('href')
  2684. if (groupA) {
  2685. const groupName = groupA.match(/steamcommunity.com\/groups\/([\w\d\-_]*)/)[1]
  2686. this.taskInfo.groups.push(groupName)
  2687. } else {
  2688. fuc.echoLog({
  2689. type: 'custom',
  2690. text: `<li><font class="error">${getI18n('getGroupFailed')}</font></li>`
  2691. })
  2692. }
  2693. }
  2694. }
  2695. }
  2696. }
  2697. this.groups = fuc.unique(this.groups)
  2698. this.twitters = fuc.unique(this.twitters)
  2699. this.facebooks = fuc.unique(this.facebooks)
  2700. this.youtubes = fuc.unique(this.youtubes)
  2701. this.discords = fuc.unique(this.discords)
  2702. this.groups = fuc.unique(this.groups)
  2703. this.others = fuc.unique(this.others)
  2704. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  2705. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  2706. status.success()
  2707. if (debug) console.log(this)
  2708. if (callback === 'do_task') {
  2709. this.do_task()
  2710. } else if (callback === 'verify') {
  2711. this.verify(true)
  2712. } else {
  2713. !fuc.isEmptyObjArr(this.taskInfo) ? this.remove(true) : fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('cannotRemove')}</font></li>` })
  2714. }
  2715. }
  2716. },
  2717. do_task: function () {
  2718. this.updateSteamInfo(() => {
  2719. const pro = []
  2720. const groups = fuc.unique(this.groups)
  2721. const twitters = fuc.unique(this.twitters)
  2722. const discords = fuc.unique(this.discords)
  2723. const facebooks = fuc.unique(this.facebooks)
  2724. const youtubes = fuc.unique(this.youtubes)
  2725. const others = fuc.unique(this.others)
  2726. const links = fuc.unique(this.links)
  2727. const socals = [...discords, ...facebooks, ...youtubes]
  2728. if (this.conf.fuck.group && groups.length > 0) {
  2729. for (const group of groups) {
  2730. pro.push(new Promise((resolve) => {
  2731. fuc.joinSteamGroup(resolve, group)
  2732. }))
  2733. }
  2734. }
  2735. if (globalConf.other.autoOpen) {
  2736. if (twitters.length > 0) {
  2737. for (const twitter of twitters) {
  2738. const title = $(twitter).find('.entry-method-title').text().trim()
  2739. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('doing')}:${title}...<font></font></li>` })
  2740. const followButton = $(twitter).find('a.twitter-button:contains(Follow)').attr('href')
  2741. const retweetButton = $(twitter).find('a.twitter-button:contains(Retweet)').attr('href')
  2742. const button = followButton || retweetButton
  2743. if (button) {
  2744. window.open(button, '_blank')
  2745. status.warning(getI18n('openPage'))
  2746. } else {
  2747. status.error(getI18n('getTaskUrlFailed'))
  2748. }
  2749. }
  2750. }
  2751. if (socals.length > 0) {
  2752. for (const task of socals) {
  2753. const title = $(task).find('.entry-method-title').text().trim()
  2754. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('doing')}:${title}...<font></font></li>` })
  2755. const button = $(task).find('a.btn-info:first').attr('href')
  2756. if (button) {
  2757. window.open(button, '_blank')
  2758. status.warning(getI18n('openPage'))
  2759. } else {
  2760. status.error(getI18n('getTaskUrlFailed'))
  2761. }
  2762. }
  2763. }
  2764. }
  2765. if ((globalConf.other.autoOpen || this.conf.fuck.visit) && links.length > 0) {
  2766. pro.push(new Promise((resolve) => {
  2767. this.visit_link(links, 0, resolve)
  2768. }))
  2769. }
  2770. for (const other of others) {
  2771. const icon = $(other).find('.icon-wrapper i')
  2772. if (icon.hasClass('fa-steam')) {
  2773. const title = $(other).find('.entry-method-title').text().trim()
  2774. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('unknowntype')}:${title}</font></li>` })
  2775. } else {
  2776. const taskType = icon.attr('class').match(/fa-([\w]+)/) ? icon.attr('class').match(/fa-([\w]+)/)[1] : icon.attr('class')
  2777. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('unknowntype')}:${taskType}</font></li>` })
  2778. }
  2779. }
  2780. Promise.all(pro).finally(() => {
  2781. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  2782. if (this.conf.fuck.verify) this.verify(0)
  2783. })
  2784. })
  2785. },
  2786. verify: function (i = 0) {
  2787. if ($('.ng-scope[ng-include*=challenge]').is(':visible')) {
  2788. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('notRobot')}</font></li>` })
  2789. return
  2790. }
  2791. const tasks = $('div.entry-content .entry-method')
  2792. if (i < tasks.length) {
  2793. if (tasks.eq(i).find('i.fa-question').length > 0) {
  2794. const title = tasks.eq(i).find('.entry-method-title').text().trim()
  2795. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('verifyingTask')}:${title}...<font></font></li>` })
  2796. tasks.eq(i).find('a.enter-link')[0].click()
  2797. const enterBtn = tasks.eq(i).find('.form-actions.center .btn-primary:contains(Continue)').removeAttr('disabled')
  2798. if (enterBtn.length > 0) {
  2799. setTimeout(() => {
  2800. enterBtn[0].click()
  2801. status.warning('Complete')
  2802. setTimeout(() => { gleam.verify(++i) }, 1000)
  2803. }, 1000)
  2804. } else {
  2805. setTimeout(() => { gleam.verify(++i) }, 1000)
  2806. }
  2807. } else {
  2808. this.verify(++i)
  2809. }
  2810. } else {
  2811. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font><font class="warning">${getI18n('finishSelf')}</font></li>` })
  2812. }
  2813. },
  2814. remove: function (remove = false) {
  2815. const pro = []
  2816. if (remove) {
  2817. this.updateSteamInfo(() => {
  2818. if (this.conf.remove.group) {
  2819. for (const group of fuc.unique(this.taskInfo.groups)) {
  2820. pro.push(new Promise((resolve) => {
  2821. fuc.leaveSteamGroup(resolve, group)
  2822. }))
  2823. }
  2824. }
  2825. Promise.all(pro).finally(() => {
  2826. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  2827. })
  2828. })
  2829. } else {
  2830. this.get_tasks('remove')
  2831. }
  2832. },
  2833. visit_link: function (links, i, r) {
  2834. if (i < links.length) {
  2835. const title = $(links[i]).find('.entry-method-title').text().trim()
  2836. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('doing')}:${title}...<font></font></li>` })
  2837. const taskTime = $(links[i]).find('.form-actions.center span:contains(Visit):contains(seconds)').text()
  2838. if (taskTime) {
  2839. const taskBtn = $(links[i]).find('a.btn-info')
  2840. const href = taskBtn.attr('href')
  2841. taskBtn.removeAttr('href')[0].click()
  2842. const time = taskTime.match(/[\d]+/)
  2843. if (time) {
  2844. const url = language === 'en' ? 'https://userjs.hclonely.com/time_en.html?time=' : 'https://userjs.hclonely.com/time.html?time='
  2845. GM_openInTab(url + time[0], { active: 1, setParent: 1 }).onclose = () => {
  2846. status.warning('Complete')
  2847. taskBtn.attr('target', '_blank').attr('href', href)
  2848. gleam.visit_link(links, ++i, r)
  2849. }
  2850. } else {
  2851. GM_openInTab('javascript:setTimeout(()=>{window.close()},1000)', { active: 1, setParent: 1 }).onclose = () => {
  2852. status.warning('Complete')
  2853. taskBtn.attr('target', '_blank').attr('href', href)
  2854. gleam.visit_link(links, ++i, r)
  2855. }
  2856. }
  2857. } else {
  2858. status.error(getI18n('getVisitTimeFailed'))
  2859. }
  2860. } else {
  2861. r(1)
  2862. }
  2863. },
  2864. get_giveawayId: function () {
  2865. return window.location.pathname.replace(/\?.*/, '') || window.location.href
  2866. },
  2867. updateSteamInfo: function (callback) {
  2868. new Promise(resolve => {
  2869. if (this.taskInfo.groups.length > 0) {
  2870. fuc.updateSteamInfo(resolve, 'community')
  2871. } else {
  2872. resolve(1)
  2873. }
  2874. }).then(s => {
  2875. if (s === 1) callback()
  2876. }).catch(err => {
  2877. console.error(err)
  2878. })
  2879. },
  2880. checkLeft: function (ui) {
  2881. if ($('.massive-message:contains(ended)').is(':visible')) {
  2882. ui.$confirm(getI18n('noKeysLeft'), getI18n('notice'), {
  2883. confirmButtonText: getI18n('confirm'),
  2884. cancelButtonText: getI18n('cancel'),
  2885. type: 'warning',
  2886. center: true
  2887. }).then(() => {
  2888. window.close()
  2889. })
  2890. }
  2891. },
  2892. groups: [], // 任务需要加的组
  2893. links: [], // 需要浏览的页面链接
  2894. twitters: [], // twitter任务
  2895. discords: [], // discord任务
  2896. facebooks: [], // facebook任务
  2897. youtubes: [], // youtube任务
  2898. others: [], // 位置类型任务
  2899. taskInfo: {
  2900. groups: []// 所有任务需要加的组
  2901. },
  2902. tasks: [], // 任务信息
  2903. setting: {
  2904. fuck: true,
  2905. verify: true,
  2906. join: false,
  2907. remove: true
  2908. },
  2909. conf: GM_getValue('conf') ? ((GM_getValue('conf').gleam && GM_getValue('conf').gleam.load) ? GM_getValue('conf').gleam : (GM_getValue('conf').global || defaultConf)) : defaultConf
  2910. }
  2911.  
  2912. const indiedb = {
  2913. test: () => { return window.location.host.includes('indiedb') },
  2914. fuck: function () {
  2915. if ($('a.buttonenter:contains(Register to join)').length > 0) fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('needLogin')}</font></li>` })
  2916. const currentoption = $('a.buttonenter.buttongiveaway')
  2917. if (/join giveaway/gim.test(currentoption.text())) {
  2918. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('joinGiveaway')}<font></font></li>` })
  2919. const doTask = this.do_task
  2920. fuc.httpRequest({
  2921. url: currentoption.attr('href'),
  2922. method: 'POST',
  2923. data: 'ajax=t',
  2924. dataType: 'json',
  2925. headers: {
  2926. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  2927. accept: 'application/json, text/javascript, */*; q=0.01'
  2928. },
  2929. onload: function (response) {
  2930. if (debug) console.log(response)
  2931. if (response.status === 200 && response.response) {
  2932. if (response.response.success) {
  2933. currentoption.addClass('buttonentered').text('Success - Giveaway joined')
  2934. $('#giveawaysjoined').slideDown()
  2935. $('#giveawaysrecommend').slideDown()
  2936. status.success('Success' + (response.response.text ? (':' + response.response.text) : ''))
  2937. doTask()
  2938. } else {
  2939. status.error('Error' + (response.response.text ? (':' + response.response.text) : ''))
  2940. }
  2941. } else {
  2942. status.error('Error:' + (response.statusText || response.status))
  2943. }
  2944. }
  2945. })
  2946. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  2947. this.do_task()
  2948. } else {
  2949. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('needJoinGiveaway')}</font></li>` })
  2950. }
  2951. },
  2952. do_task: function () {
  2953. const id = $('script').map(function (i, e) {
  2954. if (/\$\(document\)/gim.test(e.innerHTML)) {
  2955. const optionId = e.innerHTML.match(/"\/newsletter\/ajax\/subscribeprofile\/optin\/[\d]+"/gim)[0].match(/[\d]+/)[0]
  2956. const taskId = e.innerHTML.match(/"\/[\d]+"/gim)[0].match(/[\d]+/)[0]
  2957. return [taskId, optionId]
  2958. }
  2959. })
  2960. if (id.length === 2) {
  2961. const tasks = $('#giveawaysjoined a[class*=promo]')
  2962. const pro = []
  2963. for (const task of tasks) {
  2964. const promo = $(task)
  2965. if (!promo.hasClass('buttonentered')) {
  2966. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('doing')}:${promo.parents('p').text()}...<font></font></li>` })
  2967. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  2968. pro.push(new Promise(resolve => {
  2969. $.ajax({
  2970. type: 'POST',
  2971. url: urlPath('/giveaways/ajax/' + (promo.hasClass('facebookpromo') ? 'facebookpromo' : (promo.hasClass('twitterpromo') ? 'twitterpromo' : 'visitpromo')) + '/' + id[0]),
  2972. timeout: 60000,
  2973. dataType: 'json',
  2974. data: { ajax: 't' },
  2975. error: function (response, error, exception) {
  2976. if (debug) console.log({ response, error, exception })
  2977. status.error('Error:An error has occurred performing the action requested. Please try again shortly.')
  2978. resolve(0)
  2979. },
  2980. success: function (response) {
  2981. if (debug) console.log(response)
  2982. if (response.success) {
  2983. status.success('Success:' + response.text)
  2984. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html())
  2985. resolve(1)
  2986. } else {
  2987. status.error('Error:' + response.text)
  2988. resolve(0)
  2989. }
  2990. }
  2991. })
  2992. }))
  2993. } else if (promo.hasClass('emailoptinpromo')) {
  2994. pro.push(new Promise(resolve => {
  2995. $.ajax({
  2996. type: 'POST',
  2997. url: urlPath('/newsletter/ajax/subscribeprofile/optin/' + id[1]),
  2998. timeout: 60000,
  2999. dataType: 'json',
  3000. data: { ajax: 't', emailsystoggle: 4 },
  3001. error: function (response, error, exception) {
  3002. if (debug) console.log({ response, error, exception })
  3003. status.error('Error:An error has occurred performing the action requested. Please try again shortly.')
  3004. resolve(0)
  3005. },
  3006. success: function (response) {
  3007. if (debug) console.log(response)
  3008. if (response.success) {
  3009. status.success('Success:' + response.text)
  3010. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html())
  3011. resolve(1)
  3012. } else {
  3013. status.error('Error:' + response.text)
  3014. resolve(0)
  3015. }
  3016. }
  3017. })
  3018. }))
  3019. } else if (promo.hasClass('watchingpromo')) {
  3020. pro.push(new Promise(resolve => {
  3021. const data = fuc.getUrlQuery(promo.attr('href'))
  3022. data.ajax = 't'
  3023. $.ajax({
  3024. type: 'POST',
  3025. url: urlPath(promo.attr('href').split(/[?#]/)[0]),
  3026. timeout: 60000,
  3027. dataType: 'json',
  3028. data: data,
  3029. error: function (response, error, exception) {
  3030. if (debug) console.log({ response, error, exception })
  3031. status.error('Error:An error has occurred performing the action requested. Please try again shortly.')
  3032. resolve(0)
  3033. },
  3034. success: function (response) {
  3035. if (debug) console.log(response)
  3036. if (response.success) {
  3037. status.success('Success:' + response.text)
  3038. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html())
  3039. resolve(1)
  3040. } else {
  3041. status.error('Error:' + response.text)
  3042. resolve(0)
  3043. }
  3044. }
  3045. })
  3046. }))
  3047. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  3048. pro.push(new Promise(resolve => {
  3049. $.ajax({
  3050. type: 'POST',
  3051. url: urlPath(promo.attr('href')),
  3052. timeout: 60000,
  3053. dataType: 'json',
  3054. data: { ajax: 't' },
  3055. error: function (response, error, exception) {
  3056. if (debug) console.log({ response, error, exception })
  3057. status.error('Error:An error has occurred performing the action requested. Please try again shortly.')
  3058. resolve(0)
  3059. },
  3060. success: function (response) {
  3061. if (debug) console.log(response)
  3062. if (response.success) {
  3063. status.success('Success:' + response.text)
  3064. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html())
  3065. resolve(1)
  3066. } else {
  3067. status.error('Error:' + response.text)
  3068. resolve(0)
  3069. }
  3070. }
  3071. })
  3072. }))
  3073. } else {
  3074. status.error('Error:' + getI18n('unknowntype'))
  3075. }
  3076. }
  3077. }
  3078. Promise.all(pro).finally(() => {
  3079. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('allTasksComplete')}</font></li>` })
  3080. })
  3081. } else {
  3082. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('getIdFailed')}</font></li>` })
  3083. }
  3084. },
  3085. checkLogin: function () {
  3086. if ($('a.buttonenter:contains(Register to join)').length > 0) window.open('/members/login', '_self')
  3087. },
  3088. setting: {
  3089. fuck: true,
  3090. verify: false,
  3091. join: false,
  3092. remove: false
  3093. },
  3094. conf: GM_getValue('conf') ? ((GM_getValue('conf').indiedb && GM_getValue('conf').indiedb.load) ? GM_getValue('conf').indiedb : (GM_getValue('conf').global || defaultConf)) : defaultConf
  3095. }
  3096.  
  3097. const marvelousga = {
  3098. test: () => { return (window.location.host.includes('marvelousga') || window.location.host.includes('dupedornot')) },
  3099. before: () => { fuc.newTabBlock() },
  3100. fuck: function () { this.get_tasks('do_task') },
  3101. get_tasks: function (callback = 'do_task') {
  3102. const taskInfoHistory = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  3103. if (taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) this.taskInfo = taskInfoHistory
  3104. if (callback === 'remove' && taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) {
  3105. this.remove(true)
  3106. } else {
  3107. this.tasks = []
  3108. this.groups = []
  3109. this.curators = []
  3110. this.links = []
  3111. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('getTasksInfo')}<font></font></li>` })
  3112.  
  3113. const tasksContainer = $('.container_task')
  3114. for (const task of tasksContainer) { // 遍历任务信息
  3115. const taskDes = $(task).find('.card-body p.card-text.monospace')
  3116. const verifyBtn = $(task).find('button[id^=task_]:not(:contains(VERIFIED))')
  3117. if (/join[\w\W]*?steamcommunity.com\/groups/gim.test(taskDes.html())) { // 加组任务
  3118. const groupName = taskDes.find('a[href*="steamcommunity.com/groups"]').attr('href').match(/steamcommunity.com\/groups\/([\w\d\-_]*)/)[1]
  3119. if (verifyBtn.length > 0) {
  3120. this.groups.push(groupName)
  3121. }
  3122. this.taskInfo.groups.push(groupName)
  3123. }
  3124. if (/follow[\w\W]*?store.steampowered.com\/curator/gim.test(taskDes.html())) { // 关注鉴赏家任务
  3125. const curatorName = taskDes.find('a[href*="store.steampowered.com/curator"]').attr('href').match(/store.steampowered.com\/curator\/([\d]*)/)[1]
  3126. if (verifyBtn.length > 0) {
  3127. this.curators.push(curatorName)
  3128. }
  3129. this.taskInfo.curators.push(curatorName)
  3130. }
  3131. if (/visit.*?this.*?page/gim.test(taskDes.text()) && verifyBtn.length > 0) { // 浏览页面任务
  3132. const pageUrl = taskDes.find('a[id^="task_webpage_clickedLink"]').attr('href')
  3133. this.links.push({ pageUrl: pageUrl, taskId: verifyBtn.attr('id').split('_')[3] })
  3134. }
  3135. if (verifyBtn.length > 0) { // 任务验证信息
  3136. const provider = verifyBtn.attr('id').split('_')[1]
  3137. const taskRoute = verifyBtn.attr('id').split('_')[2]
  3138. const taskId = verifyBtn.attr('id').split('_')[3]
  3139. this.tasks.push({ provider, taskRoute, taskId, taskDes: taskDes.html() })
  3140. }
  3141. }
  3142. this.groups = fuc.unique(this.groups)
  3143. this.curators = fuc.unique(this.curators)
  3144. this.links = fuc.unique(this.links)
  3145. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  3146. this.taskInfo.curators = fuc.unique(this.taskInfo.curators)
  3147. this.tasks = fuc.unique(this.tasks)
  3148. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  3149. status.success()
  3150. if (debug) console.log(this)
  3151. if (callback === 'do_task') {
  3152. if (this.tasks.length === 0) {
  3153. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3154. if (this.conf.fuck.verify) this.verify()
  3155. } else {
  3156. this.do_task()
  3157. }
  3158. } else if (callback === 'verify') {
  3159. this.tasks.length > 0 ? this.verify(true) : fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('verifyTasksComplete')}</font></li>` })
  3160. } else {
  3161. !fuc.isEmptyObjArr(this.taskInfo) ? this.remove(true) : fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('cannotRemove')}</font></li>` })
  3162. }
  3163. }
  3164. },
  3165. do_task: function () {
  3166. this.updateSteamInfo(() => {
  3167. const pro = []
  3168. const groups = fuc.unique(this.groups)
  3169. const curators = fuc.unique(this.curators)
  3170. const links = fuc.unique(this.links)
  3171. if (this.conf.fuck.group) {
  3172. for (const group of groups) {
  3173. pro.push(new Promise(resolve => {
  3174. fuc.joinSteamGroup(resolve, group)
  3175. }))
  3176. }
  3177. }
  3178. if (this.conf.fuck.curator) {
  3179. for (const curator of curators) {
  3180. pro.push(new Promise(resolve => {
  3181. fuc.followCurator(resolve, curator)
  3182. }))
  3183. }
  3184. }
  3185. if (this.conf.fuck.visit) {
  3186. for (const link of links) {
  3187. pro.push(new Promise(resolve => {
  3188. fuc.visitLink(resolve, link.pageUrl, {
  3189. url: '/ajax/verifyTasks/webpage/clickedLink',
  3190. method: 'POST',
  3191. headers: {
  3192. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  3193. 'x-csrf-token': $('meta[name="csrf-token"]').attr('content')
  3194. },
  3195. data: $.param({
  3196. giveaway_slug: this.get_giveawayId(),
  3197. giveaway_task_id: link.taskId
  3198. })
  3199. })
  3200. }))
  3201. }
  3202. }
  3203. Promise.all(pro).finally(() => {
  3204. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3205. if (this.conf.fuck.verify) this.verify()
  3206. })
  3207. })
  3208. },
  3209. verify: function (verify = false) {
  3210. if (verify) {
  3211. const pro = []
  3212. for (const task of fuc.unique(this.tasks)) {
  3213. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('verifyingTask')}${task.taskDes}...<font></font></li>` })
  3214. pro.push(new Promise(resolve => {
  3215. fuc.httpRequest({
  3216. url: '/ajax/verifyTasks/' + task.provider + '/' + task.taskRoute,
  3217. method: 'POST',
  3218. dataType: 'json',
  3219. headers: {
  3220. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  3221. 'x-csrf-token': $('meta[name="csrf-token"]').attr('content')
  3222. },
  3223. data: $.param({
  3224. giveaway_slug: this.get_giveawayId(),
  3225. giveaway_task_id: task.taskId
  3226. }),
  3227. onload: function (response) {
  3228. if (debug) console.log(response)
  3229. if (response.status === 200) {
  3230. if (response.response.status === 1) {
  3231. $(`#task_${task.provider}_${task.taskRoute}_${task.taskId}`).text('VERIFIED')
  3232. status.success(response.response.percentageNanoBar.toFixed(2) + '%')
  3233. resolve({ result: 'success', statusText: response.statusText, status: response.status })
  3234. } else {
  3235. status.error('Error:' + (response.response.message || 'error'))
  3236. if (globalConf.other.autoOpen) window.open($(`<div>${task.taskDes}</div>`).find('a').attr('href'), '_blank')
  3237. resolve({ result: 'error', statusText: response.statusText, status: response.status })
  3238. }
  3239. } else {
  3240. status.error('Error:' + (response.response.message || response.statusText || response.status))
  3241. if (globalConf.other.autoOpen) window.open($(`<div>${task.taskDes}</div>`).find('a').attr('href'), '_blank')
  3242. resolve({ result: 'error', statusText: response.statusText, status: response.status })
  3243. }
  3244. },
  3245. r: resolve,
  3246. status
  3247. })
  3248. }))
  3249. }
  3250. Promise.all(pro).finally(() => {
  3251. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('verifyTasksComplete')}</font><font class="warning">${getI18n('doYourself')}<a class="hclonely-google" href="javascript:void(0)" target="_self">${getI18n('googleVerify')}</a>${getI18n('getKey')}!</font></li>` })
  3252. $('#get_key_container').show()
  3253. $('.hclonely-google').unbind()
  3254. $('.hclonely-google').click(() => { $('#get_key_container')[0].scrollIntoView() })
  3255. })
  3256. } else {
  3257. this.get_tasks('verify')
  3258. }
  3259. },
  3260. remove: function (remove = false) {
  3261. const pro = []
  3262. if (remove) {
  3263. this.updateSteamInfo(() => {
  3264. if (this.conf.remove.group) {
  3265. for (const group of fuc.unique(this.taskInfo.groups)) {
  3266. pro.push(new Promise(resolve => {
  3267. fuc.leaveSteamGroup(resolve, group)
  3268. }))
  3269. }
  3270. }
  3271. if (this.conf.remove.curator) {
  3272. for (const curator of fuc.unique(this.taskInfo.curators)) {
  3273. pro.push(new Promise(resolve => {
  3274. fuc.unfollowCurator(resolve, curator)
  3275. }))
  3276. }
  3277. }
  3278. Promise.all(pro).finally(() => {
  3279. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3280. })
  3281. })
  3282. } else {
  3283. this.get_tasks('remove')
  3284. }
  3285. },
  3286. get_giveawayId: function () {
  3287. return $('#giveawaySlug').val() || window.location.href
  3288. },
  3289. updateSteamInfo: function (callback) {
  3290. new Promise(resolve => {
  3291. if (this.taskInfo.groups.length > 0) {
  3292. if (this.taskInfo.curators.length > 0) {
  3293. fuc.updateSteamInfo(resolve, 'all')
  3294. } else {
  3295. fuc.updateSteamInfo(resolve, 'community')
  3296. }
  3297. } else if (this.taskInfo.curators.length > 0) {
  3298. fuc.updateSteamInfo(resolve, 'store')
  3299. } else {
  3300. resolve(1)
  3301. }
  3302. }).then(s => {
  3303. if (s === 1) callback()
  3304. }).catch(err => {
  3305. console.error(err)
  3306. })
  3307. },
  3308. checkLogin: function () {
  3309. if ($('a[href*=login]').length > 0) window.open('/login', '_self')
  3310. },
  3311. checkLeft: function (ui) {
  3312. if ($('h3.text-danger:contains(this giveaway is closed)').length > 0) {
  3313. $('#link_to_click').remove()
  3314. ui.$confirm(getI18n('noKeysLeft'), getI18n('notice'), {
  3315. confirmButtonText: getI18n('confirm'),
  3316. cancelButtonText: getI18n('cancel'),
  3317. type: 'warning',
  3318. center: true
  3319. }).then(() => {
  3320. window.close()
  3321. })
  3322. }
  3323. },
  3324. groups: [], // 任务需要加的组
  3325. curators: [], // 任务需要关注的鉴赏家
  3326. links: [], // 需要浏览的页面链接
  3327. taskInfo: {
  3328. groups: [], // 所有任务需要加的组
  3329. curators: []// 所有任务需要关注的鉴赏家
  3330. },
  3331. tasks: [], // 任务信息
  3332. setting: {
  3333. fuck: true,
  3334. verify: true,
  3335. join: false,
  3336. remove: true
  3337. },
  3338. conf: GM_getValue('conf') ? ((GM_getValue('conf').marvelousga && GM_getValue('conf').marvelousga.load) ? GM_getValue('conf').marvelousga : (GM_getValue('conf').global || defaultConf)) : defaultConf
  3339. }
  3340.  
  3341. const opiumpulses = {
  3342. test: () => { return window.location.host.includes('opiumpulses') },
  3343. fuck: function () { this.get_tasks('FREE') },
  3344. get_tasks: async function (type = 'FREE') {
  3345. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`)
  3346. const myPoint = this.myPoints
  3347. const maxPoint = this.maxPoint()
  3348. for (let i = 0; i < items.length; i++) {
  3349. const item = items[i]
  3350. const needPoints = $(item).find('.giveaways-page-item-header-points').text().match(/[\d]+/gim)
  3351. if (type === 'points' && needPoints && parseInt(needPoints[0]) > myPoint) {
  3352. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('noPoints')}</font></li>` })
  3353. } else if (type === 'points' && !needPoints) {
  3354. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('getNeedPointsFailed')}</font></li>` })
  3355. } else if (!(type === 'points' && parseInt(needPoints[0]) > maxPoint)) {
  3356. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('joinLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${$(item).find('.giveaways-page-item-footer-name').text().trim()}</a>...<font></font></li>` })
  3357. const a = $(item).find("a.giveaways-page-item-img-btn-enter:contains('enter')")
  3358. if (a.attr('onclick') && a.attr('onclick').includes('checkUser')) {
  3359. const giveawayId = a.attr('onclick').match(/[\d]+/)
  3360. if (giveawayId) checkUser(giveawayId[0])
  3361. }
  3362. await new Promise(resolve => {
  3363. fuc.httpRequest({
  3364. url: a.attr('href'),
  3365. method: 'GET',
  3366. onload: response => {
  3367. if (debug) console.log(response)
  3368. if (response.responseText && /You've entered this giveaway/gim.test(response.responseText)) {
  3369. status.success()
  3370. const points = response.responseText.match(/Points:[\s]*?([\d]+)/)
  3371. if (type === 'points' && points) {
  3372. if (debug) console.log(getI18n('pointsLeft') + points[1])
  3373. opiumpulses.myPoints = parseInt(points[1])
  3374. }
  3375. } else {
  3376. status.error('Error:' + (response.status || response.statusText))
  3377. }
  3378. resolve(1)
  3379. },
  3380. status,
  3381. r: resolve
  3382. })
  3383. }).then(data => {
  3384. return true
  3385. }).catch(() => {
  3386. return false
  3387. })
  3388. }
  3389. }
  3390. fuc.echoLog({ type: 'custom', text: '<li>-----END-----</li>' })
  3391. },
  3392. verify: function () {
  3393. const myPoints = $('.page-header__nav-func-user-nav-items.points-items').text().match(/[\d]+/gim)
  3394. if (myPoints) {
  3395. this.myPoints = myPoints
  3396. this.get_tasks('points')
  3397. } else {
  3398. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('getPointsFailed')}</font></li>` })
  3399. }
  3400. },
  3401. myPoints: 0,
  3402. setting: {
  3403. fuck: true,
  3404. fuckText: 'Free',
  3405. fuckTitle: getI18n('joinFreeLottery'),
  3406. verify: true,
  3407. verifyText: 'Point',
  3408. verifyTitle: getI18n('joinPointLottery'),
  3409. join: false,
  3410. remove: false
  3411. },
  3412. conf: GM_getValue('conf') ? ((GM_getValue('conf').opiumpulses && GM_getValue('conf').opiumpulses.load) ? GM_getValue('conf').opiumpulses : (GM_getValue('conf').global || defaultConf)) : defaultConf,
  3413. maxPoint: function () {
  3414. return this.conf['max-point'] || Infinity
  3415. }
  3416. }
  3417.  
  3418. const prys = {
  3419. test: () => { return window.location.host.includes('prys.revadike') },
  3420. fuck: function () { this.get_tasks('do_task') },
  3421. get_tasks: function (callback = 'do_task') {
  3422. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('getTasksInfo')}<font></font></li>` })
  3423. const steps = $('#steps tbody tr')
  3424. for (let i = 0; i < steps.length; i++) {
  3425. if (steps.eq(i).find('span:contains(Success)').length === 0) checkClick(i)
  3426. }
  3427. if (callback === 'do_task') {
  3428. const taskInfoHistory = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  3429. if (taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) this.taskInfo = taskInfoHistory
  3430. this.groups = []
  3431. this.curators = []
  3432. const pro = []
  3433. for (const step of steps) {
  3434. if ($(step).find('span:contains(Success)').length === 0) {
  3435. if ($(step).find("a[href*='store.steampowered.com/curator/']").length > 0) {
  3436. const link = $(step).find("a[href*='store.steampowered.com/curator/']").attr('href')
  3437. const curatorId = link.match(/curator\/([\d]+)/)
  3438. if (curatorId) {
  3439. this.curators.push(curatorId[1])
  3440. this.taskInfo.curators.push(curatorId[1])
  3441. }
  3442. } else if ($(step).find("a[href*='steampowered.com/groups/']").length > 0) {
  3443. const link = $(step).find("a[href*='steampowered.com/groups/']").attr('href')
  3444. const groupName = link.match(/groups\/(.+)\/?/)
  3445. if (groupName) {
  3446. this.groups.push(groupName[1])
  3447. this.taskInfo.groups.push(groupName[1])
  3448. }
  3449. } else if ($(step).find("a[href*='steamcommunity.com/gid']").length > 0) {
  3450. const link = $(step).find("a[href*='steamcommunity.com/gid']").attr('href')
  3451. pro.push(new Promise(r => { // eslint-disable-line
  3452. new Promise(resolve => {
  3453. fuc.getFinalUrl(resolve, link)
  3454. }).then(data => {
  3455. if (data.result === 'success') {
  3456. const groupName = data.finalUrl.match(/groups\/(.+)\/?/)
  3457. if (groupName) {
  3458. this.groups.push(groupName[1])
  3459. this.taskInfo.groups.push(groupName[1])
  3460. }
  3461. }
  3462. r(1)
  3463. })
  3464. }))
  3465. }
  3466. }
  3467. }
  3468. if (pro.length > 0) {
  3469. Promise.all(pro).finally(() => {
  3470. this.groups = fuc.unique(this.groups)
  3471. this.curators = fuc.unique(this.curators)
  3472. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  3473. this.taskInfo.curators = fuc.unique(this.taskInfo.curators)
  3474. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  3475. if (this.groups.length > 0 || this.curators.length > 0) {
  3476. this.do_task()
  3477. } else {
  3478. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3479. if (this.conf.fuck.verify) this.verify()
  3480. }
  3481. })
  3482. } else {
  3483. this.groups = fuc.unique(this.groups)
  3484. this.curators = fuc.unique(this.curators)
  3485. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  3486. this.taskInfo.curators = fuc.unique(this.taskInfo.curators)
  3487. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  3488. if (this.groups.length > 0 || this.curators.length > 0) {
  3489. this.do_task()
  3490. } else {
  3491. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3492. if (this.conf.fuck.verify) this.verify()
  3493. }
  3494. }
  3495. } else if (callback === 'verify') {
  3496. this.tasks = []
  3497. const checks = $('#steps tbody a[id^=check]')
  3498. if (checks.length > 0) {
  3499. for (const check of checks) {
  3500. const id = $(check).attr('id').match(/[\d]+/)
  3501. if (id) this.tasks.push({ id: id[0], taskDes: $(check).parent().prev().html().trim() })
  3502. }
  3503. this.verify(true)
  3504. } else {
  3505. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('prysAllTasksComplete')}</font></li>` })
  3506. }
  3507. } else if (callback === 'remove') {
  3508. const taskInfo = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  3509. if (taskInfo && !fuc.isEmptyObjArr(taskInfo)) {
  3510. this.taskInfo = taskInfo
  3511. this.remove(true)
  3512. } else {
  3513. const pro = []
  3514. for (const step of steps) {
  3515. if ($(step).find("a[href*='store.steampowered.com/curator/']").length > 0) {
  3516. const link = $(step).find("a[href*='store.steampowered.com/curator/']").attr('href')
  3517. const curatorId = link.match(/curator\/([\d]+)/)
  3518. if (curatorId) this.taskInfo.curators.push(curatorId[1])
  3519. } else if ($(step).find("a[href*='steampowered.com/groups/']").length > 0) {
  3520. const link = $(step).find("a[href*='steampowered.com/groups/']").attr('href')
  3521. const groupName = link.match(/groups\/(.+)\/?/)
  3522. if (groupName) this.taskInfo.groups.push(groupName[1])
  3523. } else if ($(step).find("a[href*='steamcommunity.com/gid']").length > 0) {
  3524. const link = $(step).find("a[href*='steamcommunity.com/gid']").attr('href')
  3525. pro.push(new Promise(r => { // eslint-disable-line
  3526. new Promise(resolve => {
  3527. fuc.getFinalUrl(resolve, link)
  3528. }).then(data => {
  3529. if (data.result === 'success') {
  3530. const groupName = data.finalUrl.match(/groups\/(.+)\/?/)
  3531. if (groupName) {
  3532. this.taskInfo.groups.push(groupName[1])
  3533. }
  3534. }
  3535. r(1)
  3536. })
  3537. }))
  3538. }
  3539. }
  3540. if (pro.length > 0) {
  3541. Promise.all(pro).finally(() => {
  3542. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  3543. this.taskInfo.curators = fuc.unique(this.taskInfo.curators)
  3544. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  3545. if (this.taskInfo.groups.length > 0 || this.taskInfo.curators.length > 0) {
  3546. this.remove(true)
  3547. } else {
  3548. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('cannotRemove')}</font></li>` })
  3549. }
  3550. })
  3551. } else {
  3552. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  3553. this.taskInfo.curators = fuc.unique(this.taskInfo.curators)
  3554. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  3555. if (this.taskInfo.groups.length > 0 || this.taskInfo.curators.length > 0) {
  3556. this.remove(true)
  3557. } else {
  3558. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('cannotRemove')}</font></li>` })
  3559. }
  3560. }
  3561. }
  3562. } else {
  3563. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('unknown')}!</font></li>` })
  3564. }
  3565. status.success()
  3566. if (debug) console.log(this)
  3567. },
  3568. do_task: function () {
  3569. this.updateSteamInfo(() => {
  3570. const pro = []
  3571. const groups = fuc.unique(this.groups)
  3572. const curators = fuc.unique(this.curators)
  3573. if (this.conf.fuck.group) {
  3574. for (const group of groups) {
  3575. pro.push(new Promise(resolve => {
  3576. fuc.joinSteamGroup(resolve, group)
  3577. }))
  3578. }
  3579. }
  3580. if (this.conf.fuck.curator) {
  3581. for (const curator of curators) {
  3582. pro.push(new Promise(resolve => {
  3583. fuc.followCurator(resolve, curator)
  3584. }))
  3585. }
  3586. }
  3587. Promise.all(pro).finally(() => {
  3588. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3589. if (this.conf.fuck.verify) this.verify()
  3590. })
  3591. })
  3592. },
  3593. verify: function (verify = false) {
  3594. if (verify) {
  3595. const pro = []
  3596. for (const task of fuc.unique(this.tasks)) {
  3597. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('verifyingTask')}${task.taskDes}...<font></font></li>` })
  3598. pro.push(new Promise(resolve => {
  3599. this.checkStep(task.id, resolve, status)
  3600. }))
  3601. }
  3602. Promise.all(pro).finally(() => {
  3603. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('prysAllTasksComplete')}</font></li>` })
  3604. })
  3605. } else {
  3606. this.get_tasks('verify')
  3607. }
  3608. },
  3609. checkStep: function (step, r, status, captcha) {
  3610. if (!captcha) captcha = null
  3611. if (step !== 'captcha') {
  3612. $('#check' + step).replaceWith('<span id="check' + step + '"><i class="fa fa-refresh fa-spin fa-fw"></i> Checking...</span>')
  3613. }
  3614. $.post('/api/check_step', {
  3615. step: step,
  3616. id: getURLParameter('id'),
  3617. 'g-recaptcha-response': captcha
  3618. }, function (json) {
  3619. r(1)
  3620. if (json.success && step !== 'captcha') {
  3621. $('#check' + step).replaceWith('<span class="text-success" id="check' + step + '"><i class="fa fa-check"></i> Success</span>')
  3622. status.success()
  3623. } else if (step !== 'captcha') {
  3624. $('#check' + step).replaceWith('<a id="check' + step + '" href="javascript:checkStep(' + step + ')"><i class="fa fa-question"></i> Check</a>')
  3625. status.error((json.response ? json.response.error ? json.response.error : 'Error' : 'Error'))
  3626. }
  3627. if (json.response) {
  3628. if (json.response.captcha && json.success) {
  3629. showAlert('info', json.response.captcha)
  3630. captchaCheck()
  3631. } else if (json.response.captcha) {
  3632. showAlert('warning', json.response.captcha)
  3633. captchaCheck()
  3634. }
  3635. if (json.response.prize) {
  3636. showAlert('success', 'Here is your prize:<h1 role="button" align="middle" style="word-wrap: break-word;">' + json.response.prize + '</h2>')
  3637. }
  3638. }
  3639. }).fail(function () {
  3640. r(1)
  3641. $('#check' + step).replaceWith('<a id="check' + step + '" href="javascript:checkStep(' + step + ')"><i class="fa fa-question"></i> Check</a>')
  3642. status.error('Error:0')
  3643. })
  3644. },
  3645. remove: function (remove = false) {
  3646. const pro = []
  3647. if (remove) {
  3648. this.updateSteamInfo(() => {
  3649. if (this.conf.remove.group) {
  3650. for (const group of fuc.unique(this.taskInfo.groups)) {
  3651. pro.push(new Promise(resolve => {
  3652. fuc.leaveSteamGroup(resolve, group)
  3653. }))
  3654. }
  3655. }
  3656. if (this.conf.remove.curator) {
  3657. for (const curator of fuc.unique(this.taskInfo.curators)) {
  3658. pro.push(new Promise(resolve => {
  3659. fuc.unfollowCurator(resolve, curator)
  3660. }))
  3661. }
  3662. }
  3663. Promise.all(pro).finally(() => {
  3664. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3665. })
  3666. })
  3667. } else {
  3668. this.get_tasks('remove')
  3669. }
  3670. },
  3671. get_giveawayId: function () {
  3672. const id = window.location.search.match(/id=([\d]+)/)
  3673. return id ? id[1] : window.location.href
  3674. },
  3675. updateSteamInfo: function (callback) {
  3676. new Promise(resolve => {
  3677. if (this.taskInfo.groups.length > 0) {
  3678. if (this.taskInfo.curators.length > 0) {
  3679. fuc.updateSteamInfo(resolve, 'all')
  3680. } else {
  3681. fuc.updateSteamInfo(resolve, 'community')
  3682. }
  3683. } else if (this.taskInfo.curators.length > 0) {
  3684. fuc.updateSteamInfo(resolve, 'store')
  3685. } else {
  3686. resolve(1)
  3687. }
  3688. }).then(s => {
  3689. if (s === 1) callback()
  3690. }).catch(err => {
  3691. console.error(err)
  3692. })
  3693. },
  3694. checkLeft: function (ui) {
  3695. const left = $('#header').text().match(/([\d]+).*?prize.*?left/)
  3696. if (!(left.length > 0 && left[1] !== '0')) {
  3697. ui.$confirm(getI18n('noKeysLeft'), getI18n('notice'), {
  3698. confirmButtonText: getI18n('confirm'),
  3699. cancelButtonText: getI18n('cancel'),
  3700. type: 'warning',
  3701. center: true
  3702. }).then(() => {
  3703. window.close()
  3704. })
  3705. }
  3706. },
  3707. groups: [], // 任务需要加的组
  3708. curators: [], // 任务需要关注的鉴赏家
  3709. taskInfo: {
  3710. groups: [], // 所有任务需要加的组
  3711. curators: []// 所有任务需要关注的鉴赏家
  3712. },
  3713. tasks: [], // 任务信息
  3714. setting: {
  3715. fuck: true,
  3716. verify: true,
  3717. join: false,
  3718. remove: true
  3719. },
  3720. conf: GM_getValue('conf') ? ((GM_getValue('conf').prys && GM_getValue('conf').prys.load) ? GM_getValue('conf').prys : (GM_getValue('conf').global || defaultConf)) : defaultConf
  3721. }
  3722.  
  3723. const spoune = {
  3724. test: () => { return window.location.host.includes('spoune') },
  3725. fuck: function () { this.get_tasks() },
  3726. get_tasks: function () {
  3727. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('getTasksInfo')}<font></font></li>` })
  3728. const giveawayTasks = $('#GiveawayTasks button')
  3729. for (const task of giveawayTasks) {
  3730. const taskClick = $(task).attr('onclick')
  3731. if (taskClick) {
  3732. const taskId = taskClick.match(/loadTask\(([\d]+)/)
  3733. if (taskId) {
  3734. this.tasks.push({ id: taskId[1], text: $(task).text() })
  3735. } else {
  3736. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('getTaskIdFailed', $(task).text())}</font></li>` })
  3737. }
  3738. } else {
  3739. fuc.echoLog({ type: 'custom', text: `<li><font class="error">${getI18n('getTaskIdFailed', $(task).text())}</font></li>` })
  3740. }
  3741. }
  3742. status.warning('Complete')
  3743. if (this.tasks.length > 0) {
  3744. this.verify()
  3745. } else {
  3746. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('noAutoFinish')}</font></li>` })
  3747. }
  3748. },
  3749. verify: async function ({ arr, i, end }) {
  3750. const tasks = fuc.unique(this.tasks)
  3751. for (let i = 0; i < tasks.length; i++) {
  3752. const task = tasks[i]
  3753. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('doing')}${task.text}...<font></font></li>` })
  3754. await new Promise(resolve => {
  3755. fuc.httpRequest({
  3756. url: `/controller.php?taskDetail=${task.id}&show`,
  3757. method: 'get',
  3758. onload: response => {
  3759. if (debug) console.log(response)
  3760. if (response.status === 200) {
  3761. const src = response.responseText.match(/src="\.([\w\W]*?)">/)
  3762. if (src) {
  3763. fuc.httpRequest({
  3764. url: src[1],
  3765. method: 'get',
  3766. onload: response => {
  3767. if (debug) console.log(response)
  3768. if (response.status === 200) {
  3769. const href = response.responseText.match(/href="\.(\/verify[\w\W]*?)"/) || response.responseText.match(/href="\.(\/steamgroup[\w\W]*?)"/)
  3770. if (href) {
  3771. fuc.httpRequest({
  3772. url: '/werbung' + href[1],
  3773. method: 'get',
  3774. onload: response => {
  3775. if (debug) console.log(response)
  3776. if (response.status === 200 && /Task.*completed/gim.test(response.responseText)) {
  3777. status.success()
  3778. resolve()
  3779. } else {
  3780. const href = response.responseText.match(/href="\.(\/verify[\w\W]*?)"/) || response.responseText.match(/href="\.(\/steamgroup[\w\W]*?)"/)
  3781. if (href) {
  3782. fuc.httpRequest({
  3783. url: '/werbung' + href[1],
  3784. method: 'get',
  3785. onload: response => {
  3786. if (debug) console.log(response)
  3787. if (response.status === 200 && /Task.*completed/gim.test(response.responseText)) {
  3788. status.success()
  3789. } else {
  3790. status.error('Error:' + (response.statusText || response.status))
  3791. }
  3792. resolve()
  3793. },
  3794. r: resolve,
  3795. status
  3796. })
  3797. } else {
  3798. status.error('Error:' + (response.statusText || response.status))
  3799. resolve()
  3800. }
  3801. }
  3802. },
  3803. r: resolve,
  3804. status
  3805. })
  3806. } else {
  3807. status.error('Error:' + getI18n('getUrlFailed', '2'))
  3808. resolve()
  3809. }
  3810. } else {
  3811. status.error('Error:' + (response.statusText || response.status))
  3812. resolve()
  3813. }
  3814. },
  3815. r: resolve,
  3816. status
  3817. })
  3818. } else {
  3819. status.error('Error:' + getI18n('getUrlFailed', '1'))
  3820. resolve()
  3821. }
  3822. } else {
  3823. status.error('Error:' + (response.statusText || response.status))
  3824. resolve()
  3825. }
  3826. },
  3827. r: resolve,
  3828. status
  3829. })
  3830. }).then(() => {
  3831. return true
  3832. }).catch(() => {
  3833. return false
  3834. })
  3835. }
  3836. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font>,<font class="warning">${getI18n('finishSelf')}</font></li>` })
  3837. },
  3838. checkLeft: function (ui) {
  3839. const checkLeft = setInterval(() => {
  3840. if ($('#keysAvailable').length > 0) {
  3841. clearInterval(checkLeft)
  3842. if ($('#keysAvailable').text() === '0') {
  3843. ui.$confirm(getI18n('noKeysLeft'), getI18n('notice'), {
  3844. confirmButtonText: getI18n('confirm'),
  3845. cancelButtonText: getI18n('cancel'),
  3846. type: 'warning',
  3847. center: true
  3848. }).then(() => {
  3849. window.close()
  3850. })
  3851. }
  3852. }
  3853. }, 500)
  3854. },
  3855. tasks: [], // 任务信息
  3856. setting: {
  3857. fuck: true,
  3858. verify: false,
  3859. join: false,
  3860. remove: false
  3861. },
  3862. conf: GM_getValue('conf') ? ((GM_getValue('conf').spoune && GM_getValue('conf').spoune.load) ? GM_getValue('conf').spoune : (GM_getValue('conf').global || defaultConf)) : defaultConf
  3863. }
  3864.  
  3865. const takekey = {
  3866. test: () => { return window.location.host.includes('takekey') },
  3867. fuck: function () { this.get_tasks('do_task') },
  3868. get_tasks: function (callback = 'do_task') {
  3869. const taskInfoHistory = GM_getValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']')
  3870. if (taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) this.taskInfo = taskInfoHistory
  3871. if (callback === 'remove' && taskInfoHistory && !fuc.isEmptyObjArr(taskInfoHistory)) {
  3872. this.remove(true)
  3873. } else {
  3874. this.tasks = []
  3875. this.groups = []
  3876. // this.curators=[];
  3877. this.links = []
  3878. const pro = []
  3879. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('getTasksInfo')}<font></font></li>` })
  3880.  
  3881. const tasksContainer = $('#usl>div')
  3882. for (const task of tasksContainer) { // 遍历任务信息
  3883. this.tasks.push(task)
  3884. const icon = $(task).find('i')
  3885. const link = $(task).children('a[id]').attr('href')
  3886. const id = $(task).children('a[id]').attr('id')
  3887. if (icon.hasClass('fa-steam')) {
  3888. if (link && /gid\/[\d]+/.test(link)) {
  3889. pro.push(new Promise(r => { // eslint-disable-line
  3890. new Promise(resolve => {
  3891. fuc.getFinalUrl(resolve, link)
  3892. }).then(data => {
  3893. if (data.result === 'success') {
  3894. const groupName = data.finalUrl.match(/steamcommunity.com\/groups\/([\w\d\-_]*)/)[1]
  3895. if (groupName) {
  3896. this.groups.push(groupName)
  3897. this.taskInfo.groups.push(groupName)
  3898. r(1)
  3899. } else {
  3900. r(0)
  3901. }
  3902. } else {
  3903. r(0)
  3904. }
  3905. }).catch(() => {
  3906. r(0)
  3907. })
  3908. }))
  3909. }
  3910. } else if (icon.hasClass('fa-link')) {
  3911. this.links.push(id)
  3912. } else if (icon.hasClass('fa-vk')) {
  3913. this.vks.push(link)
  3914. } else {
  3915. this.others.push(icon)
  3916. }
  3917. }
  3918. Promise.all(pro).finally(() => {
  3919. this.groups = fuc.unique(this.groups)
  3920. // this.curators=fuc.unique(this.curators);
  3921. this.links = fuc.unique(this.links)
  3922. this.others = fuc.unique(this.others)
  3923. this.taskInfo.groups = fuc.unique(this.taskInfo.groups)
  3924. // this.taskInfo.curators=fuc.unique(this.taskInfo.curators);
  3925. this.tasks = fuc.unique(this.tasks)
  3926. GM_setValue('taskInfo[' + window.location.host + this.get_giveawayId() + ']', this.taskInfo)
  3927. status.success()
  3928. if (debug) console.log(this)
  3929. if (callback === 'do_task') {
  3930. if (this.tasks.length === 0) {
  3931. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3932. if (this.conf.fuck.verify) this.verify()
  3933. } else {
  3934. this.do_task()
  3935. }
  3936. } else {
  3937. !fuc.isEmptyObjArr(this.taskInfo) ? this.remove(true) : fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('cannotRemove')}</font></li>` })
  3938. }
  3939. })
  3940. }
  3941. },
  3942. do_task: function () {
  3943. this.updateSteamInfo(() => {
  3944. const pro = []
  3945. const groups = fuc.unique(this.groups)
  3946. // let curators = fuc.unique(this.curators);
  3947. const links = fuc.unique(this.links)
  3948. const others = fuc.unique(this.others)
  3949. const vks = fuc.unique(this.vks)
  3950. if (this.conf.fuck.group) {
  3951. for (const group of groups) {
  3952. pro.push(new Promise(resolve => {
  3953. fuc.joinSteamGroup(resolve, group)
  3954. }))
  3955. }
  3956. }
  3957. if (this.conf.fuck.visit) {
  3958. for (const link of links) {
  3959. const a = $(`a[id='${link}']`).attr('onclick', 'return false;')
  3960. a[0].click()
  3961. a.removeAttr('onclick')
  3962. pro.push(new Promise(resolve => {
  3963. fuc.visitLink(resolve, $(`a[id='${link}']`).attr('href'))
  3964. }))
  3965. }
  3966. }
  3967. if (globalConf.other.autoOpen) {
  3968. for (const vk of vks) {
  3969. window.open(vk, '_blank')
  3970. }
  3971. }
  3972. for (const other of others) {
  3973. fuc.echoLog({ type: 'custom', text: `<li><font class="warning">${getI18n('unknowntype')}:${$(other).attr('class')}</font></li>` })
  3974. }
  3975. Promise.all(pro).finally(() => {
  3976. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3977. if (this.conf.fuck.verify) this.verify()
  3978. })
  3979. })
  3980. },
  3981. verify: function () {
  3982. setTimeout(() => { $('.fa-check').click() }, 1000)
  3983. },
  3984. remove: function (remove = false) {
  3985. const pro = []
  3986. if (remove) {
  3987. this.updateSteamInfo(() => {
  3988. if (this.conf.remove.group) {
  3989. for (const group of fuc.unique(this.taskInfo.groups)) {
  3990. pro.push(new Promise(resolve => {
  3991. fuc.leaveSteamGroup(resolve, group)
  3992. }))
  3993. }
  3994. }
  3995. Promise.all(pro).finally(() => {
  3996. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('allTasksComplete')}</font></li>` })
  3997. })
  3998. })
  3999. } else {
  4000. this.get_tasks('remove')
  4001. }
  4002. },
  4003. get_giveawayId: function () {
  4004. const id = window.location.href.match(/distribution\/([\d]+)/)
  4005. return id ? id[1] : window.location.href
  4006. },
  4007. updateSteamInfo: function (callback) {
  4008. new Promise(resolve => {
  4009. if (this.taskInfo.groups.length > 0) {
  4010. if (this.taskInfo.curators.length > 0) {
  4011. fuc.updateSteamInfo(resolve, 'all')
  4012. } else {
  4013. fuc.updateSteamInfo(resolve, 'community')
  4014. }
  4015. } else if (this.taskInfo.curators.length > 0) {
  4016. fuc.updateSteamInfo(resolve, 'store')
  4017. } else {
  4018. resolve(1)
  4019. }
  4020. }).then(s => {
  4021. if (s === 1) callback()
  4022. }).catch(err => {
  4023. console.error(err)
  4024. })
  4025. },
  4026. checkLogin: function () {
  4027. if ($('i.fa-sign-in').length > 0) window.open('/auth/steam', '_self')
  4028. },
  4029. checkLeft: function (ui) {
  4030. const leftKey = $('span:contains(Осталось ключей),span:contains(Keys Left)').text().match(/[\d]+/)
  4031. if (!(leftKey && parseInt(leftKey[0]) > 0)) {
  4032. ui.$confirm(getI18n('noKeysLeft'), getI18n('notice'), {
  4033. confirmButtonText: getI18n('confirm'),
  4034. cancelButtonText: getI18n('cancel'),
  4035. type: 'warning',
  4036. center: true
  4037. }).then(() => {
  4038. window.close()
  4039. })
  4040. }
  4041. },
  4042. groups: [], // 任务需要加的组
  4043. curators: [], // 任务需要关注的鉴赏家
  4044. links: [], // 需要浏览的页面链接
  4045. others: [],
  4046. vks: [],
  4047. taskInfo: {
  4048. groups: [], // 所有任务需要加的组
  4049. curators: []// 所有任务需要关注的鉴赏家
  4050. },
  4051. tasks: [], // 任务信息
  4052. setting: {
  4053. fuck: true,
  4054. verify: true,
  4055. join: false,
  4056. remove: true
  4057. },
  4058. conf: GM_getValue('conf') ? ((GM_getValue('conf').takekey && GM_getValue('conf').takekey.load) ? GM_getValue('conf').takekey : (GM_getValue('conf').global || defaultConf)) : defaultConf
  4059. }
  4060.  
  4061. const loadSetting = function () {
  4062. const eNameToNameJoin = {
  4063. group: getI18n('group'),
  4064. curator: getI18n('curator'),
  4065. developer: getI18n('developer'),
  4066. publisher: getI18n('publisher'),
  4067. announcement: getI18n('announcement'),
  4068. wishlist: getI18n('wishlist'),
  4069. followGame: getI18n('fGame'),
  4070. visit: getI18n('visit'),
  4071. verify: getI18n('verify'),
  4072. autoLogin: getI18n('autoLogin'),
  4073. doTask: getI18n('doTask')
  4074. }
  4075. const eNameToNameRemove = {
  4076. group: getI18n('ungroup'),
  4077. curator: getI18n('uncurator'),
  4078. developer: getI18n('undeveloper'),
  4079. publisher: getI18n('unpublisher'),
  4080. wishlist: getI18n('unwishlist'),
  4081. unfollowGame: getI18n('unfGame')
  4082. }
  4083. const eNameToNameOther = {
  4084. showLogs: getI18n('showLogs'),
  4085. showDetails: getI18n('showDetails'),
  4086. checkLogin: getI18n('checkLogin'),
  4087. checkLeft: getI18n('checkLeft'),
  4088. autoOpen: getI18n('autoOpen'),
  4089. autoCheckUpdate: getI18n('checkUpdate'),
  4090. reCaptcha: getI18n('reCaptcha')
  4091. }
  4092. const Options = {
  4093. fuckOptions: [
  4094. { name: getI18n('group'), eName: 'group', des: 'Join XXX steam group' },
  4095. { name: getI18n('curator'), eName: 'curator', des: 'Follow XXX curator' },
  4096. { name: getI18n('developer'), eName: 'developer', des: 'Follow XXX developer' },
  4097. { name: getI18n('publisher'), eName: 'publisher', des: 'Follow XXX publisher' },
  4098. { name: getI18n('announcement'), eName: 'announcement', des: 'Like Steam announcement' },
  4099. { name: getI18n('wishlist'), eName: 'wishlist', des: 'Add XXX to your wishlist' },
  4100. { name: getI18n('fGame'), eName: 'followGame', des: 'Click "Follow" button' },
  4101. { name: getI18n('visit'), eName: 'visit', des: 'Visit XXX page' },
  4102. { name: getI18n('verify'), eName: 'verify', des: getI18n('verify') },
  4103. { name: getI18n('autoLogin'), eName: 'autoLogin', des: getI18n('autoLoginDes') },
  4104. { name: getI18n('doTask'), eName: 'doTask', des: getI18n('doTaskDes') }
  4105. ],
  4106. joinOptions: [
  4107. { name: getI18n('group'), eName: 'group', des: 'Join XXX steam group' },
  4108. { name: getI18n('curator'), eName: 'curator', des: 'Follow XXX curator' },
  4109. { name: getI18n('developer'), eName: 'developer', des: 'Follow XXX developer' },
  4110. { name: getI18n('publisher'), eName: 'publisher', des: 'Follow XXX publisher' },
  4111. { name: getI18n('announcement'), eName: 'announcement', des: 'Like Steam announcement' },
  4112. { name: getI18n('wishlist'), eName: 'wishlist', des: 'Add XXX to your wishlist' },
  4113. { name: getI18n('fGame'), eName: 'followGame', des: 'Click "Follow" button' },
  4114. { name: getI18n('visit'), eName: 'visit', des: 'Visit XXX page' }
  4115. ],
  4116. removeOptions: [
  4117. { name: getI18n('ungroup'), eName: 'group', des: getI18n('ungroupDes') },
  4118. { name: getI18n('uncurator'), eName: 'curator', des: getI18n('uncuratorDes') },
  4119. { name: getI18n('undeveloper'), eName: 'developer', des: getI18n('undeveloperDes') },
  4120. { name: getI18n('unpublisher'), eName: 'publisher', des: getI18n('unpublisherDes') },
  4121. { name: getI18n('unwishlist'), eName: 'wishlist', des: getI18n('unwishlistDes') },
  4122. { name: getI18n('unfGame'), eName: 'unfollowGame', des: getI18n('unfGameDes') }
  4123. ],
  4124. otherOptions: [
  4125. { name: getI18n('checkLogin'), eName: 'checkLogin', des: getI18n('checkLoginDes') },
  4126. { name: getI18n('checkLeft'), eName: 'checkLeft', des: getI18n('checkLeftDes') },
  4127. { name: getI18n('autoOpen'), eName: 'autoOpen', des: getI18n('autoOpenDes') },
  4128. { name: getI18n('showLogs'), eName: 'showLogs', des: getI18n('showLogsDes') },
  4129. { name: getI18n('showDetails'), eName: 'showDetails', des: getI18n('showDetailsDes') },
  4130. { name: getI18n('autoCheckUpdate'), eName: 'checkUpdate', des: getI18n('autoCheckUpdate') },
  4131. { name: getI18n('reCaptcha'), eName: 'reCaptcha', des: getI18n('reCaptchaDes') }
  4132. ],
  4133. checkedFucks: [getI18n('group'), getI18n('curator'), getI18n('developer'), getI18n('publisher'), getI18n('announcement'), getI18n('wishlist'), getI18n('fGame'), getI18n('visit'), getI18n('verify'), getI18n('autoLogin'), getI18n('doTask')],
  4134. checkedJoins: [getI18n('group'), getI18n('curator'), getI18n('developer'), getI18n('publisher'), getI18n('announcement'), getI18n('wishlist'), getI18n('fGame'), getI18n('visit')],
  4135. checkedRemoves: [getI18n('ungroup'), getI18n('uncurator'), getI18n('undeveloper'), getI18n('unpublisher'), getI18n('unwishlist'), getI18n('unfGame')],
  4136. checkedOthers: [getI18n('checkLogin'), getI18n('checkLeft'), getI18n('autoOpen'), getI18n('showLogs'), getI18n('showDetails'), getI18n('autoCheckUpdate'), getI18n('reCaptcha')]
  4137. }
  4138. function getOptions (type, options) {
  4139. const opt = []
  4140. const defaultOpt = Options[type]
  4141. options.map(function (e, i) {
  4142. opt.push(defaultOpt[e])
  4143. })
  4144. return opt
  4145. }
  4146.  
  4147. (function () {
  4148. const fuckOptions = getOptions('fuckOptions', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
  4149. const checkedFucks = (GM_getValue('conf') && GM_getValue('conf').global) ? (() => {
  4150. const conf = []
  4151. for (const eName of Object.keys(GM_getValue('conf').global.fuck)) {
  4152. conf.push(eNameToNameJoin[eName])
  4153. }
  4154. return conf
  4155. })() : getOptions('checkedFucks', [0, 1, 2, 3, 4, 5, 6, 7, 8, 10])
  4156.  
  4157. const joinOptions = getOptions('joinOptions', [0, 1, 2, 3, 4, 5, 6, 7])
  4158. const checkedJoins = (GM_getValue('conf') && GM_getValue('conf').global) ? (() => {
  4159. const conf = []
  4160. for (const eName of Object.keys(GM_getValue('conf').global.join)) {
  4161. conf.push(eNameToNameJoin[eName])
  4162. }
  4163. return conf
  4164. })() : getOptions('checkedJoins', [0, 1, 2, 3, 4, 5, 6, 7])
  4165.  
  4166. const removeOptions = getOptions('removeOptions', [0, 1, 2, 3, 4, 5])
  4167. const checkedRemoves = (GM_getValue('conf') && GM_getValue('conf').global) ? (() => {
  4168. const conf = []
  4169. for (const eName of Object.keys(GM_getValue('conf').global.remove)) {
  4170. conf.push(eNameToNameRemove[eName])
  4171. }
  4172. return conf
  4173. })() : getOptions('checkedRemoves', [0, 1, 2, 3, 4, 5])
  4174.  
  4175. const otherOptions = getOptions('otherOptions', [0, 1, 2, 3, 4, 5, 6])
  4176. const checkedOthers = (GM_getValue('conf') && GM_getValue('conf').global) ? (() => {
  4177. const conf = []
  4178. for (const eName of Object.keys(GM_getValue('conf').global.other)) {
  4179. conf.push(eNameToNameOther[eName])
  4180. }
  4181. return conf
  4182. })() : getOptions('checkedOthers', [0, 1, 3])
  4183.  
  4184. new Vue({ // eslint-disable-line no-new
  4185. el: '#global',
  4186. data: {
  4187. header: getI18n('globalSettings'),
  4188. fuck: {
  4189. checkAll: fuckOptions.length === checkedFucks.length,
  4190. checkedFucks: checkedFucks,
  4191. fucks: fuckOptions,
  4192. isIndeterminate: fuckOptions.length !== checkedFucks.length
  4193. },
  4194. join: {
  4195. checkAll: joinOptions.length === checkedJoins.length,
  4196. checkedJoins: checkedJoins,
  4197. joins: joinOptions,
  4198. isIndeterminate: joinOptions.length !== checkedJoins.length
  4199. },
  4200. remove: {
  4201. checkAll: removeOptions.length === checkedRemoves.length,
  4202. checkedRemoves: checkedRemoves,
  4203. removes: removeOptions,
  4204. isIndeterminate: removeOptions.length !== checkedRemoves.length
  4205. },
  4206. other: {
  4207. checkAll: otherOptions.length === checkedOthers.length,
  4208. checkedOthers: checkedOthers,
  4209. others: otherOptions,
  4210. isIndeterminate: otherOptions.length !== checkedOthers.length
  4211. },
  4212. openDelay: 100,
  4213. rowType: 'flex',
  4214. rowAlign: 'middle',
  4215. verify: '1'
  4216. },
  4217. methods: {
  4218. fuckHandleCheckAllChange (val) {
  4219. this.fuck.checkedFucks = val ? fuckOptions.map(e => e.name) : []
  4220. this.fuck.isIndeterminate = false
  4221. },
  4222. handleCheckedFucksChange (value) {
  4223. const checkedCount = value.length
  4224. this.fuck.checkAll = checkedCount === this.fuck.fucks.length
  4225. this.fuck.isIndeterminate = checkedCount > 0 && checkedCount < this.fuck.fucks.length
  4226. },
  4227. joinHandleCheckAllChange (val) {
  4228. this.join.checkedJoins = val ? joinOptions.map(e => e.name) : []
  4229. this.join.isIndeterminate = false
  4230. },
  4231. handleCheckedJoinsChange (value) {
  4232. const checkedCount = value.length
  4233. this.join.checkAll = checkedCount === this.join.joins.length
  4234. this.join.isIndeterminate = checkedCount > 0 && checkedCount < this.join.joins.length
  4235. },
  4236. removeHandleCheckAllChange (val) {
  4237. this.remove.checkedRemoves = val ? removeOptions.map(e => e.name) : []
  4238. this.remove.isIndeterminate = false
  4239. },
  4240. handleCheckedRemovesChange (value) {
  4241. const checkedCount = value.length
  4242. this.remove.checkAll = checkedCount === this.remove.removes.length
  4243. this.remove.isIndeterminate = checkedCount > 0 && checkedCount < this.remove.removes.length
  4244. },
  4245. otherHandleCheckAllChange (val) {
  4246. this.other.checkedOthers = val ? otherOptions.map(e => e.name) : []
  4247. this.other.isIndeterminate = false
  4248. },
  4249. handleCheckedOthersChange (value) {
  4250. const checkedCount = value.length
  4251. this.other.checkAll = checkedCount === this.other.others.length
  4252. this.other.isIndeterminate = checkedCount > 0 && checkedCount < this.other.others.length
  4253. }
  4254. }
  4255. })
  4256. })();
  4257. (function () {
  4258. const joinOptions = getOptions('joinOptions', [0, 1, 2, 3, 4, 5, 6])
  4259. const checkedJoins = (GM_getValue('conf') && GM_getValue('conf').giveawaysu) ? (() => {
  4260. const conf = []
  4261. for (const eName of Object.keys(GM_getValue('conf').giveawaysu.join)) {
  4262. conf.push(eNameToNameJoin[eName])
  4263. }
  4264. return conf
  4265. })() : getOptions('checkedJoins', [0, 1, 2, 3, 4, 5, 6])
  4266.  
  4267. const removeOptions = getOptions('removeOptions', [0, 1, 2, 3, 4, 5])
  4268. const checkedRemoves = (GM_getValue('conf') && GM_getValue('conf').giveawaysu) ? (() => {
  4269. const conf = []
  4270. for (const eName of Object.keys(GM_getValue('conf').giveawaysu.remove)) {
  4271. conf.push(eNameToNameRemove[eName])
  4272. }
  4273. return conf
  4274. })() : getOptions('checkedRemoves', [0, 1, 2, 3, 4, 5])
  4275.  
  4276. new Vue({ // eslint-disable-line no-new
  4277. el: '#giveawaysu',
  4278. data: {
  4279. header: 'giveaway.su' + getI18n('websiteSetting'),
  4280. checked: GM_getValue('conf') ? GM_getValue('conf').giveawaysu ? !!GM_getValue('conf').giveawaysu.load : false : false,
  4281. remove: {
  4282. checkAll: removeOptions.length === checkedRemoves.length,
  4283. checkedRemoves: checkedRemoves,
  4284. removes: removeOptions,
  4285. isIndeterminate: removeOptions.length !== checkedRemoves.length
  4286. },
  4287. join: {
  4288. checkAll: joinOptions.length === checkedJoins.length,
  4289. checkedJoins: checkedJoins,
  4290. joins: joinOptions,
  4291. isIndeterminate: joinOptions.length !== checkedJoins.length
  4292. },
  4293. openDelay: 100,
  4294. rowType: 'flex',
  4295. rowAlign: 'middle',
  4296. verify: '1'
  4297. },
  4298. methods: {
  4299. removeHandleCheckAllChange (val) {
  4300. this.remove.checkedRemoves = val ? removeOptions.map(e => e.name) : []
  4301. this.remove.isIndeterminate = false
  4302. },
  4303. handleCheckedRemovesChange (value) {
  4304. const checkedCount = value.length
  4305. this.remove.checkAll = checkedCount === this.remove.removes.length
  4306. this.remove.isIndeterminate = checkedCount > 0 && checkedCount < this.remove.removes.length
  4307. },
  4308. joinHandleCheckAllChange (val) {
  4309. this.join.checkedJoins = val ? joinOptions.map(e => e.name) : []
  4310. this.join.isIndeterminate = false
  4311. },
  4312. handleCheckedJoinsChange (value) {
  4313. const checkedCount = value.length
  4314. this.join.checkAll = checkedCount === this.join.joins.length
  4315. this.join.isIndeterminate = checkedCount > 0 && checkedCount < this.join.joins.length
  4316. }
  4317. }
  4318. })
  4319. })();
  4320. (function () {
  4321. const fuckOptions = getOptions('fuckOptions', [0, 1, 2, 3, 5, 6, 7, 8])
  4322. const checkedFucks = (GM_getValue('conf') && GM_getValue('conf').marvelousga) ? (() => {
  4323. const conf = []
  4324. for (const eName of Object.keys(GM_getValue('conf').marvelousga.fuck)) {
  4325. conf.push(eNameToNameJoin[eName])
  4326. }
  4327. return conf
  4328. })() : getOptions('checkedFucks', [0, 1, 2, 3, 5, 6, 7, 8])
  4329.  
  4330. const removeOptions = getOptions('removeOptions', [0, 1, 2, 3, 4, 5])
  4331. const checkedRemoves = (GM_getValue('conf') && GM_getValue('conf').marvelousga) ? (() => {
  4332. const conf = []
  4333. for (const eName of Object.keys(GM_getValue('conf').marvelousga.remove)) {
  4334. conf.push(eNameToNameRemove[eName])
  4335. }
  4336. return conf
  4337. })() : getOptions('checkedRemoves', [0, 1, 2, 3, 4, 5])
  4338.  
  4339. fuc.creatSetting('marvelousga', 'marvelousGA & dupedornot', fuckOptions, checkedFucks, removeOptions, checkedRemoves)
  4340. })();
  4341. (function () {
  4342. const fuckOptions = getOptions('fuckOptions', [0, 1, 2, 3, 5, 6, 7, 8])
  4343. const checkedFucks = (GM_getValue('conf') && GM_getValue('conf').banana) ? (() => {
  4344. const conf = []
  4345. for (const eName of Object.keys(GM_getValue('conf').banana.fuck)) {
  4346. conf.push(eNameToNameJoin[eName])
  4347. }
  4348. return conf
  4349. })() : getOptions('checkedFucks', [0, 1, 2, 3, 5, 6, 7, 8])
  4350.  
  4351. const removeOptions = getOptions('removeOptions', [0, 1, 2, 3, 4, 5])
  4352. const checkedRemoves = (GM_getValue('conf') && GM_getValue('conf').banana) ? (() => {
  4353. const conf = []
  4354. for (const eName of Object.keys(GM_getValue('conf').banana.remove)) {
  4355. conf.push(eNameToNameRemove[eName])
  4356. }
  4357. return conf
  4358. })() : getOptions('checkedRemoves', [0, 1, 2, 3, 4, 5])
  4359.  
  4360. fuc.creatSetting('banana', 'grabfreegame & bananagiveaway', fuckOptions, checkedFucks, removeOptions, checkedRemoves)
  4361. })();
  4362.  
  4363. (function () {
  4364. const fuckOptions = getOptions('fuckOptions', [0, 7, 8])
  4365. const checkedFucks = (GM_getValue('conf') && GM_getValue('conf').gamehag) ? (() => {
  4366. const conf = []
  4367. for (const eName of Object.keys(GM_getValue('conf').gamehag.fuck)) {
  4368. conf.push(eNameToNameJoin[eName])
  4369. }
  4370. return conf
  4371. })() : getOptions('checkedFucks', [0, 7, 8])
  4372.  
  4373. const removeOptions = getOptions('removeOptions', [0])
  4374. const checkedRemoves = (GM_getValue('conf') && GM_getValue('conf').gamehag) ? (() => {
  4375. const conf = []
  4376. for (const eName of Object.keys(GM_getValue('conf').gamehag.remove)) {
  4377. conf.push(eNameToNameRemove[eName])
  4378. }
  4379. return conf
  4380. })() : getOptions('checkedRemoves', [0])
  4381.  
  4382. fuc.creatSetting('gamehag', 'gamehag', fuckOptions, checkedFucks, removeOptions, checkedRemoves)
  4383. })();
  4384. (function () {
  4385. const fuckOptions = getOptions('fuckOptions', [0, 1, 8])
  4386. const checkedFucks = (GM_getValue('conf') && GM_getValue('conf').prys) ? (() => {
  4387. const conf = []
  4388. for (const eName of Object.keys(GM_getValue('conf').prys.fuck)) {
  4389. conf.push(eNameToNameJoin[eName])
  4390. }
  4391. return conf
  4392. })() : getOptions('checkedFucks', [0, 1, 8])
  4393.  
  4394. const removeOptions = getOptions('removeOptions', [0, 1])
  4395. const checkedRemoves = (GM_getValue('conf') && GM_getValue('conf').prys) ? (() => {
  4396. const conf = []
  4397. for (const eName of Object.keys(GM_getValue('conf').prys.remove)) {
  4398. conf.push(eNameToNameRemove[eName])
  4399. }
  4400. return conf
  4401. })() : getOptions('checkedRemoves', [0, 1])
  4402.  
  4403. fuc.creatSetting('prys', 'prys', fuckOptions, checkedFucks, removeOptions, checkedRemoves)
  4404. })();
  4405. (function () {
  4406. const fuckOptions = getOptions('fuckOptions', [0, 1, 5, 6, 7])
  4407. const checkedFucks = (GM_getValue('conf') && GM_getValue('conf').givekey) ? (() => {
  4408. const conf = []
  4409. for (const eName of Object.keys(GM_getValue('conf').givekey.fuck)) {
  4410. conf.push(eNameToNameJoin[eName])
  4411. }
  4412. return conf
  4413. })() : getOptions('checkedFucks', [0, 1, 5, 6, 7])
  4414.  
  4415. const removeOptions = getOptions('removeOptions', [0, 1, 4, 5])
  4416. const checkedRemoves = (GM_getValue('conf') && GM_getValue('conf').givekey) ? (() => {
  4417. const conf = []
  4418. for (const eName of Object.keys(GM_getValue('conf').givekey.remove)) {
  4419. conf.push(eNameToNameRemove[eName])
  4420. }
  4421. return conf
  4422. })() : getOptions('checkedRemoves', [0, 1, 4, 5])
  4423.  
  4424. fuc.creatSetting('givekey', 'givekey.ru', fuckOptions, checkedFucks, removeOptions, checkedRemoves)
  4425. })();
  4426. (function () {
  4427. const fuckOptions = getOptions('fuckOptions', [0, 7])
  4428. const checkedFucks = (GM_getValue('conf') && GM_getValue('conf').takekey) ? (() => {
  4429. const conf = []
  4430. for (const eName of Object.keys(GM_getValue('conf').takekey.fuck)) {
  4431. conf.push(eNameToNameJoin[eName])
  4432. }
  4433. return conf
  4434. })() : getOptions('checkedFucks', [0, 7])
  4435.  
  4436. const removeOptions = getOptions('removeOptions', [0])
  4437. const checkedRemoves = (GM_getValue('conf') && GM_getValue('conf').takekey) ? (() => {
  4438. const conf = []
  4439. for (const eName of Object.keys(GM_getValue('conf').takekey.remove)) {
  4440. conf.push(eNameToNameRemove[eName])
  4441. }
  4442. return conf
  4443. })() : getOptions('checkedRemoves', [0])
  4444.  
  4445. fuc.creatSetting('takekey', 'takekey.ru', fuckOptions, checkedFucks, removeOptions, checkedRemoves)
  4446. })();
  4447. (function () {
  4448. const fuckOptions = getOptions('fuckOptions', [0, 7, 8])
  4449. const checkedFucks = (GM_getValue('conf') && GM_getValue('conf').gleam) ? (() => {
  4450. const conf = []
  4451. for (const eName of Object.keys(GM_getValue('conf').gleam.fuck)) {
  4452. conf.push(eNameToNameJoin[eName])
  4453. }
  4454. return conf
  4455. })() : getOptions('checkedFucks', [0, 7, 8])
  4456.  
  4457. const removeOptions = getOptions('removeOptions', [0])
  4458. const checkedRemoves = (GM_getValue('conf') && GM_getValue('conf').gleam) ? (() => {
  4459. const conf = []
  4460. for (const eName of Object.keys(GM_getValue('conf').gleam.remove)) {
  4461. conf.push(eNameToNameRemove[eName])
  4462. }
  4463. return conf
  4464. })() : getOptions('checkedRemoves', [0])
  4465.  
  4466. fuc.creatSetting('gleam', 'gleam.io', fuckOptions, checkedFucks, removeOptions, checkedRemoves)
  4467. })();
  4468. (function () {
  4469. const fuckOptions = getOptions('fuckOptions', [9, 10])
  4470. const checkedFucks = (GM_getValue('conf') && GM_getValue('conf').freegamelottery) ? (() => {
  4471. const conf = []
  4472. for (const eName of Object.keys(GM_getValue('conf').freegamelottery.fuck)) {
  4473. conf.push(eNameToNameJoin[eName])
  4474. }
  4475. return conf
  4476. })() : getOptions('checkedFucks', [10])
  4477.  
  4478. new Vue({ // eslint-disable-line no-new
  4479. el: '#freegamelottery',
  4480. data: {
  4481. header: 'freegamelottery' + getI18n('websiteSetting'),
  4482. checked: GM_getValue('conf') ? GM_getValue('conf').freegamelottery ? !!GM_getValue('conf').freegamelottery.load : false : false,
  4483. fuck: {
  4484. checkAll: fuckOptions.length === checkedFucks.length,
  4485. checkedFucks: checkedFucks,
  4486. fucks: fuckOptions,
  4487. isIndeterminate: fuckOptions.length !== checkedFucks.length
  4488. },
  4489. openDelay: 100,
  4490. rowType: 'flex',
  4491. rowAlign: 'middle',
  4492. verify: '1'
  4493. },
  4494. methods: {
  4495. fuckHandleCheckAllChange (val) {
  4496. this.fuck.checkedFucks = val ? fuckOptions.map(e => e.name) : []
  4497. this.fuck.isIndeterminate = false
  4498. },
  4499. handleCheckedFucksChange (value) {
  4500. const checkedCount = value.length
  4501. this.fuck.checkAll = checkedCount === this.fuck.fucks.length
  4502. this.fuck.isIndeterminate = checkedCount > 0 && checkedCount < this.fuck.fucks.length
  4503. }
  4504. }
  4505. })
  4506. })();
  4507.  
  4508. (function () {
  4509. new Vue({ // eslint-disable-line no-new
  4510. el: '#save',
  4511. data: {
  4512. title: getI18n('saveSetting')
  4513. },
  4514. methods: {
  4515. save () {
  4516. const conf = fuc.creatConf()
  4517. GM_setValue('conf', conf)
  4518. this.$notify({
  4519. title: getI18n('saveSuccess'),
  4520. type: 'success'
  4521. })
  4522. }
  4523. }
  4524. })
  4525. new Vue({ // eslint-disable-line no-new
  4526. el: '#reset',
  4527. data: {
  4528. title: getI18n('resetSetting')
  4529. },
  4530. methods: {
  4531. reset () {
  4532. this.$confirm(getI18n('resetSettingNotice'), getI18n('notice'), {
  4533. confirmButtonText: getI18n('confirm'),
  4534. cancelButtonText: getI18n('cancel'),
  4535. type: 'warning'
  4536. }).then(() => {
  4537. GM_deleteValue('conf')
  4538. if (!GM_getValue('conf')) {
  4539. vueUi.$message({
  4540. type: 'success',
  4541. message: getI18n('resetSettingSuccess')
  4542. })
  4543. } else {
  4544. vueUi.$message({
  4545. type: 'error',
  4546. message: getI18n('resetSettingFailed')
  4547. })
  4548. }
  4549. }).catch(() => {
  4550. vueUi.$message({
  4551. type: 'info',
  4552. message: getI18n('resetSettingCancel')
  4553. })
  4554. })
  4555. }
  4556. }
  4557. })
  4558. new Vue({ // eslint-disable-line no-new
  4559. el: '#download',
  4560. data: {
  4561. title: getI18n('downloadSetting')
  4562. },
  4563. methods: {
  4564. download () {
  4565. const msg = vueUi.$message({
  4566. type: 'info',
  4567. message: getI18n('processSetting')
  4568. })
  4569. const conf = fuc.creatConf()
  4570. const creatFile = new FileReader()
  4571. creatFile.onload = () => {
  4572. $(`<a href="${creatFile.result}" download="auto-task.conf.json" target="_self"></a>`)[0].click()
  4573. }
  4574. creatFile.onerror = (e) => {
  4575. if (debug) console.log(e)
  4576. msg.close()
  4577. vueUi.$message({
  4578. type: 'error',
  4579. message: getI18n('creatUrlFailed')
  4580. })
  4581. }
  4582. creatFile.readAsDataURL(new File([JSON.stringify(conf, null, 4)], 'setting.conf.txt'))
  4583. }
  4584. }
  4585. })
  4586. new Vue({ // eslint-disable-line no-new
  4587. el: '#upload2',
  4588. data: {
  4589. title: getI18n('loadSetting'),
  4590. multiple: false,
  4591. sfl: false,
  4592. accept: 'json',
  4593. httpRequest: () => { }
  4594. },
  4595. methods: {
  4596. upload (file) {
  4597. const msg = vueUi.$message({
  4598. type: 'info',
  4599. message: getI18n('readSetting')
  4600. })
  4601. if (window.FileReader) {
  4602. const reader = new FileReader()
  4603. reader.onload = () => {
  4604. if (debug) console.log(reader.result)
  4605. msg.close()
  4606. const cMsg = vueUi.$message({
  4607. type: 'success',
  4608. message: getI18n('readSettingComplete')
  4609. })
  4610. try {
  4611. GM_setValue('conf', JSON.parse(reader.result))
  4612. cMsg.close()
  4613. vueUi.$message({
  4614. type: 'success',
  4615. message: getI18n('loadSettingComplete')
  4616. })
  4617. window.location.reload()
  4618. } catch (e) {
  4619. cMsg.close()
  4620. vueUi.$message({
  4621. type: 'error',
  4622. message: `${getI18n('loadSettingFailed')}!`
  4623. })
  4624. if (debug) console.log(`${getI18n('loadSettingFailed')}: `, e)
  4625. }
  4626. }
  4627. reader.onerror = (e) => {
  4628. if (debug) console.log(e)
  4629. msg.close()
  4630. vueUi.$message({
  4631. type: 'error',
  4632. message: getI18n('readSettingFailed')
  4633. })
  4634. }
  4635. reader.readAsText(file)
  4636. } else {
  4637. msg.close()
  4638. vueUi.$message({
  4639. type: 'warning',
  4640. duration: 5000,
  4641. message: getI18n('notSupport')
  4642. })
  4643. this.$msgbox({
  4644. title: getI18n('copySetting'),
  4645. type: 'info',
  4646. showClose: false,
  4647. showCancelButton: true,
  4648. confirmButtonText: getI18n('confirm'),
  4649. cancelButtonText: getI18n('cancel'),
  4650. closeOnClickModal: false,
  4651. closeOnPressEscape: false,
  4652. closeOnHashChange: false,
  4653. center: true,
  4654. showInput: true,
  4655. inputType: 'textarea'
  4656. })
  4657. .then(({ value }) => {
  4658. if (debug) console.log(value)
  4659. const cMsg = vueUi.$message({
  4660. type: 'info',
  4661. message: getI18n('loadSettingText')
  4662. })
  4663. try {
  4664. GM_setValue('conf', JSON.parse(value))
  4665. cMsg.close()
  4666. vueUi.$message({
  4667. type: 'success',
  4668. message: getI18n('loadSettingComplete')
  4669. })
  4670. window.location.reload()
  4671. } catch (e) {
  4672. cMsg.close()
  4673. vueUi.$message({
  4674. type: 'error',
  4675. message: `${getI18n('loadSettingFailed')}!`
  4676. })
  4677. if (debug) console.log(`${getI18n('loadSettingFailed')}: `, e)
  4678. }
  4679. })
  4680. .catch(action => {
  4681. vueUi.$message({
  4682. type: 'info',
  4683. message: getI18n('cancelled')
  4684. })
  4685. })
  4686. }
  4687. this.$refs.upload.abort(file.name)
  4688. }
  4689. }
  4690. })
  4691. })();
  4692. (function () {
  4693. const maxPoint = GM_getValue('conf') ? GM_getValue('conf').opiumpulses ? (GM_getValue('conf').opiumpulses['max-point'] || 0) : 0 : 0
  4694.  
  4695. new Vue({ // eslint-disable-line no-new
  4696. el: '#opiumpulses',
  4697. data: {
  4698. header: 'opiumpulses' + getI18n('websiteSetting'),
  4699. checked: GM_getValue('conf') ? GM_getValue('conf').opiumpulses ? !!GM_getValue('conf').opiumpulses.load : false : false,
  4700. maxPoint: maxPoint,
  4701. openDelay: 100,
  4702. rowType: 'flex',
  4703. rowAlign: 'middle',
  4704. verify: '1'
  4705. }
  4706. })
  4707. })()
  4708. }
  4709.  
  4710. const loadAnnouncement = function () {
  4711. new Promise(resolve => {
  4712. fuc.httpRequest({
  4713. url: 'https://userjs.hclonely.com/announcement.json',
  4714. method: 'get',
  4715. dataType: 'json',
  4716. onload: response => {
  4717. if (debug) console.log(response)
  4718. if (response.status === 200 && response.response) {
  4719. resolve({ result: 'success', data: response.response })
  4720. } else {
  4721. resolve({ result: 'error', data: response })
  4722. }
  4723. },
  4724. r: resolve
  4725. })
  4726. }).then(data => {
  4727. if (data.result === 'success') {
  4728. const announcements = data.data
  4729. announcements.map(e => {
  4730. e.time = fuc.dateFormat('YYYY-mm-dd HH:MM', new Date(e.time))
  4731. return e
  4732. })
  4733. new Vue({ // eslint-disable-line no-new
  4734. el: '#app',
  4735. data: { announcements }
  4736. })
  4737. } else {
  4738. vueUi.$message({ type: 'error', duration: 0, message: `${getI18n('loadAnnouncementFailed')}${data.statusText || getI18n('checkConsole')}!`, showClose: true })
  4739. console.error(data)
  4740. }
  4741. }).catch(error => {
  4742. vueUi.$message({ type: 'error', duration: 0, message: `${getI18n('loadAnnouncementFailed') + getI18n('checkConsole')}`, showClose: true })
  4743. console.error(error)
  4744. })
  4745. }
  4746.  
  4747. const plugins = [banana, freegamelottery, gamehag, giveawaysu, givekey, gleam, indiedb, marvelousga, opiumpulses, prys, spoune, takekey]
  4748.  
  4749. if (window.location.host.includes('hclonely')) {
  4750. if (window.location.pathname.includes('setting')) {
  4751. fuc.addBackground()
  4752. loadSetting()
  4753. } else if (window.location.pathname.includes('announcement')) {
  4754. fuc.addBackground()
  4755. loadAnnouncement()
  4756. }
  4757. } else if ((window.location.host.includes('marvelousga') || window.location.host.includes('dupedornot') || window.location.host.includes('gamecode.win')) && (!window.location.pathname.includes('giveaway'))) {
  4758. fuc.newTabBlock()
  4759. } else {
  4760. let website = {}
  4761. plugins.map((e, i) => {
  4762. if (e.test()) {
  4763. website = e
  4764. if (website.before) website.before(website)
  4765. }
  4766. })
  4767.  
  4768. if (globalConf.other.checkLogin && website.checkLogin) website.checkLogin()
  4769. if (globalConf.other.checkLeft && website.checkLeft) website.checkLeft(vueUi)
  4770.  
  4771. $('body').append(`
  4772. <div id="fuck-task-app">
  4773. <div v-cloak id="fuck-task-btn">
  4774. <el-button :style="style" @click="toggleThisDiv" :icon="icon" :title="title" :show="show"></el-button>
  4775. <el-button type="primary" v-for="item in buttons" v-if="item.show" @click="item.click" :id="item.id" :title="item.title">{{item.text}}</el-button>
  4776. <el-button type="primary" @click="toggle" :id="drawerBtn.id" :title="drawerBtn.title">{{drawerBtn.text}}</el-button>
  4777. </div>
  4778. <div id="fuck-task-info"></div>
  4779. </div>
  4780. `)
  4781. const showLogs = globalConf.other ? globalConf.other.showLogs : defaultConf.other.showLogs
  4782.  
  4783. let btnNum = 1
  4784. for (const boolean of Object.values(website.setting)) {
  4785. if (boolean === true) btnNum++
  4786. }
  4787.  
  4788. const btnArea = new Vue({
  4789. el: '#fuck-task-btn',
  4790. data: {
  4791. icon: 'el-icon-arrow-right',
  4792. title: getI18n('hide'),
  4793. show: true,
  4794. style: `position:absolute;left:-20px;width:20px;border:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;padding:0;height:${btnNum * 40}px;opacity:80%;`,
  4795. buttons: [
  4796. {
  4797. id: 'fuck-task',
  4798. text: website.setting.fuckText || 'FuckTask',
  4799. title: website.setting.fuckTitle || getI18n('fuckBtnTitle'),
  4800. show: website.setting.fuck,
  4801. click: () => { website.fuck(btnArea) }
  4802. },
  4803. {
  4804. id: 'verify-task',
  4805. text: website.setting.verifyText || 'Verify',
  4806. title: website.setting.verifyTitle || getI18n('verifyBtnTitle'),
  4807. show: website.setting.verify,
  4808. click: () => { website.verify() }
  4809. },
  4810. {
  4811. id: 'join-task',
  4812. text: website.setting.joinText || 'Join',
  4813. title: website.setting.joinDes || getI18n('joinBtnTitle'),
  4814. show: website.setting.join,
  4815. click: () => { website.join() }
  4816. },
  4817. {
  4818. id: 'remove-task',
  4819. text: website.setting.removeText || 'Remove',
  4820. title: website.setting.removeTitle || getI18n('removeBtnTitle'),
  4821. show: website.setting.remove,
  4822. click: () => { website.remove() }
  4823. }
  4824. ],
  4825. drawerBtn: {
  4826. id: 'show-logs',
  4827. text: !showLogs ? 'ShowLogs' : 'HideLogs',
  4828. title: !showLogs ? getI18n('showLog') : getI18n('hideLog'),
  4829. show: !!showLogs
  4830. }
  4831. },
  4832. methods: {
  4833. toggleThisDiv () {
  4834. if (this.show) {
  4835. this.icon = 'el-icon-arrow-left'
  4836. this.title = getI18n('show')
  4837. $('#fuck-task-btn').animate({ width: '0' })
  4838. } else {
  4839. this.icon = 'el-icon-arrow-right'
  4840. this.title = getI18n('hide')
  4841. $('#fuck-task-btn').animate({ width: '110' })
  4842. }
  4843. this.show = !this.show
  4844. },
  4845. toggle () {
  4846. if (this.drawerBtn.show) {
  4847. this.drawerBtn.text = 'ShowLogs'
  4848. this.drawerBtn.title = getI18n('showLog')
  4849. $('.fuck-task-logs').animate({ right: '-100%' }, 'fast')
  4850. } else {
  4851. this.drawerBtn.text = 'HideLogs'
  4852. this.drawerBtn.title = getI18n('hideLog')
  4853. $('.fuck-task-logs').animate({ right: '16px' }, 'fast')
  4854. }
  4855. this.drawerBtn.show = !this.drawerBtn.show
  4856. }
  4857. }
  4858. })
  4859. new Vue({
  4860. el: '#fuck-task-info'
  4861. }).$notify({
  4862. title: getI18n('taskLog'),
  4863. iconClass: '',
  4864. duration: 0,
  4865. position: 'bottom-right',
  4866. showClose: false,
  4867. customClass: 'fuck-task-logs',
  4868. dangerouslyUseHTMLString: true,
  4869. message: ''
  4870. })
  4871. $('.fuck-task-logs .el-notification__title').before(`
  4872. <h2 v-cloak id="extraBtn" class="el-notification__title">
  4873. <el-badge is-dot class="item" :hidden="hidden">
  4874. <el-button :icon="icon" :title="title" @click="checkUpdate" circle></el-button>
  4875. </el-badge>
  4876. <el-badge is-dot class="item" :hidden="settingHidden">
  4877. <el-button icon="el-icon-setting" title="${getI18n('setting')}" @click="setting" circle></el-button>
  4878. </el-badge>
  4879. <el-badge is-dot class="item" :hidden="announcementHidden">
  4880. <el-button :icon="announcementIcon" title="${getI18n('visitUpdateText')}" @click="updateText" circle></el-button>
  4881. </el-badge>
  4882. <el-badge is-dot class="item" :hidden="otherHidden">
  4883. <el-button icon="el-icon-brush" title="${getI18n('cleanCache')}" @click="clearTemp" circle></el-button>
  4884. </el-badge>
  4885. <el-badge is-dot class="item" :hidden="otherHidden">
  4886. <el-button icon="el-icon-s-promotion" title="${getI18n('feedback')}" @click="updateBug" circle></el-button>
  4887. </el-badge>
  4888. </h2>
  4889. `)
  4890. const extraBtn = new Vue({
  4891. el: '#extraBtn',
  4892. data: {
  4893. title: getI18n('checkUpdate'),
  4894. icon: 'el-icon-refresh',
  4895. hidden: true,
  4896. settingHidden: !!GM_getValue('conf'),
  4897. otherHidden: true,
  4898. announcementHidden: true,
  4899. announcementIcon: 'el-icon-document'
  4900. },
  4901. methods: {
  4902. setting () {
  4903. language === 'en' ? window.open('https://userjs.hclonely.com/setting_en.html', '_blank') : window.open('https://userjs.hclonely.com/setting.html', '_blank')
  4904. },
  4905. updateText () {
  4906. fuc.getAnnouncement(this)
  4907. },
  4908. updateBug () {
  4909. window.open('https://github.com/HCLonely/auto-task/issues/new/choose', '_blank')
  4910. },
  4911. checkUpdate () {
  4912. fuc.checkUpdate(this, true)
  4913. },
  4914. clearTemp () {
  4915. const status = fuc.echoLog({ type: 'custom', text: `<li>${getI18n('cleaning')}<font></font></li>` })
  4916. const listValues = GM_listValues()
  4917. for (const value of listValues) {
  4918. if (value !== 'conf' && value !== 'language') GM_deleteValue(value)
  4919. }
  4920. status.success()
  4921. }
  4922. }
  4923. })
  4924.  
  4925. if (globalConf.other.checkUpdate) fuc.checkUpdate(extraBtn)
  4926.  
  4927. $('.fuck-task-logs .el-notification__content').show()
  4928. if (!showLogs) {
  4929. $('.fuck-task-logs').animate({
  4930. right: '-100%',
  4931. display: '-webkit-box',
  4932. display: '-ms-flexbox', // eslint-disable-line no-dupe-keys
  4933. display: 'flex' // eslint-disable-line no-dupe-keys
  4934. }, 0)
  4935. }
  4936. if (website.after) website.after(website)
  4937. }
  4938.  
  4939. GM_registerMenuCommand(getI18n('readme'), () => { window.open('https://blog.hclonely.com/posts/777c60d5/', '_blank') })
  4940. GM_registerMenuCommand(getI18n('updateSteamInfo'), () => {
  4941. new Promise(resolve => {
  4942. fuc.updateSteamInfo(resolve, 'all', true)
  4943. }).then(r => {
  4944. fuc.echoLog({ type: 'custom', text: `<li><font class="success">${getI18n('updateSteamInfoComplete')}</font></li>` })
  4945. })
  4946. })
  4947. GM_registerMenuCommand('Language', () => {
  4948. vueUi.$msgbox({
  4949. title: getI18n('language') + ' : ' + language,
  4950. message: `<select id="auto-task-language"><option value="auto">${getI18n('auto')}</option><option value="zh-cn">简体中文</option><option value="en">English</option></select>`,
  4951. dangerouslyUseHTMLString: true,
  4952. confirmButtonText: getI18n('confirm'),
  4953. cancelButtonText: getI18n('cancel'),
  4954. type: 'info'
  4955. }).then(value => {
  4956. if (value) GM_setValue('language', $('#auto-task-language option:selected').val())
  4957. language = getLanguage()
  4958. })
  4959. })
  4960. } catch (e) {
  4961. setTimeout(() => {
  4962. vueUi.$message({ type: 'error', duration: 0, message: getI18n('jsError'), showClose: true })
  4963. }, 500)
  4964. console.log('%c%s', 'color:white;background:red', e.stack)
  4965. }
  4966. })()