auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.23
  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. };
  7376. var _checkLogin = new WeakSet();
  7377. var GiveawaySu_checkLeftKey = new WeakSet();
  7378. var GiveawaySu_getGiveawayId = new WeakSet();
  7379. class GiveawaySu extends website_Website {
  7380. constructor() {
  7381. super(...arguments);
  7382. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7383. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_checkLeftKey);
  7384. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7385. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7386. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7387. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7388. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7389. }
  7390. static test() {
  7391. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7392. }
  7393. async after() {
  7394. try {
  7395. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7396. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7397. }
  7398. if (!await GiveawaySu_classPrivateMethodGet(this, GiveawaySu_checkLeftKey, GiveawaySu_checkLeftKey2).call(this)) {
  7399. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7400. }
  7401. scripts_echoLog({}).warning(i18n('gsNotice'));
  7402. } catch (error) {
  7403. throwError(error, 'Giveawaysu.after');
  7404. }
  7405. }
  7406. init() {
  7407. try {
  7408. const logStatus = scripts_echoLog({
  7409. text: i18n('initing')
  7410. });
  7411. if ($('a.steam-login').length > 0) {
  7412. window.open('/steam/redirect', '_self');
  7413. logStatus.warning(i18n('needLogin'));
  7414. return false;
  7415. }
  7416. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7417. return false;
  7418. }
  7419. this.initialized = true;
  7420. logStatus.success();
  7421. return true;
  7422. } catch (error) {
  7423. throwError(error, 'Giveawaysu.init');
  7424. return false;
  7425. }
  7426. }
  7427. async classifyTask(action) {
  7428. try {
  7429. const logStatus = scripts_echoLog({
  7430. text: i18n('getTasksInfo')
  7431. });
  7432. if (action === 'undo') {
  7433. var _GM_getValue;
  7434. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7435. return true;
  7436. }
  7437. const pro = [];
  7438. const tasks = $('#actions tr');
  7439. if ($('div.bind-discord').is(':visible')) {
  7440. $('div.bind-discord a')[0].click();
  7441. }
  7442. if ($('div.bind-twitch').is(':visible')) {
  7443. $('div.bind-twitch a')[0].click();
  7444. }
  7445. for (const task of tasks) {
  7446. pro.push(new Promise(resolve => {
  7447. const td = $(task).find('td:not(".hidden")');
  7448. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7449. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7450. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7451. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7452. const taskName = taskDes.text().trim();
  7453. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7454. return resolve(true);
  7455. }
  7456. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7457. if (!taskLink) {
  7458. return resolve(false);
  7459. }
  7460. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7461. this.undoneTasks.steam.groupLinks.push(taskLink);
  7462. } else if (/like.*announcement/gi.test(taskName)) {
  7463. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7464. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7465. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7466. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7467. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7468. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7469. this.undoneTasks.steam.forumLinks.push(taskLink);
  7470. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7471. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7472. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7473. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7474. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7475. this.undoneTasks.discord.serverLinks.push(taskLink);
  7476. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7477. this.undoneTasks.instagram.userLinks.push(taskLink);
  7478. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7479. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7480. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7481. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7482. } else if (/watch.*art/gim.test(taskName)) {
  7483. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7484. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7485. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7486. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7487. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7488. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7489. this.undoneTasks.vk.nameLinks.push(taskLink);
  7490. } else {
  7491. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7492. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7493. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7494. }
  7495. if (/follow.*button/gim.test(taskName)) {
  7496. this.undoneTasks.steam.followLinks.push(taskLink);
  7497. }
  7498. }
  7499. }
  7500. resolve(true);
  7501. }).catch(error => {
  7502. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7503. return false;
  7504. });
  7505. }));
  7506. }
  7507. await Promise.all(pro);
  7508. logStatus.success();
  7509. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7510. this.socialTasks = this.undoneTasks;
  7511. if (window.DEBUG) {
  7512. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7513. }
  7514. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7515. tasks: this.socialTasks,
  7516. time: new Date().getTime()
  7517. });
  7518. return true;
  7519. } catch (error) {
  7520. throwError(error, 'Giveawaysu.classifyTask');
  7521. return false;
  7522. }
  7523. }
  7524. }
  7525. function _checkLogin2() {
  7526. try {
  7527. if (!globalOptions.other.checkLogin) {
  7528. return true;
  7529. }
  7530. if ($('a.steam-login').length > 0) {
  7531. window.open('/steam/redirect', '_self');
  7532. }
  7533. return true;
  7534. } catch (error) {
  7535. throwError(error, 'Giveawaysu.checkLogin');
  7536. return false;
  7537. }
  7538. }
  7539. async function GiveawaySu_checkLeftKey2() {
  7540. try {
  7541. if (!globalOptions.other.checkLeftKey) {
  7542. return true;
  7543. }
  7544. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7545. await external_Swal_default().fire({
  7546. icon: 'warning',
  7547. title: i18n('notice'),
  7548. text: i18n('noKeysLeft'),
  7549. confirmButtonText: i18n('confirm'),
  7550. cancelButtonText: i18n('cancel'),
  7551. showCancelButton: true
  7552. }).then(_ref => {
  7553. let {
  7554. value
  7555. } = _ref;
  7556. if (value) {
  7557. window.close();
  7558. }
  7559. });
  7560. }
  7561. return true;
  7562. } catch (error) {
  7563. throwError(error, 'Giveawaysu.checkLeftKey');
  7564. return false;
  7565. }
  7566. }
  7567. function GiveawaySu_getGiveawayId2() {
  7568. var _window$location$href;
  7569. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7570. if (giveawayId) {
  7571. this.giveawayId = giveawayId;
  7572. return true;
  7573. }
  7574. scripts_echoLog({
  7575. text: i18n('getFailed', 'GiveawayId')
  7576. });
  7577. return false;
  7578. }
  7579. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7580. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7581. privateSet.add(obj);
  7582. }
  7583. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7584. if (privateCollection.has(obj)) {
  7585. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7586. }
  7587. }
  7588. function Indiedb_defineProperty(obj, key, value) {
  7589. if (key in obj) {
  7590. Object.defineProperty(obj, key, {
  7591. value: value,
  7592. enumerable: true,
  7593. configurable: true,
  7594. writable: true
  7595. });
  7596. } else {
  7597. obj[key] = value;
  7598. }
  7599. return obj;
  7600. }
  7601. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7602. if (!privateSet.has(receiver)) {
  7603. throw new TypeError('attempted to get private field on non-instance');
  7604. }
  7605. return fn;
  7606. }
  7607. var _join = new WeakSet();
  7608. var _do = new WeakSet();
  7609. var Indiedb_checkLogin = new WeakSet();
  7610. var Indiedb_checkLeftKey = new WeakSet();
  7611. class Indiedb {
  7612. constructor() {
  7613. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7614. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7615. Indiedb_classPrivateMethodInitSpec(this, _do);
  7616. Indiedb_classPrivateMethodInitSpec(this, _join);
  7617. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7618. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7619. }
  7620. static test() {
  7621. return window.location.host === 'www.indiedb.com';
  7622. }
  7623. async after() {
  7624. try {
  7625. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7626. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7627. }
  7628. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7629. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7630. }
  7631. } catch (error) {
  7632. throwError(error, 'Indiedb.after');
  7633. }
  7634. }
  7635. async doTask() {
  7636. try {
  7637. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7638. return false;
  7639. }
  7640. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7641. } catch (error) {
  7642. throwError(error, 'Indiedb.doTask');
  7643. return false;
  7644. }
  7645. }
  7646. }
  7647. async function _join2() {
  7648. try {
  7649. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7650. scripts_echoLog({}).error(i18n('needLogin'));
  7651. return false;
  7652. }
  7653. const currentoption = $('a.buttonenter.buttongiveaway');
  7654. if (/join giveaway/gim.test(currentoption.text())) {
  7655. const logStatus = scripts_echoLog({
  7656. text: `${i18n('joiningGiveaway')}...`
  7657. });
  7658. const {
  7659. result,
  7660. statusText,
  7661. status,
  7662. data
  7663. } = await tools_httpRequest({
  7664. url: currentoption.attr('href'),
  7665. method: 'POST',
  7666. data: 'ajax=t',
  7667. dataType: 'json',
  7668. headers: {
  7669. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7670. accept: 'application/json, text/javascript, */*; q=0.01',
  7671. origin: window.location.origin
  7672. }
  7673. });
  7674. if (result === 'Success') {
  7675. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7676. var _data$response, _data$response4, _data$response5;
  7677. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7678. var _data$response2, _data$response3;
  7679. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7680. $('#giveawaysjoined').slideDown();
  7681. $('#giveawaysrecommend').slideDown();
  7682. 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}` : ''}`);
  7683. return true;
  7684. }
  7685. 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}` : ''}`);
  7686. return false;
  7687. }
  7688. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7689. return false;
  7690. }
  7691. logStatus.error(`${result}:${statusText}(${status})`);
  7692. return false;
  7693. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7694. return true;
  7695. }
  7696. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7697. return false;
  7698. } catch (error) {
  7699. throwError(error, 'Indiedb.init');
  7700. return false;
  7701. }
  7702. }
  7703. async function _do2() {
  7704. try {
  7705. const id = $('script').map((index, script) => {
  7706. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7707. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7708. 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] ];
  7709. }
  7710. return null;
  7711. });
  7712. if (id.length === 2) {
  7713. const pro = [];
  7714. const tasks = $('#giveawaysjoined a[class*=promo]');
  7715. for (const task of tasks) {
  7716. const promo = $(task);
  7717. if (!promo.hasClass('buttonentered')) {
  7718. const status = scripts_echoLog({
  7719. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7720. });
  7721. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7722. let text = '';
  7723. if (promo.hasClass('facebookpromo')) {
  7724. text = 'facebookpromo';
  7725. } else if (promo.hasClass('twitterpromo')) {
  7726. text = 'twitterpromo';
  7727. } else {
  7728. text = 'visitpromo';
  7729. }
  7730. pro.push(new Promise(resolve => {
  7731. $.ajax({
  7732. type: 'POST',
  7733. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7734. timeout: 6e4,
  7735. dataType: 'json',
  7736. data: {
  7737. ajax: 't'
  7738. },
  7739. error(response, error, exception) {
  7740. if (window.DEBUG) {
  7741. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7742. response: response,
  7743. error: error,
  7744. exception: exception
  7745. });
  7746. }
  7747. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7748. resolve(true);
  7749. },
  7750. success(response) {
  7751. if (response.success) {
  7752. status.success(`Success:${response.text}`);
  7753. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7754. resolve(true);
  7755. } else {
  7756. status.error(`Error:${response.text}`);
  7757. resolve(true);
  7758. }
  7759. }
  7760. });
  7761. }));
  7762. } else if (promo.hasClass('emailoptinpromo')) {
  7763. pro.push(new Promise(resolve => {
  7764. $.ajax({
  7765. type: 'POST',
  7766. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7767. timeout: 6e4,
  7768. dataType: 'json',
  7769. data: {
  7770. ajax: 't',
  7771. emailsystoggle: 4
  7772. },
  7773. error(response, error, exception) {
  7774. if (window.DEBUG) {
  7775. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7776. response: response,
  7777. error: error,
  7778. exception: exception
  7779. });
  7780. }
  7781. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7782. resolve(true);
  7783. },
  7784. success(response) {
  7785. if (response.success) {
  7786. status.success(`Success:${response.text}`);
  7787. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7788. resolve(true);
  7789. } else {
  7790. status.error(`Error:${response.text}`);
  7791. resolve(true);
  7792. }
  7793. }
  7794. });
  7795. }));
  7796. } else if (promo.hasClass('watchingpromo')) {
  7797. pro.push(new Promise(resolve => {
  7798. var _promo$attr;
  7799. const data = getUrlQuery(promo.attr('href'));
  7800. data.ajax = 't';
  7801. $.ajax({
  7802. type: 'POST',
  7803. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7804. timeout: 6e4,
  7805. dataType: 'json',
  7806. data: data,
  7807. error(response, error, exception) {
  7808. if (window.DEBUG) {
  7809. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7810. response: response,
  7811. error: error,
  7812. exception: exception
  7813. });
  7814. }
  7815. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7816. resolve(true);
  7817. },
  7818. success(response) {
  7819. if (response.success) {
  7820. status.success(`Success:${response.text}`);
  7821. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7822. resolve(true);
  7823. } else {
  7824. status.error(`Error:${response.text}`);
  7825. resolve(true);
  7826. }
  7827. }
  7828. });
  7829. }));
  7830. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7831. pro.push(new Promise(resolve => {
  7832. $.ajax({
  7833. type: 'POST',
  7834. url: urlPath(promo.attr('href')),
  7835. timeout: 6e4,
  7836. dataType: 'json',
  7837. data: {
  7838. ajax: 't'
  7839. },
  7840. error(response, error, exception) {
  7841. if (window.DEBUG) {
  7842. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7843. response: response,
  7844. error: error,
  7845. exception: exception
  7846. });
  7847. }
  7848. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7849. resolve(true);
  7850. },
  7851. success(response) {
  7852. if (response.success) {
  7853. status.success(`Success:${response.text}`);
  7854. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7855. resolve(true);
  7856. } else {
  7857. status.error(`Error:${response.text}`);
  7858. resolve(true);
  7859. }
  7860. }
  7861. });
  7862. }));
  7863. } else {
  7864. status.error(`Error:${i18n('unKnownTaskType')}`);
  7865. }
  7866. }
  7867. }
  7868. await Promise.all(pro);
  7869. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7870. return true;
  7871. }
  7872. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7873. return false;
  7874. } catch (error) {
  7875. throwError(error, 'Indiedb.classifyTask');
  7876. return false;
  7877. }
  7878. }
  7879. function Indiedb_checkLogin2() {
  7880. try {
  7881. if (!globalOptions.other.checkLogin) {
  7882. return true;
  7883. }
  7884. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7885. window.open('/members/login', '_self');
  7886. }
  7887. return true;
  7888. } catch (error) {
  7889. throwError(error, 'Indiedb.checkLogin');
  7890. return false;
  7891. }
  7892. }
  7893. async function Indiedb_checkLeftKey2() {
  7894. try {
  7895. if (!globalOptions.other.checkLeftKey) {
  7896. return true;
  7897. }
  7898. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7899. await external_Swal_default().fire({
  7900. icon: 'warning',
  7901. title: i18n('notice'),
  7902. text: i18n('giveawayEnded'),
  7903. confirmButtonText: i18n('confirm'),
  7904. cancelButtonText: i18n('cancel'),
  7905. showCancelButton: true
  7906. }).then(_ref => {
  7907. let {
  7908. value
  7909. } = _ref;
  7910. if (value) {
  7911. window.close();
  7912. }
  7913. });
  7914. }
  7915. return true;
  7916. } catch (error) {
  7917. throwError(error, 'Indiedb.checkLeftKey');
  7918. return false;
  7919. }
  7920. }
  7921. const website_Indiedb = Indiedb;
  7922. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7923. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7924. privateSet.add(obj);
  7925. }
  7926. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7927. if (privateCollection.has(obj)) {
  7928. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7929. }
  7930. }
  7931. function Keyhub_defineProperty(obj, key, value) {
  7932. if (key in obj) {
  7933. Object.defineProperty(obj, key, {
  7934. value: value,
  7935. enumerable: true,
  7936. configurable: true,
  7937. writable: true
  7938. });
  7939. } else {
  7940. obj[key] = value;
  7941. }
  7942. return obj;
  7943. }
  7944. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7945. if (!privateSet.has(receiver)) {
  7946. throw new TypeError('attempted to get private field on non-instance');
  7947. }
  7948. return fn;
  7949. }
  7950. const Keyhub_defaultTasksTemplate = {
  7951. steam: {
  7952. groupLinks: [],
  7953. officialGroupLinks: [],
  7954. wishlistLinks: [],
  7955. curatorLinks: []
  7956. },
  7957. discord: {
  7958. serverLinks: []
  7959. },
  7960. extra: {
  7961. videoTasks: []
  7962. },
  7963. links: []
  7964. };
  7965. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7966. var _doScriptTask = new WeakSet();
  7967. var Keyhub_getGiveawayId = new WeakSet();
  7968. var Keyhub_checkLeftKey = new WeakSet();
  7969. var Keyhub_checkLogin = new WeakSet();
  7970. class Keyhub extends website_Website {
  7971. constructor() {
  7972. super(...arguments);
  7973. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7974. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7975. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7976. Keyhub_classPrivateMethodInitSpec(this, _doScriptTask);
  7977. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7978. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7979. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7980. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7981. }
  7982. static test() {
  7983. return window.location.host === 'key-hub.eu';
  7984. }
  7985. async after() {
  7986. try {
  7987. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7988. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7989. }
  7990. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7991. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7992. }
  7993. $('.NSFW').hide();
  7994. } catch (error) {
  7995. throwError(error, 'Keyhub.after');
  7996. }
  7997. }
  7998. init() {
  7999. try {
  8000. const logStatus = scripts_echoLog({
  8001. text: i18n('initing')
  8002. });
  8003. if ($('a[href*="/connect/steam"]').length > 0) {
  8004. window.open('/connect/steam', '_self');
  8005. logStatus.warning(i18n('needLogin'));
  8006. return false;
  8007. }
  8008. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  8009. return false;
  8010. }
  8011. $('#VPNoverlay').hide();
  8012. $('#mainArticleSection').show();
  8013. this.initialized = true;
  8014. logStatus.success();
  8015. return true;
  8016. } catch (error) {
  8017. throwError(error, 'Keyhub.init');
  8018. return false;
  8019. }
  8020. }
  8021. async classifyTask(action) {
  8022. try {
  8023. const logStatus = scripts_echoLog({
  8024. text: i18n('getTasksInfo')
  8025. });
  8026. if (action === 'undo') {
  8027. var _GM_getValue;
  8028. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  8029. }
  8030. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  8031. for (const task of tasks) {
  8032. let link = $(task).attr('href');
  8033. const taskDes = $(task).text().trim();
  8034. if (!link) {
  8035. continue;
  8036. }
  8037. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  8038. link = await getRedirectLink(link) || link;
  8039. }
  8040. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  8041. window.open(link, '_blank');
  8042. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  8043. if (action === 'undo') {
  8044. this.socialTasks.steam.groupLinks.push(link);
  8045. }
  8046. if (action === 'do') {
  8047. this.undoneTasks.steam.groupLinks.push(link);
  8048. }
  8049. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  8050. if (action === 'undo') {
  8051. this.socialTasks.steam.officialGroupLinks.push(link);
  8052. }
  8053. if (action === 'do') {
  8054. this.undoneTasks.steam.officialGroupLinks.push(link);
  8055. }
  8056. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  8057. if (action === 'undo') {
  8058. this.socialTasks.steam.wishlistLinks.push(link);
  8059. }
  8060. if (action === 'do') {
  8061. this.undoneTasks.steam.wishlistLinks.push(link);
  8062. }
  8063. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  8064. if (action === 'undo') {
  8065. this.socialTasks.steam.curatorLinks.push(link);
  8066. }
  8067. if (action === 'do') {
  8068. this.undoneTasks.steam.curatorLinks.push(link);
  8069. }
  8070. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  8071. if (action === 'undo') {
  8072. this.socialTasks.discord.serverLinks.push(link);
  8073. }
  8074. if (action === 'do') {
  8075. this.undoneTasks.discord.serverLinks.push(link);
  8076. }
  8077. } else if (/^javascript:videoTask.+/.test(link)) {
  8078. if (action === 'do') {
  8079. var _link$match;
  8080. const taskData = (_link$match = link.match(/javascript:videoTask\('.+?','(.+?)'/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  8081. if (taskData) {
  8082. this.undoneTasks.extra.videoTasks.push(taskData);
  8083. }
  8084. }
  8085. } 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 {
  8086. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8087. }
  8088. }
  8089. logStatus.success();
  8090. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8091. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8092. if (window.DEBUG) {
  8093. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8094. }
  8095. GM_setValue(`khTasks-${this.giveawayId}`, {
  8096. tasks: this.socialTasks,
  8097. time: new Date().getTime()
  8098. });
  8099. return true;
  8100. } catch (error) {
  8101. throwError(error, 'Keyhub.classifyTask');
  8102. return false;
  8103. }
  8104. }
  8105. async extraDoTask(_ref) {
  8106. let {
  8107. videoTasks
  8108. } = _ref;
  8109. try {
  8110. const pro = [];
  8111. for (const data of videoTasks) {
  8112. pro.push(Keyhub_classPrivateMethodGet(this, _doScriptTask, _doScriptTask2).call(this, data));
  8113. }
  8114. return Promise.all(pro).then(() => true);
  8115. } catch (error) {
  8116. throwError(error, 'Keyhub.extraDoTask');
  8117. return false;
  8118. }
  8119. }
  8120. }
  8121. async function _doScriptTask2(data) {
  8122. try {
  8123. const logStatus = scripts_echoLog({
  8124. text: i18n('doingKeyhubTask')
  8125. });
  8126. const {
  8127. result,
  8128. statusText,
  8129. status,
  8130. data: response
  8131. } = await tools_httpRequest({
  8132. url: `/away?data=${data}`,
  8133. method: 'GET',
  8134. headers: {
  8135. origin: 'https://key-hub.eu',
  8136. referer: 'https://key-hub.eu/'
  8137. }
  8138. });
  8139. if (result === 'Success') {
  8140. if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
  8141. logStatus.success();
  8142. return true;
  8143. }
  8144. logStatus.error(`Error:${response === null || response === void 0 ? void 0 : response.statusText}(${response === null || response === void 0 ? void 0 : response.status})`);
  8145. return false;
  8146. }
  8147. logStatus.error(`${result}:${statusText}(${status})`);
  8148. return false;
  8149. } catch (error) {
  8150. throwError(error, 'Keyhub.doScriptTask');
  8151. return false;
  8152. }
  8153. }
  8154. function Keyhub_getGiveawayId2() {
  8155. try {
  8156. var _window$location$href;
  8157. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8158. if (giveawayId) {
  8159. this.giveawayId = giveawayId;
  8160. return true;
  8161. }
  8162. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8163. return false;
  8164. } catch (error) {
  8165. throwError(error, 'Keyhub.getGiveawayId');
  8166. return false;
  8167. }
  8168. }
  8169. async function Keyhub_checkLeftKey2() {
  8170. try {
  8171. if (!globalOptions.other.checkLeftKey) {
  8172. return true;
  8173. }
  8174. const leftKey = $('#keysleft').text().trim();
  8175. if (leftKey === '0') {
  8176. await external_Swal_default().fire({
  8177. icon: 'warning',
  8178. title: i18n('notice'),
  8179. text: i18n('noKeysLeft'),
  8180. confirmButtonText: i18n('confirm'),
  8181. cancelButtonText: i18n('cancel'),
  8182. showCancelButton: true
  8183. }).then(_ref2 => {
  8184. let {
  8185. value
  8186. } = _ref2;
  8187. if (value) {
  8188. window.close();
  8189. }
  8190. });
  8191. }
  8192. return true;
  8193. } catch (error) {
  8194. throwError(error, 'Keyhub.checkLeftKey');
  8195. return false;
  8196. }
  8197. }
  8198. function Keyhub_checkLogin2() {
  8199. try {
  8200. if (!globalOptions.other.checkLogin) {
  8201. return true;
  8202. }
  8203. if ($('a[href*="/connect/steam"]').length > 0) {
  8204. window.open('/connect/steam', '_self');
  8205. }
  8206. return true;
  8207. } catch (error) {
  8208. throwError(error, 'Keyhub.checkLogin');
  8209. return false;
  8210. }
  8211. }
  8212. const website_Keyhub = Keyhub;
  8213. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  8214. Givekey_checkPrivateRedeclaration(obj, privateSet);
  8215. privateSet.add(obj);
  8216. }
  8217. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  8218. if (privateCollection.has(obj)) {
  8219. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8220. }
  8221. }
  8222. function Givekey_defineProperty(obj, key, value) {
  8223. if (key in obj) {
  8224. Object.defineProperty(obj, key, {
  8225. value: value,
  8226. enumerable: true,
  8227. configurable: true,
  8228. writable: true
  8229. });
  8230. } else {
  8231. obj[key] = value;
  8232. }
  8233. return obj;
  8234. }
  8235. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  8236. if (!privateSet.has(receiver)) {
  8237. throw new TypeError('attempted to get private field on non-instance');
  8238. }
  8239. return fn;
  8240. }
  8241. const Givekey_defaultTasksTemplate = {
  8242. steam: {
  8243. groupLinks: [],
  8244. wishlistLinks: [],
  8245. curatorLinks: [],
  8246. curatorLikeLinks: []
  8247. },
  8248. twitter: {
  8249. userLinks: []
  8250. },
  8251. vk: {
  8252. nameLinks: []
  8253. },
  8254. discord: {
  8255. serverLinks: []
  8256. }
  8257. };
  8258. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  8259. var Givekey_verify = new WeakSet();
  8260. var Givekey_getGiveawayId = new WeakSet();
  8261. var Givekey_checkLeftKey = new WeakSet();
  8262. class Givekey extends website_Website {
  8263. constructor() {
  8264. super(...arguments);
  8265. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  8266. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  8267. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  8268. Givekey_defineProperty(this, 'name', 'Givekey');
  8269. Givekey_defineProperty(this, 'tasks', []);
  8270. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  8271. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  8272. Givekey_defineProperty(this, 'userId', void 0);
  8273. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8274. }
  8275. static test() {
  8276. return window.location.host === 'givekey.ru';
  8277. }
  8278. async after() {
  8279. try {
  8280. await new Promise(resolve => {
  8281. const checker = setInterval(() => {
  8282. if ($('#navbarDropdown').length > 0) {
  8283. clearInterval(checker);
  8284. resolve(true);
  8285. }
  8286. });
  8287. });
  8288. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8289. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8290. }
  8291. } catch (error) {
  8292. throwError(error, 'Givekey.after');
  8293. return false;
  8294. }
  8295. }
  8296. init() {
  8297. try {
  8298. const logStatus = scripts_echoLog({
  8299. text: i18n('initing')
  8300. });
  8301. if ($('a[href*="/auth/steam"]').length > 0) {
  8302. window.open('/auth/steam', '_self');
  8303. logStatus.warning(i18n('needLogin'));
  8304. return false;
  8305. }
  8306. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8307. return false;
  8308. }
  8309. const userId = $('meta[name="user-id"]').attr('content');
  8310. if (!userId) {
  8311. logStatus.error(i18n('getFailed', i18n('userId')));
  8312. return false;
  8313. }
  8314. this.userId = userId;
  8315. this.initialized = true;
  8316. logStatus.success();
  8317. return true;
  8318. } catch (error) {
  8319. throwError(error, 'Givekey.init');
  8320. return false;
  8321. }
  8322. }
  8323. async classifyTask(action) {
  8324. try {
  8325. const logStatus = scripts_echoLog({
  8326. text: i18n('getTasksInfo')
  8327. });
  8328. if (action === 'undo') {
  8329. var _GM_getValue;
  8330. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8331. }
  8332. const tasks = $('.card-body:has("button") .row');
  8333. for (const task of tasks) {
  8334. const taskEle = $(task);
  8335. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8336. if (isSuccess && action !== 'undo') {
  8337. continue;
  8338. }
  8339. const checkButton = taskEle.find('#task_check');
  8340. const taskId = checkButton.attr('data-id');
  8341. if (taskId) {
  8342. this.tasks.push(taskId);
  8343. }
  8344. if (action === 'verify') {
  8345. continue;
  8346. }
  8347. let href = taskEle.find('a').attr('href') || null;
  8348. const text = taskEle.find('a').text().trim();
  8349. const icon = taskEle.find('i');
  8350. if (!href || !text) {
  8351. continue;
  8352. }
  8353. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8354. href = await getRedirectLink(href);
  8355. }
  8356. if (!href) {
  8357. continue;
  8358. }
  8359. if (/^https?:\/\/vk\.com\//.test(href)) {
  8360. this.socialTasks.vk.nameLinks.push(href);
  8361. if (action === 'do' && !isSuccess) {
  8362. this.undoneTasks.vk.nameLinks.push(href);
  8363. }
  8364. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8365. this.socialTasks.steam.groupLinks.push(href);
  8366. if (action === 'do' && !isSuccess) {
  8367. this.undoneTasks.steam.groupLinks.push(href);
  8368. }
  8369. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8370. this.socialTasks.steam.wishlistLinks.push(href);
  8371. if (action === 'do' && !isSuccess) {
  8372. this.undoneTasks.steam.wishlistLinks.push(href);
  8373. }
  8374. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8375. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8376. this.socialTasks.steam.curatorLinks.push(href);
  8377. if (action === 'do' && !isSuccess) {
  8378. this.undoneTasks.steam.curatorLinks.push(href);
  8379. }
  8380. } else {
  8381. this.socialTasks.steam.curatorLikeLinks.push(href);
  8382. if (action === 'do' && !isSuccess) {
  8383. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8384. }
  8385. }
  8386. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8387. this.socialTasks.twitter.userLinks.push(href);
  8388. if (action === 'do' && !isSuccess) {
  8389. this.undoneTasks.twitter.userLinks.push(href);
  8390. }
  8391. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8392. this.socialTasks.discord.serverLinks.push(href);
  8393. if (action === 'do' && !isSuccess) {
  8394. this.undoneTasks.discord.serverLinks.push(href);
  8395. }
  8396. } else {
  8397. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8398. }
  8399. }
  8400. logStatus.success();
  8401. this.tasks = unique(this.tasks);
  8402. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8403. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8404. if (window.DEBUG) {
  8405. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8406. }
  8407. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8408. tasks: this.socialTasks,
  8409. time: new Date().getTime()
  8410. });
  8411. return true;
  8412. } catch (error) {
  8413. throwError(error, 'Givekey.classifyTask');
  8414. return false;
  8415. }
  8416. }
  8417. async verifyTask() {
  8418. try {
  8419. if (!this.initialized && !this.init()) {
  8420. return false;
  8421. }
  8422. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8423. return false;
  8424. }
  8425. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8426. const taskLength = this.tasks.length;
  8427. for (let i = 0; i < taskLength; i++) {
  8428. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8429. if (i < taskLength - 1) {
  8430. await delay(15e3);
  8431. }
  8432. }
  8433. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8434. scripts_echoLog({
  8435. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8436. });
  8437. return true;
  8438. } catch (error) {
  8439. throwError(error, 'Givekey.verifyTask');
  8440. return false;
  8441. }
  8442. }
  8443. }
  8444. async function Givekey_verify2(task) {
  8445. try {
  8446. const logStatus = scripts_echoLog({
  8447. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8448. });
  8449. return await new Promise(resolve => {
  8450. $.ajax({
  8451. url: 'https://givekey.ru/giveaway/task',
  8452. method: 'POST',
  8453. data: `id=${task}&user_id=${this.userId}`,
  8454. dataType: 'json',
  8455. headers: {
  8456. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8457. },
  8458. success: data => {
  8459. if (data.btn) {
  8460. $(`button[data-id=${this.userId}]`).html(data.btn);
  8461. }
  8462. if (data.status === 'ok') {
  8463. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8464. logStatus.success();
  8465. resolve(true);
  8466. } else if (data.status === 'end') {
  8467. logStatus.success();
  8468. scripts_echoLog({}).success(data.key);
  8469. resolve(true);
  8470. } else {
  8471. logStatus.error(`Error:${data.msg}`);
  8472. resolve(false);
  8473. }
  8474. },
  8475. error: xhr => {
  8476. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8477. resolve(false);
  8478. }
  8479. });
  8480. });
  8481. } catch (error) {
  8482. throwError(error, 'Givekey.verify');
  8483. return false;
  8484. }
  8485. }
  8486. function Givekey_getGiveawayId2() {
  8487. try {
  8488. var _window$location$href;
  8489. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8490. if (giveawayId) {
  8491. this.giveawayId = giveawayId;
  8492. return true;
  8493. }
  8494. scripts_echoLog({
  8495. text: i18n('getFailed', 'GiveawayId')
  8496. });
  8497. return false;
  8498. } catch (error) {
  8499. throwError(error, 'Givekey.getGiveawayId');
  8500. return false;
  8501. }
  8502. }
  8503. async function Givekey_checkLeftKey2() {
  8504. try {
  8505. if (!globalOptions.other.checkLeftKey) {
  8506. return true;
  8507. }
  8508. if (!$('#keys_count').text()) {
  8509. await external_Swal_default().fire({
  8510. icon: 'warning',
  8511. title: i18n('notice'),
  8512. text: i18n('noKeysLeft'),
  8513. confirmButtonText: i18n('confirm'),
  8514. cancelButtonText: i18n('cancel'),
  8515. showCancelButton: true
  8516. }).then(_ref => {
  8517. let {
  8518. value
  8519. } = _ref;
  8520. if (value) {
  8521. window.close();
  8522. }
  8523. });
  8524. }
  8525. return true;
  8526. } catch (error) {
  8527. throwError(error, 'Givekey.checkLeftKey');
  8528. return false;
  8529. }
  8530. }
  8531. const website_Givekey = Givekey;
  8532. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8533. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8534. privateSet.add(obj);
  8535. }
  8536. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8537. if (privateCollection.has(obj)) {
  8538. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8539. }
  8540. }
  8541. function GiveeClub_defineProperty(obj, key, value) {
  8542. if (key in obj) {
  8543. Object.defineProperty(obj, key, {
  8544. value: value,
  8545. enumerable: true,
  8546. configurable: true,
  8547. writable: true
  8548. });
  8549. } else {
  8550. obj[key] = value;
  8551. }
  8552. return obj;
  8553. }
  8554. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8555. if (!privateSet.has(receiver)) {
  8556. throw new TypeError('attempted to get private field on non-instance');
  8557. }
  8558. return fn;
  8559. }
  8560. var GiveeClub_checkLogin = new WeakSet();
  8561. var GiveeClub_getGiveawayId = new WeakSet();
  8562. var GiveeClub_checkLeftKey = new WeakSet();
  8563. class GiveeClub extends GiveawaySu {
  8564. constructor() {
  8565. super(...arguments);
  8566. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8567. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8568. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8569. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8570. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8571. }
  8572. static test() {
  8573. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8574. }
  8575. async after() {
  8576. try {
  8577. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8578. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8579. }
  8580. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8581. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8582. }
  8583. } catch (error) {
  8584. throwError(error, 'GiveeClub.after');
  8585. }
  8586. }
  8587. init() {
  8588. try {
  8589. const logStatus = scripts_echoLog({
  8590. text: i18n('initing')
  8591. });
  8592. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8593. logStatus.warning(i18n('needLogin'));
  8594. return false;
  8595. }
  8596. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8597. return false;
  8598. }
  8599. this.initialized = true;
  8600. logStatus.success();
  8601. return true;
  8602. } catch (error) {
  8603. throwError(error, 'GiveeClub.init');
  8604. return false;
  8605. }
  8606. }
  8607. async classifyTask(action) {
  8608. try {
  8609. const logStatus = scripts_echoLog({
  8610. text: i18n('getTasksInfo')
  8611. });
  8612. if (action === 'undo') {
  8613. var _GM_getValue;
  8614. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8615. return true;
  8616. }
  8617. const pro = [];
  8618. const tasks = $('.event-actions tr');
  8619. for (const task of tasks) {
  8620. pro.push(new Promise(resolve => {
  8621. var _$$find;
  8622. const taskDes = $(task).find('.event-action-label a');
  8623. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8624. const taskName = taskDes.text().trim();
  8625. const taskType = (_$$find = $(task).find('button[data-type]')) === null || _$$find === void 0 ? void 0 : _$$find.attr('data-type');
  8626. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8627. return resolve(true);
  8628. }
  8629. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8630. if (!taskLink) {
  8631. return resolve(false);
  8632. }
  8633. if (taskType === 'steam.group.join' && /^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8634. this.undoneTasks.steam.groupLinks.push(taskLink);
  8635. } else if (/like.*announcement/gi.test(taskName)) {
  8636. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8637. } else if (taskType === 'steam.game.wishlist' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8638. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8639. } else if (taskType === 'steam.game.wishlist' && taskDes.attr('data-steam-wishlist-appid')) {
  8640. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8641. } else if (taskType === 'steam.game.follow' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8642. this.undoneTasks.steam.followLinks.push(taskLink);
  8643. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8644. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8645. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8646. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8647. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8648. this.undoneTasks.steam.forumLinks.push(taskLink);
  8649. } else if (taskIcon.includes('discord')) {
  8650. this.undoneTasks.discord.serverLinks.push(taskLink);
  8651. } else if (taskIcon.includes('instagram')) {
  8652. this.undoneTasks.instagram.userLinks.push(taskLink);
  8653. } else if (taskIcon.includes('twitch')) {
  8654. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8655. } else if (taskIcon.includes('reddit')) {
  8656. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8657. } else if (/watch.*art/gim.test(taskName)) {
  8658. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8659. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8660. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8661. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8662. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8663. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8664. this.undoneTasks.vk.nameLinks.push(taskLink);
  8665. } else {
  8666. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8667. if (/follow.*button/gim.test(taskName)) {
  8668. this.undoneTasks.steam.followLinks.push(taskLink);
  8669. }
  8670. }
  8671. }
  8672. resolve(true);
  8673. }).catch(error => {
  8674. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8675. return false;
  8676. });
  8677. }));
  8678. }
  8679. await Promise.all(pro);
  8680. logStatus.success();
  8681. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8682. this.socialTasks = this.undoneTasks;
  8683. if (window.DEBUG) {
  8684. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8685. }
  8686. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8687. tasks: this.socialTasks,
  8688. time: new Date().getTime()
  8689. });
  8690. return true;
  8691. } catch (error) {
  8692. throwError(error, 'GiveeClub.classifyTask');
  8693. return false;
  8694. }
  8695. }
  8696. async verifyTask() {
  8697. try {
  8698. const logStatus = scripts_echoLog({
  8699. text: i18n('giveeClubVerifyNotice')
  8700. });
  8701. const taskButtons = $('.event-actions tr button').has('i.glyphicon-refresh').not('[data-type="user.adblock"]');
  8702. for (const button of taskButtons) {
  8703. button.click();
  8704. if ($(button).attr('data-type') !== 'steam.game.wishlist') {
  8705. await delay(1e3);
  8706. }
  8707. }
  8708. logStatus.warning(i18n('giveeClubVerifyFinished'));
  8709. return true;
  8710. } catch (error) {
  8711. throwError(error, 'Givekey.verifyTask');
  8712. return false;
  8713. }
  8714. }
  8715. }
  8716. function GiveeClub_checkLogin2() {
  8717. try {
  8718. if (!globalOptions.other.checkLogin) {
  8719. return true;
  8720. }
  8721. if ($('a[href*="/account/auth"]').length > 0) {
  8722. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8723. }
  8724. return true;
  8725. } catch (error) {
  8726. throwError(error, 'GiveeClub.checkLogin');
  8727. return false;
  8728. }
  8729. }
  8730. function GiveeClub_getGiveawayId2() {
  8731. var _window$location$href;
  8732. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8733. if (giveawayId) {
  8734. this.giveawayId = giveawayId;
  8735. return true;
  8736. }
  8737. scripts_echoLog({
  8738. text: i18n('getFailed', 'GiveawayId')
  8739. });
  8740. return false;
  8741. }
  8742. async function GiveeClub_checkLeftKey2() {
  8743. try {
  8744. if (!globalOptions.other.checkLeftKey) {
  8745. return true;
  8746. }
  8747. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8748. await external_Swal_default().fire({
  8749. icon: 'warning',
  8750. title: i18n('notice'),
  8751. text: i18n('giveawayEnded'),
  8752. confirmButtonText: i18n('confirm'),
  8753. cancelButtonText: i18n('cancel'),
  8754. showCancelButton: true
  8755. }).then(_ref => {
  8756. let {
  8757. value
  8758. } = _ref;
  8759. if (value) {
  8760. window.close();
  8761. }
  8762. });
  8763. }
  8764. return true;
  8765. } catch (error) {
  8766. throwError(error, 'Giveawaysu.checkLeftKey');
  8767. return false;
  8768. }
  8769. }
  8770. const website_GiveeClub = GiveeClub;
  8771. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8772. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8773. privateSet.add(obj);
  8774. }
  8775. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8776. if (privateCollection.has(obj)) {
  8777. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8778. }
  8779. }
  8780. function OpiumPulses_defineProperty(obj, key, value) {
  8781. if (key in obj) {
  8782. Object.defineProperty(obj, key, {
  8783. value: value,
  8784. enumerable: true,
  8785. configurable: true,
  8786. writable: true
  8787. });
  8788. } else {
  8789. obj[key] = value;
  8790. }
  8791. return obj;
  8792. }
  8793. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8794. if (!privateSet.has(receiver)) {
  8795. throw new TypeError('attempted to get private field on non-instance');
  8796. }
  8797. return fn;
  8798. }
  8799. const defaultOptions = {
  8800. maxPoint: '99999999'
  8801. };
  8802. var _toggleTask = new WeakSet();
  8803. var OpiumPulses_checkLogin = new WeakSet();
  8804. class OpiumPulses {
  8805. constructor() {
  8806. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8807. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8808. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8809. OpiumPulses_defineProperty(this, 'options', {
  8810. ...defaultOptions,
  8811. ...GM_getValue('OpiumPulsesOptions')
  8812. });
  8813. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8814. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8815. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8816. }
  8817. static test() {
  8818. return window.location.host === 'www.opiumpulses.com';
  8819. }
  8820. async after() {
  8821. try {
  8822. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8823. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8824. }
  8825. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8826. } catch (error) {
  8827. throwError(error, 'OpiumPulses.after');
  8828. }
  8829. }
  8830. async doFreeTask() {
  8831. try {
  8832. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8833. } catch (error) {
  8834. throwError(error, 'OpiumPulses.doFreeTask');
  8835. }
  8836. }
  8837. async doPointTask() {
  8838. try {
  8839. var _$$text$match;
  8840. 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);
  8841. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8842. } catch (error) {
  8843. throwError(error, 'OpiumPulses.doPointTask');
  8844. }
  8845. }
  8846. init() {
  8847. return true;
  8848. }
  8849. classifyTask() {
  8850. return true;
  8851. }
  8852. }
  8853. async function _toggleTask2(type) {
  8854. try {
  8855. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8856. for (const item of items) {
  8857. var _$$find$text$match;
  8858. 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);
  8859. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8860. if (type === 'points' && needPoints > this.myPoints) {
  8861. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8862. } else if (type === 'points' && !needPoints) {
  8863. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8864. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8865. var _aElement$attr;
  8866. const logStatus = scripts_echoLog({
  8867. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8868. });
  8869. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8870. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8871. var _aElement$attr2, _aElement$attr2$match;
  8872. 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];
  8873. if (giveawayId) {
  8874. checkUser(giveawayId);
  8875. }
  8876. }
  8877. if (!aElement.attr('href')) {
  8878. logStatus.error('Error: No "href".');
  8879. continue;
  8880. }
  8881. const {
  8882. result,
  8883. statusText,
  8884. status,
  8885. data
  8886. } = await tools_httpRequest({
  8887. url: aElement.attr('href'),
  8888. method: 'GET'
  8889. });
  8890. if (result === 'Success') {
  8891. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8892. var _data$responseText$ma;
  8893. logStatus.success();
  8894. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8895. if (type === 'points' && points) {
  8896. this.myPoints = parseInt(points, 10);
  8897. }
  8898. } else {
  8899. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8900. }
  8901. } else {
  8902. logStatus.error(`${result}:${statusText}(${status})`);
  8903. }
  8904. }
  8905. }
  8906. scripts_echoLog({
  8907. text: '-----END-----'
  8908. });
  8909. } catch (error) {
  8910. throwError(error, 'OpiumPulses.toggleTask');
  8911. }
  8912. }
  8913. function OpiumPulses_checkLogin2() {
  8914. try {
  8915. if (!globalOptions.other.checkLogin) {
  8916. return true;
  8917. }
  8918. if ($('a[href*="/site/login"]').length > 1) {
  8919. window.open('/site/login', '_self');
  8920. }
  8921. return true;
  8922. } catch (error) {
  8923. throwError(error, 'OpiumPulses.checkLogin');
  8924. return false;
  8925. }
  8926. }
  8927. const website_OpiumPulses = OpiumPulses;
  8928. const external_dayjs_namespaceObject = dayjs;
  8929. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8930. const leftKeyChecker = {
  8931. async classify(link) {
  8932. try {
  8933. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8934. return await this.giveawaySu(link);
  8935. }
  8936. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8937. return await this.giveeClub(link);
  8938. }
  8939. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8940. return await this.gleam(link);
  8941. }
  8942. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8943. return await this.indieDb(link);
  8944. }
  8945. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8946. return await this.keyhub(link);
  8947. }
  8948. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8949. return await this.opquests(link);
  8950. }
  8951. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8952. return await this.itch(link);
  8953. }
  8954. return false;
  8955. } catch (error) {
  8956. throwError(error, 'leftKeyChecker.classify');
  8957. return false;
  8958. }
  8959. },
  8960. async giveawaySu(link) {
  8961. try {
  8962. const {
  8963. result,
  8964. data
  8965. } = await tools_httpRequest({
  8966. url: link,
  8967. method: 'GET'
  8968. });
  8969. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8970. if (data.responseText.includes('class="steam-login"')) {
  8971. return false;
  8972. }
  8973. if (data.responseText.includes('class="giveaway-ended"')) {
  8974. return 'Ended';
  8975. }
  8976. return 'Active';
  8977. }
  8978. return false;
  8979. } catch (error) {
  8980. throwError(error, 'leftKeyChecker.giveawaySu');
  8981. return false;
  8982. }
  8983. },
  8984. async giveeClub(link) {
  8985. try {
  8986. const {
  8987. result,
  8988. data
  8989. } = await tools_httpRequest({
  8990. url: link,
  8991. method: 'GET'
  8992. });
  8993. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8994. if (data.responseText.includes('class="event-winner"')) {
  8995. return 'Won';
  8996. }
  8997. if (data.responseText.includes('class="event-ended"')) {
  8998. return 'Ended';
  8999. }
  9000. return 'Active';
  9001. }
  9002. return false;
  9003. } catch (error) {
  9004. throwError(error, 'leftKeyChecker.giveeClub');
  9005. return false;
  9006. }
  9007. },
  9008. async gleam(link) {
  9009. try {
  9010. const {
  9011. result,
  9012. data
  9013. } = await tools_httpRequest({
  9014. url: link,
  9015. method: 'GET'
  9016. });
  9017. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9018. var _data$responseText$ma, _$$attr, _$$attr$match;
  9019. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  9020. return 'Won';
  9021. }
  9022. 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];
  9023. if (!campaignDiv) {
  9024. return false;
  9025. }
  9026. 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];
  9027. if (!campaignString) {
  9028. return false;
  9029. }
  9030. const {
  9031. campaign
  9032. } = JSON.parse(campaignString);
  9033. if (campaign.banned) {
  9034. return 'Banned';
  9035. }
  9036. if (campaign.finished) {
  9037. return 'Ended';
  9038. }
  9039. if (campaign.paused) {
  9040. return 'Paused';
  9041. }
  9042. if (new Date().getTime() < campaign.starts_at * 1e3) {
  9043. return 'NotStart';
  9044. }
  9045. return 'Active';
  9046. }
  9047. return false;
  9048. } catch (error) {
  9049. throwError(error, 'leftKeyChecker.gleam');
  9050. return false;
  9051. }
  9052. },
  9053. async indieDb(link) {
  9054. try {
  9055. const {
  9056. result,
  9057. data
  9058. } = await tools_httpRequest({
  9059. url: link,
  9060. method: 'GET'
  9061. });
  9062. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9063. if (data.responseText.includes('Congrats you WON')) {
  9064. return 'Won';
  9065. }
  9066. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  9067. return 'Ended';
  9068. }
  9069. return 'Active';
  9070. }
  9071. return false;
  9072. } catch (error) {
  9073. throwError(error, 'leftKeyChecker.indieDb');
  9074. return false;
  9075. }
  9076. },
  9077. async keyhub(link) {
  9078. try {
  9079. const {
  9080. result,
  9081. data
  9082. } = await tools_httpRequest({
  9083. url: link,
  9084. method: 'GET'
  9085. });
  9086. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9087. var _data$responseText$ma2;
  9088. 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];
  9089. if (!keysleft) {
  9090. return false;
  9091. }
  9092. if (keysleft === '0') {
  9093. return 'Ended';
  9094. }
  9095. return `Active(${keysleft})`;
  9096. }
  9097. return false;
  9098. } catch (error) {
  9099. throwError(error, 'leftKeyChecker.keyhub');
  9100. return false;
  9101. }
  9102. },
  9103. async opquests(link) {
  9104. try {
  9105. const {
  9106. result,
  9107. data
  9108. } = await tools_httpRequest({
  9109. url: link,
  9110. method: 'GET'
  9111. });
  9112. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9113. var _data$responseText$ma3;
  9114. 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];
  9115. if (!keysleft) {
  9116. return false;
  9117. }
  9118. if (keysleft === '0') {
  9119. return 'Ended';
  9120. }
  9121. return `Active(${keysleft})`;
  9122. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  9123. return 'Ended';
  9124. }
  9125. return false;
  9126. } catch (error) {
  9127. throwError(error, 'leftKeyChecker.opquests');
  9128. return false;
  9129. }
  9130. },
  9131. async itch(link) {
  9132. try {
  9133. const {
  9134. result,
  9135. data
  9136. } = await tools_httpRequest({
  9137. url: link,
  9138. method: 'GET'
  9139. });
  9140. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9141. var _data$responseText$ma4;
  9142. 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];
  9143. if (!endDate) {
  9144. return false;
  9145. }
  9146. if (new Date().getTime() > new Date(endDate).getTime()) {
  9147. return 'Ended';
  9148. }
  9149. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  9150. }
  9151. return false;
  9152. } catch (error) {
  9153. throwError(error, 'leftKeyChecker.opquests');
  9154. return false;
  9155. }
  9156. }
  9157. };
  9158. const website_leftKeyChecker = leftKeyChecker;
  9159. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  9160. Keylol_checkPrivateRedeclaration(obj, privateSet);
  9161. privateSet.add(obj);
  9162. }
  9163. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  9164. if (privateCollection.has(obj)) {
  9165. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9166. }
  9167. }
  9168. function Keylol_defineProperty(obj, key, value) {
  9169. if (key in obj) {
  9170. Object.defineProperty(obj, key, {
  9171. value: value,
  9172. enumerable: true,
  9173. configurable: true,
  9174. writable: true
  9175. });
  9176. } else {
  9177. obj[key] = value;
  9178. }
  9179. return obj;
  9180. }
  9181. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  9182. if (!privateSet.has(receiver)) {
  9183. throw new TypeError('attempted to get private field on non-instance');
  9184. }
  9185. return fn;
  9186. }
  9187. const Keylol_defaultTasksTemplate = {
  9188. steam: {
  9189. groupLinks: [],
  9190. wishlistLinks: [],
  9191. curatorLinks: [],
  9192. curatorLikeLinks: [],
  9193. followLinks: [],
  9194. forumLinks: [],
  9195. announcementLinks: [],
  9196. workshopVoteLinks: [],
  9197. licenseLinks: []
  9198. },
  9199. discord: {
  9200. serverLinks: []
  9201. },
  9202. instagram: {
  9203. userLinks: []
  9204. },
  9205. vk: {
  9206. nameLinks: []
  9207. },
  9208. twitch: {
  9209. channelLinks: []
  9210. },
  9211. reddit: {
  9212. redditLinks: []
  9213. },
  9214. twitter: {
  9215. userLinks: [],
  9216. retweetLinks: []
  9217. },
  9218. youtube: {
  9219. channelLinks: [],
  9220. likeLinks: []
  9221. }
  9222. };
  9223. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  9224. var _addBtn = new WeakSet();
  9225. class Keylol extends website_Website {
  9226. constructor() {
  9227. super(...arguments);
  9228. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  9229. Keylol_defineProperty(this, 'name', 'Keylol');
  9230. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  9231. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  9232. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  9233. }
  9234. static test() {
  9235. var _$$eq$attr, _$$eq$attr2;
  9236. 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')));
  9237. }
  9238. init() {
  9239. return true;
  9240. }
  9241. after() {
  9242. try {
  9243. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  9244. const mainPost = $(selector);
  9245. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  9246. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  9247. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  9248. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  9249. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  9250. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  9251. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  9252. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  9253. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  9254. if (discordLinks.length > 0) {
  9255. for (const discordLink of discordLinks) {
  9256. const link = $(discordLink).attr('href');
  9257. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  9258. continue;
  9259. }
  9260. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  9261. }
  9262. }
  9263. if (redditLinks.length > 0) {
  9264. for (const redditLink of redditLinks) {
  9265. const link = $(redditLink).attr('href');
  9266. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  9267. continue;
  9268. }
  9269. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  9270. }
  9271. }
  9272. if (insLinks.length > 0) {
  9273. for (const insLink of insLinks) {
  9274. const link = $(insLink).attr('href');
  9275. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  9276. continue;
  9277. }
  9278. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  9279. }
  9280. }
  9281. if (twitterLinks.length > 0) {
  9282. for (const twitterLink of twitterLinks) {
  9283. const link = $(twitterLink).attr('href');
  9284. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  9285. continue;
  9286. }
  9287. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  9288. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  9289. } else {
  9290. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  9291. }
  9292. }
  9293. }
  9294. if (twitchLinks.length > 0) {
  9295. for (const twitchLink of twitchLinks) {
  9296. const link = $(twitchLink).attr('href');
  9297. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  9298. continue;
  9299. }
  9300. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9301. }
  9302. }
  9303. if (vkLinks.length > 0) {
  9304. for (const vkLink of vkLinks) {
  9305. const link = $(vkLink).attr('href');
  9306. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9307. continue;
  9308. }
  9309. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9310. }
  9311. }
  9312. if (steamStoreLinks.length > 0) {
  9313. for (const steamStoreLink of steamStoreLinks) {
  9314. const link = $(steamStoreLink).attr('href');
  9315. if (!link) {
  9316. continue;
  9317. }
  9318. if (/curator\/[\d]+/.test(link)) {
  9319. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9320. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9321. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9322. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9323. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9324. } else if (/app\/[\d]+/.test(link)) {
  9325. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9326. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9327. }
  9328. }
  9329. }
  9330. if (steamCommunityLinks.length > 0) {
  9331. for (const steamCommunityLink of steamCommunityLinks) {
  9332. const link = $(steamCommunityLink).attr('href');
  9333. if (!link) {
  9334. continue;
  9335. }
  9336. if (/groups\/.+/.test(link)) {
  9337. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9338. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9339. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9340. }
  9341. }
  9342. }
  9343. if (ytbLinks.length > 0) {
  9344. for (const ytbLink of ytbLinks) {
  9345. const link = $(ytbLink).attr('href');
  9346. if (!link) {
  9347. continue;
  9348. }
  9349. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9350. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9351. }
  9352. }
  9353. 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');
  9354. if (giveawayLinks.length > 0) {
  9355. for (const giveawayLink of giveawayLinks) {
  9356. const link = $(giveawayLink).attr('href');
  9357. if (!link) {
  9358. continue;
  9359. }
  9360. website_leftKeyChecker.classify(link).then(status => {
  9361. if (!status) {
  9362. return;
  9363. }
  9364. if (/^Active/.test(status)) {
  9365. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9366. return;
  9367. }
  9368. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9369. }).catch(error => {
  9370. throwError(error, 'keylol.after -> leftKeyChecker');
  9371. });
  9372. }
  9373. }
  9374. if (this.name === 'Keylol') {
  9375. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9376. if (asfLinks.length > 0) {
  9377. for (const asfLink of asfLinks) {
  9378. const link = $(asfLink).attr('href');
  9379. if (!link) {
  9380. continue;
  9381. }
  9382. 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', '')}`);
  9383. }
  9384. }
  9385. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9386. if (subLinks.length > 0) {
  9387. for (const subLink of subLinks) {
  9388. var _link$match;
  9389. const link = $(subLink).attr('href');
  9390. if (!link) {
  9391. continue;
  9392. }
  9393. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9394. if (!subid) {
  9395. continue;
  9396. }
  9397. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9398. }
  9399. }
  9400. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9401. if (asfLinks2.length > 0) {
  9402. for (const asfLink of asfLinks2) {
  9403. const subid = asfLink.innerText.match(/[\d]+/g);
  9404. if (!subid || subid.length === 0) {
  9405. continue;
  9406. }
  9407. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9408. }
  9409. }
  9410. }
  9411. } catch (error) {
  9412. throwError(error, 'keylol.after');
  9413. }
  9414. }
  9415. classifyTask(action) {
  9416. try {
  9417. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9418. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9419. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9420. for (const btn of selectedBtns) {
  9421. const button = $(btn);
  9422. const social = button.attr('data-social');
  9423. const type = button.attr('data-type');
  9424. const link = button.attr('data-link');
  9425. if (!(social && type && link)) {
  9426. continue;
  9427. }
  9428. if (action === 'do') {
  9429. this.undoneTasks[social][type].push(link);
  9430. }
  9431. if (action === 'undo') {
  9432. this.socialTasks[social][type].push(link);
  9433. }
  9434. }
  9435. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9436. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9437. if (window.DEBUG) {
  9438. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9439. }
  9440. return true;
  9441. } catch (error) {
  9442. throwError(error, 'Keylol.classifyTask');
  9443. return false;
  9444. }
  9445. }
  9446. selectAll() {
  9447. try {
  9448. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9449. } catch (error) {
  9450. throwError(error, 'Keylol.selectAll');
  9451. }
  9452. }
  9453. selectNone() {
  9454. try {
  9455. $('.auto-task-keylol:visible').removeAttr('selected');
  9456. } catch (error) {
  9457. throwError(error, 'Keylol.selectNone');
  9458. }
  9459. }
  9460. invertSelect() {
  9461. try {
  9462. $('.auto-task-keylol:visible').each((index, element) => {
  9463. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9464. });
  9465. } catch (error) {
  9466. throwError(error, 'Keylol.invertSelect');
  9467. }
  9468. }
  9469. }
  9470. function _addBtn2(before, social, linkType, link) {
  9471. try {
  9472. $(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>`);
  9473. } catch (error) {
  9474. throwError(error, 'keylol.addBtn');
  9475. }
  9476. }
  9477. const website_Keylol = Keylol;
  9478. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9479. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9480. privateSet.add(obj);
  9481. }
  9482. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9483. if (privateCollection.has(obj)) {
  9484. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9485. }
  9486. }
  9487. function Opquests_defineProperty(obj, key, value) {
  9488. if (key in obj) {
  9489. Object.defineProperty(obj, key, {
  9490. value: value,
  9491. enumerable: true,
  9492. configurable: true,
  9493. writable: true
  9494. });
  9495. } else {
  9496. obj[key] = value;
  9497. }
  9498. return obj;
  9499. }
  9500. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9501. if (!privateSet.has(receiver)) {
  9502. throw new TypeError('attempted to get private field on non-instance');
  9503. }
  9504. return fn;
  9505. }
  9506. const Opquests_defaultTasks = {
  9507. steam: {
  9508. groupLinks: [],
  9509. wishlistLinks: [],
  9510. followLinks: [],
  9511. curatorLikeLinks: []
  9512. }
  9513. };
  9514. var Opquests_getGiveawayId = new WeakSet();
  9515. var Opquests_checkLogin = new WeakSet();
  9516. class Opquests extends website_Website {
  9517. constructor() {
  9518. super(...arguments);
  9519. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9520. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9521. Opquests_defineProperty(this, 'name', 'Opquests');
  9522. Opquests_defineProperty(this, 'undoneTasks', {
  9523. ...Opquests_defaultTasks
  9524. });
  9525. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9526. }
  9527. static test() {
  9528. return window.location.host === 'opquests.com';
  9529. }
  9530. async after() {
  9531. try {
  9532. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9533. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9534. }
  9535. } catch (error) {
  9536. throwError(error, 'Opquests.after');
  9537. }
  9538. }
  9539. init() {
  9540. try {
  9541. const logStatus = scripts_echoLog({
  9542. text: i18n('initing')
  9543. });
  9544. if ($('a[href*="/auth/redirect"]').length > 0) {
  9545. window.open('/auth/redirect', '_self');
  9546. logStatus.warning(i18n('needLogin'));
  9547. return false;
  9548. }
  9549. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9550. return false;
  9551. }
  9552. this.initialized = true;
  9553. logStatus.success();
  9554. return true;
  9555. } catch (error) {
  9556. throwError(error, 'Opquests.init');
  9557. return false;
  9558. }
  9559. }
  9560. async classifyTask(action) {
  9561. try {
  9562. if (action === 'undo') {
  9563. scripts_echoLog({
  9564. text: i18n('cannotUndo')
  9565. });
  9566. return false;
  9567. }
  9568. const logStatus = scripts_echoLog({
  9569. text: i18n('getTasksInfo')
  9570. });
  9571. const tasks = $('.w-full:contains("Validate") .items-center');
  9572. for (const task of tasks) {
  9573. const link = $(task).find('a:contains("Open")').attr('href');
  9574. const taskDes = $(task).find('div').eq(1).text().trim();
  9575. if (!link) {
  9576. continue;
  9577. }
  9578. if (/steamcommunity\.com\/groups\//.test(link)) {
  9579. this.undoneTasks.steam.groupLinks.push(link);
  9580. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9581. if (/wishlist/gim.test(taskDes)) {
  9582. this.undoneTasks.steam.wishlistLinks.push(link);
  9583. } else if (/follow/gim.test(taskDes)) {
  9584. this.undoneTasks.steam.followLinks.push(link);
  9585. }
  9586. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9587. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9588. } else {
  9589. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9590. }
  9591. }
  9592. logStatus.success();
  9593. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9594. if (window.DEBUG) {
  9595. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9596. }
  9597. return true;
  9598. } catch (error) {
  9599. throwError(error, 'Opquests.classifyTask');
  9600. return false;
  9601. }
  9602. }
  9603. }
  9604. function Opquests_getGiveawayId2() {
  9605. try {
  9606. var _window$location$href;
  9607. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9608. if (giveawayId) {
  9609. this.giveawayId = giveawayId;
  9610. return true;
  9611. }
  9612. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9613. return false;
  9614. } catch (error) {
  9615. throwError(error, 'Opquests.getGiveawayId');
  9616. return false;
  9617. }
  9618. }
  9619. function Opquests_checkLogin2() {
  9620. try {
  9621. if (!globalOptions.other.checkLogin) {
  9622. return true;
  9623. }
  9624. if ($('a[href*="/auth/redirect"]').length > 0) {
  9625. window.open('/auth/redirect', '_self');
  9626. }
  9627. return true;
  9628. } catch (error) {
  9629. throwError(error, 'Opquests.checkLogin');
  9630. return false;
  9631. }
  9632. }
  9633. const website_Opquests = Opquests;
  9634. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9635. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9636. privateSet.add(obj);
  9637. }
  9638. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9639. if (privateCollection.has(obj)) {
  9640. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9641. }
  9642. }
  9643. function Gleam_defineProperty(obj, key, value) {
  9644. if (key in obj) {
  9645. Object.defineProperty(obj, key, {
  9646. value: value,
  9647. enumerable: true,
  9648. configurable: true,
  9649. writable: true
  9650. });
  9651. } else {
  9652. obj[key] = value;
  9653. }
  9654. return obj;
  9655. }
  9656. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9657. if (!privateSet.has(receiver)) {
  9658. throw new TypeError('attempted to get private field on non-instance');
  9659. }
  9660. return fn;
  9661. }
  9662. const Gleam_defaultTasksTemplate = {
  9663. steam: {
  9664. groupLinks: [],
  9665. wishlistLinks: [],
  9666. followLinks: [],
  9667. curatorLinks: [],
  9668. curatorLikeLinks: []
  9669. },
  9670. twitter: {
  9671. userLinks: [],
  9672. retweetLinks: []
  9673. },
  9674. twitch: {
  9675. channelLinks: []
  9676. },
  9677. discord: {
  9678. serverLinks: []
  9679. },
  9680. youtube: {
  9681. channelLinks: []
  9682. },
  9683. extra: {
  9684. gleam: []
  9685. }
  9686. };
  9687. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9688. const Gleam_defaultOptions = {
  9689. vlootUsername: '',
  9690. gameroundUsername: ''
  9691. };
  9692. var _checkSync = new WeakSet();
  9693. var _doGleamTask = new WeakSet();
  9694. var Gleam_getGiveawayId = new WeakSet();
  9695. var _getGleamLink = new WeakSet();
  9696. var Gleam_checkLeftKey = new WeakSet();
  9697. class Gleam extends website_Website {
  9698. constructor() {
  9699. super(...arguments);
  9700. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9701. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9702. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9703. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9704. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9705. Gleam_defineProperty(this, 'name', 'Gleam');
  9706. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9707. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9708. Gleam_defineProperty(this, 'options', {
  9709. ...Gleam_defaultOptions,
  9710. ...GM_getValue('GleamOptions')
  9711. });
  9712. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9713. }
  9714. static test() {
  9715. return window.location.host === 'gleam.io';
  9716. }
  9717. async after() {
  9718. try {
  9719. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9720. const checkComplete = setInterval(() => {
  9721. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9722. clearInterval(checkComplete);
  9723. window.close();
  9724. }
  9725. });
  9726. for (const task of $('.entry-content .entry-method')) {
  9727. const taskInfo = $(task).find('.user-links');
  9728. const expandInfo = $(task).find('.expandable');
  9729. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9730. if (aElements.length > 0) {
  9731. for (const element of aElements) {
  9732. const $element = $(element);
  9733. const href = $element.attr('href');
  9734. $element.removeAttr('href')[0].click();
  9735. $element.attr('href', href);
  9736. await delay(1e3);
  9737. }
  9738. }
  9739. taskInfo[0].click();
  9740. await delay(1e3);
  9741. }
  9742. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9743. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9744. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9745. }
  9746. } catch (error) {
  9747. throwError(error, 'Gleam.after');
  9748. return false;
  9749. }
  9750. }
  9751. init() {
  9752. try {
  9753. const logStatus = scripts_echoLog({
  9754. text: i18n('initing')
  9755. });
  9756. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9757. return false;
  9758. }
  9759. this.initialized = true;
  9760. logStatus.success();
  9761. return true;
  9762. } catch (error) {
  9763. throwError(error, 'Gleam.init');
  9764. return false;
  9765. }
  9766. }
  9767. async classifyTask(action) {
  9768. try {
  9769. const logStatus = scripts_echoLog({
  9770. text: i18n('getTasksInfo')
  9771. });
  9772. if (action === 'undo') {
  9773. var _GM_getValue;
  9774. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9775. }
  9776. const tasks = $('.entry-content .entry-method');
  9777. for (const task of tasks) {
  9778. var _socialIcon$attr;
  9779. const $task = $(task);
  9780. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9781. continue;
  9782. }
  9783. const socialIcon = $task.find('.icon-wrapper i');
  9784. const taskInfo = $task.find('.user-links');
  9785. const taskText = taskInfo.text().trim();
  9786. const expandInfo = $task.find('.expandable');
  9787. const aElements = expandInfo.find('a.btn');
  9788. if (aElements.length > 0) {
  9789. for (const element of aElements) {
  9790. const $element = $(element);
  9791. const href = $element.attr('href');
  9792. $element.removeAttr('href')[0].click();
  9793. $element.attr('href', href);
  9794. }
  9795. }
  9796. if (socialIcon.hasClass('fa-twitter')) {
  9797. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9798. if (!link) {
  9799. continue;
  9800. }
  9801. if (/follow/gi.test(taskText)) {
  9802. if (action === 'undo') {
  9803. this.socialTasks.twitter.userLinks.push(link);
  9804. }
  9805. if (action === 'do') {
  9806. this.undoneTasks.twitter.userLinks.push(link);
  9807. }
  9808. } else if (/retweet/gim.test(taskText)) {
  9809. if (action === 'undo') {
  9810. this.socialTasks.twitter.retweetLinks.push(link);
  9811. }
  9812. if (action === 'do') {
  9813. this.undoneTasks.twitter.retweetLinks.push(link);
  9814. }
  9815. }
  9816. } else if (socialIcon.hasClass('fa-twitch')) {
  9817. if (/follow/gim.test(taskText)) {
  9818. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9819. if (!link) {
  9820. continue;
  9821. }
  9822. if (action === 'undo') {
  9823. this.socialTasks.twitch.channelLinks.push(link);
  9824. }
  9825. if (action === 'do') {
  9826. this.undoneTasks.twitch.channelLinks.push(link);
  9827. }
  9828. }
  9829. } else if (socialIcon.hasClass('fa-discord')) {
  9830. if (/join/gim.test(taskText)) {
  9831. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9832. if (!link) {
  9833. var _$task$find$attr, _$task$find$attr$matc;
  9834. 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];
  9835. if (!ggLink) {
  9836. continue;
  9837. }
  9838. link = `https://discord.com/invite/${ggLink}`;
  9839. }
  9840. if (action === 'undo') {
  9841. this.socialTasks.discord.serverLinks.push(link);
  9842. }
  9843. if (action === 'do') {
  9844. this.undoneTasks.discord.serverLinks.push(link);
  9845. }
  9846. }
  9847. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9848. continue;
  9849. } else if (socialIcon.hasClass('fa-youtube')) {
  9850. if (/subscribe/gim.test(taskText)) {
  9851. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9852. if (!link) {
  9853. continue;
  9854. }
  9855. if (action === 'undo') {
  9856. this.socialTasks.youtube.channelLinks.push(link);
  9857. }
  9858. if (action === 'do') {
  9859. this.undoneTasks.youtube.channelLinks.push(link);
  9860. }
  9861. }
  9862. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9863. if (/join.*group/gi.test(taskText)) {
  9864. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9865. if (!link) {
  9866. continue;
  9867. }
  9868. if (action === 'undo') {
  9869. this.socialTasks.steam.groupLinks.push(link);
  9870. }
  9871. if (action === 'do') {
  9872. this.undoneTasks.steam.groupLinks.push(link);
  9873. }
  9874. } else if (/follow.*curator/gi.test(taskText)) {
  9875. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9876. if (!link) {
  9877. continue;
  9878. }
  9879. if (action === 'undo') {
  9880. this.socialTasks.steam.curatorLinks.push(link);
  9881. }
  9882. if (action === 'do') {
  9883. this.undoneTasks.steam.curatorLinks.push(link);
  9884. }
  9885. }
  9886. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('vloot.io') || socialIcon.hasClass('fa-tiktok')) {
  9887. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9888. for (const button of continueBtn) {
  9889. button.click();
  9890. await delay(500);
  9891. expandInfo.find('input').val(this.options.vlootUsername);
  9892. }
  9893. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9894. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9895. for (const button of continueBtn) {
  9896. button.click();
  9897. await delay(500);
  9898. expandInfo.find('input').val(this.options.gameroundUsername);
  9899. }
  9900. } else if (socialIcon.hasClass('fa-bullhorn') && /Complete/gi.test(taskText)) {
  9901. if (action !== 'do') {
  9902. continue;
  9903. }
  9904. const link = aElements.attr('href');
  9905. if (!link) {
  9906. continue;
  9907. }
  9908. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9909. if (!gleamLink) {
  9910. continue;
  9911. }
  9912. this.undoneTasks.extra.gleam.push(gleamLink);
  9913. } 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 {
  9914. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9915. }
  9916. }
  9917. logStatus.success();
  9918. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9919. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9920. if (window.DEBUG) {
  9921. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9922. }
  9923. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9924. tasks: this.socialTasks,
  9925. time: new Date().getTime()
  9926. });
  9927. return true;
  9928. } catch (error) {
  9929. throwError(error, 'Gleam.classifyTask');
  9930. return false;
  9931. }
  9932. }
  9933. async extraDoTask(_ref) {
  9934. let {
  9935. gleam
  9936. } = _ref;
  9937. try {
  9938. const pro = [];
  9939. for (const link of gleam) {
  9940. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9941. }
  9942. return Promise.all(pro).then(() => true);
  9943. } catch (error) {
  9944. throwError(error, 'Gleam.extraDoTask');
  9945. return false;
  9946. }
  9947. }
  9948. async verifyTask() {
  9949. try {
  9950. scripts_echoLog({
  9951. text: `${i18n('verifyingTask')}...`
  9952. });
  9953. const tasks = $('.entry-content .entry-method');
  9954. for (const task of tasks) {
  9955. const $task = $(task);
  9956. if ($task.find('i.fa-question').length === 0) {
  9957. continue;
  9958. }
  9959. const taskInfo = $task.find('.user-links');
  9960. taskInfo[0].click();
  9961. await delay(500);
  9962. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9963. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9964. for (const button of continueBtn) {
  9965. button.click();
  9966. await delay(500);
  9967. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9968. }
  9969. }
  9970. scripts_echoLog({
  9971. text: i18n('verifiedGleamTasks')
  9972. });
  9973. } catch (error) {
  9974. throwError(error, 'Gleam.verifyTask');
  9975. return false;
  9976. }
  9977. }
  9978. }
  9979. async function _checkSync2() {
  9980. try {
  9981. return await new Promise(resolve => {
  9982. const checker = setInterval(() => {
  9983. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9984. clearInterval(checker);
  9985. resolve(true);
  9986. }
  9987. }, 500);
  9988. });
  9989. } catch (error) {
  9990. throwError(error, 'Gleam.checkSync');
  9991. return false;
  9992. }
  9993. }
  9994. async function _doGleamTask2(link) {
  9995. try {
  9996. const logStatus = scripts_echoLog({
  9997. text: i18n('doingGleamTask')
  9998. });
  9999. return await new Promise(resolve => {
  10000. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  10001. active: true,
  10002. insert: true,
  10003. setParent: true
  10004. }).onclose = () => {
  10005. logStatus.success();
  10006. resolve(true);
  10007. };
  10008. });
  10009. } catch (error) {
  10010. throwError(error, 'Gleam.doGleamTask');
  10011. return false;
  10012. }
  10013. }
  10014. function Gleam_getGiveawayId2() {
  10015. try {
  10016. const giveawayId = window.location.pathname;
  10017. if (giveawayId) {
  10018. this.giveawayId = giveawayId;
  10019. return true;
  10020. }
  10021. scripts_echoLog({
  10022. text: i18n('getFailed', 'GiveawayId')
  10023. });
  10024. return false;
  10025. } catch (error) {
  10026. throwError(error, 'Gleam.getGiveawayId');
  10027. return false;
  10028. }
  10029. }
  10030. async function _getGleamLink2(link) {
  10031. try {
  10032. const logStatus = scripts_echoLog({
  10033. text: i18n('gettingGleamLink')
  10034. });
  10035. const {
  10036. result,
  10037. statusText,
  10038. status,
  10039. data
  10040. } = await tools_httpRequest({
  10041. url: link,
  10042. method: 'GET'
  10043. });
  10044. if (result === 'Success') {
  10045. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10046. var _data$responseText$ma;
  10047. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  10048. if (gleamLink) {
  10049. logStatus.success();
  10050. return gleamLink;
  10051. }
  10052. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  10053. return false;
  10054. }
  10055. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10056. return false;
  10057. }
  10058. logStatus.error(`${result}:${statusText}(${status})`);
  10059. return false;
  10060. } catch (error) {
  10061. throwError(error, 'Gleam.getGleamLink');
  10062. return false;
  10063. }
  10064. }
  10065. async function Gleam_checkLeftKey2() {
  10066. try {
  10067. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  10068. if (!globalOptions.other.checkLeftKey) {
  10069. return true;
  10070. }
  10071. 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];
  10072. if (!campaignString) {
  10073. return false;
  10074. }
  10075. const {
  10076. campaign,
  10077. incentive
  10078. } = JSON.parse(campaignString);
  10079. 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];
  10080. let ownedKey = false;
  10081. if (controllerString) {
  10082. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  10083. 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) {
  10084. ownedKey = true;
  10085. }
  10086. }
  10087. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  10088. await external_Swal_default().fire({
  10089. icon: 'warning',
  10090. title: i18n('notice'),
  10091. text: i18n('giveawayNotWork'),
  10092. confirmButtonText: i18n('confirm'),
  10093. cancelButtonText: i18n('cancel'),
  10094. showCancelButton: true
  10095. }).then(_ref2 => {
  10096. let {
  10097. value
  10098. } = _ref2;
  10099. if (value) {
  10100. window.close();
  10101. }
  10102. });
  10103. }
  10104. return true;
  10105. } catch (error) {
  10106. throwError(error, 'Gleam.checkLeftKey');
  10107. return false;
  10108. }
  10109. }
  10110. const website_Gleam = Gleam;
  10111. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  10112. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  10113. privateSet.add(obj);
  10114. }
  10115. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  10116. if (privateCollection.has(obj)) {
  10117. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10118. }
  10119. }
  10120. function SweepWidget_defineProperty(obj, key, value) {
  10121. if (key in obj) {
  10122. Object.defineProperty(obj, key, {
  10123. value: value,
  10124. enumerable: true,
  10125. configurable: true,
  10126. writable: true
  10127. });
  10128. } else {
  10129. obj[key] = value;
  10130. }
  10131. return obj;
  10132. }
  10133. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  10134. if (!privateSet.has(receiver)) {
  10135. throw new TypeError('attempted to get private field on non-instance');
  10136. }
  10137. return fn;
  10138. }
  10139. const SweepWidget_defaultOptions = {
  10140. username: '',
  10141. email: ''
  10142. };
  10143. var SweepWidget_checkLogin = new WeakSet();
  10144. var SweepWidget_getGiveawayId = new WeakSet();
  10145. var _checkEnter = new WeakSet();
  10146. var _checkFinish = new WeakSet();
  10147. class SweepWidget extends website_Website {
  10148. constructor() {
  10149. super(...arguments);
  10150. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  10151. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  10152. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  10153. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  10154. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  10155. SweepWidget_defineProperty(this, 'options', {
  10156. ...SweepWidget_defaultOptions,
  10157. ...GM_getValue('SweepWidgetOptions')
  10158. });
  10159. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  10160. }
  10161. static test() {
  10162. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  10163. }
  10164. async after() {
  10165. try {
  10166. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  10167. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  10168. }
  10169. } catch (error) {
  10170. throwError(error, 'SweepWidget.after');
  10171. }
  10172. }
  10173. init() {
  10174. try {
  10175. const logStatus = scripts_echoLog({
  10176. text: i18n('initing')
  10177. });
  10178. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  10179. logStatus.warning(i18n('needLogin'));
  10180. return false;
  10181. }
  10182. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  10183. return false;
  10184. }
  10185. this.initialized = true;
  10186. logStatus.success();
  10187. return true;
  10188. } catch (error) {
  10189. throwError(error, 'SweepWidget.init');
  10190. return false;
  10191. }
  10192. }
  10193. classifyTask() {
  10194. return true;
  10195. }
  10196. async doTask() {
  10197. try {
  10198. if ($('#unlock_rewards_main_wrapper').length === 0) {
  10199. if ($('input[name="sw__login_name"]:visible').length > 0) {
  10200. $('input[name="sw__login_name"]').val(this.options.username);
  10201. }
  10202. if ($('input[name="sw__login_email"]:visible').length > 0) {
  10203. $('input[name="sw__login_email"]').val(this.options.email);
  10204. }
  10205. if ($('#sw_login_button:visible').length > 0) {
  10206. $('#sw_login_button')[0].click();
  10207. }
  10208. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  10209. return false;
  10210. }
  10211. }
  10212. const logStatus = scripts_echoLog({
  10213. text: i18n('SweepWidgetNotice')
  10214. });
  10215. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  10216. for (const task of tasks) {
  10217. var _aElement$, _$task$find$removeAtt;
  10218. const $task = $(task);
  10219. if ($task.find('i.fa-check:visible').length > 0) {
  10220. continue;
  10221. }
  10222. const title = $task.find('.sw_text_inner');
  10223. title[0].click();
  10224. const aElement = $task.find('a.sw_link');
  10225. const link = aElement.attr('href');
  10226. aElement.attr('href', '#a').attr('target', '_self');
  10227. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  10228. await delay(300);
  10229. aElement.attr('href', link).attr('target', '_blank');
  10230. $task.find('input[type="text"]').val('test');
  10231. const verifyBtn = $task.find('input.sw_verify');
  10232. if (verifyBtn.prop('disabled') === true) {
  10233. title[0].click();
  10234. await delay(300);
  10235. title[0].click();
  10236. await delay(300);
  10237. }
  10238. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  10239. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  10240. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  10241. }
  10242. logStatus.success();
  10243. return true;
  10244. } catch (error) {
  10245. throwError(error, 'SweepWidget.doTask');
  10246. return false;
  10247. }
  10248. }
  10249. }
  10250. function SweepWidget_checkLogin2() {
  10251. try {
  10252. if ($('#twitter_login_button').length > 0) {
  10253. $('#twitter_login_button')[0].click();
  10254. }
  10255. return true;
  10256. } catch (error) {
  10257. throwError(error, 'SweepWidget.checkLogin');
  10258. return false;
  10259. }
  10260. }
  10261. function SweepWidget_getGiveawayId2() {
  10262. try {
  10263. var _window$location$href;
  10264. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  10265. if (giveawayId) {
  10266. this.giveawayId = giveawayId;
  10267. return true;
  10268. }
  10269. scripts_echoLog({
  10270. text: i18n('getFailed', 'GiveawayId')
  10271. });
  10272. return false;
  10273. } catch (error) {
  10274. throwError(error, 'SweepWidget.getGiveawayId');
  10275. return false;
  10276. }
  10277. }
  10278. async function _checkEnter2() {
  10279. try {
  10280. return new Promise(resolve => {
  10281. const checker = setInterval(() => {
  10282. if ($('#unlock_rewards_main_wrapper').length > 0) {
  10283. clearInterval(checker);
  10284. resolve(true);
  10285. }
  10286. });
  10287. });
  10288. } catch (error) {
  10289. throwError(error, 'SweepWidget.checkEnter');
  10290. return false;
  10291. }
  10292. }
  10293. async function _checkFinish2($task) {
  10294. try {
  10295. return new Promise(resolve => {
  10296. const checker = setInterval(() => {
  10297. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  10298. clearInterval(checker);
  10299. resolve(true);
  10300. }
  10301. });
  10302. });
  10303. } catch (error) {
  10304. throwError(error, 'SweepWidget.checkFinish');
  10305. return false;
  10306. }
  10307. }
  10308. const website_SweepWidget = SweepWidget;
  10309. const defaultWhiteList = {
  10310. discord: {
  10311. servers: []
  10312. },
  10313. instagram: {
  10314. users: []
  10315. },
  10316. twitch: {
  10317. channels: []
  10318. },
  10319. twitter: {
  10320. users: [],
  10321. retweets: [],
  10322. likes: []
  10323. },
  10324. vk: {
  10325. names: []
  10326. },
  10327. youtube: {
  10328. channels: [],
  10329. likes: []
  10330. },
  10331. reddit: {
  10332. reddits: []
  10333. },
  10334. steam: {
  10335. groups: [],
  10336. officialGroups: [],
  10337. wishlists: [],
  10338. follows: [],
  10339. forums: [],
  10340. workshops: [],
  10341. curators: [],
  10342. workshopVotes: [],
  10343. curatorLikes: [],
  10344. announcements: [],
  10345. licenses: [],
  10346. playtests: []
  10347. }
  10348. };
  10349. const link2id = async function(type) {
  10350. 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;
  10351. try {
  10352. const link = $('#socialLink').val();
  10353. let id = '';
  10354. switch (type) {
  10355. case 'discord.servers':
  10356. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10357. break;
  10358.  
  10359. case 'instagram.users':
  10360. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10361. break;
  10362.  
  10363. case 'twitch.channels':
  10364. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10365. break;
  10366.  
  10367. case 'twitter.users':
  10368. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10369. break;
  10370.  
  10371. case 'twitter.retweets':
  10372. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10373. break;
  10374.  
  10375. case 'vk.names':
  10376. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10377. break;
  10378.  
  10379. case 'youtube.channels':
  10380. 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) || '';
  10381. break;
  10382.  
  10383. case 'youtube.likes':
  10384. 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) || '';
  10385. break;
  10386.  
  10387. case 'reddit.reddits':
  10388. 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]) || '';
  10389. break;
  10390.  
  10391. case 'steam.groups':
  10392. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10393. break;
  10394.  
  10395. case 'steam.wishlists':
  10396. case 'steam.follows':
  10397. case 'steam.forums':
  10398. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10399. break;
  10400.  
  10401. case 'steam.workshops':
  10402. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10403. break;
  10404.  
  10405. case 'steam.curators':
  10406. {
  10407. if (link.includes('curator')) {
  10408. var _link$match12;
  10409. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10410. } else {
  10411. var _link$match13;
  10412. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10413. if (!param || param.length !== 2) {
  10414. break;
  10415. }
  10416. const steam = new social_Steam();
  10417. if (await steam.init()) {
  10418. id = await steam.getCuratorId(param[0], param[1]) || '';
  10419. }
  10420. }
  10421. }
  10422. break;
  10423. }
  10424. return id;
  10425. } catch (error) {
  10426. throwError(error, 'link2id');
  10427. return i18n('getFailed', 'id');
  10428. }
  10429. };
  10430. const disabledType = {
  10431. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10432. twitter: [ 'likes' ]
  10433. };
  10434. const assignWhiteList = whiteList => {
  10435. try {
  10436. const newWhiteList = {};
  10437. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10438. newWhiteList[key] = {
  10439. ...value,
  10440. ...whiteList[key]
  10441. };
  10442. }
  10443. return newWhiteList;
  10444. } catch (error) {
  10445. throwError(error, 'assignWhiteList');
  10446. return defaultWhiteList;
  10447. }
  10448. };
  10449. const whiteListOptions = function(showType) {
  10450. try {
  10451. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10452. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10453. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10454. for (const [ social, types ] of Object.entries(whiteList)) {
  10455. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10456. var _disabledType$social;
  10457. 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>`;
  10458. }).join('');
  10459. }
  10460. whiteListOptionsForm += '</tbody></table></form>';
  10461. if (showType === 'swal') {
  10462. external_Swal_default().fire({
  10463. title: i18n('whiteListOptions'),
  10464. html: whiteListOptionsForm,
  10465. showConfirmButton: false,
  10466. showCloseButton: true
  10467. });
  10468. } else {
  10469. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10470. }
  10471. $('.editWhiteList').on('click', function() {
  10472. var _whiteList$social;
  10473. const value = $(this).attr('data-value');
  10474. if (!value) {
  10475. return;
  10476. }
  10477. const [ social, type ] = value.split('.');
  10478. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10479. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10480. return;
  10481. }
  10482. external_Swal_default().fire({
  10483. title: i18n('changeWhiteListOption', value),
  10484. input: 'textarea',
  10485. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10486. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10487. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10488. inputValue: whiteList[social][type].join('\n'),
  10489. showConfirmButton: true,
  10490. confirmButtonText: i18n('save'),
  10491. showCancelButton: true,
  10492. cancelButtonText: i18n('close'),
  10493. showDenyButton: true,
  10494. denyButtonText: i18n('return')
  10495. }).then(_ref => {
  10496. let {
  10497. isDenied,
  10498. isConfirmed,
  10499. value
  10500. } = _ref;
  10501. if (isDenied) {
  10502. if (showType === 'swal') {
  10503. whiteListOptions(showType);
  10504. }
  10505. return;
  10506. } else if (isConfirmed) {
  10507. whiteList[social][type] = value.split('\n');
  10508. GM_setValue('whiteList', whiteList);
  10509. external_Swal_default().fire({
  10510. title: i18n('changeWhiteListSuccess'),
  10511. icon: 'success'
  10512. });
  10513. }
  10514. });
  10515. $('#link2id').on('click', async function() {
  10516. const type = $(this).attr('data-type');
  10517. $('#socialLink').val(await link2id(type));
  10518. });
  10519. });
  10520. } catch (error) {
  10521. throwError(error, 'whiteListOptions');
  10522. }
  10523. };
  10524. const whiteList = whiteListOptions;
  10525. const setGistData = async (token, gistId, fileName, content) => {
  10526. try {
  10527. const logStatus = scripts_echoLog({
  10528. text: i18n('settingData')
  10529. });
  10530. const contentData = JSON.stringify({
  10531. files: {
  10532. [fileName]: {
  10533. content: JSON.stringify(content)
  10534. }
  10535. }
  10536. });
  10537. const {
  10538. result,
  10539. statusText,
  10540. status,
  10541. data
  10542. } = await tools_httpRequest({
  10543. url: `https://api.github.com/gists/${gistId}`,
  10544. headers: {
  10545. Accept: 'application/vnd.github.v3+json',
  10546. Authorization: `token ${token}`
  10547. },
  10548. data: contentData,
  10549. responseType: 'json',
  10550. method: 'POST',
  10551. timeout: 3e4
  10552. });
  10553. if (result === 'Success') {
  10554. var _data$response$files, _data$response$files$;
  10555. 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)) {
  10556. logStatus.success();
  10557. return true;
  10558. }
  10559. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10560. return false;
  10561. }
  10562. logStatus.error(`${result}:${statusText}(${status})`);
  10563. return false;
  10564. } catch (error) {
  10565. throwError(error, 'setGistData');
  10566. return false;
  10567. }
  10568. };
  10569. const getGistData = async function(token, gistId, fileName) {
  10570. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10571. try {
  10572. const logStatus = scripts_echoLog({
  10573. text: i18n('gettingData')
  10574. });
  10575. const {
  10576. result,
  10577. statusText,
  10578. status,
  10579. data
  10580. } = await tools_httpRequest({
  10581. url: `https://api.github.com/gists/${gistId}`,
  10582. headers: {
  10583. Accept: 'application/vnd.github.v3+json',
  10584. Authorization: `token ${token}`
  10585. },
  10586. responseType: 'json',
  10587. method: 'GET',
  10588. timeout: 3e4
  10589. });
  10590. if (result === 'Success') {
  10591. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10592. var _data$response, _data$response$files2, _data$response$files3;
  10593. 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;
  10594. let formatedContent;
  10595. if (!content) {
  10596. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10597. return false;
  10598. }
  10599. if (test) {
  10600. logStatus.success();
  10601. return true;
  10602. }
  10603. try {
  10604. formatedContent = JSON.parse(content);
  10605. } catch (error) {
  10606. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10607. return false;
  10608. }
  10609. logStatus.success();
  10610. return formatedContent;
  10611. }
  10612. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10613. return false;
  10614. }
  10615. logStatus.error(`${result}:${statusText}(${status})`);
  10616. return false;
  10617. } catch (error) {
  10618. throwError(error, 'getGistData');
  10619. return false;
  10620. }
  10621. };
  10622. const syncOptions = () => {
  10623. try {
  10624. const {
  10625. TOKEN,
  10626. GIST_ID,
  10627. FILE_NAME,
  10628. SYNC_HISTORY
  10629. } = GM_getValue('gistOptions') || {
  10630. TOKEN: '',
  10631. GIST_ID: '',
  10632. FILE_NAME: '',
  10633. SYNC_HISTORY: true
  10634. };
  10635. external_Swal_default().fire({
  10636. title: i18n('gistOptions'),
  10637. 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;">
  10638. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10639. ${i18n('downloadFromGist')}</button></p>`,
  10640. focusConfirm: false,
  10641. showLoaderOnConfirm: true,
  10642. 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>`,
  10643. preConfirm: async () => {
  10644. const token = $('#github-token').val();
  10645. const gistId = $('#gist-id').val();
  10646. const fileName = $('#file-name').val();
  10647. const syncHistory = $('#sync-history').prop('checked');
  10648. GM_setValue('gistOptions', {
  10649. TOKEN: token,
  10650. GIST_ID: gistId,
  10651. FILE_NAME: fileName,
  10652. SYNC_HISTORY: syncHistory
  10653. });
  10654. return await getGistData(token, gistId, fileName, true);
  10655. },
  10656. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10657. confirmButtonText: i18n('saveAndTest'),
  10658. showCancelButton: true,
  10659. cancelButtonText: i18n('close')
  10660. }).then(_ref => {
  10661. let {
  10662. value
  10663. } = _ref;
  10664. if (value) {
  10665. external_Swal_default().fire({
  10666. icon: 'success',
  10667. title: i18n('testSuccess')
  10668. }).then(syncOptions);
  10669. } else if (value !== undefined) {
  10670. external_Swal_default().fire({
  10671. icon: 'error',
  10672. title: i18n('testFailed')
  10673. }).then(syncOptions);
  10674. }
  10675. });
  10676. $('#upload-data').on('click', async () => {
  10677. const {
  10678. TOKEN,
  10679. GIST_ID,
  10680. FILE_NAME
  10681. } = GM_getValue('gistOptions') || {};
  10682. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10683. return external_Swal_default().fire({
  10684. icon: 'error',
  10685. title: i18n('saveAndTestNotice')
  10686. }).then(syncOptions);
  10687. }
  10688. external_Swal_default().fire({
  10689. icon: 'info',
  10690. title: i18n('processingData')
  10691. });
  10692. const data = {};
  10693. const names = GM_listValues();
  10694. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10695. for (const name of names) {
  10696. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10697. continue;
  10698. }
  10699. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10700. continue;
  10701. }
  10702. data[name] = GM_getValue(name);
  10703. }
  10704. external_Swal_default().update({
  10705. icon: 'info',
  10706. title: i18n('updatingData')
  10707. });
  10708. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10709. external_Swal_default().fire({
  10710. icon: 'success',
  10711. title: i18n('syncDataSuccess')
  10712. });
  10713. } else {
  10714. external_Swal_default().fire({
  10715. icon: 'error',
  10716. title: i18n('syncDataFailed')
  10717. });
  10718. }
  10719. });
  10720. $('#download-data').on('click', async () => {
  10721. const {
  10722. TOKEN,
  10723. GIST_ID,
  10724. FILE_NAME
  10725. } = GM_getValue('gistOptions') || {};
  10726. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10727. return external_Swal_default().fire({
  10728. icon: 'error',
  10729. title: i18n('saveAndTestNotice')
  10730. }).then(syncOptions);
  10731. }
  10732. external_Swal_default().fire({
  10733. icon: 'info',
  10734. title: i18n('downloadingData')
  10735. });
  10736. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10737. if (!data) {
  10738. return external_Swal_default().fire({
  10739. icon: 'error',
  10740. title: i18n('checkedNoData')
  10741. }).then(syncOptions);
  10742. }
  10743. external_Swal_default().update({
  10744. icon: 'info',
  10745. title: i18n('savingData')
  10746. });
  10747. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10748. for (const [ name, value ] of Object.entries(data)) {
  10749. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10750. continue;
  10751. }
  10752. GM_setValue(name, value);
  10753. }
  10754. external_Swal_default().fire({
  10755. icon: 'success',
  10756. title: i18n('syncDataSuccess')
  10757. });
  10758. });
  10759. } catch (error) {
  10760. throwError(error, 'syncOptions');
  10761. }
  10762. };
  10763. const dataSync = syncOptions;
  10764. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10765. Setting_checkPrivateRedeclaration(obj, privateSet);
  10766. privateSet.add(obj);
  10767. }
  10768. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10769. if (privateCollection.has(obj)) {
  10770. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10771. }
  10772. }
  10773. function Setting_defineProperty(obj, key, value) {
  10774. if (key in obj) {
  10775. Object.defineProperty(obj, key, {
  10776. value: value,
  10777. enumerable: true,
  10778. configurable: true,
  10779. writable: true
  10780. });
  10781. } else {
  10782. obj[key] = value;
  10783. }
  10784. return obj;
  10785. }
  10786. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10787. if (!privateSet.has(receiver)) {
  10788. throw new TypeError('attempted to get private field on non-instance');
  10789. }
  10790. return fn;
  10791. }
  10792. var Setting_getId = new WeakSet();
  10793. var _environment = new WeakSet();
  10794. class Setting {
  10795. constructor() {
  10796. Setting_classPrivateMethodInitSpec(this, _environment);
  10797. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10798. Setting_defineProperty(this, 'name', 'Setting');
  10799. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10800. Setting_defineProperty(this, 'syncData', dataSync);
  10801. }
  10802. tasksHistory() {
  10803. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10804. }
  10805. static test() {
  10806. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10807. }
  10808. before() {
  10809. $('body').html('').addClass('auto-task-options');
  10810. }
  10811. after() {
  10812. try {
  10813. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10814. changeGlobalOptions('page');
  10815. whiteList('page');
  10816. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10817. $('#getTwitterUserId').on('click', () => {
  10818. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10819. });
  10820. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10821. $('#getYoutubeChannelId').on('click', () => {
  10822. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10823. });
  10824. $('input[name^="position"]').on('input', function() {
  10825. const type = $(this).attr('name').replace('position.', '');
  10826. const xLabel = 'rightleft';
  10827. const yLabel = 'topbottpm';
  10828. switch (type) {
  10829. case 'buttonSideX':
  10830. case 'buttonSideY':
  10831. case 'buttonDistance':
  10832. {
  10833. const distance = $('input[name="position.buttonDistance"]').val();
  10834. const sideX = $('input[name="position.buttonSideX"]').val();
  10835. const sideY = $('input[name="position.buttonSideY"]').val();
  10836. if (![ 'right', 'left' ].includes(sideX)) {
  10837. break;
  10838. }
  10839. if (![ 'top', 'bottom' ].includes(sideY)) {
  10840. break;
  10841. }
  10842. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10843. break;
  10844. }
  10845. const distanceArr = distance.split(',');
  10846. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10847. break;
  10848. }
  10849.  
  10850. case 'showButtonSideX':
  10851. case 'showButtonSideY':
  10852. case 'showButtonDistance':
  10853. {
  10854. const distance = $('input[name="position.showButtonDistance"]').val();
  10855. const sideX = $('input[name="position.showButtonSideX"]').val();
  10856. const sideY = $('input[name="position.showButtonSideY"]').val();
  10857. if (![ 'right', 'left' ].includes(sideX)) {
  10858. break;
  10859. }
  10860. if (![ 'top', 'bottom' ].includes(sideY)) {
  10861. break;
  10862. }
  10863. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10864. break;
  10865. }
  10866. const distanceArr = distance.split(',');
  10867. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10868. break;
  10869. }
  10870.  
  10871. case 'logSideX':
  10872. case 'logSideY':
  10873. case 'logDistance':
  10874. {
  10875. const distance = $('input[name="position.logDistance"]').val();
  10876. const sideX = $('input[name="position.logSideX"]').val();
  10877. const sideY = $('input[name="position.logSideY"]').val();
  10878. if (![ 'right', 'left' ].includes(sideX)) {
  10879. break;
  10880. }
  10881. if (![ 'top', 'bottom' ].includes(sideY)) {
  10882. break;
  10883. }
  10884. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10885. break;
  10886. }
  10887. const distanceArr = distance.split(',');
  10888. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10889. break;
  10890. }
  10891.  
  10892. default:
  10893. break;
  10894. }
  10895. });
  10896. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10897. let functionKey = '';
  10898. if (event.altKey) {
  10899. functionKey += 'alt + ';
  10900. } else if (event.ctrlKey) {
  10901. functionKey += 'ctrl + ';
  10902. } else if (event.shiftKey) {
  10903. functionKey += 'shift + ';
  10904. }
  10905. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10906. });
  10907. } catch (error) {
  10908. throwError(error, 'Setting.after');
  10909. }
  10910. }
  10911. saveGlobalOptions() {
  10912. saveData();
  10913. }
  10914. }
  10915. function Setting_getId2(social) {
  10916. try {
  10917. external_Swal_default().fire({
  10918. title: i18n('getId', i18n(social)),
  10919. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10920. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10921. showCancelButton: true,
  10922. cancelButtonText: i18n('close'),
  10923. showConfirmButton: false
  10924. });
  10925. $('#link2id').on('click', async function() {
  10926. const link = $('#socialLink').val();
  10927. if (!link) {
  10928. return;
  10929. }
  10930. const type = $(this).attr('data-type');
  10931. if (type === 'twitterUser') {
  10932. var _link$match;
  10933. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10934. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10935. } else if (type === 'youtubeChannel') {
  10936. var _link$match2, _await$getInfo, _await$getInfo$params;
  10937. 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;
  10938. $('#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) || '');
  10939. }
  10940. });
  10941. } catch (error) {
  10942. throwError(error, 'Setting.getId');
  10943. }
  10944. }
  10945. function _environment2() {
  10946. try {
  10947. const userAgent = (0, javascript_utils_umd_min.ua)();
  10948. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10949. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10950. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10951. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10952. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10953. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10954. </tbody></table></form>`;
  10955. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10956. } catch (error) {
  10957. throwError(error, 'Setting.environment');
  10958. }
  10959. }
  10960. const website_Setting = Setting;
  10961. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10962. History_checkPrivateRedeclaration(obj, privateSet);
  10963. privateSet.add(obj);
  10964. }
  10965. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10966. if (privateCollection.has(obj)) {
  10967. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10968. }
  10969. }
  10970. function History_defineProperty(obj, key, value) {
  10971. if (key in obj) {
  10972. Object.defineProperty(obj, key, {
  10973. value: value,
  10974. enumerable: true,
  10975. configurable: true,
  10976. writable: true
  10977. });
  10978. } else {
  10979. obj[key] = value;
  10980. }
  10981. return obj;
  10982. }
  10983. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10984. if (!privateSet.has(receiver)) {
  10985. throw new TypeError('attempted to get private field on non-instance');
  10986. }
  10987. return fn;
  10988. }
  10989. var _addItem = new WeakSet();
  10990. class History extends website_Keylol {
  10991. constructor() {
  10992. super(...arguments);
  10993. History_classPrivateMethodInitSpec(this, _addItem);
  10994. History_defineProperty(this, 'name', 'History');
  10995. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10996. }
  10997. static test() {
  10998. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10999. }
  11000. before() {
  11001. try {
  11002. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  11003. const data = GM_listValues() || [];
  11004. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  11005. for (const item of tasksHistory) {
  11006. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  11007. }
  11008. } catch (error) {
  11009. throwError(error, 'History.before');
  11010. }
  11011. }
  11012. clearHistory() {
  11013. try {
  11014. const data = GM_listValues() || [];
  11015. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  11016. for (const item of tasksHistory) {
  11017. GM_deleteValue(item);
  11018. }
  11019. external_Swal_default().fire({
  11020. title: i18n('clearHistoryFinished'),
  11021. icon: 'success'
  11022. });
  11023. } catch (error) {
  11024. throwError(error, 'History.after');
  11025. }
  11026. }
  11027. }
  11028. function _addItem2(item) {
  11029. try {
  11030. const tasksData = GM_getValue(item);
  11031. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  11032. return;
  11033. }
  11034. let html = '';
  11035. let title = '';
  11036. let link = '';
  11037. const [ website, id ] = item.split('-');
  11038. switch (website) {
  11039. case 'fawTasks':
  11040. title = `Freeanywhere[${id}]`;
  11041. link = `https://freeanywhere.net/#/giveaway/${id}`;
  11042. break;
  11043.  
  11044. case 'gasTasks':
  11045. title = `Giveawaysu[${id}]`;
  11046. link = `https://giveaway.su/giveaway/view/${id}`;
  11047. break;
  11048.  
  11049. case 'gcTasks':
  11050. title = `GiveeClub[${id}]`;
  11051. link = `https://givee.club/event/${id}`;
  11052. break;
  11053.  
  11054. case 'gkTasks':
  11055. title = `Givekey[${id}]`;
  11056. link = `https://givekey.ru/giveaway/${id}`;
  11057. break;
  11058.  
  11059. case 'gleamTasks':
  11060. title = `Gleam[${id}]`;
  11061. link = `https://gleam.io${id}`;
  11062. break;
  11063.  
  11064. case 'khTasks':
  11065. title = `keyhub[${id}]`;
  11066. link = `https://key-hub.eu/giveaway/${id}`;
  11067. break;
  11068.  
  11069. case 'prysTasks':
  11070. title = `Prys[${id}]`;
  11071. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  11072. break;
  11073.  
  11074. default:
  11075. return;
  11076. }
  11077. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  11078. for (const [ type, tasks ] of Object.entries(types)) {
  11079. for (const task of tasks) {
  11080. 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>`;
  11081. }
  11082. }
  11083. }
  11084. $('.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>`);
  11085. $('span.delete-task').on('click', function() {
  11086. const itemName = $(this).attr('data-name');
  11087. if (itemName) {
  11088. GM_deleteValue(itemName);
  11089. $(`div.card[data-name="${itemName}"]`).remove();
  11090. external_Swal_default().fire({
  11091. title: i18n('clearTaskFinished'),
  11092. text: itemName,
  11093. icon: 'success'
  11094. });
  11095. } else {
  11096. external_Swal_default().fire({
  11097. title: i18n('clearTaskFailed'),
  11098. icon: 'error'
  11099. });
  11100. }
  11101. });
  11102. } catch (error) {
  11103. throwError(error, 'History.addItem');
  11104. }
  11105. }
  11106. const website_History = History;
  11107. 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 ];
  11108. const websiteOptions = function(website, options) {
  11109. try {
  11110. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  11111. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  11112. for (const [ option, value ] of Object.entries(options)) {
  11113. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  11114. }
  11115. websiteOptionsForm += '</tbody></table></form>';
  11116. external_Swal_default().fire({
  11117. title: i18n('websiteOptions'),
  11118. html: websiteOptionsForm,
  11119. showConfirmButton: true,
  11120. confirmButtonText: i18n('save'),
  11121. showCancelButton: true,
  11122. cancelButtonText: i18n('close')
  11123. }).then(_ref => {
  11124. let {
  11125. isConfirmed
  11126. } = _ref;
  11127. if (isConfirmed) {
  11128. $('#websiteOptionsForm').serializeArray().map(value => {
  11129. options[value.name] = value.value;
  11130. return value;
  11131. });
  11132. GM_setValue(`${website}Options`, options);
  11133. external_Swal_default().fire({
  11134. title: i18n('changeWebsiteOptionsSuccess'),
  11135. icon: 'success'
  11136. });
  11137. }
  11138. });
  11139. } catch (error) {
  11140. throwError(error, 'websiteOptions');
  11141. }
  11142. };
  11143. const options = websiteOptions;
  11144. const external_keyboardJS_namespaceObject = keyboardJS;
  11145. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  11146. const checkUpdate = async (updateLink, auto) => {
  11147. try {
  11148. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  11149. const {
  11150. result,
  11151. statusText,
  11152. status,
  11153. data
  11154. } = await tools_httpRequest({
  11155. url: checkUrl,
  11156. responseType: 'json',
  11157. method: 'GET',
  11158. timeout: 3e4
  11159. });
  11160. if (result === 'Success') {
  11161. var _data$response;
  11162. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  11163. return data.response;
  11164. }
  11165. if (!auto) {
  11166. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  11167. }
  11168. return false;
  11169. }
  11170. if (!auto) {
  11171. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  11172. }
  11173. return false;
  11174. } catch (error) {
  11175. throwError(error, 'checkUpdate');
  11176. return false;
  11177. }
  11178. };
  11179. const hasNewVersion = (currentVersion, remoteVersion) => {
  11180. try {
  11181. const [ currentRealVersion ] = currentVersion.split('-');
  11182. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  11183. if (isPreview && !globalOptions.other.receivePreview) {
  11184. return false;
  11185. }
  11186. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  11187. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  11188. if (remoteVersion1 > currentVersion1) {
  11189. return true;
  11190. }
  11191. if (remoteVersion1 < currentVersion1) {
  11192. return false;
  11193. }
  11194. if (remoteVersion2 > currentVersion2) {
  11195. return true;
  11196. }
  11197. if (remoteVersion2 < currentVersion2) {
  11198. return false;
  11199. }
  11200. if (remoteVersion3 > currentVersion3) {
  11201. return true;
  11202. }
  11203. return false;
  11204. } catch (error) {
  11205. throwError(error, 'compareVersion');
  11206. return false;
  11207. }
  11208. };
  11209. const updateChecker = async () => {
  11210. try {
  11211. const currentVersion = GM_info.script.version;
  11212. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  11213. const updateLinks = {
  11214. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  11215. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  11216. standby: 'https://auto-task-v4.hclonely.com/'
  11217. };
  11218. let version;
  11219. let updateLink = '';
  11220. let packageData;
  11221. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  11222. updateLink = updateLinks[updateSource];
  11223. packageData = await checkUpdate(updateLink, false);
  11224. } else {
  11225. updateLink = updateLinks.github;
  11226. packageData = await checkUpdate(updateLink, true);
  11227. if (!packageData) {
  11228. updateLink = updateLinks.jsdelivr;
  11229. packageData = await checkUpdate(updateLink, true);
  11230. if (!packageData) {
  11231. updateLink = updateLinks.standby;
  11232. packageData = await checkUpdate(updateLink, true);
  11233. }
  11234. }
  11235. }
  11236. if (packageData) {
  11237. version = packageData.version || currentVersion;
  11238. } else {
  11239. version = currentVersion;
  11240. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  11241. }
  11242. if (packageData && hasNewVersion(currentVersion, version)) {
  11243. var _packageData$change;
  11244. scripts_echoLog({
  11245. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  11246. });
  11247. scripts_echoLog({
  11248. 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>`
  11249. });
  11250. }
  11251. } catch (error) {
  11252. throwError(error, 'updateChecker');
  11253. }
  11254. };
  11255. const scripts_updateChecker = updateChecker;
  11256. var _globalOptions$other, _globalOptions$other2;
  11257. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  11258. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  11259. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  11260. const loadScript = async () => {
  11261. var _website, _website2, _website3, _website4, _website5, _website6;
  11262. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  11263. const authToken = external_Cookies_namespaceObject.get('auth-token');
  11264. const isLogin = !!external_Cookies_namespaceObject.get('login');
  11265. if (isLogin) {
  11266. var _commonOptions, _commonOptions$header, _commonOptions2, _commonOptions2$heade;
  11267. GM_setValue('twitchAuth', {
  11268. authToken: authToken,
  11269. clientVersion: __twilightBuildID,
  11270. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID'],
  11271. deviceId: (_commonOptions2 = commonOptions) === null || _commonOptions2 === void 0 ? void 0 : (_commonOptions2$heade = _commonOptions2.headers) === null || _commonOptions2$heade === void 0 ? void 0 : _commonOptions2$heade['Device-ID'],
  11272. clientSessionId: window.localStorage.local_storage_app_session_id.replace(/"/g, '')
  11273. });
  11274. window.close();
  11275. external_Swal_default().fire('', i18n('closePageNotice'));
  11276. } else {
  11277. external_Swal_default().fire('', i18n('needLogin'));
  11278. }
  11279. return;
  11280. }
  11281. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  11282. const ct0 = external_Cookies_namespaceObject.get('ct0');
  11283. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  11284. if (isLogin && ct0) {
  11285. GM_setValue('twitterAuth', {
  11286. ct0: ct0
  11287. });
  11288. window.close();
  11289. external_Swal_default().fire('', i18n('closePageNotice'));
  11290. } else {
  11291. external_Swal_default().fire('', i18n('needLogin'));
  11292. }
  11293. return;
  11294. }
  11295. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  11296. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  11297. if (PAPISID) {
  11298. GM_setValue('youtubeAuth', {
  11299. PAPISID: PAPISID
  11300. });
  11301. window.close();
  11302. external_Swal_default().fire('', i18n('closePageNotice'));
  11303. } else {
  11304. external_Swal_default().fire('', i18n('needLogin'));
  11305. }
  11306. return;
  11307. }
  11308. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11309. const betaButton = $('#redesign-beta-optin-btn');
  11310. if (betaButton.length > 0) {
  11311. GM_setValue('redditAuth', '#auth');
  11312. return betaButton[0].click();
  11313. }
  11314. GM_setValue('redditAuth', null);
  11315. window.close();
  11316. external_Swal_default().fire('', i18n('closePageNotice'));
  11317. return;
  11318. }
  11319. let website;
  11320. for (const Website of Websites) {
  11321. if (Website.test()) {
  11322. website = new Website();
  11323. break;
  11324. }
  11325. }
  11326. if (!website) {
  11327. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11328. return;
  11329. }
  11330. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11331. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11332. }
  11333. $('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>`);
  11334. $('div.show-button-div').on('click', () => {
  11335. $('#auto-task-buttons').show();
  11336. $('div.show-button-div').hide();
  11337. });
  11338. const toggleLog = () => {
  11339. const $this = $('#toggle-log');
  11340. const status = $this.attr('data-status');
  11341. if (status === 'show') {
  11342. $('#auto-task-info').hide();
  11343. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11344. } else {
  11345. $('#auto-task-info').show();
  11346. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11347. }
  11348. };
  11349. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11350. if (website.doTask) {
  11351. website.doTask();
  11352. }
  11353. });
  11354. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11355. if (website.undoTask) {
  11356. website.doTask();
  11357. }
  11358. });
  11359. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11360. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11361. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11362. }
  11363. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11364. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11365. for (const button of website.buttons) {
  11366. if (website[button]) {
  11367. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11368. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11369. website[button]();
  11370. });
  11371. $('#auto-task-buttons').append(btnElement);
  11372. }
  11373. }
  11374. }
  11375. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11376. ${i18n('hideButton')}</a></p>`);
  11377. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11378. $('#auto-task-buttons').hide();
  11379. $('div.show-button-div').show();
  11380. });
  11381. 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'}">
  11382. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11383. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11384. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11385. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11386. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11387. options(website.name, website.options);
  11388. });
  11389. }
  11390. if (website.name !== 'Setting') {
  11391. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11392. changeGlobalOptions('swal');
  11393. });
  11394. GM_registerMenuCommand(i18n('settingPage'), () => {
  11395. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11396. });
  11397. }
  11398. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11399. if (!GM_getValue('notice')) {
  11400. var _echoLog$font;
  11401. external_Swal_default().fire({
  11402. title: i18n('swalNotice'),
  11403. icon: 'warning'
  11404. }).then(() => {
  11405. window.open(i18n('noticeLink'), '_blank');
  11406. GM_setValue('notice', new Date().getTime());
  11407. });
  11408. (_echoLog$font = scripts_echoLog({
  11409. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11410. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11411. GM_setValue('notice', new Date().getTime());
  11412. });
  11413. }
  11414. scripts_updateChecker();
  11415. };
  11416. if (window.location.hostname === 'discord.com') {
  11417. const LocalStorage = window.localStorage;
  11418. if (window.location.hash === '#auth') {
  11419. var _LocalStorage$getItem;
  11420. window.localStorage.removeItem = () => true;
  11421. 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, '');
  11422. if (discordAuth && discordAuth.length > 0) {
  11423. GM_setValue('discordAuth', {
  11424. auth: discordAuth
  11425. });
  11426. window.close();
  11427. external_Swal_default().fire('', i18n('closePageNotice'));
  11428. } else {
  11429. external_Swal_default().fire({
  11430. text: i18n('getDiscordAuthFailed'),
  11431. icon: 'error'
  11432. });
  11433. }
  11434. } else {
  11435. var _LocalStorage$getItem2;
  11436. 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, '');
  11437. if (discordAuth && discordAuth.length > 0) {
  11438. GM_setValue('discordAuth', {
  11439. auth: discordAuth
  11440. });
  11441. }
  11442. }
  11443. } else if (window.location.hostname === 'opquests.com') {
  11444. loadScript();
  11445. } else {
  11446. if (window.location.hostname === 'key-hub.eu') {
  11447. unsafeWindow.keyhubtracker = 1;
  11448. unsafeWindow.gaData = {};
  11449. }
  11450. $(loadScript);
  11451. }
  11452. }();
  11453. })();