auto-task-v4

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

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

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