auto-task-v4

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

当前为 2022-09-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.20
  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 twitter.com
  53. // @connect api.twitter.com
  54. // @connect youtube.com
  55. // @connect www.youtube.com
  56. // @connect facebook.com
  57. // @connect instagram.com
  58. // @connect vk.com
  59. // @connect twitch.tv
  60. // @connect www.twitch.tv
  61. // @connect gql.twitch.tv
  62. // @connect github.com
  63. // @connect discordapp.com
  64. // @connect discord.gg
  65. // @connect discord.com
  66. // @connect www.reddit.com
  67. // @connect oauth.reddit.com
  68. // @connect raw.githubusercontent.com
  69. // @connect t.me
  70. // @connect bit.ly
  71. // @connect giveaway.su
  72. // @connect google.com
  73. // @connect www.vloot.io
  74. // @connect givee.club
  75. // @connect gleam.io
  76. // @connect www.indiedb.com
  77. // @connect key-hub.eu
  78. // @connect opquests.com
  79. // @connect itch.io
  80. // @connect auto-task-v4.hclonely.com
  81. // @connect *
  82. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  83. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  84. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  85. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  86. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  87. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  88. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  89. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  90.  
  91. // @noframes
  92. // ==/UserScript==
  93.  
  94. console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
  95.  
  96. (function() {
  97. var __webpack_modules__ = {
  98. 588: function(__unused_webpack_module, exports) {
  99. !function(e, n) {
  100. true ? n(exports) : 0;
  101. }(this, function(e) {
  102. 'use strict';
  103. var t = function() {
  104. return (t = Object.assign || function(e) {
  105. for (var n, o = 1, t = arguments.length; o < t; o++) {
  106. for (var r in n = arguments[o]) {
  107. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  108. }
  109. }
  110. return e;
  111. }).apply(this, arguments);
  112. };
  113. function r(e, n, o) {
  114. if (o || 2 === arguments.length) {
  115. for (var t, r = 0, i = n.length; r < i; r++) {
  116. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  117. }
  118. }
  119. return e.concat(t || Array.prototype.slice.call(n));
  120. }
  121. function d(e) {
  122. return '[object Object]' === n(e);
  123. }
  124. function l(e, n) {
  125. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  126. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  127. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  128. });
  129. }
  130. var n = function(e) {
  131. return Object.prototype.toString.call(e);
  132. };
  133. var o = (i.prototype.init = function() {
  134. try {
  135. this.getSystemName(), this.getBrowserName();
  136. } catch (e) {
  137. console.warn('[UA formatter error] '.concat(e));
  138. }
  139. }, i.prototype.getEngine = function() {
  140. var e = this.agent;
  141. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  142. }, i.prototype.getSystemName = function() {
  143. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  144. try {
  145. var o = '';
  146. if (/Windows/i.test(n)) {
  147. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  148. switch (this.info.os = 'Windows', t) {
  149. case '6.3':
  150. o = '8.1';
  151. break;
  152.  
  153. case '6.2':
  154. o = '8';
  155. break;
  156.  
  157. case '6.1':
  158. o = '7';
  159. break;
  160.  
  161. case '5.2':
  162. case '5.1':
  163. o = 'XP';
  164. break;
  165.  
  166. default:
  167. o = t;
  168. }
  169. return this.info.device = 'PC', void (this.info.osVersion = o);
  170. }
  171. if (/^Macintosh/i.test(n)) {
  172. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  173. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  174. }
  175. if (/^iPad/i.test(n)) {
  176. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  177. void (this.info.osVersion = o.replace(/_/g, '.'));
  178. }
  179. if (/^iPhone/i.test(n)) {
  180. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  181. void (this.info.osVersion = o.replace(/_/g, '.'));
  182. }
  183. if (-1 !== n.indexOf('Android')) {
  184. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  185. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  186. }
  187. if (/Linux\s[a-z\d_]+/.test(n)) {
  188. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  189. }
  190. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  191. } catch (e) {
  192. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  193. }
  194. }, i.prototype.getBrowserName = function() {
  195. var e = Object.keys(this.browserNameMap).map(function(e) {
  196. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  197. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  198. return -1 !== e.findIndex(function(e) {
  199. return e.test(n);
  200. });
  201. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  202. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  203. }, i.prototype._formatBrowserVersion = function(e) {
  204. var n, o, t, r;
  205. try {
  206. 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++) {
  207. var d = u[f], l = d[0], h = d[1];
  208. if (new RegExp(l).test(s)) {
  209. c = h;
  210. break;
  211. }
  212. }
  213. var p = {
  214. browserVersion: null != a ? a : 'Unknown',
  215. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  216. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  217. };
  218. return 'Trident' === s && (p.browserVersion = {
  219. '4.0': 8,
  220. '5.0': 9,
  221. '6.0': 10,
  222. '7.0': 11
  223. }[a]), p;
  224. } catch (e) {
  225. return console.warn('[UA formatter error] '.concat(e)), {
  226. browser: 'Unknown',
  227. browserVersion: 'Unknown'
  228. };
  229. }
  230. }, i);
  231. function i(e) {
  232. this.agent = '', this.info = {
  233. browser: '',
  234. browserZH: '',
  235. browserVersion: '',
  236. os: '',
  237. osVersion: '',
  238. device: 'Unknown',
  239. engine: 'WebKit'
  240. }, this.browserNameMap = {
  241. MicroMessenger: {
  242. en: 'MicroMessenger',
  243. zh: '微信'
  244. },
  245. MetaSr: {
  246. en: 'MetaSr',
  247. zh: '搜狗浏览器'
  248. },
  249. 'QQ(Browser)?': {
  250. en: 'QQBrowser',
  251. zh: 'QQ浏览器'
  252. },
  253. UCBrowser: {
  254. en: 'UCBrowser',
  255. zh: 'UC浏览器'
  256. },
  257. '2345Explorer': {
  258. en: '2345Explorer',
  259. zh: '2345极速浏览器'
  260. },
  261. Mb2345Browser: {
  262. en: 'Mb2345Browser',
  263. zh: '2345手机浏览器'
  264. },
  265. Trident: {
  266. en: 'Internet Explorer'
  267. },
  268. 'Edge?': {
  269. en: 'Edge'
  270. },
  271. OPR: {
  272. en: 'Opera'
  273. },
  274. Vivaldi: {
  275. en: 'Vivaldi'
  276. },
  277. Firefox: {
  278. en: 'Firefox'
  279. },
  280. Chrome: {
  281. en: 'Chrome'
  282. },
  283. Safari: {
  284. en: 'Safari'
  285. }
  286. }, this.agent = e, this.init();
  287. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  288. this.info = t(t({}, this.info), {
  289. engine: this.getEngine(),
  290. browserVersion: 'Safari' === o ? n : e
  291. });
  292. }
  293. function s() {
  294. this.cookies = {}, this.init();
  295. }
  296. var a = new (s.prototype.init = function() {
  297. var o = {};
  298. document.cookie.split(/;\s/).forEach(function(e) {
  299. var n = e.split(/=/), e = n[0], n = n[1];
  300. o[e] = n;
  301. }), this.cookies = o;
  302. }, s.prototype.getItem = function(e) {
  303. return this.cookies[e];
  304. }, s.prototype.getAllItems = function() {
  305. return this.cookies;
  306. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  307. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  308. }, s)();
  309. e.countDown = function e(n, o, t, r) {
  310. if (!window) {
  311. throw new Error('window is not defind.');
  312. }
  313. if (0 < n) {
  314. return r && r(), n--, window[o] = window.setTimeout(function() {
  315. e(n, o, t, r);
  316. }, 1e3), function() {
  317. return clearTimeout(window[o]);
  318. };
  319. }
  320. clearTimeout(window[o]), t && t();
  321. }, e.createRandomID = function(e) {
  322. void 0 === e && (e = 12);
  323. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  324. n.push(o[Math.round(Math.random() * t)]);
  325. }
  326. return n.join('');
  327. }, e.dCookie = a, e.debounce = function(o, t, r) {
  328. var i;
  329. void 0 === t && (t = 0);
  330. var s = r = void 0 === r ? !1 : r;
  331. return function() {
  332. var e = this, n = arguments;
  333. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  334. r ? s = !0 : o.apply(e, n);
  335. }, t);
  336. };
  337. }, e.deepCopy = function e(n) {
  338. if (d(n) || Array.isArray(n)) {
  339. var o, t = Array.isArray(n) ? [] : {};
  340. for (o in n) {
  341. t[o] = e(n[o]);
  342. }
  343. return t;
  344. }
  345. return n;
  346. }, e.formatQueryParams = function(e) {
  347. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  348. if (!e) {
  349. return {};
  350. }
  351. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  352. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  353. return t[n] = o, e;
  354. });
  355. }
  356. return t;
  357. }, e.formatThousandth = function(e) {
  358. 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, '$&,');
  359. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  360. }, e.generateTree = function e(n, o, t, r) {
  361. for (var i = [], s = 0; s < n.length; s++) {
  362. var a = n[s];
  363. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  364. }
  365. return i;
  366. }, e.isEmpty = function(e) {
  367. 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);
  368. }, e.isFunction = function(e) {
  369. return '[object Function]' === n(e);
  370. }, e.isImageUrl = function(e) {
  371. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  372. }, e.isObject = d, e.isRegexp = function(e) {
  373. return '[object RegExp]' === n(e);
  374. }, e.objectKeyToCamelCase = function e(n, o, t) {
  375. if (Array.isArray(n)) {
  376. for (var r = [], i = 0; i < n.length; i++) {
  377. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  378. }
  379. } else if (d(n)) {
  380. r = {};
  381. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  382. var f = (u = c[a])[0], u = u[1];
  383. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  384. }
  385. } else {
  386. r = n;
  387. }
  388. return r;
  389. }, e.realType = n, e.searchParams = function(e, n) {
  390. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  391. new URLSearchParams(e).get(n);
  392. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  393. return e.replace(/([A-Z])/g, function(e) {
  394. return '_'.concat(e.toLocaleLowerCase());
  395. });
  396. }, e.ua = function(e) {
  397. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  398. }, Object.defineProperty(e, '__esModule', {
  399. value: !0
  400. });
  401. });
  402. },
  403. 301: function(module, __webpack_exports__, __webpack_require__) {
  404. 'use strict';
  405. __webpack_require__.d(__webpack_exports__, {
  406. Z: function() {
  407. return __WEBPACK_DEFAULT_EXPORT__;
  408. }
  409. });
  410. 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);
  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___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__);
  412. 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);
  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___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__);
  414. 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());
  415. ___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}', '' ]);
  416. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  417. },
  418. 400: function(module) {
  419. 'use strict';
  420. module.exports = function(cssWithMappingToString) {
  421. var list = [];
  422. list.toString = function toString() {
  423. return this.map(function(item) {
  424. var content = '';
  425. var needLayer = typeof item[5] !== 'undefined';
  426. if (item[4]) {
  427. content += '@supports ('.concat(item[4], ') {');
  428. }
  429. if (item[2]) {
  430. content += '@media '.concat(item[2], ' {');
  431. }
  432. if (needLayer) {
  433. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  434. }
  435. content += cssWithMappingToString(item);
  436. if (needLayer) {
  437. content += '}';
  438. }
  439. if (item[2]) {
  440. content += '}';
  441. }
  442. if (item[4]) {
  443. content += '}';
  444. }
  445. return content;
  446. }).join('');
  447. };
  448. list.i = function i(modules, media, dedupe, supports, layer) {
  449. if (typeof modules === 'string') {
  450. modules = [ [ null, modules, undefined ] ];
  451. }
  452. var alreadyImportedModules = {};
  453. if (dedupe) {
  454. for (var k = 0; k < this.length; k++) {
  455. var id = this[k][0];
  456. if (id != null) {
  457. alreadyImportedModules[id] = true;
  458. }
  459. }
  460. }
  461. for (var _k = 0; _k < modules.length; _k++) {
  462. var item = [].concat(modules[_k]);
  463. if (dedupe && alreadyImportedModules[item[0]]) {
  464. continue;
  465. }
  466. if (typeof layer !== 'undefined') {
  467. if (typeof item[5] === 'undefined') {
  468. item[5] = layer;
  469. } else {
  470. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  471. item[5] = layer;
  472. }
  473. }
  474. if (media) {
  475. if (!item[2]) {
  476. item[2] = media;
  477. } else {
  478. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  479. item[2] = media;
  480. }
  481. }
  482. if (supports) {
  483. if (!item[4]) {
  484. item[4] = ''.concat(supports);
  485. } else {
  486. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  487. item[4] = supports;
  488. }
  489. }
  490. list.push(item);
  491. }
  492. };
  493. return list;
  494. };
  495. },
  496. 220: function(module) {
  497. 'use strict';
  498. module.exports = function(i) {
  499. return i[1];
  500. };
  501. }
  502. };
  503. var __webpack_module_cache__ = {};
  504. function __webpack_require__(moduleId) {
  505. var cachedModule = __webpack_module_cache__[moduleId];
  506. if (cachedModule !== undefined) {
  507. return cachedModule.exports;
  508. }
  509. var module = __webpack_module_cache__[moduleId] = {
  510. id: moduleId,
  511. exports: {}
  512. };
  513. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  514. return module.exports;
  515. }
  516. !function() {
  517. __webpack_require__.n = function(module) {
  518. var getter = module && module.__esModule ? function() {
  519. return module['default'];
  520. } : function() {
  521. return module;
  522. };
  523. __webpack_require__.d(getter, {
  524. a: getter
  525. });
  526. return getter;
  527. };
  528. }();
  529. !function() {
  530. __webpack_require__.d = function(exports, definition) {
  531. for (var key in definition) {
  532. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  533. Object.defineProperty(exports, key, {
  534. enumerable: true,
  535. get: definition[key]
  536. });
  537. }
  538. }
  539. };
  540. }();
  541. !function() {
  542. __webpack_require__.o = function(obj, prop) {
  543. return Object.prototype.hasOwnProperty.call(obj, prop);
  544. };
  545. }();
  546. var __webpack_exports__ = {};
  547. !function() {
  548. 'use strict';
  549. const external_Swal_namespaceObject = Swal;
  550. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  551. const external_Cookies_namespaceObject = Cookies;
  552. var auto_task = __webpack_require__(301);
  553. var javascript_utils_umd_min = __webpack_require__(588);
  554. const httpRequest = async function(options) {
  555. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  556. if (window.TRACE) {
  557. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  558. }
  559. try {
  560. const result = await new Promise(resolve => {
  561. if (options.dataType) {
  562. options.responseType = options.dataType;
  563. }
  564. const requestObj = {
  565. ...{
  566. timeout: 3e4,
  567. ontimeout(data) {
  568. resolve({
  569. result: 'Error',
  570. statusText: 'Timeout',
  571. status: 601,
  572. data: data,
  573. options: options
  574. });
  575. },
  576. onabort(data) {
  577. resolve({
  578. result: 'Error',
  579. statusText: 'Aborted',
  580. status: 602,
  581. data: data,
  582. options: options
  583. });
  584. },
  585. onerror(data) {
  586. resolve({
  587. result: 'Error',
  588. statusText: 'Error',
  589. status: 603,
  590. data: data,
  591. options: options
  592. });
  593. },
  594. onload(data) {
  595. resolve({
  596. result: 'Success',
  597. statusText: 'Load',
  598. status: 600,
  599. data: data,
  600. options: options
  601. });
  602. }
  603. },
  604. ...options
  605. };
  606. GM_xmlhttpRequest(requestObj);
  607. });
  608. if (window.DEBUG) {
  609. console.log('%cAuto-Task[httpRequest]:', 'color:blue', JSON.stringify(result));
  610. }
  611. if (result.status !== 600 && times < 2) {
  612. return await httpRequest(options, times + 1);
  613. }
  614. return result;
  615. } catch (error) {
  616. console.log('%cAuto-Task[httpRequest]:', 'color:red', JSON.stringify({
  617. errorMsg: error,
  618. options: options
  619. }));
  620. throwError(error, 'httpRequest');
  621. return {
  622. result: 'JsError',
  623. statusText: 'Error',
  624. status: 604,
  625. error: error,
  626. options: options
  627. };
  628. }
  629. };
  630. const tools_httpRequest = httpRequest;
  631. const echoLog = _ref => {
  632. let {
  633. type,
  634. text,
  635. html,
  636. id
  637. } = _ref;
  638. const emptyStatus = {
  639. success: () => emptyStatus,
  640. error: () => emptyStatus,
  641. warning: () => emptyStatus,
  642. info: () => emptyStatus,
  643. view: () => emptyStatus
  644. };
  645. try {
  646. var _ele$;
  647. let ele;
  648. if (type) {
  649. switch (type) {
  650. case 'joiningSteamGroup':
  651. case 'leavingSteamGroup':
  652. case 'gettingSteamGroupId':
  653. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  654. break;
  655.  
  656. case 'joiningSteamOfficialGroup':
  657. case 'leavingSteamOfficialGroup':
  658. case 'gettingSteamOfficialGroupId':
  659. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/games/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  660. break;
  661.  
  662. case 'subscribingForum':
  663. case 'unsubscribingForum':
  664. case 'gettingForumId':
  665. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>]...<font></font></li>`);
  666. break;
  667.  
  668. case 'followingCurator':
  669. case 'unfollowingCurator':
  670. case 'getCuratorId':
  671. 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>`);
  672. break;
  673.  
  674. case 'addingToWishlist':
  675. case 'removingFromWishlist':
  676. case 'followingGame':
  677. case 'unfollowingGame':
  678. case 'gettingSubid':
  679. case 'addingFreeLicense':
  680. case 'requestingPlayTestAccess':
  681. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  682. break;
  683.  
  684. case 'addingFreeLicenseSubid':
  685. ele = $(`<li>${i18n('addingFreeLicense')}[<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  686. break;
  687.  
  688. case 'favoritingWorkshop':
  689. case 'unfavoritingWorkshop':
  690. case 'gettingWorkshopAppId':
  691. case 'votingUpWorkshop':
  692. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  693. ${text}</a>]...<font></font></li>`);
  694. break;
  695.  
  696. case 'gettingAnnouncementParams':
  697. case 'likingAnnouncement':
  698. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  699. ${id}</a>]...<font></font></li>`);
  700. break;
  701.  
  702. case 'joiningDiscordServer':
  703. case 'gettingDiscordGuild':
  704. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  705. break;
  706.  
  707. case 'leavingDiscordServer':
  708. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  709. break;
  710.  
  711. case 'updateDiscordAuth':
  712. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  713. break;
  714.  
  715. case 'followingTwitchChannel':
  716. case 'unfollowingTwitchChannel':
  717. case 'gettingTwitchChannelId':
  718. ele = $(`<li>${i18n(type)}[<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  719. break;
  720.  
  721. case 'gettingInsUserId':
  722. case 'followingIns':
  723. case 'unfollowingIns':
  724. ele = $(`<li>${i18n(type)}[<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  725. break;
  726.  
  727. case 'gettingTwitterUserId':
  728. case 'followingTwitterUser':
  729. case 'unfollowingTwitterUser':
  730. ele = $(`<li>${i18n(type)}[<a href="https://twitter.com/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  731. break;
  732.  
  733. case 'retweetting':
  734. case 'unretweetting':
  735. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  736. break;
  737.  
  738. case 'joiningReddit':
  739. case 'leavingReddit':
  740. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  741. break;
  742.  
  743. case 'followingRedditUser':
  744. case 'unfollowingRedditUser':
  745. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  746. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>]...<font></font></li>`);
  747. break;
  748.  
  749. case 'followingYtbChannel':
  750. case 'unfollowingYtbChannel':
  751. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  752. break;
  753.  
  754. case 'likingYtbVideo':
  755. case 'unlikingYtbVideo':
  756. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>]...<font></font></li>`);
  757. break;
  758.  
  759. case 'gettingVkId':
  760. case 'joiningVkGroup':
  761. case 'leavingVkGroup':
  762. case 'joiningVkPublic':
  763. case 'leavingVkPublic':
  764. case 'sendingVkWall':
  765. case 'deletingVkWall':
  766. ele = $(`<li>${i18n(type)}[<a href="https://vk.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  767. break;
  768.  
  769. case 'visitingLink':
  770. ele = $(`<li>${i18n('visitingLink')}[<a href="${text}" target="_blank">${text}</a>]...<font></font></li>`);
  771. break;
  772.  
  773. case 'verifyingInsAuth':
  774. case 'text':
  775. ele = $(`<li>${i18n(text)}<font></font></li>`);
  776. break;
  777.  
  778. case 'html':
  779. ele = $(text || html);
  780. break;
  781.  
  782. case 'whiteList':
  783. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  784. break;
  785.  
  786. case 'globalOptionsSkip':
  787. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  788. break;
  789.  
  790. default:
  791. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  792. break;
  793. }
  794. } else if (text) {
  795. ele = $(`<li>${i18n(text)}<font></font></li>`);
  796. } else if (html) {
  797. ele = $(html);
  798. } else {
  799. ele = $('<li><font></font></li>');
  800. }
  801. ele.addClass('card-text');
  802. $('#auto-task-info').append(ele);
  803. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  804. const font = ele.find('font');
  805. const status = {
  806. font: font,
  807. success() {
  808. var _this$font, _this$font2, _this$font3;
  809. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  810. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  811. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  812. 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);
  813. return this;
  814. },
  815. error() {
  816. var _this$font4, _this$font5, _this$font6;
  817. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  818. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  819. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  820. 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);
  821. return this;
  822. },
  823. warning() {
  824. var _this$font7, _this$font8, _this$font9;
  825. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  826. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  827. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  828. 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);
  829. return this;
  830. },
  831. info() {
  832. var _this$font10, _this$font11, _this$font12;
  833. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  834. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  835. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  836. 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);
  837. return this;
  838. },
  839. view() {
  840. var _this$font13;
  841. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  842. return this;
  843. }
  844. };
  845. return status;
  846. } catch (error) {
  847. throwError(error, 'echoLog');
  848. return emptyStatus;
  849. }
  850. };
  851. const scripts_echoLog = echoLog;
  852. const unique = array => {
  853. try {
  854. return [ ...new Set(array) ];
  855. } catch (error) {
  856. throwError(error, 'unique');
  857. return [];
  858. }
  859. };
  860. const delay = function() {
  861. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  862. return new Promise(resolve => {
  863. setTimeout(() => {
  864. resolve(true);
  865. }, time);
  866. });
  867. };
  868. const getRedirectLink = async link => {
  869. try {
  870. if (!link) {
  871. return null;
  872. }
  873. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  874. if (redirectLinksCache[link]) {
  875. redirectLinksCache[link];
  876. }
  877. return await tools_httpRequest({
  878. url: link,
  879. method: 'GET'
  880. }).then(_ref => {
  881. let {
  882. data
  883. } = _ref;
  884. if (data !== null && data !== void 0 && data.finalUrl) {
  885. redirectLinksCache[link] = data.finalUrl;
  886. GM_setValue('redirectLinks', redirectLinksCache);
  887. return data.finalUrl;
  888. }
  889. return null;
  890. });
  891. } catch (error) {
  892. throwError(error, 'getRedirectLink');
  893. return null;
  894. }
  895. };
  896. const visitLink = async (link, options) => {
  897. try {
  898. const logStatus = scripts_echoLog({
  899. type: 'visitLink',
  900. text: link
  901. });
  902. return await tools_httpRequest({
  903. url: link,
  904. method: 'GET',
  905. ...options
  906. }).then(_ref2 => {
  907. let {
  908. result,
  909. statusText,
  910. status
  911. } = _ref2;
  912. if (result === 'Success') {
  913. logStatus.success();
  914. return true;
  915. }
  916. logStatus.error(`${result}:${statusText}(${status})`);
  917. return false;
  918. });
  919. } catch (error) {
  920. throwError(error, 'visitLink');
  921. return false;
  922. }
  923. };
  924. const getUrlQuery = url => {
  925. try {
  926. const query = {};
  927. if (url) {
  928. if (url.includes('?')) {
  929. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  930. query[key] = value;
  931. return str;
  932. });
  933. }
  934. } else {
  935. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  936. query[key] = value;
  937. return str;
  938. });
  939. }
  940. return query;
  941. } catch (error) {
  942. throwError(error, 'getUrlQuery');
  943. return {};
  944. }
  945. };
  946. const getUuid = () => {
  947. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  948. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  949. };
  950. const stringToColour = str => {
  951. try {
  952. let hash = 0;
  953. for (let i = 0; i < str.length; i++) {
  954. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  955. }
  956. let colour = '#';
  957. for (let i = 0; i < 3; i++) {
  958. const value = hash >> i * 8 & 255;
  959. colour += `00${value.toString(16)}`.slice(-2);
  960. }
  961. return colour;
  962. } catch (error) {
  963. throwError(error, 'stringToColour');
  964. return '#fff';
  965. }
  966. };
  967. const defaultGlobalOptions = {
  968. doTask: {
  969. discord: {
  970. servers: true
  971. },
  972. instagram: {
  973. users: true
  974. },
  975. twitch: {
  976. channels: true
  977. },
  978. twitter: {
  979. users: true,
  980. retweets: true
  981. },
  982. vk: {
  983. names: true
  984. },
  985. youtube: {
  986. channels: true,
  987. likes: true
  988. },
  989. reddit: {
  990. reddits: true
  991. },
  992. steam: {
  993. groups: true,
  994. officialGroups: true,
  995. wishlists: true,
  996. follows: true,
  997. forums: true,
  998. workshops: true,
  999. curators: true,
  1000. workshopVotes: true,
  1001. announcements: true,
  1002. licenses: true,
  1003. playtests: true
  1004. }
  1005. },
  1006. undoTask: {
  1007. discord: {
  1008. servers: true
  1009. },
  1010. instagram: {
  1011. users: true
  1012. },
  1013. twitch: {
  1014. channels: true
  1015. },
  1016. twitter: {
  1017. users: true,
  1018. retweets: true
  1019. },
  1020. vk: {
  1021. names: true
  1022. },
  1023. youtube: {
  1024. channels: true,
  1025. likes: true
  1026. },
  1027. reddit: {
  1028. reddits: true
  1029. },
  1030. steam: {
  1031. groups: true,
  1032. officialGroups: true,
  1033. wishlists: true,
  1034. follows: true,
  1035. forums: true,
  1036. workshops: true,
  1037. curators: true
  1038. }
  1039. },
  1040. position: {
  1041. buttonSideX: 'right',
  1042. buttonSideY: 'top',
  1043. buttonDistance: '15,30',
  1044. showButtonSideX: 'right',
  1045. showButtonSideY: 'top',
  1046. showButtonDistance: '15,30',
  1047. logSideX: 'right',
  1048. logSideY: 'bottom',
  1049. logDistance: '10,10'
  1050. },
  1051. hotKey: {
  1052. doTaskKey: 'alt + d',
  1053. undoTaskKey: 'alt + u',
  1054. toggleLogKey: 'alt + l'
  1055. },
  1056. other: {
  1057. twitterVerifyId: '783214',
  1058. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1059. autoUpdateSource: 'jsdelivr',
  1060. language: 'zh',
  1061. checkLogin: true,
  1062. checkLeftKey: true,
  1063. defaultShowButton: true,
  1064. defaultShowLog: true,
  1065. debug: false,
  1066. receivePreview: true
  1067. }
  1068. };
  1069. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1070. const assignObject = (obj1, obj2) => {
  1071. try {
  1072. const newObj = {};
  1073. for (const [ key, value ] of Object.entries(obj1)) {
  1074. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1075. newObj[key] = assignObject(value, obj2[key]);
  1076. } else {
  1077. newObj[key] = obj2[key] ?? value;
  1078. }
  1079. }
  1080. return newObj;
  1081. } catch (error) {
  1082. throwError(error, 'assignObject');
  1083. return defaultGlobalOptions;
  1084. }
  1085. };
  1086. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1087. const saveData = () => {
  1088. try {
  1089. const data = {};
  1090. $('#globalOptionsForm').serializeArray().map(value => {
  1091. data[value.name] = value.value;
  1092. return value;
  1093. });
  1094. $.makeArray($('#globalOptionsForm input')).map(element => {
  1095. const name = $(element).attr('name');
  1096. const keys = name.split('.');
  1097. if (keys.length === 3) {
  1098. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1099. } else if (keys.length === 2) {
  1100. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1101. }
  1102. return element;
  1103. });
  1104. GM_setValue('globalOptions', globalOptions);
  1105. external_Swal_default().fire({
  1106. title: i18n('changeGlobalOptionsSuccess'),
  1107. icon: 'success'
  1108. });
  1109. } catch (error) {
  1110. throwError(error, 'saveData');
  1111. }
  1112. };
  1113. const changeGlobalOptions = showType => {
  1114. try {
  1115. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1116. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1117. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1118. for (const [ option, data2 ] of Object.entries(data1)) {
  1119. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1120. if (typeof data2 === 'boolean') {
  1121. 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>`;
  1122. } else {
  1123. 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>`;
  1124. }
  1125. } else {
  1126. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1127. 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>`;
  1128. }
  1129. }
  1130. }
  1131. }
  1132. globalOptionsForm += '</tbody></table></form>';
  1133. if (showType === 'swal') {
  1134. external_Swal_default().fire({
  1135. title: i18n('globalOptions'),
  1136. html: globalOptionsForm,
  1137. showConfirmButton: true,
  1138. confirmButtonText: i18n('save'),
  1139. showCancelButton: true,
  1140. cancelButtonText: i18n('close')
  1141. }).then(_ref => {
  1142. let {
  1143. isConfirmed
  1144. } = _ref;
  1145. if (isConfirmed) {
  1146. saveData();
  1147. }
  1148. });
  1149. } else {
  1150. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1151. }
  1152. } catch (error) {
  1153. throwError(error, 'changeGlobalOptions');
  1154. }
  1155. };
  1156. const data = {
  1157. website: '网站',
  1158. type: '类型',
  1159. edit: '编辑',
  1160. whiteList: '白名单',
  1161. skipTask: '跳过撤销任务',
  1162. whiteListOptions: '白名单设置',
  1163. changeWhiteListOption: '设置白名单(%0)',
  1164. whiteListNotFound: '找不到此项白名单: %0',
  1165. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1166. changeWebsiteOptions: '网站设置',
  1167. changeGlobalOptions: '全局设置',
  1168. ok: '是',
  1169. save: '保存',
  1170. close: '关闭',
  1171. return: '返回',
  1172. option: '选项',
  1173. value: '值',
  1174. websiteOptions: '当前网站设置',
  1175. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1176. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1177. needLogin: '请先登录!',
  1178. getTasksInfo: '正在获取并处理任务信息...',
  1179. gettingKey: '正在获取Key...',
  1180. verifyingTask: '正在验证任务',
  1181. notice: '自动任务脚本提醒',
  1182. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1183. giveawayEnded: '此活动已结束,是否关闭?',
  1184. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1185. confirm: '确定',
  1186. cancel: '取消',
  1187. unKnown: '未知',
  1188. unKnownTaskType: '未识别的任务',
  1189. doing: '正在做任务',
  1190. allTasksComplete: '所有任务已完成!',
  1191. getTaskIdFailed: '获取任务Id失败!',
  1192. initSuccess: '%0 初始化成功!',
  1193. initFailed: '%0 初始化失败!',
  1194. errorLink: '链接错误: %0',
  1195. needInit: '请先初始化',
  1196. verifyingAuth: '正在验证%0凭证...',
  1197. updatingAuth: '正在更新%0凭证...',
  1198. initing: '正在初始化...',
  1199. getFailed: '获取%0失败!',
  1200. checkLoginFailed: '检测登录状态失败!',
  1201. checkLeftKeyFailed: '检测剩余Key失败!',
  1202. userId: '用户Id',
  1203. joiningGiveaway: '正在加入赠Key',
  1204. needJoinGiveaway: '需要先加入赠Key',
  1205. cannotUndo: '此网站不支持取消任务',
  1206. verifyAuth: '正在验证 %0 凭证...',
  1207. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1208. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1209. visitingLink: '正在访问链接: ',
  1210. doTask: '做任务',
  1211. undoTask: '撤销任务',
  1212. verifyTask: '验证任务',
  1213. getKey: '获取Key',
  1214. selectAll: '全选',
  1215. selectNone: '全不选',
  1216. invertSelect: '反选',
  1217. doFreeTask: '加入免费赠品',
  1218. doPointTask: '加入点数赠品',
  1219. skipTaskOption: '设置中已配置跳过任务',
  1220. other: '其他',
  1221. globalOptions: '全局设置',
  1222. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1223. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1224. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1225. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1226. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1227. saveGlobalOptions: '保存全局设置',
  1228. settingPage: '设置页面',
  1229. name: '名称',
  1230. version: '版本',
  1231. scriptManager: '脚本管理器',
  1232. script: '脚本',
  1233. environment: '环境',
  1234. os: '系统',
  1235. browser: '浏览器',
  1236. getId: '获取 %0 id',
  1237. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1238. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1239. showButton: '显示按钮',
  1240. hideButton: '隐藏按钮',
  1241. showLog: '显示日志',
  1242. hideLog: '隐藏日志',
  1243. defaultShowButton: '默认显示按钮',
  1244. defaultShowLog: '默认显示日志',
  1245. debug: '输出调试日志,不要开启此选项!',
  1246. receivePreview: '接收预览版更新',
  1247. position: '组件位置',
  1248. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1249. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1250. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1251. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1252. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1253. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1254. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1255. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1256. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1257. hotKey: '快捷键',
  1258. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1259. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1260. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1261. tasksHistory: '任务历史',
  1262. clearHistory: '清空历史',
  1263. clearHistoryFinished: '已清空任务历史!',
  1264. deleteTask: '删除任务',
  1265. lastChangeTime: '最后一次修改时间',
  1266. clearTaskFinished: '删除以下任务完成!',
  1267. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1268. syncData: '数据同步',
  1269. settingData: '正在上传数据...',
  1270. gettingData: '正在获取数据...',
  1271. help: '帮助',
  1272. fileName: '文件名',
  1273. upload2gist: '同步到Gist',
  1274. downloadFromGist: '从Gist同步',
  1275. saveAndTest: '保存配置并测试',
  1276. testSuccess: '测试成功!',
  1277. testFailed: '测试失败!',
  1278. saveAndTestNotice: '请先保存配置并测试!',
  1279. processingData: '正在处理数据...',
  1280. updatingData: '正在上传数据...',
  1281. syncDataSuccess: '同步数据成功!',
  1282. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1283. downloadingData: '正在下载数据...',
  1284. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1285. savingData: '正在保存数据...',
  1286. syncHistory: '同步任务历史',
  1287. checkUpdateFailed: '检测更新失败',
  1288. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1289. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1290. gistOptions: 'Gist 设置',
  1291. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1292. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1293. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1294. toGithub: '前往Github反馈',
  1295. toKeylol: '前往其乐论坛反馈',
  1296. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1297. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1298. updateText: '%0 版本更新内容:',
  1299. Active: '进行中',
  1300. Ended: '已结束',
  1301. Banned: '已封禁',
  1302. Paused: '已暂停',
  1303. notStart: '未开始',
  1304. noRemoteData: '检测到远程无数据',
  1305. errorRemoteDataFormat: '远程数据格式错误',
  1306. updateHistory: '历史更新记录<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">点此查看</a>',
  1307. groups: '组',
  1308. officialGroups: '官方组',
  1309. wishlists: '愿望单',
  1310. follows: '游戏关注',
  1311. forums: '论坛',
  1312. workshops: '创意工坊收藏',
  1313. curators: '鉴赏家',
  1314. workshopVotes: '创意工坊点赞',
  1315. announcements: '社区通知',
  1316. steamCommunity: 'Steam社区',
  1317. steamStore: 'Steam商店',
  1318. licenses: '入库免费游戏',
  1319. playtests: '请求访问权限',
  1320. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1321. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1322. joiningSteamGroup: '正在加入Steam组',
  1323. leavingSteamGroup: '正在退出Steam组',
  1324. gettingSteamGroupId: '正在获取Steam组Id',
  1325. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1326. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1327. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1328. subscribingForum: '正在订阅Steam论坛',
  1329. unsubscribingForum: '正在取消订阅Steam论坛',
  1330. gettingForumId: '正在获取Steam论坛Id',
  1331. followingCurator: '正在关注Steam鉴赏家',
  1332. unfollowingCurator: '正在取关Steam鉴赏家',
  1333. gettingCuratorId: '正在获取Steam鉴赏家Id',
  1334. addingToWishlist: '正在添加游戏到Steam愿望单',
  1335. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1336. followingGame: '正在关注Steam游戏',
  1337. unfollowingGame: '正在取关Steam游戏',
  1338. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1339. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1340. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1341. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1342. gettingAnnouncementParams: '正在获取Steam通知信息',
  1343. likingAnnouncement: '正在点赞Steam通知',
  1344. changingArea: '正在更换Steam地区: %0...',
  1345. notNeededChangeArea: '当前地区不需要更换',
  1346. noAnotherArea: '请检测是否开启正确开启代理',
  1347. gettingAreaInfo: '正在获取Steam地区信息...',
  1348. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1349. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1350. gettingSubid: '正在获取游戏subid',
  1351. addingFreeLicense: '正在入库',
  1352. missParams: '缺少参数',
  1353. gettingLicenses: '正在获取Licenses...',
  1354. requestingPlayTestAccess: '正在请求访问权限',
  1355. tryChangeAreaNotice: '此功能无法检测游戏是否限区,因此会尝试换区后再入库,换区失败也不影响后续入库',
  1356. servers: '服务器',
  1357. joiningDiscordServer: '正在加入Discord服务器',
  1358. leavingDiscordServer: '正在退出Discord服务器',
  1359. gettingDiscordGuild: '正在获取Discord服务器Id',
  1360. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1361. discordImportantNotice: '重要提醒!!!',
  1362. discordImportantNoticeText: '由于Discord网站后台更新,目前使用此脚本加组后可能会导致Discord帐号被强制退出,且需要两步验证才能正常登录,请谨慎使用!!!',
  1363. continue: '继续',
  1364. skipDiscordTask: '跳过Discord任务',
  1365. continueAndDontRemindAgain: '继续且不再提醒',
  1366. users: '用户',
  1367. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1368. insBanned: '您的Instagram账户已被封禁',
  1369. verifyingInsAuth: '正在验证Instagram凭证...',
  1370. gettingInsUserId: '正在获取Instagram用户Id',
  1371. followingIns: '正在关注Instagram用户',
  1372. unfollowingIns: '正在取关Instagram用户',
  1373. reddits: '社区/用户',
  1374. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1375. changingRedditVersion: '正在切换Reddit为新版页面...',
  1376. joiningReddit: '正在加入Reddit社区',
  1377. leavingReddit: '正在退出Reddit社区',
  1378. followingRedditUser: '正在关注Reddit用户',
  1379. unfollowingRedditUser: '正在取关Reddit用户',
  1380. channels: '频道',
  1381. followingTwitchChannel: '正在关注Twitch频道',
  1382. unfollowingTwitchChannel: '正在取关Twitch频道',
  1383. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1384. twitterUser: '推特用户',
  1385. retweets: '转推',
  1386. gettingTwitterUserId: '正在获取推特用户Id',
  1387. followingTwitterUser: '正在关注推特用户',
  1388. unfollowingTwitterUser: '正在取关推特用户',
  1389. retweetting: '正在转推',
  1390. unretweetting: '正在撤销转推',
  1391. names: '组/社区/动态',
  1392. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1393. gettingVkId: '正在获取Vk任务Id',
  1394. joiningVkGroup: '正在加入Vk组',
  1395. leavingVkGroup: '正在退出Vk组',
  1396. joiningVkPublic: '正在加入Vk社区',
  1397. leavingVkPublic: '正在退出Vk社区',
  1398. sendingVkWall: '正在转发Vk动态',
  1399. deletingVkWall: '正在撤销转发Vk动态',
  1400. youtubeChannel: 'YouTube频道',
  1401. likes: '点赞',
  1402. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1403. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1404. gettingYtbToken: '正在获取YouTube Token...',
  1405. followingYtbChannel: '正在订阅YouTube频道',
  1406. unfollowingYtbChannel: '正在退订YouTube频道',
  1407. likingYtbVideo: '正在点赞YouTube视频',
  1408. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1409. giveKeyNoticeBefore: '每次验证间隔15s',
  1410. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1411. noPoints: '点数不够,跳过抽奖',
  1412. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1413. joiningLottery: '正在加入抽奖',
  1414. doingGleamTask: '正在做Gleam任务...',
  1415. gettingGleamLink: '正在获取Gleam任务链接...',
  1416. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1417. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1418. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1419. giveeClubVerifyNotice: '正在验证任务...',
  1420. giveeClubVerifyFinished: '请等待验证完成后自行加入赠Key',
  1421. doingKeyhubTask: '正在做Keyhub任务...',
  1422. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1423. };
  1424. const zh_CN = data;
  1425. const en_US_data = {
  1426. website: 'Website',
  1427. type: 'Type',
  1428. edit: 'Edit',
  1429. whiteList: 'Whitelist',
  1430. skipTask: 'Skip undo task',
  1431. whiteListOptions: 'Whitelist options',
  1432. changeWhiteListOption: 'Whitelist option(%0)',
  1433. whiteListNotFound: 'Cannot find this whitelist: %0',
  1434. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1435. changeWebsiteOptions: 'Website options',
  1436. changeGlobalOptions: 'Global options',
  1437. ok: 'OK',
  1438. save: 'Save',
  1439. close: 'Close',
  1440. return: 'Return',
  1441. option: 'Option',
  1442. value: 'Value',
  1443. websiteOptions: 'Current website settings',
  1444. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1445. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1446. needLogin: 'Please log in first!',
  1447. getTasksInfo: 'Obtaining and processing task information...',
  1448. gettingKey: 'Getting Key...',
  1449. verifyingTask: 'Verifying task',
  1450. notice: 'Automatic task script notice',
  1451. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1452. giveawayEnded: 'This event has ended, do you want to close it?',
  1453. 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?',
  1454. confirm: 'Confirm',
  1455. cancel: 'Cancel',
  1456. unKnown: 'Unknown',
  1457. unKnownTaskType: 'Unrecognized task',
  1458. doing: 'Doing a task',
  1459. allTasksComplete: 'All tasks have been completed!',
  1460. getTaskIdFailed: 'Failed to obtain task Id!',
  1461. initSuccess: '%0 was initialized successfully!',
  1462. initFailed: '%0 initialization failed!',
  1463. errorLink: 'Link error: %0',
  1464. needInit: 'Please initialize first',
  1465. verifyingAuth: 'Verifying %0 token...',
  1466. updatingAuth: 'Update %0 token...',
  1467. initing: 'Initializing...',
  1468. getFailed: 'Failed to get %0!',
  1469. checkLoginFailed: 'Failed to detect login status!',
  1470. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1471. userId: 'User Id',
  1472. joiningGiveaway: 'Joining giveaway',
  1473. needJoinGiveaway: 'Need to join the giveaway first',
  1474. cannotUndo: 'This website does not support canceling tasks',
  1475. verifyAuth: 'Verifying %0 token...',
  1476. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1477. errorReport: 'A script error is detected, do you want to report the BUG?',
  1478. visitingLink: 'Visiting link: ',
  1479. doTask: 'DoTask',
  1480. undoTask: 'UndoTask',
  1481. verifyTask: 'Verify',
  1482. getKey: 'GetKey',
  1483. selectAll: 'SelectAll',
  1484. selectNone: 'SelectNone',
  1485. invertSelect: 'InvertSelect',
  1486. doFreeTask: 'FreeTask',
  1487. doPointTask: 'PointTask',
  1488. skipTaskOption: 'Skip task has been configured in the settings',
  1489. other: 'Other',
  1490. globalOptions: 'Global Options',
  1491. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1492. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1493. 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.',
  1494. 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.',
  1495. 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.',
  1496. saveGlobalOptions: 'SaveSettings',
  1497. settingPage: 'Setting Page',
  1498. name: 'Name',
  1499. version: 'Version',
  1500. scriptManager: 'Script Manager',
  1501. script: 'Script',
  1502. environment: 'Environment',
  1503. os: 'OS',
  1504. browser: 'Browser',
  1505. getId: 'Get %0 id',
  1506. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1507. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1508. showButton: 'ShowButton',
  1509. hideButton: 'HideButton',
  1510. showLog: 'ShowLog',
  1511. hideLog: 'HideLog',
  1512. defaultShowButton: 'Default display button',
  1513. defaultShowLog: 'Display log by default',
  1514. debug: 'Output debug log, do not enable this option!',
  1515. receivePreview: 'Receive preview updates',
  1516. position: 'Component position',
  1517. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1518. 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',
  1519. 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',
  1520. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1521. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1522. 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',
  1523. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1524. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1525. 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',
  1526. hotKey: 'Shortcut key',
  1527. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1528. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1529. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1530. tasksHistory: 'TasksHistory',
  1531. clearHistory: 'Clear history',
  1532. clearHistoryFinished: 'The mission history has been cleared!',
  1533. deleteTask: 'Delete task',
  1534. lastChangeTime: 'Last Change Time',
  1535. clearTaskFinished: 'Delete the following tasks completed!',
  1536. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1537. syncData: 'DataSync',
  1538. settingData: 'Uploading data...',
  1539. gettingData: 'Getting data...',
  1540. help: 'Help',
  1541. fileName: 'Filename',
  1542. upload2gist: 'Sync to Gist',
  1543. downloadFromGist: 'Sync from Gist',
  1544. saveAndTest: 'Save configuration and test',
  1545. testSuccess: 'Test success!',
  1546. testFailed: 'Test failed!',
  1547. saveAndTestNotice: 'Please save the configuration and test first!',
  1548. processingData: 'Processing data...',
  1549. updatingData: 'Uploading data...',
  1550. syncDataSuccess: 'Synchronized data successfully!',
  1551. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1552. downloadingData: 'Downloading data...',
  1553. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1554. savingData: 'Saving data...',
  1555. syncHistory: 'Synchronize tasks history',
  1556. checkUpdateFailed: 'Check update failed',
  1557. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1558. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1559. gistOptions: 'Gist Settings',
  1560. 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!',
  1561. 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!',
  1562. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1563. toGithub: 'Feedback(Github)',
  1564. toKeylol: 'Feedback(Keylol)',
  1565. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1566. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1567. updateText: 'Updates in version %0:',
  1568. Active: 'Active',
  1569. Ended: 'Ended',
  1570. Banned: 'Banned',
  1571. Paused: 'Paused',
  1572. notStart: 'notStart',
  1573. noRemoteData: 'No data remotely',
  1574. errorRemoteDataFormat: 'Remote data has wrong format',
  1575. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1576. groups: 'Group',
  1577. officialGroups: 'Official Group',
  1578. wishlists: 'Wishlist',
  1579. follows: 'Follow Game',
  1580. forums: 'Forum',
  1581. workshops: 'Favorite Workshop',
  1582. curators: 'Curator',
  1583. workshopVotes: 'Voteup Workshop',
  1584. announcements: 'Announcement',
  1585. steamCommunity: 'Steam Community',
  1586. steamStore: 'Steam Store',
  1587. licenses: 'Add License',
  1588. playtests: 'Playtest Access',
  1589. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1590. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1591. joiningSteamGroup: 'Joining Steam Group',
  1592. leavingSteamGroup: 'Leaving Steam Group',
  1593. gettingSteamGroupId: 'Getting Steam Group Id',
  1594. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1595. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1596. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1597. subscribingForum: 'Subscribing the Steam Forum',
  1598. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1599. gettingForumId: 'Getting Steam Forum Id',
  1600. followingCurator: 'Following Steam Curator',
  1601. unfollowingCurator: 'Unfollowing Steam Curator',
  1602. gettingCuratorId: 'Getting Steam Curator Id',
  1603. addingToWishlist: 'Adding the game to the Steam wishlist',
  1604. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1605. followingGame: 'Following Steam games',
  1606. unfollowingGame: 'Unfollowing Steam games',
  1607. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1608. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1609. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1610. votingUpWorkshop: 'Liking Steam workshop items',
  1611. gettingAnnouncementParams: 'Getting Steam announcement information',
  1612. likingAnnouncement: 'Liking Steam announcement',
  1613. changingArea: 'Changing Steam area: %0...',
  1614. notNeededChangeArea: 'The current area does not need to be changed',
  1615. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1616. gettingAreaInfo: 'Getting Steam area information...',
  1617. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1618. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1619. gettingSubid: 'Getting subid',
  1620. addingFreeLicense: 'Adding free license',
  1621. missParams: 'Missing parameters',
  1622. gettingLicenses: 'Getting licenses...',
  1623. requestingPlayTestAccess: 'Requesting play test access',
  1624. 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.',
  1625. servers: 'Server',
  1626. joiningDiscordServer: 'Joining Discord Server',
  1627. leavingDiscordServer: 'Leaving Discord Server',
  1628. gettingDiscordGuild: 'Getting Discord server Id',
  1629. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1630. discordImportantNotice: 'Important Reminder! ! !',
  1631. 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! ! !',
  1632. continue: 'Continue',
  1633. skipDiscordTask: 'Skip',
  1634. continueAndDontRemindAgain: 'Continue without Reminders',
  1635. users: 'User',
  1636. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1637. insBanned: 'Your Instagram account has been banned',
  1638. verifyingInsAuth: 'Verifying Instagram token...',
  1639. gettingInsUserId: 'Getting Instagram user Id',
  1640. followingIns: 'Following Instagram user',
  1641. unfollowingIns: 'Unfollowing Instagram user',
  1642. reddits: 'Reddit/User',
  1643. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1644. changingRedditVersion: 'Switching Reddit to a new version page...',
  1645. joiningReddit: 'Joining the Reddit',
  1646. leavingReddit: 'Leaving the Reddit',
  1647. followingRedditUser: 'Following Reddit User',
  1648. unfollowingRedditUser: 'Unfollowing Reddit User',
  1649. channels: 'Channel',
  1650. followingTwitchChannel: 'Following Twitch Channel',
  1651. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1652. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1653. twitterUser: 'Twitter User',
  1654. retweets: 'Retweet',
  1655. gettingTwitterUserId: 'Getting Twitter User Id',
  1656. followingTwitterUser: 'Following Twitter User',
  1657. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1658. retweetting: 'Retweetting',
  1659. unretweetting: 'Unretweetting',
  1660. names: 'Group/Public/Wall',
  1661. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1662. gettingVkId: 'Getting Vk task Id',
  1663. joiningVkGroup: 'Joining Vk Group',
  1664. leavingVkGroup: 'Leaving Vk Group',
  1665. joiningVkPublic: 'Joining Vk Public',
  1666. leavingVkPublic: 'Leaving Vk Public',
  1667. sendingVkWall: 'Sending Vk Wall',
  1668. deletingVkWall: 'Deleting Vk Wall',
  1669. youtubeChannel: 'YouTube Channel',
  1670. likes: 'Like',
  1671. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1672. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1673. gettingYtbToken: 'Getting YouTube Token...',
  1674. followingYtbChannel: 'Subscribing to YouTube channel',
  1675. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1676. likingYtbVideo: 'Liking YouTube video',
  1677. unlikingYtbVideo: 'Unliking YouTube video',
  1678. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1679. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1680. noPoints: 'Not enough points, skip the lottery',
  1681. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1682. joiningLottery: 'Joining the lottery',
  1683. doingGleamTask: 'Doing Gleam Task...',
  1684. gettingGleamLink: 'Getting Gleam task link...',
  1685. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1686. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1687. 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!',
  1688. giveeClubVerifyNotice: 'Verifying task...',
  1689. giveeClubVerifyFinished: 'Wait for the verification to complete and join it by yourself',
  1690. doingKeyhubTask: 'Doing Keyhub Task...',
  1691. 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...'
  1692. };
  1693. const en_US = en_US_data;
  1694. const languages = {
  1695. zh: zh_CN,
  1696. en: en_US
  1697. };
  1698. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1699. const I18n = function(key) {
  1700. var _languages$language;
  1701. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1702. argvs[_key - 1] = arguments[_key];
  1703. }
  1704. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1705. return key;
  1706. }
  1707. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1708. };
  1709. const i18n = I18n;
  1710. function throwError(error, name) {
  1711. if (window.TRACE) {
  1712. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1713. }
  1714. external_Swal_default().fire({
  1715. title: i18n('errorReport'),
  1716. icon: 'error',
  1717. showCancelButton: true,
  1718. confirmButtonText: i18n('toGithub'),
  1719. showDenyButton: true,
  1720. denyButtonText: i18n('toKeylol'),
  1721. cancelButtonText: i18n('close')
  1722. }).then(_ref => {
  1723. let {
  1724. isDenied,
  1725. isConfirmed
  1726. } = _ref;
  1727. if (isConfirmed) {
  1728. 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,
  1729. 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');
  1730. } else if (isDenied) {
  1731. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1732.  
  1733. 环境:
  1734.  
  1735. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1736.  
  1737. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1738. 脚本版本: ${GM_info.script.version}
  1739.  
  1740. 报错信息:
  1741. [code]${error.stack}[/code]
  1742.  
  1743. 执行日志:
  1744. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1745. GM_setClipboard(text);
  1746. external_Swal_default().fire({
  1747. title: i18n('copySuccess'),
  1748. icon: 'success',
  1749. confirmButtonText: i18n('ok')
  1750. }).then(() => {
  1751. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1752. });
  1753. }
  1754. });
  1755. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1756. }
  1757. function _defineProperty(obj, key, value) {
  1758. if (key in obj) {
  1759. Object.defineProperty(obj, key, {
  1760. value: value,
  1761. enumerable: true,
  1762. configurable: true,
  1763. writable: true
  1764. });
  1765. } else {
  1766. obj[key] = value;
  1767. }
  1768. return obj;
  1769. }
  1770. class Social {
  1771. constructor() {
  1772. _defineProperty(this, 'tasks', void 0);
  1773. }
  1774. getRealParams(name, links, doTask, link2param) {
  1775. try {
  1776. let realParams = [];
  1777. if (links.length > 0) {
  1778. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1779. }
  1780. if (!doTask && this.tasks[name].length > 0) {
  1781. realParams = [ ...realParams, ...this.tasks[name] ];
  1782. }
  1783. return unique(realParams);
  1784. } catch (error) {
  1785. throwError(error, 'Social.getRealParams');
  1786. return [];
  1787. }
  1788. }
  1789. }
  1790. const social_Social = Social;
  1791. function _classPrivateMethodInitSpec(obj, privateSet) {
  1792. _checkPrivateRedeclaration(obj, privateSet);
  1793. privateSet.add(obj);
  1794. }
  1795. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1796. _checkPrivateRedeclaration(obj, privateMap);
  1797. privateMap.set(obj, value);
  1798. }
  1799. function _checkPrivateRedeclaration(obj, privateCollection) {
  1800. if (privateCollection.has(obj)) {
  1801. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1802. }
  1803. }
  1804. function Discord_defineProperty(obj, key, value) {
  1805. if (key in obj) {
  1806. Object.defineProperty(obj, key, {
  1807. value: value,
  1808. enumerable: true,
  1809. configurable: true,
  1810. writable: true
  1811. });
  1812. } else {
  1813. obj[key] = value;
  1814. }
  1815. return obj;
  1816. }
  1817. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1818. if (!privateSet.has(receiver)) {
  1819. throw new TypeError('attempted to get private field on non-instance');
  1820. }
  1821. return fn;
  1822. }
  1823. function _classPrivateFieldGet(receiver, privateMap) {
  1824. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1825. return _classApplyDescriptorGet(receiver, descriptor);
  1826. }
  1827. function _classApplyDescriptorGet(receiver, descriptor) {
  1828. if (descriptor.get) {
  1829. return descriptor.get.call(receiver);
  1830. }
  1831. return descriptor.value;
  1832. }
  1833. function _classPrivateFieldSet(receiver, privateMap, value) {
  1834. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1835. _classApplyDescriptorSet(receiver, descriptor, value);
  1836. return value;
  1837. }
  1838. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1839. if (!privateMap.has(receiver)) {
  1840. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1841. }
  1842. return privateMap.get(receiver);
  1843. }
  1844. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1845. if (descriptor.set) {
  1846. descriptor.set.call(receiver, value);
  1847. } else {
  1848. if (!descriptor.writable) {
  1849. throw new TypeError('attempted to set read only private field');
  1850. }
  1851. descriptor.value = value;
  1852. }
  1853. }
  1854. const defaultTasksTemplate = {
  1855. servers: []
  1856. };
  1857. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1858. var _auth = new WeakMap();
  1859. var _cache = new WeakMap();
  1860. var _initialized = new WeakMap();
  1861. var _verifyAuth = new WeakSet();
  1862. var _updateAuth = new WeakSet();
  1863. var _joinServer = new WeakSet();
  1864. var _leaveServer = new WeakSet();
  1865. var _getGuild = new WeakSet();
  1866. var _setCache = new WeakSet();
  1867. class Discord extends social_Social {
  1868. constructor() {
  1869. var _GM_getValue;
  1870. super(...arguments);
  1871. _classPrivateMethodInitSpec(this, _setCache);
  1872. _classPrivateMethodInitSpec(this, _getGuild);
  1873. _classPrivateMethodInitSpec(this, _leaveServer);
  1874. _classPrivateMethodInitSpec(this, _joinServer);
  1875. _classPrivateMethodInitSpec(this, _updateAuth);
  1876. _classPrivateMethodInitSpec(this, _verifyAuth);
  1877. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1878. Discord_defineProperty(this, 'whiteList', {
  1879. ...JSON.parse(defaultTasks),
  1880. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1881. });
  1882. _classPrivateFieldInitSpec(this, _auth, {
  1883. writable: true,
  1884. value: GM_getValue('discordAuth') || {}
  1885. });
  1886. _classPrivateFieldInitSpec(this, _cache, {
  1887. writable: true,
  1888. value: GM_getValue('discordCache') || {}
  1889. });
  1890. _classPrivateFieldInitSpec(this, _initialized, {
  1891. writable: true,
  1892. value: false
  1893. });
  1894. }
  1895. async init() {
  1896. try {
  1897. if (!GM_getValue('dontRemindDiscordAgain')) {
  1898. const result = await external_Swal_default().fire({
  1899. title: i18n('discordImportantNotice'),
  1900. text: i18n('discordImportantNoticeText'),
  1901. showCancelButton: true,
  1902. showDenyButton: true,
  1903. confirmButtonText: i18n('continue'),
  1904. cancelButtonText: i18n('skipDiscordTask'),
  1905. denyButtonText: i18n('continueAndDontRemindAgain')
  1906. }).then(_ref => {
  1907. let {
  1908. isConfirmed,
  1909. isDenied
  1910. } = _ref;
  1911. if (isConfirmed) {
  1912. return true;
  1913. }
  1914. if (isDenied) {
  1915. GM_setValue('dontRemindDiscordAgain', true);
  1916. return true;
  1917. }
  1918. return false;
  1919. });
  1920. if (!result) {
  1921. _classPrivateFieldSet(this, _initialized, false);
  1922. return 'skip';
  1923. }
  1924. }
  1925. if (_classPrivateFieldGet(this, _initialized)) {
  1926. return true;
  1927. }
  1928. if (!_classPrivateFieldGet(this, _auth).auth) {
  1929. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1930. _classPrivateFieldSet(this, _initialized, true);
  1931. return true;
  1932. }
  1933. return false;
  1934. }
  1935. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1936. if (isVerified) {
  1937. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1938. _classPrivateFieldSet(this, _initialized, true);
  1939. return true;
  1940. }
  1941. GM_setValue('discordAuth', {
  1942. auth: null
  1943. });
  1944. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1945. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1946. _classPrivateFieldSet(this, _initialized, true);
  1947. return true;
  1948. }
  1949. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1950. return false;
  1951. } catch (error) {
  1952. throwError(error, 'Discord.init');
  1953. return false;
  1954. }
  1955. }
  1956. async toggle(_ref2) {
  1957. let {
  1958. doTask = true,
  1959. serverLinks = []
  1960. } = _ref2;
  1961. try {
  1962. if (!_classPrivateFieldGet(this, _initialized)) {
  1963. scripts_echoLog({
  1964. text: i18n('needInit')
  1965. });
  1966. return false;
  1967. }
  1968. const prom = [];
  1969. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1970. scripts_echoLog({
  1971. type: 'globalOptionsSkip',
  1972. text: 'discord.servers'
  1973. });
  1974. } else {
  1975. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1976. var _link$match;
  1977. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1978. });
  1979. if (realServers.length > 0) {
  1980. for (const server of realServers) {
  1981. if (doTask) {
  1982. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1983. } else {
  1984. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1985. }
  1986. await delay(1e3);
  1987. }
  1988. }
  1989. }
  1990. return await Promise.all(prom).then(() => true);
  1991. } catch (error) {
  1992. throwError(error, 'Discord.toggleServers');
  1993. return false;
  1994. }
  1995. }
  1996. }
  1997. async function _verifyAuth2() {
  1998. try {
  1999. const logStatus = scripts_echoLog({
  2000. text: i18n('verifyingAuth', 'Discord')
  2001. });
  2002. const {
  2003. result,
  2004. statusText,
  2005. status,
  2006. data
  2007. } = await tools_httpRequest({
  2008. url: 'https://discord.com/api/v6/users/@me',
  2009. method: 'HEAD',
  2010. headers: {
  2011. authorization: _classPrivateFieldGet(this, _auth).auth
  2012. }
  2013. });
  2014. if (result === 'Success') {
  2015. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2016. logStatus.success();
  2017. return true;
  2018. }
  2019. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2020. return false;
  2021. }
  2022. logStatus.error(`${result}:${statusText}(${status})`);
  2023. return false;
  2024. } catch (error) {
  2025. throwError(error, 'Discord.verifyAuth');
  2026. return false;
  2027. }
  2028. }
  2029. async function _updateAuth2() {
  2030. try {
  2031. const logStatus = scripts_echoLog({
  2032. text: i18n('updatingAuth', 'Discord')
  2033. });
  2034. return await new Promise(resolve => {
  2035. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  2036. active: true,
  2037. insert: true,
  2038. setParent: true
  2039. });
  2040. newTab.onclose = async () => {
  2041. var _GM_getValue2;
  2042. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  2043. if (auth) {
  2044. _classPrivateFieldSet(this, _auth, {
  2045. auth: auth
  2046. });
  2047. logStatus.success();
  2048. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  2049. } else {
  2050. logStatus.error('Error: Update discord auth failed!');
  2051. resolve(false);
  2052. }
  2053. };
  2054. });
  2055. } catch (error) {
  2056. throwError(error, 'Discord.updateAuth');
  2057. return false;
  2058. }
  2059. }
  2060. async function _joinServer2(inviteId) {
  2061. try {
  2062. const logStatus = scripts_echoLog({
  2063. type: 'joiningDiscordServer',
  2064. text: inviteId
  2065. });
  2066. const {
  2067. result,
  2068. statusText,
  2069. status,
  2070. data
  2071. } = await tools_httpRequest({
  2072. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2073. method: 'POST',
  2074. dataType: 'json',
  2075. headers: {
  2076. authorization: _classPrivateFieldGet(this, _auth).auth,
  2077. origin: 'https://discord.com',
  2078. referer: `https://discord.com/invite/${inviteId}`
  2079. }
  2080. });
  2081. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2082. var _data$response, _data$response$guild;
  2083. logStatus.success();
  2084. 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);
  2085. if (guild) {
  2086. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2087. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2088. }
  2089. return true;
  2090. }
  2091. logStatus.error(`${result}:${statusText}(${status})`);
  2092. return false;
  2093. } catch (error) {
  2094. throwError(error, 'Discord.joinServer');
  2095. return false;
  2096. }
  2097. }
  2098. async function _leaveServer2(inviteId) {
  2099. try {
  2100. if (this.whiteList.servers.includes(inviteId)) {
  2101. scripts_echoLog({
  2102. type: 'whiteList',
  2103. text: 'Discord.leaveServer',
  2104. id: inviteId
  2105. });
  2106. return true;
  2107. }
  2108. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2109. if (!guild) {
  2110. return false;
  2111. }
  2112. const logStatus = scripts_echoLog({
  2113. type: 'leavingDiscordServer',
  2114. text: guild
  2115. });
  2116. const {
  2117. result,
  2118. statusText,
  2119. status,
  2120. data
  2121. } = await tools_httpRequest({
  2122. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2123. method: 'DELETE',
  2124. headers: {
  2125. authorization: _classPrivateFieldGet(this, _auth).auth
  2126. }
  2127. });
  2128. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2129. logStatus.success();
  2130. return true;
  2131. }
  2132. logStatus.error(`${result}:${statusText}(${status})`);
  2133. return false;
  2134. } catch (error) {
  2135. throwError(error, 'Discord.leaveServer');
  2136. return false;
  2137. }
  2138. }
  2139. async function _getGuild2(inviteId) {
  2140. try {
  2141. const logStatus = scripts_echoLog({
  2142. type: 'gettingDiscordGuild',
  2143. text: inviteId
  2144. });
  2145. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2146. if (guild) {
  2147. logStatus.success();
  2148. return guild;
  2149. }
  2150. const {
  2151. result,
  2152. statusText,
  2153. status,
  2154. data
  2155. } = await tools_httpRequest({
  2156. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2157. responseType: 'json',
  2158. method: 'GET'
  2159. });
  2160. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2161. var _data$response2, _data$response2$guild;
  2162. 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;
  2163. if (guild) {
  2164. logStatus.success();
  2165. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2166. return guild;
  2167. }
  2168. logStatus.error(`${result}:${statusText}(${status})`);
  2169. return false;
  2170. }
  2171. logStatus.error(`${result}:${statusText}(${status})`);
  2172. return false;
  2173. } catch (error) {
  2174. throwError(error, 'Discord.getGuild');
  2175. return false;
  2176. }
  2177. }
  2178. function _setCache2(inviteId, guild) {
  2179. try {
  2180. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2181. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2182. } catch (error) {
  2183. throwError(error, 'Discord.setCache');
  2184. }
  2185. }
  2186. const social_Discord = Discord;
  2187. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2188. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2189. privateSet.add(obj);
  2190. }
  2191. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2192. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2193. privateMap.set(obj, value);
  2194. }
  2195. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2196. if (privateCollection.has(obj)) {
  2197. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2198. }
  2199. }
  2200. function Instagram_defineProperty(obj, key, value) {
  2201. if (key in obj) {
  2202. Object.defineProperty(obj, key, {
  2203. value: value,
  2204. enumerable: true,
  2205. configurable: true,
  2206. writable: true
  2207. });
  2208. } else {
  2209. obj[key] = value;
  2210. }
  2211. return obj;
  2212. }
  2213. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2214. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2215. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2216. return value;
  2217. }
  2218. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2219. if (descriptor.set) {
  2220. descriptor.set.call(receiver, value);
  2221. } else {
  2222. if (!descriptor.writable) {
  2223. throw new TypeError('attempted to set read only private field');
  2224. }
  2225. descriptor.value = value;
  2226. }
  2227. }
  2228. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2229. if (!privateSet.has(receiver)) {
  2230. throw new TypeError('attempted to get private field on non-instance');
  2231. }
  2232. return fn;
  2233. }
  2234. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2235. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2236. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2237. }
  2238. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2239. if (!privateMap.has(receiver)) {
  2240. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2241. }
  2242. return privateMap.get(receiver);
  2243. }
  2244. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2245. if (descriptor.get) {
  2246. return descriptor.get.call(receiver);
  2247. }
  2248. return descriptor.value;
  2249. }
  2250. const Instagram_defaultTasksTemplate = {
  2251. users: []
  2252. };
  2253. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2254. var Instagram_cache = new WeakMap();
  2255. var Instagram_auth = new WeakMap();
  2256. var Instagram_initialized = new WeakMap();
  2257. var _getUserInfo = new WeakSet();
  2258. var _followUser = new WeakSet();
  2259. var _unfollowUser = new WeakSet();
  2260. var Instagram_setCache = new WeakSet();
  2261. class Instagram extends social_Social {
  2262. constructor() {
  2263. var _GM_getValue;
  2264. super(...arguments);
  2265. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2266. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2267. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2268. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2269. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2270. Instagram_defineProperty(this, 'whiteList', {
  2271. ...JSON.parse(Instagram_defaultTasks),
  2272. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2273. });
  2274. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2275. writable: true,
  2276. value: GM_getValue('instagramCache') || {}
  2277. });
  2278. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2279. writable: true,
  2280. value: {}
  2281. });
  2282. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2283. writable: true,
  2284. value: false
  2285. });
  2286. }
  2287. async init() {
  2288. try {
  2289. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2290. return true;
  2291. }
  2292. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2293. if (isVerified) {
  2294. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2295. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2296. return true;
  2297. }
  2298. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2299. return false;
  2300. } catch (error) {
  2301. throwError(error, 'Instagram.init');
  2302. return false;
  2303. }
  2304. }
  2305. async toggle(_ref) {
  2306. let {
  2307. doTask = true,
  2308. userLinks = []
  2309. } = _ref;
  2310. try {
  2311. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2312. scripts_echoLog({
  2313. text: i18n('needInit')
  2314. });
  2315. return false;
  2316. }
  2317. const prom = [];
  2318. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2319. scripts_echoLog({
  2320. type: 'globalOptionsSkip',
  2321. text: 'instagram.users'
  2322. });
  2323. } else {
  2324. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2325. var _link$match;
  2326. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2327. });
  2328. if (realUsers.length > 0) {
  2329. for (const username of realUsers) {
  2330. if (doTask) {
  2331. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2332. } else {
  2333. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2334. }
  2335. await delay(1e3);
  2336. }
  2337. }
  2338. }
  2339. return await Promise.all(prom).then(() => true);
  2340. } catch (error) {
  2341. throwError(error, 'Instagram.toggleUsers');
  2342. return false;
  2343. }
  2344. }
  2345. }
  2346. async function _getUserInfo2() {
  2347. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2348. try {
  2349. const logStatus = scripts_echoLog({
  2350. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2351. text: name
  2352. });
  2353. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2354. if (userId && name !== 'instagram') {
  2355. logStatus.success();
  2356. return userId;
  2357. }
  2358. const {
  2359. result,
  2360. statusText,
  2361. status,
  2362. data
  2363. } = await tools_httpRequest({
  2364. url: `https://www.instagram.com/${name}/`,
  2365. method: 'GET'
  2366. });
  2367. if (result === 'Success') {
  2368. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2369. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2370. return false;
  2371. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2372. logStatus.error(`Error:${i18n('insBanned')}`);
  2373. return false;
  2374. }
  2375. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2376. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2377. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2378. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2379. if (name === 'instagram') {
  2380. if (csrftoken && hash) {
  2381. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2382. csrftoken: csrftoken,
  2383. hash: hash
  2384. });
  2385. return true;
  2386. }
  2387. return false;
  2388. }
  2389. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2390. if (id) {
  2391. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2392. logStatus.success();
  2393. return id;
  2394. }
  2395. logStatus.error('Error: Get ins data error!');
  2396. return false;
  2397. }
  2398. logStatus.error(`${result}:${statusText}(${status})`);
  2399. return false;
  2400. }
  2401. return false;
  2402. } catch (error) {
  2403. throwError(error, 'Instagram.getUserInfo');
  2404. return false;
  2405. }
  2406. }
  2407. async function _followUser2(name) {
  2408. try {
  2409. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2410. if (!id) {
  2411. return false;
  2412. }
  2413. const logStatus = scripts_echoLog({
  2414. type: 'followingIns',
  2415. text: name
  2416. });
  2417. const {
  2418. result,
  2419. statusText,
  2420. status,
  2421. data
  2422. } = await tools_httpRequest({
  2423. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2424. method: 'POST',
  2425. dataType: 'json',
  2426. headers: {
  2427. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2428. origin: 'https://www.instagram.com',
  2429. referer: `https://www.instagram.com/${name}/`,
  2430. 'content-type': 'application/x-www-form-urlencoded',
  2431. 'sec-fetch-site': 'same-origin',
  2432. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2433. }
  2434. });
  2435. if (result === 'Success') {
  2436. var _data$response, _data$response2;
  2437. 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') {
  2438. logStatus.success();
  2439. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2440. return true;
  2441. }
  2442. 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})`}`);
  2443. return false;
  2444. }
  2445. logStatus.error(`${result}:${statusText}(${status})`);
  2446. return false;
  2447. } catch (error) {
  2448. throwError(error, 'Instagram.followUser');
  2449. return false;
  2450. }
  2451. }
  2452. async function _unfollowUser2(name) {
  2453. try {
  2454. if (this.whiteList.users.includes(name)) {
  2455. scripts_echoLog({
  2456. type: 'whiteList',
  2457. text: 'Instagram.unfollowUser',
  2458. id: name
  2459. });
  2460. return true;
  2461. }
  2462. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2463. if (!id) {
  2464. return false;
  2465. }
  2466. const logStatus = scripts_echoLog({
  2467. type: 'unfollowingIns',
  2468. text: name
  2469. });
  2470. const {
  2471. result,
  2472. statusText,
  2473. status,
  2474. data
  2475. } = await tools_httpRequest({
  2476. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2477. method: 'POST',
  2478. dataType: 'json',
  2479. headers: {
  2480. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2481. origin: 'https://www.instagram.com',
  2482. referer: `https://www.instagram.com/${name}/`,
  2483. 'content-type': 'application/x-www-form-urlencoded',
  2484. 'sec-fetch-site': 'same-origin',
  2485. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2486. }
  2487. });
  2488. if (result === 'Success') {
  2489. var _data$response3;
  2490. 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') {
  2491. logStatus.success();
  2492. return true;
  2493. }
  2494. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2495. return false;
  2496. }
  2497. logStatus.error(`${result}:${statusText}(${status})`);
  2498. return false;
  2499. } catch (error) {
  2500. throwError(error, 'Instagram.unfollowUser');
  2501. return false;
  2502. }
  2503. }
  2504. function Instagram_setCache2(name, id) {
  2505. try {
  2506. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2507. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2508. } catch (error) {
  2509. throwError(error, 'Instagram.setCache');
  2510. }
  2511. }
  2512. const social_Instagram = Instagram;
  2513. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2514. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2515. privateSet.add(obj);
  2516. }
  2517. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2518. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2519. privateMap.set(obj, value);
  2520. }
  2521. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2522. if (privateCollection.has(obj)) {
  2523. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2524. }
  2525. }
  2526. function Reddit_defineProperty(obj, key, value) {
  2527. if (key in obj) {
  2528. Object.defineProperty(obj, key, {
  2529. value: value,
  2530. enumerable: true,
  2531. configurable: true,
  2532. writable: true
  2533. });
  2534. } else {
  2535. obj[key] = value;
  2536. }
  2537. return obj;
  2538. }
  2539. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2540. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2541. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2542. return value;
  2543. }
  2544. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2545. if (descriptor.set) {
  2546. descriptor.set.call(receiver, value);
  2547. } else {
  2548. if (!descriptor.writable) {
  2549. throw new TypeError('attempted to set read only private field');
  2550. }
  2551. descriptor.value = value;
  2552. }
  2553. }
  2554. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2555. if (!privateSet.has(receiver)) {
  2556. throw new TypeError('attempted to get private field on non-instance');
  2557. }
  2558. return fn;
  2559. }
  2560. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2561. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2562. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2563. }
  2564. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2565. if (!privateMap.has(receiver)) {
  2566. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2567. }
  2568. return privateMap.get(receiver);
  2569. }
  2570. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2571. if (descriptor.get) {
  2572. return descriptor.get.call(receiver);
  2573. }
  2574. return descriptor.value;
  2575. }
  2576. const Reddit_defaultTasksTemplate = {
  2577. reddits: []
  2578. };
  2579. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2580. var Reddit_auth = new WeakMap();
  2581. var Reddit_initialized = new WeakMap();
  2582. var _useBeta = new WeakSet();
  2583. var Reddit_updateAuth = new WeakSet();
  2584. class Reddit extends social_Social {
  2585. constructor() {
  2586. var _GM_getValue;
  2587. super(...arguments);
  2588. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2589. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2590. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2591. Reddit_defineProperty(this, 'whiteList', {
  2592. ...JSON.parse(Reddit_defaultTasks),
  2593. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2594. });
  2595. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2596. writable: true,
  2597. value: void 0
  2598. });
  2599. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2600. writable: true,
  2601. value: false
  2602. });
  2603. }
  2604. async init() {
  2605. try {
  2606. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2607. return true;
  2608. }
  2609. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2610. if (isVerified) {
  2611. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2612. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2613. return true;
  2614. }
  2615. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2616. return false;
  2617. } catch (error) {
  2618. throwError(error, 'Reddit.init');
  2619. return false;
  2620. }
  2621. }
  2622. async toggleTask(_ref) {
  2623. let {
  2624. name,
  2625. doTask = true
  2626. } = _ref;
  2627. try {
  2628. if (!doTask && this.whiteList.reddits.includes(name)) {
  2629. scripts_echoLog({
  2630. type: 'whiteList',
  2631. text: 'Reddit.undoTask',
  2632. id: name
  2633. });
  2634. return true;
  2635. }
  2636. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2637. if (/^u_/.test(name)) {
  2638. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2639. }
  2640. const logStatus = scripts_echoLog({
  2641. type: type,
  2642. text: name
  2643. });
  2644. const {
  2645. result,
  2646. statusText,
  2647. status,
  2648. data
  2649. } = await tools_httpRequest({
  2650. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2651. method: 'POST',
  2652. headers: {
  2653. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2654. 'content-type': 'application/x-www-form-urlencoded'
  2655. },
  2656. data: $.param({
  2657. action: doTask ? 'sub' : 'unsub',
  2658. sr_name: name,
  2659. api_type: 'json'
  2660. })
  2661. });
  2662. if (result === 'Success') {
  2663. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2664. logStatus.success();
  2665. if (doTask) {
  2666. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2667. }
  2668. return true;
  2669. }
  2670. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2671. return false;
  2672. }
  2673. logStatus.error(`${result}:${statusText}(${status})`);
  2674. return false;
  2675. } catch (error) {
  2676. throwError(error, 'Reddit.toggleTask');
  2677. return false;
  2678. }
  2679. }
  2680. async toggle(_ref2) {
  2681. let {
  2682. doTask = true,
  2683. redditLinks = []
  2684. } = _ref2;
  2685. try {
  2686. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2687. scripts_echoLog({
  2688. text: i18n('needInit')
  2689. });
  2690. return false;
  2691. }
  2692. const prom = [];
  2693. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2694. scripts_echoLog({
  2695. type: 'globalOptionsSkip',
  2696. text: 'reddit.reddits'
  2697. });
  2698. } else {
  2699. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2700. var _link$match, _link$match2;
  2701. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2702. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2703. if (userName) {
  2704. return name || userName;
  2705. }
  2706. return name;
  2707. });
  2708. if (realReddits.length > 0) {
  2709. for (const name of realReddits) {
  2710. prom.push(this.toggleTask({
  2711. name: name,
  2712. doTask: doTask
  2713. }));
  2714. await delay(1e3);
  2715. }
  2716. }
  2717. }
  2718. return await Promise.all(prom).then(() => true);
  2719. } catch (error) {
  2720. throwError(error, 'Reddit.toggle');
  2721. return false;
  2722. }
  2723. }
  2724. }
  2725. async function _useBeta2() {
  2726. try {
  2727. const logStatus = scripts_echoLog({
  2728. text: i18n('changingRedditVersion')
  2729. });
  2730. GM_setValue('redditAuth', null);
  2731. return await new Promise(resolve => {
  2732. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2733. active: true,
  2734. insert: true,
  2735. setParent: true
  2736. });
  2737. newTab.onclose = async () => {
  2738. logStatus.success();
  2739. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2740. };
  2741. });
  2742. } catch (error) {
  2743. throwError(error, 'Reddit.useBeta');
  2744. return false;
  2745. }
  2746. }
  2747. async function Reddit_updateAuth2() {
  2748. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2749. try {
  2750. const logStatus = scripts_echoLog({
  2751. text: i18n('updatingAuth', 'Reddit')
  2752. });
  2753. const {
  2754. result,
  2755. statusText,
  2756. status,
  2757. data
  2758. } = await tools_httpRequest({
  2759. url: 'https://www.reddit.com/',
  2760. method: 'GET',
  2761. nochche: true,
  2762. headers: {
  2763. 'Cache-Control': 'no-cache'
  2764. }
  2765. });
  2766. if (result === 'Success') {
  2767. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2768. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2769. return false;
  2770. }
  2771. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2772. var _data$responseText$ma;
  2773. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2774. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2775. }
  2776. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2777. if (accessToken) {
  2778. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2779. token: accessToken
  2780. });
  2781. logStatus.success();
  2782. return true;
  2783. }
  2784. logStatus.error('Error: Parameter "accessToken" not found!');
  2785. return false;
  2786. }
  2787. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2788. return false;
  2789. }
  2790. logStatus.error(`${result}:${statusText}(${status})`);
  2791. return false;
  2792. } catch (error) {
  2793. throwError(error, 'Reddit.updateAuth');
  2794. return false;
  2795. }
  2796. }
  2797. const social_Reddit = Reddit;
  2798. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2799. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2800. privateSet.add(obj);
  2801. }
  2802. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2803. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2804. privateMap.set(obj, value);
  2805. }
  2806. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2807. if (privateCollection.has(obj)) {
  2808. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2809. }
  2810. }
  2811. function Twitch_defineProperty(obj, key, value) {
  2812. if (key in obj) {
  2813. Object.defineProperty(obj, key, {
  2814. value: value,
  2815. enumerable: true,
  2816. configurable: true,
  2817. writable: true
  2818. });
  2819. } else {
  2820. obj[key] = value;
  2821. }
  2822. return obj;
  2823. }
  2824. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2825. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2826. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2827. return value;
  2828. }
  2829. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2830. if (descriptor.set) {
  2831. descriptor.set.call(receiver, value);
  2832. } else {
  2833. if (!descriptor.writable) {
  2834. throw new TypeError('attempted to set read only private field');
  2835. }
  2836. descriptor.value = value;
  2837. }
  2838. }
  2839. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2840. if (!privateSet.has(receiver)) {
  2841. throw new TypeError('attempted to get private field on non-instance');
  2842. }
  2843. return fn;
  2844. }
  2845. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2846. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2847. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2848. }
  2849. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2850. if (!privateMap.has(receiver)) {
  2851. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2852. }
  2853. return privateMap.get(receiver);
  2854. }
  2855. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2856. if (descriptor.get) {
  2857. return descriptor.get.call(receiver);
  2858. }
  2859. return descriptor.value;
  2860. }
  2861. const Twitch_defaultTasksTemplate = {
  2862. channels: []
  2863. };
  2864. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2865. var Twitch_auth = new WeakMap();
  2866. var Twitch_cache = new WeakMap();
  2867. var Twitch_initialized = new WeakMap();
  2868. var Twitch_verifyAuth = new WeakSet();
  2869. var Twitch_updateAuth = new WeakSet();
  2870. var _toggleChannel = new WeakSet();
  2871. var _getChannelId = new WeakSet();
  2872. var Twitch_setCache = new WeakSet();
  2873. class Twitch extends social_Social {
  2874. constructor() {
  2875. var _GM_getValue;
  2876. super(...arguments);
  2877. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2878. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2879. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2880. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2881. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2882. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2883. Twitch_defineProperty(this, 'whiteList', {
  2884. ...JSON.parse(Twitch_defaultTasks),
  2885. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2886. });
  2887. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2888. writable: true,
  2889. value: GM_getValue('twitchAuth') || {}
  2890. });
  2891. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2892. writable: true,
  2893. value: GM_getValue('twitchCache') || {}
  2894. });
  2895. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2896. writable: true,
  2897. value: false
  2898. });
  2899. }
  2900. async init() {
  2901. try {
  2902. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2903. return true;
  2904. }
  2905. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2906. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2907. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2908. return true;
  2909. }
  2910. return false;
  2911. }
  2912. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2913. if (isVerified) {
  2914. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2915. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2916. return true;
  2917. }
  2918. GM_setValue('twitchAuth', null);
  2919. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2920. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2921. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2922. return true;
  2923. }
  2924. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2925. return false;
  2926. } catch (error) {
  2927. throwError(error, 'Twitch.init');
  2928. return false;
  2929. }
  2930. }
  2931. async toggle(_ref) {
  2932. let {
  2933. doTask = true,
  2934. channelLinks = []
  2935. } = _ref;
  2936. try {
  2937. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2938. scripts_echoLog({
  2939. text: i18n('needInit')
  2940. });
  2941. return false;
  2942. }
  2943. const prom = [];
  2944. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2945. scripts_echoLog({
  2946. type: 'globalOptionsSkip',
  2947. text: 'twitch.channels'
  2948. });
  2949. } else {
  2950. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2951. var _link$match;
  2952. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2953. });
  2954. if (realChannels.length > 0) {
  2955. for (const channel of realChannels) {
  2956. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2957. name: channel,
  2958. doTask: doTask
  2959. }));
  2960. await delay(1e3);
  2961. }
  2962. }
  2963. }
  2964. return Promise.all(prom).then(() => true);
  2965. } catch (error) {
  2966. throwError(error, 'Twitch.toggle');
  2967. return false;
  2968. }
  2969. }
  2970. }
  2971. async function Twitch_verifyAuth2() {
  2972. try {
  2973. const logStatus = scripts_echoLog({
  2974. text: i18n('verifyingAuth', 'Twitch')
  2975. });
  2976. const {
  2977. result,
  2978. statusText,
  2979. status,
  2980. data
  2981. } = await tools_httpRequest({
  2982. url: 'https://gql.twitch.tv/gql',
  2983. method: 'POST',
  2984. dataType: 'json',
  2985. headers: {
  2986. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2987. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2988. },
  2989. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2990. });
  2991. if (result === 'Success') {
  2992. var _data$response, _data$response$, _data$response$$data;
  2993. 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) {
  2994. logStatus.success();
  2995. return true;
  2996. }
  2997. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2998. return false;
  2999. }
  3000. logStatus.error(`${result}:${statusText}(${status})`);
  3001. return false;
  3002. } catch (error) {
  3003. throwError(error, 'Twitch.verifyAuth');
  3004. return false;
  3005. }
  3006. }
  3007. async function Twitch_updateAuth2() {
  3008. try {
  3009. const logStatus = scripts_echoLog({
  3010. text: i18n('updatingAuth', 'Twitch')
  3011. });
  3012. return await new Promise(resolve => {
  3013. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  3014. active: true,
  3015. insert: true,
  3016. setParent: true
  3017. });
  3018. newTab.onclose = async () => {
  3019. const auth = GM_getValue('twitchAuth');
  3020. if (auth) {
  3021. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  3022. logStatus.success();
  3023. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  3024. } else {
  3025. logStatus.error('Error: Update twitch auth failed!');
  3026. resolve(false);
  3027. }
  3028. };
  3029. });
  3030. } catch (error) {
  3031. throwError(error, 'Twitch.updateAuth');
  3032. return false;
  3033. }
  3034. }
  3035. async function _toggleChannel2(_ref2) {
  3036. let {
  3037. name,
  3038. doTask = true
  3039. } = _ref2;
  3040. try {
  3041. if (!doTask && this.whiteList.channels.includes(name)) {
  3042. scripts_echoLog({
  3043. type: 'whiteList',
  3044. text: 'Twitch.unfollowChannel',
  3045. id: name
  3046. });
  3047. return true;
  3048. }
  3049. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  3050. if (!channelId) {
  3051. return false;
  3052. }
  3053. const logStatus = scripts_echoLog({
  3054. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  3055. text: name
  3056. });
  3057. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  3058. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  3059. const {
  3060. result,
  3061. statusText,
  3062. status,
  3063. data
  3064. } = await tools_httpRequest({
  3065. url: 'https://gql.twitch.tv/gql',
  3066. method: 'POST',
  3067. dataType: 'json',
  3068. headers: {
  3069. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  3070. },
  3071. data: doTask ? followData : unfollowData
  3072. });
  3073. if (result === 'Success') {
  3074. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3075. logStatus.success();
  3076. if (doTask) {
  3077. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3078. }
  3079. return true;
  3080. }
  3081. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3082. return false;
  3083. }
  3084. logStatus.error(`${result}:${statusText}(${status})`);
  3085. return false;
  3086. } catch (error) {
  3087. throwError(error, 'Twitch.toggleChannel');
  3088. return false;
  3089. }
  3090. }
  3091. async function _getChannelId2(name) {
  3092. try {
  3093. const logStatus = scripts_echoLog({
  3094. type: 'gettingTwitchChannelId',
  3095. text: name
  3096. });
  3097. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3098. if (channelId) {
  3099. logStatus.success();
  3100. return channelId;
  3101. }
  3102. const {
  3103. result,
  3104. statusText,
  3105. status,
  3106. data
  3107. } = await tools_httpRequest({
  3108. url: 'https://gql.twitch.tv/gql',
  3109. method: 'POST',
  3110. headers: {
  3111. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3112. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3113. },
  3114. responseType: 'json',
  3115. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3116. });
  3117. if (result === 'Success') {
  3118. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3119. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3120. const channelId = String((_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$ = _data$response2[0]) === null || _data$response2$ === void 0 ? void 0 : (_data$response2$$data = _data$response2$.data) === null || _data$response2$$data === void 0 ? void 0 : (_data$response2$$data2 = _data$response2$$data.user) === null || _data$response2$$data2 === void 0 ? void 0 : _data$response2$$data2.id);
  3121. if (channelId) {
  3122. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3123. logStatus.success();
  3124. return channelId;
  3125. }
  3126. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3127. return false;
  3128. }
  3129. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3130. return false;
  3131. }
  3132. logStatus.error(`${result}:${statusText}(${status})`);
  3133. return false;
  3134. } catch (error) {
  3135. throwError(error, 'Twitch.getChannelId');
  3136. return false;
  3137. }
  3138. }
  3139. function Twitch_setCache2(name, id) {
  3140. try {
  3141. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3142. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3143. } catch (error) {
  3144. throwError(error, 'Twitch.setCache');
  3145. }
  3146. }
  3147. const social_Twitch = Twitch;
  3148. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3149. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3150. privateSet.add(obj);
  3151. }
  3152. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3153. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3154. privateMap.set(obj, value);
  3155. }
  3156. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3157. if (privateCollection.has(obj)) {
  3158. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3159. }
  3160. }
  3161. function Twitter_defineProperty(obj, key, value) {
  3162. if (key in obj) {
  3163. Object.defineProperty(obj, key, {
  3164. value: value,
  3165. enumerable: true,
  3166. configurable: true,
  3167. writable: true
  3168. });
  3169. } else {
  3170. obj[key] = value;
  3171. }
  3172. return obj;
  3173. }
  3174. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3175. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3176. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3177. return value;
  3178. }
  3179. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3180. if (descriptor.set) {
  3181. descriptor.set.call(receiver, value);
  3182. } else {
  3183. if (!descriptor.writable) {
  3184. throw new TypeError('attempted to set read only private field');
  3185. }
  3186. descriptor.value = value;
  3187. }
  3188. }
  3189. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3190. if (!privateSet.has(receiver)) {
  3191. throw new TypeError('attempted to get private field on non-instance');
  3192. }
  3193. return fn;
  3194. }
  3195. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3196. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3197. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3198. }
  3199. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3200. if (!privateMap.has(receiver)) {
  3201. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3202. }
  3203. return privateMap.get(receiver);
  3204. }
  3205. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3206. if (descriptor.get) {
  3207. return descriptor.get.call(receiver);
  3208. }
  3209. return descriptor.value;
  3210. }
  3211. const Twitter_defaultTasksTemplate = {
  3212. users: [],
  3213. retweets: [],
  3214. likes: []
  3215. };
  3216. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3217. var _verifyId = new WeakMap();
  3218. var Twitter_auth = new WeakMap();
  3219. var Twitter_cache = new WeakMap();
  3220. var Twitter_initialized = new WeakMap();
  3221. var Twitter_verifyAuth = new WeakSet();
  3222. var Twitter_updateAuth = new WeakSet();
  3223. var _toggleUser = new WeakSet();
  3224. var _toggleRetweet = new WeakSet();
  3225. var Twitter_setCache = new WeakSet();
  3226. class Twitter extends social_Social {
  3227. constructor() {
  3228. var _GM_getValue;
  3229. super(...arguments);
  3230. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3231. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3232. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3233. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3234. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3235. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3236. Twitter_defineProperty(this, 'whiteList', {
  3237. ...JSON.parse(Twitter_defaultTasks),
  3238. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3239. });
  3240. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3241. writable: true,
  3242. value: globalOptions.other.twitterVerifyId
  3243. });
  3244. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3245. writable: true,
  3246. value: GM_getValue('twitterAuth') || {}
  3247. });
  3248. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3249. writable: true,
  3250. value: GM_getValue('twitterCache') || {}
  3251. });
  3252. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3253. writable: true,
  3254. value: false
  3255. });
  3256. }
  3257. async init() {
  3258. try {
  3259. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3260. return true;
  3261. }
  3262. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3263. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3264. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3265. return true;
  3266. }
  3267. return false;
  3268. }
  3269. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3270. if (isVerified) {
  3271. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3272. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3273. return true;
  3274. }
  3275. GM_setValue('twitterAuth', null);
  3276. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3277. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3278. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3279. return true;
  3280. }
  3281. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3282. return false;
  3283. } catch (error) {
  3284. throwError(error, 'Twitter.init');
  3285. return false;
  3286. }
  3287. }
  3288. async userName2id(name) {
  3289. try {
  3290. const logStatus = scripts_echoLog({
  3291. type: 'gettingTwitterUserId',
  3292. text: name
  3293. });
  3294. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3295. if (userId) {
  3296. logStatus.success();
  3297. return userId;
  3298. }
  3299. const {
  3300. result,
  3301. statusText,
  3302. status,
  3303. data
  3304. } = await tools_httpRequest({
  3305. 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`,
  3306. method: 'GET',
  3307. headers: {
  3308. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3309. 'content-type': 'application/json',
  3310. referer: `https://twitter.com/${name}`,
  3311. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3312. },
  3313. responseType: 'json'
  3314. });
  3315. if (result === 'Success') {
  3316. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3317. var _response, _response$data, _response$data$user, _response$data$user$r;
  3318. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3319. if (!response) {
  3320. try {
  3321. response = JSON.parse(data.responseText);
  3322. } catch (error) {
  3323. response = null;
  3324. }
  3325. }
  3326. 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);
  3327. if (userId) {
  3328. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3329. logStatus.success();
  3330. return userId;
  3331. }
  3332. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3333. return false;
  3334. }
  3335. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3336. return false;
  3337. }
  3338. logStatus.error(`${result}:${statusText}(${status})`);
  3339. return false;
  3340. } catch (error) {
  3341. throwError(error, 'Twitter.getUserId');
  3342. return false;
  3343. }
  3344. }
  3345. async toggle(_ref) {
  3346. let {
  3347. doTask = true,
  3348. userLinks = [],
  3349. retweetLinks = []
  3350. } = _ref;
  3351. try {
  3352. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3353. scripts_echoLog({
  3354. text: i18n('needInit')
  3355. });
  3356. return false;
  3357. }
  3358. const prom = [];
  3359. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3360. scripts_echoLog({
  3361. type: 'globalOptionsSkip',
  3362. text: 'twitter.users'
  3363. });
  3364. } else {
  3365. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3366. var _link$match;
  3367. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3368. });
  3369. if (realUsers.length > 0) {
  3370. for (const user of realUsers) {
  3371. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3372. name: user,
  3373. doTask: doTask
  3374. }));
  3375. await delay(1e3);
  3376. }
  3377. }
  3378. }
  3379. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3380. scripts_echoLog({
  3381. type: 'globalOptionsSkip',
  3382. text: 'twitter.retweets'
  3383. });
  3384. } else {
  3385. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3386. var _link$match2;
  3387. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3388. });
  3389. if (realRetweets.length > 0) {
  3390. for (const retweet of realRetweets) {
  3391. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3392. retweetId: retweet,
  3393. doTask: doTask
  3394. }));
  3395. await delay(1e3);
  3396. }
  3397. }
  3398. }
  3399. return Promise.all(prom).then(() => true);
  3400. } catch (error) {
  3401. throwError(error, 'Twitter.toggle');
  3402. return false;
  3403. }
  3404. }
  3405. }
  3406. async function Twitter_verifyAuth2() {
  3407. try {
  3408. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3409. name: 'verify',
  3410. doTask: true,
  3411. verify: true
  3412. });
  3413. } catch (error) {
  3414. throwError(error, 'Twitter.verifyAuth');
  3415. return false;
  3416. }
  3417. }
  3418. async function Twitter_updateAuth2() {
  3419. try {
  3420. const logStatus = scripts_echoLog({
  3421. text: i18n('updatingAuth', 'Twitter')
  3422. });
  3423. return await new Promise(resolve => {
  3424. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3425. active: true,
  3426. insert: true,
  3427. setParent: true
  3428. });
  3429. newTab.onclose = async () => {
  3430. const auth = GM_getValue('twitterAuth');
  3431. if (auth) {
  3432. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3433. logStatus.success();
  3434. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3435. } else {
  3436. logStatus.error('Error: Update twitter auth failed!');
  3437. resolve(false);
  3438. }
  3439. };
  3440. });
  3441. } catch (error) {
  3442. throwError(error, 'Twitter.updateToken');
  3443. return false;
  3444. }
  3445. }
  3446. async function _toggleUser2(_ref2) {
  3447. let {
  3448. name,
  3449. doTask = true,
  3450. verify = false
  3451. } = _ref2;
  3452. try {
  3453. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3454. scripts_echoLog({
  3455. type: 'whiteList',
  3456. text: 'Twitter.unfollowUser',
  3457. id: name
  3458. });
  3459. return true;
  3460. }
  3461. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3462. if (!userId) {
  3463. return false;
  3464. }
  3465. const logStatus = verify ? scripts_echoLog({
  3466. text: i18n('verifyingAuth', 'Twitter')
  3467. }) : scripts_echoLog({
  3468. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3469. text: name
  3470. });
  3471. const {
  3472. result,
  3473. statusText,
  3474. status,
  3475. data
  3476. } = await tools_httpRequest({
  3477. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3478. method: 'POST',
  3479. headers: {
  3480. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3481. 'Content-Type': 'application/x-www-form-urlencoded',
  3482. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3483. },
  3484. responseType: 'json',
  3485. data: $.param({
  3486. include_profile_interstitial_type: 1,
  3487. include_blocking: 1,
  3488. include_blocked_by: 1,
  3489. include_followed_by: 1,
  3490. include_want_retweets: 1,
  3491. include_mute_edge: 1,
  3492. include_can_dm: 1,
  3493. include_can_media_tag: 1,
  3494. skip_status: 1,
  3495. id: userId
  3496. })
  3497. });
  3498. if (result === 'Success') {
  3499. var _data$response, _data$response$errors, _data$response$errors2;
  3500. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3501. logStatus.success();
  3502. if (doTask && !verify) {
  3503. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3504. }
  3505. return true;
  3506. }
  3507. 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) {
  3508. logStatus.success();
  3509. return true;
  3510. }
  3511. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3512. return false;
  3513. }
  3514. logStatus.error(`${result}:${statusText}(${status})`);
  3515. return false;
  3516. } catch (error) {
  3517. throwError(error, 'Twitter.toggleUser');
  3518. return false;
  3519. }
  3520. }
  3521. async function _toggleRetweet2(_ref3) {
  3522. let {
  3523. retweetId,
  3524. doTask = true
  3525. } = _ref3;
  3526. try {
  3527. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3528. scripts_echoLog({
  3529. type: 'whiteList',
  3530. text: 'Twitter.unretweet',
  3531. id: retweetId
  3532. });
  3533. return true;
  3534. }
  3535. const logStatus = scripts_echoLog({
  3536. type: `${doTask ? '' : 'un'}retweetting`,
  3537. text: retweetId
  3538. });
  3539. const {
  3540. result,
  3541. statusText,
  3542. status,
  3543. data
  3544. } = await tools_httpRequest({
  3545. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3546. method: 'POST',
  3547. headers: {
  3548. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3549. 'Content-Type': 'application/x-www-form-urlencoded',
  3550. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3551. },
  3552. data: $.param({
  3553. tweet_mode: 'extended',
  3554. id: retweetId
  3555. }),
  3556. responseType: 'json'
  3557. });
  3558. if (result === 'Success') {
  3559. var _data$response2, _data$response2$error, _data$response2$error2;
  3560. 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) {
  3561. logStatus.success();
  3562. if (doTask) {
  3563. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3564. }
  3565. return true;
  3566. }
  3567. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3568. return false;
  3569. }
  3570. logStatus.error(`${result}:${statusText}(${status})`);
  3571. return false;
  3572. } catch (error) {
  3573. throwError(error, 'Twitter.toggleRetweet');
  3574. return false;
  3575. }
  3576. }
  3577. function Twitter_setCache2(name, id) {
  3578. try {
  3579. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3580. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3581. } catch (error) {
  3582. throwError(error, 'Twitter.setCache');
  3583. }
  3584. }
  3585. const social_Twitter = Twitter;
  3586. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3587. Vk_checkPrivateRedeclaration(obj, privateSet);
  3588. privateSet.add(obj);
  3589. }
  3590. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3591. Vk_checkPrivateRedeclaration(obj, privateMap);
  3592. privateMap.set(obj, value);
  3593. }
  3594. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3595. if (privateCollection.has(obj)) {
  3596. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3597. }
  3598. }
  3599. function Vk_defineProperty(obj, key, value) {
  3600. if (key in obj) {
  3601. Object.defineProperty(obj, key, {
  3602. value: value,
  3603. enumerable: true,
  3604. configurable: true,
  3605. writable: true
  3606. });
  3607. } else {
  3608. obj[key] = value;
  3609. }
  3610. return obj;
  3611. }
  3612. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3613. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3614. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3615. return value;
  3616. }
  3617. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3618. if (descriptor.set) {
  3619. descriptor.set.call(receiver, value);
  3620. } else {
  3621. if (!descriptor.writable) {
  3622. throw new TypeError('attempted to set read only private field');
  3623. }
  3624. descriptor.value = value;
  3625. }
  3626. }
  3627. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3628. if (!privateSet.has(receiver)) {
  3629. throw new TypeError('attempted to get private field on non-instance');
  3630. }
  3631. return fn;
  3632. }
  3633. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3634. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3635. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3636. }
  3637. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3638. if (!privateMap.has(receiver)) {
  3639. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3640. }
  3641. return privateMap.get(receiver);
  3642. }
  3643. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3644. if (descriptor.get) {
  3645. return descriptor.get.call(receiver);
  3646. }
  3647. return descriptor.value;
  3648. }
  3649. const Vk_defaultTasksTemplate = {
  3650. names: []
  3651. };
  3652. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3653. var _username = new WeakMap();
  3654. var Vk_cache = new WeakMap();
  3655. var Vk_initialized = new WeakMap();
  3656. var Vk_verifyAuth = new WeakSet();
  3657. var _toggleGroup = new WeakSet();
  3658. var _togglePublic = new WeakSet();
  3659. var _sendWall = new WeakSet();
  3660. var _deleteWall = new WeakSet();
  3661. var _getId = new WeakSet();
  3662. var _toggleVk = new WeakSet();
  3663. var Vk_setCache = new WeakSet();
  3664. class Vk extends social_Social {
  3665. constructor() {
  3666. var _GM_getValue;
  3667. super(...arguments);
  3668. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3669. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3670. Vk_classPrivateMethodInitSpec(this, _getId);
  3671. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3672. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3673. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3674. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3675. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3676. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3677. Vk_defineProperty(this, 'whiteList', {
  3678. ...JSON.parse(Vk_defaultTasks),
  3679. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3680. });
  3681. Vk_classPrivateFieldInitSpec(this, _username, {
  3682. writable: true,
  3683. value: ''
  3684. });
  3685. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3686. writable: true,
  3687. value: GM_getValue('vkCache') || {}
  3688. });
  3689. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3690. writable: true,
  3691. value: false
  3692. });
  3693. }
  3694. async init() {
  3695. try {
  3696. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3697. return true;
  3698. }
  3699. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3700. if (isVerified) {
  3701. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3702. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3703. return true;
  3704. }
  3705. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3706. return false;
  3707. } catch (error) {
  3708. throwError(error, 'Vk.init');
  3709. return false;
  3710. }
  3711. }
  3712. async toggle(_ref) {
  3713. let {
  3714. doTask = true,
  3715. nameLinks = []
  3716. } = _ref;
  3717. try {
  3718. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3719. scripts_echoLog({
  3720. text: i18n('needInit')
  3721. });
  3722. return false;
  3723. }
  3724. const prom = [];
  3725. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3726. scripts_echoLog({
  3727. type: 'globalOptionsSkip',
  3728. text: 'vk.names'
  3729. });
  3730. } else {
  3731. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3732. var _link$match;
  3733. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3734. });
  3735. if (realNames.length > 0) {
  3736. for (const name of realNames) {
  3737. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3738. name: name,
  3739. doTask: doTask
  3740. }));
  3741. await delay(1e3);
  3742. }
  3743. }
  3744. }
  3745. return Promise.all(prom).then(() => true);
  3746. } catch (error) {
  3747. throwError(error, 'Vk.toggle');
  3748. return false;
  3749. }
  3750. }
  3751. }
  3752. async function Vk_verifyAuth2() {
  3753. try {
  3754. const logStatus = scripts_echoLog({
  3755. text: i18n('verifyAuth', 'Vk')
  3756. });
  3757. const {
  3758. result,
  3759. statusText,
  3760. status,
  3761. data
  3762. } = await tools_httpRequest({
  3763. url: 'https://vk.com/im',
  3764. method: 'GET'
  3765. });
  3766. if (result === 'Success') {
  3767. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3768. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3769. return false;
  3770. }
  3771. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3772. var _data$responseText$ma;
  3773. 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]) || '');
  3774. logStatus.success();
  3775. return true;
  3776. }
  3777. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3778. return false;
  3779. }
  3780. logStatus.error(`${result}:${statusText}(${status})`);
  3781. return false;
  3782. } catch (error) {
  3783. throwError(error, 'Vk.verifyAuth');
  3784. return false;
  3785. }
  3786. }
  3787. async function _toggleGroup2(name, dataParam) {
  3788. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3789. try {
  3790. const logStatus = scripts_echoLog({
  3791. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3792. text: name
  3793. });
  3794. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3795. logStatus.success();
  3796. return true;
  3797. }
  3798. const reqData = {
  3799. act: doTask ? 'enter' : 'leave',
  3800. al: 1,
  3801. gid: dataParam.groupId,
  3802. hash: dataParam.groupHash
  3803. };
  3804. if (doTask) {
  3805. reqData.context = '_';
  3806. }
  3807. const {
  3808. result,
  3809. statusText,
  3810. status,
  3811. data
  3812. } = await tools_httpRequest({
  3813. url: 'https://vk.com/al_groups.php',
  3814. method: 'POST',
  3815. headers: {
  3816. origin: 'https://vk.com',
  3817. referer: `https://vk.com/${name}`,
  3818. 'content-type': 'application/x-www-form-urlencoded'
  3819. },
  3820. data: $.param(reqData)
  3821. });
  3822. if (result === 'Success') {
  3823. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3824. logStatus.success();
  3825. if (doTask) {
  3826. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3827. }
  3828. return true;
  3829. }
  3830. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3831. return false;
  3832. }
  3833. logStatus.error(`${result}:${statusText}(${status})`);
  3834. return false;
  3835. } catch (error) {
  3836. throwError(error, 'Vk.toggleGroup');
  3837. return false;
  3838. }
  3839. }
  3840. async function _togglePublic2(name, dataParam) {
  3841. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3842. try {
  3843. const logStatus = scripts_echoLog({
  3844. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3845. text: name
  3846. });
  3847. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3848. logStatus.success();
  3849. return true;
  3850. }
  3851. const {
  3852. result,
  3853. statusText,
  3854. status,
  3855. data
  3856. } = await tools_httpRequest({
  3857. url: 'https://vk.com/al_public.php',
  3858. method: 'POST',
  3859. headers: {
  3860. origin: 'https://vk.com',
  3861. referer: `https://vk.com/${name}`,
  3862. 'content-type': 'application/x-www-form-urlencoded'
  3863. },
  3864. data: $.param({
  3865. act: doTask ? 'a_enter' : 'a_leave',
  3866. al: 1,
  3867. pid: dataParam.publicPid,
  3868. hash: dataParam.publicHash
  3869. })
  3870. });
  3871. if (result === 'Success') {
  3872. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3873. logStatus.success();
  3874. if (doTask) {
  3875. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3876. }
  3877. return true;
  3878. }
  3879. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3880. return false;
  3881. }
  3882. logStatus.error(`${result}:${statusText}(${status})`);
  3883. return false;
  3884. } catch (error) {
  3885. throwError(error, 'Vk.togglePublic');
  3886. return false;
  3887. }
  3888. }
  3889. async function _sendWall2(name) {
  3890. try {
  3891. const logStatus = scripts_echoLog({
  3892. type: 'sendingVkWall',
  3893. text: name
  3894. });
  3895. const {
  3896. result,
  3897. statusText,
  3898. status,
  3899. data
  3900. } = await tools_httpRequest({
  3901. url: 'https://vk.com/like.php',
  3902. method: 'POST',
  3903. headers: {
  3904. origin: 'https://vk.com',
  3905. referer: `https://vk.com/${name}`,
  3906. 'content-type': 'application/x-www-form-urlencoded'
  3907. },
  3908. data: $.param({
  3909. act: 'publish_box',
  3910. al: 1,
  3911. object: name
  3912. })
  3913. });
  3914. if (result === 'Success') {
  3915. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3916. var _data$responseText$ma2;
  3917. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3918. if (hash) {
  3919. const {
  3920. result: resultR,
  3921. statusText: statusTextR,
  3922. status: statusR,
  3923. data: dataR
  3924. } = await tools_httpRequest({
  3925. url: 'https://vk.com/like.php',
  3926. method: 'POST',
  3927. headers: {
  3928. origin: 'https://vk.com',
  3929. referer: `https://vk.com/${name}`,
  3930. 'content-type': 'application/x-www-form-urlencoded'
  3931. },
  3932. data: $.param({
  3933. Message: '',
  3934. act: 'a_do_publish',
  3935. al: 1,
  3936. close_comments: 0,
  3937. friends_only: 0,
  3938. from: 'box',
  3939. hash: hash,
  3940. list: '',
  3941. mark_as_ads: 0,
  3942. mute_notifications: 0,
  3943. object: name,
  3944. ret_data: 1,
  3945. to: 0
  3946. })
  3947. });
  3948. if (resultR === 'Success') {
  3949. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3950. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3951. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3952. 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) {
  3953. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3954. logStatus.success();
  3955. 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);
  3956. 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);
  3957. if (postId && ownerId) {
  3958. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3959. }
  3960. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3961. return true;
  3962. }
  3963. }
  3964. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3965. return false;
  3966. }
  3967. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3968. return false;
  3969. }
  3970. logStatus.error('Error: Get "hash" failed');
  3971. return false;
  3972. }
  3973. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3974. return false;
  3975. }
  3976. logStatus.error(`${result}:${statusText}(${status})`);
  3977. return false;
  3978. } catch (error) {
  3979. throwError(error, 'Vk.sendWall');
  3980. return false;
  3981. }
  3982. }
  3983. async function _deleteWall2(name, dataParams) {
  3984. try {
  3985. const logStatus = scripts_echoLog({
  3986. type: 'deletingVkWall',
  3987. text: name
  3988. });
  3989. const {
  3990. result,
  3991. statusText,
  3992. status,
  3993. data
  3994. } = await tools_httpRequest({
  3995. url: 'https://vk.com/al_wall.php?act=delete',
  3996. method: 'POST',
  3997. headers: {
  3998. origin: 'https://vk.com',
  3999. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  4000. 'content-type': 'application/x-www-form-urlencoded'
  4001. },
  4002. data: $.param({
  4003. act: 'delete',
  4004. al: 1,
  4005. confirm: 0,
  4006. from: 'wkview',
  4007. hash: dataParams.wallHash,
  4008. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  4009. })
  4010. });
  4011. if (result === 'Success') {
  4012. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4013. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  4014. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  4015. 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]) {
  4016. logStatus.success();
  4017. return true;
  4018. }
  4019. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4020. return false;
  4021. }
  4022. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4023. return false;
  4024. }
  4025. logStatus.error(`${result}:${statusText}(${status})`);
  4026. return false;
  4027. } catch (error) {
  4028. throwError(error, 'Vk.deleteWall');
  4029. return false;
  4030. }
  4031. }
  4032. async function _getId2(name, doTask) {
  4033. try {
  4034. let url = `https://vk.com/${name}`;
  4035. if (/^wall-/.test(name)) {
  4036. if (doTask) {
  4037. return {
  4038. type: 'sendWall'
  4039. };
  4040. }
  4041. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  4042. return {
  4043. type: 'unSupport'
  4044. };
  4045. }
  4046. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  4047. }
  4048. const logStatus = scripts_echoLog({
  4049. type: 'gettingVkId',
  4050. text: name
  4051. });
  4052. const {
  4053. result,
  4054. statusText,
  4055. status,
  4056. data
  4057. } = await tools_httpRequest({
  4058. url: url,
  4059. method: 'GET'
  4060. });
  4061. if (result === 'Success') {
  4062. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4063. var _data$responseText$ma3, _data$responseText$ma4;
  4064. const [ , groupAct, groupId, , groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), (&#39;|')(.*?)(&#39;|')/) || [];
  4065. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4066. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4067. const publicJoined = !data.responseText.includes('Public.subscribe');
  4068. if (groupAct && groupId && groupHash) {
  4069. logStatus.success();
  4070. return {
  4071. groupAct: groupAct,
  4072. groupId: groupId,
  4073. groupHash: groupHash,
  4074. type: 'group'
  4075. };
  4076. } else if (publicHash && publicPid) {
  4077. logStatus.success();
  4078. return {
  4079. publicHash: publicHash,
  4080. publicPid: publicPid,
  4081. publicJoined: publicJoined,
  4082. type: 'public'
  4083. };
  4084. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4085. var _data$responseText$ma5;
  4086. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4087. if (wallHash) {
  4088. logStatus.success();
  4089. return {
  4090. type: 'deleteWall',
  4091. wallHash: wallHash
  4092. };
  4093. }
  4094. } else if (name.includes('wall') && doTask) {
  4095. logStatus.success();
  4096. return {
  4097. type: 'sendWall'
  4098. };
  4099. }
  4100. logStatus.error('Error: Parameters not found!');
  4101. return false;
  4102. }
  4103. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4104. return false;
  4105. }
  4106. logStatus.error(`${result}:${statusText}(${status})`);
  4107. return false;
  4108. } catch (error) {
  4109. throwError(error, 'Vk.getId');
  4110. return false;
  4111. }
  4112. }
  4113. async function _toggleVk2(_ref2) {
  4114. let {
  4115. name,
  4116. doTask = true
  4117. } = _ref2;
  4118. try {
  4119. if (!doTask && this.whiteList.names.includes(name)) {
  4120. scripts_echoLog({
  4121. type: 'whiteList',
  4122. text: 'Vk.undoTask',
  4123. id: name
  4124. });
  4125. return true;
  4126. }
  4127. const formatName = name.replace(/\/$/, '');
  4128. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4129. if (!data) {
  4130. return false;
  4131. }
  4132. switch (data.type) {
  4133. case 'group':
  4134. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4135.  
  4136. case 'public':
  4137. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4138.  
  4139. case 'sendWall':
  4140. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4141.  
  4142. case 'deleteWall':
  4143. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4144.  
  4145. default:
  4146. return false;
  4147. }
  4148. } catch (error) {
  4149. throwError(error, 'Vk.toggleVk');
  4150. return false;
  4151. }
  4152. }
  4153. function Vk_setCache2(name, postId) {
  4154. try {
  4155. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4156. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4157. } catch (error) {
  4158. throwError(error, 'Vk.setCache');
  4159. }
  4160. }
  4161. const social_Vk = Vk;
  4162. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4163. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4164. privateSet.add(obj);
  4165. }
  4166. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4167. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4168. privateMap.set(obj, value);
  4169. }
  4170. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4171. if (privateCollection.has(obj)) {
  4172. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4173. }
  4174. }
  4175. function Youtube_defineProperty(obj, key, value) {
  4176. if (key in obj) {
  4177. Object.defineProperty(obj, key, {
  4178. value: value,
  4179. enumerable: true,
  4180. configurable: true,
  4181. writable: true
  4182. });
  4183. } else {
  4184. obj[key] = value;
  4185. }
  4186. return obj;
  4187. }
  4188. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4189. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4190. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4191. return value;
  4192. }
  4193. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4194. if (descriptor.set) {
  4195. descriptor.set.call(receiver, value);
  4196. } else {
  4197. if (!descriptor.writable) {
  4198. throw new TypeError('attempted to set read only private field');
  4199. }
  4200. descriptor.value = value;
  4201. }
  4202. }
  4203. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4204. if (!privateSet.has(receiver)) {
  4205. throw new TypeError('attempted to get private field on non-instance');
  4206. }
  4207. return fn;
  4208. }
  4209. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4210. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4211. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4212. }
  4213. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4214. if (!privateMap.has(receiver)) {
  4215. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4216. }
  4217. return privateMap.get(receiver);
  4218. }
  4219. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4220. if (descriptor.get) {
  4221. return descriptor.get.call(receiver);
  4222. }
  4223. return descriptor.value;
  4224. }
  4225. const Youtube_defaultTasksTemplate = {
  4226. channels: [],
  4227. likes: []
  4228. };
  4229. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4230. const getInfo = async function(link, type) {
  4231. try {
  4232. const logStatus = scripts_echoLog({
  4233. text: i18n('gettingYtbToken')
  4234. });
  4235. const {
  4236. result,
  4237. statusText,
  4238. status,
  4239. data
  4240. } = await tools_httpRequest({
  4241. url: link,
  4242. method: 'GET'
  4243. });
  4244. if (result === 'Success') {
  4245. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4246. var _data$responseText$ma, _ref;
  4247. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4248. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4249. return {
  4250. needLogin: true
  4251. };
  4252. }
  4253. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4254. 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]) || '{}';
  4255. const {
  4256. client,
  4257. request
  4258. } = JSON.parse(context);
  4259. if (apiKey && client && request) {
  4260. client.hl = 'en';
  4261. if (type === 'channel') {
  4262. var _data$responseText$ma2;
  4263. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4264. if (channelId) {
  4265. logStatus.success();
  4266. return {
  4267. params: {
  4268. apiKey: apiKey,
  4269. client: client,
  4270. request: request,
  4271. channelId: channelId
  4272. }
  4273. };
  4274. }
  4275. logStatus.error('Error: Get "channelId" failed!');
  4276. return {};
  4277. } else if (type === 'likeVideo') {
  4278. var _data$responseText$ma3, _data$responseText$ma4;
  4279. 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];
  4280. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4281. if (videoId) {
  4282. logStatus.success();
  4283. return {
  4284. params: {
  4285. apiKey: apiKey,
  4286. client: client,
  4287. request: request,
  4288. videoId: videoId,
  4289. likeParams: likeParams
  4290. }
  4291. };
  4292. }
  4293. logStatus.error('Error: Get "videoId" failed!');
  4294. return {};
  4295. }
  4296. logStatus.error('Error: Unknown type');
  4297. return {};
  4298. }
  4299. logStatus.error('Error: Parameter "apiKey" not found!');
  4300. return {};
  4301. }
  4302. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4303. return {};
  4304. }
  4305. logStatus.error(`${result}:${statusText}(${status})`);
  4306. return {};
  4307. } catch (error) {
  4308. throwError(error, 'Youtube.getInfo');
  4309. return {};
  4310. }
  4311. };
  4312. var Youtube_auth = new WeakMap();
  4313. var Youtube_initialized = new WeakMap();
  4314. var _verifyChannel = new WeakMap();
  4315. var Youtube_verifyAuth = new WeakSet();
  4316. var Youtube_updateAuth = new WeakSet();
  4317. var _getInfo = new WeakSet();
  4318. var Youtube_toggleChannel = new WeakSet();
  4319. var _toggleLikeVideo = new WeakSet();
  4320. class Youtube extends social_Social {
  4321. constructor() {
  4322. var _GM_getValue;
  4323. super(...arguments);
  4324. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4325. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4326. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4327. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4328. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4329. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4330. Youtube_defineProperty(this, 'whiteList', {
  4331. ...JSON.parse(Youtube_defaultTasks),
  4332. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4333. });
  4334. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4335. writable: true,
  4336. value: GM_getValue('youtubeAuth') || {}
  4337. });
  4338. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4339. writable: true,
  4340. value: false
  4341. });
  4342. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4343. writable: true,
  4344. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4345. });
  4346. }
  4347. async init() {
  4348. try {
  4349. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4350. return true;
  4351. }
  4352. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4353. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4354. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4355. return true;
  4356. }
  4357. return false;
  4358. }
  4359. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4360. if (isVerified) {
  4361. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4362. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4363. return true;
  4364. }
  4365. GM_setValue('youtubeAuth', null);
  4366. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4367. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4368. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4369. return true;
  4370. }
  4371. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4372. return false;
  4373. } catch (error) {
  4374. throwError(error, 'Youtube.init');
  4375. return false;
  4376. }
  4377. }
  4378. async toggle(_ref2) {
  4379. let {
  4380. doTask = true,
  4381. channelLinks = [],
  4382. videoLinks = []
  4383. } = _ref2;
  4384. try {
  4385. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4386. scripts_echoLog({
  4387. text: i18n('needInit')
  4388. });
  4389. return false;
  4390. }
  4391. const prom = [];
  4392. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4393. scripts_echoLog({
  4394. type: 'globalOptionsSkip',
  4395. text: 'youtube.channels'
  4396. });
  4397. } else {
  4398. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4399. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4400. var _link$match;
  4401. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4402. }
  4403. return link;
  4404. });
  4405. if (realChannels.length > 0) {
  4406. for (const channel of realChannels) {
  4407. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4408. link: channel,
  4409. doTask: doTask
  4410. }));
  4411. await delay(1e3);
  4412. }
  4413. }
  4414. }
  4415. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4416. scripts_echoLog({
  4417. type: 'globalOptionsSkip',
  4418. text: 'youtube.likes'
  4419. });
  4420. } else {
  4421. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4422. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4423. var _link$match2;
  4424. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4425. }
  4426. return link;
  4427. });
  4428. if (realLikes.length > 0) {
  4429. for (const video of realLikes) {
  4430. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4431. link: video,
  4432. doTask: doTask
  4433. }));
  4434. await delay(1e3);
  4435. }
  4436. }
  4437. }
  4438. return Promise.all(prom).then(() => true);
  4439. } catch (error) {
  4440. throwError(error, 'Youtube.toggle');
  4441. return false;
  4442. }
  4443. }
  4444. }
  4445. async function Youtube_verifyAuth2() {
  4446. try {
  4447. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4448. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4449. doTask: true,
  4450. verify: true
  4451. });
  4452. } catch (error) {
  4453. throwError(error, 'Youtube.verifyAuth');
  4454. return false;
  4455. }
  4456. }
  4457. async function Youtube_updateAuth2() {
  4458. try {
  4459. const logStatus = scripts_echoLog({
  4460. text: i18n('updatingAuth', 'Youtube')
  4461. });
  4462. return await new Promise(resolve => {
  4463. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4464. active: true,
  4465. insert: true,
  4466. setParent: true
  4467. });
  4468. newTab.onclose = async () => {
  4469. const auth = GM_getValue('youtubeAuth');
  4470. if (auth) {
  4471. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4472. logStatus.success();
  4473. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4474. resolve(result);
  4475. });
  4476. } else {
  4477. logStatus.error('Error: Update youtube auth failed!');
  4478. resolve(false);
  4479. }
  4480. };
  4481. });
  4482. } catch (error) {
  4483. throwError(error, 'Discord.updateAuth');
  4484. return false;
  4485. }
  4486. }
  4487. function _getInfo2(link, type) {
  4488. return getInfo(link, type);
  4489. }
  4490. async function Youtube_toggleChannel2(_ref3) {
  4491. let {
  4492. link,
  4493. doTask = true,
  4494. verify = false
  4495. } = _ref3;
  4496. try {
  4497. const {
  4498. params,
  4499. needLogin
  4500. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4501. const {
  4502. apiKey,
  4503. client,
  4504. request,
  4505. channelId
  4506. } = params || {};
  4507. if (needLogin) {
  4508. scripts_echoLog({
  4509. html: i18n('loginYtb')
  4510. });
  4511. return false;
  4512. }
  4513. if (!(apiKey && client && request && channelId)) {
  4514. scripts_echoLog({
  4515. text: '"getYtbToken" failed'
  4516. });
  4517. return false;
  4518. }
  4519. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4520. scripts_echoLog({
  4521. type: 'whiteList',
  4522. text: 'Youtube.unfollowChannel',
  4523. id: channelId
  4524. });
  4525. return true;
  4526. }
  4527. const logStatus = verify ? scripts_echoLog({
  4528. text: i18n('verifyingAuth', 'Youtube')
  4529. }) : scripts_echoLog({
  4530. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4531. text: channelId
  4532. });
  4533. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4534. const {
  4535. result,
  4536. statusText,
  4537. status,
  4538. data
  4539. } = await tools_httpRequest({
  4540. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4541. method: 'POST',
  4542. headers: {
  4543. origin: 'https://www.youtube.com',
  4544. referer: `https://www.youtube.com/channel/${channelId}`,
  4545. 'content-type': 'application/json',
  4546. 'x-goog-authuser': '0',
  4547. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4548. 'x-origin': 'https://www.youtube.com',
  4549. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4550. },
  4551. data: JSON.stringify({
  4552. context: {
  4553. client: client,
  4554. request: {
  4555. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4556. internalExperimentFlags: [],
  4557. consistencyTokenJars: []
  4558. },
  4559. user: {}
  4560. },
  4561. channelIds: [ channelId ],
  4562. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4563. })
  4564. });
  4565. if (result === 'Success') {
  4566. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4567. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4568. logStatus.success();
  4569. if (doTask && !verify) {
  4570. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4571. }
  4572. return true;
  4573. }
  4574. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4575. logStatus.success();
  4576. return true;
  4577. }
  4578. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4579. return false;
  4580. }
  4581. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4582. return false;
  4583. }
  4584. logStatus.error(`${result}:${statusText}(${status})`);
  4585. return false;
  4586. } catch (error) {
  4587. throwError(error, 'Youtube.toggleChannel');
  4588. return false;
  4589. }
  4590. }
  4591. async function _toggleLikeVideo2(_ref4) {
  4592. let {
  4593. link,
  4594. doTask = true
  4595. } = _ref4;
  4596. try {
  4597. const {
  4598. params,
  4599. needLogin
  4600. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4601. const {
  4602. apiKey,
  4603. client,
  4604. request,
  4605. videoId,
  4606. likeParams
  4607. } = params || {};
  4608. if (needLogin) {
  4609. scripts_echoLog({
  4610. html: `${i18n('loginYtb')}`
  4611. });
  4612. return false;
  4613. }
  4614. if (!(apiKey && client && request && videoId && likeParams)) {
  4615. scripts_echoLog({
  4616. text: '"getYtbToken" failed'
  4617. });
  4618. return false;
  4619. }
  4620. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4621. scripts_echoLog({
  4622. type: 'whiteList',
  4623. text: 'Youtube.unlikeVideo',
  4624. id: videoId
  4625. });
  4626. return true;
  4627. }
  4628. const logStatus = scripts_echoLog({
  4629. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4630. text: videoId
  4631. });
  4632. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4633. const likeVideoData = {
  4634. context: {
  4635. client: client,
  4636. request: {
  4637. sessionId: request.sessionId,
  4638. internalExperimentFlags: [],
  4639. consistencyTokenJars: []
  4640. },
  4641. user: {}
  4642. },
  4643. target: {
  4644. videoId: videoId
  4645. }
  4646. };
  4647. if (doTask) {
  4648. if (likeParams) {
  4649. likeVideoData.params = likeParams;
  4650. } else {
  4651. logStatus.error('Empty likeParams');
  4652. return false;
  4653. }
  4654. }
  4655. const {
  4656. result,
  4657. statusText,
  4658. status,
  4659. data
  4660. } = await tools_httpRequest({
  4661. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4662. method: 'POST',
  4663. headers: {
  4664. origin: 'https://www.youtube.com',
  4665. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4666. 'content-type': 'application/json',
  4667. 'x-goog-authuser': '0',
  4668. 'x-goog-visitor-id': client.visitorData,
  4669. 'x-origin': 'https://www.youtube.com',
  4670. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4671. },
  4672. data: JSON.stringify(likeVideoData)
  4673. });
  4674. if (result === 'Success') {
  4675. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4676. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4677. logStatus.success();
  4678. if (doTask) {
  4679. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4680. }
  4681. return true;
  4682. }
  4683. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4684. return false;
  4685. }
  4686. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4687. return false;
  4688. }
  4689. logStatus.error(`${result}:${statusText}(${status})`);
  4690. return false;
  4691. } catch (error) {
  4692. throwError(error, 'Youtube.toggleLikeVideo');
  4693. return false;
  4694. }
  4695. }
  4696. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4697. Steam_checkPrivateRedeclaration(obj, privateSet);
  4698. privateSet.add(obj);
  4699. }
  4700. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4701. Steam_checkPrivateRedeclaration(obj, privateMap);
  4702. privateMap.set(obj, value);
  4703. }
  4704. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4705. if (privateCollection.has(obj)) {
  4706. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4707. }
  4708. }
  4709. function Steam_defineProperty(obj, key, value) {
  4710. if (key in obj) {
  4711. Object.defineProperty(obj, key, {
  4712. value: value,
  4713. enumerable: true,
  4714. configurable: true,
  4715. writable: true
  4716. });
  4717. } else {
  4718. obj[key] = value;
  4719. }
  4720. return obj;
  4721. }
  4722. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4723. if (!privateSet.has(receiver)) {
  4724. throw new TypeError('attempted to get private field on non-instance');
  4725. }
  4726. return fn;
  4727. }
  4728. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4729. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4730. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4731. return value;
  4732. }
  4733. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4734. if (descriptor.set) {
  4735. descriptor.set.call(receiver, value);
  4736. } else {
  4737. if (!descriptor.writable) {
  4738. throw new TypeError('attempted to set read only private field');
  4739. }
  4740. descriptor.value = value;
  4741. }
  4742. }
  4743. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4744. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4745. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4746. }
  4747. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4748. if (!privateMap.has(receiver)) {
  4749. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4750. }
  4751. return privateMap.get(receiver);
  4752. }
  4753. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4754. if (descriptor.get) {
  4755. return descriptor.get.call(receiver);
  4756. }
  4757. return descriptor.value;
  4758. }
  4759. const Steam_defaultTasksTemplate = {
  4760. groups: [],
  4761. officialGroups: [],
  4762. wishlists: [],
  4763. follows: [],
  4764. forums: [],
  4765. workshops: [],
  4766. workshopVotes: [],
  4767. curators: [],
  4768. curatorLikes: [],
  4769. announcements: [],
  4770. licenses: [],
  4771. playtests: []
  4772. };
  4773. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4774. var Steam_cache = new WeakMap();
  4775. var Steam_auth = new WeakMap();
  4776. var _storeInitialized = new WeakMap();
  4777. var _communityInitialized = new WeakMap();
  4778. var _area = new WeakMap();
  4779. var _areaStatus = new WeakMap();
  4780. var _updateStoreAuth = new WeakSet();
  4781. var _updateCommunityAuth = new WeakSet();
  4782. var _getAreaInfo = new WeakSet();
  4783. var _changeArea = new WeakSet();
  4784. var _joinGroup = new WeakSet();
  4785. var _leaveGroup = new WeakSet();
  4786. var _getGroupId = new WeakSet();
  4787. var _joinOfficialGroup = new WeakSet();
  4788. var _leaveOfficialGroup = new WeakSet();
  4789. var _getOfficialGroupId = new WeakSet();
  4790. var _addToWishlist = new WeakSet();
  4791. var _removeFromWishlist = new WeakSet();
  4792. var _toggleFollowGame = new WeakSet();
  4793. var _isFollowedGame = new WeakSet();
  4794. var _toggleForum = new WeakSet();
  4795. var _getForumId = new WeakSet();
  4796. var _toggleFavoriteWorkshop = new WeakSet();
  4797. var _getWorkshopAppId = new WeakSet();
  4798. var _voteUpWorkshop = new WeakSet();
  4799. var _toggleCurator = new WeakSet();
  4800. var _toggleCuratorLike = new WeakSet();
  4801. var _getAnnouncementParams = new WeakSet();
  4802. var _likeAnnouncement = new WeakSet();
  4803. var _appid2subid = new WeakSet();
  4804. var _getLicenses = new WeakSet();
  4805. var _addLicense = new WeakSet();
  4806. var _addFreeLicense = new WeakSet();
  4807. var _requestPlayTestAccess = new WeakSet();
  4808. var Steam_setCache = new WeakSet();
  4809. class Steam extends social_Social {
  4810. constructor() {
  4811. var _GM_getValue;
  4812. super(...arguments);
  4813. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4814. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4815. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4816. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4817. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4818. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4819. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4820. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4821. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4822. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4823. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4824. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4825. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4826. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4827. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4828. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4829. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4830. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4831. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4832. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4833. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4834. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4835. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4836. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4837. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4838. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4839. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4840. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4841. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4842. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4843. Steam_defineProperty(this, 'whiteList', {
  4844. ...JSON.parse(Steam_defaultTasks),
  4845. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4846. });
  4847. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4848. writable: true,
  4849. value: {
  4850. ...{
  4851. group: {},
  4852. officialGroup: {},
  4853. forum: {},
  4854. workshop: {},
  4855. curator: {}
  4856. },
  4857. ...GM_getValue('steamCache')
  4858. }
  4859. });
  4860. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4861. writable: true,
  4862. value: {}
  4863. });
  4864. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4865. writable: true,
  4866. value: false
  4867. });
  4868. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4869. writable: true,
  4870. value: false
  4871. });
  4872. Steam_classPrivateFieldInitSpec(this, _area, {
  4873. writable: true,
  4874. value: 'CN'
  4875. });
  4876. Steam_classPrivateFieldInitSpec(this, _areaStatus, {
  4877. writable: true,
  4878. value: 'end'
  4879. });
  4880. }
  4881. async init() {
  4882. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4883. try {
  4884. if (type === 'store') {
  4885. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4886. return true;
  4887. }
  4888. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4889. if (!Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4890. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4891. return false;
  4892. }
  4893. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4894. return true;
  4895. }
  4896. if (type === 'community') {
  4897. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4898. return true;
  4899. }
  4900. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4901. if (!Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4902. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4903. return false;
  4904. }
  4905. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4906. return true;
  4907. }
  4908. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4909. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4910. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4911. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4912. return true;
  4913. }
  4914. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4915. return false;
  4916. } catch (error) {
  4917. throwError(error, 'Steam.init');
  4918. return false;
  4919. }
  4920. }
  4921. async getCuratorId(path, name) {
  4922. try {
  4923. const logStatus = scripts_echoLog({
  4924. type: 'gettingCuratorId',
  4925. text: `${path}/${name}`
  4926. });
  4927. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4928. if (curatorId) {
  4929. logStatus.success();
  4930. return curatorId;
  4931. }
  4932. const {
  4933. result,
  4934. statusText,
  4935. status,
  4936. data
  4937. } = await tools_httpRequest({
  4938. url: `https://store.steampowered.com/${path}/${name}`,
  4939. method: 'GET',
  4940. headers: {
  4941. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4942. }
  4943. });
  4944. if (result === 'Success') {
  4945. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4946. var _data$responseText$ma;
  4947. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4948. if (curatorId) {
  4949. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4950. logStatus.success();
  4951. return curatorId;
  4952. }
  4953. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4954. return false;
  4955. }
  4956. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4957. return false;
  4958. }
  4959. logStatus.error(`${result}:${statusText}(${status})`);
  4960. return false;
  4961. } catch (error) {
  4962. throwError(error, 'Steam.getCuratorID');
  4963. return false;
  4964. }
  4965. }
  4966. async toggle(_ref) {
  4967. let {
  4968. doTask = true,
  4969. groupLinks = [],
  4970. officialGroupLinks = [],
  4971. wishlistLinks = [],
  4972. followLinks = [],
  4973. forumLinks = [],
  4974. workshopLinks = [],
  4975. workshopVoteLinks = [],
  4976. curatorLinks = [],
  4977. curatorLikeLinks = [],
  4978. announcementLinks = [],
  4979. licenseLinks = [],
  4980. playtestLinks = []
  4981. } = _ref;
  4982. try {
  4983. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4984. scripts_echoLog({
  4985. text: i18n('needInit')
  4986. });
  4987. return false;
  4988. }
  4989. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4990. scripts_echoLog({
  4991. text: i18n('needInit')
  4992. });
  4993. return false;
  4994. }
  4995. const prom = [];
  4996. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4997. scripts_echoLog({
  4998. type: 'globalOptionsSkip',
  4999. text: 'steam.groups'
  5000. });
  5001. } else {
  5002. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  5003. var _link$match;
  5004. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  5005. });
  5006. if (realGroups.length > 0) {
  5007. for (const group of realGroups) {
  5008. if (doTask) {
  5009. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  5010. } else {
  5011. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  5012. }
  5013. await delay(1e3);
  5014. }
  5015. }
  5016. }
  5017. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  5018. scripts_echoLog({
  5019. type: 'globalOptionsSkip',
  5020. text: 'steam.officialGroups'
  5021. });
  5022. } else {
  5023. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  5024. var _link$match2;
  5025. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  5026. });
  5027. if (realOfficialGroups.length > 0) {
  5028. for (const officialGroup of realOfficialGroups) {
  5029. if (doTask) {
  5030. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  5031. } else {
  5032. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  5033. }
  5034. await delay(1e3);
  5035. }
  5036. }
  5037. }
  5038. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  5039. scripts_echoLog({
  5040. type: 'globalOptionsSkip',
  5041. text: 'steam.wishlists'
  5042. });
  5043. } else {
  5044. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  5045. var _link$match3;
  5046. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5047. });
  5048. if (realWishlists.length > 0) {
  5049. for (const game of realWishlists) {
  5050. if (doTask) {
  5051. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  5052. } else {
  5053. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  5054. }
  5055. await delay(1e3);
  5056. }
  5057. }
  5058. }
  5059. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5060. scripts_echoLog({
  5061. type: 'globalOptionsSkip',
  5062. text: 'steam.follows'
  5063. });
  5064. } else {
  5065. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5066. var _link$match4;
  5067. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5068. });
  5069. if (realFollows.length > 0) {
  5070. for (const game of realFollows) {
  5071. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  5072. await delay(1e3);
  5073. }
  5074. }
  5075. }
  5076. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5077. scripts_echoLog({
  5078. type: 'globalOptionsSkip',
  5079. text: 'steam.forums'
  5080. });
  5081. } else {
  5082. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5083. var _link$match5;
  5084. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5085. });
  5086. if (realForums.length > 0) {
  5087. for (const forum of realForums) {
  5088. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5089. await delay(1e3);
  5090. }
  5091. }
  5092. }
  5093. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5094. scripts_echoLog({
  5095. type: 'globalOptionsSkip',
  5096. text: 'steam.workshops'
  5097. });
  5098. } else {
  5099. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5100. var _link$match6;
  5101. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5102. });
  5103. if (realWorkshops.length > 0) {
  5104. for (const workshop of realWorkshops) {
  5105. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5106. await delay(1e3);
  5107. }
  5108. }
  5109. }
  5110. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5111. scripts_echoLog({
  5112. type: 'globalOptionsSkip',
  5113. text: 'steam.workshopVotes'
  5114. });
  5115. } else {
  5116. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5117. var _link$match7;
  5118. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5119. });
  5120. if (doTask && realworkshopVotes.length > 0) {
  5121. for (const workshop of realworkshopVotes) {
  5122. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5123. await delay(1e3);
  5124. }
  5125. }
  5126. }
  5127. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5128. scripts_echoLog({
  5129. type: 'globalOptionsSkip',
  5130. text: 'steam.curators'
  5131. });
  5132. } else {
  5133. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5134. var _link$match8;
  5135. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5136. });
  5137. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5138. var _link$match9;
  5139. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5140. });
  5141. if (realCurators.length > 0) {
  5142. for (const curator of realCurators) {
  5143. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5144. await delay(1e3);
  5145. }
  5146. }
  5147. if (realCuratorLikes.length > 0) {
  5148. for (const curatorLike of realCuratorLikes) {
  5149. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5150. await delay(1e3);
  5151. }
  5152. }
  5153. }
  5154. if (doTask && !globalOptions.doTask.steam.announcements) {
  5155. scripts_echoLog({
  5156. type: 'globalOptionsSkip',
  5157. text: 'steam.announcements'
  5158. });
  5159. } else {
  5160. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5161. var _link$match11;
  5162. if (link.includes('store.steampowered.com')) {
  5163. var _link$match10;
  5164. 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('/');
  5165. }
  5166. 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('/');
  5167. });
  5168. if (doTask && realAnnouncements.length > 0) {
  5169. for (const id of realAnnouncements) {
  5170. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5171. await delay(1e3);
  5172. }
  5173. }
  5174. }
  5175. if (doTask && !globalOptions.doTask.steam.licenses) {
  5176. scripts_echoLog({
  5177. type: 'globalOptionsSkip',
  5178. text: 'steam.licenses'
  5179. });
  5180. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5181. for (const id of licenseLinks) {
  5182. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5183. await delay(1e3);
  5184. }
  5185. }
  5186. if (doTask && !globalOptions.doTask.steam.playtests) {
  5187. scripts_echoLog({
  5188. type: 'globalOptionsSkip',
  5189. text: 'steam.playtests'
  5190. });
  5191. } else {
  5192. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5193. var _link$match12;
  5194. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5195. });
  5196. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5197. for (const id of realPlaytests) {
  5198. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5199. await delay(1e3);
  5200. }
  5201. }
  5202. }
  5203. return Promise.all(prom).then(async () => {
  5204. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5205. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5206. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5207. }
  5208. return true;
  5209. });
  5210. } catch (error) {
  5211. throwError(error, 'Steam.toggle');
  5212. return false;
  5213. }
  5214. }
  5215. }
  5216. async function _updateStoreAuth2() {
  5217. try {
  5218. const logStatus = scripts_echoLog({
  5219. text: i18n('updatingAuth', i18n('steamStore'))
  5220. });
  5221. const {
  5222. result,
  5223. statusText,
  5224. status,
  5225. data
  5226. } = await tools_httpRequest({
  5227. url: 'https://store.steampowered.com/stats/',
  5228. method: 'GET'
  5229. });
  5230. if (result === 'Success') {
  5231. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5232. var _data$responseText$ma2;
  5233. if (!data.responseText.includes('data-miniprofile=')) {
  5234. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5235. return false;
  5236. }
  5237. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5238. if (storeSessionID) {
  5239. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5240. logStatus.success();
  5241. return true;
  5242. }
  5243. logStatus.error('Error: Get "sessionID" failed');
  5244. return false;
  5245. }
  5246. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5247. return false;
  5248. }
  5249. logStatus.error(`${result}:${statusText}(${status})`);
  5250. return false;
  5251. } catch (error) {
  5252. throwError(error, 'Steam.updateStoreAuth');
  5253. return false;
  5254. }
  5255. }
  5256. async function _updateCommunityAuth2() {
  5257. try {
  5258. const logStatus = scripts_echoLog({
  5259. text: i18n('updatingAuth', i18n('steamCommunity'))
  5260. });
  5261. const {
  5262. result,
  5263. statusText,
  5264. status,
  5265. data
  5266. } = await tools_httpRequest({
  5267. url: 'https://steamcommunity.com/my',
  5268. method: 'GET'
  5269. });
  5270. if (result === 'Success') {
  5271. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5272. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5273. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5274. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5275. return false;
  5276. }
  5277. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5278. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5279. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5280. if (steam64Id) {
  5281. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5282. }
  5283. if (userName) {
  5284. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5285. }
  5286. if (communitySessionID) {
  5287. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5288. logStatus.success();
  5289. return true;
  5290. }
  5291. logStatus.error('Error: Get "sessionID" failed');
  5292. return false;
  5293. }
  5294. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5295. return false;
  5296. }
  5297. logStatus.error(`${result}:${statusText}(${status})`);
  5298. return false;
  5299. } catch (error) {
  5300. throwError(error, 'Steam.updateCommunityAuth');
  5301. return false;
  5302. }
  5303. }
  5304. async function _getAreaInfo2() {
  5305. try {
  5306. const logStatus = scripts_echoLog({
  5307. text: i18n('gettingAreaInfo')
  5308. });
  5309. const {
  5310. result,
  5311. statusText,
  5312. status,
  5313. data
  5314. } = await tools_httpRequest({
  5315. url: 'https://store.steampowered.com/cart/',
  5316. method: 'GET'
  5317. });
  5318. if (result === 'Success') {
  5319. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5320. var _data$responseText$ma6;
  5321. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5322. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5323. if (currentArea && areas.length > 0) {
  5324. Steam_classPrivateFieldSet(this, _area, currentArea);
  5325. logStatus.success();
  5326. return {
  5327. currentArea: currentArea,
  5328. areas: areas
  5329. };
  5330. }
  5331. logStatus.error('Error: get country info filed');
  5332. return {};
  5333. }
  5334. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5335. return {};
  5336. }
  5337. logStatus.error(`${result}:${statusText}(${status})`);
  5338. return {};
  5339. } catch (error) {
  5340. throwError(error, 'Steam.getAreaInfo');
  5341. return {};
  5342. }
  5343. }
  5344. async function _changeArea2(area) {
  5345. try {
  5346. if (Steam_classPrivateFieldGet(this, _areaStatus) === 'waiting') {
  5347. await new Promise(resolve => {
  5348. const checker = setInterval(() => {
  5349. if (Steam_classPrivateFieldGet(this, _areaStatus) !== 'waiting') {
  5350. clearInterval(checker);
  5351. resolve(true);
  5352. }
  5353. });
  5354. });
  5355. }
  5356. if (Steam_classPrivateFieldGet(this, _area) === area || !area && Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5357. return true;
  5358. }
  5359. Steam_classPrivateFieldSet(this, _areaStatus, 'waiting');
  5360. let aimedArea = area;
  5361. if (!aimedArea) {
  5362. const {
  5363. currentArea,
  5364. areas
  5365. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5366. if (!currentArea || !areas) {
  5367. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5368. return false;
  5369. }
  5370. if (currentArea !== 'CN') {
  5371. Steam_classPrivateFieldSet(this, _areaStatus, 'skip');
  5372. scripts_echoLog({
  5373. text: 'notNeededChangeArea'
  5374. });
  5375. return 'skip';
  5376. }
  5377. const anotherArea = areas.filter(area => area && area !== 'CN');
  5378. if (!anotherArea || anotherArea.length === 0) {
  5379. Steam_classPrivateFieldSet(this, _areaStatus, 'noAnotherArea');
  5380. scripts_echoLog({
  5381. text: 'noAnotherArea'
  5382. });
  5383. return false;
  5384. }
  5385. [ aimedArea ] = anotherArea;
  5386. }
  5387. const logStatus = scripts_echoLog({
  5388. text: i18n('changingArea', aimedArea)
  5389. });
  5390. const {
  5391. result,
  5392. statusText,
  5393. status,
  5394. data
  5395. } = await tools_httpRequest({
  5396. url: 'https://store.steampowered.com/account/setcountry',
  5397. method: 'POST',
  5398. headers: {
  5399. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5400. },
  5401. data: $.param({
  5402. cc: aimedArea,
  5403. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5404. })
  5405. });
  5406. if (result === 'Success') {
  5407. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5408. const {
  5409. currentArea
  5410. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5411. if (currentArea === aimedArea) {
  5412. Steam_classPrivateFieldSet(this, _areaStatus, 'success');
  5413. logStatus.success();
  5414. return currentArea;
  5415. }
  5416. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5417. logStatus.error('Error: change country filed');
  5418. return 'CN';
  5419. }
  5420. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5421. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5422. return 'CN';
  5423. }
  5424. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5425. logStatus.error(`${result}:${statusText}(${status})`);
  5426. return 'CN';
  5427. } catch (error) {
  5428. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5429. throwError(error, 'Steam.changeArea');
  5430. return false;
  5431. }
  5432. }
  5433. async function _joinGroup2(groupName) {
  5434. try {
  5435. const logStatus = scripts_echoLog({
  5436. type: 'joiningSteamGroup',
  5437. text: groupName
  5438. });
  5439. const {
  5440. result,
  5441. statusText,
  5442. status,
  5443. data
  5444. } = await tools_httpRequest({
  5445. url: `https://steamcommunity.com/groups/${groupName}`,
  5446. method: 'POST',
  5447. headers: {
  5448. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5449. },
  5450. data: $.param({
  5451. action: 'join',
  5452. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5453. })
  5454. });
  5455. if (result === 'Success') {
  5456. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5457. logStatus.success();
  5458. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5459. return true;
  5460. }
  5461. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5462. return false;
  5463. }
  5464. logStatus.error(`${result}:${statusText}(${status})`);
  5465. return false;
  5466. } catch (error) {
  5467. throwError(error, 'Steam.joinGroup');
  5468. return false;
  5469. }
  5470. }
  5471. async function _leaveGroup2(groupName) {
  5472. try {
  5473. if (this.whiteList.groups.includes(groupName)) {
  5474. scripts_echoLog({
  5475. type: 'whiteList',
  5476. text: 'Steam.leaveGroup',
  5477. id: groupName
  5478. });
  5479. return true;
  5480. }
  5481. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5482. if (!groupId) {
  5483. return false;
  5484. }
  5485. const logStatus = scripts_echoLog({
  5486. type: 'leavingSteamGroup',
  5487. text: groupName
  5488. });
  5489. const {
  5490. result,
  5491. statusText,
  5492. status,
  5493. data
  5494. } = await tools_httpRequest({
  5495. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5496. method: 'POST',
  5497. headers: {
  5498. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5499. },
  5500. data: $.param({
  5501. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5502. action: 'leaveGroup',
  5503. groupId: groupId
  5504. })
  5505. });
  5506. if (result === 'Success') {
  5507. 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) {
  5508. logStatus.success();
  5509. return true;
  5510. }
  5511. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5512. return false;
  5513. }
  5514. logStatus.error(`${result}:${statusText}(${status})`);
  5515. return false;
  5516. } catch (error) {
  5517. throwError(error, 'Steam.leaveGroup');
  5518. return false;
  5519. }
  5520. }
  5521. async function _getGroupId2(groupName) {
  5522. try {
  5523. const logStatus = scripts_echoLog({
  5524. type: 'gettingSteamGroupId',
  5525. text: groupName
  5526. });
  5527. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5528. if (groupId) {
  5529. logStatus.success();
  5530. return groupId;
  5531. }
  5532. const {
  5533. result,
  5534. statusText,
  5535. status,
  5536. data
  5537. } = await tools_httpRequest({
  5538. url: `https://steamcommunity.com/groups/${groupName}`,
  5539. method: 'GET',
  5540. headers: {
  5541. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5542. }
  5543. });
  5544. if (result === 'Success') {
  5545. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5546. var _data$responseText$ma7;
  5547. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5548. if (groupId) {
  5549. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5550. logStatus.success();
  5551. return groupId;
  5552. }
  5553. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5554. return false;
  5555. }
  5556. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5557. return false;
  5558. }
  5559. logStatus.error(`${result}:${statusText}(${status})`);
  5560. return false;
  5561. } catch (error) {
  5562. throwError(error, 'Steam.getGroupID');
  5563. return false;
  5564. }
  5565. }
  5566. async function _joinOfficialGroup2(gameId) {
  5567. try {
  5568. const logStatus = scripts_echoLog({
  5569. type: 'joiningSteamOfficialGroup',
  5570. text: gameId
  5571. });
  5572. const {
  5573. result,
  5574. statusText,
  5575. status,
  5576. data
  5577. } = await tools_httpRequest({
  5578. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5579. method: 'GET',
  5580. headers: {
  5581. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5582. }
  5583. });
  5584. if (result === 'Success') {
  5585. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5586. var _data$responseText$ma8;
  5587. logStatus.success();
  5588. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5589. 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];
  5590. if (groupId) {
  5591. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5592. }
  5593. return true;
  5594. }
  5595. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5596. return false;
  5597. }
  5598. logStatus.error(`${result}:${statusText}(${status})`);
  5599. return false;
  5600. } catch (error) {
  5601. throwError(error, 'Steam.joinOfficialGroup');
  5602. return false;
  5603. }
  5604. }
  5605. async function _leaveOfficialGroup2(gameId) {
  5606. try {
  5607. if (this.whiteList.officialGroups.includes(gameId)) {
  5608. scripts_echoLog({
  5609. type: 'whiteList',
  5610. text: 'Steam.leaveOfficialGroup',
  5611. id: gameId
  5612. });
  5613. return true;
  5614. }
  5615. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5616. if (!groupId) {
  5617. return false;
  5618. }
  5619. const logStatus = scripts_echoLog({
  5620. type: 'leavingSteamOfficialGroup',
  5621. text: gameId
  5622. });
  5623. const {
  5624. result,
  5625. statusText,
  5626. status,
  5627. data
  5628. } = await tools_httpRequest({
  5629. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5630. method: 'POST',
  5631. headers: {
  5632. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5633. },
  5634. data: $.param({
  5635. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5636. action: 'leaveGroup',
  5637. groupId: groupId
  5638. })
  5639. });
  5640. if (result === 'Success') {
  5641. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5642. const {
  5643. result: resultR,
  5644. statusText: statusTextR,
  5645. status: statusR,
  5646. data: dataR
  5647. } = await tools_httpRequest({
  5648. url: `https://steamcommunity.com/games/${gameId}`,
  5649. method: 'GET',
  5650. headers: {
  5651. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5652. }
  5653. });
  5654. if (resultR === 'Success') {
  5655. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5656. logStatus.success();
  5657. return true;
  5658. }
  5659. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5660. return false;
  5661. }
  5662. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5663. return false;
  5664. }
  5665. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5666. return false;
  5667. }
  5668. logStatus.error(`${result}:${statusText}(${status})`);
  5669. return false;
  5670. } catch (error) {
  5671. throwError(error, 'Steam.leaveOfficialGroup');
  5672. return false;
  5673. }
  5674. }
  5675. async function _getOfficialGroupId2(gameId) {
  5676. try {
  5677. const logStatus = scripts_echoLog({
  5678. type: 'gettingSteamOfficialGroupId',
  5679. text: gameId
  5680. });
  5681. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5682. if (groupId) {
  5683. logStatus.success();
  5684. return groupId;
  5685. }
  5686. const {
  5687. result,
  5688. statusText,
  5689. status,
  5690. data
  5691. } = await tools_httpRequest({
  5692. url: `https://steamcommunity.com/games/${gameId}`,
  5693. method: 'GET',
  5694. headers: {
  5695. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5696. }
  5697. });
  5698. if (result === 'Success') {
  5699. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5700. var _data$responseText$ma9;
  5701. 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];
  5702. if (groupId) {
  5703. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5704. logStatus.success();
  5705. return groupId;
  5706. }
  5707. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5708. return false;
  5709. }
  5710. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5711. return false;
  5712. }
  5713. logStatus.error(`${result}:${statusText}(${status})`);
  5714. return false;
  5715. } catch (error) {
  5716. throwError(error, 'Steam.getGroupID');
  5717. return false;
  5718. }
  5719. }
  5720. async function _addToWishlist2(gameId) {
  5721. try {
  5722. var _data$response;
  5723. const logStatus = scripts_echoLog({
  5724. type: 'addingToWishlist',
  5725. text: gameId
  5726. });
  5727. const {
  5728. result,
  5729. data
  5730. } = await tools_httpRequest({
  5731. url: 'https://store.steampowered.com/api/addtowishlist',
  5732. method: 'POST',
  5733. headers: {
  5734. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5735. },
  5736. data: $.param({
  5737. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5738. appid: gameId
  5739. }),
  5740. dataType: 'json'
  5741. });
  5742. 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) {
  5743. logStatus.success();
  5744. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5745. return true;
  5746. }
  5747. const {
  5748. result: resultR,
  5749. statusText: statusTextR,
  5750. status: statusR,
  5751. data: dataR
  5752. } = await tools_httpRequest({
  5753. url: `https://store.steampowered.com/app/${gameId}`,
  5754. method: 'GET'
  5755. });
  5756. if (resultR === 'Success') {
  5757. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5758. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5759. logStatus.warning(i18n('changeAreaNotice'));
  5760. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5761. return false;
  5762. }
  5763. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5764. }
  5765. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5766. logStatus.success();
  5767. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5768. return true;
  5769. } 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"')) {
  5770. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5771. return false;
  5772. }
  5773. logStatus.success();
  5774. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5775. return true;
  5776. }
  5777. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5778. return false;
  5779. }
  5780. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5781. return false;
  5782. } catch (error) {
  5783. throwError(error, 'Steam.addToWishlist');
  5784. return false;
  5785. }
  5786. }
  5787. async function _removeFromWishlist2(gameId) {
  5788. try {
  5789. var _data$response2;
  5790. if (this.whiteList.wishlists.includes(gameId)) {
  5791. scripts_echoLog({
  5792. type: 'whiteList',
  5793. text: 'Steam.removeFromWishlist',
  5794. id: gameId
  5795. });
  5796. return true;
  5797. }
  5798. const logStatus = scripts_echoLog({
  5799. type: 'removingFromWishlist',
  5800. text: gameId
  5801. });
  5802. const {
  5803. result,
  5804. data
  5805. } = await tools_httpRequest({
  5806. url: 'https://store.steampowered.com/api/removefromwishlist',
  5807. method: 'POST',
  5808. headers: {
  5809. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5810. },
  5811. data: $.param({
  5812. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5813. appid: gameId
  5814. }),
  5815. dataType: 'json'
  5816. });
  5817. 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) {
  5818. logStatus.success();
  5819. return true;
  5820. }
  5821. const {
  5822. result: resultR,
  5823. statusText: statusTextR,
  5824. status: statusR,
  5825. data: dataR
  5826. } = await tools_httpRequest({
  5827. url: `https://store.steampowered.com/app/${gameId}`,
  5828. method: 'GET'
  5829. });
  5830. if (resultR === 'Success') {
  5831. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5832. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5833. logStatus.warning(i18n('changeAreaNotice'));
  5834. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5835. if (!result || result === 'CN' || result === 'skip') {
  5836. return false;
  5837. }
  5838. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5839. }
  5840. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5841. logStatus.success();
  5842. return true;
  5843. }
  5844. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5845. return false;
  5846. }
  5847. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5848. return false;
  5849. }
  5850. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5851. return false;
  5852. } catch (error) {
  5853. throwError(error, 'Steam.removeFromWishlist');
  5854. return false;
  5855. }
  5856. }
  5857. async function _toggleFollowGame2(gameId, doTask) {
  5858. try {
  5859. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5860. scripts_echoLog({
  5861. type: 'whiteList',
  5862. text: 'Steam.unfollowGame',
  5863. id: gameId
  5864. });
  5865. return true;
  5866. }
  5867. const logStatus = scripts_echoLog({
  5868. type: `${doTask ? '' : 'un'}followingGame`,
  5869. text: gameId
  5870. });
  5871. const requestData = {
  5872. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5873. appid: gameId
  5874. };
  5875. if (!doTask) {
  5876. requestData.unfollow = '1';
  5877. }
  5878. const {
  5879. result,
  5880. data
  5881. } = await tools_httpRequest({
  5882. url: 'https://store.steampowered.com/explore/followgame/',
  5883. method: 'POST',
  5884. headers: {
  5885. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5886. },
  5887. data: $.param(requestData)
  5888. });
  5889. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5890. logStatus.success();
  5891. return true;
  5892. }
  5893. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5894. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5895. logStatus.warning(i18n('changeAreaNotice'));
  5896. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5897. return false;
  5898. }
  5899. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5900. }
  5901. if (doTask === followed) {
  5902. logStatus.success();
  5903. if (doTask) {
  5904. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5905. }
  5906. return true;
  5907. }
  5908. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5909. return false;
  5910. } catch (error) {
  5911. throwError(error, 'Steam.toggleFollowGame');
  5912. return false;
  5913. }
  5914. }
  5915. async function _isFollowedGame2(gameId) {
  5916. try {
  5917. const {
  5918. result,
  5919. data
  5920. } = await tools_httpRequest({
  5921. url: `https://store.steampowered.com/app/${gameId}`,
  5922. method: 'GET'
  5923. });
  5924. if (result === 'Success') {
  5925. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5926. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5927. return 'areaLocked';
  5928. }
  5929. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5930. return true;
  5931. }
  5932. return false;
  5933. }
  5934. return false;
  5935. }
  5936. return false;
  5937. } catch (error) {
  5938. throwError(error, 'Steam.isFollowedGame');
  5939. return false;
  5940. }
  5941. }
  5942. async function _toggleForum2(gameId) {
  5943. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5944. try {
  5945. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5946. scripts_echoLog({
  5947. type: 'whiteList',
  5948. text: 'Steam.unsubscribeForum',
  5949. id: gameId
  5950. });
  5951. return true;
  5952. }
  5953. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5954. if (!forumId) {
  5955. return false;
  5956. }
  5957. const logStatus = scripts_echoLog({
  5958. type: `${doTask ? '' : 'un'}subscribingForum`,
  5959. text: gameId
  5960. });
  5961. const [ id, feature ] = forumId.split('_');
  5962. const {
  5963. result,
  5964. statusText,
  5965. status,
  5966. data
  5967. } = await tools_httpRequest({
  5968. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5969. method: 'POST',
  5970. responseType: 'json',
  5971. headers: {
  5972. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5973. },
  5974. data: $.param({
  5975. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5976. })
  5977. });
  5978. if (result === 'Success') {
  5979. var _data$response3, _data$response4;
  5980. 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)) {
  5981. if (doTask) {
  5982. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5983. }
  5984. logStatus.success();
  5985. return true;
  5986. }
  5987. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5988. return true;
  5989. }
  5990. logStatus.error(`${result}:${statusText}(${status})`);
  5991. return true;
  5992. } catch (error) {
  5993. throwError(error, 'Steam.toggleForum');
  5994. return true;
  5995. }
  5996. }
  5997. async function _getForumId2(gameId) {
  5998. try {
  5999. const logStatus = scripts_echoLog({
  6000. type: 'gettingForumId',
  6001. text: gameId
  6002. });
  6003. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  6004. if (forumId) {
  6005. logStatus.success();
  6006. return forumId;
  6007. }
  6008. const {
  6009. result,
  6010. statusText,
  6011. status,
  6012. data
  6013. } = await tools_httpRequest({
  6014. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  6015. method: 'GET'
  6016. });
  6017. if (result === 'Success') {
  6018. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6019. var _data$responseText, _data$responseText$ma10;
  6020. 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];
  6021. if (forumId) {
  6022. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  6023. logStatus.success();
  6024. return forumId;
  6025. }
  6026. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6027. return false;
  6028. }
  6029. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6030. return false;
  6031. }
  6032. logStatus.error(`${result}:${statusText}(${status})`);
  6033. return false;
  6034. } catch (error) {
  6035. throwError(error, 'Steam.getForumId');
  6036. return false;
  6037. }
  6038. }
  6039. async function _toggleFavoriteWorkshop2(id) {
  6040. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6041. try {
  6042. if (!doTask && this.whiteList.workshops.includes(id)) {
  6043. scripts_echoLog({
  6044. type: 'whiteList',
  6045. text: 'Steam.unfavoriteWorkshop',
  6046. id: id
  6047. });
  6048. return true;
  6049. }
  6050. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  6051. if (!appid) {
  6052. return false;
  6053. }
  6054. const logStatus = scripts_echoLog({
  6055. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  6056. text: id
  6057. });
  6058. const {
  6059. result,
  6060. statusText,
  6061. status,
  6062. data
  6063. } = await tools_httpRequest({
  6064. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  6065. method: 'POST',
  6066. headers: {
  6067. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6068. },
  6069. data: $.param({
  6070. id: id,
  6071. appid: appid,
  6072. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6073. })
  6074. });
  6075. if (result === 'Success') {
  6076. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  6077. if (doTask) {
  6078. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  6079. }
  6080. logStatus.success();
  6081. return true;
  6082. }
  6083. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6084. return false;
  6085. }
  6086. logStatus.error(`${result}:${statusText}(${status})`);
  6087. return false;
  6088. } catch (error) {
  6089. throwError(error, 'Steam.toggleFavoriteWorkshop');
  6090. return false;
  6091. }
  6092. }
  6093. async function _getWorkshopAppId2(id) {
  6094. try {
  6095. const logStatus = scripts_echoLog({
  6096. type: 'gettingWorkshopAppId',
  6097. text: id
  6098. });
  6099. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  6100. if (appId) {
  6101. logStatus.success();
  6102. return appId;
  6103. }
  6104. const {
  6105. result,
  6106. statusText,
  6107. status,
  6108. data
  6109. } = await tools_httpRequest({
  6110. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6111. method: 'GET'
  6112. });
  6113. if (result === 'Success') {
  6114. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6115. var _data$responseText$ma11;
  6116. 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];
  6117. if (appId) {
  6118. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6119. logStatus.success();
  6120. return appId;
  6121. }
  6122. logStatus.error('Error: getWorkshopAppId failed');
  6123. return false;
  6124. }
  6125. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6126. return false;
  6127. }
  6128. logStatus.error(`${result}:${statusText}(${status})`);
  6129. return false;
  6130. } catch (error) {
  6131. throwError(error, 'Steam.getWorkshopAppId');
  6132. return false;
  6133. }
  6134. }
  6135. async function _voteUpWorkshop2(id) {
  6136. try {
  6137. const logStatus = scripts_echoLog({
  6138. type: 'votingUpWorkshop',
  6139. text: id
  6140. });
  6141. const {
  6142. result,
  6143. statusText,
  6144. status,
  6145. data
  6146. } = await tools_httpRequest({
  6147. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6148. method: 'POST',
  6149. responseType: 'json',
  6150. headers: {
  6151. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6152. },
  6153. data: $.param({
  6154. id: id,
  6155. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6156. })
  6157. });
  6158. if (result === 'Success') {
  6159. var _data$response5;
  6160. 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) {
  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 true;
  6166. }
  6167. logStatus.error(`${result}:${statusText}(${status})`);
  6168. return true;
  6169. } catch (error) {
  6170. throwError(error, 'Steam.voteupWorkshop');
  6171. return true;
  6172. }
  6173. }
  6174. async function _toggleCurator2(curatorId) {
  6175. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6176. try {
  6177. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6178. scripts_echoLog({
  6179. type: 'whiteList',
  6180. text: 'Steam.unfollowCurator',
  6181. id: curatorId
  6182. });
  6183. return true;
  6184. }
  6185. const logStatus = scripts_echoLog({
  6186. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6187. text: curatorId
  6188. });
  6189. const {
  6190. result,
  6191. statusText,
  6192. status,
  6193. data
  6194. } = await tools_httpRequest({
  6195. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6196. method: 'POST',
  6197. headers: {
  6198. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6199. },
  6200. data: $.param({
  6201. clanid: curatorId,
  6202. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6203. follow: doTask
  6204. }),
  6205. dataType: 'json'
  6206. });
  6207. if (result === 'Success') {
  6208. var _data$response6, _data$response6$succe, _data$response7;
  6209. 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) {
  6210. logStatus.success();
  6211. return true;
  6212. }
  6213. 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})`);
  6214. return false;
  6215. }
  6216. logStatus.error(`${result}:${statusText}(${status})`);
  6217. return false;
  6218. } catch (error) {
  6219. throwError(error, 'Steam.toggleCurator');
  6220. return false;
  6221. }
  6222. }
  6223. async function _toggleCuratorLike2(link) {
  6224. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6225. try {
  6226. const [ path, name ] = link.split('/');
  6227. if (!(path && name)) {
  6228. scripts_echoLog({
  6229. text: i18n('errorLink', link)
  6230. });
  6231. return false;
  6232. }
  6233. const curatorId = await this.getCuratorId(path, name);
  6234. if (curatorId) {
  6235. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6236. }
  6237. return false;
  6238. } catch (error) {
  6239. throwError(error, 'Steam.toggleCuratorLike');
  6240. return false;
  6241. }
  6242. }
  6243. async function _getAnnouncementParams2(appId, viewId) {
  6244. try {
  6245. const logStatus = scripts_echoLog({
  6246. type: 'gettingAnnouncementParams',
  6247. text: appId,
  6248. id: viewId
  6249. });
  6250. const {
  6251. result,
  6252. statusText,
  6253. status,
  6254. data
  6255. } = await tools_httpRequest({
  6256. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6257. method: 'GET',
  6258. headers: {
  6259. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6260. }
  6261. });
  6262. if (result === 'Success') {
  6263. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6264. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6265. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6266. logStatus.warning(i18n('changeAreaNotice'));
  6267. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6268. return {};
  6269. }
  6270. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6271. }
  6272. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6273. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6274. 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];
  6275. if (authWgToken && clanId) {
  6276. logStatus.success();
  6277. return {
  6278. authWgToken: authWgToken,
  6279. clanId: clanId,
  6280. gid: gid
  6281. };
  6282. }
  6283. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6284. return {};
  6285. }
  6286. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6287. return {};
  6288. }
  6289. logStatus.error(`${result}:${statusText}(${status})`);
  6290. return {};
  6291. } catch (error) {
  6292. throwError(error, 'Steam.likeAnnouncement');
  6293. return {};
  6294. }
  6295. }
  6296. async function _likeAnnouncement2(id) {
  6297. try {
  6298. const [ appId, viewId ] = id.split('/');
  6299. if (!(appId && viewId)) {
  6300. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6301. return false;
  6302. }
  6303. const {
  6304. authWgToken,
  6305. clanId,
  6306. gid
  6307. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6308. if (!(authWgToken && clanId)) {
  6309. return false;
  6310. }
  6311. const logStatus = scripts_echoLog({
  6312. type: 'likingAnnouncement',
  6313. text: appId,
  6314. id: viewId
  6315. });
  6316. const {
  6317. result,
  6318. statusText,
  6319. status,
  6320. data
  6321. } = await tools_httpRequest({
  6322. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6323. method: 'POST',
  6324. headers: {
  6325. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6326. Host: 'store.steampowered.com',
  6327. Origin: 'https://store.steampowered.com',
  6328. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6329. },
  6330. data: $.param({
  6331. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6332. wgauthtoken: authWgToken,
  6333. voteup: 1,
  6334. clanid: clanId,
  6335. ajax: 1
  6336. }),
  6337. dataType: 'json'
  6338. });
  6339. if (result === 'Success') {
  6340. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6341. logStatus.success();
  6342. return true;
  6343. }
  6344. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6345. return false;
  6346. }
  6347. logStatus.error(`${result}:${statusText}(${status})`);
  6348. return false;
  6349. } catch (error) {
  6350. throwError(error, 'Steam.likeAnnouncement');
  6351. return false;
  6352. }
  6353. }
  6354. async function _appid2subid2(id) {
  6355. try {
  6356. const logStatus = scripts_echoLog({
  6357. type: 'gettingSubid',
  6358. text: id
  6359. });
  6360. const {
  6361. result,
  6362. statusText,
  6363. status,
  6364. data
  6365. } = await tools_httpRequest({
  6366. url: `https://store.steampowered.com/app/${id}`,
  6367. method: 'GET',
  6368. headers: {
  6369. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6370. }
  6371. });
  6372. if (result === 'Success') {
  6373. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6374. var _data$responseText$ma15;
  6375. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6376. logStatus.warning(i18n('changeAreaNotice'));
  6377. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6378. if (!result || result === 'CN' || result === 'skip') {
  6379. return false;
  6380. }
  6381. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6382. }
  6383. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6384. if (subid) {
  6385. logStatus.success();
  6386. return subid;
  6387. }
  6388. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6389. return false;
  6390. }
  6391. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6392. return false;
  6393. }
  6394. logStatus.error(`${result}:${statusText}(${status})`);
  6395. return false;
  6396. } catch (error) {
  6397. throwError(error, 'Steam.appid2subid');
  6398. return false;
  6399. }
  6400. }
  6401. async function _getLicenses2() {
  6402. try {
  6403. const logStatus = scripts_echoLog({
  6404. text: i18n('gettingLicenses')
  6405. });
  6406. const {
  6407. result,
  6408. statusText,
  6409. status,
  6410. data
  6411. } = await tools_httpRequest({
  6412. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  6413. method: 'GET',
  6414. responseType: 'json'
  6415. });
  6416. if (result === 'Success') {
  6417. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6418. var _data$response8;
  6419. logStatus.success();
  6420. return (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.rgOwnedPackages;
  6421. }
  6422. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6423. return false;
  6424. }
  6425. logStatus.error(`${result}:${statusText}(${status})`);
  6426. return false;
  6427. } catch (error) {
  6428. throwError(error, 'Steam.getLicenses');
  6429. return false;
  6430. }
  6431. }
  6432. async function _addLicense2(id) {
  6433. try {
  6434. const [ type, ids ] = id.split('-');
  6435. if (type === 'appid') {
  6436. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6437. if (!subid) {
  6438. return false;
  6439. }
  6440. const logStatus = scripts_echoLog({
  6441. type: 'addingFreeLicense',
  6442. text: ids
  6443. });
  6444. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6445. return false;
  6446. }
  6447. const {
  6448. result,
  6449. statusText,
  6450. status,
  6451. data
  6452. } = await tools_httpRequest({
  6453. url: `https://store.steampowered.com/app/${ids}`,
  6454. method: 'GET'
  6455. });
  6456. if (result === 'Success') {
  6457. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6458. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6459. logStatus.success();
  6460. return true;
  6461. }
  6462. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6463. return false;
  6464. }
  6465. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6466. return false;
  6467. }
  6468. logStatus.error(`${result}:${statusText}(${status})`);
  6469. return false;
  6470. } else if (type === 'subid') {
  6471. if (Steam_classPrivateFieldGet(this, _area) === 'CN') {
  6472. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  6473. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6474. }
  6475. const logStatusArr = {};
  6476. const idsArr = ids.split(',');
  6477. for (const subid of idsArr) {
  6478. const logStatus = scripts_echoLog({
  6479. type: 'addingFreeLicenseSubid',
  6480. text: subid
  6481. });
  6482. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6483. return false;
  6484. }
  6485. logStatusArr[subid] = logStatus;
  6486. }
  6487. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6488. if (!licenses) {
  6489. return false;
  6490. }
  6491. for (const subid of idsArr) {
  6492. if (licenses.includes(parseInt(subid, 10))) {
  6493. logStatusArr[subid].success();
  6494. } else {
  6495. logStatusArr[subid].error();
  6496. }
  6497. }
  6498. return true;
  6499. }
  6500. return false;
  6501. } catch (error) {
  6502. throwError(error, 'Steam.addLicense');
  6503. return false;
  6504. }
  6505. }
  6506. async function _addFreeLicense2(id, logStatusPre) {
  6507. try {
  6508. const logStatus = logStatusPre || scripts_echoLog({
  6509. type: 'addingFreeLicenseSubid',
  6510. text: id
  6511. });
  6512. const {
  6513. result,
  6514. statusText,
  6515. status,
  6516. data
  6517. } = await tools_httpRequest({
  6518. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6519. method: 'POST',
  6520. headers: {
  6521. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6522. Host: 'store.steampowered.com',
  6523. Origin: 'https://store.steampowered.com',
  6524. Referer: 'https://store.steampowered.com/account/licenses/'
  6525. },
  6526. data: $.param({
  6527. action: 'add_to_cart',
  6528. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6529. subid: id
  6530. }),
  6531. dataType: 'json'
  6532. });
  6533. if (result === 'Success') {
  6534. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6535. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6536. logStatus.warning(i18n('changeAreaNotice'));
  6537. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6538. if (!result || result === 'CN') {
  6539. return false;
  6540. }
  6541. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6542. }
  6543. logStatus.success();
  6544. return true;
  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. } catch (error) {
  6552. throwError(error, 'Steam.addFreeLicense');
  6553. return false;
  6554. }
  6555. }
  6556. async function _requestPlayTestAccess2(id) {
  6557. try {
  6558. const logStatus = scripts_echoLog({
  6559. type: 'requestingPlayTestAccess',
  6560. text: id
  6561. });
  6562. const {
  6563. result,
  6564. statusText,
  6565. status,
  6566. data
  6567. } = await tools_httpRequest({
  6568. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6569. method: 'POST',
  6570. headers: {
  6571. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6572. Host: 'store.steampowered.com',
  6573. Origin: 'https://store.steampowered.com',
  6574. Referer: `https://store.steampowered.com/app/${id}`
  6575. },
  6576. data: $.param({
  6577. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6578. }),
  6579. dataType: 'json'
  6580. });
  6581. if (result === 'Success') {
  6582. var _data$response9;
  6583. 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) {
  6584. logStatus.success();
  6585. return true;
  6586. }
  6587. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6588. return false;
  6589. }
  6590. logStatus.error(`${result}:${statusText}(${status})`);
  6591. return false;
  6592. } catch (error) {
  6593. throwError(error, 'Steam.requestPlayTestAccess');
  6594. return false;
  6595. }
  6596. }
  6597. function Steam_setCache2(type, name, id) {
  6598. try {
  6599. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6600. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6601. } catch (error) {
  6602. throwError(error, 'Steam.setCache');
  6603. }
  6604. }
  6605. const social_Steam = Steam;
  6606. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6607. Website_checkPrivateRedeclaration(obj, privateSet);
  6608. privateSet.add(obj);
  6609. }
  6610. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6611. if (privateCollection.has(obj)) {
  6612. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6613. }
  6614. }
  6615. function Website_defineProperty(obj, key, value) {
  6616. if (key in obj) {
  6617. Object.defineProperty(obj, key, {
  6618. value: value,
  6619. enumerable: true,
  6620. configurable: true,
  6621. writable: true
  6622. });
  6623. } else {
  6624. obj[key] = value;
  6625. }
  6626. return obj;
  6627. }
  6628. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6629. if (!privateSet.has(receiver)) {
  6630. throw new TypeError('attempted to get private field on non-instance');
  6631. }
  6632. return fn;
  6633. }
  6634. var _bind = new WeakSet();
  6635. class Website {
  6636. constructor() {
  6637. Website_classPrivateMethodInitSpec(this, _bind);
  6638. Website_defineProperty(this, 'undoneTasks', void 0);
  6639. Website_defineProperty(this, 'socialTasks', void 0);
  6640. Website_defineProperty(this, 'giveawayId', void 0);
  6641. Website_defineProperty(this, 'socialInitialized', {
  6642. discord: false,
  6643. instagram: false,
  6644. reddit: false,
  6645. twitch: false,
  6646. twitter: false,
  6647. vk: false,
  6648. youtube: false,
  6649. steamStore: false,
  6650. steamCommunity: false
  6651. });
  6652. Website_defineProperty(this, 'initialized', false);
  6653. Website_defineProperty(this, 'social', {});
  6654. }
  6655. async initSocial(action) {
  6656. try {
  6657. const pro = [];
  6658. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6659. if (tasks.discord) {
  6660. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6661. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6662. this.social.discord = new social_Discord();
  6663. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6664. }
  6665. }
  6666. if (tasks.instagram) {
  6667. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6668. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6669. this.social.instagram = new social_Instagram();
  6670. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6671. }
  6672. }
  6673. if (tasks.reddit) {
  6674. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6675. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6676. this.social.reddit = new social_Reddit();
  6677. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6678. }
  6679. }
  6680. if (tasks.twitch) {
  6681. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6682. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6683. this.social.twitch = new social_Twitch();
  6684. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6685. }
  6686. }
  6687. if (tasks.twitter) {
  6688. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6689. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6690. this.social.twitter = new social_Twitter();
  6691. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6692. }
  6693. }
  6694. if (tasks.vk) {
  6695. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6696. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6697. this.social.vk = new social_Vk();
  6698. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6699. }
  6700. }
  6701. if (tasks.youtube) {
  6702. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6703. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6704. this.social.youtube = new Youtube();
  6705. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6706. }
  6707. }
  6708. if (tasks.steam) {
  6709. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6710. if (steamLength > 0) {
  6711. if (!this.social.steam) {
  6712. this.social.steam = new social_Steam();
  6713. }
  6714. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6715. var _tasks$steam, _tasks$steam$type;
  6716. 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;
  6717. }).reduce((total, number) => total + number, 0);
  6718. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6719. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6720. }
  6721. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6722. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6723. }
  6724. }
  6725. }
  6726. if (tasks.links && tasks.links.length > 0) {
  6727. this.social.visitLink = visitLink;
  6728. }
  6729. return await Promise.all(pro).then(result => {
  6730. let checked = true;
  6731. for (const data of result) {
  6732. if (data.result) {
  6733. this.socialInitialized[data.name] = data.result;
  6734. } else {
  6735. checked = false;
  6736. }
  6737. }
  6738. return checked;
  6739. });
  6740. } catch (error) {
  6741. throwError(error, 'Website.initSocial');
  6742. return false;
  6743. }
  6744. }
  6745. uniqueTasks(allTasks) {
  6746. const result = {};
  6747. for (const [ social, types ] of Object.entries(allTasks)) {
  6748. result[social] = {};
  6749. for (const [ type, tasks ] of Object.entries(types)) {
  6750. result[social][type] = unique(tasks);
  6751. }
  6752. }
  6753. return result;
  6754. }
  6755. async toggleTask(action) {
  6756. try {
  6757. if (!this.initialized && !this.init()) {
  6758. return false;
  6759. }
  6760. if (!await this.classifyTask(action)) {
  6761. return false;
  6762. }
  6763. if (!await this.initSocial(action)) {
  6764. return false;
  6765. }
  6766. const pro = [];
  6767. const doTask = action === 'do';
  6768. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6769. if (this.socialInitialized.discord !== 'skip' && this.social.discord) {
  6770. pro.push(this.social.discord.toggle({
  6771. doTask: doTask,
  6772. ...tasks.discord
  6773. }));
  6774. }
  6775. if (this.social.instagram) {
  6776. pro.push(this.social.instagram.toggle({
  6777. doTask: doTask,
  6778. ...tasks.instagram
  6779. }));
  6780. }
  6781. if (this.social.reddit) {
  6782. pro.push(this.social.reddit.toggle({
  6783. doTask: doTask,
  6784. ...tasks.reddit
  6785. }));
  6786. }
  6787. if (this.social.twitch) {
  6788. pro.push(this.social.twitch.toggle({
  6789. doTask: doTask,
  6790. ...tasks.twitch
  6791. }));
  6792. }
  6793. if (this.social.twitter) {
  6794. pro.push(this.social.twitter.toggle({
  6795. doTask: doTask,
  6796. ...tasks.twitter
  6797. }));
  6798. }
  6799. if (this.social.vk) {
  6800. pro.push(this.social.vk.toggle({
  6801. doTask: doTask,
  6802. ...tasks.vk
  6803. }));
  6804. }
  6805. if (this.social.youtube) {
  6806. pro.push(this.social.youtube.toggle({
  6807. doTask: doTask,
  6808. ...tasks.youtube
  6809. }));
  6810. }
  6811. if (this.social.steam) {
  6812. pro.push(this.social.steam.toggle({
  6813. doTask: doTask,
  6814. ...tasks.steam
  6815. }));
  6816. }
  6817. if (this.social.visitLink && tasks.links && doTask) {
  6818. for (const link of tasks.links) {
  6819. pro.push(this.social.visitLink(link));
  6820. }
  6821. }
  6822. if (doTask && tasks.extra && this.extraDoTask) {
  6823. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6824. if (hasExtra) {
  6825. pro.push(this.extraDoTask(tasks.extra));
  6826. }
  6827. }
  6828. await Promise.all(pro);
  6829. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6830. return true;
  6831. } catch (error) {
  6832. throwError(error, 'Website.toggleTask');
  6833. return false;
  6834. }
  6835. }
  6836. async doTask() {
  6837. try {
  6838. return await this.toggleTask('do');
  6839. } catch (error) {
  6840. throwError(error, 'Website.doTask');
  6841. return false;
  6842. }
  6843. }
  6844. async undoTask() {
  6845. try {
  6846. return await this.toggleTask('undo');
  6847. } catch (error) {
  6848. throwError(error, 'Website.undoTask');
  6849. return false;
  6850. }
  6851. }
  6852. }
  6853. async function _bind2(name, init) {
  6854. try {
  6855. return {
  6856. name: name,
  6857. result: await init
  6858. };
  6859. } catch (error) {
  6860. throwError(error, 'Website.bind');
  6861. return {
  6862. name: name,
  6863. result: false
  6864. };
  6865. }
  6866. }
  6867. const website_Website = Website;
  6868. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6869. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6870. privateSet.add(obj);
  6871. }
  6872. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6873. if (privateCollection.has(obj)) {
  6874. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6875. }
  6876. }
  6877. function FreeAnyWhere_defineProperty(obj, key, value) {
  6878. if (key in obj) {
  6879. Object.defineProperty(obj, key, {
  6880. value: value,
  6881. enumerable: true,
  6882. configurable: true,
  6883. writable: true
  6884. });
  6885. } else {
  6886. obj[key] = value;
  6887. }
  6888. return obj;
  6889. }
  6890. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6891. if (!privateSet.has(receiver)) {
  6892. throw new TypeError('attempted to get private field on non-instance');
  6893. }
  6894. return fn;
  6895. }
  6896. const FreeAnyWhere_defaultTasksTemplate = {
  6897. steam: {
  6898. groupLinks: [],
  6899. wishlistLinks: [],
  6900. curatorLinks: [],
  6901. followLinks: []
  6902. },
  6903. vk: {
  6904. nameLinks: []
  6905. }
  6906. };
  6907. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6908. var _getGiveawayId = new WeakSet();
  6909. var _verify = new WeakSet();
  6910. class FreeAnyWhere extends website_Website {
  6911. constructor() {
  6912. super(...arguments);
  6913. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6914. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6915. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6916. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6917. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6918. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6919. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6920. }
  6921. static test() {
  6922. return window.location.host === 'freeanywhere.net';
  6923. }
  6924. init() {
  6925. try {
  6926. const logStatus = scripts_echoLog({
  6927. text: i18n('initing')
  6928. });
  6929. if ($('a[href="#/login"]').length > 0) {
  6930. window.open('/#/login', '_self');
  6931. logStatus.warning(i18n('needLogin'));
  6932. return false;
  6933. }
  6934. if (window.location.href.includes('/login')) {
  6935. logStatus.warning(i18n('needLogin'));
  6936. return false;
  6937. }
  6938. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6939. var _window$location$href;
  6940. 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];
  6941. if (!id) {
  6942. logStatus.error(i18n('getFailed', 'Id'));
  6943. return false;
  6944. }
  6945. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6946. }
  6947. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6948. return false;
  6949. }
  6950. this.initialized = true;
  6951. logStatus.success();
  6952. return true;
  6953. } catch (error) {
  6954. throwError(error, 'Freeanywhere.init');
  6955. return false;
  6956. }
  6957. }
  6958. async classifyTask(action) {
  6959. try {
  6960. const logStatus = scripts_echoLog({
  6961. text: i18n('getTasksInfo')
  6962. });
  6963. if (action === 'undo') {
  6964. var _GM_getValue;
  6965. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6966. }
  6967. const {
  6968. result,
  6969. statusText,
  6970. status,
  6971. data
  6972. } = await tools_httpRequest({
  6973. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6974. method: 'GET',
  6975. headers: {
  6976. authorization: `Token ${window.localStorage.getItem('token')}`,
  6977. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6978. },
  6979. responseType: 'json'
  6980. });
  6981. if (result === 'Success') {
  6982. var _data$response;
  6983. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6984. if (tasks) {
  6985. if (action === 'verify') {
  6986. this.tasks = [];
  6987. }
  6988. for (const task of tasks) {
  6989. const type = task.challenge;
  6990. const social = task.challenge_provider;
  6991. const taskInfo = {
  6992. id: task.id,
  6993. title: task.title
  6994. };
  6995. if (action === 'verify' && !task.is_success) {
  6996. this.tasks.push(taskInfo);
  6997. continue;
  6998. }
  6999. switch (social) {
  7000. case 'steam':
  7001. taskInfo.social = 'steam';
  7002. switch (type) {
  7003. case 'WL':
  7004. if (action === 'undo') {
  7005. this.socialTasks.steam.wishlistLinks.push(task.link);
  7006. }
  7007. if (action === 'do' && !task.is_success) {
  7008. this.undoneTasks.steam.wishlistLinks.push(task.link);
  7009. }
  7010. break;
  7011.  
  7012. case 'JTG':
  7013. if (action === 'undo') {
  7014. this.socialTasks.steam.groupLinks.push(task.link);
  7015. }
  7016. if (action === 'do' && !task.is_success) {
  7017. this.undoneTasks.steam.groupLinks.push(task.link);
  7018. }
  7019. break;
  7020.  
  7021. case 'STC':
  7022. if (action === 'undo') {
  7023. this.socialTasks.steam.curatorLinks.push(task.link);
  7024. }
  7025. if (action === 'do' && !task.is_success) {
  7026. this.undoneTasks.steam.curatorLinks.push(task.link);
  7027. }
  7028. break;
  7029.  
  7030. case 'GF':
  7031. if (action === 'undo') {
  7032. this.socialTasks.steam.followLinks.push(task.link);
  7033. }
  7034. if (action === 'do' && !task.is_success) {
  7035. this.undoneTasks.steam.followLinks.push(task.link);
  7036. }
  7037. break;
  7038. }
  7039. break;
  7040.  
  7041. case 'vk-oauth2':
  7042. if (action === 'undo') {
  7043. this.socialTasks.vk.nameLinks.push(task.link);
  7044. }
  7045. if (action === 'do' && !task.is_success) {
  7046. this.undoneTasks.vk.nameLinks.push(task.link);
  7047. }
  7048. break;
  7049.  
  7050. case 'website':
  7051. break;
  7052.  
  7053. default:
  7054. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  7055. break;
  7056. }
  7057. }
  7058. logStatus.success();
  7059. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7060. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7061. if (window.DEBUG) {
  7062. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7063. }
  7064. GM_setValue(`fawTasks-${this.giveawayId}`, {
  7065. tasks: this.socialTasks,
  7066. time: new Date().getTime()
  7067. });
  7068. return true;
  7069. }
  7070. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7071. return false;
  7072. }
  7073. logStatus.error(`${result}:${statusText}(${status})`);
  7074. return false;
  7075. } catch (error) {
  7076. throwError(error, 'Freeanywhere.classifyTask');
  7077. return false;
  7078. }
  7079. }
  7080. async verifyTask() {
  7081. try {
  7082. if (!this.initialized && !this.init()) {
  7083. return false;
  7084. }
  7085. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7086. return false;
  7087. }
  7088. const pro = [];
  7089. for (const task of this.tasks) {
  7090. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  7091. await delay(1e3);
  7092. }
  7093. await Promise.all(pro);
  7094. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7095. return !!await this.getKey(true);
  7096. } catch (error) {
  7097. throwError(error, 'Freeanywhere.verifyTask');
  7098. return false;
  7099. }
  7100. }
  7101. async getKey(initialized) {
  7102. try {
  7103. if (!initialized && !this.initialized && !this.init()) {
  7104. return false;
  7105. }
  7106. const logStatus = scripts_echoLog({
  7107. text: i18n('gettingKey')
  7108. });
  7109. const {
  7110. result,
  7111. statusText,
  7112. status,
  7113. data
  7114. } = await tools_httpRequest({
  7115. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7116. method: 'GET',
  7117. dataType: 'json',
  7118. headers: {
  7119. authorization: `Token ${window.localStorage.getItem('token')}`
  7120. }
  7121. });
  7122. if (result === 'Success') {
  7123. var _data$response2;
  7124. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7125. logStatus.success();
  7126. scripts_echoLog({}).success(data.response.reward);
  7127. return data.response.reward;
  7128. }
  7129. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7130. return false;
  7131. }
  7132. logStatus.error(`${result}:${statusText}(${status})`);
  7133. return false;
  7134. } catch (error) {
  7135. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7136. return false;
  7137. }
  7138. }
  7139. }
  7140. function _getGiveawayId2() {
  7141. try {
  7142. var _window$location$href2;
  7143. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7144. if (giveawayId) {
  7145. this.giveawayId = giveawayId;
  7146. return true;
  7147. }
  7148. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7149. return false;
  7150. } catch (error) {
  7151. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7152. }
  7153. }
  7154. async function _verify2(task) {
  7155. try {
  7156. const logStatus = scripts_echoLog({
  7157. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7158. });
  7159. const {
  7160. result,
  7161. statusText,
  7162. status,
  7163. data
  7164. } = await tools_httpRequest({
  7165. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7166. method: 'GET',
  7167. dataType: 'json',
  7168. headers: {
  7169. authorization: `Token ${window.localStorage.getItem('token')}`,
  7170. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7171. }
  7172. });
  7173. if (result === 'Success') {
  7174. var _data$response3;
  7175. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7176. logStatus.success();
  7177. return true;
  7178. }
  7179. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7180. return false;
  7181. }
  7182. logStatus.error(`${result}:${statusText}(${status})`);
  7183. return false;
  7184. } catch (error) {
  7185. throwError(error, 'Freeanywhere.verify');
  7186. return false;
  7187. }
  7188. }
  7189. const website_FreeAnyWhere = FreeAnyWhere;
  7190. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7191. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7192. privateSet.add(obj);
  7193. }
  7194. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7195. if (privateCollection.has(obj)) {
  7196. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7197. }
  7198. }
  7199. function GiveawaySu_defineProperty(obj, key, value) {
  7200. if (key in obj) {
  7201. Object.defineProperty(obj, key, {
  7202. value: value,
  7203. enumerable: true,
  7204. configurable: true,
  7205. writable: true
  7206. });
  7207. } else {
  7208. obj[key] = value;
  7209. }
  7210. return obj;
  7211. }
  7212. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7213. if (!privateSet.has(receiver)) {
  7214. throw new TypeError('attempted to get private field on non-instance');
  7215. }
  7216. return fn;
  7217. }
  7218. const GiveawaySu_defaultTasks = {
  7219. steam: {
  7220. groupLinks: [],
  7221. wishlistLinks: [],
  7222. curatorLinks: [],
  7223. curatorLikeLinks: [],
  7224. followLinks: [],
  7225. forumLinks: [],
  7226. announcementLinks: [],
  7227. workshopVoteLinks: [],
  7228. playtestLinks: []
  7229. },
  7230. discord: {
  7231. serverLinks: []
  7232. },
  7233. instagram: {
  7234. userLinks: []
  7235. },
  7236. vk: {
  7237. nameLinks: []
  7238. },
  7239. twitch: {
  7240. channelLinks: []
  7241. },
  7242. reddit: {
  7243. redditLinks: []
  7244. },
  7245. youtube: {
  7246. channelLinks: [],
  7247. likeLinks: []
  7248. }
  7249. };
  7250. var _checkLogin = new WeakSet();
  7251. var _checkLeftKey = new WeakSet();
  7252. var GiveawaySu_getGiveawayId = new WeakSet();
  7253. class GiveawaySu extends website_Website {
  7254. constructor() {
  7255. super(...arguments);
  7256. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7257. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  7258. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7259. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7260. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7261. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7262. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7263. }
  7264. static test() {
  7265. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7266. }
  7267. async after() {
  7268. try {
  7269. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7270. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7271. }
  7272. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7273. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7274. }
  7275. scripts_echoLog({}).warning(i18n('gsNotice'));
  7276. } catch (error) {
  7277. throwError(error, 'Giveawaysu.after');
  7278. }
  7279. }
  7280. init() {
  7281. try {
  7282. const logStatus = scripts_echoLog({
  7283. text: i18n('initing')
  7284. });
  7285. if ($('a.steam-login').length > 0) {
  7286. window.open('/steam/redirect', '_self');
  7287. logStatus.warning(i18n('needLogin'));
  7288. return false;
  7289. }
  7290. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7291. return false;
  7292. }
  7293. this.initialized = true;
  7294. logStatus.success();
  7295. return true;
  7296. } catch (error) {
  7297. throwError(error, 'Giveawaysu.init');
  7298. return false;
  7299. }
  7300. }
  7301. async classifyTask(action) {
  7302. try {
  7303. const logStatus = scripts_echoLog({
  7304. text: i18n('getTasksInfo')
  7305. });
  7306. if (action === 'undo') {
  7307. var _GM_getValue;
  7308. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7309. return true;
  7310. }
  7311. const pro = [];
  7312. const tasks = $('#actions tr');
  7313. if ($('div.bind-discord').is(':visible')) {
  7314. $('div.bind-discord a')[0].click();
  7315. }
  7316. if ($('div.bind-twitch').is(':visible')) {
  7317. $('div.bind-twitch a')[0].click();
  7318. }
  7319. for (const task of tasks) {
  7320. pro.push(new Promise(resolve => {
  7321. const td = $(task).find('td:not(".hidden")');
  7322. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7323. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7324. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7325. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7326. const taskName = taskDes.text().trim();
  7327. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7328. return resolve(true);
  7329. }
  7330. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7331. if (!taskLink) {
  7332. return resolve(false);
  7333. }
  7334. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7335. this.undoneTasks.steam.groupLinks.push(taskLink);
  7336. } else if (/like.*announcement/gi.test(taskName)) {
  7337. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7338. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7339. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7340. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7341. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7342. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7343. this.undoneTasks.steam.forumLinks.push(taskLink);
  7344. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7345. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7346. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7347. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7348. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7349. this.undoneTasks.discord.serverLinks.push(taskLink);
  7350. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7351. this.undoneTasks.instagram.userLinks.push(taskLink);
  7352. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7353. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7354. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7355. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7356. } else if (/watch.*art/gim.test(taskName)) {
  7357. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7358. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7359. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7360. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7361. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7362. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7363. this.undoneTasks.vk.nameLinks.push(taskLink);
  7364. } else {
  7365. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7366. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7367. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7368. }
  7369. if (/follow.*button/gim.test(taskName)) {
  7370. this.undoneTasks.steam.followLinks.push(taskLink);
  7371. }
  7372. }
  7373. }
  7374. resolve(true);
  7375. }).catch(error => {
  7376. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7377. return false;
  7378. });
  7379. }));
  7380. }
  7381. await Promise.all(pro);
  7382. logStatus.success();
  7383. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7384. this.socialTasks = this.undoneTasks;
  7385. if (window.DEBUG) {
  7386. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7387. }
  7388. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7389. tasks: this.socialTasks,
  7390. time: new Date().getTime()
  7391. });
  7392. return true;
  7393. } catch (error) {
  7394. throwError(error, 'Giveawaysu.classifyTask');
  7395. return false;
  7396. }
  7397. }
  7398. }
  7399. function _checkLogin2() {
  7400. try {
  7401. if (!globalOptions.other.checkLogin) {
  7402. return true;
  7403. }
  7404. if ($('a.steam-login').length > 0) {
  7405. window.open('/steam/redirect', '_self');
  7406. }
  7407. return true;
  7408. } catch (error) {
  7409. throwError(error, 'Giveawaysu.checkLogin');
  7410. return false;
  7411. }
  7412. }
  7413. async function _checkLeftKey2() {
  7414. try {
  7415. if (!globalOptions.other.checkLeftKey) {
  7416. return true;
  7417. }
  7418. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7419. await external_Swal_default().fire({
  7420. icon: 'warning',
  7421. title: i18n('notice'),
  7422. text: i18n('noKeysLeft'),
  7423. confirmButtonText: i18n('confirm'),
  7424. cancelButtonText: i18n('cancel'),
  7425. showCancelButton: true
  7426. }).then(_ref => {
  7427. let {
  7428. value
  7429. } = _ref;
  7430. if (value) {
  7431. window.close();
  7432. }
  7433. });
  7434. }
  7435. return true;
  7436. } catch (error) {
  7437. throwError(error, 'Giveawaysu.checkLeftKey');
  7438. return false;
  7439. }
  7440. }
  7441. function GiveawaySu_getGiveawayId2() {
  7442. var _window$location$href;
  7443. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7444. if (giveawayId) {
  7445. this.giveawayId = giveawayId;
  7446. return true;
  7447. }
  7448. scripts_echoLog({
  7449. text: i18n('getFailed', 'GiveawayId')
  7450. });
  7451. return false;
  7452. }
  7453. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7454. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7455. privateSet.add(obj);
  7456. }
  7457. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7458. if (privateCollection.has(obj)) {
  7459. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7460. }
  7461. }
  7462. function Indiedb_defineProperty(obj, key, value) {
  7463. if (key in obj) {
  7464. Object.defineProperty(obj, key, {
  7465. value: value,
  7466. enumerable: true,
  7467. configurable: true,
  7468. writable: true
  7469. });
  7470. } else {
  7471. obj[key] = value;
  7472. }
  7473. return obj;
  7474. }
  7475. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7476. if (!privateSet.has(receiver)) {
  7477. throw new TypeError('attempted to get private field on non-instance');
  7478. }
  7479. return fn;
  7480. }
  7481. var _join = new WeakSet();
  7482. var _do = new WeakSet();
  7483. var Indiedb_checkLogin = new WeakSet();
  7484. var Indiedb_checkLeftKey = new WeakSet();
  7485. class Indiedb {
  7486. constructor() {
  7487. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7488. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7489. Indiedb_classPrivateMethodInitSpec(this, _do);
  7490. Indiedb_classPrivateMethodInitSpec(this, _join);
  7491. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7492. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7493. }
  7494. static test() {
  7495. return window.location.host === 'www.indiedb.com';
  7496. }
  7497. async after() {
  7498. try {
  7499. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7500. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7501. }
  7502. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7503. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7504. }
  7505. } catch (error) {
  7506. throwError(error, 'Indiedb.after');
  7507. }
  7508. }
  7509. async doTask() {
  7510. try {
  7511. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7512. return false;
  7513. }
  7514. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7515. } catch (error) {
  7516. throwError(error, 'Indiedb.doTask');
  7517. return false;
  7518. }
  7519. }
  7520. }
  7521. async function _join2() {
  7522. try {
  7523. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7524. scripts_echoLog({}).error(i18n('needLogin'));
  7525. return false;
  7526. }
  7527. const currentoption = $('a.buttonenter.buttongiveaway');
  7528. if (/join giveaway/gim.test(currentoption.text())) {
  7529. const logStatus = scripts_echoLog({
  7530. text: `${i18n('joiningGiveaway')}...`
  7531. });
  7532. const {
  7533. result,
  7534. statusText,
  7535. status,
  7536. data
  7537. } = await tools_httpRequest({
  7538. url: currentoption.attr('href'),
  7539. method: 'POST',
  7540. data: 'ajax=t',
  7541. dataType: 'json',
  7542. headers: {
  7543. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7544. accept: 'application/json, text/javascript, */*; q=0.01',
  7545. origin: window.location.origin
  7546. }
  7547. });
  7548. if (result === 'Success') {
  7549. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7550. var _data$response, _data$response4, _data$response5;
  7551. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7552. var _data$response2, _data$response3;
  7553. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7554. $('#giveawaysjoined').slideDown();
  7555. $('#giveawaysrecommend').slideDown();
  7556. 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}` : ''}`);
  7557. return true;
  7558. }
  7559. 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}` : ''}`);
  7560. return false;
  7561. }
  7562. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7563. return false;
  7564. }
  7565. logStatus.error(`${result}:${statusText}(${status})`);
  7566. return false;
  7567. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7568. return true;
  7569. }
  7570. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7571. return false;
  7572. } catch (error) {
  7573. throwError(error, 'Indiedb.init');
  7574. return false;
  7575. }
  7576. }
  7577. async function _do2() {
  7578. try {
  7579. const id = $('script').map((index, script) => {
  7580. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7581. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7582. 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] ];
  7583. }
  7584. return null;
  7585. });
  7586. if (id.length === 2) {
  7587. const pro = [];
  7588. const tasks = $('#giveawaysjoined a[class*=promo]');
  7589. for (const task of tasks) {
  7590. const promo = $(task);
  7591. if (!promo.hasClass('buttonentered')) {
  7592. const status = scripts_echoLog({
  7593. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7594. });
  7595. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7596. let text = '';
  7597. if (promo.hasClass('facebookpromo')) {
  7598. text = 'facebookpromo';
  7599. } else if (promo.hasClass('twitterpromo')) {
  7600. text = 'twitterpromo';
  7601. } else {
  7602. text = 'visitpromo';
  7603. }
  7604. pro.push(new Promise(resolve => {
  7605. $.ajax({
  7606. type: 'POST',
  7607. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7608. timeout: 6e4,
  7609. dataType: 'json',
  7610. data: {
  7611. ajax: 't'
  7612. },
  7613. error(response, error, exception) {
  7614. if (window.DEBUG) {
  7615. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7616. response: response,
  7617. error: error,
  7618. exception: exception
  7619. });
  7620. }
  7621. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7622. resolve(true);
  7623. },
  7624. success(response) {
  7625. if (response.success) {
  7626. status.success(`Success:${response.text}`);
  7627. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7628. resolve(true);
  7629. } else {
  7630. status.error(`Error:${response.text}`);
  7631. resolve(true);
  7632. }
  7633. }
  7634. });
  7635. }));
  7636. } else if (promo.hasClass('emailoptinpromo')) {
  7637. pro.push(new Promise(resolve => {
  7638. $.ajax({
  7639. type: 'POST',
  7640. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7641. timeout: 6e4,
  7642. dataType: 'json',
  7643. data: {
  7644. ajax: 't',
  7645. emailsystoggle: 4
  7646. },
  7647. error(response, error, exception) {
  7648. if (window.DEBUG) {
  7649. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7650. response: response,
  7651. error: error,
  7652. exception: exception
  7653. });
  7654. }
  7655. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7656. resolve(true);
  7657. },
  7658. success(response) {
  7659. if (response.success) {
  7660. status.success(`Success:${response.text}`);
  7661. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7662. resolve(true);
  7663. } else {
  7664. status.error(`Error:${response.text}`);
  7665. resolve(true);
  7666. }
  7667. }
  7668. });
  7669. }));
  7670. } else if (promo.hasClass('watchingpromo')) {
  7671. pro.push(new Promise(resolve => {
  7672. var _promo$attr;
  7673. const data = getUrlQuery(promo.attr('href'));
  7674. data.ajax = 't';
  7675. $.ajax({
  7676. type: 'POST',
  7677. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7678. timeout: 6e4,
  7679. dataType: 'json',
  7680. data: data,
  7681. error(response, error, exception) {
  7682. if (window.DEBUG) {
  7683. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7684. response: response,
  7685. error: error,
  7686. exception: exception
  7687. });
  7688. }
  7689. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7690. resolve(true);
  7691. },
  7692. success(response) {
  7693. if (response.success) {
  7694. status.success(`Success:${response.text}`);
  7695. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7696. resolve(true);
  7697. } else {
  7698. status.error(`Error:${response.text}`);
  7699. resolve(true);
  7700. }
  7701. }
  7702. });
  7703. }));
  7704. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7705. pro.push(new Promise(resolve => {
  7706. $.ajax({
  7707. type: 'POST',
  7708. url: urlPath(promo.attr('href')),
  7709. timeout: 6e4,
  7710. dataType: 'json',
  7711. data: {
  7712. ajax: 't'
  7713. },
  7714. error(response, error, exception) {
  7715. if (window.DEBUG) {
  7716. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7717. response: response,
  7718. error: error,
  7719. exception: exception
  7720. });
  7721. }
  7722. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7723. resolve(true);
  7724. },
  7725. success(response) {
  7726. if (response.success) {
  7727. status.success(`Success:${response.text}`);
  7728. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7729. resolve(true);
  7730. } else {
  7731. status.error(`Error:${response.text}`);
  7732. resolve(true);
  7733. }
  7734. }
  7735. });
  7736. }));
  7737. } else {
  7738. status.error(`Error:${i18n('unKnownTaskType')}`);
  7739. }
  7740. }
  7741. }
  7742. await Promise.all(pro);
  7743. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7744. return true;
  7745. }
  7746. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7747. return false;
  7748. } catch (error) {
  7749. throwError(error, 'Indiedb.classifyTask');
  7750. return false;
  7751. }
  7752. }
  7753. function Indiedb_checkLogin2() {
  7754. try {
  7755. if (!globalOptions.other.checkLogin) {
  7756. return true;
  7757. }
  7758. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7759. window.open('/members/login', '_self');
  7760. }
  7761. return true;
  7762. } catch (error) {
  7763. throwError(error, 'Indiedb.checkLogin');
  7764. return false;
  7765. }
  7766. }
  7767. async function Indiedb_checkLeftKey2() {
  7768. try {
  7769. if (!globalOptions.other.checkLeftKey) {
  7770. return true;
  7771. }
  7772. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7773. await external_Swal_default().fire({
  7774. icon: 'warning',
  7775. title: i18n('notice'),
  7776. text: i18n('giveawayEnded'),
  7777. confirmButtonText: i18n('confirm'),
  7778. cancelButtonText: i18n('cancel'),
  7779. showCancelButton: true
  7780. }).then(_ref => {
  7781. let {
  7782. value
  7783. } = _ref;
  7784. if (value) {
  7785. window.close();
  7786. }
  7787. });
  7788. }
  7789. return true;
  7790. } catch (error) {
  7791. throwError(error, 'Indiedb.checkLeftKey');
  7792. return false;
  7793. }
  7794. }
  7795. const website_Indiedb = Indiedb;
  7796. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7797. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7798. privateSet.add(obj);
  7799. }
  7800. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7801. if (privateCollection.has(obj)) {
  7802. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7803. }
  7804. }
  7805. function Keyhub_defineProperty(obj, key, value) {
  7806. if (key in obj) {
  7807. Object.defineProperty(obj, key, {
  7808. value: value,
  7809. enumerable: true,
  7810. configurable: true,
  7811. writable: true
  7812. });
  7813. } else {
  7814. obj[key] = value;
  7815. }
  7816. return obj;
  7817. }
  7818. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7819. if (!privateSet.has(receiver)) {
  7820. throw new TypeError('attempted to get private field on non-instance');
  7821. }
  7822. return fn;
  7823. }
  7824. const Keyhub_defaultTasksTemplate = {
  7825. steam: {
  7826. groupLinks: [],
  7827. officialGroupLinks: [],
  7828. wishlistLinks: [],
  7829. curatorLinks: []
  7830. },
  7831. discord: {
  7832. serverLinks: []
  7833. },
  7834. extra: {
  7835. videoTasks: []
  7836. },
  7837. links: []
  7838. };
  7839. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7840. var _doScriptTask = new WeakSet();
  7841. var Keyhub_getGiveawayId = new WeakSet();
  7842. var Keyhub_checkLeftKey = new WeakSet();
  7843. var Keyhub_checkLogin = new WeakSet();
  7844. class Keyhub extends website_Website {
  7845. constructor() {
  7846. super(...arguments);
  7847. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7848. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7849. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7850. Keyhub_classPrivateMethodInitSpec(this, _doScriptTask);
  7851. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7852. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7853. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7854. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7855. }
  7856. static test() {
  7857. return window.location.host === 'key-hub.eu';
  7858. }
  7859. async after() {
  7860. try {
  7861. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7862. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7863. }
  7864. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7865. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7866. }
  7867. $('.NSFW').hide();
  7868. } catch (error) {
  7869. throwError(error, 'Keyhub.after');
  7870. }
  7871. }
  7872. init() {
  7873. try {
  7874. const logStatus = scripts_echoLog({
  7875. text: i18n('initing')
  7876. });
  7877. if ($('a[href*="/connect/steam"]').length > 0) {
  7878. window.open('/connect/steam', '_self');
  7879. logStatus.warning(i18n('needLogin'));
  7880. return false;
  7881. }
  7882. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7883. return false;
  7884. }
  7885. $('#VPNoverlay').hide();
  7886. $('#mainArticleSection').show();
  7887. this.initialized = true;
  7888. logStatus.success();
  7889. return true;
  7890. } catch (error) {
  7891. throwError(error, 'Keyhub.init');
  7892. return false;
  7893. }
  7894. }
  7895. async classifyTask(action) {
  7896. try {
  7897. const logStatus = scripts_echoLog({
  7898. text: i18n('getTasksInfo')
  7899. });
  7900. if (action === 'undo') {
  7901. var _GM_getValue;
  7902. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7903. }
  7904. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7905. for (const task of tasks) {
  7906. let link = $(task).attr('href');
  7907. const taskDes = $(task).text().trim();
  7908. if (!link) {
  7909. continue;
  7910. }
  7911. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7912. link = await getRedirectLink(link) || link;
  7913. }
  7914. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7915. window.open(link, '_blank');
  7916. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7917. if (action === 'undo') {
  7918. this.socialTasks.steam.groupLinks.push(link);
  7919. }
  7920. if (action === 'do') {
  7921. this.undoneTasks.steam.groupLinks.push(link);
  7922. }
  7923. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7924. if (action === 'undo') {
  7925. this.socialTasks.steam.officialGroupLinks.push(link);
  7926. }
  7927. if (action === 'do') {
  7928. this.undoneTasks.steam.officialGroupLinks.push(link);
  7929. }
  7930. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7931. if (action === 'undo') {
  7932. this.socialTasks.steam.wishlistLinks.push(link);
  7933. }
  7934. if (action === 'do') {
  7935. this.undoneTasks.steam.wishlistLinks.push(link);
  7936. }
  7937. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7938. if (action === 'undo') {
  7939. this.socialTasks.steam.curatorLinks.push(link);
  7940. }
  7941. if (action === 'do') {
  7942. this.undoneTasks.steam.curatorLinks.push(link);
  7943. }
  7944. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7945. if (action === 'undo') {
  7946. this.socialTasks.discord.serverLinks.push(link);
  7947. }
  7948. if (action === 'do') {
  7949. this.undoneTasks.discord.serverLinks.push(link);
  7950. }
  7951. } else if (/^javascript:videoTask.+/.test(link)) {
  7952. if (action === 'do') {
  7953. var _link$match;
  7954. const taskData = (_link$match = link.match(/javascript:videoTask\('.+?','(.+?)'/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  7955. if (taskData) {
  7956. this.undoneTasks.extra.videoTasks.push(taskData);
  7957. }
  7958. }
  7959. } 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?:\/\/.*?\.itch\.io\/.*/.test(link) || /^https?:\/\/key-hub\.eu.*/.test(link) || /^https?:\/\/store\.steampowered\.com\/app\/.*/.test(link)) {} else {
  7960. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7961. }
  7962. }
  7963. logStatus.success();
  7964. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7965. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7966. if (window.DEBUG) {
  7967. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7968. }
  7969. GM_setValue(`khTasks-${this.giveawayId}`, {
  7970. tasks: this.socialTasks,
  7971. time: new Date().getTime()
  7972. });
  7973. return true;
  7974. } catch (error) {
  7975. throwError(error, 'Keyhub.classifyTask');
  7976. return false;
  7977. }
  7978. }
  7979. async extraDoTask(_ref) {
  7980. let {
  7981. videoTasks
  7982. } = _ref;
  7983. try {
  7984. const pro = [];
  7985. for (const data of videoTasks) {
  7986. pro.push(Keyhub_classPrivateMethodGet(this, _doScriptTask, _doScriptTask2).call(this, data));
  7987. }
  7988. return Promise.all(pro).then(() => true);
  7989. } catch (error) {
  7990. throwError(error, 'Keyhub.extraDoTask');
  7991. return false;
  7992. }
  7993. }
  7994. }
  7995. async function _doScriptTask2(data) {
  7996. try {
  7997. const logStatus = scripts_echoLog({
  7998. text: i18n('doingKeyhubTask')
  7999. });
  8000. const {
  8001. result,
  8002. statusText,
  8003. status,
  8004. data: response
  8005. } = await tools_httpRequest({
  8006. url: `/away?data=${data}`,
  8007. method: 'GET',
  8008. headers: {
  8009. origin: 'https://key-hub.eu',
  8010. referer: 'https://key-hub.eu/'
  8011. }
  8012. });
  8013. if (result === 'Success') {
  8014. if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
  8015. logStatus.success();
  8016. return true;
  8017. }
  8018. logStatus.error(`Error:${response === null || response === void 0 ? void 0 : response.statusText}(${response === null || response === void 0 ? void 0 : response.status})`);
  8019. return false;
  8020. }
  8021. logStatus.error(`${result}:${statusText}(${status})`);
  8022. return false;
  8023. } catch (error) {
  8024. throwError(error, 'Keyhub.doScriptTask');
  8025. return false;
  8026. }
  8027. }
  8028. function Keyhub_getGiveawayId2() {
  8029. try {
  8030. var _window$location$href;
  8031. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8032. if (giveawayId) {
  8033. this.giveawayId = giveawayId;
  8034. return true;
  8035. }
  8036. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8037. return false;
  8038. } catch (error) {
  8039. throwError(error, 'Keyhub.getGiveawayId');
  8040. return false;
  8041. }
  8042. }
  8043. async function Keyhub_checkLeftKey2() {
  8044. try {
  8045. if (!globalOptions.other.checkLeftKey) {
  8046. return true;
  8047. }
  8048. const leftKey = $('#keysleft').text().trim();
  8049. if (leftKey === '0') {
  8050. await external_Swal_default().fire({
  8051. icon: 'warning',
  8052. title: i18n('notice'),
  8053. text: i18n('noKeysLeft'),
  8054. confirmButtonText: i18n('confirm'),
  8055. cancelButtonText: i18n('cancel'),
  8056. showCancelButton: true
  8057. }).then(_ref2 => {
  8058. let {
  8059. value
  8060. } = _ref2;
  8061. if (value) {
  8062. window.close();
  8063. }
  8064. });
  8065. }
  8066. return true;
  8067. } catch (error) {
  8068. throwError(error, 'Keyhub.checkLeftKey');
  8069. return false;
  8070. }
  8071. }
  8072. function Keyhub_checkLogin2() {
  8073. try {
  8074. if (!globalOptions.other.checkLogin) {
  8075. return true;
  8076. }
  8077. if ($('a[href*="/connect/steam"]').length > 0) {
  8078. window.open('/connect/steam', '_self');
  8079. }
  8080. return true;
  8081. } catch (error) {
  8082. throwError(error, 'Keyhub.checkLogin');
  8083. return false;
  8084. }
  8085. }
  8086. const website_Keyhub = Keyhub;
  8087. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  8088. Givekey_checkPrivateRedeclaration(obj, privateSet);
  8089. privateSet.add(obj);
  8090. }
  8091. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  8092. if (privateCollection.has(obj)) {
  8093. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8094. }
  8095. }
  8096. function Givekey_defineProperty(obj, key, value) {
  8097. if (key in obj) {
  8098. Object.defineProperty(obj, key, {
  8099. value: value,
  8100. enumerable: true,
  8101. configurable: true,
  8102. writable: true
  8103. });
  8104. } else {
  8105. obj[key] = value;
  8106. }
  8107. return obj;
  8108. }
  8109. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  8110. if (!privateSet.has(receiver)) {
  8111. throw new TypeError('attempted to get private field on non-instance');
  8112. }
  8113. return fn;
  8114. }
  8115. const Givekey_defaultTasksTemplate = {
  8116. steam: {
  8117. groupLinks: [],
  8118. wishlistLinks: [],
  8119. curatorLinks: [],
  8120. curatorLikeLinks: []
  8121. },
  8122. twitter: {
  8123. userLinks: []
  8124. },
  8125. vk: {
  8126. nameLinks: []
  8127. },
  8128. discord: {
  8129. serverLinks: []
  8130. }
  8131. };
  8132. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  8133. var Givekey_verify = new WeakSet();
  8134. var Givekey_getGiveawayId = new WeakSet();
  8135. var Givekey_checkLeftKey = new WeakSet();
  8136. class Givekey extends website_Website {
  8137. constructor() {
  8138. super(...arguments);
  8139. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  8140. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  8141. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  8142. Givekey_defineProperty(this, 'name', 'Givekey');
  8143. Givekey_defineProperty(this, 'tasks', []);
  8144. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  8145. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  8146. Givekey_defineProperty(this, 'userId', void 0);
  8147. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8148. }
  8149. static test() {
  8150. return window.location.host === 'givekey.ru';
  8151. }
  8152. async after() {
  8153. try {
  8154. await new Promise(resolve => {
  8155. const checker = setInterval(() => {
  8156. if ($('#navbarDropdown').length > 0) {
  8157. clearInterval(checker);
  8158. resolve(true);
  8159. }
  8160. });
  8161. });
  8162. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8163. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8164. }
  8165. } catch (error) {
  8166. throwError(error, 'Givekey.after');
  8167. return false;
  8168. }
  8169. }
  8170. init() {
  8171. try {
  8172. const logStatus = scripts_echoLog({
  8173. text: i18n('initing')
  8174. });
  8175. if ($('a[href*="/auth/steam"]').length > 0) {
  8176. window.open('/auth/steam', '_self');
  8177. logStatus.warning(i18n('needLogin'));
  8178. return false;
  8179. }
  8180. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8181. return false;
  8182. }
  8183. const userId = $('meta[name="user-id"]').attr('content');
  8184. if (!userId) {
  8185. logStatus.error(i18n('getFailed', i18n('userId')));
  8186. return false;
  8187. }
  8188. this.userId = userId;
  8189. this.initialized = true;
  8190. logStatus.success();
  8191. return true;
  8192. } catch (error) {
  8193. throwError(error, 'Givekey.init');
  8194. return false;
  8195. }
  8196. }
  8197. async classifyTask(action) {
  8198. try {
  8199. const logStatus = scripts_echoLog({
  8200. text: i18n('getTasksInfo')
  8201. });
  8202. if (action === 'undo') {
  8203. var _GM_getValue;
  8204. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8205. }
  8206. const tasks = $('.card-body:has("button") .row');
  8207. for (const task of tasks) {
  8208. const taskEle = $(task);
  8209. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8210. if (isSuccess && action !== 'undo') {
  8211. continue;
  8212. }
  8213. const checkButton = taskEle.find('#task_check');
  8214. const taskId = checkButton.attr('data-id');
  8215. if (taskId) {
  8216. this.tasks.push(taskId);
  8217. }
  8218. if (action === 'verify') {
  8219. continue;
  8220. }
  8221. let href = taskEle.find('a').attr('href') || null;
  8222. const text = taskEle.find('a').text().trim();
  8223. const icon = taskEle.find('i');
  8224. if (!href || !text) {
  8225. continue;
  8226. }
  8227. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8228. href = await getRedirectLink(href);
  8229. }
  8230. if (!href) {
  8231. continue;
  8232. }
  8233. if (/^https?:\/\/vk\.com\//.test(href)) {
  8234. this.socialTasks.vk.nameLinks.push(href);
  8235. if (action === 'do' && !isSuccess) {
  8236. this.undoneTasks.vk.nameLinks.push(href);
  8237. }
  8238. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8239. this.socialTasks.steam.groupLinks.push(href);
  8240. if (action === 'do' && !isSuccess) {
  8241. this.undoneTasks.steam.groupLinks.push(href);
  8242. }
  8243. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8244. this.socialTasks.steam.wishlistLinks.push(href);
  8245. if (action === 'do' && !isSuccess) {
  8246. this.undoneTasks.steam.wishlistLinks.push(href);
  8247. }
  8248. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8249. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8250. this.socialTasks.steam.curatorLinks.push(href);
  8251. if (action === 'do' && !isSuccess) {
  8252. this.undoneTasks.steam.curatorLinks.push(href);
  8253. }
  8254. } else {
  8255. this.socialTasks.steam.curatorLikeLinks.push(href);
  8256. if (action === 'do' && !isSuccess) {
  8257. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8258. }
  8259. }
  8260. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8261. this.socialTasks.twitter.userLinks.push(href);
  8262. if (action === 'do' && !isSuccess) {
  8263. this.undoneTasks.twitter.userLinks.push(href);
  8264. }
  8265. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8266. this.socialTasks.discord.serverLinks.push(href);
  8267. if (action === 'do' && !isSuccess) {
  8268. this.undoneTasks.discord.serverLinks.push(href);
  8269. }
  8270. } else {
  8271. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8272. }
  8273. }
  8274. logStatus.success();
  8275. this.tasks = unique(this.tasks);
  8276. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8277. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8278. if (window.DEBUG) {
  8279. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8280. }
  8281. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8282. tasks: this.socialTasks,
  8283. time: new Date().getTime()
  8284. });
  8285. return true;
  8286. } catch (error) {
  8287. throwError(error, 'Givekey.classifyTask');
  8288. return false;
  8289. }
  8290. }
  8291. async verifyTask() {
  8292. try {
  8293. if (!this.initialized && !this.init()) {
  8294. return false;
  8295. }
  8296. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8297. return false;
  8298. }
  8299. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8300. const taskLength = this.tasks.length;
  8301. for (let i = 0; i < taskLength; i++) {
  8302. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8303. if (i < taskLength - 1) {
  8304. await delay(15e3);
  8305. }
  8306. }
  8307. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8308. scripts_echoLog({
  8309. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8310. });
  8311. return true;
  8312. } catch (error) {
  8313. throwError(error, 'Givekey.verifyTask');
  8314. return false;
  8315. }
  8316. }
  8317. }
  8318. async function Givekey_verify2(task) {
  8319. try {
  8320. const logStatus = scripts_echoLog({
  8321. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8322. });
  8323. return await new Promise(resolve => {
  8324. $.ajax({
  8325. url: 'https://givekey.ru/giveaway/task',
  8326. method: 'POST',
  8327. data: `id=${task}&user_id=${this.userId}`,
  8328. dataType: 'json',
  8329. headers: {
  8330. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8331. },
  8332. success: data => {
  8333. if (data.btn) {
  8334. $(`button[data-id=${this.userId}]`).html(data.btn);
  8335. }
  8336. if (data.status === 'ok') {
  8337. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8338. logStatus.success();
  8339. resolve(true);
  8340. } else if (data.status === 'end') {
  8341. logStatus.success();
  8342. scripts_echoLog({}).success(data.key);
  8343. resolve(true);
  8344. } else {
  8345. logStatus.error(`Error:${data.msg}`);
  8346. resolve(false);
  8347. }
  8348. },
  8349. error: xhr => {
  8350. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8351. resolve(false);
  8352. }
  8353. });
  8354. });
  8355. } catch (error) {
  8356. throwError(error, 'Givekey.verify');
  8357. return false;
  8358. }
  8359. }
  8360. function Givekey_getGiveawayId2() {
  8361. try {
  8362. var _window$location$href;
  8363. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8364. if (giveawayId) {
  8365. this.giveawayId = giveawayId;
  8366. return true;
  8367. }
  8368. scripts_echoLog({
  8369. text: i18n('getFailed', 'GiveawayId')
  8370. });
  8371. return false;
  8372. } catch (error) {
  8373. throwError(error, 'Givekey.getGiveawayId');
  8374. return false;
  8375. }
  8376. }
  8377. async function Givekey_checkLeftKey2() {
  8378. try {
  8379. if (!globalOptions.other.checkLeftKey) {
  8380. return true;
  8381. }
  8382. if (!$('#keys_count').text()) {
  8383. await external_Swal_default().fire({
  8384. icon: 'warning',
  8385. title: i18n('notice'),
  8386. text: i18n('noKeysLeft'),
  8387. confirmButtonText: i18n('confirm'),
  8388. cancelButtonText: i18n('cancel'),
  8389. showCancelButton: true
  8390. }).then(_ref => {
  8391. let {
  8392. value
  8393. } = _ref;
  8394. if (value) {
  8395. window.close();
  8396. }
  8397. });
  8398. }
  8399. return true;
  8400. } catch (error) {
  8401. throwError(error, 'Givekey.checkLeftKey');
  8402. return false;
  8403. }
  8404. }
  8405. const website_Givekey = Givekey;
  8406. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8407. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8408. privateSet.add(obj);
  8409. }
  8410. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8411. if (privateCollection.has(obj)) {
  8412. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8413. }
  8414. }
  8415. function GiveeClub_defineProperty(obj, key, value) {
  8416. if (key in obj) {
  8417. Object.defineProperty(obj, key, {
  8418. value: value,
  8419. enumerable: true,
  8420. configurable: true,
  8421. writable: true
  8422. });
  8423. } else {
  8424. obj[key] = value;
  8425. }
  8426. return obj;
  8427. }
  8428. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8429. if (!privateSet.has(receiver)) {
  8430. throw new TypeError('attempted to get private field on non-instance');
  8431. }
  8432. return fn;
  8433. }
  8434. var GiveeClub_checkLogin = new WeakSet();
  8435. var GiveeClub_getGiveawayId = new WeakSet();
  8436. var GiveeClub_checkLeftKey = new WeakSet();
  8437. class GiveeClub extends GiveawaySu {
  8438. constructor() {
  8439. super(...arguments);
  8440. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8441. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8442. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8443. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8444. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8445. }
  8446. static test() {
  8447. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8448. }
  8449. async after() {
  8450. try {
  8451. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8452. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8453. }
  8454. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8455. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8456. }
  8457. } catch (error) {
  8458. throwError(error, 'GiveeClub.after');
  8459. }
  8460. }
  8461. init() {
  8462. try {
  8463. const logStatus = scripts_echoLog({
  8464. text: i18n('initing')
  8465. });
  8466. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8467. logStatus.warning(i18n('needLogin'));
  8468. return false;
  8469. }
  8470. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8471. return false;
  8472. }
  8473. this.initialized = true;
  8474. logStatus.success();
  8475. return true;
  8476. } catch (error) {
  8477. throwError(error, 'GiveeClub.init');
  8478. return false;
  8479. }
  8480. }
  8481. async classifyTask(action) {
  8482. try {
  8483. const logStatus = scripts_echoLog({
  8484. text: i18n('getTasksInfo')
  8485. });
  8486. if (action === 'undo') {
  8487. var _GM_getValue;
  8488. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8489. return true;
  8490. }
  8491. const pro = [];
  8492. const tasks = $('.event-actions tr');
  8493. for (const task of tasks) {
  8494. pro.push(new Promise(resolve => {
  8495. var _$$find;
  8496. const taskDes = $(task).find('.event-action-label a');
  8497. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8498. const taskName = taskDes.text().trim();
  8499. const taskType = (_$$find = $(task).find('button[data-type]')) === null || _$$find === void 0 ? void 0 : _$$find.attr('data-type');
  8500. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8501. return resolve(true);
  8502. }
  8503. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8504. if (!taskLink) {
  8505. return resolve(false);
  8506. }
  8507. if (taskType === 'steam.group.join' && /^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8508. this.undoneTasks.steam.groupLinks.push(taskLink);
  8509. } else if (/like.*announcement/gi.test(taskName)) {
  8510. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8511. } else if (taskType === 'steam.game.wishlist' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8512. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8513. } else if (taskType === 'steam.game.wishlist' && taskDes.attr('data-steam-wishlist-appid')) {
  8514. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8515. } else if (taskType === 'steam.game.follow' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8516. this.undoneTasks.steam.followLinks.push(taskLink);
  8517. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8518. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8519. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8520. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8521. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8522. this.undoneTasks.steam.forumLinks.push(taskLink);
  8523. } else if (taskIcon.includes('discord')) {
  8524. this.undoneTasks.discord.serverLinks.push(taskLink);
  8525. } else if (taskIcon.includes('instagram')) {
  8526. this.undoneTasks.instagram.userLinks.push(taskLink);
  8527. } else if (taskIcon.includes('twitch')) {
  8528. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8529. } else if (taskIcon.includes('reddit')) {
  8530. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8531. } else if (/watch.*art/gim.test(taskName)) {
  8532. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8533. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8534. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8535. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8536. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8537. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8538. this.undoneTasks.vk.nameLinks.push(taskLink);
  8539. } else {
  8540. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8541. if (/follow.*button/gim.test(taskName)) {
  8542. this.undoneTasks.steam.followLinks.push(taskLink);
  8543. }
  8544. }
  8545. }
  8546. resolve(true);
  8547. }).catch(error => {
  8548. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8549. return false;
  8550. });
  8551. }));
  8552. }
  8553. await Promise.all(pro);
  8554. logStatus.success();
  8555. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8556. this.socialTasks = this.undoneTasks;
  8557. if (window.DEBUG) {
  8558. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8559. }
  8560. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8561. tasks: this.socialTasks,
  8562. time: new Date().getTime()
  8563. });
  8564. return true;
  8565. } catch (error) {
  8566. throwError(error, 'GiveeClub.classifyTask');
  8567. return false;
  8568. }
  8569. }
  8570. async verifyTask() {
  8571. try {
  8572. const logStatus = scripts_echoLog({
  8573. text: i18n('giveeClubVerifyNotice')
  8574. });
  8575. const taskButtons = $('.event-actions tr button').has('i.glyphicon-refresh').not('[data-type="user.adblock"]');
  8576. for (const button of taskButtons) {
  8577. button.click();
  8578. if ($(button).attr('data-type') !== 'steam.game.wishlist') {
  8579. await delay(1e3);
  8580. }
  8581. }
  8582. logStatus.warning(i18n('giveeClubVerifyFinished'));
  8583. return true;
  8584. } catch (error) {
  8585. throwError(error, 'Givekey.verifyTask');
  8586. return false;
  8587. }
  8588. }
  8589. }
  8590. function GiveeClub_checkLogin2() {
  8591. try {
  8592. if (!globalOptions.other.checkLogin) {
  8593. return true;
  8594. }
  8595. if ($('a[href*="/account/auth"]').length > 0) {
  8596. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8597. }
  8598. return true;
  8599. } catch (error) {
  8600. throwError(error, 'GiveeClub.checkLogin');
  8601. return false;
  8602. }
  8603. }
  8604. function GiveeClub_getGiveawayId2() {
  8605. var _window$location$href;
  8606. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8607. if (giveawayId) {
  8608. this.giveawayId = giveawayId;
  8609. return true;
  8610. }
  8611. scripts_echoLog({
  8612. text: i18n('getFailed', 'GiveawayId')
  8613. });
  8614. return false;
  8615. }
  8616. async function GiveeClub_checkLeftKey2() {
  8617. try {
  8618. if (!globalOptions.other.checkLeftKey) {
  8619. return true;
  8620. }
  8621. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8622. await external_Swal_default().fire({
  8623. icon: 'warning',
  8624. title: i18n('notice'),
  8625. text: i18n('giveawayEnded'),
  8626. confirmButtonText: i18n('confirm'),
  8627. cancelButtonText: i18n('cancel'),
  8628. showCancelButton: true
  8629. }).then(_ref => {
  8630. let {
  8631. value
  8632. } = _ref;
  8633. if (value) {
  8634. window.close();
  8635. }
  8636. });
  8637. }
  8638. return true;
  8639. } catch (error) {
  8640. throwError(error, 'Giveawaysu.checkLeftKey');
  8641. return false;
  8642. }
  8643. }
  8644. const website_GiveeClub = GiveeClub;
  8645. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8646. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8647. privateSet.add(obj);
  8648. }
  8649. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8650. if (privateCollection.has(obj)) {
  8651. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8652. }
  8653. }
  8654. function OpiumPulses_defineProperty(obj, key, value) {
  8655. if (key in obj) {
  8656. Object.defineProperty(obj, key, {
  8657. value: value,
  8658. enumerable: true,
  8659. configurable: true,
  8660. writable: true
  8661. });
  8662. } else {
  8663. obj[key] = value;
  8664. }
  8665. return obj;
  8666. }
  8667. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8668. if (!privateSet.has(receiver)) {
  8669. throw new TypeError('attempted to get private field on non-instance');
  8670. }
  8671. return fn;
  8672. }
  8673. const defaultOptions = {
  8674. maxPoint: '99999999'
  8675. };
  8676. var _toggleTask = new WeakSet();
  8677. var OpiumPulses_checkLogin = new WeakSet();
  8678. class OpiumPulses {
  8679. constructor() {
  8680. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8681. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8682. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8683. OpiumPulses_defineProperty(this, 'options', {
  8684. ...defaultOptions,
  8685. ...GM_getValue('OpiumPulsesOptions')
  8686. });
  8687. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8688. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8689. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8690. }
  8691. static test() {
  8692. return window.location.host === 'www.opiumpulses.com';
  8693. }
  8694. async after() {
  8695. try {
  8696. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8697. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8698. }
  8699. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8700. } catch (error) {
  8701. throwError(error, 'OpiumPulses.after');
  8702. }
  8703. }
  8704. async doFreeTask() {
  8705. try {
  8706. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8707. } catch (error) {
  8708. throwError(error, 'OpiumPulses.doFreeTask');
  8709. }
  8710. }
  8711. async doPointTask() {
  8712. try {
  8713. var _$$text$match;
  8714. 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);
  8715. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8716. } catch (error) {
  8717. throwError(error, 'OpiumPulses.doPointTask');
  8718. }
  8719. }
  8720. init() {
  8721. return true;
  8722. }
  8723. classifyTask() {
  8724. return true;
  8725. }
  8726. }
  8727. async function _toggleTask2(type) {
  8728. try {
  8729. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8730. for (const item of items) {
  8731. var _$$find$text$match;
  8732. 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);
  8733. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8734. if (type === 'points' && needPoints > this.myPoints) {
  8735. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8736. } else if (type === 'points' && !needPoints) {
  8737. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8738. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8739. var _aElement$attr;
  8740. const logStatus = scripts_echoLog({
  8741. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8742. });
  8743. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8744. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8745. var _aElement$attr2, _aElement$attr2$match;
  8746. 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];
  8747. if (giveawayId) {
  8748. checkUser(giveawayId);
  8749. }
  8750. }
  8751. if (!aElement.attr('href')) {
  8752. logStatus.error('Error: No "href".');
  8753. continue;
  8754. }
  8755. const {
  8756. result,
  8757. statusText,
  8758. status,
  8759. data
  8760. } = await tools_httpRequest({
  8761. url: aElement.attr('href'),
  8762. method: 'GET'
  8763. });
  8764. if (result === 'Success') {
  8765. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8766. var _data$responseText$ma;
  8767. logStatus.success();
  8768. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8769. if (type === 'points' && points) {
  8770. this.myPoints = parseInt(points, 10);
  8771. }
  8772. } else {
  8773. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8774. }
  8775. } else {
  8776. logStatus.error(`${result}:${statusText}(${status})`);
  8777. }
  8778. }
  8779. }
  8780. scripts_echoLog({
  8781. text: '-----END-----'
  8782. });
  8783. } catch (error) {
  8784. throwError(error, 'OpiumPulses.toggleTask');
  8785. }
  8786. }
  8787. function OpiumPulses_checkLogin2() {
  8788. try {
  8789. if (!globalOptions.other.checkLogin) {
  8790. return true;
  8791. }
  8792. if ($('a[href*="/site/login"]').length > 1) {
  8793. window.open('/site/login', '_self');
  8794. }
  8795. return true;
  8796. } catch (error) {
  8797. throwError(error, 'OpiumPulses.checkLogin');
  8798. return false;
  8799. }
  8800. }
  8801. const website_OpiumPulses = OpiumPulses;
  8802. const external_dayjs_namespaceObject = dayjs;
  8803. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8804. const leftKeyChecker = {
  8805. async classify(link) {
  8806. try {
  8807. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8808. return await this.giveawaySu(link);
  8809. }
  8810. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8811. return await this.giveeClub(link);
  8812. }
  8813. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8814. return await this.gleam(link);
  8815. }
  8816. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8817. return await this.indieDb(link);
  8818. }
  8819. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8820. return await this.keyhub(link);
  8821. }
  8822. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8823. return await this.opquests(link);
  8824. }
  8825. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8826. return await this.itch(link);
  8827. }
  8828. return false;
  8829. } catch (error) {
  8830. throwError(error, 'leftKeyChecker.classify');
  8831. return false;
  8832. }
  8833. },
  8834. async giveawaySu(link) {
  8835. try {
  8836. const {
  8837. result,
  8838. data
  8839. } = await tools_httpRequest({
  8840. url: link,
  8841. method: 'GET'
  8842. });
  8843. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8844. if (data.responseText.includes('class="steam-login"')) {
  8845. return false;
  8846. }
  8847. if (data.responseText.includes('class="giveaway-ended"')) {
  8848. return 'Ended';
  8849. }
  8850. return 'Active';
  8851. }
  8852. return false;
  8853. } catch (error) {
  8854. throwError(error, 'leftKeyChecker.giveawaySu');
  8855. return false;
  8856. }
  8857. },
  8858. async giveeClub(link) {
  8859. try {
  8860. const {
  8861. result,
  8862. data
  8863. } = await tools_httpRequest({
  8864. url: link,
  8865. method: 'GET'
  8866. });
  8867. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8868. if (data.responseText.includes('class="event-winner"')) {
  8869. return 'Won';
  8870. }
  8871. if (data.responseText.includes('class="event-ended"')) {
  8872. return 'Ended';
  8873. }
  8874. return 'Active';
  8875. }
  8876. return false;
  8877. } catch (error) {
  8878. throwError(error, 'leftKeyChecker.giveeClub');
  8879. return false;
  8880. }
  8881. },
  8882. async gleam(link) {
  8883. try {
  8884. const {
  8885. result,
  8886. data
  8887. } = await tools_httpRequest({
  8888. url: link,
  8889. method: 'GET'
  8890. });
  8891. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8892. var _data$responseText$ma, _$$attr, _$$attr$match;
  8893. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8894. return 'Won';
  8895. }
  8896. 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];
  8897. if (!campaignDiv) {
  8898. return false;
  8899. }
  8900. 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];
  8901. if (!campaignString) {
  8902. return false;
  8903. }
  8904. const {
  8905. campaign
  8906. } = JSON.parse(campaignString);
  8907. if (campaign.banned) {
  8908. return 'Banned';
  8909. }
  8910. if (campaign.finished) {
  8911. return 'Ended';
  8912. }
  8913. if (campaign.paused) {
  8914. return 'Paused';
  8915. }
  8916. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8917. return 'NotStart';
  8918. }
  8919. return 'Active';
  8920. }
  8921. return false;
  8922. } catch (error) {
  8923. throwError(error, 'leftKeyChecker.gleam');
  8924. return false;
  8925. }
  8926. },
  8927. async indieDb(link) {
  8928. try {
  8929. const {
  8930. result,
  8931. data
  8932. } = await tools_httpRequest({
  8933. url: link,
  8934. method: 'GET'
  8935. });
  8936. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8937. if (data.responseText.includes('Congrats you WON')) {
  8938. return 'Won';
  8939. }
  8940. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8941. return 'Ended';
  8942. }
  8943. return 'Active';
  8944. }
  8945. return false;
  8946. } catch (error) {
  8947. throwError(error, 'leftKeyChecker.indieDb');
  8948. return false;
  8949. }
  8950. },
  8951. async keyhub(link) {
  8952. try {
  8953. const {
  8954. result,
  8955. data
  8956. } = await tools_httpRequest({
  8957. url: link,
  8958. method: 'GET'
  8959. });
  8960. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8961. var _data$responseText$ma2;
  8962. 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];
  8963. if (!keysleft) {
  8964. return false;
  8965. }
  8966. if (keysleft === '0') {
  8967. return 'Ended';
  8968. }
  8969. return `Active(${keysleft})`;
  8970. }
  8971. return false;
  8972. } catch (error) {
  8973. throwError(error, 'leftKeyChecker.keyhub');
  8974. return false;
  8975. }
  8976. },
  8977. async opquests(link) {
  8978. try {
  8979. const {
  8980. result,
  8981. data
  8982. } = await tools_httpRequest({
  8983. url: link,
  8984. method: 'GET'
  8985. });
  8986. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8987. var _data$responseText$ma3;
  8988. 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];
  8989. if (!keysleft) {
  8990. return false;
  8991. }
  8992. if (keysleft === '0') {
  8993. return 'Ended';
  8994. }
  8995. return `Active(${keysleft})`;
  8996. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8997. return 'Ended';
  8998. }
  8999. return false;
  9000. } catch (error) {
  9001. throwError(error, 'leftKeyChecker.opquests');
  9002. return false;
  9003. }
  9004. },
  9005. async itch(link) {
  9006. try {
  9007. const {
  9008. result,
  9009. data
  9010. } = await tools_httpRequest({
  9011. url: link,
  9012. method: 'GET'
  9013. });
  9014. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9015. var _data$responseText$ma4;
  9016. 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];
  9017. if (!endDate) {
  9018. return false;
  9019. }
  9020. if (new Date().getTime() > new Date(endDate).getTime()) {
  9021. return 'Ended';
  9022. }
  9023. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  9024. }
  9025. return false;
  9026. } catch (error) {
  9027. throwError(error, 'leftKeyChecker.opquests');
  9028. return false;
  9029. }
  9030. }
  9031. };
  9032. const website_leftKeyChecker = leftKeyChecker;
  9033. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  9034. Keylol_checkPrivateRedeclaration(obj, privateSet);
  9035. privateSet.add(obj);
  9036. }
  9037. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  9038. if (privateCollection.has(obj)) {
  9039. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9040. }
  9041. }
  9042. function Keylol_defineProperty(obj, key, value) {
  9043. if (key in obj) {
  9044. Object.defineProperty(obj, key, {
  9045. value: value,
  9046. enumerable: true,
  9047. configurable: true,
  9048. writable: true
  9049. });
  9050. } else {
  9051. obj[key] = value;
  9052. }
  9053. return obj;
  9054. }
  9055. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  9056. if (!privateSet.has(receiver)) {
  9057. throw new TypeError('attempted to get private field on non-instance');
  9058. }
  9059. return fn;
  9060. }
  9061. const Keylol_defaultTasksTemplate = {
  9062. steam: {
  9063. groupLinks: [],
  9064. wishlistLinks: [],
  9065. curatorLinks: [],
  9066. curatorLikeLinks: [],
  9067. followLinks: [],
  9068. forumLinks: [],
  9069. announcementLinks: [],
  9070. workshopVoteLinks: [],
  9071. licenseLinks: []
  9072. },
  9073. discord: {
  9074. serverLinks: []
  9075. },
  9076. instagram: {
  9077. userLinks: []
  9078. },
  9079. vk: {
  9080. nameLinks: []
  9081. },
  9082. twitch: {
  9083. channelLinks: []
  9084. },
  9085. reddit: {
  9086. redditLinks: []
  9087. },
  9088. twitter: {
  9089. userLinks: [],
  9090. retweetLinks: []
  9091. },
  9092. youtube: {
  9093. channelLinks: [],
  9094. likeLinks: []
  9095. }
  9096. };
  9097. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  9098. var _addBtn = new WeakSet();
  9099. class Keylol extends website_Website {
  9100. constructor() {
  9101. super(...arguments);
  9102. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  9103. Keylol_defineProperty(this, 'name', 'Keylol');
  9104. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  9105. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  9106. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  9107. }
  9108. static test() {
  9109. var _$$eq$attr, _$$eq$attr2;
  9110. 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')));
  9111. }
  9112. init() {
  9113. return true;
  9114. }
  9115. after() {
  9116. try {
  9117. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  9118. const mainPost = $(selector);
  9119. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  9120. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  9121. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  9122. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  9123. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  9124. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  9125. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  9126. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  9127. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  9128. if (discordLinks.length > 0) {
  9129. for (const discordLink of discordLinks) {
  9130. const link = $(discordLink).attr('href');
  9131. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  9132. continue;
  9133. }
  9134. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  9135. }
  9136. }
  9137. if (redditLinks.length > 0) {
  9138. for (const redditLink of redditLinks) {
  9139. const link = $(redditLink).attr('href');
  9140. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  9141. continue;
  9142. }
  9143. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  9144. }
  9145. }
  9146. if (insLinks.length > 0) {
  9147. for (const insLink of insLinks) {
  9148. const link = $(insLink).attr('href');
  9149. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  9150. continue;
  9151. }
  9152. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  9153. }
  9154. }
  9155. if (twitterLinks.length > 0) {
  9156. for (const twitterLink of twitterLinks) {
  9157. const link = $(twitterLink).attr('href');
  9158. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  9159. continue;
  9160. }
  9161. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  9162. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  9163. } else {
  9164. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  9165. }
  9166. }
  9167. }
  9168. if (twitchLinks.length > 0) {
  9169. for (const twitchLink of twitchLinks) {
  9170. const link = $(twitchLink).attr('href');
  9171. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  9172. continue;
  9173. }
  9174. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9175. }
  9176. }
  9177. if (vkLinks.length > 0) {
  9178. for (const vkLink of vkLinks) {
  9179. const link = $(vkLink).attr('href');
  9180. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9181. continue;
  9182. }
  9183. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9184. }
  9185. }
  9186. if (steamStoreLinks.length > 0) {
  9187. for (const steamStoreLink of steamStoreLinks) {
  9188. const link = $(steamStoreLink).attr('href');
  9189. if (!link) {
  9190. continue;
  9191. }
  9192. if (/curator\/[\d]+/.test(link)) {
  9193. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9194. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9195. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9196. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9197. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9198. } else if (/app\/[\d]+/.test(link)) {
  9199. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9200. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9201. }
  9202. }
  9203. }
  9204. if (steamCommunityLinks.length > 0) {
  9205. for (const steamCommunityLink of steamCommunityLinks) {
  9206. const link = $(steamCommunityLink).attr('href');
  9207. if (!link) {
  9208. continue;
  9209. }
  9210. if (/groups\/.+/.test(link)) {
  9211. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9212. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9213. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9214. }
  9215. }
  9216. }
  9217. if (ytbLinks.length > 0) {
  9218. for (const ytbLink of ytbLinks) {
  9219. const link = $(ytbLink).attr('href');
  9220. if (!link) {
  9221. continue;
  9222. }
  9223. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9224. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9225. }
  9226. }
  9227. 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');
  9228. if (giveawayLinks.length > 0) {
  9229. for (const giveawayLink of giveawayLinks) {
  9230. const link = $(giveawayLink).attr('href');
  9231. if (!link) {
  9232. continue;
  9233. }
  9234. website_leftKeyChecker.classify(link).then(status => {
  9235. if (!status) {
  9236. return;
  9237. }
  9238. if (/^Active/.test(status)) {
  9239. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9240. return;
  9241. }
  9242. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9243. }).catch(error => {
  9244. throwError(error, 'keylol.after -> leftKeyChecker');
  9245. });
  9246. }
  9247. }
  9248. if (this.name === 'Keylol') {
  9249. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9250. if (asfLinks.length > 0) {
  9251. for (const asfLink of asfLinks) {
  9252. const link = $(asfLink).attr('href');
  9253. if (!link) {
  9254. continue;
  9255. }
  9256. 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', '')}`);
  9257. }
  9258. }
  9259. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9260. if (subLinks.length > 0) {
  9261. for (const subLink of subLinks) {
  9262. var _link$match;
  9263. const link = $(subLink).attr('href');
  9264. if (!link) {
  9265. continue;
  9266. }
  9267. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9268. if (!subid) {
  9269. continue;
  9270. }
  9271. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9272. }
  9273. }
  9274. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9275. if (asfLinks2.length > 0) {
  9276. for (const asfLink of asfLinks2) {
  9277. const subid = asfLink.innerText.match(/[\d]+/g);
  9278. if (!subid || subid.length === 0) {
  9279. continue;
  9280. }
  9281. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9282. }
  9283. }
  9284. }
  9285. } catch (error) {
  9286. throwError(error, 'keylol.after');
  9287. }
  9288. }
  9289. classifyTask(action) {
  9290. try {
  9291. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9292. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9293. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9294. for (const btn of selectedBtns) {
  9295. const button = $(btn);
  9296. const social = button.attr('data-social');
  9297. const type = button.attr('data-type');
  9298. const link = button.attr('data-link');
  9299. if (!(social && type && link)) {
  9300. continue;
  9301. }
  9302. if (action === 'do') {
  9303. this.undoneTasks[social][type].push(link);
  9304. }
  9305. if (action === 'undo') {
  9306. this.socialTasks[social][type].push(link);
  9307. }
  9308. }
  9309. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9310. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9311. if (window.DEBUG) {
  9312. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9313. }
  9314. return true;
  9315. } catch (error) {
  9316. throwError(error, 'Keylol.classifyTask');
  9317. return false;
  9318. }
  9319. }
  9320. selectAll() {
  9321. try {
  9322. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9323. } catch (error) {
  9324. throwError(error, 'Keylol.selectAll');
  9325. }
  9326. }
  9327. selectNone() {
  9328. try {
  9329. $('.auto-task-keylol:visible').removeAttr('selected');
  9330. } catch (error) {
  9331. throwError(error, 'Keylol.selectNone');
  9332. }
  9333. }
  9334. invertSelect() {
  9335. try {
  9336. $('.auto-task-keylol:visible').each((index, element) => {
  9337. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9338. });
  9339. } catch (error) {
  9340. throwError(error, 'Keylol.invertSelect');
  9341. }
  9342. }
  9343. }
  9344. function _addBtn2(before, social, linkType, link) {
  9345. try {
  9346. $(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>`);
  9347. } catch (error) {
  9348. throwError(error, 'keylol.addBtn');
  9349. }
  9350. }
  9351. const website_Keylol = Keylol;
  9352. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9353. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9354. privateSet.add(obj);
  9355. }
  9356. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9357. if (privateCollection.has(obj)) {
  9358. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9359. }
  9360. }
  9361. function Opquests_defineProperty(obj, key, value) {
  9362. if (key in obj) {
  9363. Object.defineProperty(obj, key, {
  9364. value: value,
  9365. enumerable: true,
  9366. configurable: true,
  9367. writable: true
  9368. });
  9369. } else {
  9370. obj[key] = value;
  9371. }
  9372. return obj;
  9373. }
  9374. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9375. if (!privateSet.has(receiver)) {
  9376. throw new TypeError('attempted to get private field on non-instance');
  9377. }
  9378. return fn;
  9379. }
  9380. const Opquests_defaultTasks = {
  9381. steam: {
  9382. groupLinks: [],
  9383. wishlistLinks: [],
  9384. followLinks: [],
  9385. curatorLikeLinks: []
  9386. }
  9387. };
  9388. var Opquests_getGiveawayId = new WeakSet();
  9389. var Opquests_checkLogin = new WeakSet();
  9390. class Opquests extends website_Website {
  9391. constructor() {
  9392. super(...arguments);
  9393. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9394. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9395. Opquests_defineProperty(this, 'name', 'Opquests');
  9396. Opquests_defineProperty(this, 'undoneTasks', {
  9397. ...Opquests_defaultTasks
  9398. });
  9399. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9400. }
  9401. static test() {
  9402. return window.location.host === 'opquests.com';
  9403. }
  9404. async after() {
  9405. try {
  9406. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9407. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9408. }
  9409. } catch (error) {
  9410. throwError(error, 'Opquests.after');
  9411. }
  9412. }
  9413. init() {
  9414. try {
  9415. const logStatus = scripts_echoLog({
  9416. text: i18n('initing')
  9417. });
  9418. if ($('a[href*="/auth/redirect"]').length > 0) {
  9419. window.open('/auth/redirect', '_self');
  9420. logStatus.warning(i18n('needLogin'));
  9421. return false;
  9422. }
  9423. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9424. return false;
  9425. }
  9426. this.initialized = true;
  9427. logStatus.success();
  9428. return true;
  9429. } catch (error) {
  9430. throwError(error, 'Opquests.init');
  9431. return false;
  9432. }
  9433. }
  9434. async classifyTask(action) {
  9435. try {
  9436. if (action === 'undo') {
  9437. scripts_echoLog({
  9438. text: i18n('cannotUndo')
  9439. });
  9440. return false;
  9441. }
  9442. const logStatus = scripts_echoLog({
  9443. text: i18n('getTasksInfo')
  9444. });
  9445. const tasks = $('.w-full:contains("Validate") .items-center');
  9446. for (const task of tasks) {
  9447. const link = $(task).find('a:contains("Open")').attr('href');
  9448. const taskDes = $(task).find('div').eq(1).text().trim();
  9449. if (!link) {
  9450. continue;
  9451. }
  9452. if (/steamcommunity\.com\/groups\//.test(link)) {
  9453. this.undoneTasks.steam.groupLinks.push(link);
  9454. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9455. if (/wishlist/gim.test(taskDes)) {
  9456. this.undoneTasks.steam.wishlistLinks.push(link);
  9457. } else if (/follow/gim.test(taskDes)) {
  9458. this.undoneTasks.steam.followLinks.push(link);
  9459. }
  9460. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9461. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9462. } else {
  9463. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9464. }
  9465. }
  9466. logStatus.success();
  9467. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9468. if (window.DEBUG) {
  9469. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9470. }
  9471. return true;
  9472. } catch (error) {
  9473. throwError(error, 'Opquests.classifyTask');
  9474. return false;
  9475. }
  9476. }
  9477. }
  9478. function Opquests_getGiveawayId2() {
  9479. try {
  9480. var _window$location$href;
  9481. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9482. if (giveawayId) {
  9483. this.giveawayId = giveawayId;
  9484. return true;
  9485. }
  9486. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9487. return false;
  9488. } catch (error) {
  9489. throwError(error, 'Opquests.getGiveawayId');
  9490. return false;
  9491. }
  9492. }
  9493. function Opquests_checkLogin2() {
  9494. try {
  9495. if (!globalOptions.other.checkLogin) {
  9496. return true;
  9497. }
  9498. if ($('a[href*="/auth/redirect"]').length > 0) {
  9499. window.open('/auth/redirect', '_self');
  9500. }
  9501. return true;
  9502. } catch (error) {
  9503. throwError(error, 'Opquests.checkLogin');
  9504. return false;
  9505. }
  9506. }
  9507. const website_Opquests = Opquests;
  9508. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9509. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9510. privateSet.add(obj);
  9511. }
  9512. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9513. if (privateCollection.has(obj)) {
  9514. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9515. }
  9516. }
  9517. function Gleam_defineProperty(obj, key, value) {
  9518. if (key in obj) {
  9519. Object.defineProperty(obj, key, {
  9520. value: value,
  9521. enumerable: true,
  9522. configurable: true,
  9523. writable: true
  9524. });
  9525. } else {
  9526. obj[key] = value;
  9527. }
  9528. return obj;
  9529. }
  9530. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9531. if (!privateSet.has(receiver)) {
  9532. throw new TypeError('attempted to get private field on non-instance');
  9533. }
  9534. return fn;
  9535. }
  9536. const Gleam_defaultTasksTemplate = {
  9537. steam: {
  9538. groupLinks: [],
  9539. wishlistLinks: [],
  9540. followLinks: [],
  9541. curatorLinks: [],
  9542. curatorLikeLinks: []
  9543. },
  9544. twitter: {
  9545. userLinks: [],
  9546. retweetLinks: []
  9547. },
  9548. twitch: {
  9549. channelLinks: []
  9550. },
  9551. discord: {
  9552. serverLinks: []
  9553. },
  9554. youtube: {
  9555. channelLinks: []
  9556. },
  9557. extra: {
  9558. gleam: []
  9559. }
  9560. };
  9561. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9562. const Gleam_defaultOptions = {
  9563. vlootUsername: '',
  9564. gameroundUsername: ''
  9565. };
  9566. var _checkSync = new WeakSet();
  9567. var _doGleamTask = new WeakSet();
  9568. var Gleam_getGiveawayId = new WeakSet();
  9569. var _getGleamLink = new WeakSet();
  9570. var Gleam_checkLeftKey = new WeakSet();
  9571. class Gleam extends website_Website {
  9572. constructor() {
  9573. super(...arguments);
  9574. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9575. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9576. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9577. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9578. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9579. Gleam_defineProperty(this, 'name', 'Gleam');
  9580. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9581. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9582. Gleam_defineProperty(this, 'options', {
  9583. ...Gleam_defaultOptions,
  9584. ...GM_getValue('GleamOptions')
  9585. });
  9586. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9587. }
  9588. static test() {
  9589. return window.location.host === 'gleam.io';
  9590. }
  9591. async after() {
  9592. try {
  9593. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9594. const checkComplete = setInterval(() => {
  9595. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9596. clearInterval(checkComplete);
  9597. window.close();
  9598. }
  9599. });
  9600. for (const task of $('.entry-content .entry-method')) {
  9601. const taskInfo = $(task).find('.user-links');
  9602. const expandInfo = $(task).find('.expandable');
  9603. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9604. if (aElements.length > 0) {
  9605. for (const element of aElements) {
  9606. const $element = $(element);
  9607. const href = $element.attr('href');
  9608. $element.removeAttr('href')[0].click();
  9609. $element.attr('href', href);
  9610. await delay(1e3);
  9611. }
  9612. }
  9613. taskInfo[0].click();
  9614. await delay(1e3);
  9615. }
  9616. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9617. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9618. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9619. }
  9620. } catch (error) {
  9621. throwError(error, 'Gleam.after');
  9622. return false;
  9623. }
  9624. }
  9625. init() {
  9626. try {
  9627. const logStatus = scripts_echoLog({
  9628. text: i18n('initing')
  9629. });
  9630. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9631. return false;
  9632. }
  9633. this.initialized = true;
  9634. logStatus.success();
  9635. return true;
  9636. } catch (error) {
  9637. throwError(error, 'Gleam.init');
  9638. return false;
  9639. }
  9640. }
  9641. async classifyTask(action) {
  9642. try {
  9643. const logStatus = scripts_echoLog({
  9644. text: i18n('getTasksInfo')
  9645. });
  9646. if (action === 'undo') {
  9647. var _GM_getValue;
  9648. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9649. }
  9650. const tasks = $('.entry-content .entry-method');
  9651. for (const task of tasks) {
  9652. var _socialIcon$attr;
  9653. const $task = $(task);
  9654. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9655. continue;
  9656. }
  9657. const socialIcon = $task.find('.icon-wrapper i');
  9658. const taskInfo = $task.find('.user-links');
  9659. const taskText = taskInfo.text().trim();
  9660. const expandInfo = $task.find('.expandable');
  9661. const aElements = expandInfo.find('a.btn');
  9662. if (aElements.length > 0) {
  9663. for (const element of aElements) {
  9664. const $element = $(element);
  9665. const href = $element.attr('href');
  9666. $element.removeAttr('href')[0].click();
  9667. $element.attr('href', href);
  9668. }
  9669. }
  9670. if (socialIcon.hasClass('fa-twitter')) {
  9671. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9672. if (!link) {
  9673. continue;
  9674. }
  9675. if (/follow/gi.test(taskText)) {
  9676. if (action === 'undo') {
  9677. this.socialTasks.twitter.userLinks.push(link);
  9678. }
  9679. if (action === 'do') {
  9680. this.undoneTasks.twitter.userLinks.push(link);
  9681. }
  9682. } else if (/retweet/gim.test(taskText)) {
  9683. if (action === 'undo') {
  9684. this.socialTasks.twitter.retweetLinks.push(link);
  9685. }
  9686. if (action === 'do') {
  9687. this.undoneTasks.twitter.retweetLinks.push(link);
  9688. }
  9689. }
  9690. } else if (socialIcon.hasClass('fa-twitch')) {
  9691. if (/follow/gim.test(taskText)) {
  9692. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9693. if (!link) {
  9694. continue;
  9695. }
  9696. if (action === 'undo') {
  9697. this.socialTasks.twitch.channelLinks.push(link);
  9698. }
  9699. if (action === 'do') {
  9700. this.undoneTasks.twitch.channelLinks.push(link);
  9701. }
  9702. }
  9703. } else if (socialIcon.hasClass('fa-discord')) {
  9704. if (/join/gim.test(taskText)) {
  9705. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9706. if (!link) {
  9707. var _$task$find$attr, _$task$find$attr$matc;
  9708. 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];
  9709. if (!ggLink) {
  9710. continue;
  9711. }
  9712. link = `https://discord.com/invite/${ggLink}`;
  9713. }
  9714. if (action === 'undo') {
  9715. this.socialTasks.discord.serverLinks.push(link);
  9716. }
  9717. if (action === 'do') {
  9718. this.undoneTasks.discord.serverLinks.push(link);
  9719. }
  9720. }
  9721. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9722. continue;
  9723. } else if (socialIcon.hasClass('fa-youtube')) {
  9724. if (/subscribe/gim.test(taskText)) {
  9725. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9726. if (!link) {
  9727. continue;
  9728. }
  9729. if (action === 'undo') {
  9730. this.socialTasks.youtube.channelLinks.push(link);
  9731. }
  9732. if (action === 'do') {
  9733. this.undoneTasks.youtube.channelLinks.push(link);
  9734. }
  9735. }
  9736. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9737. if (/join.*group/gi.test(taskText)) {
  9738. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9739. if (!link) {
  9740. continue;
  9741. }
  9742. if (action === 'undo') {
  9743. this.socialTasks.steam.groupLinks.push(link);
  9744. }
  9745. if (action === 'do') {
  9746. this.undoneTasks.steam.groupLinks.push(link);
  9747. }
  9748. } else if (/follow.*curator/gi.test(taskText)) {
  9749. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9750. if (!link) {
  9751. continue;
  9752. }
  9753. if (action === 'undo') {
  9754. this.socialTasks.steam.curatorLinks.push(link);
  9755. }
  9756. if (action === 'do') {
  9757. this.undoneTasks.steam.curatorLinks.push(link);
  9758. }
  9759. }
  9760. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('vloot.io') || socialIcon.hasClass('fa-tiktok')) {
  9761. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9762. for (const button of continueBtn) {
  9763. button.click();
  9764. await delay(500);
  9765. expandInfo.find('input').val(this.options.vlootUsername);
  9766. }
  9767. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9768. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9769. for (const button of continueBtn) {
  9770. button.click();
  9771. await delay(500);
  9772. expandInfo.find('input').val(this.options.gameroundUsername);
  9773. }
  9774. } else if (socialIcon.hasClass('fa-bullhorn') && /Complete/gi.test(taskText)) {
  9775. if (action !== 'do') {
  9776. continue;
  9777. }
  9778. const link = aElements.attr('href');
  9779. if (!link) {
  9780. continue;
  9781. }
  9782. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9783. if (!gleamLink) {
  9784. continue;
  9785. }
  9786. this.undoneTasks.extra.gleam.push(gleamLink);
  9787. } 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 {
  9788. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9789. }
  9790. }
  9791. logStatus.success();
  9792. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9793. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9794. if (window.DEBUG) {
  9795. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9796. }
  9797. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9798. tasks: this.socialTasks,
  9799. time: new Date().getTime()
  9800. });
  9801. return true;
  9802. } catch (error) {
  9803. throwError(error, 'Gleam.classifyTask');
  9804. return false;
  9805. }
  9806. }
  9807. async extraDoTask(_ref) {
  9808. let {
  9809. gleam
  9810. } = _ref;
  9811. try {
  9812. const pro = [];
  9813. for (const link of gleam) {
  9814. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9815. }
  9816. return Promise.all(pro).then(() => true);
  9817. } catch (error) {
  9818. throwError(error, 'Gleam.extraDoTask');
  9819. return false;
  9820. }
  9821. }
  9822. async verifyTask() {
  9823. try {
  9824. scripts_echoLog({
  9825. text: `${i18n('verifyingTask')}...`
  9826. });
  9827. const tasks = $('.entry-content .entry-method');
  9828. for (const task of tasks) {
  9829. const $task = $(task);
  9830. if ($task.find('i.fa-question').length === 0) {
  9831. continue;
  9832. }
  9833. const taskInfo = $task.find('.user-links');
  9834. taskInfo[0].click();
  9835. await delay(500);
  9836. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9837. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9838. for (const button of continueBtn) {
  9839. button.click();
  9840. await delay(500);
  9841. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9842. }
  9843. }
  9844. scripts_echoLog({
  9845. text: i18n('verifiedGleamTasks')
  9846. });
  9847. } catch (error) {
  9848. throwError(error, 'Gleam.verifyTask');
  9849. return false;
  9850. }
  9851. }
  9852. }
  9853. async function _checkSync2() {
  9854. try {
  9855. return await new Promise(resolve => {
  9856. const checker = setInterval(() => {
  9857. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9858. clearInterval(checker);
  9859. resolve(true);
  9860. }
  9861. }, 500);
  9862. });
  9863. } catch (error) {
  9864. throwError(error, 'Gleam.checkSync');
  9865. return false;
  9866. }
  9867. }
  9868. async function _doGleamTask2(link) {
  9869. try {
  9870. const logStatus = scripts_echoLog({
  9871. text: i18n('doingGleamTask')
  9872. });
  9873. return await new Promise(resolve => {
  9874. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9875. active: true,
  9876. insert: true,
  9877. setParent: true
  9878. }).onclose = () => {
  9879. logStatus.success();
  9880. resolve(true);
  9881. };
  9882. });
  9883. } catch (error) {
  9884. throwError(error, 'Gleam.doGleamTask');
  9885. return false;
  9886. }
  9887. }
  9888. function Gleam_getGiveawayId2() {
  9889. try {
  9890. const giveawayId = window.location.pathname;
  9891. if (giveawayId) {
  9892. this.giveawayId = giveawayId;
  9893. return true;
  9894. }
  9895. scripts_echoLog({
  9896. text: i18n('getFailed', 'GiveawayId')
  9897. });
  9898. return false;
  9899. } catch (error) {
  9900. throwError(error, 'Gleam.getGiveawayId');
  9901. return false;
  9902. }
  9903. }
  9904. async function _getGleamLink2(link) {
  9905. try {
  9906. const logStatus = scripts_echoLog({
  9907. text: i18n('gettingGleamLink')
  9908. });
  9909. const {
  9910. result,
  9911. statusText,
  9912. status,
  9913. data
  9914. } = await tools_httpRequest({
  9915. url: link,
  9916. method: 'GET'
  9917. });
  9918. if (result === 'Success') {
  9919. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9920. var _data$responseText$ma;
  9921. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9922. if (gleamLink) {
  9923. logStatus.success();
  9924. return gleamLink;
  9925. }
  9926. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9927. return false;
  9928. }
  9929. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9930. return false;
  9931. }
  9932. logStatus.error(`${result}:${statusText}(${status})`);
  9933. return false;
  9934. } catch (error) {
  9935. throwError(error, 'Gleam.getGleamLink');
  9936. return false;
  9937. }
  9938. }
  9939. async function Gleam_checkLeftKey2() {
  9940. try {
  9941. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9942. if (!globalOptions.other.checkLeftKey) {
  9943. return true;
  9944. }
  9945. 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];
  9946. if (!campaignString) {
  9947. return false;
  9948. }
  9949. const {
  9950. campaign,
  9951. incentive
  9952. } = JSON.parse(campaignString);
  9953. 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];
  9954. let ownedKey = false;
  9955. if (controllerString) {
  9956. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9957. 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) {
  9958. ownedKey = true;
  9959. }
  9960. }
  9961. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9962. await external_Swal_default().fire({
  9963. icon: 'warning',
  9964. title: i18n('notice'),
  9965. text: i18n('giveawayNotWork'),
  9966. confirmButtonText: i18n('confirm'),
  9967. cancelButtonText: i18n('cancel'),
  9968. showCancelButton: true
  9969. }).then(_ref2 => {
  9970. let {
  9971. value
  9972. } = _ref2;
  9973. if (value) {
  9974. window.close();
  9975. }
  9976. });
  9977. }
  9978. return true;
  9979. } catch (error) {
  9980. throwError(error, 'Gleam.checkLeftKey');
  9981. return false;
  9982. }
  9983. }
  9984. const website_Gleam = Gleam;
  9985. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9986. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9987. privateSet.add(obj);
  9988. }
  9989. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9990. if (privateCollection.has(obj)) {
  9991. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9992. }
  9993. }
  9994. function SweepWidget_defineProperty(obj, key, value) {
  9995. if (key in obj) {
  9996. Object.defineProperty(obj, key, {
  9997. value: value,
  9998. enumerable: true,
  9999. configurable: true,
  10000. writable: true
  10001. });
  10002. } else {
  10003. obj[key] = value;
  10004. }
  10005. return obj;
  10006. }
  10007. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  10008. if (!privateSet.has(receiver)) {
  10009. throw new TypeError('attempted to get private field on non-instance');
  10010. }
  10011. return fn;
  10012. }
  10013. const SweepWidget_defaultOptions = {
  10014. username: '',
  10015. email: ''
  10016. };
  10017. var SweepWidget_checkLogin = new WeakSet();
  10018. var SweepWidget_getGiveawayId = new WeakSet();
  10019. var _checkEnter = new WeakSet();
  10020. var _checkFinish = new WeakSet();
  10021. class SweepWidget extends website_Website {
  10022. constructor() {
  10023. super(...arguments);
  10024. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  10025. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  10026. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  10027. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  10028. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  10029. SweepWidget_defineProperty(this, 'options', {
  10030. ...SweepWidget_defaultOptions,
  10031. ...GM_getValue('SweepWidgetOptions')
  10032. });
  10033. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  10034. }
  10035. static test() {
  10036. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  10037. }
  10038. async after() {
  10039. try {
  10040. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  10041. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  10042. }
  10043. } catch (error) {
  10044. throwError(error, 'SweepWidget.after');
  10045. }
  10046. }
  10047. init() {
  10048. try {
  10049. const logStatus = scripts_echoLog({
  10050. text: i18n('initing')
  10051. });
  10052. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  10053. logStatus.warning(i18n('needLogin'));
  10054. return false;
  10055. }
  10056. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  10057. return false;
  10058. }
  10059. this.initialized = true;
  10060. logStatus.success();
  10061. return true;
  10062. } catch (error) {
  10063. throwError(error, 'SweepWidget.init');
  10064. return false;
  10065. }
  10066. }
  10067. classifyTask() {
  10068. return true;
  10069. }
  10070. async doTask() {
  10071. try {
  10072. if ($('#unlock_rewards_main_wrapper').length === 0) {
  10073. if ($('input[name="sw__login_name"]:visible').length > 0) {
  10074. $('input[name="sw__login_name"]').val(this.options.username);
  10075. }
  10076. if ($('input[name="sw__login_email"]:visible').length > 0) {
  10077. $('input[name="sw__login_email"]').val(this.options.email);
  10078. }
  10079. if ($('#sw_login_button:visible').length > 0) {
  10080. $('#sw_login_button')[0].click();
  10081. }
  10082. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  10083. return false;
  10084. }
  10085. }
  10086. const logStatus = scripts_echoLog({
  10087. text: i18n('SweepWidgetNotice')
  10088. });
  10089. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  10090. for (const task of tasks) {
  10091. var _aElement$, _$task$find$removeAtt;
  10092. const $task = $(task);
  10093. if ($task.find('i.fa-check:visible').length > 0) {
  10094. continue;
  10095. }
  10096. const title = $task.find('.sw_text_inner');
  10097. title[0].click();
  10098. const aElement = $task.find('a.sw_link');
  10099. const link = aElement.attr('href');
  10100. aElement.attr('href', '#a').attr('target', '_self');
  10101. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  10102. await delay(300);
  10103. aElement.attr('href', link).attr('target', '_blank');
  10104. $task.find('input[type="text"]').val('test');
  10105. const verifyBtn = $task.find('input.sw_verify');
  10106. if (verifyBtn.prop('disabled') === true) {
  10107. title[0].click();
  10108. await delay(300);
  10109. title[0].click();
  10110. await delay(300);
  10111. }
  10112. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  10113. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  10114. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  10115. }
  10116. logStatus.success();
  10117. return true;
  10118. } catch (error) {
  10119. throwError(error, 'SweepWidget.doTask');
  10120. return false;
  10121. }
  10122. }
  10123. }
  10124. function SweepWidget_checkLogin2() {
  10125. try {
  10126. if ($('#twitter_login_button').length > 0) {
  10127. $('#twitter_login_button')[0].click();
  10128. }
  10129. return true;
  10130. } catch (error) {
  10131. throwError(error, 'SweepWidget.checkLogin');
  10132. return false;
  10133. }
  10134. }
  10135. function SweepWidget_getGiveawayId2() {
  10136. try {
  10137. var _window$location$href;
  10138. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  10139. if (giveawayId) {
  10140. this.giveawayId = giveawayId;
  10141. return true;
  10142. }
  10143. scripts_echoLog({
  10144. text: i18n('getFailed', 'GiveawayId')
  10145. });
  10146. return false;
  10147. } catch (error) {
  10148. throwError(error, 'SweepWidget.getGiveawayId');
  10149. return false;
  10150. }
  10151. }
  10152. async function _checkEnter2() {
  10153. try {
  10154. return new Promise(resolve => {
  10155. const checker = setInterval(() => {
  10156. if ($('#unlock_rewards_main_wrapper').length > 0) {
  10157. clearInterval(checker);
  10158. resolve(true);
  10159. }
  10160. });
  10161. });
  10162. } catch (error) {
  10163. throwError(error, 'SweepWidget.checkEnter');
  10164. return false;
  10165. }
  10166. }
  10167. async function _checkFinish2($task) {
  10168. try {
  10169. return new Promise(resolve => {
  10170. const checker = setInterval(() => {
  10171. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  10172. clearInterval(checker);
  10173. resolve(true);
  10174. }
  10175. });
  10176. });
  10177. } catch (error) {
  10178. throwError(error, 'SweepWidget.checkFinish');
  10179. return false;
  10180. }
  10181. }
  10182. const website_SweepWidget = SweepWidget;
  10183. const defaultWhiteList = {
  10184. discord: {
  10185. servers: []
  10186. },
  10187. instagram: {
  10188. users: []
  10189. },
  10190. twitch: {
  10191. channels: []
  10192. },
  10193. twitter: {
  10194. users: [],
  10195. retweets: [],
  10196. likes: []
  10197. },
  10198. vk: {
  10199. names: []
  10200. },
  10201. youtube: {
  10202. channels: [],
  10203. likes: []
  10204. },
  10205. reddit: {
  10206. reddits: []
  10207. },
  10208. steam: {
  10209. groups: [],
  10210. officialGroups: [],
  10211. wishlists: [],
  10212. follows: [],
  10213. forums: [],
  10214. workshops: [],
  10215. curators: [],
  10216. workshopVotes: [],
  10217. curatorLikes: [],
  10218. announcements: [],
  10219. licenses: [],
  10220. playtests: []
  10221. }
  10222. };
  10223. const link2id = async function(type) {
  10224. 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;
  10225. try {
  10226. const link = $('#socialLink').val();
  10227. let id = '';
  10228. switch (type) {
  10229. case 'discord.servers':
  10230. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10231. break;
  10232.  
  10233. case 'instagram.users':
  10234. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10235. break;
  10236.  
  10237. case 'twitch.channels':
  10238. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10239. break;
  10240.  
  10241. case 'twitter.users':
  10242. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10243. break;
  10244.  
  10245. case 'twitter.retweets':
  10246. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10247. break;
  10248.  
  10249. case 'vk.names':
  10250. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10251. break;
  10252.  
  10253. case 'youtube.channels':
  10254. 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) || '';
  10255. break;
  10256.  
  10257. case 'youtube.likes':
  10258. 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) || '';
  10259. break;
  10260.  
  10261. case 'reddit.reddits':
  10262. 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]) || '';
  10263. break;
  10264.  
  10265. case 'steam.groups':
  10266. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10267. break;
  10268.  
  10269. case 'steam.wishlists':
  10270. case 'steam.follows':
  10271. case 'steam.forums':
  10272. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10273. break;
  10274.  
  10275. case 'steam.workshops':
  10276. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10277. break;
  10278.  
  10279. case 'steam.curators':
  10280. {
  10281. if (link.includes('curator')) {
  10282. var _link$match12;
  10283. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10284. } else {
  10285. var _link$match13;
  10286. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10287. if (!param || param.length !== 2) {
  10288. break;
  10289. }
  10290. const steam = new social_Steam();
  10291. if (await steam.init()) {
  10292. id = await steam.getCuratorId(param[0], param[1]) || '';
  10293. }
  10294. }
  10295. }
  10296. break;
  10297. }
  10298. return id;
  10299. } catch (error) {
  10300. throwError(error, 'link2id');
  10301. return i18n('getFailed', 'id');
  10302. }
  10303. };
  10304. const disabledType = {
  10305. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10306. twitter: [ 'likes' ]
  10307. };
  10308. const assignWhiteList = whiteList => {
  10309. try {
  10310. const newWhiteList = {};
  10311. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10312. newWhiteList[key] = {
  10313. ...value,
  10314. ...whiteList[key]
  10315. };
  10316. }
  10317. return newWhiteList;
  10318. } catch (error) {
  10319. throwError(error, 'assignWhiteList');
  10320. return defaultWhiteList;
  10321. }
  10322. };
  10323. const whiteListOptions = function(showType) {
  10324. try {
  10325. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10326. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10327. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10328. for (const [ social, types ] of Object.entries(whiteList)) {
  10329. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10330. var _disabledType$social;
  10331. 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>`;
  10332. }).join('');
  10333. }
  10334. whiteListOptionsForm += '</tbody></table></form>';
  10335. if (showType === 'swal') {
  10336. external_Swal_default().fire({
  10337. title: i18n('whiteListOptions'),
  10338. html: whiteListOptionsForm,
  10339. showConfirmButton: false,
  10340. showCloseButton: true
  10341. });
  10342. } else {
  10343. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10344. }
  10345. $('.editWhiteList').on('click', function() {
  10346. var _whiteList$social;
  10347. const value = $(this).attr('data-value');
  10348. if (!value) {
  10349. return;
  10350. }
  10351. const [ social, type ] = value.split('.');
  10352. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10353. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10354. return;
  10355. }
  10356. external_Swal_default().fire({
  10357. title: i18n('changeWhiteListOption', value),
  10358. input: 'textarea',
  10359. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10360. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10361. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10362. inputValue: whiteList[social][type].join('\n'),
  10363. showConfirmButton: true,
  10364. confirmButtonText: i18n('save'),
  10365. showCancelButton: true,
  10366. cancelButtonText: i18n('close'),
  10367. showDenyButton: true,
  10368. denyButtonText: i18n('return')
  10369. }).then(_ref => {
  10370. let {
  10371. isDenied,
  10372. isConfirmed,
  10373. value
  10374. } = _ref;
  10375. if (isDenied) {
  10376. if (showType === 'swal') {
  10377. whiteListOptions(showType);
  10378. }
  10379. return;
  10380. } else if (isConfirmed) {
  10381. whiteList[social][type] = value.split('\n');
  10382. GM_setValue('whiteList', whiteList);
  10383. external_Swal_default().fire({
  10384. title: i18n('changeWhiteListSuccess'),
  10385. icon: 'success'
  10386. });
  10387. }
  10388. });
  10389. $('#link2id').on('click', async function() {
  10390. const type = $(this).attr('data-type');
  10391. $('#socialLink').val(await link2id(type));
  10392. });
  10393. });
  10394. } catch (error) {
  10395. throwError(error, 'whiteListOptions');
  10396. }
  10397. };
  10398. const whiteList = whiteListOptions;
  10399. const setGistData = async (token, gistId, fileName, content) => {
  10400. try {
  10401. const logStatus = scripts_echoLog({
  10402. text: i18n('settingData')
  10403. });
  10404. const contentData = JSON.stringify({
  10405. files: {
  10406. [fileName]: {
  10407. content: JSON.stringify(content)
  10408. }
  10409. }
  10410. });
  10411. const {
  10412. result,
  10413. statusText,
  10414. status,
  10415. data
  10416. } = await tools_httpRequest({
  10417. url: `https://api.github.com/gists/${gistId}`,
  10418. headers: {
  10419. Accept: 'application/vnd.github.v3+json',
  10420. Authorization: `token ${token}`
  10421. },
  10422. data: contentData,
  10423. responseType: 'json',
  10424. method: 'POST',
  10425. timeout: 3e4
  10426. });
  10427. if (result === 'Success') {
  10428. var _data$response$files, _data$response$files$;
  10429. 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)) {
  10430. logStatus.success();
  10431. return true;
  10432. }
  10433. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10434. return false;
  10435. }
  10436. logStatus.error(`${result}:${statusText}(${status})`);
  10437. return false;
  10438. } catch (error) {
  10439. throwError(error, 'setGistData');
  10440. return false;
  10441. }
  10442. };
  10443. const getGistData = async function(token, gistId, fileName) {
  10444. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10445. try {
  10446. const logStatus = scripts_echoLog({
  10447. text: i18n('gettingData')
  10448. });
  10449. const {
  10450. result,
  10451. statusText,
  10452. status,
  10453. data
  10454. } = await tools_httpRequest({
  10455. url: `https://api.github.com/gists/${gistId}`,
  10456. headers: {
  10457. Accept: 'application/vnd.github.v3+json',
  10458. Authorization: `token ${token}`
  10459. },
  10460. responseType: 'json',
  10461. method: 'GET',
  10462. timeout: 3e4
  10463. });
  10464. if (result === 'Success') {
  10465. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10466. var _data$response, _data$response$files2, _data$response$files3;
  10467. 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;
  10468. let formatedContent;
  10469. if (!content) {
  10470. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10471. return false;
  10472. }
  10473. if (test) {
  10474. logStatus.success();
  10475. return true;
  10476. }
  10477. try {
  10478. formatedContent = JSON.parse(content);
  10479. } catch (error) {
  10480. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10481. return false;
  10482. }
  10483. logStatus.success();
  10484. return formatedContent;
  10485. }
  10486. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10487. return false;
  10488. }
  10489. logStatus.error(`${result}:${statusText}(${status})`);
  10490. return false;
  10491. } catch (error) {
  10492. throwError(error, 'getGistData');
  10493. return false;
  10494. }
  10495. };
  10496. const syncOptions = () => {
  10497. try {
  10498. const {
  10499. TOKEN,
  10500. GIST_ID,
  10501. FILE_NAME,
  10502. SYNC_HISTORY
  10503. } = GM_getValue('gistOptions') || {
  10504. TOKEN: '',
  10505. GIST_ID: '',
  10506. FILE_NAME: '',
  10507. SYNC_HISTORY: true
  10508. };
  10509. external_Swal_default().fire({
  10510. title: i18n('gistOptions'),
  10511. 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;">
  10512. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10513. ${i18n('downloadFromGist')}</button></p>`,
  10514. focusConfirm: false,
  10515. showLoaderOnConfirm: true,
  10516. 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>`,
  10517. preConfirm: async () => {
  10518. const token = $('#github-token').val();
  10519. const gistId = $('#gist-id').val();
  10520. const fileName = $('#file-name').val();
  10521. const syncHistory = $('#sync-history').prop('checked');
  10522. GM_setValue('gistOptions', {
  10523. TOKEN: token,
  10524. GIST_ID: gistId,
  10525. FILE_NAME: fileName,
  10526. SYNC_HISTORY: syncHistory
  10527. });
  10528. return await getGistData(token, gistId, fileName, true);
  10529. },
  10530. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10531. confirmButtonText: i18n('saveAndTest'),
  10532. showCancelButton: true,
  10533. cancelButtonText: i18n('close')
  10534. }).then(_ref => {
  10535. let {
  10536. value
  10537. } = _ref;
  10538. if (value) {
  10539. external_Swal_default().fire({
  10540. icon: 'success',
  10541. title: i18n('testSuccess')
  10542. }).then(syncOptions);
  10543. } else if (value !== undefined) {
  10544. external_Swal_default().fire({
  10545. icon: 'error',
  10546. title: i18n('testFailed')
  10547. }).then(syncOptions);
  10548. }
  10549. });
  10550. $('#upload-data').on('click', async () => {
  10551. const {
  10552. TOKEN,
  10553. GIST_ID,
  10554. FILE_NAME
  10555. } = GM_getValue('gistOptions') || {};
  10556. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10557. return external_Swal_default().fire({
  10558. icon: 'error',
  10559. title: i18n('saveAndTestNotice')
  10560. }).then(syncOptions);
  10561. }
  10562. external_Swal_default().fire({
  10563. icon: 'info',
  10564. title: i18n('processingData')
  10565. });
  10566. const data = {};
  10567. const names = GM_listValues();
  10568. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10569. for (const name of names) {
  10570. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10571. continue;
  10572. }
  10573. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10574. continue;
  10575. }
  10576. data[name] = GM_getValue(name);
  10577. }
  10578. external_Swal_default().update({
  10579. icon: 'info',
  10580. title: i18n('updatingData')
  10581. });
  10582. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10583. external_Swal_default().fire({
  10584. icon: 'success',
  10585. title: i18n('syncDataSuccess')
  10586. });
  10587. } else {
  10588. external_Swal_default().fire({
  10589. icon: 'error',
  10590. title: i18n('syncDataFailed')
  10591. });
  10592. }
  10593. });
  10594. $('#download-data').on('click', async () => {
  10595. const {
  10596. TOKEN,
  10597. GIST_ID,
  10598. FILE_NAME
  10599. } = GM_getValue('gistOptions') || {};
  10600. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10601. return external_Swal_default().fire({
  10602. icon: 'error',
  10603. title: i18n('saveAndTestNotice')
  10604. }).then(syncOptions);
  10605. }
  10606. external_Swal_default().fire({
  10607. icon: 'info',
  10608. title: i18n('downloadingData')
  10609. });
  10610. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10611. if (!data) {
  10612. return external_Swal_default().fire({
  10613. icon: 'error',
  10614. title: i18n('checkedNoData')
  10615. }).then(syncOptions);
  10616. }
  10617. external_Swal_default().update({
  10618. icon: 'info',
  10619. title: i18n('savingData')
  10620. });
  10621. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10622. for (const [ name, value ] of Object.entries(data)) {
  10623. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10624. continue;
  10625. }
  10626. GM_setValue(name, value);
  10627. }
  10628. external_Swal_default().fire({
  10629. icon: 'success',
  10630. title: i18n('syncDataSuccess')
  10631. });
  10632. });
  10633. } catch (error) {
  10634. throwError(error, 'syncOptions');
  10635. }
  10636. };
  10637. const dataSync = syncOptions;
  10638. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10639. Setting_checkPrivateRedeclaration(obj, privateSet);
  10640. privateSet.add(obj);
  10641. }
  10642. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10643. if (privateCollection.has(obj)) {
  10644. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10645. }
  10646. }
  10647. function Setting_defineProperty(obj, key, value) {
  10648. if (key in obj) {
  10649. Object.defineProperty(obj, key, {
  10650. value: value,
  10651. enumerable: true,
  10652. configurable: true,
  10653. writable: true
  10654. });
  10655. } else {
  10656. obj[key] = value;
  10657. }
  10658. return obj;
  10659. }
  10660. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10661. if (!privateSet.has(receiver)) {
  10662. throw new TypeError('attempted to get private field on non-instance');
  10663. }
  10664. return fn;
  10665. }
  10666. var Setting_getId = new WeakSet();
  10667. var _environment = new WeakSet();
  10668. class Setting {
  10669. constructor() {
  10670. Setting_classPrivateMethodInitSpec(this, _environment);
  10671. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10672. Setting_defineProperty(this, 'name', 'Setting');
  10673. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10674. Setting_defineProperty(this, 'syncData', dataSync);
  10675. }
  10676. tasksHistory() {
  10677. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10678. }
  10679. static test() {
  10680. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10681. }
  10682. before() {
  10683. $('body').html('').addClass('auto-task-options');
  10684. }
  10685. after() {
  10686. try {
  10687. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10688. changeGlobalOptions('page');
  10689. whiteList('page');
  10690. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10691. $('#getTwitterUserId').on('click', () => {
  10692. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10693. });
  10694. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10695. $('#getYoutubeChannelId').on('click', () => {
  10696. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10697. });
  10698. $('input[name^="position"]').on('input', function() {
  10699. const type = $(this).attr('name').replace('position.', '');
  10700. const xLabel = 'rightleft';
  10701. const yLabel = 'topbottpm';
  10702. switch (type) {
  10703. case 'buttonSideX':
  10704. case 'buttonSideY':
  10705. case 'buttonDistance':
  10706. {
  10707. const distance = $('input[name="position.buttonDistance"]').val();
  10708. const sideX = $('input[name="position.buttonSideX"]').val();
  10709. const sideY = $('input[name="position.buttonSideY"]').val();
  10710. if (![ 'right', 'left' ].includes(sideX)) {
  10711. break;
  10712. }
  10713. if (![ 'top', 'bottom' ].includes(sideY)) {
  10714. break;
  10715. }
  10716. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10717. break;
  10718. }
  10719. const distanceArr = distance.split(',');
  10720. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10721. break;
  10722. }
  10723.  
  10724. case 'showButtonSideX':
  10725. case 'showButtonSideY':
  10726. case 'showButtonDistance':
  10727. {
  10728. const distance = $('input[name="position.showButtonDistance"]').val();
  10729. const sideX = $('input[name="position.showButtonSideX"]').val();
  10730. const sideY = $('input[name="position.showButtonSideY"]').val();
  10731. if (![ 'right', 'left' ].includes(sideX)) {
  10732. break;
  10733. }
  10734. if (![ 'top', 'bottom' ].includes(sideY)) {
  10735. break;
  10736. }
  10737. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10738. break;
  10739. }
  10740. const distanceArr = distance.split(',');
  10741. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10742. break;
  10743. }
  10744.  
  10745. case 'logSideX':
  10746. case 'logSideY':
  10747. case 'logDistance':
  10748. {
  10749. const distance = $('input[name="position.logDistance"]').val();
  10750. const sideX = $('input[name="position.logSideX"]').val();
  10751. const sideY = $('input[name="position.logSideY"]').val();
  10752. if (![ 'right', 'left' ].includes(sideX)) {
  10753. break;
  10754. }
  10755. if (![ 'top', 'bottom' ].includes(sideY)) {
  10756. break;
  10757. }
  10758. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10759. break;
  10760. }
  10761. const distanceArr = distance.split(',');
  10762. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10763. break;
  10764. }
  10765.  
  10766. default:
  10767. break;
  10768. }
  10769. });
  10770. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10771. let functionKey = '';
  10772. if (event.altKey) {
  10773. functionKey += 'alt + ';
  10774. } else if (event.ctrlKey) {
  10775. functionKey += 'ctrl + ';
  10776. } else if (event.shiftKey) {
  10777. functionKey += 'shift + ';
  10778. }
  10779. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10780. });
  10781. } catch (error) {
  10782. throwError(error, 'Setting.after');
  10783. }
  10784. }
  10785. saveGlobalOptions() {
  10786. saveData();
  10787. }
  10788. }
  10789. function Setting_getId2(social) {
  10790. try {
  10791. external_Swal_default().fire({
  10792. title: i18n('getId', i18n(social)),
  10793. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10794. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10795. showCancelButton: true,
  10796. cancelButtonText: i18n('close'),
  10797. showConfirmButton: false
  10798. });
  10799. $('#link2id').on('click', async function() {
  10800. const link = $('#socialLink').val();
  10801. if (!link) {
  10802. return;
  10803. }
  10804. const type = $(this).attr('data-type');
  10805. if (type === 'twitterUser') {
  10806. var _link$match;
  10807. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10808. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10809. } else if (type === 'youtubeChannel') {
  10810. var _link$match2, _await$getInfo, _await$getInfo$params;
  10811. 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;
  10812. $('#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) || '');
  10813. }
  10814. });
  10815. } catch (error) {
  10816. throwError(error, 'Setting.getId');
  10817. }
  10818. }
  10819. function _environment2() {
  10820. try {
  10821. const userAgent = (0, javascript_utils_umd_min.ua)();
  10822. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10823. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10824. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10825. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10826. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10827. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10828. </tbody></table></form>`;
  10829. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10830. } catch (error) {
  10831. throwError(error, 'Setting.environment');
  10832. }
  10833. }
  10834. const website_Setting = Setting;
  10835. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10836. History_checkPrivateRedeclaration(obj, privateSet);
  10837. privateSet.add(obj);
  10838. }
  10839. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10840. if (privateCollection.has(obj)) {
  10841. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10842. }
  10843. }
  10844. function History_defineProperty(obj, key, value) {
  10845. if (key in obj) {
  10846. Object.defineProperty(obj, key, {
  10847. value: value,
  10848. enumerable: true,
  10849. configurable: true,
  10850. writable: true
  10851. });
  10852. } else {
  10853. obj[key] = value;
  10854. }
  10855. return obj;
  10856. }
  10857. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10858. if (!privateSet.has(receiver)) {
  10859. throw new TypeError('attempted to get private field on non-instance');
  10860. }
  10861. return fn;
  10862. }
  10863. var _addItem = new WeakSet();
  10864. class History extends website_Keylol {
  10865. constructor() {
  10866. super(...arguments);
  10867. History_classPrivateMethodInitSpec(this, _addItem);
  10868. History_defineProperty(this, 'name', 'History');
  10869. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10870. }
  10871. static test() {
  10872. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10873. }
  10874. before() {
  10875. try {
  10876. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10877. const data = GM_listValues() || [];
  10878. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10879. for (const item of tasksHistory) {
  10880. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10881. }
  10882. } catch (error) {
  10883. throwError(error, 'History.before');
  10884. }
  10885. }
  10886. clearHistory() {
  10887. try {
  10888. const data = GM_listValues() || [];
  10889. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10890. for (const item of tasksHistory) {
  10891. GM_deleteValue(item);
  10892. }
  10893. external_Swal_default().fire({
  10894. title: i18n('clearHistoryFinished'),
  10895. icon: 'success'
  10896. });
  10897. } catch (error) {
  10898. throwError(error, 'History.after');
  10899. }
  10900. }
  10901. }
  10902. function _addItem2(item) {
  10903. try {
  10904. const tasksData = GM_getValue(item);
  10905. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10906. return;
  10907. }
  10908. let html = '';
  10909. let title = '';
  10910. let link = '';
  10911. const [ website, id ] = item.split('-');
  10912. switch (website) {
  10913. case 'fawTasks':
  10914. title = `Freeanywhere[${id}]`;
  10915. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10916. break;
  10917.  
  10918. case 'gasTasks':
  10919. title = `Giveawaysu[${id}]`;
  10920. link = `https://giveaway.su/giveaway/view/${id}`;
  10921. break;
  10922.  
  10923. case 'gcTasks':
  10924. title = `GiveeClub[${id}]`;
  10925. link = `https://givee.club/event/${id}`;
  10926. break;
  10927.  
  10928. case 'gkTasks':
  10929. title = `Givekey[${id}]`;
  10930. link = `https://givekey.ru/giveaway/${id}`;
  10931. break;
  10932.  
  10933. case 'gleamTasks':
  10934. title = `Gleam[${id}]`;
  10935. link = `https://gleam.io${id}`;
  10936. break;
  10937.  
  10938. case 'khTasks':
  10939. title = `keyhub[${id}]`;
  10940. link = `https://key-hub.eu/giveaway/${id}`;
  10941. break;
  10942.  
  10943. case 'prysTasks':
  10944. title = `Prys[${id}]`;
  10945. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10946. break;
  10947.  
  10948. default:
  10949. return;
  10950. }
  10951. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10952. for (const [ type, tasks ] of Object.entries(types)) {
  10953. for (const task of tasks) {
  10954. 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>`;
  10955. }
  10956. }
  10957. }
  10958. $('.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>`);
  10959. $('span.delete-task').on('click', function() {
  10960. const itemName = $(this).attr('data-name');
  10961. if (itemName) {
  10962. GM_deleteValue(itemName);
  10963. $(`div.card[data-name="${itemName}"]`).remove();
  10964. external_Swal_default().fire({
  10965. title: i18n('clearTaskFinished'),
  10966. text: itemName,
  10967. icon: 'success'
  10968. });
  10969. } else {
  10970. external_Swal_default().fire({
  10971. title: i18n('clearTaskFailed'),
  10972. icon: 'error'
  10973. });
  10974. }
  10975. });
  10976. } catch (error) {
  10977. throwError(error, 'History.addItem');
  10978. }
  10979. }
  10980. const website_History = History;
  10981. 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 ];
  10982. const websiteOptions = function(website, options) {
  10983. try {
  10984. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10985. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10986. for (const [ option, value ] of Object.entries(options)) {
  10987. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10988. }
  10989. websiteOptionsForm += '</tbody></table></form>';
  10990. external_Swal_default().fire({
  10991. title: i18n('websiteOptions'),
  10992. html: websiteOptionsForm,
  10993. showConfirmButton: true,
  10994. confirmButtonText: i18n('save'),
  10995. showCancelButton: true,
  10996. cancelButtonText: i18n('close')
  10997. }).then(_ref => {
  10998. let {
  10999. isConfirmed
  11000. } = _ref;
  11001. if (isConfirmed) {
  11002. $('#websiteOptionsForm').serializeArray().map(value => {
  11003. options[value.name] = value.value;
  11004. return value;
  11005. });
  11006. GM_setValue(`${website}Options`, options);
  11007. external_Swal_default().fire({
  11008. title: i18n('changeWebsiteOptionsSuccess'),
  11009. icon: 'success'
  11010. });
  11011. }
  11012. });
  11013. } catch (error) {
  11014. throwError(error, 'websiteOptions');
  11015. }
  11016. };
  11017. const options = websiteOptions;
  11018. const external_keyboardJS_namespaceObject = keyboardJS;
  11019. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  11020. const checkUpdate = async (updateLink, auto) => {
  11021. try {
  11022. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  11023. const {
  11024. result,
  11025. statusText,
  11026. status,
  11027. data
  11028. } = await tools_httpRequest({
  11029. url: checkUrl,
  11030. responseType: 'json',
  11031. method: 'GET',
  11032. timeout: 3e4
  11033. });
  11034. if (result === 'Success') {
  11035. var _data$response;
  11036. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  11037. return data.response;
  11038. }
  11039. if (!auto) {
  11040. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  11041. }
  11042. return false;
  11043. }
  11044. if (!auto) {
  11045. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  11046. }
  11047. return false;
  11048. } catch (error) {
  11049. throwError(error, 'checkUpdate');
  11050. return false;
  11051. }
  11052. };
  11053. const hasNewVersion = (currentVersion, remoteVersion) => {
  11054. try {
  11055. const [ currentRealVersion ] = currentVersion.split('-');
  11056. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  11057. if (isPreview && !globalOptions.other.receivePreview) {
  11058. return false;
  11059. }
  11060. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  11061. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  11062. if (remoteVersion1 > currentVersion1) {
  11063. return true;
  11064. }
  11065. if (remoteVersion1 < currentVersion1) {
  11066. return false;
  11067. }
  11068. if (remoteVersion2 > currentVersion2) {
  11069. return true;
  11070. }
  11071. if (remoteVersion2 < currentVersion2) {
  11072. return false;
  11073. }
  11074. if (remoteVersion3 > currentVersion3) {
  11075. return true;
  11076. }
  11077. return false;
  11078. } catch (error) {
  11079. throwError(error, 'compareVersion');
  11080. return false;
  11081. }
  11082. };
  11083. const updateChecker = async () => {
  11084. try {
  11085. const currentVersion = GM_info.script.version;
  11086. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  11087. const updateLinks = {
  11088. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  11089. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  11090. standby: 'https://auto-task-v4.hclonely.com/'
  11091. };
  11092. let version;
  11093. let updateLink = '';
  11094. let packageData;
  11095. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  11096. updateLink = updateLinks[updateSource];
  11097. packageData = await checkUpdate(updateLink, false);
  11098. } else {
  11099. updateLink = updateLinks.github;
  11100. packageData = await checkUpdate(updateLink, true);
  11101. if (!packageData) {
  11102. updateLink = updateLinks.jsdelivr;
  11103. packageData = await checkUpdate(updateLink, true);
  11104. if (!packageData) {
  11105. updateLink = updateLinks.standby;
  11106. packageData = await checkUpdate(updateLink, true);
  11107. }
  11108. }
  11109. }
  11110. if (packageData) {
  11111. version = packageData.version || currentVersion;
  11112. } else {
  11113. version = currentVersion;
  11114. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  11115. }
  11116. if (packageData && hasNewVersion(currentVersion, version)) {
  11117. var _packageData$change;
  11118. scripts_echoLog({
  11119. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  11120. });
  11121. scripts_echoLog({
  11122. 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>`
  11123. });
  11124. }
  11125. } catch (error) {
  11126. throwError(error, 'updateChecker');
  11127. }
  11128. };
  11129. const scripts_updateChecker = updateChecker;
  11130. var _globalOptions$other, _globalOptions$other2;
  11131. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  11132. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  11133. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  11134. const loadScript = async () => {
  11135. var _website, _website2, _website3, _website4, _website5, _website6;
  11136. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  11137. const authToken = external_Cookies_namespaceObject.get('auth-token');
  11138. const isLogin = !!external_Cookies_namespaceObject.get('login');
  11139. if (isLogin) {
  11140. var _commonOptions, _commonOptions$header;
  11141. GM_setValue('twitchAuth', {
  11142. authToken: authToken,
  11143. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  11144. });
  11145. window.close();
  11146. external_Swal_default().fire('', i18n('closePageNotice'));
  11147. } else {
  11148. external_Swal_default().fire('', i18n('needLogin'));
  11149. }
  11150. return;
  11151. }
  11152. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  11153. const ct0 = external_Cookies_namespaceObject.get('ct0');
  11154. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  11155. if (isLogin && ct0) {
  11156. GM_setValue('twitterAuth', {
  11157. ct0: ct0
  11158. });
  11159. window.close();
  11160. external_Swal_default().fire('', i18n('closePageNotice'));
  11161. } else {
  11162. external_Swal_default().fire('', i18n('needLogin'));
  11163. }
  11164. return;
  11165. }
  11166. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  11167. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  11168. if (PAPISID) {
  11169. GM_setValue('youtubeAuth', {
  11170. PAPISID: PAPISID
  11171. });
  11172. window.close();
  11173. external_Swal_default().fire('', i18n('closePageNotice'));
  11174. } else {
  11175. external_Swal_default().fire('', i18n('needLogin'));
  11176. }
  11177. return;
  11178. }
  11179. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11180. const betaButton = $('#redesign-beta-optin-btn');
  11181. if (betaButton.length > 0) {
  11182. GM_setValue('redditAuth', '#auth');
  11183. return betaButton[0].click();
  11184. }
  11185. GM_setValue('redditAuth', null);
  11186. window.close();
  11187. external_Swal_default().fire('', i18n('closePageNotice'));
  11188. return;
  11189. }
  11190. let website;
  11191. for (const Website of Websites) {
  11192. if (Website.test()) {
  11193. website = new Website();
  11194. break;
  11195. }
  11196. }
  11197. if (!website) {
  11198. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11199. return;
  11200. }
  11201. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11202. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11203. }
  11204. $('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>`);
  11205. $('div.show-button-div').on('click', () => {
  11206. $('#auto-task-buttons').show();
  11207. $('div.show-button-div').hide();
  11208. });
  11209. const toggleLog = () => {
  11210. const $this = $('#toggle-log');
  11211. const status = $this.attr('data-status');
  11212. if (status === 'show') {
  11213. $('#auto-task-info').hide();
  11214. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11215. } else {
  11216. $('#auto-task-info').show();
  11217. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11218. }
  11219. };
  11220. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11221. if (website.doTask) {
  11222. website.doTask();
  11223. }
  11224. });
  11225. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11226. if (website.undoTask) {
  11227. website.doTask();
  11228. }
  11229. });
  11230. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11231. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11232. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11233. }
  11234. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11235. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11236. for (const button of website.buttons) {
  11237. if (website[button]) {
  11238. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11239. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11240. website[button]();
  11241. });
  11242. $('#auto-task-buttons').append(btnElement);
  11243. }
  11244. }
  11245. }
  11246. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11247. ${i18n('hideButton')}</a></p>`);
  11248. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11249. $('#auto-task-buttons').hide();
  11250. $('div.show-button-div').show();
  11251. });
  11252. 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'}">
  11253. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11254. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11255. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11256. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11257. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11258. options(website.name, website.options);
  11259. });
  11260. }
  11261. if (website.name !== 'Setting') {
  11262. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11263. changeGlobalOptions('swal');
  11264. });
  11265. GM_registerMenuCommand(i18n('settingPage'), () => {
  11266. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11267. });
  11268. }
  11269. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11270. if (!GM_getValue('notice')) {
  11271. var _echoLog$font;
  11272. external_Swal_default().fire({
  11273. title: i18n('swalNotice'),
  11274. icon: 'warning'
  11275. }).then(() => {
  11276. window.open(i18n('noticeLink'), '_blank');
  11277. GM_setValue('notice', new Date().getTime());
  11278. });
  11279. (_echoLog$font = scripts_echoLog({
  11280. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11281. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11282. GM_setValue('notice', new Date().getTime());
  11283. });
  11284. }
  11285. scripts_updateChecker();
  11286. };
  11287. if (window.location.hostname === 'discord.com') {
  11288. const LocalStorage = window.localStorage;
  11289. if (window.location.hash === '#auth') {
  11290. var _LocalStorage$getItem;
  11291. window.localStorage.removeItem = () => true;
  11292. 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, '');
  11293. if (discordAuth && discordAuth.length > 0) {
  11294. GM_setValue('discordAuth', {
  11295. auth: discordAuth
  11296. });
  11297. window.close();
  11298. external_Swal_default().fire('', i18n('closePageNotice'));
  11299. } else {
  11300. external_Swal_default().fire({
  11301. text: i18n('getDiscordAuthFailed'),
  11302. icon: 'error'
  11303. });
  11304. }
  11305. } else {
  11306. var _LocalStorage$getItem2;
  11307. 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, '');
  11308. if (discordAuth && discordAuth.length > 0) {
  11309. GM_setValue('discordAuth', {
  11310. auth: discordAuth
  11311. });
  11312. }
  11313. }
  11314. } else if (window.location.hostname === 'opquests.com') {
  11315. loadScript();
  11316. } else {
  11317. $(loadScript);
  11318. }
  11319. }();
  11320. })();