auto-task-v4

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

当前为 2022-12-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.25
  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. initing: '正在初始化...',
  1200. getFailed: '获取%0失败!',
  1201. checkLoginFailed: '检测登录状态失败!',
  1202. checkLeftKeyFailed: '检测剩余Key失败!',
  1203. userId: '用户Id',
  1204. joiningGiveaway: '正在加入赠Key',
  1205. needJoinGiveaway: '需要先加入赠Key',
  1206. cannotUndo: '此网站不支持取消任务',
  1207. verifyAuth: '正在验证 %0 凭证...',
  1208. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1209. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1210. visitingLink: '正在访问链接: ',
  1211. doTask: '做任务',
  1212. undoTask: '撤销任务',
  1213. verifyTask: '验证任务',
  1214. getKey: '获取Key',
  1215. selectAll: '全选',
  1216. selectNone: '全不选',
  1217. invertSelect: '反选',
  1218. doFreeTask: '加入免费赠品',
  1219. doPointTask: '加入点数赠品',
  1220. skipTaskOption: '设置中已配置跳过任务',
  1221. other: '其他',
  1222. globalOptions: '全局设置',
  1223. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1224. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1225. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1226. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1227. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1228. saveGlobalOptions: '保存全局设置',
  1229. settingPage: '设置页面',
  1230. name: '名称',
  1231. version: '版本',
  1232. scriptManager: '脚本管理器',
  1233. script: '脚本',
  1234. environment: '环境',
  1235. os: '系统',
  1236. browser: '浏览器',
  1237. getId: '获取 %0 id',
  1238. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1239. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1240. showButton: '显示按钮',
  1241. hideButton: '隐藏按钮',
  1242. showLog: '显示日志',
  1243. hideLog: '隐藏日志',
  1244. defaultShowButton: '默认显示按钮',
  1245. defaultShowLog: '默认显示日志',
  1246. debug: '输出调试日志,不要开启此选项!',
  1247. receivePreview: '接收预览版更新',
  1248. position: '组件位置',
  1249. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1250. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1251. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1252. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1253. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1254. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1255. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1256. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1257. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1258. hotKey: '快捷键',
  1259. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1260. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1261. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1262. tasksHistory: '任务历史',
  1263. clearHistory: '清空历史',
  1264. clearHistoryFinished: '已清空任务历史!',
  1265. deleteTask: '删除任务',
  1266. lastChangeTime: '最后一次修改时间',
  1267. clearTaskFinished: '删除以下任务完成!',
  1268. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1269. syncData: '数据同步',
  1270. settingData: '正在上传数据...',
  1271. gettingData: '正在获取数据...',
  1272. help: '帮助',
  1273. fileName: '文件名',
  1274. upload2gist: '同步到Gist',
  1275. downloadFromGist: '从Gist同步',
  1276. saveAndTest: '保存配置并测试',
  1277. testSuccess: '测试成功!',
  1278. testFailed: '测试失败!',
  1279. saveAndTestNotice: '请先保存配置并测试!',
  1280. processingData: '正在处理数据...',
  1281. updatingData: '正在上传数据...',
  1282. syncDataSuccess: '同步数据成功!',
  1283. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1284. downloadingData: '正在下载数据...',
  1285. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1286. savingData: '正在保存数据...',
  1287. syncHistory: '同步任务历史',
  1288. checkUpdateFailed: '检测更新失败',
  1289. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1290. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1291. gistOptions: 'Gist 设置',
  1292. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1293. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1294. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1295. toGithub: '前往Github反馈',
  1296. toKeylol: '前往其乐论坛反馈',
  1297. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1298. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1299. updateText: '%0 版本更新内容:',
  1300. Active: '进行中',
  1301. Ended: '已结束',
  1302. Banned: '已封禁',
  1303. Paused: '已暂停',
  1304. notStart: '未开始',
  1305. noRemoteData: '检测到远程无数据',
  1306. errorRemoteDataFormat: '远程数据格式错误',
  1307. updateHistory: '历史更新记录<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">点此查看</a>',
  1308. groups: '组',
  1309. officialGroups: '官方组',
  1310. wishlists: '愿望单',
  1311. follows: '游戏关注',
  1312. forums: '论坛',
  1313. workshops: '创意工坊收藏',
  1314. curators: '鉴赏家',
  1315. workshopVotes: '创意工坊点赞',
  1316. announcements: '社区通知',
  1317. steamCommunity: 'Steam社区',
  1318. steamStore: 'Steam商店',
  1319. licenses: '入库免费游戏',
  1320. playtests: '请求访问权限',
  1321. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1322. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1323. joiningSteamGroup: '正在加入Steam组',
  1324. leavingSteamGroup: '正在退出Steam组',
  1325. gettingSteamGroupId: '正在获取Steam组Id',
  1326. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1327. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1328. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1329. subscribingForum: '正在订阅Steam论坛',
  1330. unsubscribingForum: '正在取消订阅Steam论坛',
  1331. gettingForumId: '正在获取Steam论坛Id',
  1332. followingCurator: '正在关注Steam鉴赏家',
  1333. unfollowingCurator: '正在取关Steam鉴赏家',
  1334. gettingCuratorId: '正在获取Steam鉴赏家Id',
  1335. addingToWishlist: '正在添加游戏到Steam愿望单',
  1336. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1337. followingGame: '正在关注Steam游戏',
  1338. unfollowingGame: '正在取关Steam游戏',
  1339. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1340. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1341. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1342. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1343. gettingAnnouncementParams: '正在获取Steam通知信息',
  1344. likingAnnouncement: '正在点赞Steam通知',
  1345. changingArea: '正在更换Steam地区: %0...',
  1346. notNeededChangeArea: '当前地区不需要更换',
  1347. noAnotherArea: '请检测是否开启正确开启代理',
  1348. gettingAreaInfo: '正在获取Steam地区信息...',
  1349. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1350. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1351. gettingSubid: '正在获取游戏subid',
  1352. addingFreeLicense: '正在入库',
  1353. missParams: '缺少参数',
  1354. gettingLicenses: '正在获取Licenses...',
  1355. requestingPlayTestAccess: '正在请求访问权限',
  1356. tryChangeAreaNotice: '此功能无法检测游戏是否限区,因此会尝试换区后再入库,换区失败也不影响后续入库',
  1357. servers: '服务器',
  1358. joiningDiscordServer: '正在加入Discord服务器',
  1359. leavingDiscordServer: '正在退出Discord服务器',
  1360. gettingDiscordGuild: '正在获取Discord服务器Id',
  1361. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1362. discordImportantNotice: '重要提醒!!!',
  1363. discordImportantNoticeText: '由于Discord网站后台更新,目前使用此脚本加组后可能会导致Discord帐号被强制退出,且需要两步验证才能正常登录,请谨慎使用!!!',
  1364. continue: '继续',
  1365. skipDiscordTask: '跳过Discord任务',
  1366. continueAndDontRemindAgain: '继续且不再提醒',
  1367. users: '用户',
  1368. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1369. insBanned: '您的Instagram账户已被封禁',
  1370. verifyingInsAuth: '正在验证Instagram凭证...',
  1371. gettingInsUserId: '正在获取Instagram用户Id',
  1372. followingIns: '正在关注Instagram用户',
  1373. unfollowingIns: '正在取关Instagram用户',
  1374. reddits: '社区/用户',
  1375. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1376. changingRedditVersion: '正在切换Reddit为新版页面...',
  1377. joiningReddit: '正在加入Reddit社区',
  1378. leavingReddit: '正在退出Reddit社区',
  1379. followingRedditUser: '正在关注Reddit用户',
  1380. unfollowingRedditUser: '正在取关Reddit用户',
  1381. channels: '频道',
  1382. followingTwitchChannel: '正在关注Twitch频道',
  1383. unfollowingTwitchChannel: '正在取关Twitch频道',
  1384. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1385. checkingTwitchIntegrity: '正在检查Twitch完整性...',
  1386. twitterUser: '推特用户',
  1387. retweets: '转推',
  1388. gettingTwitterUserId: '正在获取推特用户Id',
  1389. followingTwitterUser: '正在关注推特用户',
  1390. unfollowingTwitterUser: '正在取关推特用户',
  1391. retweetting: '正在转推',
  1392. unretweetting: '正在撤销转推',
  1393. names: '组/社区/动态',
  1394. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1395. gettingVkId: '正在获取Vk任务Id',
  1396. joiningVkGroup: '正在加入Vk组',
  1397. leavingVkGroup: '正在退出Vk组',
  1398. joiningVkPublic: '正在加入Vk社区',
  1399. leavingVkPublic: '正在退出Vk社区',
  1400. sendingVkWall: '正在转发Vk动态',
  1401. deletingVkWall: '正在撤销转发Vk动态',
  1402. youtubeChannel: 'YouTube频道',
  1403. likes: '点赞',
  1404. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1405. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1406. gettingYtbToken: '正在获取YouTube Token...',
  1407. followingYtbChannel: '正在订阅YouTube频道',
  1408. unfollowingYtbChannel: '正在退订YouTube频道',
  1409. likingYtbVideo: '正在点赞YouTube视频',
  1410. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1411. giveKeyNoticeBefore: '每次验证间隔15s',
  1412. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1413. noPoints: '点数不够,跳过抽奖',
  1414. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1415. joiningLottery: '正在加入抽奖',
  1416. doingGleamTask: '正在做Gleam任务...',
  1417. gettingGleamLink: '正在获取Gleam任务链接...',
  1418. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1419. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1420. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1421. giveeClubVerifyNotice: '正在验证任务...',
  1422. giveeClubVerifyFinished: '请等待验证完成后自行加入赠Key',
  1423. doingKeyhubTask: '正在做Keyhub任务...',
  1424. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1425. };
  1426. const zh_CN = data;
  1427. const en_US_data = {
  1428. website: 'Website',
  1429. type: 'Type',
  1430. edit: 'Edit',
  1431. whiteList: 'Whitelist',
  1432. skipTask: 'Skip undo task',
  1433. whiteListOptions: 'Whitelist options',
  1434. changeWhiteListOption: 'Whitelist option(%0)',
  1435. whiteListNotFound: 'Cannot find this whitelist: %0',
  1436. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1437. changeWebsiteOptions: 'Website options',
  1438. changeGlobalOptions: 'Global options',
  1439. ok: 'OK',
  1440. save: 'Save',
  1441. close: 'Close',
  1442. return: 'Return',
  1443. option: 'Option',
  1444. value: 'Value',
  1445. websiteOptions: 'Current website settings',
  1446. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1447. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1448. needLogin: 'Please log in first!',
  1449. getTasksInfo: 'Obtaining and processing task information...',
  1450. gettingKey: 'Getting Key...',
  1451. verifyingTask: 'Verifying task',
  1452. notice: 'Automatic task script notice',
  1453. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1454. giveawayEnded: 'This event has ended, do you want to close it?',
  1455. 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?',
  1456. confirm: 'Confirm',
  1457. cancel: 'Cancel',
  1458. unKnown: 'Unknown',
  1459. unKnownTaskType: 'Unrecognized task',
  1460. doing: 'Doing a task',
  1461. allTasksComplete: 'All tasks have been completed!',
  1462. getTaskIdFailed: 'Failed to obtain task Id!',
  1463. initSuccess: '%0 was initialized successfully!',
  1464. initFailed: '%0 initialization failed!',
  1465. errorLink: 'Link error: %0',
  1466. needInit: 'Please initialize first',
  1467. verifyingAuth: 'Verifying %0 token...',
  1468. updatingAuth: 'Update %0 token...',
  1469. initing: 'Initializing...',
  1470. getFailed: 'Failed to get %0!',
  1471. checkLoginFailed: 'Failed to detect login status!',
  1472. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1473. userId: 'User Id',
  1474. joiningGiveaway: 'Joining giveaway',
  1475. needJoinGiveaway: 'Need to join the giveaway first',
  1476. cannotUndo: 'This website does not support canceling tasks',
  1477. verifyAuth: 'Verifying %0 token...',
  1478. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1479. errorReport: 'A script error is detected, do you want to report the BUG?',
  1480. visitingLink: 'Visiting link: ',
  1481. doTask: 'DoTask',
  1482. undoTask: 'UndoTask',
  1483. verifyTask: 'Verify',
  1484. getKey: 'GetKey',
  1485. selectAll: 'SelectAll',
  1486. selectNone: 'SelectNone',
  1487. invertSelect: 'InvertSelect',
  1488. doFreeTask: 'FreeTask',
  1489. doPointTask: 'PointTask',
  1490. skipTaskOption: 'Skip task has been configured in the settings',
  1491. other: 'Other',
  1492. globalOptions: 'Global Options',
  1493. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1494. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1495. 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.',
  1496. 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.',
  1497. 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.',
  1498. saveGlobalOptions: 'SaveSettings',
  1499. settingPage: 'Setting Page',
  1500. name: 'Name',
  1501. version: 'Version',
  1502. scriptManager: 'Script Manager',
  1503. script: 'Script',
  1504. environment: 'Environment',
  1505. os: 'OS',
  1506. browser: 'Browser',
  1507. getId: 'Get %0 id',
  1508. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1509. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1510. showButton: 'ShowButton',
  1511. hideButton: 'HideButton',
  1512. showLog: 'ShowLog',
  1513. hideLog: 'HideLog',
  1514. defaultShowButton: 'Default display button',
  1515. defaultShowLog: 'Display log by default',
  1516. debug: 'Output debug log, do not enable this option!',
  1517. receivePreview: 'Receive preview updates',
  1518. position: 'Component position',
  1519. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1520. 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',
  1521. 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',
  1522. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1523. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1524. 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',
  1525. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1526. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1527. 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',
  1528. hotKey: 'Shortcut key',
  1529. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1530. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1531. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1532. tasksHistory: 'TasksHistory',
  1533. clearHistory: 'Clear history',
  1534. clearHistoryFinished: 'The mission history has been cleared!',
  1535. deleteTask: 'Delete task',
  1536. lastChangeTime: 'Last Change Time',
  1537. clearTaskFinished: 'Delete the following tasks completed!',
  1538. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1539. syncData: 'DataSync',
  1540. settingData: 'Uploading data...',
  1541. gettingData: 'Getting data...',
  1542. help: 'Help',
  1543. fileName: 'Filename',
  1544. upload2gist: 'Sync to Gist',
  1545. downloadFromGist: 'Sync from Gist',
  1546. saveAndTest: 'Save configuration and test',
  1547. testSuccess: 'Test success!',
  1548. testFailed: 'Test failed!',
  1549. saveAndTestNotice: 'Please save the configuration and test first!',
  1550. processingData: 'Processing data...',
  1551. updatingData: 'Uploading data...',
  1552. syncDataSuccess: 'Synchronized data successfully!',
  1553. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1554. downloadingData: 'Downloading data...',
  1555. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1556. savingData: 'Saving data...',
  1557. syncHistory: 'Synchronize tasks history',
  1558. checkUpdateFailed: 'Check update failed',
  1559. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1560. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1561. gistOptions: 'Gist Settings',
  1562. 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!',
  1563. 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!',
  1564. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1565. toGithub: 'Feedback(Github)',
  1566. toKeylol: 'Feedback(Keylol)',
  1567. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1568. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1569. updateText: 'Updates in version %0:',
  1570. Active: 'Active',
  1571. Ended: 'Ended',
  1572. Banned: 'Banned',
  1573. Paused: 'Paused',
  1574. notStart: 'notStart',
  1575. noRemoteData: 'No data remotely',
  1576. errorRemoteDataFormat: 'Remote data has wrong format',
  1577. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1578. groups: 'Group',
  1579. officialGroups: 'Official Group',
  1580. wishlists: 'Wishlist',
  1581. follows: 'Follow Game',
  1582. forums: 'Forum',
  1583. workshops: 'Favorite Workshop',
  1584. curators: 'Curator',
  1585. workshopVotes: 'Voteup Workshop',
  1586. announcements: 'Announcement',
  1587. steamCommunity: 'Steam Community',
  1588. steamStore: 'Steam Store',
  1589. licenses: 'Add License',
  1590. playtests: 'Playtest Access',
  1591. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1592. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1593. joiningSteamGroup: 'Joining Steam Group',
  1594. leavingSteamGroup: 'Leaving Steam Group',
  1595. gettingSteamGroupId: 'Getting Steam Group Id',
  1596. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1597. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1598. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1599. subscribingForum: 'Subscribing the Steam Forum',
  1600. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1601. gettingForumId: 'Getting Steam Forum Id',
  1602. followingCurator: 'Following Steam Curator',
  1603. unfollowingCurator: 'Unfollowing Steam Curator',
  1604. gettingCuratorId: 'Getting Steam Curator Id',
  1605. addingToWishlist: 'Adding the game to the Steam wishlist',
  1606. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1607. followingGame: 'Following Steam games',
  1608. unfollowingGame: 'Unfollowing Steam games',
  1609. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1610. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1611. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1612. votingUpWorkshop: 'Liking Steam workshop items',
  1613. gettingAnnouncementParams: 'Getting Steam announcement information',
  1614. likingAnnouncement: 'Liking Steam announcement',
  1615. changingArea: 'Changing Steam area: %0...',
  1616. notNeededChangeArea: 'The current area does not need to be changed',
  1617. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1618. gettingAreaInfo: 'Getting Steam area information...',
  1619. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1620. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1621. gettingSubid: 'Getting subid',
  1622. addingFreeLicense: 'Adding free license',
  1623. missParams: 'Missing parameters',
  1624. gettingLicenses: 'Getting licenses...',
  1625. requestingPlayTestAccess: 'Requesting play test access',
  1626. 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.',
  1627. servers: 'Server',
  1628. joiningDiscordServer: 'Joining Discord Server',
  1629. leavingDiscordServer: 'Leaving Discord Server',
  1630. gettingDiscordGuild: 'Getting Discord server Id',
  1631. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1632. discordImportantNotice: 'Important Reminder! ! !',
  1633. 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! ! !',
  1634. continue: 'Continue',
  1635. skipDiscordTask: 'Skip',
  1636. continueAndDontRemindAgain: 'Continue without Reminders',
  1637. users: 'User',
  1638. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1639. insBanned: 'Your Instagram account has been banned',
  1640. verifyingInsAuth: 'Verifying Instagram token...',
  1641. gettingInsUserId: 'Getting Instagram user Id',
  1642. followingIns: 'Following Instagram user',
  1643. unfollowingIns: 'Unfollowing Instagram user',
  1644. reddits: 'Reddit/User',
  1645. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1646. changingRedditVersion: 'Switching Reddit to a new version page...',
  1647. joiningReddit: 'Joining the Reddit',
  1648. leavingReddit: 'Leaving the Reddit',
  1649. followingRedditUser: 'Following Reddit User',
  1650. unfollowingRedditUser: 'Unfollowing Reddit User',
  1651. channels: 'Channel',
  1652. followingTwitchChannel: 'Following Twitch Channel',
  1653. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1654. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1655. checkingTwitchIntegrity: 'Checking Twitch integrity...',
  1656. twitterUser: 'Twitter User',
  1657. retweets: 'Retweet',
  1658. gettingTwitterUserId: 'Getting Twitter User Id',
  1659. followingTwitterUser: 'Following Twitter User',
  1660. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1661. retweetting: 'Retweetting',
  1662. unretweetting: 'Unretweetting',
  1663. names: 'Group/Public/Wall',
  1664. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1665. gettingVkId: 'Getting Vk task Id',
  1666. joiningVkGroup: 'Joining Vk Group',
  1667. leavingVkGroup: 'Leaving Vk Group',
  1668. joiningVkPublic: 'Joining Vk Public',
  1669. leavingVkPublic: 'Leaving Vk Public',
  1670. sendingVkWall: 'Sending Vk Wall',
  1671. deletingVkWall: 'Deleting Vk Wall',
  1672. youtubeChannel: 'YouTube Channel',
  1673. likes: 'Like',
  1674. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1675. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1676. gettingYtbToken: 'Getting YouTube Token...',
  1677. followingYtbChannel: 'Subscribing to YouTube channel',
  1678. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1679. likingYtbVideo: 'Liking YouTube video',
  1680. unlikingYtbVideo: 'Unliking YouTube video',
  1681. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1682. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1683. noPoints: 'Not enough points, skip the lottery',
  1684. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1685. joiningLottery: 'Joining the lottery',
  1686. doingGleamTask: 'Doing Gleam Task...',
  1687. gettingGleamLink: 'Getting Gleam task link...',
  1688. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1689. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1690. 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!',
  1691. giveeClubVerifyNotice: 'Verifying task...',
  1692. giveeClubVerifyFinished: 'Wait for the verification to complete and join it by yourself',
  1693. doingKeyhubTask: 'Doing Keyhub Task...',
  1694. 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...'
  1695. };
  1696. const en_US = en_US_data;
  1697. const languages = {
  1698. zh: zh_CN,
  1699. en: en_US
  1700. };
  1701. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1702. const I18n = function(key) {
  1703. var _languages$language;
  1704. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1705. argvs[_key - 1] = arguments[_key];
  1706. }
  1707. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1708. return key;
  1709. }
  1710. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1711. };
  1712. const i18n = I18n;
  1713. function throwError(error, name) {
  1714. if (window.TRACE) {
  1715. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1716. }
  1717. external_Swal_default().fire({
  1718. title: i18n('errorReport'),
  1719. icon: 'error',
  1720. showCancelButton: true,
  1721. confirmButtonText: i18n('toGithub'),
  1722. showDenyButton: true,
  1723. denyButtonText: i18n('toKeylol'),
  1724. cancelButtonText: i18n('close')
  1725. }).then(_ref => {
  1726. let {
  1727. isDenied,
  1728. isConfirmed
  1729. } = _ref;
  1730. if (isConfirmed) {
  1731. 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,
  1732. 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');
  1733. } else if (isDenied) {
  1734. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1735.  
  1736. 环境:
  1737.  
  1738. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1739.  
  1740. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1741. 脚本版本: ${GM_info.script.version}
  1742.  
  1743. 报错信息:
  1744. [code]${error.stack}[/code]
  1745.  
  1746. 执行日志:
  1747. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1748. GM_setClipboard(text);
  1749. external_Swal_default().fire({
  1750. title: i18n('copySuccess'),
  1751. icon: 'success',
  1752. confirmButtonText: i18n('ok')
  1753. }).then(() => {
  1754. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1755. });
  1756. }
  1757. });
  1758. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1759. }
  1760. function _defineProperty(obj, key, value) {
  1761. if (key in obj) {
  1762. Object.defineProperty(obj, key, {
  1763. value: value,
  1764. enumerable: true,
  1765. configurable: true,
  1766. writable: true
  1767. });
  1768. } else {
  1769. obj[key] = value;
  1770. }
  1771. return obj;
  1772. }
  1773. class Social {
  1774. constructor() {
  1775. _defineProperty(this, 'tasks', void 0);
  1776. }
  1777. getRealParams(name, links, doTask, link2param) {
  1778. try {
  1779. let realParams = [];
  1780. if (links.length > 0) {
  1781. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1782. }
  1783. if (!doTask && this.tasks[name].length > 0) {
  1784. realParams = [ ...realParams, ...this.tasks[name] ];
  1785. }
  1786. return unique(realParams);
  1787. } catch (error) {
  1788. throwError(error, 'Social.getRealParams');
  1789. return [];
  1790. }
  1791. }
  1792. }
  1793. const social_Social = Social;
  1794. function _classPrivateMethodInitSpec(obj, privateSet) {
  1795. _checkPrivateRedeclaration(obj, privateSet);
  1796. privateSet.add(obj);
  1797. }
  1798. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1799. _checkPrivateRedeclaration(obj, privateMap);
  1800. privateMap.set(obj, value);
  1801. }
  1802. function _checkPrivateRedeclaration(obj, privateCollection) {
  1803. if (privateCollection.has(obj)) {
  1804. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1805. }
  1806. }
  1807. function Discord_defineProperty(obj, key, value) {
  1808. if (key in obj) {
  1809. Object.defineProperty(obj, key, {
  1810. value: value,
  1811. enumerable: true,
  1812. configurable: true,
  1813. writable: true
  1814. });
  1815. } else {
  1816. obj[key] = value;
  1817. }
  1818. return obj;
  1819. }
  1820. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1821. if (!privateSet.has(receiver)) {
  1822. throw new TypeError('attempted to get private field on non-instance');
  1823. }
  1824. return fn;
  1825. }
  1826. function _classPrivateFieldGet(receiver, privateMap) {
  1827. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1828. return _classApplyDescriptorGet(receiver, descriptor);
  1829. }
  1830. function _classApplyDescriptorGet(receiver, descriptor) {
  1831. if (descriptor.get) {
  1832. return descriptor.get.call(receiver);
  1833. }
  1834. return descriptor.value;
  1835. }
  1836. function _classPrivateFieldSet(receiver, privateMap, value) {
  1837. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1838. _classApplyDescriptorSet(receiver, descriptor, value);
  1839. return value;
  1840. }
  1841. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1842. if (!privateMap.has(receiver)) {
  1843. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1844. }
  1845. return privateMap.get(receiver);
  1846. }
  1847. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1848. if (descriptor.set) {
  1849. descriptor.set.call(receiver, value);
  1850. } else {
  1851. if (!descriptor.writable) {
  1852. throw new TypeError('attempted to set read only private field');
  1853. }
  1854. descriptor.value = value;
  1855. }
  1856. }
  1857. const defaultTasksTemplate = {
  1858. servers: []
  1859. };
  1860. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1861. var _auth = new WeakMap();
  1862. var _cache = new WeakMap();
  1863. var _initialized = new WeakMap();
  1864. var _verifyAuth = new WeakSet();
  1865. var _updateAuth = new WeakSet();
  1866. var _joinServer = new WeakSet();
  1867. var _leaveServer = new WeakSet();
  1868. var _getGuild = new WeakSet();
  1869. var _setCache = new WeakSet();
  1870. class Discord extends social_Social {
  1871. constructor() {
  1872. var _GM_getValue;
  1873. super(...arguments);
  1874. _classPrivateMethodInitSpec(this, _setCache);
  1875. _classPrivateMethodInitSpec(this, _getGuild);
  1876. _classPrivateMethodInitSpec(this, _leaveServer);
  1877. _classPrivateMethodInitSpec(this, _joinServer);
  1878. _classPrivateMethodInitSpec(this, _updateAuth);
  1879. _classPrivateMethodInitSpec(this, _verifyAuth);
  1880. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1881. Discord_defineProperty(this, 'whiteList', {
  1882. ...JSON.parse(defaultTasks),
  1883. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1884. });
  1885. _classPrivateFieldInitSpec(this, _auth, {
  1886. writable: true,
  1887. value: GM_getValue('discordAuth') || {}
  1888. });
  1889. _classPrivateFieldInitSpec(this, _cache, {
  1890. writable: true,
  1891. value: GM_getValue('discordCache') || {}
  1892. });
  1893. _classPrivateFieldInitSpec(this, _initialized, {
  1894. writable: true,
  1895. value: false
  1896. });
  1897. }
  1898. async init() {
  1899. try {
  1900. if (!GM_getValue('dontRemindDiscordAgain')) {
  1901. const result = await external_Swal_default().fire({
  1902. title: i18n('discordImportantNotice'),
  1903. text: i18n('discordImportantNoticeText'),
  1904. showCancelButton: true,
  1905. showDenyButton: true,
  1906. confirmButtonText: i18n('continue'),
  1907. cancelButtonText: i18n('skipDiscordTask'),
  1908. denyButtonText: i18n('continueAndDontRemindAgain')
  1909. }).then(_ref => {
  1910. let {
  1911. isConfirmed,
  1912. isDenied
  1913. } = _ref;
  1914. if (isConfirmed) {
  1915. return true;
  1916. }
  1917. if (isDenied) {
  1918. GM_setValue('dontRemindDiscordAgain', true);
  1919. return true;
  1920. }
  1921. return false;
  1922. });
  1923. if (!result) {
  1924. _classPrivateFieldSet(this, _initialized, false);
  1925. return 'skip';
  1926. }
  1927. }
  1928. if (_classPrivateFieldGet(this, _initialized)) {
  1929. return true;
  1930. }
  1931. if (!_classPrivateFieldGet(this, _auth).auth) {
  1932. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1933. _classPrivateFieldSet(this, _initialized, true);
  1934. return true;
  1935. }
  1936. return false;
  1937. }
  1938. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1939. if (isVerified) {
  1940. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1941. _classPrivateFieldSet(this, _initialized, true);
  1942. return true;
  1943. }
  1944. GM_setValue('discordAuth', {
  1945. auth: null
  1946. });
  1947. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1948. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1949. _classPrivateFieldSet(this, _initialized, true);
  1950. return true;
  1951. }
  1952. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1953. return false;
  1954. } catch (error) {
  1955. throwError(error, 'Discord.init');
  1956. return false;
  1957. }
  1958. }
  1959. async toggle(_ref2) {
  1960. let {
  1961. doTask = true,
  1962. serverLinks = []
  1963. } = _ref2;
  1964. try {
  1965. if (!_classPrivateFieldGet(this, _initialized)) {
  1966. scripts_echoLog({
  1967. text: i18n('needInit')
  1968. });
  1969. return false;
  1970. }
  1971. const prom = [];
  1972. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1973. scripts_echoLog({
  1974. type: 'globalOptionsSkip',
  1975. text: 'discord.servers'
  1976. });
  1977. } else {
  1978. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1979. var _link$match;
  1980. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1981. });
  1982. if (realServers.length > 0) {
  1983. for (const server of realServers) {
  1984. if (doTask) {
  1985. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1986. } else {
  1987. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1988. }
  1989. await delay(1e3);
  1990. }
  1991. }
  1992. }
  1993. return await Promise.all(prom).then(() => true);
  1994. } catch (error) {
  1995. throwError(error, 'Discord.toggleServers');
  1996. return false;
  1997. }
  1998. }
  1999. }
  2000. async function _verifyAuth2() {
  2001. try {
  2002. const logStatus = scripts_echoLog({
  2003. text: i18n('verifyingAuth', 'Discord')
  2004. });
  2005. const {
  2006. result,
  2007. statusText,
  2008. status,
  2009. data
  2010. } = await tools_httpRequest({
  2011. url: 'https://discord.com/api/v6/users/@me',
  2012. method: 'HEAD',
  2013. headers: {
  2014. authorization: _classPrivateFieldGet(this, _auth).auth
  2015. }
  2016. });
  2017. if (result === 'Success') {
  2018. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2019. logStatus.success();
  2020. return true;
  2021. }
  2022. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2023. return false;
  2024. }
  2025. logStatus.error(`${result}:${statusText}(${status})`);
  2026. return false;
  2027. } catch (error) {
  2028. throwError(error, 'Discord.verifyAuth');
  2029. return false;
  2030. }
  2031. }
  2032. async function _updateAuth2() {
  2033. try {
  2034. const logStatus = scripts_echoLog({
  2035. text: i18n('updatingAuth', 'Discord')
  2036. });
  2037. return await new Promise(resolve => {
  2038. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  2039. active: true,
  2040. insert: true,
  2041. setParent: true
  2042. });
  2043. newTab.onclose = async () => {
  2044. var _GM_getValue2;
  2045. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  2046. if (auth) {
  2047. _classPrivateFieldSet(this, _auth, {
  2048. auth: auth
  2049. });
  2050. logStatus.success();
  2051. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  2052. } else {
  2053. logStatus.error('Error: Update discord auth failed!');
  2054. resolve(false);
  2055. }
  2056. };
  2057. });
  2058. } catch (error) {
  2059. throwError(error, 'Discord.updateAuth');
  2060. return false;
  2061. }
  2062. }
  2063. async function _joinServer2(inviteId) {
  2064. try {
  2065. const logStatus = scripts_echoLog({
  2066. type: 'joiningDiscordServer',
  2067. text: inviteId
  2068. });
  2069. const {
  2070. result,
  2071. statusText,
  2072. status,
  2073. data
  2074. } = await tools_httpRequest({
  2075. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2076. method: 'POST',
  2077. dataType: 'json',
  2078. headers: {
  2079. authorization: _classPrivateFieldGet(this, _auth).auth,
  2080. origin: 'https://discord.com',
  2081. referer: `https://discord.com/invite/${inviteId}`
  2082. }
  2083. });
  2084. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2085. var _data$response, _data$response$guild;
  2086. logStatus.success();
  2087. 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);
  2088. if (guild) {
  2089. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2090. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2091. }
  2092. return true;
  2093. }
  2094. logStatus.error(`${result}:${statusText}(${status})`);
  2095. return false;
  2096. } catch (error) {
  2097. throwError(error, 'Discord.joinServer');
  2098. return false;
  2099. }
  2100. }
  2101. async function _leaveServer2(inviteId) {
  2102. try {
  2103. if (this.whiteList.servers.includes(inviteId)) {
  2104. scripts_echoLog({
  2105. type: 'whiteList',
  2106. text: 'Discord.leaveServer',
  2107. id: inviteId
  2108. });
  2109. return true;
  2110. }
  2111. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2112. if (!guild) {
  2113. return false;
  2114. }
  2115. const logStatus = scripts_echoLog({
  2116. type: 'leavingDiscordServer',
  2117. text: guild
  2118. });
  2119. const {
  2120. result,
  2121. statusText,
  2122. status,
  2123. data
  2124. } = await tools_httpRequest({
  2125. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2126. method: 'DELETE',
  2127. headers: {
  2128. authorization: _classPrivateFieldGet(this, _auth).auth
  2129. }
  2130. });
  2131. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2132. logStatus.success();
  2133. return true;
  2134. }
  2135. logStatus.error(`${result}:${statusText}(${status})`);
  2136. return false;
  2137. } catch (error) {
  2138. throwError(error, 'Discord.leaveServer');
  2139. return false;
  2140. }
  2141. }
  2142. async function _getGuild2(inviteId) {
  2143. try {
  2144. const logStatus = scripts_echoLog({
  2145. type: 'gettingDiscordGuild',
  2146. text: inviteId
  2147. });
  2148. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2149. if (guild) {
  2150. logStatus.success();
  2151. return guild;
  2152. }
  2153. const {
  2154. result,
  2155. statusText,
  2156. status,
  2157. data
  2158. } = await tools_httpRequest({
  2159. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2160. responseType: 'json',
  2161. method: 'GET'
  2162. });
  2163. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2164. var _data$response2, _data$response2$guild;
  2165. 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;
  2166. if (guild) {
  2167. logStatus.success();
  2168. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2169. return guild;
  2170. }
  2171. logStatus.error(`${result}:${statusText}(${status})`);
  2172. return false;
  2173. }
  2174. logStatus.error(`${result}:${statusText}(${status})`);
  2175. return false;
  2176. } catch (error) {
  2177. throwError(error, 'Discord.getGuild');
  2178. return false;
  2179. }
  2180. }
  2181. function _setCache2(inviteId, guild) {
  2182. try {
  2183. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2184. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2185. } catch (error) {
  2186. throwError(error, 'Discord.setCache');
  2187. }
  2188. }
  2189. const social_Discord = Discord;
  2190. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2191. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2192. privateSet.add(obj);
  2193. }
  2194. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2195. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2196. privateMap.set(obj, value);
  2197. }
  2198. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2199. if (privateCollection.has(obj)) {
  2200. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2201. }
  2202. }
  2203. function Instagram_defineProperty(obj, key, value) {
  2204. if (key in obj) {
  2205. Object.defineProperty(obj, key, {
  2206. value: value,
  2207. enumerable: true,
  2208. configurable: true,
  2209. writable: true
  2210. });
  2211. } else {
  2212. obj[key] = value;
  2213. }
  2214. return obj;
  2215. }
  2216. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2217. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2218. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2219. return value;
  2220. }
  2221. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2222. if (descriptor.set) {
  2223. descriptor.set.call(receiver, value);
  2224. } else {
  2225. if (!descriptor.writable) {
  2226. throw new TypeError('attempted to set read only private field');
  2227. }
  2228. descriptor.value = value;
  2229. }
  2230. }
  2231. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2232. if (!privateSet.has(receiver)) {
  2233. throw new TypeError('attempted to get private field on non-instance');
  2234. }
  2235. return fn;
  2236. }
  2237. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2238. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2239. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2240. }
  2241. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2242. if (!privateMap.has(receiver)) {
  2243. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2244. }
  2245. return privateMap.get(receiver);
  2246. }
  2247. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2248. if (descriptor.get) {
  2249. return descriptor.get.call(receiver);
  2250. }
  2251. return descriptor.value;
  2252. }
  2253. const Instagram_defaultTasksTemplate = {
  2254. users: []
  2255. };
  2256. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2257. var Instagram_cache = new WeakMap();
  2258. var Instagram_auth = new WeakMap();
  2259. var Instagram_initialized = new WeakMap();
  2260. var _getUserInfo = new WeakSet();
  2261. var _followUser = new WeakSet();
  2262. var _unfollowUser = new WeakSet();
  2263. var Instagram_setCache = new WeakSet();
  2264. class Instagram extends social_Social {
  2265. constructor() {
  2266. var _GM_getValue;
  2267. super(...arguments);
  2268. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2269. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2270. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2271. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2272. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2273. Instagram_defineProperty(this, 'whiteList', {
  2274. ...JSON.parse(Instagram_defaultTasks),
  2275. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2276. });
  2277. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2278. writable: true,
  2279. value: GM_getValue('instagramCache') || {}
  2280. });
  2281. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2282. writable: true,
  2283. value: {}
  2284. });
  2285. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2286. writable: true,
  2287. value: false
  2288. });
  2289. }
  2290. async init() {
  2291. try {
  2292. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2293. return true;
  2294. }
  2295. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2296. if (isVerified) {
  2297. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2298. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2299. return true;
  2300. }
  2301. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2302. return false;
  2303. } catch (error) {
  2304. throwError(error, 'Instagram.init');
  2305. return false;
  2306. }
  2307. }
  2308. async toggle(_ref) {
  2309. let {
  2310. doTask = true,
  2311. userLinks = []
  2312. } = _ref;
  2313. try {
  2314. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2315. scripts_echoLog({
  2316. text: i18n('needInit')
  2317. });
  2318. return false;
  2319. }
  2320. const prom = [];
  2321. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2322. scripts_echoLog({
  2323. type: 'globalOptionsSkip',
  2324. text: 'instagram.users'
  2325. });
  2326. } else {
  2327. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2328. var _link$match;
  2329. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2330. });
  2331. if (realUsers.length > 0) {
  2332. for (const username of realUsers) {
  2333. if (doTask) {
  2334. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2335. } else {
  2336. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2337. }
  2338. await delay(1e3);
  2339. }
  2340. }
  2341. }
  2342. return await Promise.all(prom).then(() => true);
  2343. } catch (error) {
  2344. throwError(error, 'Instagram.toggleUsers');
  2345. return false;
  2346. }
  2347. }
  2348. }
  2349. async function _getUserInfo2() {
  2350. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2351. try {
  2352. const logStatus = scripts_echoLog({
  2353. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2354. text: name
  2355. });
  2356. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2357. if (userId && name !== 'instagram') {
  2358. logStatus.success();
  2359. return userId;
  2360. }
  2361. const {
  2362. result,
  2363. statusText,
  2364. status,
  2365. data
  2366. } = await tools_httpRequest({
  2367. url: `https://www.instagram.com/${name}/`,
  2368. method: 'GET'
  2369. });
  2370. if (result === 'Success') {
  2371. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2372. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2373. return false;
  2374. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2375. logStatus.error(`Error:${i18n('insBanned')}`);
  2376. return false;
  2377. }
  2378. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2379. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2380. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2381. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2382. if (name === 'instagram') {
  2383. if (csrftoken && hash) {
  2384. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2385. csrftoken: csrftoken,
  2386. hash: hash
  2387. });
  2388. return true;
  2389. }
  2390. return false;
  2391. }
  2392. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2393. if (id) {
  2394. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2395. logStatus.success();
  2396. return id;
  2397. }
  2398. logStatus.error('Error: Get ins data error!');
  2399. return false;
  2400. }
  2401. logStatus.error(`${result}:${statusText}(${status})`);
  2402. return false;
  2403. }
  2404. return false;
  2405. } catch (error) {
  2406. throwError(error, 'Instagram.getUserInfo');
  2407. return false;
  2408. }
  2409. }
  2410. async function _followUser2(name) {
  2411. try {
  2412. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2413. if (!id) {
  2414. return false;
  2415. }
  2416. const logStatus = scripts_echoLog({
  2417. type: 'followingIns',
  2418. text: name
  2419. });
  2420. const {
  2421. result,
  2422. statusText,
  2423. status,
  2424. data
  2425. } = await tools_httpRequest({
  2426. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2427. method: 'POST',
  2428. dataType: 'json',
  2429. headers: {
  2430. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2431. origin: 'https://www.instagram.com',
  2432. referer: `https://www.instagram.com/${name}/`,
  2433. 'content-type': 'application/x-www-form-urlencoded',
  2434. 'sec-fetch-site': 'same-origin',
  2435. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2436. }
  2437. });
  2438. if (result === 'Success') {
  2439. var _data$response, _data$response2;
  2440. 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') {
  2441. logStatus.success();
  2442. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2443. return true;
  2444. }
  2445. 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})`}`);
  2446. return false;
  2447. }
  2448. logStatus.error(`${result}:${statusText}(${status})`);
  2449. return false;
  2450. } catch (error) {
  2451. throwError(error, 'Instagram.followUser');
  2452. return false;
  2453. }
  2454. }
  2455. async function _unfollowUser2(name) {
  2456. try {
  2457. if (this.whiteList.users.includes(name)) {
  2458. scripts_echoLog({
  2459. type: 'whiteList',
  2460. text: 'Instagram.unfollowUser',
  2461. id: name
  2462. });
  2463. return true;
  2464. }
  2465. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2466. if (!id) {
  2467. return false;
  2468. }
  2469. const logStatus = scripts_echoLog({
  2470. type: 'unfollowingIns',
  2471. text: name
  2472. });
  2473. const {
  2474. result,
  2475. statusText,
  2476. status,
  2477. data
  2478. } = await tools_httpRequest({
  2479. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2480. method: 'POST',
  2481. dataType: 'json',
  2482. headers: {
  2483. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2484. origin: 'https://www.instagram.com',
  2485. referer: `https://www.instagram.com/${name}/`,
  2486. 'content-type': 'application/x-www-form-urlencoded',
  2487. 'sec-fetch-site': 'same-origin',
  2488. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2489. }
  2490. });
  2491. if (result === 'Success') {
  2492. var _data$response3;
  2493. 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') {
  2494. logStatus.success();
  2495. return true;
  2496. }
  2497. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2498. return false;
  2499. }
  2500. logStatus.error(`${result}:${statusText}(${status})`);
  2501. return false;
  2502. } catch (error) {
  2503. throwError(error, 'Instagram.unfollowUser');
  2504. return false;
  2505. }
  2506. }
  2507. function Instagram_setCache2(name, id) {
  2508. try {
  2509. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2510. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2511. } catch (error) {
  2512. throwError(error, 'Instagram.setCache');
  2513. }
  2514. }
  2515. const social_Instagram = Instagram;
  2516. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2517. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2518. privateSet.add(obj);
  2519. }
  2520. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2521. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2522. privateMap.set(obj, value);
  2523. }
  2524. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2525. if (privateCollection.has(obj)) {
  2526. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2527. }
  2528. }
  2529. function Reddit_defineProperty(obj, key, value) {
  2530. if (key in obj) {
  2531. Object.defineProperty(obj, key, {
  2532. value: value,
  2533. enumerable: true,
  2534. configurable: true,
  2535. writable: true
  2536. });
  2537. } else {
  2538. obj[key] = value;
  2539. }
  2540. return obj;
  2541. }
  2542. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2543. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2544. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2545. return value;
  2546. }
  2547. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2548. if (descriptor.set) {
  2549. descriptor.set.call(receiver, value);
  2550. } else {
  2551. if (!descriptor.writable) {
  2552. throw new TypeError('attempted to set read only private field');
  2553. }
  2554. descriptor.value = value;
  2555. }
  2556. }
  2557. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2558. if (!privateSet.has(receiver)) {
  2559. throw new TypeError('attempted to get private field on non-instance');
  2560. }
  2561. return fn;
  2562. }
  2563. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2564. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2565. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2566. }
  2567. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2568. if (!privateMap.has(receiver)) {
  2569. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2570. }
  2571. return privateMap.get(receiver);
  2572. }
  2573. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2574. if (descriptor.get) {
  2575. return descriptor.get.call(receiver);
  2576. }
  2577. return descriptor.value;
  2578. }
  2579. const Reddit_defaultTasksTemplate = {
  2580. reddits: []
  2581. };
  2582. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2583. var Reddit_auth = new WeakMap();
  2584. var Reddit_initialized = new WeakMap();
  2585. var _useBeta = new WeakSet();
  2586. var Reddit_updateAuth = new WeakSet();
  2587. class Reddit extends social_Social {
  2588. constructor() {
  2589. var _GM_getValue;
  2590. super(...arguments);
  2591. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2592. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2593. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2594. Reddit_defineProperty(this, 'whiteList', {
  2595. ...JSON.parse(Reddit_defaultTasks),
  2596. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2597. });
  2598. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2599. writable: true,
  2600. value: void 0
  2601. });
  2602. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2603. writable: true,
  2604. value: false
  2605. });
  2606. }
  2607. async init() {
  2608. try {
  2609. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2610. return true;
  2611. }
  2612. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2613. if (isVerified) {
  2614. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2615. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2616. return true;
  2617. }
  2618. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2619. return false;
  2620. } catch (error) {
  2621. throwError(error, 'Reddit.init');
  2622. return false;
  2623. }
  2624. }
  2625. async toggleTask(_ref) {
  2626. let {
  2627. name,
  2628. doTask = true
  2629. } = _ref;
  2630. try {
  2631. if (!doTask && this.whiteList.reddits.includes(name)) {
  2632. scripts_echoLog({
  2633. type: 'whiteList',
  2634. text: 'Reddit.undoTask',
  2635. id: name
  2636. });
  2637. return true;
  2638. }
  2639. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2640. if (/^u_/.test(name)) {
  2641. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2642. }
  2643. const logStatus = scripts_echoLog({
  2644. type: type,
  2645. text: name
  2646. });
  2647. const {
  2648. result,
  2649. statusText,
  2650. status,
  2651. data
  2652. } = await tools_httpRequest({
  2653. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2654. method: 'POST',
  2655. headers: {
  2656. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2657. 'content-type': 'application/x-www-form-urlencoded'
  2658. },
  2659. data: $.param({
  2660. action: doTask ? 'sub' : 'unsub',
  2661. sr_name: name,
  2662. api_type: 'json'
  2663. })
  2664. });
  2665. if (result === 'Success') {
  2666. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2667. logStatus.success();
  2668. if (doTask) {
  2669. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2670. }
  2671. return true;
  2672. }
  2673. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2674. return false;
  2675. }
  2676. logStatus.error(`${result}:${statusText}(${status})`);
  2677. return false;
  2678. } catch (error) {
  2679. throwError(error, 'Reddit.toggleTask');
  2680. return false;
  2681. }
  2682. }
  2683. async toggle(_ref2) {
  2684. let {
  2685. doTask = true,
  2686. redditLinks = []
  2687. } = _ref2;
  2688. try {
  2689. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2690. scripts_echoLog({
  2691. text: i18n('needInit')
  2692. });
  2693. return false;
  2694. }
  2695. const prom = [];
  2696. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2697. scripts_echoLog({
  2698. type: 'globalOptionsSkip',
  2699. text: 'reddit.reddits'
  2700. });
  2701. } else {
  2702. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2703. var _link$match, _link$match2;
  2704. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2705. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2706. if (userName) {
  2707. return name || userName;
  2708. }
  2709. return name;
  2710. });
  2711. if (realReddits.length > 0) {
  2712. for (const name of realReddits) {
  2713. prom.push(this.toggleTask({
  2714. name: name,
  2715. doTask: doTask
  2716. }));
  2717. await delay(1e3);
  2718. }
  2719. }
  2720. }
  2721. return await Promise.all(prom).then(() => true);
  2722. } catch (error) {
  2723. throwError(error, 'Reddit.toggle');
  2724. return false;
  2725. }
  2726. }
  2727. }
  2728. async function _useBeta2() {
  2729. try {
  2730. const logStatus = scripts_echoLog({
  2731. text: i18n('changingRedditVersion')
  2732. });
  2733. GM_setValue('redditAuth', null);
  2734. return await new Promise(resolve => {
  2735. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2736. active: true,
  2737. insert: true,
  2738. setParent: true
  2739. });
  2740. newTab.onclose = async () => {
  2741. logStatus.success();
  2742. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2743. };
  2744. });
  2745. } catch (error) {
  2746. throwError(error, 'Reddit.useBeta');
  2747. return false;
  2748. }
  2749. }
  2750. async function Reddit_updateAuth2() {
  2751. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2752. try {
  2753. const logStatus = scripts_echoLog({
  2754. text: i18n('updatingAuth', 'Reddit')
  2755. });
  2756. const {
  2757. result,
  2758. statusText,
  2759. status,
  2760. data
  2761. } = await tools_httpRequest({
  2762. url: 'https://www.reddit.com/',
  2763. method: 'GET',
  2764. nochche: true,
  2765. headers: {
  2766. 'Cache-Control': 'no-cache'
  2767. }
  2768. });
  2769. if (result === 'Success') {
  2770. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2771. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2772. return false;
  2773. }
  2774. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2775. var _data$responseText$ma;
  2776. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2777. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2778. }
  2779. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2780. if (accessToken) {
  2781. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2782. token: accessToken
  2783. });
  2784. logStatus.success();
  2785. return true;
  2786. }
  2787. logStatus.error('Error: Parameter "accessToken" not found!');
  2788. return false;
  2789. }
  2790. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2791. return false;
  2792. }
  2793. logStatus.error(`${result}:${statusText}(${status})`);
  2794. return false;
  2795. } catch (error) {
  2796. throwError(error, 'Reddit.updateAuth');
  2797. return false;
  2798. }
  2799. }
  2800. const social_Reddit = Reddit;
  2801. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2802. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2803. privateSet.add(obj);
  2804. }
  2805. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2806. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2807. privateMap.set(obj, value);
  2808. }
  2809. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2810. if (privateCollection.has(obj)) {
  2811. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2812. }
  2813. }
  2814. function Twitch_defineProperty(obj, key, value) {
  2815. if (key in obj) {
  2816. Object.defineProperty(obj, key, {
  2817. value: value,
  2818. enumerable: true,
  2819. configurable: true,
  2820. writable: true
  2821. });
  2822. } else {
  2823. obj[key] = value;
  2824. }
  2825. return obj;
  2826. }
  2827. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2828. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2829. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2830. return value;
  2831. }
  2832. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2833. if (descriptor.set) {
  2834. descriptor.set.call(receiver, value);
  2835. } else {
  2836. if (!descriptor.writable) {
  2837. throw new TypeError('attempted to set read only private field');
  2838. }
  2839. descriptor.value = value;
  2840. }
  2841. }
  2842. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2843. if (!privateSet.has(receiver)) {
  2844. throw new TypeError('attempted to get private field on non-instance');
  2845. }
  2846. return fn;
  2847. }
  2848. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2849. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2850. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2851. }
  2852. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2853. if (!privateMap.has(receiver)) {
  2854. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2855. }
  2856. return privateMap.get(receiver);
  2857. }
  2858. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2859. if (descriptor.get) {
  2860. return descriptor.get.call(receiver);
  2861. }
  2862. return descriptor.value;
  2863. }
  2864. const Twitch_defaultTasksTemplate = {
  2865. channels: []
  2866. };
  2867. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2868. var Twitch_auth = new WeakMap();
  2869. var Twitch_cache = new WeakMap();
  2870. var Twitch_initialized = new WeakMap();
  2871. var _integrityToken = new WeakMap();
  2872. var Twitch_verifyAuth = new WeakSet();
  2873. var _integrity = new WeakSet();
  2874. var Twitch_updateAuth = new WeakSet();
  2875. var _toggleChannel = new WeakSet();
  2876. var _getChannelId = new WeakSet();
  2877. var Twitch_setCache = new WeakSet();
  2878. class Twitch extends social_Social {
  2879. constructor() {
  2880. var _GM_getValue;
  2881. super(...arguments);
  2882. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2883. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2884. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2885. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2886. Twitch_classPrivateMethodInitSpec(this, _integrity);
  2887. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2888. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2889. Twitch_defineProperty(this, 'whiteList', {
  2890. ...JSON.parse(Twitch_defaultTasks),
  2891. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2892. });
  2893. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2894. writable: true,
  2895. value: GM_getValue('twitchAuth') || {}
  2896. });
  2897. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2898. writable: true,
  2899. value: GM_getValue('twitchCache') || {}
  2900. });
  2901. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2902. writable: true,
  2903. value: false
  2904. });
  2905. Twitch_classPrivateFieldInitSpec(this, _integrityToken, {
  2906. writable: true,
  2907. value: void 0
  2908. });
  2909. }
  2910. async init() {
  2911. try {
  2912. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2913. return true;
  2914. }
  2915. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken || !Twitch_classPrivateFieldGet(this, Twitch_auth).clientId || !Twitch_classPrivateFieldGet(this, Twitch_auth).clientVersion || !Twitch_classPrivateFieldGet(this, Twitch_auth).deviceId || !Twitch_classPrivateFieldGet(this, Twitch_auth).clientSessionId) {
  2916. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2917. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2918. return true;
  2919. }
  2920. return false;
  2921. }
  2922. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2923. if (isVerified) {
  2924. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2925. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2926. return true;
  2927. }
  2928. GM_setValue('twitchAuth', null);
  2929. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2930. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2931. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2932. return true;
  2933. }
  2934. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2935. return false;
  2936. } catch (error) {
  2937. throwError(error, 'Twitch.init');
  2938. return false;
  2939. }
  2940. }
  2941. async toggle(_ref) {
  2942. let {
  2943. doTask = true,
  2944. channelLinks = []
  2945. } = _ref;
  2946. try {
  2947. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2948. scripts_echoLog({
  2949. text: i18n('needInit')
  2950. });
  2951. return false;
  2952. }
  2953. const prom = [];
  2954. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2955. scripts_echoLog({
  2956. type: 'globalOptionsSkip',
  2957. text: 'twitch.channels'
  2958. });
  2959. } else {
  2960. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2961. var _link$match;
  2962. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2963. });
  2964. if (realChannels.length > 0) {
  2965. for (const channel of realChannels) {
  2966. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2967. name: channel,
  2968. doTask: doTask
  2969. }));
  2970. await delay(1e3);
  2971. }
  2972. }
  2973. }
  2974. return Promise.all(prom).then(() => true);
  2975. } catch (error) {
  2976. throwError(error, 'Twitch.toggle');
  2977. return false;
  2978. }
  2979. }
  2980. }
  2981. async function Twitch_verifyAuth2() {
  2982. try {
  2983. const logStatus = scripts_echoLog({
  2984. text: i18n('verifyingAuth', 'Twitch')
  2985. });
  2986. const {
  2987. result,
  2988. statusText,
  2989. status,
  2990. data
  2991. } = await tools_httpRequest({
  2992. url: 'https://gql.twitch.tv/gql',
  2993. method: 'POST',
  2994. dataType: 'json',
  2995. headers: {
  2996. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2997. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2998. },
  2999. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  3000. });
  3001. if (result === 'Success') {
  3002. var _data$response, _data$response$, _data$response$$data;
  3003. 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) {
  3004. await Twitch_classPrivateMethodGet(this, _integrity, _integrity2).call(this);
  3005. logStatus.success();
  3006. return true;
  3007. }
  3008. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3009. return false;
  3010. }
  3011. logStatus.error(`${result}:${statusText}(${status})`);
  3012. return false;
  3013. } catch (error) {
  3014. throwError(error, 'Twitch.verifyAuth');
  3015. return false;
  3016. }
  3017. }
  3018. async function _integrity2() {
  3019. let ct = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  3020. try {
  3021. const logStatus = scripts_echoLog({
  3022. text: i18n('checkingTwitchIntegrity')
  3023. });
  3024. const {
  3025. result,
  3026. statusText,
  3027. status,
  3028. data
  3029. } = await tools_httpRequest({
  3030. url: 'https://gql.twitch.tv/integrity',
  3031. method: 'POST',
  3032. dataType: 'json',
  3033. anonymous: true,
  3034. headers: {
  3035. Origin: 'https://www.twitch.tv',
  3036. Referer: 'https://www.twitch.tv/',
  3037. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3038. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId,
  3039. 'Client-Version': Twitch_classPrivateFieldGet(this, Twitch_auth).clientVersion,
  3040. 'X-Device-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).deviceId,
  3041. 'Client-Session-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientSessionId,
  3042. 'x-kpsdk-ct': ct
  3043. }
  3044. });
  3045. if (result === 'Success') {
  3046. var _data$responseHeaders, _data$response2;
  3047. if (!ct && data !== null && data !== void 0 && (_data$responseHeaders = data.responseHeaders) !== null && _data$responseHeaders !== void 0 && _data$responseHeaders['x-kpsdk-ct']) {
  3048. return await Twitch_classPrivateMethodGet(this, _integrity, _integrity2).call(this, data.responseHeaders['x-kpsdk-ct']);
  3049. }
  3050. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.token) {
  3051. Twitch_classPrivateFieldSet(this, _integrityToken, data.response.token);
  3052. logStatus.success();
  3053. return true;
  3054. }
  3055. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3056. return false;
  3057. }
  3058. logStatus.error(`${result}:${statusText}(${status})`);
  3059. return false;
  3060. } catch (error) {
  3061. throwError(error, 'Twitch.integrity');
  3062. return false;
  3063. }
  3064. }
  3065. async function Twitch_updateAuth2() {
  3066. try {
  3067. const logStatus = scripts_echoLog({
  3068. text: i18n('updatingAuth', 'Twitch')
  3069. });
  3070. return await new Promise(resolve => {
  3071. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  3072. active: true,
  3073. insert: true,
  3074. setParent: true
  3075. });
  3076. newTab.onclose = async () => {
  3077. const auth = GM_getValue('twitchAuth');
  3078. if (auth) {
  3079. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  3080. logStatus.success();
  3081. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  3082. } else {
  3083. logStatus.error('Error: Update twitch auth failed!');
  3084. resolve(false);
  3085. }
  3086. };
  3087. });
  3088. } catch (error) {
  3089. throwError(error, 'Twitch.updateAuth');
  3090. return false;
  3091. }
  3092. }
  3093. async function _toggleChannel2(_ref2) {
  3094. let {
  3095. name,
  3096. doTask = true
  3097. } = _ref2;
  3098. try {
  3099. if (!doTask && this.whiteList.channels.includes(name)) {
  3100. scripts_echoLog({
  3101. type: 'whiteList',
  3102. text: 'Twitch.unfollowChannel',
  3103. id: name
  3104. });
  3105. return true;
  3106. }
  3107. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  3108. if (!channelId) {
  3109. return false;
  3110. }
  3111. const logStatus = scripts_echoLog({
  3112. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  3113. text: name
  3114. });
  3115. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"800e7346bdf7e5278a3c1d3f21b2b56e2639928f86815677a7126b093b2fdd08"}}}]';
  3116. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"f7dae976ebf41c755ae2d758546bfd176b4eeb856656098bb40e0a672ca0d880"}}}]';
  3117. const {
  3118. result,
  3119. statusText,
  3120. status,
  3121. data
  3122. } = await tools_httpRequest({
  3123. url: 'https://gql.twitch.tv/gql',
  3124. method: 'POST',
  3125. dataType: 'json',
  3126. anonymous: true,
  3127. headers: {
  3128. Origin: 'https://www.twitch.tv',
  3129. Referer: 'https://www.twitch.tv/',
  3130. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3131. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId,
  3132. 'Client-Version': Twitch_classPrivateFieldGet(this, Twitch_auth).clientVersion,
  3133. 'X-Device-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).deviceId,
  3134. 'Client-Session-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientSessionId,
  3135. 'Client-Integrity': Twitch_classPrivateFieldGet(this, _integrityToken)
  3136. },
  3137. data: doTask ? followData : unfollowData
  3138. });
  3139. if (result === 'Success') {
  3140. var _data$response3, _data$response4, _data$response4$0$err, _data$response4$0$err2;
  3141. 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) {
  3142. logStatus.success();
  3143. if (doTask) {
  3144. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3145. }
  3146. return true;
  3147. }
  3148. 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})`}`);
  3149. return false;
  3150. }
  3151. logStatus.error(`${result}:${statusText}(${status})`);
  3152. return false;
  3153. } catch (error) {
  3154. throwError(error, 'Twitch.toggleChannel');
  3155. return false;
  3156. }
  3157. }
  3158. async function _getChannelId2(name) {
  3159. try {
  3160. const logStatus = scripts_echoLog({
  3161. type: 'gettingTwitchChannelId',
  3162. text: name
  3163. });
  3164. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3165. if (channelId) {
  3166. logStatus.success();
  3167. return channelId;
  3168. }
  3169. const {
  3170. result,
  3171. statusText,
  3172. status,
  3173. data
  3174. } = await tools_httpRequest({
  3175. url: 'https://gql.twitch.tv/gql',
  3176. method: 'POST',
  3177. headers: {
  3178. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3179. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3180. },
  3181. responseType: 'json',
  3182. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3183. });
  3184. if (result === 'Success') {
  3185. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3186. var _data$response5, _data$response5$, _data$response5$$data, _data$response5$$data2;
  3187. 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;
  3188. if (channelId) {
  3189. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, String(channelId));
  3190. logStatus.success();
  3191. return channelId;
  3192. }
  3193. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3194. return false;
  3195. }
  3196. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3197. return false;
  3198. }
  3199. logStatus.error(`${result}:${statusText}(${status})`);
  3200. return false;
  3201. } catch (error) {
  3202. throwError(error, 'Twitch.getChannelId');
  3203. return false;
  3204. }
  3205. }
  3206. function Twitch_setCache2(name, id) {
  3207. try {
  3208. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3209. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3210. } catch (error) {
  3211. throwError(error, 'Twitch.setCache');
  3212. }
  3213. }
  3214. const social_Twitch = Twitch;
  3215. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3216. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3217. privateSet.add(obj);
  3218. }
  3219. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3220. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3221. privateMap.set(obj, value);
  3222. }
  3223. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3224. if (privateCollection.has(obj)) {
  3225. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3226. }
  3227. }
  3228. function Twitter_defineProperty(obj, key, value) {
  3229. if (key in obj) {
  3230. Object.defineProperty(obj, key, {
  3231. value: value,
  3232. enumerable: true,
  3233. configurable: true,
  3234. writable: true
  3235. });
  3236. } else {
  3237. obj[key] = value;
  3238. }
  3239. return obj;
  3240. }
  3241. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3242. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3243. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3244. return value;
  3245. }
  3246. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3247. if (descriptor.set) {
  3248. descriptor.set.call(receiver, value);
  3249. } else {
  3250. if (!descriptor.writable) {
  3251. throw new TypeError('attempted to set read only private field');
  3252. }
  3253. descriptor.value = value;
  3254. }
  3255. }
  3256. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3257. if (!privateSet.has(receiver)) {
  3258. throw new TypeError('attempted to get private field on non-instance');
  3259. }
  3260. return fn;
  3261. }
  3262. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3263. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3264. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3265. }
  3266. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3267. if (!privateMap.has(receiver)) {
  3268. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3269. }
  3270. return privateMap.get(receiver);
  3271. }
  3272. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3273. if (descriptor.get) {
  3274. return descriptor.get.call(receiver);
  3275. }
  3276. return descriptor.value;
  3277. }
  3278. const Twitter_defaultTasksTemplate = {
  3279. users: [],
  3280. retweets: [],
  3281. likes: []
  3282. };
  3283. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3284. var _verifyId = new WeakMap();
  3285. var Twitter_auth = new WeakMap();
  3286. var Twitter_cache = new WeakMap();
  3287. var Twitter_initialized = new WeakMap();
  3288. var Twitter_verifyAuth = new WeakSet();
  3289. var Twitter_updateAuth = new WeakSet();
  3290. var _toggleUser = new WeakSet();
  3291. var _toggleRetweet = new WeakSet();
  3292. var Twitter_setCache = new WeakSet();
  3293. class Twitter extends social_Social {
  3294. constructor() {
  3295. var _GM_getValue;
  3296. super(...arguments);
  3297. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3298. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3299. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3300. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3301. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3302. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3303. Twitter_defineProperty(this, 'whiteList', {
  3304. ...JSON.parse(Twitter_defaultTasks),
  3305. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3306. });
  3307. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3308. writable: true,
  3309. value: globalOptions.other.twitterVerifyId
  3310. });
  3311. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3312. writable: true,
  3313. value: GM_getValue('twitterAuth') || {}
  3314. });
  3315. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3316. writable: true,
  3317. value: GM_getValue('twitterCache') || {}
  3318. });
  3319. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3320. writable: true,
  3321. value: false
  3322. });
  3323. }
  3324. async init() {
  3325. try {
  3326. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3327. return true;
  3328. }
  3329. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3330. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3331. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3332. return true;
  3333. }
  3334. return false;
  3335. }
  3336. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3337. if (isVerified) {
  3338. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3339. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3340. return true;
  3341. }
  3342. GM_setValue('twitterAuth', null);
  3343. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3344. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3345. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3346. return true;
  3347. }
  3348. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3349. return false;
  3350. } catch (error) {
  3351. throwError(error, 'Twitter.init');
  3352. return false;
  3353. }
  3354. }
  3355. async userName2id(name) {
  3356. try {
  3357. const logStatus = scripts_echoLog({
  3358. type: 'gettingTwitterUserId',
  3359. text: name
  3360. });
  3361. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3362. if (userId) {
  3363. logStatus.success();
  3364. return userId;
  3365. }
  3366. const {
  3367. result,
  3368. statusText,
  3369. status,
  3370. data
  3371. } = await tools_httpRequest({
  3372. 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`,
  3373. method: 'GET',
  3374. headers: {
  3375. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3376. 'content-type': 'application/json',
  3377. referer: `https://twitter.com/${name}`,
  3378. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3379. },
  3380. responseType: 'json'
  3381. });
  3382. if (result === 'Success') {
  3383. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3384. var _response, _response$data, _response$data$user, _response$data$user$r;
  3385. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3386. if (!response) {
  3387. try {
  3388. response = JSON.parse(data.responseText);
  3389. } catch (error) {
  3390. response = null;
  3391. }
  3392. }
  3393. 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);
  3394. if (userId) {
  3395. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3396. logStatus.success();
  3397. return userId;
  3398. }
  3399. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3400. return false;
  3401. }
  3402. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3403. return false;
  3404. }
  3405. logStatus.error(`${result}:${statusText}(${status})`);
  3406. return false;
  3407. } catch (error) {
  3408. throwError(error, 'Twitter.getUserId');
  3409. return false;
  3410. }
  3411. }
  3412. async toggle(_ref) {
  3413. let {
  3414. doTask = true,
  3415. userLinks = [],
  3416. retweetLinks = []
  3417. } = _ref;
  3418. try {
  3419. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3420. scripts_echoLog({
  3421. text: i18n('needInit')
  3422. });
  3423. return false;
  3424. }
  3425. const prom = [];
  3426. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3427. scripts_echoLog({
  3428. type: 'globalOptionsSkip',
  3429. text: 'twitter.users'
  3430. });
  3431. } else {
  3432. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3433. var _link$match;
  3434. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3435. });
  3436. if (realUsers.length > 0) {
  3437. for (const user of realUsers) {
  3438. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3439. name: user,
  3440. doTask: doTask
  3441. }));
  3442. await delay(1e3);
  3443. }
  3444. }
  3445. }
  3446. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3447. scripts_echoLog({
  3448. type: 'globalOptionsSkip',
  3449. text: 'twitter.retweets'
  3450. });
  3451. } else {
  3452. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3453. var _link$match2;
  3454. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3455. });
  3456. if (realRetweets.length > 0) {
  3457. for (const retweet of realRetweets) {
  3458. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3459. retweetId: retweet,
  3460. doTask: doTask
  3461. }));
  3462. await delay(1e3);
  3463. }
  3464. }
  3465. }
  3466. return Promise.all(prom).then(() => true);
  3467. } catch (error) {
  3468. throwError(error, 'Twitter.toggle');
  3469. return false;
  3470. }
  3471. }
  3472. }
  3473. async function Twitter_verifyAuth2() {
  3474. try {
  3475. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3476. name: 'verify',
  3477. doTask: true,
  3478. verify: true
  3479. });
  3480. } catch (error) {
  3481. throwError(error, 'Twitter.verifyAuth');
  3482. return false;
  3483. }
  3484. }
  3485. async function Twitter_updateAuth2() {
  3486. try {
  3487. const logStatus = scripts_echoLog({
  3488. text: i18n('updatingAuth', 'Twitter')
  3489. });
  3490. return await new Promise(resolve => {
  3491. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3492. active: true,
  3493. insert: true,
  3494. setParent: true
  3495. });
  3496. newTab.onclose = async () => {
  3497. const auth = GM_getValue('twitterAuth');
  3498. if (auth) {
  3499. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3500. logStatus.success();
  3501. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3502. } else {
  3503. logStatus.error('Error: Update twitter auth failed!');
  3504. resolve(false);
  3505. }
  3506. };
  3507. });
  3508. } catch (error) {
  3509. throwError(error, 'Twitter.updateToken');
  3510. return false;
  3511. }
  3512. }
  3513. async function _toggleUser2(_ref2) {
  3514. let {
  3515. name,
  3516. doTask = true,
  3517. verify = false
  3518. } = _ref2;
  3519. try {
  3520. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3521. scripts_echoLog({
  3522. type: 'whiteList',
  3523. text: 'Twitter.unfollowUser',
  3524. id: name
  3525. });
  3526. return true;
  3527. }
  3528. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3529. if (!userId) {
  3530. return false;
  3531. }
  3532. const logStatus = verify ? scripts_echoLog({
  3533. text: i18n('verifyingAuth', 'Twitter')
  3534. }) : scripts_echoLog({
  3535. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3536. text: name
  3537. });
  3538. const {
  3539. result,
  3540. statusText,
  3541. status,
  3542. data
  3543. } = await tools_httpRequest({
  3544. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3545. method: 'POST',
  3546. headers: {
  3547. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3548. 'Content-Type': 'application/x-www-form-urlencoded',
  3549. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3550. },
  3551. responseType: 'json',
  3552. data: $.param({
  3553. include_profile_interstitial_type: 1,
  3554. include_blocking: 1,
  3555. include_blocked_by: 1,
  3556. include_followed_by: 1,
  3557. include_want_retweets: 1,
  3558. include_mute_edge: 1,
  3559. include_can_dm: 1,
  3560. include_can_media_tag: 1,
  3561. skip_status: 1,
  3562. id: userId
  3563. })
  3564. });
  3565. if (result === 'Success') {
  3566. var _data$response, _data$response$errors, _data$response$errors2;
  3567. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3568. logStatus.success();
  3569. if (doTask && !verify) {
  3570. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3571. }
  3572. return true;
  3573. }
  3574. 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) {
  3575. logStatus.success();
  3576. return true;
  3577. }
  3578. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3579. return false;
  3580. }
  3581. logStatus.error(`${result}:${statusText}(${status})`);
  3582. return false;
  3583. } catch (error) {
  3584. throwError(error, 'Twitter.toggleUser');
  3585. return false;
  3586. }
  3587. }
  3588. async function _toggleRetweet2(_ref3) {
  3589. let {
  3590. retweetId,
  3591. doTask = true
  3592. } = _ref3;
  3593. try {
  3594. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3595. scripts_echoLog({
  3596. type: 'whiteList',
  3597. text: 'Twitter.unretweet',
  3598. id: retweetId
  3599. });
  3600. return true;
  3601. }
  3602. const logStatus = scripts_echoLog({
  3603. type: `${doTask ? '' : 'un'}retweetting`,
  3604. text: retweetId
  3605. });
  3606. const {
  3607. result,
  3608. statusText,
  3609. status,
  3610. data
  3611. } = await tools_httpRequest({
  3612. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3613. method: 'POST',
  3614. headers: {
  3615. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3616. 'Content-Type': 'application/x-www-form-urlencoded',
  3617. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3618. },
  3619. data: $.param({
  3620. tweet_mode: 'extended',
  3621. id: retweetId
  3622. }),
  3623. responseType: 'json'
  3624. });
  3625. if (result === 'Success') {
  3626. var _data$response2, _data$response2$error, _data$response2$error2;
  3627. 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) {
  3628. logStatus.success();
  3629. if (doTask) {
  3630. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3631. }
  3632. return true;
  3633. }
  3634. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3635. return false;
  3636. }
  3637. logStatus.error(`${result}:${statusText}(${status})`);
  3638. return false;
  3639. } catch (error) {
  3640. throwError(error, 'Twitter.toggleRetweet');
  3641. return false;
  3642. }
  3643. }
  3644. function Twitter_setCache2(name, id) {
  3645. try {
  3646. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3647. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3648. } catch (error) {
  3649. throwError(error, 'Twitter.setCache');
  3650. }
  3651. }
  3652. const social_Twitter = Twitter;
  3653. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3654. Vk_checkPrivateRedeclaration(obj, privateSet);
  3655. privateSet.add(obj);
  3656. }
  3657. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3658. Vk_checkPrivateRedeclaration(obj, privateMap);
  3659. privateMap.set(obj, value);
  3660. }
  3661. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3662. if (privateCollection.has(obj)) {
  3663. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3664. }
  3665. }
  3666. function Vk_defineProperty(obj, key, value) {
  3667. if (key in obj) {
  3668. Object.defineProperty(obj, key, {
  3669. value: value,
  3670. enumerable: true,
  3671. configurable: true,
  3672. writable: true
  3673. });
  3674. } else {
  3675. obj[key] = value;
  3676. }
  3677. return obj;
  3678. }
  3679. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3680. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3681. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3682. return value;
  3683. }
  3684. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3685. if (descriptor.set) {
  3686. descriptor.set.call(receiver, value);
  3687. } else {
  3688. if (!descriptor.writable) {
  3689. throw new TypeError('attempted to set read only private field');
  3690. }
  3691. descriptor.value = value;
  3692. }
  3693. }
  3694. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3695. if (!privateSet.has(receiver)) {
  3696. throw new TypeError('attempted to get private field on non-instance');
  3697. }
  3698. return fn;
  3699. }
  3700. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3701. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3702. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3703. }
  3704. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3705. if (!privateMap.has(receiver)) {
  3706. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3707. }
  3708. return privateMap.get(receiver);
  3709. }
  3710. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3711. if (descriptor.get) {
  3712. return descriptor.get.call(receiver);
  3713. }
  3714. return descriptor.value;
  3715. }
  3716. const Vk_defaultTasksTemplate = {
  3717. names: []
  3718. };
  3719. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3720. var _username = new WeakMap();
  3721. var Vk_cache = new WeakMap();
  3722. var Vk_initialized = new WeakMap();
  3723. var Vk_verifyAuth = new WeakSet();
  3724. var _toggleGroup = new WeakSet();
  3725. var _togglePublic = new WeakSet();
  3726. var _sendWall = new WeakSet();
  3727. var _deleteWall = new WeakSet();
  3728. var _getId = new WeakSet();
  3729. var _toggleVk = new WeakSet();
  3730. var Vk_setCache = new WeakSet();
  3731. class Vk extends social_Social {
  3732. constructor() {
  3733. var _GM_getValue;
  3734. super(...arguments);
  3735. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3736. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3737. Vk_classPrivateMethodInitSpec(this, _getId);
  3738. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3739. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3740. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3741. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3742. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3743. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3744. Vk_defineProperty(this, 'whiteList', {
  3745. ...JSON.parse(Vk_defaultTasks),
  3746. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3747. });
  3748. Vk_classPrivateFieldInitSpec(this, _username, {
  3749. writable: true,
  3750. value: ''
  3751. });
  3752. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3753. writable: true,
  3754. value: GM_getValue('vkCache') || {}
  3755. });
  3756. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3757. writable: true,
  3758. value: false
  3759. });
  3760. }
  3761. async init() {
  3762. try {
  3763. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3764. return true;
  3765. }
  3766. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3767. if (isVerified) {
  3768. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3769. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3770. return true;
  3771. }
  3772. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3773. return false;
  3774. } catch (error) {
  3775. throwError(error, 'Vk.init');
  3776. return false;
  3777. }
  3778. }
  3779. async toggle(_ref) {
  3780. let {
  3781. doTask = true,
  3782. nameLinks = []
  3783. } = _ref;
  3784. try {
  3785. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3786. scripts_echoLog({
  3787. text: i18n('needInit')
  3788. });
  3789. return false;
  3790. }
  3791. const prom = [];
  3792. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3793. scripts_echoLog({
  3794. type: 'globalOptionsSkip',
  3795. text: 'vk.names'
  3796. });
  3797. } else {
  3798. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3799. var _link$match;
  3800. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3801. });
  3802. if (realNames.length > 0) {
  3803. for (const name of realNames) {
  3804. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3805. name: name,
  3806. doTask: doTask
  3807. }));
  3808. await delay(1e3);
  3809. }
  3810. }
  3811. }
  3812. return Promise.all(prom).then(() => true);
  3813. } catch (error) {
  3814. throwError(error, 'Vk.toggle');
  3815. return false;
  3816. }
  3817. }
  3818. }
  3819. async function Vk_verifyAuth2() {
  3820. try {
  3821. const logStatus = scripts_echoLog({
  3822. text: i18n('verifyAuth', 'Vk')
  3823. });
  3824. const {
  3825. result,
  3826. statusText,
  3827. status,
  3828. data
  3829. } = await tools_httpRequest({
  3830. url: 'https://vk.com/im',
  3831. method: 'GET'
  3832. });
  3833. if (result === 'Success') {
  3834. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3835. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3836. return false;
  3837. }
  3838. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3839. var _data$responseText$ma;
  3840. Vk_classPrivateFieldSet(this, _username, ((_data$responseText$ma = data.responseText.match(/TopNavBtn__profileLink" href="\/(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1]) || '');
  3841. logStatus.success();
  3842. return true;
  3843. }
  3844. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3845. return false;
  3846. }
  3847. logStatus.error(`${result}:${statusText}(${status})`);
  3848. return false;
  3849. } catch (error) {
  3850. throwError(error, 'Vk.verifyAuth');
  3851. return false;
  3852. }
  3853. }
  3854. async function _toggleGroup2(name, dataParam) {
  3855. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3856. try {
  3857. const logStatus = scripts_echoLog({
  3858. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3859. text: name
  3860. });
  3861. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3862. logStatus.success();
  3863. return true;
  3864. }
  3865. const reqData = {
  3866. act: doTask ? 'enter' : 'leave',
  3867. al: 1,
  3868. gid: dataParam.groupId,
  3869. hash: dataParam.groupHash
  3870. };
  3871. if (doTask) {
  3872. reqData.context = '_';
  3873. }
  3874. const {
  3875. result,
  3876. statusText,
  3877. status,
  3878. data
  3879. } = await tools_httpRequest({
  3880. url: 'https://vk.com/al_groups.php',
  3881. method: 'POST',
  3882. headers: {
  3883. origin: 'https://vk.com',
  3884. referer: `https://vk.com/${name}`,
  3885. 'content-type': 'application/x-www-form-urlencoded'
  3886. },
  3887. data: $.param(reqData)
  3888. });
  3889. if (result === 'Success') {
  3890. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3891. logStatus.success();
  3892. if (doTask) {
  3893. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3894. }
  3895. return true;
  3896. }
  3897. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3898. return false;
  3899. }
  3900. logStatus.error(`${result}:${statusText}(${status})`);
  3901. return false;
  3902. } catch (error) {
  3903. throwError(error, 'Vk.toggleGroup');
  3904. return false;
  3905. }
  3906. }
  3907. async function _togglePublic2(name, dataParam) {
  3908. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3909. try {
  3910. const logStatus = scripts_echoLog({
  3911. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3912. text: name
  3913. });
  3914. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3915. logStatus.success();
  3916. return true;
  3917. }
  3918. const {
  3919. result,
  3920. statusText,
  3921. status,
  3922. data
  3923. } = await tools_httpRequest({
  3924. url: 'https://vk.com/al_public.php',
  3925. method: 'POST',
  3926. headers: {
  3927. origin: 'https://vk.com',
  3928. referer: `https://vk.com/${name}`,
  3929. 'content-type': 'application/x-www-form-urlencoded'
  3930. },
  3931. data: $.param({
  3932. act: doTask ? 'a_enter' : 'a_leave',
  3933. al: 1,
  3934. pid: dataParam.publicPid,
  3935. hash: dataParam.publicHash
  3936. })
  3937. });
  3938. if (result === 'Success') {
  3939. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3940. logStatus.success();
  3941. if (doTask) {
  3942. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3943. }
  3944. return true;
  3945. }
  3946. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3947. return false;
  3948. }
  3949. logStatus.error(`${result}:${statusText}(${status})`);
  3950. return false;
  3951. } catch (error) {
  3952. throwError(error, 'Vk.togglePublic');
  3953. return false;
  3954. }
  3955. }
  3956. async function _sendWall2(name) {
  3957. try {
  3958. const logStatus = scripts_echoLog({
  3959. type: 'sendingVkWall',
  3960. text: name
  3961. });
  3962. const {
  3963. result,
  3964. statusText,
  3965. status,
  3966. data
  3967. } = await tools_httpRequest({
  3968. url: 'https://vk.com/like.php',
  3969. method: 'POST',
  3970. headers: {
  3971. origin: 'https://vk.com',
  3972. referer: `https://vk.com/${name}`,
  3973. 'content-type': 'application/x-www-form-urlencoded'
  3974. },
  3975. data: $.param({
  3976. act: 'publish_box',
  3977. al: 1,
  3978. object: name
  3979. })
  3980. });
  3981. if (result === 'Success') {
  3982. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3983. var _data$responseText$ma2;
  3984. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3985. if (hash) {
  3986. const {
  3987. result: resultR,
  3988. statusText: statusTextR,
  3989. status: statusR,
  3990. data: dataR
  3991. } = await tools_httpRequest({
  3992. url: 'https://vk.com/like.php',
  3993. method: 'POST',
  3994. headers: {
  3995. origin: 'https://vk.com',
  3996. referer: `https://vk.com/${name}`,
  3997. 'content-type': 'application/x-www-form-urlencoded'
  3998. },
  3999. data: $.param({
  4000. Message: '',
  4001. act: 'a_do_publish',
  4002. al: 1,
  4003. close_comments: 0,
  4004. friends_only: 0,
  4005. from: 'box',
  4006. hash: hash,
  4007. list: '',
  4008. mark_as_ads: 0,
  4009. mute_notifications: 0,
  4010. object: name,
  4011. ret_data: 1,
  4012. to: 0
  4013. })
  4014. });
  4015. if (resultR === 'Success') {
  4016. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  4017. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  4018. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  4019. 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) {
  4020. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  4021. logStatus.success();
  4022. 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);
  4023. 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);
  4024. if (postId && ownerId) {
  4025. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  4026. }
  4027. this.tasks.names = unique([ ...this.tasks.names, name ]);
  4028. return true;
  4029. }
  4030. }
  4031. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4032. return false;
  4033. }
  4034. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4035. return false;
  4036. }
  4037. logStatus.error('Error: Get "hash" failed');
  4038. return false;
  4039. }
  4040. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4041. return false;
  4042. }
  4043. logStatus.error(`${result}:${statusText}(${status})`);
  4044. return false;
  4045. } catch (error) {
  4046. throwError(error, 'Vk.sendWall');
  4047. return false;
  4048. }
  4049. }
  4050. async function _deleteWall2(name, dataParams) {
  4051. try {
  4052. const logStatus = scripts_echoLog({
  4053. type: 'deletingVkWall',
  4054. text: name
  4055. });
  4056. const {
  4057. result,
  4058. statusText,
  4059. status,
  4060. data
  4061. } = await tools_httpRequest({
  4062. url: 'https://vk.com/al_wall.php?act=delete',
  4063. method: 'POST',
  4064. headers: {
  4065. origin: 'https://vk.com',
  4066. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  4067. 'content-type': 'application/x-www-form-urlencoded'
  4068. },
  4069. data: $.param({
  4070. act: 'delete',
  4071. al: 1,
  4072. confirm: 0,
  4073. from: 'wkview',
  4074. hash: dataParams.wallHash,
  4075. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  4076. })
  4077. });
  4078. if (result === 'Success') {
  4079. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4080. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  4081. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  4082. 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]) {
  4083. logStatus.success();
  4084. return true;
  4085. }
  4086. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4087. return false;
  4088. }
  4089. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4090. return false;
  4091. }
  4092. logStatus.error(`${result}:${statusText}(${status})`);
  4093. return false;
  4094. } catch (error) {
  4095. throwError(error, 'Vk.deleteWall');
  4096. return false;
  4097. }
  4098. }
  4099. async function _getId2(name, doTask) {
  4100. try {
  4101. let url = `https://vk.com/${name}`;
  4102. if (/^wall-/.test(name)) {
  4103. if (doTask) {
  4104. return {
  4105. type: 'sendWall'
  4106. };
  4107. }
  4108. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  4109. return {
  4110. type: 'unSupport'
  4111. };
  4112. }
  4113. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  4114. }
  4115. const logStatus = scripts_echoLog({
  4116. type: 'gettingVkId',
  4117. text: name
  4118. });
  4119. const {
  4120. result,
  4121. statusText,
  4122. status,
  4123. data
  4124. } = await tools_httpRequest({
  4125. url: url,
  4126. method: 'GET'
  4127. });
  4128. if (result === 'Success') {
  4129. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4130. var _data$responseText$ma3, _data$responseText$ma4;
  4131. const [ , groupAct, groupId, , groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), (&#39;|')(.*?)(&#39;|')/) || [];
  4132. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4133. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4134. const publicJoined = !data.responseText.includes('Public.subscribe');
  4135. if (groupAct && groupId && groupHash) {
  4136. logStatus.success();
  4137. return {
  4138. groupAct: groupAct,
  4139. groupId: groupId,
  4140. groupHash: groupHash,
  4141. type: 'group'
  4142. };
  4143. } else if (publicHash && publicPid) {
  4144. logStatus.success();
  4145. return {
  4146. publicHash: publicHash,
  4147. publicPid: publicPid,
  4148. publicJoined: publicJoined,
  4149. type: 'public'
  4150. };
  4151. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4152. var _data$responseText$ma5;
  4153. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4154. if (wallHash) {
  4155. logStatus.success();
  4156. return {
  4157. type: 'deleteWall',
  4158. wallHash: wallHash
  4159. };
  4160. }
  4161. } else if (name.includes('wall') && doTask) {
  4162. logStatus.success();
  4163. return {
  4164. type: 'sendWall'
  4165. };
  4166. }
  4167. logStatus.error('Error: Parameters not found!');
  4168. return false;
  4169. }
  4170. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4171. return false;
  4172. }
  4173. logStatus.error(`${result}:${statusText}(${status})`);
  4174. return false;
  4175. } catch (error) {
  4176. throwError(error, 'Vk.getId');
  4177. return false;
  4178. }
  4179. }
  4180. async function _toggleVk2(_ref2) {
  4181. let {
  4182. name,
  4183. doTask = true
  4184. } = _ref2;
  4185. try {
  4186. if (!doTask && this.whiteList.names.includes(name)) {
  4187. scripts_echoLog({
  4188. type: 'whiteList',
  4189. text: 'Vk.undoTask',
  4190. id: name
  4191. });
  4192. return true;
  4193. }
  4194. const formatName = name.replace(/\/$/, '');
  4195. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4196. if (!data) {
  4197. return false;
  4198. }
  4199. switch (data.type) {
  4200. case 'group':
  4201. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4202.  
  4203. case 'public':
  4204. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4205.  
  4206. case 'sendWall':
  4207. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4208.  
  4209. case 'deleteWall':
  4210. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4211.  
  4212. default:
  4213. return false;
  4214. }
  4215. } catch (error) {
  4216. throwError(error, 'Vk.toggleVk');
  4217. return false;
  4218. }
  4219. }
  4220. function Vk_setCache2(name, postId) {
  4221. try {
  4222. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4223. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4224. } catch (error) {
  4225. throwError(error, 'Vk.setCache');
  4226. }
  4227. }
  4228. const social_Vk = Vk;
  4229. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4230. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4231. privateSet.add(obj);
  4232. }
  4233. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4234. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4235. privateMap.set(obj, value);
  4236. }
  4237. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4238. if (privateCollection.has(obj)) {
  4239. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4240. }
  4241. }
  4242. function Youtube_defineProperty(obj, key, value) {
  4243. if (key in obj) {
  4244. Object.defineProperty(obj, key, {
  4245. value: value,
  4246. enumerable: true,
  4247. configurable: true,
  4248. writable: true
  4249. });
  4250. } else {
  4251. obj[key] = value;
  4252. }
  4253. return obj;
  4254. }
  4255. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4256. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4257. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4258. return value;
  4259. }
  4260. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4261. if (descriptor.set) {
  4262. descriptor.set.call(receiver, value);
  4263. } else {
  4264. if (!descriptor.writable) {
  4265. throw new TypeError('attempted to set read only private field');
  4266. }
  4267. descriptor.value = value;
  4268. }
  4269. }
  4270. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4271. if (!privateSet.has(receiver)) {
  4272. throw new TypeError('attempted to get private field on non-instance');
  4273. }
  4274. return fn;
  4275. }
  4276. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4277. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4278. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4279. }
  4280. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4281. if (!privateMap.has(receiver)) {
  4282. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4283. }
  4284. return privateMap.get(receiver);
  4285. }
  4286. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4287. if (descriptor.get) {
  4288. return descriptor.get.call(receiver);
  4289. }
  4290. return descriptor.value;
  4291. }
  4292. const Youtube_defaultTasksTemplate = {
  4293. channels: [],
  4294. likes: []
  4295. };
  4296. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4297. const getInfo = async function(link, type) {
  4298. try {
  4299. const logStatus = scripts_echoLog({
  4300. text: i18n('gettingYtbToken')
  4301. });
  4302. const {
  4303. result,
  4304. statusText,
  4305. status,
  4306. data
  4307. } = await tools_httpRequest({
  4308. url: link,
  4309. method: 'GET'
  4310. });
  4311. if (result === 'Success') {
  4312. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4313. var _data$responseText$ma, _ref;
  4314. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4315. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4316. return {
  4317. needLogin: true
  4318. };
  4319. }
  4320. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4321. 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]) || '{}';
  4322. const {
  4323. client,
  4324. request
  4325. } = JSON.parse(context);
  4326. if (apiKey && client && request) {
  4327. client.hl = 'en';
  4328. if (type === 'channel') {
  4329. var _data$responseText$ma2;
  4330. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4331. if (channelId) {
  4332. logStatus.success();
  4333. return {
  4334. params: {
  4335. apiKey: apiKey,
  4336. client: client,
  4337. request: request,
  4338. channelId: channelId
  4339. }
  4340. };
  4341. }
  4342. logStatus.error('Error: Get "channelId" failed!');
  4343. return {};
  4344. } else if (type === 'likeVideo') {
  4345. var _data$responseText$ma3, _data$responseText$ma4;
  4346. 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];
  4347. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4348. if (videoId) {
  4349. logStatus.success();
  4350. return {
  4351. params: {
  4352. apiKey: apiKey,
  4353. client: client,
  4354. request: request,
  4355. videoId: videoId,
  4356. likeParams: likeParams
  4357. }
  4358. };
  4359. }
  4360. logStatus.error('Error: Get "videoId" failed!');
  4361. return {};
  4362. }
  4363. logStatus.error('Error: Unknown type');
  4364. return {};
  4365. }
  4366. logStatus.error('Error: Parameter "apiKey" not found!');
  4367. return {};
  4368. }
  4369. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4370. return {};
  4371. }
  4372. logStatus.error(`${result}:${statusText}(${status})`);
  4373. return {};
  4374. } catch (error) {
  4375. throwError(error, 'Youtube.getInfo');
  4376. return {};
  4377. }
  4378. };
  4379. var Youtube_auth = new WeakMap();
  4380. var Youtube_initialized = new WeakMap();
  4381. var _verifyChannel = new WeakMap();
  4382. var Youtube_verifyAuth = new WeakSet();
  4383. var Youtube_updateAuth = new WeakSet();
  4384. var _getInfo = new WeakSet();
  4385. var Youtube_toggleChannel = new WeakSet();
  4386. var _toggleLikeVideo = new WeakSet();
  4387. class Youtube extends social_Social {
  4388. constructor() {
  4389. var _GM_getValue;
  4390. super(...arguments);
  4391. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4392. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4393. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4394. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4395. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4396. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4397. Youtube_defineProperty(this, 'whiteList', {
  4398. ...JSON.parse(Youtube_defaultTasks),
  4399. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4400. });
  4401. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4402. writable: true,
  4403. value: GM_getValue('youtubeAuth') || {}
  4404. });
  4405. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4406. writable: true,
  4407. value: false
  4408. });
  4409. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4410. writable: true,
  4411. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4412. });
  4413. }
  4414. async init() {
  4415. try {
  4416. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4417. return true;
  4418. }
  4419. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4420. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4421. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4422. return true;
  4423. }
  4424. return false;
  4425. }
  4426. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4427. if (isVerified) {
  4428. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4429. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4430. return true;
  4431. }
  4432. GM_setValue('youtubeAuth', null);
  4433. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4434. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4435. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4436. return true;
  4437. }
  4438. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4439. return false;
  4440. } catch (error) {
  4441. throwError(error, 'Youtube.init');
  4442. return false;
  4443. }
  4444. }
  4445. async toggle(_ref2) {
  4446. let {
  4447. doTask = true,
  4448. channelLinks = [],
  4449. videoLinks = []
  4450. } = _ref2;
  4451. try {
  4452. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4453. scripts_echoLog({
  4454. text: i18n('needInit')
  4455. });
  4456. return false;
  4457. }
  4458. const prom = [];
  4459. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4460. scripts_echoLog({
  4461. type: 'globalOptionsSkip',
  4462. text: 'youtube.channels'
  4463. });
  4464. } else {
  4465. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4466. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4467. var _link$match;
  4468. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4469. }
  4470. return link;
  4471. });
  4472. if (realChannels.length > 0) {
  4473. for (const channel of realChannels) {
  4474. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4475. link: channel,
  4476. doTask: doTask
  4477. }));
  4478. await delay(1e3);
  4479. }
  4480. }
  4481. }
  4482. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4483. scripts_echoLog({
  4484. type: 'globalOptionsSkip',
  4485. text: 'youtube.likes'
  4486. });
  4487. } else {
  4488. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4489. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4490. var _link$match2;
  4491. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4492. }
  4493. return link;
  4494. });
  4495. if (realLikes.length > 0) {
  4496. for (const video of realLikes) {
  4497. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4498. link: video,
  4499. doTask: doTask
  4500. }));
  4501. await delay(1e3);
  4502. }
  4503. }
  4504. }
  4505. return Promise.all(prom).then(() => true);
  4506. } catch (error) {
  4507. throwError(error, 'Youtube.toggle');
  4508. return false;
  4509. }
  4510. }
  4511. }
  4512. async function Youtube_verifyAuth2() {
  4513. try {
  4514. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4515. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4516. doTask: true,
  4517. verify: true
  4518. });
  4519. } catch (error) {
  4520. throwError(error, 'Youtube.verifyAuth');
  4521. return false;
  4522. }
  4523. }
  4524. async function Youtube_updateAuth2() {
  4525. try {
  4526. const logStatus = scripts_echoLog({
  4527. text: i18n('updatingAuth', 'Youtube')
  4528. });
  4529. return await new Promise(resolve => {
  4530. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4531. active: true,
  4532. insert: true,
  4533. setParent: true
  4534. });
  4535. newTab.onclose = async () => {
  4536. const auth = GM_getValue('youtubeAuth');
  4537. if (auth) {
  4538. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4539. logStatus.success();
  4540. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4541. resolve(result);
  4542. });
  4543. } else {
  4544. logStatus.error('Error: Update youtube auth failed!');
  4545. resolve(false);
  4546. }
  4547. };
  4548. });
  4549. } catch (error) {
  4550. throwError(error, 'Discord.updateAuth');
  4551. return false;
  4552. }
  4553. }
  4554. function _getInfo2(link, type) {
  4555. return getInfo(link, type);
  4556. }
  4557. async function Youtube_toggleChannel2(_ref3) {
  4558. let {
  4559. link,
  4560. doTask = true,
  4561. verify = false
  4562. } = _ref3;
  4563. try {
  4564. const {
  4565. params,
  4566. needLogin
  4567. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4568. const {
  4569. apiKey,
  4570. client,
  4571. request,
  4572. channelId
  4573. } = params || {};
  4574. if (needLogin) {
  4575. scripts_echoLog({
  4576. html: i18n('loginYtb')
  4577. });
  4578. return false;
  4579. }
  4580. if (!(apiKey && client && request && channelId)) {
  4581. scripts_echoLog({
  4582. text: '"getYtbToken" failed'
  4583. });
  4584. return false;
  4585. }
  4586. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4587. scripts_echoLog({
  4588. type: 'whiteList',
  4589. text: 'Youtube.unfollowChannel',
  4590. id: channelId
  4591. });
  4592. return true;
  4593. }
  4594. const logStatus = verify ? scripts_echoLog({
  4595. text: i18n('verifyingAuth', 'Youtube')
  4596. }) : scripts_echoLog({
  4597. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4598. text: channelId
  4599. });
  4600. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4601. const {
  4602. result,
  4603. statusText,
  4604. status,
  4605. data
  4606. } = await tools_httpRequest({
  4607. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4608. method: 'POST',
  4609. headers: {
  4610. origin: 'https://www.youtube.com',
  4611. referer: `https://www.youtube.com/channel/${channelId}`,
  4612. 'content-type': 'application/json',
  4613. 'x-goog-authuser': '0',
  4614. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4615. 'x-origin': 'https://www.youtube.com',
  4616. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4617. },
  4618. data: JSON.stringify({
  4619. context: {
  4620. client: client,
  4621. request: {
  4622. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4623. internalExperimentFlags: [],
  4624. consistencyTokenJars: []
  4625. },
  4626. user: {}
  4627. },
  4628. channelIds: [ channelId ],
  4629. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4630. })
  4631. });
  4632. if (result === 'Success') {
  4633. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4634. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4635. logStatus.success();
  4636. if (doTask && !verify) {
  4637. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4638. }
  4639. return true;
  4640. }
  4641. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4642. logStatus.success();
  4643. return true;
  4644. }
  4645. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  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, 'Youtube.toggleChannel');
  4655. return false;
  4656. }
  4657. }
  4658. async function _toggleLikeVideo2(_ref4) {
  4659. let {
  4660. link,
  4661. doTask = true
  4662. } = _ref4;
  4663. try {
  4664. const {
  4665. params,
  4666. needLogin
  4667. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4668. const {
  4669. apiKey,
  4670. client,
  4671. request,
  4672. videoId,
  4673. likeParams
  4674. } = params || {};
  4675. if (needLogin) {
  4676. scripts_echoLog({
  4677. html: `${i18n('loginYtb')}`
  4678. });
  4679. return false;
  4680. }
  4681. if (!(apiKey && client && request && videoId && likeParams)) {
  4682. scripts_echoLog({
  4683. text: '"getYtbToken" failed'
  4684. });
  4685. return false;
  4686. }
  4687. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4688. scripts_echoLog({
  4689. type: 'whiteList',
  4690. text: 'Youtube.unlikeVideo',
  4691. id: videoId
  4692. });
  4693. return true;
  4694. }
  4695. const logStatus = scripts_echoLog({
  4696. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4697. text: videoId
  4698. });
  4699. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4700. const likeVideoData = {
  4701. context: {
  4702. client: client,
  4703. request: {
  4704. sessionId: request.sessionId,
  4705. internalExperimentFlags: [],
  4706. consistencyTokenJars: []
  4707. },
  4708. user: {}
  4709. },
  4710. target: {
  4711. videoId: videoId
  4712. }
  4713. };
  4714. if (doTask) {
  4715. if (likeParams) {
  4716. likeVideoData.params = likeParams;
  4717. } else {
  4718. logStatus.error('Empty likeParams');
  4719. return false;
  4720. }
  4721. }
  4722. const {
  4723. result,
  4724. statusText,
  4725. status,
  4726. data
  4727. } = await tools_httpRequest({
  4728. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4729. method: 'POST',
  4730. headers: {
  4731. origin: 'https://www.youtube.com',
  4732. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4733. 'content-type': 'application/json',
  4734. 'x-goog-authuser': '0',
  4735. 'x-goog-visitor-id': client.visitorData,
  4736. 'x-origin': 'https://www.youtube.com',
  4737. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4738. },
  4739. data: JSON.stringify(likeVideoData)
  4740. });
  4741. if (result === 'Success') {
  4742. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4743. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4744. logStatus.success();
  4745. if (doTask) {
  4746. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4747. }
  4748. return true;
  4749. }
  4750. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4751. return false;
  4752. }
  4753. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4754. return false;
  4755. }
  4756. logStatus.error(`${result}:${statusText}(${status})`);
  4757. return false;
  4758. } catch (error) {
  4759. throwError(error, 'Youtube.toggleLikeVideo');
  4760. return false;
  4761. }
  4762. }
  4763. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4764. Steam_checkPrivateRedeclaration(obj, privateSet);
  4765. privateSet.add(obj);
  4766. }
  4767. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4768. Steam_checkPrivateRedeclaration(obj, privateMap);
  4769. privateMap.set(obj, value);
  4770. }
  4771. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4772. if (privateCollection.has(obj)) {
  4773. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4774. }
  4775. }
  4776. function Steam_defineProperty(obj, key, value) {
  4777. if (key in obj) {
  4778. Object.defineProperty(obj, key, {
  4779. value: value,
  4780. enumerable: true,
  4781. configurable: true,
  4782. writable: true
  4783. });
  4784. } else {
  4785. obj[key] = value;
  4786. }
  4787. return obj;
  4788. }
  4789. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4790. if (!privateSet.has(receiver)) {
  4791. throw new TypeError('attempted to get private field on non-instance');
  4792. }
  4793. return fn;
  4794. }
  4795. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4796. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4797. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4798. return value;
  4799. }
  4800. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4801. if (descriptor.set) {
  4802. descriptor.set.call(receiver, value);
  4803. } else {
  4804. if (!descriptor.writable) {
  4805. throw new TypeError('attempted to set read only private field');
  4806. }
  4807. descriptor.value = value;
  4808. }
  4809. }
  4810. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4811. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4812. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4813. }
  4814. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4815. if (!privateMap.has(receiver)) {
  4816. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4817. }
  4818. return privateMap.get(receiver);
  4819. }
  4820. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4821. if (descriptor.get) {
  4822. return descriptor.get.call(receiver);
  4823. }
  4824. return descriptor.value;
  4825. }
  4826. const Steam_defaultTasksTemplate = {
  4827. groups: [],
  4828. officialGroups: [],
  4829. wishlists: [],
  4830. follows: [],
  4831. forums: [],
  4832. workshops: [],
  4833. workshopVotes: [],
  4834. curators: [],
  4835. curatorLikes: [],
  4836. announcements: [],
  4837. licenses: [],
  4838. playtests: []
  4839. };
  4840. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4841. var Steam_cache = new WeakMap();
  4842. var Steam_auth = new WeakMap();
  4843. var _storeInitialized = new WeakMap();
  4844. var _communityInitialized = new WeakMap();
  4845. var _area = new WeakMap();
  4846. var _areaStatus = new WeakMap();
  4847. var _updateStoreAuth = new WeakSet();
  4848. var _updateCommunityAuth = new WeakSet();
  4849. var _getAreaInfo = new WeakSet();
  4850. var _changeArea = new WeakSet();
  4851. var _joinGroup = new WeakSet();
  4852. var _leaveGroup = new WeakSet();
  4853. var _getGroupId = new WeakSet();
  4854. var _joinOfficialGroup = new WeakSet();
  4855. var _leaveOfficialGroup = new WeakSet();
  4856. var _getOfficialGroupId = new WeakSet();
  4857. var _addToWishlist = new WeakSet();
  4858. var _removeFromWishlist = new WeakSet();
  4859. var _toggleFollowGame = new WeakSet();
  4860. var _isFollowedGame = new WeakSet();
  4861. var _toggleForum = new WeakSet();
  4862. var _getForumId = new WeakSet();
  4863. var _toggleFavoriteWorkshop = new WeakSet();
  4864. var _getWorkshopAppId = new WeakSet();
  4865. var _voteUpWorkshop = new WeakSet();
  4866. var _toggleCurator = new WeakSet();
  4867. var _toggleCuratorLike = new WeakSet();
  4868. var _getAnnouncementParams = new WeakSet();
  4869. var _likeAnnouncement = new WeakSet();
  4870. var _appid2subid = new WeakSet();
  4871. var _getLicenses = new WeakSet();
  4872. var _addLicense = new WeakSet();
  4873. var _addFreeLicense = new WeakSet();
  4874. var _requestPlayTestAccess = new WeakSet();
  4875. var Steam_setCache = new WeakSet();
  4876. class Steam extends social_Social {
  4877. constructor() {
  4878. var _GM_getValue;
  4879. super(...arguments);
  4880. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4881. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4882. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4883. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4884. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4885. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4886. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4887. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4888. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4889. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4890. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4891. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4892. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4893. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4894. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4895. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4896. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4897. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4898. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4899. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4900. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4901. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4902. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4903. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4904. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4905. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4906. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4907. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4908. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4909. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4910. Steam_defineProperty(this, 'whiteList', {
  4911. ...JSON.parse(Steam_defaultTasks),
  4912. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4913. });
  4914. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4915. writable: true,
  4916. value: {
  4917. ...{
  4918. group: {},
  4919. officialGroup: {},
  4920. forum: {},
  4921. workshop: {},
  4922. curator: {}
  4923. },
  4924. ...GM_getValue('steamCache')
  4925. }
  4926. });
  4927. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4928. writable: true,
  4929. value: {}
  4930. });
  4931. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4932. writable: true,
  4933. value: false
  4934. });
  4935. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4936. writable: true,
  4937. value: false
  4938. });
  4939. Steam_classPrivateFieldInitSpec(this, _area, {
  4940. writable: true,
  4941. value: 'CN'
  4942. });
  4943. Steam_classPrivateFieldInitSpec(this, _areaStatus, {
  4944. writable: true,
  4945. value: 'end'
  4946. });
  4947. }
  4948. async init() {
  4949. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4950. try {
  4951. if (type === 'store') {
  4952. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4953. return true;
  4954. }
  4955. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4956. if (!Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4957. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4958. return false;
  4959. }
  4960. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4961. return true;
  4962. }
  4963. if (type === 'community') {
  4964. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4965. return true;
  4966. }
  4967. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4968. if (!Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4969. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4970. return false;
  4971. }
  4972. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4973. return true;
  4974. }
  4975. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4976. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4977. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4978. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4979. return true;
  4980. }
  4981. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4982. return false;
  4983. } catch (error) {
  4984. throwError(error, 'Steam.init');
  4985. return false;
  4986. }
  4987. }
  4988. async getCuratorId(path, name) {
  4989. try {
  4990. const logStatus = scripts_echoLog({
  4991. type: 'gettingCuratorId',
  4992. text: `${path}/${name}`
  4993. });
  4994. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4995. if (curatorId) {
  4996. logStatus.success();
  4997. return curatorId;
  4998. }
  4999. const {
  5000. result,
  5001. statusText,
  5002. status,
  5003. data
  5004. } = await tools_httpRequest({
  5005. url: `https://store.steampowered.com/${path}/${name}`,
  5006. method: 'GET',
  5007. headers: {
  5008. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5009. }
  5010. });
  5011. if (result === 'Success') {
  5012. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5013. var _data$responseText$ma;
  5014. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  5015. if (curatorId) {
  5016. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  5017. logStatus.success();
  5018. return curatorId;
  5019. }
  5020. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5021. return false;
  5022. }
  5023. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5024. return false;
  5025. }
  5026. logStatus.error(`${result}:${statusText}(${status})`);
  5027. return false;
  5028. } catch (error) {
  5029. throwError(error, 'Steam.getCuratorID');
  5030. return false;
  5031. }
  5032. }
  5033. async toggle(_ref) {
  5034. let {
  5035. doTask = true,
  5036. groupLinks = [],
  5037. officialGroupLinks = [],
  5038. wishlistLinks = [],
  5039. followLinks = [],
  5040. forumLinks = [],
  5041. workshopLinks = [],
  5042. workshopVoteLinks = [],
  5043. curatorLinks = [],
  5044. curatorLikeLinks = [],
  5045. announcementLinks = [],
  5046. licenseLinks = [],
  5047. playtestLinks = []
  5048. } = _ref;
  5049. try {
  5050. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  5051. scripts_echoLog({
  5052. text: i18n('needInit')
  5053. });
  5054. return false;
  5055. }
  5056. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  5057. scripts_echoLog({
  5058. text: i18n('needInit')
  5059. });
  5060. return false;
  5061. }
  5062. const prom = [];
  5063. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  5064. scripts_echoLog({
  5065. type: 'globalOptionsSkip',
  5066. text: 'steam.groups'
  5067. });
  5068. } else {
  5069. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  5070. var _link$match;
  5071. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  5072. });
  5073. if (realGroups.length > 0) {
  5074. for (const group of realGroups) {
  5075. if (doTask) {
  5076. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  5077. } else {
  5078. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  5079. }
  5080. await delay(1e3);
  5081. }
  5082. }
  5083. }
  5084. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  5085. scripts_echoLog({
  5086. type: 'globalOptionsSkip',
  5087. text: 'steam.officialGroups'
  5088. });
  5089. } else {
  5090. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  5091. var _link$match2;
  5092. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  5093. });
  5094. if (realOfficialGroups.length > 0) {
  5095. for (const officialGroup of realOfficialGroups) {
  5096. if (doTask) {
  5097. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  5098. } else {
  5099. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  5100. }
  5101. await delay(1e3);
  5102. }
  5103. }
  5104. }
  5105. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  5106. scripts_echoLog({
  5107. type: 'globalOptionsSkip',
  5108. text: 'steam.wishlists'
  5109. });
  5110. } else {
  5111. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  5112. var _link$match3;
  5113. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5114. });
  5115. if (realWishlists.length > 0) {
  5116. for (const game of realWishlists) {
  5117. if (doTask) {
  5118. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  5119. } else {
  5120. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  5121. }
  5122. await delay(1e3);
  5123. }
  5124. }
  5125. }
  5126. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5127. scripts_echoLog({
  5128. type: 'globalOptionsSkip',
  5129. text: 'steam.follows'
  5130. });
  5131. } else {
  5132. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5133. var _link$match4;
  5134. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5135. });
  5136. if (realFollows.length > 0) {
  5137. for (const game of realFollows) {
  5138. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  5139. await delay(1e3);
  5140. }
  5141. }
  5142. }
  5143. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5144. scripts_echoLog({
  5145. type: 'globalOptionsSkip',
  5146. text: 'steam.forums'
  5147. });
  5148. } else {
  5149. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5150. var _link$match5;
  5151. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5152. });
  5153. if (realForums.length > 0) {
  5154. for (const forum of realForums) {
  5155. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5156. await delay(1e3);
  5157. }
  5158. }
  5159. }
  5160. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5161. scripts_echoLog({
  5162. type: 'globalOptionsSkip',
  5163. text: 'steam.workshops'
  5164. });
  5165. } else {
  5166. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5167. var _link$match6;
  5168. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5169. });
  5170. if (realWorkshops.length > 0) {
  5171. for (const workshop of realWorkshops) {
  5172. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5173. await delay(1e3);
  5174. }
  5175. }
  5176. }
  5177. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5178. scripts_echoLog({
  5179. type: 'globalOptionsSkip',
  5180. text: 'steam.workshopVotes'
  5181. });
  5182. } else {
  5183. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5184. var _link$match7;
  5185. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5186. });
  5187. if (doTask && realworkshopVotes.length > 0) {
  5188. for (const workshop of realworkshopVotes) {
  5189. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5190. await delay(1e3);
  5191. }
  5192. }
  5193. }
  5194. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5195. scripts_echoLog({
  5196. type: 'globalOptionsSkip',
  5197. text: 'steam.curators'
  5198. });
  5199. } else {
  5200. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5201. var _link$match8;
  5202. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5203. });
  5204. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5205. var _link$match9;
  5206. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5207. });
  5208. if (realCurators.length > 0) {
  5209. for (const curator of realCurators) {
  5210. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5211. await delay(1e3);
  5212. }
  5213. }
  5214. if (realCuratorLikes.length > 0) {
  5215. for (const curatorLike of realCuratorLikes) {
  5216. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5217. await delay(1e3);
  5218. }
  5219. }
  5220. }
  5221. if (doTask && !globalOptions.doTask.steam.announcements) {
  5222. scripts_echoLog({
  5223. type: 'globalOptionsSkip',
  5224. text: 'steam.announcements'
  5225. });
  5226. } else {
  5227. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5228. var _link$match11;
  5229. if (link.includes('store.steampowered.com')) {
  5230. var _link$match10;
  5231. 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('/');
  5232. }
  5233. 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('/');
  5234. });
  5235. if (doTask && realAnnouncements.length > 0) {
  5236. for (const id of realAnnouncements) {
  5237. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5238. await delay(1e3);
  5239. }
  5240. }
  5241. }
  5242. if (doTask && !globalOptions.doTask.steam.licenses) {
  5243. scripts_echoLog({
  5244. type: 'globalOptionsSkip',
  5245. text: 'steam.licenses'
  5246. });
  5247. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5248. for (const id of licenseLinks) {
  5249. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5250. await delay(1e3);
  5251. }
  5252. }
  5253. if (doTask && !globalOptions.doTask.steam.playtests) {
  5254. scripts_echoLog({
  5255. type: 'globalOptionsSkip',
  5256. text: 'steam.playtests'
  5257. });
  5258. } else {
  5259. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5260. var _link$match12;
  5261. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5262. });
  5263. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5264. for (const id of realPlaytests) {
  5265. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5266. await delay(1e3);
  5267. }
  5268. }
  5269. }
  5270. return Promise.all(prom).then(async () => {
  5271. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5272. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5273. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5274. }
  5275. return true;
  5276. });
  5277. } catch (error) {
  5278. throwError(error, 'Steam.toggle');
  5279. return false;
  5280. }
  5281. }
  5282. }
  5283. async function _updateStoreAuth2() {
  5284. try {
  5285. const logStatus = scripts_echoLog({
  5286. text: i18n('updatingAuth', i18n('steamStore'))
  5287. });
  5288. const {
  5289. result,
  5290. statusText,
  5291. status,
  5292. data
  5293. } = await tools_httpRequest({
  5294. url: 'https://store.steampowered.com/',
  5295. method: 'GET',
  5296. headers: {
  5297. 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',
  5298. 'Cache-Control': 'max-age=0',
  5299. 'Sec-Fetch-Dest': 'document',
  5300. 'Sec-Fetch-Mode': 'navigate',
  5301. 'Upgrade-Insecure-Requests': '1'
  5302. }
  5303. });
  5304. if (result === 'Success') {
  5305. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5306. var _data$responseText$ma2;
  5307. if (!data.responseText.includes('data-miniprofile=')) {
  5308. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5309. return false;
  5310. }
  5311. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5312. if (storeSessionID) {
  5313. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5314. logStatus.success();
  5315. return true;
  5316. }
  5317. logStatus.error('Error: Get "sessionID" failed');
  5318. return false;
  5319. }
  5320. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5321. return false;
  5322. }
  5323. logStatus.error(`${result}:${statusText}(${status})`);
  5324. return false;
  5325. } catch (error) {
  5326. throwError(error, 'Steam.updateStoreAuth');
  5327. return false;
  5328. }
  5329. }
  5330. async function _updateCommunityAuth2() {
  5331. try {
  5332. const logStatus = scripts_echoLog({
  5333. text: i18n('updatingAuth', i18n('steamCommunity'))
  5334. });
  5335. const {
  5336. result,
  5337. statusText,
  5338. status,
  5339. data
  5340. } = await tools_httpRequest({
  5341. url: 'https://steamcommunity.com/my',
  5342. method: 'GET',
  5343. headers: {
  5344. 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',
  5345. 'Cache-Control': 'max-age=0',
  5346. 'Sec-Fetch-Dest': 'document',
  5347. 'Sec-Fetch-Mode': 'navigate',
  5348. 'Upgrade-Insecure-Requests': '1'
  5349. }
  5350. });
  5351. if (result === 'Success') {
  5352. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5353. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5354. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5355. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5356. return false;
  5357. }
  5358. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5359. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5360. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5361. if (steam64Id) {
  5362. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5363. }
  5364. if (userName) {
  5365. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5366. }
  5367. if (communitySessionID) {
  5368. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5369. logStatus.success();
  5370. return true;
  5371. }
  5372. logStatus.error('Error: Get "sessionID" failed');
  5373. return false;
  5374. }
  5375. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5376. return false;
  5377. }
  5378. logStatus.error(`${result}:${statusText}(${status})`);
  5379. return false;
  5380. } catch (error) {
  5381. throwError(error, 'Steam.updateCommunityAuth');
  5382. return false;
  5383. }
  5384. }
  5385. async function _getAreaInfo2() {
  5386. try {
  5387. const logStatus = scripts_echoLog({
  5388. text: i18n('gettingAreaInfo')
  5389. });
  5390. const {
  5391. result,
  5392. statusText,
  5393. status,
  5394. data
  5395. } = await tools_httpRequest({
  5396. url: 'https://store.steampowered.com/cart/',
  5397. method: 'GET'
  5398. });
  5399. if (result === 'Success') {
  5400. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5401. var _data$responseText$ma6;
  5402. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5403. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5404. if (currentArea && areas.length > 0) {
  5405. Steam_classPrivateFieldSet(this, _area, currentArea);
  5406. logStatus.success();
  5407. return {
  5408. currentArea: currentArea,
  5409. areas: areas
  5410. };
  5411. }
  5412. logStatus.error('Error: get country info filed');
  5413. return {};
  5414. }
  5415. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5416. return {};
  5417. }
  5418. logStatus.error(`${result}:${statusText}(${status})`);
  5419. return {};
  5420. } catch (error) {
  5421. throwError(error, 'Steam.getAreaInfo');
  5422. return {};
  5423. }
  5424. }
  5425. async function _changeArea2(area) {
  5426. try {
  5427. if (Steam_classPrivateFieldGet(this, _areaStatus) === 'waiting') {
  5428. await new Promise(resolve => {
  5429. const checker = setInterval(() => {
  5430. if (Steam_classPrivateFieldGet(this, _areaStatus) !== 'waiting') {
  5431. clearInterval(checker);
  5432. resolve(true);
  5433. }
  5434. });
  5435. });
  5436. }
  5437. if (Steam_classPrivateFieldGet(this, _area) === area || !area && Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5438. return true;
  5439. }
  5440. Steam_classPrivateFieldSet(this, _areaStatus, 'waiting');
  5441. let aimedArea = area;
  5442. if (!aimedArea) {
  5443. const {
  5444. currentArea,
  5445. areas
  5446. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5447. if (!currentArea || !areas) {
  5448. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5449. return false;
  5450. }
  5451. if (currentArea !== 'CN') {
  5452. Steam_classPrivateFieldSet(this, _areaStatus, 'skip');
  5453. scripts_echoLog({
  5454. text: 'notNeededChangeArea'
  5455. });
  5456. return 'skip';
  5457. }
  5458. const anotherArea = areas.filter(area => area && area !== 'CN');
  5459. if (!anotherArea || anotherArea.length === 0) {
  5460. Steam_classPrivateFieldSet(this, _areaStatus, 'noAnotherArea');
  5461. scripts_echoLog({
  5462. text: 'noAnotherArea'
  5463. });
  5464. return false;
  5465. }
  5466. [ aimedArea ] = anotherArea;
  5467. }
  5468. const logStatus = scripts_echoLog({
  5469. text: i18n('changingArea', aimedArea)
  5470. });
  5471. const {
  5472. result,
  5473. statusText,
  5474. status,
  5475. data
  5476. } = await tools_httpRequest({
  5477. url: 'https://store.steampowered.com/account/setcountry',
  5478. method: 'POST',
  5479. headers: {
  5480. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5481. },
  5482. data: $.param({
  5483. cc: aimedArea,
  5484. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5485. })
  5486. });
  5487. if (result === 'Success') {
  5488. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5489. const {
  5490. currentArea
  5491. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5492. if (currentArea === aimedArea) {
  5493. Steam_classPrivateFieldSet(this, _areaStatus, 'success');
  5494. logStatus.success();
  5495. return currentArea;
  5496. }
  5497. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5498. logStatus.error('Error: change country filed');
  5499. return 'CN';
  5500. }
  5501. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5502. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5503. return 'CN';
  5504. }
  5505. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5506. logStatus.error(`${result}:${statusText}(${status})`);
  5507. return 'CN';
  5508. } catch (error) {
  5509. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5510. throwError(error, 'Steam.changeArea');
  5511. return false;
  5512. }
  5513. }
  5514. async function _joinGroup2(groupName) {
  5515. try {
  5516. const logStatus = scripts_echoLog({
  5517. type: 'joiningSteamGroup',
  5518. text: groupName
  5519. });
  5520. const {
  5521. result,
  5522. statusText,
  5523. status,
  5524. data
  5525. } = await tools_httpRequest({
  5526. url: `https://steamcommunity.com/groups/${groupName}`,
  5527. method: 'POST',
  5528. headers: {
  5529. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5530. },
  5531. data: $.param({
  5532. action: 'join',
  5533. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5534. })
  5535. });
  5536. if (result === 'Success') {
  5537. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5538. logStatus.success();
  5539. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5540. return true;
  5541. }
  5542. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5543. return false;
  5544. }
  5545. logStatus.error(`${result}:${statusText}(${status})`);
  5546. return false;
  5547. } catch (error) {
  5548. throwError(error, 'Steam.joinGroup');
  5549. return false;
  5550. }
  5551. }
  5552. async function _leaveGroup2(groupName) {
  5553. try {
  5554. if (this.whiteList.groups.includes(groupName)) {
  5555. scripts_echoLog({
  5556. type: 'whiteList',
  5557. text: 'Steam.leaveGroup',
  5558. id: groupName
  5559. });
  5560. return true;
  5561. }
  5562. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5563. if (!groupId) {
  5564. return false;
  5565. }
  5566. const logStatus = scripts_echoLog({
  5567. type: 'leavingSteamGroup',
  5568. text: groupName
  5569. });
  5570. const {
  5571. result,
  5572. statusText,
  5573. status,
  5574. data
  5575. } = await tools_httpRequest({
  5576. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5577. method: 'POST',
  5578. headers: {
  5579. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5580. },
  5581. data: $.param({
  5582. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5583. action: 'leaveGroup',
  5584. groupId: groupId
  5585. })
  5586. });
  5587. if (result === 'Success') {
  5588. 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) {
  5589. logStatus.success();
  5590. return true;
  5591. }
  5592. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5593. return false;
  5594. }
  5595. logStatus.error(`${result}:${statusText}(${status})`);
  5596. return false;
  5597. } catch (error) {
  5598. throwError(error, 'Steam.leaveGroup');
  5599. return false;
  5600. }
  5601. }
  5602. async function _getGroupId2(groupName) {
  5603. try {
  5604. const logStatus = scripts_echoLog({
  5605. type: 'gettingSteamGroupId',
  5606. text: groupName
  5607. });
  5608. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5609. if (groupId) {
  5610. logStatus.success();
  5611. return groupId;
  5612. }
  5613. const {
  5614. result,
  5615. statusText,
  5616. status,
  5617. data
  5618. } = await tools_httpRequest({
  5619. url: `https://steamcommunity.com/groups/${groupName}`,
  5620. method: 'GET',
  5621. headers: {
  5622. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5623. }
  5624. });
  5625. if (result === 'Success') {
  5626. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5627. var _data$responseText$ma7;
  5628. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5629. if (groupId) {
  5630. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5631. logStatus.success();
  5632. return groupId;
  5633. }
  5634. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5635. return false;
  5636. }
  5637. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5638. return false;
  5639. }
  5640. logStatus.error(`${result}:${statusText}(${status})`);
  5641. return false;
  5642. } catch (error) {
  5643. throwError(error, 'Steam.getGroupID');
  5644. return false;
  5645. }
  5646. }
  5647. async function _joinOfficialGroup2(gameId) {
  5648. try {
  5649. const logStatus = scripts_echoLog({
  5650. type: 'joiningSteamOfficialGroup',
  5651. text: gameId
  5652. });
  5653. const {
  5654. result,
  5655. statusText,
  5656. status,
  5657. data
  5658. } = await tools_httpRequest({
  5659. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5660. method: 'GET',
  5661. headers: {
  5662. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5663. }
  5664. });
  5665. if (result === 'Success') {
  5666. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5667. var _data$responseText$ma8;
  5668. logStatus.success();
  5669. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5670. 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];
  5671. if (groupId) {
  5672. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5673. }
  5674. return true;
  5675. }
  5676. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5677. return false;
  5678. }
  5679. logStatus.error(`${result}:${statusText}(${status})`);
  5680. return false;
  5681. } catch (error) {
  5682. throwError(error, 'Steam.joinOfficialGroup');
  5683. return false;
  5684. }
  5685. }
  5686. async function _leaveOfficialGroup2(gameId) {
  5687. try {
  5688. if (this.whiteList.officialGroups.includes(gameId)) {
  5689. scripts_echoLog({
  5690. type: 'whiteList',
  5691. text: 'Steam.leaveOfficialGroup',
  5692. id: gameId
  5693. });
  5694. return true;
  5695. }
  5696. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5697. if (!groupId) {
  5698. return false;
  5699. }
  5700. const logStatus = scripts_echoLog({
  5701. type: 'leavingSteamOfficialGroup',
  5702. text: gameId
  5703. });
  5704. const {
  5705. result,
  5706. statusText,
  5707. status,
  5708. data
  5709. } = await tools_httpRequest({
  5710. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5711. method: 'POST',
  5712. headers: {
  5713. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5714. },
  5715. data: $.param({
  5716. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5717. action: 'leaveGroup',
  5718. groupId: groupId
  5719. })
  5720. });
  5721. if (result === 'Success') {
  5722. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5723. const {
  5724. result: resultR,
  5725. statusText: statusTextR,
  5726. status: statusR,
  5727. data: dataR
  5728. } = await tools_httpRequest({
  5729. url: `https://steamcommunity.com/games/${gameId}`,
  5730. method: 'GET',
  5731. headers: {
  5732. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5733. }
  5734. });
  5735. if (resultR === 'Success') {
  5736. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5737. logStatus.success();
  5738. return true;
  5739. }
  5740. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5741. return false;
  5742. }
  5743. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5744. return false;
  5745. }
  5746. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5747. return false;
  5748. }
  5749. logStatus.error(`${result}:${statusText}(${status})`);
  5750. return false;
  5751. } catch (error) {
  5752. throwError(error, 'Steam.leaveOfficialGroup');
  5753. return false;
  5754. }
  5755. }
  5756. async function _getOfficialGroupId2(gameId) {
  5757. try {
  5758. const logStatus = scripts_echoLog({
  5759. type: 'gettingSteamOfficialGroupId',
  5760. text: gameId
  5761. });
  5762. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5763. if (groupId) {
  5764. logStatus.success();
  5765. return groupId;
  5766. }
  5767. const {
  5768. result,
  5769. statusText,
  5770. status,
  5771. data
  5772. } = await tools_httpRequest({
  5773. url: `https://steamcommunity.com/games/${gameId}`,
  5774. method: 'GET',
  5775. headers: {
  5776. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5777. }
  5778. });
  5779. if (result === 'Success') {
  5780. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5781. var _data$responseText$ma9;
  5782. const groupId = (_data$responseText$ma9 = data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)) === null || _data$responseText$ma9 === void 0 ? void 0 : _data$responseText$ma9[1];
  5783. if (groupId) {
  5784. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5785. logStatus.success();
  5786. return groupId;
  5787. }
  5788. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5789. return false;
  5790. }
  5791. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5792. return false;
  5793. }
  5794. logStatus.error(`${result}:${statusText}(${status})`);
  5795. return false;
  5796. } catch (error) {
  5797. throwError(error, 'Steam.getGroupID');
  5798. return false;
  5799. }
  5800. }
  5801. async function _addToWishlist2(gameId) {
  5802. try {
  5803. var _data$response;
  5804. const logStatus = scripts_echoLog({
  5805. type: 'addingToWishlist',
  5806. text: gameId
  5807. });
  5808. const {
  5809. result,
  5810. data
  5811. } = await tools_httpRequest({
  5812. url: 'https://store.steampowered.com/api/addtowishlist',
  5813. method: 'POST',
  5814. headers: {
  5815. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5816. },
  5817. data: $.param({
  5818. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5819. appid: gameId
  5820. }),
  5821. dataType: 'json'
  5822. });
  5823. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.success) === true) {
  5824. logStatus.success();
  5825. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5826. return true;
  5827. }
  5828. const {
  5829. result: resultR,
  5830. statusText: statusTextR,
  5831. status: statusR,
  5832. data: dataR
  5833. } = await tools_httpRequest({
  5834. url: `https://store.steampowered.com/app/${gameId}`,
  5835. method: 'GET'
  5836. });
  5837. if (resultR === 'Success') {
  5838. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5839. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5840. logStatus.warning(i18n('changeAreaNotice'));
  5841. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5842. return false;
  5843. }
  5844. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5845. }
  5846. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5847. logStatus.success();
  5848. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5849. return true;
  5850. } 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"')) {
  5851. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5852. return false;
  5853. }
  5854. logStatus.success();
  5855. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5856. return true;
  5857. }
  5858. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5859. return false;
  5860. }
  5861. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5862. return false;
  5863. } catch (error) {
  5864. throwError(error, 'Steam.addToWishlist');
  5865. return false;
  5866. }
  5867. }
  5868. async function _removeFromWishlist2(gameId) {
  5869. try {
  5870. var _data$response2;
  5871. if (this.whiteList.wishlists.includes(gameId)) {
  5872. scripts_echoLog({
  5873. type: 'whiteList',
  5874. text: 'Steam.removeFromWishlist',
  5875. id: gameId
  5876. });
  5877. return true;
  5878. }
  5879. const logStatus = scripts_echoLog({
  5880. type: 'removingFromWishlist',
  5881. text: gameId
  5882. });
  5883. const {
  5884. result,
  5885. data
  5886. } = await tools_httpRequest({
  5887. url: 'https://store.steampowered.com/api/removefromwishlist',
  5888. method: 'POST',
  5889. headers: {
  5890. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5891. },
  5892. data: $.param({
  5893. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5894. appid: gameId
  5895. }),
  5896. dataType: 'json'
  5897. });
  5898. 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) {
  5899. logStatus.success();
  5900. return true;
  5901. }
  5902. const {
  5903. result: resultR,
  5904. statusText: statusTextR,
  5905. status: statusR,
  5906. data: dataR
  5907. } = await tools_httpRequest({
  5908. url: `https://store.steampowered.com/app/${gameId}`,
  5909. method: 'GET'
  5910. });
  5911. if (resultR === 'Success') {
  5912. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5913. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5914. logStatus.warning(i18n('changeAreaNotice'));
  5915. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5916. if (!result || result === 'CN' || result === 'skip') {
  5917. return false;
  5918. }
  5919. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5920. }
  5921. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5922. logStatus.success();
  5923. return true;
  5924. }
  5925. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5926. return false;
  5927. }
  5928. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5929. return false;
  5930. }
  5931. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5932. return false;
  5933. } catch (error) {
  5934. throwError(error, 'Steam.removeFromWishlist');
  5935. return false;
  5936. }
  5937. }
  5938. async function _toggleFollowGame2(gameId, doTask) {
  5939. try {
  5940. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5941. scripts_echoLog({
  5942. type: 'whiteList',
  5943. text: 'Steam.unfollowGame',
  5944. id: gameId
  5945. });
  5946. return true;
  5947. }
  5948. const logStatus = scripts_echoLog({
  5949. type: `${doTask ? '' : 'un'}followingGame`,
  5950. text: gameId
  5951. });
  5952. const requestData = {
  5953. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5954. appid: gameId
  5955. };
  5956. if (!doTask) {
  5957. requestData.unfollow = '1';
  5958. }
  5959. const {
  5960. result,
  5961. data
  5962. } = await tools_httpRequest({
  5963. url: 'https://store.steampowered.com/explore/followgame/',
  5964. method: 'POST',
  5965. headers: {
  5966. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5967. },
  5968. data: $.param(requestData)
  5969. });
  5970. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5971. logStatus.success();
  5972. return true;
  5973. }
  5974. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5975. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5976. logStatus.warning(i18n('changeAreaNotice'));
  5977. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5978. return false;
  5979. }
  5980. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5981. }
  5982. if (doTask === followed) {
  5983. logStatus.success();
  5984. if (doTask) {
  5985. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5986. }
  5987. return true;
  5988. }
  5989. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5990. return false;
  5991. } catch (error) {
  5992. throwError(error, 'Steam.toggleFollowGame');
  5993. return false;
  5994. }
  5995. }
  5996. async function _isFollowedGame2(gameId) {
  5997. try {
  5998. const {
  5999. result,
  6000. data
  6001. } = await tools_httpRequest({
  6002. url: `https://store.steampowered.com/app/${gameId}`,
  6003. method: 'GET'
  6004. });
  6005. if (result === 'Success') {
  6006. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6007. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6008. return 'areaLocked';
  6009. }
  6010. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  6011. return true;
  6012. }
  6013. return false;
  6014. }
  6015. return false;
  6016. }
  6017. return false;
  6018. } catch (error) {
  6019. throwError(error, 'Steam.isFollowedGame');
  6020. return false;
  6021. }
  6022. }
  6023. async function _toggleForum2(gameId) {
  6024. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6025. try {
  6026. if (!doTask && this.whiteList.forums.includes(gameId)) {
  6027. scripts_echoLog({
  6028. type: 'whiteList',
  6029. text: 'Steam.unsubscribeForum',
  6030. id: gameId
  6031. });
  6032. return true;
  6033. }
  6034. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  6035. if (!forumId) {
  6036. return false;
  6037. }
  6038. const logStatus = scripts_echoLog({
  6039. type: `${doTask ? '' : 'un'}subscribingForum`,
  6040. text: gameId
  6041. });
  6042. const [ id, feature ] = forumId.split('_');
  6043. const {
  6044. result,
  6045. statusText,
  6046. status,
  6047. data
  6048. } = await tools_httpRequest({
  6049. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  6050. method: 'POST',
  6051. responseType: 'json',
  6052. headers: {
  6053. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6054. },
  6055. data: $.param({
  6056. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6057. })
  6058. });
  6059. if (result === 'Success') {
  6060. var _data$response3, _data$response4;
  6061. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (((_data$response3 = data.response) === null || _data$response3 === void 0 ? void 0 : _data$response3.success) === 1 || ((_data$response4 = data.response) === null || _data$response4 === void 0 ? void 0 : _data$response4.success) === 29)) {
  6062. if (doTask) {
  6063. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  6064. }
  6065. logStatus.success();
  6066. return true;
  6067. }
  6068. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6069. return true;
  6070. }
  6071. logStatus.error(`${result}:${statusText}(${status})`);
  6072. return true;
  6073. } catch (error) {
  6074. throwError(error, 'Steam.toggleForum');
  6075. return true;
  6076. }
  6077. }
  6078. async function _getForumId2(gameId) {
  6079. try {
  6080. const logStatus = scripts_echoLog({
  6081. type: 'gettingForumId',
  6082. text: gameId
  6083. });
  6084. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  6085. if (forumId) {
  6086. logStatus.success();
  6087. return forumId;
  6088. }
  6089. const {
  6090. result,
  6091. statusText,
  6092. status,
  6093. data
  6094. } = await tools_httpRequest({
  6095. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  6096. method: 'GET'
  6097. });
  6098. if (result === 'Success') {
  6099. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6100. var _data$responseText, _data$responseText$ma10;
  6101. const forumId = (_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : (_data$responseText$ma10 = _data$responseText.match(/General_([\d]+(_[\d]+)?)/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  6102. if (forumId) {
  6103. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  6104. logStatus.success();
  6105. return forumId;
  6106. }
  6107. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6108. return false;
  6109. }
  6110. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6111. return false;
  6112. }
  6113. logStatus.error(`${result}:${statusText}(${status})`);
  6114. return false;
  6115. } catch (error) {
  6116. throwError(error, 'Steam.getForumId');
  6117. return false;
  6118. }
  6119. }
  6120. async function _toggleFavoriteWorkshop2(id) {
  6121. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6122. try {
  6123. if (!doTask && this.whiteList.workshops.includes(id)) {
  6124. scripts_echoLog({
  6125. type: 'whiteList',
  6126. text: 'Steam.unfavoriteWorkshop',
  6127. id: id
  6128. });
  6129. return true;
  6130. }
  6131. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  6132. if (!appid) {
  6133. return false;
  6134. }
  6135. const logStatus = scripts_echoLog({
  6136. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  6137. text: id
  6138. });
  6139. const {
  6140. result,
  6141. statusText,
  6142. status,
  6143. data
  6144. } = await tools_httpRequest({
  6145. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  6146. method: 'POST',
  6147. headers: {
  6148. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6149. },
  6150. data: $.param({
  6151. id: id,
  6152. appid: appid,
  6153. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6154. })
  6155. });
  6156. if (result === 'Success') {
  6157. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  6158. if (doTask) {
  6159. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  6160. }
  6161. logStatus.success();
  6162. return true;
  6163. }
  6164. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6165. return false;
  6166. }
  6167. logStatus.error(`${result}:${statusText}(${status})`);
  6168. return false;
  6169. } catch (error) {
  6170. throwError(error, 'Steam.toggleFavoriteWorkshop');
  6171. return false;
  6172. }
  6173. }
  6174. async function _getWorkshopAppId2(id) {
  6175. try {
  6176. const logStatus = scripts_echoLog({
  6177. type: 'gettingWorkshopAppId',
  6178. text: id
  6179. });
  6180. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  6181. if (appId) {
  6182. logStatus.success();
  6183. return appId;
  6184. }
  6185. const {
  6186. result,
  6187. statusText,
  6188. status,
  6189. data
  6190. } = await tools_httpRequest({
  6191. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6192. method: 'GET'
  6193. });
  6194. if (result === 'Success') {
  6195. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6196. var _data$responseText$ma11;
  6197. const appId = (_data$responseText$ma11 = data.responseText.match(/<input type="hidden" name="appid" value="([\d]+?)" \/>/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  6198. if (appId) {
  6199. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6200. logStatus.success();
  6201. return appId;
  6202. }
  6203. logStatus.error('Error: getWorkshopAppId failed');
  6204. return false;
  6205. }
  6206. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6207. return false;
  6208. }
  6209. logStatus.error(`${result}:${statusText}(${status})`);
  6210. return false;
  6211. } catch (error) {
  6212. throwError(error, 'Steam.getWorkshopAppId');
  6213. return false;
  6214. }
  6215. }
  6216. async function _voteUpWorkshop2(id) {
  6217. try {
  6218. const logStatus = scripts_echoLog({
  6219. type: 'votingUpWorkshop',
  6220. text: id
  6221. });
  6222. const {
  6223. result,
  6224. statusText,
  6225. status,
  6226. data
  6227. } = await tools_httpRequest({
  6228. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6229. method: 'POST',
  6230. responseType: 'json',
  6231. headers: {
  6232. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6233. },
  6234. data: $.param({
  6235. id: id,
  6236. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6237. })
  6238. });
  6239. if (result === 'Success') {
  6240. var _data$response5;
  6241. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response5 = data.response) === null || _data$response5 === void 0 ? void 0 : _data$response5.success) === 1) {
  6242. logStatus.success();
  6243. return true;
  6244. }
  6245. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6246. return true;
  6247. }
  6248. logStatus.error(`${result}:${statusText}(${status})`);
  6249. return true;
  6250. } catch (error) {
  6251. throwError(error, 'Steam.voteupWorkshop');
  6252. return true;
  6253. }
  6254. }
  6255. async function _toggleCurator2(curatorId) {
  6256. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6257. try {
  6258. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6259. scripts_echoLog({
  6260. type: 'whiteList',
  6261. text: 'Steam.unfollowCurator',
  6262. id: curatorId
  6263. });
  6264. return true;
  6265. }
  6266. const logStatus = scripts_echoLog({
  6267. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6268. text: curatorId
  6269. });
  6270. const {
  6271. result,
  6272. statusText,
  6273. status,
  6274. data
  6275. } = await tools_httpRequest({
  6276. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6277. method: 'POST',
  6278. headers: {
  6279. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6280. },
  6281. data: $.param({
  6282. clanid: curatorId,
  6283. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6284. follow: doTask
  6285. }),
  6286. dataType: 'json'
  6287. });
  6288. if (result === 'Success') {
  6289. var _data$response6, _data$response6$succe, _data$response7;
  6290. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response6 = data.response) === null || _data$response6 === void 0 ? void 0 : (_data$response6$succe = _data$response6.success) === null || _data$response6$succe === void 0 ? void 0 : _data$response6$succe.success) === 1) {
  6291. logStatus.success();
  6292. return true;
  6293. }
  6294. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : (_data$response7 = data.response) === null || _data$response7 === void 0 ? void 0 : _data$response7.success}` || `${data === null || data === void 0 ? void 0 : data.status})`);
  6295. return false;
  6296. }
  6297. logStatus.error(`${result}:${statusText}(${status})`);
  6298. return false;
  6299. } catch (error) {
  6300. throwError(error, 'Steam.toggleCurator');
  6301. return false;
  6302. }
  6303. }
  6304. async function _toggleCuratorLike2(link) {
  6305. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6306. try {
  6307. const [ path, name ] = link.split('/');
  6308. if (!(path && name)) {
  6309. scripts_echoLog({
  6310. text: i18n('errorLink', link)
  6311. });
  6312. return false;
  6313. }
  6314. const curatorId = await this.getCuratorId(path, name);
  6315. if (curatorId) {
  6316. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6317. }
  6318. return false;
  6319. } catch (error) {
  6320. throwError(error, 'Steam.toggleCuratorLike');
  6321. return false;
  6322. }
  6323. }
  6324. async function _getAnnouncementParams2(appId, viewId) {
  6325. try {
  6326. const logStatus = scripts_echoLog({
  6327. type: 'gettingAnnouncementParams',
  6328. text: appId,
  6329. id: viewId
  6330. });
  6331. const {
  6332. result,
  6333. statusText,
  6334. status,
  6335. data
  6336. } = await tools_httpRequest({
  6337. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6338. method: 'GET',
  6339. headers: {
  6340. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6341. }
  6342. });
  6343. if (result === 'Success') {
  6344. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6345. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6346. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6347. logStatus.warning(i18n('changeAreaNotice'));
  6348. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6349. return {};
  6350. }
  6351. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6352. }
  6353. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6354. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6355. const gid = (_data$responseText$ma14 = data.responseText.match(/announcementGID&quot;:&quot;([\d]+?)&quot;/)) === null || _data$responseText$ma14 === void 0 ? void 0 : _data$responseText$ma14[1];
  6356. if (authWgToken && clanId) {
  6357. logStatus.success();
  6358. return {
  6359. authWgToken: authWgToken,
  6360. clanId: clanId,
  6361. gid: gid
  6362. };
  6363. }
  6364. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6365. return {};
  6366. }
  6367. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6368. return {};
  6369. }
  6370. logStatus.error(`${result}:${statusText}(${status})`);
  6371. return {};
  6372. } catch (error) {
  6373. throwError(error, 'Steam.likeAnnouncement');
  6374. return {};
  6375. }
  6376. }
  6377. async function _likeAnnouncement2(id) {
  6378. try {
  6379. const [ appId, viewId ] = id.split('/');
  6380. if (!(appId && viewId)) {
  6381. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6382. return false;
  6383. }
  6384. const {
  6385. authWgToken,
  6386. clanId,
  6387. gid
  6388. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6389. if (!(authWgToken && clanId)) {
  6390. return false;
  6391. }
  6392. const logStatus = scripts_echoLog({
  6393. type: 'likingAnnouncement',
  6394. text: appId,
  6395. id: viewId
  6396. });
  6397. const {
  6398. result,
  6399. statusText,
  6400. status,
  6401. data
  6402. } = await tools_httpRequest({
  6403. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6404. method: 'POST',
  6405. headers: {
  6406. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6407. Host: 'store.steampowered.com',
  6408. Origin: 'https://store.steampowered.com',
  6409. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6410. },
  6411. data: $.param({
  6412. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6413. wgauthtoken: authWgToken,
  6414. voteup: 1,
  6415. clanid: clanId,
  6416. ajax: 1
  6417. }),
  6418. dataType: 'json'
  6419. });
  6420. if (result === 'Success') {
  6421. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6422. logStatus.success();
  6423. return true;
  6424. }
  6425. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6426. return false;
  6427. }
  6428. logStatus.error(`${result}:${statusText}(${status})`);
  6429. return false;
  6430. } catch (error) {
  6431. throwError(error, 'Steam.likeAnnouncement');
  6432. return false;
  6433. }
  6434. }
  6435. async function _appid2subid2(id) {
  6436. try {
  6437. const logStatus = scripts_echoLog({
  6438. type: 'gettingSubid',
  6439. text: id
  6440. });
  6441. const {
  6442. result,
  6443. statusText,
  6444. status,
  6445. data
  6446. } = await tools_httpRequest({
  6447. url: `https://store.steampowered.com/app/${id}`,
  6448. method: 'GET',
  6449. headers: {
  6450. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6451. }
  6452. });
  6453. if (result === 'Success') {
  6454. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6455. var _data$responseText$ma15;
  6456. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6457. logStatus.warning(i18n('changeAreaNotice'));
  6458. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6459. if (!result || result === 'CN' || result === 'skip') {
  6460. return false;
  6461. }
  6462. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6463. }
  6464. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6465. if (subid) {
  6466. logStatus.success();
  6467. return subid;
  6468. }
  6469. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6470. return false;
  6471. }
  6472. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6473. return false;
  6474. }
  6475. logStatus.error(`${result}:${statusText}(${status})`);
  6476. return false;
  6477. } catch (error) {
  6478. throwError(error, 'Steam.appid2subid');
  6479. return false;
  6480. }
  6481. }
  6482. async function _getLicenses2() {
  6483. try {
  6484. const logStatus = scripts_echoLog({
  6485. text: i18n('gettingLicenses')
  6486. });
  6487. const {
  6488. result,
  6489. statusText,
  6490. status,
  6491. data
  6492. } = await tools_httpRequest({
  6493. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  6494. method: 'GET',
  6495. responseType: 'json'
  6496. });
  6497. if (result === 'Success') {
  6498. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6499. var _data$response8;
  6500. logStatus.success();
  6501. return (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.rgOwnedPackages;
  6502. }
  6503. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6504. return false;
  6505. }
  6506. logStatus.error(`${result}:${statusText}(${status})`);
  6507. return false;
  6508. } catch (error) {
  6509. throwError(error, 'Steam.getLicenses');
  6510. return false;
  6511. }
  6512. }
  6513. async function _addLicense2(id) {
  6514. try {
  6515. const [ type, ids ] = id.split('-');
  6516. if (type === 'appid') {
  6517. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6518. if (!subid) {
  6519. return false;
  6520. }
  6521. const logStatus = scripts_echoLog({
  6522. type: 'addingFreeLicense',
  6523. text: ids
  6524. });
  6525. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6526. return false;
  6527. }
  6528. const {
  6529. result,
  6530. statusText,
  6531. status,
  6532. data
  6533. } = await tools_httpRequest({
  6534. url: `https://store.steampowered.com/app/${ids}`,
  6535. method: 'GET'
  6536. });
  6537. if (result === 'Success') {
  6538. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6539. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6540. logStatus.success();
  6541. return true;
  6542. }
  6543. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6544. return false;
  6545. }
  6546. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6547. return false;
  6548. }
  6549. logStatus.error(`${result}:${statusText}(${status})`);
  6550. return false;
  6551. } else if (type === 'subid') {
  6552. if (Steam_classPrivateFieldGet(this, _area) === 'CN') {
  6553. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  6554. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6555. }
  6556. const logStatusArr = {};
  6557. const idsArr = ids.split(',');
  6558. for (const subid of idsArr) {
  6559. const logStatus = scripts_echoLog({
  6560. type: 'addingFreeLicenseSubid',
  6561. text: subid
  6562. });
  6563. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6564. return false;
  6565. }
  6566. logStatusArr[subid] = logStatus;
  6567. }
  6568. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6569. if (!licenses) {
  6570. return false;
  6571. }
  6572. for (const subid of idsArr) {
  6573. if (licenses.includes(parseInt(subid, 10))) {
  6574. logStatusArr[subid].success();
  6575. } else {
  6576. logStatusArr[subid].error();
  6577. }
  6578. }
  6579. return true;
  6580. }
  6581. return false;
  6582. } catch (error) {
  6583. throwError(error, 'Steam.addLicense');
  6584. return false;
  6585. }
  6586. }
  6587. async function _addFreeLicense2(id, logStatusPre) {
  6588. try {
  6589. const logStatus = logStatusPre || scripts_echoLog({
  6590. type: 'addingFreeLicenseSubid',
  6591. text: id
  6592. });
  6593. const {
  6594. result,
  6595. statusText,
  6596. status,
  6597. data
  6598. } = await tools_httpRequest({
  6599. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6600. method: 'POST',
  6601. headers: {
  6602. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6603. Host: 'store.steampowered.com',
  6604. Origin: 'https://store.steampowered.com',
  6605. Referer: 'https://store.steampowered.com/account/licenses/'
  6606. },
  6607. data: $.param({
  6608. action: 'add_to_cart',
  6609. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6610. subid: id
  6611. }),
  6612. dataType: 'json'
  6613. });
  6614. if (result === 'Success') {
  6615. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6616. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6617. logStatus.warning(i18n('changeAreaNotice'));
  6618. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6619. if (!result || result === 'CN') {
  6620. return false;
  6621. }
  6622. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6623. }
  6624. logStatus.success();
  6625. return true;
  6626. }
  6627. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6628. return false;
  6629. }
  6630. logStatus.error(`${result}:${statusText}(${status})`);
  6631. return false;
  6632. } catch (error) {
  6633. throwError(error, 'Steam.addFreeLicense');
  6634. return false;
  6635. }
  6636. }
  6637. async function _requestPlayTestAccess2(id) {
  6638. try {
  6639. const logStatus = scripts_echoLog({
  6640. type: 'requestingPlayTestAccess',
  6641. text: id
  6642. });
  6643. const {
  6644. result,
  6645. statusText,
  6646. status,
  6647. data
  6648. } = await tools_httpRequest({
  6649. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6650. method: 'POST',
  6651. headers: {
  6652. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6653. Host: 'store.steampowered.com',
  6654. Origin: 'https://store.steampowered.com',
  6655. Referer: `https://store.steampowered.com/app/${id}`
  6656. },
  6657. data: $.param({
  6658. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6659. }),
  6660. dataType: 'json'
  6661. });
  6662. if (result === 'Success') {
  6663. var _data$response9;
  6664. 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) {
  6665. logStatus.success();
  6666. return true;
  6667. }
  6668. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6669. return false;
  6670. }
  6671. logStatus.error(`${result}:${statusText}(${status})`);
  6672. return false;
  6673. } catch (error) {
  6674. throwError(error, 'Steam.requestPlayTestAccess');
  6675. return false;
  6676. }
  6677. }
  6678. function Steam_setCache2(type, name, id) {
  6679. try {
  6680. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6681. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6682. } catch (error) {
  6683. throwError(error, 'Steam.setCache');
  6684. }
  6685. }
  6686. const social_Steam = Steam;
  6687. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6688. Website_checkPrivateRedeclaration(obj, privateSet);
  6689. privateSet.add(obj);
  6690. }
  6691. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6692. if (privateCollection.has(obj)) {
  6693. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6694. }
  6695. }
  6696. function Website_defineProperty(obj, key, value) {
  6697. if (key in obj) {
  6698. Object.defineProperty(obj, key, {
  6699. value: value,
  6700. enumerable: true,
  6701. configurable: true,
  6702. writable: true
  6703. });
  6704. } else {
  6705. obj[key] = value;
  6706. }
  6707. return obj;
  6708. }
  6709. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6710. if (!privateSet.has(receiver)) {
  6711. throw new TypeError('attempted to get private field on non-instance');
  6712. }
  6713. return fn;
  6714. }
  6715. var _bind = new WeakSet();
  6716. class Website {
  6717. constructor() {
  6718. Website_classPrivateMethodInitSpec(this, _bind);
  6719. Website_defineProperty(this, 'undoneTasks', void 0);
  6720. Website_defineProperty(this, 'socialTasks', void 0);
  6721. Website_defineProperty(this, 'giveawayId', void 0);
  6722. Website_defineProperty(this, 'socialInitialized', {
  6723. discord: false,
  6724. instagram: false,
  6725. reddit: false,
  6726. twitch: false,
  6727. twitter: false,
  6728. vk: false,
  6729. youtube: false,
  6730. steamStore: false,
  6731. steamCommunity: false
  6732. });
  6733. Website_defineProperty(this, 'initialized', false);
  6734. Website_defineProperty(this, 'social', {});
  6735. }
  6736. async initSocial(action) {
  6737. try {
  6738. const pro = [];
  6739. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6740. if (tasks.discord) {
  6741. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6742. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6743. this.social.discord = new social_Discord();
  6744. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6745. }
  6746. }
  6747. if (tasks.instagram) {
  6748. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6749. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6750. this.social.instagram = new social_Instagram();
  6751. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6752. }
  6753. }
  6754. if (tasks.reddit) {
  6755. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6756. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6757. this.social.reddit = new social_Reddit();
  6758. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6759. }
  6760. }
  6761. if (tasks.twitch) {
  6762. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6763. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6764. this.social.twitch = new social_Twitch();
  6765. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6766. }
  6767. }
  6768. if (tasks.twitter) {
  6769. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6770. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6771. this.social.twitter = new social_Twitter();
  6772. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6773. }
  6774. }
  6775. if (tasks.vk) {
  6776. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6777. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6778. this.social.vk = new social_Vk();
  6779. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6780. }
  6781. }
  6782. if (tasks.youtube) {
  6783. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6784. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6785. this.social.youtube = new Youtube();
  6786. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6787. }
  6788. }
  6789. if (tasks.steam) {
  6790. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6791. if (steamLength > 0) {
  6792. if (!this.social.steam) {
  6793. this.social.steam = new social_Steam();
  6794. }
  6795. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6796. var _tasks$steam, _tasks$steam$type;
  6797. 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;
  6798. }).reduce((total, number) => total + number, 0);
  6799. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6800. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6801. }
  6802. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6803. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6804. }
  6805. }
  6806. }
  6807. if (tasks.links && tasks.links.length > 0) {
  6808. this.social.visitLink = visitLink;
  6809. }
  6810. return await Promise.all(pro).then(result => {
  6811. let checked = true;
  6812. for (const data of result) {
  6813. if (data.result) {
  6814. this.socialInitialized[data.name] = data.result;
  6815. } else {
  6816. checked = false;
  6817. }
  6818. }
  6819. return checked;
  6820. });
  6821. } catch (error) {
  6822. throwError(error, 'Website.initSocial');
  6823. return false;
  6824. }
  6825. }
  6826. uniqueTasks(allTasks) {
  6827. const result = {};
  6828. for (const [ social, types ] of Object.entries(allTasks)) {
  6829. result[social] = {};
  6830. for (const [ type, tasks ] of Object.entries(types)) {
  6831. result[social][type] = unique(tasks);
  6832. }
  6833. }
  6834. return result;
  6835. }
  6836. async toggleTask(action) {
  6837. try {
  6838. if (!this.initialized && !this.init()) {
  6839. return false;
  6840. }
  6841. if (!await this.classifyTask(action)) {
  6842. return false;
  6843. }
  6844. if (!await this.initSocial(action)) {
  6845. return false;
  6846. }
  6847. const pro = [];
  6848. const doTask = action === 'do';
  6849. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6850. if (this.socialInitialized.discord !== 'skip' && this.social.discord) {
  6851. pro.push(this.social.discord.toggle({
  6852. doTask: doTask,
  6853. ...tasks.discord
  6854. }));
  6855. }
  6856. if (this.social.instagram) {
  6857. pro.push(this.social.instagram.toggle({
  6858. doTask: doTask,
  6859. ...tasks.instagram
  6860. }));
  6861. }
  6862. if (this.social.reddit) {
  6863. pro.push(this.social.reddit.toggle({
  6864. doTask: doTask,
  6865. ...tasks.reddit
  6866. }));
  6867. }
  6868. if (this.social.twitch) {
  6869. pro.push(this.social.twitch.toggle({
  6870. doTask: doTask,
  6871. ...tasks.twitch
  6872. }));
  6873. }
  6874. if (this.social.twitter) {
  6875. pro.push(this.social.twitter.toggle({
  6876. doTask: doTask,
  6877. ...tasks.twitter
  6878. }));
  6879. }
  6880. if (this.social.vk) {
  6881. pro.push(this.social.vk.toggle({
  6882. doTask: doTask,
  6883. ...tasks.vk
  6884. }));
  6885. }
  6886. if (this.social.youtube) {
  6887. pro.push(this.social.youtube.toggle({
  6888. doTask: doTask,
  6889. ...tasks.youtube
  6890. }));
  6891. }
  6892. if (this.social.steam) {
  6893. pro.push(this.social.steam.toggle({
  6894. doTask: doTask,
  6895. ...tasks.steam
  6896. }));
  6897. }
  6898. if (this.social.visitLink && tasks.links && doTask) {
  6899. for (const link of tasks.links) {
  6900. pro.push(this.social.visitLink(link));
  6901. }
  6902. }
  6903. if (doTask && tasks.extra && this.extraDoTask) {
  6904. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6905. if (hasExtra) {
  6906. pro.push(this.extraDoTask(tasks.extra));
  6907. }
  6908. }
  6909. await Promise.all(pro);
  6910. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6911. return true;
  6912. } catch (error) {
  6913. throwError(error, 'Website.toggleTask');
  6914. return false;
  6915. }
  6916. }
  6917. async doTask() {
  6918. try {
  6919. return await this.toggleTask('do');
  6920. } catch (error) {
  6921. throwError(error, 'Website.doTask');
  6922. return false;
  6923. }
  6924. }
  6925. async undoTask() {
  6926. try {
  6927. return await this.toggleTask('undo');
  6928. } catch (error) {
  6929. throwError(error, 'Website.undoTask');
  6930. return false;
  6931. }
  6932. }
  6933. }
  6934. async function _bind2(name, init) {
  6935. try {
  6936. return {
  6937. name: name,
  6938. result: await init
  6939. };
  6940. } catch (error) {
  6941. throwError(error, 'Website.bind');
  6942. return {
  6943. name: name,
  6944. result: false
  6945. };
  6946. }
  6947. }
  6948. const website_Website = Website;
  6949. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6950. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6951. privateSet.add(obj);
  6952. }
  6953. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6954. if (privateCollection.has(obj)) {
  6955. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6956. }
  6957. }
  6958. function FreeAnyWhere_defineProperty(obj, key, value) {
  6959. if (key in obj) {
  6960. Object.defineProperty(obj, key, {
  6961. value: value,
  6962. enumerable: true,
  6963. configurable: true,
  6964. writable: true
  6965. });
  6966. } else {
  6967. obj[key] = value;
  6968. }
  6969. return obj;
  6970. }
  6971. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6972. if (!privateSet.has(receiver)) {
  6973. throw new TypeError('attempted to get private field on non-instance');
  6974. }
  6975. return fn;
  6976. }
  6977. const FreeAnyWhere_defaultTasksTemplate = {
  6978. steam: {
  6979. groupLinks: [],
  6980. wishlistLinks: [],
  6981. curatorLinks: [],
  6982. followLinks: []
  6983. },
  6984. vk: {
  6985. nameLinks: []
  6986. }
  6987. };
  6988. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6989. var _getGiveawayId = new WeakSet();
  6990. var _verify = new WeakSet();
  6991. var _checkLeftKey = new WeakSet();
  6992. class FreeAnyWhere extends website_Website {
  6993. constructor() {
  6994. super(...arguments);
  6995. FreeAnyWhere_classPrivateMethodInitSpec(this, _checkLeftKey);
  6996. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6997. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6998. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6999. FreeAnyWhere_defineProperty(this, 'tasks', []);
  7000. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  7001. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  7002. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  7003. }
  7004. static test() {
  7005. return window.location.host === 'freeanywhere.net';
  7006. }
  7007. async init() {
  7008. try {
  7009. const logStatus = scripts_echoLog({
  7010. text: i18n('initing')
  7011. });
  7012. if ($('a[href="#/login"]').length > 0) {
  7013. window.open('/#/login', '_self');
  7014. logStatus.warning(i18n('needLogin'));
  7015. return false;
  7016. }
  7017. if (window.location.href.includes('/login')) {
  7018. logStatus.warning(i18n('needLogin'));
  7019. return false;
  7020. }
  7021. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  7022. var _window$location$href;
  7023. 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];
  7024. if (!id) {
  7025. logStatus.error(i18n('getFailed', 'Id'));
  7026. return false;
  7027. }
  7028. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  7029. }
  7030. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  7031. return false;
  7032. }
  7033. if (!await FreeAnyWhere_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7034. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7035. }
  7036. this.initialized = true;
  7037. logStatus.success();
  7038. return true;
  7039. } catch (error) {
  7040. throwError(error, 'Freeanywhere.init');
  7041. return false;
  7042. }
  7043. }
  7044. async classifyTask(action) {
  7045. try {
  7046. const logStatus = scripts_echoLog({
  7047. text: i18n('getTasksInfo')
  7048. });
  7049. if (action === 'undo') {
  7050. var _GM_getValue;
  7051. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  7052. }
  7053. const {
  7054. result,
  7055. statusText,
  7056. status,
  7057. data
  7058. } = await tools_httpRequest({
  7059. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  7060. method: 'GET',
  7061. headers: {
  7062. authorization: `Token ${window.localStorage.getItem('token')}`,
  7063. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7064. },
  7065. responseType: 'json'
  7066. });
  7067. if (result === 'Success') {
  7068. var _data$response;
  7069. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  7070. if (tasks) {
  7071. if (action === 'verify') {
  7072. this.tasks = [];
  7073. }
  7074. for (const task of tasks) {
  7075. const type = task.challenge;
  7076. const social = task.challenge_provider;
  7077. const taskInfo = {
  7078. id: task.id,
  7079. title: task.title
  7080. };
  7081. if (action === 'verify' && !task.is_success) {
  7082. this.tasks.push(taskInfo);
  7083. continue;
  7084. }
  7085. switch (social) {
  7086. case 'steam':
  7087. taskInfo.social = 'steam';
  7088. switch (type) {
  7089. case 'WL':
  7090. if (action === 'undo') {
  7091. this.socialTasks.steam.wishlistLinks.push(task.link);
  7092. }
  7093. if (action === 'do' && !task.is_success) {
  7094. this.undoneTasks.steam.wishlistLinks.push(task.link);
  7095. }
  7096. break;
  7097.  
  7098. case 'JTG':
  7099. if (action === 'undo') {
  7100. this.socialTasks.steam.groupLinks.push(task.link);
  7101. }
  7102. if (action === 'do' && !task.is_success) {
  7103. this.undoneTasks.steam.groupLinks.push(task.link);
  7104. }
  7105. break;
  7106.  
  7107. case 'STC':
  7108. if (action === 'undo') {
  7109. this.socialTasks.steam.curatorLinks.push(task.link);
  7110. }
  7111. if (action === 'do' && !task.is_success) {
  7112. this.undoneTasks.steam.curatorLinks.push(task.link);
  7113. }
  7114. break;
  7115.  
  7116. case 'GF':
  7117. if (action === 'undo') {
  7118. this.socialTasks.steam.followLinks.push(task.link);
  7119. }
  7120. if (action === 'do' && !task.is_success) {
  7121. this.undoneTasks.steam.followLinks.push(task.link);
  7122. }
  7123. break;
  7124. }
  7125. break;
  7126.  
  7127. case 'vk-oauth2':
  7128. if (action === 'undo') {
  7129. this.socialTasks.vk.nameLinks.push(task.link);
  7130. }
  7131. if (action === 'do' && !task.is_success) {
  7132. this.undoneTasks.vk.nameLinks.push(task.link);
  7133. }
  7134. break;
  7135.  
  7136. case 'website':
  7137. break;
  7138.  
  7139. default:
  7140. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  7141. break;
  7142. }
  7143. }
  7144. logStatus.success();
  7145. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7146. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7147. if (window.DEBUG) {
  7148. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7149. }
  7150. GM_setValue(`fawTasks-${this.giveawayId}`, {
  7151. tasks: this.socialTasks,
  7152. time: new Date().getTime()
  7153. });
  7154. return true;
  7155. }
  7156. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7157. return false;
  7158. }
  7159. logStatus.error(`${result}:${statusText}(${status})`);
  7160. return false;
  7161. } catch (error) {
  7162. throwError(error, 'Freeanywhere.classifyTask');
  7163. return false;
  7164. }
  7165. }
  7166. async verifyTask() {
  7167. try {
  7168. if (!this.initialized && !this.init()) {
  7169. return false;
  7170. }
  7171. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7172. return false;
  7173. }
  7174. const pro = [];
  7175. for (const task of this.tasks) {
  7176. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  7177. await delay(1e3);
  7178. }
  7179. await Promise.all(pro);
  7180. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7181. return !!await this.getKey(true);
  7182. } catch (error) {
  7183. throwError(error, 'Freeanywhere.verifyTask');
  7184. return false;
  7185. }
  7186. }
  7187. async getKey(initialized) {
  7188. try {
  7189. if (!initialized && !this.initialized && !this.init()) {
  7190. return false;
  7191. }
  7192. const logStatus = scripts_echoLog({
  7193. text: i18n('gettingKey')
  7194. });
  7195. const {
  7196. result,
  7197. statusText,
  7198. status,
  7199. data
  7200. } = await tools_httpRequest({
  7201. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7202. method: 'GET',
  7203. dataType: 'json',
  7204. headers: {
  7205. authorization: `Token ${window.localStorage.getItem('token')}`
  7206. }
  7207. });
  7208. if (result === 'Success') {
  7209. var _data$response2;
  7210. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7211. logStatus.success();
  7212. scripts_echoLog({}).success(data.response.reward);
  7213. return data.response.reward;
  7214. }
  7215. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7216. return false;
  7217. }
  7218. logStatus.error(`${result}:${statusText}(${status})`);
  7219. return false;
  7220. } catch (error) {
  7221. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7222. return false;
  7223. }
  7224. }
  7225. }
  7226. function _getGiveawayId2() {
  7227. try {
  7228. var _window$location$href2;
  7229. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7230. if (giveawayId) {
  7231. this.giveawayId = giveawayId;
  7232. return true;
  7233. }
  7234. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7235. return false;
  7236. } catch (error) {
  7237. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7238. }
  7239. }
  7240. async function _verify2(task) {
  7241. try {
  7242. const logStatus = scripts_echoLog({
  7243. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7244. });
  7245. const {
  7246. result,
  7247. statusText,
  7248. status,
  7249. data
  7250. } = await tools_httpRequest({
  7251. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7252. method: 'GET',
  7253. dataType: 'json',
  7254. headers: {
  7255. authorization: `Token ${window.localStorage.getItem('token')}`,
  7256. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7257. }
  7258. });
  7259. if (result === 'Success') {
  7260. var _data$response3;
  7261. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7262. logStatus.success();
  7263. return true;
  7264. }
  7265. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7266. return false;
  7267. }
  7268. logStatus.error(`${result}:${statusText}(${status})`);
  7269. return false;
  7270. } catch (error) {
  7271. throwError(error, 'Freeanywhere.verify');
  7272. return false;
  7273. }
  7274. }
  7275. async function _checkLeftKey2() {
  7276. try {
  7277. var _data$response4;
  7278. if (!globalOptions.other.checkLeftKey) {
  7279. return true;
  7280. }
  7281. const {
  7282. data
  7283. } = await tools_httpRequest({
  7284. url: 'https://freeanywhere.net/api/v1/widget/?format=json',
  7285. method: 'GET',
  7286. dataType: 'json',
  7287. headers: {
  7288. authorization: `Token ${window.localStorage.getItem('token')}`
  7289. }
  7290. });
  7291. 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)) {
  7292. return true;
  7293. }
  7294. await external_Swal_default().fire({
  7295. icon: 'warning',
  7296. title: i18n('notice'),
  7297. text: i18n('noKeysLeft'),
  7298. confirmButtonText: i18n('confirm'),
  7299. cancelButtonText: i18n('cancel'),
  7300. showCancelButton: true
  7301. }).then(_ref => {
  7302. let {
  7303. value
  7304. } = _ref;
  7305. if (value) {
  7306. window.close();
  7307. }
  7308. });
  7309. return true;
  7310. } catch (error) {
  7311. throwError(error, 'Giveawaysu.checkLeftKey');
  7312. return false;
  7313. }
  7314. }
  7315. const website_FreeAnyWhere = FreeAnyWhere;
  7316. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7317. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7318. privateSet.add(obj);
  7319. }
  7320. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7321. if (privateCollection.has(obj)) {
  7322. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7323. }
  7324. }
  7325. function GiveawaySu_defineProperty(obj, key, value) {
  7326. if (key in obj) {
  7327. Object.defineProperty(obj, key, {
  7328. value: value,
  7329. enumerable: true,
  7330. configurable: true,
  7331. writable: true
  7332. });
  7333. } else {
  7334. obj[key] = value;
  7335. }
  7336. return obj;
  7337. }
  7338. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7339. if (!privateSet.has(receiver)) {
  7340. throw new TypeError('attempted to get private field on non-instance');
  7341. }
  7342. return fn;
  7343. }
  7344. const GiveawaySu_defaultTasks = {
  7345. steam: {
  7346. groupLinks: [],
  7347. wishlistLinks: [],
  7348. curatorLinks: [],
  7349. curatorLikeLinks: [],
  7350. followLinks: [],
  7351. forumLinks: [],
  7352. announcementLinks: [],
  7353. workshopVoteLinks: [],
  7354. playtestLinks: []
  7355. },
  7356. discord: {
  7357. serverLinks: []
  7358. },
  7359. instagram: {
  7360. userLinks: []
  7361. },
  7362. vk: {
  7363. nameLinks: []
  7364. },
  7365. twitch: {
  7366. channelLinks: []
  7367. },
  7368. reddit: {
  7369. redditLinks: []
  7370. },
  7371. youtube: {
  7372. channelLinks: [],
  7373. likeLinks: []
  7374. },
  7375. twitter: {
  7376. userLinks: [],
  7377. retweetLinks: []
  7378. }
  7379. };
  7380. var _checkLogin = new WeakSet();
  7381. var GiveawaySu_checkLeftKey = new WeakSet();
  7382. var GiveawaySu_getGiveawayId = new WeakSet();
  7383. class GiveawaySu extends website_Website {
  7384. constructor() {
  7385. super(...arguments);
  7386. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7387. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_checkLeftKey);
  7388. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7389. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7390. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7391. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7392. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7393. }
  7394. static test() {
  7395. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7396. }
  7397. async after() {
  7398. try {
  7399. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7400. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7401. }
  7402. if (!await GiveawaySu_classPrivateMethodGet(this, GiveawaySu_checkLeftKey, GiveawaySu_checkLeftKey2).call(this)) {
  7403. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7404. }
  7405. scripts_echoLog({}).warning(i18n('gsNotice'));
  7406. } catch (error) {
  7407. throwError(error, 'Giveawaysu.after');
  7408. }
  7409. }
  7410. init() {
  7411. try {
  7412. const logStatus = scripts_echoLog({
  7413. text: i18n('initing')
  7414. });
  7415. if ($('a.steam-login').length > 0) {
  7416. window.open('/steam/redirect', '_self');
  7417. logStatus.warning(i18n('needLogin'));
  7418. return false;
  7419. }
  7420. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7421. return false;
  7422. }
  7423. this.initialized = true;
  7424. logStatus.success();
  7425. return true;
  7426. } catch (error) {
  7427. throwError(error, 'Giveawaysu.init');
  7428. return false;
  7429. }
  7430. }
  7431. async classifyTask(action) {
  7432. try {
  7433. const logStatus = scripts_echoLog({
  7434. text: i18n('getTasksInfo')
  7435. });
  7436. if (action === 'undo') {
  7437. var _GM_getValue;
  7438. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7439. return true;
  7440. }
  7441. const pro = [];
  7442. const tasks = $('#actions tr');
  7443. if ($('div.bind-discord').is(':visible')) {
  7444. $('div.bind-discord a')[0].click();
  7445. }
  7446. if ($('div.bind-twitch').is(':visible')) {
  7447. $('div.bind-twitch a')[0].click();
  7448. }
  7449. for (const task of tasks) {
  7450. pro.push(new Promise(resolve => {
  7451. const td = $(task).find('td:not(".hidden")');
  7452. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7453. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7454. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7455. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7456. const taskName = taskDes.text().trim();
  7457. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7458. return resolve(true);
  7459. }
  7460. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7461. if (!taskLink) {
  7462. return resolve(false);
  7463. }
  7464. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7465. this.undoneTasks.steam.groupLinks.push(taskLink);
  7466. } else if (/like.*announcement/gi.test(taskName)) {
  7467. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7468. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7469. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7470. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7471. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7472. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7473. this.undoneTasks.steam.forumLinks.push(taskLink);
  7474. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7475. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7476. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7477. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7478. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7479. this.undoneTasks.discord.serverLinks.push(taskLink);
  7480. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7481. this.undoneTasks.instagram.userLinks.push(taskLink);
  7482. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7483. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7484. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7485. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7486. } else if (/watch.*art/gim.test(taskName)) {
  7487. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7488. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7489. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7490. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7491. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7492. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7493. this.undoneTasks.vk.nameLinks.push(taskLink);
  7494. } else {
  7495. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7496. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7497. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7498. }
  7499. if (/follow.*button/gim.test(taskName)) {
  7500. this.undoneTasks.steam.followLinks.push(taskLink);
  7501. }
  7502. }
  7503. }
  7504. resolve(true);
  7505. }).catch(error => {
  7506. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7507. return false;
  7508. });
  7509. }));
  7510. }
  7511. await Promise.all(pro);
  7512. logStatus.success();
  7513. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7514. this.socialTasks = this.undoneTasks;
  7515. if (window.DEBUG) {
  7516. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7517. }
  7518. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7519. tasks: this.socialTasks,
  7520. time: new Date().getTime()
  7521. });
  7522. return true;
  7523. } catch (error) {
  7524. throwError(error, 'Giveawaysu.classifyTask');
  7525. return false;
  7526. }
  7527. }
  7528. }
  7529. function _checkLogin2() {
  7530. try {
  7531. if (!globalOptions.other.checkLogin) {
  7532. return true;
  7533. }
  7534. if ($('a.steam-login').length > 0) {
  7535. window.open('/steam/redirect', '_self');
  7536. }
  7537. return true;
  7538. } catch (error) {
  7539. throwError(error, 'Giveawaysu.checkLogin');
  7540. return false;
  7541. }
  7542. }
  7543. async function GiveawaySu_checkLeftKey2() {
  7544. try {
  7545. if (!globalOptions.other.checkLeftKey) {
  7546. return true;
  7547. }
  7548. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7549. await external_Swal_default().fire({
  7550. icon: 'warning',
  7551. title: i18n('notice'),
  7552. text: i18n('noKeysLeft'),
  7553. confirmButtonText: i18n('confirm'),
  7554. cancelButtonText: i18n('cancel'),
  7555. showCancelButton: true
  7556. }).then(_ref => {
  7557. let {
  7558. value
  7559. } = _ref;
  7560. if (value) {
  7561. window.close();
  7562. }
  7563. });
  7564. }
  7565. return true;
  7566. } catch (error) {
  7567. throwError(error, 'Giveawaysu.checkLeftKey');
  7568. return false;
  7569. }
  7570. }
  7571. function GiveawaySu_getGiveawayId2() {
  7572. var _window$location$href;
  7573. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7574. if (giveawayId) {
  7575. this.giveawayId = giveawayId;
  7576. return true;
  7577. }
  7578. scripts_echoLog({
  7579. text: i18n('getFailed', 'GiveawayId')
  7580. });
  7581. return false;
  7582. }
  7583. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7584. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7585. privateSet.add(obj);
  7586. }
  7587. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7588. if (privateCollection.has(obj)) {
  7589. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7590. }
  7591. }
  7592. function Indiedb_defineProperty(obj, key, value) {
  7593. if (key in obj) {
  7594. Object.defineProperty(obj, key, {
  7595. value: value,
  7596. enumerable: true,
  7597. configurable: true,
  7598. writable: true
  7599. });
  7600. } else {
  7601. obj[key] = value;
  7602. }
  7603. return obj;
  7604. }
  7605. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7606. if (!privateSet.has(receiver)) {
  7607. throw new TypeError('attempted to get private field on non-instance');
  7608. }
  7609. return fn;
  7610. }
  7611. var _join = new WeakSet();
  7612. var _do = new WeakSet();
  7613. var Indiedb_checkLogin = new WeakSet();
  7614. var Indiedb_checkLeftKey = new WeakSet();
  7615. class Indiedb {
  7616. constructor() {
  7617. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7618. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7619. Indiedb_classPrivateMethodInitSpec(this, _do);
  7620. Indiedb_classPrivateMethodInitSpec(this, _join);
  7621. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7622. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7623. }
  7624. static test() {
  7625. return window.location.host === 'www.indiedb.com';
  7626. }
  7627. async after() {
  7628. try {
  7629. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7630. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7631. }
  7632. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7633. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7634. }
  7635. } catch (error) {
  7636. throwError(error, 'Indiedb.after');
  7637. }
  7638. }
  7639. async doTask() {
  7640. try {
  7641. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7642. return false;
  7643. }
  7644. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7645. } catch (error) {
  7646. throwError(error, 'Indiedb.doTask');
  7647. return false;
  7648. }
  7649. }
  7650. }
  7651. async function _join2() {
  7652. try {
  7653. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7654. scripts_echoLog({}).error(i18n('needLogin'));
  7655. return false;
  7656. }
  7657. const currentoption = $('a.buttonenter.buttongiveaway');
  7658. if (/join giveaway/gim.test(currentoption.text())) {
  7659. const logStatus = scripts_echoLog({
  7660. text: `${i18n('joiningGiveaway')}...`
  7661. });
  7662. const {
  7663. result,
  7664. statusText,
  7665. status,
  7666. data
  7667. } = await tools_httpRequest({
  7668. url: currentoption.attr('href'),
  7669. method: 'POST',
  7670. data: 'ajax=t',
  7671. dataType: 'json',
  7672. headers: {
  7673. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7674. accept: 'application/json, text/javascript, */*; q=0.01',
  7675. origin: window.location.origin
  7676. }
  7677. });
  7678. if (result === 'Success') {
  7679. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7680. var _data$response, _data$response4, _data$response5;
  7681. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7682. var _data$response2, _data$response3;
  7683. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7684. $('#giveawaysjoined').slideDown();
  7685. $('#giveawaysrecommend').slideDown();
  7686. 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}` : ''}`);
  7687. return true;
  7688. }
  7689. 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}` : ''}`);
  7690. return false;
  7691. }
  7692. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7693. return false;
  7694. }
  7695. logStatus.error(`${result}:${statusText}(${status})`);
  7696. return false;
  7697. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7698. return true;
  7699. }
  7700. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7701. return false;
  7702. } catch (error) {
  7703. throwError(error, 'Indiedb.init');
  7704. return false;
  7705. }
  7706. }
  7707. async function _do2() {
  7708. try {
  7709. const id = $('script').map((index, script) => {
  7710. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7711. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7712. 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] ];
  7713. }
  7714. return null;
  7715. });
  7716. if (id.length === 2) {
  7717. const pro = [];
  7718. const tasks = $('#giveawaysjoined a[class*=promo]');
  7719. for (const task of tasks) {
  7720. const promo = $(task);
  7721. if (!promo.hasClass('buttonentered')) {
  7722. const status = scripts_echoLog({
  7723. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7724. });
  7725. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7726. let text = '';
  7727. if (promo.hasClass('facebookpromo')) {
  7728. text = 'facebookpromo';
  7729. } else if (promo.hasClass('twitterpromo')) {
  7730. text = 'twitterpromo';
  7731. } else {
  7732. text = 'visitpromo';
  7733. }
  7734. pro.push(new Promise(resolve => {
  7735. $.ajax({
  7736. type: 'POST',
  7737. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7738. timeout: 6e4,
  7739. dataType: 'json',
  7740. data: {
  7741. ajax: 't'
  7742. },
  7743. error(response, error, exception) {
  7744. if (window.DEBUG) {
  7745. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7746. response: response,
  7747. error: error,
  7748. exception: exception
  7749. });
  7750. }
  7751. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7752. resolve(true);
  7753. },
  7754. success(response) {
  7755. if (response.success) {
  7756. status.success(`Success:${response.text}`);
  7757. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7758. resolve(true);
  7759. } else {
  7760. status.error(`Error:${response.text}`);
  7761. resolve(true);
  7762. }
  7763. }
  7764. });
  7765. }));
  7766. } else if (promo.hasClass('emailoptinpromo')) {
  7767. pro.push(new Promise(resolve => {
  7768. $.ajax({
  7769. type: 'POST',
  7770. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7771. timeout: 6e4,
  7772. dataType: 'json',
  7773. data: {
  7774. ajax: 't',
  7775. emailsystoggle: 4
  7776. },
  7777. error(response, error, exception) {
  7778. if (window.DEBUG) {
  7779. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7780. response: response,
  7781. error: error,
  7782. exception: exception
  7783. });
  7784. }
  7785. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7786. resolve(true);
  7787. },
  7788. success(response) {
  7789. if (response.success) {
  7790. status.success(`Success:${response.text}`);
  7791. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7792. resolve(true);
  7793. } else {
  7794. status.error(`Error:${response.text}`);
  7795. resolve(true);
  7796. }
  7797. }
  7798. });
  7799. }));
  7800. } else if (promo.hasClass('watchingpromo')) {
  7801. pro.push(new Promise(resolve => {
  7802. var _promo$attr;
  7803. const data = getUrlQuery(promo.attr('href'));
  7804. data.ajax = 't';
  7805. $.ajax({
  7806. type: 'POST',
  7807. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7808. timeout: 6e4,
  7809. dataType: 'json',
  7810. data: data,
  7811. error(response, error, exception) {
  7812. if (window.DEBUG) {
  7813. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7814. response: response,
  7815. error: error,
  7816. exception: exception
  7817. });
  7818. }
  7819. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7820. resolve(true);
  7821. },
  7822. success(response) {
  7823. if (response.success) {
  7824. status.success(`Success:${response.text}`);
  7825. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7826. resolve(true);
  7827. } else {
  7828. status.error(`Error:${response.text}`);
  7829. resolve(true);
  7830. }
  7831. }
  7832. });
  7833. }));
  7834. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7835. pro.push(new Promise(resolve => {
  7836. $.ajax({
  7837. type: 'POST',
  7838. url: urlPath(promo.attr('href')),
  7839. timeout: 6e4,
  7840. dataType: 'json',
  7841. data: {
  7842. ajax: 't'
  7843. },
  7844. error(response, error, exception) {
  7845. if (window.DEBUG) {
  7846. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7847. response: response,
  7848. error: error,
  7849. exception: exception
  7850. });
  7851. }
  7852. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7853. resolve(true);
  7854. },
  7855. success(response) {
  7856. if (response.success) {
  7857. status.success(`Success:${response.text}`);
  7858. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7859. resolve(true);
  7860. } else {
  7861. status.error(`Error:${response.text}`);
  7862. resolve(true);
  7863. }
  7864. }
  7865. });
  7866. }));
  7867. } else {
  7868. status.error(`Error:${i18n('unKnownTaskType')}`);
  7869. }
  7870. }
  7871. }
  7872. await Promise.all(pro);
  7873. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7874. return true;
  7875. }
  7876. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7877. return false;
  7878. } catch (error) {
  7879. throwError(error, 'Indiedb.classifyTask');
  7880. return false;
  7881. }
  7882. }
  7883. function Indiedb_checkLogin2() {
  7884. try {
  7885. if (!globalOptions.other.checkLogin) {
  7886. return true;
  7887. }
  7888. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7889. window.open('/members/login', '_self');
  7890. }
  7891. return true;
  7892. } catch (error) {
  7893. throwError(error, 'Indiedb.checkLogin');
  7894. return false;
  7895. }
  7896. }
  7897. async function Indiedb_checkLeftKey2() {
  7898. try {
  7899. if (!globalOptions.other.checkLeftKey) {
  7900. return true;
  7901. }
  7902. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7903. await external_Swal_default().fire({
  7904. icon: 'warning',
  7905. title: i18n('notice'),
  7906. text: i18n('giveawayEnded'),
  7907. confirmButtonText: i18n('confirm'),
  7908. cancelButtonText: i18n('cancel'),
  7909. showCancelButton: true
  7910. }).then(_ref => {
  7911. let {
  7912. value
  7913. } = _ref;
  7914. if (value) {
  7915. window.close();
  7916. }
  7917. });
  7918. }
  7919. return true;
  7920. } catch (error) {
  7921. throwError(error, 'Indiedb.checkLeftKey');
  7922. return false;
  7923. }
  7924. }
  7925. const website_Indiedb = Indiedb;
  7926. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7927. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7928. privateSet.add(obj);
  7929. }
  7930. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7931. if (privateCollection.has(obj)) {
  7932. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7933. }
  7934. }
  7935. function Keyhub_defineProperty(obj, key, value) {
  7936. if (key in obj) {
  7937. Object.defineProperty(obj, key, {
  7938. value: value,
  7939. enumerable: true,
  7940. configurable: true,
  7941. writable: true
  7942. });
  7943. } else {
  7944. obj[key] = value;
  7945. }
  7946. return obj;
  7947. }
  7948. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7949. if (!privateSet.has(receiver)) {
  7950. throw new TypeError('attempted to get private field on non-instance');
  7951. }
  7952. return fn;
  7953. }
  7954. const Keyhub_defaultTasksTemplate = {
  7955. steam: {
  7956. groupLinks: [],
  7957. officialGroupLinks: [],
  7958. wishlistLinks: [],
  7959. curatorLinks: []
  7960. },
  7961. discord: {
  7962. serverLinks: []
  7963. },
  7964. extra: {
  7965. videoTasks: []
  7966. },
  7967. links: []
  7968. };
  7969. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7970. var _doScriptTask = new WeakSet();
  7971. var Keyhub_getGiveawayId = new WeakSet();
  7972. var Keyhub_checkLeftKey = new WeakSet();
  7973. var Keyhub_checkLogin = new WeakSet();
  7974. class Keyhub extends website_Website {
  7975. constructor() {
  7976. super(...arguments);
  7977. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7978. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7979. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7980. Keyhub_classPrivateMethodInitSpec(this, _doScriptTask);
  7981. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7982. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7983. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7984. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7985. }
  7986. static test() {
  7987. return window.location.host === 'key-hub.eu';
  7988. }
  7989. async after() {
  7990. try {
  7991. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7992. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7993. }
  7994. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7995. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7996. }
  7997. $('.NSFW').hide();
  7998. } catch (error) {
  7999. throwError(error, 'Keyhub.after');
  8000. }
  8001. }
  8002. init() {
  8003. try {
  8004. const logStatus = scripts_echoLog({
  8005. text: i18n('initing')
  8006. });
  8007. if ($('a[href*="/connect/steam"]').length > 0) {
  8008. window.open('/connect/steam', '_self');
  8009. logStatus.warning(i18n('needLogin'));
  8010. return false;
  8011. }
  8012. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  8013. return false;
  8014. }
  8015. $('#VPNoverlay').hide();
  8016. $('#mainArticleSection').show();
  8017. this.initialized = true;
  8018. logStatus.success();
  8019. return true;
  8020. } catch (error) {
  8021. throwError(error, 'Keyhub.init');
  8022. return false;
  8023. }
  8024. }
  8025. async classifyTask(action) {
  8026. try {
  8027. const logStatus = scripts_echoLog({
  8028. text: i18n('getTasksInfo')
  8029. });
  8030. if (action === 'undo') {
  8031. var _GM_getValue;
  8032. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  8033. }
  8034. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  8035. for (const task of tasks) {
  8036. let link = $(task).attr('href');
  8037. const taskDes = $(task).text().trim();
  8038. if (!link) {
  8039. continue;
  8040. }
  8041. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  8042. link = await getRedirectLink(link) || link;
  8043. }
  8044. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  8045. window.open(link, '_blank');
  8046. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  8047. if (action === 'undo') {
  8048. this.socialTasks.steam.groupLinks.push(link);
  8049. }
  8050. if (action === 'do') {
  8051. this.undoneTasks.steam.groupLinks.push(link);
  8052. }
  8053. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  8054. if (action === 'undo') {
  8055. this.socialTasks.steam.officialGroupLinks.push(link);
  8056. }
  8057. if (action === 'do') {
  8058. this.undoneTasks.steam.officialGroupLinks.push(link);
  8059. }
  8060. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  8061. if (action === 'undo') {
  8062. this.socialTasks.steam.wishlistLinks.push(link);
  8063. }
  8064. if (action === 'do') {
  8065. this.undoneTasks.steam.wishlistLinks.push(link);
  8066. }
  8067. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  8068. if (action === 'undo') {
  8069. this.socialTasks.steam.curatorLinks.push(link);
  8070. }
  8071. if (action === 'do') {
  8072. this.undoneTasks.steam.curatorLinks.push(link);
  8073. }
  8074. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  8075. if (action === 'undo') {
  8076. this.socialTasks.discord.serverLinks.push(link);
  8077. }
  8078. if (action === 'do') {
  8079. this.undoneTasks.discord.serverLinks.push(link);
  8080. }
  8081. } else if (/^javascript:videoTask.+/.test(link)) {
  8082. if (action === 'do') {
  8083. var _link$match;
  8084. const taskData = (_link$match = link.match(/javascript:videoTask\('.+?','(.+?)'/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  8085. if (taskData) {
  8086. this.undoneTasks.extra.videoTasks.push(taskData);
  8087. }
  8088. }
  8089. } 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 {
  8090. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8091. }
  8092. }
  8093. logStatus.success();
  8094. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8095. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8096. if (window.DEBUG) {
  8097. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8098. }
  8099. GM_setValue(`khTasks-${this.giveawayId}`, {
  8100. tasks: this.socialTasks,
  8101. time: new Date().getTime()
  8102. });
  8103. return true;
  8104. } catch (error) {
  8105. throwError(error, 'Keyhub.classifyTask');
  8106. return false;
  8107. }
  8108. }
  8109. async extraDoTask(_ref) {
  8110. let {
  8111. videoTasks
  8112. } = _ref;
  8113. try {
  8114. const pro = [];
  8115. for (const data of videoTasks) {
  8116. pro.push(Keyhub_classPrivateMethodGet(this, _doScriptTask, _doScriptTask2).call(this, data));
  8117. }
  8118. return Promise.all(pro).then(() => true);
  8119. } catch (error) {
  8120. throwError(error, 'Keyhub.extraDoTask');
  8121. return false;
  8122. }
  8123. }
  8124. }
  8125. async function _doScriptTask2(data) {
  8126. try {
  8127. const logStatus = scripts_echoLog({
  8128. text: i18n('doingKeyhubTask')
  8129. });
  8130. const {
  8131. result,
  8132. statusText,
  8133. status,
  8134. data: response
  8135. } = await tools_httpRequest({
  8136. url: `/away?data=${data}`,
  8137. method: 'GET',
  8138. headers: {
  8139. origin: 'https://key-hub.eu',
  8140. referer: 'https://key-hub.eu/'
  8141. }
  8142. });
  8143. if (result === 'Success') {
  8144. if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
  8145. logStatus.success();
  8146. return true;
  8147. }
  8148. logStatus.error(`Error:${response === null || response === void 0 ? void 0 : response.statusText}(${response === null || response === void 0 ? void 0 : response.status})`);
  8149. return false;
  8150. }
  8151. logStatus.error(`${result}:${statusText}(${status})`);
  8152. return false;
  8153. } catch (error) {
  8154. throwError(error, 'Keyhub.doScriptTask');
  8155. return false;
  8156. }
  8157. }
  8158. function Keyhub_getGiveawayId2() {
  8159. try {
  8160. var _window$location$href;
  8161. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8162. if (giveawayId) {
  8163. this.giveawayId = giveawayId;
  8164. return true;
  8165. }
  8166. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8167. return false;
  8168. } catch (error) {
  8169. throwError(error, 'Keyhub.getGiveawayId');
  8170. return false;
  8171. }
  8172. }
  8173. async function Keyhub_checkLeftKey2() {
  8174. try {
  8175. if (!globalOptions.other.checkLeftKey) {
  8176. return true;
  8177. }
  8178. const leftKey = $('#keysleft').text().trim();
  8179. if (leftKey === '0') {
  8180. await external_Swal_default().fire({
  8181. icon: 'warning',
  8182. title: i18n('notice'),
  8183. text: i18n('noKeysLeft'),
  8184. confirmButtonText: i18n('confirm'),
  8185. cancelButtonText: i18n('cancel'),
  8186. showCancelButton: true
  8187. }).then(_ref2 => {
  8188. let {
  8189. value
  8190. } = _ref2;
  8191. if (value) {
  8192. window.close();
  8193. }
  8194. });
  8195. }
  8196. return true;
  8197. } catch (error) {
  8198. throwError(error, 'Keyhub.checkLeftKey');
  8199. return false;
  8200. }
  8201. }
  8202. function Keyhub_checkLogin2() {
  8203. try {
  8204. if (!globalOptions.other.checkLogin) {
  8205. return true;
  8206. }
  8207. if ($('a[href*="/connect/steam"]').length > 0) {
  8208. window.open('/connect/steam', '_self');
  8209. }
  8210. return true;
  8211. } catch (error) {
  8212. throwError(error, 'Keyhub.checkLogin');
  8213. return false;
  8214. }
  8215. }
  8216. const website_Keyhub = Keyhub;
  8217. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  8218. Givekey_checkPrivateRedeclaration(obj, privateSet);
  8219. privateSet.add(obj);
  8220. }
  8221. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  8222. if (privateCollection.has(obj)) {
  8223. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8224. }
  8225. }
  8226. function Givekey_defineProperty(obj, key, value) {
  8227. if (key in obj) {
  8228. Object.defineProperty(obj, key, {
  8229. value: value,
  8230. enumerable: true,
  8231. configurable: true,
  8232. writable: true
  8233. });
  8234. } else {
  8235. obj[key] = value;
  8236. }
  8237. return obj;
  8238. }
  8239. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  8240. if (!privateSet.has(receiver)) {
  8241. throw new TypeError('attempted to get private field on non-instance');
  8242. }
  8243. return fn;
  8244. }
  8245. const Givekey_defaultTasksTemplate = {
  8246. steam: {
  8247. groupLinks: [],
  8248. wishlistLinks: [],
  8249. curatorLinks: [],
  8250. curatorLikeLinks: []
  8251. },
  8252. twitter: {
  8253. userLinks: []
  8254. },
  8255. vk: {
  8256. nameLinks: []
  8257. },
  8258. discord: {
  8259. serverLinks: []
  8260. }
  8261. };
  8262. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  8263. var Givekey_verify = new WeakSet();
  8264. var Givekey_getGiveawayId = new WeakSet();
  8265. var Givekey_checkLeftKey = new WeakSet();
  8266. class Givekey extends website_Website {
  8267. constructor() {
  8268. super(...arguments);
  8269. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  8270. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  8271. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  8272. Givekey_defineProperty(this, 'name', 'Givekey');
  8273. Givekey_defineProperty(this, 'tasks', []);
  8274. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  8275. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  8276. Givekey_defineProperty(this, 'userId', void 0);
  8277. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8278. }
  8279. static test() {
  8280. return window.location.host === 'givekey.ru';
  8281. }
  8282. async after() {
  8283. try {
  8284. await new Promise(resolve => {
  8285. const checker = setInterval(() => {
  8286. if ($('#navbarDropdown').length > 0) {
  8287. clearInterval(checker);
  8288. resolve(true);
  8289. }
  8290. });
  8291. });
  8292. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8293. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8294. }
  8295. } catch (error) {
  8296. throwError(error, 'Givekey.after');
  8297. return false;
  8298. }
  8299. }
  8300. init() {
  8301. try {
  8302. const logStatus = scripts_echoLog({
  8303. text: i18n('initing')
  8304. });
  8305. if ($('a[href*="/auth/steam"]').length > 0) {
  8306. window.open('/auth/steam', '_self');
  8307. logStatus.warning(i18n('needLogin'));
  8308. return false;
  8309. }
  8310. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8311. return false;
  8312. }
  8313. const userId = $('meta[name="user-id"]').attr('content');
  8314. if (!userId) {
  8315. logStatus.error(i18n('getFailed', i18n('userId')));
  8316. return false;
  8317. }
  8318. this.userId = userId;
  8319. this.initialized = true;
  8320. logStatus.success();
  8321. return true;
  8322. } catch (error) {
  8323. throwError(error, 'Givekey.init');
  8324. return false;
  8325. }
  8326. }
  8327. async classifyTask(action) {
  8328. try {
  8329. const logStatus = scripts_echoLog({
  8330. text: i18n('getTasksInfo')
  8331. });
  8332. if (action === 'undo') {
  8333. var _GM_getValue;
  8334. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8335. }
  8336. const tasks = $('.card-body:has("button") .row');
  8337. for (const task of tasks) {
  8338. const taskEle = $(task);
  8339. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8340. if (isSuccess && action !== 'undo') {
  8341. continue;
  8342. }
  8343. const checkButton = taskEle.find('#task_check');
  8344. const taskId = checkButton.attr('data-id');
  8345. if (taskId) {
  8346. this.tasks.push(taskId);
  8347. }
  8348. if (action === 'verify') {
  8349. continue;
  8350. }
  8351. let href = taskEle.find('a').attr('href') || null;
  8352. const text = taskEle.find('a').text().trim();
  8353. const icon = taskEle.find('i');
  8354. if (!href || !text) {
  8355. continue;
  8356. }
  8357. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8358. href = await getRedirectLink(href);
  8359. }
  8360. if (!href) {
  8361. continue;
  8362. }
  8363. if (/^https?:\/\/vk\.com\//.test(href)) {
  8364. this.socialTasks.vk.nameLinks.push(href);
  8365. if (action === 'do' && !isSuccess) {
  8366. this.undoneTasks.vk.nameLinks.push(href);
  8367. }
  8368. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8369. this.socialTasks.steam.groupLinks.push(href);
  8370. if (action === 'do' && !isSuccess) {
  8371. this.undoneTasks.steam.groupLinks.push(href);
  8372. }
  8373. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8374. this.socialTasks.steam.wishlistLinks.push(href);
  8375. if (action === 'do' && !isSuccess) {
  8376. this.undoneTasks.steam.wishlistLinks.push(href);
  8377. }
  8378. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8379. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8380. this.socialTasks.steam.curatorLinks.push(href);
  8381. if (action === 'do' && !isSuccess) {
  8382. this.undoneTasks.steam.curatorLinks.push(href);
  8383. }
  8384. } else {
  8385. this.socialTasks.steam.curatorLikeLinks.push(href);
  8386. if (action === 'do' && !isSuccess) {
  8387. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8388. }
  8389. }
  8390. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8391. this.socialTasks.twitter.userLinks.push(href);
  8392. if (action === 'do' && !isSuccess) {
  8393. this.undoneTasks.twitter.userLinks.push(href);
  8394. }
  8395. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8396. this.socialTasks.discord.serverLinks.push(href);
  8397. if (action === 'do' && !isSuccess) {
  8398. this.undoneTasks.discord.serverLinks.push(href);
  8399. }
  8400. } else {
  8401. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8402. }
  8403. }
  8404. logStatus.success();
  8405. this.tasks = unique(this.tasks);
  8406. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8407. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8408. if (window.DEBUG) {
  8409. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8410. }
  8411. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8412. tasks: this.socialTasks,
  8413. time: new Date().getTime()
  8414. });
  8415. return true;
  8416. } catch (error) {
  8417. throwError(error, 'Givekey.classifyTask');
  8418. return false;
  8419. }
  8420. }
  8421. async verifyTask() {
  8422. try {
  8423. if (!this.initialized && !this.init()) {
  8424. return false;
  8425. }
  8426. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8427. return false;
  8428. }
  8429. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8430. const taskLength = this.tasks.length;
  8431. for (let i = 0; i < taskLength; i++) {
  8432. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8433. if (i < taskLength - 1) {
  8434. await delay(15e3);
  8435. }
  8436. }
  8437. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8438. scripts_echoLog({
  8439. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8440. });
  8441. return true;
  8442. } catch (error) {
  8443. throwError(error, 'Givekey.verifyTask');
  8444. return false;
  8445. }
  8446. }
  8447. }
  8448. async function Givekey_verify2(task) {
  8449. try {
  8450. const logStatus = scripts_echoLog({
  8451. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8452. });
  8453. return await new Promise(resolve => {
  8454. $.ajax({
  8455. url: 'https://givekey.ru/giveaway/task',
  8456. method: 'POST',
  8457. data: `id=${task}&user_id=${this.userId}`,
  8458. dataType: 'json',
  8459. headers: {
  8460. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8461. },
  8462. success: data => {
  8463. if (data.btn) {
  8464. $(`button[data-id=${this.userId}]`).html(data.btn);
  8465. }
  8466. if (data.status === 'ok') {
  8467. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8468. logStatus.success();
  8469. resolve(true);
  8470. } else if (data.status === 'end') {
  8471. logStatus.success();
  8472. scripts_echoLog({}).success(data.key);
  8473. resolve(true);
  8474. } else {
  8475. logStatus.error(`Error:${data.msg}`);
  8476. resolve(false);
  8477. }
  8478. },
  8479. error: xhr => {
  8480. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8481. resolve(false);
  8482. }
  8483. });
  8484. });
  8485. } catch (error) {
  8486. throwError(error, 'Givekey.verify');
  8487. return false;
  8488. }
  8489. }
  8490. function Givekey_getGiveawayId2() {
  8491. try {
  8492. var _window$location$href;
  8493. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8494. if (giveawayId) {
  8495. this.giveawayId = giveawayId;
  8496. return true;
  8497. }
  8498. scripts_echoLog({
  8499. text: i18n('getFailed', 'GiveawayId')
  8500. });
  8501. return false;
  8502. } catch (error) {
  8503. throwError(error, 'Givekey.getGiveawayId');
  8504. return false;
  8505. }
  8506. }
  8507. async function Givekey_checkLeftKey2() {
  8508. try {
  8509. if (!globalOptions.other.checkLeftKey) {
  8510. return true;
  8511. }
  8512. if (!$('#keys_count').text()) {
  8513. await external_Swal_default().fire({
  8514. icon: 'warning',
  8515. title: i18n('notice'),
  8516. text: i18n('noKeysLeft'),
  8517. confirmButtonText: i18n('confirm'),
  8518. cancelButtonText: i18n('cancel'),
  8519. showCancelButton: true
  8520. }).then(_ref => {
  8521. let {
  8522. value
  8523. } = _ref;
  8524. if (value) {
  8525. window.close();
  8526. }
  8527. });
  8528. }
  8529. return true;
  8530. } catch (error) {
  8531. throwError(error, 'Givekey.checkLeftKey');
  8532. return false;
  8533. }
  8534. }
  8535. const website_Givekey = Givekey;
  8536. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8537. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8538. privateSet.add(obj);
  8539. }
  8540. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8541. if (privateCollection.has(obj)) {
  8542. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8543. }
  8544. }
  8545. function GiveeClub_defineProperty(obj, key, value) {
  8546. if (key in obj) {
  8547. Object.defineProperty(obj, key, {
  8548. value: value,
  8549. enumerable: true,
  8550. configurable: true,
  8551. writable: true
  8552. });
  8553. } else {
  8554. obj[key] = value;
  8555. }
  8556. return obj;
  8557. }
  8558. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8559. if (!privateSet.has(receiver)) {
  8560. throw new TypeError('attempted to get private field on non-instance');
  8561. }
  8562. return fn;
  8563. }
  8564. var GiveeClub_checkLogin = new WeakSet();
  8565. var GiveeClub_getGiveawayId = new WeakSet();
  8566. var GiveeClub_checkLeftKey = new WeakSet();
  8567. class GiveeClub extends GiveawaySu {
  8568. constructor() {
  8569. super(...arguments);
  8570. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8571. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8572. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8573. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8574. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8575. }
  8576. static test() {
  8577. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8578. }
  8579. async after() {
  8580. try {
  8581. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8582. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8583. }
  8584. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8585. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8586. }
  8587. } catch (error) {
  8588. throwError(error, 'GiveeClub.after');
  8589. }
  8590. }
  8591. init() {
  8592. try {
  8593. const logStatus = scripts_echoLog({
  8594. text: i18n('initing')
  8595. });
  8596. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8597. logStatus.warning(i18n('needLogin'));
  8598. return false;
  8599. }
  8600. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8601. return false;
  8602. }
  8603. this.initialized = true;
  8604. logStatus.success();
  8605. return true;
  8606. } catch (error) {
  8607. throwError(error, 'GiveeClub.init');
  8608. return false;
  8609. }
  8610. }
  8611. async classifyTask(action) {
  8612. try {
  8613. const logStatus = scripts_echoLog({
  8614. text: i18n('getTasksInfo')
  8615. });
  8616. if (action === 'undo') {
  8617. var _GM_getValue;
  8618. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8619. return true;
  8620. }
  8621. const pro = [];
  8622. const tasks = $('.event-actions tr');
  8623. for (const task of tasks) {
  8624. pro.push(new Promise(resolve => {
  8625. var _$$find, _$$find2;
  8626. const taskDes = $(task).find('.event-action-label a');
  8627. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8628. const taskName = taskDes.text().trim();
  8629. const taskType = (_$$find = $(task).find('button[data-type]')) === null || _$$find === void 0 ? void 0 : _$$find.attr('data-type');
  8630. const taskFinished = (_$$find2 = $(task).find('.event-action-buttons .btn-success')) === null || _$$find2 === void 0 ? void 0 : _$$find2.length;
  8631. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope') || taskFinished) {
  8632. return resolve(true);
  8633. }
  8634. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8635. if (!taskLink) {
  8636. return resolve(false);
  8637. }
  8638. if (taskType === 'steam.group.join' && /^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8639. this.undoneTasks.steam.groupLinks.push(taskLink);
  8640. } else if (/like.*announcement/gi.test(taskName)) {
  8641. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8642. } else if (taskType === 'steam.game.wishlist' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8643. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8644. } else if (taskType === 'steam.game.wishlist' && taskDes.attr('data-steam-wishlist-appid')) {
  8645. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8646. } else if (taskType === 'steam.game.follow' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8647. this.undoneTasks.steam.followLinks.push(taskLink);
  8648. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8649. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8650. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8651. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8652. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8653. this.undoneTasks.steam.forumLinks.push(taskLink);
  8654. } else if (taskIcon.includes('discord')) {
  8655. this.undoneTasks.discord.serverLinks.push(taskLink);
  8656. } else if (taskIcon.includes('instagram')) {
  8657. this.undoneTasks.instagram.userLinks.push(taskLink);
  8658. } else if (taskIcon.includes('twitch')) {
  8659. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8660. } else if (taskIcon.includes('reddit')) {
  8661. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8662. } else if (/watch.*art/gim.test(taskName)) {
  8663. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8664. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8665. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8666. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8667. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8668. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8669. this.undoneTasks.vk.nameLinks.push(taskLink);
  8670. } else if (taskIcon.includes('twitter')) {
  8671. if (/https?:\/\/twitter\.com\/[^/]+\/?$/gim.test(taskLink)) {
  8672. this.undoneTasks.twitter.userLinks.push(taskLink);
  8673. } else if (/https?:\/\/twitter\.com\/[^/]+?\/status\/[\d]+/gim.test(taskLink)) {
  8674. this.undoneTasks.twitter.retweetLinks.push(taskLink);
  8675. }
  8676. } else {
  8677. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8678. if (/follow.*button/gim.test(taskName)) {
  8679. this.undoneTasks.steam.followLinks.push(taskLink);
  8680. }
  8681. }
  8682. }
  8683. resolve(true);
  8684. }).catch(error => {
  8685. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8686. return false;
  8687. });
  8688. }));
  8689. }
  8690. await Promise.all(pro);
  8691. logStatus.success();
  8692. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8693. this.socialTasks = this.undoneTasks;
  8694. if (window.DEBUG) {
  8695. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8696. }
  8697. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8698. tasks: this.socialTasks,
  8699. time: new Date().getTime()
  8700. });
  8701. return true;
  8702. } catch (error) {
  8703. throwError(error, 'GiveeClub.classifyTask');
  8704. return false;
  8705. }
  8706. }
  8707. async verifyTask() {
  8708. try {
  8709. const logStatus = scripts_echoLog({
  8710. text: i18n('giveeClubVerifyNotice')
  8711. });
  8712. const taskButtons = $('.event-actions tr button').has('i.glyphicon-refresh').not('[data-type="user.adblock"]');
  8713. for (const button of taskButtons) {
  8714. button.click();
  8715. if ($(button).attr('data-type') !== 'steam.game.wishlist') {
  8716. await delay(1e3);
  8717. }
  8718. }
  8719. logStatus.warning(i18n('giveeClubVerifyFinished'));
  8720. return true;
  8721. } catch (error) {
  8722. throwError(error, 'Givekey.verifyTask');
  8723. return false;
  8724. }
  8725. }
  8726. }
  8727. function GiveeClub_checkLogin2() {
  8728. try {
  8729. if (!globalOptions.other.checkLogin) {
  8730. return true;
  8731. }
  8732. if ($('a[href*="/account/auth"]').length > 0) {
  8733. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8734. }
  8735. return true;
  8736. } catch (error) {
  8737. throwError(error, 'GiveeClub.checkLogin');
  8738. return false;
  8739. }
  8740. }
  8741. function GiveeClub_getGiveawayId2() {
  8742. var _window$location$href;
  8743. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8744. if (giveawayId) {
  8745. this.giveawayId = giveawayId;
  8746. return true;
  8747. }
  8748. scripts_echoLog({
  8749. text: i18n('getFailed', 'GiveawayId')
  8750. });
  8751. return false;
  8752. }
  8753. async function GiveeClub_checkLeftKey2() {
  8754. try {
  8755. if (!globalOptions.other.checkLeftKey) {
  8756. return true;
  8757. }
  8758. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8759. await external_Swal_default().fire({
  8760. icon: 'warning',
  8761. title: i18n('notice'),
  8762. text: i18n('giveawayEnded'),
  8763. confirmButtonText: i18n('confirm'),
  8764. cancelButtonText: i18n('cancel'),
  8765. showCancelButton: true
  8766. }).then(_ref => {
  8767. let {
  8768. value
  8769. } = _ref;
  8770. if (value) {
  8771. window.close();
  8772. }
  8773. });
  8774. }
  8775. return true;
  8776. } catch (error) {
  8777. throwError(error, 'Giveawaysu.checkLeftKey');
  8778. return false;
  8779. }
  8780. }
  8781. const website_GiveeClub = GiveeClub;
  8782. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8783. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8784. privateSet.add(obj);
  8785. }
  8786. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8787. if (privateCollection.has(obj)) {
  8788. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8789. }
  8790. }
  8791. function OpiumPulses_defineProperty(obj, key, value) {
  8792. if (key in obj) {
  8793. Object.defineProperty(obj, key, {
  8794. value: value,
  8795. enumerable: true,
  8796. configurable: true,
  8797. writable: true
  8798. });
  8799. } else {
  8800. obj[key] = value;
  8801. }
  8802. return obj;
  8803. }
  8804. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8805. if (!privateSet.has(receiver)) {
  8806. throw new TypeError('attempted to get private field on non-instance');
  8807. }
  8808. return fn;
  8809. }
  8810. const defaultOptions = {
  8811. maxPoint: '99999999'
  8812. };
  8813. var _toggleTask = new WeakSet();
  8814. var OpiumPulses_checkLogin = new WeakSet();
  8815. class OpiumPulses {
  8816. constructor() {
  8817. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8818. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8819. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8820. OpiumPulses_defineProperty(this, 'options', {
  8821. ...defaultOptions,
  8822. ...GM_getValue('OpiumPulsesOptions')
  8823. });
  8824. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8825. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8826. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8827. }
  8828. static test() {
  8829. return window.location.host === 'www.opiumpulses.com';
  8830. }
  8831. async after() {
  8832. try {
  8833. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8834. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8835. }
  8836. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8837. } catch (error) {
  8838. throwError(error, 'OpiumPulses.after');
  8839. }
  8840. }
  8841. async doFreeTask() {
  8842. try {
  8843. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8844. } catch (error) {
  8845. throwError(error, 'OpiumPulses.doFreeTask');
  8846. }
  8847. }
  8848. async doPointTask() {
  8849. try {
  8850. var _$$text$match;
  8851. 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);
  8852. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8853. } catch (error) {
  8854. throwError(error, 'OpiumPulses.doPointTask');
  8855. }
  8856. }
  8857. init() {
  8858. return true;
  8859. }
  8860. classifyTask() {
  8861. return true;
  8862. }
  8863. }
  8864. async function _toggleTask2(type) {
  8865. try {
  8866. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8867. for (const item of items) {
  8868. var _$$find$text$match;
  8869. 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);
  8870. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8871. if (type === 'points' && needPoints > this.myPoints) {
  8872. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8873. } else if (type === 'points' && !needPoints) {
  8874. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8875. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8876. var _aElement$attr;
  8877. const logStatus = scripts_echoLog({
  8878. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8879. });
  8880. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8881. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8882. var _aElement$attr2, _aElement$attr2$match;
  8883. 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];
  8884. if (giveawayId) {
  8885. checkUser(giveawayId);
  8886. }
  8887. }
  8888. if (!aElement.attr('href')) {
  8889. logStatus.error('Error: No "href".');
  8890. continue;
  8891. }
  8892. const {
  8893. result,
  8894. statusText,
  8895. status,
  8896. data
  8897. } = await tools_httpRequest({
  8898. url: aElement.attr('href'),
  8899. method: 'GET'
  8900. });
  8901. if (result === 'Success') {
  8902. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8903. var _data$responseText$ma;
  8904. logStatus.success();
  8905. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8906. if (type === 'points' && points) {
  8907. this.myPoints = parseInt(points, 10);
  8908. }
  8909. } else {
  8910. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8911. }
  8912. } else {
  8913. logStatus.error(`${result}:${statusText}(${status})`);
  8914. }
  8915. }
  8916. }
  8917. scripts_echoLog({
  8918. text: '-----END-----'
  8919. });
  8920. } catch (error) {
  8921. throwError(error, 'OpiumPulses.toggleTask');
  8922. }
  8923. }
  8924. function OpiumPulses_checkLogin2() {
  8925. try {
  8926. if (!globalOptions.other.checkLogin) {
  8927. return true;
  8928. }
  8929. if ($('a[href*="/site/login"]').length > 1) {
  8930. window.open('/site/login', '_self');
  8931. }
  8932. return true;
  8933. } catch (error) {
  8934. throwError(error, 'OpiumPulses.checkLogin');
  8935. return false;
  8936. }
  8937. }
  8938. const website_OpiumPulses = OpiumPulses;
  8939. const external_dayjs_namespaceObject = dayjs;
  8940. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8941. const leftKeyChecker = {
  8942. async classify(link) {
  8943. try {
  8944. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8945. return await this.giveawaySu(link);
  8946. }
  8947. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8948. return await this.giveeClub(link);
  8949. }
  8950. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8951. return await this.gleam(link);
  8952. }
  8953. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8954. return await this.indieDb(link);
  8955. }
  8956. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8957. return await this.keyhub(link);
  8958. }
  8959. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8960. return await this.opquests(link);
  8961. }
  8962. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8963. return await this.itch(link);
  8964. }
  8965. return false;
  8966. } catch (error) {
  8967. throwError(error, 'leftKeyChecker.classify');
  8968. return false;
  8969. }
  8970. },
  8971. async giveawaySu(link) {
  8972. try {
  8973. const {
  8974. result,
  8975. data
  8976. } = await tools_httpRequest({
  8977. url: link,
  8978. method: 'GET'
  8979. });
  8980. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8981. if (data.responseText.includes('class="steam-login"')) {
  8982. return false;
  8983. }
  8984. if (data.responseText.includes('class="giveaway-ended"')) {
  8985. return 'Ended';
  8986. }
  8987. return 'Active';
  8988. }
  8989. return false;
  8990. } catch (error) {
  8991. throwError(error, 'leftKeyChecker.giveawaySu');
  8992. return false;
  8993. }
  8994. },
  8995. async giveeClub(link) {
  8996. try {
  8997. const {
  8998. result,
  8999. data
  9000. } = await tools_httpRequest({
  9001. url: link,
  9002. method: 'GET'
  9003. });
  9004. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9005. if (data.responseText.includes('class="event-winner"')) {
  9006. return 'Won';
  9007. }
  9008. if (data.responseText.includes('class="event-ended"')) {
  9009. return 'Ended';
  9010. }
  9011. return 'Active';
  9012. }
  9013. return false;
  9014. } catch (error) {
  9015. throwError(error, 'leftKeyChecker.giveeClub');
  9016. return false;
  9017. }
  9018. },
  9019. async gleam(link) {
  9020. try {
  9021. const {
  9022. result,
  9023. data
  9024. } = await tools_httpRequest({
  9025. url: link,
  9026. method: 'GET'
  9027. });
  9028. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9029. var _data$responseText$ma, _$$attr, _$$attr$match;
  9030. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  9031. return 'Won';
  9032. }
  9033. 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];
  9034. if (!campaignDiv) {
  9035. return false;
  9036. }
  9037. 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];
  9038. if (!campaignString) {
  9039. return false;
  9040. }
  9041. const {
  9042. campaign
  9043. } = JSON.parse(campaignString);
  9044. if (campaign.banned) {
  9045. return 'Banned';
  9046. }
  9047. if (campaign.finished) {
  9048. return 'Ended';
  9049. }
  9050. if (campaign.paused) {
  9051. return 'Paused';
  9052. }
  9053. if (new Date().getTime() < campaign.starts_at * 1e3) {
  9054. return 'NotStart';
  9055. }
  9056. return 'Active';
  9057. }
  9058. return false;
  9059. } catch (error) {
  9060. throwError(error, 'leftKeyChecker.gleam');
  9061. return false;
  9062. }
  9063. },
  9064. async indieDb(link) {
  9065. try {
  9066. const {
  9067. result,
  9068. data
  9069. } = await tools_httpRequest({
  9070. url: link,
  9071. method: 'GET'
  9072. });
  9073. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9074. if (data.responseText.includes('Congrats you WON')) {
  9075. return 'Won';
  9076. }
  9077. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  9078. return 'Ended';
  9079. }
  9080. return 'Active';
  9081. }
  9082. return false;
  9083. } catch (error) {
  9084. throwError(error, 'leftKeyChecker.indieDb');
  9085. return false;
  9086. }
  9087. },
  9088. async keyhub(link) {
  9089. try {
  9090. const {
  9091. result,
  9092. data
  9093. } = await tools_httpRequest({
  9094. url: link,
  9095. method: 'GET'
  9096. });
  9097. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9098. var _data$responseText$ma2;
  9099. 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];
  9100. if (!keysleft) {
  9101. return false;
  9102. }
  9103. if (keysleft === '0') {
  9104. return 'Ended';
  9105. }
  9106. return `Active(${keysleft})`;
  9107. }
  9108. return false;
  9109. } catch (error) {
  9110. throwError(error, 'leftKeyChecker.keyhub');
  9111. return false;
  9112. }
  9113. },
  9114. async opquests(link) {
  9115. try {
  9116. const {
  9117. result,
  9118. data
  9119. } = await tools_httpRequest({
  9120. url: link,
  9121. method: 'GET'
  9122. });
  9123. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9124. var _data$responseText$ma3;
  9125. 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];
  9126. if (!keysleft) {
  9127. return false;
  9128. }
  9129. if (keysleft === '0') {
  9130. return 'Ended';
  9131. }
  9132. return `Active(${keysleft})`;
  9133. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  9134. return 'Ended';
  9135. }
  9136. return false;
  9137. } catch (error) {
  9138. throwError(error, 'leftKeyChecker.opquests');
  9139. return false;
  9140. }
  9141. },
  9142. async itch(link) {
  9143. try {
  9144. const {
  9145. result,
  9146. data
  9147. } = await tools_httpRequest({
  9148. url: link,
  9149. method: 'GET'
  9150. });
  9151. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9152. var _data$responseText$ma4;
  9153. 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];
  9154. if (!endDate) {
  9155. return false;
  9156. }
  9157. if (new Date().getTime() > new Date(endDate).getTime()) {
  9158. return 'Ended';
  9159. }
  9160. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  9161. }
  9162. return false;
  9163. } catch (error) {
  9164. throwError(error, 'leftKeyChecker.opquests');
  9165. return false;
  9166. }
  9167. }
  9168. };
  9169. const website_leftKeyChecker = leftKeyChecker;
  9170. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  9171. Keylol_checkPrivateRedeclaration(obj, privateSet);
  9172. privateSet.add(obj);
  9173. }
  9174. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  9175. if (privateCollection.has(obj)) {
  9176. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9177. }
  9178. }
  9179. function Keylol_defineProperty(obj, key, value) {
  9180. if (key in obj) {
  9181. Object.defineProperty(obj, key, {
  9182. value: value,
  9183. enumerable: true,
  9184. configurable: true,
  9185. writable: true
  9186. });
  9187. } else {
  9188. obj[key] = value;
  9189. }
  9190. return obj;
  9191. }
  9192. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  9193. if (!privateSet.has(receiver)) {
  9194. throw new TypeError('attempted to get private field on non-instance');
  9195. }
  9196. return fn;
  9197. }
  9198. const Keylol_defaultTasksTemplate = {
  9199. steam: {
  9200. groupLinks: [],
  9201. wishlistLinks: [],
  9202. curatorLinks: [],
  9203. curatorLikeLinks: [],
  9204. followLinks: [],
  9205. forumLinks: [],
  9206. announcementLinks: [],
  9207. workshopVoteLinks: [],
  9208. licenseLinks: []
  9209. },
  9210. discord: {
  9211. serverLinks: []
  9212. },
  9213. instagram: {
  9214. userLinks: []
  9215. },
  9216. vk: {
  9217. nameLinks: []
  9218. },
  9219. twitch: {
  9220. channelLinks: []
  9221. },
  9222. reddit: {
  9223. redditLinks: []
  9224. },
  9225. twitter: {
  9226. userLinks: [],
  9227. retweetLinks: []
  9228. },
  9229. youtube: {
  9230. channelLinks: [],
  9231. likeLinks: []
  9232. }
  9233. };
  9234. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  9235. var _addBtn = new WeakSet();
  9236. class Keylol extends website_Website {
  9237. constructor() {
  9238. super(...arguments);
  9239. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  9240. Keylol_defineProperty(this, 'name', 'Keylol');
  9241. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  9242. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  9243. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  9244. }
  9245. static test() {
  9246. var _$$eq$attr, _$$eq$attr2;
  9247. 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')));
  9248. }
  9249. init() {
  9250. return true;
  9251. }
  9252. after() {
  9253. try {
  9254. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  9255. const mainPost = $(selector);
  9256. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  9257. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  9258. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  9259. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  9260. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  9261. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  9262. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  9263. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  9264. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  9265. if (discordLinks.length > 0) {
  9266. for (const discordLink of discordLinks) {
  9267. const link = $(discordLink).attr('href');
  9268. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  9269. continue;
  9270. }
  9271. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  9272. }
  9273. }
  9274. if (redditLinks.length > 0) {
  9275. for (const redditLink of redditLinks) {
  9276. const link = $(redditLink).attr('href');
  9277. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  9278. continue;
  9279. }
  9280. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  9281. }
  9282. }
  9283. if (insLinks.length > 0) {
  9284. for (const insLink of insLinks) {
  9285. const link = $(insLink).attr('href');
  9286. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  9287. continue;
  9288. }
  9289. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  9290. }
  9291. }
  9292. if (twitterLinks.length > 0) {
  9293. for (const twitterLink of twitterLinks) {
  9294. const link = $(twitterLink).attr('href');
  9295. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  9296. continue;
  9297. }
  9298. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  9299. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  9300. } else {
  9301. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  9302. }
  9303. }
  9304. }
  9305. if (twitchLinks.length > 0) {
  9306. for (const twitchLink of twitchLinks) {
  9307. const link = $(twitchLink).attr('href');
  9308. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  9309. continue;
  9310. }
  9311. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9312. }
  9313. }
  9314. if (vkLinks.length > 0) {
  9315. for (const vkLink of vkLinks) {
  9316. const link = $(vkLink).attr('href');
  9317. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9318. continue;
  9319. }
  9320. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9321. }
  9322. }
  9323. if (steamStoreLinks.length > 0) {
  9324. for (const steamStoreLink of steamStoreLinks) {
  9325. const link = $(steamStoreLink).attr('href');
  9326. if (!link) {
  9327. continue;
  9328. }
  9329. if (/curator\/[\d]+/.test(link)) {
  9330. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9331. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9332. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9333. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9334. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9335. } else if (/app\/[\d]+/.test(link)) {
  9336. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9337. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9338. }
  9339. }
  9340. }
  9341. if (steamCommunityLinks.length > 0) {
  9342. for (const steamCommunityLink of steamCommunityLinks) {
  9343. const link = $(steamCommunityLink).attr('href');
  9344. if (!link) {
  9345. continue;
  9346. }
  9347. if (/groups\/.+/.test(link)) {
  9348. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9349. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9350. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9351. }
  9352. }
  9353. }
  9354. if (ytbLinks.length > 0) {
  9355. for (const ytbLink of ytbLinks) {
  9356. const link = $(ytbLink).attr('href');
  9357. if (!link) {
  9358. continue;
  9359. }
  9360. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9361. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9362. }
  9363. }
  9364. 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');
  9365. if (giveawayLinks.length > 0) {
  9366. for (const giveawayLink of giveawayLinks) {
  9367. const link = $(giveawayLink).attr('href');
  9368. if (!link) {
  9369. continue;
  9370. }
  9371. website_leftKeyChecker.classify(link).then(status => {
  9372. if (!status) {
  9373. return;
  9374. }
  9375. if (/^Active/.test(status)) {
  9376. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9377. return;
  9378. }
  9379. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9380. }).catch(error => {
  9381. throwError(error, 'keylol.after -> leftKeyChecker');
  9382. });
  9383. }
  9384. }
  9385. if (this.name === 'Keylol') {
  9386. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9387. if (asfLinks.length > 0) {
  9388. for (const asfLink of asfLinks) {
  9389. const link = $(asfLink).attr('href');
  9390. if (!link) {
  9391. continue;
  9392. }
  9393. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(`a[href="${link}"]`).after('<span style="color: #ccc; margin: 0 -5px 0 5px"> | </span>').next()[0], 'steam', 'licenseLinks', `appid-${link.replace('#asf', '')}`);
  9394. }
  9395. }
  9396. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9397. if (subLinks.length > 0) {
  9398. for (const subLink of subLinks) {
  9399. var _link$match;
  9400. const link = $(subLink).attr('href');
  9401. if (!link) {
  9402. continue;
  9403. }
  9404. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9405. if (!subid) {
  9406. continue;
  9407. }
  9408. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9409. }
  9410. }
  9411. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9412. if (asfLinks2.length > 0) {
  9413. for (const asfLink of asfLinks2) {
  9414. const subid = asfLink.innerText.match(/[\d]+/g);
  9415. if (!subid || subid.length === 0) {
  9416. continue;
  9417. }
  9418. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9419. }
  9420. }
  9421. }
  9422. } catch (error) {
  9423. throwError(error, 'keylol.after');
  9424. }
  9425. }
  9426. classifyTask(action) {
  9427. try {
  9428. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9429. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9430. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9431. for (const btn of selectedBtns) {
  9432. const button = $(btn);
  9433. const social = button.attr('data-social');
  9434. const type = button.attr('data-type');
  9435. const link = button.attr('data-link');
  9436. if (!(social && type && link)) {
  9437. continue;
  9438. }
  9439. if (action === 'do') {
  9440. this.undoneTasks[social][type].push(link);
  9441. }
  9442. if (action === 'undo') {
  9443. this.socialTasks[social][type].push(link);
  9444. }
  9445. }
  9446. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9447. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9448. if (window.DEBUG) {
  9449. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9450. }
  9451. return true;
  9452. } catch (error) {
  9453. throwError(error, 'Keylol.classifyTask');
  9454. return false;
  9455. }
  9456. }
  9457. selectAll() {
  9458. try {
  9459. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9460. } catch (error) {
  9461. throwError(error, 'Keylol.selectAll');
  9462. }
  9463. }
  9464. selectNone() {
  9465. try {
  9466. $('.auto-task-keylol:visible').removeAttr('selected');
  9467. } catch (error) {
  9468. throwError(error, 'Keylol.selectNone');
  9469. }
  9470. }
  9471. invertSelect() {
  9472. try {
  9473. $('.auto-task-keylol:visible').each((index, element) => {
  9474. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9475. });
  9476. } catch (error) {
  9477. throwError(error, 'Keylol.invertSelect');
  9478. }
  9479. }
  9480. }
  9481. function _addBtn2(before, social, linkType, link) {
  9482. try {
  9483. $(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>`);
  9484. } catch (error) {
  9485. throwError(error, 'keylol.addBtn');
  9486. }
  9487. }
  9488. const website_Keylol = Keylol;
  9489. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9490. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9491. privateSet.add(obj);
  9492. }
  9493. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9494. if (privateCollection.has(obj)) {
  9495. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9496. }
  9497. }
  9498. function Opquests_defineProperty(obj, key, value) {
  9499. if (key in obj) {
  9500. Object.defineProperty(obj, key, {
  9501. value: value,
  9502. enumerable: true,
  9503. configurable: true,
  9504. writable: true
  9505. });
  9506. } else {
  9507. obj[key] = value;
  9508. }
  9509. return obj;
  9510. }
  9511. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9512. if (!privateSet.has(receiver)) {
  9513. throw new TypeError('attempted to get private field on non-instance');
  9514. }
  9515. return fn;
  9516. }
  9517. const Opquests_defaultTasks = {
  9518. steam: {
  9519. groupLinks: [],
  9520. wishlistLinks: [],
  9521. followLinks: [],
  9522. curatorLikeLinks: []
  9523. }
  9524. };
  9525. var Opquests_verify = new WeakSet();
  9526. var Opquests_getGiveawayId = new WeakSet();
  9527. var Opquests_checkLogin = new WeakSet();
  9528. class Opquests extends website_Website {
  9529. constructor() {
  9530. super(...arguments);
  9531. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9532. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9533. Opquests_classPrivateMethodInitSpec(this, Opquests_verify);
  9534. Opquests_defineProperty(this, 'name', 'Opquests');
  9535. Opquests_defineProperty(this, 'undoneTasks', {
  9536. ...Opquests_defaultTasks
  9537. });
  9538. Opquests_defineProperty(this, 'buttons', [ 'doTask', 'verifyTask', 'getKey' ]);
  9539. }
  9540. static test() {
  9541. return window.location.host === 'opquests.com';
  9542. }
  9543. async after() {
  9544. try {
  9545. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9546. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9547. }
  9548. } catch (error) {
  9549. throwError(error, 'Opquests.after');
  9550. }
  9551. }
  9552. init() {
  9553. try {
  9554. const logStatus = scripts_echoLog({
  9555. text: i18n('initing')
  9556. });
  9557. if ($('a[href*="/auth/redirect"]').length > 0) {
  9558. window.open('/auth/redirect', '_self');
  9559. logStatus.warning(i18n('needLogin'));
  9560. return false;
  9561. }
  9562. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9563. return false;
  9564. }
  9565. this.initialized = true;
  9566. logStatus.success();
  9567. return true;
  9568. } catch (error) {
  9569. throwError(error, 'Opquests.init');
  9570. return false;
  9571. }
  9572. }
  9573. async classifyTask(action) {
  9574. try {
  9575. if (action === 'undo') {
  9576. scripts_echoLog({
  9577. text: i18n('cannotUndo')
  9578. });
  9579. return false;
  9580. }
  9581. const logStatus = scripts_echoLog({
  9582. text: i18n('getTasksInfo')
  9583. });
  9584. const tasks = $('.w-full:contains("Validate") .items-center');
  9585. for (const task of tasks) {
  9586. const link = $(task).find('a:contains("Open")').attr('href');
  9587. const taskDes = $(task).find('div').eq(1).text().trim();
  9588. if (!link) {
  9589. continue;
  9590. }
  9591. if (/steamcommunity\.com\/groups\//.test(link)) {
  9592. this.undoneTasks.steam.groupLinks.push(link);
  9593. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9594. if (/wishlist/gim.test(taskDes)) {
  9595. this.undoneTasks.steam.wishlistLinks.push(link);
  9596. } else if (/follow/gim.test(taskDes)) {
  9597. this.undoneTasks.steam.followLinks.push(link);
  9598. }
  9599. } else if (/store\.steampowered\.com\/(publisher|developer|curator)\//.test(link) && /follow/gim.test(taskDes)) {
  9600. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9601. } else {
  9602. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9603. }
  9604. }
  9605. logStatus.success();
  9606. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9607. if (window.DEBUG) {
  9608. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9609. }
  9610. return true;
  9611. } catch (error) {
  9612. throwError(error, 'Opquests.classifyTask');
  9613. return false;
  9614. }
  9615. }
  9616. async verifyTask() {
  9617. try {
  9618. const tasks = $.makeArray($('div.w-full').find('.items-center').has('button.submit-loader')).map(ele => ({
  9619. token: $(ele).find('input[name="_token"]').val(),
  9620. taskId: $(ele).find('input[name="task_id"]').val(),
  9621. title: $(ele).find('span.text-sm').text().trim()
  9622. }));
  9623. const pro = [];
  9624. for (const task of tasks) {
  9625. pro.push(Opquests_classPrivateMethodGet(this, Opquests_verify, Opquests_verify2).call(this, task));
  9626. await delay(1e3);
  9627. }
  9628. await Promise.all(pro);
  9629. scripts_echoLog({}).success(i18n('allTasksComplete'));
  9630. if (await this.getKey()) {
  9631. return true;
  9632. }
  9633. window.location.reload();
  9634. return false;
  9635. } catch (error) {
  9636. throwError(error, 'Opquests.verifyTask');
  9637. return false;
  9638. }
  9639. }
  9640. async getKey(isButton) {
  9641. try {
  9642. const logStatus = scripts_echoLog({
  9643. text: i18n('gettingKey')
  9644. });
  9645. const {
  9646. result,
  9647. statusText,
  9648. status,
  9649. data
  9650. } = await tools_httpRequest({
  9651. url: 'https://opquests.com/keys',
  9652. method: 'GET'
  9653. });
  9654. if (result === 'Success') {
  9655. if (data !== null && data !== void 0 && data.responseText) {
  9656. 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();
  9657. if (!key) {
  9658. logStatus.error('Error: Key was not found');
  9659. if (isButton) {
  9660. window.open('https://opquests.com/keys', '_self');
  9661. }
  9662. return false;
  9663. }
  9664. logStatus.success();
  9665. scripts_echoLog({}).success(key);
  9666. return true;
  9667. }
  9668. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9669. return false;
  9670. }
  9671. logStatus.error(`${result}:${statusText}(${status})`);
  9672. return false;
  9673. } catch (error) {
  9674. throwError(error, 'Opquests.getGiveawayId');
  9675. return false;
  9676. }
  9677. }
  9678. }
  9679. async function Opquests_verify2(task) {
  9680. try {
  9681. const logStatus = scripts_echoLog({
  9682. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  9683. });
  9684. const {
  9685. result,
  9686. statusText,
  9687. status,
  9688. data
  9689. } = await tools_httpRequest({
  9690. url: 'https://opquests.com/entries',
  9691. method: 'POST',
  9692. dataType: 'json',
  9693. nochche: true,
  9694. headers: {
  9695. origin: 'https://opquests.com',
  9696. pragma: 'no-cache',
  9697. referer: window.location.href,
  9698. 'content-type': 'application/x-www-form-urlencoded'
  9699. },
  9700. data: `_token=${task.token}&task_id=${task.taskId}`
  9701. });
  9702. if (result === 'Success') {
  9703. var _data$responseText, _data$responseText2, _$$find$attr;
  9704. 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')) {
  9705. logStatus.success();
  9706. return true;
  9707. }
  9708. 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();
  9709. if (key) {
  9710. logStatus.success();
  9711. scripts_echoLog({}).success(key);
  9712. return true;
  9713. }
  9714. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9715. return false;
  9716. }
  9717. logStatus.error(`${result}:${statusText}(${status})`);
  9718. return false;
  9719. } catch (error) {
  9720. throwError(error, 'Opquests.verify');
  9721. return false;
  9722. }
  9723. }
  9724. function Opquests_getGiveawayId2() {
  9725. try {
  9726. var _window$location$href;
  9727. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9728. if (giveawayId) {
  9729. this.giveawayId = giveawayId;
  9730. return true;
  9731. }
  9732. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9733. return false;
  9734. } catch (error) {
  9735. throwError(error, 'Opquests.getGiveawayId');
  9736. return false;
  9737. }
  9738. }
  9739. function Opquests_checkLogin2() {
  9740. try {
  9741. if (!globalOptions.other.checkLogin) {
  9742. return true;
  9743. }
  9744. if ($('a[href*="/auth/redirect"]').length > 0) {
  9745. window.open('/auth/redirect', '_self');
  9746. }
  9747. return true;
  9748. } catch (error) {
  9749. throwError(error, 'Opquests.checkLogin');
  9750. return false;
  9751. }
  9752. }
  9753. const website_Opquests = Opquests;
  9754. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9755. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9756. privateSet.add(obj);
  9757. }
  9758. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9759. if (privateCollection.has(obj)) {
  9760. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9761. }
  9762. }
  9763. function Gleam_defineProperty(obj, key, value) {
  9764. if (key in obj) {
  9765. Object.defineProperty(obj, key, {
  9766. value: value,
  9767. enumerable: true,
  9768. configurable: true,
  9769. writable: true
  9770. });
  9771. } else {
  9772. obj[key] = value;
  9773. }
  9774. return obj;
  9775. }
  9776. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9777. if (!privateSet.has(receiver)) {
  9778. throw new TypeError('attempted to get private field on non-instance');
  9779. }
  9780. return fn;
  9781. }
  9782. const Gleam_defaultTasksTemplate = {
  9783. steam: {
  9784. groupLinks: [],
  9785. wishlistLinks: [],
  9786. followLinks: [],
  9787. curatorLinks: [],
  9788. curatorLikeLinks: []
  9789. },
  9790. twitter: {
  9791. userLinks: [],
  9792. retweetLinks: []
  9793. },
  9794. twitch: {
  9795. channelLinks: []
  9796. },
  9797. discord: {
  9798. serverLinks: []
  9799. },
  9800. youtube: {
  9801. channelLinks: []
  9802. },
  9803. extra: {
  9804. gleam: []
  9805. }
  9806. };
  9807. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9808. const Gleam_defaultOptions = {
  9809. vlootUsername: '',
  9810. gameroundUsername: ''
  9811. };
  9812. var _checkSync = new WeakSet();
  9813. var _doGleamTask = new WeakSet();
  9814. var Gleam_getGiveawayId = new WeakSet();
  9815. var _getGleamLink = new WeakSet();
  9816. var Gleam_checkLeftKey = new WeakSet();
  9817. class Gleam extends website_Website {
  9818. constructor() {
  9819. super(...arguments);
  9820. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9821. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9822. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9823. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9824. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9825. Gleam_defineProperty(this, 'name', 'Gleam');
  9826. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9827. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9828. Gleam_defineProperty(this, 'options', {
  9829. ...Gleam_defaultOptions,
  9830. ...GM_getValue('GleamOptions')
  9831. });
  9832. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9833. }
  9834. static test() {
  9835. return window.location.host === 'gleam.io';
  9836. }
  9837. async after() {
  9838. try {
  9839. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9840. const checkComplete = setInterval(() => {
  9841. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9842. clearInterval(checkComplete);
  9843. window.close();
  9844. }
  9845. });
  9846. for (const task of $('.entry-content .entry-method')) {
  9847. const taskInfo = $(task).find('.user-links');
  9848. const expandInfo = $(task).find('.expandable');
  9849. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9850. if (aElements.length > 0) {
  9851. for (const element of aElements) {
  9852. const $element = $(element);
  9853. const href = $element.attr('href');
  9854. $element.removeAttr('href')[0].click();
  9855. $element.attr('href', href);
  9856. await delay(1e3);
  9857. }
  9858. }
  9859. taskInfo[0].click();
  9860. await delay(1e3);
  9861. }
  9862. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9863. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9864. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9865. }
  9866. } catch (error) {
  9867. throwError(error, 'Gleam.after');
  9868. return false;
  9869. }
  9870. }
  9871. init() {
  9872. try {
  9873. const logStatus = scripts_echoLog({
  9874. text: i18n('initing')
  9875. });
  9876. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9877. return false;
  9878. }
  9879. this.initialized = true;
  9880. logStatus.success();
  9881. return true;
  9882. } catch (error) {
  9883. throwError(error, 'Gleam.init');
  9884. return false;
  9885. }
  9886. }
  9887. async classifyTask(action) {
  9888. try {
  9889. const logStatus = scripts_echoLog({
  9890. text: i18n('getTasksInfo')
  9891. });
  9892. if (action === 'undo') {
  9893. var _GM_getValue;
  9894. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9895. }
  9896. const tasks = $('.entry-content .entry-method');
  9897. for (const task of tasks) {
  9898. var _socialIcon$attr;
  9899. const $task = $(task);
  9900. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9901. continue;
  9902. }
  9903. const socialIcon = $task.find('.icon-wrapper i');
  9904. const taskInfo = $task.find('.user-links');
  9905. const taskText = taskInfo.text().trim();
  9906. const expandInfo = $task.find('.expandable');
  9907. const aElements = expandInfo.find('a.btn');
  9908. if (aElements.length > 0) {
  9909. for (const element of aElements) {
  9910. const $element = $(element);
  9911. const href = $element.attr('href');
  9912. $element.removeAttr('href')[0].click();
  9913. $element.attr('href', href);
  9914. }
  9915. }
  9916. if (socialIcon.hasClass('fa-twitter')) {
  9917. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9918. if (!link) {
  9919. continue;
  9920. }
  9921. if (/follow/gi.test(taskText)) {
  9922. if (action === 'undo') {
  9923. this.socialTasks.twitter.userLinks.push(link);
  9924. }
  9925. if (action === 'do') {
  9926. this.undoneTasks.twitter.userLinks.push(link);
  9927. }
  9928. } else if (/retweet/gim.test(taskText)) {
  9929. if (action === 'undo') {
  9930. this.socialTasks.twitter.retweetLinks.push(link);
  9931. }
  9932. if (action === 'do') {
  9933. this.undoneTasks.twitter.retweetLinks.push(link);
  9934. }
  9935. }
  9936. } else if (socialIcon.hasClass('fa-twitch')) {
  9937. if (/follow/gim.test(taskText)) {
  9938. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9939. if (!link) {
  9940. continue;
  9941. }
  9942. if (action === 'undo') {
  9943. this.socialTasks.twitch.channelLinks.push(link);
  9944. }
  9945. if (action === 'do') {
  9946. this.undoneTasks.twitch.channelLinks.push(link);
  9947. }
  9948. }
  9949. } else if (socialIcon.hasClass('fa-discord')) {
  9950. if (/join/gim.test(taskText)) {
  9951. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9952. if (!link) {
  9953. var _$task$find$attr, _$task$find$attr$matc;
  9954. 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];
  9955. if (!ggLink) {
  9956. continue;
  9957. }
  9958. link = `https://discord.com/invite/${ggLink}`;
  9959. }
  9960. if (action === 'undo') {
  9961. this.socialTasks.discord.serverLinks.push(link);
  9962. }
  9963. if (action === 'do') {
  9964. this.undoneTasks.discord.serverLinks.push(link);
  9965. }
  9966. }
  9967. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9968. continue;
  9969. } else if (socialIcon.hasClass('fa-youtube')) {
  9970. if (/subscribe/gim.test(taskText)) {
  9971. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9972. if (!link) {
  9973. continue;
  9974. }
  9975. if (action === 'undo') {
  9976. this.socialTasks.youtube.channelLinks.push(link);
  9977. }
  9978. if (action === 'do') {
  9979. this.undoneTasks.youtube.channelLinks.push(link);
  9980. }
  9981. }
  9982. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9983. if (/join.*group/gi.test(taskText)) {
  9984. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9985. if (!link) {
  9986. continue;
  9987. }
  9988. if (action === 'undo') {
  9989. this.socialTasks.steam.groupLinks.push(link);
  9990. }
  9991. if (action === 'do') {
  9992. this.undoneTasks.steam.groupLinks.push(link);
  9993. }
  9994. } else if (/follow.*curator/gi.test(taskText)) {
  9995. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9996. if (!link) {
  9997. continue;
  9998. }
  9999. if (action === 'undo') {
  10000. this.socialTasks.steam.curatorLinks.push(link);
  10001. }
  10002. if (action === 'do') {
  10003. this.undoneTasks.steam.curatorLinks.push(link);
  10004. }
  10005. }
  10006. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('vloot.io') || socialIcon.hasClass('fa-tiktok')) {
  10007. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  10008. for (const button of continueBtn) {
  10009. button.click();
  10010. await delay(500);
  10011. expandInfo.find('input').val(this.options.vlootUsername);
  10012. }
  10013. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  10014. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  10015. for (const button of continueBtn) {
  10016. button.click();
  10017. await delay(500);
  10018. expandInfo.find('input').val(this.options.gameroundUsername);
  10019. }
  10020. } else if (socialIcon.hasClass('fa-bullhorn') && /Complete/gi.test(taskText)) {
  10021. if (action !== 'do') {
  10022. continue;
  10023. }
  10024. const link = aElements.attr('href');
  10025. if (!link) {
  10026. continue;
  10027. }
  10028. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  10029. if (!gleamLink) {
  10030. continue;
  10031. }
  10032. this.undoneTasks.extra.gleam.push(gleamLink);
  10033. } 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-shield') && taskText.includes('Check out')) {} else {
  10034. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  10035. }
  10036. }
  10037. logStatus.success();
  10038. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  10039. this.socialTasks = this.uniqueTasks(this.socialTasks);
  10040. if (window.DEBUG) {
  10041. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  10042. }
  10043. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  10044. tasks: this.socialTasks,
  10045. time: new Date().getTime()
  10046. });
  10047. return true;
  10048. } catch (error) {
  10049. throwError(error, 'Gleam.classifyTask');
  10050. return false;
  10051. }
  10052. }
  10053. async extraDoTask(_ref) {
  10054. let {
  10055. gleam
  10056. } = _ref;
  10057. try {
  10058. const pro = [];
  10059. for (const link of gleam) {
  10060. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  10061. }
  10062. return Promise.all(pro).then(() => true);
  10063. } catch (error) {
  10064. throwError(error, 'Gleam.extraDoTask');
  10065. return false;
  10066. }
  10067. }
  10068. async verifyTask() {
  10069. try {
  10070. scripts_echoLog({
  10071. text: `${i18n('verifyingTask')}...`
  10072. });
  10073. const tasks = $('.entry-content .entry-method');
  10074. for (const task of tasks) {
  10075. const $task = $(task);
  10076. if ($task.find('i.fa-question').length === 0) {
  10077. continue;
  10078. }
  10079. const taskInfo = $task.find('.user-links');
  10080. taskInfo[0].click();
  10081. await delay(500);
  10082. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  10083. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  10084. for (const button of continueBtn) {
  10085. button.click();
  10086. await delay(500);
  10087. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  10088. }
  10089. }
  10090. scripts_echoLog({
  10091. text: i18n('verifiedGleamTasks')
  10092. });
  10093. } catch (error) {
  10094. throwError(error, 'Gleam.verifyTask');
  10095. return false;
  10096. }
  10097. }
  10098. }
  10099. async function _checkSync2() {
  10100. try {
  10101. return await new Promise(resolve => {
  10102. const checker = setInterval(() => {
  10103. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  10104. clearInterval(checker);
  10105. resolve(true);
  10106. }
  10107. }, 500);
  10108. });
  10109. } catch (error) {
  10110. throwError(error, 'Gleam.checkSync');
  10111. return false;
  10112. }
  10113. }
  10114. async function _doGleamTask2(link) {
  10115. try {
  10116. const logStatus = scripts_echoLog({
  10117. text: i18n('doingGleamTask')
  10118. });
  10119. return await new Promise(resolve => {
  10120. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  10121. active: true,
  10122. insert: true,
  10123. setParent: true
  10124. }).onclose = () => {
  10125. logStatus.success();
  10126. resolve(true);
  10127. };
  10128. });
  10129. } catch (error) {
  10130. throwError(error, 'Gleam.doGleamTask');
  10131. return false;
  10132. }
  10133. }
  10134. function Gleam_getGiveawayId2() {
  10135. try {
  10136. const giveawayId = window.location.pathname;
  10137. if (giveawayId) {
  10138. this.giveawayId = giveawayId;
  10139. return true;
  10140. }
  10141. scripts_echoLog({
  10142. text: i18n('getFailed', 'GiveawayId')
  10143. });
  10144. return false;
  10145. } catch (error) {
  10146. throwError(error, 'Gleam.getGiveawayId');
  10147. return false;
  10148. }
  10149. }
  10150. async function _getGleamLink2(link) {
  10151. try {
  10152. const logStatus = scripts_echoLog({
  10153. text: i18n('gettingGleamLink')
  10154. });
  10155. const {
  10156. result,
  10157. statusText,
  10158. status,
  10159. data
  10160. } = await tools_httpRequest({
  10161. url: link,
  10162. method: 'GET'
  10163. });
  10164. if (result === 'Success') {
  10165. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10166. var _data$responseText$ma;
  10167. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  10168. if (gleamLink) {
  10169. logStatus.success();
  10170. return gleamLink;
  10171. }
  10172. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  10173. return false;
  10174. }
  10175. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10176. return false;
  10177. }
  10178. logStatus.error(`${result}:${statusText}(${status})`);
  10179. return false;
  10180. } catch (error) {
  10181. throwError(error, 'Gleam.getGleamLink');
  10182. return false;
  10183. }
  10184. }
  10185. async function Gleam_checkLeftKey2() {
  10186. try {
  10187. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  10188. if (!globalOptions.other.checkLeftKey) {
  10189. return true;
  10190. }
  10191. 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];
  10192. if (!campaignString) {
  10193. return false;
  10194. }
  10195. const {
  10196. campaign,
  10197. incentive
  10198. } = JSON.parse(campaignString);
  10199. 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];
  10200. let ownedKey = false;
  10201. if (controllerString) {
  10202. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  10203. 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) {
  10204. ownedKey = true;
  10205. }
  10206. }
  10207. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  10208. await external_Swal_default().fire({
  10209. icon: 'warning',
  10210. title: i18n('notice'),
  10211. text: i18n('giveawayNotWork'),
  10212. confirmButtonText: i18n('confirm'),
  10213. cancelButtonText: i18n('cancel'),
  10214. showCancelButton: true
  10215. }).then(_ref2 => {
  10216. let {
  10217. value
  10218. } = _ref2;
  10219. if (value) {
  10220. window.close();
  10221. }
  10222. });
  10223. }
  10224. return true;
  10225. } catch (error) {
  10226. throwError(error, 'Gleam.checkLeftKey');
  10227. return false;
  10228. }
  10229. }
  10230. const website_Gleam = Gleam;
  10231. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  10232. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  10233. privateSet.add(obj);
  10234. }
  10235. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  10236. if (privateCollection.has(obj)) {
  10237. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10238. }
  10239. }
  10240. function SweepWidget_defineProperty(obj, key, value) {
  10241. if (key in obj) {
  10242. Object.defineProperty(obj, key, {
  10243. value: value,
  10244. enumerable: true,
  10245. configurable: true,
  10246. writable: true
  10247. });
  10248. } else {
  10249. obj[key] = value;
  10250. }
  10251. return obj;
  10252. }
  10253. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  10254. if (!privateSet.has(receiver)) {
  10255. throw new TypeError('attempted to get private field on non-instance');
  10256. }
  10257. return fn;
  10258. }
  10259. const SweepWidget_defaultOptions = {
  10260. username: '',
  10261. email: ''
  10262. };
  10263. var SweepWidget_checkLogin = new WeakSet();
  10264. var SweepWidget_getGiveawayId = new WeakSet();
  10265. var _checkEnter = new WeakSet();
  10266. var _checkFinish = new WeakSet();
  10267. class SweepWidget extends website_Website {
  10268. constructor() {
  10269. super(...arguments);
  10270. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  10271. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  10272. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  10273. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  10274. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  10275. SweepWidget_defineProperty(this, 'options', {
  10276. ...SweepWidget_defaultOptions,
  10277. ...GM_getValue('SweepWidgetOptions')
  10278. });
  10279. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  10280. }
  10281. static test() {
  10282. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  10283. }
  10284. async after() {
  10285. try {
  10286. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  10287. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  10288. }
  10289. } catch (error) {
  10290. throwError(error, 'SweepWidget.after');
  10291. }
  10292. }
  10293. init() {
  10294. try {
  10295. const logStatus = scripts_echoLog({
  10296. text: i18n('initing')
  10297. });
  10298. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  10299. logStatus.warning(i18n('needLogin'));
  10300. return false;
  10301. }
  10302. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  10303. return false;
  10304. }
  10305. this.initialized = true;
  10306. logStatus.success();
  10307. return true;
  10308. } catch (error) {
  10309. throwError(error, 'SweepWidget.init');
  10310. return false;
  10311. }
  10312. }
  10313. classifyTask() {
  10314. return true;
  10315. }
  10316. async doTask() {
  10317. try {
  10318. if ($('#unlock_rewards_main_wrapper').length === 0) {
  10319. if ($('input[name="sw__login_name"]:visible').length > 0) {
  10320. $('input[name="sw__login_name"]').val(this.options.username);
  10321. }
  10322. if ($('input[name="sw__login_email"]:visible').length > 0) {
  10323. $('input[name="sw__login_email"]').val(this.options.email);
  10324. }
  10325. if ($('#sw_login_button:visible').length > 0) {
  10326. $('#sw_login_button')[0].click();
  10327. }
  10328. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  10329. return false;
  10330. }
  10331. }
  10332. const logStatus = scripts_echoLog({
  10333. text: i18n('SweepWidgetNotice')
  10334. });
  10335. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  10336. for (const task of tasks) {
  10337. var _aElement$, _$task$find$removeAtt;
  10338. const $task = $(task);
  10339. if ($task.find('i.fa-check:visible').length > 0) {
  10340. continue;
  10341. }
  10342. const title = $task.find('.sw_text_inner');
  10343. title[0].click();
  10344. const aElement = $task.find('a.sw_link');
  10345. const link = aElement.attr('href');
  10346. aElement.attr('href', '#a').attr('target', '_self');
  10347. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  10348. await delay(300);
  10349. aElement.attr('href', link).attr('target', '_blank');
  10350. $task.find('input[type="text"]').val('test');
  10351. const verifyBtn = $task.find('input.sw_verify');
  10352. if (verifyBtn.prop('disabled') === true) {
  10353. title[0].click();
  10354. await delay(300);
  10355. title[0].click();
  10356. await delay(300);
  10357. }
  10358. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  10359. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  10360. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  10361. }
  10362. logStatus.success();
  10363. return true;
  10364. } catch (error) {
  10365. throwError(error, 'SweepWidget.doTask');
  10366. return false;
  10367. }
  10368. }
  10369. }
  10370. function SweepWidget_checkLogin2() {
  10371. try {
  10372. if ($('#twitter_login_button').length > 0) {
  10373. $('#twitter_login_button')[0].click();
  10374. }
  10375. return true;
  10376. } catch (error) {
  10377. throwError(error, 'SweepWidget.checkLogin');
  10378. return false;
  10379. }
  10380. }
  10381. function SweepWidget_getGiveawayId2() {
  10382. try {
  10383. var _window$location$href;
  10384. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  10385. if (giveawayId) {
  10386. this.giveawayId = giveawayId;
  10387. return true;
  10388. }
  10389. scripts_echoLog({
  10390. text: i18n('getFailed', 'GiveawayId')
  10391. });
  10392. return false;
  10393. } catch (error) {
  10394. throwError(error, 'SweepWidget.getGiveawayId');
  10395. return false;
  10396. }
  10397. }
  10398. async function _checkEnter2() {
  10399. try {
  10400. return new Promise(resolve => {
  10401. const checker = setInterval(() => {
  10402. if ($('#unlock_rewards_main_wrapper').length > 0) {
  10403. clearInterval(checker);
  10404. resolve(true);
  10405. }
  10406. });
  10407. });
  10408. } catch (error) {
  10409. throwError(error, 'SweepWidget.checkEnter');
  10410. return false;
  10411. }
  10412. }
  10413. async function _checkFinish2($task) {
  10414. try {
  10415. return new Promise(resolve => {
  10416. const checker = setInterval(() => {
  10417. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  10418. clearInterval(checker);
  10419. resolve(true);
  10420. }
  10421. });
  10422. });
  10423. } catch (error) {
  10424. throwError(error, 'SweepWidget.checkFinish');
  10425. return false;
  10426. }
  10427. }
  10428. const website_SweepWidget = SweepWidget;
  10429. const defaultWhiteList = {
  10430. discord: {
  10431. servers: []
  10432. },
  10433. instagram: {
  10434. users: []
  10435. },
  10436. twitch: {
  10437. channels: []
  10438. },
  10439. twitter: {
  10440. users: [],
  10441. retweets: [],
  10442. likes: []
  10443. },
  10444. vk: {
  10445. names: []
  10446. },
  10447. youtube: {
  10448. channels: [],
  10449. likes: []
  10450. },
  10451. reddit: {
  10452. reddits: []
  10453. },
  10454. steam: {
  10455. groups: [],
  10456. officialGroups: [],
  10457. wishlists: [],
  10458. follows: [],
  10459. forums: [],
  10460. workshops: [],
  10461. curators: [],
  10462. workshopVotes: [],
  10463. curatorLikes: [],
  10464. announcements: [],
  10465. licenses: [],
  10466. playtests: []
  10467. }
  10468. };
  10469. const link2id = async function(type) {
  10470. 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;
  10471. try {
  10472. const link = $('#socialLink').val();
  10473. let id = '';
  10474. switch (type) {
  10475. case 'discord.servers':
  10476. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10477. break;
  10478.  
  10479. case 'instagram.users':
  10480. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10481. break;
  10482.  
  10483. case 'twitch.channels':
  10484. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10485. break;
  10486.  
  10487. case 'twitter.users':
  10488. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10489. break;
  10490.  
  10491. case 'twitter.retweets':
  10492. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10493. break;
  10494.  
  10495. case 'vk.names':
  10496. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10497. break;
  10498.  
  10499. case 'youtube.channels':
  10500. 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) || '';
  10501. break;
  10502.  
  10503. case 'youtube.likes':
  10504. 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) || '';
  10505. break;
  10506.  
  10507. case 'reddit.reddits':
  10508. 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]) || '';
  10509. break;
  10510.  
  10511. case 'steam.groups':
  10512. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10513. break;
  10514.  
  10515. case 'steam.wishlists':
  10516. case 'steam.follows':
  10517. case 'steam.forums':
  10518. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10519. break;
  10520.  
  10521. case 'steam.workshops':
  10522. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10523. break;
  10524.  
  10525. case 'steam.curators':
  10526. {
  10527. if (link.includes('curator')) {
  10528. var _link$match12;
  10529. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10530. } else {
  10531. var _link$match13;
  10532. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10533. if (!param || param.length !== 2) {
  10534. break;
  10535. }
  10536. const steam = new social_Steam();
  10537. if (await steam.init()) {
  10538. id = await steam.getCuratorId(param[0], param[1]) || '';
  10539. }
  10540. }
  10541. }
  10542. break;
  10543. }
  10544. return id;
  10545. } catch (error) {
  10546. throwError(error, 'link2id');
  10547. return i18n('getFailed', 'id');
  10548. }
  10549. };
  10550. const disabledType = {
  10551. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10552. twitter: [ 'likes' ]
  10553. };
  10554. const assignWhiteList = whiteList => {
  10555. try {
  10556. const newWhiteList = {};
  10557. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10558. newWhiteList[key] = {
  10559. ...value,
  10560. ...whiteList[key]
  10561. };
  10562. }
  10563. return newWhiteList;
  10564. } catch (error) {
  10565. throwError(error, 'assignWhiteList');
  10566. return defaultWhiteList;
  10567. }
  10568. };
  10569. const whiteListOptions = function(showType) {
  10570. try {
  10571. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10572. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10573. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10574. for (const [ social, types ] of Object.entries(whiteList)) {
  10575. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10576. var _disabledType$social;
  10577. 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>`;
  10578. }).join('');
  10579. }
  10580. whiteListOptionsForm += '</tbody></table></form>';
  10581. if (showType === 'swal') {
  10582. external_Swal_default().fire({
  10583. title: i18n('whiteListOptions'),
  10584. html: whiteListOptionsForm,
  10585. showConfirmButton: false,
  10586. showCloseButton: true
  10587. });
  10588. } else {
  10589. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10590. }
  10591. $('.editWhiteList').on('click', function() {
  10592. var _whiteList$social;
  10593. const value = $(this).attr('data-value');
  10594. if (!value) {
  10595. return;
  10596. }
  10597. const [ social, type ] = value.split('.');
  10598. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10599. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10600. return;
  10601. }
  10602. external_Swal_default().fire({
  10603. title: i18n('changeWhiteListOption', value),
  10604. input: 'textarea',
  10605. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10606. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10607. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10608. inputValue: whiteList[social][type].join('\n'),
  10609. showConfirmButton: true,
  10610. confirmButtonText: i18n('save'),
  10611. showCancelButton: true,
  10612. cancelButtonText: i18n('close'),
  10613. showDenyButton: true,
  10614. denyButtonText: i18n('return')
  10615. }).then(_ref => {
  10616. let {
  10617. isDenied,
  10618. isConfirmed,
  10619. value
  10620. } = _ref;
  10621. if (isDenied) {
  10622. if (showType === 'swal') {
  10623. whiteListOptions(showType);
  10624. }
  10625. return;
  10626. } else if (isConfirmed) {
  10627. whiteList[social][type] = value.split('\n');
  10628. GM_setValue('whiteList', whiteList);
  10629. external_Swal_default().fire({
  10630. title: i18n('changeWhiteListSuccess'),
  10631. icon: 'success'
  10632. });
  10633. }
  10634. });
  10635. $('#link2id').on('click', async function() {
  10636. const type = $(this).attr('data-type');
  10637. $('#socialLink').val(await link2id(type));
  10638. });
  10639. });
  10640. } catch (error) {
  10641. throwError(error, 'whiteListOptions');
  10642. }
  10643. };
  10644. const whiteList = whiteListOptions;
  10645. const setGistData = async (token, gistId, fileName, content) => {
  10646. try {
  10647. const logStatus = scripts_echoLog({
  10648. text: i18n('settingData')
  10649. });
  10650. const contentData = JSON.stringify({
  10651. files: {
  10652. [fileName]: {
  10653. content: JSON.stringify(content)
  10654. }
  10655. }
  10656. });
  10657. const {
  10658. result,
  10659. statusText,
  10660. status,
  10661. data
  10662. } = await tools_httpRequest({
  10663. url: `https://api.github.com/gists/${gistId}`,
  10664. headers: {
  10665. Accept: 'application/vnd.github.v3+json',
  10666. Authorization: `token ${token}`
  10667. },
  10668. data: contentData,
  10669. responseType: 'json',
  10670. method: 'POST',
  10671. timeout: 3e4
  10672. });
  10673. if (result === 'Success') {
  10674. var _data$response$files, _data$response$files$;
  10675. 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)) {
  10676. logStatus.success();
  10677. return true;
  10678. }
  10679. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10680. return false;
  10681. }
  10682. logStatus.error(`${result}:${statusText}(${status})`);
  10683. return false;
  10684. } catch (error) {
  10685. throwError(error, 'setGistData');
  10686. return false;
  10687. }
  10688. };
  10689. const getGistData = async function(token, gistId, fileName) {
  10690. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10691. try {
  10692. const logStatus = scripts_echoLog({
  10693. text: i18n('gettingData')
  10694. });
  10695. const {
  10696. result,
  10697. statusText,
  10698. status,
  10699. data
  10700. } = await tools_httpRequest({
  10701. url: `https://api.github.com/gists/${gistId}`,
  10702. headers: {
  10703. Accept: 'application/vnd.github.v3+json',
  10704. Authorization: `token ${token}`
  10705. },
  10706. responseType: 'json',
  10707. method: 'GET',
  10708. timeout: 3e4
  10709. });
  10710. if (result === 'Success') {
  10711. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10712. var _data$response, _data$response$files2, _data$response$files3;
  10713. 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;
  10714. let formatedContent;
  10715. if (!content) {
  10716. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10717. return false;
  10718. }
  10719. if (test) {
  10720. logStatus.success();
  10721. return true;
  10722. }
  10723. try {
  10724. formatedContent = JSON.parse(content);
  10725. } catch (error) {
  10726. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10727. return false;
  10728. }
  10729. logStatus.success();
  10730. return formatedContent;
  10731. }
  10732. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10733. return false;
  10734. }
  10735. logStatus.error(`${result}:${statusText}(${status})`);
  10736. return false;
  10737. } catch (error) {
  10738. throwError(error, 'getGistData');
  10739. return false;
  10740. }
  10741. };
  10742. const syncOptions = () => {
  10743. try {
  10744. const {
  10745. TOKEN,
  10746. GIST_ID,
  10747. FILE_NAME,
  10748. SYNC_HISTORY
  10749. } = GM_getValue('gistOptions') || {
  10750. TOKEN: '',
  10751. GIST_ID: '',
  10752. FILE_NAME: '',
  10753. SYNC_HISTORY: true
  10754. };
  10755. external_Swal_default().fire({
  10756. title: i18n('gistOptions'),
  10757. 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;">
  10758. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10759. ${i18n('downloadFromGist')}</button></p>`,
  10760. focusConfirm: false,
  10761. showLoaderOnConfirm: true,
  10762. 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>`,
  10763. preConfirm: async () => {
  10764. const token = $('#github-token').val();
  10765. const gistId = $('#gist-id').val();
  10766. const fileName = $('#file-name').val();
  10767. const syncHistory = $('#sync-history').prop('checked');
  10768. GM_setValue('gistOptions', {
  10769. TOKEN: token,
  10770. GIST_ID: gistId,
  10771. FILE_NAME: fileName,
  10772. SYNC_HISTORY: syncHistory
  10773. });
  10774. return await getGistData(token, gistId, fileName, true);
  10775. },
  10776. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10777. confirmButtonText: i18n('saveAndTest'),
  10778. showCancelButton: true,
  10779. cancelButtonText: i18n('close')
  10780. }).then(_ref => {
  10781. let {
  10782. value
  10783. } = _ref;
  10784. if (value) {
  10785. external_Swal_default().fire({
  10786. icon: 'success',
  10787. title: i18n('testSuccess')
  10788. }).then(syncOptions);
  10789. } else if (value !== undefined) {
  10790. external_Swal_default().fire({
  10791. icon: 'error',
  10792. title: i18n('testFailed')
  10793. }).then(syncOptions);
  10794. }
  10795. });
  10796. $('#upload-data').on('click', async () => {
  10797. const {
  10798. TOKEN,
  10799. GIST_ID,
  10800. FILE_NAME
  10801. } = GM_getValue('gistOptions') || {};
  10802. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10803. return external_Swal_default().fire({
  10804. icon: 'error',
  10805. title: i18n('saveAndTestNotice')
  10806. }).then(syncOptions);
  10807. }
  10808. external_Swal_default().fire({
  10809. icon: 'info',
  10810. title: i18n('processingData')
  10811. });
  10812. const data = {};
  10813. const names = GM_listValues();
  10814. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10815. for (const name of names) {
  10816. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10817. continue;
  10818. }
  10819. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10820. continue;
  10821. }
  10822. data[name] = GM_getValue(name);
  10823. }
  10824. external_Swal_default().update({
  10825. icon: 'info',
  10826. title: i18n('updatingData')
  10827. });
  10828. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10829. external_Swal_default().fire({
  10830. icon: 'success',
  10831. title: i18n('syncDataSuccess')
  10832. });
  10833. } else {
  10834. external_Swal_default().fire({
  10835. icon: 'error',
  10836. title: i18n('syncDataFailed')
  10837. });
  10838. }
  10839. });
  10840. $('#download-data').on('click', async () => {
  10841. const {
  10842. TOKEN,
  10843. GIST_ID,
  10844. FILE_NAME
  10845. } = GM_getValue('gistOptions') || {};
  10846. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10847. return external_Swal_default().fire({
  10848. icon: 'error',
  10849. title: i18n('saveAndTestNotice')
  10850. }).then(syncOptions);
  10851. }
  10852. external_Swal_default().fire({
  10853. icon: 'info',
  10854. title: i18n('downloadingData')
  10855. });
  10856. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10857. if (!data) {
  10858. return external_Swal_default().fire({
  10859. icon: 'error',
  10860. title: i18n('checkedNoData')
  10861. }).then(syncOptions);
  10862. }
  10863. external_Swal_default().update({
  10864. icon: 'info',
  10865. title: i18n('savingData')
  10866. });
  10867. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10868. for (const [ name, value ] of Object.entries(data)) {
  10869. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10870. continue;
  10871. }
  10872. GM_setValue(name, value);
  10873. }
  10874. external_Swal_default().fire({
  10875. icon: 'success',
  10876. title: i18n('syncDataSuccess')
  10877. });
  10878. });
  10879. } catch (error) {
  10880. throwError(error, 'syncOptions');
  10881. }
  10882. };
  10883. const dataSync = syncOptions;
  10884. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10885. Setting_checkPrivateRedeclaration(obj, privateSet);
  10886. privateSet.add(obj);
  10887. }
  10888. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10889. if (privateCollection.has(obj)) {
  10890. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10891. }
  10892. }
  10893. function Setting_defineProperty(obj, key, value) {
  10894. if (key in obj) {
  10895. Object.defineProperty(obj, key, {
  10896. value: value,
  10897. enumerable: true,
  10898. configurable: true,
  10899. writable: true
  10900. });
  10901. } else {
  10902. obj[key] = value;
  10903. }
  10904. return obj;
  10905. }
  10906. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10907. if (!privateSet.has(receiver)) {
  10908. throw new TypeError('attempted to get private field on non-instance');
  10909. }
  10910. return fn;
  10911. }
  10912. var Setting_getId = new WeakSet();
  10913. var _environment = new WeakSet();
  10914. class Setting {
  10915. constructor() {
  10916. Setting_classPrivateMethodInitSpec(this, _environment);
  10917. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10918. Setting_defineProperty(this, 'name', 'Setting');
  10919. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10920. Setting_defineProperty(this, 'syncData', dataSync);
  10921. }
  10922. tasksHistory() {
  10923. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10924. }
  10925. static test() {
  10926. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10927. }
  10928. before() {
  10929. $('body').html('').addClass('auto-task-options');
  10930. }
  10931. after() {
  10932. try {
  10933. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10934. changeGlobalOptions('page');
  10935. whiteList('page');
  10936. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10937. $('#getTwitterUserId').on('click', () => {
  10938. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10939. });
  10940. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10941. $('#getYoutubeChannelId').on('click', () => {
  10942. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10943. });
  10944. $('input[name^="position"]').on('input', function() {
  10945. const type = $(this).attr('name').replace('position.', '');
  10946. const xLabel = 'rightleft';
  10947. const yLabel = 'topbottpm';
  10948. switch (type) {
  10949. case 'buttonSideX':
  10950. case 'buttonSideY':
  10951. case 'buttonDistance':
  10952. {
  10953. const distance = $('input[name="position.buttonDistance"]').val();
  10954. const sideX = $('input[name="position.buttonSideX"]').val();
  10955. const sideY = $('input[name="position.buttonSideY"]').val();
  10956. if (![ 'right', 'left' ].includes(sideX)) {
  10957. break;
  10958. }
  10959. if (![ 'top', 'bottom' ].includes(sideY)) {
  10960. break;
  10961. }
  10962. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10963. break;
  10964. }
  10965. const distanceArr = distance.split(',');
  10966. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10967. break;
  10968. }
  10969.  
  10970. case 'showButtonSideX':
  10971. case 'showButtonSideY':
  10972. case 'showButtonDistance':
  10973. {
  10974. const distance = $('input[name="position.showButtonDistance"]').val();
  10975. const sideX = $('input[name="position.showButtonSideX"]').val();
  10976. const sideY = $('input[name="position.showButtonSideY"]').val();
  10977. if (![ 'right', 'left' ].includes(sideX)) {
  10978. break;
  10979. }
  10980. if (![ 'top', 'bottom' ].includes(sideY)) {
  10981. break;
  10982. }
  10983. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10984. break;
  10985. }
  10986. const distanceArr = distance.split(',');
  10987. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10988. break;
  10989. }
  10990.  
  10991. case 'logSideX':
  10992. case 'logSideY':
  10993. case 'logDistance':
  10994. {
  10995. const distance = $('input[name="position.logDistance"]').val();
  10996. const sideX = $('input[name="position.logSideX"]').val();
  10997. const sideY = $('input[name="position.logSideY"]').val();
  10998. if (![ 'right', 'left' ].includes(sideX)) {
  10999. break;
  11000. }
  11001. if (![ 'top', 'bottom' ].includes(sideY)) {
  11002. break;
  11003. }
  11004. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  11005. break;
  11006. }
  11007. const distanceArr = distance.split(',');
  11008. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  11009. break;
  11010. }
  11011.  
  11012. default:
  11013. break;
  11014. }
  11015. });
  11016. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  11017. let functionKey = '';
  11018. if (event.altKey) {
  11019. functionKey += 'alt + ';
  11020. } else if (event.ctrlKey) {
  11021. functionKey += 'ctrl + ';
  11022. } else if (event.shiftKey) {
  11023. functionKey += 'shift + ';
  11024. }
  11025. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  11026. });
  11027. } catch (error) {
  11028. throwError(error, 'Setting.after');
  11029. }
  11030. }
  11031. saveGlobalOptions() {
  11032. saveData();
  11033. }
  11034. }
  11035. function Setting_getId2(social) {
  11036. try {
  11037. external_Swal_default().fire({
  11038. title: i18n('getId', i18n(social)),
  11039. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  11040. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  11041. showCancelButton: true,
  11042. cancelButtonText: i18n('close'),
  11043. showConfirmButton: false
  11044. });
  11045. $('#link2id').on('click', async function() {
  11046. const link = $('#socialLink').val();
  11047. if (!link) {
  11048. return;
  11049. }
  11050. const type = $(this).attr('data-type');
  11051. if (type === 'twitterUser') {
  11052. var _link$match;
  11053. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  11054. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  11055. } else if (type === 'youtubeChannel') {
  11056. var _link$match2, _await$getInfo, _await$getInfo$params;
  11057. 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;
  11058. $('#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) || '');
  11059. }
  11060. });
  11061. } catch (error) {
  11062. throwError(error, 'Setting.getId');
  11063. }
  11064. }
  11065. function _environment2() {
  11066. try {
  11067. const userAgent = (0, javascript_utils_umd_min.ua)();
  11068. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  11069. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  11070. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  11071. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  11072. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  11073. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  11074. </tbody></table></form>`;
  11075. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  11076. } catch (error) {
  11077. throwError(error, 'Setting.environment');
  11078. }
  11079. }
  11080. const website_Setting = Setting;
  11081. function History_classPrivateMethodInitSpec(obj, privateSet) {
  11082. History_checkPrivateRedeclaration(obj, privateSet);
  11083. privateSet.add(obj);
  11084. }
  11085. function History_checkPrivateRedeclaration(obj, privateCollection) {
  11086. if (privateCollection.has(obj)) {
  11087. throw new TypeError('Cannot initialize the same private elements twice on an object');
  11088. }
  11089. }
  11090. function History_defineProperty(obj, key, value) {
  11091. if (key in obj) {
  11092. Object.defineProperty(obj, key, {
  11093. value: value,
  11094. enumerable: true,
  11095. configurable: true,
  11096. writable: true
  11097. });
  11098. } else {
  11099. obj[key] = value;
  11100. }
  11101. return obj;
  11102. }
  11103. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  11104. if (!privateSet.has(receiver)) {
  11105. throw new TypeError('attempted to get private field on non-instance');
  11106. }
  11107. return fn;
  11108. }
  11109. var _addItem = new WeakSet();
  11110. class History extends website_Keylol {
  11111. constructor() {
  11112. super(...arguments);
  11113. History_classPrivateMethodInitSpec(this, _addItem);
  11114. History_defineProperty(this, 'name', 'History');
  11115. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  11116. }
  11117. static test() {
  11118. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  11119. }
  11120. before() {
  11121. try {
  11122. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  11123. const data = GM_listValues() || [];
  11124. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  11125. for (const item of tasksHistory) {
  11126. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  11127. }
  11128. } catch (error) {
  11129. throwError(error, 'History.before');
  11130. }
  11131. }
  11132. clearHistory() {
  11133. try {
  11134. const data = GM_listValues() || [];
  11135. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  11136. for (const item of tasksHistory) {
  11137. GM_deleteValue(item);
  11138. }
  11139. external_Swal_default().fire({
  11140. title: i18n('clearHistoryFinished'),
  11141. icon: 'success'
  11142. });
  11143. } catch (error) {
  11144. throwError(error, 'History.after');
  11145. }
  11146. }
  11147. }
  11148. function _addItem2(item) {
  11149. try {
  11150. const tasksData = GM_getValue(item);
  11151. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  11152. return;
  11153. }
  11154. let html = '';
  11155. let title = '';
  11156. let link = '';
  11157. const [ website, id ] = item.split('-');
  11158. switch (website) {
  11159. case 'fawTasks':
  11160. title = `Freeanywhere[${id}]`;
  11161. link = `https://freeanywhere.net/#/giveaway/${id}`;
  11162. break;
  11163.  
  11164. case 'gasTasks':
  11165. title = `Giveawaysu[${id}]`;
  11166. link = `https://giveaway.su/giveaway/view/${id}`;
  11167. break;
  11168.  
  11169. case 'gcTasks':
  11170. title = `GiveeClub[${id}]`;
  11171. link = `https://givee.club/event/${id}`;
  11172. break;
  11173.  
  11174. case 'gkTasks':
  11175. title = `Givekey[${id}]`;
  11176. link = `https://givekey.ru/giveaway/${id}`;
  11177. break;
  11178.  
  11179. case 'gleamTasks':
  11180. title = `Gleam[${id}]`;
  11181. link = `https://gleam.io${id}`;
  11182. break;
  11183.  
  11184. case 'khTasks':
  11185. title = `keyhub[${id}]`;
  11186. link = `https://key-hub.eu/giveaway/${id}`;
  11187. break;
  11188.  
  11189. case 'prysTasks':
  11190. title = `Prys[${id}]`;
  11191. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  11192. break;
  11193.  
  11194. default:
  11195. return;
  11196. }
  11197. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  11198. for (const [ type, tasks ] of Object.entries(types)) {
  11199. for (const task of tasks) {
  11200. 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>`;
  11201. }
  11202. }
  11203. }
  11204. $('.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>`);
  11205. $('span.delete-task').on('click', function() {
  11206. const itemName = $(this).attr('data-name');
  11207. if (itemName) {
  11208. GM_deleteValue(itemName);
  11209. $(`div.card[data-name="${itemName}"]`).remove();
  11210. external_Swal_default().fire({
  11211. title: i18n('clearTaskFinished'),
  11212. text: itemName,
  11213. icon: 'success'
  11214. });
  11215. } else {
  11216. external_Swal_default().fire({
  11217. title: i18n('clearTaskFailed'),
  11218. icon: 'error'
  11219. });
  11220. }
  11221. });
  11222. } catch (error) {
  11223. throwError(error, 'History.addItem');
  11224. }
  11225. }
  11226. const website_History = History;
  11227. 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 ];
  11228. const websiteOptions = function(website, options) {
  11229. try {
  11230. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  11231. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  11232. for (const [ option, value ] of Object.entries(options)) {
  11233. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  11234. }
  11235. websiteOptionsForm += '</tbody></table></form>';
  11236. external_Swal_default().fire({
  11237. title: i18n('websiteOptions'),
  11238. html: websiteOptionsForm,
  11239. showConfirmButton: true,
  11240. confirmButtonText: i18n('save'),
  11241. showCancelButton: true,
  11242. cancelButtonText: i18n('close')
  11243. }).then(_ref => {
  11244. let {
  11245. isConfirmed
  11246. } = _ref;
  11247. if (isConfirmed) {
  11248. $('#websiteOptionsForm').serializeArray().map(value => {
  11249. options[value.name] = value.value;
  11250. return value;
  11251. });
  11252. GM_setValue(`${website}Options`, options);
  11253. external_Swal_default().fire({
  11254. title: i18n('changeWebsiteOptionsSuccess'),
  11255. icon: 'success'
  11256. });
  11257. }
  11258. });
  11259. } catch (error) {
  11260. throwError(error, 'websiteOptions');
  11261. }
  11262. };
  11263. const options = websiteOptions;
  11264. const external_keyboardJS_namespaceObject = keyboardJS;
  11265. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  11266. const checkUpdate = async (updateLink, auto) => {
  11267. try {
  11268. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  11269. const {
  11270. result,
  11271. statusText,
  11272. status,
  11273. data
  11274. } = await tools_httpRequest({
  11275. url: checkUrl,
  11276. responseType: 'json',
  11277. method: 'GET',
  11278. timeout: 3e4
  11279. });
  11280. if (result === 'Success') {
  11281. var _data$response;
  11282. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  11283. return data.response;
  11284. }
  11285. if (!auto) {
  11286. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  11287. }
  11288. return false;
  11289. }
  11290. if (!auto) {
  11291. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  11292. }
  11293. return false;
  11294. } catch (error) {
  11295. throwError(error, 'checkUpdate');
  11296. return false;
  11297. }
  11298. };
  11299. const hasNewVersion = (currentVersion, remoteVersion) => {
  11300. try {
  11301. const [ currentRealVersion ] = currentVersion.split('-');
  11302. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  11303. if (isPreview && !globalOptions.other.receivePreview) {
  11304. return false;
  11305. }
  11306. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  11307. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  11308. if (remoteVersion1 > currentVersion1) {
  11309. return true;
  11310. }
  11311. if (remoteVersion1 < currentVersion1) {
  11312. return false;
  11313. }
  11314. if (remoteVersion2 > currentVersion2) {
  11315. return true;
  11316. }
  11317. if (remoteVersion2 < currentVersion2) {
  11318. return false;
  11319. }
  11320. if (remoteVersion3 > currentVersion3) {
  11321. return true;
  11322. }
  11323. return false;
  11324. } catch (error) {
  11325. throwError(error, 'compareVersion');
  11326. return false;
  11327. }
  11328. };
  11329. const updateChecker = async () => {
  11330. try {
  11331. const currentVersion = GM_info.script.version;
  11332. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  11333. const updateLinks = {
  11334. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  11335. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  11336. standby: 'https://auto-task-v4.hclonely.com/'
  11337. };
  11338. let version;
  11339. let updateLink = '';
  11340. let packageData;
  11341. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  11342. updateLink = updateLinks[updateSource];
  11343. packageData = await checkUpdate(updateLink, false);
  11344. } else {
  11345. updateLink = updateLinks.github;
  11346. packageData = await checkUpdate(updateLink, true);
  11347. if (!packageData) {
  11348. updateLink = updateLinks.jsdelivr;
  11349. packageData = await checkUpdate(updateLink, true);
  11350. if (!packageData) {
  11351. updateLink = updateLinks.standby;
  11352. packageData = await checkUpdate(updateLink, true);
  11353. }
  11354. }
  11355. }
  11356. if (packageData) {
  11357. version = packageData.version || currentVersion;
  11358. } else {
  11359. version = currentVersion;
  11360. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  11361. }
  11362. if (packageData && hasNewVersion(currentVersion, version)) {
  11363. var _packageData$change;
  11364. scripts_echoLog({
  11365. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  11366. });
  11367. scripts_echoLog({
  11368. 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>`
  11369. });
  11370. }
  11371. } catch (error) {
  11372. throwError(error, 'updateChecker');
  11373. }
  11374. };
  11375. const scripts_updateChecker = updateChecker;
  11376. var _globalOptions$other, _globalOptions$other2;
  11377. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  11378. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  11379. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  11380. const loadScript = async () => {
  11381. var _website, _website2, _website3, _website4, _website5, _website6;
  11382. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  11383. const authToken = external_Cookies_namespaceObject.get('auth-token');
  11384. const isLogin = !!external_Cookies_namespaceObject.get('login');
  11385. if (isLogin) {
  11386. var _commonOptions, _commonOptions$header, _commonOptions2, _commonOptions2$heade;
  11387. GM_setValue('twitchAuth', {
  11388. authToken: authToken,
  11389. clientVersion: __twilightBuildID,
  11390. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID'],
  11391. deviceId: (_commonOptions2 = commonOptions) === null || _commonOptions2 === void 0 ? void 0 : (_commonOptions2$heade = _commonOptions2.headers) === null || _commonOptions2$heade === void 0 ? void 0 : _commonOptions2$heade['Device-ID'],
  11392. clientSessionId: window.localStorage.local_storage_app_session_id.replace(/"/g, '')
  11393. });
  11394. window.close();
  11395. external_Swal_default().fire('', i18n('closePageNotice'));
  11396. } else {
  11397. external_Swal_default().fire('', i18n('needLogin'));
  11398. }
  11399. return;
  11400. }
  11401. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  11402. const ct0 = external_Cookies_namespaceObject.get('ct0');
  11403. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  11404. if (isLogin && ct0) {
  11405. GM_setValue('twitterAuth', {
  11406. ct0: ct0
  11407. });
  11408. window.close();
  11409. external_Swal_default().fire('', i18n('closePageNotice'));
  11410. } else {
  11411. external_Swal_default().fire('', i18n('needLogin'));
  11412. }
  11413. return;
  11414. }
  11415. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  11416. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  11417. if (PAPISID) {
  11418. GM_setValue('youtubeAuth', {
  11419. PAPISID: PAPISID
  11420. });
  11421. window.close();
  11422. external_Swal_default().fire('', i18n('closePageNotice'));
  11423. } else {
  11424. external_Swal_default().fire('', i18n('needLogin'));
  11425. }
  11426. return;
  11427. }
  11428. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11429. const betaButton = $('#redesign-beta-optin-btn');
  11430. if (betaButton.length > 0) {
  11431. GM_setValue('redditAuth', '#auth');
  11432. return betaButton[0].click();
  11433. }
  11434. GM_setValue('redditAuth', null);
  11435. window.close();
  11436. external_Swal_default().fire('', i18n('closePageNotice'));
  11437. return;
  11438. }
  11439. let website;
  11440. for (const Website of Websites) {
  11441. if (Website.test()) {
  11442. website = new Website();
  11443. break;
  11444. }
  11445. }
  11446. if (!website) {
  11447. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11448. return;
  11449. }
  11450. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11451. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11452. }
  11453. $('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>`);
  11454. $('div.show-button-div').on('click', () => {
  11455. $('#auto-task-buttons').show();
  11456. $('div.show-button-div').hide();
  11457. });
  11458. const toggleLog = () => {
  11459. const $this = $('#toggle-log');
  11460. const status = $this.attr('data-status');
  11461. if (status === 'show') {
  11462. $('#auto-task-info').hide();
  11463. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11464. } else {
  11465. $('#auto-task-info').show();
  11466. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11467. }
  11468. };
  11469. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11470. if (website.doTask) {
  11471. website.doTask();
  11472. }
  11473. });
  11474. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11475. if (website.undoTask) {
  11476. website.doTask();
  11477. }
  11478. });
  11479. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11480. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11481. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11482. }
  11483. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11484. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11485. for (const button of website.buttons) {
  11486. if (website[button]) {
  11487. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11488. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11489. website[button]();
  11490. });
  11491. $('#auto-task-buttons').append(btnElement);
  11492. }
  11493. }
  11494. }
  11495. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11496. ${i18n('hideButton')}</a></p>`);
  11497. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11498. $('#auto-task-buttons').hide();
  11499. $('div.show-button-div').show();
  11500. });
  11501. 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'}">
  11502. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11503. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11504. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11505. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11506. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11507. options(website.name, website.options);
  11508. });
  11509. }
  11510. if (website.name !== 'Setting') {
  11511. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11512. changeGlobalOptions('swal');
  11513. });
  11514. GM_registerMenuCommand(i18n('settingPage'), () => {
  11515. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11516. });
  11517. }
  11518. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11519. if (!GM_getValue('notice')) {
  11520. var _echoLog$font;
  11521. external_Swal_default().fire({
  11522. title: i18n('swalNotice'),
  11523. icon: 'warning'
  11524. }).then(() => {
  11525. window.open(i18n('noticeLink'), '_blank');
  11526. GM_setValue('notice', new Date().getTime());
  11527. });
  11528. (_echoLog$font = scripts_echoLog({
  11529. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11530. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11531. GM_setValue('notice', new Date().getTime());
  11532. });
  11533. }
  11534. scripts_updateChecker();
  11535. };
  11536. if (window.location.hostname === 'discord.com') {
  11537. const LocalStorage = window.localStorage;
  11538. if (window.location.hash === '#auth') {
  11539. var _LocalStorage$getItem;
  11540. window.localStorage.removeItem = () => true;
  11541. 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, '');
  11542. if (discordAuth && discordAuth.length > 0) {
  11543. GM_setValue('discordAuth', {
  11544. auth: discordAuth
  11545. });
  11546. window.close();
  11547. external_Swal_default().fire('', i18n('closePageNotice'));
  11548. } else {
  11549. external_Swal_default().fire({
  11550. text: i18n('getDiscordAuthFailed'),
  11551. icon: 'error'
  11552. });
  11553. }
  11554. } else {
  11555. var _LocalStorage$getItem2;
  11556. 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, '');
  11557. if (discordAuth && discordAuth.length > 0) {
  11558. GM_setValue('discordAuth', {
  11559. auth: discordAuth
  11560. });
  11561. }
  11562. }
  11563. } else if (window.location.hostname === 'opquests.com') {
  11564. loadScript();
  11565. } else {
  11566. if (window.location.hostname === 'key-hub.eu') {
  11567. unsafeWindow.keyhubtracker = 1;
  11568. unsafeWindow.gaData = {};
  11569. }
  11570. $(loadScript);
  11571. }
  11572. }();
  11573. })();