auto-task-v4

自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。

当前为 2023-05-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.34
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12. // @icon https://auto-task-v4.hclonely.com/favicon.ico
  13.  
  14. // @include *://freeanywhere.net/*
  15. // @include *://giveaway.su/giveaway/view/*
  16. // @include *://givee.club/*/event/*
  17. // @include *://givekey.ru/giveaway/*
  18. // @include *://www.indiedb.com/giveaways*
  19. // @include *://key-hub.eu/giveaway/*
  20. // @include *://keylol.com/*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://prys.revadike.com/giveaway/?id=*
  23. // @include *://opquests.com/quests/*
  24. // @include *://gleam.io/*
  25. // @include *://sweepwidget.com/view/*
  26. // @include *://discord.com/*
  27. // @include *://www.twitch.tv/*
  28. // @include *://www.youtube.com/*
  29. // @include *://*.reddit.com/*
  30. // @include *://twitter.com/settings/account?k*
  31. // @include https://auto-task-v4.hclonely.com/setting.html
  32. // @include https://auto-task-v4.hclonely.com/history.html
  33.  
  34. // @grant GM_setValue
  35. // @grant GM_getValue
  36. // @grant GM_listValues
  37. // @grant GM_deleteValue
  38. // @grant GM_addStyle
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_info
  42. // @grant GM_openInTab
  43. // @grant GM_setClipboard
  44. // @grant GM_getResourceText
  45. // @grant unsafeWindow
  46. // @grant window.close
  47. // @grant window.localStorage
  48.  
  49. // @connect cdn.jsdelivr.net
  50. // @connect store.steampowered.com
  51. // @connect steamcommunity.com
  52. // @connect login.steampowered.com
  53. // @connect twitter.com
  54. // @connect api.twitter.com
  55. // @connect youtube.com
  56. // @connect www.youtube.com
  57. // @connect facebook.com
  58. // @connect instagram.com
  59. // @connect vk.com
  60. // @connect twitch.tv
  61. // @connect www.twitch.tv
  62. // @connect gql.twitch.tv
  63. // @connect github.com
  64. // @connect discordapp.com
  65. // @connect discord.gg
  66. // @connect discord.com
  67. // @connect www.reddit.com
  68. // @connect oauth.reddit.com
  69. // @connect raw.githubusercontent.com
  70. // @connect t.me
  71. // @connect bit.ly
  72. // @connect giveaway.su
  73. // @connect google.com
  74. // @connect www.vloot.io
  75. // @connect givee.club
  76. // @connect gleam.io
  77. // @connect www.indiedb.com
  78. // @connect key-hub.eu
  79. // @connect opquests.com
  80. // @connect itch.io
  81. // @connect auto-task-v4.hclonely.com
  82. // @connect *
  83. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  84. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  85. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  86. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  87. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  88. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  89. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  90. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  91.  
  92. // @noframes
  93. // ==/UserScript==
  94.  
  95. console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
  96.  
  97. (function() {
  98. var __webpack_modules__ = {
  99. 588: function(__unused_webpack_module, exports) {
  100. !function(e, n) {
  101. true ? n(exports) : 0;
  102. }(this, function(e) {
  103. 'use strict';
  104. var t = function() {
  105. return (t = Object.assign || function(e) {
  106. for (var n, o = 1, t = arguments.length; o < t; o++) {
  107. for (var r in n = arguments[o]) {
  108. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  109. }
  110. }
  111. return e;
  112. }).apply(this, arguments);
  113. };
  114. function r(e, n, o) {
  115. if (o || 2 === arguments.length) {
  116. for (var t, r = 0, i = n.length; r < i; r++) {
  117. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  118. }
  119. }
  120. return e.concat(t || Array.prototype.slice.call(n));
  121. }
  122. function d(e) {
  123. return '[object Object]' === n(e);
  124. }
  125. function l(e, n) {
  126. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  127. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  128. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  129. });
  130. }
  131. var n = function(e) {
  132. return Object.prototype.toString.call(e);
  133. };
  134. var o = (i.prototype.init = function() {
  135. try {
  136. this.getSystemName(), this.getBrowserName();
  137. } catch (e) {
  138. console.warn('[UA formatter error] '.concat(e));
  139. }
  140. }, i.prototype.getEngine = function() {
  141. var e = this.agent;
  142. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  143. }, i.prototype.getSystemName = function() {
  144. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  145. try {
  146. var o = '';
  147. if (/Windows/i.test(n)) {
  148. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  149. switch (this.info.os = 'Windows', t) {
  150. case '6.3':
  151. o = '8.1';
  152. break;
  153.  
  154. case '6.2':
  155. o = '8';
  156. break;
  157.  
  158. case '6.1':
  159. o = '7';
  160. break;
  161.  
  162. case '5.2':
  163. case '5.1':
  164. o = 'XP';
  165. break;
  166.  
  167. default:
  168. o = t;
  169. }
  170. return this.info.device = 'PC', void (this.info.osVersion = o);
  171. }
  172. if (/^Macintosh/i.test(n)) {
  173. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  174. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  175. }
  176. if (/^iPad/i.test(n)) {
  177. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  178. void (this.info.osVersion = o.replace(/_/g, '.'));
  179. }
  180. if (/^iPhone/i.test(n)) {
  181. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  182. void (this.info.osVersion = o.replace(/_/g, '.'));
  183. }
  184. if (-1 !== n.indexOf('Android')) {
  185. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  186. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  187. }
  188. if (/Linux\s[a-z\d_]+/.test(n)) {
  189. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  190. }
  191. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  192. } catch (e) {
  193. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  194. }
  195. }, i.prototype.getBrowserName = function() {
  196. var e = Object.keys(this.browserNameMap).map(function(e) {
  197. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  198. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  199. return -1 !== e.findIndex(function(e) {
  200. return e.test(n);
  201. });
  202. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  203. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  204. }, i.prototype._formatBrowserVersion = function(e) {
  205. var n, o, t, r;
  206. try {
  207. for (var i = null !== (o = null === (n = e.match(/(?<name>[a-z\d]+)(\/|\s)(?<version>(\d+\.)+\d+)/i)) || void 0 === n ? void 0 : n.groups) && void 0 !== o ? o : {}, s = i.name, a = i.version, c = {}, f = 0, u = Object.entries(this.browserNameMap); f < u.length; f++) {
  208. var d = u[f], l = d[0], h = d[1];
  209. if (new RegExp(l).test(s)) {
  210. c = h;
  211. break;
  212. }
  213. }
  214. var p = {
  215. browserVersion: null != a ? a : 'Unknown',
  216. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  217. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  218. };
  219. return 'Trident' === s && (p.browserVersion = {
  220. '4.0': 8,
  221. '5.0': 9,
  222. '6.0': 10,
  223. '7.0': 11
  224. }[a]), p;
  225. } catch (e) {
  226. return console.warn('[UA formatter error] '.concat(e)), {
  227. browser: 'Unknown',
  228. browserVersion: 'Unknown'
  229. };
  230. }
  231. }, i);
  232. function i(e) {
  233. this.agent = '', this.info = {
  234. browser: '',
  235. browserZH: '',
  236. browserVersion: '',
  237. os: '',
  238. osVersion: '',
  239. device: 'Unknown',
  240. engine: 'WebKit'
  241. }, this.browserNameMap = {
  242. MicroMessenger: {
  243. en: 'MicroMessenger',
  244. zh: '微信'
  245. },
  246. MetaSr: {
  247. en: 'MetaSr',
  248. zh: '搜狗浏览器'
  249. },
  250. 'QQ(Browser)?': {
  251. en: 'QQBrowser',
  252. zh: 'QQ浏览器'
  253. },
  254. UCBrowser: {
  255. en: 'UCBrowser',
  256. zh: 'UC浏览器'
  257. },
  258. '2345Explorer': {
  259. en: '2345Explorer',
  260. zh: '2345极速浏览器'
  261. },
  262. Mb2345Browser: {
  263. en: 'Mb2345Browser',
  264. zh: '2345手机浏览器'
  265. },
  266. Trident: {
  267. en: 'Internet Explorer'
  268. },
  269. 'Edge?': {
  270. en: 'Edge'
  271. },
  272. OPR: {
  273. en: 'Opera'
  274. },
  275. Vivaldi: {
  276. en: 'Vivaldi'
  277. },
  278. Firefox: {
  279. en: 'Firefox'
  280. },
  281. Chrome: {
  282. en: 'Chrome'
  283. },
  284. Safari: {
  285. en: 'Safari'
  286. }
  287. }, this.agent = e, this.init();
  288. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  289. this.info = t(t({}, this.info), {
  290. engine: this.getEngine(),
  291. browserVersion: 'Safari' === o ? n : e
  292. });
  293. }
  294. function s() {
  295. this.cookies = {}, this.init();
  296. }
  297. var a = new (s.prototype.init = function() {
  298. var o = {};
  299. document.cookie.split(/;\s/).forEach(function(e) {
  300. var n = e.split(/=/), e = n[0], n = n[1];
  301. o[e] = n;
  302. }), this.cookies = o;
  303. }, s.prototype.getItem = function(e) {
  304. return this.cookies[e];
  305. }, s.prototype.getAllItems = function() {
  306. return this.cookies;
  307. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  308. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  309. }, s)();
  310. e.countDown = function e(n, o, t, r) {
  311. if (!window) {
  312. throw new Error('window is not defind.');
  313. }
  314. if (0 < n) {
  315. return r && r(), n--, window[o] = window.setTimeout(function() {
  316. e(n, o, t, r);
  317. }, 1e3), function() {
  318. return clearTimeout(window[o]);
  319. };
  320. }
  321. clearTimeout(window[o]), t && t();
  322. }, e.createRandomID = function(e) {
  323. void 0 === e && (e = 12);
  324. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  325. n.push(o[Math.round(Math.random() * t)]);
  326. }
  327. return n.join('');
  328. }, e.dCookie = a, e.debounce = function(o, t, r) {
  329. var i;
  330. void 0 === t && (t = 0);
  331. var s = r = void 0 === r ? !1 : r;
  332. return function() {
  333. var e = this, n = arguments;
  334. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  335. r ? s = !0 : o.apply(e, n);
  336. }, t);
  337. };
  338. }, e.deepCopy = function e(n) {
  339. if (d(n) || Array.isArray(n)) {
  340. var o, t = Array.isArray(n) ? [] : {};
  341. for (o in n) {
  342. t[o] = e(n[o]);
  343. }
  344. return t;
  345. }
  346. return n;
  347. }, e.formatQueryParams = function(e) {
  348. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  349. if (!e) {
  350. return {};
  351. }
  352. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  353. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  354. return t[n] = o, e;
  355. });
  356. }
  357. return t;
  358. }, e.formatThousandth = function(e) {
  359. var n = ''.concat(e).split('.'), e = n[0], n = n[1], n = void 0 === n ? '' : n, e = e.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
  360. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  361. }, e.generateTree = function e(n, o, t, r) {
  362. for (var i = [], s = 0; s < n.length; s++) {
  363. var a = n[s];
  364. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  365. }
  366. return i;
  367. }, e.isEmpty = function(e) {
  368. return Array.isArray(e) ? 0 === e.length : d(e) ? 0 === Object.keys(e).length : [ '[object Set]', '[object Map]' ].includes(n(e)) ? 0 === e.size : [ null, void 0, '' ].includes(e);
  369. }, e.isFunction = function(e) {
  370. return '[object Function]' === n(e);
  371. }, e.isImageUrl = function(e) {
  372. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  373. }, e.isObject = d, e.isRegexp = function(e) {
  374. return '[object RegExp]' === n(e);
  375. }, e.objectKeyToCamelCase = function e(n, o, t) {
  376. if (Array.isArray(n)) {
  377. for (var r = [], i = 0; i < n.length; i++) {
  378. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  379. }
  380. } else if (d(n)) {
  381. r = {};
  382. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  383. var f = (u = c[a])[0], u = u[1];
  384. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  385. }
  386. } else {
  387. r = n;
  388. }
  389. return r;
  390. }, e.realType = n, e.searchParams = function(e, n) {
  391. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  392. new URLSearchParams(e).get(n);
  393. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  394. return e.replace(/([A-Z])/g, function(e) {
  395. return '_'.concat(e.toLocaleLowerCase());
  396. });
  397. }, e.ua = function(e) {
  398. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  399. }, Object.defineProperty(e, '__esModule', {
  400. value: !0
  401. });
  402. });
  403. },
  404. 301: function(module, __webpack_exports__, __webpack_require__) {
  405. 'use strict';
  406. __webpack_require__.d(__webpack_exports__, {
  407. Z: function() {
  408. return __WEBPACK_DEFAULT_EXPORT__;
  409. }
  410. });
  411. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  412. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  413. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  414. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  415. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default());
  416. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(10px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px #05be0566}body.auto-task-options .auto-task-form table label input:checked~span i{left:84px}body.auto-task-options .auto-task-form table label input:checked~span i::before{background:#05be05;box-shadow:35px 0 0 #05be05}body.auto-task-options .auto-task-form table label input:checked~span i::after{bottom:12px;height:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;background:#05be05}body.auto-task-options .auto-task-form table label span{position:absolute;top:0;left:0;width:100%;height:100%;background:#fe0000;border-radius:80px;transition:.5s;box-shadow:0 15px 25px #fe000066}body.auto-task-options .auto-task-form table label span i{position:absolute;top:4px;left:4px;width:72px;height:72px;background:#fff;border-radius:50%}body.auto-task-options .auto-task-form table label span i::before{content:"";position:absolute;top:22px;left:12px;width:12px;height:12px;border-radius:50%;background:#fe0000;box-shadow:35px 0 0 #fe0000;transition:.5s}body.auto-task-options .auto-task-form table label span i::after{content:"";position:absolute;bottom:15px;left:calc(50% - 15px);width:30px;height:6px;border-radius:6px;background:#fe0000;transition:.5s}body.auto-task-history{font-size:15px;font-weight:400;line-height:1.5}body.auto-task-history .container a{color:#007bff;text-decoration:none;background-color:transparent}body.auto-task-history .container .card{width:80%;max-width:800px;border-radius:10px;background:#7676761a;border-top:1px solid #ffffff80;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px #0000001a;margin:20px auto;position:relative;display:flex;flex-direction:column;word-wrap:break-word;-webkit-background-clip:border-box;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}body.auto-task-history .container .card .title{text-align:center;font-size:30px;font-weight:bold;margin:5px 0}body.auto-task-history .container .card .title a:hover{text-decoration:none;background:#93e1ff;border-radius:10px;padding:3px}body.auto-task-history .container .card ul{margin-bottom:25px}body.auto-task-history .container .card ul li{margin-bottom:5px;line-height:20px}body.auto-task-history .container .card ul a:hover{text-decoration:underline}body.auto-task-history .container .card .delete-task{right:10px;width:38px;height:35px;position:absolute;font-size:24px;cursor:pointer;border-radius:10px}body.auto-task-history .container .card .delete-task:hover{background:#fff}body.auto-task-history .container .card .time{right:5px;position:absolute;bottom:0;color:#e83e8c;font-family:\'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace\';font-size:15px}#auto-task-buttons,.show-button-div{position:fixed;top:30px;right:15px;width:170px;z-index:999999999 !important;transform:scale(0.9)}#auto-task-buttons p,.show-button-div p{line-height:30px;height:40px;text-align:center;margin:5px !important}#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn{width:150px;height:40px;line-height:30px;font-size:20px}.show-button-div{width:20px}.auto-task-capitalize{text-transform:capitalize !important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{box-shadow:inset 0px 0px 4px 1px rgba(100,150,200,.5) !important}.swal2-checkbox-custom{align-items:center;justify-content:center;background:#fff;color:inherit;margin:1em auto}.swal2-checkbox-custom input{flex-shrink:0;margin:0 .4em}.giveaway-actions #getKey{display:none !important}.auto-task-giveaway-status{color:#fff;border-radius:10px;padding:0 5px;margin-left:5px}.auto-task-giveaway-status.active{background-color:#5cb85c}.auto-task-giveaway-status.not-active{background-color:#d9534f}', '' ]);
  417. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  418. },
  419. 400: function(module) {
  420. 'use strict';
  421. module.exports = function(cssWithMappingToString) {
  422. var list = [];
  423. list.toString = function toString() {
  424. return this.map(function(item) {
  425. var content = '';
  426. var needLayer = typeof item[5] !== 'undefined';
  427. if (item[4]) {
  428. content += '@supports ('.concat(item[4], ') {');
  429. }
  430. if (item[2]) {
  431. content += '@media '.concat(item[2], ' {');
  432. }
  433. if (needLayer) {
  434. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  435. }
  436. content += cssWithMappingToString(item);
  437. if (needLayer) {
  438. content += '}';
  439. }
  440. if (item[2]) {
  441. content += '}';
  442. }
  443. if (item[4]) {
  444. content += '}';
  445. }
  446. return content;
  447. }).join('');
  448. };
  449. list.i = function i(modules, media, dedupe, supports, layer) {
  450. if (typeof modules === 'string') {
  451. modules = [ [ null, modules, undefined ] ];
  452. }
  453. var alreadyImportedModules = {};
  454. if (dedupe) {
  455. for (var k = 0; k < this.length; k++) {
  456. var id = this[k][0];
  457. if (id != null) {
  458. alreadyImportedModules[id] = true;
  459. }
  460. }
  461. }
  462. for (var _k = 0; _k < modules.length; _k++) {
  463. var item = [].concat(modules[_k]);
  464. if (dedupe && alreadyImportedModules[item[0]]) {
  465. continue;
  466. }
  467. if (typeof layer !== 'undefined') {
  468. if (typeof item[5] === 'undefined') {
  469. item[5] = layer;
  470. } else {
  471. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  472. item[5] = layer;
  473. }
  474. }
  475. if (media) {
  476. if (!item[2]) {
  477. item[2] = media;
  478. } else {
  479. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  480. item[2] = media;
  481. }
  482. }
  483. if (supports) {
  484. if (!item[4]) {
  485. item[4] = ''.concat(supports);
  486. } else {
  487. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  488. item[4] = supports;
  489. }
  490. }
  491. list.push(item);
  492. }
  493. };
  494. return list;
  495. };
  496. },
  497. 220: function(module) {
  498. 'use strict';
  499. module.exports = function(i) {
  500. return i[1];
  501. };
  502. }
  503. };
  504. var __webpack_module_cache__ = {};
  505. function __webpack_require__(moduleId) {
  506. var cachedModule = __webpack_module_cache__[moduleId];
  507. if (cachedModule !== undefined) {
  508. return cachedModule.exports;
  509. }
  510. var module = __webpack_module_cache__[moduleId] = {
  511. id: moduleId,
  512. exports: {}
  513. };
  514. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  515. return module.exports;
  516. }
  517. !function() {
  518. __webpack_require__.n = function(module) {
  519. var getter = module && module.__esModule ? function() {
  520. return module['default'];
  521. } : function() {
  522. return module;
  523. };
  524. __webpack_require__.d(getter, {
  525. a: getter
  526. });
  527. return getter;
  528. };
  529. }();
  530. !function() {
  531. __webpack_require__.d = function(exports, definition) {
  532. for (var key in definition) {
  533. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  534. Object.defineProperty(exports, key, {
  535. enumerable: true,
  536. get: definition[key]
  537. });
  538. }
  539. }
  540. };
  541. }();
  542. !function() {
  543. __webpack_require__.o = function(obj, prop) {
  544. return Object.prototype.hasOwnProperty.call(obj, prop);
  545. };
  546. }();
  547. var __webpack_exports__ = {};
  548. !function() {
  549. 'use strict';
  550. const external_Swal_namespaceObject = Swal;
  551. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  552. const external_Cookies_namespaceObject = Cookies;
  553. var auto_task = __webpack_require__(301);
  554. var javascript_utils_umd_min = __webpack_require__(588);
  555. const httpRequest = async function(options) {
  556. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  557. if (window.TRACE) {
  558. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  559. }
  560. try {
  561. const result = await new Promise(resolve => {
  562. if (options.dataType) {
  563. options.responseType = options.dataType;
  564. }
  565. const requestObj = {
  566. ...{
  567. timeout: 3e4,
  568. ontimeout(data) {
  569. resolve({
  570. result: 'Error',
  571. statusText: 'Timeout',
  572. status: 601,
  573. data: data,
  574. options: options
  575. });
  576. },
  577. onabort(data) {
  578. resolve({
  579. result: 'Error',
  580. statusText: 'Aborted',
  581. status: 602,
  582. data: data,
  583. options: options
  584. });
  585. },
  586. onerror(data) {
  587. resolve({
  588. result: 'Error',
  589. statusText: 'Error',
  590. status: 603,
  591. data: data,
  592. options: options
  593. });
  594. },
  595. onload(data) {
  596. resolve({
  597. result: 'Success',
  598. statusText: 'Load',
  599. status: 600,
  600. data: data,
  601. options: options
  602. });
  603. }
  604. },
  605. ...options
  606. };
  607. GM_xmlhttpRequest(requestObj);
  608. });
  609. if (window.DEBUG) {
  610. console.log('%cAuto-Task[httpRequest]:', 'color:blue', JSON.stringify(result));
  611. }
  612. if (result.status !== 600 && times < 2) {
  613. return await httpRequest(options, times + 1);
  614. }
  615. return result;
  616. } catch (error) {
  617. console.log('%cAuto-Task[httpRequest]:', 'color:red', JSON.stringify({
  618. errorMsg: error,
  619. options: options
  620. }));
  621. throwError(error, 'httpRequest');
  622. return {
  623. result: 'JsError',
  624. statusText: 'Error',
  625. status: 604,
  626. error: error,
  627. options: options
  628. };
  629. }
  630. };
  631. const tools_httpRequest = httpRequest;
  632. const echoLog = _ref => {
  633. let {
  634. type,
  635. text,
  636. html,
  637. id
  638. } = _ref;
  639. const emptyStatus = {
  640. success: () => emptyStatus,
  641. error: () => emptyStatus,
  642. warning: () => emptyStatus,
  643. info: () => emptyStatus,
  644. view: () => emptyStatus
  645. };
  646. try {
  647. var _ele$;
  648. let ele;
  649. if (type) {
  650. switch (type) {
  651. case 'joiningSteamGroup':
  652. case 'leavingSteamGroup':
  653. case 'gettingSteamGroupId':
  654. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  655. break;
  656.  
  657. case 'joiningSteamOfficialGroup':
  658. case 'leavingSteamOfficialGroup':
  659. case 'gettingSteamOfficialGroupId':
  660. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/games/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  661. break;
  662.  
  663. case 'subscribingForum':
  664. case 'unsubscribingForum':
  665. case 'gettingForumId':
  666. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>]...<font></font></li>`);
  667. break;
  668.  
  669. case 'followingCurator':
  670. case 'unfollowingCurator':
  671. case 'gettingCuratorId':
  672. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/${text !== null && text !== void 0 && text.includes('/') ? text : `curator/${text}`}" target="_blank">${text}</a>]...<font></font></li>`);
  673. break;
  674.  
  675. case 'addingToWishlist':
  676. case 'removingFromWishlist':
  677. case 'followingGame':
  678. case 'unfollowingGame':
  679. case 'gettingSubid':
  680. case 'addingFreeLicense':
  681. case 'requestingPlayTestAccess':
  682. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  683. break;
  684.  
  685. case 'addingFreeLicenseSubid':
  686. ele = $(`<li>${i18n('addingFreeLicense')}[<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  687. break;
  688.  
  689. case 'favoritingWorkshop':
  690. case 'unfavoritingWorkshop':
  691. case 'gettingWorkshopAppId':
  692. case 'votingUpWorkshop':
  693. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  694. ${text}</a>]...<font></font></li>`);
  695. break;
  696.  
  697. case 'gettingAnnouncementParams':
  698. case 'likingAnnouncement':
  699. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  700. ${id}</a>]...<font></font></li>`);
  701. break;
  702.  
  703. case 'joiningDiscordServer':
  704. case 'gettingDiscordGuild':
  705. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  706. break;
  707.  
  708. case 'leavingDiscordServer':
  709. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  710. break;
  711.  
  712. case 'updateDiscordAuth':
  713. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  714. break;
  715.  
  716. case 'followingTwitchChannel':
  717. case 'unfollowingTwitchChannel':
  718. case 'gettingTwitchChannelId':
  719. ele = $(`<li>${i18n(type)}[<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  720. break;
  721.  
  722. case 'gettingInsUserId':
  723. case 'followingIns':
  724. case 'unfollowingIns':
  725. ele = $(`<li>${i18n(type)}[<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  726. break;
  727.  
  728. case 'gettingTwitterUserId':
  729. case 'followingTwitterUser':
  730. case 'unfollowingTwitterUser':
  731. ele = $(`<li>${i18n(type)}[<a href="https://twitter.com/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  732. break;
  733.  
  734. case 'retweetting':
  735. case 'unretweetting':
  736. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  737. break;
  738.  
  739. case 'joiningReddit':
  740. case 'leavingReddit':
  741. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  742. break;
  743.  
  744. case 'followingRedditUser':
  745. case 'unfollowingRedditUser':
  746. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  747. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>]...<font></font></li>`);
  748. break;
  749.  
  750. case 'followingYtbChannel':
  751. case 'unfollowingYtbChannel':
  752. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  753. break;
  754.  
  755. case 'likingYtbVideo':
  756. case 'unlikingYtbVideo':
  757. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>]...<font></font></li>`);
  758. break;
  759.  
  760. case 'gettingVkId':
  761. case 'joiningVkGroup':
  762. case 'leavingVkGroup':
  763. case 'joiningVkPublic':
  764. case 'leavingVkPublic':
  765. case 'sendingVkWall':
  766. case 'deletingVkWall':
  767. ele = $(`<li>${i18n(type)}[<a href="https://vk.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  768. break;
  769.  
  770. case 'visitingLink':
  771. ele = $(`<li>${i18n('visitingLink')}[<a href="${text}" target="_blank">${text}</a>]...<font></font></li>`);
  772. break;
  773.  
  774. case 'verifyingInsAuth':
  775. case 'text':
  776. ele = $(`<li>${i18n(text)}<font></font></li>`);
  777. break;
  778.  
  779. case 'html':
  780. ele = $(text || html);
  781. break;
  782.  
  783. case 'whiteList':
  784. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  785. break;
  786.  
  787. case 'globalOptionsSkip':
  788. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  789. break;
  790.  
  791. default:
  792. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  793. break;
  794. }
  795. } else if (text) {
  796. ele = $(`<li>${i18n(text)}<font></font></li>`);
  797. } else if (html) {
  798. ele = $(html);
  799. } else {
  800. ele = $('<li><font></font></li>');
  801. }
  802. ele.addClass('card-text');
  803. $('#auto-task-info').append(ele);
  804. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  805. const font = ele.find('font');
  806. const status = {
  807. font: font,
  808. success() {
  809. var _this$font, _this$font2, _this$font3;
  810. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  811. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  812. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  813. html ? (_this$font2 = this.font) === null || _this$font2 === void 0 ? void 0 : _this$font2.html(text) : (_this$font3 = this.font) === null || _this$font3 === void 0 ? void 0 : _this$font3.text(text);
  814. return this;
  815. },
  816. error() {
  817. var _this$font4, _this$font5, _this$font6;
  818. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  819. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  820. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  821. html ? (_this$font5 = this.font) === null || _this$font5 === void 0 ? void 0 : _this$font5.html(text) : (_this$font6 = this.font) === null || _this$font6 === void 0 ? void 0 : _this$font6.text(text);
  822. return this;
  823. },
  824. warning() {
  825. var _this$font7, _this$font8, _this$font9;
  826. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  827. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  828. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  829. html ? (_this$font8 = this.font) === null || _this$font8 === void 0 ? void 0 : _this$font8.html(text) : (_this$font9 = this.font) === null || _this$font9 === void 0 ? void 0 : _this$font9.text(text);
  830. return this;
  831. },
  832. info() {
  833. var _this$font10, _this$font11, _this$font12;
  834. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  835. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  836. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  837. html ? (_this$font11 = this.font) === null || _this$font11 === void 0 ? void 0 : _this$font11.html(text) : (_this$font12 = this.font) === null || _this$font12 === void 0 ? void 0 : _this$font12.text(text);
  838. return this;
  839. },
  840. view() {
  841. var _this$font13;
  842. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  843. return this;
  844. }
  845. };
  846. return status;
  847. } catch (error) {
  848. throwError(error, 'echoLog');
  849. return emptyStatus;
  850. }
  851. };
  852. const scripts_echoLog = echoLog;
  853. const unique = array => {
  854. try {
  855. return [ ...new Set(array) ];
  856. } catch (error) {
  857. throwError(error, 'unique');
  858. return [];
  859. }
  860. };
  861. const delay = function() {
  862. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  863. return new Promise(resolve => {
  864. setTimeout(() => {
  865. resolve(true);
  866. }, time);
  867. });
  868. };
  869. const getRedirectLink = async link => {
  870. try {
  871. if (!link) {
  872. return null;
  873. }
  874. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  875. if (redirectLinksCache[link]) {
  876. redirectLinksCache[link];
  877. }
  878. return await tools_httpRequest({
  879. url: link,
  880. method: 'GET'
  881. }).then(_ref => {
  882. let {
  883. data
  884. } = _ref;
  885. if (data !== null && data !== void 0 && data.finalUrl) {
  886. redirectLinksCache[link] = data.finalUrl;
  887. GM_setValue('redirectLinks', redirectLinksCache);
  888. return data.finalUrl;
  889. }
  890. return null;
  891. });
  892. } catch (error) {
  893. throwError(error, 'getRedirectLink');
  894. return null;
  895. }
  896. };
  897. const visitLink = async (link, options) => {
  898. try {
  899. const logStatus = scripts_echoLog({
  900. type: 'visitLink',
  901. text: link
  902. });
  903. return await tools_httpRequest({
  904. url: link,
  905. method: 'GET',
  906. ...options
  907. }).then(_ref2 => {
  908. let {
  909. result,
  910. statusText,
  911. status
  912. } = _ref2;
  913. if (result === 'Success') {
  914. logStatus.success();
  915. return true;
  916. }
  917. logStatus.error(`${result}:${statusText}(${status})`);
  918. return false;
  919. });
  920. } catch (error) {
  921. throwError(error, 'visitLink');
  922. return false;
  923. }
  924. };
  925. const getUrlQuery = url => {
  926. try {
  927. const query = {};
  928. if (url) {
  929. if (url.includes('?')) {
  930. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  931. query[key] = value;
  932. return str;
  933. });
  934. }
  935. } else {
  936. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  937. query[key] = value;
  938. return str;
  939. });
  940. }
  941. return query;
  942. } catch (error) {
  943. throwError(error, 'getUrlQuery');
  944. return {};
  945. }
  946. };
  947. const getUuid = () => {
  948. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  949. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  950. };
  951. const stringToColour = str => {
  952. try {
  953. let hash = 0;
  954. for (let i = 0; i < str.length; i++) {
  955. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  956. }
  957. let colour = '#';
  958. for (let i = 0; i < 3; i++) {
  959. const value = hash >> i * 8 & 255;
  960. colour += `00${value.toString(16)}`.slice(-2);
  961. }
  962. return colour;
  963. } catch (error) {
  964. throwError(error, 'stringToColour');
  965. return '#fff';
  966. }
  967. };
  968. const defaultGlobalOptions = {
  969. doTask: {
  970. discord: {
  971. servers: true
  972. },
  973. instagram: {
  974. users: true
  975. },
  976. twitch: {
  977. channels: true
  978. },
  979. twitter: {
  980. users: true,
  981. retweets: true
  982. },
  983. vk: {
  984. names: true
  985. },
  986. youtube: {
  987. channels: true,
  988. likes: true
  989. },
  990. reddit: {
  991. reddits: true
  992. },
  993. steam: {
  994. groups: true,
  995. officialGroups: true,
  996. wishlists: true,
  997. follows: true,
  998. forums: true,
  999. workshops: true,
  1000. curators: true,
  1001. workshopVotes: true,
  1002. announcements: true,
  1003. licenses: true,
  1004. playtests: true
  1005. }
  1006. },
  1007. undoTask: {
  1008. discord: {
  1009. servers: true
  1010. },
  1011. instagram: {
  1012. users: true
  1013. },
  1014. twitch: {
  1015. channels: true
  1016. },
  1017. twitter: {
  1018. users: true,
  1019. retweets: true
  1020. },
  1021. vk: {
  1022. names: true
  1023. },
  1024. youtube: {
  1025. channels: true,
  1026. likes: true
  1027. },
  1028. reddit: {
  1029. reddits: true
  1030. },
  1031. steam: {
  1032. groups: true,
  1033. officialGroups: true,
  1034. wishlists: true,
  1035. follows: true,
  1036. forums: true,
  1037. workshops: true,
  1038. curators: true
  1039. }
  1040. },
  1041. position: {
  1042. buttonSideX: 'right',
  1043. buttonSideY: 'top',
  1044. buttonDistance: '15,30',
  1045. showButtonSideX: 'right',
  1046. showButtonSideY: 'top',
  1047. showButtonDistance: '15,30',
  1048. logSideX: 'right',
  1049. logSideY: 'bottom',
  1050. logDistance: '10,10'
  1051. },
  1052. hotKey: {
  1053. doTaskKey: 'alt + d',
  1054. undoTaskKey: 'alt + u',
  1055. toggleLogKey: 'alt + l'
  1056. },
  1057. other: {
  1058. twitterVerifyId: '783214',
  1059. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1060. autoUpdateSource: 'jsdelivr',
  1061. language: 'zh',
  1062. checkLogin: true,
  1063. checkLeftKey: true,
  1064. defaultShowButton: true,
  1065. defaultShowLog: true,
  1066. debug: false,
  1067. receivePreview: true
  1068. }
  1069. };
  1070. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1071. const assignObject = (obj1, obj2) => {
  1072. try {
  1073. const newObj = {};
  1074. for (const [ key, value ] of Object.entries(obj1)) {
  1075. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1076. newObj[key] = assignObject(value, obj2[key]);
  1077. } else {
  1078. newObj[key] = obj2[key] ?? value;
  1079. }
  1080. }
  1081. return newObj;
  1082. } catch (error) {
  1083. throwError(error, 'assignObject');
  1084. return defaultGlobalOptions;
  1085. }
  1086. };
  1087. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1088. const saveData = () => {
  1089. try {
  1090. const data = {};
  1091. $('#globalOptionsForm').serializeArray().map(value => {
  1092. data[value.name] = value.value;
  1093. return value;
  1094. });
  1095. $.makeArray($('#globalOptionsForm input')).map(element => {
  1096. const name = $(element).attr('name');
  1097. const keys = name.split('.');
  1098. if (keys.length === 3) {
  1099. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1100. } else if (keys.length === 2) {
  1101. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1102. }
  1103. return element;
  1104. });
  1105. GM_setValue('globalOptions', globalOptions);
  1106. external_Swal_default().fire({
  1107. title: i18n('changeGlobalOptionsSuccess'),
  1108. icon: 'success'
  1109. });
  1110. } catch (error) {
  1111. throwError(error, 'saveData');
  1112. }
  1113. };
  1114. const changeGlobalOptions = showType => {
  1115. try {
  1116. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1117. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1118. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1119. for (const [ option, data2 ] of Object.entries(data1)) {
  1120. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1121. if (typeof data2 === 'boolean') {
  1122. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><label><input type="checkbox" name="${type}.${option}"${data2 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1123. } else {
  1124. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><input class="editOption" type="text" name="${type}.${option}" value="${data2}"/></td></tr>`;
  1125. }
  1126. } else {
  1127. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1128. globalOptionsForm += `<tr style="background-color: ${stringToColour(option)}66">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).map(key => Object.keys(data1[key]).length).reduce((acr, cur) => acr + cur)}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${option}.${i18n(socialType)}</td><td><label><input type="checkbox" name="${type}.${option}.${socialType}"${data3 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1129. }
  1130. }
  1131. }
  1132. }
  1133. globalOptionsForm += '</tbody></table></form>';
  1134. if (showType === 'swal') {
  1135. external_Swal_default().fire({
  1136. title: i18n('globalOptions'),
  1137. html: globalOptionsForm,
  1138. showConfirmButton: true,
  1139. confirmButtonText: i18n('save'),
  1140. showCancelButton: true,
  1141. cancelButtonText: i18n('close')
  1142. }).then(_ref => {
  1143. let {
  1144. isConfirmed
  1145. } = _ref;
  1146. if (isConfirmed) {
  1147. saveData();
  1148. }
  1149. });
  1150. } else {
  1151. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1152. }
  1153. } catch (error) {
  1154. throwError(error, 'changeGlobalOptions');
  1155. }
  1156. };
  1157. const data = {
  1158. website: '网站',
  1159. type: '类型',
  1160. edit: '编辑',
  1161. whiteList: '白名单',
  1162. skipTask: '跳过撤销任务',
  1163. whiteListOptions: '白名单设置',
  1164. changeWhiteListOption: '设置白名单(%0)',
  1165. whiteListNotFound: '找不到此项白名单: %0',
  1166. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1167. changeWebsiteOptions: '网站设置',
  1168. changeGlobalOptions: '全局设置',
  1169. ok: '是',
  1170. save: '保存',
  1171. close: '关闭',
  1172. return: '返回',
  1173. option: '选项',
  1174. value: '值',
  1175. websiteOptions: '当前网站设置',
  1176. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1177. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1178. needLogin: '请先登录!',
  1179. getTasksInfo: '正在获取并处理任务信息...',
  1180. gettingKey: '正在获取Key...',
  1181. verifyingTask: '正在验证任务',
  1182. notice: '自动任务脚本提醒',
  1183. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1184. giveawayEnded: '此活动已结束,是否关闭?',
  1185. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1186. confirm: '确定',
  1187. cancel: '取消',
  1188. unKnown: '未知',
  1189. unKnownTaskType: '未识别的任务',
  1190. doing: '正在做任务',
  1191. allTasksComplete: '所有任务已完成!',
  1192. getTaskIdFailed: '获取任务Id失败!',
  1193. initSuccess: '%0 初始化成功!',
  1194. initFailed: '%0 初始化失败!',
  1195. errorLink: '链接错误: %0',
  1196. needInit: '请先初始化',
  1197. verifyingAuth: '正在验证%0凭证...',
  1198. updatingAuth: '正在更新%0凭证...',
  1199. refreshingToken: '正在刷新%0凭证...',
  1200. settingToken: '正在设置%0凭证...',
  1201. initing: '正在初始化...',
  1202. getFailed: '获取%0失败!',
  1203. checkLoginFailed: '检测登录状态失败!',
  1204. checkLeftKeyFailed: '检测剩余Key失败!',
  1205. userId: '用户Id',
  1206. joiningGiveaway: '正在加入赠Key',
  1207. needJoinGiveaway: '需要先加入赠Key',
  1208. cannotUndo: '此网站不支持取消任务',
  1209. verifyAuth: '正在验证 %0 凭证...',
  1210. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1211. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1212. visitingLink: '正在访问链接: ',
  1213. doTask: '做任务',
  1214. undoTask: '撤销任务',
  1215. verifyTask: '验证任务',
  1216. getKey: '获取Key',
  1217. selectAll: '全选',
  1218. selectNone: '全不选',
  1219. invertSelect: '反选',
  1220. doFreeTask: '加入免费赠品',
  1221. doPointTask: '加入点数赠品',
  1222. skipTaskOption: '设置中已配置跳过任务',
  1223. other: '其他',
  1224. globalOptions: '全局设置',
  1225. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1226. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1227. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1228. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1229. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1230. saveGlobalOptions: '保存全局设置',
  1231. settingPage: '设置页面',
  1232. name: '名称',
  1233. version: '版本',
  1234. scriptManager: '脚本管理器',
  1235. script: '脚本',
  1236. environment: '环境',
  1237. os: '系统',
  1238. browser: '浏览器',
  1239. getId: '获取 %0 id',
  1240. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1241. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1242. showButton: '显示按钮',
  1243. hideButton: '隐藏按钮',
  1244. showLog: '显示日志',
  1245. hideLog: '隐藏日志',
  1246. defaultShowButton: '默认显示按钮',
  1247. defaultShowLog: '默认显示日志',
  1248. debug: '输出调试日志,不要开启此选项!',
  1249. receivePreview: '接收预览版更新',
  1250. position: '组件位置',
  1251. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1252. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1253. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1254. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1255. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1256. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1257. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1258. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1259. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1260. hotKey: '快捷键',
  1261. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1262. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1263. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1264. tasksHistory: '任务历史',
  1265. clearHistory: '清空历史',
  1266. clearHistoryFinished: '已清空任务历史!',
  1267. deleteTask: '删除任务',
  1268. lastChangeTime: '最后一次修改时间',
  1269. clearTaskFinished: '删除以下任务完成!',
  1270. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1271. syncData: '数据同步',
  1272. settingData: '正在上传数据...',
  1273. gettingData: '正在获取数据...',
  1274. help: '帮助',
  1275. fileName: '文件名',
  1276. upload2gist: '同步到Gist',
  1277. downloadFromGist: '从Gist同步',
  1278. saveAndTest: '保存配置并测试',
  1279. testSuccess: '测试成功!',
  1280. testFailed: '测试失败!',
  1281. saveAndTestNotice: '请先保存配置并测试!',
  1282. processingData: '正在处理数据...',
  1283. updatingData: '正在上传数据...',
  1284. syncDataSuccess: '同步数据成功!',
  1285. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1286. downloadingData: '正在下载数据...',
  1287. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1288. savingData: '正在保存数据...',
  1289. syncHistory: '同步任务历史',
  1290. checkUpdateFailed: '检测更新失败',
  1291. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1292. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1293. gistOptions: 'Gist 设置',
  1294. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1295. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1296. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1297. toGithub: '前往Github反馈',
  1298. toKeylol: '前往其乐论坛反馈',
  1299. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1300. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1301. updateText: '%0 版本更新内容:',
  1302. Active: '进行中',
  1303. Ended: '已结束',
  1304. Banned: '已封禁',
  1305. Paused: '已暂停',
  1306. notStart: '未开始',
  1307. noRemoteData: '检测到远程无数据',
  1308. errorRemoteDataFormat: '远程数据格式错误',
  1309. updateHistory: '历史更新记录<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">点此查看</a>',
  1310. groups: '组',
  1311. officialGroups: '官方组',
  1312. wishlists: '愿望单',
  1313. follows: '游戏关注',
  1314. forums: '论坛',
  1315. workshops: '创意工坊收藏',
  1316. curators: '鉴赏家',
  1317. workshopVotes: '创意工坊点赞',
  1318. announcements: '社区通知',
  1319. steamCommunity: 'Steam社区',
  1320. steamStore: 'Steam商店',
  1321. licenses: '入库免费游戏',
  1322. playtests: '请求访问权限',
  1323. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1324. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1325. joiningSteamGroup: '正在加入Steam组',
  1326. leavingSteamGroup: '正在退出Steam组',
  1327. gettingSteamGroupId: '正在获取Steam组Id',
  1328. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1329. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1330. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1331. subscribingForum: '正在订阅Steam论坛',
  1332. unsubscribingForum: '正在取消订阅Steam论坛',
  1333. gettingForumId: '正在获取Steam论坛Id',
  1334. followingCurator: '正在关注Steam鉴赏家',
  1335. unfollowingCurator: '正在取关Steam鉴赏家',
  1336. gettingCuratorId: '正在获取Steam鉴赏家Id',
  1337. addingToWishlist: '正在添加游戏到Steam愿望单',
  1338. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1339. followingGame: '正在关注Steam游戏',
  1340. unfollowingGame: '正在取关Steam游戏',
  1341. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1342. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1343. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1344. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1345. gettingAnnouncementParams: '正在获取Steam通知信息',
  1346. likingAnnouncement: '正在点赞Steam通知',
  1347. changingArea: '正在更换Steam地区: %0...',
  1348. notNeededChangeArea: '当前地区不需要更换',
  1349. noAnotherArea: '请检测是否开启正确开启代理',
  1350. gettingAreaInfo: '正在获取Steam地区信息...',
  1351. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1352. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1353. gettingSubid: '正在获取游戏subid',
  1354. addingFreeLicense: '正在入库',
  1355. missParams: '缺少参数',
  1356. gettingLicenses: '正在获取Licenses...',
  1357. requestingPlayTestAccess: '正在请求访问权限',
  1358. tryChangeAreaNotice: '此功能无法检测游戏是否限区,因此会尝试换区后再入库,换区失败也不影响后续入库',
  1359. servers: '服务器',
  1360. joiningDiscordServer: '正在加入Discord服务器',
  1361. leavingDiscordServer: '正在退出Discord服务器',
  1362. gettingDiscordGuild: '正在获取Discord服务器Id',
  1363. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1364. discordImportantNotice: '重要提醒!!!',
  1365. discordImportantNoticeText: '由于Discord网站后台更新,目前使用此脚本加组后可能会导致Discord帐号被强制退出,且需要两步验证才能正常登录,请谨慎使用!!!',
  1366. continue: '继续',
  1367. skipDiscordTask: '跳过Discord任务',
  1368. continueAndDontRemindAgain: '继续且不再提醒',
  1369. users: '用户',
  1370. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1371. insBanned: '您的Instagram账户已被封禁',
  1372. verifyingInsAuth: '正在验证Instagram凭证...',
  1373. gettingInsUserId: '正在获取Instagram用户Id',
  1374. followingIns: '正在关注Instagram用户',
  1375. unfollowingIns: '正在取关Instagram用户',
  1376. reddits: '社区/用户',
  1377. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1378. changingRedditVersion: '正在切换Reddit为新版页面...',
  1379. joiningReddit: '正在加入Reddit社区',
  1380. leavingReddit: '正在退出Reddit社区',
  1381. followingRedditUser: '正在关注Reddit用户',
  1382. unfollowingRedditUser: '正在取关Reddit用户',
  1383. channels: '频道',
  1384. followingTwitchChannel: '正在关注Twitch频道',
  1385. unfollowingTwitchChannel: '正在取关Twitch频道',
  1386. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1387. checkingTwitchIntegrity: '正在检查Twitch完整性...',
  1388. twitterUser: '推特用户',
  1389. retweets: '转推',
  1390. gettingTwitterUserId: '正在获取推特用户Id',
  1391. followingTwitterUser: '正在关注推特用户',
  1392. unfollowingTwitterUser: '正在取关推特用户',
  1393. retweetting: '正在转推',
  1394. unretweetting: '正在撤销转推',
  1395. names: '组/社区/动态',
  1396. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1397. gettingVkId: '正在获取Vk任务Id',
  1398. joiningVkGroup: '正在加入Vk组',
  1399. leavingVkGroup: '正在退出Vk组',
  1400. joiningVkPublic: '正在加入Vk社区',
  1401. leavingVkPublic: '正在退出Vk社区',
  1402. sendingVkWall: '正在转发Vk动态',
  1403. deletingVkWall: '正在撤销转发Vk动态',
  1404. youtubeChannel: 'YouTube频道',
  1405. likes: '点赞',
  1406. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1407. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1408. gettingYtbToken: '正在获取YouTube Token...',
  1409. followingYtbChannel: '正在订阅YouTube频道',
  1410. unfollowingYtbChannel: '正在退订YouTube频道',
  1411. likingYtbVideo: '正在点赞YouTube视频',
  1412. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1413. giveKeyNoticeBefore: '每次验证间隔15s',
  1414. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1415. noPoints: '点数不够,跳过抽奖',
  1416. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1417. joiningLottery: '正在加入抽奖',
  1418. doingGleamTask: '正在做Gleam任务...',
  1419. gettingGleamLink: '正在获取Gleam任务链接...',
  1420. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1421. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1422. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1423. giveeClubVerifyNotice: '正在验证任务...',
  1424. giveeClubVerifyFinished: '请等待验证完成后自行加入赠Key',
  1425. doingKeyhubTask: '正在做Keyhub任务...',
  1426. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...',
  1427. confirmingTask: '正在跳过警告页面...'
  1428. };
  1429. const zh_CN = data;
  1430. const en_US_data = {
  1431. website: 'Website',
  1432. type: 'Type',
  1433. edit: 'Edit',
  1434. whiteList: 'Whitelist',
  1435. skipTask: 'Skip undo task',
  1436. whiteListOptions: 'Whitelist options',
  1437. changeWhiteListOption: 'Whitelist option(%0)',
  1438. whiteListNotFound: 'Cannot find this whitelist: %0',
  1439. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1440. changeWebsiteOptions: 'Website options',
  1441. changeGlobalOptions: 'Global options',
  1442. ok: 'OK',
  1443. save: 'Save',
  1444. close: 'Close',
  1445. return: 'Return',
  1446. option: 'Option',
  1447. value: 'Value',
  1448. websiteOptions: 'Current website settings',
  1449. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1450. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1451. needLogin: 'Please log in first!',
  1452. getTasksInfo: 'Obtaining and processing task information...',
  1453. gettingKey: 'Getting Key...',
  1454. verifyingTask: 'Verifying task',
  1455. notice: 'Automatic task script notice',
  1456. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1457. giveawayEnded: 'This event has ended, do you want to close it?',
  1458. giveawayNotWork: 'This activity is unavailable for some reasons (banned/ended/paused/not started...)' + ' (if it is a script misjudgment, please give us feedback in time), is it closed?',
  1459. confirm: 'Confirm',
  1460. cancel: 'Cancel',
  1461. unKnown: 'Unknown',
  1462. unKnownTaskType: 'Unrecognized task',
  1463. doing: 'Doing a task',
  1464. allTasksComplete: 'All tasks have been completed!',
  1465. getTaskIdFailed: 'Failed to obtain task Id!',
  1466. initSuccess: '%0 was initialized successfully!',
  1467. initFailed: '%0 initialization failed!',
  1468. errorLink: 'Link error: %0',
  1469. needInit: 'Please initialize first',
  1470. verifyingAuth: 'Verifying %0 token...',
  1471. updatingAuth: 'Update %0 token...',
  1472. initing: 'Initializing...',
  1473. getFailed: 'Failed to get %0!',
  1474. checkLoginFailed: 'Failed to detect login status!',
  1475. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1476. userId: 'User Id',
  1477. joiningGiveaway: 'Joining giveaway',
  1478. needJoinGiveaway: 'Need to join the giveaway first',
  1479. cannotUndo: 'This website does not support canceling tasks',
  1480. verifyAuth: 'Verifying %0 token...',
  1481. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1482. errorReport: 'A script error is detected, do you want to report the BUG?',
  1483. visitingLink: 'Visiting link: ',
  1484. doTask: 'DoTask',
  1485. undoTask: 'UndoTask',
  1486. verifyTask: 'Verify',
  1487. getKey: 'GetKey',
  1488. selectAll: 'SelectAll',
  1489. selectNone: 'SelectNone',
  1490. invertSelect: 'InvertSelect',
  1491. doFreeTask: 'FreeTask',
  1492. doPointTask: 'PointTask',
  1493. skipTaskOption: 'Skip task has been configured in the settings',
  1494. other: 'Other',
  1495. globalOptions: 'Global Options',
  1496. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1497. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1498. twitterVerifyId: 'Verify Twitter token by trying to follow the account.</br>The default is the official Twitter account 783214.</br>' + 'If you don\'t want to follow the official account, you can change it to your own account.',
  1499. youtubeVerifyChannel: 'Verify YouTube token by trying to subscribe to the channel.</br>' + 'The default is the official YouTube channel UCrXUsMBcfTVqwAS7DKg9C0Q.</br>' + 'If you don\'t want to follow the official channel, you can change it to your own channel.',
  1500. autoUpdateSource: 'The source to update</br>github: Fast update.</br>jsdelivr: Update is delayed.</br>' + 'standby: Standby source.</br>auto: Try to update using github, jsdelivr, standby sources in turn.',
  1501. saveGlobalOptions: 'SaveSettings',
  1502. settingPage: 'Setting Page',
  1503. name: 'Name',
  1504. version: 'Version',
  1505. scriptManager: 'Script Manager',
  1506. script: 'Script',
  1507. environment: 'Environment',
  1508. os: 'OS',
  1509. browser: 'Browser',
  1510. getId: 'Get %0 id',
  1511. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1512. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1513. showButton: 'ShowButton',
  1514. hideButton: 'HideButton',
  1515. showLog: 'ShowLog',
  1516. hideLog: 'HideLog',
  1517. defaultShowButton: 'Default display button',
  1518. defaultShowLog: 'Display log by default',
  1519. debug: 'Output debug log, do not enable this option!',
  1520. receivePreview: 'Receive preview updates',
  1521. position: 'Component position',
  1522. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1523. buttonSideY: 'The button area is positioned in the vertical direction (real-time preview function is only available on the settings page).' + '</br>top: top | bottom: bottom',
  1524. buttonDistance: 'The distance between the button area and the edge (the real-time preview function is only available on the setting page).' + '</br> Format: X distance, Y distance',
  1525. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1526. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1527. showButtonDistance: 'The distance between the ShowButton and the edge (real-time preview function is only available on the setting page).' + '</br> Format: X distance, Y distance',
  1528. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1529. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1530. logDistance: 'The distance between the log area and the edge (the real-time preview function is only available on the setting page).' + '</br> Format: X distance, Y distance',
  1531. hotKey: 'Shortcut key',
  1532. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1533. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1534. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1535. tasksHistory: 'TasksHistory',
  1536. clearHistory: 'Clear history',
  1537. clearHistoryFinished: 'The mission history has been cleared!',
  1538. deleteTask: 'Delete task',
  1539. lastChangeTime: 'Last Change Time',
  1540. clearTaskFinished: 'Delete the following tasks completed!',
  1541. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1542. syncData: 'DataSync',
  1543. settingData: 'Uploading data...',
  1544. gettingData: 'Getting data...',
  1545. help: 'Help',
  1546. fileName: 'Filename',
  1547. upload2gist: 'Sync to Gist',
  1548. downloadFromGist: 'Sync from Gist',
  1549. saveAndTest: 'Save configuration and test',
  1550. testSuccess: 'Test success!',
  1551. testFailed: 'Test failed!',
  1552. saveAndTestNotice: 'Please save the configuration and test first!',
  1553. processingData: 'Processing data...',
  1554. updatingData: 'Uploading data...',
  1555. syncDataSuccess: 'Synchronized data successfully!',
  1556. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1557. downloadingData: 'Downloading data...',
  1558. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1559. savingData: 'Saving data...',
  1560. syncHistory: 'Synchronize tasks history',
  1561. checkUpdateFailed: 'Check update failed',
  1562. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1563. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1564. gistOptions: 'Gist Settings',
  1565. swalNotice: 'It is detected that you are installing the V4 version script for the first time' + ', please go to read the READ ME FIRST content before use!',
  1566. echoNotice: 'It is detected that you are installing the V4 version script for the first time' + ', please <a class="high-light" href="%0" target="_blank">click here</a> to read the READ ME FIRST content before use!',
  1567. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1568. toGithub: 'Feedback(Github)',
  1569. toKeylol: 'Feedback(Keylol)',
  1570. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1571. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1572. updateText: 'Updates in version %0:',
  1573. Active: 'Active',
  1574. Ended: 'Ended',
  1575. Banned: 'Banned',
  1576. Paused: 'Paused',
  1577. notStart: 'notStart',
  1578. noRemoteData: 'No data remotely',
  1579. errorRemoteDataFormat: 'Remote data has wrong format',
  1580. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1581. groups: 'Group',
  1582. officialGroups: 'Official Group',
  1583. wishlists: 'Wishlist',
  1584. follows: 'Follow Game',
  1585. forums: 'Forum',
  1586. workshops: 'Favorite Workshop',
  1587. curators: 'Curator',
  1588. workshopVotes: 'Voteup Workshop',
  1589. announcements: 'Announcement',
  1590. steamCommunity: 'Steam Community',
  1591. steamStore: 'Steam Store',
  1592. licenses: 'Add License',
  1593. playtests: 'Playtest Access',
  1594. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1595. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1596. joiningSteamGroup: 'Joining Steam Group',
  1597. leavingSteamGroup: 'Leaving Steam Group',
  1598. gettingSteamGroupId: 'Getting Steam Group Id',
  1599. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1600. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1601. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1602. subscribingForum: 'Subscribing the Steam Forum',
  1603. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1604. gettingForumId: 'Getting Steam Forum Id',
  1605. followingCurator: 'Following Steam Curator',
  1606. unfollowingCurator: 'Unfollowing Steam Curator',
  1607. gettingCuratorId: 'Getting Steam Curator Id',
  1608. addingToWishlist: 'Adding the game to the Steam wishlist',
  1609. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1610. followingGame: 'Following Steam games',
  1611. unfollowingGame: 'Unfollowing Steam games',
  1612. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1613. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1614. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1615. votingUpWorkshop: 'Liking Steam workshop items',
  1616. gettingAnnouncementParams: 'Getting Steam announcement information',
  1617. likingAnnouncement: 'Liking Steam announcement',
  1618. changingArea: 'Changing Steam area: %0...',
  1619. notNeededChangeArea: 'The current area does not need to be changed',
  1620. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1621. gettingAreaInfo: 'Getting Steam area information...',
  1622. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1623. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1624. gettingSubid: 'Getting subid',
  1625. addingFreeLicense: 'Adding free license',
  1626. missParams: 'Missing parameters',
  1627. gettingLicenses: 'Getting licenses...',
  1628. requestingPlayTestAccess: 'Requesting play test access',
  1629. tryChangeAreaNotice: 'This function cannot detect whether the game is limited, so it will try to change the area before entering the library' + '. Failure to change the area will not affect the subsequent storage.',
  1630. servers: 'Server',
  1631. joiningDiscordServer: 'Joining Discord Server',
  1632. leavingDiscordServer: 'Leaving Discord Server',
  1633. gettingDiscordGuild: 'Getting Discord server Id',
  1634. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1635. discordImportantNotice: 'Important Reminder! ! !',
  1636. discordImportantNoticeText: 'Due to the background update of the Discord website, currently using this script to join a group may cause the Discord account to be forcibly logged out, and two-step verification is required to log in normally, please use it with caution! ! !',
  1637. continue: 'Continue',
  1638. skipDiscordTask: 'Skip',
  1639. continueAndDontRemindAgain: 'Continue without Reminders',
  1640. users: 'User',
  1641. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1642. insBanned: 'Your Instagram account has been banned',
  1643. verifyingInsAuth: 'Verifying Instagram token...',
  1644. gettingInsUserId: 'Getting Instagram user Id',
  1645. followingIns: 'Following Instagram user',
  1646. unfollowingIns: 'Unfollowing Instagram user',
  1647. reddits: 'Reddit/User',
  1648. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1649. changingRedditVersion: 'Switching Reddit to a new version page...',
  1650. joiningReddit: 'Joining the Reddit',
  1651. leavingReddit: 'Leaving the Reddit',
  1652. followingRedditUser: 'Following Reddit User',
  1653. unfollowingRedditUser: 'Unfollowing Reddit User',
  1654. channels: 'Channel',
  1655. followingTwitchChannel: 'Following Twitch Channel',
  1656. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1657. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1658. checkingTwitchIntegrity: 'Checking Twitch integrity...',
  1659. twitterUser: 'Twitter User',
  1660. retweets: 'Retweet',
  1661. gettingTwitterUserId: 'Getting Twitter User Id',
  1662. followingTwitterUser: 'Following Twitter User',
  1663. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1664. retweetting: 'Retweetting',
  1665. unretweetting: 'Unretweetting',
  1666. names: 'Group/Public/Wall',
  1667. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1668. gettingVkId: 'Getting Vk task Id',
  1669. joiningVkGroup: 'Joining Vk Group',
  1670. leavingVkGroup: 'Leaving Vk Group',
  1671. joiningVkPublic: 'Joining Vk Public',
  1672. leavingVkPublic: 'Leaving Vk Public',
  1673. sendingVkWall: 'Sending Vk Wall',
  1674. deletingVkWall: 'Deleting Vk Wall',
  1675. youtubeChannel: 'YouTube Channel',
  1676. likes: 'Like',
  1677. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1678. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1679. gettingYtbToken: 'Getting YouTube Token...',
  1680. followingYtbChannel: 'Subscribing to YouTube channel',
  1681. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1682. likingYtbVideo: 'Liking YouTube video',
  1683. unlikingYtbVideo: 'Unliking YouTube video',
  1684. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1685. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1686. noPoints: 'Not enough points, skip the lottery',
  1687. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1688. joiningLottery: 'Joining the lottery',
  1689. doingGleamTask: 'Doing Gleam Task...',
  1690. gettingGleamLink: 'Getting Gleam task link...',
  1691. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1692. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1693. gsNotice: 'In order to avoid getting the "0000-0000-0000" key, the "Grab Key" button has been hidden,' + ' please close the script when obtaining the key!',
  1694. giveeClubVerifyNotice: 'Verifying task...',
  1695. giveeClubVerifyFinished: 'Wait for the verification to complete and join it by yourself',
  1696. doingKeyhubTask: 'Doing Keyhub Task...',
  1697. SweepWidgetNotice: 'The task is being processed and verified. ' + 'There is an interval of 1~3s for each verification task to prevent the triggering of too fast verification warning...',
  1698. confirmingTask: 'Confirming task...'
  1699. };
  1700. const en_US = en_US_data;
  1701. const languages = {
  1702. zh: zh_CN,
  1703. en: en_US
  1704. };
  1705. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1706. const I18n = function(key) {
  1707. var _languages$language;
  1708. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1709. argvs[_key - 1] = arguments[_key];
  1710. }
  1711. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1712. return key;
  1713. }
  1714. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1715. };
  1716. const i18n = I18n;
  1717. function throwError(error, name) {
  1718. if (window.TRACE) {
  1719. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1720. }
  1721. external_Swal_default().fire({
  1722. title: i18n('errorReport'),
  1723. icon: 'error',
  1724. showCancelButton: true,
  1725. confirmButtonText: i18n('toGithub'),
  1726. showDenyButton: true,
  1727. denyButtonText: i18n('toKeylol'),
  1728. cancelButtonText: i18n('close')
  1729. }).then(_ref => {
  1730. let {
  1731. isDenied,
  1732. isConfirmed
  1733. } = _ref;
  1734. if (isConfirmed) {
  1735. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`[BUG] 脚本报错: ${name}`)}&labels=bug&template=bug_report.yml&website=${encodeURIComponent(window.location.href)}&browser=${encodeURIComponent(JSON.stringify((0,
  1736. javascript_utils_umd_min.ua)(), null, 4))}&manager=${encodeURIComponent(`${GM_info.scriptHandler} ${GM_info.version}`)}&user-script=${encodeURIComponent(GM_info.script.version)}&logs=${encodeURIComponent(error.stack || 'null')}&run-logs=${encodeURIComponent($.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n'))}`, '_blank');
  1737. } else if (isDenied) {
  1738. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1739.  
  1740. 环境:
  1741.  
  1742. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1743.  
  1744. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1745. 脚本版本: ${GM_info.script.version}
  1746.  
  1747. 报错信息:
  1748. [code]${error.stack}[/code]
  1749.  
  1750. 执行日志:
  1751. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1752. GM_setClipboard(text);
  1753. external_Swal_default().fire({
  1754. title: i18n('copySuccess'),
  1755. icon: 'success',
  1756. confirmButtonText: i18n('ok')
  1757. }).then(() => {
  1758. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1759. });
  1760. }
  1761. });
  1762. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1763. }
  1764. class Social {
  1765. tasks;
  1766. getRealParams(name, links, doTask, link2param) {
  1767. try {
  1768. let realParams = [];
  1769. if (links.length > 0) {
  1770. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1771. }
  1772. if (!doTask && this.tasks[name].length > 0) {
  1773. realParams = [ ...realParams, ...this.tasks[name] ];
  1774. }
  1775. return unique(realParams);
  1776. } catch (error) {
  1777. throwError(error, 'Social.getRealParams');
  1778. return [];
  1779. }
  1780. }
  1781. }
  1782. const social_Social = Social;
  1783. var _GM_getValue;
  1784. const defaultTasksTemplate = {
  1785. servers: []
  1786. };
  1787. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1788. class Discord extends social_Social {
  1789. tasks = JSON.parse(defaultTasks);
  1790. whiteList = {
  1791. ...JSON.parse(defaultTasks),
  1792. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1793. };
  1794. #auth = GM_getValue('discordAuth') || {};
  1795. #cache = GM_getValue('discordCache') || {};
  1796. #initialized = false;
  1797. async init() {
  1798. try {
  1799. if (!GM_getValue('dontRemindDiscordAgain')) {
  1800. const result = await external_Swal_default().fire({
  1801. title: i18n('discordImportantNotice'),
  1802. text: i18n('discordImportantNoticeText'),
  1803. showCancelButton: true,
  1804. showDenyButton: true,
  1805. confirmButtonText: i18n('continue'),
  1806. cancelButtonText: i18n('skipDiscordTask'),
  1807. denyButtonText: i18n('continueAndDontRemindAgain')
  1808. }).then(_ref => {
  1809. let {
  1810. isConfirmed,
  1811. isDenied
  1812. } = _ref;
  1813. if (isConfirmed) {
  1814. return true;
  1815. }
  1816. if (isDenied) {
  1817. GM_setValue('dontRemindDiscordAgain', true);
  1818. return true;
  1819. }
  1820. return false;
  1821. });
  1822. if (!result) {
  1823. this.#initialized = false;
  1824. return 'skip';
  1825. }
  1826. }
  1827. if (!globalOptions.doTask.discord.servers && !globalOptions.undoTask.discord.servers) {
  1828. this.#initialized = false;
  1829. return 'skip';
  1830. }
  1831. if (this.#initialized) {
  1832. return true;
  1833. }
  1834. if (!this.#auth.auth) {
  1835. if (await this.#updateAuth()) {
  1836. this.#initialized = true;
  1837. return true;
  1838. }
  1839. return false;
  1840. }
  1841. const isVerified = await this.#verifyAuth();
  1842. if (isVerified) {
  1843. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1844. this.#initialized = true;
  1845. return true;
  1846. }
  1847. GM_setValue('discordAuth', {
  1848. auth: null
  1849. });
  1850. if (await this.#updateAuth()) {
  1851. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1852. this.#initialized = true;
  1853. return true;
  1854. }
  1855. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1856. return false;
  1857. } catch (error) {
  1858. throwError(error, 'Discord.init');
  1859. return false;
  1860. }
  1861. }
  1862. async #verifyAuth() {
  1863. try {
  1864. const logStatus = scripts_echoLog({
  1865. text: i18n('verifyingAuth', 'Discord')
  1866. });
  1867. const {
  1868. result,
  1869. statusText,
  1870. status,
  1871. data
  1872. } = await tools_httpRequest({
  1873. url: 'https://discord.com/api/v6/users/@me',
  1874. method: 'HEAD',
  1875. headers: {
  1876. authorization: this.#auth.auth
  1877. }
  1878. });
  1879. if (result === 'Success') {
  1880. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1881. logStatus.success();
  1882. return true;
  1883. }
  1884. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1885. return false;
  1886. }
  1887. logStatus.error(`${result}:${statusText}(${status})`);
  1888. return false;
  1889. } catch (error) {
  1890. throwError(error, 'Discord.verifyAuth');
  1891. return false;
  1892. }
  1893. }
  1894. async #updateAuth() {
  1895. try {
  1896. const logStatus = scripts_echoLog({
  1897. text: i18n('updatingAuth', 'Discord')
  1898. });
  1899. return await new Promise(resolve => {
  1900. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1901. active: true,
  1902. insert: true,
  1903. setParent: true
  1904. });
  1905. newTab.onclose = async () => {
  1906. var _GM_getValue2;
  1907. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1908. if (auth) {
  1909. this.#auth = {
  1910. auth: auth
  1911. };
  1912. logStatus.success();
  1913. resolve(await this.#verifyAuth());
  1914. } else {
  1915. logStatus.error('Error: Update discord auth failed!');
  1916. resolve(false);
  1917. }
  1918. };
  1919. });
  1920. } catch (error) {
  1921. throwError(error, 'Discord.updateAuth');
  1922. return false;
  1923. }
  1924. }
  1925. async #joinServer(inviteId) {
  1926. try {
  1927. const logStatus = scripts_echoLog({
  1928. type: 'joiningDiscordServer',
  1929. text: inviteId
  1930. });
  1931. const {
  1932. result,
  1933. statusText,
  1934. status,
  1935. data
  1936. } = await tools_httpRequest({
  1937. url: `https://discord.com/api/v9/invites/${inviteId}`,
  1938. method: 'POST',
  1939. dataType: 'json',
  1940. headers: {
  1941. authorization: this.#auth.auth,
  1942. origin: 'https://discord.com',
  1943. referer: `https://discord.com/invite/${inviteId}`
  1944. }
  1945. });
  1946. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1947. var _data$response, _data$response$guild;
  1948. logStatus.success();
  1949. const guild = String((_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$guild = _data$response.guild) === null || _data$response$guild === void 0 ? void 0 : _data$response$guild.id);
  1950. if (guild) {
  1951. this.#setCache(inviteId, guild);
  1952. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1953. }
  1954. return true;
  1955. }
  1956. logStatus.error(`${result}:${statusText}(${status})`);
  1957. return false;
  1958. } catch (error) {
  1959. throwError(error, 'Discord.joinServer');
  1960. return false;
  1961. }
  1962. }
  1963. async #leaveServer(inviteId) {
  1964. try {
  1965. if (this.whiteList.servers.includes(inviteId)) {
  1966. scripts_echoLog({
  1967. type: 'whiteList',
  1968. text: 'Discord.leaveServer',
  1969. id: inviteId
  1970. });
  1971. return true;
  1972. }
  1973. const guild = await this.#getGuild(inviteId);
  1974. if (!guild) {
  1975. return false;
  1976. }
  1977. const logStatus = scripts_echoLog({
  1978. type: 'leavingDiscordServer',
  1979. text: guild
  1980. });
  1981. const {
  1982. result,
  1983. statusText,
  1984. status,
  1985. data
  1986. } = await tools_httpRequest({
  1987. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  1988. method: 'DELETE',
  1989. headers: {
  1990. authorization: this.#auth.auth
  1991. }
  1992. });
  1993. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  1994. logStatus.success();
  1995. return true;
  1996. }
  1997. logStatus.error(`${result}:${statusText}(${status})`);
  1998. return false;
  1999. } catch (error) {
  2000. throwError(error, 'Discord.leaveServer');
  2001. return false;
  2002. }
  2003. }
  2004. async #getGuild(inviteId) {
  2005. try {
  2006. const logStatus = scripts_echoLog({
  2007. type: 'gettingDiscordGuild',
  2008. text: inviteId
  2009. });
  2010. const guild = this.#cache[inviteId];
  2011. if (guild) {
  2012. logStatus.success();
  2013. return guild;
  2014. }
  2015. const {
  2016. result,
  2017. statusText,
  2018. status,
  2019. data
  2020. } = await tools_httpRequest({
  2021. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2022. responseType: 'json',
  2023. method: 'GET'
  2024. });
  2025. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2026. var _data$response2, _data$response2$guild;
  2027. const guild = (_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$guild = _data$response2.guild) === null || _data$response2$guild === void 0 ? void 0 : _data$response2$guild.id;
  2028. if (guild) {
  2029. logStatus.success();
  2030. this.#setCache(inviteId, guild);
  2031. return guild;
  2032. }
  2033. logStatus.error(`${result}:${statusText}(${status})`);
  2034. return false;
  2035. }
  2036. logStatus.error(`${result}:${statusText}(${status})`);
  2037. return false;
  2038. } catch (error) {
  2039. throwError(error, 'Discord.getGuild');
  2040. return false;
  2041. }
  2042. }
  2043. async toggle(_ref2) {
  2044. let {
  2045. doTask = true,
  2046. serverLinks = []
  2047. } = _ref2;
  2048. try {
  2049. if (!this.#initialized) {
  2050. scripts_echoLog({
  2051. text: i18n('needInit')
  2052. });
  2053. return false;
  2054. }
  2055. const prom = [];
  2056. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  2057. scripts_echoLog({
  2058. type: 'globalOptionsSkip',
  2059. text: 'discord.servers'
  2060. });
  2061. } else {
  2062. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  2063. var _link$match;
  2064. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2065. });
  2066. if (realServers.length > 0) {
  2067. for (const server of realServers) {
  2068. if (doTask) {
  2069. prom.push(this.#joinServer(server));
  2070. } else {
  2071. prom.push(this.#leaveServer(server));
  2072. }
  2073. await delay(1e3);
  2074. }
  2075. }
  2076. }
  2077. return await Promise.all(prom).then(() => true);
  2078. } catch (error) {
  2079. throwError(error, 'Discord.toggleServers');
  2080. return false;
  2081. }
  2082. }
  2083. #setCache(inviteId, guild) {
  2084. try {
  2085. this.#cache[inviteId] = guild;
  2086. GM_setValue('discordCache', this.#cache);
  2087. } catch (error) {
  2088. throwError(error, 'Discord.setCache');
  2089. }
  2090. }
  2091. }
  2092. const social_Discord = Discord;
  2093. var Instagram_GM_getValue;
  2094. const Instagram_defaultTasksTemplate = {
  2095. users: []
  2096. };
  2097. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2098. class Instagram extends social_Social {
  2099. tasks = JSON.parse(Instagram_defaultTasks);
  2100. whiteList = {
  2101. ...JSON.parse(Instagram_defaultTasks),
  2102. ...(Instagram_GM_getValue = GM_getValue('whiteList')) === null || Instagram_GM_getValue === void 0 ? void 0 : Instagram_GM_getValue.instagram
  2103. };
  2104. #cache = GM_getValue('instagramCache') || {};
  2105. #auth = {};
  2106. #initialized = false;
  2107. async init() {
  2108. try {
  2109. if (this.#initialized) {
  2110. return true;
  2111. }
  2112. const isVerified = await this.#getUserInfo();
  2113. if (isVerified) {
  2114. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2115. this.#initialized = true;
  2116. return true;
  2117. }
  2118. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2119. return false;
  2120. } catch (error) {
  2121. throwError(error, 'Instagram.init');
  2122. return false;
  2123. }
  2124. }
  2125. async #getUserInfo() {
  2126. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2127. try {
  2128. const logStatus = scripts_echoLog({
  2129. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2130. text: name
  2131. });
  2132. const userId = this.#cache[name];
  2133. if (userId && name !== 'instagram') {
  2134. logStatus.success();
  2135. return userId;
  2136. }
  2137. const {
  2138. result,
  2139. statusText,
  2140. status,
  2141. data
  2142. } = await tools_httpRequest({
  2143. url: `https://www.instagram.com/${name}/`,
  2144. method: 'GET'
  2145. });
  2146. if (result === 'Success') {
  2147. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2148. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2149. return false;
  2150. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2151. logStatus.error(`Error:${i18n('insBanned')}`);
  2152. return false;
  2153. }
  2154. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2155. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2156. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2157. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2158. if (name === 'instagram') {
  2159. if (csrftoken && hash) {
  2160. this.#auth = {
  2161. csrftoken: csrftoken,
  2162. hash: hash
  2163. };
  2164. return true;
  2165. }
  2166. return false;
  2167. }
  2168. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2169. if (id) {
  2170. this.#setCache(name, id);
  2171. logStatus.success();
  2172. return id;
  2173. }
  2174. logStatus.error('Error: Get ins data error!');
  2175. return false;
  2176. }
  2177. logStatus.error(`${result}:${statusText}(${status})`);
  2178. return false;
  2179. }
  2180. return false;
  2181. } catch (error) {
  2182. throwError(error, 'Instagram.getUserInfo');
  2183. return false;
  2184. }
  2185. }
  2186. async #followUser(name) {
  2187. try {
  2188. const id = await this.#getUserInfo(name);
  2189. if (!id) {
  2190. return false;
  2191. }
  2192. const logStatus = scripts_echoLog({
  2193. type: 'followingIns',
  2194. text: name
  2195. });
  2196. const {
  2197. result,
  2198. statusText,
  2199. status,
  2200. data
  2201. } = await tools_httpRequest({
  2202. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2203. method: 'POST',
  2204. dataType: 'json',
  2205. headers: {
  2206. 'x-csrftoken': this.#auth.csrftoken,
  2207. origin: 'https://www.instagram.com',
  2208. referer: `https://www.instagram.com/${name}/`,
  2209. 'content-type': 'application/x-www-form-urlencoded',
  2210. 'sec-fetch-site': 'same-origin',
  2211. 'x-instagram-ajax': this.#auth.hash
  2212. }
  2213. });
  2214. if (result === 'Success') {
  2215. var _data$response, _data$response2;
  2216. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.result) === 'following') {
  2217. logStatus.success();
  2218. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2219. return true;
  2220. }
  2221. logStatus.error(`Error:${(data === null || data === void 0 ? void 0 : (_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : _data$response2.feedback_message) || `${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`}`);
  2222. return false;
  2223. }
  2224. logStatus.error(`${result}:${statusText}(${status})`);
  2225. return false;
  2226. } catch (error) {
  2227. throwError(error, 'Instagram.followUser');
  2228. return false;
  2229. }
  2230. }
  2231. async #unfollowUser(name) {
  2232. try {
  2233. if (this.whiteList.users.includes(name)) {
  2234. scripts_echoLog({
  2235. type: 'whiteList',
  2236. text: 'Instagram.unfollowUser',
  2237. id: name
  2238. });
  2239. return true;
  2240. }
  2241. const id = await this.#getUserInfo(name);
  2242. if (!id) {
  2243. return false;
  2244. }
  2245. const logStatus = scripts_echoLog({
  2246. type: 'unfollowingIns',
  2247. text: name
  2248. });
  2249. const {
  2250. result,
  2251. statusText,
  2252. status,
  2253. data
  2254. } = await tools_httpRequest({
  2255. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2256. method: 'POST',
  2257. dataType: 'json',
  2258. headers: {
  2259. 'x-csrftoken': this.#auth.csrftoken,
  2260. origin: 'https://www.instagram.com',
  2261. referer: `https://www.instagram.com/${name}/`,
  2262. 'content-type': 'application/x-www-form-urlencoded',
  2263. 'sec-fetch-site': 'same-origin',
  2264. 'x-instagram-ajax': this.#auth.hash
  2265. }
  2266. });
  2267. if (result === 'Success') {
  2268. var _data$response3;
  2269. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response3 = data.response) === null || _data$response3 === void 0 ? void 0 : _data$response3.status) === 'ok') {
  2270. logStatus.success();
  2271. return true;
  2272. }
  2273. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2274. return false;
  2275. }
  2276. logStatus.error(`${result}:${statusText}(${status})`);
  2277. return false;
  2278. } catch (error) {
  2279. throwError(error, 'Instagram.unfollowUser');
  2280. return false;
  2281. }
  2282. }
  2283. async toggle(_ref) {
  2284. let {
  2285. doTask = true,
  2286. userLinks = []
  2287. } = _ref;
  2288. try {
  2289. if (!this.#initialized) {
  2290. scripts_echoLog({
  2291. text: i18n('needInit')
  2292. });
  2293. return false;
  2294. }
  2295. const prom = [];
  2296. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2297. scripts_echoLog({
  2298. type: 'globalOptionsSkip',
  2299. text: 'instagram.users'
  2300. });
  2301. } else {
  2302. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2303. var _link$match;
  2304. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2305. });
  2306. if (realUsers.length > 0) {
  2307. for (const username of realUsers) {
  2308. if (doTask) {
  2309. prom.push(this.#followUser(username));
  2310. } else {
  2311. prom.push(this.#unfollowUser(username));
  2312. }
  2313. await delay(1e3);
  2314. }
  2315. }
  2316. }
  2317. return await Promise.all(prom).then(() => true);
  2318. } catch (error) {
  2319. throwError(error, 'Instagram.toggleUsers');
  2320. return false;
  2321. }
  2322. }
  2323. #setCache(name, id) {
  2324. try {
  2325. this.#cache[name] = id;
  2326. GM_setValue('instagramCache', this.#cache);
  2327. } catch (error) {
  2328. throwError(error, 'Instagram.setCache');
  2329. }
  2330. }
  2331. }
  2332. const social_Instagram = Instagram;
  2333. var Reddit_GM_getValue;
  2334. const Reddit_defaultTasksTemplate = {
  2335. reddits: []
  2336. };
  2337. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2338. class Reddit extends social_Social {
  2339. tasks = JSON.parse(Reddit_defaultTasks);
  2340. whiteList = {
  2341. ...JSON.parse(Reddit_defaultTasks),
  2342. ...(Reddit_GM_getValue = GM_getValue('whiteList')) === null || Reddit_GM_getValue === void 0 ? void 0 : Reddit_GM_getValue.reddit
  2343. };
  2344. #auth;
  2345. #initialized = false;
  2346. async init() {
  2347. try {
  2348. if (this.#initialized) {
  2349. return true;
  2350. }
  2351. const isVerified = await this.#updateAuth();
  2352. if (isVerified) {
  2353. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2354. this.#initialized = true;
  2355. return true;
  2356. }
  2357. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2358. return false;
  2359. } catch (error) {
  2360. throwError(error, 'Reddit.init');
  2361. return false;
  2362. }
  2363. }
  2364. async #useBeta() {
  2365. try {
  2366. const logStatus = scripts_echoLog({
  2367. text: i18n('changingRedditVersion')
  2368. });
  2369. GM_setValue('redditAuth', null);
  2370. return await new Promise(resolve => {
  2371. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2372. active: true,
  2373. insert: true,
  2374. setParent: true
  2375. });
  2376. newTab.onclose = async () => {
  2377. logStatus.success();
  2378. resolve(await this.#updateAuth(true));
  2379. };
  2380. });
  2381. } catch (error) {
  2382. throwError(error, 'Reddit.useBeta');
  2383. return false;
  2384. }
  2385. }
  2386. async #updateAuth() {
  2387. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2388. try {
  2389. const logStatus = scripts_echoLog({
  2390. text: i18n('updatingAuth', 'Reddit')
  2391. });
  2392. const {
  2393. result,
  2394. statusText,
  2395. status,
  2396. data
  2397. } = await tools_httpRequest({
  2398. url: 'https://www.reddit.com/',
  2399. method: 'GET',
  2400. nochche: true,
  2401. headers: {
  2402. 'Cache-Control': 'no-cache'
  2403. }
  2404. });
  2405. if (result === 'Success') {
  2406. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2407. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2408. return false;
  2409. }
  2410. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2411. var _data$responseText$ma;
  2412. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2413. return await this.#useBeta();
  2414. }
  2415. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2416. if (accessToken) {
  2417. this.#auth = {
  2418. token: accessToken
  2419. };
  2420. logStatus.success();
  2421. return true;
  2422. }
  2423. logStatus.error('Error: Parameter "accessToken" not found!');
  2424. return false;
  2425. }
  2426. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2427. return false;
  2428. }
  2429. logStatus.error(`${result}:${statusText}(${status})`);
  2430. return false;
  2431. } catch (error) {
  2432. throwError(error, 'Reddit.updateAuth');
  2433. return false;
  2434. }
  2435. }
  2436. async toggleTask(_ref) {
  2437. let {
  2438. name,
  2439. doTask = true
  2440. } = _ref;
  2441. try {
  2442. if (!doTask && this.whiteList.reddits.includes(name)) {
  2443. scripts_echoLog({
  2444. type: 'whiteList',
  2445. text: 'Reddit.undoTask',
  2446. id: name
  2447. });
  2448. return true;
  2449. }
  2450. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2451. if (/^u_/.test(name)) {
  2452. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2453. }
  2454. const logStatus = scripts_echoLog({
  2455. type: type,
  2456. text: name
  2457. });
  2458. const {
  2459. result,
  2460. statusText,
  2461. status,
  2462. data
  2463. } = await tools_httpRequest({
  2464. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2465. method: 'POST',
  2466. headers: {
  2467. authorization: `Bearer ${this.#auth.token}`,
  2468. 'content-type': 'application/x-www-form-urlencoded'
  2469. },
  2470. data: $.param({
  2471. action: doTask ? 'sub' : 'unsub',
  2472. sr_name: name,
  2473. api_type: 'json'
  2474. })
  2475. });
  2476. if (result === 'Success') {
  2477. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2478. logStatus.success();
  2479. if (doTask) {
  2480. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2481. }
  2482. return true;
  2483. }
  2484. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2485. return false;
  2486. }
  2487. logStatus.error(`${result}:${statusText}(${status})`);
  2488. return false;
  2489. } catch (error) {
  2490. throwError(error, 'Reddit.toggleTask');
  2491. return false;
  2492. }
  2493. }
  2494. async toggle(_ref2) {
  2495. let {
  2496. doTask = true,
  2497. redditLinks = []
  2498. } = _ref2;
  2499. try {
  2500. if (!this.#initialized) {
  2501. scripts_echoLog({
  2502. text: i18n('needInit')
  2503. });
  2504. return false;
  2505. }
  2506. const prom = [];
  2507. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2508. scripts_echoLog({
  2509. type: 'globalOptionsSkip',
  2510. text: 'reddit.reddits'
  2511. });
  2512. } else {
  2513. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2514. var _link$match, _link$match2;
  2515. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2516. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2517. if (userName) {
  2518. return name || userName;
  2519. }
  2520. return name;
  2521. });
  2522. if (realReddits.length > 0) {
  2523. for (const name of realReddits) {
  2524. prom.push(this.toggleTask({
  2525. name: name,
  2526. doTask: doTask
  2527. }));
  2528. await delay(1e3);
  2529. }
  2530. }
  2531. }
  2532. return await Promise.all(prom).then(() => true);
  2533. } catch (error) {
  2534. throwError(error, 'Reddit.toggle');
  2535. return false;
  2536. }
  2537. }
  2538. }
  2539. const social_Reddit = Reddit;
  2540. var Twitch_GM_getValue;
  2541. const Twitch_defaultTasksTemplate = {
  2542. channels: []
  2543. };
  2544. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2545. class Twitch extends social_Social {
  2546. tasks = JSON.parse(Twitch_defaultTasks);
  2547. whiteList = {
  2548. ...JSON.parse(Twitch_defaultTasks),
  2549. ...(Twitch_GM_getValue = GM_getValue('whiteList')) === null || Twitch_GM_getValue === void 0 ? void 0 : Twitch_GM_getValue.twitch
  2550. };
  2551. #auth = GM_getValue('twitchAuth') || {};
  2552. #cache = GM_getValue('twitchCache') || {};
  2553. #initialized = false;
  2554. #integrityToken;
  2555. async init() {
  2556. try {
  2557. if (this.#initialized) {
  2558. return true;
  2559. }
  2560. if (!this.#auth.authToken || !this.#auth.clientId || !this.#auth.clientVersion || !this.#auth.deviceId || !this.#auth.clientSessionId) {
  2561. if (await this.#updateAuth()) {
  2562. this.#initialized = true;
  2563. return true;
  2564. }
  2565. return false;
  2566. }
  2567. const isVerified = await this.#verifyAuth(true);
  2568. if (isVerified) {
  2569. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2570. this.#initialized = true;
  2571. return true;
  2572. }
  2573. GM_setValue('twitchAuth', null);
  2574. if (await this.#updateAuth()) {
  2575. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2576. this.#initialized = true;
  2577. return true;
  2578. }
  2579. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2580. return false;
  2581. } catch (error) {
  2582. throwError(error, 'Twitch.init');
  2583. return false;
  2584. }
  2585. }
  2586. async #verifyAuth(isFirst) {
  2587. try {
  2588. const logStatus = scripts_echoLog({
  2589. text: i18n('verifyingAuth', 'Twitch')
  2590. });
  2591. const {
  2592. result,
  2593. statusText,
  2594. status,
  2595. data
  2596. } = await tools_httpRequest({
  2597. url: 'https://gql.twitch.tv/gql',
  2598. method: 'POST',
  2599. dataType: 'json',
  2600. headers: {
  2601. Authorization: `OAuth ${this.#auth.authToken}`,
  2602. 'Client-Id': this.#auth.clientId
  2603. },
  2604. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2605. });
  2606. if (result === 'Success') {
  2607. var _data$response, _data$response$, _data$response$$data;
  2608. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response = data.response) !== null && _data$response !== void 0 && (_data$response$ = _data$response[0]) !== null && _data$response$ !== void 0 && (_data$response$$data = _data$response$.data) !== null && _data$response$$data !== void 0 && _data$response$$data.currentUser) {
  2609. await this.#integrity(isFirst);
  2610. logStatus.success();
  2611. return true;
  2612. }
  2613. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2614. return false;
  2615. }
  2616. logStatus.error(`${result}:${statusText}(${status})`);
  2617. return false;
  2618. } catch (error) {
  2619. throwError(error, 'Twitch.verifyAuth');
  2620. return false;
  2621. }
  2622. }
  2623. async #integrity() {
  2624. let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  2625. let ct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2626. try {
  2627. const logStatus = scripts_echoLog({
  2628. text: i18n('checkingTwitchIntegrity')
  2629. });
  2630. if (isFirst && (!this.#auth.authToken || !this.#auth.clientId || !this.#auth.clientVersion || !this.#auth.deviceId || !this.#auth.clientSessionId)) {
  2631. return await this.#updateAuth(false);
  2632. }
  2633. const {
  2634. result,
  2635. statusText,
  2636. status,
  2637. data
  2638. } = await tools_httpRequest({
  2639. url: 'https://gql.twitch.tv/integrity',
  2640. method: 'POST',
  2641. dataType: 'json',
  2642. anonymous: true,
  2643. headers: {
  2644. Origin: 'https://www.twitch.tv',
  2645. Referer: 'https://www.twitch.tv/',
  2646. Authorization: `OAuth ${this.#auth.authToken}`,
  2647. 'Client-Id': this.#auth.clientId,
  2648. 'Client-Version': this.#auth.clientVersion,
  2649. 'X-Device-Id': this.#auth.deviceId,
  2650. 'Client-Session-Id': this.#auth.clientSessionId,
  2651. 'x-kpsdk-ct': ct
  2652. }
  2653. });
  2654. if (result === 'Success') {
  2655. var _data$responseHeaders, _data$response2;
  2656. if (!ct && data !== null && data !== void 0 && (_data$responseHeaders = data.responseHeaders) !== null && _data$responseHeaders !== void 0 && _data$responseHeaders['x-kpsdk-ct']) {
  2657. return await this.#integrity(isFirst, data.responseHeaders['x-kpsdk-ct']);
  2658. }
  2659. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.token) {
  2660. this.#integrityToken = data.response.token;
  2661. logStatus.success();
  2662. return true;
  2663. }
  2664. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2665. return false;
  2666. }
  2667. logStatus.error(`${result}:${statusText}(${status})`);
  2668. return false;
  2669. } catch (error) {
  2670. throwError(error, 'Twitch.integrity');
  2671. return false;
  2672. }
  2673. }
  2674. async #updateAuth() {
  2675. let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  2676. try {
  2677. const logStatus = scripts_echoLog({
  2678. text: i18n('updatingAuth', 'Twitch')
  2679. });
  2680. return await new Promise(resolve => {
  2681. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2682. active: true,
  2683. insert: true,
  2684. setParent: true
  2685. });
  2686. newTab.onclose = async () => {
  2687. const auth = GM_getValue('twitchAuth');
  2688. if (auth) {
  2689. this.#auth = auth;
  2690. logStatus.success();
  2691. resolve(await this.#verifyAuth(isFirst));
  2692. } else {
  2693. logStatus.error('Error: Update twitch auth failed!');
  2694. resolve(false);
  2695. }
  2696. };
  2697. });
  2698. } catch (error) {
  2699. throwError(error, 'Twitch.updateAuth');
  2700. return false;
  2701. }
  2702. }
  2703. async #toggleChannel(_ref) {
  2704. let {
  2705. name,
  2706. doTask = true
  2707. } = _ref;
  2708. try {
  2709. if (!doTask && this.whiteList.channels.includes(name)) {
  2710. scripts_echoLog({
  2711. type: 'whiteList',
  2712. text: 'Twitch.unfollowChannel',
  2713. id: name
  2714. });
  2715. return true;
  2716. }
  2717. const channelId = await this.#getChannelId(name);
  2718. if (!channelId) {
  2719. return false;
  2720. }
  2721. const logStatus = scripts_echoLog({
  2722. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2723. text: name
  2724. });
  2725. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"800e7346bdf7e5278a3c1d3f21b2b56e2639928f86815677a7126b093b2fdd08"}}}]';
  2726. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"f7dae976ebf41c755ae2d758546bfd176b4eeb856656098bb40e0a672ca0d880"}}}]';
  2727. const {
  2728. result,
  2729. statusText,
  2730. status,
  2731. data
  2732. } = await tools_httpRequest({
  2733. url: 'https://gql.twitch.tv/gql',
  2734. method: 'POST',
  2735. dataType: 'json',
  2736. anonymous: true,
  2737. headers: {
  2738. Origin: 'https://www.twitch.tv',
  2739. Referer: 'https://www.twitch.tv/',
  2740. Authorization: `OAuth ${this.#auth.authToken}`,
  2741. 'Client-Id': this.#auth.clientId,
  2742. 'Client-Version': this.#auth.clientVersion,
  2743. 'X-Device-Id': this.#auth.deviceId,
  2744. 'Client-Session-Id': this.#auth.clientSessionId,
  2745. 'Client-Integrity': this.#integrityToken
  2746. },
  2747. data: doTask ? followData : unfollowData
  2748. });
  2749. if (result === 'Success') {
  2750. var _data$response3, _data$response4, _data$response4$0$err, _data$response4$0$err2;
  2751. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3[0] && !data.response[0].errors) {
  2752. logStatus.success();
  2753. if (doTask) {
  2754. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2755. }
  2756. return true;
  2757. }
  2758. logStatus.error(`Error:${(data === null || data === void 0 ? void 0 : (_data$response4 = data.response) === null || _data$response4 === void 0 ? void 0 : (_data$response4$0$err = _data$response4[0].errors) === null || _data$response4$0$err === void 0 ? void 0 : (_data$response4$0$err2 = _data$response4$0$err[0]) === null || _data$response4$0$err2 === void 0 ? void 0 : _data$response4$0$err2.message) || `${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`}`);
  2759. return false;
  2760. }
  2761. logStatus.error(`${result}:${statusText}(${status})`);
  2762. return false;
  2763. } catch (error) {
  2764. throwError(error, 'Twitch.toggleChannel');
  2765. return false;
  2766. }
  2767. }
  2768. async #getChannelId(name) {
  2769. try {
  2770. const logStatus = scripts_echoLog({
  2771. type: 'gettingTwitchChannelId',
  2772. text: name
  2773. });
  2774. const channelId = this.#cache[name];
  2775. if (channelId) {
  2776. logStatus.success();
  2777. return channelId;
  2778. }
  2779. const {
  2780. result,
  2781. statusText,
  2782. status,
  2783. data
  2784. } = await tools_httpRequest({
  2785. url: 'https://gql.twitch.tv/gql',
  2786. method: 'POST',
  2787. headers: {
  2788. Authorization: `OAuth ${this.#auth.authToken}`,
  2789. 'Client-Id': this.#auth.clientId
  2790. },
  2791. responseType: 'json',
  2792. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  2793. });
  2794. if (result === 'Success') {
  2795. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2796. var _data$response5, _data$response5$, _data$response5$$data, _data$response5$$data2;
  2797. const channelId = (_data$response5 = data.response) === null || _data$response5 === void 0 ? void 0 : (_data$response5$ = _data$response5[0]) === null || _data$response5$ === void 0 ? void 0 : (_data$response5$$data = _data$response5$.data) === null || _data$response5$$data === void 0 ? void 0 : (_data$response5$$data2 = _data$response5$$data.user) === null || _data$response5$$data2 === void 0 ? void 0 : _data$response5$$data2.id;
  2798. if (channelId) {
  2799. this.#setCache(name, String(channelId));
  2800. logStatus.success();
  2801. return channelId;
  2802. }
  2803. logStatus.error(`Error:${data.statusText}(${data.status})`);
  2804. return false;
  2805. }
  2806. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2807. return false;
  2808. }
  2809. logStatus.error(`${result}:${statusText}(${status})`);
  2810. return false;
  2811. } catch (error) {
  2812. throwError(error, 'Twitch.getChannelId');
  2813. return false;
  2814. }
  2815. }
  2816. async toggle(_ref2) {
  2817. let {
  2818. doTask = true,
  2819. channelLinks = []
  2820. } = _ref2;
  2821. try {
  2822. if (!this.#initialized) {
  2823. scripts_echoLog({
  2824. text: i18n('needInit')
  2825. });
  2826. return false;
  2827. }
  2828. const prom = [];
  2829. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2830. scripts_echoLog({
  2831. type: 'globalOptionsSkip',
  2832. text: 'twitch.channels'
  2833. });
  2834. } else {
  2835. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2836. var _link$match;
  2837. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2838. });
  2839. if (realChannels.length > 0) {
  2840. for (const channel of realChannels) {
  2841. prom.push(this.#toggleChannel({
  2842. name: channel,
  2843. doTask: doTask
  2844. }));
  2845. await delay(1e3);
  2846. }
  2847. }
  2848. }
  2849. return Promise.all(prom).then(() => true);
  2850. } catch (error) {
  2851. throwError(error, 'Twitch.toggle');
  2852. return false;
  2853. }
  2854. }
  2855. #setCache(name, id) {
  2856. try {
  2857. this.#cache[name] = id;
  2858. GM_setValue('twitchCache', this.#cache);
  2859. } catch (error) {
  2860. throwError(error, 'Twitch.setCache');
  2861. }
  2862. }
  2863. }
  2864. const social_Twitch = Twitch;
  2865. var Twitter_GM_getValue;
  2866. const Twitter_defaultTasksTemplate = {
  2867. users: [],
  2868. retweets: [],
  2869. likes: []
  2870. };
  2871. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  2872. class Twitter extends social_Social {
  2873. tasks = JSON.parse(Twitter_defaultTasks);
  2874. whiteList = {
  2875. ...JSON.parse(Twitter_defaultTasks),
  2876. ...(Twitter_GM_getValue = GM_getValue('whiteList')) === null || Twitter_GM_getValue === void 0 ? void 0 : Twitter_GM_getValue.twitter
  2877. };
  2878. #verifyId = globalOptions.other.twitterVerifyId;
  2879. #auth = GM_getValue('twitterAuth') || {};
  2880. #cache = GM_getValue('twitterCache') || {};
  2881. #initialized = false;
  2882. async init() {
  2883. try {
  2884. if (this.#initialized) {
  2885. return true;
  2886. }
  2887. if (!this.#auth.ct0) {
  2888. if (await this.#updateAuth()) {
  2889. this.#initialized = true;
  2890. return true;
  2891. }
  2892. return false;
  2893. }
  2894. const isVerified = await this.#verifyAuth();
  2895. if (isVerified) {
  2896. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  2897. this.#initialized = true;
  2898. return true;
  2899. }
  2900. GM_setValue('twitterAuth', null);
  2901. if (await this.#updateAuth()) {
  2902. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  2903. this.#initialized = true;
  2904. return true;
  2905. }
  2906. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  2907. return false;
  2908. } catch (error) {
  2909. throwError(error, 'Twitter.init');
  2910. return false;
  2911. }
  2912. }
  2913. async #verifyAuth() {
  2914. try {
  2915. return await this.#toggleUser({
  2916. name: 'verify',
  2917. doTask: true,
  2918. verify: true
  2919. });
  2920. } catch (error) {
  2921. throwError(error, 'Twitter.verifyAuth');
  2922. return false;
  2923. }
  2924. }
  2925. async #updateAuth() {
  2926. try {
  2927. const logStatus = scripts_echoLog({
  2928. text: i18n('updatingAuth', 'Twitter')
  2929. });
  2930. return await new Promise(resolve => {
  2931. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  2932. active: true,
  2933. insert: true,
  2934. setParent: true
  2935. });
  2936. newTab.onclose = async () => {
  2937. const auth = GM_getValue('twitterAuth');
  2938. if (auth) {
  2939. this.#auth = auth;
  2940. logStatus.success();
  2941. resolve(await this.#verifyAuth());
  2942. } else {
  2943. logStatus.error('Error: Update twitter auth failed!');
  2944. resolve(false);
  2945. }
  2946. };
  2947. });
  2948. } catch (error) {
  2949. throwError(error, 'Twitter.updateToken');
  2950. return false;
  2951. }
  2952. }
  2953. async #toggleUser(_ref) {
  2954. let {
  2955. name,
  2956. doTask = true,
  2957. verify = false
  2958. } = _ref;
  2959. try {
  2960. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  2961. scripts_echoLog({
  2962. type: 'whiteList',
  2963. text: 'Twitter.unfollowUser',
  2964. id: name
  2965. });
  2966. return true;
  2967. }
  2968. const userId = verify ? this.#verifyId : await this.userName2id(name);
  2969. if (!userId) {
  2970. return false;
  2971. }
  2972. const logStatus = verify ? scripts_echoLog({
  2973. text: i18n('verifyingAuth', 'Twitter')
  2974. }) : scripts_echoLog({
  2975. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  2976. text: name
  2977. });
  2978. const {
  2979. result,
  2980. statusText,
  2981. status,
  2982. data
  2983. } = await tools_httpRequest({
  2984. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  2985. method: 'POST',
  2986. headers: {
  2987. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  2988. 'Content-Type': 'application/x-www-form-urlencoded',
  2989. 'x-csrf-token': this.#auth.ct0
  2990. },
  2991. responseType: 'json',
  2992. data: $.param({
  2993. include_profile_interstitial_type: 1,
  2994. include_blocking: 1,
  2995. include_blocked_by: 1,
  2996. include_followed_by: 1,
  2997. include_want_retweets: 1,
  2998. include_mute_edge: 1,
  2999. include_can_dm: 1,
  3000. include_can_media_tag: 1,
  3001. skip_status: 1,
  3002. id: userId
  3003. })
  3004. });
  3005. if (result === 'Success') {
  3006. var _data$response, _data$response$errors, _data$response$errors2;
  3007. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3008. logStatus.success();
  3009. if (doTask && !verify) {
  3010. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3011. }
  3012. return true;
  3013. }
  3014. if (verify && (data === null || data === void 0 ? void 0 : data.status) === 403 && ((_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$errors = _data$response.errors) === null || _data$response$errors === void 0 ? void 0 : (_data$response$errors2 = _data$response$errors[0]) === null || _data$response$errors2 === void 0 ? void 0 : _data$response$errors2.code) === 158) {
  3015. logStatus.success();
  3016. return true;
  3017. }
  3018. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3019. return false;
  3020. }
  3021. logStatus.error(`${result}:${statusText}(${status})`);
  3022. return false;
  3023. } catch (error) {
  3024. throwError(error, 'Twitter.toggleUser');
  3025. return false;
  3026. }
  3027. }
  3028. async userName2id(name) {
  3029. try {
  3030. const logStatus = scripts_echoLog({
  3031. type: 'gettingTwitterUserId',
  3032. text: name
  3033. });
  3034. const userId = this.#cache[name];
  3035. if (userId) {
  3036. logStatus.success();
  3037. return userId;
  3038. }
  3039. const {
  3040. result,
  3041. statusText,
  3042. status,
  3043. data
  3044. } = await tools_httpRequest({
  3045. url: 'https://api.twitter.com/graphql/mCbpQvZAw6zu_4PvuAUVVQ/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D`,
  3046. method: 'GET',
  3047. headers: {
  3048. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3049. 'content-type': 'application/json',
  3050. referer: `https://twitter.com/${name}`,
  3051. 'x-csrf-token': this.#auth.ct0
  3052. },
  3053. responseType: 'json'
  3054. });
  3055. if (result === 'Success') {
  3056. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3057. var _response, _response$data, _response$data$user, _response$data$user$r;
  3058. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3059. if (!response) {
  3060. try {
  3061. response = JSON.parse(data.responseText);
  3062. } catch (error) {
  3063. response = null;
  3064. }
  3065. }
  3066. const userId = String((_response = response) === null || _response === void 0 ? void 0 : (_response$data = _response.data) === null || _response$data === void 0 ? void 0 : (_response$data$user = _response$data.user) === null || _response$data$user === void 0 ? void 0 : (_response$data$user$r = _response$data$user.result) === null || _response$data$user$r === void 0 ? void 0 : _response$data$user$r.rest_id);
  3067. if (userId) {
  3068. this.#setCache(name, userId);
  3069. logStatus.success();
  3070. return userId;
  3071. }
  3072. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3073. return false;
  3074. }
  3075. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3076. return false;
  3077. }
  3078. logStatus.error(`${result}:${statusText}(${status})`);
  3079. return false;
  3080. } catch (error) {
  3081. throwError(error, 'Twitter.getUserId');
  3082. return false;
  3083. }
  3084. }
  3085. async #toggleRetweet(_ref2) {
  3086. let {
  3087. retweetId,
  3088. doTask = true
  3089. } = _ref2;
  3090. try {
  3091. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3092. scripts_echoLog({
  3093. type: 'whiteList',
  3094. text: 'Twitter.unretweet',
  3095. id: retweetId
  3096. });
  3097. return true;
  3098. }
  3099. const logStatus = scripts_echoLog({
  3100. type: `${doTask ? '' : 'un'}retweetting`,
  3101. text: retweetId
  3102. });
  3103. const {
  3104. result,
  3105. statusText,
  3106. status,
  3107. data
  3108. } = await tools_httpRequest({
  3109. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3110. method: 'POST',
  3111. headers: {
  3112. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3113. 'Content-Type': 'application/x-www-form-urlencoded',
  3114. 'x-csrf-token': this.#auth.ct0
  3115. },
  3116. data: $.param({
  3117. tweet_mode: 'extended',
  3118. id: retweetId
  3119. }),
  3120. responseType: 'json'
  3121. });
  3122. if (result === 'Success') {
  3123. var _data$response2, _data$response2$error, _data$response2$error2;
  3124. if ((data === null || data === void 0 ? void 0 : data.status) === 200 || (data === null || data === void 0 ? void 0 : data.status) === 403 && ((_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$error = _data$response2.errors) === null || _data$response2$error === void 0 ? void 0 : (_data$response2$error2 = _data$response2$error[0]) === null || _data$response2$error2 === void 0 ? void 0 : _data$response2$error2.code) === 327) {
  3125. logStatus.success();
  3126. if (doTask) {
  3127. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3128. }
  3129. return true;
  3130. }
  3131. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3132. return false;
  3133. }
  3134. logStatus.error(`${result}:${statusText}(${status})`);
  3135. return false;
  3136. } catch (error) {
  3137. throwError(error, 'Twitter.toggleRetweet');
  3138. return false;
  3139. }
  3140. }
  3141. async toggle(_ref3) {
  3142. let {
  3143. doTask = true,
  3144. userLinks = [],
  3145. retweetLinks = []
  3146. } = _ref3;
  3147. try {
  3148. if (!this.#initialized) {
  3149. scripts_echoLog({
  3150. text: i18n('needInit')
  3151. });
  3152. return false;
  3153. }
  3154. const prom = [];
  3155. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3156. scripts_echoLog({
  3157. type: 'globalOptionsSkip',
  3158. text: 'twitter.users'
  3159. });
  3160. } else {
  3161. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3162. var _link$match;
  3163. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3164. });
  3165. if (realUsers.length > 0) {
  3166. for (const user of realUsers) {
  3167. prom.push(this.#toggleUser({
  3168. name: user,
  3169. doTask: doTask
  3170. }));
  3171. await delay(1e3);
  3172. }
  3173. }
  3174. }
  3175. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3176. scripts_echoLog({
  3177. type: 'globalOptionsSkip',
  3178. text: 'twitter.retweets'
  3179. });
  3180. } else {
  3181. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3182. var _link$match2;
  3183. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3184. });
  3185. if (realRetweets.length > 0) {
  3186. for (const retweet of realRetweets) {
  3187. prom.push(this.#toggleRetweet({
  3188. retweetId: retweet,
  3189. doTask: doTask
  3190. }));
  3191. await delay(1e3);
  3192. }
  3193. }
  3194. }
  3195. return Promise.all(prom).then(() => true);
  3196. } catch (error) {
  3197. throwError(error, 'Twitter.toggle');
  3198. return false;
  3199. }
  3200. }
  3201. #setCache(name, id) {
  3202. try {
  3203. this.#cache[name] = id;
  3204. GM_setValue('twitterCache', this.#cache);
  3205. } catch (error) {
  3206. throwError(error, 'Twitter.setCache');
  3207. }
  3208. }
  3209. }
  3210. const social_Twitter = Twitter;
  3211. var Vk_GM_getValue;
  3212. const Vk_defaultTasksTemplate = {
  3213. names: []
  3214. };
  3215. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3216. class Vk extends social_Social {
  3217. tasks = JSON.parse(Vk_defaultTasks);
  3218. whiteList = {
  3219. ...JSON.parse(Vk_defaultTasks),
  3220. ...(Vk_GM_getValue = GM_getValue('whiteList')) === null || Vk_GM_getValue === void 0 ? void 0 : Vk_GM_getValue.vk
  3221. };
  3222. #username = '';
  3223. #cache = GM_getValue('vkCache') || {};
  3224. #initialized = false;
  3225. async init() {
  3226. try {
  3227. if (this.#initialized) {
  3228. return true;
  3229. }
  3230. const isVerified = await this.#verifyAuth();
  3231. if (isVerified) {
  3232. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3233. this.#initialized = true;
  3234. return true;
  3235. }
  3236. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3237. return false;
  3238. } catch (error) {
  3239. throwError(error, 'Vk.init');
  3240. return false;
  3241. }
  3242. }
  3243. async #verifyAuth() {
  3244. try {
  3245. const logStatus = scripts_echoLog({
  3246. text: i18n('verifyAuth', 'Vk')
  3247. });
  3248. const {
  3249. result,
  3250. statusText,
  3251. status,
  3252. data
  3253. } = await tools_httpRequest({
  3254. url: 'https://vk.com/im',
  3255. method: 'GET'
  3256. });
  3257. if (result === 'Success') {
  3258. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3259. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3260. return false;
  3261. }
  3262. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3263. var _data$responseText$ma;
  3264. this.#username = ((_data$responseText$ma = data.responseText.match(/TopNavBtn__profileLink" href="\/(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1]) || '';
  3265. logStatus.success();
  3266. return true;
  3267. }
  3268. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3269. return false;
  3270. }
  3271. logStatus.error(`${result}:${statusText}(${status})`);
  3272. return false;
  3273. } catch (error) {
  3274. throwError(error, 'Vk.verifyAuth');
  3275. return false;
  3276. }
  3277. }
  3278. async #toggleGroup(name, dataParam) {
  3279. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3280. try {
  3281. const logStatus = scripts_echoLog({
  3282. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3283. text: name
  3284. });
  3285. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3286. logStatus.success();
  3287. return true;
  3288. }
  3289. const reqData = {
  3290. act: doTask ? 'enter' : 'leave',
  3291. al: 1,
  3292. gid: dataParam.groupId,
  3293. hash: dataParam.groupHash
  3294. };
  3295. if (doTask) {
  3296. reqData.context = '_';
  3297. }
  3298. const {
  3299. result,
  3300. statusText,
  3301. status,
  3302. data
  3303. } = await tools_httpRequest({
  3304. url: 'https://vk.com/al_groups.php',
  3305. method: 'POST',
  3306. headers: {
  3307. origin: 'https://vk.com',
  3308. referer: `https://vk.com/${name}`,
  3309. 'content-type': 'application/x-www-form-urlencoded'
  3310. },
  3311. data: $.param(reqData)
  3312. });
  3313. if (result === 'Success') {
  3314. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3315. logStatus.success();
  3316. if (doTask) {
  3317. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3318. }
  3319. return true;
  3320. }
  3321. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3322. return false;
  3323. }
  3324. logStatus.error(`${result}:${statusText}(${status})`);
  3325. return false;
  3326. } catch (error) {
  3327. throwError(error, 'Vk.toggleGroup');
  3328. return false;
  3329. }
  3330. }
  3331. async #togglePublic(name, dataParam) {
  3332. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3333. try {
  3334. const logStatus = scripts_echoLog({
  3335. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3336. text: name
  3337. });
  3338. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3339. logStatus.success();
  3340. return true;
  3341. }
  3342. const {
  3343. result,
  3344. statusText,
  3345. status,
  3346. data
  3347. } = await tools_httpRequest({
  3348. url: 'https://vk.com/al_public.php',
  3349. method: 'POST',
  3350. headers: {
  3351. origin: 'https://vk.com',
  3352. referer: `https://vk.com/${name}`,
  3353. 'content-type': 'application/x-www-form-urlencoded'
  3354. },
  3355. data: $.param({
  3356. act: doTask ? 'a_enter' : 'a_leave',
  3357. al: 1,
  3358. pid: dataParam.publicPid,
  3359. hash: dataParam.publicHash
  3360. })
  3361. });
  3362. if (result === 'Success') {
  3363. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3364. logStatus.success();
  3365. if (doTask) {
  3366. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3367. }
  3368. return true;
  3369. }
  3370. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3371. return false;
  3372. }
  3373. logStatus.error(`${result}:${statusText}(${status})`);
  3374. return false;
  3375. } catch (error) {
  3376. throwError(error, 'Vk.togglePublic');
  3377. return false;
  3378. }
  3379. }
  3380. async #sendWall(name) {
  3381. try {
  3382. const logStatus = scripts_echoLog({
  3383. type: 'sendingVkWall',
  3384. text: name
  3385. });
  3386. const {
  3387. result,
  3388. statusText,
  3389. status,
  3390. data
  3391. } = await tools_httpRequest({
  3392. url: 'https://vk.com/like.php',
  3393. method: 'POST',
  3394. headers: {
  3395. origin: 'https://vk.com',
  3396. referer: `https://vk.com/${name}`,
  3397. 'content-type': 'application/x-www-form-urlencoded'
  3398. },
  3399. data: $.param({
  3400. act: 'publish_box',
  3401. al: 1,
  3402. object: name
  3403. })
  3404. });
  3405. if (result === 'Success') {
  3406. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3407. var _data$responseText$ma2;
  3408. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3409. if (hash) {
  3410. const {
  3411. result: resultR,
  3412. statusText: statusTextR,
  3413. status: statusR,
  3414. data: dataR
  3415. } = await tools_httpRequest({
  3416. url: 'https://vk.com/like.php',
  3417. method: 'POST',
  3418. headers: {
  3419. origin: 'https://vk.com',
  3420. referer: `https://vk.com/${name}`,
  3421. 'content-type': 'application/x-www-form-urlencoded'
  3422. },
  3423. data: $.param({
  3424. Message: '',
  3425. act: 'a_do_publish',
  3426. al: 1,
  3427. close_comments: 0,
  3428. friends_only: 0,
  3429. from: 'box',
  3430. hash: hash,
  3431. list: '',
  3432. mark_as_ads: 0,
  3433. mute_notifications: 0,
  3434. object: name,
  3435. ret_data: 1,
  3436. to: 0
  3437. })
  3438. });
  3439. if (resultR === 'Success') {
  3440. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3441. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3442. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3443. if ((jsonData === null || jsonData === void 0 ? void 0 : (_jsonData$payload = jsonData.payload) === null || _jsonData$payload === void 0 ? void 0 : (_jsonData$payload$ = _jsonData$payload[1]) === null || _jsonData$payload$ === void 0 ? void 0 : (_jsonData$payload$$ = _jsonData$payload$[1]) === null || _jsonData$payload$$ === void 0 ? void 0 : _jsonData$payload$$.share_my) === true) {
  3444. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3445. logStatus.success();
  3446. const postId = String(jsonData === null || jsonData === void 0 ? void 0 : (_jsonData$payload2 = jsonData.payload) === null || _jsonData$payload2 === void 0 ? void 0 : (_jsonData$payload2$ = _jsonData$payload2[1]) === null || _jsonData$payload2$ === void 0 ? void 0 : (_jsonData$payload2$$ = _jsonData$payload2$[1]) === null || _jsonData$payload2$$ === void 0 ? void 0 : _jsonData$payload2$$.post_id);
  3447. const ownerId = String(jsonData === null || jsonData === void 0 ? void 0 : (_jsonData$payload3 = jsonData.payload) === null || _jsonData$payload3 === void 0 ? void 0 : (_jsonData$payload3$ = _jsonData$payload3[1]) === null || _jsonData$payload3$ === void 0 ? void 0 : (_jsonData$payload3$$ = _jsonData$payload3$[1]) === null || _jsonData$payload3$$ === void 0 ? void 0 : _jsonData$payload3$$.owner_id);
  3448. if (postId && ownerId) {
  3449. this.#setCache(name, `${ownerId}_${postId}`);
  3450. }
  3451. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3452. return true;
  3453. }
  3454. }
  3455. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3456. return false;
  3457. }
  3458. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3459. return false;
  3460. }
  3461. logStatus.error('Error: Get "hash" failed');
  3462. return false;
  3463. }
  3464. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3465. return false;
  3466. }
  3467. logStatus.error(`${result}:${statusText}(${status})`);
  3468. return false;
  3469. } catch (error) {
  3470. throwError(error, 'Vk.sendWall');
  3471. return false;
  3472. }
  3473. }
  3474. async #deleteWall(name, dataParams) {
  3475. try {
  3476. const logStatus = scripts_echoLog({
  3477. type: 'deletingVkWall',
  3478. text: name
  3479. });
  3480. const {
  3481. result,
  3482. statusText,
  3483. status,
  3484. data
  3485. } = await tools_httpRequest({
  3486. url: 'https://vk.com/al_wall.php?act=delete',
  3487. method: 'POST',
  3488. headers: {
  3489. origin: 'https://vk.com',
  3490. referer: `https://vk.com/${this.#username}?w=wall${this.#cache[name]}%2Fall`,
  3491. 'content-type': 'application/x-www-form-urlencoded'
  3492. },
  3493. data: $.param({
  3494. act: 'delete',
  3495. al: 1,
  3496. confirm: 0,
  3497. from: 'wkview',
  3498. hash: dataParams.wallHash,
  3499. post: this.#cache[name]
  3500. })
  3501. });
  3502. if (result === 'Success') {
  3503. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3504. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3505. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3506. if (jsonData !== null && jsonData !== void 0 && (_jsonData$payload4 = jsonData.payload) !== null && _jsonData$payload4 !== void 0 && (_jsonData$payload4$ = _jsonData$payload4[1]) !== null && _jsonData$payload4$ !== void 0 && _jsonData$payload4$[1]) {
  3507. logStatus.success();
  3508. return true;
  3509. }
  3510. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3511. return false;
  3512. }
  3513. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3514. return false;
  3515. }
  3516. logStatus.error(`${result}:${statusText}(${status})`);
  3517. return false;
  3518. } catch (error) {
  3519. throwError(error, 'Vk.deleteWall');
  3520. return false;
  3521. }
  3522. }
  3523. async #getId(name, doTask) {
  3524. try {
  3525. let url = `https://vk.com/${name}`;
  3526. if (/^wall-/.test(name)) {
  3527. if (doTask) {
  3528. return {
  3529. type: 'sendWall'
  3530. };
  3531. }
  3532. if (!this.#cache[name]) {
  3533. return {
  3534. type: 'unSupport'
  3535. };
  3536. }
  3537. url = `https://vk.com/${this.#username}?w=wall${this.#cache[name]}`;
  3538. }
  3539. const logStatus = scripts_echoLog({
  3540. type: 'gettingVkId',
  3541. text: name
  3542. });
  3543. const {
  3544. result,
  3545. statusText,
  3546. status,
  3547. data
  3548. } = await tools_httpRequest({
  3549. url: url,
  3550. method: 'GET'
  3551. });
  3552. if (result === 'Success') {
  3553. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3554. var _data$responseText$ma3, _data$responseText$ma4;
  3555. const [ , groupAct, groupId, , groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), (&#39;|')(.*?)(&#39;|')/) || [];
  3556. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3557. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3558. const publicJoined = !data.responseText.includes('Public.subscribe');
  3559. if (groupAct && groupId && groupHash) {
  3560. logStatus.success();
  3561. return {
  3562. groupAct: groupAct,
  3563. groupId: groupId,
  3564. groupHash: groupHash,
  3565. type: 'group'
  3566. };
  3567. } else if (publicHash && publicPid) {
  3568. logStatus.success();
  3569. return {
  3570. publicHash: publicHash,
  3571. publicPid: publicPid,
  3572. publicJoined: publicJoined,
  3573. type: 'public'
  3574. };
  3575. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3576. var _data$responseText$ma5;
  3577. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3578. if (wallHash) {
  3579. logStatus.success();
  3580. return {
  3581. type: 'deleteWall',
  3582. wallHash: wallHash
  3583. };
  3584. }
  3585. } else if (name.includes('wall') && doTask) {
  3586. logStatus.success();
  3587. return {
  3588. type: 'sendWall'
  3589. };
  3590. }
  3591. logStatus.error('Error: Parameters not found!');
  3592. return false;
  3593. }
  3594. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3595. return false;
  3596. }
  3597. logStatus.error(`${result}:${statusText}(${status})`);
  3598. return false;
  3599. } catch (error) {
  3600. throwError(error, 'Vk.getId');
  3601. return false;
  3602. }
  3603. }
  3604. async #toggleVk(_ref) {
  3605. let {
  3606. name,
  3607. doTask = true
  3608. } = _ref;
  3609. try {
  3610. if (!doTask && this.whiteList.names.includes(name)) {
  3611. scripts_echoLog({
  3612. type: 'whiteList',
  3613. text: 'Vk.undoTask',
  3614. id: name
  3615. });
  3616. return true;
  3617. }
  3618. const formatName = name.replace(/\/$/, '');
  3619. const data = await this.#getId(formatName, doTask);
  3620. if (!data) {
  3621. return false;
  3622. }
  3623. switch (data.type) {
  3624. case 'group':
  3625. return await this.#toggleGroup(formatName, data, doTask);
  3626.  
  3627. case 'public':
  3628. return await this.#togglePublic(formatName, data, doTask);
  3629.  
  3630. case 'sendWall':
  3631. return doTask ? await this.#sendWall(formatName) : true;
  3632.  
  3633. case 'deleteWall':
  3634. return doTask ? true : await this.#deleteWall(formatName, data);
  3635.  
  3636. default:
  3637. return false;
  3638. }
  3639. } catch (error) {
  3640. throwError(error, 'Vk.toggleVk');
  3641. return false;
  3642. }
  3643. }
  3644. async toggle(_ref2) {
  3645. let {
  3646. doTask = true,
  3647. nameLinks = []
  3648. } = _ref2;
  3649. try {
  3650. if (!this.#initialized) {
  3651. scripts_echoLog({
  3652. text: i18n('needInit')
  3653. });
  3654. return false;
  3655. }
  3656. const prom = [];
  3657. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3658. scripts_echoLog({
  3659. type: 'globalOptionsSkip',
  3660. text: 'vk.names'
  3661. });
  3662. } else {
  3663. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3664. var _link$match;
  3665. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3666. });
  3667. if (realNames.length > 0) {
  3668. for (const name of realNames) {
  3669. prom.push(this.#toggleVk({
  3670. name: name,
  3671. doTask: doTask
  3672. }));
  3673. await delay(1e3);
  3674. }
  3675. }
  3676. }
  3677. return Promise.all(prom).then(() => true);
  3678. } catch (error) {
  3679. throwError(error, 'Vk.toggle');
  3680. return false;
  3681. }
  3682. }
  3683. #setCache(name, postId) {
  3684. try {
  3685. this.#cache[name] = postId;
  3686. GM_setValue('vkCache', this.#cache);
  3687. } catch (error) {
  3688. throwError(error, 'Vk.setCache');
  3689. }
  3690. }
  3691. }
  3692. const social_Vk = Vk;
  3693. var Youtube_GM_getValue;
  3694. const Youtube_defaultTasksTemplate = {
  3695. channels: [],
  3696. likes: []
  3697. };
  3698. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  3699. const getInfo = async function(link, type) {
  3700. try {
  3701. const logStatus = scripts_echoLog({
  3702. text: i18n('gettingYtbToken')
  3703. });
  3704. const {
  3705. result,
  3706. statusText,
  3707. status,
  3708. data
  3709. } = await tools_httpRequest({
  3710. url: link,
  3711. method: 'GET'
  3712. });
  3713. if (result === 'Success') {
  3714. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3715. var _data$responseText$ma, _ref;
  3716. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  3717. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  3718. return {
  3719. needLogin: true
  3720. };
  3721. }
  3722. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  3723. const context = ((_ref = data.responseText.match(/\(\{"INNERTUBE_CONTEXT":([\w\W]*?)\}\)/) || data.responseText.match(/"INNERTUBE_CONTEXT":([\w\W]*?\}),"INNERTUBE/)) === null || _ref === void 0 ? void 0 : _ref[1]) || '{}';
  3724. const {
  3725. client,
  3726. request
  3727. } = JSON.parse(context);
  3728. if (apiKey && client && request) {
  3729. client.hl = 'en';
  3730. if (type === 'channel') {
  3731. var _data$responseText$ma2;
  3732. const channelId = (_data$responseText$ma2 = data.responseText.match(/"channelId":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3733. if (channelId) {
  3734. logStatus.success();
  3735. return {
  3736. params: {
  3737. apiKey: apiKey,
  3738. client: client,
  3739. request: request,
  3740. channelId: channelId
  3741. }
  3742. };
  3743. }
  3744. logStatus.error('Error: Get "channelId" failed!');
  3745. return {};
  3746. } else if (type === 'likeVideo') {
  3747. var _data$responseText$ma3, _data$responseText$ma4;
  3748. const videoId = (_data$responseText$ma3 = data.responseText.match(/<link rel="shortlinkUrl" href="https:\/\/youtu\.be\/(.*?)">/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3749. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3750. if (videoId) {
  3751. logStatus.success();
  3752. return {
  3753. params: {
  3754. apiKey: apiKey,
  3755. client: client,
  3756. request: request,
  3757. videoId: videoId,
  3758. likeParams: likeParams
  3759. }
  3760. };
  3761. }
  3762. logStatus.error('Error: Get "videoId" failed!');
  3763. return {};
  3764. }
  3765. logStatus.error('Error: Unknown type');
  3766. return {};
  3767. }
  3768. logStatus.error('Error: Parameter "apiKey" not found!');
  3769. return {};
  3770. }
  3771. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3772. return {};
  3773. }
  3774. logStatus.error(`${result}:${statusText}(${status})`);
  3775. return {};
  3776. } catch (error) {
  3777. throwError(error, 'Youtube.getInfo');
  3778. return {};
  3779. }
  3780. };
  3781. class Youtube extends social_Social {
  3782. tasks = JSON.parse(Youtube_defaultTasks);
  3783. whiteList = {
  3784. ...JSON.parse(Youtube_defaultTasks),
  3785. ...(Youtube_GM_getValue = GM_getValue('whiteList')) === null || Youtube_GM_getValue === void 0 ? void 0 : Youtube_GM_getValue.youtube
  3786. };
  3787. #auth = GM_getValue('youtubeAuth') || {};
  3788. #initialized = false;
  3789. #verifyChannel = `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`;
  3790. async init() {
  3791. try {
  3792. if (this.#initialized) {
  3793. return true;
  3794. }
  3795. if (!this.#auth.PAPISID) {
  3796. if (await this.#updateAuth()) {
  3797. this.#initialized = true;
  3798. return true;
  3799. }
  3800. return false;
  3801. }
  3802. const isVerified = await this.#verifyAuth();
  3803. if (isVerified) {
  3804. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  3805. this.#initialized = true;
  3806. return true;
  3807. }
  3808. GM_setValue('youtubeAuth', null);
  3809. if (await this.#updateAuth()) {
  3810. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  3811. this.#initialized = true;
  3812. return true;
  3813. }
  3814. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  3815. return false;
  3816. } catch (error) {
  3817. throwError(error, 'Youtube.init');
  3818. return false;
  3819. }
  3820. }
  3821. async #verifyAuth() {
  3822. try {
  3823. return await this.#toggleChannel({
  3824. link: this.#verifyChannel,
  3825. doTask: true,
  3826. verify: true
  3827. });
  3828. } catch (error) {
  3829. throwError(error, 'Youtube.verifyAuth');
  3830. return false;
  3831. }
  3832. }
  3833. async #updateAuth() {
  3834. try {
  3835. const logStatus = scripts_echoLog({
  3836. text: i18n('updatingAuth', 'Youtube')
  3837. });
  3838. return await new Promise(resolve => {
  3839. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  3840. active: true,
  3841. insert: true,
  3842. setParent: true
  3843. });
  3844. newTab.onclose = async () => {
  3845. const auth = GM_getValue('youtubeAuth');
  3846. if (auth) {
  3847. this.#auth = auth;
  3848. logStatus.success();
  3849. this.#verifyAuth().then(result => {
  3850. resolve(result);
  3851. });
  3852. } else {
  3853. logStatus.error('Error: Update youtube auth failed!');
  3854. resolve(false);
  3855. }
  3856. };
  3857. });
  3858. } catch (error) {
  3859. throwError(error, 'Discord.updateAuth');
  3860. return false;
  3861. }
  3862. }
  3863. #getInfo(link, type) {
  3864. return getInfo(link, type);
  3865. }
  3866. async #toggleChannel(_ref2) {
  3867. let {
  3868. link,
  3869. doTask = true,
  3870. verify = false
  3871. } = _ref2;
  3872. try {
  3873. const {
  3874. params,
  3875. needLogin
  3876. } = await this.#getInfo(link, 'channel');
  3877. const {
  3878. apiKey,
  3879. client,
  3880. request,
  3881. channelId
  3882. } = params || {};
  3883. if (needLogin) {
  3884. scripts_echoLog({
  3885. html: i18n('loginYtb')
  3886. });
  3887. return false;
  3888. }
  3889. if (!(apiKey && client && request && channelId)) {
  3890. scripts_echoLog({
  3891. text: '"getYtbToken" failed'
  3892. });
  3893. return false;
  3894. }
  3895. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  3896. scripts_echoLog({
  3897. type: 'whiteList',
  3898. text: 'Youtube.unfollowChannel',
  3899. id: channelId
  3900. });
  3901. return true;
  3902. }
  3903. const logStatus = verify ? scripts_echoLog({
  3904. text: i18n('verifyingAuth', 'Youtube')
  3905. }) : scripts_echoLog({
  3906. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  3907. text: channelId
  3908. });
  3909. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  3910. const {
  3911. result,
  3912. statusText,
  3913. status,
  3914. data
  3915. } = await tools_httpRequest({
  3916. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}&prettyPrint=false`,
  3917. method: 'POST',
  3918. headers: {
  3919. origin: 'https://www.youtube.com',
  3920. referer: `https://www.youtube.com/channel/${channelId}`,
  3921. 'content-type': 'application/json',
  3922. 'x-goog-authuser': '0',
  3923. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  3924. 'x-origin': 'https://www.youtube.com',
  3925. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${this.#auth.PAPISID} https://www.youtube.com`)}`
  3926. },
  3927. data: JSON.stringify({
  3928. context: {
  3929. client: client,
  3930. request: {
  3931. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  3932. internalExperimentFlags: [],
  3933. consistencyTokenJars: []
  3934. },
  3935. user: {}
  3936. },
  3937. channelIds: [ channelId ],
  3938. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  3939. })
  3940. });
  3941. if (result === 'Success') {
  3942. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3943. if (doTask && (/"subscribed":true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed":false/.test(data.responseText)) {
  3944. logStatus.success();
  3945. if (doTask && !verify) {
  3946. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  3947. }
  3948. return true;
  3949. }
  3950. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  3951. logStatus.success();
  3952. return true;
  3953. }
  3954. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  3955. return false;
  3956. }
  3957. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3958. return false;
  3959. }
  3960. logStatus.error(`${result}:${statusText}(${status})`);
  3961. return false;
  3962. } catch (error) {
  3963. throwError(error, 'Youtube.toggleChannel');
  3964. return false;
  3965. }
  3966. }
  3967. async #toggleLikeVideo(_ref3) {
  3968. let {
  3969. link,
  3970. doTask = true
  3971. } = _ref3;
  3972. try {
  3973. const {
  3974. params,
  3975. needLogin
  3976. } = await this.#getInfo(link, 'likeVideo');
  3977. const {
  3978. apiKey,
  3979. client,
  3980. request,
  3981. videoId,
  3982. likeParams
  3983. } = params || {};
  3984. if (needLogin) {
  3985. scripts_echoLog({
  3986. html: `${i18n('loginYtb')}`
  3987. });
  3988. return false;
  3989. }
  3990. if (!(apiKey && client && request && videoId && likeParams)) {
  3991. scripts_echoLog({
  3992. text: '"getYtbToken" failed'
  3993. });
  3994. return false;
  3995. }
  3996. if (!doTask && this.whiteList.likes.includes(videoId)) {
  3997. scripts_echoLog({
  3998. type: 'whiteList',
  3999. text: 'Youtube.unlikeVideo',
  4000. id: videoId
  4001. });
  4002. return true;
  4003. }
  4004. const logStatus = scripts_echoLog({
  4005. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4006. text: videoId
  4007. });
  4008. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4009. const likeVideoData = {
  4010. context: {
  4011. client: client,
  4012. request: {
  4013. sessionId: request.sessionId,
  4014. internalExperimentFlags: [],
  4015. consistencyTokenJars: []
  4016. },
  4017. user: {}
  4018. },
  4019. target: {
  4020. videoId: videoId
  4021. }
  4022. };
  4023. if (doTask) {
  4024. if (likeParams) {
  4025. likeVideoData.params = likeParams;
  4026. } else {
  4027. logStatus.error('Empty likeParams');
  4028. return false;
  4029. }
  4030. }
  4031. const {
  4032. result,
  4033. statusText,
  4034. status,
  4035. data
  4036. } = await tools_httpRequest({
  4037. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4038. method: 'POST',
  4039. headers: {
  4040. origin: 'https://www.youtube.com',
  4041. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4042. 'content-type': 'application/json',
  4043. 'x-goog-authuser': '0',
  4044. 'x-goog-visitor-id': client.visitorData,
  4045. 'x-origin': 'https://www.youtube.com',
  4046. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${this.#auth.PAPISID} https://www.youtube.com`)}`
  4047. },
  4048. data: JSON.stringify(likeVideoData)
  4049. });
  4050. if (result === 'Success') {
  4051. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4052. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4053. logStatus.success();
  4054. if (doTask) {
  4055. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4056. }
  4057. return true;
  4058. }
  4059. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4060. return false;
  4061. }
  4062. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4063. return false;
  4064. }
  4065. logStatus.error(`${result}:${statusText}(${status})`);
  4066. return false;
  4067. } catch (error) {
  4068. throwError(error, 'Youtube.toggleLikeVideo');
  4069. return false;
  4070. }
  4071. }
  4072. async toggle(_ref4) {
  4073. let {
  4074. doTask = true,
  4075. channelLinks = [],
  4076. videoLinks = []
  4077. } = _ref4;
  4078. try {
  4079. if (!this.#initialized) {
  4080. scripts_echoLog({
  4081. text: i18n('needInit')
  4082. });
  4083. return false;
  4084. }
  4085. const prom = [];
  4086. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4087. scripts_echoLog({
  4088. type: 'globalOptionsSkip',
  4089. text: 'youtube.channels'
  4090. });
  4091. } else {
  4092. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4093. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4094. var _link$match;
  4095. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4096. }
  4097. return link;
  4098. });
  4099. if (realChannels.length > 0) {
  4100. for (const channel of realChannels) {
  4101. prom.push(this.#toggleChannel({
  4102. link: channel,
  4103. doTask: doTask
  4104. }));
  4105. await delay(1e3);
  4106. }
  4107. }
  4108. }
  4109. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4110. scripts_echoLog({
  4111. type: 'globalOptionsSkip',
  4112. text: 'youtube.likes'
  4113. });
  4114. } else {
  4115. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4116. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4117. var _link$match2;
  4118. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4119. }
  4120. return link;
  4121. });
  4122. if (realLikes.length > 0) {
  4123. for (const video of realLikes) {
  4124. prom.push(this.#toggleLikeVideo({
  4125. link: video,
  4126. doTask: doTask
  4127. }));
  4128. await delay(1e3);
  4129. }
  4130. }
  4131. }
  4132. return Promise.all(prom).then(() => true);
  4133. } catch (error) {
  4134. throwError(error, 'Youtube.toggle');
  4135. return false;
  4136. }
  4137. }
  4138. }
  4139. var Steam_GM_getValue;
  4140. const Steam_defaultTasksTemplate = {
  4141. groups: [],
  4142. officialGroups: [],
  4143. wishlists: [],
  4144. follows: [],
  4145. forums: [],
  4146. workshops: [],
  4147. workshopVotes: [],
  4148. curators: [],
  4149. curatorLikes: [],
  4150. announcements: [],
  4151. licenses: [],
  4152. playtests: []
  4153. };
  4154. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4155. class Steam extends social_Social {
  4156. tasks = JSON.parse(Steam_defaultTasks);
  4157. whiteList = {
  4158. ...JSON.parse(Steam_defaultTasks),
  4159. ...(Steam_GM_getValue = GM_getValue('whiteList')) === null || Steam_GM_getValue === void 0 ? void 0 : Steam_GM_getValue.steam
  4160. };
  4161. #cache = {
  4162. ...{
  4163. group: {},
  4164. officialGroup: {},
  4165. forum: {},
  4166. workshop: {},
  4167. curator: {}
  4168. },
  4169. ...GM_getValue('steamCache')
  4170. };
  4171. #auth = {};
  4172. #storeInitialized = false;
  4173. #communityInitialized = false;
  4174. #area = 'CN';
  4175. #areaStatus = 'end';
  4176. async init() {
  4177. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4178. try {
  4179. if (type === 'store') {
  4180. if (this.#storeInitialized) {
  4181. return true;
  4182. }
  4183. this.#storeInitialized = await this.#updateStoreAuth();
  4184. if (!this.#storeInitialized) {
  4185. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4186. return false;
  4187. }
  4188. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4189. return true;
  4190. }
  4191. if (type === 'community') {
  4192. if (this.#communityInitialized) {
  4193. return true;
  4194. }
  4195. this.#communityInitialized = await this.#updateCommunityAuth();
  4196. if (!this.#communityInitialized) {
  4197. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4198. return false;
  4199. }
  4200. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4201. return true;
  4202. }
  4203. this.#storeInitialized = await this.#updateStoreAuth();
  4204. this.#communityInitialized = await this.#updateCommunityAuth();
  4205. if (this.#storeInitialized && this.#communityInitialized) {
  4206. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4207. return true;
  4208. }
  4209. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4210. return false;
  4211. } catch (error) {
  4212. throwError(error, 'Steam.init');
  4213. return false;
  4214. }
  4215. }
  4216. async #refreshStoreToken() {
  4217. try {
  4218. const logStatus = scripts_echoLog({
  4219. text: i18n('refreshingToken', i18n('steamStore'))
  4220. });
  4221. const formData = new FormData();
  4222. formData.append('redir', 'https://store.steampowered.com/');
  4223. const {
  4224. result,
  4225. statusText,
  4226. status,
  4227. data
  4228. } = await tools_httpRequest({
  4229. url: 'https://login.steampowered.com/jwt/ajaxrefresh',
  4230. method: 'POST',
  4231. responseType: 'json',
  4232. headers: {
  4233. Host: 'login.steampowered.com',
  4234. Origin: 'https://store.steampowered.com',
  4235. Referer: 'https://store.steampowered.com/'
  4236. },
  4237. data: formData
  4238. });
  4239. if (result === 'Success') {
  4240. var _data$response;
  4241. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  4242. if (await this.#setStoreToken(data.response)) {
  4243. logStatus.success();
  4244. return true;
  4245. }
  4246. logStatus.error('Error');
  4247. return false;
  4248. }
  4249. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4250. return false;
  4251. }
  4252. logStatus.error(`${result}:${statusText}(${status})`);
  4253. return false;
  4254. } catch (error) {
  4255. throwError(error, 'Steam.refreshStoreToken');
  4256. return false;
  4257. }
  4258. }
  4259. async #setStoreToken(param) {
  4260. try {
  4261. const logStatus = scripts_echoLog({
  4262. text: i18n('settingToken', i18n('steamStore'))
  4263. });
  4264. const formData = new FormData();
  4265. formData.append('steamID', param.steamID);
  4266. formData.append('nonce', param.nonce);
  4267. formData.append('redir', param.redir);
  4268. formData.append('auth', param.auth);
  4269. const {
  4270. result,
  4271. statusText,
  4272. status,
  4273. data
  4274. } = await tools_httpRequest({
  4275. url: 'https://store.steampowered.com/login/settoken',
  4276. method: 'POST',
  4277. headers: {
  4278. Accept: 'application/json, text/plain, */*',
  4279. Host: 'store.steampowered.com',
  4280. Origin: 'https://store.steampowered.com',
  4281. Referer: 'https://store.steampowered.com/login'
  4282. },
  4283. data: formData
  4284. });
  4285. if (result === 'Success') {
  4286. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4287. logStatus.success();
  4288. return true;
  4289. }
  4290. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4291. return false;
  4292. }
  4293. logStatus.error(`${result}:${statusText}(${status})`);
  4294. return false;
  4295. } catch (error) {
  4296. throwError(error, 'Steam.setStoreToken');
  4297. return false;
  4298. }
  4299. }
  4300. async #updateStoreAuth() {
  4301. try {
  4302. const logStatus = scripts_echoLog({
  4303. text: i18n('updatingAuth', i18n('steamStore'))
  4304. });
  4305. const {
  4306. result,
  4307. statusText,
  4308. status,
  4309. data
  4310. } = await tools_httpRequest({
  4311. url: 'https://store.steampowered.com/',
  4312. method: 'GET',
  4313. headers: {
  4314. Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  4315. 'Cache-Control': 'max-age=0',
  4316. 'Sec-Fetch-Dest': 'document',
  4317. 'Sec-Fetch-Mode': 'navigate',
  4318. 'Upgrade-Insecure-Requests': '1'
  4319. }
  4320. });
  4321. if (result === 'Success') {
  4322. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4323. var _data$responseText$ma;
  4324. if (!data.responseText.includes('data-miniprofile=')) {
  4325. await this.#refreshStoreToken();
  4326. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  4327. return false;
  4328. }
  4329. const storeSessionID = (_data$responseText$ma = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4330. if (storeSessionID) {
  4331. this.#auth.storeSessionID = storeSessionID;
  4332. logStatus.success();
  4333. return true;
  4334. }
  4335. logStatus.error('Error: Get "sessionID" failed');
  4336. return false;
  4337. }
  4338. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4339. return false;
  4340. }
  4341. logStatus.error(`${result}:${statusText}(${status})`);
  4342. return false;
  4343. } catch (error) {
  4344. throwError(error, 'Steam.updateStoreAuth');
  4345. return false;
  4346. }
  4347. }
  4348. async #updateCommunityAuth() {
  4349. try {
  4350. const logStatus = scripts_echoLog({
  4351. text: i18n('updatingAuth', i18n('steamCommunity'))
  4352. });
  4353. const {
  4354. result,
  4355. statusText,
  4356. status,
  4357. data
  4358. } = await tools_httpRequest({
  4359. url: 'https://steamcommunity.com/my',
  4360. method: 'GET',
  4361. headers: {
  4362. Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  4363. 'Cache-Control': 'max-age=0',
  4364. 'Sec-Fetch-Dest': 'document',
  4365. 'Sec-Fetch-Mode': 'navigate',
  4366. 'Upgrade-Insecure-Requests': '1'
  4367. }
  4368. });
  4369. if (result === 'Success') {
  4370. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4371. var _data$responseText$ma2, _data$responseText$ma3, _data$responseText$ma4;
  4372. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  4373. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  4374. return false;
  4375. }
  4376. const steam64Id = (_data$responseText$ma2 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4377. const communitySessionID = (_data$responseText$ma3 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4378. const userName = (_data$responseText$ma4 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4379. if (steam64Id) {
  4380. this.#auth.steam64Id = steam64Id;
  4381. }
  4382. if (userName) {
  4383. this.#auth.userName = userName;
  4384. }
  4385. if (communitySessionID) {
  4386. this.#auth.communitySessionID = communitySessionID;
  4387. logStatus.success();
  4388. return true;
  4389. }
  4390. logStatus.error('Error: Get "sessionID" failed');
  4391. return false;
  4392. }
  4393. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4394. return false;
  4395. }
  4396. logStatus.error(`${result}:${statusText}(${status})`);
  4397. return false;
  4398. } catch (error) {
  4399. throwError(error, 'Steam.updateCommunityAuth');
  4400. return false;
  4401. }
  4402. }
  4403. async #getAreaInfo() {
  4404. try {
  4405. const logStatus = scripts_echoLog({
  4406. text: i18n('gettingAreaInfo')
  4407. });
  4408. const {
  4409. result,
  4410. statusText,
  4411. status,
  4412. data
  4413. } = await tools_httpRequest({
  4414. url: 'https://store.steampowered.com/cart/',
  4415. method: 'GET'
  4416. });
  4417. if (result === 'Success') {
  4418. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4419. var _data$responseText$ma5;
  4420. const currentArea = (_data$responseText$ma5 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4421. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  4422. if (currentArea && areas.length > 0) {
  4423. this.#area = currentArea;
  4424. logStatus.success();
  4425. return {
  4426. currentArea: currentArea,
  4427. areas: areas
  4428. };
  4429. }
  4430. logStatus.error('Error: get country info filed');
  4431. return {};
  4432. }
  4433. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4434. return {};
  4435. }
  4436. logStatus.error(`${result}:${statusText}(${status})`);
  4437. return {};
  4438. } catch (error) {
  4439. throwError(error, 'Steam.getAreaInfo');
  4440. return {};
  4441. }
  4442. }
  4443. async #changeArea(area) {
  4444. try {
  4445. if (this.#areaStatus === 'waiting') {
  4446. await new Promise(resolve => {
  4447. const checker = setInterval(() => {
  4448. if (this.#areaStatus !== 'waiting') {
  4449. clearInterval(checker);
  4450. resolve(true);
  4451. }
  4452. });
  4453. });
  4454. }
  4455. if (this.#area === area || !area && this.#area !== 'CN') {
  4456. return true;
  4457. }
  4458. this.#areaStatus = 'waiting';
  4459. let aimedArea = area;
  4460. if (!aimedArea) {
  4461. const {
  4462. currentArea,
  4463. areas
  4464. } = await this.#getAreaInfo();
  4465. if (!currentArea || !areas) {
  4466. this.#areaStatus = 'error';
  4467. return false;
  4468. }
  4469. if (currentArea !== 'CN') {
  4470. this.#areaStatus = 'skip';
  4471. scripts_echoLog({
  4472. text: 'notNeededChangeArea'
  4473. });
  4474. return 'skip';
  4475. }
  4476. const anotherArea = areas.filter(area => area && area !== 'CN');
  4477. if (!anotherArea || anotherArea.length === 0) {
  4478. this.#areaStatus = 'noAnotherArea';
  4479. scripts_echoLog({
  4480. text: 'noAnotherArea'
  4481. });
  4482. return false;
  4483. }
  4484. [ aimedArea ] = anotherArea;
  4485. }
  4486. const logStatus = scripts_echoLog({
  4487. text: i18n('changingArea', aimedArea)
  4488. });
  4489. const {
  4490. result,
  4491. statusText,
  4492. status,
  4493. data
  4494. } = await tools_httpRequest({
  4495. url: 'https://store.steampowered.com/account/setcountry',
  4496. method: 'POST',
  4497. headers: {
  4498. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4499. },
  4500. data: $.param({
  4501. cc: aimedArea,
  4502. sessionid: this.#auth.storeSessionID
  4503. })
  4504. });
  4505. if (result === 'Success') {
  4506. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  4507. const {
  4508. currentArea
  4509. } = await this.#getAreaInfo();
  4510. if (currentArea === aimedArea) {
  4511. this.#areaStatus = 'success';
  4512. logStatus.success();
  4513. return currentArea;
  4514. }
  4515. this.#areaStatus = 'error';
  4516. logStatus.error('Error: change country filed');
  4517. return 'CN';
  4518. }
  4519. this.#areaStatus = 'error';
  4520. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4521. return 'CN';
  4522. }
  4523. this.#areaStatus = 'error';
  4524. logStatus.error(`${result}:${statusText}(${status})`);
  4525. return 'CN';
  4526. } catch (error) {
  4527. this.#areaStatus = 'error';
  4528. throwError(error, 'Steam.changeArea');
  4529. return false;
  4530. }
  4531. }
  4532. async #joinGroup(groupName) {
  4533. try {
  4534. const logStatus = scripts_echoLog({
  4535. type: 'joiningSteamGroup',
  4536. text: groupName
  4537. });
  4538. const {
  4539. result,
  4540. statusText,
  4541. status,
  4542. data
  4543. } = await tools_httpRequest({
  4544. url: `https://steamcommunity.com/groups/${groupName}`,
  4545. method: 'POST',
  4546. headers: {
  4547. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4548. },
  4549. data: $.param({
  4550. action: 'join',
  4551. sessionID: this.#auth.communitySessionID
  4552. })
  4553. });
  4554. if (result === 'Success') {
  4555. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  4556. logStatus.success();
  4557. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  4558. return true;
  4559. }
  4560. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4561. return false;
  4562. }
  4563. logStatus.error(`${result}:${statusText}(${status})`);
  4564. return false;
  4565. } catch (error) {
  4566. throwError(error, 'Steam.joinGroup');
  4567. return false;
  4568. }
  4569. }
  4570. async #leaveGroup(groupName) {
  4571. try {
  4572. if (this.whiteList.groups.includes(groupName)) {
  4573. scripts_echoLog({
  4574. type: 'whiteList',
  4575. text: 'Steam.leaveGroup',
  4576. id: groupName
  4577. });
  4578. return true;
  4579. }
  4580. const groupId = await this.#getGroupId(groupName);
  4581. if (!groupId) {
  4582. return false;
  4583. }
  4584. const logStatus = scripts_echoLog({
  4585. type: 'leavingSteamGroup',
  4586. text: groupName
  4587. });
  4588. const {
  4589. result,
  4590. statusText,
  4591. status,
  4592. data
  4593. } = await tools_httpRequest({
  4594. url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
  4595. method: 'POST',
  4596. headers: {
  4597. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4598. },
  4599. data: $.param({
  4600. sessionID: this.#auth.communitySessionID,
  4601. action: 'leaveGroup',
  4602. groupId: groupId
  4603. })
  4604. });
  4605. if (result === 'Success') {
  4606. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.finalUrl.includes('groups') && $(data.responseText.replace(/<img.*?>/g, '').toLowerCase()).find(`a[href='https://steamcommunity.com/groups/${groupName.toLowerCase()}']`).length === 0) {
  4607. logStatus.success();
  4608. return true;
  4609. }
  4610. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4611. return false;
  4612. }
  4613. logStatus.error(`${result}:${statusText}(${status})`);
  4614. return false;
  4615. } catch (error) {
  4616. throwError(error, 'Steam.leaveGroup');
  4617. return false;
  4618. }
  4619. }
  4620. async #getGroupId(groupName) {
  4621. try {
  4622. const logStatus = scripts_echoLog({
  4623. type: 'gettingSteamGroupId',
  4624. text: groupName
  4625. });
  4626. const groupId = this.#cache.group[groupName];
  4627. if (groupId) {
  4628. logStatus.success();
  4629. return groupId;
  4630. }
  4631. const {
  4632. result,
  4633. statusText,
  4634. status,
  4635. data
  4636. } = await tools_httpRequest({
  4637. url: `https://steamcommunity.com/groups/${groupName}`,
  4638. method: 'GET',
  4639. headers: {
  4640. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4641. }
  4642. });
  4643. if (result === 'Success') {
  4644. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4645. var _data$responseText$ma6;
  4646. const groupId = (_data$responseText$ma6 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  4647. if (groupId) {
  4648. this.#setCache('group', groupName, groupId);
  4649. logStatus.success();
  4650. return groupId;
  4651. }
  4652. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4653. return false;
  4654. }
  4655. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4656. return false;
  4657. }
  4658. logStatus.error(`${result}:${statusText}(${status})`);
  4659. return false;
  4660. } catch (error) {
  4661. throwError(error, 'Steam.getGroupID');
  4662. return false;
  4663. }
  4664. }
  4665. async #joinOfficialGroup(gameId) {
  4666. try {
  4667. const logStatus = scripts_echoLog({
  4668. type: 'joiningSteamOfficialGroup',
  4669. text: gameId
  4670. });
  4671. const {
  4672. result,
  4673. statusText,
  4674. status,
  4675. data
  4676. } = await tools_httpRequest({
  4677. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${this.#auth.communitySessionID}`,
  4678. method: 'GET',
  4679. headers: {
  4680. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4681. }
  4682. });
  4683. if (result === 'Success') {
  4684. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  4685. var _data$responseText$ma7;
  4686. logStatus.success();
  4687. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  4688. const groupId = (_data$responseText$ma7 = data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  4689. if (groupId) {
  4690. this.#setCache('officialGroup', gameId, groupId);
  4691. }
  4692. return true;
  4693. }
  4694. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4695. return false;
  4696. }
  4697. logStatus.error(`${result}:${statusText}(${status})`);
  4698. return false;
  4699. } catch (error) {
  4700. throwError(error, 'Steam.joinOfficialGroup');
  4701. return false;
  4702. }
  4703. }
  4704. async #leaveOfficialGroup(gameId) {
  4705. try {
  4706. if (this.whiteList.officialGroups.includes(gameId)) {
  4707. scripts_echoLog({
  4708. type: 'whiteList',
  4709. text: 'Steam.leaveOfficialGroup',
  4710. id: gameId
  4711. });
  4712. return true;
  4713. }
  4714. const groupId = await this.#getOfficialGroupId(gameId);
  4715. if (!groupId) {
  4716. return false;
  4717. }
  4718. const logStatus = scripts_echoLog({
  4719. type: 'leavingSteamOfficialGroup',
  4720. text: gameId
  4721. });
  4722. const {
  4723. result,
  4724. statusText,
  4725. status,
  4726. data
  4727. } = await tools_httpRequest({
  4728. url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
  4729. method: 'POST',
  4730. headers: {
  4731. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4732. },
  4733. data: $.param({
  4734. sessionID: this.#auth.communitySessionID,
  4735. action: 'leaveGroup',
  4736. groupId: groupId
  4737. })
  4738. });
  4739. if (result === 'Success') {
  4740. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4741. const {
  4742. result: resultR,
  4743. statusText: statusTextR,
  4744. status: statusR,
  4745. data: dataR
  4746. } = await tools_httpRequest({
  4747. url: `https://steamcommunity.com/games/${gameId}`,
  4748. method: 'GET',
  4749. headers: {
  4750. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4751. }
  4752. });
  4753. if (resultR === 'Success') {
  4754. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  4755. logStatus.success();
  4756. return true;
  4757. }
  4758. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4759. return false;
  4760. }
  4761. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4762. return false;
  4763. }
  4764. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4765. return false;
  4766. }
  4767. logStatus.error(`${result}:${statusText}(${status})`);
  4768. return false;
  4769. } catch (error) {
  4770. throwError(error, 'Steam.leaveOfficialGroup');
  4771. return false;
  4772. }
  4773. }
  4774. async #getOfficialGroupId(gameId) {
  4775. try {
  4776. const logStatus = scripts_echoLog({
  4777. type: 'gettingSteamOfficialGroupId',
  4778. text: gameId
  4779. });
  4780. const groupId = this.#cache.officialGroup[gameId];
  4781. if (groupId) {
  4782. logStatus.success();
  4783. return groupId;
  4784. }
  4785. const {
  4786. result,
  4787. statusText,
  4788. status,
  4789. data
  4790. } = await tools_httpRequest({
  4791. url: `https://steamcommunity.com/games/${gameId}`,
  4792. method: 'GET',
  4793. headers: {
  4794. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4795. }
  4796. });
  4797. if (result === 'Success') {
  4798. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4799. var _data$responseText$ma8;
  4800. const groupId = (_data$responseText$ma8 = data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)) === null || _data$responseText$ma8 === void 0 ? void 0 : _data$responseText$ma8[1];
  4801. if (groupId) {
  4802. this.#setCache('officialGroup', gameId, groupId);
  4803. logStatus.success();
  4804. return groupId;
  4805. }
  4806. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4807. return false;
  4808. }
  4809. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4810. return false;
  4811. }
  4812. logStatus.error(`${result}:${statusText}(${status})`);
  4813. return false;
  4814. } catch (error) {
  4815. throwError(error, 'Steam.getGroupID');
  4816. return false;
  4817. }
  4818. }
  4819. async #addToWishlist(gameId) {
  4820. try {
  4821. var _data$response2;
  4822. const logStatus = scripts_echoLog({
  4823. type: 'addingToWishlist',
  4824. text: gameId
  4825. });
  4826. const {
  4827. result,
  4828. data
  4829. } = await tools_httpRequest({
  4830. url: 'https://store.steampowered.com/api/addtowishlist',
  4831. method: 'POST',
  4832. headers: {
  4833. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4834. },
  4835. data: $.param({
  4836. sessionid: this.#auth.storeSessionID,
  4837. appid: gameId
  4838. }),
  4839. dataType: 'json'
  4840. });
  4841. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : _data$response2.success) === true) {
  4842. logStatus.success();
  4843. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  4844. return true;
  4845. }
  4846. const {
  4847. result: resultR,
  4848. statusText: statusTextR,
  4849. status: statusR,
  4850. data: dataR
  4851. } = await tools_httpRequest({
  4852. url: `https://store.steampowered.com/app/${gameId}`,
  4853. method: 'GET'
  4854. });
  4855. if (resultR === 'Success') {
  4856. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  4857. if (this.#area === 'CN' && dataR.responseText.includes('id="error_box"')) {
  4858. logStatus.warning(i18n('changeAreaNotice'));
  4859. if (!await this.#changeArea()) {
  4860. return false;
  4861. }
  4862. return await this.#addToWishlist(gameId);
  4863. }
  4864. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  4865. logStatus.success();
  4866. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  4867. return true;
  4868. } else if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('id="add_to_wishlist_area_success" style="display: none;') || !dataR.responseText.includes('class="queue_actions_ctn"')) {
  4869. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  4870. return false;
  4871. }
  4872. logStatus.success();
  4873. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  4874. return true;
  4875. }
  4876. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4877. return false;
  4878. }
  4879. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4880. return false;
  4881. } catch (error) {
  4882. throwError(error, 'Steam.addToWishlist');
  4883. return false;
  4884. }
  4885. }
  4886. async #removeFromWishlist(gameId) {
  4887. try {
  4888. var _data$response3;
  4889. if (this.whiteList.wishlists.includes(gameId)) {
  4890. scripts_echoLog({
  4891. type: 'whiteList',
  4892. text: 'Steam.removeFromWishlist',
  4893. id: gameId
  4894. });
  4895. return true;
  4896. }
  4897. const logStatus = scripts_echoLog({
  4898. type: 'removingFromWishlist',
  4899. text: gameId
  4900. });
  4901. const {
  4902. result,
  4903. data
  4904. } = await tools_httpRequest({
  4905. url: 'https://store.steampowered.com/api/removefromwishlist',
  4906. method: 'POST',
  4907. headers: {
  4908. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4909. },
  4910. data: $.param({
  4911. sessionid: this.#auth.storeSessionID,
  4912. appid: gameId
  4913. }),
  4914. dataType: 'json'
  4915. });
  4916. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response3 = data.response) === null || _data$response3 === void 0 ? void 0 : _data$response3.success) === true) {
  4917. logStatus.success();
  4918. return true;
  4919. }
  4920. const {
  4921. result: resultR,
  4922. statusText: statusTextR,
  4923. status: statusR,
  4924. data: dataR
  4925. } = await tools_httpRequest({
  4926. url: `https://store.steampowered.com/app/${gameId}`,
  4927. method: 'GET'
  4928. });
  4929. if (resultR === 'Success') {
  4930. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  4931. if (this.#area === 'CN' && dataR.responseText.includes('id="error_box"')) {
  4932. logStatus.warning(i18n('changeAreaNotice'));
  4933. const result = await this.#changeArea();
  4934. if (!result || result === 'CN' || result === 'skip') {
  4935. return false;
  4936. }
  4937. return await this.#removeFromWishlist(gameId);
  4938. }
  4939. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  4940. logStatus.success();
  4941. return true;
  4942. }
  4943. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  4944. return false;
  4945. }
  4946. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4947. return false;
  4948. }
  4949. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4950. return false;
  4951. } catch (error) {
  4952. throwError(error, 'Steam.removeFromWishlist');
  4953. return false;
  4954. }
  4955. }
  4956. async #toggleFollowGame(gameId, doTask) {
  4957. try {
  4958. if (!doTask && this.whiteList.follows.includes(gameId)) {
  4959. scripts_echoLog({
  4960. type: 'whiteList',
  4961. text: 'Steam.unfollowGame',
  4962. id: gameId
  4963. });
  4964. return true;
  4965. }
  4966. const logStatus = scripts_echoLog({
  4967. type: `${doTask ? '' : 'un'}followingGame`,
  4968. text: gameId
  4969. });
  4970. const requestData = {
  4971. sessionid: this.#auth.storeSessionID,
  4972. appid: gameId
  4973. };
  4974. if (!doTask) {
  4975. requestData.unfollow = '1';
  4976. }
  4977. const {
  4978. result,
  4979. data
  4980. } = await tools_httpRequest({
  4981. url: 'https://store.steampowered.com/explore/followgame/',
  4982. method: 'POST',
  4983. headers: {
  4984. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4985. },
  4986. data: $.param(requestData)
  4987. });
  4988. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  4989. logStatus.success();
  4990. return true;
  4991. }
  4992. const followed = await this.#isFollowedGame(gameId);
  4993. if (this.#area === 'CN' && followed === 'areaLocked') {
  4994. logStatus.warning(i18n('changeAreaNotice'));
  4995. if (!await this.#changeArea()) {
  4996. return false;
  4997. }
  4998. return await this.#removeFromWishlist(gameId);
  4999. }
  5000. if (doTask === followed) {
  5001. logStatus.success();
  5002. if (doTask) {
  5003. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5004. }
  5005. return true;
  5006. }
  5007. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5008. return false;
  5009. } catch (error) {
  5010. throwError(error, 'Steam.toggleFollowGame');
  5011. return false;
  5012. }
  5013. }
  5014. async #isFollowedGame(gameId) {
  5015. try {
  5016. const {
  5017. result,
  5018. data
  5019. } = await tools_httpRequest({
  5020. url: `https://store.steampowered.com/app/${gameId}`,
  5021. method: 'GET'
  5022. });
  5023. if (result === 'Success') {
  5024. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5025. if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
  5026. return 'areaLocked';
  5027. }
  5028. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5029. return true;
  5030. }
  5031. return false;
  5032. }
  5033. return false;
  5034. }
  5035. return false;
  5036. } catch (error) {
  5037. throwError(error, 'Steam.isFollowedGame');
  5038. return false;
  5039. }
  5040. }
  5041. async #toggleForum(gameId) {
  5042. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5043. try {
  5044. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5045. scripts_echoLog({
  5046. type: 'whiteList',
  5047. text: 'Steam.unsubscribeForum',
  5048. id: gameId
  5049. });
  5050. return true;
  5051. }
  5052. const forumId = await this.#getForumId(gameId);
  5053. if (!forumId) {
  5054. return false;
  5055. }
  5056. const logStatus = scripts_echoLog({
  5057. type: `${doTask ? '' : 'un'}subscribingForum`,
  5058. text: gameId
  5059. });
  5060. const [ id, feature ] = forumId.split('_');
  5061. const {
  5062. result,
  5063. statusText,
  5064. status,
  5065. data
  5066. } = await tools_httpRequest({
  5067. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5068. method: 'POST',
  5069. responseType: 'json',
  5070. headers: {
  5071. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5072. },
  5073. data: $.param({
  5074. sessionid: this.#auth.communitySessionID
  5075. })
  5076. });
  5077. if (result === 'Success') {
  5078. var _data$response4, _data$response5;
  5079. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (((_data$response4 = data.response) === null || _data$response4 === void 0 ? void 0 : _data$response4.success) === 1 || ((_data$response5 = data.response) === null || _data$response5 === void 0 ? void 0 : _data$response5.success) === 29)) {
  5080. if (doTask) {
  5081. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5082. }
  5083. logStatus.success();
  5084. return true;
  5085. }
  5086. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5087. return true;
  5088. }
  5089. logStatus.error(`${result}:${statusText}(${status})`);
  5090. return true;
  5091. } catch (error) {
  5092. throwError(error, 'Steam.toggleForum');
  5093. return true;
  5094. }
  5095. }
  5096. async #getForumId(gameId) {
  5097. try {
  5098. const logStatus = scripts_echoLog({
  5099. type: 'gettingForumId',
  5100. text: gameId
  5101. });
  5102. const forumId = this.#cache.forum[gameId];
  5103. if (forumId) {
  5104. logStatus.success();
  5105. return forumId;
  5106. }
  5107. const {
  5108. result,
  5109. statusText,
  5110. status,
  5111. data
  5112. } = await tools_httpRequest({
  5113. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5114. method: 'GET'
  5115. });
  5116. if (result === 'Success') {
  5117. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5118. var _data$responseText, _data$responseText$ma9;
  5119. const forumId = (_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : (_data$responseText$ma9 = _data$responseText.match(/General_([\d]+(_[\d]+)?)/)) === null || _data$responseText$ma9 === void 0 ? void 0 : _data$responseText$ma9[1];
  5120. if (forumId) {
  5121. this.#setCache('forum', gameId, forumId);
  5122. logStatus.success();
  5123. return forumId;
  5124. }
  5125. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5126. return false;
  5127. }
  5128. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5129. return false;
  5130. }
  5131. logStatus.error(`${result}:${statusText}(${status})`);
  5132. return false;
  5133. } catch (error) {
  5134. throwError(error, 'Steam.getForumId');
  5135. return false;
  5136. }
  5137. }
  5138. async #toggleFavoriteWorkshop(id) {
  5139. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5140. try {
  5141. if (!doTask && this.whiteList.workshops.includes(id)) {
  5142. scripts_echoLog({
  5143. type: 'whiteList',
  5144. text: 'Steam.unfavoriteWorkshop',
  5145. id: id
  5146. });
  5147. return true;
  5148. }
  5149. const appid = await this.#getWorkshopAppId(id);
  5150. if (!appid) {
  5151. return false;
  5152. }
  5153. const logStatus = scripts_echoLog({
  5154. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5155. text: id
  5156. });
  5157. const {
  5158. result,
  5159. statusText,
  5160. status,
  5161. data
  5162. } = await tools_httpRequest({
  5163. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5164. method: 'POST',
  5165. headers: {
  5166. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5167. },
  5168. data: $.param({
  5169. id: id,
  5170. appid: appid,
  5171. sessionid: this.#auth.communitySessionID
  5172. })
  5173. });
  5174. if (result === 'Success') {
  5175. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5176. if (doTask) {
  5177. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5178. }
  5179. logStatus.success();
  5180. return true;
  5181. }
  5182. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5183. return false;
  5184. }
  5185. logStatus.error(`${result}:${statusText}(${status})`);
  5186. return false;
  5187. } catch (error) {
  5188. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5189. return false;
  5190. }
  5191. }
  5192. async #getWorkshopAppId(id) {
  5193. try {
  5194. const logStatus = scripts_echoLog({
  5195. type: 'gettingWorkshopAppId',
  5196. text: id
  5197. });
  5198. const appId = this.#cache.workshop[id];
  5199. if (appId) {
  5200. logStatus.success();
  5201. return appId;
  5202. }
  5203. const {
  5204. result,
  5205. statusText,
  5206. status,
  5207. data
  5208. } = await tools_httpRequest({
  5209. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5210. method: 'GET'
  5211. });
  5212. if (result === 'Success') {
  5213. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5214. var _data$responseText$ma10;
  5215. const appId = (_data$responseText$ma10 = data.responseText.match(/<input type="hidden" name="appid" value="([\d]+?)" \/>/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5216. if (appId) {
  5217. this.#setCache('workshop', id, appId);
  5218. logStatus.success();
  5219. return appId;
  5220. }
  5221. logStatus.error('Error: getWorkshopAppId failed');
  5222. return false;
  5223. }
  5224. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5225. return false;
  5226. }
  5227. logStatus.error(`${result}:${statusText}(${status})`);
  5228. return false;
  5229. } catch (error) {
  5230. throwError(error, 'Steam.getWorkshopAppId');
  5231. return false;
  5232. }
  5233. }
  5234. async #voteUpWorkshop(id) {
  5235. try {
  5236. const logStatus = scripts_echoLog({
  5237. type: 'votingUpWorkshop',
  5238. text: id
  5239. });
  5240. const {
  5241. result,
  5242. statusText,
  5243. status,
  5244. data
  5245. } = await tools_httpRequest({
  5246. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5247. method: 'POST',
  5248. responseType: 'json',
  5249. headers: {
  5250. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5251. },
  5252. data: $.param({
  5253. id: id,
  5254. sessionid: this.#auth.communitySessionID
  5255. })
  5256. });
  5257. if (result === 'Success') {
  5258. var _data$response6;
  5259. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response6 = data.response) === null || _data$response6 === void 0 ? void 0 : _data$response6.success) === 1) {
  5260. logStatus.success();
  5261. return true;
  5262. }
  5263. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5264. return true;
  5265. }
  5266. logStatus.error(`${result}:${statusText}(${status})`);
  5267. return true;
  5268. } catch (error) {
  5269. throwError(error, 'Steam.voteupWorkshop');
  5270. return true;
  5271. }
  5272. }
  5273. async #toggleCurator(curatorId) {
  5274. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5275. try {
  5276. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5277. scripts_echoLog({
  5278. type: 'whiteList',
  5279. text: 'Steam.unfollowCurator',
  5280. id: curatorId
  5281. });
  5282. return true;
  5283. }
  5284. const logStatus = scripts_echoLog({
  5285. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5286. text: curatorId
  5287. });
  5288. const {
  5289. result,
  5290. statusText,
  5291. status,
  5292. data
  5293. } = await tools_httpRequest({
  5294. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5295. method: 'POST',
  5296. headers: {
  5297. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5298. },
  5299. data: $.param({
  5300. clanid: curatorId,
  5301. sessionid: this.#auth.storeSessionID,
  5302. follow: doTask
  5303. }),
  5304. dataType: 'json'
  5305. });
  5306. if (result === 'Success') {
  5307. var _data$response7, _data$response7$succe, _data$response8;
  5308. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response7 = data.response) === null || _data$response7 === void 0 ? void 0 : (_data$response7$succe = _data$response7.success) === null || _data$response7$succe === void 0 ? void 0 : _data$response7$succe.success) === 1) {
  5309. logStatus.success();
  5310. return true;
  5311. }
  5312. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.success}` || `${data === null || data === void 0 ? void 0 : data.status})`);
  5313. return false;
  5314. }
  5315. logStatus.error(`${result}:${statusText}(${status})`);
  5316. return false;
  5317. } catch (error) {
  5318. throwError(error, 'Steam.toggleCurator');
  5319. return false;
  5320. }
  5321. }
  5322. async getCuratorId(path, name) {
  5323. try {
  5324. const logStatus = scripts_echoLog({
  5325. type: 'gettingCuratorId',
  5326. text: `${path}/${name}`
  5327. });
  5328. const curatorId = this.#cache.curator[`${path}/${name}`];
  5329. if (curatorId) {
  5330. logStatus.success();
  5331. return curatorId;
  5332. }
  5333. const {
  5334. result,
  5335. statusText,
  5336. status,
  5337. data
  5338. } = await tools_httpRequest({
  5339. url: `https://store.steampowered.com/${path}/${name}`,
  5340. method: 'GET',
  5341. headers: {
  5342. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5343. }
  5344. });
  5345. if (result === 'Success') {
  5346. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5347. var _data$responseText$ma11;
  5348. const curatorId = (_data$responseText$ma11 = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5349. if (curatorId) {
  5350. this.#setCache('curator', `${path}/${name}`, curatorId);
  5351. logStatus.success();
  5352. return curatorId;
  5353. }
  5354. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5355. return false;
  5356. }
  5357. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5358. return false;
  5359. }
  5360. logStatus.error(`${result}:${statusText}(${status})`);
  5361. return false;
  5362. } catch (error) {
  5363. throwError(error, 'Steam.getCuratorID');
  5364. return false;
  5365. }
  5366. }
  5367. async #toggleCuratorLike(link) {
  5368. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5369. try {
  5370. const [ path, name ] = link.split('/');
  5371. if (!(path && name)) {
  5372. scripts_echoLog({
  5373. text: i18n('errorLink', link)
  5374. });
  5375. return false;
  5376. }
  5377. const curatorId = await this.getCuratorId(path, name);
  5378. if (curatorId) {
  5379. return await this.#toggleCurator(curatorId, doTask);
  5380. }
  5381. return false;
  5382. } catch (error) {
  5383. throwError(error, 'Steam.toggleCuratorLike');
  5384. return false;
  5385. }
  5386. }
  5387. async #getAnnouncementParams(appId, viewId) {
  5388. try {
  5389. const logStatus = scripts_echoLog({
  5390. type: 'gettingAnnouncementParams',
  5391. text: appId,
  5392. id: viewId
  5393. });
  5394. const {
  5395. result,
  5396. statusText,
  5397. status,
  5398. data
  5399. } = await tools_httpRequest({
  5400. url: `https://store.steampowered.com/events/ajaxgetpartnerevent?appid=${appId}&announcement_gid=${viewId}&lang_list=6_0&last_modified_time=0&origin=https:%2F%2Fstore.steampowered.com&for_edit=false`,
  5401. method: 'GET',
  5402. responseType: 'json',
  5403. headers: {
  5404. Host: 'store.steampowered.com',
  5405. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5406. }
  5407. });
  5408. if (result === 'Success') {
  5409. var _data$response9;
  5410. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response9 = data.response) === null || _data$response9 === void 0 ? void 0 : _data$response9.success) === 1) {
  5411. var _data$response$event;
  5412. const {
  5413. clanid,
  5414. gid
  5415. } = ((_data$response$event = data.response.event) === null || _data$response$event === void 0 ? void 0 : _data$response$event.announcement_body) || {};
  5416. if (clanid) {
  5417. logStatus.success();
  5418. return {
  5419. clanId: clanid,
  5420. gid: gid
  5421. };
  5422. }
  5423. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5424. return {};
  5425. }
  5426. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5427. return {};
  5428. }
  5429. logStatus.error(`${result}:${statusText}(${status})`);
  5430. return {};
  5431. } catch (error) {
  5432. throwError(error, 'Steam.likeAnnouncement');
  5433. return {};
  5434. }
  5435. }
  5436. async #likeAnnouncement(id) {
  5437. try {
  5438. const [ appId, viewId ] = id.split('/');
  5439. if (!(appId && viewId)) {
  5440. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  5441. return false;
  5442. }
  5443. const {
  5444. clanId,
  5445. gid
  5446. } = await this.#getAnnouncementParams(appId, viewId);
  5447. if (!clanId) {
  5448. return false;
  5449. }
  5450. const logStatus = scripts_echoLog({
  5451. type: 'likingAnnouncement',
  5452. text: appId,
  5453. id: viewId
  5454. });
  5455. const {
  5456. result,
  5457. statusText,
  5458. status,
  5459. data
  5460. } = await tools_httpRequest({
  5461. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5462. method: 'POST',
  5463. headers: {
  5464. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5465. Host: 'store.steampowered.com',
  5466. Origin: 'https://store.steampowered.com',
  5467. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5468. },
  5469. data: $.param({
  5470. sessionid: this.#auth.storeSessionID,
  5471. voteup: 1,
  5472. clanid: clanId,
  5473. ajax: 1
  5474. }),
  5475. dataType: 'json'
  5476. });
  5477. if (result === 'Success') {
  5478. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5479. logStatus.success();
  5480. return true;
  5481. }
  5482. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5483. return false;
  5484. }
  5485. logStatus.error(`${result}:${statusText}(${status})`);
  5486. return false;
  5487. } catch (error) {
  5488. throwError(error, 'Steam.likeAnnouncement');
  5489. return false;
  5490. }
  5491. }
  5492. async #appid2subid(id) {
  5493. try {
  5494. const logStatus = scripts_echoLog({
  5495. type: 'gettingSubid',
  5496. text: id
  5497. });
  5498. const {
  5499. result,
  5500. statusText,
  5501. status,
  5502. data
  5503. } = await tools_httpRequest({
  5504. url: `https://store.steampowered.com/app/${id}`,
  5505. method: 'GET',
  5506. headers: {
  5507. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5508. }
  5509. });
  5510. if (result === 'Success') {
  5511. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5512. var _data$responseText$ma12;
  5513. if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
  5514. logStatus.warning(i18n('changeAreaNotice'));
  5515. const result = await this.#changeArea();
  5516. if (!result || result === 'CN' || result === 'skip') {
  5517. return false;
  5518. }
  5519. return await this.#appid2subid(id);
  5520. }
  5521. const subid = (_data$responseText$ma12 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  5522. if (subid) {
  5523. logStatus.success();
  5524. return subid;
  5525. }
  5526. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5527. return false;
  5528. }
  5529. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5530. return false;
  5531. }
  5532. logStatus.error(`${result}:${statusText}(${status})`);
  5533. return false;
  5534. } catch (error) {
  5535. throwError(error, 'Steam.appid2subid');
  5536. return false;
  5537. }
  5538. }
  5539. async #getLicenses() {
  5540. try {
  5541. const logStatus = scripts_echoLog({
  5542. text: i18n('gettingLicenses')
  5543. });
  5544. const {
  5545. result,
  5546. statusText,
  5547. status,
  5548. data
  5549. } = await tools_httpRequest({
  5550. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  5551. method: 'GET',
  5552. responseType: 'json'
  5553. });
  5554. if (result === 'Success') {
  5555. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5556. var _data$response10;
  5557. logStatus.success();
  5558. return (_data$response10 = data.response) === null || _data$response10 === void 0 ? void 0 : _data$response10.rgOwnedPackages;
  5559. }
  5560. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5561. return false;
  5562. }
  5563. logStatus.error(`${result}:${statusText}(${status})`);
  5564. return false;
  5565. } catch (error) {
  5566. throwError(error, 'Steam.getLicenses');
  5567. return false;
  5568. }
  5569. }
  5570. async #addLicense(id) {
  5571. try {
  5572. const [ type, ids ] = id.split('-');
  5573. if (type === 'appid') {
  5574. const subid = await this.#appid2subid(ids);
  5575. if (!subid) {
  5576. return false;
  5577. }
  5578. const logStatus = scripts_echoLog({
  5579. type: 'addingFreeLicense',
  5580. text: ids
  5581. });
  5582. if (!await this.#addFreeLicense(subid, logStatus)) {
  5583. return false;
  5584. }
  5585. const {
  5586. result,
  5587. statusText,
  5588. status,
  5589. data
  5590. } = await tools_httpRequest({
  5591. url: `https://store.steampowered.com/app/${ids}`,
  5592. method: 'GET'
  5593. });
  5594. if (result === 'Success') {
  5595. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5596. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  5597. logStatus.success();
  5598. return true;
  5599. }
  5600. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5601. return false;
  5602. }
  5603. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5604. return false;
  5605. }
  5606. logStatus.error(`${result}:${statusText}(${status})`);
  5607. return false;
  5608. } else if (type === 'subid') {
  5609. if (this.#area === 'CN') {
  5610. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  5611. await this.#changeArea();
  5612. }
  5613. const logStatusArr = {};
  5614. const idsArr = ids.split(',');
  5615. for (const subid of idsArr) {
  5616. const logStatus = scripts_echoLog({
  5617. type: 'addingFreeLicenseSubid',
  5618. text: subid
  5619. });
  5620. if (!await this.#addFreeLicense(subid, logStatus)) {
  5621. return false;
  5622. }
  5623. logStatusArr[subid] = logStatus;
  5624. }
  5625. const licenses = await this.#getLicenses();
  5626. if (!licenses) {
  5627. return false;
  5628. }
  5629. for (const subid of idsArr) {
  5630. if (licenses.includes(parseInt(subid, 10))) {
  5631. logStatusArr[subid].success();
  5632. } else {
  5633. logStatusArr[subid].error();
  5634. }
  5635. }
  5636. return true;
  5637. }
  5638. return false;
  5639. } catch (error) {
  5640. throwError(error, 'Steam.addLicense');
  5641. return false;
  5642. }
  5643. }
  5644. async #addFreeLicense(id, logStatusPre) {
  5645. try {
  5646. const logStatus = logStatusPre || scripts_echoLog({
  5647. type: 'addingFreeLicenseSubid',
  5648. text: id
  5649. });
  5650. const {
  5651. result,
  5652. statusText,
  5653. status,
  5654. data
  5655. } = await tools_httpRequest({
  5656. url: 'https://store.steampowered.com/checkout/addfreelicense',
  5657. method: 'POST',
  5658. headers: {
  5659. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5660. Host: 'store.steampowered.com',
  5661. Origin: 'https://store.steampowered.com',
  5662. Referer: 'https://store.steampowered.com/account/licenses/'
  5663. },
  5664. data: $.param({
  5665. action: 'add_to_cart',
  5666. sessionid: this.#auth.storeSessionID,
  5667. subid: id
  5668. }),
  5669. dataType: 'json'
  5670. });
  5671. if (result === 'Success') {
  5672. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5673. if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
  5674. logStatus.warning(i18n('changeAreaNotice'));
  5675. const result = await this.#changeArea();
  5676. if (!result || result === 'CN') {
  5677. return false;
  5678. }
  5679. return await this.#addFreeLicense(id);
  5680. }
  5681. logStatus.success();
  5682. return true;
  5683. }
  5684. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5685. return false;
  5686. }
  5687. logStatus.error(`${result}:${statusText}(${status})`);
  5688. return false;
  5689. } catch (error) {
  5690. throwError(error, 'Steam.addFreeLicense');
  5691. return false;
  5692. }
  5693. }
  5694. async #requestPlayTestAccess(id) {
  5695. try {
  5696. const logStatus = scripts_echoLog({
  5697. type: 'requestingPlayTestAccess',
  5698. text: id
  5699. });
  5700. const {
  5701. result,
  5702. statusText,
  5703. status,
  5704. data
  5705. } = await tools_httpRequest({
  5706. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  5707. method: 'POST',
  5708. headers: {
  5709. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5710. Host: 'store.steampowered.com',
  5711. Origin: 'https://store.steampowered.com',
  5712. Referer: `https://store.steampowered.com/app/${id}`
  5713. },
  5714. data: $.param({
  5715. sessionid: this.#auth.storeSessionID
  5716. }),
  5717. dataType: 'json'
  5718. });
  5719. if (result === 'Success') {
  5720. var _data$response11;
  5721. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response11 = data.response) === null || _data$response11 === void 0 ? void 0 : _data$response11.success) === 1) {
  5722. logStatus.success();
  5723. return true;
  5724. }
  5725. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5726. return false;
  5727. }
  5728. logStatus.error(`${result}:${statusText}(${status})`);
  5729. return false;
  5730. } catch (error) {
  5731. throwError(error, 'Steam.requestPlayTestAccess');
  5732. return false;
  5733. }
  5734. }
  5735. async toggle(_ref) {
  5736. let {
  5737. doTask = true,
  5738. groupLinks = [],
  5739. officialGroupLinks = [],
  5740. wishlistLinks = [],
  5741. followLinks = [],
  5742. forumLinks = [],
  5743. workshopLinks = [],
  5744. workshopVoteLinks = [],
  5745. curatorLinks = [],
  5746. curatorLikeLinks = [],
  5747. announcementLinks = [],
  5748. licenseLinks = [],
  5749. playtestLinks = []
  5750. } = _ref;
  5751. try {
  5752. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !this.#communityInitialized) {
  5753. scripts_echoLog({
  5754. text: i18n('needInit')
  5755. });
  5756. return false;
  5757. }
  5758. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !this.#storeInitialized) {
  5759. scripts_echoLog({
  5760. text: i18n('needInit')
  5761. });
  5762. return false;
  5763. }
  5764. const prom = [];
  5765. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  5766. scripts_echoLog({
  5767. type: 'globalOptionsSkip',
  5768. text: 'steam.groups'
  5769. });
  5770. } else {
  5771. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  5772. var _link$match;
  5773. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  5774. });
  5775. if (realGroups.length > 0) {
  5776. for (const group of realGroups) {
  5777. if (doTask) {
  5778. prom.push(this.#joinGroup(group));
  5779. } else {
  5780. prom.push(this.#leaveGroup(group));
  5781. }
  5782. await delay(1e3);
  5783. }
  5784. }
  5785. }
  5786. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  5787. scripts_echoLog({
  5788. type: 'globalOptionsSkip',
  5789. text: 'steam.officialGroups'
  5790. });
  5791. } else {
  5792. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  5793. var _link$match2;
  5794. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  5795. });
  5796. if (realOfficialGroups.length > 0) {
  5797. for (const officialGroup of realOfficialGroups) {
  5798. if (doTask) {
  5799. prom.push(this.#joinOfficialGroup(officialGroup));
  5800. } else {
  5801. prom.push(this.#leaveOfficialGroup(officialGroup));
  5802. }
  5803. await delay(1e3);
  5804. }
  5805. }
  5806. }
  5807. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  5808. scripts_echoLog({
  5809. type: 'globalOptionsSkip',
  5810. text: 'steam.wishlists'
  5811. });
  5812. } else {
  5813. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  5814. var _link$match3;
  5815. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5816. });
  5817. if (realWishlists.length > 0) {
  5818. for (const game of realWishlists) {
  5819. if (doTask) {
  5820. prom.push(this.#addToWishlist(game));
  5821. } else {
  5822. prom.push(this.#removeFromWishlist(game));
  5823. }
  5824. await delay(1e3);
  5825. }
  5826. }
  5827. }
  5828. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5829. scripts_echoLog({
  5830. type: 'globalOptionsSkip',
  5831. text: 'steam.follows'
  5832. });
  5833. } else {
  5834. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5835. var _link$match4;
  5836. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5837. });
  5838. if (realFollows.length > 0) {
  5839. for (const game of realFollows) {
  5840. prom.push(this.#toggleFollowGame(game, doTask));
  5841. await delay(1e3);
  5842. }
  5843. }
  5844. }
  5845. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5846. scripts_echoLog({
  5847. type: 'globalOptionsSkip',
  5848. text: 'steam.forums'
  5849. });
  5850. } else {
  5851. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5852. var _link$match5;
  5853. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5854. });
  5855. if (realForums.length > 0) {
  5856. for (const forum of realForums) {
  5857. prom.push(this.#toggleForum(forum, doTask));
  5858. await delay(1e3);
  5859. }
  5860. }
  5861. }
  5862. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5863. scripts_echoLog({
  5864. type: 'globalOptionsSkip',
  5865. text: 'steam.workshops'
  5866. });
  5867. } else {
  5868. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5869. var _link$match6;
  5870. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5871. });
  5872. if (realWorkshops.length > 0) {
  5873. for (const workshop of realWorkshops) {
  5874. prom.push(this.#toggleFavoriteWorkshop(workshop, doTask));
  5875. await delay(1e3);
  5876. }
  5877. }
  5878. }
  5879. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5880. scripts_echoLog({
  5881. type: 'globalOptionsSkip',
  5882. text: 'steam.workshopVotes'
  5883. });
  5884. } else {
  5885. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5886. var _link$match7;
  5887. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5888. });
  5889. if (doTask && realworkshopVotes.length > 0) {
  5890. for (const workshop of realworkshopVotes) {
  5891. prom.push(this.#voteUpWorkshop(workshop));
  5892. await delay(1e3);
  5893. }
  5894. }
  5895. }
  5896. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5897. scripts_echoLog({
  5898. type: 'globalOptionsSkip',
  5899. text: 'steam.curators'
  5900. });
  5901. } else {
  5902. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5903. var _link$match8;
  5904. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5905. });
  5906. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5907. var _link$match9;
  5908. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5909. });
  5910. if (realCurators.length > 0) {
  5911. for (const curator of realCurators) {
  5912. prom.push(this.#toggleCurator(curator, doTask));
  5913. await delay(1e3);
  5914. }
  5915. }
  5916. if (realCuratorLikes.length > 0) {
  5917. for (const curatorLike of realCuratorLikes) {
  5918. prom.push(this.#toggleCuratorLike(curatorLike, doTask));
  5919. await delay(1e3);
  5920. }
  5921. }
  5922. }
  5923. if (doTask && !globalOptions.doTask.steam.announcements) {
  5924. scripts_echoLog({
  5925. type: 'globalOptionsSkip',
  5926. text: 'steam.announcements'
  5927. });
  5928. } else {
  5929. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5930. var _link$match11;
  5931. if (link.includes('store.steampowered.com')) {
  5932. var _link$match10;
  5933. return (_link$match10 = link.match(/store\.steampowered\.com\/news\/app\/([\d]+)\/view\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10.slice(1, 3).join('/');
  5934. }
  5935. return (_link$match11 = link.match(/steamcommunity\.com\/games\/([\d]+)\/announcements\/detail\/([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11.slice(1, 3).join('/');
  5936. });
  5937. if (doTask && realAnnouncements.length > 0) {
  5938. for (const id of realAnnouncements) {
  5939. prom.push(this.#likeAnnouncement(id));
  5940. await delay(1e3);
  5941. }
  5942. }
  5943. }
  5944. if (doTask && !globalOptions.doTask.steam.licenses) {
  5945. scripts_echoLog({
  5946. type: 'globalOptionsSkip',
  5947. text: 'steam.licenses'
  5948. });
  5949. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5950. for (const id of licenseLinks) {
  5951. prom.push(this.#addLicense(id));
  5952. await delay(1e3);
  5953. }
  5954. }
  5955. if (doTask && !globalOptions.doTask.steam.playtests) {
  5956. scripts_echoLog({
  5957. type: 'globalOptionsSkip',
  5958. text: 'steam.playtests'
  5959. });
  5960. } else {
  5961. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5962. var _link$match12;
  5963. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5964. });
  5965. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5966. for (const id of realPlaytests) {
  5967. prom.push(this.#requestPlayTestAccess(id));
  5968. await delay(1e3);
  5969. }
  5970. }
  5971. }
  5972. return Promise.all(prom).then(async () => {
  5973. if (this.#area !== 'CN') {
  5974. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5975. await this.#changeArea('CN');
  5976. }
  5977. return true;
  5978. });
  5979. } catch (error) {
  5980. throwError(error, 'Steam.toggle');
  5981. return false;
  5982. }
  5983. }
  5984. #setCache(type, name, id) {
  5985. try {
  5986. this.#cache[type][name] = id;
  5987. GM_setValue('steamCache', this.#cache);
  5988. } catch (error) {
  5989. throwError(error, 'Steam.setCache');
  5990. }
  5991. }
  5992. }
  5993. const social_Steam = Steam;
  5994. class Website {
  5995. undoneTasks;
  5996. socialTasks;
  5997. giveawayId;
  5998. socialInitialized = {
  5999. discord: false,
  6000. instagram: false,
  6001. reddit: false,
  6002. twitch: false,
  6003. twitter: false,
  6004. vk: false,
  6005. youtube: false,
  6006. steamStore: false,
  6007. steamCommunity: false
  6008. };
  6009. initialized = false;
  6010. social = {};
  6011. async #bind(name, init) {
  6012. try {
  6013. return {
  6014. name: name,
  6015. result: await init
  6016. };
  6017. } catch (error) {
  6018. throwError(error, 'Website.bind');
  6019. return {
  6020. name: name,
  6021. result: false
  6022. };
  6023. }
  6024. }
  6025. async initSocial(action) {
  6026. try {
  6027. const pro = [];
  6028. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6029. if (tasks.discord) {
  6030. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6031. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6032. this.social.discord = new social_Discord();
  6033. pro.push(this.#bind('discord', this.social.discord.init()));
  6034. }
  6035. }
  6036. if (tasks.instagram) {
  6037. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6038. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6039. this.social.instagram = new social_Instagram();
  6040. pro.push(this.#bind('instagram', this.social.instagram.init()));
  6041. }
  6042. }
  6043. if (tasks.reddit) {
  6044. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6045. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6046. this.social.reddit = new social_Reddit();
  6047. pro.push(this.#bind('reddit', this.social.reddit.init()));
  6048. }
  6049. }
  6050. if (tasks.twitch) {
  6051. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6052. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6053. this.social.twitch = new social_Twitch();
  6054. pro.push(this.#bind('twitch', this.social.twitch.init()));
  6055. }
  6056. }
  6057. if (tasks.twitter) {
  6058. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6059. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6060. this.social.twitter = new social_Twitter();
  6061. pro.push(this.#bind('twitter', this.social.twitter.init()));
  6062. }
  6063. }
  6064. if (tasks.vk) {
  6065. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6066. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6067. this.social.vk = new social_Vk();
  6068. pro.push(this.#bind('vk', this.social.vk.init()));
  6069. }
  6070. }
  6071. if (tasks.youtube) {
  6072. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6073. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6074. this.social.youtube = new Youtube();
  6075. pro.push(this.#bind('youtube', this.social.youtube.init()));
  6076. }
  6077. }
  6078. if (tasks.steam) {
  6079. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6080. if (steamLength > 0) {
  6081. if (!this.social.steam) {
  6082. this.social.steam = new social_Steam();
  6083. }
  6084. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6085. var _tasks$steam, _tasks$steam$type;
  6086. return [ 'groupLinks', 'officialGroupLinks', 'forumLinks', 'workshopLinks', 'workshopVoteLinks' ].includes(type) ? ((_tasks$steam = tasks.steam) === null || _tasks$steam === void 0 ? void 0 : (_tasks$steam$type = _tasks$steam[type]) === null || _tasks$steam$type === void 0 ? void 0 : _tasks$steam$type.length) || 0 : 0;
  6087. }).reduce((total, number) => total + number, 0);
  6088. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6089. pro.push(this.#bind('steamStore', this.social.steam.init('store')));
  6090. }
  6091. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6092. pro.push(this.#bind('steamCommunity', this.social.steam.init('community')));
  6093. }
  6094. }
  6095. }
  6096. if (tasks.links && tasks.links.length > 0) {
  6097. this.social.visitLink = visitLink;
  6098. }
  6099. return await Promise.all(pro).then(result => {
  6100. let checked = true;
  6101. for (const data of result) {
  6102. if (data.result) {
  6103. this.socialInitialized[data.name] = data.result;
  6104. } else {
  6105. checked = false;
  6106. }
  6107. }
  6108. return checked;
  6109. });
  6110. } catch (error) {
  6111. throwError(error, 'Website.initSocial');
  6112. return false;
  6113. }
  6114. }
  6115. uniqueTasks(allTasks) {
  6116. const result = {};
  6117. for (const [ social, types ] of Object.entries(allTasks)) {
  6118. result[social] = {};
  6119. for (const [ type, tasks ] of Object.entries(types)) {
  6120. result[social][type] = unique(tasks);
  6121. }
  6122. }
  6123. return result;
  6124. }
  6125. async toggleTask(action) {
  6126. try {
  6127. if (!this.initialized && !this.init()) {
  6128. return false;
  6129. }
  6130. if (!await this.classifyTask(action)) {
  6131. return false;
  6132. }
  6133. if (!await this.initSocial(action)) {
  6134. return false;
  6135. }
  6136. const pro = [];
  6137. const doTask = action === 'do';
  6138. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6139. if (this.socialInitialized.discord !== 'skip' && this.social.discord) {
  6140. pro.push(this.social.discord.toggle({
  6141. doTask: doTask,
  6142. ...tasks.discord
  6143. }));
  6144. }
  6145. if (this.social.instagram) {
  6146. pro.push(this.social.instagram.toggle({
  6147. doTask: doTask,
  6148. ...tasks.instagram
  6149. }));
  6150. }
  6151. if (this.social.reddit) {
  6152. pro.push(this.social.reddit.toggle({
  6153. doTask: doTask,
  6154. ...tasks.reddit
  6155. }));
  6156. }
  6157. if (this.social.twitch) {
  6158. pro.push(this.social.twitch.toggle({
  6159. doTask: doTask,
  6160. ...tasks.twitch
  6161. }));
  6162. }
  6163. if (this.social.twitter) {
  6164. pro.push(this.social.twitter.toggle({
  6165. doTask: doTask,
  6166. ...tasks.twitter
  6167. }));
  6168. }
  6169. if (this.social.vk) {
  6170. pro.push(this.social.vk.toggle({
  6171. doTask: doTask,
  6172. ...tasks.vk
  6173. }));
  6174. }
  6175. if (this.social.youtube) {
  6176. pro.push(this.social.youtube.toggle({
  6177. doTask: doTask,
  6178. ...tasks.youtube
  6179. }));
  6180. }
  6181. if (this.social.steam) {
  6182. pro.push(this.social.steam.toggle({
  6183. doTask: doTask,
  6184. ...tasks.steam
  6185. }));
  6186. }
  6187. if (this.social.visitLink && tasks.links && doTask) {
  6188. for (const link of tasks.links) {
  6189. pro.push(this.social.visitLink(link));
  6190. }
  6191. }
  6192. if (doTask && tasks.extra && this.extraDoTask) {
  6193. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6194. if (hasExtra) {
  6195. pro.push(this.extraDoTask(tasks.extra));
  6196. }
  6197. }
  6198. await Promise.all(pro);
  6199. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6200. return true;
  6201. } catch (error) {
  6202. throwError(error, 'Website.toggleTask');
  6203. return false;
  6204. }
  6205. }
  6206. async doTask() {
  6207. try {
  6208. return await this.toggleTask('do');
  6209. } catch (error) {
  6210. throwError(error, 'Website.doTask');
  6211. return false;
  6212. }
  6213. }
  6214. async undoTask() {
  6215. try {
  6216. return await this.toggleTask('undo');
  6217. } catch (error) {
  6218. throwError(error, 'Website.undoTask');
  6219. return false;
  6220. }
  6221. }
  6222. }
  6223. const website_Website = Website;
  6224. const FreeAnyWhere_defaultTasksTemplate = {
  6225. steam: {
  6226. groupLinks: [],
  6227. wishlistLinks: [],
  6228. curatorLinks: [],
  6229. followLinks: []
  6230. },
  6231. vk: {
  6232. nameLinks: []
  6233. }
  6234. };
  6235. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6236. class FreeAnyWhere extends website_Website {
  6237. name = 'FreeAnyWhere';
  6238. tasks = [];
  6239. socialTasks = JSON.parse(FreeAnyWhere_defaultTasks);
  6240. undoneTasks = JSON.parse(FreeAnyWhere_defaultTasks);
  6241. buttons = [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ];
  6242. static test() {
  6243. return window.location.host === 'freeanywhere.net';
  6244. }
  6245. async init() {
  6246. try {
  6247. const logStatus = scripts_echoLog({
  6248. text: i18n('initing')
  6249. });
  6250. if ($('a[href="#/login"]').length > 0) {
  6251. window.open('/#/login', '_self');
  6252. logStatus.warning(i18n('needLogin'));
  6253. return false;
  6254. }
  6255. if (window.location.href.includes('/login')) {
  6256. logStatus.warning(i18n('needLogin'));
  6257. return false;
  6258. }
  6259. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6260. var _window$location$href;
  6261. const id = (_window$location$href = window.location.href.match(/https?:\/\/freeanywhere\.net\/.*?#\/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6262. if (!id) {
  6263. logStatus.error(i18n('getFailed', 'Id'));
  6264. return false;
  6265. }
  6266. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6267. }
  6268. if (!this.#getGiveawayId()) {
  6269. return false;
  6270. }
  6271. if (!await this.#checkLeftKey()) {
  6272. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6273. }
  6274. this.initialized = true;
  6275. logStatus.success();
  6276. return true;
  6277. } catch (error) {
  6278. throwError(error, 'Freeanywhere.init');
  6279. return false;
  6280. }
  6281. }
  6282. async classifyTask(action) {
  6283. try {
  6284. const logStatus = scripts_echoLog({
  6285. text: i18n('getTasksInfo')
  6286. });
  6287. if (action === 'undo') {
  6288. var _GM_getValue;
  6289. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6290. }
  6291. const {
  6292. result,
  6293. statusText,
  6294. status,
  6295. data
  6296. } = await tools_httpRequest({
  6297. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6298. method: 'GET',
  6299. headers: {
  6300. authorization: `Token ${window.localStorage.getItem('token')}`,
  6301. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6302. },
  6303. responseType: 'json'
  6304. });
  6305. if (result === 'Success') {
  6306. var _data$response;
  6307. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6308. if (tasks) {
  6309. if (action === 'verify') {
  6310. this.tasks = [];
  6311. }
  6312. for (const task of tasks) {
  6313. const type = task.challenge;
  6314. const social = task.challenge_provider;
  6315. const taskInfo = {
  6316. id: task.id,
  6317. title: task.title
  6318. };
  6319. if (action === 'verify' && !task.is_success) {
  6320. this.tasks.push(taskInfo);
  6321. continue;
  6322. }
  6323. switch (social) {
  6324. case 'steam':
  6325. taskInfo.social = 'steam';
  6326. switch (type) {
  6327. case 'WL':
  6328. if (action === 'undo') {
  6329. this.socialTasks.steam.wishlistLinks.push(task.link);
  6330. }
  6331. if (action === 'do' && !task.is_success) {
  6332. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6333. }
  6334. break;
  6335.  
  6336. case 'JTG':
  6337. if (action === 'undo') {
  6338. this.socialTasks.steam.groupLinks.push(task.link);
  6339. }
  6340. if (action === 'do' && !task.is_success) {
  6341. this.undoneTasks.steam.groupLinks.push(task.link);
  6342. }
  6343. break;
  6344.  
  6345. case 'STC':
  6346. if (action === 'undo') {
  6347. this.socialTasks.steam.curatorLinks.push(task.link);
  6348. }
  6349. if (action === 'do' && !task.is_success) {
  6350. this.undoneTasks.steam.curatorLinks.push(task.link);
  6351. }
  6352. break;
  6353.  
  6354. case 'GF':
  6355. if (action === 'undo') {
  6356. this.socialTasks.steam.followLinks.push(task.link);
  6357. }
  6358. if (action === 'do' && !task.is_success) {
  6359. this.undoneTasks.steam.followLinks.push(task.link);
  6360. }
  6361. break;
  6362. }
  6363. break;
  6364.  
  6365. case 'vk-oauth2':
  6366. if (action === 'undo') {
  6367. this.socialTasks.vk.nameLinks.push(task.link);
  6368. }
  6369. if (action === 'do' && !task.is_success) {
  6370. this.undoneTasks.vk.nameLinks.push(task.link);
  6371. }
  6372. break;
  6373.  
  6374. case 'website':
  6375. break;
  6376.  
  6377. default:
  6378. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6379. break;
  6380. }
  6381. }
  6382. logStatus.success();
  6383. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6384. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6385. if (window.DEBUG) {
  6386. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  6387. }
  6388. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6389. tasks: this.socialTasks,
  6390. time: new Date().getTime()
  6391. });
  6392. return true;
  6393. }
  6394. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6395. return false;
  6396. }
  6397. logStatus.error(`${result}:${statusText}(${status})`);
  6398. return false;
  6399. } catch (error) {
  6400. throwError(error, 'Freeanywhere.classifyTask');
  6401. return false;
  6402. }
  6403. }
  6404. async verifyTask() {
  6405. try {
  6406. if (!this.initialized && !this.init()) {
  6407. return false;
  6408. }
  6409. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6410. return false;
  6411. }
  6412. const pro = [];
  6413. for (const task of this.tasks) {
  6414. pro.push(this.#verify(task));
  6415. await delay(1e3);
  6416. }
  6417. await Promise.all(pro);
  6418. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6419. return !!await this.getKey(true);
  6420. } catch (error) {
  6421. throwError(error, 'Freeanywhere.verifyTask');
  6422. return false;
  6423. }
  6424. }
  6425. async getKey(initialized) {
  6426. try {
  6427. if (!initialized && !this.initialized && !this.init()) {
  6428. return false;
  6429. }
  6430. const logStatus = scripts_echoLog({
  6431. text: i18n('gettingKey')
  6432. });
  6433. const {
  6434. result,
  6435. statusText,
  6436. status,
  6437. data
  6438. } = await tools_httpRequest({
  6439. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6440. method: 'GET',
  6441. dataType: 'json',
  6442. headers: {
  6443. authorization: `Token ${window.localStorage.getItem('token')}`
  6444. }
  6445. });
  6446. if (result === 'Success') {
  6447. var _data$response2;
  6448. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6449. logStatus.success();
  6450. scripts_echoLog({}).success(data.response.reward);
  6451. return data.response.reward;
  6452. }
  6453. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6454. return false;
  6455. }
  6456. logStatus.error(`${result}:${statusText}(${status})`);
  6457. return false;
  6458. } catch (error) {
  6459. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6460. return false;
  6461. }
  6462. }
  6463. #getGiveawayId() {
  6464. try {
  6465. var _window$location$href2;
  6466. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6467. if (giveawayId) {
  6468. this.giveawayId = giveawayId;
  6469. return true;
  6470. }
  6471. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6472. return false;
  6473. } catch (error) {
  6474. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6475. }
  6476. }
  6477. async #verify(task) {
  6478. try {
  6479. const logStatus = scripts_echoLog({
  6480. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6481. });
  6482. const {
  6483. result,
  6484. statusText,
  6485. status,
  6486. data
  6487. } = await tools_httpRequest({
  6488. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6489. method: 'GET',
  6490. dataType: 'json',
  6491. headers: {
  6492. authorization: `Token ${window.localStorage.getItem('token')}`,
  6493. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6494. }
  6495. });
  6496. if (result === 'Success') {
  6497. var _data$response3;
  6498. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6499. logStatus.success();
  6500. return true;
  6501. }
  6502. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6503. return false;
  6504. }
  6505. logStatus.error(`${result}:${statusText}(${status})`);
  6506. return false;
  6507. } catch (error) {
  6508. throwError(error, 'Freeanywhere.verify');
  6509. return false;
  6510. }
  6511. }
  6512. async #checkLeftKey() {
  6513. try {
  6514. var _data$response4;
  6515. if (!globalOptions.other.checkLeftKey) {
  6516. return true;
  6517. }
  6518. const {
  6519. data
  6520. } = await tools_httpRequest({
  6521. url: 'https://freeanywhere.net/api/v1/widget/?format=json',
  6522. method: 'GET',
  6523. dataType: 'json',
  6524. headers: {
  6525. authorization: `Token ${window.localStorage.getItem('token')}`
  6526. }
  6527. });
  6528. if (data !== null && data !== void 0 && (_data$response4 = data.response) !== null && _data$response4 !== void 0 && _data$response4.giveaways.find(giveaway => `${giveaway === null || giveaway === void 0 ? void 0 : giveaway.id}` === this.giveawayId)) {
  6529. return true;
  6530. }
  6531. await external_Swal_default().fire({
  6532. icon: 'warning',
  6533. title: i18n('notice'),
  6534. text: i18n('noKeysLeft'),
  6535. confirmButtonText: i18n('confirm'),
  6536. cancelButtonText: i18n('cancel'),
  6537. showCancelButton: true
  6538. }).then(_ref => {
  6539. let {
  6540. value
  6541. } = _ref;
  6542. if (value) {
  6543. window.close();
  6544. }
  6545. });
  6546. return true;
  6547. } catch (error) {
  6548. throwError(error, 'Giveawaysu.checkLeftKey');
  6549. return false;
  6550. }
  6551. }
  6552. }
  6553. const website_FreeAnyWhere = FreeAnyWhere;
  6554. const GiveawaySu_defaultTasks = {
  6555. steam: {
  6556. groupLinks: [],
  6557. wishlistLinks: [],
  6558. curatorLinks: [],
  6559. curatorLikeLinks: [],
  6560. followLinks: [],
  6561. forumLinks: [],
  6562. announcementLinks: [],
  6563. workshopVoteLinks: [],
  6564. playtestLinks: []
  6565. },
  6566. discord: {
  6567. serverLinks: []
  6568. },
  6569. instagram: {
  6570. userLinks: []
  6571. },
  6572. vk: {
  6573. nameLinks: []
  6574. },
  6575. twitch: {
  6576. channelLinks: []
  6577. },
  6578. reddit: {
  6579. redditLinks: []
  6580. },
  6581. youtube: {
  6582. channelLinks: [],
  6583. likeLinks: []
  6584. },
  6585. twitter: {
  6586. userLinks: [],
  6587. retweetLinks: []
  6588. }
  6589. };
  6590. class GiveawaySu extends website_Website {
  6591. name = 'GiveawaySu';
  6592. socialTasks = GiveawaySu_defaultTasks;
  6593. undoneTasks = GiveawaySu_defaultTasks;
  6594. buttons = [ 'doTask', 'undoTask' ];
  6595. static test() {
  6596. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6597. }
  6598. async after() {
  6599. try {
  6600. if (!this.#checkLogin()) {
  6601. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6602. }
  6603. if (!await this.#checkLeftKey()) {
  6604. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6605. }
  6606. scripts_echoLog({}).warning(i18n('gsNotice'));
  6607. } catch (error) {
  6608. throwError(error, 'Giveawaysu.after');
  6609. }
  6610. }
  6611. init() {
  6612. try {
  6613. const logStatus = scripts_echoLog({
  6614. text: i18n('initing')
  6615. });
  6616. if ($('a.steam-login').length > 0) {
  6617. window.open('/steam/redirect', '_self');
  6618. logStatus.warning(i18n('needLogin'));
  6619. return false;
  6620. }
  6621. if (!this.#getGiveawayId()) {
  6622. return false;
  6623. }
  6624. this.initialized = true;
  6625. logStatus.success();
  6626. return true;
  6627. } catch (error) {
  6628. throwError(error, 'Giveawaysu.init');
  6629. return false;
  6630. }
  6631. }
  6632. async classifyTask(action) {
  6633. try {
  6634. const logStatus = scripts_echoLog({
  6635. text: i18n('getTasksInfo')
  6636. });
  6637. if (action === 'undo') {
  6638. var _GM_getValue;
  6639. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6640. return true;
  6641. }
  6642. const pro = [];
  6643. const tasks = $('#actions tr');
  6644. if ($('div.bind-discord').is(':visible')) {
  6645. $('div.bind-discord a')[0].click();
  6646. }
  6647. if ($('div.bind-twitch').is(':visible')) {
  6648. $('div.bind-twitch a')[0].click();
  6649. }
  6650. for (const task of tasks) {
  6651. pro.push(new Promise(resolve => {
  6652. const td = $(task).find('td:not(".hidden")');
  6653. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6654. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6655. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6656. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6657. const taskName = taskDes.text().trim();
  6658. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6659. return resolve(true);
  6660. }
  6661. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6662. if (!taskLink) {
  6663. return resolve(false);
  6664. }
  6665. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6666. this.undoneTasks.steam.groupLinks.push(taskLink);
  6667. } else if (/like.*announcement/gi.test(taskName)) {
  6668. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6669. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6670. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6671. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6672. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6673. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6674. this.undoneTasks.steam.forumLinks.push(taskLink);
  6675. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6676. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6677. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  6678. this.undoneTasks.steam.playtestLinks.push(taskLink);
  6679. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6680. this.undoneTasks.discord.serverLinks.push(taskLink);
  6681. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6682. this.undoneTasks.instagram.userLinks.push(taskLink);
  6683. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6684. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6685. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6686. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6687. } else if (/watch.*art/gim.test(taskName)) {
  6688. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6689. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6690. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6691. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6692. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6693. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6694. this.undoneTasks.vk.nameLinks.push(taskLink);
  6695. } else {
  6696. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6697. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6698. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6699. }
  6700. if (/follow.*button/gim.test(taskName)) {
  6701. this.undoneTasks.steam.followLinks.push(taskLink);
  6702. }
  6703. }
  6704. }
  6705. resolve(true);
  6706. }).catch(error => {
  6707. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6708. return false;
  6709. });
  6710. }));
  6711. }
  6712. await Promise.all(pro);
  6713. logStatus.success();
  6714. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6715. this.socialTasks = this.undoneTasks;
  6716. if (window.DEBUG) {
  6717. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  6718. }
  6719. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6720. tasks: this.socialTasks,
  6721. time: new Date().getTime()
  6722. });
  6723. return true;
  6724. } catch (error) {
  6725. throwError(error, 'Giveawaysu.classifyTask');
  6726. return false;
  6727. }
  6728. }
  6729. #checkLogin() {
  6730. try {
  6731. if (!globalOptions.other.checkLogin) {
  6732. return true;
  6733. }
  6734. if ($('a.steam-login').length > 0) {
  6735. window.open('/steam/redirect', '_self');
  6736. }
  6737. return true;
  6738. } catch (error) {
  6739. throwError(error, 'Giveawaysu.checkLogin');
  6740. return false;
  6741. }
  6742. }
  6743. async #checkLeftKey() {
  6744. try {
  6745. if (!globalOptions.other.checkLeftKey) {
  6746. return true;
  6747. }
  6748. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  6749. await external_Swal_default().fire({
  6750. icon: 'warning',
  6751. title: i18n('notice'),
  6752. text: i18n('noKeysLeft'),
  6753. confirmButtonText: i18n('confirm'),
  6754. cancelButtonText: i18n('cancel'),
  6755. showCancelButton: true
  6756. }).then(_ref => {
  6757. let {
  6758. value
  6759. } = _ref;
  6760. if (value) {
  6761. window.close();
  6762. }
  6763. });
  6764. }
  6765. return true;
  6766. } catch (error) {
  6767. throwError(error, 'Giveawaysu.checkLeftKey');
  6768. return false;
  6769. }
  6770. }
  6771. #getGiveawayId() {
  6772. var _window$location$href;
  6773. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6774. if (giveawayId) {
  6775. this.giveawayId = giveawayId;
  6776. return true;
  6777. }
  6778. scripts_echoLog({
  6779. text: i18n('getFailed', 'GiveawayId')
  6780. });
  6781. return false;
  6782. }
  6783. }
  6784. class Indiedb {
  6785. name = 'Indiedb';
  6786. buttons = [ 'doTask' ];
  6787. static test() {
  6788. return window.location.host === 'www.indiedb.com';
  6789. }
  6790. async after() {
  6791. try {
  6792. if (!this.#checkLogin()) {
  6793. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6794. }
  6795. if (!await this.#checkLeftKey()) {
  6796. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6797. }
  6798. } catch (error) {
  6799. throwError(error, 'Indiedb.after');
  6800. }
  6801. }
  6802. async doTask() {
  6803. try {
  6804. if (!await this.#join()) {
  6805. return false;
  6806. }
  6807. return await this.#do();
  6808. } catch (error) {
  6809. throwError(error, 'Indiedb.doTask');
  6810. return false;
  6811. }
  6812. }
  6813. async #join() {
  6814. try {
  6815. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  6816. scripts_echoLog({}).error(i18n('needLogin'));
  6817. return false;
  6818. }
  6819. const currentoption = $('a.buttonenter.buttongiveaway');
  6820. if (/join giveaway/gim.test(currentoption.text())) {
  6821. const logStatus = scripts_echoLog({
  6822. text: `${i18n('joiningGiveaway')}...`
  6823. });
  6824. const {
  6825. result,
  6826. statusText,
  6827. status,
  6828. data
  6829. } = await tools_httpRequest({
  6830. url: currentoption.attr('href'),
  6831. method: 'POST',
  6832. data: 'ajax=t',
  6833. dataType: 'json',
  6834. headers: {
  6835. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6836. accept: 'application/json, text/javascript, */*; q=0.01',
  6837. origin: window.location.origin
  6838. }
  6839. });
  6840. if (result === 'Success') {
  6841. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6842. var _data$response, _data$response4, _data$response5;
  6843. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  6844. var _data$response2, _data$response3;
  6845. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  6846. $('#giveawaysjoined').slideDown();
  6847. $('#giveawaysrecommend').slideDown();
  6848. logStatus.success(`Success${(_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.text ? `:${(_data$response3 = data.response) === null || _data$response3 === void 0 ? void 0 : _data$response3.text}` : ''}`);
  6849. return true;
  6850. }
  6851. logStatus.error(`Error${(_data$response4 = data.response) !== null && _data$response4 !== void 0 && _data$response4.text ? `:${(_data$response5 = data.response) === null || _data$response5 === void 0 ? void 0 : _data$response5.text}` : ''}`);
  6852. return false;
  6853. }
  6854. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6855. return false;
  6856. }
  6857. logStatus.error(`${result}:${statusText}(${status})`);
  6858. return false;
  6859. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  6860. return true;
  6861. }
  6862. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  6863. return false;
  6864. } catch (error) {
  6865. throwError(error, 'Indiedb.init');
  6866. return false;
  6867. }
  6868. }
  6869. async #do() {
  6870. try {
  6871. const id = $('script').map((index, script) => {
  6872. if (/\$\(document\)/gim.test(script.innerHTML)) {
  6873. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  6874. return [ (_script$innerHTML$mat = script.innerHTML.match(/"\/[\d]+"/gim)) === null || _script$innerHTML$mat === void 0 ? void 0 : (_script$innerHTML$mat2 = _script$innerHTML$mat[0]) === null || _script$innerHTML$mat2 === void 0 ? void 0 : (_script$innerHTML$mat3 = _script$innerHTML$mat2.match(/[\d]+/)) === null || _script$innerHTML$mat3 === void 0 ? void 0 : _script$innerHTML$mat3[0], (_script$innerHTML$mat4 = script.innerHTML.match(/"\/newsletter\/ajax\/subscribeprofile\/optin\/[\d]+"/gim)) === null || _script$innerHTML$mat4 === void 0 ? void 0 : (_script$innerHTML$mat5 = _script$innerHTML$mat4[0]) === null || _script$innerHTML$mat5 === void 0 ? void 0 : (_script$innerHTML$mat6 = _script$innerHTML$mat5.match(/[\d]+/)) === null || _script$innerHTML$mat6 === void 0 ? void 0 : _script$innerHTML$mat6[0] ];
  6875. }
  6876. return null;
  6877. });
  6878. if (id.length === 2) {
  6879. const pro = [];
  6880. const tasks = $('#giveawaysjoined a[class*=promo]');
  6881. for (const task of tasks) {
  6882. const promo = $(task);
  6883. if (!promo.hasClass('buttonentered')) {
  6884. const status = scripts_echoLog({
  6885. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  6886. });
  6887. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  6888. let text = '';
  6889. if (promo.hasClass('facebookpromo')) {
  6890. text = 'facebookpromo';
  6891. } else if (promo.hasClass('twitterpromo')) {
  6892. text = 'twitterpromo';
  6893. } else {
  6894. text = 'visitpromo';
  6895. }
  6896. pro.push(new Promise(resolve => {
  6897. $.ajax({
  6898. type: 'POST',
  6899. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  6900. timeout: 6e4,
  6901. dataType: 'json',
  6902. data: {
  6903. ajax: 't'
  6904. },
  6905. error(response, error, exception) {
  6906. if (window.DEBUG) {
  6907. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6908. response: response,
  6909. error: error,
  6910. exception: exception
  6911. });
  6912. }
  6913. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6914. resolve(true);
  6915. },
  6916. success(response) {
  6917. if (response.success) {
  6918. status.success(`Success:${response.text}`);
  6919. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6920. resolve(true);
  6921. } else {
  6922. status.error(`Error:${response.text}`);
  6923. resolve(true);
  6924. }
  6925. }
  6926. });
  6927. }));
  6928. } else if (promo.hasClass('emailoptinpromo')) {
  6929. pro.push(new Promise(resolve => {
  6930. $.ajax({
  6931. type: 'POST',
  6932. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  6933. timeout: 6e4,
  6934. dataType: 'json',
  6935. data: {
  6936. ajax: 't',
  6937. emailsystoggle: 4
  6938. },
  6939. error(response, error, exception) {
  6940. if (window.DEBUG) {
  6941. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6942. response: response,
  6943. error: error,
  6944. exception: exception
  6945. });
  6946. }
  6947. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6948. resolve(true);
  6949. },
  6950. success(response) {
  6951. if (response.success) {
  6952. status.success(`Success:${response.text}`);
  6953. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6954. resolve(true);
  6955. } else {
  6956. status.error(`Error:${response.text}`);
  6957. resolve(true);
  6958. }
  6959. }
  6960. });
  6961. }));
  6962. } else if (promo.hasClass('watchingpromo')) {
  6963. pro.push(new Promise(resolve => {
  6964. var _promo$attr;
  6965. const data = getUrlQuery(promo.attr('href'));
  6966. data.ajax = 't';
  6967. $.ajax({
  6968. type: 'POST',
  6969. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  6970. timeout: 6e4,
  6971. dataType: 'json',
  6972. data: data,
  6973. error(response, error, exception) {
  6974. if (window.DEBUG) {
  6975. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6976. response: response,
  6977. error: error,
  6978. exception: exception
  6979. });
  6980. }
  6981. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6982. resolve(true);
  6983. },
  6984. success(response) {
  6985. if (response.success) {
  6986. status.success(`Success:${response.text}`);
  6987. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6988. resolve(true);
  6989. } else {
  6990. status.error(`Error:${response.text}`);
  6991. resolve(true);
  6992. }
  6993. }
  6994. });
  6995. }));
  6996. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  6997. pro.push(new Promise(resolve => {
  6998. $.ajax({
  6999. type: 'POST',
  7000. url: urlPath(promo.attr('href')),
  7001. timeout: 6e4,
  7002. dataType: 'json',
  7003. data: {
  7004. ajax: 't'
  7005. },
  7006. error(response, error, exception) {
  7007. if (window.DEBUG) {
  7008. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7009. response: response,
  7010. error: error,
  7011. exception: exception
  7012. });
  7013. }
  7014. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7015. resolve(true);
  7016. },
  7017. success(response) {
  7018. if (response.success) {
  7019. status.success(`Success:${response.text}`);
  7020. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7021. resolve(true);
  7022. } else {
  7023. status.error(`Error:${response.text}`);
  7024. resolve(true);
  7025. }
  7026. }
  7027. });
  7028. }));
  7029. } else {
  7030. status.error(`Error:${i18n('unKnownTaskType')}`);
  7031. }
  7032. }
  7033. }
  7034. await Promise.all(pro);
  7035. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7036. return true;
  7037. }
  7038. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7039. return false;
  7040. } catch (error) {
  7041. throwError(error, 'Indiedb.classifyTask');
  7042. return false;
  7043. }
  7044. }
  7045. #checkLogin() {
  7046. try {
  7047. if (!globalOptions.other.checkLogin) {
  7048. return true;
  7049. }
  7050. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7051. window.open('/members/login', '_self');
  7052. }
  7053. return true;
  7054. } catch (error) {
  7055. throwError(error, 'Indiedb.checkLogin');
  7056. return false;
  7057. }
  7058. }
  7059. async #checkLeftKey() {
  7060. try {
  7061. if (!globalOptions.other.checkLeftKey) {
  7062. return true;
  7063. }
  7064. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7065. await external_Swal_default().fire({
  7066. icon: 'warning',
  7067. title: i18n('notice'),
  7068. text: i18n('giveawayEnded'),
  7069. confirmButtonText: i18n('confirm'),
  7070. cancelButtonText: i18n('cancel'),
  7071. showCancelButton: true
  7072. }).then(_ref => {
  7073. let {
  7074. value
  7075. } = _ref;
  7076. if (value) {
  7077. window.close();
  7078. }
  7079. });
  7080. }
  7081. return true;
  7082. } catch (error) {
  7083. throwError(error, 'Indiedb.checkLeftKey');
  7084. return false;
  7085. }
  7086. }
  7087. }
  7088. const website_Indiedb = Indiedb;
  7089. const Keyhub_defaultTasksTemplate = {
  7090. steam: {
  7091. groupLinks: [],
  7092. officialGroupLinks: [],
  7093. wishlistLinks: [],
  7094. curatorLinks: []
  7095. },
  7096. discord: {
  7097. serverLinks: []
  7098. },
  7099. extra: {
  7100. videoTasks: []
  7101. },
  7102. links: []
  7103. };
  7104. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7105. class Keyhub extends website_Website {
  7106. name = 'Keyhub';
  7107. socialTasks = JSON.parse(Keyhub_defaultTasks);
  7108. undoneTasks = JSON.parse(Keyhub_defaultTasks);
  7109. buttons = [ 'doTask', 'undoTask' ];
  7110. static test() {
  7111. return window.location.host === 'key-hub.eu';
  7112. }
  7113. async after() {
  7114. try {
  7115. if (!this.#checkLogin()) {
  7116. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7117. }
  7118. if (!await this.#checkLeftKey()) {
  7119. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7120. }
  7121. $('.NSFW').hide();
  7122. } catch (error) {
  7123. throwError(error, 'Keyhub.after');
  7124. }
  7125. }
  7126. init() {
  7127. try {
  7128. const logStatus = scripts_echoLog({
  7129. text: i18n('initing')
  7130. });
  7131. if ($('a[href*="/connect/steam"]').length > 0) {
  7132. window.open('/connect/steam', '_self');
  7133. logStatus.warning(i18n('needLogin'));
  7134. return false;
  7135. }
  7136. if (!this.#getGiveawayId()) {
  7137. return false;
  7138. }
  7139. $('#VPNoverlay').hide();
  7140. $('#mainArticleSection').show();
  7141. this.initialized = true;
  7142. logStatus.success();
  7143. return true;
  7144. } catch (error) {
  7145. throwError(error, 'Keyhub.init');
  7146. return false;
  7147. }
  7148. }
  7149. async classifyTask(action) {
  7150. try {
  7151. const logStatus = scripts_echoLog({
  7152. text: i18n('getTasksInfo')
  7153. });
  7154. if (action === 'undo') {
  7155. var _GM_getValue;
  7156. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7157. }
  7158. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7159. for (const task of tasks) {
  7160. let link = $(task).attr('href');
  7161. const taskDes = $(task).text().trim();
  7162. if (!link) {
  7163. continue;
  7164. }
  7165. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7166. link = await getRedirectLink(link) || link;
  7167. }
  7168. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7169. window.open(link, '_blank');
  7170. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7171. if (action === 'undo') {
  7172. this.socialTasks.steam.groupLinks.push(link);
  7173. }
  7174. if (action === 'do') {
  7175. this.undoneTasks.steam.groupLinks.push(link);
  7176. }
  7177. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7178. if (action === 'undo') {
  7179. this.socialTasks.steam.officialGroupLinks.push(link);
  7180. }
  7181. if (action === 'do') {
  7182. this.undoneTasks.steam.officialGroupLinks.push(link);
  7183. }
  7184. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7185. if (action === 'undo') {
  7186. this.socialTasks.steam.wishlistLinks.push(link);
  7187. }
  7188. if (action === 'do') {
  7189. this.undoneTasks.steam.wishlistLinks.push(link);
  7190. }
  7191. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7192. if (action === 'undo') {
  7193. this.socialTasks.steam.curatorLinks.push(link);
  7194. }
  7195. if (action === 'do') {
  7196. this.undoneTasks.steam.curatorLinks.push(link);
  7197. }
  7198. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7199. if (action === 'undo') {
  7200. this.socialTasks.discord.serverLinks.push(link);
  7201. }
  7202. if (action === 'do') {
  7203. this.undoneTasks.discord.serverLinks.push(link);
  7204. }
  7205. } else if (/^javascript:videoTask.+/.test(link)) {
  7206. if (action === 'do') {
  7207. var _link$match;
  7208. const taskData = (_link$match = link.match(/javascript:videoTask\('.+?','(.+?)'/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  7209. if (taskData) {
  7210. this.undoneTasks.extra.videoTasks.push(taskData);
  7211. }
  7212. }
  7213. } else if (/^https?:\/\/www\.instagram\.com\/.*/.test(link) || /^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link) || /^https?:\/\/www\.facebook\.com\/.*/.test(link) || /^https?:\/\/www\.youtube\.com\/.*/.test(link) || /^https?:\/\/store\.steampowered\.com\/developer\//.test(link) || /^https?:\/\/.*?\.itch\.io\/.*/.test(link) || /^https?:\/\/key-hub\.eu.*/.test(link) || /^https?:\/\/store\.steampowered\.com\/app\/.*/.test(link) || /^https?:\/\/qr\.streamelements\.com\/.*/.test(link) || /^https?:\/\/store\.steampowered\.com\/news\/app\/.*/.test(link)) {} else {
  7214. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7215. }
  7216. }
  7217. logStatus.success();
  7218. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7219. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7220. if (window.DEBUG) {
  7221. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7222. }
  7223. GM_setValue(`khTasks-${this.giveawayId}`, {
  7224. tasks: this.socialTasks,
  7225. time: new Date().getTime()
  7226. });
  7227. return true;
  7228. } catch (error) {
  7229. throwError(error, 'Keyhub.classifyTask');
  7230. return false;
  7231. }
  7232. }
  7233. async #doScriptTask(data) {
  7234. try {
  7235. const logStatus = scripts_echoLog({
  7236. text: i18n('doingKeyhubTask')
  7237. });
  7238. const {
  7239. result,
  7240. statusText,
  7241. status,
  7242. data: response
  7243. } = await tools_httpRequest({
  7244. url: `/away?data=${data}`,
  7245. method: 'GET',
  7246. headers: {
  7247. origin: 'https://key-hub.eu',
  7248. referer: 'https://key-hub.eu/'
  7249. }
  7250. });
  7251. if (result === 'Success') {
  7252. if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
  7253. logStatus.success();
  7254. return true;
  7255. }
  7256. logStatus.error(`Error:${response === null || response === void 0 ? void 0 : response.statusText}(${response === null || response === void 0 ? void 0 : response.status})`);
  7257. return false;
  7258. }
  7259. logStatus.error(`${result}:${statusText}(${status})`);
  7260. return false;
  7261. } catch (error) {
  7262. throwError(error, 'Keyhub.doScriptTask');
  7263. return false;
  7264. }
  7265. }
  7266. async extraDoTask(_ref) {
  7267. let {
  7268. videoTasks
  7269. } = _ref;
  7270. try {
  7271. const pro = [];
  7272. for (const data of videoTasks) {
  7273. pro.push(this.#doScriptTask(data));
  7274. }
  7275. return Promise.all(pro).then(() => true);
  7276. } catch (error) {
  7277. throwError(error, 'Keyhub.extraDoTask');
  7278. return false;
  7279. }
  7280. }
  7281. #getGiveawayId() {
  7282. try {
  7283. var _window$location$href;
  7284. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7285. if (giveawayId) {
  7286. this.giveawayId = giveawayId;
  7287. return true;
  7288. }
  7289. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7290. return false;
  7291. } catch (error) {
  7292. throwError(error, 'Keyhub.getGiveawayId');
  7293. return false;
  7294. }
  7295. }
  7296. async #checkLeftKey() {
  7297. try {
  7298. if (!globalOptions.other.checkLeftKey) {
  7299. return true;
  7300. }
  7301. const leftKey = $('#keysleft').text().trim();
  7302. if (leftKey === '0') {
  7303. await external_Swal_default().fire({
  7304. icon: 'warning',
  7305. title: i18n('notice'),
  7306. text: i18n('noKeysLeft'),
  7307. confirmButtonText: i18n('confirm'),
  7308. cancelButtonText: i18n('cancel'),
  7309. showCancelButton: true
  7310. }).then(_ref2 => {
  7311. let {
  7312. value
  7313. } = _ref2;
  7314. if (value) {
  7315. window.close();
  7316. }
  7317. });
  7318. }
  7319. return true;
  7320. } catch (error) {
  7321. throwError(error, 'Keyhub.checkLeftKey');
  7322. return false;
  7323. }
  7324. }
  7325. #checkLogin() {
  7326. try {
  7327. if (!globalOptions.other.checkLogin) {
  7328. return true;
  7329. }
  7330. if ($('a[href*="/connect/steam"]').length > 0) {
  7331. window.open('/connect/steam', '_self');
  7332. }
  7333. return true;
  7334. } catch (error) {
  7335. throwError(error, 'Keyhub.checkLogin');
  7336. return false;
  7337. }
  7338. }
  7339. }
  7340. const website_Keyhub = Keyhub;
  7341. const Givekey_defaultTasksTemplate = {
  7342. steam: {
  7343. groupLinks: [],
  7344. wishlistLinks: [],
  7345. curatorLinks: [],
  7346. curatorLikeLinks: []
  7347. },
  7348. twitter: {
  7349. userLinks: []
  7350. },
  7351. vk: {
  7352. nameLinks: []
  7353. },
  7354. discord: {
  7355. serverLinks: []
  7356. }
  7357. };
  7358. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  7359. class Givekey extends website_Website {
  7360. name = 'Givekey';
  7361. tasks = [];
  7362. socialTasks = JSON.parse(Givekey_defaultTasks);
  7363. undoneTasks = JSON.parse(Givekey_defaultTasks);
  7364. userId;
  7365. buttons = [ 'doTask', 'undoTask', 'verifyTask' ];
  7366. static test() {
  7367. return window.location.host === 'givekey.ru';
  7368. }
  7369. async after() {
  7370. try {
  7371. await new Promise(resolve => {
  7372. const checker = setInterval(() => {
  7373. if ($('#navbarDropdown').length > 0) {
  7374. clearInterval(checker);
  7375. resolve(true);
  7376. }
  7377. });
  7378. });
  7379. if (!await this.#checkLeftKey()) {
  7380. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7381. }
  7382. } catch (error) {
  7383. throwError(error, 'Givekey.after');
  7384. return false;
  7385. }
  7386. }
  7387. init() {
  7388. try {
  7389. const logStatus = scripts_echoLog({
  7390. text: i18n('initing')
  7391. });
  7392. if ($('a[href*="/auth/steam"]').length > 0) {
  7393. window.open('/auth/steam', '_self');
  7394. logStatus.warning(i18n('needLogin'));
  7395. return false;
  7396. }
  7397. if (!this.#getGiveawayId()) {
  7398. return false;
  7399. }
  7400. const userId = $('meta[name="user-id"]').attr('content');
  7401. if (!userId) {
  7402. logStatus.error(i18n('getFailed', i18n('userId')));
  7403. return false;
  7404. }
  7405. this.userId = userId;
  7406. this.initialized = true;
  7407. logStatus.success();
  7408. return true;
  7409. } catch (error) {
  7410. throwError(error, 'Givekey.init');
  7411. return false;
  7412. }
  7413. }
  7414. async classifyTask(action) {
  7415. try {
  7416. const logStatus = scripts_echoLog({
  7417. text: i18n('getTasksInfo')
  7418. });
  7419. if (action === 'undo') {
  7420. var _GM_getValue;
  7421. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  7422. }
  7423. const tasks = $('.card-body:has("button") .row');
  7424. for (const task of tasks) {
  7425. const taskEle = $(task);
  7426. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7427. if (isSuccess && action !== 'undo') {
  7428. continue;
  7429. }
  7430. const checkButton = taskEle.find('#task_check');
  7431. const taskId = checkButton.attr('data-id');
  7432. if (taskId) {
  7433. this.tasks.push(taskId);
  7434. }
  7435. if (action === 'verify') {
  7436. continue;
  7437. }
  7438. let href = taskEle.find('a').attr('href') || null;
  7439. const text = taskEle.find('a').text().trim();
  7440. const icon = taskEle.find('i');
  7441. if (!href || !text) {
  7442. continue;
  7443. }
  7444. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7445. href = await getRedirectLink(href);
  7446. }
  7447. if (!href) {
  7448. continue;
  7449. }
  7450. if (/^https?:\/\/vk\.com\//.test(href)) {
  7451. this.socialTasks.vk.nameLinks.push(href);
  7452. if (action === 'do' && !isSuccess) {
  7453. this.undoneTasks.vk.nameLinks.push(href);
  7454. }
  7455. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7456. this.socialTasks.steam.groupLinks.push(href);
  7457. if (action === 'do' && !isSuccess) {
  7458. this.undoneTasks.steam.groupLinks.push(href);
  7459. }
  7460. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7461. this.socialTasks.steam.wishlistLinks.push(href);
  7462. if (action === 'do' && !isSuccess) {
  7463. this.undoneTasks.steam.wishlistLinks.push(href);
  7464. }
  7465. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7466. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7467. this.socialTasks.steam.curatorLinks.push(href);
  7468. if (action === 'do' && !isSuccess) {
  7469. this.undoneTasks.steam.curatorLinks.push(href);
  7470. }
  7471. } else {
  7472. this.socialTasks.steam.curatorLikeLinks.push(href);
  7473. if (action === 'do' && !isSuccess) {
  7474. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7475. }
  7476. }
  7477. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7478. this.socialTasks.twitter.userLinks.push(href);
  7479. if (action === 'do' && !isSuccess) {
  7480. this.undoneTasks.twitter.userLinks.push(href);
  7481. }
  7482. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  7483. this.socialTasks.discord.serverLinks.push(href);
  7484. if (action === 'do' && !isSuccess) {
  7485. this.undoneTasks.discord.serverLinks.push(href);
  7486. }
  7487. } else {
  7488. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7489. }
  7490. }
  7491. logStatus.success();
  7492. this.tasks = unique(this.tasks);
  7493. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7494. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7495. if (window.DEBUG) {
  7496. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7497. }
  7498. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7499. tasks: this.socialTasks,
  7500. time: new Date().getTime()
  7501. });
  7502. return true;
  7503. } catch (error) {
  7504. throwError(error, 'Givekey.classifyTask');
  7505. return false;
  7506. }
  7507. }
  7508. async verifyTask() {
  7509. try {
  7510. if (!this.initialized && !this.init()) {
  7511. return false;
  7512. }
  7513. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7514. return false;
  7515. }
  7516. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7517. const taskLength = this.tasks.length;
  7518. for (let i = 0; i < taskLength; i++) {
  7519. await this.#verify(this.tasks[i]);
  7520. if (i < taskLength - 1) {
  7521. await delay(15e3);
  7522. }
  7523. }
  7524. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7525. scripts_echoLog({
  7526. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7527. });
  7528. return true;
  7529. } catch (error) {
  7530. throwError(error, 'Givekey.verifyTask');
  7531. return false;
  7532. }
  7533. }
  7534. async #verify(task) {
  7535. try {
  7536. const logStatus = scripts_echoLog({
  7537. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7538. });
  7539. return await new Promise(resolve => {
  7540. $.ajax({
  7541. url: 'https://givekey.ru/giveaway/task',
  7542. method: 'POST',
  7543. data: `id=${task}&user_id=${this.userId}`,
  7544. dataType: 'json',
  7545. headers: {
  7546. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7547. },
  7548. success: data => {
  7549. if (data.btn) {
  7550. $(`button[data-id=${this.userId}]`).html(data.btn);
  7551. }
  7552. if (data.status === 'ok') {
  7553. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7554. logStatus.success();
  7555. resolve(true);
  7556. } else if (data.status === 'end') {
  7557. logStatus.success();
  7558. scripts_echoLog({}).success(data.key);
  7559. resolve(true);
  7560. } else {
  7561. logStatus.error(`Error:${data.msg}`);
  7562. resolve(false);
  7563. }
  7564. },
  7565. error: xhr => {
  7566. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7567. resolve(false);
  7568. }
  7569. });
  7570. });
  7571. } catch (error) {
  7572. throwError(error, 'Givekey.verify');
  7573. return false;
  7574. }
  7575. }
  7576. #getGiveawayId() {
  7577. try {
  7578. var _window$location$href;
  7579. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7580. if (giveawayId) {
  7581. this.giveawayId = giveawayId;
  7582. return true;
  7583. }
  7584. scripts_echoLog({
  7585. text: i18n('getFailed', 'GiveawayId')
  7586. });
  7587. return false;
  7588. } catch (error) {
  7589. throwError(error, 'Givekey.getGiveawayId');
  7590. return false;
  7591. }
  7592. }
  7593. async #checkLeftKey() {
  7594. try {
  7595. if (!globalOptions.other.checkLeftKey) {
  7596. return true;
  7597. }
  7598. if (!$('#keys_count').text()) {
  7599. await external_Swal_default().fire({
  7600. icon: 'warning',
  7601. title: i18n('notice'),
  7602. text: i18n('noKeysLeft'),
  7603. confirmButtonText: i18n('confirm'),
  7604. cancelButtonText: i18n('cancel'),
  7605. showCancelButton: true
  7606. }).then(_ref => {
  7607. let {
  7608. value
  7609. } = _ref;
  7610. if (value) {
  7611. window.close();
  7612. }
  7613. });
  7614. }
  7615. return true;
  7616. } catch (error) {
  7617. throwError(error, 'Givekey.checkLeftKey');
  7618. return false;
  7619. }
  7620. }
  7621. }
  7622. const website_Givekey = Givekey;
  7623. class GiveeClub extends GiveawaySu {
  7624. name = 'GiveeClub';
  7625. buttons = [ 'doTask', 'undoTask', 'verifyTask' ];
  7626. static test() {
  7627. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7628. }
  7629. async after() {
  7630. try {
  7631. if (!this.#checkLogin()) {
  7632. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7633. }
  7634. if (!await this.#checkLeftKey()) {
  7635. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7636. }
  7637. } catch (error) {
  7638. throwError(error, 'GiveeClub.after');
  7639. }
  7640. }
  7641. init() {
  7642. try {
  7643. const logStatus = scripts_echoLog({
  7644. text: i18n('initing')
  7645. });
  7646. if (!this.#checkLogin()) {
  7647. logStatus.warning(i18n('needLogin'));
  7648. return false;
  7649. }
  7650. if (!this.#getGiveawayId()) {
  7651. return false;
  7652. }
  7653. this.initialized = true;
  7654. logStatus.success();
  7655. return true;
  7656. } catch (error) {
  7657. throwError(error, 'GiveeClub.init');
  7658. return false;
  7659. }
  7660. }
  7661. async classifyTask(action) {
  7662. try {
  7663. const logStatus = scripts_echoLog({
  7664. text: i18n('getTasksInfo')
  7665. });
  7666. if (action === 'undo') {
  7667. var _GM_getValue;
  7668. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7669. return true;
  7670. }
  7671. const pro = [];
  7672. const tasks = $('.event-actions tr');
  7673. for (const task of tasks) {
  7674. pro.push(new Promise(resolve => {
  7675. var _$$find, _$$find2;
  7676. const taskDes = $(task).find('.event-action-label a');
  7677. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7678. const taskName = taskDes.text().trim();
  7679. const taskType = (_$$find = $(task).find('button[data-type]')) === null || _$$find === void 0 ? void 0 : _$$find.attr('data-type');
  7680. const taskFinished = (_$$find2 = $(task).find('.event-action-buttons .btn-success')) === null || _$$find2 === void 0 ? void 0 : _$$find2.length;
  7681. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope') || taskFinished) {
  7682. return resolve(true);
  7683. }
  7684. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7685. if (!taskLink) {
  7686. return resolve(false);
  7687. }
  7688. if (taskType === 'steam.group.join' && /^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7689. this.undoneTasks.steam.groupLinks.push(taskLink);
  7690. } else if (/like.*announcement/gi.test(taskName)) {
  7691. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7692. } else if (taskType === 'steam.game.wishlist' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7693. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7694. } else if (taskType === 'steam.game.wishlist' && taskDes.attr('data-steam-wishlist-appid')) {
  7695. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  7696. } else if (taskType === 'steam.game.follow' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7697. this.undoneTasks.steam.followLinks.push(taskLink);
  7698. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7699. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7700. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7701. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7702. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7703. this.undoneTasks.steam.forumLinks.push(taskLink);
  7704. } else if (taskIcon.includes('discord')) {
  7705. this.undoneTasks.discord.serverLinks.push(taskLink);
  7706. } else if (taskIcon.includes('instagram')) {
  7707. this.undoneTasks.instagram.userLinks.push(taskLink);
  7708. } else if (taskIcon.includes('twitch')) {
  7709. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7710. } else if (taskIcon.includes('reddit')) {
  7711. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7712. } else if (/watch.*art/gim.test(taskName)) {
  7713. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7714. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7715. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7716. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7717. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7718. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7719. this.undoneTasks.vk.nameLinks.push(taskLink);
  7720. } else if (taskIcon.includes('twitter')) {
  7721. if (/https?:\/\/twitter\.com\/[^/]+\/?$/gim.test(taskLink)) {
  7722. this.undoneTasks.twitter.userLinks.push(taskLink);
  7723. } else if (/https?:\/\/twitter\.com\/[^/]+?\/status\/[\d]+/gim.test(taskLink)) {
  7724. this.undoneTasks.twitter.retweetLinks.push(taskLink);
  7725. }
  7726. } else {
  7727. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7728. if (/follow.*button/gim.test(taskName)) {
  7729. this.undoneTasks.steam.followLinks.push(taskLink);
  7730. }
  7731. }
  7732. }
  7733. resolve(true);
  7734. }).catch(error => {
  7735. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7736. return false;
  7737. });
  7738. }));
  7739. }
  7740. await Promise.all(pro);
  7741. logStatus.success();
  7742. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7743. this.socialTasks = this.undoneTasks;
  7744. if (window.DEBUG) {
  7745. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7746. }
  7747. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7748. tasks: this.socialTasks,
  7749. time: new Date().getTime()
  7750. });
  7751. return true;
  7752. } catch (error) {
  7753. throwError(error, 'GiveeClub.classifyTask');
  7754. return false;
  7755. }
  7756. }
  7757. async verifyTask() {
  7758. try {
  7759. const logStatus = scripts_echoLog({
  7760. text: i18n('giveeClubVerifyNotice')
  7761. });
  7762. const taskButtons = $('.event-actions tr button').has('i.glyphicon-refresh').not('[data-type="user.adblock"]');
  7763. for (const button of taskButtons) {
  7764. button.click();
  7765. if ($(button).attr('data-type') !== 'steam.game.wishlist') {
  7766. await delay(1e3);
  7767. }
  7768. }
  7769. logStatus.warning(i18n('giveeClubVerifyFinished'));
  7770. return true;
  7771. } catch (error) {
  7772. throwError(error, 'Givekey.verifyTask');
  7773. return false;
  7774. }
  7775. }
  7776. #checkLogin() {
  7777. try {
  7778. if (!globalOptions.other.checkLogin) {
  7779. return true;
  7780. }
  7781. if ($('a[href*="/account/auth"]').length > 0) {
  7782. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  7783. }
  7784. return true;
  7785. } catch (error) {
  7786. throwError(error, 'GiveeClub.checkLogin');
  7787. return false;
  7788. }
  7789. }
  7790. #getGiveawayId() {
  7791. var _window$location$href;
  7792. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7793. if (giveawayId) {
  7794. this.giveawayId = giveawayId;
  7795. return true;
  7796. }
  7797. scripts_echoLog({
  7798. text: i18n('getFailed', 'GiveawayId')
  7799. });
  7800. return false;
  7801. }
  7802. async #checkLeftKey() {
  7803. try {
  7804. if (!globalOptions.other.checkLeftKey) {
  7805. return true;
  7806. }
  7807. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  7808. await external_Swal_default().fire({
  7809. icon: 'warning',
  7810. title: i18n('notice'),
  7811. text: i18n('giveawayEnded'),
  7812. confirmButtonText: i18n('confirm'),
  7813. cancelButtonText: i18n('cancel'),
  7814. showCancelButton: true
  7815. }).then(_ref => {
  7816. let {
  7817. value
  7818. } = _ref;
  7819. if (value) {
  7820. window.close();
  7821. }
  7822. });
  7823. }
  7824. return true;
  7825. } catch (error) {
  7826. throwError(error, 'Giveawaysu.checkLeftKey');
  7827. return false;
  7828. }
  7829. }
  7830. }
  7831. const website_GiveeClub = GiveeClub;
  7832. const defaultOptions = {
  7833. maxPoint: '99999999'
  7834. };
  7835. class OpiumPulses {
  7836. name = 'OpiumPulses';
  7837. options = {
  7838. ...defaultOptions,
  7839. ...GM_getValue('OpiumPulsesOptions')
  7840. };
  7841. maxPoints = 99999999;
  7842. myPoints = 0;
  7843. buttons = [ 'doFreeTask', 'doPointTask' ];
  7844. static test() {
  7845. return window.location.host === 'www.opiumpulses.com';
  7846. }
  7847. async after() {
  7848. try {
  7849. if (!this.#checkLogin()) {
  7850. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7851. }
  7852. this.maxPoints = parseInt(this.options.maxPoint, 10);
  7853. } catch (error) {
  7854. throwError(error, 'OpiumPulses.after');
  7855. }
  7856. }
  7857. async doFreeTask() {
  7858. try {
  7859. this.#toggleTask('FREE');
  7860. } catch (error) {
  7861. throwError(error, 'OpiumPulses.doFreeTask');
  7862. }
  7863. }
  7864. async doPointTask() {
  7865. try {
  7866. var _$$text$match;
  7867. this.myPoints = parseInt(((_$$text$match = $('.page-header__nav-func-user-nav-items.points-items').text().match(/[\d]+/gim)) === null || _$$text$match === void 0 ? void 0 : _$$text$match[0]) || '0', 10);
  7868. this.#toggleTask('points');
  7869. } catch (error) {
  7870. throwError(error, 'OpiumPulses.doPointTask');
  7871. }
  7872. }
  7873. async #toggleTask(type) {
  7874. try {
  7875. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  7876. for (const item of items) {
  7877. var _$$find$text$match;
  7878. const needPoints = parseInt(((_$$find$text$match = $(item).find('.giveaways-page-item-header-points').text().match(/[\d]+/gim)) === null || _$$find$text$match === void 0 ? void 0 : _$$find$text$match[0]) || '999999', 10);
  7879. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  7880. if (type === 'points' && needPoints > this.myPoints) {
  7881. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  7882. } else if (type === 'points' && !needPoints) {
  7883. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  7884. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  7885. var _aElement$attr;
  7886. const logStatus = scripts_echoLog({
  7887. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  7888. });
  7889. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  7890. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  7891. var _aElement$attr2, _aElement$attr2$match;
  7892. const giveawayId = (_aElement$attr2 = aElement.attr('onclick')) === null || _aElement$attr2 === void 0 ? void 0 : (_aElement$attr2$match = _aElement$attr2.match(/[\d]+/)) === null || _aElement$attr2$match === void 0 ? void 0 : _aElement$attr2$match[0];
  7893. if (giveawayId) {
  7894. checkUser(giveawayId);
  7895. }
  7896. }
  7897. if (!aElement.attr('href')) {
  7898. logStatus.error('Error: No "href".');
  7899. continue;
  7900. }
  7901. const {
  7902. result,
  7903. statusText,
  7904. status,
  7905. data
  7906. } = await tools_httpRequest({
  7907. url: aElement.attr('href'),
  7908. method: 'GET'
  7909. });
  7910. if (result === 'Success') {
  7911. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  7912. var _data$responseText$ma;
  7913. logStatus.success();
  7914. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  7915. if (type === 'points' && points) {
  7916. this.myPoints = parseInt(points, 10);
  7917. }
  7918. } else {
  7919. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7920. }
  7921. } else {
  7922. logStatus.error(`${result}:${statusText}(${status})`);
  7923. }
  7924. }
  7925. }
  7926. scripts_echoLog({
  7927. text: '-----END-----'
  7928. });
  7929. } catch (error) {
  7930. throwError(error, 'OpiumPulses.toggleTask');
  7931. }
  7932. }
  7933. init() {
  7934. return true;
  7935. }
  7936. classifyTask() {
  7937. return true;
  7938. }
  7939. #checkLogin() {
  7940. try {
  7941. if (!globalOptions.other.checkLogin) {
  7942. return true;
  7943. }
  7944. if ($('a[href*="/site/login"]').length > 1) {
  7945. window.open('/site/login', '_self');
  7946. }
  7947. return true;
  7948. } catch (error) {
  7949. throwError(error, 'OpiumPulses.checkLogin');
  7950. return false;
  7951. }
  7952. }
  7953. }
  7954. const website_OpiumPulses = OpiumPulses;
  7955. const external_dayjs_namespaceObject = dayjs;
  7956. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  7957. const leftKeyChecker = {
  7958. async classify(link) {
  7959. try {
  7960. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  7961. return await this.giveawaySu(link);
  7962. }
  7963. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  7964. return await this.giveeClub(link);
  7965. }
  7966. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  7967. return await this.gleam(link);
  7968. }
  7969. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  7970. return await this.indieDb(link);
  7971. }
  7972. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  7973. return await this.keyhub(link);
  7974. }
  7975. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  7976. return await this.opquests(link);
  7977. }
  7978. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  7979. return await this.itch(link);
  7980. }
  7981. return false;
  7982. } catch (error) {
  7983. throwError(error, 'leftKeyChecker.classify');
  7984. return false;
  7985. }
  7986. },
  7987. async giveawaySu(link) {
  7988. try {
  7989. const {
  7990. result,
  7991. data
  7992. } = await tools_httpRequest({
  7993. url: link,
  7994. method: 'GET'
  7995. });
  7996. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  7997. if (data.responseText.includes('class="steam-login"')) {
  7998. return false;
  7999. }
  8000. if (data.responseText.includes('class="giveaway-ended"')) {
  8001. return 'Ended';
  8002. }
  8003. return 'Active';
  8004. }
  8005. return false;
  8006. } catch (error) {
  8007. throwError(error, 'leftKeyChecker.giveawaySu');
  8008. return false;
  8009. }
  8010. },
  8011. async giveeClub(link) {
  8012. try {
  8013. const {
  8014. result,
  8015. data
  8016. } = await tools_httpRequest({
  8017. url: link,
  8018. method: 'GET'
  8019. });
  8020. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8021. if (data.responseText.includes('class="event-winner"')) {
  8022. return 'Won';
  8023. }
  8024. if (data.responseText.includes('class="event-ended"')) {
  8025. return 'Ended';
  8026. }
  8027. return 'Active';
  8028. }
  8029. return false;
  8030. } catch (error) {
  8031. throwError(error, 'leftKeyChecker.giveeClub');
  8032. return false;
  8033. }
  8034. },
  8035. async gleam(link) {
  8036. try {
  8037. const {
  8038. result,
  8039. data
  8040. } = await tools_httpRequest({
  8041. url: link,
  8042. method: 'GET'
  8043. });
  8044. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8045. var _data$responseText$ma, _$$attr, _$$attr$match;
  8046. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8047. return 'Won';
  8048. }
  8049. const campaignDiv = (_data$responseText$ma = data.responseText.match(/<div class='popup-blocks-container'[\w\W]+?'>/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[0];
  8050. if (!campaignDiv) {
  8051. return false;
  8052. }
  8053. const campaignString = (_$$attr = $(campaignDiv).attr('ng-init')) === null || _$$attr === void 0 ? void 0 : (_$$attr$match = _$$attr.match(/initCampaign\(([\w\W]+?)\)$/)) === null || _$$attr$match === void 0 ? void 0 : _$$attr$match[1];
  8054. if (!campaignString) {
  8055. return false;
  8056. }
  8057. const {
  8058. campaign
  8059. } = JSON.parse(campaignString);
  8060. if (campaign.banned) {
  8061. return 'Banned';
  8062. }
  8063. if (campaign.finished) {
  8064. return 'Ended';
  8065. }
  8066. if (campaign.paused) {
  8067. return 'Paused';
  8068. }
  8069. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8070. return 'NotStart';
  8071. }
  8072. return 'Active';
  8073. }
  8074. return false;
  8075. } catch (error) {
  8076. throwError(error, 'leftKeyChecker.gleam');
  8077. return false;
  8078. }
  8079. },
  8080. async indieDb(link) {
  8081. try {
  8082. const {
  8083. result,
  8084. data
  8085. } = await tools_httpRequest({
  8086. url: link,
  8087. method: 'GET'
  8088. });
  8089. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8090. if (data.responseText.includes('Congrats you WON')) {
  8091. return 'Won';
  8092. }
  8093. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8094. return 'Ended';
  8095. }
  8096. return 'Active';
  8097. }
  8098. return false;
  8099. } catch (error) {
  8100. throwError(error, 'leftKeyChecker.indieDb');
  8101. return false;
  8102. }
  8103. },
  8104. async keyhub(link) {
  8105. try {
  8106. const {
  8107. result,
  8108. data
  8109. } = await tools_httpRequest({
  8110. url: link,
  8111. method: 'GET'
  8112. });
  8113. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8114. var _data$responseText$ma2;
  8115. const keysleft = (_data$responseText$ma2 = data.responseText.match(/<span id="keysleft">([\d]+?)<\/span>/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  8116. if (!keysleft) {
  8117. return false;
  8118. }
  8119. if (keysleft === '0') {
  8120. return 'Ended';
  8121. }
  8122. return `Active(${keysleft})`;
  8123. }
  8124. return false;
  8125. } catch (error) {
  8126. throwError(error, 'leftKeyChecker.keyhub');
  8127. return false;
  8128. }
  8129. },
  8130. async opquests(link) {
  8131. try {
  8132. const {
  8133. result,
  8134. data
  8135. } = await tools_httpRequest({
  8136. url: link,
  8137. method: 'GET'
  8138. });
  8139. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8140. var _data$responseText$ma3;
  8141. const keysleft = (_data$responseText$ma3 = data.responseText.match(/<div class="">[\s]*?([\d]+?)[\s]*?of/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  8142. if (!keysleft) {
  8143. return false;
  8144. }
  8145. if (keysleft === '0') {
  8146. return 'Ended';
  8147. }
  8148. return `Active(${keysleft})`;
  8149. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8150. return 'Ended';
  8151. }
  8152. return false;
  8153. } catch (error) {
  8154. throwError(error, 'leftKeyChecker.opquests');
  8155. return false;
  8156. }
  8157. },
  8158. async itch(link) {
  8159. try {
  8160. const {
  8161. result,
  8162. data
  8163. } = await tools_httpRequest({
  8164. url: link,
  8165. method: 'GET'
  8166. });
  8167. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8168. var _data$responseText$ma4;
  8169. const endDate = (_data$responseText$ma4 = data.responseText.match(/{"start_date":"[0-9A-Z-:]+?".*?"end_date":"([0-9A-Z-:]+?)".*?}/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  8170. if (!endDate) {
  8171. return false;
  8172. }
  8173. if (new Date().getTime() > new Date(endDate).getTime()) {
  8174. return 'Ended';
  8175. }
  8176. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8177. }
  8178. return false;
  8179. } catch (error) {
  8180. throwError(error, 'leftKeyChecker.opquests');
  8181. return false;
  8182. }
  8183. }
  8184. };
  8185. const website_leftKeyChecker = leftKeyChecker;
  8186. const Keylol_defaultTasksTemplate = {
  8187. steam: {
  8188. groupLinks: [],
  8189. wishlistLinks: [],
  8190. curatorLinks: [],
  8191. curatorLikeLinks: [],
  8192. followLinks: [],
  8193. forumLinks: [],
  8194. announcementLinks: [],
  8195. workshopVoteLinks: [],
  8196. licenseLinks: []
  8197. },
  8198. discord: {
  8199. serverLinks: []
  8200. },
  8201. instagram: {
  8202. userLinks: []
  8203. },
  8204. vk: {
  8205. nameLinks: []
  8206. },
  8207. twitch: {
  8208. channelLinks: []
  8209. },
  8210. reddit: {
  8211. redditLinks: []
  8212. },
  8213. twitter: {
  8214. userLinks: [],
  8215. retweetLinks: []
  8216. },
  8217. youtube: {
  8218. channelLinks: [],
  8219. likeLinks: []
  8220. }
  8221. };
  8222. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  8223. class Keylol extends website_Website {
  8224. name = 'Keylol';
  8225. socialTasks = JSON.parse(Keylol_defaultTasks);
  8226. undoneTasks = JSON.parse(Keylol_defaultTasks);
  8227. buttons = [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ];
  8228. static test() {
  8229. var _$$eq$attr, _$$eq$attr2;
  8230. return window.location.host === 'keylol.com' && (!!((_$$eq$attr = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr !== void 0 && _$$eq$attr.includes('319')) || !!((_$$eq$attr2 = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr2 !== void 0 && _$$eq$attr2.includes('234')));
  8231. }
  8232. init() {
  8233. return true;
  8234. }
  8235. after() {
  8236. try {
  8237. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8238. const mainPost = $(selector);
  8239. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  8240. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  8241. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  8242. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  8243. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  8244. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  8245. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  8246. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  8247. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  8248. if (discordLinks.length > 0) {
  8249. for (const discordLink of discordLinks) {
  8250. const link = $(discordLink).attr('href');
  8251. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8252. continue;
  8253. }
  8254. this.#addBtn(discordLink, 'discord', 'serverLinks', link);
  8255. }
  8256. }
  8257. if (redditLinks.length > 0) {
  8258. for (const redditLink of redditLinks) {
  8259. const link = $(redditLink).attr('href');
  8260. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8261. continue;
  8262. }
  8263. this.#addBtn(redditLink, 'reddit', 'redditLinks', link);
  8264. }
  8265. }
  8266. if (insLinks.length > 0) {
  8267. for (const insLink of insLinks) {
  8268. const link = $(insLink).attr('href');
  8269. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8270. continue;
  8271. }
  8272. this.#addBtn(insLink, 'instagram', 'userLinks', link);
  8273. }
  8274. }
  8275. if (twitterLinks.length > 0) {
  8276. for (const twitterLink of twitterLinks) {
  8277. const link = $(twitterLink).attr('href');
  8278. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8279. continue;
  8280. }
  8281. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8282. this.#addBtn(twitterLink, 'twitter', 'retweetLinks', link);
  8283. } else {
  8284. this.#addBtn(twitterLink, 'twitter', 'userLinks', link);
  8285. }
  8286. }
  8287. }
  8288. if (twitchLinks.length > 0) {
  8289. for (const twitchLink of twitchLinks) {
  8290. const link = $(twitchLink).attr('href');
  8291. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8292. continue;
  8293. }
  8294. this.#addBtn(twitchLink, 'twitch', 'channelLinks', link);
  8295. }
  8296. }
  8297. if (vkLinks.length > 0) {
  8298. for (const vkLink of vkLinks) {
  8299. const link = $(vkLink).attr('href');
  8300. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8301. continue;
  8302. }
  8303. this.#addBtn(vkLink, 'vk', 'nameLinks', link);
  8304. }
  8305. }
  8306. if (steamStoreLinks.length > 0) {
  8307. for (const steamStoreLink of steamStoreLinks) {
  8308. const link = $(steamStoreLink).attr('href');
  8309. if (!link) {
  8310. continue;
  8311. }
  8312. if (/curator\/[\d]+/.test(link)) {
  8313. this.#addBtn(steamStoreLink, 'steam', 'curatorLinks', link);
  8314. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8315. this.#addBtn(steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8316. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8317. this.#addBtn(steamStoreLink, 'steam', 'announcementLinks', link);
  8318. } else if (/app\/[\d]+/.test(link)) {
  8319. this.#addBtn(steamStoreLink, 'steam', 'followLinks', link);
  8320. this.#addBtn(steamStoreLink, 'steam', 'wishlistLinks', link);
  8321. }
  8322. }
  8323. }
  8324. if (steamCommunityLinks.length > 0) {
  8325. for (const steamCommunityLink of steamCommunityLinks) {
  8326. const link = $(steamCommunityLink).attr('href');
  8327. if (!link) {
  8328. continue;
  8329. }
  8330. if (/groups\/.+/.test(link)) {
  8331. this.#addBtn(steamCommunityLink, 'steam', 'groupLinks', link);
  8332. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8333. this.#addBtn(steamCommunityLink, 'steam', 'announcementLinks', link);
  8334. }
  8335. }
  8336. }
  8337. if (ytbLinks.length > 0) {
  8338. for (const ytbLink of ytbLinks) {
  8339. const link = $(ytbLink).attr('href');
  8340. if (!link) {
  8341. continue;
  8342. }
  8343. this.#addBtn(ytbLink, 'youtube', 'channelLinks', link);
  8344. this.#addBtn(ytbLink, 'youtube', 'likeLinks', link);
  8345. }
  8346. }
  8347. const giveawayLinks = mainPost.find('a[href*="giveaway.su/giveaway/view/"]:visible,a[href*="givee.club/"]:visible,a[href*="gleam.io/"]:visible,a[href*="www.indiedb.com/giveaways/"]:visible,a[href*="key-hub.eu/giveaway/"]:visible,a[href*="opquests.com/quests/"]:visible,a[href*="itch.io/s/"]:visible');
  8348. if (giveawayLinks.length > 0) {
  8349. for (const giveawayLink of giveawayLinks) {
  8350. const link = $(giveawayLink).attr('href');
  8351. if (!link) {
  8352. continue;
  8353. }
  8354. website_leftKeyChecker.classify(link).then(status => {
  8355. if (!status) {
  8356. return;
  8357. }
  8358. if (/^Active/.test(status)) {
  8359. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  8360. return;
  8361. }
  8362. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  8363. }).catch(error => {
  8364. throwError(error, 'keylol.after -> leftKeyChecker');
  8365. });
  8366. }
  8367. }
  8368. if (this.name === 'Keylol') {
  8369. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  8370. if (asfLinks.length > 0) {
  8371. for (const asfLink of asfLinks) {
  8372. const link = $(asfLink).attr('href');
  8373. if (!link) {
  8374. continue;
  8375. }
  8376. this.#addBtn($(`a[href="${link}"]`).after('<span style="color: #ccc; margin: 0 -5px 0 5px"> | </span>').next()[0], 'steam', 'licenseLinks', `appid-${link.replace('#asf', '')}`);
  8377. }
  8378. }
  8379. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  8380. if (subLinks.length > 0) {
  8381. for (const subLink of subLinks) {
  8382. var _link$match;
  8383. const link = $(subLink).attr('href');
  8384. if (!link) {
  8385. continue;
  8386. }
  8387. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  8388. if (!subid) {
  8389. continue;
  8390. }
  8391. this.#addBtn(subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  8392. }
  8393. }
  8394. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  8395. if (asfLinks2.length > 0) {
  8396. for (const asfLink of asfLinks2) {
  8397. const subid = asfLink.innerText.match(/[\d]+/g);
  8398. if (!subid || subid.length === 0) {
  8399. continue;
  8400. }
  8401. this.#addBtn($(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  8402. }
  8403. }
  8404. }
  8405. } catch (error) {
  8406. throwError(error, 'keylol.after');
  8407. }
  8408. }
  8409. classifyTask(action) {
  8410. try {
  8411. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  8412. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  8413. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  8414. for (const btn of selectedBtns) {
  8415. const button = $(btn);
  8416. const social = button.attr('data-social');
  8417. const type = button.attr('data-type');
  8418. const link = button.attr('data-link');
  8419. if (!(social && type && link)) {
  8420. continue;
  8421. }
  8422. if (action === 'do') {
  8423. this.undoneTasks[social][type].push(link);
  8424. }
  8425. if (action === 'undo') {
  8426. this.socialTasks[social][type].push(link);
  8427. }
  8428. }
  8429. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8430. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8431. if (window.DEBUG) {
  8432. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8433. }
  8434. return true;
  8435. } catch (error) {
  8436. throwError(error, 'Keylol.classifyTask');
  8437. return false;
  8438. }
  8439. }
  8440. selectAll() {
  8441. try {
  8442. $('.auto-task-keylol:visible').attr('selected', 'selected');
  8443. } catch (error) {
  8444. throwError(error, 'Keylol.selectAll');
  8445. }
  8446. }
  8447. selectNone() {
  8448. try {
  8449. $('.auto-task-keylol:visible').removeAttr('selected');
  8450. } catch (error) {
  8451. throwError(error, 'Keylol.selectNone');
  8452. }
  8453. }
  8454. invertSelect() {
  8455. try {
  8456. $('.auto-task-keylol:visible').each((index, element) => {
  8457. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8458. });
  8459. } catch (error) {
  8460. throwError(error, 'Keylol.invertSelect');
  8461. }
  8462. }
  8463. #addBtn(before, social, linkType, link) {
  8464. try {
  8465. $(before).after('<a href="javascript:void(0);" class="auto-task-keylol" target="_self"' + ' onclick="this.getAttribute(\'selected\') ? this.removeAttribute(\'selected\') : this.setAttribute(\'selected\', \'selected\')"' + ` data-social="${social}" data-type="${linkType}" data-link="${link}">${linkType.replace('Links', '')}</a>`);
  8466. } catch (error) {
  8467. throwError(error, 'keylol.addBtn');
  8468. }
  8469. }
  8470. }
  8471. const website_Keylol = Keylol;
  8472. const Opquests_defaultTasks = {
  8473. steam: {
  8474. groupLinks: [],
  8475. wishlistLinks: [],
  8476. followLinks: [],
  8477. curatorLikeLinks: []
  8478. }
  8479. };
  8480. class Opquests extends website_Website {
  8481. name = 'Opquests';
  8482. undoneTasks = {
  8483. ...Opquests_defaultTasks
  8484. };
  8485. buttons = [ 'doTask', 'verifyTask', 'getKey' ];
  8486. static test() {
  8487. return window.location.host === 'opquests.com';
  8488. }
  8489. async after() {
  8490. try {
  8491. if (!this.#checkLogin()) {
  8492. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8493. }
  8494. } catch (error) {
  8495. throwError(error, 'Opquests.after');
  8496. }
  8497. }
  8498. init() {
  8499. try {
  8500. const logStatus = scripts_echoLog({
  8501. text: i18n('initing')
  8502. });
  8503. if ($('a[href*="/auth/redirect"]').length > 0) {
  8504. window.open('/auth/redirect', '_self');
  8505. logStatus.warning(i18n('needLogin'));
  8506. return false;
  8507. }
  8508. if (!this.#getGiveawayId()) {
  8509. return false;
  8510. }
  8511. this.initialized = true;
  8512. logStatus.success();
  8513. return true;
  8514. } catch (error) {
  8515. throwError(error, 'Opquests.init');
  8516. return false;
  8517. }
  8518. }
  8519. async classifyTask(action) {
  8520. try {
  8521. if (action === 'undo') {
  8522. scripts_echoLog({
  8523. text: i18n('cannotUndo')
  8524. });
  8525. return false;
  8526. }
  8527. const logStatus = scripts_echoLog({
  8528. text: i18n('getTasksInfo')
  8529. });
  8530. const tasks = $('.w-full:contains("Validate") .items-center');
  8531. for (const task of tasks) {
  8532. const link = $(task).find('a:contains("Open")').attr('href');
  8533. const taskDes = $(task).find('div').eq(1).text().trim();
  8534. if (!link) {
  8535. continue;
  8536. }
  8537. if (/steamcommunity\.com\/groups\//.test(link)) {
  8538. this.undoneTasks.steam.groupLinks.push(link);
  8539. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8540. if (/wishlist/gim.test(taskDes)) {
  8541. this.undoneTasks.steam.wishlistLinks.push(link);
  8542. } else if (/follow/gim.test(taskDes)) {
  8543. this.undoneTasks.steam.followLinks.push(link);
  8544. }
  8545. } else if (/store\.steampowered\.com\/(publisher|developer|curator)\//.test(link) && /follow/gim.test(taskDes)) {
  8546. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8547. } else {
  8548. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8549. }
  8550. }
  8551. logStatus.success();
  8552. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8553. if (window.DEBUG) {
  8554. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8555. }
  8556. return true;
  8557. } catch (error) {
  8558. throwError(error, 'Opquests.classifyTask');
  8559. return false;
  8560. }
  8561. }
  8562. async verifyTask() {
  8563. try {
  8564. if (!this.initialized) {
  8565. this.init();
  8566. }
  8567. const tasks = $.makeArray($('div.w-full').find('.items-center').has('button.submit-loader')).map(ele => ({
  8568. token: $(ele).find('input[name="_token"]').val(),
  8569. taskId: $(ele).find('input[name="task_id"]').val(),
  8570. title: $(ele).find('span.text-sm').text().trim()
  8571. }));
  8572. await this.#confirm();
  8573. const pro = [];
  8574. for (const task of tasks) {
  8575. pro.push(this.#verify(task));
  8576. await delay(1e3);
  8577. }
  8578. await Promise.all(pro);
  8579. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8580. if (await this.getKey()) {
  8581. return true;
  8582. }
  8583. window.location.reload();
  8584. return false;
  8585. } catch (error) {
  8586. throwError(error, 'Opquests.verifyTask');
  8587. return false;
  8588. }
  8589. }
  8590. async #confirm() {
  8591. try {
  8592. const logStatus = scripts_echoLog({
  8593. html: `<li>${i18n('confirmingTask')}...<font></font></li>`
  8594. });
  8595. const {
  8596. result,
  8597. statusText,
  8598. status,
  8599. data
  8600. } = await tools_httpRequest({
  8601. url: `https://opquests.com/quests/${this.giveawayId}?confirm=1`,
  8602. method: 'GET',
  8603. nochche: true,
  8604. headers: {
  8605. origin: 'https://opquests.com',
  8606. referer: `https://opquests.com/warning?id=${this.giveawayId}`
  8607. }
  8608. });
  8609. if (result === 'Success') {
  8610. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  8611. logStatus.success();
  8612. return true;
  8613. }
  8614. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8615. return false;
  8616. }
  8617. logStatus.error(`${result}:${statusText}(${status})`);
  8618. return false;
  8619. } catch (error) {
  8620. throwError(error, 'Opquests.confirm');
  8621. return false;
  8622. }
  8623. }
  8624. async #verify(task) {
  8625. try {
  8626. const logStatus = scripts_echoLog({
  8627. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  8628. });
  8629. const {
  8630. result,
  8631. statusText,
  8632. status,
  8633. data
  8634. } = await tools_httpRequest({
  8635. url: 'https://opquests.com/entries',
  8636. method: 'POST',
  8637. dataType: 'json',
  8638. nochche: true,
  8639. headers: {
  8640. origin: 'https://opquests.com',
  8641. pragma: 'no-cache',
  8642. referer: window.location.href,
  8643. 'content-type': 'application/x-www-form-urlencoded'
  8644. },
  8645. data: `_token=${task.token}&task_id=${task.taskId}`
  8646. });
  8647. if (result === 'Success') {
  8648. var _data$responseText, _data$responseText2, _$$find$attr;
  8649. if (data !== null && data !== void 0 && (_data$responseText = data.responseText) !== null && _data$responseText !== void 0 && _data$responseText.includes('Successfully completed task') || data !== null && data !== void 0 && (_data$responseText2 = data.responseText) !== null && _data$responseText2 !== void 0 && _data$responseText2.includes('unlocked the key')) {
  8650. logStatus.success();
  8651. return true;
  8652. }
  8653. const key = (_$$find$attr = $((data === null || data === void 0 ? void 0 : data.responseText) || '').find('button[data-clipboard-text]:contains("Copy")').attr('data-clipboard-text')) === null || _$$find$attr === void 0 ? void 0 : _$$find$attr.trim();
  8654. if (key) {
  8655. logStatus.success();
  8656. scripts_echoLog({}).success(key);
  8657. return true;
  8658. }
  8659. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8660. return false;
  8661. }
  8662. logStatus.error(`${result}:${statusText}(${status})`);
  8663. return false;
  8664. } catch (error) {
  8665. throwError(error, 'Opquests.verify');
  8666. return false;
  8667. }
  8668. }
  8669. async getKey(isButton) {
  8670. try {
  8671. const logStatus = scripts_echoLog({
  8672. text: i18n('gettingKey')
  8673. });
  8674. const {
  8675. result,
  8676. statusText,
  8677. status,
  8678. data
  8679. } = await tools_httpRequest({
  8680. url: 'https://opquests.com/keys',
  8681. method: 'GET'
  8682. });
  8683. if (result === 'Success') {
  8684. if (data !== null && data !== void 0 && data.responseText) {
  8685. const key = $(data === null || data === void 0 ? void 0 : data.responseText).find(`div.items-center:contains("${$('h1.font-bold').text().trim().replace(' Quest', '')}")`).find('div.font-bold').next().text();
  8686. if (!key) {
  8687. logStatus.error('Error: Key was not found');
  8688. if (isButton) {
  8689. window.open('https://opquests.com/keys', '_self');
  8690. }
  8691. return false;
  8692. }
  8693. logStatus.success();
  8694. scripts_echoLog({}).success(key);
  8695. return true;
  8696. }
  8697. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8698. return false;
  8699. }
  8700. logStatus.error(`${result}:${statusText}(${status})`);
  8701. return false;
  8702. } catch (error) {
  8703. throwError(error, 'Opquests.getGiveawayId');
  8704. return false;
  8705. }
  8706. }
  8707. #getGiveawayId() {
  8708. try {
  8709. var _window$location$href;
  8710. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8711. if (giveawayId) {
  8712. this.giveawayId = giveawayId;
  8713. return true;
  8714. }
  8715. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8716. return false;
  8717. } catch (error) {
  8718. throwError(error, 'Opquests.getGiveawayId');
  8719. return false;
  8720. }
  8721. }
  8722. #checkLogin() {
  8723. try {
  8724. if (!globalOptions.other.checkLogin) {
  8725. return true;
  8726. }
  8727. if ($('a[href*="/auth/redirect"]').length > 0) {
  8728. window.open('/auth/redirect', '_self');
  8729. }
  8730. return true;
  8731. } catch (error) {
  8732. throwError(error, 'Opquests.checkLogin');
  8733. return false;
  8734. }
  8735. }
  8736. }
  8737. const website_Opquests = Opquests;
  8738. const Gleam_defaultTasksTemplate = {
  8739. steam: {
  8740. groupLinks: [],
  8741. wishlistLinks: [],
  8742. followLinks: [],
  8743. curatorLinks: [],
  8744. curatorLikeLinks: []
  8745. },
  8746. twitter: {
  8747. userLinks: [],
  8748. retweetLinks: []
  8749. },
  8750. twitch: {
  8751. channelLinks: []
  8752. },
  8753. discord: {
  8754. serverLinks: []
  8755. },
  8756. youtube: {
  8757. channelLinks: []
  8758. },
  8759. extra: {
  8760. gleam: []
  8761. }
  8762. };
  8763. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  8764. const Gleam_defaultOptions = {
  8765. vlootUsername: '',
  8766. gameroundUsername: ''
  8767. };
  8768. class Gleam extends website_Website {
  8769. name = 'Gleam';
  8770. undoneTasks = JSON.parse(Gleam_defaultTasks);
  8771. socialTasks = JSON.parse(Gleam_defaultTasks);
  8772. options = {
  8773. ...Gleam_defaultOptions,
  8774. ...GM_getValue('GleamOptions')
  8775. };
  8776. buttons = [ 'doTask', 'undoTask', 'verifyTask' ];
  8777. static test() {
  8778. return window.location.host === 'gleam.io';
  8779. }
  8780. async after() {
  8781. try {
  8782. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8783. const checkComplete = setInterval(() => {
  8784. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8785. clearInterval(checkComplete);
  8786. window.close();
  8787. }
  8788. });
  8789. for (const task of $('.entry-content .entry-method')) {
  8790. const taskInfo = $(task).find('.user-links');
  8791. const expandInfo = $(task).find('.expandable');
  8792. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8793. if (aElements.length > 0) {
  8794. for (const element of aElements) {
  8795. const $element = $(element);
  8796. const href = $element.attr('href');
  8797. $element.removeAttr('href')[0].click();
  8798. $element.attr('href', href);
  8799. await delay(1e3);
  8800. }
  8801. }
  8802. taskInfo[0].click();
  8803. await delay(1e3);
  8804. }
  8805. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8806. } else if (!await this.#checkLeftKey()) {
  8807. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8808. }
  8809. } catch (error) {
  8810. throwError(error, 'Gleam.after');
  8811. return false;
  8812. }
  8813. }
  8814. init() {
  8815. try {
  8816. const logStatus = scripts_echoLog({
  8817. text: i18n('initing')
  8818. });
  8819. if (!this.#getGiveawayId()) {
  8820. return false;
  8821. }
  8822. this.initialized = true;
  8823. logStatus.success();
  8824. return true;
  8825. } catch (error) {
  8826. throwError(error, 'Gleam.init');
  8827. return false;
  8828. }
  8829. }
  8830. async classifyTask(action) {
  8831. try {
  8832. const logStatus = scripts_echoLog({
  8833. text: i18n('getTasksInfo')
  8834. });
  8835. if (action === 'undo') {
  8836. var _GM_getValue;
  8837. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  8838. }
  8839. const tasks = $('.entry-content .entry-method');
  8840. for (const task of tasks) {
  8841. var _socialIcon$attr;
  8842. const $task = $(task);
  8843. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  8844. continue;
  8845. }
  8846. const socialIcon = $task.find('.icon-wrapper i');
  8847. const taskInfo = $task.find('.user-links');
  8848. const taskText = taskInfo.text().trim();
  8849. const expandInfo = $task.find('.expandable');
  8850. const aElements = expandInfo.find('a.btn');
  8851. if (aElements.length > 0) {
  8852. for (const element of aElements) {
  8853. const $element = $(element);
  8854. const href = $element.attr('href');
  8855. $element.removeAttr('href')[0].click();
  8856. $element.attr('href', href);
  8857. }
  8858. }
  8859. if (socialIcon.hasClass('fa-twitter')) {
  8860. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  8861. if (!link) {
  8862. continue;
  8863. }
  8864. if (/follow/gi.test(taskText)) {
  8865. if (action === 'undo') {
  8866. this.socialTasks.twitter.userLinks.push(link);
  8867. }
  8868. if (action === 'do') {
  8869. this.undoneTasks.twitter.userLinks.push(link);
  8870. }
  8871. } else if (/retweet/gim.test(taskText)) {
  8872. if (action === 'undo') {
  8873. this.socialTasks.twitter.retweetLinks.push(link);
  8874. }
  8875. if (action === 'do') {
  8876. this.undoneTasks.twitter.retweetLinks.push(link);
  8877. }
  8878. }
  8879. } else if (socialIcon.hasClass('fa-twitch')) {
  8880. if (/follow/gim.test(taskText)) {
  8881. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  8882. if (!link) {
  8883. continue;
  8884. }
  8885. if (action === 'undo') {
  8886. this.socialTasks.twitch.channelLinks.push(link);
  8887. }
  8888. if (action === 'do') {
  8889. this.undoneTasks.twitch.channelLinks.push(link);
  8890. }
  8891. }
  8892. } else if (socialIcon.hasClass('fa-discord')) {
  8893. if (/join/gim.test(taskText)) {
  8894. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  8895. if (!link) {
  8896. var _$task$find$attr, _$task$find$attr$matc;
  8897. const ggLink = (_$task$find$attr = $task.find('a[href^="https://discord.gg/"]').attr('href')) === null || _$task$find$attr === void 0 ? void 0 : (_$task$find$attr$matc = _$task$find$attr.match(/discord\.gg\/([^/]+)/)) === null || _$task$find$attr$matc === void 0 ? void 0 : _$task$find$attr$matc[1];
  8898. if (!ggLink) {
  8899. continue;
  8900. }
  8901. link = `https://discord.com/invite/${ggLink}`;
  8902. }
  8903. if (action === 'undo') {
  8904. this.socialTasks.discord.serverLinks.push(link);
  8905. }
  8906. if (action === 'do') {
  8907. this.undoneTasks.discord.serverLinks.push(link);
  8908. }
  8909. }
  8910. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  8911. continue;
  8912. } else if (socialIcon.hasClass('fa-youtube')) {
  8913. if (/subscribe/gim.test(taskText)) {
  8914. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  8915. if (!link) {
  8916. continue;
  8917. }
  8918. if (action === 'undo') {
  8919. this.socialTasks.youtube.channelLinks.push(link);
  8920. }
  8921. if (action === 'do') {
  8922. this.undoneTasks.youtube.channelLinks.push(link);
  8923. }
  8924. }
  8925. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  8926. if (/join.*group/gi.test(taskText)) {
  8927. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  8928. if (!link) {
  8929. continue;
  8930. }
  8931. if (action === 'undo') {
  8932. this.socialTasks.steam.groupLinks.push(link);
  8933. }
  8934. if (action === 'do') {
  8935. this.undoneTasks.steam.groupLinks.push(link);
  8936. }
  8937. } else if (/follow.*curator/gi.test(taskText)) {
  8938. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  8939. if (!link) {
  8940. continue;
  8941. }
  8942. if (action === 'undo') {
  8943. this.socialTasks.steam.curatorLinks.push(link);
  8944. }
  8945. if (action === 'do') {
  8946. this.undoneTasks.steam.curatorLinks.push(link);
  8947. }
  8948. }
  8949. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('vloot.io') || socialIcon.hasClass('fa-tiktok')) {
  8950. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  8951. for (const button of continueBtn) {
  8952. button.click();
  8953. await delay(500);
  8954. expandInfo.find('input').val(this.options.vlootUsername);
  8955. }
  8956. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  8957. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  8958. for (const button of continueBtn) {
  8959. button.click();
  8960. await delay(500);
  8961. expandInfo.find('input').val(this.options.gameroundUsername);
  8962. }
  8963. } else if (socialIcon.hasClass('fa-bullhorn') && /Complete/gi.test(taskText)) {
  8964. if (action !== 'do') {
  8965. continue;
  8966. }
  8967. const gleamLink = await this.#getGleamLink(taskText);
  8968. if (!gleamLink) {
  8969. continue;
  8970. }
  8971. this.undoneTasks.extra.gleam.push(gleamLink);
  8972. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-instagram') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-telegram-plane') || socialIcon.hasClass('fa-envelope') || socialIcon.hasClass('fa-gift') || socialIcon.hasClass('fa-shield') && taskText.includes('one of our giveaways') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  8973. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  8974. }
  8975. }
  8976. logStatus.success();
  8977. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8978. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8979. if (window.DEBUG) {
  8980. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8981. }
  8982. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  8983. tasks: this.socialTasks,
  8984. time: new Date().getTime()
  8985. });
  8986. return true;
  8987. } catch (error) {
  8988. throwError(error, 'Gleam.classifyTask');
  8989. return false;
  8990. }
  8991. }
  8992. async extraDoTask(_ref) {
  8993. let {
  8994. gleam
  8995. } = _ref;
  8996. try {
  8997. const pro = [];
  8998. for (const link of gleam) {
  8999. pro.push(this.#doGleamTask(link));
  9000. }
  9001. return Promise.all(pro).then(() => true);
  9002. } catch (error) {
  9003. throwError(error, 'Gleam.extraDoTask');
  9004. return false;
  9005. }
  9006. }
  9007. async verifyTask() {
  9008. try {
  9009. scripts_echoLog({
  9010. text: `${i18n('verifyingTask')}...`
  9011. });
  9012. const tasks = $('.entry-content .entry-method');
  9013. for (const task of tasks) {
  9014. const $task = $(task);
  9015. if ($task.find('i.fa-question').length === 0) {
  9016. continue;
  9017. }
  9018. const taskInfo = $task.find('.user-links');
  9019. taskInfo[0].click();
  9020. await delay(500);
  9021. await this.#checkSync();
  9022. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9023. for (const button of continueBtn) {
  9024. button.click();
  9025. await delay(500);
  9026. await this.#checkSync();
  9027. }
  9028. }
  9029. scripts_echoLog({
  9030. text: i18n('verifiedGleamTasks')
  9031. });
  9032. } catch (error) {
  9033. throwError(error, 'Gleam.verifyTask');
  9034. return false;
  9035. }
  9036. }
  9037. async #checkSync() {
  9038. try {
  9039. return await new Promise(resolve => {
  9040. const checker = setInterval(() => {
  9041. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9042. clearInterval(checker);
  9043. resolve(true);
  9044. }
  9045. }, 500);
  9046. });
  9047. } catch (error) {
  9048. throwError(error, 'Gleam.checkSync');
  9049. return false;
  9050. }
  9051. }
  9052. async #doGleamTask(link) {
  9053. try {
  9054. const logStatus = scripts_echoLog({
  9055. text: i18n('doingGleamTask')
  9056. });
  9057. return await new Promise(resolve => {
  9058. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9059. active: true,
  9060. insert: true,
  9061. setParent: true
  9062. }).onclose = () => {
  9063. logStatus.success();
  9064. resolve(true);
  9065. };
  9066. });
  9067. } catch (error) {
  9068. throwError(error, 'Gleam.doGleamTask');
  9069. return false;
  9070. }
  9071. }
  9072. #getGiveawayId() {
  9073. try {
  9074. const giveawayId = window.location.pathname;
  9075. if (giveawayId) {
  9076. this.giveawayId = giveawayId;
  9077. return true;
  9078. }
  9079. scripts_echoLog({
  9080. text: i18n('getFailed', 'GiveawayId')
  9081. });
  9082. return false;
  9083. } catch (error) {
  9084. throwError(error, 'Gleam.getGiveawayId');
  9085. return false;
  9086. }
  9087. }
  9088. async #getGleamLink(title) {
  9089. try {
  9090. const logStatus = scripts_echoLog({
  9091. text: i18n('gettingGleamLink')
  9092. });
  9093. const {
  9094. result,
  9095. statusText,
  9096. status,
  9097. data
  9098. } = await tools_httpRequest({
  9099. url: 'https://www.vloot.io/api/v1/giveaways',
  9100. method: 'GET',
  9101. responseType: 'json'
  9102. });
  9103. if (result === 'Success') {
  9104. var _data$response, _data$response2;
  9105. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.Success) === true && data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.Data) {
  9106. const {
  9107. link
  9108. } = data.response.Data.find(giveaway => title.replace(/[\s]/g, '').toLowerCase().includes(giveaway.title.replace(/[\s]/g, '').toLowerCase())) || {};
  9109. if (link) {
  9110. logStatus.success();
  9111. return link;
  9112. }
  9113. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9114. return false;
  9115. }
  9116. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9117. return false;
  9118. }
  9119. logStatus.error(`${result}:${statusText}(${status})`);
  9120. return false;
  9121. } catch (error) {
  9122. throwError(error, 'Gleam.getGleamLink');
  9123. return false;
  9124. }
  9125. }
  9126. async #checkLeftKey() {
  9127. try {
  9128. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9129. if (!globalOptions.other.checkLeftKey) {
  9130. return true;
  9131. }
  9132. const campaignString = (_$$attr = $('div.popup-blocks-container').attr('ng-init')) === null || _$$attr === void 0 ? void 0 : (_$$attr$match = _$$attr.match(/initCampaign\(([\w\W]+?)\)$/)) === null || _$$attr$match === void 0 ? void 0 : _$$attr$match[1];
  9133. if (!campaignString) {
  9134. return false;
  9135. }
  9136. const {
  9137. campaign,
  9138. incentive
  9139. } = JSON.parse(campaignString);
  9140. const controllerString = (_$$attr2 = $('div.campaign.reward').attr('ng-init')) === null || _$$attr2 === void 0 ? void 0 : (_$$attr2$match = _$$attr2.match(/initContestant\(([\w\W]+?)\);/)) === null || _$$attr2$match === void 0 ? void 0 : _$$attr2$match[1];
  9141. let ownedKey = false;
  9142. if (controllerString) {
  9143. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9144. if ((_JSON$parse$contestan = JSON.parse(controllerString).contestant) !== null && _JSON$parse$contestan !== void 0 && (_JSON$parse$contestan2 = _JSON$parse$contestan.claims) !== null && _JSON$parse$contestan2 !== void 0 && (_JSON$parse$contestan3 = _JSON$parse$contestan2.incentives) !== null && _JSON$parse$contestan3 !== void 0 && (_JSON$parse$contestan4 = _JSON$parse$contestan3[incentive.id]) !== null && _JSON$parse$contestan4 !== void 0 && _JSON$parse$contestan4.length) {
  9145. ownedKey = true;
  9146. }
  9147. }
  9148. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9149. await external_Swal_default().fire({
  9150. icon: 'warning',
  9151. title: i18n('notice'),
  9152. text: i18n('giveawayNotWork'),
  9153. confirmButtonText: i18n('confirm'),
  9154. cancelButtonText: i18n('cancel'),
  9155. showCancelButton: true
  9156. }).then(_ref2 => {
  9157. let {
  9158. value
  9159. } = _ref2;
  9160. if (value) {
  9161. window.close();
  9162. }
  9163. });
  9164. }
  9165. return true;
  9166. } catch (error) {
  9167. throwError(error, 'Gleam.checkLeftKey');
  9168. return false;
  9169. }
  9170. }
  9171. }
  9172. const website_Gleam = Gleam;
  9173. const SweepWidget_defaultOptions = {
  9174. username: '',
  9175. email: ''
  9176. };
  9177. class SweepWidget extends website_Website {
  9178. name = 'SweepWidget';
  9179. options = {
  9180. ...SweepWidget_defaultOptions,
  9181. ...GM_getValue('SweepWidgetOptions')
  9182. };
  9183. buttons = [ 'doTask' ];
  9184. static test() {
  9185. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9186. }
  9187. async after() {
  9188. try {
  9189. if (!this.#checkLogin()) {
  9190. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9191. }
  9192. } catch (error) {
  9193. throwError(error, 'SweepWidget.after');
  9194. }
  9195. }
  9196. init() {
  9197. try {
  9198. const logStatus = scripts_echoLog({
  9199. text: i18n('initing')
  9200. });
  9201. if (!this.#checkLogin()) {
  9202. logStatus.warning(i18n('needLogin'));
  9203. return false;
  9204. }
  9205. if (!this.#getGiveawayId()) {
  9206. return false;
  9207. }
  9208. this.initialized = true;
  9209. logStatus.success();
  9210. return true;
  9211. } catch (error) {
  9212. throwError(error, 'SweepWidget.init');
  9213. return false;
  9214. }
  9215. }
  9216. classifyTask() {
  9217. return true;
  9218. }
  9219. async doTask() {
  9220. try {
  9221. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9222. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9223. $('input[name="sw__login_name"]').val(this.options.username);
  9224. }
  9225. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9226. $('input[name="sw__login_email"]').val(this.options.email);
  9227. }
  9228. if ($('#sw_login_button:visible').length > 0) {
  9229. $('#sw_login_button')[0].click();
  9230. }
  9231. if (!await this.#checkEnter()) {
  9232. return false;
  9233. }
  9234. }
  9235. const logStatus = scripts_echoLog({
  9236. text: i18n('SweepWidgetNotice')
  9237. });
  9238. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9239. for (const task of tasks) {
  9240. var _aElement$, _$task$find$removeAtt;
  9241. const $task = $(task);
  9242. if ($task.find('i.fa-check:visible').length > 0) {
  9243. continue;
  9244. }
  9245. const title = $task.find('.sw_text_inner');
  9246. title[0].click();
  9247. const aElement = $task.find('a.sw_link');
  9248. const link = aElement.attr('href');
  9249. aElement.attr('href', '#a').attr('target', '_self');
  9250. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9251. await delay(300);
  9252. aElement.attr('href', link).attr('target', '_blank');
  9253. $task.find('input[type="text"]').val('test');
  9254. const verifyBtn = $task.find('input.sw_verify');
  9255. if (verifyBtn.prop('disabled') === true) {
  9256. title[0].click();
  9257. await delay(300);
  9258. title[0].click();
  9259. await delay(300);
  9260. }
  9261. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9262. await this.#checkFinish($task);
  9263. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9264. }
  9265. logStatus.success();
  9266. return true;
  9267. } catch (error) {
  9268. throwError(error, 'SweepWidget.doTask');
  9269. return false;
  9270. }
  9271. }
  9272. #checkLogin() {
  9273. try {
  9274. if ($('#twitter_login_button').length > 0) {
  9275. $('#twitter_login_button')[0].click();
  9276. }
  9277. return true;
  9278. } catch (error) {
  9279. throwError(error, 'SweepWidget.checkLogin');
  9280. return false;
  9281. }
  9282. }
  9283. #getGiveawayId() {
  9284. try {
  9285. var _window$location$href;
  9286. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9287. if (giveawayId) {
  9288. this.giveawayId = giveawayId;
  9289. return true;
  9290. }
  9291. scripts_echoLog({
  9292. text: i18n('getFailed', 'GiveawayId')
  9293. });
  9294. return false;
  9295. } catch (error) {
  9296. throwError(error, 'SweepWidget.getGiveawayId');
  9297. return false;
  9298. }
  9299. }
  9300. async #checkEnter() {
  9301. try {
  9302. return new Promise(resolve => {
  9303. const checker = setInterval(() => {
  9304. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9305. clearInterval(checker);
  9306. resolve(true);
  9307. }
  9308. });
  9309. });
  9310. } catch (error) {
  9311. throwError(error, 'SweepWidget.checkEnter');
  9312. return false;
  9313. }
  9314. }
  9315. async #checkFinish($task) {
  9316. try {
  9317. return new Promise(resolve => {
  9318. const checker = setInterval(() => {
  9319. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9320. clearInterval(checker);
  9321. resolve(true);
  9322. }
  9323. });
  9324. });
  9325. } catch (error) {
  9326. throwError(error, 'SweepWidget.checkFinish');
  9327. return false;
  9328. }
  9329. }
  9330. }
  9331. const website_SweepWidget = SweepWidget;
  9332. const defaultWhiteList = {
  9333. discord: {
  9334. servers: []
  9335. },
  9336. instagram: {
  9337. users: []
  9338. },
  9339. twitch: {
  9340. channels: []
  9341. },
  9342. twitter: {
  9343. users: [],
  9344. retweets: [],
  9345. likes: []
  9346. },
  9347. vk: {
  9348. names: []
  9349. },
  9350. youtube: {
  9351. channels: [],
  9352. likes: []
  9353. },
  9354. reddit: {
  9355. reddits: []
  9356. },
  9357. steam: {
  9358. groups: [],
  9359. officialGroups: [],
  9360. wishlists: [],
  9361. follows: [],
  9362. forums: [],
  9363. workshops: [],
  9364. curators: [],
  9365. workshopVotes: [],
  9366. curatorLikes: [],
  9367. announcements: [],
  9368. licenses: [],
  9369. playtests: []
  9370. }
  9371. };
  9372. const link2id = async function(type) {
  9373. var _link$match, _link$match2, _link$match3, _link$match4, _link$match5, _link$match6, _await$getInfo, _await$getInfo$params, _await$getInfo2, _await$getInfo2$param, _link$match7, _link$match8, _link$match9, _link$match10, _link$match11;
  9374. try {
  9375. const link = $('#socialLink').val();
  9376. let id = '';
  9377. switch (type) {
  9378. case 'discord.servers':
  9379. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9380. break;
  9381.  
  9382. case 'instagram.users':
  9383. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9384. break;
  9385.  
  9386. case 'twitch.channels':
  9387. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9388. break;
  9389.  
  9390. case 'twitter.users':
  9391. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9392. break;
  9393.  
  9394. case 'twitter.retweets':
  9395. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9396. break;
  9397.  
  9398. case 'vk.names':
  9399. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9400. break;
  9401.  
  9402. case 'youtube.channels':
  9403. id = ((_await$getInfo = await getInfo(link, 'channel')) === null || _await$getInfo === void 0 ? void 0 : (_await$getInfo$params = _await$getInfo.params) === null || _await$getInfo$params === void 0 ? void 0 : _await$getInfo$params.channelId) || '';
  9404. break;
  9405.  
  9406. case 'youtube.likes':
  9407. id = ((_await$getInfo2 = await getInfo(link, 'likeVideo')) === null || _await$getInfo2 === void 0 ? void 0 : (_await$getInfo2$param = _await$getInfo2.params) === null || _await$getInfo2$param === void 0 ? void 0 : _await$getInfo2$param.videoId) || '';
  9408. break;
  9409.  
  9410. case 'reddit.reddits':
  9411. id = ((_link$match7 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1]) || ((_link$match8 = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1]) || '';
  9412. break;
  9413.  
  9414. case 'steam.groups':
  9415. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9416. break;
  9417.  
  9418. case 'steam.wishlists':
  9419. case 'steam.follows':
  9420. case 'steam.forums':
  9421. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9422. break;
  9423.  
  9424. case 'steam.workshops':
  9425. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9426. break;
  9427.  
  9428. case 'steam.curators':
  9429. {
  9430. if (link.includes('curator')) {
  9431. var _link$match12;
  9432. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9433. } else {
  9434. var _link$match13;
  9435. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9436. if (!param || param.length !== 2) {
  9437. break;
  9438. }
  9439. const steam = new social_Steam();
  9440. if (await steam.init()) {
  9441. id = await steam.getCuratorId(param[0], param[1]) || '';
  9442. }
  9443. }
  9444. }
  9445. break;
  9446. }
  9447. return id;
  9448. } catch (error) {
  9449. throwError(error, 'link2id');
  9450. return i18n('getFailed', 'id');
  9451. }
  9452. };
  9453. const disabledType = {
  9454. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9455. twitter: [ 'likes' ]
  9456. };
  9457. const assignWhiteList = whiteList => {
  9458. try {
  9459. const newWhiteList = {};
  9460. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  9461. newWhiteList[key] = {
  9462. ...value,
  9463. ...whiteList[key]
  9464. };
  9465. }
  9466. return newWhiteList;
  9467. } catch (error) {
  9468. throwError(error, 'assignWhiteList');
  9469. return defaultWhiteList;
  9470. }
  9471. };
  9472. const whiteListOptions = function(showType) {
  9473. try {
  9474. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  9475. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9476. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9477. for (const [ social, types ] of Object.entries(whiteList)) {
  9478. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9479. var _disabledType$social;
  9480. return (_disabledType$social = disabledType[social]) !== null && _disabledType$social !== void 0 && _disabledType$social.includes(type) ? '' : `<tr style="background-color: ${stringToColour(social)}66">${index === 0 ? `<th rowspan="${Object.keys(types).length - (disabledType[social] || []).length}" style="background-color: ${stringToColour(social)}66">${social}</th>` : ''}<td>${i18n(type)}</td><td><button type="button" class="editWhiteList" data-value="${social}.${type}">${i18n('edit')}</button></td></tr>`;
  9481. }).join('');
  9482. }
  9483. whiteListOptionsForm += '</tbody></table></form>';
  9484. if (showType === 'swal') {
  9485. external_Swal_default().fire({
  9486. title: i18n('whiteListOptions'),
  9487. html: whiteListOptionsForm,
  9488. showConfirmButton: false,
  9489. showCloseButton: true
  9490. });
  9491. } else {
  9492. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9493. }
  9494. $('.editWhiteList').on('click', function() {
  9495. var _whiteList$social;
  9496. const value = $(this).attr('data-value');
  9497. if (!value) {
  9498. return;
  9499. }
  9500. const [ social, type ] = value.split('.');
  9501. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9502. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9503. return;
  9504. }
  9505. external_Swal_default().fire({
  9506. title: i18n('changeWhiteListOption', value),
  9507. input: 'textarea',
  9508. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9509. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9510. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9511. inputValue: whiteList[social][type].join('\n'),
  9512. showConfirmButton: true,
  9513. confirmButtonText: i18n('save'),
  9514. showCancelButton: true,
  9515. cancelButtonText: i18n('close'),
  9516. showDenyButton: true,
  9517. denyButtonText: i18n('return')
  9518. }).then(_ref => {
  9519. let {
  9520. isDenied,
  9521. isConfirmed,
  9522. value
  9523. } = _ref;
  9524. if (isDenied) {
  9525. if (showType === 'swal') {
  9526. whiteListOptions(showType);
  9527. }
  9528. return;
  9529. } else if (isConfirmed) {
  9530. whiteList[social][type] = value.split('\n');
  9531. GM_setValue('whiteList', whiteList);
  9532. external_Swal_default().fire({
  9533. title: i18n('changeWhiteListSuccess'),
  9534. icon: 'success'
  9535. });
  9536. }
  9537. });
  9538. $('#link2id').on('click', async function() {
  9539. const type = $(this).attr('data-type');
  9540. $('#socialLink').val(await link2id(type));
  9541. });
  9542. });
  9543. } catch (error) {
  9544. throwError(error, 'whiteListOptions');
  9545. }
  9546. };
  9547. const whiteList = whiteListOptions;
  9548. const setGistData = async (token, gistId, fileName, content) => {
  9549. try {
  9550. const logStatus = scripts_echoLog({
  9551. text: i18n('settingData')
  9552. });
  9553. const contentData = JSON.stringify({
  9554. files: {
  9555. [fileName]: {
  9556. content: JSON.stringify(content)
  9557. }
  9558. }
  9559. });
  9560. const {
  9561. result,
  9562. statusText,
  9563. status,
  9564. data
  9565. } = await tools_httpRequest({
  9566. url: `https://api.github.com/gists/${gistId}`,
  9567. headers: {
  9568. Accept: 'application/vnd.github.v3+json',
  9569. Authorization: `token ${token}`
  9570. },
  9571. data: contentData,
  9572. responseType: 'json',
  9573. method: 'POST',
  9574. timeout: 3e4
  9575. });
  9576. if (result === 'Success') {
  9577. var _data$response$files, _data$response$files$;
  9578. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response$files = data.response.files) === null || _data$response$files === void 0 ? void 0 : (_data$response$files$ = _data$response$files[fileName]) === null || _data$response$files$ === void 0 ? void 0 : _data$response$files$.content) === JSON.stringify(content)) {
  9579. logStatus.success();
  9580. return true;
  9581. }
  9582. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9583. return false;
  9584. }
  9585. logStatus.error(`${result}:${statusText}(${status})`);
  9586. return false;
  9587. } catch (error) {
  9588. throwError(error, 'setGistData');
  9589. return false;
  9590. }
  9591. };
  9592. const getGistData = async function(token, gistId, fileName) {
  9593. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9594. try {
  9595. const logStatus = scripts_echoLog({
  9596. text: i18n('gettingData')
  9597. });
  9598. const {
  9599. result,
  9600. statusText,
  9601. status,
  9602. data
  9603. } = await tools_httpRequest({
  9604. url: `https://api.github.com/gists/${gistId}`,
  9605. headers: {
  9606. Accept: 'application/vnd.github.v3+json',
  9607. Authorization: `token ${token}`
  9608. },
  9609. responseType: 'json',
  9610. method: 'GET',
  9611. timeout: 3e4
  9612. });
  9613. if (result === 'Success') {
  9614. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9615. var _data$response, _data$response$files2, _data$response$files3;
  9616. const content = (_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$files2 = _data$response.files) === null || _data$response$files2 === void 0 ? void 0 : (_data$response$files3 = _data$response$files2[fileName]) === null || _data$response$files3 === void 0 ? void 0 : _data$response$files3.content;
  9617. let formatedContent;
  9618. if (!content) {
  9619. logStatus.error(`Error:${i18n('noRemoteData')}`);
  9620. return false;
  9621. }
  9622. if (test) {
  9623. logStatus.success();
  9624. return true;
  9625. }
  9626. try {
  9627. formatedContent = JSON.parse(content);
  9628. } catch (error) {
  9629. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  9630. return false;
  9631. }
  9632. logStatus.success();
  9633. return formatedContent;
  9634. }
  9635. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9636. return false;
  9637. }
  9638. logStatus.error(`${result}:${statusText}(${status})`);
  9639. return false;
  9640. } catch (error) {
  9641. throwError(error, 'getGistData');
  9642. return false;
  9643. }
  9644. };
  9645. const syncOptions = () => {
  9646. try {
  9647. const {
  9648. TOKEN,
  9649. GIST_ID,
  9650. FILE_NAME,
  9651. SYNC_HISTORY
  9652. } = GM_getValue('gistOptions') || {
  9653. TOKEN: '',
  9654. GIST_ID: '',
  9655. FILE_NAME: '',
  9656. SYNC_HISTORY: true
  9657. };
  9658. external_Swal_default().fire({
  9659. title: i18n('gistOptions'),
  9660. html: `<p>Github Token<input id="github-token" class="swal2-input" placeholder="Github Token" value="${TOKEN}"></p>` + `<p>Gist ID<input id="gist-id" class="swal2-input" placeholder="Gist ID" value="${GIST_ID}"></p>` + `<p>${i18n('fileName')}<input id="file-name" class="swal2-input" placeholder="${i18n('fileName')}" value="${FILE_NAME}"></p>` + '<p><label for="sync-history" class="swal2-checkbox-custom" style="display: flex;">' + `<input id="sync-history" type="checkbox"${SYNC_HISTORY ? ' checked="checked"' : ''}/>` + `<span class="swal2-label">${i18n('syncHistory')}</span></label></p>` + `<p><button id="upload-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9661. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9662. ${i18n('downloadFromGist')}</button></p>`,
  9663. focusConfirm: false,
  9664. showLoaderOnConfirm: true,
  9665. footer: `<a href="https://auto-task-doc.js.org/guide/#%E6%95%B0%E6%8D%AE%E5%90%8C%E6%AD%A5" target="_blank">${i18n('help')}</a>`,
  9666. preConfirm: async () => {
  9667. const token = $('#github-token').val();
  9668. const gistId = $('#gist-id').val();
  9669. const fileName = $('#file-name').val();
  9670. const syncHistory = $('#sync-history').prop('checked');
  9671. GM_setValue('gistOptions', {
  9672. TOKEN: token,
  9673. GIST_ID: gistId,
  9674. FILE_NAME: fileName,
  9675. SYNC_HISTORY: syncHistory
  9676. });
  9677. return await getGistData(token, gistId, fileName, true);
  9678. },
  9679. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9680. confirmButtonText: i18n('saveAndTest'),
  9681. showCancelButton: true,
  9682. cancelButtonText: i18n('close')
  9683. }).then(_ref => {
  9684. let {
  9685. value
  9686. } = _ref;
  9687. if (value) {
  9688. external_Swal_default().fire({
  9689. icon: 'success',
  9690. title: i18n('testSuccess')
  9691. }).then(syncOptions);
  9692. } else if (value !== undefined) {
  9693. external_Swal_default().fire({
  9694. icon: 'error',
  9695. title: i18n('testFailed')
  9696. }).then(syncOptions);
  9697. }
  9698. });
  9699. $('#upload-data').on('click', async () => {
  9700. const {
  9701. TOKEN,
  9702. GIST_ID,
  9703. FILE_NAME
  9704. } = GM_getValue('gistOptions') || {};
  9705. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9706. return external_Swal_default().fire({
  9707. icon: 'error',
  9708. title: i18n('saveAndTestNotice')
  9709. }).then(syncOptions);
  9710. }
  9711. external_Swal_default().fire({
  9712. icon: 'info',
  9713. title: i18n('processingData')
  9714. });
  9715. const data = {};
  9716. const names = GM_listValues();
  9717. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9718. for (const name of names) {
  9719. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9720. continue;
  9721. }
  9722. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9723. continue;
  9724. }
  9725. data[name] = GM_getValue(name);
  9726. }
  9727. external_Swal_default().update({
  9728. icon: 'info',
  9729. title: i18n('updatingData')
  9730. });
  9731. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9732. external_Swal_default().fire({
  9733. icon: 'success',
  9734. title: i18n('syncDataSuccess')
  9735. });
  9736. } else {
  9737. external_Swal_default().fire({
  9738. icon: 'error',
  9739. title: i18n('syncDataFailed')
  9740. });
  9741. }
  9742. });
  9743. $('#download-data').on('click', async () => {
  9744. const {
  9745. TOKEN,
  9746. GIST_ID,
  9747. FILE_NAME
  9748. } = GM_getValue('gistOptions') || {};
  9749. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9750. return external_Swal_default().fire({
  9751. icon: 'error',
  9752. title: i18n('saveAndTestNotice')
  9753. }).then(syncOptions);
  9754. }
  9755. external_Swal_default().fire({
  9756. icon: 'info',
  9757. title: i18n('downloadingData')
  9758. });
  9759. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9760. if (!data) {
  9761. return external_Swal_default().fire({
  9762. icon: 'error',
  9763. title: i18n('checkedNoData')
  9764. }).then(syncOptions);
  9765. }
  9766. external_Swal_default().update({
  9767. icon: 'info',
  9768. title: i18n('savingData')
  9769. });
  9770. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9771. for (const [ name, value ] of Object.entries(data)) {
  9772. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9773. continue;
  9774. }
  9775. GM_setValue(name, value);
  9776. }
  9777. external_Swal_default().fire({
  9778. icon: 'success',
  9779. title: i18n('syncDataSuccess')
  9780. });
  9781. });
  9782. } catch (error) {
  9783. throwError(error, 'syncOptions');
  9784. }
  9785. };
  9786. const dataSync = syncOptions;
  9787. class Setting {
  9788. name = 'Setting';
  9789. buttons = [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ];
  9790. syncData = dataSync;
  9791. tasksHistory() {
  9792. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  9793. }
  9794. static test() {
  9795. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  9796. }
  9797. before() {
  9798. $('body').html('').addClass('auto-task-options');
  9799. }
  9800. after() {
  9801. try {
  9802. this.#environment();
  9803. changeGlobalOptions('page');
  9804. whiteList('page');
  9805. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  9806. $('#getTwitterUserId').on('click', () => {
  9807. this.#getId('twitterUser');
  9808. });
  9809. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  9810. $('#getYoutubeChannelId').on('click', () => {
  9811. this.#getId('youtubeChannel');
  9812. });
  9813. $('input[name^="position"]').on('input', function() {
  9814. const type = $(this).attr('name').replace('position.', '');
  9815. const xLabel = 'rightleft';
  9816. const yLabel = 'topbottpm';
  9817. switch (type) {
  9818. case 'buttonSideX':
  9819. case 'buttonSideY':
  9820. case 'buttonDistance':
  9821. {
  9822. const distance = $('input[name="position.buttonDistance"]').val();
  9823. const sideX = $('input[name="position.buttonSideX"]').val();
  9824. const sideY = $('input[name="position.buttonSideY"]').val();
  9825. if (![ 'right', 'left' ].includes(sideX)) {
  9826. break;
  9827. }
  9828. if (![ 'top', 'bottom' ].includes(sideY)) {
  9829. break;
  9830. }
  9831. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9832. break;
  9833. }
  9834. const distanceArr = distance.split(',');
  9835. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9836. break;
  9837. }
  9838.  
  9839. case 'showButtonSideX':
  9840. case 'showButtonSideY':
  9841. case 'showButtonDistance':
  9842. {
  9843. const distance = $('input[name="position.showButtonDistance"]').val();
  9844. const sideX = $('input[name="position.showButtonSideX"]').val();
  9845. const sideY = $('input[name="position.showButtonSideY"]').val();
  9846. if (![ 'right', 'left' ].includes(sideX)) {
  9847. break;
  9848. }
  9849. if (![ 'top', 'bottom' ].includes(sideY)) {
  9850. break;
  9851. }
  9852. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9853. break;
  9854. }
  9855. const distanceArr = distance.split(',');
  9856. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9857. break;
  9858. }
  9859.  
  9860. case 'logSideX':
  9861. case 'logSideY':
  9862. case 'logDistance':
  9863. {
  9864. const distance = $('input[name="position.logDistance"]').val();
  9865. const sideX = $('input[name="position.logSideX"]').val();
  9866. const sideY = $('input[name="position.logSideY"]').val();
  9867. if (![ 'right', 'left' ].includes(sideX)) {
  9868. break;
  9869. }
  9870. if (![ 'top', 'bottom' ].includes(sideY)) {
  9871. break;
  9872. }
  9873. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9874. break;
  9875. }
  9876. const distanceArr = distance.split(',');
  9877. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9878. break;
  9879. }
  9880.  
  9881. default:
  9882. break;
  9883. }
  9884. });
  9885. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  9886. let functionKey = '';
  9887. if (event.altKey) {
  9888. functionKey += 'alt + ';
  9889. } else if (event.ctrlKey) {
  9890. functionKey += 'ctrl + ';
  9891. } else if (event.shiftKey) {
  9892. functionKey += 'shift + ';
  9893. }
  9894. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  9895. });
  9896. } catch (error) {
  9897. throwError(error, 'Setting.after');
  9898. }
  9899. }
  9900. saveGlobalOptions() {
  9901. saveData();
  9902. }
  9903. #getId(social) {
  9904. try {
  9905. external_Swal_default().fire({
  9906. title: i18n('getId', i18n(social)),
  9907. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9908. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  9909. showCancelButton: true,
  9910. cancelButtonText: i18n('close'),
  9911. showConfirmButton: false
  9912. });
  9913. $('#link2id').on('click', async function() {
  9914. const link = $('#socialLink').val();
  9915. if (!link) {
  9916. return;
  9917. }
  9918. const type = $(this).attr('data-type');
  9919. if (type === 'twitterUser') {
  9920. var _link$match;
  9921. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  9922. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  9923. } else if (type === 'youtubeChannel') {
  9924. var _link$match2, _await$getInfo, _await$getInfo$params;
  9925. const name = /^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www.youtube.com\/.*/.test(link) ? (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1] : link;
  9926. $('#socialLink').val(((_await$getInfo = await getInfo(name, 'channel')) === null || _await$getInfo === void 0 ? void 0 : (_await$getInfo$params = _await$getInfo.params) === null || _await$getInfo$params === void 0 ? void 0 : _await$getInfo$params.channelId) || '');
  9927. }
  9928. });
  9929. } catch (error) {
  9930. throwError(error, 'Setting.getId');
  9931. }
  9932. }
  9933. #environment() {
  9934. try {
  9935. const userAgent = (0, javascript_utils_umd_min.ua)();
  9936. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  9937. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  9938. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  9939. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  9940. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  9941. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  9942. </tbody></table></form>`;
  9943. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  9944. } catch (error) {
  9945. throwError(error, 'Setting.environment');
  9946. }
  9947. }
  9948. }
  9949. const website_Setting = Setting;
  9950. class History extends website_Keylol {
  9951. name = 'History';
  9952. buttons = [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ];
  9953. static test() {
  9954. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  9955. }
  9956. before() {
  9957. try {
  9958. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  9959. const data = GM_listValues() || [];
  9960. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9961. for (const item of tasksHistory) {
  9962. this.#addItem(item);
  9963. }
  9964. } catch (error) {
  9965. throwError(error, 'History.before');
  9966. }
  9967. }
  9968. clearHistory() {
  9969. try {
  9970. const data = GM_listValues() || [];
  9971. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9972. for (const item of tasksHistory) {
  9973. GM_deleteValue(item);
  9974. }
  9975. external_Swal_default().fire({
  9976. title: i18n('clearHistoryFinished'),
  9977. icon: 'success'
  9978. });
  9979. } catch (error) {
  9980. throwError(error, 'History.after');
  9981. }
  9982. }
  9983. #addItem(item) {
  9984. try {
  9985. const tasksData = GM_getValue(item);
  9986. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  9987. return;
  9988. }
  9989. let html = '';
  9990. let title = '';
  9991. let link = '';
  9992. const [ website, id ] = item.split('-');
  9993. switch (website) {
  9994. case 'fawTasks':
  9995. title = `Freeanywhere[${id}]`;
  9996. link = `https://freeanywhere.net/#/giveaway/${id}`;
  9997. break;
  9998.  
  9999. case 'gasTasks':
  10000. title = `Giveawaysu[${id}]`;
  10001. link = `https://giveaway.su/giveaway/view/${id}`;
  10002. break;
  10003.  
  10004. case 'gcTasks':
  10005. title = `GiveeClub[${id}]`;
  10006. link = `https://givee.club/event/${id}`;
  10007. break;
  10008.  
  10009. case 'gkTasks':
  10010. title = `Givekey[${id}]`;
  10011. link = `https://givekey.ru/giveaway/${id}`;
  10012. break;
  10013.  
  10014. case 'gleamTasks':
  10015. title = `Gleam[${id}]`;
  10016. link = `https://gleam.io${id}`;
  10017. break;
  10018.  
  10019. case 'khTasks':
  10020. title = `keyhub[${id}]`;
  10021. link = `https://key-hub.eu/giveaway/${id}`;
  10022. break;
  10023.  
  10024. case 'prysTasks':
  10025. title = `Prys[${id}]`;
  10026. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10027. break;
  10028.  
  10029. default:
  10030. return;
  10031. }
  10032. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10033. for (const [ type, tasks ] of Object.entries(types)) {
  10034. for (const task of tasks) {
  10035. html += `<li><font class="auto-task-capitalize">${social}.${i18n(type.replace('Link', ''))}: </font><a href="${task}" target="_blank">${task.length > 55 ? `${task.slice(0, 55)}...` : task}</a></li>`;
  10036. }
  10037. }
  10038. }
  10039. $('.container').append(`<div class="card" data-name="${item}"><div class="title"><a href="${link}" target="_blank">${title}</a><span class="delete-task" data-name="${item}" title="${i18n('deleteTask')}"><svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2734" width="32" height="32"><path d="M607.897867 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L575.903242 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 351.94087C639.892491 753.593818 625.61532 768.043004 607.897867 768.043004z" p-id="2735" fill="#d81e06"></path><path d="M415.930119 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L383.935495 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625 17.717453 0 31.994625 14.277171 31.994625 31.994625l0 351.94087C447.924744 753.593818 433.647573 768.043004 415.930119 768.043004z" p-id="2736" fill="#d81e06"></path><path d="M928.016126 223.962372l-159.973123 0L768.043004 159.973123c0-52.980346-42.659499-95.983874-95.295817-95.983874L351.94087 63.989249c-52.980346 0-95.983874 43.003528-95.983874 95.983874l0 63.989249-159.973123 0c-17.717453 0-31.994625 14.277171-31.994625 31.994625s14.277171 31.994625 31.994625 31.994625l832.032253 0c17.717453 0 31.994625-14.277171 31.994625-31.994625S945.73358 223.962372 928.016126 223.962372zM319.946246 159.973123c0-17.545439 14.449185-31.994625 31.994625-31.994625l320.806316 0c17.545439 0 31.306568 14.105157 31.306568 31.994625l0 63.989249L319.946246 223.962372 319.946246 159.973123 319.946246 159.973123z" p-id="2737" fill="#d81e06"></path><path d="M736.048379 960.010751 288.123635 960.010751c-52.980346 0-95.983874-43.003528-95.983874-95.983874L192.139761 383.591466c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 480.435411c0 17.717453 14.449185 31.994625 31.994625 31.994625l448.096758 0c17.717453 0 31.994625-14.277171 31.994625-31.994625L768.215018 384.795565c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 479.231312C832.032253 916.835209 789.028725 960.010751 736.048379 960.010751z" p-id="2738" fill="#d81e06"></path></svg></span></div><ul>${html}</ul><span class="time">${i18n('lastChangeTime')}: ${external_dayjs_namespaceObject(tasksData.time).format('YYYY-MM-DD HH:mm:ss')}</span></div>`);
  10040. $('span.delete-task').on('click', function() {
  10041. const itemName = $(this).attr('data-name');
  10042. if (itemName) {
  10043. GM_deleteValue(itemName);
  10044. $(`div.card[data-name="${itemName}"]`).remove();
  10045. external_Swal_default().fire({
  10046. title: i18n('clearTaskFinished'),
  10047. text: itemName,
  10048. icon: 'success'
  10049. });
  10050. } else {
  10051. external_Swal_default().fire({
  10052. title: i18n('clearTaskFailed'),
  10053. icon: 'error'
  10054. });
  10055. }
  10056. });
  10057. } catch (error) {
  10058. throwError(error, 'History.addItem');
  10059. }
  10060. }
  10061. }
  10062. const website_History = History;
  10063. const Websites = [ website_FreeAnyWhere, GiveawaySu, website_Indiedb, website_Keyhub, website_Givekey, website_GiveeClub, website_OpiumPulses, website_Keylol, website_Opquests, website_Gleam, website_SweepWidget, website_Setting, website_History ];
  10064. const websiteOptions = function(website, options) {
  10065. try {
  10066. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10067. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10068. for (const [ option, value ] of Object.entries(options)) {
  10069. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10070. }
  10071. websiteOptionsForm += '</tbody></table></form>';
  10072. external_Swal_default().fire({
  10073. title: i18n('websiteOptions'),
  10074. html: websiteOptionsForm,
  10075. showConfirmButton: true,
  10076. confirmButtonText: i18n('save'),
  10077. showCancelButton: true,
  10078. cancelButtonText: i18n('close')
  10079. }).then(_ref => {
  10080. let {
  10081. isConfirmed
  10082. } = _ref;
  10083. if (isConfirmed) {
  10084. $('#websiteOptionsForm').serializeArray().map(value => {
  10085. options[value.name] = value.value;
  10086. return value;
  10087. });
  10088. GM_setValue(`${website}Options`, options);
  10089. external_Swal_default().fire({
  10090. title: i18n('changeWebsiteOptionsSuccess'),
  10091. icon: 'success'
  10092. });
  10093. }
  10094. });
  10095. } catch (error) {
  10096. throwError(error, 'websiteOptions');
  10097. }
  10098. };
  10099. const options = websiteOptions;
  10100. const external_keyboardJS_namespaceObject = keyboardJS;
  10101. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10102. const checkUpdate = async (updateLink, auto) => {
  10103. try {
  10104. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10105. const {
  10106. result,
  10107. statusText,
  10108. status,
  10109. data
  10110. } = await tools_httpRequest({
  10111. url: checkUrl,
  10112. responseType: 'json',
  10113. method: 'GET',
  10114. timeout: 3e4
  10115. });
  10116. if (result === 'Success') {
  10117. var _data$response;
  10118. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10119. return data.response;
  10120. }
  10121. if (!auto) {
  10122. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10123. }
  10124. return false;
  10125. }
  10126. if (!auto) {
  10127. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10128. }
  10129. return false;
  10130. } catch (error) {
  10131. throwError(error, 'checkUpdate');
  10132. return false;
  10133. }
  10134. };
  10135. const hasNewVersion = (currentVersion, remoteVersion) => {
  10136. try {
  10137. const [ currentRealVersion ] = currentVersion.split('-');
  10138. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  10139. if (isPreview && !globalOptions.other.receivePreview) {
  10140. return false;
  10141. }
  10142. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10143. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10144. if (remoteVersion1 > currentVersion1) {
  10145. return true;
  10146. }
  10147. if (remoteVersion1 < currentVersion1) {
  10148. return false;
  10149. }
  10150. if (remoteVersion2 > currentVersion2) {
  10151. return true;
  10152. }
  10153. if (remoteVersion2 < currentVersion2) {
  10154. return false;
  10155. }
  10156. if (remoteVersion3 > currentVersion3) {
  10157. return true;
  10158. }
  10159. return false;
  10160. } catch (error) {
  10161. throwError(error, 'compareVersion');
  10162. return false;
  10163. }
  10164. };
  10165. const updateChecker = async () => {
  10166. try {
  10167. const currentVersion = GM_info.script.version;
  10168. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10169. const updateLinks = {
  10170. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10171. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10172. standby: 'https://auto-task-v4.hclonely.com/'
  10173. };
  10174. let version;
  10175. let updateLink = '';
  10176. let packageData;
  10177. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10178. updateLink = updateLinks[updateSource];
  10179. packageData = await checkUpdate(updateLink, false);
  10180. } else {
  10181. updateLink = updateLinks.github;
  10182. packageData = await checkUpdate(updateLink, true);
  10183. if (!packageData) {
  10184. updateLink = updateLinks.jsdelivr;
  10185. packageData = await checkUpdate(updateLink, true);
  10186. if (!packageData) {
  10187. updateLink = updateLinks.standby;
  10188. packageData = await checkUpdate(updateLink, true);
  10189. }
  10190. }
  10191. }
  10192. if (packageData) {
  10193. version = packageData.version || currentVersion;
  10194. } else {
  10195. version = currentVersion;
  10196. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10197. }
  10198. if (packageData && hasNewVersion(currentVersion, version)) {
  10199. var _packageData$change;
  10200. scripts_echoLog({
  10201. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10202. });
  10203. scripts_echoLog({
  10204. html: `<li>${i18n('updateText', version)}</li><ol class="update-text">${(_packageData$change = packageData.change) === null || _packageData$change === void 0 ? void 0 : _packageData$change.map(change => `<li>${change}</li>`).join('')}<li>${i18n('updateHistory')}</li></ol>`
  10205. });
  10206. }
  10207. } catch (error) {
  10208. throwError(error, 'updateChecker');
  10209. }
  10210. };
  10211. const scripts_updateChecker = updateChecker;
  10212. var _globalOptions$other, _globalOptions$other2;
  10213. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  10214. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  10215. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  10216. const loadScript = async () => {
  10217. var _website, _website2, _website3, _website4, _website5, _website6;
  10218. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10219. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10220. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10221. if (isLogin) {
  10222. var _commonOptions, _commonOptions$header, _commonOptions2, _commonOptions2$heade;
  10223. GM_setValue('twitchAuth', {
  10224. authToken: authToken,
  10225. clientVersion: __twilightBuildID,
  10226. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID'],
  10227. deviceId: (_commonOptions2 = commonOptions) === null || _commonOptions2 === void 0 ? void 0 : (_commonOptions2$heade = _commonOptions2.headers) === null || _commonOptions2$heade === void 0 ? void 0 : _commonOptions2$heade['Device-ID'],
  10228. clientSessionId: window.localStorage.local_storage_app_session_id.replace(/"/g, '')
  10229. });
  10230. window.close();
  10231. external_Swal_default().fire('', i18n('closePageNotice'));
  10232. } else {
  10233. external_Swal_default().fire('', i18n('needLogin'));
  10234. }
  10235. return;
  10236. }
  10237. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10238. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10239. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10240. if (isLogin && ct0) {
  10241. GM_setValue('twitterAuth', {
  10242. ct0: ct0
  10243. });
  10244. window.close();
  10245. external_Swal_default().fire('', i18n('closePageNotice'));
  10246. } else {
  10247. external_Swal_default().fire('', i18n('needLogin'));
  10248. }
  10249. return;
  10250. }
  10251. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10252. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10253. if (PAPISID) {
  10254. GM_setValue('youtubeAuth', {
  10255. PAPISID: PAPISID
  10256. });
  10257. window.close();
  10258. external_Swal_default().fire('', i18n('closePageNotice'));
  10259. } else {
  10260. external_Swal_default().fire('', i18n('needLogin'));
  10261. }
  10262. return;
  10263. }
  10264. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10265. const betaButton = $('#redesign-beta-optin-btn');
  10266. if (betaButton.length > 0) {
  10267. GM_setValue('redditAuth', '#auth');
  10268. return betaButton[0].click();
  10269. }
  10270. GM_setValue('redditAuth', null);
  10271. window.close();
  10272. external_Swal_default().fire('', i18n('closePageNotice'));
  10273. return;
  10274. }
  10275. let website;
  10276. for (const Website of Websites) {
  10277. if (Website.test()) {
  10278. website = new Website();
  10279. break;
  10280. }
  10281. }
  10282. if (!website) {
  10283. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  10284. return;
  10285. }
  10286. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10287. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10288. }
  10289. $('body').append(`<div id="auto-task-info" style="display:${globalOptions.other.defaultShowLog ? 'block' : 'none'};${globalOptions.position.logSideX}:${globalOptions.position.logDistance.split(',')[0]}px;${globalOptions.position.logSideY}:${globalOptions.position.logDistance.split(',')[1]}px;"></div><div id="auto-task-buttons" style="display:${globalOptions.other.defaultShowButton ? 'block' : 'none'};${globalOptions.position.buttonSideX}:${globalOptions.position.buttonDistance.split(',')[0]}px;${globalOptions.position.buttonSideY}:${globalOptions.position.buttonDistance.split(',')[1]}px;"></div><div class="show-button-div" style="display:${globalOptions.other.defaultShowButton ? 'none' : 'block'};${globalOptions.position.showButtonSideX}:${globalOptions.position.showButtonDistance.split(',')[0]}px;${globalOptions.position.showButtonSideY}:${globalOptions.position.showButtonDistance.split(',')[1]}px;"><a class="auto-task-website-btn" href="javascript:void(0);" target="_self" title="${i18n('showButton')}"></a></div>`);
  10290. $('div.show-button-div').on('click', () => {
  10291. $('#auto-task-buttons').show();
  10292. $('div.show-button-div').hide();
  10293. });
  10294. const toggleLog = () => {
  10295. const $this = $('#toggle-log');
  10296. const status = $this.attr('data-status');
  10297. if (status === 'show') {
  10298. $('#auto-task-info').hide();
  10299. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10300. } else {
  10301. $('#auto-task-info').show();
  10302. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10303. }
  10304. };
  10305. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10306. if (website.doTask) {
  10307. website.doTask();
  10308. }
  10309. });
  10310. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10311. if (website.undoTask) {
  10312. website.doTask();
  10313. }
  10314. });
  10315. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10316. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10317. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10318. }
  10319. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10320. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10321. for (const button of website.buttons) {
  10322. if (website[button]) {
  10323. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10324. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10325. website[button]();
  10326. });
  10327. $('#auto-task-buttons').append(btnElement);
  10328. }
  10329. }
  10330. }
  10331. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10332. ${i18n('hideButton')}</a></p>`);
  10333. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10334. $('#auto-task-buttons').hide();
  10335. $('div.show-button-div').show();
  10336. });
  10337. const toggleLogElement = $(`<p><a id="toggle-log" class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self" data-status="${globalOptions.other.defaultShowLog ? 'show' : 'hide'}">
  10338. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10339. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10340. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10341. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10342. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10343. options(website.name, website.options);
  10344. });
  10345. }
  10346. if (website.name !== 'Setting') {
  10347. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10348. changeGlobalOptions('swal');
  10349. });
  10350. GM_registerMenuCommand(i18n('settingPage'), () => {
  10351. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10352. });
  10353. }
  10354. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  10355. if (!GM_getValue('notice')) {
  10356. var _echoLog$font;
  10357. external_Swal_default().fire({
  10358. title: i18n('swalNotice'),
  10359. icon: 'warning'
  10360. }).then(() => {
  10361. window.open(i18n('noticeLink'), '_blank');
  10362. GM_setValue('notice', new Date().getTime());
  10363. });
  10364. (_echoLog$font = scripts_echoLog({
  10365. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10366. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10367. GM_setValue('notice', new Date().getTime());
  10368. });
  10369. }
  10370. scripts_updateChecker();
  10371. };
  10372. if (window.location.hostname === 'discord.com') {
  10373. const LocalStorage = window.localStorage;
  10374. if (window.location.hash === '#auth') {
  10375. var _LocalStorage$getItem;
  10376. window.localStorage.removeItem = () => true;
  10377. const discordAuth = LocalStorage === null || LocalStorage === void 0 ? void 0 : (_LocalStorage$getItem = LocalStorage.getItem('token')) === null || _LocalStorage$getItem === void 0 ? void 0 : _LocalStorage$getItem.replace(/^"|"$/g, '');
  10378. if (discordAuth && discordAuth.length > 0) {
  10379. GM_setValue('discordAuth', {
  10380. auth: discordAuth
  10381. });
  10382. window.close();
  10383. external_Swal_default().fire('', i18n('closePageNotice'));
  10384. } else {
  10385. external_Swal_default().fire({
  10386. text: i18n('getDiscordAuthFailed'),
  10387. icon: 'error'
  10388. });
  10389. }
  10390. } else {
  10391. var _LocalStorage$getItem2;
  10392. const discordAuth = LocalStorage === null || LocalStorage === void 0 ? void 0 : (_LocalStorage$getItem2 = LocalStorage.getItem('token')) === null || _LocalStorage$getItem2 === void 0 ? void 0 : _LocalStorage$getItem2.replace(/^"|"$/g, '');
  10393. if (discordAuth && discordAuth.length > 0) {
  10394. GM_setValue('discordAuth', {
  10395. auth: discordAuth
  10396. });
  10397. }
  10398. }
  10399. } else if (window.location.hostname === 'opquests.com') {
  10400. loadScript();
  10401. } else {
  10402. if (window.location.hostname === 'key-hub.eu') {
  10403. unsafeWindow.keyhubtracker = 1;
  10404. unsafeWindow.gaData = {};
  10405. }
  10406. $(loadScript);
  10407. }
  10408. }();
  10409. })();