auto-task-v4

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

当前为 2023-01-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.31
  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. };
  1428. const zh_CN = data;
  1429. const en_US_data = {
  1430. website: 'Website',
  1431. type: 'Type',
  1432. edit: 'Edit',
  1433. whiteList: 'Whitelist',
  1434. skipTask: 'Skip undo task',
  1435. whiteListOptions: 'Whitelist options',
  1436. changeWhiteListOption: 'Whitelist option(%0)',
  1437. whiteListNotFound: 'Cannot find this whitelist: %0',
  1438. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1439. changeWebsiteOptions: 'Website options',
  1440. changeGlobalOptions: 'Global options',
  1441. ok: 'OK',
  1442. save: 'Save',
  1443. close: 'Close',
  1444. return: 'Return',
  1445. option: 'Option',
  1446. value: 'Value',
  1447. websiteOptions: 'Current website settings',
  1448. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1449. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1450. needLogin: 'Please log in first!',
  1451. getTasksInfo: 'Obtaining and processing task information...',
  1452. gettingKey: 'Getting Key...',
  1453. verifyingTask: 'Verifying task',
  1454. notice: 'Automatic task script notice',
  1455. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1456. giveawayEnded: 'This event has ended, do you want to close it?',
  1457. 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?',
  1458. confirm: 'Confirm',
  1459. cancel: 'Cancel',
  1460. unKnown: 'Unknown',
  1461. unKnownTaskType: 'Unrecognized task',
  1462. doing: 'Doing a task',
  1463. allTasksComplete: 'All tasks have been completed!',
  1464. getTaskIdFailed: 'Failed to obtain task Id!',
  1465. initSuccess: '%0 was initialized successfully!',
  1466. initFailed: '%0 initialization failed!',
  1467. errorLink: 'Link error: %0',
  1468. needInit: 'Please initialize first',
  1469. verifyingAuth: 'Verifying %0 token...',
  1470. updatingAuth: 'Update %0 token...',
  1471. initing: 'Initializing...',
  1472. getFailed: 'Failed to get %0!',
  1473. checkLoginFailed: 'Failed to detect login status!',
  1474. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1475. userId: 'User Id',
  1476. joiningGiveaway: 'Joining giveaway',
  1477. needJoinGiveaway: 'Need to join the giveaway first',
  1478. cannotUndo: 'This website does not support canceling tasks',
  1479. verifyAuth: 'Verifying %0 token...',
  1480. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1481. errorReport: 'A script error is detected, do you want to report the BUG?',
  1482. visitingLink: 'Visiting link: ',
  1483. doTask: 'DoTask',
  1484. undoTask: 'UndoTask',
  1485. verifyTask: 'Verify',
  1486. getKey: 'GetKey',
  1487. selectAll: 'SelectAll',
  1488. selectNone: 'SelectNone',
  1489. invertSelect: 'InvertSelect',
  1490. doFreeTask: 'FreeTask',
  1491. doPointTask: 'PointTask',
  1492. skipTaskOption: 'Skip task has been configured in the settings',
  1493. other: 'Other',
  1494. globalOptions: 'Global Options',
  1495. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1496. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1497. 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.',
  1498. 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.',
  1499. 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.',
  1500. saveGlobalOptions: 'SaveSettings',
  1501. settingPage: 'Setting Page',
  1502. name: 'Name',
  1503. version: 'Version',
  1504. scriptManager: 'Script Manager',
  1505. script: 'Script',
  1506. environment: 'Environment',
  1507. os: 'OS',
  1508. browser: 'Browser',
  1509. getId: 'Get %0 id',
  1510. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1511. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1512. showButton: 'ShowButton',
  1513. hideButton: 'HideButton',
  1514. showLog: 'ShowLog',
  1515. hideLog: 'HideLog',
  1516. defaultShowButton: 'Default display button',
  1517. defaultShowLog: 'Display log by default',
  1518. debug: 'Output debug log, do not enable this option!',
  1519. receivePreview: 'Receive preview updates',
  1520. position: 'Component position',
  1521. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1522. 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',
  1523. 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',
  1524. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1525. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1526. 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',
  1527. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1528. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1529. 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',
  1530. hotKey: 'Shortcut key',
  1531. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1532. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1533. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1534. tasksHistory: 'TasksHistory',
  1535. clearHistory: 'Clear history',
  1536. clearHistoryFinished: 'The mission history has been cleared!',
  1537. deleteTask: 'Delete task',
  1538. lastChangeTime: 'Last Change Time',
  1539. clearTaskFinished: 'Delete the following tasks completed!',
  1540. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1541. syncData: 'DataSync',
  1542. settingData: 'Uploading data...',
  1543. gettingData: 'Getting data...',
  1544. help: 'Help',
  1545. fileName: 'Filename',
  1546. upload2gist: 'Sync to Gist',
  1547. downloadFromGist: 'Sync from Gist',
  1548. saveAndTest: 'Save configuration and test',
  1549. testSuccess: 'Test success!',
  1550. testFailed: 'Test failed!',
  1551. saveAndTestNotice: 'Please save the configuration and test first!',
  1552. processingData: 'Processing data...',
  1553. updatingData: 'Uploading data...',
  1554. syncDataSuccess: 'Synchronized data successfully!',
  1555. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1556. downloadingData: 'Downloading data...',
  1557. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1558. savingData: 'Saving data...',
  1559. syncHistory: 'Synchronize tasks history',
  1560. checkUpdateFailed: 'Check update failed',
  1561. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1562. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1563. gistOptions: 'Gist Settings',
  1564. 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!',
  1565. 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!',
  1566. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1567. toGithub: 'Feedback(Github)',
  1568. toKeylol: 'Feedback(Keylol)',
  1569. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1570. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1571. updateText: 'Updates in version %0:',
  1572. Active: 'Active',
  1573. Ended: 'Ended',
  1574. Banned: 'Banned',
  1575. Paused: 'Paused',
  1576. notStart: 'notStart',
  1577. noRemoteData: 'No data remotely',
  1578. errorRemoteDataFormat: 'Remote data has wrong format',
  1579. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1580. groups: 'Group',
  1581. officialGroups: 'Official Group',
  1582. wishlists: 'Wishlist',
  1583. follows: 'Follow Game',
  1584. forums: 'Forum',
  1585. workshops: 'Favorite Workshop',
  1586. curators: 'Curator',
  1587. workshopVotes: 'Voteup Workshop',
  1588. announcements: 'Announcement',
  1589. steamCommunity: 'Steam Community',
  1590. steamStore: 'Steam Store',
  1591. licenses: 'Add License',
  1592. playtests: 'Playtest Access',
  1593. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1594. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1595. joiningSteamGroup: 'Joining Steam Group',
  1596. leavingSteamGroup: 'Leaving Steam Group',
  1597. gettingSteamGroupId: 'Getting Steam Group Id',
  1598. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1599. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1600. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1601. subscribingForum: 'Subscribing the Steam Forum',
  1602. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1603. gettingForumId: 'Getting Steam Forum Id',
  1604. followingCurator: 'Following Steam Curator',
  1605. unfollowingCurator: 'Unfollowing Steam Curator',
  1606. gettingCuratorId: 'Getting Steam Curator Id',
  1607. addingToWishlist: 'Adding the game to the Steam wishlist',
  1608. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1609. followingGame: 'Following Steam games',
  1610. unfollowingGame: 'Unfollowing Steam games',
  1611. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1612. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1613. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1614. votingUpWorkshop: 'Liking Steam workshop items',
  1615. gettingAnnouncementParams: 'Getting Steam announcement information',
  1616. likingAnnouncement: 'Liking Steam announcement',
  1617. changingArea: 'Changing Steam area: %0...',
  1618. notNeededChangeArea: 'The current area does not need to be changed',
  1619. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1620. gettingAreaInfo: 'Getting Steam area information...',
  1621. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1622. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1623. gettingSubid: 'Getting subid',
  1624. addingFreeLicense: 'Adding free license',
  1625. missParams: 'Missing parameters',
  1626. gettingLicenses: 'Getting licenses...',
  1627. requestingPlayTestAccess: 'Requesting play test access',
  1628. 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.',
  1629. servers: 'Server',
  1630. joiningDiscordServer: 'Joining Discord Server',
  1631. leavingDiscordServer: 'Leaving Discord Server',
  1632. gettingDiscordGuild: 'Getting Discord server Id',
  1633. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1634. discordImportantNotice: 'Important Reminder! ! !',
  1635. 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! ! !',
  1636. continue: 'Continue',
  1637. skipDiscordTask: 'Skip',
  1638. continueAndDontRemindAgain: 'Continue without Reminders',
  1639. users: 'User',
  1640. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1641. insBanned: 'Your Instagram account has been banned',
  1642. verifyingInsAuth: 'Verifying Instagram token...',
  1643. gettingInsUserId: 'Getting Instagram user Id',
  1644. followingIns: 'Following Instagram user',
  1645. unfollowingIns: 'Unfollowing Instagram user',
  1646. reddits: 'Reddit/User',
  1647. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1648. changingRedditVersion: 'Switching Reddit to a new version page...',
  1649. joiningReddit: 'Joining the Reddit',
  1650. leavingReddit: 'Leaving the Reddit',
  1651. followingRedditUser: 'Following Reddit User',
  1652. unfollowingRedditUser: 'Unfollowing Reddit User',
  1653. channels: 'Channel',
  1654. followingTwitchChannel: 'Following Twitch Channel',
  1655. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1656. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1657. checkingTwitchIntegrity: 'Checking Twitch integrity...',
  1658. twitterUser: 'Twitter User',
  1659. retweets: 'Retweet',
  1660. gettingTwitterUserId: 'Getting Twitter User Id',
  1661. followingTwitterUser: 'Following Twitter User',
  1662. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1663. retweetting: 'Retweetting',
  1664. unretweetting: 'Unretweetting',
  1665. names: 'Group/Public/Wall',
  1666. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1667. gettingVkId: 'Getting Vk task Id',
  1668. joiningVkGroup: 'Joining Vk Group',
  1669. leavingVkGroup: 'Leaving Vk Group',
  1670. joiningVkPublic: 'Joining Vk Public',
  1671. leavingVkPublic: 'Leaving Vk Public',
  1672. sendingVkWall: 'Sending Vk Wall',
  1673. deletingVkWall: 'Deleting Vk Wall',
  1674. youtubeChannel: 'YouTube Channel',
  1675. likes: 'Like',
  1676. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1677. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1678. gettingYtbToken: 'Getting YouTube Token...',
  1679. followingYtbChannel: 'Subscribing to YouTube channel',
  1680. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1681. likingYtbVideo: 'Liking YouTube video',
  1682. unlikingYtbVideo: 'Unliking YouTube video',
  1683. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1684. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1685. noPoints: 'Not enough points, skip the lottery',
  1686. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1687. joiningLottery: 'Joining the lottery',
  1688. doingGleamTask: 'Doing Gleam Task...',
  1689. gettingGleamLink: 'Getting Gleam task link...',
  1690. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1691. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1692. 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!',
  1693. giveeClubVerifyNotice: 'Verifying task...',
  1694. giveeClubVerifyFinished: 'Wait for the verification to complete and join it by yourself',
  1695. doingKeyhubTask: 'Doing Keyhub Task...',
  1696. 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...'
  1697. };
  1698. const en_US = en_US_data;
  1699. const languages = {
  1700. zh: zh_CN,
  1701. en: en_US
  1702. };
  1703. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1704. const I18n = function(key) {
  1705. var _languages$language;
  1706. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1707. argvs[_key - 1] = arguments[_key];
  1708. }
  1709. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1710. return key;
  1711. }
  1712. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1713. };
  1714. const i18n = I18n;
  1715. function throwError(error, name) {
  1716. if (window.TRACE) {
  1717. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1718. }
  1719. external_Swal_default().fire({
  1720. title: i18n('errorReport'),
  1721. icon: 'error',
  1722. showCancelButton: true,
  1723. confirmButtonText: i18n('toGithub'),
  1724. showDenyButton: true,
  1725. denyButtonText: i18n('toKeylol'),
  1726. cancelButtonText: i18n('close')
  1727. }).then(_ref => {
  1728. let {
  1729. isDenied,
  1730. isConfirmed
  1731. } = _ref;
  1732. if (isConfirmed) {
  1733. 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,
  1734. 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');
  1735. } else if (isDenied) {
  1736. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1737.  
  1738. 环境:
  1739.  
  1740. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1741.  
  1742. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1743. 脚本版本: ${GM_info.script.version}
  1744.  
  1745. 报错信息:
  1746. [code]${error.stack}[/code]
  1747.  
  1748. 执行日志:
  1749. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1750. GM_setClipboard(text);
  1751. external_Swal_default().fire({
  1752. title: i18n('copySuccess'),
  1753. icon: 'success',
  1754. confirmButtonText: i18n('ok')
  1755. }).then(() => {
  1756. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1757. });
  1758. }
  1759. });
  1760. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1761. }
  1762. class Social {
  1763. tasks;
  1764. getRealParams(name, links, doTask, link2param) {
  1765. try {
  1766. let realParams = [];
  1767. if (links.length > 0) {
  1768. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1769. }
  1770. if (!doTask && this.tasks[name].length > 0) {
  1771. realParams = [ ...realParams, ...this.tasks[name] ];
  1772. }
  1773. return unique(realParams);
  1774. } catch (error) {
  1775. throwError(error, 'Social.getRealParams');
  1776. return [];
  1777. }
  1778. }
  1779. }
  1780. const social_Social = Social;
  1781. var _GM_getValue;
  1782. const defaultTasksTemplate = {
  1783. servers: []
  1784. };
  1785. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1786. class Discord extends social_Social {
  1787. tasks = JSON.parse(defaultTasks);
  1788. whiteList = {
  1789. ...JSON.parse(defaultTasks),
  1790. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1791. };
  1792. #auth = GM_getValue('discordAuth') || {};
  1793. #cache = GM_getValue('discordCache') || {};
  1794. #initialized = false;
  1795. async init() {
  1796. try {
  1797. if (!GM_getValue('dontRemindDiscordAgain')) {
  1798. const result = await external_Swal_default().fire({
  1799. title: i18n('discordImportantNotice'),
  1800. text: i18n('discordImportantNoticeText'),
  1801. showCancelButton: true,
  1802. showDenyButton: true,
  1803. confirmButtonText: i18n('continue'),
  1804. cancelButtonText: i18n('skipDiscordTask'),
  1805. denyButtonText: i18n('continueAndDontRemindAgain')
  1806. }).then(_ref => {
  1807. let {
  1808. isConfirmed,
  1809. isDenied
  1810. } = _ref;
  1811. if (isConfirmed) {
  1812. return true;
  1813. }
  1814. if (isDenied) {
  1815. GM_setValue('dontRemindDiscordAgain', true);
  1816. return true;
  1817. }
  1818. return false;
  1819. });
  1820. if (!result) {
  1821. this.#initialized = false;
  1822. return 'skip';
  1823. }
  1824. }
  1825. if (!globalOptions.doTask.discord.servers && !globalOptions.undoTask.discord.servers) {
  1826. this.#initialized = false;
  1827. return 'skip';
  1828. }
  1829. if (this.#initialized) {
  1830. return true;
  1831. }
  1832. if (!this.#auth.auth) {
  1833. if (await this.#updateAuth()) {
  1834. this.#initialized = true;
  1835. return true;
  1836. }
  1837. return false;
  1838. }
  1839. const isVerified = await this.#verifyAuth();
  1840. if (isVerified) {
  1841. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1842. this.#initialized = true;
  1843. return true;
  1844. }
  1845. GM_setValue('discordAuth', {
  1846. auth: null
  1847. });
  1848. if (await this.#updateAuth()) {
  1849. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1850. this.#initialized = true;
  1851. return true;
  1852. }
  1853. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1854. return false;
  1855. } catch (error) {
  1856. throwError(error, 'Discord.init');
  1857. return false;
  1858. }
  1859. }
  1860. async #verifyAuth() {
  1861. try {
  1862. const logStatus = scripts_echoLog({
  1863. text: i18n('verifyingAuth', 'Discord')
  1864. });
  1865. const {
  1866. result,
  1867. statusText,
  1868. status,
  1869. data
  1870. } = await tools_httpRequest({
  1871. url: 'https://discord.com/api/v6/users/@me',
  1872. method: 'HEAD',
  1873. headers: {
  1874. authorization: this.#auth.auth
  1875. }
  1876. });
  1877. if (result === 'Success') {
  1878. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1879. logStatus.success();
  1880. return true;
  1881. }
  1882. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1883. return false;
  1884. }
  1885. logStatus.error(`${result}:${statusText}(${status})`);
  1886. return false;
  1887. } catch (error) {
  1888. throwError(error, 'Discord.verifyAuth');
  1889. return false;
  1890. }
  1891. }
  1892. async #updateAuth() {
  1893. try {
  1894. const logStatus = scripts_echoLog({
  1895. text: i18n('updatingAuth', 'Discord')
  1896. });
  1897. return await new Promise(resolve => {
  1898. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1899. active: true,
  1900. insert: true,
  1901. setParent: true
  1902. });
  1903. newTab.onclose = async () => {
  1904. var _GM_getValue2;
  1905. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1906. if (auth) {
  1907. this.#auth = {
  1908. auth: auth
  1909. };
  1910. logStatus.success();
  1911. resolve(await this.#verifyAuth());
  1912. } else {
  1913. logStatus.error('Error: Update discord auth failed!');
  1914. resolve(false);
  1915. }
  1916. };
  1917. });
  1918. } catch (error) {
  1919. throwError(error, 'Discord.updateAuth');
  1920. return false;
  1921. }
  1922. }
  1923. async #joinServer(inviteId) {
  1924. try {
  1925. const logStatus = scripts_echoLog({
  1926. type: 'joiningDiscordServer',
  1927. text: inviteId
  1928. });
  1929. const {
  1930. result,
  1931. statusText,
  1932. status,
  1933. data
  1934. } = await tools_httpRequest({
  1935. url: `https://discord.com/api/v9/invites/${inviteId}`,
  1936. method: 'POST',
  1937. dataType: 'json',
  1938. headers: {
  1939. authorization: this.#auth.auth,
  1940. origin: 'https://discord.com',
  1941. referer: `https://discord.com/invite/${inviteId}`
  1942. }
  1943. });
  1944. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1945. var _data$response, _data$response$guild;
  1946. logStatus.success();
  1947. 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);
  1948. if (guild) {
  1949. this.#setCache(inviteId, guild);
  1950. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1951. }
  1952. return true;
  1953. }
  1954. logStatus.error(`${result}:${statusText}(${status})`);
  1955. return false;
  1956. } catch (error) {
  1957. throwError(error, 'Discord.joinServer');
  1958. return false;
  1959. }
  1960. }
  1961. async #leaveServer(inviteId) {
  1962. try {
  1963. if (this.whiteList.servers.includes(inviteId)) {
  1964. scripts_echoLog({
  1965. type: 'whiteList',
  1966. text: 'Discord.leaveServer',
  1967. id: inviteId
  1968. });
  1969. return true;
  1970. }
  1971. const guild = await this.#getGuild(inviteId);
  1972. if (!guild) {
  1973. return false;
  1974. }
  1975. const logStatus = scripts_echoLog({
  1976. type: 'leavingDiscordServer',
  1977. text: guild
  1978. });
  1979. const {
  1980. result,
  1981. statusText,
  1982. status,
  1983. data
  1984. } = await tools_httpRequest({
  1985. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  1986. method: 'DELETE',
  1987. headers: {
  1988. authorization: this.#auth.auth
  1989. }
  1990. });
  1991. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  1992. logStatus.success();
  1993. return true;
  1994. }
  1995. logStatus.error(`${result}:${statusText}(${status})`);
  1996. return false;
  1997. } catch (error) {
  1998. throwError(error, 'Discord.leaveServer');
  1999. return false;
  2000. }
  2001. }
  2002. async #getGuild(inviteId) {
  2003. try {
  2004. const logStatus = scripts_echoLog({
  2005. type: 'gettingDiscordGuild',
  2006. text: inviteId
  2007. });
  2008. const guild = this.#cache[inviteId];
  2009. if (guild) {
  2010. logStatus.success();
  2011. return guild;
  2012. }
  2013. const {
  2014. result,
  2015. statusText,
  2016. status,
  2017. data
  2018. } = await tools_httpRequest({
  2019. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2020. responseType: 'json',
  2021. method: 'GET'
  2022. });
  2023. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2024. var _data$response2, _data$response2$guild;
  2025. 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;
  2026. if (guild) {
  2027. logStatus.success();
  2028. this.#setCache(inviteId, guild);
  2029. return guild;
  2030. }
  2031. logStatus.error(`${result}:${statusText}(${status})`);
  2032. return false;
  2033. }
  2034. logStatus.error(`${result}:${statusText}(${status})`);
  2035. return false;
  2036. } catch (error) {
  2037. throwError(error, 'Discord.getGuild');
  2038. return false;
  2039. }
  2040. }
  2041. async toggle(_ref2) {
  2042. let {
  2043. doTask = true,
  2044. serverLinks = []
  2045. } = _ref2;
  2046. try {
  2047. if (!this.#initialized) {
  2048. scripts_echoLog({
  2049. text: i18n('needInit')
  2050. });
  2051. return false;
  2052. }
  2053. const prom = [];
  2054. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  2055. scripts_echoLog({
  2056. type: 'globalOptionsSkip',
  2057. text: 'discord.servers'
  2058. });
  2059. } else {
  2060. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  2061. var _link$match;
  2062. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2063. });
  2064. if (realServers.length > 0) {
  2065. for (const server of realServers) {
  2066. if (doTask) {
  2067. prom.push(this.#joinServer(server));
  2068. } else {
  2069. prom.push(this.#leaveServer(server));
  2070. }
  2071. await delay(1e3);
  2072. }
  2073. }
  2074. }
  2075. return await Promise.all(prom).then(() => true);
  2076. } catch (error) {
  2077. throwError(error, 'Discord.toggleServers');
  2078. return false;
  2079. }
  2080. }
  2081. #setCache(inviteId, guild) {
  2082. try {
  2083. this.#cache[inviteId] = guild;
  2084. GM_setValue('discordCache', this.#cache);
  2085. } catch (error) {
  2086. throwError(error, 'Discord.setCache');
  2087. }
  2088. }
  2089. }
  2090. const social_Discord = Discord;
  2091. var Instagram_GM_getValue;
  2092. const Instagram_defaultTasksTemplate = {
  2093. users: []
  2094. };
  2095. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2096. class Instagram extends social_Social {
  2097. tasks = JSON.parse(Instagram_defaultTasks);
  2098. whiteList = {
  2099. ...JSON.parse(Instagram_defaultTasks),
  2100. ...(Instagram_GM_getValue = GM_getValue('whiteList')) === null || Instagram_GM_getValue === void 0 ? void 0 : Instagram_GM_getValue.instagram
  2101. };
  2102. #cache = GM_getValue('instagramCache') || {};
  2103. #auth = {};
  2104. #initialized = false;
  2105. async init() {
  2106. try {
  2107. if (this.#initialized) {
  2108. return true;
  2109. }
  2110. const isVerified = await this.#getUserInfo();
  2111. if (isVerified) {
  2112. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2113. this.#initialized = true;
  2114. return true;
  2115. }
  2116. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2117. return false;
  2118. } catch (error) {
  2119. throwError(error, 'Instagram.init');
  2120. return false;
  2121. }
  2122. }
  2123. async #getUserInfo() {
  2124. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2125. try {
  2126. const logStatus = scripts_echoLog({
  2127. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2128. text: name
  2129. });
  2130. const userId = this.#cache[name];
  2131. if (userId && name !== 'instagram') {
  2132. logStatus.success();
  2133. return userId;
  2134. }
  2135. const {
  2136. result,
  2137. statusText,
  2138. status,
  2139. data
  2140. } = await tools_httpRequest({
  2141. url: `https://www.instagram.com/${name}/`,
  2142. method: 'GET'
  2143. });
  2144. if (result === 'Success') {
  2145. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2146. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2147. return false;
  2148. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2149. logStatus.error(`Error:${i18n('insBanned')}`);
  2150. return false;
  2151. }
  2152. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2153. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2154. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2155. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2156. if (name === 'instagram') {
  2157. if (csrftoken && hash) {
  2158. this.#auth = {
  2159. csrftoken: csrftoken,
  2160. hash: hash
  2161. };
  2162. return true;
  2163. }
  2164. return false;
  2165. }
  2166. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2167. if (id) {
  2168. this.#setCache(name, id);
  2169. logStatus.success();
  2170. return id;
  2171. }
  2172. logStatus.error('Error: Get ins data error!');
  2173. return false;
  2174. }
  2175. logStatus.error(`${result}:${statusText}(${status})`);
  2176. return false;
  2177. }
  2178. return false;
  2179. } catch (error) {
  2180. throwError(error, 'Instagram.getUserInfo');
  2181. return false;
  2182. }
  2183. }
  2184. async #followUser(name) {
  2185. try {
  2186. const id = await this.#getUserInfo(name);
  2187. if (!id) {
  2188. return false;
  2189. }
  2190. const logStatus = scripts_echoLog({
  2191. type: 'followingIns',
  2192. text: name
  2193. });
  2194. const {
  2195. result,
  2196. statusText,
  2197. status,
  2198. data
  2199. } = await tools_httpRequest({
  2200. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2201. method: 'POST',
  2202. dataType: 'json',
  2203. headers: {
  2204. 'x-csrftoken': this.#auth.csrftoken,
  2205. origin: 'https://www.instagram.com',
  2206. referer: `https://www.instagram.com/${name}/`,
  2207. 'content-type': 'application/x-www-form-urlencoded',
  2208. 'sec-fetch-site': 'same-origin',
  2209. 'x-instagram-ajax': this.#auth.hash
  2210. }
  2211. });
  2212. if (result === 'Success') {
  2213. var _data$response, _data$response2;
  2214. 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') {
  2215. logStatus.success();
  2216. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2217. return true;
  2218. }
  2219. 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})`}`);
  2220. return false;
  2221. }
  2222. logStatus.error(`${result}:${statusText}(${status})`);
  2223. return false;
  2224. } catch (error) {
  2225. throwError(error, 'Instagram.followUser');
  2226. return false;
  2227. }
  2228. }
  2229. async #unfollowUser(name) {
  2230. try {
  2231. if (this.whiteList.users.includes(name)) {
  2232. scripts_echoLog({
  2233. type: 'whiteList',
  2234. text: 'Instagram.unfollowUser',
  2235. id: name
  2236. });
  2237. return true;
  2238. }
  2239. const id = await this.#getUserInfo(name);
  2240. if (!id) {
  2241. return false;
  2242. }
  2243. const logStatus = scripts_echoLog({
  2244. type: 'unfollowingIns',
  2245. text: name
  2246. });
  2247. const {
  2248. result,
  2249. statusText,
  2250. status,
  2251. data
  2252. } = await tools_httpRequest({
  2253. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2254. method: 'POST',
  2255. dataType: 'json',
  2256. headers: {
  2257. 'x-csrftoken': this.#auth.csrftoken,
  2258. origin: 'https://www.instagram.com',
  2259. referer: `https://www.instagram.com/${name}/`,
  2260. 'content-type': 'application/x-www-form-urlencoded',
  2261. 'sec-fetch-site': 'same-origin',
  2262. 'x-instagram-ajax': this.#auth.hash
  2263. }
  2264. });
  2265. if (result === 'Success') {
  2266. var _data$response3;
  2267. 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') {
  2268. logStatus.success();
  2269. return true;
  2270. }
  2271. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2272. return false;
  2273. }
  2274. logStatus.error(`${result}:${statusText}(${status})`);
  2275. return false;
  2276. } catch (error) {
  2277. throwError(error, 'Instagram.unfollowUser');
  2278. return false;
  2279. }
  2280. }
  2281. async toggle(_ref) {
  2282. let {
  2283. doTask = true,
  2284. userLinks = []
  2285. } = _ref;
  2286. try {
  2287. if (!this.#initialized) {
  2288. scripts_echoLog({
  2289. text: i18n('needInit')
  2290. });
  2291. return false;
  2292. }
  2293. const prom = [];
  2294. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2295. scripts_echoLog({
  2296. type: 'globalOptionsSkip',
  2297. text: 'instagram.users'
  2298. });
  2299. } else {
  2300. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2301. var _link$match;
  2302. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2303. });
  2304. if (realUsers.length > 0) {
  2305. for (const username of realUsers) {
  2306. if (doTask) {
  2307. prom.push(this.#followUser(username));
  2308. } else {
  2309. prom.push(this.#unfollowUser(username));
  2310. }
  2311. await delay(1e3);
  2312. }
  2313. }
  2314. }
  2315. return await Promise.all(prom).then(() => true);
  2316. } catch (error) {
  2317. throwError(error, 'Instagram.toggleUsers');
  2318. return false;
  2319. }
  2320. }
  2321. #setCache(name, id) {
  2322. try {
  2323. this.#cache[name] = id;
  2324. GM_setValue('instagramCache', this.#cache);
  2325. } catch (error) {
  2326. throwError(error, 'Instagram.setCache');
  2327. }
  2328. }
  2329. }
  2330. const social_Instagram = Instagram;
  2331. var Reddit_GM_getValue;
  2332. const Reddit_defaultTasksTemplate = {
  2333. reddits: []
  2334. };
  2335. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2336. class Reddit extends social_Social {
  2337. tasks = JSON.parse(Reddit_defaultTasks);
  2338. whiteList = {
  2339. ...JSON.parse(Reddit_defaultTasks),
  2340. ...(Reddit_GM_getValue = GM_getValue('whiteList')) === null || Reddit_GM_getValue === void 0 ? void 0 : Reddit_GM_getValue.reddit
  2341. };
  2342. #auth;
  2343. #initialized = false;
  2344. async init() {
  2345. try {
  2346. if (this.#initialized) {
  2347. return true;
  2348. }
  2349. const isVerified = await this.#updateAuth();
  2350. if (isVerified) {
  2351. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2352. this.#initialized = true;
  2353. return true;
  2354. }
  2355. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2356. return false;
  2357. } catch (error) {
  2358. throwError(error, 'Reddit.init');
  2359. return false;
  2360. }
  2361. }
  2362. async #useBeta() {
  2363. try {
  2364. const logStatus = scripts_echoLog({
  2365. text: i18n('changingRedditVersion')
  2366. });
  2367. GM_setValue('redditAuth', null);
  2368. return await new Promise(resolve => {
  2369. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2370. active: true,
  2371. insert: true,
  2372. setParent: true
  2373. });
  2374. newTab.onclose = async () => {
  2375. logStatus.success();
  2376. resolve(await this.#updateAuth(true));
  2377. };
  2378. });
  2379. } catch (error) {
  2380. throwError(error, 'Reddit.useBeta');
  2381. return false;
  2382. }
  2383. }
  2384. async #updateAuth() {
  2385. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2386. try {
  2387. const logStatus = scripts_echoLog({
  2388. text: i18n('updatingAuth', 'Reddit')
  2389. });
  2390. const {
  2391. result,
  2392. statusText,
  2393. status,
  2394. data
  2395. } = await tools_httpRequest({
  2396. url: 'https://www.reddit.com/',
  2397. method: 'GET',
  2398. nochche: true,
  2399. headers: {
  2400. 'Cache-Control': 'no-cache'
  2401. }
  2402. });
  2403. if (result === 'Success') {
  2404. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2405. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2406. return false;
  2407. }
  2408. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2409. var _data$responseText$ma;
  2410. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2411. return await this.#useBeta();
  2412. }
  2413. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2414. if (accessToken) {
  2415. this.#auth = {
  2416. token: accessToken
  2417. };
  2418. logStatus.success();
  2419. return true;
  2420. }
  2421. logStatus.error('Error: Parameter "accessToken" not found!');
  2422. return false;
  2423. }
  2424. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2425. return false;
  2426. }
  2427. logStatus.error(`${result}:${statusText}(${status})`);
  2428. return false;
  2429. } catch (error) {
  2430. throwError(error, 'Reddit.updateAuth');
  2431. return false;
  2432. }
  2433. }
  2434. async toggleTask(_ref) {
  2435. let {
  2436. name,
  2437. doTask = true
  2438. } = _ref;
  2439. try {
  2440. if (!doTask && this.whiteList.reddits.includes(name)) {
  2441. scripts_echoLog({
  2442. type: 'whiteList',
  2443. text: 'Reddit.undoTask',
  2444. id: name
  2445. });
  2446. return true;
  2447. }
  2448. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2449. if (/^u_/.test(name)) {
  2450. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2451. }
  2452. const logStatus = scripts_echoLog({
  2453. type: type,
  2454. text: name
  2455. });
  2456. const {
  2457. result,
  2458. statusText,
  2459. status,
  2460. data
  2461. } = await tools_httpRequest({
  2462. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2463. method: 'POST',
  2464. headers: {
  2465. authorization: `Bearer ${this.#auth.token}`,
  2466. 'content-type': 'application/x-www-form-urlencoded'
  2467. },
  2468. data: $.param({
  2469. action: doTask ? 'sub' : 'unsub',
  2470. sr_name: name,
  2471. api_type: 'json'
  2472. })
  2473. });
  2474. if (result === 'Success') {
  2475. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2476. logStatus.success();
  2477. if (doTask) {
  2478. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2479. }
  2480. return true;
  2481. }
  2482. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2483. return false;
  2484. }
  2485. logStatus.error(`${result}:${statusText}(${status})`);
  2486. return false;
  2487. } catch (error) {
  2488. throwError(error, 'Reddit.toggleTask');
  2489. return false;
  2490. }
  2491. }
  2492. async toggle(_ref2) {
  2493. let {
  2494. doTask = true,
  2495. redditLinks = []
  2496. } = _ref2;
  2497. try {
  2498. if (!this.#initialized) {
  2499. scripts_echoLog({
  2500. text: i18n('needInit')
  2501. });
  2502. return false;
  2503. }
  2504. const prom = [];
  2505. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2506. scripts_echoLog({
  2507. type: 'globalOptionsSkip',
  2508. text: 'reddit.reddits'
  2509. });
  2510. } else {
  2511. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2512. var _link$match, _link$match2;
  2513. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2514. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2515. if (userName) {
  2516. return name || userName;
  2517. }
  2518. return name;
  2519. });
  2520. if (realReddits.length > 0) {
  2521. for (const name of realReddits) {
  2522. prom.push(this.toggleTask({
  2523. name: name,
  2524. doTask: doTask
  2525. }));
  2526. await delay(1e3);
  2527. }
  2528. }
  2529. }
  2530. return await Promise.all(prom).then(() => true);
  2531. } catch (error) {
  2532. throwError(error, 'Reddit.toggle');
  2533. return false;
  2534. }
  2535. }
  2536. }
  2537. const social_Reddit = Reddit;
  2538. var Twitch_GM_getValue;
  2539. const Twitch_defaultTasksTemplate = {
  2540. channels: []
  2541. };
  2542. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2543. class Twitch extends social_Social {
  2544. tasks = JSON.parse(Twitch_defaultTasks);
  2545. whiteList = {
  2546. ...JSON.parse(Twitch_defaultTasks),
  2547. ...(Twitch_GM_getValue = GM_getValue('whiteList')) === null || Twitch_GM_getValue === void 0 ? void 0 : Twitch_GM_getValue.twitch
  2548. };
  2549. #auth = GM_getValue('twitchAuth') || {};
  2550. #cache = GM_getValue('twitchCache') || {};
  2551. #initialized = false;
  2552. #integrityToken;
  2553. async init() {
  2554. try {
  2555. if (this.#initialized) {
  2556. return true;
  2557. }
  2558. if (!this.#auth.authToken || !this.#auth.clientId || !this.#auth.clientVersion || !this.#auth.deviceId || !this.#auth.clientSessionId) {
  2559. if (await this.#updateAuth()) {
  2560. this.#initialized = true;
  2561. return true;
  2562. }
  2563. return false;
  2564. }
  2565. const isVerified = await this.#verifyAuth(true);
  2566. if (isVerified) {
  2567. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2568. this.#initialized = true;
  2569. return true;
  2570. }
  2571. GM_setValue('twitchAuth', null);
  2572. if (await this.#updateAuth()) {
  2573. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2574. this.#initialized = true;
  2575. return true;
  2576. }
  2577. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2578. return false;
  2579. } catch (error) {
  2580. throwError(error, 'Twitch.init');
  2581. return false;
  2582. }
  2583. }
  2584. async #verifyAuth(isFirst) {
  2585. try {
  2586. const logStatus = scripts_echoLog({
  2587. text: i18n('verifyingAuth', 'Twitch')
  2588. });
  2589. const {
  2590. result,
  2591. statusText,
  2592. status,
  2593. data
  2594. } = await tools_httpRequest({
  2595. url: 'https://gql.twitch.tv/gql',
  2596. method: 'POST',
  2597. dataType: 'json',
  2598. headers: {
  2599. Authorization: `OAuth ${this.#auth.authToken}`,
  2600. 'Client-Id': this.#auth.clientId
  2601. },
  2602. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2603. });
  2604. if (result === 'Success') {
  2605. var _data$response, _data$response$, _data$response$$data;
  2606. 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) {
  2607. await this.#integrity(isFirst);
  2608. logStatus.success();
  2609. return true;
  2610. }
  2611. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2612. return false;
  2613. }
  2614. logStatus.error(`${result}:${statusText}(${status})`);
  2615. return false;
  2616. } catch (error) {
  2617. throwError(error, 'Twitch.verifyAuth');
  2618. return false;
  2619. }
  2620. }
  2621. async #integrity() {
  2622. let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  2623. let ct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2624. try {
  2625. const logStatus = scripts_echoLog({
  2626. text: i18n('checkingTwitchIntegrity')
  2627. });
  2628. if (isFirst && (!this.#auth.authToken || !this.#auth.clientId || !this.#auth.clientVersion || !this.#auth.deviceId || !this.#auth.clientSessionId)) {
  2629. return await this.#updateAuth(false);
  2630. }
  2631. const {
  2632. result,
  2633. statusText,
  2634. status,
  2635. data
  2636. } = await tools_httpRequest({
  2637. url: 'https://gql.twitch.tv/integrity',
  2638. method: 'POST',
  2639. dataType: 'json',
  2640. anonymous: true,
  2641. headers: {
  2642. Origin: 'https://www.twitch.tv',
  2643. Referer: 'https://www.twitch.tv/',
  2644. Authorization: `OAuth ${this.#auth.authToken}`,
  2645. 'Client-Id': this.#auth.clientId,
  2646. 'Client-Version': this.#auth.clientVersion,
  2647. 'X-Device-Id': this.#auth.deviceId,
  2648. 'Client-Session-Id': this.#auth.clientSessionId,
  2649. 'x-kpsdk-ct': ct
  2650. }
  2651. });
  2652. if (result === 'Success') {
  2653. var _data$responseHeaders, _data$response2;
  2654. if (!ct && data !== null && data !== void 0 && (_data$responseHeaders = data.responseHeaders) !== null && _data$responseHeaders !== void 0 && _data$responseHeaders['x-kpsdk-ct']) {
  2655. return await this.#integrity(isFirst, data.responseHeaders['x-kpsdk-ct']);
  2656. }
  2657. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.token) {
  2658. this.#integrityToken = data.response.token;
  2659. logStatus.success();
  2660. return true;
  2661. }
  2662. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2663. return false;
  2664. }
  2665. logStatus.error(`${result}:${statusText}(${status})`);
  2666. return false;
  2667. } catch (error) {
  2668. throwError(error, 'Twitch.integrity');
  2669. return false;
  2670. }
  2671. }
  2672. async #updateAuth() {
  2673. let isFirst = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  2674. try {
  2675. const logStatus = scripts_echoLog({
  2676. text: i18n('updatingAuth', 'Twitch')
  2677. });
  2678. return await new Promise(resolve => {
  2679. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2680. active: true,
  2681. insert: true,
  2682. setParent: true
  2683. });
  2684. newTab.onclose = async () => {
  2685. const auth = GM_getValue('twitchAuth');
  2686. if (auth) {
  2687. this.#auth = auth;
  2688. logStatus.success();
  2689. resolve(await this.#verifyAuth(isFirst));
  2690. } else {
  2691. logStatus.error('Error: Update twitch auth failed!');
  2692. resolve(false);
  2693. }
  2694. };
  2695. });
  2696. } catch (error) {
  2697. throwError(error, 'Twitch.updateAuth');
  2698. return false;
  2699. }
  2700. }
  2701. async #toggleChannel(_ref) {
  2702. let {
  2703. name,
  2704. doTask = true
  2705. } = _ref;
  2706. try {
  2707. if (!doTask && this.whiteList.channels.includes(name)) {
  2708. scripts_echoLog({
  2709. type: 'whiteList',
  2710. text: 'Twitch.unfollowChannel',
  2711. id: name
  2712. });
  2713. return true;
  2714. }
  2715. const channelId = await this.#getChannelId(name);
  2716. if (!channelId) {
  2717. return false;
  2718. }
  2719. const logStatus = scripts_echoLog({
  2720. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2721. text: name
  2722. });
  2723. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"800e7346bdf7e5278a3c1d3f21b2b56e2639928f86815677a7126b093b2fdd08"}}}]';
  2724. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"f7dae976ebf41c755ae2d758546bfd176b4eeb856656098bb40e0a672ca0d880"}}}]';
  2725. const {
  2726. result,
  2727. statusText,
  2728. status,
  2729. data
  2730. } = await tools_httpRequest({
  2731. url: 'https://gql.twitch.tv/gql',
  2732. method: 'POST',
  2733. dataType: 'json',
  2734. anonymous: true,
  2735. headers: {
  2736. Origin: 'https://www.twitch.tv',
  2737. Referer: 'https://www.twitch.tv/',
  2738. Authorization: `OAuth ${this.#auth.authToken}`,
  2739. 'Client-Id': this.#auth.clientId,
  2740. 'Client-Version': this.#auth.clientVersion,
  2741. 'X-Device-Id': this.#auth.deviceId,
  2742. 'Client-Session-Id': this.#auth.clientSessionId,
  2743. 'Client-Integrity': this.#integrityToken
  2744. },
  2745. data: doTask ? followData : unfollowData
  2746. });
  2747. if (result === 'Success') {
  2748. var _data$response3, _data$response4, _data$response4$0$err, _data$response4$0$err2;
  2749. 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) {
  2750. logStatus.success();
  2751. if (doTask) {
  2752. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2753. }
  2754. return true;
  2755. }
  2756. 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})`}`);
  2757. return false;
  2758. }
  2759. logStatus.error(`${result}:${statusText}(${status})`);
  2760. return false;
  2761. } catch (error) {
  2762. throwError(error, 'Twitch.toggleChannel');
  2763. return false;
  2764. }
  2765. }
  2766. async #getChannelId(name) {
  2767. try {
  2768. const logStatus = scripts_echoLog({
  2769. type: 'gettingTwitchChannelId',
  2770. text: name
  2771. });
  2772. const channelId = this.#cache[name];
  2773. if (channelId) {
  2774. logStatus.success();
  2775. return channelId;
  2776. }
  2777. const {
  2778. result,
  2779. statusText,
  2780. status,
  2781. data
  2782. } = await tools_httpRequest({
  2783. url: 'https://gql.twitch.tv/gql',
  2784. method: 'POST',
  2785. headers: {
  2786. Authorization: `OAuth ${this.#auth.authToken}`,
  2787. 'Client-Id': this.#auth.clientId
  2788. },
  2789. responseType: 'json',
  2790. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  2791. });
  2792. if (result === 'Success') {
  2793. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2794. var _data$response5, _data$response5$, _data$response5$$data, _data$response5$$data2;
  2795. 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;
  2796. if (channelId) {
  2797. this.#setCache(name, String(channelId));
  2798. logStatus.success();
  2799. return channelId;
  2800. }
  2801. logStatus.error(`Error:${data.statusText}(${data.status})`);
  2802. return false;
  2803. }
  2804. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2805. return false;
  2806. }
  2807. logStatus.error(`${result}:${statusText}(${status})`);
  2808. return false;
  2809. } catch (error) {
  2810. throwError(error, 'Twitch.getChannelId');
  2811. return false;
  2812. }
  2813. }
  2814. async toggle(_ref2) {
  2815. let {
  2816. doTask = true,
  2817. channelLinks = []
  2818. } = _ref2;
  2819. try {
  2820. if (!this.#initialized) {
  2821. scripts_echoLog({
  2822. text: i18n('needInit')
  2823. });
  2824. return false;
  2825. }
  2826. const prom = [];
  2827. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2828. scripts_echoLog({
  2829. type: 'globalOptionsSkip',
  2830. text: 'twitch.channels'
  2831. });
  2832. } else {
  2833. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2834. var _link$match;
  2835. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2836. });
  2837. if (realChannels.length > 0) {
  2838. for (const channel of realChannels) {
  2839. prom.push(this.#toggleChannel({
  2840. name: channel,
  2841. doTask: doTask
  2842. }));
  2843. await delay(1e3);
  2844. }
  2845. }
  2846. }
  2847. return Promise.all(prom).then(() => true);
  2848. } catch (error) {
  2849. throwError(error, 'Twitch.toggle');
  2850. return false;
  2851. }
  2852. }
  2853. #setCache(name, id) {
  2854. try {
  2855. this.#cache[name] = id;
  2856. GM_setValue('twitchCache', this.#cache);
  2857. } catch (error) {
  2858. throwError(error, 'Twitch.setCache');
  2859. }
  2860. }
  2861. }
  2862. const social_Twitch = Twitch;
  2863. var Twitter_GM_getValue;
  2864. const Twitter_defaultTasksTemplate = {
  2865. users: [],
  2866. retweets: [],
  2867. likes: []
  2868. };
  2869. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  2870. class Twitter extends social_Social {
  2871. tasks = JSON.parse(Twitter_defaultTasks);
  2872. whiteList = {
  2873. ...JSON.parse(Twitter_defaultTasks),
  2874. ...(Twitter_GM_getValue = GM_getValue('whiteList')) === null || Twitter_GM_getValue === void 0 ? void 0 : Twitter_GM_getValue.twitter
  2875. };
  2876. #verifyId = globalOptions.other.twitterVerifyId;
  2877. #auth = GM_getValue('twitterAuth') || {};
  2878. #cache = GM_getValue('twitterCache') || {};
  2879. #initialized = false;
  2880. async init() {
  2881. try {
  2882. if (this.#initialized) {
  2883. return true;
  2884. }
  2885. if (!this.#auth.ct0) {
  2886. if (await this.#updateAuth()) {
  2887. this.#initialized = true;
  2888. return true;
  2889. }
  2890. return false;
  2891. }
  2892. const isVerified = await this.#verifyAuth();
  2893. if (isVerified) {
  2894. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  2895. this.#initialized = true;
  2896. return true;
  2897. }
  2898. GM_setValue('twitterAuth', null);
  2899. if (await this.#updateAuth()) {
  2900. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  2901. this.#initialized = true;
  2902. return true;
  2903. }
  2904. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  2905. return false;
  2906. } catch (error) {
  2907. throwError(error, 'Twitter.init');
  2908. return false;
  2909. }
  2910. }
  2911. async #verifyAuth() {
  2912. try {
  2913. return await this.#toggleUser({
  2914. name: 'verify',
  2915. doTask: true,
  2916. verify: true
  2917. });
  2918. } catch (error) {
  2919. throwError(error, 'Twitter.verifyAuth');
  2920. return false;
  2921. }
  2922. }
  2923. async #updateAuth() {
  2924. try {
  2925. const logStatus = scripts_echoLog({
  2926. text: i18n('updatingAuth', 'Twitter')
  2927. });
  2928. return await new Promise(resolve => {
  2929. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  2930. active: true,
  2931. insert: true,
  2932. setParent: true
  2933. });
  2934. newTab.onclose = async () => {
  2935. const auth = GM_getValue('twitterAuth');
  2936. if (auth) {
  2937. this.#auth = auth;
  2938. logStatus.success();
  2939. resolve(await this.#verifyAuth());
  2940. } else {
  2941. logStatus.error('Error: Update twitter auth failed!');
  2942. resolve(false);
  2943. }
  2944. };
  2945. });
  2946. } catch (error) {
  2947. throwError(error, 'Twitter.updateToken');
  2948. return false;
  2949. }
  2950. }
  2951. async #toggleUser(_ref) {
  2952. let {
  2953. name,
  2954. doTask = true,
  2955. verify = false
  2956. } = _ref;
  2957. try {
  2958. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  2959. scripts_echoLog({
  2960. type: 'whiteList',
  2961. text: 'Twitter.unfollowUser',
  2962. id: name
  2963. });
  2964. return true;
  2965. }
  2966. const userId = verify ? this.#verifyId : await this.userName2id(name);
  2967. if (!userId) {
  2968. return false;
  2969. }
  2970. const logStatus = verify ? scripts_echoLog({
  2971. text: i18n('verifyingAuth', 'Twitter')
  2972. }) : scripts_echoLog({
  2973. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  2974. text: name
  2975. });
  2976. const {
  2977. result,
  2978. statusText,
  2979. status,
  2980. data
  2981. } = await tools_httpRequest({
  2982. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  2983. method: 'POST',
  2984. headers: {
  2985. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  2986. 'Content-Type': 'application/x-www-form-urlencoded',
  2987. 'x-csrf-token': this.#auth.ct0
  2988. },
  2989. responseType: 'json',
  2990. data: $.param({
  2991. include_profile_interstitial_type: 1,
  2992. include_blocking: 1,
  2993. include_blocked_by: 1,
  2994. include_followed_by: 1,
  2995. include_want_retweets: 1,
  2996. include_mute_edge: 1,
  2997. include_can_dm: 1,
  2998. include_can_media_tag: 1,
  2999. skip_status: 1,
  3000. id: userId
  3001. })
  3002. });
  3003. if (result === 'Success') {
  3004. var _data$response, _data$response$errors, _data$response$errors2;
  3005. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3006. logStatus.success();
  3007. if (doTask && !verify) {
  3008. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3009. }
  3010. return true;
  3011. }
  3012. 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) {
  3013. logStatus.success();
  3014. return true;
  3015. }
  3016. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3017. return false;
  3018. }
  3019. logStatus.error(`${result}:${statusText}(${status})`);
  3020. return false;
  3021. } catch (error) {
  3022. throwError(error, 'Twitter.toggleUser');
  3023. return false;
  3024. }
  3025. }
  3026. async userName2id(name) {
  3027. try {
  3028. const logStatus = scripts_echoLog({
  3029. type: 'gettingTwitterUserId',
  3030. text: name
  3031. });
  3032. const userId = this.#cache[name];
  3033. if (userId) {
  3034. logStatus.success();
  3035. return userId;
  3036. }
  3037. const {
  3038. result,
  3039. statusText,
  3040. status,
  3041. data
  3042. } = await tools_httpRequest({
  3043. 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`,
  3044. method: 'GET',
  3045. headers: {
  3046. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3047. 'content-type': 'application/json',
  3048. referer: `https://twitter.com/${name}`,
  3049. 'x-csrf-token': this.#auth.ct0
  3050. },
  3051. responseType: 'json'
  3052. });
  3053. if (result === 'Success') {
  3054. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3055. var _response, _response$data, _response$data$user, _response$data$user$r;
  3056. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3057. if (!response) {
  3058. try {
  3059. response = JSON.parse(data.responseText);
  3060. } catch (error) {
  3061. response = null;
  3062. }
  3063. }
  3064. 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);
  3065. if (userId) {
  3066. this.#setCache(name, userId);
  3067. logStatus.success();
  3068. return userId;
  3069. }
  3070. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3071. return false;
  3072. }
  3073. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3074. return false;
  3075. }
  3076. logStatus.error(`${result}:${statusText}(${status})`);
  3077. return false;
  3078. } catch (error) {
  3079. throwError(error, 'Twitter.getUserId');
  3080. return false;
  3081. }
  3082. }
  3083. async #toggleRetweet(_ref2) {
  3084. let {
  3085. retweetId,
  3086. doTask = true
  3087. } = _ref2;
  3088. try {
  3089. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3090. scripts_echoLog({
  3091. type: 'whiteList',
  3092. text: 'Twitter.unretweet',
  3093. id: retweetId
  3094. });
  3095. return true;
  3096. }
  3097. const logStatus = scripts_echoLog({
  3098. type: `${doTask ? '' : 'un'}retweetting`,
  3099. text: retweetId
  3100. });
  3101. const {
  3102. result,
  3103. statusText,
  3104. status,
  3105. data
  3106. } = await tools_httpRequest({
  3107. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3108. method: 'POST',
  3109. headers: {
  3110. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3111. 'Content-Type': 'application/x-www-form-urlencoded',
  3112. 'x-csrf-token': this.#auth.ct0
  3113. },
  3114. data: $.param({
  3115. tweet_mode: 'extended',
  3116. id: retweetId
  3117. }),
  3118. responseType: 'json'
  3119. });
  3120. if (result === 'Success') {
  3121. var _data$response2, _data$response2$error, _data$response2$error2;
  3122. 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) {
  3123. logStatus.success();
  3124. if (doTask) {
  3125. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3126. }
  3127. return true;
  3128. }
  3129. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3130. return false;
  3131. }
  3132. logStatus.error(`${result}:${statusText}(${status})`);
  3133. return false;
  3134. } catch (error) {
  3135. throwError(error, 'Twitter.toggleRetweet');
  3136. return false;
  3137. }
  3138. }
  3139. async toggle(_ref3) {
  3140. let {
  3141. doTask = true,
  3142. userLinks = [],
  3143. retweetLinks = []
  3144. } = _ref3;
  3145. try {
  3146. if (!this.#initialized) {
  3147. scripts_echoLog({
  3148. text: i18n('needInit')
  3149. });
  3150. return false;
  3151. }
  3152. const prom = [];
  3153. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3154. scripts_echoLog({
  3155. type: 'globalOptionsSkip',
  3156. text: 'twitter.users'
  3157. });
  3158. } else {
  3159. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3160. var _link$match;
  3161. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3162. });
  3163. if (realUsers.length > 0) {
  3164. for (const user of realUsers) {
  3165. prom.push(this.#toggleUser({
  3166. name: user,
  3167. doTask: doTask
  3168. }));
  3169. await delay(1e3);
  3170. }
  3171. }
  3172. }
  3173. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3174. scripts_echoLog({
  3175. type: 'globalOptionsSkip',
  3176. text: 'twitter.retweets'
  3177. });
  3178. } else {
  3179. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3180. var _link$match2;
  3181. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3182. });
  3183. if (realRetweets.length > 0) {
  3184. for (const retweet of realRetweets) {
  3185. prom.push(this.#toggleRetweet({
  3186. retweetId: retweet,
  3187. doTask: doTask
  3188. }));
  3189. await delay(1e3);
  3190. }
  3191. }
  3192. }
  3193. return Promise.all(prom).then(() => true);
  3194. } catch (error) {
  3195. throwError(error, 'Twitter.toggle');
  3196. return false;
  3197. }
  3198. }
  3199. #setCache(name, id) {
  3200. try {
  3201. this.#cache[name] = id;
  3202. GM_setValue('twitterCache', this.#cache);
  3203. } catch (error) {
  3204. throwError(error, 'Twitter.setCache');
  3205. }
  3206. }
  3207. }
  3208. const social_Twitter = Twitter;
  3209. var Vk_GM_getValue;
  3210. const Vk_defaultTasksTemplate = {
  3211. names: []
  3212. };
  3213. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3214. class Vk extends social_Social {
  3215. tasks = JSON.parse(Vk_defaultTasks);
  3216. whiteList = {
  3217. ...JSON.parse(Vk_defaultTasks),
  3218. ...(Vk_GM_getValue = GM_getValue('whiteList')) === null || Vk_GM_getValue === void 0 ? void 0 : Vk_GM_getValue.vk
  3219. };
  3220. #username = '';
  3221. #cache = GM_getValue('vkCache') || {};
  3222. #initialized = false;
  3223. async init() {
  3224. try {
  3225. if (this.#initialized) {
  3226. return true;
  3227. }
  3228. const isVerified = await this.#verifyAuth();
  3229. if (isVerified) {
  3230. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3231. this.#initialized = true;
  3232. return true;
  3233. }
  3234. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3235. return false;
  3236. } catch (error) {
  3237. throwError(error, 'Vk.init');
  3238. return false;
  3239. }
  3240. }
  3241. async #verifyAuth() {
  3242. try {
  3243. const logStatus = scripts_echoLog({
  3244. text: i18n('verifyAuth', 'Vk')
  3245. });
  3246. const {
  3247. result,
  3248. statusText,
  3249. status,
  3250. data
  3251. } = await tools_httpRequest({
  3252. url: 'https://vk.com/im',
  3253. method: 'GET'
  3254. });
  3255. if (result === 'Success') {
  3256. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3257. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3258. return false;
  3259. }
  3260. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3261. var _data$responseText$ma;
  3262. this.#username = ((_data$responseText$ma = data.responseText.match(/TopNavBtn__profileLink" href="\/(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1]) || '';
  3263. logStatus.success();
  3264. return true;
  3265. }
  3266. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3267. return false;
  3268. }
  3269. logStatus.error(`${result}:${statusText}(${status})`);
  3270. return false;
  3271. } catch (error) {
  3272. throwError(error, 'Vk.verifyAuth');
  3273. return false;
  3274. }
  3275. }
  3276. async #toggleGroup(name, dataParam) {
  3277. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3278. try {
  3279. const logStatus = scripts_echoLog({
  3280. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3281. text: name
  3282. });
  3283. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3284. logStatus.success();
  3285. return true;
  3286. }
  3287. const reqData = {
  3288. act: doTask ? 'enter' : 'leave',
  3289. al: 1,
  3290. gid: dataParam.groupId,
  3291. hash: dataParam.groupHash
  3292. };
  3293. if (doTask) {
  3294. reqData.context = '_';
  3295. }
  3296. const {
  3297. result,
  3298. statusText,
  3299. status,
  3300. data
  3301. } = await tools_httpRequest({
  3302. url: 'https://vk.com/al_groups.php',
  3303. method: 'POST',
  3304. headers: {
  3305. origin: 'https://vk.com',
  3306. referer: `https://vk.com/${name}`,
  3307. 'content-type': 'application/x-www-form-urlencoded'
  3308. },
  3309. data: $.param(reqData)
  3310. });
  3311. if (result === 'Success') {
  3312. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3313. logStatus.success();
  3314. if (doTask) {
  3315. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3316. }
  3317. return true;
  3318. }
  3319. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3320. return false;
  3321. }
  3322. logStatus.error(`${result}:${statusText}(${status})`);
  3323. return false;
  3324. } catch (error) {
  3325. throwError(error, 'Vk.toggleGroup');
  3326. return false;
  3327. }
  3328. }
  3329. async #togglePublic(name, dataParam) {
  3330. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3331. try {
  3332. const logStatus = scripts_echoLog({
  3333. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3334. text: name
  3335. });
  3336. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3337. logStatus.success();
  3338. return true;
  3339. }
  3340. const {
  3341. result,
  3342. statusText,
  3343. status,
  3344. data
  3345. } = await tools_httpRequest({
  3346. url: 'https://vk.com/al_public.php',
  3347. method: 'POST',
  3348. headers: {
  3349. origin: 'https://vk.com',
  3350. referer: `https://vk.com/${name}`,
  3351. 'content-type': 'application/x-www-form-urlencoded'
  3352. },
  3353. data: $.param({
  3354. act: doTask ? 'a_enter' : 'a_leave',
  3355. al: 1,
  3356. pid: dataParam.publicPid,
  3357. hash: dataParam.publicHash
  3358. })
  3359. });
  3360. if (result === 'Success') {
  3361. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3362. logStatus.success();
  3363. if (doTask) {
  3364. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3365. }
  3366. return true;
  3367. }
  3368. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3369. return false;
  3370. }
  3371. logStatus.error(`${result}:${statusText}(${status})`);
  3372. return false;
  3373. } catch (error) {
  3374. throwError(error, 'Vk.togglePublic');
  3375. return false;
  3376. }
  3377. }
  3378. async #sendWall(name) {
  3379. try {
  3380. const logStatus = scripts_echoLog({
  3381. type: 'sendingVkWall',
  3382. text: name
  3383. });
  3384. const {
  3385. result,
  3386. statusText,
  3387. status,
  3388. data
  3389. } = await tools_httpRequest({
  3390. url: 'https://vk.com/like.php',
  3391. method: 'POST',
  3392. headers: {
  3393. origin: 'https://vk.com',
  3394. referer: `https://vk.com/${name}`,
  3395. 'content-type': 'application/x-www-form-urlencoded'
  3396. },
  3397. data: $.param({
  3398. act: 'publish_box',
  3399. al: 1,
  3400. object: name
  3401. })
  3402. });
  3403. if (result === 'Success') {
  3404. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3405. var _data$responseText$ma2;
  3406. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3407. if (hash) {
  3408. const {
  3409. result: resultR,
  3410. statusText: statusTextR,
  3411. status: statusR,
  3412. data: dataR
  3413. } = await tools_httpRequest({
  3414. url: 'https://vk.com/like.php',
  3415. method: 'POST',
  3416. headers: {
  3417. origin: 'https://vk.com',
  3418. referer: `https://vk.com/${name}`,
  3419. 'content-type': 'application/x-www-form-urlencoded'
  3420. },
  3421. data: $.param({
  3422. Message: '',
  3423. act: 'a_do_publish',
  3424. al: 1,
  3425. close_comments: 0,
  3426. friends_only: 0,
  3427. from: 'box',
  3428. hash: hash,
  3429. list: '',
  3430. mark_as_ads: 0,
  3431. mute_notifications: 0,
  3432. object: name,
  3433. ret_data: 1,
  3434. to: 0
  3435. })
  3436. });
  3437. if (resultR === 'Success') {
  3438. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3439. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3440. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3441. 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) {
  3442. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3443. logStatus.success();
  3444. 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);
  3445. 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);
  3446. if (postId && ownerId) {
  3447. this.#setCache(name, `${ownerId}_${postId}`);
  3448. }
  3449. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3450. return true;
  3451. }
  3452. }
  3453. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3454. return false;
  3455. }
  3456. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3457. return false;
  3458. }
  3459. logStatus.error('Error: Get "hash" failed');
  3460. return false;
  3461. }
  3462. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3463. return false;
  3464. }
  3465. logStatus.error(`${result}:${statusText}(${status})`);
  3466. return false;
  3467. } catch (error) {
  3468. throwError(error, 'Vk.sendWall');
  3469. return false;
  3470. }
  3471. }
  3472. async #deleteWall(name, dataParams) {
  3473. try {
  3474. const logStatus = scripts_echoLog({
  3475. type: 'deletingVkWall',
  3476. text: name
  3477. });
  3478. const {
  3479. result,
  3480. statusText,
  3481. status,
  3482. data
  3483. } = await tools_httpRequest({
  3484. url: 'https://vk.com/al_wall.php?act=delete',
  3485. method: 'POST',
  3486. headers: {
  3487. origin: 'https://vk.com',
  3488. referer: `https://vk.com/${this.#username}?w=wall${this.#cache[name]}%2Fall`,
  3489. 'content-type': 'application/x-www-form-urlencoded'
  3490. },
  3491. data: $.param({
  3492. act: 'delete',
  3493. al: 1,
  3494. confirm: 0,
  3495. from: 'wkview',
  3496. hash: dataParams.wallHash,
  3497. post: this.#cache[name]
  3498. })
  3499. });
  3500. if (result === 'Success') {
  3501. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3502. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3503. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3504. 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]) {
  3505. logStatus.success();
  3506. return true;
  3507. }
  3508. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3509. return false;
  3510. }
  3511. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3512. return false;
  3513. }
  3514. logStatus.error(`${result}:${statusText}(${status})`);
  3515. return false;
  3516. } catch (error) {
  3517. throwError(error, 'Vk.deleteWall');
  3518. return false;
  3519. }
  3520. }
  3521. async #getId(name, doTask) {
  3522. try {
  3523. let url = `https://vk.com/${name}`;
  3524. if (/^wall-/.test(name)) {
  3525. if (doTask) {
  3526. return {
  3527. type: 'sendWall'
  3528. };
  3529. }
  3530. if (!this.#cache[name]) {
  3531. return {
  3532. type: 'unSupport'
  3533. };
  3534. }
  3535. url = `https://vk.com/${this.#username}?w=wall${this.#cache[name]}`;
  3536. }
  3537. const logStatus = scripts_echoLog({
  3538. type: 'gettingVkId',
  3539. text: name
  3540. });
  3541. const {
  3542. result,
  3543. statusText,
  3544. status,
  3545. data
  3546. } = await tools_httpRequest({
  3547. url: url,
  3548. method: 'GET'
  3549. });
  3550. if (result === 'Success') {
  3551. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3552. var _data$responseText$ma3, _data$responseText$ma4;
  3553. const [ , groupAct, groupId, , groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), (&#39;|')(.*?)(&#39;|')/) || [];
  3554. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3555. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3556. const publicJoined = !data.responseText.includes('Public.subscribe');
  3557. if (groupAct && groupId && groupHash) {
  3558. logStatus.success();
  3559. return {
  3560. groupAct: groupAct,
  3561. groupId: groupId,
  3562. groupHash: groupHash,
  3563. type: 'group'
  3564. };
  3565. } else if (publicHash && publicPid) {
  3566. logStatus.success();
  3567. return {
  3568. publicHash: publicHash,
  3569. publicPid: publicPid,
  3570. publicJoined: publicJoined,
  3571. type: 'public'
  3572. };
  3573. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3574. var _data$responseText$ma5;
  3575. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3576. if (wallHash) {
  3577. logStatus.success();
  3578. return {
  3579. type: 'deleteWall',
  3580. wallHash: wallHash
  3581. };
  3582. }
  3583. } else if (name.includes('wall') && doTask) {
  3584. logStatus.success();
  3585. return {
  3586. type: 'sendWall'
  3587. };
  3588. }
  3589. logStatus.error('Error: Parameters not found!');
  3590. return false;
  3591. }
  3592. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3593. return false;
  3594. }
  3595. logStatus.error(`${result}:${statusText}(${status})`);
  3596. return false;
  3597. } catch (error) {
  3598. throwError(error, 'Vk.getId');
  3599. return false;
  3600. }
  3601. }
  3602. async #toggleVk(_ref) {
  3603. let {
  3604. name,
  3605. doTask = true
  3606. } = _ref;
  3607. try {
  3608. if (!doTask && this.whiteList.names.includes(name)) {
  3609. scripts_echoLog({
  3610. type: 'whiteList',
  3611. text: 'Vk.undoTask',
  3612. id: name
  3613. });
  3614. return true;
  3615. }
  3616. const formatName = name.replace(/\/$/, '');
  3617. const data = await this.#getId(formatName, doTask);
  3618. if (!data) {
  3619. return false;
  3620. }
  3621. switch (data.type) {
  3622. case 'group':
  3623. return await this.#toggleGroup(formatName, data, doTask);
  3624.  
  3625. case 'public':
  3626. return await this.#togglePublic(formatName, data, doTask);
  3627.  
  3628. case 'sendWall':
  3629. return doTask ? await this.#sendWall(formatName) : true;
  3630.  
  3631. case 'deleteWall':
  3632. return doTask ? true : await this.#deleteWall(formatName, data);
  3633.  
  3634. default:
  3635. return false;
  3636. }
  3637. } catch (error) {
  3638. throwError(error, 'Vk.toggleVk');
  3639. return false;
  3640. }
  3641. }
  3642. async toggle(_ref2) {
  3643. let {
  3644. doTask = true,
  3645. nameLinks = []
  3646. } = _ref2;
  3647. try {
  3648. if (!this.#initialized) {
  3649. scripts_echoLog({
  3650. text: i18n('needInit')
  3651. });
  3652. return false;
  3653. }
  3654. const prom = [];
  3655. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3656. scripts_echoLog({
  3657. type: 'globalOptionsSkip',
  3658. text: 'vk.names'
  3659. });
  3660. } else {
  3661. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3662. var _link$match;
  3663. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3664. });
  3665. if (realNames.length > 0) {
  3666. for (const name of realNames) {
  3667. prom.push(this.#toggleVk({
  3668. name: name,
  3669. doTask: doTask
  3670. }));
  3671. await delay(1e3);
  3672. }
  3673. }
  3674. }
  3675. return Promise.all(prom).then(() => true);
  3676. } catch (error) {
  3677. throwError(error, 'Vk.toggle');
  3678. return false;
  3679. }
  3680. }
  3681. #setCache(name, postId) {
  3682. try {
  3683. this.#cache[name] = postId;
  3684. GM_setValue('vkCache', this.#cache);
  3685. } catch (error) {
  3686. throwError(error, 'Vk.setCache');
  3687. }
  3688. }
  3689. }
  3690. const social_Vk = Vk;
  3691. var Youtube_GM_getValue;
  3692. const Youtube_defaultTasksTemplate = {
  3693. channels: [],
  3694. likes: []
  3695. };
  3696. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  3697. const getInfo = async function(link, type) {
  3698. try {
  3699. const logStatus = scripts_echoLog({
  3700. text: i18n('gettingYtbToken')
  3701. });
  3702. const {
  3703. result,
  3704. statusText,
  3705. status,
  3706. data
  3707. } = await tools_httpRequest({
  3708. url: link,
  3709. method: 'GET'
  3710. });
  3711. if (result === 'Success') {
  3712. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3713. var _data$responseText$ma, _ref;
  3714. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  3715. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  3716. return {
  3717. needLogin: true
  3718. };
  3719. }
  3720. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  3721. 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]) || '{}';
  3722. const {
  3723. client,
  3724. request
  3725. } = JSON.parse(context);
  3726. if (apiKey && client && request) {
  3727. client.hl = 'en';
  3728. if (type === 'channel') {
  3729. var _data$responseText$ma2;
  3730. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3731. if (channelId) {
  3732. logStatus.success();
  3733. return {
  3734. params: {
  3735. apiKey: apiKey,
  3736. client: client,
  3737. request: request,
  3738. channelId: channelId
  3739. }
  3740. };
  3741. }
  3742. logStatus.error('Error: Get "channelId" failed!');
  3743. return {};
  3744. } else if (type === 'likeVideo') {
  3745. var _data$responseText$ma3, _data$responseText$ma4;
  3746. 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];
  3747. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3748. if (videoId) {
  3749. logStatus.success();
  3750. return {
  3751. params: {
  3752. apiKey: apiKey,
  3753. client: client,
  3754. request: request,
  3755. videoId: videoId,
  3756. likeParams: likeParams
  3757. }
  3758. };
  3759. }
  3760. logStatus.error('Error: Get "videoId" failed!');
  3761. return {};
  3762. }
  3763. logStatus.error('Error: Unknown type');
  3764. return {};
  3765. }
  3766. logStatus.error('Error: Parameter "apiKey" not found!');
  3767. return {};
  3768. }
  3769. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3770. return {};
  3771. }
  3772. logStatus.error(`${result}:${statusText}(${status})`);
  3773. return {};
  3774. } catch (error) {
  3775. throwError(error, 'Youtube.getInfo');
  3776. return {};
  3777. }
  3778. };
  3779. class Youtube extends social_Social {
  3780. tasks = JSON.parse(Youtube_defaultTasks);
  3781. whiteList = {
  3782. ...JSON.parse(Youtube_defaultTasks),
  3783. ...(Youtube_GM_getValue = GM_getValue('whiteList')) === null || Youtube_GM_getValue === void 0 ? void 0 : Youtube_GM_getValue.youtube
  3784. };
  3785. #auth = GM_getValue('youtubeAuth') || {};
  3786. #initialized = false;
  3787. #verifyChannel = `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`;
  3788. async init() {
  3789. try {
  3790. if (this.#initialized) {
  3791. return true;
  3792. }
  3793. if (!this.#auth.PAPISID) {
  3794. if (await this.#updateAuth()) {
  3795. this.#initialized = true;
  3796. return true;
  3797. }
  3798. return false;
  3799. }
  3800. const isVerified = await this.#verifyAuth();
  3801. if (isVerified) {
  3802. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  3803. this.#initialized = true;
  3804. return true;
  3805. }
  3806. GM_setValue('youtubeAuth', null);
  3807. if (await this.#updateAuth()) {
  3808. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  3809. this.#initialized = true;
  3810. return true;
  3811. }
  3812. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  3813. return false;
  3814. } catch (error) {
  3815. throwError(error, 'Youtube.init');
  3816. return false;
  3817. }
  3818. }
  3819. async #verifyAuth() {
  3820. try {
  3821. return await this.#toggleChannel({
  3822. link: this.#verifyChannel,
  3823. doTask: true,
  3824. verify: true
  3825. });
  3826. } catch (error) {
  3827. throwError(error, 'Youtube.verifyAuth');
  3828. return false;
  3829. }
  3830. }
  3831. async #updateAuth() {
  3832. try {
  3833. const logStatus = scripts_echoLog({
  3834. text: i18n('updatingAuth', 'Youtube')
  3835. });
  3836. return await new Promise(resolve => {
  3837. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  3838. active: true,
  3839. insert: true,
  3840. setParent: true
  3841. });
  3842. newTab.onclose = async () => {
  3843. const auth = GM_getValue('youtubeAuth');
  3844. if (auth) {
  3845. this.#auth = auth;
  3846. logStatus.success();
  3847. this.#verifyAuth().then(result => {
  3848. resolve(result);
  3849. });
  3850. } else {
  3851. logStatus.error('Error: Update youtube auth failed!');
  3852. resolve(false);
  3853. }
  3854. };
  3855. });
  3856. } catch (error) {
  3857. throwError(error, 'Discord.updateAuth');
  3858. return false;
  3859. }
  3860. }
  3861. #getInfo(link, type) {
  3862. return getInfo(link, type);
  3863. }
  3864. async #toggleChannel(_ref2) {
  3865. let {
  3866. link,
  3867. doTask = true,
  3868. verify = false
  3869. } = _ref2;
  3870. try {
  3871. const {
  3872. params,
  3873. needLogin
  3874. } = await this.#getInfo(link, 'channel');
  3875. const {
  3876. apiKey,
  3877. client,
  3878. request,
  3879. channelId
  3880. } = params || {};
  3881. if (needLogin) {
  3882. scripts_echoLog({
  3883. html: i18n('loginYtb')
  3884. });
  3885. return false;
  3886. }
  3887. if (!(apiKey && client && request && channelId)) {
  3888. scripts_echoLog({
  3889. text: '"getYtbToken" failed'
  3890. });
  3891. return false;
  3892. }
  3893. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  3894. scripts_echoLog({
  3895. type: 'whiteList',
  3896. text: 'Youtube.unfollowChannel',
  3897. id: channelId
  3898. });
  3899. return true;
  3900. }
  3901. const logStatus = verify ? scripts_echoLog({
  3902. text: i18n('verifyingAuth', 'Youtube')
  3903. }) : scripts_echoLog({
  3904. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  3905. text: channelId
  3906. });
  3907. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  3908. const {
  3909. result,
  3910. statusText,
  3911. status,
  3912. data
  3913. } = await tools_httpRequest({
  3914. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  3915. method: 'POST',
  3916. headers: {
  3917. origin: 'https://www.youtube.com',
  3918. referer: `https://www.youtube.com/channel/${channelId}`,
  3919. 'content-type': 'application/json',
  3920. 'x-goog-authuser': '0',
  3921. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  3922. 'x-origin': 'https://www.youtube.com',
  3923. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${this.#auth.PAPISID} https://www.youtube.com`)}`
  3924. },
  3925. data: JSON.stringify({
  3926. context: {
  3927. client: client,
  3928. request: {
  3929. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  3930. internalExperimentFlags: [],
  3931. consistencyTokenJars: []
  3932. },
  3933. user: {}
  3934. },
  3935. channelIds: [ channelId ],
  3936. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  3937. })
  3938. });
  3939. if (result === 'Success') {
  3940. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3941. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  3942. logStatus.success();
  3943. if (doTask && !verify) {
  3944. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  3945. }
  3946. return true;
  3947. }
  3948. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  3949. logStatus.success();
  3950. return true;
  3951. }
  3952. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  3953. return false;
  3954. }
  3955. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3956. return false;
  3957. }
  3958. logStatus.error(`${result}:${statusText}(${status})`);
  3959. return false;
  3960. } catch (error) {
  3961. throwError(error, 'Youtube.toggleChannel');
  3962. return false;
  3963. }
  3964. }
  3965. async #toggleLikeVideo(_ref3) {
  3966. let {
  3967. link,
  3968. doTask = true
  3969. } = _ref3;
  3970. try {
  3971. const {
  3972. params,
  3973. needLogin
  3974. } = await this.#getInfo(link, 'likeVideo');
  3975. const {
  3976. apiKey,
  3977. client,
  3978. request,
  3979. videoId,
  3980. likeParams
  3981. } = params || {};
  3982. if (needLogin) {
  3983. scripts_echoLog({
  3984. html: `${i18n('loginYtb')}`
  3985. });
  3986. return false;
  3987. }
  3988. if (!(apiKey && client && request && videoId && likeParams)) {
  3989. scripts_echoLog({
  3990. text: '"getYtbToken" failed'
  3991. });
  3992. return false;
  3993. }
  3994. if (!doTask && this.whiteList.likes.includes(videoId)) {
  3995. scripts_echoLog({
  3996. type: 'whiteList',
  3997. text: 'Youtube.unlikeVideo',
  3998. id: videoId
  3999. });
  4000. return true;
  4001. }
  4002. const logStatus = scripts_echoLog({
  4003. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4004. text: videoId
  4005. });
  4006. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4007. const likeVideoData = {
  4008. context: {
  4009. client: client,
  4010. request: {
  4011. sessionId: request.sessionId,
  4012. internalExperimentFlags: [],
  4013. consistencyTokenJars: []
  4014. },
  4015. user: {}
  4016. },
  4017. target: {
  4018. videoId: videoId
  4019. }
  4020. };
  4021. if (doTask) {
  4022. if (likeParams) {
  4023. likeVideoData.params = likeParams;
  4024. } else {
  4025. logStatus.error('Empty likeParams');
  4026. return false;
  4027. }
  4028. }
  4029. const {
  4030. result,
  4031. statusText,
  4032. status,
  4033. data
  4034. } = await tools_httpRequest({
  4035. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4036. method: 'POST',
  4037. headers: {
  4038. origin: 'https://www.youtube.com',
  4039. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4040. 'content-type': 'application/json',
  4041. 'x-goog-authuser': '0',
  4042. 'x-goog-visitor-id': client.visitorData,
  4043. 'x-origin': 'https://www.youtube.com',
  4044. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${this.#auth.PAPISID} https://www.youtube.com`)}`
  4045. },
  4046. data: JSON.stringify(likeVideoData)
  4047. });
  4048. if (result === 'Success') {
  4049. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4050. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4051. logStatus.success();
  4052. if (doTask) {
  4053. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4054. }
  4055. return true;
  4056. }
  4057. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4058. return false;
  4059. }
  4060. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4061. return false;
  4062. }
  4063. logStatus.error(`${result}:${statusText}(${status})`);
  4064. return false;
  4065. } catch (error) {
  4066. throwError(error, 'Youtube.toggleLikeVideo');
  4067. return false;
  4068. }
  4069. }
  4070. async toggle(_ref4) {
  4071. let {
  4072. doTask = true,
  4073. channelLinks = [],
  4074. videoLinks = []
  4075. } = _ref4;
  4076. try {
  4077. if (!this.#initialized) {
  4078. scripts_echoLog({
  4079. text: i18n('needInit')
  4080. });
  4081. return false;
  4082. }
  4083. const prom = [];
  4084. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4085. scripts_echoLog({
  4086. type: 'globalOptionsSkip',
  4087. text: 'youtube.channels'
  4088. });
  4089. } else {
  4090. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4091. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4092. var _link$match;
  4093. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4094. }
  4095. return link;
  4096. });
  4097. if (realChannels.length > 0) {
  4098. for (const channel of realChannels) {
  4099. prom.push(this.#toggleChannel({
  4100. link: channel,
  4101. doTask: doTask
  4102. }));
  4103. await delay(1e3);
  4104. }
  4105. }
  4106. }
  4107. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4108. scripts_echoLog({
  4109. type: 'globalOptionsSkip',
  4110. text: 'youtube.likes'
  4111. });
  4112. } else {
  4113. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4114. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4115. var _link$match2;
  4116. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4117. }
  4118. return link;
  4119. });
  4120. if (realLikes.length > 0) {
  4121. for (const video of realLikes) {
  4122. prom.push(this.#toggleLikeVideo({
  4123. link: video,
  4124. doTask: doTask
  4125. }));
  4126. await delay(1e3);
  4127. }
  4128. }
  4129. }
  4130. return Promise.all(prom).then(() => true);
  4131. } catch (error) {
  4132. throwError(error, 'Youtube.toggle');
  4133. return false;
  4134. }
  4135. }
  4136. }
  4137. var Steam_GM_getValue;
  4138. const Steam_defaultTasksTemplate = {
  4139. groups: [],
  4140. officialGroups: [],
  4141. wishlists: [],
  4142. follows: [],
  4143. forums: [],
  4144. workshops: [],
  4145. workshopVotes: [],
  4146. curators: [],
  4147. curatorLikes: [],
  4148. announcements: [],
  4149. licenses: [],
  4150. playtests: []
  4151. };
  4152. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4153. class Steam extends social_Social {
  4154. tasks = JSON.parse(Steam_defaultTasks);
  4155. whiteList = {
  4156. ...JSON.parse(Steam_defaultTasks),
  4157. ...(Steam_GM_getValue = GM_getValue('whiteList')) === null || Steam_GM_getValue === void 0 ? void 0 : Steam_GM_getValue.steam
  4158. };
  4159. #cache = {
  4160. ...{
  4161. group: {},
  4162. officialGroup: {},
  4163. forum: {},
  4164. workshop: {},
  4165. curator: {}
  4166. },
  4167. ...GM_getValue('steamCache')
  4168. };
  4169. #auth = {};
  4170. #storeInitialized = false;
  4171. #communityInitialized = false;
  4172. #area = 'CN';
  4173. #areaStatus = 'end';
  4174. async init() {
  4175. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4176. try {
  4177. if (type === 'store') {
  4178. if (this.#storeInitialized) {
  4179. return true;
  4180. }
  4181. this.#storeInitialized = await this.#updateStoreAuth();
  4182. if (!this.#storeInitialized) {
  4183. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4184. return false;
  4185. }
  4186. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4187. return true;
  4188. }
  4189. if (type === 'community') {
  4190. if (this.#communityInitialized) {
  4191. return true;
  4192. }
  4193. this.#communityInitialized = await this.#updateCommunityAuth();
  4194. if (!this.#communityInitialized) {
  4195. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4196. return false;
  4197. }
  4198. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4199. return true;
  4200. }
  4201. this.#storeInitialized = await this.#updateStoreAuth();
  4202. this.#communityInitialized = await this.#updateCommunityAuth();
  4203. if (this.#storeInitialized && this.#communityInitialized) {
  4204. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4205. return true;
  4206. }
  4207. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4208. return false;
  4209. } catch (error) {
  4210. throwError(error, 'Steam.init');
  4211. return false;
  4212. }
  4213. }
  4214. async #refreshStoreToken() {
  4215. try {
  4216. const logStatus = scripts_echoLog({
  4217. text: i18n('refreshingToken', i18n('steamStore'))
  4218. });
  4219. const formData = new FormData();
  4220. formData.append('redir', 'https://store.steampowered.com/');
  4221. const {
  4222. result,
  4223. statusText,
  4224. status,
  4225. data
  4226. } = await tools_httpRequest({
  4227. url: 'https://login.steampowered.com/jwt/ajaxrefresh',
  4228. method: 'POST',
  4229. responseType: 'json',
  4230. headers: {
  4231. Host: 'login.steampowered.com',
  4232. Origin: 'https://store.steampowered.com',
  4233. Referer: 'https://store.steampowered.com/'
  4234. },
  4235. data: formData
  4236. });
  4237. if (result === 'Success') {
  4238. var _data$response;
  4239. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  4240. if (await this.#setStoreToken(data.response)) {
  4241. logStatus.success();
  4242. return true;
  4243. }
  4244. logStatus.error('Error');
  4245. return false;
  4246. }
  4247. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4248. return false;
  4249. }
  4250. logStatus.error(`${result}:${statusText}(${status})`);
  4251. return false;
  4252. } catch (error) {
  4253. throwError(error, 'Steam.refreshStoreToken');
  4254. return false;
  4255. }
  4256. }
  4257. async #setStoreToken(param) {
  4258. try {
  4259. const logStatus = scripts_echoLog({
  4260. text: i18n('settingToken', i18n('steamStore'))
  4261. });
  4262. const formData = new FormData();
  4263. formData.append('steamID', param.steamID);
  4264. formData.append('nonce', param.nonce);
  4265. formData.append('redir', param.redir);
  4266. formData.append('auth', param.auth);
  4267. const {
  4268. result,
  4269. statusText,
  4270. status,
  4271. data
  4272. } = await tools_httpRequest({
  4273. url: 'https://store.steampowered.com/login/settoken',
  4274. method: 'POST',
  4275. headers: {
  4276. Accept: 'application/json, text/plain, */*',
  4277. Host: 'store.steampowered.com',
  4278. Origin: 'https://store.steampowered.com',
  4279. Referer: 'https://store.steampowered.com/login'
  4280. },
  4281. data: formData
  4282. });
  4283. if (result === 'Success') {
  4284. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4285. logStatus.success();
  4286. return true;
  4287. }
  4288. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4289. return false;
  4290. }
  4291. logStatus.error(`${result}:${statusText}(${status})`);
  4292. return false;
  4293. } catch (error) {
  4294. throwError(error, 'Steam.setStoreToken');
  4295. return false;
  4296. }
  4297. }
  4298. async #updateStoreAuth() {
  4299. try {
  4300. const logStatus = scripts_echoLog({
  4301. text: i18n('updatingAuth', i18n('steamStore'))
  4302. });
  4303. const {
  4304. result,
  4305. statusText,
  4306. status,
  4307. data
  4308. } = await tools_httpRequest({
  4309. url: 'https://store.steampowered.com/',
  4310. method: 'GET',
  4311. headers: {
  4312. 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',
  4313. 'Cache-Control': 'max-age=0',
  4314. 'Sec-Fetch-Dest': 'document',
  4315. 'Sec-Fetch-Mode': 'navigate',
  4316. 'Upgrade-Insecure-Requests': '1'
  4317. }
  4318. });
  4319. if (result === 'Success') {
  4320. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4321. var _data$responseText$ma;
  4322. if (!data.responseText.includes('data-miniprofile=')) {
  4323. await this.#refreshStoreToken();
  4324. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  4325. return false;
  4326. }
  4327. const storeSessionID = (_data$responseText$ma = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4328. if (storeSessionID) {
  4329. this.#auth.storeSessionID = storeSessionID;
  4330. logStatus.success();
  4331. return true;
  4332. }
  4333. logStatus.error('Error: Get "sessionID" failed');
  4334. return false;
  4335. }
  4336. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4337. return false;
  4338. }
  4339. logStatus.error(`${result}:${statusText}(${status})`);
  4340. return false;
  4341. } catch (error) {
  4342. throwError(error, 'Steam.updateStoreAuth');
  4343. return false;
  4344. }
  4345. }
  4346. async #updateCommunityAuth() {
  4347. try {
  4348. const logStatus = scripts_echoLog({
  4349. text: i18n('updatingAuth', i18n('steamCommunity'))
  4350. });
  4351. const {
  4352. result,
  4353. statusText,
  4354. status,
  4355. data
  4356. } = await tools_httpRequest({
  4357. url: 'https://steamcommunity.com/my',
  4358. method: 'GET',
  4359. headers: {
  4360. 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',
  4361. 'Cache-Control': 'max-age=0',
  4362. 'Sec-Fetch-Dest': 'document',
  4363. 'Sec-Fetch-Mode': 'navigate',
  4364. 'Upgrade-Insecure-Requests': '1'
  4365. }
  4366. });
  4367. if (result === 'Success') {
  4368. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4369. var _data$responseText$ma2, _data$responseText$ma3, _data$responseText$ma4;
  4370. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  4371. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  4372. return false;
  4373. }
  4374. const steam64Id = (_data$responseText$ma2 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4375. const communitySessionID = (_data$responseText$ma3 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4376. const userName = (_data$responseText$ma4 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4377. if (steam64Id) {
  4378. this.#auth.steam64Id = steam64Id;
  4379. }
  4380. if (userName) {
  4381. this.#auth.userName = userName;
  4382. }
  4383. if (communitySessionID) {
  4384. this.#auth.communitySessionID = communitySessionID;
  4385. logStatus.success();
  4386. return true;
  4387. }
  4388. logStatus.error('Error: Get "sessionID" failed');
  4389. return false;
  4390. }
  4391. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4392. return false;
  4393. }
  4394. logStatus.error(`${result}:${statusText}(${status})`);
  4395. return false;
  4396. } catch (error) {
  4397. throwError(error, 'Steam.updateCommunityAuth');
  4398. return false;
  4399. }
  4400. }
  4401. async #getAreaInfo() {
  4402. try {
  4403. const logStatus = scripts_echoLog({
  4404. text: i18n('gettingAreaInfo')
  4405. });
  4406. const {
  4407. result,
  4408. statusText,
  4409. status,
  4410. data
  4411. } = await tools_httpRequest({
  4412. url: 'https://store.steampowered.com/cart/',
  4413. method: 'GET'
  4414. });
  4415. if (result === 'Success') {
  4416. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4417. var _data$responseText$ma5;
  4418. const currentArea = (_data$responseText$ma5 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4419. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  4420. if (currentArea && areas.length > 0) {
  4421. this.#area = currentArea;
  4422. logStatus.success();
  4423. return {
  4424. currentArea: currentArea,
  4425. areas: areas
  4426. };
  4427. }
  4428. logStatus.error('Error: get country info filed');
  4429. return {};
  4430. }
  4431. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4432. return {};
  4433. }
  4434. logStatus.error(`${result}:${statusText}(${status})`);
  4435. return {};
  4436. } catch (error) {
  4437. throwError(error, 'Steam.getAreaInfo');
  4438. return {};
  4439. }
  4440. }
  4441. async #changeArea(area) {
  4442. try {
  4443. if (this.#areaStatus === 'waiting') {
  4444. await new Promise(resolve => {
  4445. const checker = setInterval(() => {
  4446. if (this.#areaStatus !== 'waiting') {
  4447. clearInterval(checker);
  4448. resolve(true);
  4449. }
  4450. });
  4451. });
  4452. }
  4453. if (this.#area === area || !area && this.#area !== 'CN') {
  4454. return true;
  4455. }
  4456. this.#areaStatus = 'waiting';
  4457. let aimedArea = area;
  4458. if (!aimedArea) {
  4459. const {
  4460. currentArea,
  4461. areas
  4462. } = await this.#getAreaInfo();
  4463. if (!currentArea || !areas) {
  4464. this.#areaStatus = 'error';
  4465. return false;
  4466. }
  4467. if (currentArea !== 'CN') {
  4468. this.#areaStatus = 'skip';
  4469. scripts_echoLog({
  4470. text: 'notNeededChangeArea'
  4471. });
  4472. return 'skip';
  4473. }
  4474. const anotherArea = areas.filter(area => area && area !== 'CN');
  4475. if (!anotherArea || anotherArea.length === 0) {
  4476. this.#areaStatus = 'noAnotherArea';
  4477. scripts_echoLog({
  4478. text: 'noAnotherArea'
  4479. });
  4480. return false;
  4481. }
  4482. [ aimedArea ] = anotherArea;
  4483. }
  4484. const logStatus = scripts_echoLog({
  4485. text: i18n('changingArea', aimedArea)
  4486. });
  4487. const {
  4488. result,
  4489. statusText,
  4490. status,
  4491. data
  4492. } = await tools_httpRequest({
  4493. url: 'https://store.steampowered.com/account/setcountry',
  4494. method: 'POST',
  4495. headers: {
  4496. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4497. },
  4498. data: $.param({
  4499. cc: aimedArea,
  4500. sessionid: this.#auth.storeSessionID
  4501. })
  4502. });
  4503. if (result === 'Success') {
  4504. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  4505. const {
  4506. currentArea
  4507. } = await this.#getAreaInfo();
  4508. if (currentArea === aimedArea) {
  4509. this.#areaStatus = 'success';
  4510. logStatus.success();
  4511. return currentArea;
  4512. }
  4513. this.#areaStatus = 'error';
  4514. logStatus.error('Error: change country filed');
  4515. return 'CN';
  4516. }
  4517. this.#areaStatus = 'error';
  4518. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4519. return 'CN';
  4520. }
  4521. this.#areaStatus = 'error';
  4522. logStatus.error(`${result}:${statusText}(${status})`);
  4523. return 'CN';
  4524. } catch (error) {
  4525. this.#areaStatus = 'error';
  4526. throwError(error, 'Steam.changeArea');
  4527. return false;
  4528. }
  4529. }
  4530. async #joinGroup(groupName) {
  4531. try {
  4532. const logStatus = scripts_echoLog({
  4533. type: 'joiningSteamGroup',
  4534. text: groupName
  4535. });
  4536. const {
  4537. result,
  4538. statusText,
  4539. status,
  4540. data
  4541. } = await tools_httpRequest({
  4542. url: `https://steamcommunity.com/groups/${groupName}`,
  4543. method: 'POST',
  4544. headers: {
  4545. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4546. },
  4547. data: $.param({
  4548. action: 'join',
  4549. sessionID: this.#auth.communitySessionID
  4550. })
  4551. });
  4552. if (result === 'Success') {
  4553. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  4554. logStatus.success();
  4555. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  4556. return true;
  4557. }
  4558. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4559. return false;
  4560. }
  4561. logStatus.error(`${result}:${statusText}(${status})`);
  4562. return false;
  4563. } catch (error) {
  4564. throwError(error, 'Steam.joinGroup');
  4565. return false;
  4566. }
  4567. }
  4568. async #leaveGroup(groupName) {
  4569. try {
  4570. if (this.whiteList.groups.includes(groupName)) {
  4571. scripts_echoLog({
  4572. type: 'whiteList',
  4573. text: 'Steam.leaveGroup',
  4574. id: groupName
  4575. });
  4576. return true;
  4577. }
  4578. const groupId = await this.#getGroupId(groupName);
  4579. if (!groupId) {
  4580. return false;
  4581. }
  4582. const logStatus = scripts_echoLog({
  4583. type: 'leavingSteamGroup',
  4584. text: groupName
  4585. });
  4586. const {
  4587. result,
  4588. statusText,
  4589. status,
  4590. data
  4591. } = await tools_httpRequest({
  4592. url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
  4593. method: 'POST',
  4594. headers: {
  4595. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4596. },
  4597. data: $.param({
  4598. sessionID: this.#auth.communitySessionID,
  4599. action: 'leaveGroup',
  4600. groupId: groupId
  4601. })
  4602. });
  4603. if (result === 'Success') {
  4604. 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) {
  4605. logStatus.success();
  4606. return true;
  4607. }
  4608. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4609. return false;
  4610. }
  4611. logStatus.error(`${result}:${statusText}(${status})`);
  4612. return false;
  4613. } catch (error) {
  4614. throwError(error, 'Steam.leaveGroup');
  4615. return false;
  4616. }
  4617. }
  4618. async #getGroupId(groupName) {
  4619. try {
  4620. const logStatus = scripts_echoLog({
  4621. type: 'gettingSteamGroupId',
  4622. text: groupName
  4623. });
  4624. const groupId = this.#cache.group[groupName];
  4625. if (groupId) {
  4626. logStatus.success();
  4627. return groupId;
  4628. }
  4629. const {
  4630. result,
  4631. statusText,
  4632. status,
  4633. data
  4634. } = await tools_httpRequest({
  4635. url: `https://steamcommunity.com/groups/${groupName}`,
  4636. method: 'GET',
  4637. headers: {
  4638. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4639. }
  4640. });
  4641. if (result === 'Success') {
  4642. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4643. var _data$responseText$ma6;
  4644. const groupId = (_data$responseText$ma6 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  4645. if (groupId) {
  4646. this.#setCache('group', groupName, groupId);
  4647. logStatus.success();
  4648. return groupId;
  4649. }
  4650. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4651. return false;
  4652. }
  4653. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4654. return false;
  4655. }
  4656. logStatus.error(`${result}:${statusText}(${status})`);
  4657. return false;
  4658. } catch (error) {
  4659. throwError(error, 'Steam.getGroupID');
  4660. return false;
  4661. }
  4662. }
  4663. async #joinOfficialGroup(gameId) {
  4664. try {
  4665. const logStatus = scripts_echoLog({
  4666. type: 'joiningSteamOfficialGroup',
  4667. text: gameId
  4668. });
  4669. const {
  4670. result,
  4671. statusText,
  4672. status,
  4673. data
  4674. } = await tools_httpRequest({
  4675. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${this.#auth.communitySessionID}`,
  4676. method: 'GET',
  4677. headers: {
  4678. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4679. }
  4680. });
  4681. if (result === 'Success') {
  4682. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  4683. var _data$responseText$ma7;
  4684. logStatus.success();
  4685. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  4686. 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];
  4687. if (groupId) {
  4688. this.#setCache('officialGroup', gameId, groupId);
  4689. }
  4690. return true;
  4691. }
  4692. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4693. return false;
  4694. }
  4695. logStatus.error(`${result}:${statusText}(${status})`);
  4696. return false;
  4697. } catch (error) {
  4698. throwError(error, 'Steam.joinOfficialGroup');
  4699. return false;
  4700. }
  4701. }
  4702. async #leaveOfficialGroup(gameId) {
  4703. try {
  4704. if (this.whiteList.officialGroups.includes(gameId)) {
  4705. scripts_echoLog({
  4706. type: 'whiteList',
  4707. text: 'Steam.leaveOfficialGroup',
  4708. id: gameId
  4709. });
  4710. return true;
  4711. }
  4712. const groupId = await this.#getOfficialGroupId(gameId);
  4713. if (!groupId) {
  4714. return false;
  4715. }
  4716. const logStatus = scripts_echoLog({
  4717. type: 'leavingSteamOfficialGroup',
  4718. text: gameId
  4719. });
  4720. const {
  4721. result,
  4722. statusText,
  4723. status,
  4724. data
  4725. } = await tools_httpRequest({
  4726. url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
  4727. method: 'POST',
  4728. headers: {
  4729. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4730. },
  4731. data: $.param({
  4732. sessionID: this.#auth.communitySessionID,
  4733. action: 'leaveGroup',
  4734. groupId: groupId
  4735. })
  4736. });
  4737. if (result === 'Success') {
  4738. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4739. const {
  4740. result: resultR,
  4741. statusText: statusTextR,
  4742. status: statusR,
  4743. data: dataR
  4744. } = await tools_httpRequest({
  4745. url: `https://steamcommunity.com/games/${gameId}`,
  4746. method: 'GET',
  4747. headers: {
  4748. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4749. }
  4750. });
  4751. if (resultR === 'Success') {
  4752. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  4753. logStatus.success();
  4754. return true;
  4755. }
  4756. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4757. return false;
  4758. }
  4759. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4760. return false;
  4761. }
  4762. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4763. return false;
  4764. }
  4765. logStatus.error(`${result}:${statusText}(${status})`);
  4766. return false;
  4767. } catch (error) {
  4768. throwError(error, 'Steam.leaveOfficialGroup');
  4769. return false;
  4770. }
  4771. }
  4772. async #getOfficialGroupId(gameId) {
  4773. try {
  4774. const logStatus = scripts_echoLog({
  4775. type: 'gettingSteamOfficialGroupId',
  4776. text: gameId
  4777. });
  4778. const groupId = this.#cache.officialGroup[gameId];
  4779. if (groupId) {
  4780. logStatus.success();
  4781. return groupId;
  4782. }
  4783. const {
  4784. result,
  4785. statusText,
  4786. status,
  4787. data
  4788. } = await tools_httpRequest({
  4789. url: `https://steamcommunity.com/games/${gameId}`,
  4790. method: 'GET',
  4791. headers: {
  4792. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4793. }
  4794. });
  4795. if (result === 'Success') {
  4796. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4797. var _data$responseText$ma8;
  4798. 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];
  4799. if (groupId) {
  4800. this.#setCache('officialGroup', gameId, groupId);
  4801. logStatus.success();
  4802. return groupId;
  4803. }
  4804. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4805. return false;
  4806. }
  4807. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4808. return false;
  4809. }
  4810. logStatus.error(`${result}:${statusText}(${status})`);
  4811. return false;
  4812. } catch (error) {
  4813. throwError(error, 'Steam.getGroupID');
  4814. return false;
  4815. }
  4816. }
  4817. async #addToWishlist(gameId) {
  4818. try {
  4819. var _data$response2;
  4820. const logStatus = scripts_echoLog({
  4821. type: 'addingToWishlist',
  4822. text: gameId
  4823. });
  4824. const {
  4825. result,
  4826. data
  4827. } = await tools_httpRequest({
  4828. url: 'https://store.steampowered.com/api/addtowishlist',
  4829. method: 'POST',
  4830. headers: {
  4831. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4832. },
  4833. data: $.param({
  4834. sessionid: this.#auth.storeSessionID,
  4835. appid: gameId
  4836. }),
  4837. dataType: 'json'
  4838. });
  4839. 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) {
  4840. logStatus.success();
  4841. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  4842. return true;
  4843. }
  4844. const {
  4845. result: resultR,
  4846. statusText: statusTextR,
  4847. status: statusR,
  4848. data: dataR
  4849. } = await tools_httpRequest({
  4850. url: `https://store.steampowered.com/app/${gameId}`,
  4851. method: 'GET'
  4852. });
  4853. if (resultR === 'Success') {
  4854. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  4855. if (this.#area === 'CN' && dataR.responseText.includes('id="error_box"')) {
  4856. logStatus.warning(i18n('changeAreaNotice'));
  4857. if (!await this.#changeArea()) {
  4858. return false;
  4859. }
  4860. return await this.#addToWishlist(gameId);
  4861. }
  4862. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  4863. logStatus.success();
  4864. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  4865. return true;
  4866. } 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"')) {
  4867. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  4868. return false;
  4869. }
  4870. logStatus.success();
  4871. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  4872. return true;
  4873. }
  4874. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4875. return false;
  4876. }
  4877. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4878. return false;
  4879. } catch (error) {
  4880. throwError(error, 'Steam.addToWishlist');
  4881. return false;
  4882. }
  4883. }
  4884. async #removeFromWishlist(gameId) {
  4885. try {
  4886. var _data$response3;
  4887. if (this.whiteList.wishlists.includes(gameId)) {
  4888. scripts_echoLog({
  4889. type: 'whiteList',
  4890. text: 'Steam.removeFromWishlist',
  4891. id: gameId
  4892. });
  4893. return true;
  4894. }
  4895. const logStatus = scripts_echoLog({
  4896. type: 'removingFromWishlist',
  4897. text: gameId
  4898. });
  4899. const {
  4900. result,
  4901. data
  4902. } = await tools_httpRequest({
  4903. url: 'https://store.steampowered.com/api/removefromwishlist',
  4904. method: 'POST',
  4905. headers: {
  4906. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4907. },
  4908. data: $.param({
  4909. sessionid: this.#auth.storeSessionID,
  4910. appid: gameId
  4911. }),
  4912. dataType: 'json'
  4913. });
  4914. 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) {
  4915. logStatus.success();
  4916. return true;
  4917. }
  4918. const {
  4919. result: resultR,
  4920. statusText: statusTextR,
  4921. status: statusR,
  4922. data: dataR
  4923. } = await tools_httpRequest({
  4924. url: `https://store.steampowered.com/app/${gameId}`,
  4925. method: 'GET'
  4926. });
  4927. if (resultR === 'Success') {
  4928. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  4929. if (this.#area === 'CN' && dataR.responseText.includes('id="error_box"')) {
  4930. logStatus.warning(i18n('changeAreaNotice'));
  4931. const result = await this.#changeArea();
  4932. if (!result || result === 'CN' || result === 'skip') {
  4933. return false;
  4934. }
  4935. return await this.#removeFromWishlist(gameId);
  4936. }
  4937. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  4938. logStatus.success();
  4939. return true;
  4940. }
  4941. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  4942. return false;
  4943. }
  4944. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4945. return false;
  4946. }
  4947. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4948. return false;
  4949. } catch (error) {
  4950. throwError(error, 'Steam.removeFromWishlist');
  4951. return false;
  4952. }
  4953. }
  4954. async #toggleFollowGame(gameId, doTask) {
  4955. try {
  4956. if (!doTask && this.whiteList.follows.includes(gameId)) {
  4957. scripts_echoLog({
  4958. type: 'whiteList',
  4959. text: 'Steam.unfollowGame',
  4960. id: gameId
  4961. });
  4962. return true;
  4963. }
  4964. const logStatus = scripts_echoLog({
  4965. type: `${doTask ? '' : 'un'}followingGame`,
  4966. text: gameId
  4967. });
  4968. const requestData = {
  4969. sessionid: this.#auth.storeSessionID,
  4970. appid: gameId
  4971. };
  4972. if (!doTask) {
  4973. requestData.unfollow = '1';
  4974. }
  4975. const {
  4976. result,
  4977. data
  4978. } = await tools_httpRequest({
  4979. url: 'https://store.steampowered.com/explore/followgame/',
  4980. method: 'POST',
  4981. headers: {
  4982. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4983. },
  4984. data: $.param(requestData)
  4985. });
  4986. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  4987. logStatus.success();
  4988. return true;
  4989. }
  4990. const followed = await this.#isFollowedGame(gameId);
  4991. if (this.#area === 'CN' && followed === 'areaLocked') {
  4992. logStatus.warning(i18n('changeAreaNotice'));
  4993. if (!await this.#changeArea()) {
  4994. return false;
  4995. }
  4996. return await this.#removeFromWishlist(gameId);
  4997. }
  4998. if (doTask === followed) {
  4999. logStatus.success();
  5000. if (doTask) {
  5001. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5002. }
  5003. return true;
  5004. }
  5005. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5006. return false;
  5007. } catch (error) {
  5008. throwError(error, 'Steam.toggleFollowGame');
  5009. return false;
  5010. }
  5011. }
  5012. async #isFollowedGame(gameId) {
  5013. try {
  5014. const {
  5015. result,
  5016. data
  5017. } = await tools_httpRequest({
  5018. url: `https://store.steampowered.com/app/${gameId}`,
  5019. method: 'GET'
  5020. });
  5021. if (result === 'Success') {
  5022. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5023. if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
  5024. return 'areaLocked';
  5025. }
  5026. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5027. return true;
  5028. }
  5029. return false;
  5030. }
  5031. return false;
  5032. }
  5033. return false;
  5034. } catch (error) {
  5035. throwError(error, 'Steam.isFollowedGame');
  5036. return false;
  5037. }
  5038. }
  5039. async #toggleForum(gameId) {
  5040. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5041. try {
  5042. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5043. scripts_echoLog({
  5044. type: 'whiteList',
  5045. text: 'Steam.unsubscribeForum',
  5046. id: gameId
  5047. });
  5048. return true;
  5049. }
  5050. const forumId = await this.#getForumId(gameId);
  5051. if (!forumId) {
  5052. return false;
  5053. }
  5054. const logStatus = scripts_echoLog({
  5055. type: `${doTask ? '' : 'un'}subscribingForum`,
  5056. text: gameId
  5057. });
  5058. const [ id, feature ] = forumId.split('_');
  5059. const {
  5060. result,
  5061. statusText,
  5062. status,
  5063. data
  5064. } = await tools_httpRequest({
  5065. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5066. method: 'POST',
  5067. responseType: 'json',
  5068. headers: {
  5069. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5070. },
  5071. data: $.param({
  5072. sessionid: this.#auth.communitySessionID
  5073. })
  5074. });
  5075. if (result === 'Success') {
  5076. var _data$response4, _data$response5;
  5077. 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)) {
  5078. if (doTask) {
  5079. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5080. }
  5081. logStatus.success();
  5082. return true;
  5083. }
  5084. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5085. return true;
  5086. }
  5087. logStatus.error(`${result}:${statusText}(${status})`);
  5088. return true;
  5089. } catch (error) {
  5090. throwError(error, 'Steam.toggleForum');
  5091. return true;
  5092. }
  5093. }
  5094. async #getForumId(gameId) {
  5095. try {
  5096. const logStatus = scripts_echoLog({
  5097. type: 'gettingForumId',
  5098. text: gameId
  5099. });
  5100. const forumId = this.#cache.forum[gameId];
  5101. if (forumId) {
  5102. logStatus.success();
  5103. return forumId;
  5104. }
  5105. const {
  5106. result,
  5107. statusText,
  5108. status,
  5109. data
  5110. } = await tools_httpRequest({
  5111. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5112. method: 'GET'
  5113. });
  5114. if (result === 'Success') {
  5115. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5116. var _data$responseText, _data$responseText$ma9;
  5117. 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];
  5118. if (forumId) {
  5119. this.#setCache('forum', gameId, forumId);
  5120. logStatus.success();
  5121. return forumId;
  5122. }
  5123. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5124. return false;
  5125. }
  5126. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5127. return false;
  5128. }
  5129. logStatus.error(`${result}:${statusText}(${status})`);
  5130. return false;
  5131. } catch (error) {
  5132. throwError(error, 'Steam.getForumId');
  5133. return false;
  5134. }
  5135. }
  5136. async #toggleFavoriteWorkshop(id) {
  5137. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5138. try {
  5139. if (!doTask && this.whiteList.workshops.includes(id)) {
  5140. scripts_echoLog({
  5141. type: 'whiteList',
  5142. text: 'Steam.unfavoriteWorkshop',
  5143. id: id
  5144. });
  5145. return true;
  5146. }
  5147. const appid = await this.#getWorkshopAppId(id);
  5148. if (!appid) {
  5149. return false;
  5150. }
  5151. const logStatus = scripts_echoLog({
  5152. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5153. text: id
  5154. });
  5155. const {
  5156. result,
  5157. statusText,
  5158. status,
  5159. data
  5160. } = await tools_httpRequest({
  5161. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5162. method: 'POST',
  5163. headers: {
  5164. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5165. },
  5166. data: $.param({
  5167. id: id,
  5168. appid: appid,
  5169. sessionid: this.#auth.communitySessionID
  5170. })
  5171. });
  5172. if (result === 'Success') {
  5173. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5174. if (doTask) {
  5175. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5176. }
  5177. logStatus.success();
  5178. return true;
  5179. }
  5180. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5181. return false;
  5182. }
  5183. logStatus.error(`${result}:${statusText}(${status})`);
  5184. return false;
  5185. } catch (error) {
  5186. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5187. return false;
  5188. }
  5189. }
  5190. async #getWorkshopAppId(id) {
  5191. try {
  5192. const logStatus = scripts_echoLog({
  5193. type: 'gettingWorkshopAppId',
  5194. text: id
  5195. });
  5196. const appId = this.#cache.workshop[id];
  5197. if (appId) {
  5198. logStatus.success();
  5199. return appId;
  5200. }
  5201. const {
  5202. result,
  5203. statusText,
  5204. status,
  5205. data
  5206. } = await tools_httpRequest({
  5207. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5208. method: 'GET'
  5209. });
  5210. if (result === 'Success') {
  5211. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5212. var _data$responseText$ma10;
  5213. 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];
  5214. if (appId) {
  5215. this.#setCache('workshop', id, appId);
  5216. logStatus.success();
  5217. return appId;
  5218. }
  5219. logStatus.error('Error: getWorkshopAppId failed');
  5220. return false;
  5221. }
  5222. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5223. return false;
  5224. }
  5225. logStatus.error(`${result}:${statusText}(${status})`);
  5226. return false;
  5227. } catch (error) {
  5228. throwError(error, 'Steam.getWorkshopAppId');
  5229. return false;
  5230. }
  5231. }
  5232. async #voteUpWorkshop(id) {
  5233. try {
  5234. const logStatus = scripts_echoLog({
  5235. type: 'votingUpWorkshop',
  5236. text: id
  5237. });
  5238. const {
  5239. result,
  5240. statusText,
  5241. status,
  5242. data
  5243. } = await tools_httpRequest({
  5244. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5245. method: 'POST',
  5246. responseType: 'json',
  5247. headers: {
  5248. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5249. },
  5250. data: $.param({
  5251. id: id,
  5252. sessionid: this.#auth.communitySessionID
  5253. })
  5254. });
  5255. if (result === 'Success') {
  5256. var _data$response6;
  5257. 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) {
  5258. logStatus.success();
  5259. return true;
  5260. }
  5261. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5262. return true;
  5263. }
  5264. logStatus.error(`${result}:${statusText}(${status})`);
  5265. return true;
  5266. } catch (error) {
  5267. throwError(error, 'Steam.voteupWorkshop');
  5268. return true;
  5269. }
  5270. }
  5271. async #toggleCurator(curatorId) {
  5272. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5273. try {
  5274. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5275. scripts_echoLog({
  5276. type: 'whiteList',
  5277. text: 'Steam.unfollowCurator',
  5278. id: curatorId
  5279. });
  5280. return true;
  5281. }
  5282. const logStatus = scripts_echoLog({
  5283. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5284. text: curatorId
  5285. });
  5286. const {
  5287. result,
  5288. statusText,
  5289. status,
  5290. data
  5291. } = await tools_httpRequest({
  5292. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5293. method: 'POST',
  5294. headers: {
  5295. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5296. },
  5297. data: $.param({
  5298. clanid: curatorId,
  5299. sessionid: this.#auth.storeSessionID,
  5300. follow: doTask
  5301. }),
  5302. dataType: 'json'
  5303. });
  5304. if (result === 'Success') {
  5305. var _data$response7, _data$response7$succe, _data$response8;
  5306. 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) {
  5307. logStatus.success();
  5308. return true;
  5309. }
  5310. 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})`);
  5311. return false;
  5312. }
  5313. logStatus.error(`${result}:${statusText}(${status})`);
  5314. return false;
  5315. } catch (error) {
  5316. throwError(error, 'Steam.toggleCurator');
  5317. return false;
  5318. }
  5319. }
  5320. async getCuratorId(path, name) {
  5321. try {
  5322. const logStatus = scripts_echoLog({
  5323. type: 'gettingCuratorId',
  5324. text: `${path}/${name}`
  5325. });
  5326. const curatorId = this.#cache.curator[`${path}/${name}`];
  5327. if (curatorId) {
  5328. logStatus.success();
  5329. return curatorId;
  5330. }
  5331. const {
  5332. result,
  5333. statusText,
  5334. status,
  5335. data
  5336. } = await tools_httpRequest({
  5337. url: `https://store.steampowered.com/${path}/${name}`,
  5338. method: 'GET',
  5339. headers: {
  5340. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5341. }
  5342. });
  5343. if (result === 'Success') {
  5344. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5345. var _data$responseText$ma11;
  5346. const curatorId = (_data$responseText$ma11 = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5347. if (curatorId) {
  5348. this.#setCache('curator', `${path}/${name}`, curatorId);
  5349. logStatus.success();
  5350. return curatorId;
  5351. }
  5352. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5353. return false;
  5354. }
  5355. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5356. return false;
  5357. }
  5358. logStatus.error(`${result}:${statusText}(${status})`);
  5359. return false;
  5360. } catch (error) {
  5361. throwError(error, 'Steam.getCuratorID');
  5362. return false;
  5363. }
  5364. }
  5365. async #toggleCuratorLike(link) {
  5366. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5367. try {
  5368. const [ path, name ] = link.split('/');
  5369. if (!(path && name)) {
  5370. scripts_echoLog({
  5371. text: i18n('errorLink', link)
  5372. });
  5373. return false;
  5374. }
  5375. const curatorId = await this.getCuratorId(path, name);
  5376. if (curatorId) {
  5377. return await this.#toggleCurator(curatorId, doTask);
  5378. }
  5379. return false;
  5380. } catch (error) {
  5381. throwError(error, 'Steam.toggleCuratorLike');
  5382. return false;
  5383. }
  5384. }
  5385. async #getAnnouncementParams(appId, viewId) {
  5386. try {
  5387. const logStatus = scripts_echoLog({
  5388. type: 'gettingAnnouncementParams',
  5389. text: appId,
  5390. id: viewId
  5391. });
  5392. const {
  5393. result,
  5394. statusText,
  5395. status,
  5396. data
  5397. } = await tools_httpRequest({
  5398. 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`,
  5399. method: 'GET',
  5400. responseType: 'json',
  5401. headers: {
  5402. Host: 'store.steampowered.com',
  5403. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5404. }
  5405. });
  5406. if (result === 'Success') {
  5407. var _data$response9;
  5408. 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) {
  5409. var _data$response$event;
  5410. const {
  5411. clanid,
  5412. gid
  5413. } = ((_data$response$event = data.response.event) === null || _data$response$event === void 0 ? void 0 : _data$response$event.announcement_body) || {};
  5414. if (clanid) {
  5415. logStatus.success();
  5416. return {
  5417. clanId: clanid,
  5418. gid: gid
  5419. };
  5420. }
  5421. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5422. return {};
  5423. }
  5424. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5425. return {};
  5426. }
  5427. logStatus.error(`${result}:${statusText}(${status})`);
  5428. return {};
  5429. } catch (error) {
  5430. throwError(error, 'Steam.likeAnnouncement');
  5431. return {};
  5432. }
  5433. }
  5434. async #likeAnnouncement(id) {
  5435. try {
  5436. const [ appId, viewId ] = id.split('/');
  5437. if (!(appId && viewId)) {
  5438. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  5439. return false;
  5440. }
  5441. const {
  5442. clanId,
  5443. gid
  5444. } = await this.#getAnnouncementParams(appId, viewId);
  5445. if (!clanId) {
  5446. return false;
  5447. }
  5448. const logStatus = scripts_echoLog({
  5449. type: 'likingAnnouncement',
  5450. text: appId,
  5451. id: viewId
  5452. });
  5453. const {
  5454. result,
  5455. statusText,
  5456. status,
  5457. data
  5458. } = await tools_httpRequest({
  5459. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5460. method: 'POST',
  5461. headers: {
  5462. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5463. Host: 'store.steampowered.com',
  5464. Origin: 'https://store.steampowered.com',
  5465. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5466. },
  5467. data: $.param({
  5468. sessionid: this.#auth.storeSessionID,
  5469. voteup: 1,
  5470. clanid: clanId,
  5471. ajax: 1
  5472. }),
  5473. dataType: 'json'
  5474. });
  5475. if (result === 'Success') {
  5476. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5477. logStatus.success();
  5478. return true;
  5479. }
  5480. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5481. return false;
  5482. }
  5483. logStatus.error(`${result}:${statusText}(${status})`);
  5484. return false;
  5485. } catch (error) {
  5486. throwError(error, 'Steam.likeAnnouncement');
  5487. return false;
  5488. }
  5489. }
  5490. async #appid2subid(id) {
  5491. try {
  5492. const logStatus = scripts_echoLog({
  5493. type: 'gettingSubid',
  5494. text: id
  5495. });
  5496. const {
  5497. result,
  5498. statusText,
  5499. status,
  5500. data
  5501. } = await tools_httpRequest({
  5502. url: `https://store.steampowered.com/app/${id}`,
  5503. method: 'GET',
  5504. headers: {
  5505. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5506. }
  5507. });
  5508. if (result === 'Success') {
  5509. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5510. var _data$responseText$ma12;
  5511. if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
  5512. logStatus.warning(i18n('changeAreaNotice'));
  5513. const result = await this.#changeArea();
  5514. if (!result || result === 'CN' || result === 'skip') {
  5515. return false;
  5516. }
  5517. return await this.#appid2subid(id);
  5518. }
  5519. const subid = (_data$responseText$ma12 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  5520. if (subid) {
  5521. logStatus.success();
  5522. return subid;
  5523. }
  5524. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5525. return false;
  5526. }
  5527. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5528. return false;
  5529. }
  5530. logStatus.error(`${result}:${statusText}(${status})`);
  5531. return false;
  5532. } catch (error) {
  5533. throwError(error, 'Steam.appid2subid');
  5534. return false;
  5535. }
  5536. }
  5537. async #getLicenses() {
  5538. try {
  5539. const logStatus = scripts_echoLog({
  5540. text: i18n('gettingLicenses')
  5541. });
  5542. const {
  5543. result,
  5544. statusText,
  5545. status,
  5546. data
  5547. } = await tools_httpRequest({
  5548. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  5549. method: 'GET',
  5550. responseType: 'json'
  5551. });
  5552. if (result === 'Success') {
  5553. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5554. var _data$response10;
  5555. logStatus.success();
  5556. return (_data$response10 = data.response) === null || _data$response10 === void 0 ? void 0 : _data$response10.rgOwnedPackages;
  5557. }
  5558. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5559. return false;
  5560. }
  5561. logStatus.error(`${result}:${statusText}(${status})`);
  5562. return false;
  5563. } catch (error) {
  5564. throwError(error, 'Steam.getLicenses');
  5565. return false;
  5566. }
  5567. }
  5568. async #addLicense(id) {
  5569. try {
  5570. const [ type, ids ] = id.split('-');
  5571. if (type === 'appid') {
  5572. const subid = await this.#appid2subid(ids);
  5573. if (!subid) {
  5574. return false;
  5575. }
  5576. const logStatus = scripts_echoLog({
  5577. type: 'addingFreeLicense',
  5578. text: ids
  5579. });
  5580. if (!await this.#addFreeLicense(subid, logStatus)) {
  5581. return false;
  5582. }
  5583. const {
  5584. result,
  5585. statusText,
  5586. status,
  5587. data
  5588. } = await tools_httpRequest({
  5589. url: `https://store.steampowered.com/app/${ids}`,
  5590. method: 'GET'
  5591. });
  5592. if (result === 'Success') {
  5593. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5594. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  5595. logStatus.success();
  5596. return true;
  5597. }
  5598. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5599. return false;
  5600. }
  5601. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5602. return false;
  5603. }
  5604. logStatus.error(`${result}:${statusText}(${status})`);
  5605. return false;
  5606. } else if (type === 'subid') {
  5607. if (this.#area === 'CN') {
  5608. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  5609. await this.#changeArea();
  5610. }
  5611. const logStatusArr = {};
  5612. const idsArr = ids.split(',');
  5613. for (const subid of idsArr) {
  5614. const logStatus = scripts_echoLog({
  5615. type: 'addingFreeLicenseSubid',
  5616. text: subid
  5617. });
  5618. if (!await this.#addFreeLicense(subid, logStatus)) {
  5619. return false;
  5620. }
  5621. logStatusArr[subid] = logStatus;
  5622. }
  5623. const licenses = await this.#getLicenses();
  5624. if (!licenses) {
  5625. return false;
  5626. }
  5627. for (const subid of idsArr) {
  5628. if (licenses.includes(parseInt(subid, 10))) {
  5629. logStatusArr[subid].success();
  5630. } else {
  5631. logStatusArr[subid].error();
  5632. }
  5633. }
  5634. return true;
  5635. }
  5636. return false;
  5637. } catch (error) {
  5638. throwError(error, 'Steam.addLicense');
  5639. return false;
  5640. }
  5641. }
  5642. async #addFreeLicense(id, logStatusPre) {
  5643. try {
  5644. const logStatus = logStatusPre || scripts_echoLog({
  5645. type: 'addingFreeLicenseSubid',
  5646. text: id
  5647. });
  5648. const {
  5649. result,
  5650. statusText,
  5651. status,
  5652. data
  5653. } = await tools_httpRequest({
  5654. url: 'https://store.steampowered.com/checkout/addfreelicense',
  5655. method: 'POST',
  5656. headers: {
  5657. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5658. Host: 'store.steampowered.com',
  5659. Origin: 'https://store.steampowered.com',
  5660. Referer: 'https://store.steampowered.com/account/licenses/'
  5661. },
  5662. data: $.param({
  5663. action: 'add_to_cart',
  5664. sessionid: this.#auth.storeSessionID,
  5665. subid: id
  5666. }),
  5667. dataType: 'json'
  5668. });
  5669. if (result === 'Success') {
  5670. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5671. if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
  5672. logStatus.warning(i18n('changeAreaNotice'));
  5673. const result = await this.#changeArea();
  5674. if (!result || result === 'CN') {
  5675. return false;
  5676. }
  5677. return await this.#addFreeLicense(id);
  5678. }
  5679. logStatus.success();
  5680. return true;
  5681. }
  5682. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5683. return false;
  5684. }
  5685. logStatus.error(`${result}:${statusText}(${status})`);
  5686. return false;
  5687. } catch (error) {
  5688. throwError(error, 'Steam.addFreeLicense');
  5689. return false;
  5690. }
  5691. }
  5692. async #requestPlayTestAccess(id) {
  5693. try {
  5694. const logStatus = scripts_echoLog({
  5695. type: 'requestingPlayTestAccess',
  5696. text: id
  5697. });
  5698. const {
  5699. result,
  5700. statusText,
  5701. status,
  5702. data
  5703. } = await tools_httpRequest({
  5704. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  5705. method: 'POST',
  5706. headers: {
  5707. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5708. Host: 'store.steampowered.com',
  5709. Origin: 'https://store.steampowered.com',
  5710. Referer: `https://store.steampowered.com/app/${id}`
  5711. },
  5712. data: $.param({
  5713. sessionid: this.#auth.storeSessionID
  5714. }),
  5715. dataType: 'json'
  5716. });
  5717. if (result === 'Success') {
  5718. var _data$response11;
  5719. 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) {
  5720. logStatus.success();
  5721. return true;
  5722. }
  5723. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5724. return false;
  5725. }
  5726. logStatus.error(`${result}:${statusText}(${status})`);
  5727. return false;
  5728. } catch (error) {
  5729. throwError(error, 'Steam.requestPlayTestAccess');
  5730. return false;
  5731. }
  5732. }
  5733. async toggle(_ref) {
  5734. let {
  5735. doTask = true,
  5736. groupLinks = [],
  5737. officialGroupLinks = [],
  5738. wishlistLinks = [],
  5739. followLinks = [],
  5740. forumLinks = [],
  5741. workshopLinks = [],
  5742. workshopVoteLinks = [],
  5743. curatorLinks = [],
  5744. curatorLikeLinks = [],
  5745. announcementLinks = [],
  5746. licenseLinks = [],
  5747. playtestLinks = []
  5748. } = _ref;
  5749. try {
  5750. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !this.#communityInitialized) {
  5751. scripts_echoLog({
  5752. text: i18n('needInit')
  5753. });
  5754. return false;
  5755. }
  5756. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !this.#storeInitialized) {
  5757. scripts_echoLog({
  5758. text: i18n('needInit')
  5759. });
  5760. return false;
  5761. }
  5762. const prom = [];
  5763. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  5764. scripts_echoLog({
  5765. type: 'globalOptionsSkip',
  5766. text: 'steam.groups'
  5767. });
  5768. } else {
  5769. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  5770. var _link$match;
  5771. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  5772. });
  5773. if (realGroups.length > 0) {
  5774. for (const group of realGroups) {
  5775. if (doTask) {
  5776. prom.push(this.#joinGroup(group));
  5777. } else {
  5778. prom.push(this.#leaveGroup(group));
  5779. }
  5780. await delay(1e3);
  5781. }
  5782. }
  5783. }
  5784. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  5785. scripts_echoLog({
  5786. type: 'globalOptionsSkip',
  5787. text: 'steam.officialGroups'
  5788. });
  5789. } else {
  5790. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  5791. var _link$match2;
  5792. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  5793. });
  5794. if (realOfficialGroups.length > 0) {
  5795. for (const officialGroup of realOfficialGroups) {
  5796. if (doTask) {
  5797. prom.push(this.#joinOfficialGroup(officialGroup));
  5798. } else {
  5799. prom.push(this.#leaveOfficialGroup(officialGroup));
  5800. }
  5801. await delay(1e3);
  5802. }
  5803. }
  5804. }
  5805. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  5806. scripts_echoLog({
  5807. type: 'globalOptionsSkip',
  5808. text: 'steam.wishlists'
  5809. });
  5810. } else {
  5811. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  5812. var _link$match3;
  5813. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5814. });
  5815. if (realWishlists.length > 0) {
  5816. for (const game of realWishlists) {
  5817. if (doTask) {
  5818. prom.push(this.#addToWishlist(game));
  5819. } else {
  5820. prom.push(this.#removeFromWishlist(game));
  5821. }
  5822. await delay(1e3);
  5823. }
  5824. }
  5825. }
  5826. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5827. scripts_echoLog({
  5828. type: 'globalOptionsSkip',
  5829. text: 'steam.follows'
  5830. });
  5831. } else {
  5832. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5833. var _link$match4;
  5834. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5835. });
  5836. if (realFollows.length > 0) {
  5837. for (const game of realFollows) {
  5838. prom.push(this.#toggleFollowGame(game, doTask));
  5839. await delay(1e3);
  5840. }
  5841. }
  5842. }
  5843. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5844. scripts_echoLog({
  5845. type: 'globalOptionsSkip',
  5846. text: 'steam.forums'
  5847. });
  5848. } else {
  5849. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5850. var _link$match5;
  5851. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5852. });
  5853. if (realForums.length > 0) {
  5854. for (const forum of realForums) {
  5855. prom.push(this.#toggleForum(forum, doTask));
  5856. await delay(1e3);
  5857. }
  5858. }
  5859. }
  5860. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5861. scripts_echoLog({
  5862. type: 'globalOptionsSkip',
  5863. text: 'steam.workshops'
  5864. });
  5865. } else {
  5866. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5867. var _link$match6;
  5868. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5869. });
  5870. if (realWorkshops.length > 0) {
  5871. for (const workshop of realWorkshops) {
  5872. prom.push(this.#toggleFavoriteWorkshop(workshop, doTask));
  5873. await delay(1e3);
  5874. }
  5875. }
  5876. }
  5877. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5878. scripts_echoLog({
  5879. type: 'globalOptionsSkip',
  5880. text: 'steam.workshopVotes'
  5881. });
  5882. } else {
  5883. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5884. var _link$match7;
  5885. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5886. });
  5887. if (doTask && realworkshopVotes.length > 0) {
  5888. for (const workshop of realworkshopVotes) {
  5889. prom.push(this.#voteUpWorkshop(workshop));
  5890. await delay(1e3);
  5891. }
  5892. }
  5893. }
  5894. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5895. scripts_echoLog({
  5896. type: 'globalOptionsSkip',
  5897. text: 'steam.curators'
  5898. });
  5899. } else {
  5900. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5901. var _link$match8;
  5902. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5903. });
  5904. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5905. var _link$match9;
  5906. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5907. });
  5908. if (realCurators.length > 0) {
  5909. for (const curator of realCurators) {
  5910. prom.push(this.#toggleCurator(curator, doTask));
  5911. await delay(1e3);
  5912. }
  5913. }
  5914. if (realCuratorLikes.length > 0) {
  5915. for (const curatorLike of realCuratorLikes) {
  5916. prom.push(this.#toggleCuratorLike(curatorLike, doTask));
  5917. await delay(1e3);
  5918. }
  5919. }
  5920. }
  5921. if (doTask && !globalOptions.doTask.steam.announcements) {
  5922. scripts_echoLog({
  5923. type: 'globalOptionsSkip',
  5924. text: 'steam.announcements'
  5925. });
  5926. } else {
  5927. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5928. var _link$match11;
  5929. if (link.includes('store.steampowered.com')) {
  5930. var _link$match10;
  5931. 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('/');
  5932. }
  5933. 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('/');
  5934. });
  5935. if (doTask && realAnnouncements.length > 0) {
  5936. for (const id of realAnnouncements) {
  5937. prom.push(this.#likeAnnouncement(id));
  5938. await delay(1e3);
  5939. }
  5940. }
  5941. }
  5942. if (doTask && !globalOptions.doTask.steam.licenses) {
  5943. scripts_echoLog({
  5944. type: 'globalOptionsSkip',
  5945. text: 'steam.licenses'
  5946. });
  5947. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5948. for (const id of licenseLinks) {
  5949. prom.push(this.#addLicense(id));
  5950. await delay(1e3);
  5951. }
  5952. }
  5953. if (doTask && !globalOptions.doTask.steam.playtests) {
  5954. scripts_echoLog({
  5955. type: 'globalOptionsSkip',
  5956. text: 'steam.playtests'
  5957. });
  5958. } else {
  5959. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5960. var _link$match12;
  5961. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5962. });
  5963. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5964. for (const id of realPlaytests) {
  5965. prom.push(this.#requestPlayTestAccess(id));
  5966. await delay(1e3);
  5967. }
  5968. }
  5969. }
  5970. return Promise.all(prom).then(async () => {
  5971. if (this.#area !== 'CN') {
  5972. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5973. await this.#changeArea('CN');
  5974. }
  5975. return true;
  5976. });
  5977. } catch (error) {
  5978. throwError(error, 'Steam.toggle');
  5979. return false;
  5980. }
  5981. }
  5982. #setCache(type, name, id) {
  5983. try {
  5984. this.#cache[type][name] = id;
  5985. GM_setValue('steamCache', this.#cache);
  5986. } catch (error) {
  5987. throwError(error, 'Steam.setCache');
  5988. }
  5989. }
  5990. }
  5991. const social_Steam = Steam;
  5992. class Website {
  5993. undoneTasks;
  5994. socialTasks;
  5995. giveawayId;
  5996. socialInitialized = {
  5997. discord: false,
  5998. instagram: false,
  5999. reddit: false,
  6000. twitch: false,
  6001. twitter: false,
  6002. vk: false,
  6003. youtube: false,
  6004. steamStore: false,
  6005. steamCommunity: false
  6006. };
  6007. initialized = false;
  6008. social = {};
  6009. async #bind(name, init) {
  6010. try {
  6011. return {
  6012. name: name,
  6013. result: await init
  6014. };
  6015. } catch (error) {
  6016. throwError(error, 'Website.bind');
  6017. return {
  6018. name: name,
  6019. result: false
  6020. };
  6021. }
  6022. }
  6023. async initSocial(action) {
  6024. try {
  6025. const pro = [];
  6026. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6027. if (tasks.discord) {
  6028. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6029. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6030. this.social.discord = new social_Discord();
  6031. pro.push(this.#bind('discord', this.social.discord.init()));
  6032. }
  6033. }
  6034. if (tasks.instagram) {
  6035. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6036. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6037. this.social.instagram = new social_Instagram();
  6038. pro.push(this.#bind('instagram', this.social.instagram.init()));
  6039. }
  6040. }
  6041. if (tasks.reddit) {
  6042. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6043. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6044. this.social.reddit = new social_Reddit();
  6045. pro.push(this.#bind('reddit', this.social.reddit.init()));
  6046. }
  6047. }
  6048. if (tasks.twitch) {
  6049. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6050. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6051. this.social.twitch = new social_Twitch();
  6052. pro.push(this.#bind('twitch', this.social.twitch.init()));
  6053. }
  6054. }
  6055. if (tasks.twitter) {
  6056. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6057. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6058. this.social.twitter = new social_Twitter();
  6059. pro.push(this.#bind('twitter', this.social.twitter.init()));
  6060. }
  6061. }
  6062. if (tasks.vk) {
  6063. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6064. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6065. this.social.vk = new social_Vk();
  6066. pro.push(this.#bind('vk', this.social.vk.init()));
  6067. }
  6068. }
  6069. if (tasks.youtube) {
  6070. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6071. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6072. this.social.youtube = new Youtube();
  6073. pro.push(this.#bind('youtube', this.social.youtube.init()));
  6074. }
  6075. }
  6076. if (tasks.steam) {
  6077. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6078. if (steamLength > 0) {
  6079. if (!this.social.steam) {
  6080. this.social.steam = new social_Steam();
  6081. }
  6082. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6083. var _tasks$steam, _tasks$steam$type;
  6084. 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;
  6085. }).reduce((total, number) => total + number, 0);
  6086. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6087. pro.push(this.#bind('steamStore', this.social.steam.init('store')));
  6088. }
  6089. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6090. pro.push(this.#bind('steamCommunity', this.social.steam.init('community')));
  6091. }
  6092. }
  6093. }
  6094. if (tasks.links && tasks.links.length > 0) {
  6095. this.social.visitLink = visitLink;
  6096. }
  6097. return await Promise.all(pro).then(result => {
  6098. let checked = true;
  6099. for (const data of result) {
  6100. if (data.result) {
  6101. this.socialInitialized[data.name] = data.result;
  6102. } else {
  6103. checked = false;
  6104. }
  6105. }
  6106. return checked;
  6107. });
  6108. } catch (error) {
  6109. throwError(error, 'Website.initSocial');
  6110. return false;
  6111. }
  6112. }
  6113. uniqueTasks(allTasks) {
  6114. const result = {};
  6115. for (const [ social, types ] of Object.entries(allTasks)) {
  6116. result[social] = {};
  6117. for (const [ type, tasks ] of Object.entries(types)) {
  6118. result[social][type] = unique(tasks);
  6119. }
  6120. }
  6121. return result;
  6122. }
  6123. async toggleTask(action) {
  6124. try {
  6125. if (!this.initialized && !this.init()) {
  6126. return false;
  6127. }
  6128. if (!await this.classifyTask(action)) {
  6129. return false;
  6130. }
  6131. if (!await this.initSocial(action)) {
  6132. return false;
  6133. }
  6134. const pro = [];
  6135. const doTask = action === 'do';
  6136. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6137. if (this.socialInitialized.discord !== 'skip' && this.social.discord) {
  6138. pro.push(this.social.discord.toggle({
  6139. doTask: doTask,
  6140. ...tasks.discord
  6141. }));
  6142. }
  6143. if (this.social.instagram) {
  6144. pro.push(this.social.instagram.toggle({
  6145. doTask: doTask,
  6146. ...tasks.instagram
  6147. }));
  6148. }
  6149. if (this.social.reddit) {
  6150. pro.push(this.social.reddit.toggle({
  6151. doTask: doTask,
  6152. ...tasks.reddit
  6153. }));
  6154. }
  6155. if (this.social.twitch) {
  6156. pro.push(this.social.twitch.toggle({
  6157. doTask: doTask,
  6158. ...tasks.twitch
  6159. }));
  6160. }
  6161. if (this.social.twitter) {
  6162. pro.push(this.social.twitter.toggle({
  6163. doTask: doTask,
  6164. ...tasks.twitter
  6165. }));
  6166. }
  6167. if (this.social.vk) {
  6168. pro.push(this.social.vk.toggle({
  6169. doTask: doTask,
  6170. ...tasks.vk
  6171. }));
  6172. }
  6173. if (this.social.youtube) {
  6174. pro.push(this.social.youtube.toggle({
  6175. doTask: doTask,
  6176. ...tasks.youtube
  6177. }));
  6178. }
  6179. if (this.social.steam) {
  6180. pro.push(this.social.steam.toggle({
  6181. doTask: doTask,
  6182. ...tasks.steam
  6183. }));
  6184. }
  6185. if (this.social.visitLink && tasks.links && doTask) {
  6186. for (const link of tasks.links) {
  6187. pro.push(this.social.visitLink(link));
  6188. }
  6189. }
  6190. if (doTask && tasks.extra && this.extraDoTask) {
  6191. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6192. if (hasExtra) {
  6193. pro.push(this.extraDoTask(tasks.extra));
  6194. }
  6195. }
  6196. await Promise.all(pro);
  6197. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6198. return true;
  6199. } catch (error) {
  6200. throwError(error, 'Website.toggleTask');
  6201. return false;
  6202. }
  6203. }
  6204. async doTask() {
  6205. try {
  6206. return await this.toggleTask('do');
  6207. } catch (error) {
  6208. throwError(error, 'Website.doTask');
  6209. return false;
  6210. }
  6211. }
  6212. async undoTask() {
  6213. try {
  6214. return await this.toggleTask('undo');
  6215. } catch (error) {
  6216. throwError(error, 'Website.undoTask');
  6217. return false;
  6218. }
  6219. }
  6220. }
  6221. const website_Website = Website;
  6222. const FreeAnyWhere_defaultTasksTemplate = {
  6223. steam: {
  6224. groupLinks: [],
  6225. wishlistLinks: [],
  6226. curatorLinks: [],
  6227. followLinks: []
  6228. },
  6229. vk: {
  6230. nameLinks: []
  6231. }
  6232. };
  6233. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6234. class FreeAnyWhere extends website_Website {
  6235. name = 'FreeAnyWhere';
  6236. tasks = [];
  6237. socialTasks = JSON.parse(FreeAnyWhere_defaultTasks);
  6238. undoneTasks = JSON.parse(FreeAnyWhere_defaultTasks);
  6239. buttons = [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ];
  6240. static test() {
  6241. return window.location.host === 'freeanywhere.net';
  6242. }
  6243. async init() {
  6244. try {
  6245. const logStatus = scripts_echoLog({
  6246. text: i18n('initing')
  6247. });
  6248. if ($('a[href="#/login"]').length > 0) {
  6249. window.open('/#/login', '_self');
  6250. logStatus.warning(i18n('needLogin'));
  6251. return false;
  6252. }
  6253. if (window.location.href.includes('/login')) {
  6254. logStatus.warning(i18n('needLogin'));
  6255. return false;
  6256. }
  6257. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6258. var _window$location$href;
  6259. 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];
  6260. if (!id) {
  6261. logStatus.error(i18n('getFailed', 'Id'));
  6262. return false;
  6263. }
  6264. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6265. }
  6266. if (!this.#getGiveawayId()) {
  6267. return false;
  6268. }
  6269. if (!await this.#checkLeftKey()) {
  6270. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6271. }
  6272. this.initialized = true;
  6273. logStatus.success();
  6274. return true;
  6275. } catch (error) {
  6276. throwError(error, 'Freeanywhere.init');
  6277. return false;
  6278. }
  6279. }
  6280. async classifyTask(action) {
  6281. try {
  6282. const logStatus = scripts_echoLog({
  6283. text: i18n('getTasksInfo')
  6284. });
  6285. if (action === 'undo') {
  6286. var _GM_getValue;
  6287. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6288. }
  6289. const {
  6290. result,
  6291. statusText,
  6292. status,
  6293. data
  6294. } = await tools_httpRequest({
  6295. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6296. method: 'GET',
  6297. headers: {
  6298. authorization: `Token ${window.localStorage.getItem('token')}`,
  6299. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6300. },
  6301. responseType: 'json'
  6302. });
  6303. if (result === 'Success') {
  6304. var _data$response;
  6305. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6306. if (tasks) {
  6307. if (action === 'verify') {
  6308. this.tasks = [];
  6309. }
  6310. for (const task of tasks) {
  6311. const type = task.challenge;
  6312. const social = task.challenge_provider;
  6313. const taskInfo = {
  6314. id: task.id,
  6315. title: task.title
  6316. };
  6317. if (action === 'verify' && !task.is_success) {
  6318. this.tasks.push(taskInfo);
  6319. continue;
  6320. }
  6321. switch (social) {
  6322. case 'steam':
  6323. taskInfo.social = 'steam';
  6324. switch (type) {
  6325. case 'WL':
  6326. if (action === 'undo') {
  6327. this.socialTasks.steam.wishlistLinks.push(task.link);
  6328. }
  6329. if (action === 'do' && !task.is_success) {
  6330. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6331. }
  6332. break;
  6333.  
  6334. case 'JTG':
  6335. if (action === 'undo') {
  6336. this.socialTasks.steam.groupLinks.push(task.link);
  6337. }
  6338. if (action === 'do' && !task.is_success) {
  6339. this.undoneTasks.steam.groupLinks.push(task.link);
  6340. }
  6341. break;
  6342.  
  6343. case 'STC':
  6344. if (action === 'undo') {
  6345. this.socialTasks.steam.curatorLinks.push(task.link);
  6346. }
  6347. if (action === 'do' && !task.is_success) {
  6348. this.undoneTasks.steam.curatorLinks.push(task.link);
  6349. }
  6350. break;
  6351.  
  6352. case 'GF':
  6353. if (action === 'undo') {
  6354. this.socialTasks.steam.followLinks.push(task.link);
  6355. }
  6356. if (action === 'do' && !task.is_success) {
  6357. this.undoneTasks.steam.followLinks.push(task.link);
  6358. }
  6359. break;
  6360. }
  6361. break;
  6362.  
  6363. case 'vk-oauth2':
  6364. if (action === 'undo') {
  6365. this.socialTasks.vk.nameLinks.push(task.link);
  6366. }
  6367. if (action === 'do' && !task.is_success) {
  6368. this.undoneTasks.vk.nameLinks.push(task.link);
  6369. }
  6370. break;
  6371.  
  6372. case 'website':
  6373. break;
  6374.  
  6375. default:
  6376. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6377. break;
  6378. }
  6379. }
  6380. logStatus.success();
  6381. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6382. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6383. if (window.DEBUG) {
  6384. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  6385. }
  6386. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6387. tasks: this.socialTasks,
  6388. time: new Date().getTime()
  6389. });
  6390. return true;
  6391. }
  6392. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6393. return false;
  6394. }
  6395. logStatus.error(`${result}:${statusText}(${status})`);
  6396. return false;
  6397. } catch (error) {
  6398. throwError(error, 'Freeanywhere.classifyTask');
  6399. return false;
  6400. }
  6401. }
  6402. async verifyTask() {
  6403. try {
  6404. if (!this.initialized && !this.init()) {
  6405. return false;
  6406. }
  6407. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6408. return false;
  6409. }
  6410. const pro = [];
  6411. for (const task of this.tasks) {
  6412. pro.push(this.#verify(task));
  6413. await delay(1e3);
  6414. }
  6415. await Promise.all(pro);
  6416. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6417. return !!await this.getKey(true);
  6418. } catch (error) {
  6419. throwError(error, 'Freeanywhere.verifyTask');
  6420. return false;
  6421. }
  6422. }
  6423. async getKey(initialized) {
  6424. try {
  6425. if (!initialized && !this.initialized && !this.init()) {
  6426. return false;
  6427. }
  6428. const logStatus = scripts_echoLog({
  6429. text: i18n('gettingKey')
  6430. });
  6431. const {
  6432. result,
  6433. statusText,
  6434. status,
  6435. data
  6436. } = await tools_httpRequest({
  6437. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6438. method: 'GET',
  6439. dataType: 'json',
  6440. headers: {
  6441. authorization: `Token ${window.localStorage.getItem('token')}`
  6442. }
  6443. });
  6444. if (result === 'Success') {
  6445. var _data$response2;
  6446. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6447. logStatus.success();
  6448. scripts_echoLog({}).success(data.response.reward);
  6449. return data.response.reward;
  6450. }
  6451. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6452. return false;
  6453. }
  6454. logStatus.error(`${result}:${statusText}(${status})`);
  6455. return false;
  6456. } catch (error) {
  6457. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6458. return false;
  6459. }
  6460. }
  6461. #getGiveawayId() {
  6462. try {
  6463. var _window$location$href2;
  6464. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6465. if (giveawayId) {
  6466. this.giveawayId = giveawayId;
  6467. return true;
  6468. }
  6469. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6470. return false;
  6471. } catch (error) {
  6472. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6473. }
  6474. }
  6475. async #verify(task) {
  6476. try {
  6477. const logStatus = scripts_echoLog({
  6478. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6479. });
  6480. const {
  6481. result,
  6482. statusText,
  6483. status,
  6484. data
  6485. } = await tools_httpRequest({
  6486. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6487. method: 'GET',
  6488. dataType: 'json',
  6489. headers: {
  6490. authorization: `Token ${window.localStorage.getItem('token')}`,
  6491. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6492. }
  6493. });
  6494. if (result === 'Success') {
  6495. var _data$response3;
  6496. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6497. logStatus.success();
  6498. return true;
  6499. }
  6500. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6501. return false;
  6502. }
  6503. logStatus.error(`${result}:${statusText}(${status})`);
  6504. return false;
  6505. } catch (error) {
  6506. throwError(error, 'Freeanywhere.verify');
  6507. return false;
  6508. }
  6509. }
  6510. async #checkLeftKey() {
  6511. try {
  6512. var _data$response4;
  6513. if (!globalOptions.other.checkLeftKey) {
  6514. return true;
  6515. }
  6516. const {
  6517. data
  6518. } = await tools_httpRequest({
  6519. url: 'https://freeanywhere.net/api/v1/widget/?format=json',
  6520. method: 'GET',
  6521. dataType: 'json',
  6522. headers: {
  6523. authorization: `Token ${window.localStorage.getItem('token')}`
  6524. }
  6525. });
  6526. 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)) {
  6527. return true;
  6528. }
  6529. await external_Swal_default().fire({
  6530. icon: 'warning',
  6531. title: i18n('notice'),
  6532. text: i18n('noKeysLeft'),
  6533. confirmButtonText: i18n('confirm'),
  6534. cancelButtonText: i18n('cancel'),
  6535. showCancelButton: true
  6536. }).then(_ref => {
  6537. let {
  6538. value
  6539. } = _ref;
  6540. if (value) {
  6541. window.close();
  6542. }
  6543. });
  6544. return true;
  6545. } catch (error) {
  6546. throwError(error, 'Giveawaysu.checkLeftKey');
  6547. return false;
  6548. }
  6549. }
  6550. }
  6551. const website_FreeAnyWhere = FreeAnyWhere;
  6552. const GiveawaySu_defaultTasks = {
  6553. steam: {
  6554. groupLinks: [],
  6555. wishlistLinks: [],
  6556. curatorLinks: [],
  6557. curatorLikeLinks: [],
  6558. followLinks: [],
  6559. forumLinks: [],
  6560. announcementLinks: [],
  6561. workshopVoteLinks: [],
  6562. playtestLinks: []
  6563. },
  6564. discord: {
  6565. serverLinks: []
  6566. },
  6567. instagram: {
  6568. userLinks: []
  6569. },
  6570. vk: {
  6571. nameLinks: []
  6572. },
  6573. twitch: {
  6574. channelLinks: []
  6575. },
  6576. reddit: {
  6577. redditLinks: []
  6578. },
  6579. youtube: {
  6580. channelLinks: [],
  6581. likeLinks: []
  6582. },
  6583. twitter: {
  6584. userLinks: [],
  6585. retweetLinks: []
  6586. }
  6587. };
  6588. class GiveawaySu extends website_Website {
  6589. name = 'GiveawaySu';
  6590. socialTasks = GiveawaySu_defaultTasks;
  6591. undoneTasks = GiveawaySu_defaultTasks;
  6592. buttons = [ 'doTask', 'undoTask' ];
  6593. static test() {
  6594. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6595. }
  6596. async after() {
  6597. try {
  6598. if (!this.#checkLogin()) {
  6599. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6600. }
  6601. if (!await this.#checkLeftKey()) {
  6602. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6603. }
  6604. scripts_echoLog({}).warning(i18n('gsNotice'));
  6605. } catch (error) {
  6606. throwError(error, 'Giveawaysu.after');
  6607. }
  6608. }
  6609. init() {
  6610. try {
  6611. const logStatus = scripts_echoLog({
  6612. text: i18n('initing')
  6613. });
  6614. if ($('a.steam-login').length > 0) {
  6615. window.open('/steam/redirect', '_self');
  6616. logStatus.warning(i18n('needLogin'));
  6617. return false;
  6618. }
  6619. if (!this.#getGiveawayId()) {
  6620. return false;
  6621. }
  6622. this.initialized = true;
  6623. logStatus.success();
  6624. return true;
  6625. } catch (error) {
  6626. throwError(error, 'Giveawaysu.init');
  6627. return false;
  6628. }
  6629. }
  6630. async classifyTask(action) {
  6631. try {
  6632. const logStatus = scripts_echoLog({
  6633. text: i18n('getTasksInfo')
  6634. });
  6635. if (action === 'undo') {
  6636. var _GM_getValue;
  6637. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6638. return true;
  6639. }
  6640. const pro = [];
  6641. const tasks = $('#actions tr');
  6642. if ($('div.bind-discord').is(':visible')) {
  6643. $('div.bind-discord a')[0].click();
  6644. }
  6645. if ($('div.bind-twitch').is(':visible')) {
  6646. $('div.bind-twitch a')[0].click();
  6647. }
  6648. for (const task of tasks) {
  6649. pro.push(new Promise(resolve => {
  6650. const td = $(task).find('td:not(".hidden")');
  6651. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6652. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6653. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6654. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6655. const taskName = taskDes.text().trim();
  6656. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6657. return resolve(true);
  6658. }
  6659. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6660. if (!taskLink) {
  6661. return resolve(false);
  6662. }
  6663. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6664. this.undoneTasks.steam.groupLinks.push(taskLink);
  6665. } else if (/like.*announcement/gi.test(taskName)) {
  6666. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6667. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6668. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6669. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6670. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6671. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6672. this.undoneTasks.steam.forumLinks.push(taskLink);
  6673. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6674. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6675. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  6676. this.undoneTasks.steam.playtestLinks.push(taskLink);
  6677. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6678. this.undoneTasks.discord.serverLinks.push(taskLink);
  6679. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6680. this.undoneTasks.instagram.userLinks.push(taskLink);
  6681. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6682. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6683. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6684. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6685. } else if (/watch.*art/gim.test(taskName)) {
  6686. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6687. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6688. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6689. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6690. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6691. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6692. this.undoneTasks.vk.nameLinks.push(taskLink);
  6693. } else {
  6694. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6695. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6696. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6697. }
  6698. if (/follow.*button/gim.test(taskName)) {
  6699. this.undoneTasks.steam.followLinks.push(taskLink);
  6700. }
  6701. }
  6702. }
  6703. resolve(true);
  6704. }).catch(error => {
  6705. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6706. return false;
  6707. });
  6708. }));
  6709. }
  6710. await Promise.all(pro);
  6711. logStatus.success();
  6712. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6713. this.socialTasks = this.undoneTasks;
  6714. if (window.DEBUG) {
  6715. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  6716. }
  6717. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6718. tasks: this.socialTasks,
  6719. time: new Date().getTime()
  6720. });
  6721. return true;
  6722. } catch (error) {
  6723. throwError(error, 'Giveawaysu.classifyTask');
  6724. return false;
  6725. }
  6726. }
  6727. #checkLogin() {
  6728. try {
  6729. if (!globalOptions.other.checkLogin) {
  6730. return true;
  6731. }
  6732. if ($('a.steam-login').length > 0) {
  6733. window.open('/steam/redirect', '_self');
  6734. }
  6735. return true;
  6736. } catch (error) {
  6737. throwError(error, 'Giveawaysu.checkLogin');
  6738. return false;
  6739. }
  6740. }
  6741. async #checkLeftKey() {
  6742. try {
  6743. if (!globalOptions.other.checkLeftKey) {
  6744. return true;
  6745. }
  6746. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  6747. await external_Swal_default().fire({
  6748. icon: 'warning',
  6749. title: i18n('notice'),
  6750. text: i18n('noKeysLeft'),
  6751. confirmButtonText: i18n('confirm'),
  6752. cancelButtonText: i18n('cancel'),
  6753. showCancelButton: true
  6754. }).then(_ref => {
  6755. let {
  6756. value
  6757. } = _ref;
  6758. if (value) {
  6759. window.close();
  6760. }
  6761. });
  6762. }
  6763. return true;
  6764. } catch (error) {
  6765. throwError(error, 'Giveawaysu.checkLeftKey');
  6766. return false;
  6767. }
  6768. }
  6769. #getGiveawayId() {
  6770. var _window$location$href;
  6771. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6772. if (giveawayId) {
  6773. this.giveawayId = giveawayId;
  6774. return true;
  6775. }
  6776. scripts_echoLog({
  6777. text: i18n('getFailed', 'GiveawayId')
  6778. });
  6779. return false;
  6780. }
  6781. }
  6782. class Indiedb {
  6783. name = 'Indiedb';
  6784. buttons = [ 'doTask' ];
  6785. static test() {
  6786. return window.location.host === 'www.indiedb.com';
  6787. }
  6788. async after() {
  6789. try {
  6790. if (!this.#checkLogin()) {
  6791. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6792. }
  6793. if (!await this.#checkLeftKey()) {
  6794. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6795. }
  6796. } catch (error) {
  6797. throwError(error, 'Indiedb.after');
  6798. }
  6799. }
  6800. async doTask() {
  6801. try {
  6802. if (!await this.#join()) {
  6803. return false;
  6804. }
  6805. return await this.#do();
  6806. } catch (error) {
  6807. throwError(error, 'Indiedb.doTask');
  6808. return false;
  6809. }
  6810. }
  6811. async #join() {
  6812. try {
  6813. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  6814. scripts_echoLog({}).error(i18n('needLogin'));
  6815. return false;
  6816. }
  6817. const currentoption = $('a.buttonenter.buttongiveaway');
  6818. if (/join giveaway/gim.test(currentoption.text())) {
  6819. const logStatus = scripts_echoLog({
  6820. text: `${i18n('joiningGiveaway')}...`
  6821. });
  6822. const {
  6823. result,
  6824. statusText,
  6825. status,
  6826. data
  6827. } = await tools_httpRequest({
  6828. url: currentoption.attr('href'),
  6829. method: 'POST',
  6830. data: 'ajax=t',
  6831. dataType: 'json',
  6832. headers: {
  6833. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6834. accept: 'application/json, text/javascript, */*; q=0.01',
  6835. origin: window.location.origin
  6836. }
  6837. });
  6838. if (result === 'Success') {
  6839. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6840. var _data$response, _data$response4, _data$response5;
  6841. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  6842. var _data$response2, _data$response3;
  6843. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  6844. $('#giveawaysjoined').slideDown();
  6845. $('#giveawaysrecommend').slideDown();
  6846. 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}` : ''}`);
  6847. return true;
  6848. }
  6849. 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}` : ''}`);
  6850. return false;
  6851. }
  6852. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6853. return false;
  6854. }
  6855. logStatus.error(`${result}:${statusText}(${status})`);
  6856. return false;
  6857. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  6858. return true;
  6859. }
  6860. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  6861. return false;
  6862. } catch (error) {
  6863. throwError(error, 'Indiedb.init');
  6864. return false;
  6865. }
  6866. }
  6867. async #do() {
  6868. try {
  6869. const id = $('script').map((index, script) => {
  6870. if (/\$\(document\)/gim.test(script.innerHTML)) {
  6871. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  6872. 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] ];
  6873. }
  6874. return null;
  6875. });
  6876. if (id.length === 2) {
  6877. const pro = [];
  6878. const tasks = $('#giveawaysjoined a[class*=promo]');
  6879. for (const task of tasks) {
  6880. const promo = $(task);
  6881. if (!promo.hasClass('buttonentered')) {
  6882. const status = scripts_echoLog({
  6883. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  6884. });
  6885. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  6886. let text = '';
  6887. if (promo.hasClass('facebookpromo')) {
  6888. text = 'facebookpromo';
  6889. } else if (promo.hasClass('twitterpromo')) {
  6890. text = 'twitterpromo';
  6891. } else {
  6892. text = 'visitpromo';
  6893. }
  6894. pro.push(new Promise(resolve => {
  6895. $.ajax({
  6896. type: 'POST',
  6897. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  6898. timeout: 6e4,
  6899. dataType: 'json',
  6900. data: {
  6901. ajax: 't'
  6902. },
  6903. error(response, error, exception) {
  6904. if (window.DEBUG) {
  6905. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6906. response: response,
  6907. error: error,
  6908. exception: exception
  6909. });
  6910. }
  6911. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6912. resolve(true);
  6913. },
  6914. success(response) {
  6915. if (response.success) {
  6916. status.success(`Success:${response.text}`);
  6917. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6918. resolve(true);
  6919. } else {
  6920. status.error(`Error:${response.text}`);
  6921. resolve(true);
  6922. }
  6923. }
  6924. });
  6925. }));
  6926. } else if (promo.hasClass('emailoptinpromo')) {
  6927. pro.push(new Promise(resolve => {
  6928. $.ajax({
  6929. type: 'POST',
  6930. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  6931. timeout: 6e4,
  6932. dataType: 'json',
  6933. data: {
  6934. ajax: 't',
  6935. emailsystoggle: 4
  6936. },
  6937. error(response, error, exception) {
  6938. if (window.DEBUG) {
  6939. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6940. response: response,
  6941. error: error,
  6942. exception: exception
  6943. });
  6944. }
  6945. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6946. resolve(true);
  6947. },
  6948. success(response) {
  6949. if (response.success) {
  6950. status.success(`Success:${response.text}`);
  6951. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6952. resolve(true);
  6953. } else {
  6954. status.error(`Error:${response.text}`);
  6955. resolve(true);
  6956. }
  6957. }
  6958. });
  6959. }));
  6960. } else if (promo.hasClass('watchingpromo')) {
  6961. pro.push(new Promise(resolve => {
  6962. var _promo$attr;
  6963. const data = getUrlQuery(promo.attr('href'));
  6964. data.ajax = 't';
  6965. $.ajax({
  6966. type: 'POST',
  6967. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  6968. timeout: 6e4,
  6969. dataType: 'json',
  6970. data: data,
  6971. error(response, error, exception) {
  6972. if (window.DEBUG) {
  6973. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6974. response: response,
  6975. error: error,
  6976. exception: exception
  6977. });
  6978. }
  6979. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6980. resolve(true);
  6981. },
  6982. success(response) {
  6983. if (response.success) {
  6984. status.success(`Success:${response.text}`);
  6985. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6986. resolve(true);
  6987. } else {
  6988. status.error(`Error:${response.text}`);
  6989. resolve(true);
  6990. }
  6991. }
  6992. });
  6993. }));
  6994. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  6995. pro.push(new Promise(resolve => {
  6996. $.ajax({
  6997. type: 'POST',
  6998. url: urlPath(promo.attr('href')),
  6999. timeout: 6e4,
  7000. dataType: 'json',
  7001. data: {
  7002. ajax: 't'
  7003. },
  7004. error(response, error, exception) {
  7005. if (window.DEBUG) {
  7006. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7007. response: response,
  7008. error: error,
  7009. exception: exception
  7010. });
  7011. }
  7012. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7013. resolve(true);
  7014. },
  7015. success(response) {
  7016. if (response.success) {
  7017. status.success(`Success:${response.text}`);
  7018. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7019. resolve(true);
  7020. } else {
  7021. status.error(`Error:${response.text}`);
  7022. resolve(true);
  7023. }
  7024. }
  7025. });
  7026. }));
  7027. } else {
  7028. status.error(`Error:${i18n('unKnownTaskType')}`);
  7029. }
  7030. }
  7031. }
  7032. await Promise.all(pro);
  7033. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7034. return true;
  7035. }
  7036. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7037. return false;
  7038. } catch (error) {
  7039. throwError(error, 'Indiedb.classifyTask');
  7040. return false;
  7041. }
  7042. }
  7043. #checkLogin() {
  7044. try {
  7045. if (!globalOptions.other.checkLogin) {
  7046. return true;
  7047. }
  7048. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7049. window.open('/members/login', '_self');
  7050. }
  7051. return true;
  7052. } catch (error) {
  7053. throwError(error, 'Indiedb.checkLogin');
  7054. return false;
  7055. }
  7056. }
  7057. async #checkLeftKey() {
  7058. try {
  7059. if (!globalOptions.other.checkLeftKey) {
  7060. return true;
  7061. }
  7062. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7063. await external_Swal_default().fire({
  7064. icon: 'warning',
  7065. title: i18n('notice'),
  7066. text: i18n('giveawayEnded'),
  7067. confirmButtonText: i18n('confirm'),
  7068. cancelButtonText: i18n('cancel'),
  7069. showCancelButton: true
  7070. }).then(_ref => {
  7071. let {
  7072. value
  7073. } = _ref;
  7074. if (value) {
  7075. window.close();
  7076. }
  7077. });
  7078. }
  7079. return true;
  7080. } catch (error) {
  7081. throwError(error, 'Indiedb.checkLeftKey');
  7082. return false;
  7083. }
  7084. }
  7085. }
  7086. const website_Indiedb = Indiedb;
  7087. const Keyhub_defaultTasksTemplate = {
  7088. steam: {
  7089. groupLinks: [],
  7090. officialGroupLinks: [],
  7091. wishlistLinks: [],
  7092. curatorLinks: []
  7093. },
  7094. discord: {
  7095. serverLinks: []
  7096. },
  7097. extra: {
  7098. videoTasks: []
  7099. },
  7100. links: []
  7101. };
  7102. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7103. class Keyhub extends website_Website {
  7104. name = 'Keyhub';
  7105. socialTasks = JSON.parse(Keyhub_defaultTasks);
  7106. undoneTasks = JSON.parse(Keyhub_defaultTasks);
  7107. buttons = [ 'doTask', 'undoTask' ];
  7108. static test() {
  7109. return window.location.host === 'key-hub.eu';
  7110. }
  7111. async after() {
  7112. try {
  7113. if (!this.#checkLogin()) {
  7114. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7115. }
  7116. if (!await this.#checkLeftKey()) {
  7117. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7118. }
  7119. $('.NSFW').hide();
  7120. } catch (error) {
  7121. throwError(error, 'Keyhub.after');
  7122. }
  7123. }
  7124. init() {
  7125. try {
  7126. const logStatus = scripts_echoLog({
  7127. text: i18n('initing')
  7128. });
  7129. if ($('a[href*="/connect/steam"]').length > 0) {
  7130. window.open('/connect/steam', '_self');
  7131. logStatus.warning(i18n('needLogin'));
  7132. return false;
  7133. }
  7134. if (!this.#getGiveawayId()) {
  7135. return false;
  7136. }
  7137. $('#VPNoverlay').hide();
  7138. $('#mainArticleSection').show();
  7139. this.initialized = true;
  7140. logStatus.success();
  7141. return true;
  7142. } catch (error) {
  7143. throwError(error, 'Keyhub.init');
  7144. return false;
  7145. }
  7146. }
  7147. async classifyTask(action) {
  7148. try {
  7149. const logStatus = scripts_echoLog({
  7150. text: i18n('getTasksInfo')
  7151. });
  7152. if (action === 'undo') {
  7153. var _GM_getValue;
  7154. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7155. }
  7156. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7157. for (const task of tasks) {
  7158. let link = $(task).attr('href');
  7159. const taskDes = $(task).text().trim();
  7160. if (!link) {
  7161. continue;
  7162. }
  7163. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7164. link = await getRedirectLink(link) || link;
  7165. }
  7166. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7167. window.open(link, '_blank');
  7168. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7169. if (action === 'undo') {
  7170. this.socialTasks.steam.groupLinks.push(link);
  7171. }
  7172. if (action === 'do') {
  7173. this.undoneTasks.steam.groupLinks.push(link);
  7174. }
  7175. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7176. if (action === 'undo') {
  7177. this.socialTasks.steam.officialGroupLinks.push(link);
  7178. }
  7179. if (action === 'do') {
  7180. this.undoneTasks.steam.officialGroupLinks.push(link);
  7181. }
  7182. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7183. if (action === 'undo') {
  7184. this.socialTasks.steam.wishlistLinks.push(link);
  7185. }
  7186. if (action === 'do') {
  7187. this.undoneTasks.steam.wishlistLinks.push(link);
  7188. }
  7189. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7190. if (action === 'undo') {
  7191. this.socialTasks.steam.curatorLinks.push(link);
  7192. }
  7193. if (action === 'do') {
  7194. this.undoneTasks.steam.curatorLinks.push(link);
  7195. }
  7196. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7197. if (action === 'undo') {
  7198. this.socialTasks.discord.serverLinks.push(link);
  7199. }
  7200. if (action === 'do') {
  7201. this.undoneTasks.discord.serverLinks.push(link);
  7202. }
  7203. } else if (/^javascript:videoTask.+/.test(link)) {
  7204. if (action === 'do') {
  7205. var _link$match;
  7206. const taskData = (_link$match = link.match(/javascript:videoTask\('.+?','(.+?)'/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  7207. if (taskData) {
  7208. this.undoneTasks.extra.videoTasks.push(taskData);
  7209. }
  7210. }
  7211. } 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 {
  7212. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7213. }
  7214. }
  7215. logStatus.success();
  7216. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7217. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7218. if (window.DEBUG) {
  7219. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7220. }
  7221. GM_setValue(`khTasks-${this.giveawayId}`, {
  7222. tasks: this.socialTasks,
  7223. time: new Date().getTime()
  7224. });
  7225. return true;
  7226. } catch (error) {
  7227. throwError(error, 'Keyhub.classifyTask');
  7228. return false;
  7229. }
  7230. }
  7231. async #doScriptTask(data) {
  7232. try {
  7233. const logStatus = scripts_echoLog({
  7234. text: i18n('doingKeyhubTask')
  7235. });
  7236. const {
  7237. result,
  7238. statusText,
  7239. status,
  7240. data: response
  7241. } = await tools_httpRequest({
  7242. url: `/away?data=${data}`,
  7243. method: 'GET',
  7244. headers: {
  7245. origin: 'https://key-hub.eu',
  7246. referer: 'https://key-hub.eu/'
  7247. }
  7248. });
  7249. if (result === 'Success') {
  7250. if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
  7251. logStatus.success();
  7252. return true;
  7253. }
  7254. logStatus.error(`Error:${response === null || response === void 0 ? void 0 : response.statusText}(${response === null || response === void 0 ? void 0 : response.status})`);
  7255. return false;
  7256. }
  7257. logStatus.error(`${result}:${statusText}(${status})`);
  7258. return false;
  7259. } catch (error) {
  7260. throwError(error, 'Keyhub.doScriptTask');
  7261. return false;
  7262. }
  7263. }
  7264. async extraDoTask(_ref) {
  7265. let {
  7266. videoTasks
  7267. } = _ref;
  7268. try {
  7269. const pro = [];
  7270. for (const data of videoTasks) {
  7271. pro.push(this.#doScriptTask(data));
  7272. }
  7273. return Promise.all(pro).then(() => true);
  7274. } catch (error) {
  7275. throwError(error, 'Keyhub.extraDoTask');
  7276. return false;
  7277. }
  7278. }
  7279. #getGiveawayId() {
  7280. try {
  7281. var _window$location$href;
  7282. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7283. if (giveawayId) {
  7284. this.giveawayId = giveawayId;
  7285. return true;
  7286. }
  7287. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7288. return false;
  7289. } catch (error) {
  7290. throwError(error, 'Keyhub.getGiveawayId');
  7291. return false;
  7292. }
  7293. }
  7294. async #checkLeftKey() {
  7295. try {
  7296. if (!globalOptions.other.checkLeftKey) {
  7297. return true;
  7298. }
  7299. const leftKey = $('#keysleft').text().trim();
  7300. if (leftKey === '0') {
  7301. await external_Swal_default().fire({
  7302. icon: 'warning',
  7303. title: i18n('notice'),
  7304. text: i18n('noKeysLeft'),
  7305. confirmButtonText: i18n('confirm'),
  7306. cancelButtonText: i18n('cancel'),
  7307. showCancelButton: true
  7308. }).then(_ref2 => {
  7309. let {
  7310. value
  7311. } = _ref2;
  7312. if (value) {
  7313. window.close();
  7314. }
  7315. });
  7316. }
  7317. return true;
  7318. } catch (error) {
  7319. throwError(error, 'Keyhub.checkLeftKey');
  7320. return false;
  7321. }
  7322. }
  7323. #checkLogin() {
  7324. try {
  7325. if (!globalOptions.other.checkLogin) {
  7326. return true;
  7327. }
  7328. if ($('a[href*="/connect/steam"]').length > 0) {
  7329. window.open('/connect/steam', '_self');
  7330. }
  7331. return true;
  7332. } catch (error) {
  7333. throwError(error, 'Keyhub.checkLogin');
  7334. return false;
  7335. }
  7336. }
  7337. }
  7338. const website_Keyhub = Keyhub;
  7339. const Givekey_defaultTasksTemplate = {
  7340. steam: {
  7341. groupLinks: [],
  7342. wishlistLinks: [],
  7343. curatorLinks: [],
  7344. curatorLikeLinks: []
  7345. },
  7346. twitter: {
  7347. userLinks: []
  7348. },
  7349. vk: {
  7350. nameLinks: []
  7351. },
  7352. discord: {
  7353. serverLinks: []
  7354. }
  7355. };
  7356. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  7357. class Givekey extends website_Website {
  7358. name = 'Givekey';
  7359. tasks = [];
  7360. socialTasks = JSON.parse(Givekey_defaultTasks);
  7361. undoneTasks = JSON.parse(Givekey_defaultTasks);
  7362. userId;
  7363. buttons = [ 'doTask', 'undoTask', 'verifyTask' ];
  7364. static test() {
  7365. return window.location.host === 'givekey.ru';
  7366. }
  7367. async after() {
  7368. try {
  7369. await new Promise(resolve => {
  7370. const checker = setInterval(() => {
  7371. if ($('#navbarDropdown').length > 0) {
  7372. clearInterval(checker);
  7373. resolve(true);
  7374. }
  7375. });
  7376. });
  7377. if (!await this.#checkLeftKey()) {
  7378. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7379. }
  7380. } catch (error) {
  7381. throwError(error, 'Givekey.after');
  7382. return false;
  7383. }
  7384. }
  7385. init() {
  7386. try {
  7387. const logStatus = scripts_echoLog({
  7388. text: i18n('initing')
  7389. });
  7390. if ($('a[href*="/auth/steam"]').length > 0) {
  7391. window.open('/auth/steam', '_self');
  7392. logStatus.warning(i18n('needLogin'));
  7393. return false;
  7394. }
  7395. if (!this.#getGiveawayId()) {
  7396. return false;
  7397. }
  7398. const userId = $('meta[name="user-id"]').attr('content');
  7399. if (!userId) {
  7400. logStatus.error(i18n('getFailed', i18n('userId')));
  7401. return false;
  7402. }
  7403. this.userId = userId;
  7404. this.initialized = true;
  7405. logStatus.success();
  7406. return true;
  7407. } catch (error) {
  7408. throwError(error, 'Givekey.init');
  7409. return false;
  7410. }
  7411. }
  7412. async classifyTask(action) {
  7413. try {
  7414. const logStatus = scripts_echoLog({
  7415. text: i18n('getTasksInfo')
  7416. });
  7417. if (action === 'undo') {
  7418. var _GM_getValue;
  7419. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  7420. }
  7421. const tasks = $('.card-body:has("button") .row');
  7422. for (const task of tasks) {
  7423. const taskEle = $(task);
  7424. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7425. if (isSuccess && action !== 'undo') {
  7426. continue;
  7427. }
  7428. const checkButton = taskEle.find('#task_check');
  7429. const taskId = checkButton.attr('data-id');
  7430. if (taskId) {
  7431. this.tasks.push(taskId);
  7432. }
  7433. if (action === 'verify') {
  7434. continue;
  7435. }
  7436. let href = taskEle.find('a').attr('href') || null;
  7437. const text = taskEle.find('a').text().trim();
  7438. const icon = taskEle.find('i');
  7439. if (!href || !text) {
  7440. continue;
  7441. }
  7442. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7443. href = await getRedirectLink(href);
  7444. }
  7445. if (!href) {
  7446. continue;
  7447. }
  7448. if (/^https?:\/\/vk\.com\//.test(href)) {
  7449. this.socialTasks.vk.nameLinks.push(href);
  7450. if (action === 'do' && !isSuccess) {
  7451. this.undoneTasks.vk.nameLinks.push(href);
  7452. }
  7453. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7454. this.socialTasks.steam.groupLinks.push(href);
  7455. if (action === 'do' && !isSuccess) {
  7456. this.undoneTasks.steam.groupLinks.push(href);
  7457. }
  7458. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7459. this.socialTasks.steam.wishlistLinks.push(href);
  7460. if (action === 'do' && !isSuccess) {
  7461. this.undoneTasks.steam.wishlistLinks.push(href);
  7462. }
  7463. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7464. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7465. this.socialTasks.steam.curatorLinks.push(href);
  7466. if (action === 'do' && !isSuccess) {
  7467. this.undoneTasks.steam.curatorLinks.push(href);
  7468. }
  7469. } else {
  7470. this.socialTasks.steam.curatorLikeLinks.push(href);
  7471. if (action === 'do' && !isSuccess) {
  7472. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7473. }
  7474. }
  7475. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7476. this.socialTasks.twitter.userLinks.push(href);
  7477. if (action === 'do' && !isSuccess) {
  7478. this.undoneTasks.twitter.userLinks.push(href);
  7479. }
  7480. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  7481. this.socialTasks.discord.serverLinks.push(href);
  7482. if (action === 'do' && !isSuccess) {
  7483. this.undoneTasks.discord.serverLinks.push(href);
  7484. }
  7485. } else {
  7486. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7487. }
  7488. }
  7489. logStatus.success();
  7490. this.tasks = unique(this.tasks);
  7491. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7492. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7493. if (window.DEBUG) {
  7494. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7495. }
  7496. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7497. tasks: this.socialTasks,
  7498. time: new Date().getTime()
  7499. });
  7500. return true;
  7501. } catch (error) {
  7502. throwError(error, 'Givekey.classifyTask');
  7503. return false;
  7504. }
  7505. }
  7506. async verifyTask() {
  7507. try {
  7508. if (!this.initialized && !this.init()) {
  7509. return false;
  7510. }
  7511. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7512. return false;
  7513. }
  7514. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7515. const taskLength = this.tasks.length;
  7516. for (let i = 0; i < taskLength; i++) {
  7517. await this.#verify(this.tasks[i]);
  7518. if (i < taskLength - 1) {
  7519. await delay(15e3);
  7520. }
  7521. }
  7522. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7523. scripts_echoLog({
  7524. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7525. });
  7526. return true;
  7527. } catch (error) {
  7528. throwError(error, 'Givekey.verifyTask');
  7529. return false;
  7530. }
  7531. }
  7532. async #verify(task) {
  7533. try {
  7534. const logStatus = scripts_echoLog({
  7535. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7536. });
  7537. return await new Promise(resolve => {
  7538. $.ajax({
  7539. url: 'https://givekey.ru/giveaway/task',
  7540. method: 'POST',
  7541. data: `id=${task}&user_id=${this.userId}`,
  7542. dataType: 'json',
  7543. headers: {
  7544. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7545. },
  7546. success: data => {
  7547. if (data.btn) {
  7548. $(`button[data-id=${this.userId}]`).html(data.btn);
  7549. }
  7550. if (data.status === 'ok') {
  7551. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7552. logStatus.success();
  7553. resolve(true);
  7554. } else if (data.status === 'end') {
  7555. logStatus.success();
  7556. scripts_echoLog({}).success(data.key);
  7557. resolve(true);
  7558. } else {
  7559. logStatus.error(`Error:${data.msg}`);
  7560. resolve(false);
  7561. }
  7562. },
  7563. error: xhr => {
  7564. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7565. resolve(false);
  7566. }
  7567. });
  7568. });
  7569. } catch (error) {
  7570. throwError(error, 'Givekey.verify');
  7571. return false;
  7572. }
  7573. }
  7574. #getGiveawayId() {
  7575. try {
  7576. var _window$location$href;
  7577. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7578. if (giveawayId) {
  7579. this.giveawayId = giveawayId;
  7580. return true;
  7581. }
  7582. scripts_echoLog({
  7583. text: i18n('getFailed', 'GiveawayId')
  7584. });
  7585. return false;
  7586. } catch (error) {
  7587. throwError(error, 'Givekey.getGiveawayId');
  7588. return false;
  7589. }
  7590. }
  7591. async #checkLeftKey() {
  7592. try {
  7593. if (!globalOptions.other.checkLeftKey) {
  7594. return true;
  7595. }
  7596. if (!$('#keys_count').text()) {
  7597. await external_Swal_default().fire({
  7598. icon: 'warning',
  7599. title: i18n('notice'),
  7600. text: i18n('noKeysLeft'),
  7601. confirmButtonText: i18n('confirm'),
  7602. cancelButtonText: i18n('cancel'),
  7603. showCancelButton: true
  7604. }).then(_ref => {
  7605. let {
  7606. value
  7607. } = _ref;
  7608. if (value) {
  7609. window.close();
  7610. }
  7611. });
  7612. }
  7613. return true;
  7614. } catch (error) {
  7615. throwError(error, 'Givekey.checkLeftKey');
  7616. return false;
  7617. }
  7618. }
  7619. }
  7620. const website_Givekey = Givekey;
  7621. class GiveeClub extends GiveawaySu {
  7622. name = 'GiveeClub';
  7623. buttons = [ 'doTask', 'undoTask', 'verifyTask' ];
  7624. static test() {
  7625. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7626. }
  7627. async after() {
  7628. try {
  7629. if (!this.#checkLogin()) {
  7630. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7631. }
  7632. if (!await this.#checkLeftKey()) {
  7633. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7634. }
  7635. } catch (error) {
  7636. throwError(error, 'GiveeClub.after');
  7637. }
  7638. }
  7639. init() {
  7640. try {
  7641. const logStatus = scripts_echoLog({
  7642. text: i18n('initing')
  7643. });
  7644. if (!this.#checkLogin()) {
  7645. logStatus.warning(i18n('needLogin'));
  7646. return false;
  7647. }
  7648. if (!this.#getGiveawayId()) {
  7649. return false;
  7650. }
  7651. this.initialized = true;
  7652. logStatus.success();
  7653. return true;
  7654. } catch (error) {
  7655. throwError(error, 'GiveeClub.init');
  7656. return false;
  7657. }
  7658. }
  7659. async classifyTask(action) {
  7660. try {
  7661. const logStatus = scripts_echoLog({
  7662. text: i18n('getTasksInfo')
  7663. });
  7664. if (action === 'undo') {
  7665. var _GM_getValue;
  7666. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7667. return true;
  7668. }
  7669. const pro = [];
  7670. const tasks = $('.event-actions tr');
  7671. for (const task of tasks) {
  7672. pro.push(new Promise(resolve => {
  7673. var _$$find, _$$find2;
  7674. const taskDes = $(task).find('.event-action-label a');
  7675. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7676. const taskName = taskDes.text().trim();
  7677. const taskType = (_$$find = $(task).find('button[data-type]')) === null || _$$find === void 0 ? void 0 : _$$find.attr('data-type');
  7678. const taskFinished = (_$$find2 = $(task).find('.event-action-buttons .btn-success')) === null || _$$find2 === void 0 ? void 0 : _$$find2.length;
  7679. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope') || taskFinished) {
  7680. return resolve(true);
  7681. }
  7682. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7683. if (!taskLink) {
  7684. return resolve(false);
  7685. }
  7686. if (taskType === 'steam.group.join' && /^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7687. this.undoneTasks.steam.groupLinks.push(taskLink);
  7688. } else if (/like.*announcement/gi.test(taskName)) {
  7689. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7690. } else if (taskType === 'steam.game.wishlist' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7691. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7692. } else if (taskType === 'steam.game.wishlist' && taskDes.attr('data-steam-wishlist-appid')) {
  7693. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  7694. } else if (taskType === 'steam.game.follow' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7695. this.undoneTasks.steam.followLinks.push(taskLink);
  7696. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7697. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7698. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7699. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7700. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7701. this.undoneTasks.steam.forumLinks.push(taskLink);
  7702. } else if (taskIcon.includes('discord')) {
  7703. this.undoneTasks.discord.serverLinks.push(taskLink);
  7704. } else if (taskIcon.includes('instagram')) {
  7705. this.undoneTasks.instagram.userLinks.push(taskLink);
  7706. } else if (taskIcon.includes('twitch')) {
  7707. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7708. } else if (taskIcon.includes('reddit')) {
  7709. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7710. } else if (/watch.*art/gim.test(taskName)) {
  7711. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7712. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7713. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7714. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7715. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7716. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7717. this.undoneTasks.vk.nameLinks.push(taskLink);
  7718. } else if (taskIcon.includes('twitter')) {
  7719. if (/https?:\/\/twitter\.com\/[^/]+\/?$/gim.test(taskLink)) {
  7720. this.undoneTasks.twitter.userLinks.push(taskLink);
  7721. } else if (/https?:\/\/twitter\.com\/[^/]+?\/status\/[\d]+/gim.test(taskLink)) {
  7722. this.undoneTasks.twitter.retweetLinks.push(taskLink);
  7723. }
  7724. } else {
  7725. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7726. if (/follow.*button/gim.test(taskName)) {
  7727. this.undoneTasks.steam.followLinks.push(taskLink);
  7728. }
  7729. }
  7730. }
  7731. resolve(true);
  7732. }).catch(error => {
  7733. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7734. return false;
  7735. });
  7736. }));
  7737. }
  7738. await Promise.all(pro);
  7739. logStatus.success();
  7740. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7741. this.socialTasks = this.undoneTasks;
  7742. if (window.DEBUG) {
  7743. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7744. }
  7745. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7746. tasks: this.socialTasks,
  7747. time: new Date().getTime()
  7748. });
  7749. return true;
  7750. } catch (error) {
  7751. throwError(error, 'GiveeClub.classifyTask');
  7752. return false;
  7753. }
  7754. }
  7755. async verifyTask() {
  7756. try {
  7757. const logStatus = scripts_echoLog({
  7758. text: i18n('giveeClubVerifyNotice')
  7759. });
  7760. const taskButtons = $('.event-actions tr button').has('i.glyphicon-refresh').not('[data-type="user.adblock"]');
  7761. for (const button of taskButtons) {
  7762. button.click();
  7763. if ($(button).attr('data-type') !== 'steam.game.wishlist') {
  7764. await delay(1e3);
  7765. }
  7766. }
  7767. logStatus.warning(i18n('giveeClubVerifyFinished'));
  7768. return true;
  7769. } catch (error) {
  7770. throwError(error, 'Givekey.verifyTask');
  7771. return false;
  7772. }
  7773. }
  7774. #checkLogin() {
  7775. try {
  7776. if (!globalOptions.other.checkLogin) {
  7777. return true;
  7778. }
  7779. if ($('a[href*="/account/auth"]').length > 0) {
  7780. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  7781. }
  7782. return true;
  7783. } catch (error) {
  7784. throwError(error, 'GiveeClub.checkLogin');
  7785. return false;
  7786. }
  7787. }
  7788. #getGiveawayId() {
  7789. var _window$location$href;
  7790. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7791. if (giveawayId) {
  7792. this.giveawayId = giveawayId;
  7793. return true;
  7794. }
  7795. scripts_echoLog({
  7796. text: i18n('getFailed', 'GiveawayId')
  7797. });
  7798. return false;
  7799. }
  7800. async #checkLeftKey() {
  7801. try {
  7802. if (!globalOptions.other.checkLeftKey) {
  7803. return true;
  7804. }
  7805. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  7806. await external_Swal_default().fire({
  7807. icon: 'warning',
  7808. title: i18n('notice'),
  7809. text: i18n('giveawayEnded'),
  7810. confirmButtonText: i18n('confirm'),
  7811. cancelButtonText: i18n('cancel'),
  7812. showCancelButton: true
  7813. }).then(_ref => {
  7814. let {
  7815. value
  7816. } = _ref;
  7817. if (value) {
  7818. window.close();
  7819. }
  7820. });
  7821. }
  7822. return true;
  7823. } catch (error) {
  7824. throwError(error, 'Giveawaysu.checkLeftKey');
  7825. return false;
  7826. }
  7827. }
  7828. }
  7829. const website_GiveeClub = GiveeClub;
  7830. const defaultOptions = {
  7831. maxPoint: '99999999'
  7832. };
  7833. class OpiumPulses {
  7834. name = 'OpiumPulses';
  7835. options = {
  7836. ...defaultOptions,
  7837. ...GM_getValue('OpiumPulsesOptions')
  7838. };
  7839. maxPoints = 99999999;
  7840. myPoints = 0;
  7841. buttons = [ 'doFreeTask', 'doPointTask' ];
  7842. static test() {
  7843. return window.location.host === 'www.opiumpulses.com';
  7844. }
  7845. async after() {
  7846. try {
  7847. if (!this.#checkLogin()) {
  7848. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7849. }
  7850. this.maxPoints = parseInt(this.options.maxPoint, 10);
  7851. } catch (error) {
  7852. throwError(error, 'OpiumPulses.after');
  7853. }
  7854. }
  7855. async doFreeTask() {
  7856. try {
  7857. this.#toggleTask('FREE');
  7858. } catch (error) {
  7859. throwError(error, 'OpiumPulses.doFreeTask');
  7860. }
  7861. }
  7862. async doPointTask() {
  7863. try {
  7864. var _$$text$match;
  7865. 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);
  7866. this.#toggleTask('points');
  7867. } catch (error) {
  7868. throwError(error, 'OpiumPulses.doPointTask');
  7869. }
  7870. }
  7871. async #toggleTask(type) {
  7872. try {
  7873. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  7874. for (const item of items) {
  7875. var _$$find$text$match;
  7876. 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);
  7877. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  7878. if (type === 'points' && needPoints > this.myPoints) {
  7879. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  7880. } else if (type === 'points' && !needPoints) {
  7881. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  7882. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  7883. var _aElement$attr;
  7884. const logStatus = scripts_echoLog({
  7885. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  7886. });
  7887. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  7888. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  7889. var _aElement$attr2, _aElement$attr2$match;
  7890. 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];
  7891. if (giveawayId) {
  7892. checkUser(giveawayId);
  7893. }
  7894. }
  7895. if (!aElement.attr('href')) {
  7896. logStatus.error('Error: No "href".');
  7897. continue;
  7898. }
  7899. const {
  7900. result,
  7901. statusText,
  7902. status,
  7903. data
  7904. } = await tools_httpRequest({
  7905. url: aElement.attr('href'),
  7906. method: 'GET'
  7907. });
  7908. if (result === 'Success') {
  7909. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  7910. var _data$responseText$ma;
  7911. logStatus.success();
  7912. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  7913. if (type === 'points' && points) {
  7914. this.myPoints = parseInt(points, 10);
  7915. }
  7916. } else {
  7917. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7918. }
  7919. } else {
  7920. logStatus.error(`${result}:${statusText}(${status})`);
  7921. }
  7922. }
  7923. }
  7924. scripts_echoLog({
  7925. text: '-----END-----'
  7926. });
  7927. } catch (error) {
  7928. throwError(error, 'OpiumPulses.toggleTask');
  7929. }
  7930. }
  7931. init() {
  7932. return true;
  7933. }
  7934. classifyTask() {
  7935. return true;
  7936. }
  7937. #checkLogin() {
  7938. try {
  7939. if (!globalOptions.other.checkLogin) {
  7940. return true;
  7941. }
  7942. if ($('a[href*="/site/login"]').length > 1) {
  7943. window.open('/site/login', '_self');
  7944. }
  7945. return true;
  7946. } catch (error) {
  7947. throwError(error, 'OpiumPulses.checkLogin');
  7948. return false;
  7949. }
  7950. }
  7951. }
  7952. const website_OpiumPulses = OpiumPulses;
  7953. const external_dayjs_namespaceObject = dayjs;
  7954. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  7955. const leftKeyChecker = {
  7956. async classify(link) {
  7957. try {
  7958. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  7959. return await this.giveawaySu(link);
  7960. }
  7961. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  7962. return await this.giveeClub(link);
  7963. }
  7964. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  7965. return await this.gleam(link);
  7966. }
  7967. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  7968. return await this.indieDb(link);
  7969. }
  7970. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  7971. return await this.keyhub(link);
  7972. }
  7973. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  7974. return await this.opquests(link);
  7975. }
  7976. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  7977. return await this.itch(link);
  7978. }
  7979. return false;
  7980. } catch (error) {
  7981. throwError(error, 'leftKeyChecker.classify');
  7982. return false;
  7983. }
  7984. },
  7985. async giveawaySu(link) {
  7986. try {
  7987. const {
  7988. result,
  7989. data
  7990. } = await tools_httpRequest({
  7991. url: link,
  7992. method: 'GET'
  7993. });
  7994. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  7995. if (data.responseText.includes('class="steam-login"')) {
  7996. return false;
  7997. }
  7998. if (data.responseText.includes('class="giveaway-ended"')) {
  7999. return 'Ended';
  8000. }
  8001. return 'Active';
  8002. }
  8003. return false;
  8004. } catch (error) {
  8005. throwError(error, 'leftKeyChecker.giveawaySu');
  8006. return false;
  8007. }
  8008. },
  8009. async giveeClub(link) {
  8010. try {
  8011. const {
  8012. result,
  8013. data
  8014. } = await tools_httpRequest({
  8015. url: link,
  8016. method: 'GET'
  8017. });
  8018. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8019. if (data.responseText.includes('class="event-winner"')) {
  8020. return 'Won';
  8021. }
  8022. if (data.responseText.includes('class="event-ended"')) {
  8023. return 'Ended';
  8024. }
  8025. return 'Active';
  8026. }
  8027. return false;
  8028. } catch (error) {
  8029. throwError(error, 'leftKeyChecker.giveeClub');
  8030. return false;
  8031. }
  8032. },
  8033. async gleam(link) {
  8034. try {
  8035. const {
  8036. result,
  8037. data
  8038. } = await tools_httpRequest({
  8039. url: link,
  8040. method: 'GET'
  8041. });
  8042. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8043. var _data$responseText$ma, _$$attr, _$$attr$match;
  8044. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8045. return 'Won';
  8046. }
  8047. 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];
  8048. if (!campaignDiv) {
  8049. return false;
  8050. }
  8051. 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];
  8052. if (!campaignString) {
  8053. return false;
  8054. }
  8055. const {
  8056. campaign
  8057. } = JSON.parse(campaignString);
  8058. if (campaign.banned) {
  8059. return 'Banned';
  8060. }
  8061. if (campaign.finished) {
  8062. return 'Ended';
  8063. }
  8064. if (campaign.paused) {
  8065. return 'Paused';
  8066. }
  8067. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8068. return 'NotStart';
  8069. }
  8070. return 'Active';
  8071. }
  8072. return false;
  8073. } catch (error) {
  8074. throwError(error, 'leftKeyChecker.gleam');
  8075. return false;
  8076. }
  8077. },
  8078. async indieDb(link) {
  8079. try {
  8080. const {
  8081. result,
  8082. data
  8083. } = await tools_httpRequest({
  8084. url: link,
  8085. method: 'GET'
  8086. });
  8087. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8088. if (data.responseText.includes('Congrats you WON')) {
  8089. return 'Won';
  8090. }
  8091. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8092. return 'Ended';
  8093. }
  8094. return 'Active';
  8095. }
  8096. return false;
  8097. } catch (error) {
  8098. throwError(error, 'leftKeyChecker.indieDb');
  8099. return false;
  8100. }
  8101. },
  8102. async keyhub(link) {
  8103. try {
  8104. const {
  8105. result,
  8106. data
  8107. } = await tools_httpRequest({
  8108. url: link,
  8109. method: 'GET'
  8110. });
  8111. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8112. var _data$responseText$ma2;
  8113. 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];
  8114. if (!keysleft) {
  8115. return false;
  8116. }
  8117. if (keysleft === '0') {
  8118. return 'Ended';
  8119. }
  8120. return `Active(${keysleft})`;
  8121. }
  8122. return false;
  8123. } catch (error) {
  8124. throwError(error, 'leftKeyChecker.keyhub');
  8125. return false;
  8126. }
  8127. },
  8128. async opquests(link) {
  8129. try {
  8130. const {
  8131. result,
  8132. data
  8133. } = await tools_httpRequest({
  8134. url: link,
  8135. method: 'GET'
  8136. });
  8137. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8138. var _data$responseText$ma3;
  8139. 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];
  8140. if (!keysleft) {
  8141. return false;
  8142. }
  8143. if (keysleft === '0') {
  8144. return 'Ended';
  8145. }
  8146. return `Active(${keysleft})`;
  8147. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8148. return 'Ended';
  8149. }
  8150. return false;
  8151. } catch (error) {
  8152. throwError(error, 'leftKeyChecker.opquests');
  8153. return false;
  8154. }
  8155. },
  8156. async itch(link) {
  8157. try {
  8158. const {
  8159. result,
  8160. data
  8161. } = await tools_httpRequest({
  8162. url: link,
  8163. method: 'GET'
  8164. });
  8165. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8166. var _data$responseText$ma4;
  8167. 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];
  8168. if (!endDate) {
  8169. return false;
  8170. }
  8171. if (new Date().getTime() > new Date(endDate).getTime()) {
  8172. return 'Ended';
  8173. }
  8174. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8175. }
  8176. return false;
  8177. } catch (error) {
  8178. throwError(error, 'leftKeyChecker.opquests');
  8179. return false;
  8180. }
  8181. }
  8182. };
  8183. const website_leftKeyChecker = leftKeyChecker;
  8184. const Keylol_defaultTasksTemplate = {
  8185. steam: {
  8186. groupLinks: [],
  8187. wishlistLinks: [],
  8188. curatorLinks: [],
  8189. curatorLikeLinks: [],
  8190. followLinks: [],
  8191. forumLinks: [],
  8192. announcementLinks: [],
  8193. workshopVoteLinks: [],
  8194. licenseLinks: []
  8195. },
  8196. discord: {
  8197. serverLinks: []
  8198. },
  8199. instagram: {
  8200. userLinks: []
  8201. },
  8202. vk: {
  8203. nameLinks: []
  8204. },
  8205. twitch: {
  8206. channelLinks: []
  8207. },
  8208. reddit: {
  8209. redditLinks: []
  8210. },
  8211. twitter: {
  8212. userLinks: [],
  8213. retweetLinks: []
  8214. },
  8215. youtube: {
  8216. channelLinks: [],
  8217. likeLinks: []
  8218. }
  8219. };
  8220. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  8221. class Keylol extends website_Website {
  8222. name = 'Keylol';
  8223. socialTasks = JSON.parse(Keylol_defaultTasks);
  8224. undoneTasks = JSON.parse(Keylol_defaultTasks);
  8225. buttons = [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ];
  8226. static test() {
  8227. var _$$eq$attr, _$$eq$attr2;
  8228. 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')));
  8229. }
  8230. init() {
  8231. return true;
  8232. }
  8233. after() {
  8234. try {
  8235. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8236. const mainPost = $(selector);
  8237. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  8238. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  8239. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  8240. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  8241. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  8242. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  8243. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  8244. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  8245. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  8246. if (discordLinks.length > 0) {
  8247. for (const discordLink of discordLinks) {
  8248. const link = $(discordLink).attr('href');
  8249. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8250. continue;
  8251. }
  8252. this.#addBtn(discordLink, 'discord', 'serverLinks', link);
  8253. }
  8254. }
  8255. if (redditLinks.length > 0) {
  8256. for (const redditLink of redditLinks) {
  8257. const link = $(redditLink).attr('href');
  8258. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8259. continue;
  8260. }
  8261. this.#addBtn(redditLink, 'reddit', 'redditLinks', link);
  8262. }
  8263. }
  8264. if (insLinks.length > 0) {
  8265. for (const insLink of insLinks) {
  8266. const link = $(insLink).attr('href');
  8267. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8268. continue;
  8269. }
  8270. this.#addBtn(insLink, 'instagram', 'userLinks', link);
  8271. }
  8272. }
  8273. if (twitterLinks.length > 0) {
  8274. for (const twitterLink of twitterLinks) {
  8275. const link = $(twitterLink).attr('href');
  8276. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8277. continue;
  8278. }
  8279. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8280. this.#addBtn(twitterLink, 'twitter', 'retweetLinks', link);
  8281. } else {
  8282. this.#addBtn(twitterLink, 'twitter', 'userLinks', link);
  8283. }
  8284. }
  8285. }
  8286. if (twitchLinks.length > 0) {
  8287. for (const twitchLink of twitchLinks) {
  8288. const link = $(twitchLink).attr('href');
  8289. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8290. continue;
  8291. }
  8292. this.#addBtn(twitchLink, 'twitch', 'channelLinks', link);
  8293. }
  8294. }
  8295. if (vkLinks.length > 0) {
  8296. for (const vkLink of vkLinks) {
  8297. const link = $(vkLink).attr('href');
  8298. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8299. continue;
  8300. }
  8301. this.#addBtn(vkLink, 'vk', 'nameLinks', link);
  8302. }
  8303. }
  8304. if (steamStoreLinks.length > 0) {
  8305. for (const steamStoreLink of steamStoreLinks) {
  8306. const link = $(steamStoreLink).attr('href');
  8307. if (!link) {
  8308. continue;
  8309. }
  8310. if (/curator\/[\d]+/.test(link)) {
  8311. this.#addBtn(steamStoreLink, 'steam', 'curatorLinks', link);
  8312. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8313. this.#addBtn(steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8314. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8315. this.#addBtn(steamStoreLink, 'steam', 'announcementLinks', link);
  8316. } else if (/app\/[\d]+/.test(link)) {
  8317. this.#addBtn(steamStoreLink, 'steam', 'followLinks', link);
  8318. this.#addBtn(steamStoreLink, 'steam', 'wishlistLinks', link);
  8319. }
  8320. }
  8321. }
  8322. if (steamCommunityLinks.length > 0) {
  8323. for (const steamCommunityLink of steamCommunityLinks) {
  8324. const link = $(steamCommunityLink).attr('href');
  8325. if (!link) {
  8326. continue;
  8327. }
  8328. if (/groups\/.+/.test(link)) {
  8329. this.#addBtn(steamCommunityLink, 'steam', 'groupLinks', link);
  8330. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8331. this.#addBtn(steamCommunityLink, 'steam', 'announcementLinks', link);
  8332. }
  8333. }
  8334. }
  8335. if (ytbLinks.length > 0) {
  8336. for (const ytbLink of ytbLinks) {
  8337. const link = $(ytbLink).attr('href');
  8338. if (!link) {
  8339. continue;
  8340. }
  8341. this.#addBtn(ytbLink, 'youtube', 'channelLinks', link);
  8342. this.#addBtn(ytbLink, 'youtube', 'likeLinks', link);
  8343. }
  8344. }
  8345. 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');
  8346. if (giveawayLinks.length > 0) {
  8347. for (const giveawayLink of giveawayLinks) {
  8348. const link = $(giveawayLink).attr('href');
  8349. if (!link) {
  8350. continue;
  8351. }
  8352. website_leftKeyChecker.classify(link).then(status => {
  8353. if (!status) {
  8354. return;
  8355. }
  8356. if (/^Active/.test(status)) {
  8357. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  8358. return;
  8359. }
  8360. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  8361. }).catch(error => {
  8362. throwError(error, 'keylol.after -> leftKeyChecker');
  8363. });
  8364. }
  8365. }
  8366. if (this.name === 'Keylol') {
  8367. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  8368. if (asfLinks.length > 0) {
  8369. for (const asfLink of asfLinks) {
  8370. const link = $(asfLink).attr('href');
  8371. if (!link) {
  8372. continue;
  8373. }
  8374. this.#addBtn($(`a[href="${link}"]`).after('<span style="color: #ccc; margin: 0 -5px 0 5px"> | </span>').next()[0], 'steam', 'licenseLinks', `appid-${link.replace('#asf', '')}`);
  8375. }
  8376. }
  8377. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  8378. if (subLinks.length > 0) {
  8379. for (const subLink of subLinks) {
  8380. var _link$match;
  8381. const link = $(subLink).attr('href');
  8382. if (!link) {
  8383. continue;
  8384. }
  8385. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  8386. if (!subid) {
  8387. continue;
  8388. }
  8389. this.#addBtn(subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  8390. }
  8391. }
  8392. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  8393. if (asfLinks2.length > 0) {
  8394. for (const asfLink of asfLinks2) {
  8395. const subid = asfLink.innerText.match(/[\d]+/g);
  8396. if (!subid || subid.length === 0) {
  8397. continue;
  8398. }
  8399. this.#addBtn($(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  8400. }
  8401. }
  8402. }
  8403. } catch (error) {
  8404. throwError(error, 'keylol.after');
  8405. }
  8406. }
  8407. classifyTask(action) {
  8408. try {
  8409. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  8410. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  8411. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  8412. for (const btn of selectedBtns) {
  8413. const button = $(btn);
  8414. const social = button.attr('data-social');
  8415. const type = button.attr('data-type');
  8416. const link = button.attr('data-link');
  8417. if (!(social && type && link)) {
  8418. continue;
  8419. }
  8420. if (action === 'do') {
  8421. this.undoneTasks[social][type].push(link);
  8422. }
  8423. if (action === 'undo') {
  8424. this.socialTasks[social][type].push(link);
  8425. }
  8426. }
  8427. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8428. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8429. if (window.DEBUG) {
  8430. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8431. }
  8432. return true;
  8433. } catch (error) {
  8434. throwError(error, 'Keylol.classifyTask');
  8435. return false;
  8436. }
  8437. }
  8438. selectAll() {
  8439. try {
  8440. $('.auto-task-keylol:visible').attr('selected', 'selected');
  8441. } catch (error) {
  8442. throwError(error, 'Keylol.selectAll');
  8443. }
  8444. }
  8445. selectNone() {
  8446. try {
  8447. $('.auto-task-keylol:visible').removeAttr('selected');
  8448. } catch (error) {
  8449. throwError(error, 'Keylol.selectNone');
  8450. }
  8451. }
  8452. invertSelect() {
  8453. try {
  8454. $('.auto-task-keylol:visible').each((index, element) => {
  8455. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8456. });
  8457. } catch (error) {
  8458. throwError(error, 'Keylol.invertSelect');
  8459. }
  8460. }
  8461. #addBtn(before, social, linkType, link) {
  8462. try {
  8463. $(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>`);
  8464. } catch (error) {
  8465. throwError(error, 'keylol.addBtn');
  8466. }
  8467. }
  8468. }
  8469. const website_Keylol = Keylol;
  8470. const Opquests_defaultTasks = {
  8471. steam: {
  8472. groupLinks: [],
  8473. wishlistLinks: [],
  8474. followLinks: [],
  8475. curatorLikeLinks: []
  8476. }
  8477. };
  8478. class Opquests extends website_Website {
  8479. name = 'Opquests';
  8480. undoneTasks = {
  8481. ...Opquests_defaultTasks
  8482. };
  8483. buttons = [ 'doTask', 'verifyTask', 'getKey' ];
  8484. static test() {
  8485. return window.location.host === 'opquests.com';
  8486. }
  8487. async after() {
  8488. try {
  8489. if (!this.#checkLogin()) {
  8490. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8491. }
  8492. } catch (error) {
  8493. throwError(error, 'Opquests.after');
  8494. }
  8495. }
  8496. init() {
  8497. try {
  8498. const logStatus = scripts_echoLog({
  8499. text: i18n('initing')
  8500. });
  8501. if ($('a[href*="/auth/redirect"]').length > 0) {
  8502. window.open('/auth/redirect', '_self');
  8503. logStatus.warning(i18n('needLogin'));
  8504. return false;
  8505. }
  8506. if (!this.#getGiveawayId()) {
  8507. return false;
  8508. }
  8509. this.initialized = true;
  8510. logStatus.success();
  8511. return true;
  8512. } catch (error) {
  8513. throwError(error, 'Opquests.init');
  8514. return false;
  8515. }
  8516. }
  8517. async classifyTask(action) {
  8518. try {
  8519. if (action === 'undo') {
  8520. scripts_echoLog({
  8521. text: i18n('cannotUndo')
  8522. });
  8523. return false;
  8524. }
  8525. const logStatus = scripts_echoLog({
  8526. text: i18n('getTasksInfo')
  8527. });
  8528. const tasks = $('.w-full:contains("Validate") .items-center');
  8529. for (const task of tasks) {
  8530. const link = $(task).find('a:contains("Open")').attr('href');
  8531. const taskDes = $(task).find('div').eq(1).text().trim();
  8532. if (!link) {
  8533. continue;
  8534. }
  8535. if (/steamcommunity\.com\/groups\//.test(link)) {
  8536. this.undoneTasks.steam.groupLinks.push(link);
  8537. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8538. if (/wishlist/gim.test(taskDes)) {
  8539. this.undoneTasks.steam.wishlistLinks.push(link);
  8540. } else if (/follow/gim.test(taskDes)) {
  8541. this.undoneTasks.steam.followLinks.push(link);
  8542. }
  8543. } else if (/store\.steampowered\.com\/(publisher|developer|curator)\//.test(link) && /follow/gim.test(taskDes)) {
  8544. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8545. } else {
  8546. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8547. }
  8548. }
  8549. logStatus.success();
  8550. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8551. if (window.DEBUG) {
  8552. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8553. }
  8554. return true;
  8555. } catch (error) {
  8556. throwError(error, 'Opquests.classifyTask');
  8557. return false;
  8558. }
  8559. }
  8560. async verifyTask() {
  8561. try {
  8562. const tasks = $.makeArray($('div.w-full').find('.items-center').has('button.submit-loader')).map(ele => ({
  8563. token: $(ele).find('input[name="_token"]').val(),
  8564. taskId: $(ele).find('input[name="task_id"]').val(),
  8565. title: $(ele).find('span.text-sm').text().trim()
  8566. }));
  8567. const pro = [];
  8568. for (const task of tasks) {
  8569. pro.push(this.#verify(task));
  8570. await delay(1e3);
  8571. }
  8572. await Promise.all(pro);
  8573. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8574. if (await this.getKey()) {
  8575. return true;
  8576. }
  8577. window.location.reload();
  8578. return false;
  8579. } catch (error) {
  8580. throwError(error, 'Opquests.verifyTask');
  8581. return false;
  8582. }
  8583. }
  8584. async #verify(task) {
  8585. try {
  8586. const logStatus = scripts_echoLog({
  8587. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  8588. });
  8589. const {
  8590. result,
  8591. statusText,
  8592. status,
  8593. data
  8594. } = await tools_httpRequest({
  8595. url: 'https://opquests.com/entries',
  8596. method: 'POST',
  8597. dataType: 'json',
  8598. nochche: true,
  8599. headers: {
  8600. origin: 'https://opquests.com',
  8601. pragma: 'no-cache',
  8602. referer: window.location.href,
  8603. 'content-type': 'application/x-www-form-urlencoded'
  8604. },
  8605. data: `_token=${task.token}&task_id=${task.taskId}`
  8606. });
  8607. if (result === 'Success') {
  8608. var _data$responseText, _data$responseText2, _$$find$attr;
  8609. 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')) {
  8610. logStatus.success();
  8611. return true;
  8612. }
  8613. 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();
  8614. if (key) {
  8615. logStatus.success();
  8616. scripts_echoLog({}).success(key);
  8617. return true;
  8618. }
  8619. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8620. return false;
  8621. }
  8622. logStatus.error(`${result}:${statusText}(${status})`);
  8623. return false;
  8624. } catch (error) {
  8625. throwError(error, 'Opquests.verify');
  8626. return false;
  8627. }
  8628. }
  8629. async getKey(isButton) {
  8630. try {
  8631. const logStatus = scripts_echoLog({
  8632. text: i18n('gettingKey')
  8633. });
  8634. const {
  8635. result,
  8636. statusText,
  8637. status,
  8638. data
  8639. } = await tools_httpRequest({
  8640. url: 'https://opquests.com/keys',
  8641. method: 'GET'
  8642. });
  8643. if (result === 'Success') {
  8644. if (data !== null && data !== void 0 && data.responseText) {
  8645. 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();
  8646. if (!key) {
  8647. logStatus.error('Error: Key was not found');
  8648. if (isButton) {
  8649. window.open('https://opquests.com/keys', '_self');
  8650. }
  8651. return false;
  8652. }
  8653. logStatus.success();
  8654. scripts_echoLog({}).success(key);
  8655. return true;
  8656. }
  8657. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8658. return false;
  8659. }
  8660. logStatus.error(`${result}:${statusText}(${status})`);
  8661. return false;
  8662. } catch (error) {
  8663. throwError(error, 'Opquests.getGiveawayId');
  8664. return false;
  8665. }
  8666. }
  8667. #getGiveawayId() {
  8668. try {
  8669. var _window$location$href;
  8670. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8671. if (giveawayId) {
  8672. this.giveawayId = giveawayId;
  8673. return true;
  8674. }
  8675. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8676. return false;
  8677. } catch (error) {
  8678. throwError(error, 'Opquests.getGiveawayId');
  8679. return false;
  8680. }
  8681. }
  8682. #checkLogin() {
  8683. try {
  8684. if (!globalOptions.other.checkLogin) {
  8685. return true;
  8686. }
  8687. if ($('a[href*="/auth/redirect"]').length > 0) {
  8688. window.open('/auth/redirect', '_self');
  8689. }
  8690. return true;
  8691. } catch (error) {
  8692. throwError(error, 'Opquests.checkLogin');
  8693. return false;
  8694. }
  8695. }
  8696. }
  8697. const website_Opquests = Opquests;
  8698. const Gleam_defaultTasksTemplate = {
  8699. steam: {
  8700. groupLinks: [],
  8701. wishlistLinks: [],
  8702. followLinks: [],
  8703. curatorLinks: [],
  8704. curatorLikeLinks: []
  8705. },
  8706. twitter: {
  8707. userLinks: [],
  8708. retweetLinks: []
  8709. },
  8710. twitch: {
  8711. channelLinks: []
  8712. },
  8713. discord: {
  8714. serverLinks: []
  8715. },
  8716. youtube: {
  8717. channelLinks: []
  8718. },
  8719. extra: {
  8720. gleam: []
  8721. }
  8722. };
  8723. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  8724. const Gleam_defaultOptions = {
  8725. vlootUsername: '',
  8726. gameroundUsername: ''
  8727. };
  8728. class Gleam extends website_Website {
  8729. name = 'Gleam';
  8730. undoneTasks = JSON.parse(Gleam_defaultTasks);
  8731. socialTasks = JSON.parse(Gleam_defaultTasks);
  8732. options = {
  8733. ...Gleam_defaultOptions,
  8734. ...GM_getValue('GleamOptions')
  8735. };
  8736. buttons = [ 'doTask', 'undoTask', 'verifyTask' ];
  8737. static test() {
  8738. return window.location.host === 'gleam.io';
  8739. }
  8740. async after() {
  8741. try {
  8742. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8743. const checkComplete = setInterval(() => {
  8744. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8745. clearInterval(checkComplete);
  8746. window.close();
  8747. }
  8748. });
  8749. for (const task of $('.entry-content .entry-method')) {
  8750. const taskInfo = $(task).find('.user-links');
  8751. const expandInfo = $(task).find('.expandable');
  8752. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8753. if (aElements.length > 0) {
  8754. for (const element of aElements) {
  8755. const $element = $(element);
  8756. const href = $element.attr('href');
  8757. $element.removeAttr('href')[0].click();
  8758. $element.attr('href', href);
  8759. await delay(1e3);
  8760. }
  8761. }
  8762. taskInfo[0].click();
  8763. await delay(1e3);
  8764. }
  8765. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8766. } else if (!await this.#checkLeftKey()) {
  8767. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8768. }
  8769. } catch (error) {
  8770. throwError(error, 'Gleam.after');
  8771. return false;
  8772. }
  8773. }
  8774. init() {
  8775. try {
  8776. const logStatus = scripts_echoLog({
  8777. text: i18n('initing')
  8778. });
  8779. if (!this.#getGiveawayId()) {
  8780. return false;
  8781. }
  8782. this.initialized = true;
  8783. logStatus.success();
  8784. return true;
  8785. } catch (error) {
  8786. throwError(error, 'Gleam.init');
  8787. return false;
  8788. }
  8789. }
  8790. async classifyTask(action) {
  8791. try {
  8792. const logStatus = scripts_echoLog({
  8793. text: i18n('getTasksInfo')
  8794. });
  8795. if (action === 'undo') {
  8796. var _GM_getValue;
  8797. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  8798. }
  8799. const tasks = $('.entry-content .entry-method');
  8800. for (const task of tasks) {
  8801. var _socialIcon$attr;
  8802. const $task = $(task);
  8803. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  8804. continue;
  8805. }
  8806. const socialIcon = $task.find('.icon-wrapper i');
  8807. const taskInfo = $task.find('.user-links');
  8808. const taskText = taskInfo.text().trim();
  8809. const expandInfo = $task.find('.expandable');
  8810. const aElements = expandInfo.find('a.btn');
  8811. if (aElements.length > 0) {
  8812. for (const element of aElements) {
  8813. const $element = $(element);
  8814. const href = $element.attr('href');
  8815. $element.removeAttr('href')[0].click();
  8816. $element.attr('href', href);
  8817. }
  8818. }
  8819. if (socialIcon.hasClass('fa-twitter')) {
  8820. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  8821. if (!link) {
  8822. continue;
  8823. }
  8824. if (/follow/gi.test(taskText)) {
  8825. if (action === 'undo') {
  8826. this.socialTasks.twitter.userLinks.push(link);
  8827. }
  8828. if (action === 'do') {
  8829. this.undoneTasks.twitter.userLinks.push(link);
  8830. }
  8831. } else if (/retweet/gim.test(taskText)) {
  8832. if (action === 'undo') {
  8833. this.socialTasks.twitter.retweetLinks.push(link);
  8834. }
  8835. if (action === 'do') {
  8836. this.undoneTasks.twitter.retweetLinks.push(link);
  8837. }
  8838. }
  8839. } else if (socialIcon.hasClass('fa-twitch')) {
  8840. if (/follow/gim.test(taskText)) {
  8841. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  8842. if (!link) {
  8843. continue;
  8844. }
  8845. if (action === 'undo') {
  8846. this.socialTasks.twitch.channelLinks.push(link);
  8847. }
  8848. if (action === 'do') {
  8849. this.undoneTasks.twitch.channelLinks.push(link);
  8850. }
  8851. }
  8852. } else if (socialIcon.hasClass('fa-discord')) {
  8853. if (/join/gim.test(taskText)) {
  8854. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  8855. if (!link) {
  8856. var _$task$find$attr, _$task$find$attr$matc;
  8857. 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];
  8858. if (!ggLink) {
  8859. continue;
  8860. }
  8861. link = `https://discord.com/invite/${ggLink}`;
  8862. }
  8863. if (action === 'undo') {
  8864. this.socialTasks.discord.serverLinks.push(link);
  8865. }
  8866. if (action === 'do') {
  8867. this.undoneTasks.discord.serverLinks.push(link);
  8868. }
  8869. }
  8870. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  8871. continue;
  8872. } else if (socialIcon.hasClass('fa-youtube')) {
  8873. if (/subscribe/gim.test(taskText)) {
  8874. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  8875. if (!link) {
  8876. continue;
  8877. }
  8878. if (action === 'undo') {
  8879. this.socialTasks.youtube.channelLinks.push(link);
  8880. }
  8881. if (action === 'do') {
  8882. this.undoneTasks.youtube.channelLinks.push(link);
  8883. }
  8884. }
  8885. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  8886. if (/join.*group/gi.test(taskText)) {
  8887. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  8888. if (!link) {
  8889. continue;
  8890. }
  8891. if (action === 'undo') {
  8892. this.socialTasks.steam.groupLinks.push(link);
  8893. }
  8894. if (action === 'do') {
  8895. this.undoneTasks.steam.groupLinks.push(link);
  8896. }
  8897. } else if (/follow.*curator/gi.test(taskText)) {
  8898. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  8899. if (!link) {
  8900. continue;
  8901. }
  8902. if (action === 'undo') {
  8903. this.socialTasks.steam.curatorLinks.push(link);
  8904. }
  8905. if (action === 'do') {
  8906. this.undoneTasks.steam.curatorLinks.push(link);
  8907. }
  8908. }
  8909. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('vloot.io') || socialIcon.hasClass('fa-tiktok')) {
  8910. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  8911. for (const button of continueBtn) {
  8912. button.click();
  8913. await delay(500);
  8914. expandInfo.find('input').val(this.options.vlootUsername);
  8915. }
  8916. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  8917. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  8918. for (const button of continueBtn) {
  8919. button.click();
  8920. await delay(500);
  8921. expandInfo.find('input').val(this.options.gameroundUsername);
  8922. }
  8923. } else if (socialIcon.hasClass('fa-bullhorn') && /Complete/gi.test(taskText)) {
  8924. if (action !== 'do') {
  8925. continue;
  8926. }
  8927. const gleamLink = await this.#getGleamLink(taskText);
  8928. if (!gleamLink) {
  8929. continue;
  8930. }
  8931. this.undoneTasks.extra.gleam.push(gleamLink);
  8932. } 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 {
  8933. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  8934. }
  8935. }
  8936. logStatus.success();
  8937. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8938. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8939. if (window.DEBUG) {
  8940. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8941. }
  8942. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  8943. tasks: this.socialTasks,
  8944. time: new Date().getTime()
  8945. });
  8946. return true;
  8947. } catch (error) {
  8948. throwError(error, 'Gleam.classifyTask');
  8949. return false;
  8950. }
  8951. }
  8952. async extraDoTask(_ref) {
  8953. let {
  8954. gleam
  8955. } = _ref;
  8956. try {
  8957. const pro = [];
  8958. for (const link of gleam) {
  8959. pro.push(this.#doGleamTask(link));
  8960. }
  8961. return Promise.all(pro).then(() => true);
  8962. } catch (error) {
  8963. throwError(error, 'Gleam.extraDoTask');
  8964. return false;
  8965. }
  8966. }
  8967. async verifyTask() {
  8968. try {
  8969. scripts_echoLog({
  8970. text: `${i18n('verifyingTask')}...`
  8971. });
  8972. const tasks = $('.entry-content .entry-method');
  8973. for (const task of tasks) {
  8974. const $task = $(task);
  8975. if ($task.find('i.fa-question').length === 0) {
  8976. continue;
  8977. }
  8978. const taskInfo = $task.find('.user-links');
  8979. taskInfo[0].click();
  8980. await delay(500);
  8981. await this.#checkSync();
  8982. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  8983. for (const button of continueBtn) {
  8984. button.click();
  8985. await delay(500);
  8986. await this.#checkSync();
  8987. }
  8988. }
  8989. scripts_echoLog({
  8990. text: i18n('verifiedGleamTasks')
  8991. });
  8992. } catch (error) {
  8993. throwError(error, 'Gleam.verifyTask');
  8994. return false;
  8995. }
  8996. }
  8997. async #checkSync() {
  8998. try {
  8999. return await new Promise(resolve => {
  9000. const checker = setInterval(() => {
  9001. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9002. clearInterval(checker);
  9003. resolve(true);
  9004. }
  9005. }, 500);
  9006. });
  9007. } catch (error) {
  9008. throwError(error, 'Gleam.checkSync');
  9009. return false;
  9010. }
  9011. }
  9012. async #doGleamTask(link) {
  9013. try {
  9014. const logStatus = scripts_echoLog({
  9015. text: i18n('doingGleamTask')
  9016. });
  9017. return await new Promise(resolve => {
  9018. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9019. active: true,
  9020. insert: true,
  9021. setParent: true
  9022. }).onclose = () => {
  9023. logStatus.success();
  9024. resolve(true);
  9025. };
  9026. });
  9027. } catch (error) {
  9028. throwError(error, 'Gleam.doGleamTask');
  9029. return false;
  9030. }
  9031. }
  9032. #getGiveawayId() {
  9033. try {
  9034. const giveawayId = window.location.pathname;
  9035. if (giveawayId) {
  9036. this.giveawayId = giveawayId;
  9037. return true;
  9038. }
  9039. scripts_echoLog({
  9040. text: i18n('getFailed', 'GiveawayId')
  9041. });
  9042. return false;
  9043. } catch (error) {
  9044. throwError(error, 'Gleam.getGiveawayId');
  9045. return false;
  9046. }
  9047. }
  9048. async #getGleamLink(title) {
  9049. try {
  9050. const logStatus = scripts_echoLog({
  9051. text: i18n('gettingGleamLink')
  9052. });
  9053. const {
  9054. result,
  9055. statusText,
  9056. status,
  9057. data
  9058. } = await tools_httpRequest({
  9059. url: 'https://www.vloot.io/api/v1/giveaways',
  9060. method: 'GET',
  9061. responseType: 'json'
  9062. });
  9063. if (result === 'Success') {
  9064. var _data$response, _data$response2;
  9065. 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) {
  9066. const {
  9067. link
  9068. } = data.response.Data.find(giveaway => title.replace(/[\s]/g, '').toLowerCase().includes(giveaway.title.replace(/[\s]/g, '').toLowerCase())) || {};
  9069. if (link) {
  9070. logStatus.success();
  9071. return link;
  9072. }
  9073. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9074. return false;
  9075. }
  9076. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9077. return false;
  9078. }
  9079. logStatus.error(`${result}:${statusText}(${status})`);
  9080. return false;
  9081. } catch (error) {
  9082. throwError(error, 'Gleam.getGleamLink');
  9083. return false;
  9084. }
  9085. }
  9086. async #checkLeftKey() {
  9087. try {
  9088. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9089. if (!globalOptions.other.checkLeftKey) {
  9090. return true;
  9091. }
  9092. 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];
  9093. if (!campaignString) {
  9094. return false;
  9095. }
  9096. const {
  9097. campaign,
  9098. incentive
  9099. } = JSON.parse(campaignString);
  9100. 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];
  9101. let ownedKey = false;
  9102. if (controllerString) {
  9103. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9104. 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) {
  9105. ownedKey = true;
  9106. }
  9107. }
  9108. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9109. await external_Swal_default().fire({
  9110. icon: 'warning',
  9111. title: i18n('notice'),
  9112. text: i18n('giveawayNotWork'),
  9113. confirmButtonText: i18n('confirm'),
  9114. cancelButtonText: i18n('cancel'),
  9115. showCancelButton: true
  9116. }).then(_ref2 => {
  9117. let {
  9118. value
  9119. } = _ref2;
  9120. if (value) {
  9121. window.close();
  9122. }
  9123. });
  9124. }
  9125. return true;
  9126. } catch (error) {
  9127. throwError(error, 'Gleam.checkLeftKey');
  9128. return false;
  9129. }
  9130. }
  9131. }
  9132. const website_Gleam = Gleam;
  9133. const SweepWidget_defaultOptions = {
  9134. username: '',
  9135. email: ''
  9136. };
  9137. class SweepWidget extends website_Website {
  9138. name = 'SweepWidget';
  9139. options = {
  9140. ...SweepWidget_defaultOptions,
  9141. ...GM_getValue('SweepWidgetOptions')
  9142. };
  9143. buttons = [ 'doTask' ];
  9144. static test() {
  9145. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9146. }
  9147. async after() {
  9148. try {
  9149. if (!this.#checkLogin()) {
  9150. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9151. }
  9152. } catch (error) {
  9153. throwError(error, 'SweepWidget.after');
  9154. }
  9155. }
  9156. init() {
  9157. try {
  9158. const logStatus = scripts_echoLog({
  9159. text: i18n('initing')
  9160. });
  9161. if (!this.#checkLogin()) {
  9162. logStatus.warning(i18n('needLogin'));
  9163. return false;
  9164. }
  9165. if (!this.#getGiveawayId()) {
  9166. return false;
  9167. }
  9168. this.initialized = true;
  9169. logStatus.success();
  9170. return true;
  9171. } catch (error) {
  9172. throwError(error, 'SweepWidget.init');
  9173. return false;
  9174. }
  9175. }
  9176. classifyTask() {
  9177. return true;
  9178. }
  9179. async doTask() {
  9180. try {
  9181. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9182. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9183. $('input[name="sw__login_name"]').val(this.options.username);
  9184. }
  9185. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9186. $('input[name="sw__login_email"]').val(this.options.email);
  9187. }
  9188. if ($('#sw_login_button:visible').length > 0) {
  9189. $('#sw_login_button')[0].click();
  9190. }
  9191. if (!await this.#checkEnter()) {
  9192. return false;
  9193. }
  9194. }
  9195. const logStatus = scripts_echoLog({
  9196. text: i18n('SweepWidgetNotice')
  9197. });
  9198. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9199. for (const task of tasks) {
  9200. var _aElement$, _$task$find$removeAtt;
  9201. const $task = $(task);
  9202. if ($task.find('i.fa-check:visible').length > 0) {
  9203. continue;
  9204. }
  9205. const title = $task.find('.sw_text_inner');
  9206. title[0].click();
  9207. const aElement = $task.find('a.sw_link');
  9208. const link = aElement.attr('href');
  9209. aElement.attr('href', '#a').attr('target', '_self');
  9210. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9211. await delay(300);
  9212. aElement.attr('href', link).attr('target', '_blank');
  9213. $task.find('input[type="text"]').val('test');
  9214. const verifyBtn = $task.find('input.sw_verify');
  9215. if (verifyBtn.prop('disabled') === true) {
  9216. title[0].click();
  9217. await delay(300);
  9218. title[0].click();
  9219. await delay(300);
  9220. }
  9221. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9222. await this.#checkFinish($task);
  9223. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9224. }
  9225. logStatus.success();
  9226. return true;
  9227. } catch (error) {
  9228. throwError(error, 'SweepWidget.doTask');
  9229. return false;
  9230. }
  9231. }
  9232. #checkLogin() {
  9233. try {
  9234. if ($('#twitter_login_button').length > 0) {
  9235. $('#twitter_login_button')[0].click();
  9236. }
  9237. return true;
  9238. } catch (error) {
  9239. throwError(error, 'SweepWidget.checkLogin');
  9240. return false;
  9241. }
  9242. }
  9243. #getGiveawayId() {
  9244. try {
  9245. var _window$location$href;
  9246. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9247. if (giveawayId) {
  9248. this.giveawayId = giveawayId;
  9249. return true;
  9250. }
  9251. scripts_echoLog({
  9252. text: i18n('getFailed', 'GiveawayId')
  9253. });
  9254. return false;
  9255. } catch (error) {
  9256. throwError(error, 'SweepWidget.getGiveawayId');
  9257. return false;
  9258. }
  9259. }
  9260. async #checkEnter() {
  9261. try {
  9262. return new Promise(resolve => {
  9263. const checker = setInterval(() => {
  9264. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9265. clearInterval(checker);
  9266. resolve(true);
  9267. }
  9268. });
  9269. });
  9270. } catch (error) {
  9271. throwError(error, 'SweepWidget.checkEnter');
  9272. return false;
  9273. }
  9274. }
  9275. async #checkFinish($task) {
  9276. try {
  9277. return new Promise(resolve => {
  9278. const checker = setInterval(() => {
  9279. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9280. clearInterval(checker);
  9281. resolve(true);
  9282. }
  9283. });
  9284. });
  9285. } catch (error) {
  9286. throwError(error, 'SweepWidget.checkFinish');
  9287. return false;
  9288. }
  9289. }
  9290. }
  9291. const website_SweepWidget = SweepWidget;
  9292. const defaultWhiteList = {
  9293. discord: {
  9294. servers: []
  9295. },
  9296. instagram: {
  9297. users: []
  9298. },
  9299. twitch: {
  9300. channels: []
  9301. },
  9302. twitter: {
  9303. users: [],
  9304. retweets: [],
  9305. likes: []
  9306. },
  9307. vk: {
  9308. names: []
  9309. },
  9310. youtube: {
  9311. channels: [],
  9312. likes: []
  9313. },
  9314. reddit: {
  9315. reddits: []
  9316. },
  9317. steam: {
  9318. groups: [],
  9319. officialGroups: [],
  9320. wishlists: [],
  9321. follows: [],
  9322. forums: [],
  9323. workshops: [],
  9324. curators: [],
  9325. workshopVotes: [],
  9326. curatorLikes: [],
  9327. announcements: [],
  9328. licenses: [],
  9329. playtests: []
  9330. }
  9331. };
  9332. const link2id = async function(type) {
  9333. 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;
  9334. try {
  9335. const link = $('#socialLink').val();
  9336. let id = '';
  9337. switch (type) {
  9338. case 'discord.servers':
  9339. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9340. break;
  9341.  
  9342. case 'instagram.users':
  9343. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9344. break;
  9345.  
  9346. case 'twitch.channels':
  9347. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9348. break;
  9349.  
  9350. case 'twitter.users':
  9351. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9352. break;
  9353.  
  9354. case 'twitter.retweets':
  9355. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9356. break;
  9357.  
  9358. case 'vk.names':
  9359. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9360. break;
  9361.  
  9362. case 'youtube.channels':
  9363. 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) || '';
  9364. break;
  9365.  
  9366. case 'youtube.likes':
  9367. 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) || '';
  9368. break;
  9369.  
  9370. case 'reddit.reddits':
  9371. 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]) || '';
  9372. break;
  9373.  
  9374. case 'steam.groups':
  9375. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9376. break;
  9377.  
  9378. case 'steam.wishlists':
  9379. case 'steam.follows':
  9380. case 'steam.forums':
  9381. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9382. break;
  9383.  
  9384. case 'steam.workshops':
  9385. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9386. break;
  9387.  
  9388. case 'steam.curators':
  9389. {
  9390. if (link.includes('curator')) {
  9391. var _link$match12;
  9392. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9393. } else {
  9394. var _link$match13;
  9395. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9396. if (!param || param.length !== 2) {
  9397. break;
  9398. }
  9399. const steam = new social_Steam();
  9400. if (await steam.init()) {
  9401. id = await steam.getCuratorId(param[0], param[1]) || '';
  9402. }
  9403. }
  9404. }
  9405. break;
  9406. }
  9407. return id;
  9408. } catch (error) {
  9409. throwError(error, 'link2id');
  9410. return i18n('getFailed', 'id');
  9411. }
  9412. };
  9413. const disabledType = {
  9414. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9415. twitter: [ 'likes' ]
  9416. };
  9417. const assignWhiteList = whiteList => {
  9418. try {
  9419. const newWhiteList = {};
  9420. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  9421. newWhiteList[key] = {
  9422. ...value,
  9423. ...whiteList[key]
  9424. };
  9425. }
  9426. return newWhiteList;
  9427. } catch (error) {
  9428. throwError(error, 'assignWhiteList');
  9429. return defaultWhiteList;
  9430. }
  9431. };
  9432. const whiteListOptions = function(showType) {
  9433. try {
  9434. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  9435. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9436. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9437. for (const [ social, types ] of Object.entries(whiteList)) {
  9438. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9439. var _disabledType$social;
  9440. 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>`;
  9441. }).join('');
  9442. }
  9443. whiteListOptionsForm += '</tbody></table></form>';
  9444. if (showType === 'swal') {
  9445. external_Swal_default().fire({
  9446. title: i18n('whiteListOptions'),
  9447. html: whiteListOptionsForm,
  9448. showConfirmButton: false,
  9449. showCloseButton: true
  9450. });
  9451. } else {
  9452. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9453. }
  9454. $('.editWhiteList').on('click', function() {
  9455. var _whiteList$social;
  9456. const value = $(this).attr('data-value');
  9457. if (!value) {
  9458. return;
  9459. }
  9460. const [ social, type ] = value.split('.');
  9461. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9462. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9463. return;
  9464. }
  9465. external_Swal_default().fire({
  9466. title: i18n('changeWhiteListOption', value),
  9467. input: 'textarea',
  9468. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9469. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9470. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9471. inputValue: whiteList[social][type].join('\n'),
  9472. showConfirmButton: true,
  9473. confirmButtonText: i18n('save'),
  9474. showCancelButton: true,
  9475. cancelButtonText: i18n('close'),
  9476. showDenyButton: true,
  9477. denyButtonText: i18n('return')
  9478. }).then(_ref => {
  9479. let {
  9480. isDenied,
  9481. isConfirmed,
  9482. value
  9483. } = _ref;
  9484. if (isDenied) {
  9485. if (showType === 'swal') {
  9486. whiteListOptions(showType);
  9487. }
  9488. return;
  9489. } else if (isConfirmed) {
  9490. whiteList[social][type] = value.split('\n');
  9491. GM_setValue('whiteList', whiteList);
  9492. external_Swal_default().fire({
  9493. title: i18n('changeWhiteListSuccess'),
  9494. icon: 'success'
  9495. });
  9496. }
  9497. });
  9498. $('#link2id').on('click', async function() {
  9499. const type = $(this).attr('data-type');
  9500. $('#socialLink').val(await link2id(type));
  9501. });
  9502. });
  9503. } catch (error) {
  9504. throwError(error, 'whiteListOptions');
  9505. }
  9506. };
  9507. const whiteList = whiteListOptions;
  9508. const setGistData = async (token, gistId, fileName, content) => {
  9509. try {
  9510. const logStatus = scripts_echoLog({
  9511. text: i18n('settingData')
  9512. });
  9513. const contentData = JSON.stringify({
  9514. files: {
  9515. [fileName]: {
  9516. content: JSON.stringify(content)
  9517. }
  9518. }
  9519. });
  9520. const {
  9521. result,
  9522. statusText,
  9523. status,
  9524. data
  9525. } = await tools_httpRequest({
  9526. url: `https://api.github.com/gists/${gistId}`,
  9527. headers: {
  9528. Accept: 'application/vnd.github.v3+json',
  9529. Authorization: `token ${token}`
  9530. },
  9531. data: contentData,
  9532. responseType: 'json',
  9533. method: 'POST',
  9534. timeout: 3e4
  9535. });
  9536. if (result === 'Success') {
  9537. var _data$response$files, _data$response$files$;
  9538. 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)) {
  9539. logStatus.success();
  9540. return true;
  9541. }
  9542. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9543. return false;
  9544. }
  9545. logStatus.error(`${result}:${statusText}(${status})`);
  9546. return false;
  9547. } catch (error) {
  9548. throwError(error, 'setGistData');
  9549. return false;
  9550. }
  9551. };
  9552. const getGistData = async function(token, gistId, fileName) {
  9553. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9554. try {
  9555. const logStatus = scripts_echoLog({
  9556. text: i18n('gettingData')
  9557. });
  9558. const {
  9559. result,
  9560. statusText,
  9561. status,
  9562. data
  9563. } = await tools_httpRequest({
  9564. url: `https://api.github.com/gists/${gistId}`,
  9565. headers: {
  9566. Accept: 'application/vnd.github.v3+json',
  9567. Authorization: `token ${token}`
  9568. },
  9569. responseType: 'json',
  9570. method: 'GET',
  9571. timeout: 3e4
  9572. });
  9573. if (result === 'Success') {
  9574. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9575. var _data$response, _data$response$files2, _data$response$files3;
  9576. 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;
  9577. let formatedContent;
  9578. if (!content) {
  9579. logStatus.error(`Error:${i18n('noRemoteData')}`);
  9580. return false;
  9581. }
  9582. if (test) {
  9583. logStatus.success();
  9584. return true;
  9585. }
  9586. try {
  9587. formatedContent = JSON.parse(content);
  9588. } catch (error) {
  9589. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  9590. return false;
  9591. }
  9592. logStatus.success();
  9593. return formatedContent;
  9594. }
  9595. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9596. return false;
  9597. }
  9598. logStatus.error(`${result}:${statusText}(${status})`);
  9599. return false;
  9600. } catch (error) {
  9601. throwError(error, 'getGistData');
  9602. return false;
  9603. }
  9604. };
  9605. const syncOptions = () => {
  9606. try {
  9607. const {
  9608. TOKEN,
  9609. GIST_ID,
  9610. FILE_NAME,
  9611. SYNC_HISTORY
  9612. } = GM_getValue('gistOptions') || {
  9613. TOKEN: '',
  9614. GIST_ID: '',
  9615. FILE_NAME: '',
  9616. SYNC_HISTORY: true
  9617. };
  9618. external_Swal_default().fire({
  9619. title: i18n('gistOptions'),
  9620. 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;">
  9621. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9622. ${i18n('downloadFromGist')}</button></p>`,
  9623. focusConfirm: false,
  9624. showLoaderOnConfirm: true,
  9625. 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>`,
  9626. preConfirm: async () => {
  9627. const token = $('#github-token').val();
  9628. const gistId = $('#gist-id').val();
  9629. const fileName = $('#file-name').val();
  9630. const syncHistory = $('#sync-history').prop('checked');
  9631. GM_setValue('gistOptions', {
  9632. TOKEN: token,
  9633. GIST_ID: gistId,
  9634. FILE_NAME: fileName,
  9635. SYNC_HISTORY: syncHistory
  9636. });
  9637. return await getGistData(token, gistId, fileName, true);
  9638. },
  9639. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9640. confirmButtonText: i18n('saveAndTest'),
  9641. showCancelButton: true,
  9642. cancelButtonText: i18n('close')
  9643. }).then(_ref => {
  9644. let {
  9645. value
  9646. } = _ref;
  9647. if (value) {
  9648. external_Swal_default().fire({
  9649. icon: 'success',
  9650. title: i18n('testSuccess')
  9651. }).then(syncOptions);
  9652. } else if (value !== undefined) {
  9653. external_Swal_default().fire({
  9654. icon: 'error',
  9655. title: i18n('testFailed')
  9656. }).then(syncOptions);
  9657. }
  9658. });
  9659. $('#upload-data').on('click', async () => {
  9660. const {
  9661. TOKEN,
  9662. GIST_ID,
  9663. FILE_NAME
  9664. } = GM_getValue('gistOptions') || {};
  9665. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9666. return external_Swal_default().fire({
  9667. icon: 'error',
  9668. title: i18n('saveAndTestNotice')
  9669. }).then(syncOptions);
  9670. }
  9671. external_Swal_default().fire({
  9672. icon: 'info',
  9673. title: i18n('processingData')
  9674. });
  9675. const data = {};
  9676. const names = GM_listValues();
  9677. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9678. for (const name of names) {
  9679. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9680. continue;
  9681. }
  9682. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9683. continue;
  9684. }
  9685. data[name] = GM_getValue(name);
  9686. }
  9687. external_Swal_default().update({
  9688. icon: 'info',
  9689. title: i18n('updatingData')
  9690. });
  9691. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9692. external_Swal_default().fire({
  9693. icon: 'success',
  9694. title: i18n('syncDataSuccess')
  9695. });
  9696. } else {
  9697. external_Swal_default().fire({
  9698. icon: 'error',
  9699. title: i18n('syncDataFailed')
  9700. });
  9701. }
  9702. });
  9703. $('#download-data').on('click', async () => {
  9704. const {
  9705. TOKEN,
  9706. GIST_ID,
  9707. FILE_NAME
  9708. } = GM_getValue('gistOptions') || {};
  9709. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9710. return external_Swal_default().fire({
  9711. icon: 'error',
  9712. title: i18n('saveAndTestNotice')
  9713. }).then(syncOptions);
  9714. }
  9715. external_Swal_default().fire({
  9716. icon: 'info',
  9717. title: i18n('downloadingData')
  9718. });
  9719. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9720. if (!data) {
  9721. return external_Swal_default().fire({
  9722. icon: 'error',
  9723. title: i18n('checkedNoData')
  9724. }).then(syncOptions);
  9725. }
  9726. external_Swal_default().update({
  9727. icon: 'info',
  9728. title: i18n('savingData')
  9729. });
  9730. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9731. for (const [ name, value ] of Object.entries(data)) {
  9732. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9733. continue;
  9734. }
  9735. GM_setValue(name, value);
  9736. }
  9737. external_Swal_default().fire({
  9738. icon: 'success',
  9739. title: i18n('syncDataSuccess')
  9740. });
  9741. });
  9742. } catch (error) {
  9743. throwError(error, 'syncOptions');
  9744. }
  9745. };
  9746. const dataSync = syncOptions;
  9747. class Setting {
  9748. name = 'Setting';
  9749. buttons = [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ];
  9750. syncData = dataSync;
  9751. tasksHistory() {
  9752. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  9753. }
  9754. static test() {
  9755. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  9756. }
  9757. before() {
  9758. $('body').html('').addClass('auto-task-options');
  9759. }
  9760. after() {
  9761. try {
  9762. this.#environment();
  9763. changeGlobalOptions('page');
  9764. whiteList('page');
  9765. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  9766. $('#getTwitterUserId').on('click', () => {
  9767. this.#getId('twitterUser');
  9768. });
  9769. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  9770. $('#getYoutubeChannelId').on('click', () => {
  9771. this.#getId('youtubeChannel');
  9772. });
  9773. $('input[name^="position"]').on('input', function() {
  9774. const type = $(this).attr('name').replace('position.', '');
  9775. const xLabel = 'rightleft';
  9776. const yLabel = 'topbottpm';
  9777. switch (type) {
  9778. case 'buttonSideX':
  9779. case 'buttonSideY':
  9780. case 'buttonDistance':
  9781. {
  9782. const distance = $('input[name="position.buttonDistance"]').val();
  9783. const sideX = $('input[name="position.buttonSideX"]').val();
  9784. const sideY = $('input[name="position.buttonSideY"]').val();
  9785. if (![ 'right', 'left' ].includes(sideX)) {
  9786. break;
  9787. }
  9788. if (![ 'top', 'bottom' ].includes(sideY)) {
  9789. break;
  9790. }
  9791. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9792. break;
  9793. }
  9794. const distanceArr = distance.split(',');
  9795. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9796. break;
  9797. }
  9798.  
  9799. case 'showButtonSideX':
  9800. case 'showButtonSideY':
  9801. case 'showButtonDistance':
  9802. {
  9803. const distance = $('input[name="position.showButtonDistance"]').val();
  9804. const sideX = $('input[name="position.showButtonSideX"]').val();
  9805. const sideY = $('input[name="position.showButtonSideY"]').val();
  9806. if (![ 'right', 'left' ].includes(sideX)) {
  9807. break;
  9808. }
  9809. if (![ 'top', 'bottom' ].includes(sideY)) {
  9810. break;
  9811. }
  9812. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9813. break;
  9814. }
  9815. const distanceArr = distance.split(',');
  9816. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9817. break;
  9818. }
  9819.  
  9820. case 'logSideX':
  9821. case 'logSideY':
  9822. case 'logDistance':
  9823. {
  9824. const distance = $('input[name="position.logDistance"]').val();
  9825. const sideX = $('input[name="position.logSideX"]').val();
  9826. const sideY = $('input[name="position.logSideY"]').val();
  9827. if (![ 'right', 'left' ].includes(sideX)) {
  9828. break;
  9829. }
  9830. if (![ 'top', 'bottom' ].includes(sideY)) {
  9831. break;
  9832. }
  9833. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9834. break;
  9835. }
  9836. const distanceArr = distance.split(',');
  9837. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9838. break;
  9839. }
  9840.  
  9841. default:
  9842. break;
  9843. }
  9844. });
  9845. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  9846. let functionKey = '';
  9847. if (event.altKey) {
  9848. functionKey += 'alt + ';
  9849. } else if (event.ctrlKey) {
  9850. functionKey += 'ctrl + ';
  9851. } else if (event.shiftKey) {
  9852. functionKey += 'shift + ';
  9853. }
  9854. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  9855. });
  9856. } catch (error) {
  9857. throwError(error, 'Setting.after');
  9858. }
  9859. }
  9860. saveGlobalOptions() {
  9861. saveData();
  9862. }
  9863. #getId(social) {
  9864. try {
  9865. external_Swal_default().fire({
  9866. title: i18n('getId', i18n(social)),
  9867. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9868. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  9869. showCancelButton: true,
  9870. cancelButtonText: i18n('close'),
  9871. showConfirmButton: false
  9872. });
  9873. $('#link2id').on('click', async function() {
  9874. const link = $('#socialLink').val();
  9875. if (!link) {
  9876. return;
  9877. }
  9878. const type = $(this).attr('data-type');
  9879. if (type === 'twitterUser') {
  9880. var _link$match;
  9881. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  9882. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  9883. } else if (type === 'youtubeChannel') {
  9884. var _link$match2, _await$getInfo, _await$getInfo$params;
  9885. 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;
  9886. $('#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) || '');
  9887. }
  9888. });
  9889. } catch (error) {
  9890. throwError(error, 'Setting.getId');
  9891. }
  9892. }
  9893. #environment() {
  9894. try {
  9895. const userAgent = (0, javascript_utils_umd_min.ua)();
  9896. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  9897. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  9898. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  9899. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  9900. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  9901. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  9902. </tbody></table></form>`;
  9903. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  9904. } catch (error) {
  9905. throwError(error, 'Setting.environment');
  9906. }
  9907. }
  9908. }
  9909. const website_Setting = Setting;
  9910. class History extends website_Keylol {
  9911. name = 'History';
  9912. buttons = [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ];
  9913. static test() {
  9914. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  9915. }
  9916. before() {
  9917. try {
  9918. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  9919. const data = GM_listValues() || [];
  9920. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9921. for (const item of tasksHistory) {
  9922. this.#addItem(item);
  9923. }
  9924. } catch (error) {
  9925. throwError(error, 'History.before');
  9926. }
  9927. }
  9928. clearHistory() {
  9929. try {
  9930. const data = GM_listValues() || [];
  9931. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9932. for (const item of tasksHistory) {
  9933. GM_deleteValue(item);
  9934. }
  9935. external_Swal_default().fire({
  9936. title: i18n('clearHistoryFinished'),
  9937. icon: 'success'
  9938. });
  9939. } catch (error) {
  9940. throwError(error, 'History.after');
  9941. }
  9942. }
  9943. #addItem(item) {
  9944. try {
  9945. const tasksData = GM_getValue(item);
  9946. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  9947. return;
  9948. }
  9949. let html = '';
  9950. let title = '';
  9951. let link = '';
  9952. const [ website, id ] = item.split('-');
  9953. switch (website) {
  9954. case 'fawTasks':
  9955. title = `Freeanywhere[${id}]`;
  9956. link = `https://freeanywhere.net/#/giveaway/${id}`;
  9957. break;
  9958.  
  9959. case 'gasTasks':
  9960. title = `Giveawaysu[${id}]`;
  9961. link = `https://giveaway.su/giveaway/view/${id}`;
  9962. break;
  9963.  
  9964. case 'gcTasks':
  9965. title = `GiveeClub[${id}]`;
  9966. link = `https://givee.club/event/${id}`;
  9967. break;
  9968.  
  9969. case 'gkTasks':
  9970. title = `Givekey[${id}]`;
  9971. link = `https://givekey.ru/giveaway/${id}`;
  9972. break;
  9973.  
  9974. case 'gleamTasks':
  9975. title = `Gleam[${id}]`;
  9976. link = `https://gleam.io${id}`;
  9977. break;
  9978.  
  9979. case 'khTasks':
  9980. title = `keyhub[${id}]`;
  9981. link = `https://key-hub.eu/giveaway/${id}`;
  9982. break;
  9983.  
  9984. case 'prysTasks':
  9985. title = `Prys[${id}]`;
  9986. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  9987. break;
  9988.  
  9989. default:
  9990. return;
  9991. }
  9992. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  9993. for (const [ type, tasks ] of Object.entries(types)) {
  9994. for (const task of tasks) {
  9995. 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>`;
  9996. }
  9997. }
  9998. }
  9999. $('.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>`);
  10000. $('span.delete-task').on('click', function() {
  10001. const itemName = $(this).attr('data-name');
  10002. if (itemName) {
  10003. GM_deleteValue(itemName);
  10004. $(`div.card[data-name="${itemName}"]`).remove();
  10005. external_Swal_default().fire({
  10006. title: i18n('clearTaskFinished'),
  10007. text: itemName,
  10008. icon: 'success'
  10009. });
  10010. } else {
  10011. external_Swal_default().fire({
  10012. title: i18n('clearTaskFailed'),
  10013. icon: 'error'
  10014. });
  10015. }
  10016. });
  10017. } catch (error) {
  10018. throwError(error, 'History.addItem');
  10019. }
  10020. }
  10021. }
  10022. const website_History = History;
  10023. 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 ];
  10024. const websiteOptions = function(website, options) {
  10025. try {
  10026. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10027. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10028. for (const [ option, value ] of Object.entries(options)) {
  10029. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10030. }
  10031. websiteOptionsForm += '</tbody></table></form>';
  10032. external_Swal_default().fire({
  10033. title: i18n('websiteOptions'),
  10034. html: websiteOptionsForm,
  10035. showConfirmButton: true,
  10036. confirmButtonText: i18n('save'),
  10037. showCancelButton: true,
  10038. cancelButtonText: i18n('close')
  10039. }).then(_ref => {
  10040. let {
  10041. isConfirmed
  10042. } = _ref;
  10043. if (isConfirmed) {
  10044. $('#websiteOptionsForm').serializeArray().map(value => {
  10045. options[value.name] = value.value;
  10046. return value;
  10047. });
  10048. GM_setValue(`${website}Options`, options);
  10049. external_Swal_default().fire({
  10050. title: i18n('changeWebsiteOptionsSuccess'),
  10051. icon: 'success'
  10052. });
  10053. }
  10054. });
  10055. } catch (error) {
  10056. throwError(error, 'websiteOptions');
  10057. }
  10058. };
  10059. const options = websiteOptions;
  10060. const external_keyboardJS_namespaceObject = keyboardJS;
  10061. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10062. const checkUpdate = async (updateLink, auto) => {
  10063. try {
  10064. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10065. const {
  10066. result,
  10067. statusText,
  10068. status,
  10069. data
  10070. } = await tools_httpRequest({
  10071. url: checkUrl,
  10072. responseType: 'json',
  10073. method: 'GET',
  10074. timeout: 3e4
  10075. });
  10076. if (result === 'Success') {
  10077. var _data$response;
  10078. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10079. return data.response;
  10080. }
  10081. if (!auto) {
  10082. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10083. }
  10084. return false;
  10085. }
  10086. if (!auto) {
  10087. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10088. }
  10089. return false;
  10090. } catch (error) {
  10091. throwError(error, 'checkUpdate');
  10092. return false;
  10093. }
  10094. };
  10095. const hasNewVersion = (currentVersion, remoteVersion) => {
  10096. try {
  10097. const [ currentRealVersion ] = currentVersion.split('-');
  10098. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  10099. if (isPreview && !globalOptions.other.receivePreview) {
  10100. return false;
  10101. }
  10102. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10103. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10104. if (remoteVersion1 > currentVersion1) {
  10105. return true;
  10106. }
  10107. if (remoteVersion1 < currentVersion1) {
  10108. return false;
  10109. }
  10110. if (remoteVersion2 > currentVersion2) {
  10111. return true;
  10112. }
  10113. if (remoteVersion2 < currentVersion2) {
  10114. return false;
  10115. }
  10116. if (remoteVersion3 > currentVersion3) {
  10117. return true;
  10118. }
  10119. return false;
  10120. } catch (error) {
  10121. throwError(error, 'compareVersion');
  10122. return false;
  10123. }
  10124. };
  10125. const updateChecker = async () => {
  10126. try {
  10127. const currentVersion = GM_info.script.version;
  10128. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10129. const updateLinks = {
  10130. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10131. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10132. standby: 'https://auto-task-v4.hclonely.com/'
  10133. };
  10134. let version;
  10135. let updateLink = '';
  10136. let packageData;
  10137. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10138. updateLink = updateLinks[updateSource];
  10139. packageData = await checkUpdate(updateLink, false);
  10140. } else {
  10141. updateLink = updateLinks.github;
  10142. packageData = await checkUpdate(updateLink, true);
  10143. if (!packageData) {
  10144. updateLink = updateLinks.jsdelivr;
  10145. packageData = await checkUpdate(updateLink, true);
  10146. if (!packageData) {
  10147. updateLink = updateLinks.standby;
  10148. packageData = await checkUpdate(updateLink, true);
  10149. }
  10150. }
  10151. }
  10152. if (packageData) {
  10153. version = packageData.version || currentVersion;
  10154. } else {
  10155. version = currentVersion;
  10156. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10157. }
  10158. if (packageData && hasNewVersion(currentVersion, version)) {
  10159. var _packageData$change;
  10160. scripts_echoLog({
  10161. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10162. });
  10163. scripts_echoLog({
  10164. 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>`
  10165. });
  10166. }
  10167. } catch (error) {
  10168. throwError(error, 'updateChecker');
  10169. }
  10170. };
  10171. const scripts_updateChecker = updateChecker;
  10172. var _globalOptions$other, _globalOptions$other2;
  10173. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  10174. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  10175. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  10176. const loadScript = async () => {
  10177. var _website, _website2, _website3, _website4, _website5, _website6;
  10178. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10179. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10180. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10181. if (isLogin) {
  10182. var _commonOptions, _commonOptions$header, _commonOptions2, _commonOptions2$heade;
  10183. GM_setValue('twitchAuth', {
  10184. authToken: authToken,
  10185. clientVersion: __twilightBuildID,
  10186. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID'],
  10187. deviceId: (_commonOptions2 = commonOptions) === null || _commonOptions2 === void 0 ? void 0 : (_commonOptions2$heade = _commonOptions2.headers) === null || _commonOptions2$heade === void 0 ? void 0 : _commonOptions2$heade['Device-ID'],
  10188. clientSessionId: window.localStorage.local_storage_app_session_id.replace(/"/g, '')
  10189. });
  10190. window.close();
  10191. external_Swal_default().fire('', i18n('closePageNotice'));
  10192. } else {
  10193. external_Swal_default().fire('', i18n('needLogin'));
  10194. }
  10195. return;
  10196. }
  10197. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10198. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10199. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10200. if (isLogin && ct0) {
  10201. GM_setValue('twitterAuth', {
  10202. ct0: ct0
  10203. });
  10204. window.close();
  10205. external_Swal_default().fire('', i18n('closePageNotice'));
  10206. } else {
  10207. external_Swal_default().fire('', i18n('needLogin'));
  10208. }
  10209. return;
  10210. }
  10211. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10212. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10213. if (PAPISID) {
  10214. GM_setValue('youtubeAuth', {
  10215. PAPISID: PAPISID
  10216. });
  10217. window.close();
  10218. external_Swal_default().fire('', i18n('closePageNotice'));
  10219. } else {
  10220. external_Swal_default().fire('', i18n('needLogin'));
  10221. }
  10222. return;
  10223. }
  10224. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10225. const betaButton = $('#redesign-beta-optin-btn');
  10226. if (betaButton.length > 0) {
  10227. GM_setValue('redditAuth', '#auth');
  10228. return betaButton[0].click();
  10229. }
  10230. GM_setValue('redditAuth', null);
  10231. window.close();
  10232. external_Swal_default().fire('', i18n('closePageNotice'));
  10233. return;
  10234. }
  10235. let website;
  10236. for (const Website of Websites) {
  10237. if (Website.test()) {
  10238. website = new Website();
  10239. break;
  10240. }
  10241. }
  10242. if (!website) {
  10243. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  10244. return;
  10245. }
  10246. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10247. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10248. }
  10249. $('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>`);
  10250. $('div.show-button-div').on('click', () => {
  10251. $('#auto-task-buttons').show();
  10252. $('div.show-button-div').hide();
  10253. });
  10254. const toggleLog = () => {
  10255. const $this = $('#toggle-log');
  10256. const status = $this.attr('data-status');
  10257. if (status === 'show') {
  10258. $('#auto-task-info').hide();
  10259. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10260. } else {
  10261. $('#auto-task-info').show();
  10262. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10263. }
  10264. };
  10265. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10266. if (website.doTask) {
  10267. website.doTask();
  10268. }
  10269. });
  10270. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10271. if (website.undoTask) {
  10272. website.doTask();
  10273. }
  10274. });
  10275. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10276. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10277. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10278. }
  10279. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10280. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10281. for (const button of website.buttons) {
  10282. if (website[button]) {
  10283. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10284. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10285. website[button]();
  10286. });
  10287. $('#auto-task-buttons').append(btnElement);
  10288. }
  10289. }
  10290. }
  10291. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10292. ${i18n('hideButton')}</a></p>`);
  10293. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10294. $('#auto-task-buttons').hide();
  10295. $('div.show-button-div').show();
  10296. });
  10297. 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'}">
  10298. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10299. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10300. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10301. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10302. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10303. options(website.name, website.options);
  10304. });
  10305. }
  10306. if (website.name !== 'Setting') {
  10307. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10308. changeGlobalOptions('swal');
  10309. });
  10310. GM_registerMenuCommand(i18n('settingPage'), () => {
  10311. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10312. });
  10313. }
  10314. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  10315. if (!GM_getValue('notice')) {
  10316. var _echoLog$font;
  10317. external_Swal_default().fire({
  10318. title: i18n('swalNotice'),
  10319. icon: 'warning'
  10320. }).then(() => {
  10321. window.open(i18n('noticeLink'), '_blank');
  10322. GM_setValue('notice', new Date().getTime());
  10323. });
  10324. (_echoLog$font = scripts_echoLog({
  10325. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10326. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10327. GM_setValue('notice', new Date().getTime());
  10328. });
  10329. }
  10330. scripts_updateChecker();
  10331. };
  10332. if (window.location.hostname === 'discord.com') {
  10333. const LocalStorage = window.localStorage;
  10334. if (window.location.hash === '#auth') {
  10335. var _LocalStorage$getItem;
  10336. window.localStorage.removeItem = () => true;
  10337. 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, '');
  10338. if (discordAuth && discordAuth.length > 0) {
  10339. GM_setValue('discordAuth', {
  10340. auth: discordAuth
  10341. });
  10342. window.close();
  10343. external_Swal_default().fire('', i18n('closePageNotice'));
  10344. } else {
  10345. external_Swal_default().fire({
  10346. text: i18n('getDiscordAuthFailed'),
  10347. icon: 'error'
  10348. });
  10349. }
  10350. } else {
  10351. var _LocalStorage$getItem2;
  10352. 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, '');
  10353. if (discordAuth && discordAuth.length > 0) {
  10354. GM_setValue('discordAuth', {
  10355. auth: discordAuth
  10356. });
  10357. }
  10358. }
  10359. } else if (window.location.hostname === 'opquests.com') {
  10360. loadScript();
  10361. } else {
  10362. if (window.location.hostname === 'key-hub.eu') {
  10363. unsafeWindow.keyhubtracker = 1;
  10364. unsafeWindow.gaData = {};
  10365. }
  10366. $(loadScript);
  10367. }
  10368. }();
  10369. })();