Greasy Fork 还支持 简体中文。

auto-task-v4

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

目前為 2022-09-28 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.21
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12. // @icon https://auto-task-v4.hclonely.com/favicon.ico
  13.  
  14. // @include *://freeanywhere.net/*
  15. // @include *://giveaway.su/giveaway/view/*
  16. // @include *://givee.club/*/event/*
  17. // @include *://givekey.ru/giveaway/*
  18. // @include *://www.indiedb.com/giveaways*
  19. // @include *://key-hub.eu/giveaway/*
  20. // @include *://keylol.com/*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://prys.revadike.com/giveaway/?id=*
  23. // @include *://opquests.com/quests/*
  24. // @include *://gleam.io/*
  25. // @include *://sweepwidget.com/view/*
  26. // @include *://discord.com/*
  27. // @include *://www.twitch.tv/*
  28. // @include *://www.youtube.com/*
  29. // @include *://*.reddit.com/*
  30. // @include *://twitter.com/settings/account?k*
  31. // @include https://auto-task-v4.hclonely.com/setting.html
  32. // @include https://auto-task-v4.hclonely.com/history.html
  33.  
  34. // @grant GM_setValue
  35. // @grant GM_getValue
  36. // @grant GM_listValues
  37. // @grant GM_deleteValue
  38. // @grant GM_addStyle
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_info
  42. // @grant GM_openInTab
  43. // @grant GM_setClipboard
  44. // @grant GM_getResourceText
  45. // @grant unsafeWindow
  46. // @grant window.close
  47. // @grant window.localStorage
  48.  
  49. // @connect cdn.jsdelivr.net
  50. // @connect store.steampowered.com
  51. // @connect steamcommunity.com
  52. // @connect login.steampowered.com
  53. // @connect twitter.com
  54. // @connect api.twitter.com
  55. // @connect youtube.com
  56. // @connect www.youtube.com
  57. // @connect facebook.com
  58. // @connect instagram.com
  59. // @connect vk.com
  60. // @connect twitch.tv
  61. // @connect www.twitch.tv
  62. // @connect gql.twitch.tv
  63. // @connect github.com
  64. // @connect discordapp.com
  65. // @connect discord.gg
  66. // @connect discord.com
  67. // @connect www.reddit.com
  68. // @connect oauth.reddit.com
  69. // @connect raw.githubusercontent.com
  70. // @connect t.me
  71. // @connect bit.ly
  72. // @connect giveaway.su
  73. // @connect google.com
  74. // @connect www.vloot.io
  75. // @connect givee.club
  76. // @connect gleam.io
  77. // @connect www.indiedb.com
  78. // @connect key-hub.eu
  79. // @connect opquests.com
  80. // @connect itch.io
  81. // @connect auto-task-v4.hclonely.com
  82. // @connect *
  83. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  84. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  85. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  86. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  87. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  88. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  89. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  90. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  91.  
  92. // @noframes
  93. // ==/UserScript==
  94.  
  95. console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
  96.  
  97. (function() {
  98. var __webpack_modules__ = {
  99. 588: function(__unused_webpack_module, exports) {
  100. !function(e, n) {
  101. true ? n(exports) : 0;
  102. }(this, function(e) {
  103. 'use strict';
  104. var t = function() {
  105. return (t = Object.assign || function(e) {
  106. for (var n, o = 1, t = arguments.length; o < t; o++) {
  107. for (var r in n = arguments[o]) {
  108. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  109. }
  110. }
  111. return e;
  112. }).apply(this, arguments);
  113. };
  114. function r(e, n, o) {
  115. if (o || 2 === arguments.length) {
  116. for (var t, r = 0, i = n.length; r < i; r++) {
  117. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  118. }
  119. }
  120. return e.concat(t || Array.prototype.slice.call(n));
  121. }
  122. function d(e) {
  123. return '[object Object]' === n(e);
  124. }
  125. function l(e, n) {
  126. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  127. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  128. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  129. });
  130. }
  131. var n = function(e) {
  132. return Object.prototype.toString.call(e);
  133. };
  134. var o = (i.prototype.init = function() {
  135. try {
  136. this.getSystemName(), this.getBrowserName();
  137. } catch (e) {
  138. console.warn('[UA formatter error] '.concat(e));
  139. }
  140. }, i.prototype.getEngine = function() {
  141. var e = this.agent;
  142. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  143. }, i.prototype.getSystemName = function() {
  144. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  145. try {
  146. var o = '';
  147. if (/Windows/i.test(n)) {
  148. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  149. switch (this.info.os = 'Windows', t) {
  150. case '6.3':
  151. o = '8.1';
  152. break;
  153.  
  154. case '6.2':
  155. o = '8';
  156. break;
  157.  
  158. case '6.1':
  159. o = '7';
  160. break;
  161.  
  162. case '5.2':
  163. case '5.1':
  164. o = 'XP';
  165. break;
  166.  
  167. default:
  168. o = t;
  169. }
  170. return this.info.device = 'PC', void (this.info.osVersion = o);
  171. }
  172. if (/^Macintosh/i.test(n)) {
  173. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  174. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  175. }
  176. if (/^iPad/i.test(n)) {
  177. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  178. void (this.info.osVersion = o.replace(/_/g, '.'));
  179. }
  180. if (/^iPhone/i.test(n)) {
  181. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  182. void (this.info.osVersion = o.replace(/_/g, '.'));
  183. }
  184. if (-1 !== n.indexOf('Android')) {
  185. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  186. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  187. }
  188. if (/Linux\s[a-z\d_]+/.test(n)) {
  189. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  190. }
  191. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  192. } catch (e) {
  193. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  194. }
  195. }, i.prototype.getBrowserName = function() {
  196. var e = Object.keys(this.browserNameMap).map(function(e) {
  197. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  198. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  199. return -1 !== e.findIndex(function(e) {
  200. return e.test(n);
  201. });
  202. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  203. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  204. }, i.prototype._formatBrowserVersion = function(e) {
  205. var n, o, t, r;
  206. try {
  207. for (var i = null !== (o = null === (n = e.match(/(?<name>[a-z\d]+)(\/|\s)(?<version>(\d+\.)+\d+)/i)) || void 0 === n ? void 0 : n.groups) && void 0 !== o ? o : {}, s = i.name, a = i.version, c = {}, f = 0, u = Object.entries(this.browserNameMap); f < u.length; f++) {
  208. var d = u[f], l = d[0], h = d[1];
  209. if (new RegExp(l).test(s)) {
  210. c = h;
  211. break;
  212. }
  213. }
  214. var p = {
  215. browserVersion: null != a ? a : 'Unknown',
  216. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  217. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  218. };
  219. return 'Trident' === s && (p.browserVersion = {
  220. '4.0': 8,
  221. '5.0': 9,
  222. '6.0': 10,
  223. '7.0': 11
  224. }[a]), p;
  225. } catch (e) {
  226. return console.warn('[UA formatter error] '.concat(e)), {
  227. browser: 'Unknown',
  228. browserVersion: 'Unknown'
  229. };
  230. }
  231. }, i);
  232. function i(e) {
  233. this.agent = '', this.info = {
  234. browser: '',
  235. browserZH: '',
  236. browserVersion: '',
  237. os: '',
  238. osVersion: '',
  239. device: 'Unknown',
  240. engine: 'WebKit'
  241. }, this.browserNameMap = {
  242. MicroMessenger: {
  243. en: 'MicroMessenger',
  244. zh: '微信'
  245. },
  246. MetaSr: {
  247. en: 'MetaSr',
  248. zh: '搜狗浏览器'
  249. },
  250. 'QQ(Browser)?': {
  251. en: 'QQBrowser',
  252. zh: 'QQ浏览器'
  253. },
  254. UCBrowser: {
  255. en: 'UCBrowser',
  256. zh: 'UC浏览器'
  257. },
  258. '2345Explorer': {
  259. en: '2345Explorer',
  260. zh: '2345极速浏览器'
  261. },
  262. Mb2345Browser: {
  263. en: 'Mb2345Browser',
  264. zh: '2345手机浏览器'
  265. },
  266. Trident: {
  267. en: 'Internet Explorer'
  268. },
  269. 'Edge?': {
  270. en: 'Edge'
  271. },
  272. OPR: {
  273. en: 'Opera'
  274. },
  275. Vivaldi: {
  276. en: 'Vivaldi'
  277. },
  278. Firefox: {
  279. en: 'Firefox'
  280. },
  281. Chrome: {
  282. en: 'Chrome'
  283. },
  284. Safari: {
  285. en: 'Safari'
  286. }
  287. }, this.agent = e, this.init();
  288. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  289. this.info = t(t({}, this.info), {
  290. engine: this.getEngine(),
  291. browserVersion: 'Safari' === o ? n : e
  292. });
  293. }
  294. function s() {
  295. this.cookies = {}, this.init();
  296. }
  297. var a = new (s.prototype.init = function() {
  298. var o = {};
  299. document.cookie.split(/;\s/).forEach(function(e) {
  300. var n = e.split(/=/), e = n[0], n = n[1];
  301. o[e] = n;
  302. }), this.cookies = o;
  303. }, s.prototype.getItem = function(e) {
  304. return this.cookies[e];
  305. }, s.prototype.getAllItems = function() {
  306. return this.cookies;
  307. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  308. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  309. }, s)();
  310. e.countDown = function e(n, o, t, r) {
  311. if (!window) {
  312. throw new Error('window is not defind.');
  313. }
  314. if (0 < n) {
  315. return r && r(), n--, window[o] = window.setTimeout(function() {
  316. e(n, o, t, r);
  317. }, 1e3), function() {
  318. return clearTimeout(window[o]);
  319. };
  320. }
  321. clearTimeout(window[o]), t && t();
  322. }, e.createRandomID = function(e) {
  323. void 0 === e && (e = 12);
  324. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  325. n.push(o[Math.round(Math.random() * t)]);
  326. }
  327. return n.join('');
  328. }, e.dCookie = a, e.debounce = function(o, t, r) {
  329. var i;
  330. void 0 === t && (t = 0);
  331. var s = r = void 0 === r ? !1 : r;
  332. return function() {
  333. var e = this, n = arguments;
  334. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  335. r ? s = !0 : o.apply(e, n);
  336. }, t);
  337. };
  338. }, e.deepCopy = function e(n) {
  339. if (d(n) || Array.isArray(n)) {
  340. var o, t = Array.isArray(n) ? [] : {};
  341. for (o in n) {
  342. t[o] = e(n[o]);
  343. }
  344. return t;
  345. }
  346. return n;
  347. }, e.formatQueryParams = function(e) {
  348. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  349. if (!e) {
  350. return {};
  351. }
  352. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  353. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  354. return t[n] = o, e;
  355. });
  356. }
  357. return t;
  358. }, e.formatThousandth = function(e) {
  359. var n = ''.concat(e).split('.'), e = n[0], n = n[1], n = void 0 === n ? '' : n, e = e.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
  360. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  361. }, e.generateTree = function e(n, o, t, r) {
  362. for (var i = [], s = 0; s < n.length; s++) {
  363. var a = n[s];
  364. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  365. }
  366. return i;
  367. }, e.isEmpty = function(e) {
  368. return Array.isArray(e) ? 0 === e.length : d(e) ? 0 === Object.keys(e).length : [ '[object Set]', '[object Map]' ].includes(n(e)) ? 0 === e.size : [ null, void 0, '' ].includes(e);
  369. }, e.isFunction = function(e) {
  370. return '[object Function]' === n(e);
  371. }, e.isImageUrl = function(e) {
  372. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  373. }, e.isObject = d, e.isRegexp = function(e) {
  374. return '[object RegExp]' === n(e);
  375. }, e.objectKeyToCamelCase = function e(n, o, t) {
  376. if (Array.isArray(n)) {
  377. for (var r = [], i = 0; i < n.length; i++) {
  378. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  379. }
  380. } else if (d(n)) {
  381. r = {};
  382. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  383. var f = (u = c[a])[0], u = u[1];
  384. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  385. }
  386. } else {
  387. r = n;
  388. }
  389. return r;
  390. }, e.realType = n, e.searchParams = function(e, n) {
  391. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  392. new URLSearchParams(e).get(n);
  393. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  394. return e.replace(/([A-Z])/g, function(e) {
  395. return '_'.concat(e.toLocaleLowerCase());
  396. });
  397. }, e.ua = function(e) {
  398. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  399. }, Object.defineProperty(e, '__esModule', {
  400. value: !0
  401. });
  402. });
  403. },
  404. 301: function(module, __webpack_exports__, __webpack_require__) {
  405. 'use strict';
  406. __webpack_require__.d(__webpack_exports__, {
  407. Z: function() {
  408. return __WEBPACK_DEFAULT_EXPORT__;
  409. }
  410. });
  411. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  412. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  413. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  414. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  415. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default());
  416. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(10px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px #05be0566}body.auto-task-options .auto-task-form table label input:checked~span i{left:84px}body.auto-task-options .auto-task-form table label input:checked~span i::before{background:#05be05;box-shadow:35px 0 0 #05be05}body.auto-task-options .auto-task-form table label input:checked~span i::after{bottom:12px;height:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;background:#05be05}body.auto-task-options .auto-task-form table label span{position:absolute;top:0;left:0;width:100%;height:100%;background:#fe0000;border-radius:80px;transition:.5s;box-shadow:0 15px 25px #fe000066}body.auto-task-options .auto-task-form table label span i{position:absolute;top:4px;left:4px;width:72px;height:72px;background:#fff;border-radius:50%}body.auto-task-options .auto-task-form table label span i::before{content:"";position:absolute;top:22px;left:12px;width:12px;height:12px;border-radius:50%;background:#fe0000;box-shadow:35px 0 0 #fe0000;transition:.5s}body.auto-task-options .auto-task-form table label span i::after{content:"";position:absolute;bottom:15px;left:calc(50% - 15px);width:30px;height:6px;border-radius:6px;background:#fe0000;transition:.5s}body.auto-task-history{font-size:15px;font-weight:400;line-height:1.5}body.auto-task-history .container a{color:#007bff;text-decoration:none;background-color:transparent}body.auto-task-history .container .card{width:80%;max-width:800px;border-radius:10px;background:#7676761a;border-top:1px solid #ffffff80;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px #0000001a;margin:20px auto;position:relative;display:flex;flex-direction:column;word-wrap:break-word;-webkit-background-clip:border-box;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}body.auto-task-history .container .card .title{text-align:center;font-size:30px;font-weight:bold;margin:5px 0}body.auto-task-history .container .card .title a:hover{text-decoration:none;background:#93e1ff;border-radius:10px;padding:3px}body.auto-task-history .container .card ul{margin-bottom:25px}body.auto-task-history .container .card ul li{margin-bottom:5px;line-height:20px}body.auto-task-history .container .card ul a:hover{text-decoration:underline}body.auto-task-history .container .card .delete-task{right:10px;width:38px;height:35px;position:absolute;font-size:24px;cursor:pointer;border-radius:10px}body.auto-task-history .container .card .delete-task:hover{background:#fff}body.auto-task-history .container .card .time{right:5px;position:absolute;bottom:0;color:#e83e8c;font-family:\'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace\';font-size:15px}#auto-task-buttons,.show-button-div{position:fixed;top:30px;right:15px;width:170px;z-index:999999999 !important;transform:scale(0.9)}#auto-task-buttons p,.show-button-div p{line-height:30px;height:40px;text-align:center;margin:5px !important}#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn{width:150px;height:40px;line-height:30px;font-size:20px}.show-button-div{width:20px}.auto-task-capitalize{text-transform:capitalize !important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{box-shadow:inset 0px 0px 4px 1px rgba(100,150,200,.5) !important}.swal2-checkbox-custom{align-items:center;justify-content:center;background:#fff;color:inherit;margin:1em auto}.swal2-checkbox-custom input{flex-shrink:0;margin:0 .4em}.giveaway-actions #getKey{display:none !important}.auto-task-giveaway-status{color:#fff;border-radius:10px;padding:0 5px;margin-left:5px}.auto-task-giveaway-status.active{background-color:#5cb85c}.auto-task-giveaway-status.not-active{background-color:#d9534f}', '' ]);
  417. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  418. },
  419. 400: function(module) {
  420. 'use strict';
  421. module.exports = function(cssWithMappingToString) {
  422. var list = [];
  423. list.toString = function toString() {
  424. return this.map(function(item) {
  425. var content = '';
  426. var needLayer = typeof item[5] !== 'undefined';
  427. if (item[4]) {
  428. content += '@supports ('.concat(item[4], ') {');
  429. }
  430. if (item[2]) {
  431. content += '@media '.concat(item[2], ' {');
  432. }
  433. if (needLayer) {
  434. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  435. }
  436. content += cssWithMappingToString(item);
  437. if (needLayer) {
  438. content += '}';
  439. }
  440. if (item[2]) {
  441. content += '}';
  442. }
  443. if (item[4]) {
  444. content += '}';
  445. }
  446. return content;
  447. }).join('');
  448. };
  449. list.i = function i(modules, media, dedupe, supports, layer) {
  450. if (typeof modules === 'string') {
  451. modules = [ [ null, modules, undefined ] ];
  452. }
  453. var alreadyImportedModules = {};
  454. if (dedupe) {
  455. for (var k = 0; k < this.length; k++) {
  456. var id = this[k][0];
  457. if (id != null) {
  458. alreadyImportedModules[id] = true;
  459. }
  460. }
  461. }
  462. for (var _k = 0; _k < modules.length; _k++) {
  463. var item = [].concat(modules[_k]);
  464. if (dedupe && alreadyImportedModules[item[0]]) {
  465. continue;
  466. }
  467. if (typeof layer !== 'undefined') {
  468. if (typeof item[5] === 'undefined') {
  469. item[5] = layer;
  470. } else {
  471. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  472. item[5] = layer;
  473. }
  474. }
  475. if (media) {
  476. if (!item[2]) {
  477. item[2] = media;
  478. } else {
  479. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  480. item[2] = media;
  481. }
  482. }
  483. if (supports) {
  484. if (!item[4]) {
  485. item[4] = ''.concat(supports);
  486. } else {
  487. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  488. item[4] = supports;
  489. }
  490. }
  491. list.push(item);
  492. }
  493. };
  494. return list;
  495. };
  496. },
  497. 220: function(module) {
  498. 'use strict';
  499. module.exports = function(i) {
  500. return i[1];
  501. };
  502. }
  503. };
  504. var __webpack_module_cache__ = {};
  505. function __webpack_require__(moduleId) {
  506. var cachedModule = __webpack_module_cache__[moduleId];
  507. if (cachedModule !== undefined) {
  508. return cachedModule.exports;
  509. }
  510. var module = __webpack_module_cache__[moduleId] = {
  511. id: moduleId,
  512. exports: {}
  513. };
  514. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  515. return module.exports;
  516. }
  517. !function() {
  518. __webpack_require__.n = function(module) {
  519. var getter = module && module.__esModule ? function() {
  520. return module['default'];
  521. } : function() {
  522. return module;
  523. };
  524. __webpack_require__.d(getter, {
  525. a: getter
  526. });
  527. return getter;
  528. };
  529. }();
  530. !function() {
  531. __webpack_require__.d = function(exports, definition) {
  532. for (var key in definition) {
  533. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  534. Object.defineProperty(exports, key, {
  535. enumerable: true,
  536. get: definition[key]
  537. });
  538. }
  539. }
  540. };
  541. }();
  542. !function() {
  543. __webpack_require__.o = function(obj, prop) {
  544. return Object.prototype.hasOwnProperty.call(obj, prop);
  545. };
  546. }();
  547. var __webpack_exports__ = {};
  548. !function() {
  549. 'use strict';
  550. const external_Swal_namespaceObject = Swal;
  551. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  552. const external_Cookies_namespaceObject = Cookies;
  553. var auto_task = __webpack_require__(301);
  554. var javascript_utils_umd_min = __webpack_require__(588);
  555. const httpRequest = async function(options) {
  556. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  557. if (window.TRACE) {
  558. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  559. }
  560. try {
  561. const result = await new Promise(resolve => {
  562. if (options.dataType) {
  563. options.responseType = options.dataType;
  564. }
  565. const requestObj = {
  566. ...{
  567. timeout: 3e4,
  568. ontimeout(data) {
  569. resolve({
  570. result: 'Error',
  571. statusText: 'Timeout',
  572. status: 601,
  573. data: data,
  574. options: options
  575. });
  576. },
  577. onabort(data) {
  578. resolve({
  579. result: 'Error',
  580. statusText: 'Aborted',
  581. status: 602,
  582. data: data,
  583. options: options
  584. });
  585. },
  586. onerror(data) {
  587. resolve({
  588. result: 'Error',
  589. statusText: 'Error',
  590. status: 603,
  591. data: data,
  592. options: options
  593. });
  594. },
  595. onload(data) {
  596. resolve({
  597. result: 'Success',
  598. statusText: 'Load',
  599. status: 600,
  600. data: data,
  601. options: options
  602. });
  603. }
  604. },
  605. ...options
  606. };
  607. GM_xmlhttpRequest(requestObj);
  608. });
  609. if (window.DEBUG) {
  610. console.log('%cAuto-Task[httpRequest]:', 'color:blue', JSON.stringify(result));
  611. }
  612. if (result.status !== 600 && times < 2) {
  613. return await httpRequest(options, times + 1);
  614. }
  615. return result;
  616. } catch (error) {
  617. console.log('%cAuto-Task[httpRequest]:', 'color:red', JSON.stringify({
  618. errorMsg: error,
  619. options: options
  620. }));
  621. throwError(error, 'httpRequest');
  622. return {
  623. result: 'JsError',
  624. statusText: 'Error',
  625. status: 604,
  626. error: error,
  627. options: options
  628. };
  629. }
  630. };
  631. const tools_httpRequest = httpRequest;
  632. const echoLog = _ref => {
  633. let {
  634. type,
  635. text,
  636. html,
  637. id
  638. } = _ref;
  639. const emptyStatus = {
  640. success: () => emptyStatus,
  641. error: () => emptyStatus,
  642. warning: () => emptyStatus,
  643. info: () => emptyStatus,
  644. view: () => emptyStatus
  645. };
  646. try {
  647. var _ele$;
  648. let ele;
  649. if (type) {
  650. switch (type) {
  651. case 'joiningSteamGroup':
  652. case 'leavingSteamGroup':
  653. case 'gettingSteamGroupId':
  654. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  655. break;
  656.  
  657. case 'joiningSteamOfficialGroup':
  658. case 'leavingSteamOfficialGroup':
  659. case 'gettingSteamOfficialGroupId':
  660. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/games/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  661. break;
  662.  
  663. case 'subscribingForum':
  664. case 'unsubscribingForum':
  665. case 'gettingForumId':
  666. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>]...<font></font></li>`);
  667. break;
  668.  
  669. case 'followingCurator':
  670. case 'unfollowingCurator':
  671. case 'getCuratorId':
  672. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/${text !== null && text !== void 0 && text.includes('/') ? text : `curator/${text}`}" target="_blank">${text}</a>]...<font></font></li>`);
  673. break;
  674.  
  675. case 'addingToWishlist':
  676. case 'removingFromWishlist':
  677. case 'followingGame':
  678. case 'unfollowingGame':
  679. case 'gettingSubid':
  680. case 'addingFreeLicense':
  681. case 'requestingPlayTestAccess':
  682. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  683. break;
  684.  
  685. case 'addingFreeLicenseSubid':
  686. ele = $(`<li>${i18n('addingFreeLicense')}[<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  687. break;
  688.  
  689. case 'favoritingWorkshop':
  690. case 'unfavoritingWorkshop':
  691. case 'gettingWorkshopAppId':
  692. case 'votingUpWorkshop':
  693. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  694. ${text}</a>]...<font></font></li>`);
  695. break;
  696.  
  697. case 'gettingAnnouncementParams':
  698. case 'likingAnnouncement':
  699. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  700. ${id}</a>]...<font></font></li>`);
  701. break;
  702.  
  703. case 'joiningDiscordServer':
  704. case 'gettingDiscordGuild':
  705. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  706. break;
  707.  
  708. case 'leavingDiscordServer':
  709. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  710. break;
  711.  
  712. case 'updateDiscordAuth':
  713. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  714. break;
  715.  
  716. case 'followingTwitchChannel':
  717. case 'unfollowingTwitchChannel':
  718. case 'gettingTwitchChannelId':
  719. ele = $(`<li>${i18n(type)}[<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  720. break;
  721.  
  722. case 'gettingInsUserId':
  723. case 'followingIns':
  724. case 'unfollowingIns':
  725. ele = $(`<li>${i18n(type)}[<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  726. break;
  727.  
  728. case 'gettingTwitterUserId':
  729. case 'followingTwitterUser':
  730. case 'unfollowingTwitterUser':
  731. ele = $(`<li>${i18n(type)}[<a href="https://twitter.com/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  732. break;
  733.  
  734. case 'retweetting':
  735. case 'unretweetting':
  736. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  737. break;
  738.  
  739. case 'joiningReddit':
  740. case 'leavingReddit':
  741. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  742. break;
  743.  
  744. case 'followingRedditUser':
  745. case 'unfollowingRedditUser':
  746. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  747. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>]...<font></font></li>`);
  748. break;
  749.  
  750. case 'followingYtbChannel':
  751. case 'unfollowingYtbChannel':
  752. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  753. break;
  754.  
  755. case 'likingYtbVideo':
  756. case 'unlikingYtbVideo':
  757. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>]...<font></font></li>`);
  758. break;
  759.  
  760. case 'gettingVkId':
  761. case 'joiningVkGroup':
  762. case 'leavingVkGroup':
  763. case 'joiningVkPublic':
  764. case 'leavingVkPublic':
  765. case 'sendingVkWall':
  766. case 'deletingVkWall':
  767. ele = $(`<li>${i18n(type)}[<a href="https://vk.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  768. break;
  769.  
  770. case 'visitingLink':
  771. ele = $(`<li>${i18n('visitingLink')}[<a href="${text}" target="_blank">${text}</a>]...<font></font></li>`);
  772. break;
  773.  
  774. case 'verifyingInsAuth':
  775. case 'text':
  776. ele = $(`<li>${i18n(text)}<font></font></li>`);
  777. break;
  778.  
  779. case 'html':
  780. ele = $(text || html);
  781. break;
  782.  
  783. case 'whiteList':
  784. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  785. break;
  786.  
  787. case 'globalOptionsSkip':
  788. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  789. break;
  790.  
  791. default:
  792. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  793. break;
  794. }
  795. } else if (text) {
  796. ele = $(`<li>${i18n(text)}<font></font></li>`);
  797. } else if (html) {
  798. ele = $(html);
  799. } else {
  800. ele = $('<li><font></font></li>');
  801. }
  802. ele.addClass('card-text');
  803. $('#auto-task-info').append(ele);
  804. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  805. const font = ele.find('font');
  806. const status = {
  807. font: font,
  808. success() {
  809. var _this$font, _this$font2, _this$font3;
  810. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  811. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  812. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  813. html ? (_this$font2 = this.font) === null || _this$font2 === void 0 ? void 0 : _this$font2.html(text) : (_this$font3 = this.font) === null || _this$font3 === void 0 ? void 0 : _this$font3.text(text);
  814. return this;
  815. },
  816. error() {
  817. var _this$font4, _this$font5, _this$font6;
  818. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  819. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  820. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  821. html ? (_this$font5 = this.font) === null || _this$font5 === void 0 ? void 0 : _this$font5.html(text) : (_this$font6 = this.font) === null || _this$font6 === void 0 ? void 0 : _this$font6.text(text);
  822. return this;
  823. },
  824. warning() {
  825. var _this$font7, _this$font8, _this$font9;
  826. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  827. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  828. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  829. html ? (_this$font8 = this.font) === null || _this$font8 === void 0 ? void 0 : _this$font8.html(text) : (_this$font9 = this.font) === null || _this$font9 === void 0 ? void 0 : _this$font9.text(text);
  830. return this;
  831. },
  832. info() {
  833. var _this$font10, _this$font11, _this$font12;
  834. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  835. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  836. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  837. html ? (_this$font11 = this.font) === null || _this$font11 === void 0 ? void 0 : _this$font11.html(text) : (_this$font12 = this.font) === null || _this$font12 === void 0 ? void 0 : _this$font12.text(text);
  838. return this;
  839. },
  840. view() {
  841. var _this$font13;
  842. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  843. return this;
  844. }
  845. };
  846. return status;
  847. } catch (error) {
  848. throwError(error, 'echoLog');
  849. return emptyStatus;
  850. }
  851. };
  852. const scripts_echoLog = echoLog;
  853. const unique = array => {
  854. try {
  855. return [ ...new Set(array) ];
  856. } catch (error) {
  857. throwError(error, 'unique');
  858. return [];
  859. }
  860. };
  861. const delay = function() {
  862. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  863. return new Promise(resolve => {
  864. setTimeout(() => {
  865. resolve(true);
  866. }, time);
  867. });
  868. };
  869. const getRedirectLink = async link => {
  870. try {
  871. if (!link) {
  872. return null;
  873. }
  874. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  875. if (redirectLinksCache[link]) {
  876. redirectLinksCache[link];
  877. }
  878. return await tools_httpRequest({
  879. url: link,
  880. method: 'GET'
  881. }).then(_ref => {
  882. let {
  883. data
  884. } = _ref;
  885. if (data !== null && data !== void 0 && data.finalUrl) {
  886. redirectLinksCache[link] = data.finalUrl;
  887. GM_setValue('redirectLinks', redirectLinksCache);
  888. return data.finalUrl;
  889. }
  890. return null;
  891. });
  892. } catch (error) {
  893. throwError(error, 'getRedirectLink');
  894. return null;
  895. }
  896. };
  897. const visitLink = async (link, options) => {
  898. try {
  899. const logStatus = scripts_echoLog({
  900. type: 'visitLink',
  901. text: link
  902. });
  903. return await tools_httpRequest({
  904. url: link,
  905. method: 'GET',
  906. ...options
  907. }).then(_ref2 => {
  908. let {
  909. result,
  910. statusText,
  911. status
  912. } = _ref2;
  913. if (result === 'Success') {
  914. logStatus.success();
  915. return true;
  916. }
  917. logStatus.error(`${result}:${statusText}(${status})`);
  918. return false;
  919. });
  920. } catch (error) {
  921. throwError(error, 'visitLink');
  922. return false;
  923. }
  924. };
  925. const getUrlQuery = url => {
  926. try {
  927. const query = {};
  928. if (url) {
  929. if (url.includes('?')) {
  930. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  931. query[key] = value;
  932. return str;
  933. });
  934. }
  935. } else {
  936. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  937. query[key] = value;
  938. return str;
  939. });
  940. }
  941. return query;
  942. } catch (error) {
  943. throwError(error, 'getUrlQuery');
  944. return {};
  945. }
  946. };
  947. const getUuid = () => {
  948. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  949. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  950. };
  951. const stringToColour = str => {
  952. try {
  953. let hash = 0;
  954. for (let i = 0; i < str.length; i++) {
  955. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  956. }
  957. let colour = '#';
  958. for (let i = 0; i < 3; i++) {
  959. const value = hash >> i * 8 & 255;
  960. colour += `00${value.toString(16)}`.slice(-2);
  961. }
  962. return colour;
  963. } catch (error) {
  964. throwError(error, 'stringToColour');
  965. return '#fff';
  966. }
  967. };
  968. const defaultGlobalOptions = {
  969. doTask: {
  970. discord: {
  971. servers: true
  972. },
  973. instagram: {
  974. users: true
  975. },
  976. twitch: {
  977. channels: true
  978. },
  979. twitter: {
  980. users: true,
  981. retweets: true
  982. },
  983. vk: {
  984. names: true
  985. },
  986. youtube: {
  987. channels: true,
  988. likes: true
  989. },
  990. reddit: {
  991. reddits: true
  992. },
  993. steam: {
  994. groups: true,
  995. officialGroups: true,
  996. wishlists: true,
  997. follows: true,
  998. forums: true,
  999. workshops: true,
  1000. curators: true,
  1001. workshopVotes: true,
  1002. announcements: true,
  1003. licenses: true,
  1004. playtests: true
  1005. }
  1006. },
  1007. undoTask: {
  1008. discord: {
  1009. servers: true
  1010. },
  1011. instagram: {
  1012. users: true
  1013. },
  1014. twitch: {
  1015. channels: true
  1016. },
  1017. twitter: {
  1018. users: true,
  1019. retweets: true
  1020. },
  1021. vk: {
  1022. names: true
  1023. },
  1024. youtube: {
  1025. channels: true,
  1026. likes: true
  1027. },
  1028. reddit: {
  1029. reddits: true
  1030. },
  1031. steam: {
  1032. groups: true,
  1033. officialGroups: true,
  1034. wishlists: true,
  1035. follows: true,
  1036. forums: true,
  1037. workshops: true,
  1038. curators: true
  1039. }
  1040. },
  1041. position: {
  1042. buttonSideX: 'right',
  1043. buttonSideY: 'top',
  1044. buttonDistance: '15,30',
  1045. showButtonSideX: 'right',
  1046. showButtonSideY: 'top',
  1047. showButtonDistance: '15,30',
  1048. logSideX: 'right',
  1049. logSideY: 'bottom',
  1050. logDistance: '10,10'
  1051. },
  1052. hotKey: {
  1053. doTaskKey: 'alt + d',
  1054. undoTaskKey: 'alt + u',
  1055. toggleLogKey: 'alt + l'
  1056. },
  1057. other: {
  1058. twitterVerifyId: '783214',
  1059. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1060. autoUpdateSource: 'jsdelivr',
  1061. language: 'zh',
  1062. checkLogin: true,
  1063. checkLeftKey: true,
  1064. defaultShowButton: true,
  1065. defaultShowLog: true,
  1066. debug: false,
  1067. receivePreview: true
  1068. }
  1069. };
  1070. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1071. const assignObject = (obj1, obj2) => {
  1072. try {
  1073. const newObj = {};
  1074. for (const [ key, value ] of Object.entries(obj1)) {
  1075. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1076. newObj[key] = assignObject(value, obj2[key]);
  1077. } else {
  1078. newObj[key] = obj2[key] ?? value;
  1079. }
  1080. }
  1081. return newObj;
  1082. } catch (error) {
  1083. throwError(error, 'assignObject');
  1084. return defaultGlobalOptions;
  1085. }
  1086. };
  1087. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1088. const saveData = () => {
  1089. try {
  1090. const data = {};
  1091. $('#globalOptionsForm').serializeArray().map(value => {
  1092. data[value.name] = value.value;
  1093. return value;
  1094. });
  1095. $.makeArray($('#globalOptionsForm input')).map(element => {
  1096. const name = $(element).attr('name');
  1097. const keys = name.split('.');
  1098. if (keys.length === 3) {
  1099. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1100. } else if (keys.length === 2) {
  1101. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1102. }
  1103. return element;
  1104. });
  1105. GM_setValue('globalOptions', globalOptions);
  1106. external_Swal_default().fire({
  1107. title: i18n('changeGlobalOptionsSuccess'),
  1108. icon: 'success'
  1109. });
  1110. } catch (error) {
  1111. throwError(error, 'saveData');
  1112. }
  1113. };
  1114. const changeGlobalOptions = showType => {
  1115. try {
  1116. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1117. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1118. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1119. for (const [ option, data2 ] of Object.entries(data1)) {
  1120. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1121. if (typeof data2 === 'boolean') {
  1122. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><label><input type="checkbox" name="${type}.${option}"${data2 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1123. } else {
  1124. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><input class="editOption" type="text" name="${type}.${option}" value="${data2}"/></td></tr>`;
  1125. }
  1126. } else {
  1127. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1128. globalOptionsForm += `<tr style="background-color: ${stringToColour(option)}66">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).map(key => Object.keys(data1[key]).length).reduce((acr, cur) => acr + cur)}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${option}.${i18n(socialType)}</td><td><label><input type="checkbox" name="${type}.${option}.${socialType}"${data3 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1129. }
  1130. }
  1131. }
  1132. }
  1133. globalOptionsForm += '</tbody></table></form>';
  1134. if (showType === 'swal') {
  1135. external_Swal_default().fire({
  1136. title: i18n('globalOptions'),
  1137. html: globalOptionsForm,
  1138. showConfirmButton: true,
  1139. confirmButtonText: i18n('save'),
  1140. showCancelButton: true,
  1141. cancelButtonText: i18n('close')
  1142. }).then(_ref => {
  1143. let {
  1144. isConfirmed
  1145. } = _ref;
  1146. if (isConfirmed) {
  1147. saveData();
  1148. }
  1149. });
  1150. } else {
  1151. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1152. }
  1153. } catch (error) {
  1154. throwError(error, 'changeGlobalOptions');
  1155. }
  1156. };
  1157. const data = {
  1158. website: '网站',
  1159. type: '类型',
  1160. edit: '编辑',
  1161. whiteList: '白名单',
  1162. skipTask: '跳过撤销任务',
  1163. whiteListOptions: '白名单设置',
  1164. changeWhiteListOption: '设置白名单(%0)',
  1165. whiteListNotFound: '找不到此项白名单: %0',
  1166. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1167. changeWebsiteOptions: '网站设置',
  1168. changeGlobalOptions: '全局设置',
  1169. ok: '是',
  1170. save: '保存',
  1171. close: '关闭',
  1172. return: '返回',
  1173. option: '选项',
  1174. value: '值',
  1175. websiteOptions: '当前网站设置',
  1176. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1177. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1178. needLogin: '请先登录!',
  1179. getTasksInfo: '正在获取并处理任务信息...',
  1180. gettingKey: '正在获取Key...',
  1181. verifyingTask: '正在验证任务',
  1182. notice: '自动任务脚本提醒',
  1183. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1184. giveawayEnded: '此活动已结束,是否关闭?',
  1185. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1186. confirm: '确定',
  1187. cancel: '取消',
  1188. unKnown: '未知',
  1189. unKnownTaskType: '未识别的任务',
  1190. doing: '正在做任务',
  1191. allTasksComplete: '所有任务已完成!',
  1192. getTaskIdFailed: '获取任务Id失败!',
  1193. initSuccess: '%0 初始化成功!',
  1194. initFailed: '%0 初始化失败!',
  1195. errorLink: '链接错误: %0',
  1196. needInit: '请先初始化',
  1197. verifyingAuth: '正在验证%0凭证...',
  1198. updatingAuth: '正在更新%0凭证...',
  1199. initing: '正在初始化...',
  1200. getFailed: '获取%0失败!',
  1201. checkLoginFailed: '检测登录状态失败!',
  1202. checkLeftKeyFailed: '检测剩余Key失败!',
  1203. userId: '用户Id',
  1204. joiningGiveaway: '正在加入赠Key',
  1205. needJoinGiveaway: '需要先加入赠Key',
  1206. cannotUndo: '此网站不支持取消任务',
  1207. verifyAuth: '正在验证 %0 凭证...',
  1208. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1209. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1210. visitingLink: '正在访问链接: ',
  1211. doTask: '做任务',
  1212. undoTask: '撤销任务',
  1213. verifyTask: '验证任务',
  1214. getKey: '获取Key',
  1215. selectAll: '全选',
  1216. selectNone: '全不选',
  1217. invertSelect: '反选',
  1218. doFreeTask: '加入免费赠品',
  1219. doPointTask: '加入点数赠品',
  1220. skipTaskOption: '设置中已配置跳过任务',
  1221. other: '其他',
  1222. globalOptions: '全局设置',
  1223. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1224. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1225. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1226. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1227. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1228. saveGlobalOptions: '保存全局设置',
  1229. settingPage: '设置页面',
  1230. name: '名称',
  1231. version: '版本',
  1232. scriptManager: '脚本管理器',
  1233. script: '脚本',
  1234. environment: '环境',
  1235. os: '系统',
  1236. browser: '浏览器',
  1237. getId: '获取 %0 id',
  1238. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1239. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1240. showButton: '显示按钮',
  1241. hideButton: '隐藏按钮',
  1242. showLog: '显示日志',
  1243. hideLog: '隐藏日志',
  1244. defaultShowButton: '默认显示按钮',
  1245. defaultShowLog: '默认显示日志',
  1246. debug: '输出调试日志,不要开启此选项!',
  1247. receivePreview: '接收预览版更新',
  1248. position: '组件位置',
  1249. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1250. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1251. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1252. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1253. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1254. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1255. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1256. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1257. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1258. hotKey: '快捷键',
  1259. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1260. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1261. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1262. tasksHistory: '任务历史',
  1263. clearHistory: '清空历史',
  1264. clearHistoryFinished: '已清空任务历史!',
  1265. deleteTask: '删除任务',
  1266. lastChangeTime: '最后一次修改时间',
  1267. clearTaskFinished: '删除以下任务完成!',
  1268. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1269. syncData: '数据同步',
  1270. settingData: '正在上传数据...',
  1271. gettingData: '正在获取数据...',
  1272. help: '帮助',
  1273. fileName: '文件名',
  1274. upload2gist: '同步到Gist',
  1275. downloadFromGist: '从Gist同步',
  1276. saveAndTest: '保存配置并测试',
  1277. testSuccess: '测试成功!',
  1278. testFailed: '测试失败!',
  1279. saveAndTestNotice: '请先保存配置并测试!',
  1280. processingData: '正在处理数据...',
  1281. updatingData: '正在上传数据...',
  1282. syncDataSuccess: '同步数据成功!',
  1283. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1284. downloadingData: '正在下载数据...',
  1285. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1286. savingData: '正在保存数据...',
  1287. syncHistory: '同步任务历史',
  1288. checkUpdateFailed: '检测更新失败',
  1289. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1290. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1291. gistOptions: 'Gist 设置',
  1292. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1293. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1294. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1295. toGithub: '前往Github反馈',
  1296. toKeylol: '前往其乐论坛反馈',
  1297. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1298. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1299. updateText: '%0 版本更新内容:',
  1300. Active: '进行中',
  1301. Ended: '已结束',
  1302. Banned: '已封禁',
  1303. Paused: '已暂停',
  1304. notStart: '未开始',
  1305. noRemoteData: '检测到远程无数据',
  1306. errorRemoteDataFormat: '远程数据格式错误',
  1307. updateHistory: '历史更新记录<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">点此查看</a>',
  1308. groups: '组',
  1309. officialGroups: '官方组',
  1310. wishlists: '愿望单',
  1311. follows: '游戏关注',
  1312. forums: '论坛',
  1313. workshops: '创意工坊收藏',
  1314. curators: '鉴赏家',
  1315. workshopVotes: '创意工坊点赞',
  1316. announcements: '社区通知',
  1317. steamCommunity: 'Steam社区',
  1318. steamStore: 'Steam商店',
  1319. licenses: '入库免费游戏',
  1320. playtests: '请求访问权限',
  1321. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1322. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1323. joiningSteamGroup: '正在加入Steam组',
  1324. leavingSteamGroup: '正在退出Steam组',
  1325. gettingSteamGroupId: '正在获取Steam组Id',
  1326. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1327. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1328. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1329. subscribingForum: '正在订阅Steam论坛',
  1330. unsubscribingForum: '正在取消订阅Steam论坛',
  1331. gettingForumId: '正在获取Steam论坛Id',
  1332. followingCurator: '正在关注Steam鉴赏家',
  1333. unfollowingCurator: '正在取关Steam鉴赏家',
  1334. gettingCuratorId: '正在获取Steam鉴赏家Id',
  1335. addingToWishlist: '正在添加游戏到Steam愿望单',
  1336. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1337. followingGame: '正在关注Steam游戏',
  1338. unfollowingGame: '正在取关Steam游戏',
  1339. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1340. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1341. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1342. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1343. gettingAnnouncementParams: '正在获取Steam通知信息',
  1344. likingAnnouncement: '正在点赞Steam通知',
  1345. changingArea: '正在更换Steam地区: %0...',
  1346. notNeededChangeArea: '当前地区不需要更换',
  1347. noAnotherArea: '请检测是否开启正确开启代理',
  1348. gettingAreaInfo: '正在获取Steam地区信息...',
  1349. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1350. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1351. gettingSubid: '正在获取游戏subid',
  1352. addingFreeLicense: '正在入库',
  1353. missParams: '缺少参数',
  1354. gettingLicenses: '正在获取Licenses...',
  1355. requestingPlayTestAccess: '正在请求访问权限',
  1356. tryChangeAreaNotice: '此功能无法检测游戏是否限区,因此会尝试换区后再入库,换区失败也不影响后续入库',
  1357. servers: '服务器',
  1358. joiningDiscordServer: '正在加入Discord服务器',
  1359. leavingDiscordServer: '正在退出Discord服务器',
  1360. gettingDiscordGuild: '正在获取Discord服务器Id',
  1361. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1362. discordImportantNotice: '重要提醒!!!',
  1363. discordImportantNoticeText: '由于Discord网站后台更新,目前使用此脚本加组后可能会导致Discord帐号被强制退出,且需要两步验证才能正常登录,请谨慎使用!!!',
  1364. continue: '继续',
  1365. skipDiscordTask: '跳过Discord任务',
  1366. continueAndDontRemindAgain: '继续且不再提醒',
  1367. users: '用户',
  1368. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1369. insBanned: '您的Instagram账户已被封禁',
  1370. verifyingInsAuth: '正在验证Instagram凭证...',
  1371. gettingInsUserId: '正在获取Instagram用户Id',
  1372. followingIns: '正在关注Instagram用户',
  1373. unfollowingIns: '正在取关Instagram用户',
  1374. reddits: '社区/用户',
  1375. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1376. changingRedditVersion: '正在切换Reddit为新版页面...',
  1377. joiningReddit: '正在加入Reddit社区',
  1378. leavingReddit: '正在退出Reddit社区',
  1379. followingRedditUser: '正在关注Reddit用户',
  1380. unfollowingRedditUser: '正在取关Reddit用户',
  1381. channels: '频道',
  1382. followingTwitchChannel: '正在关注Twitch频道',
  1383. unfollowingTwitchChannel: '正在取关Twitch频道',
  1384. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1385. twitterUser: '推特用户',
  1386. retweets: '转推',
  1387. gettingTwitterUserId: '正在获取推特用户Id',
  1388. followingTwitterUser: '正在关注推特用户',
  1389. unfollowingTwitterUser: '正在取关推特用户',
  1390. retweetting: '正在转推',
  1391. unretweetting: '正在撤销转推',
  1392. names: '组/社区/动态',
  1393. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1394. gettingVkId: '正在获取Vk任务Id',
  1395. joiningVkGroup: '正在加入Vk组',
  1396. leavingVkGroup: '正在退出Vk组',
  1397. joiningVkPublic: '正在加入Vk社区',
  1398. leavingVkPublic: '正在退出Vk社区',
  1399. sendingVkWall: '正在转发Vk动态',
  1400. deletingVkWall: '正在撤销转发Vk动态',
  1401. youtubeChannel: 'YouTube频道',
  1402. likes: '点赞',
  1403. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1404. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1405. gettingYtbToken: '正在获取YouTube Token...',
  1406. followingYtbChannel: '正在订阅YouTube频道',
  1407. unfollowingYtbChannel: '正在退订YouTube频道',
  1408. likingYtbVideo: '正在点赞YouTube视频',
  1409. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1410. giveKeyNoticeBefore: '每次验证间隔15s',
  1411. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1412. noPoints: '点数不够,跳过抽奖',
  1413. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1414. joiningLottery: '正在加入抽奖',
  1415. doingGleamTask: '正在做Gleam任务...',
  1416. gettingGleamLink: '正在获取Gleam任务链接...',
  1417. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1418. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1419. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1420. giveeClubVerifyNotice: '正在验证任务...',
  1421. giveeClubVerifyFinished: '请等待验证完成后自行加入赠Key',
  1422. doingKeyhubTask: '正在做Keyhub任务...',
  1423. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1424. };
  1425. const zh_CN = data;
  1426. const en_US_data = {
  1427. website: 'Website',
  1428. type: 'Type',
  1429. edit: 'Edit',
  1430. whiteList: 'Whitelist',
  1431. skipTask: 'Skip undo task',
  1432. whiteListOptions: 'Whitelist options',
  1433. changeWhiteListOption: 'Whitelist option(%0)',
  1434. whiteListNotFound: 'Cannot find this whitelist: %0',
  1435. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1436. changeWebsiteOptions: 'Website options',
  1437. changeGlobalOptions: 'Global options',
  1438. ok: 'OK',
  1439. save: 'Save',
  1440. close: 'Close',
  1441. return: 'Return',
  1442. option: 'Option',
  1443. value: 'Value',
  1444. websiteOptions: 'Current website settings',
  1445. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1446. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1447. needLogin: 'Please log in first!',
  1448. getTasksInfo: 'Obtaining and processing task information...',
  1449. gettingKey: 'Getting Key...',
  1450. verifyingTask: 'Verifying task',
  1451. notice: 'Automatic task script notice',
  1452. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1453. giveawayEnded: 'This event has ended, do you want to close it?',
  1454. 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?',
  1455. confirm: 'Confirm',
  1456. cancel: 'Cancel',
  1457. unKnown: 'Unknown',
  1458. unKnownTaskType: 'Unrecognized task',
  1459. doing: 'Doing a task',
  1460. allTasksComplete: 'All tasks have been completed!',
  1461. getTaskIdFailed: 'Failed to obtain task Id!',
  1462. initSuccess: '%0 was initialized successfully!',
  1463. initFailed: '%0 initialization failed!',
  1464. errorLink: 'Link error: %0',
  1465. needInit: 'Please initialize first',
  1466. verifyingAuth: 'Verifying %0 token...',
  1467. updatingAuth: 'Update %0 token...',
  1468. initing: 'Initializing...',
  1469. getFailed: 'Failed to get %0!',
  1470. checkLoginFailed: 'Failed to detect login status!',
  1471. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1472. userId: 'User Id',
  1473. joiningGiveaway: 'Joining giveaway',
  1474. needJoinGiveaway: 'Need to join the giveaway first',
  1475. cannotUndo: 'This website does not support canceling tasks',
  1476. verifyAuth: 'Verifying %0 token...',
  1477. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1478. errorReport: 'A script error is detected, do you want to report the BUG?',
  1479. visitingLink: 'Visiting link: ',
  1480. doTask: 'DoTask',
  1481. undoTask: 'UndoTask',
  1482. verifyTask: 'Verify',
  1483. getKey: 'GetKey',
  1484. selectAll: 'SelectAll',
  1485. selectNone: 'SelectNone',
  1486. invertSelect: 'InvertSelect',
  1487. doFreeTask: 'FreeTask',
  1488. doPointTask: 'PointTask',
  1489. skipTaskOption: 'Skip task has been configured in the settings',
  1490. other: 'Other',
  1491. globalOptions: 'Global Options',
  1492. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1493. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1494. 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.',
  1495. 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.',
  1496. 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.',
  1497. saveGlobalOptions: 'SaveSettings',
  1498. settingPage: 'Setting Page',
  1499. name: 'Name',
  1500. version: 'Version',
  1501. scriptManager: 'Script Manager',
  1502. script: 'Script',
  1503. environment: 'Environment',
  1504. os: 'OS',
  1505. browser: 'Browser',
  1506. getId: 'Get %0 id',
  1507. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1508. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1509. showButton: 'ShowButton',
  1510. hideButton: 'HideButton',
  1511. showLog: 'ShowLog',
  1512. hideLog: 'HideLog',
  1513. defaultShowButton: 'Default display button',
  1514. defaultShowLog: 'Display log by default',
  1515. debug: 'Output debug log, do not enable this option!',
  1516. receivePreview: 'Receive preview updates',
  1517. position: 'Component position',
  1518. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1519. 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',
  1520. 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',
  1521. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1522. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1523. 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',
  1524. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1525. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1526. 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',
  1527. hotKey: 'Shortcut key',
  1528. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1529. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1530. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1531. tasksHistory: 'TasksHistory',
  1532. clearHistory: 'Clear history',
  1533. clearHistoryFinished: 'The mission history has been cleared!',
  1534. deleteTask: 'Delete task',
  1535. lastChangeTime: 'Last Change Time',
  1536. clearTaskFinished: 'Delete the following tasks completed!',
  1537. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1538. syncData: 'DataSync',
  1539. settingData: 'Uploading data...',
  1540. gettingData: 'Getting data...',
  1541. help: 'Help',
  1542. fileName: 'Filename',
  1543. upload2gist: 'Sync to Gist',
  1544. downloadFromGist: 'Sync from Gist',
  1545. saveAndTest: 'Save configuration and test',
  1546. testSuccess: 'Test success!',
  1547. testFailed: 'Test failed!',
  1548. saveAndTestNotice: 'Please save the configuration and test first!',
  1549. processingData: 'Processing data...',
  1550. updatingData: 'Uploading data...',
  1551. syncDataSuccess: 'Synchronized data successfully!',
  1552. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1553. downloadingData: 'Downloading data...',
  1554. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1555. savingData: 'Saving data...',
  1556. syncHistory: 'Synchronize tasks history',
  1557. checkUpdateFailed: 'Check update failed',
  1558. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1559. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1560. gistOptions: 'Gist Settings',
  1561. 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!',
  1562. 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!',
  1563. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1564. toGithub: 'Feedback(Github)',
  1565. toKeylol: 'Feedback(Keylol)',
  1566. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1567. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1568. updateText: 'Updates in version %0:',
  1569. Active: 'Active',
  1570. Ended: 'Ended',
  1571. Banned: 'Banned',
  1572. Paused: 'Paused',
  1573. notStart: 'notStart',
  1574. noRemoteData: 'No data remotely',
  1575. errorRemoteDataFormat: 'Remote data has wrong format',
  1576. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1577. groups: 'Group',
  1578. officialGroups: 'Official Group',
  1579. wishlists: 'Wishlist',
  1580. follows: 'Follow Game',
  1581. forums: 'Forum',
  1582. workshops: 'Favorite Workshop',
  1583. curators: 'Curator',
  1584. workshopVotes: 'Voteup Workshop',
  1585. announcements: 'Announcement',
  1586. steamCommunity: 'Steam Community',
  1587. steamStore: 'Steam Store',
  1588. licenses: 'Add License',
  1589. playtests: 'Playtest Access',
  1590. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1591. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1592. joiningSteamGroup: 'Joining Steam Group',
  1593. leavingSteamGroup: 'Leaving Steam Group',
  1594. gettingSteamGroupId: 'Getting Steam Group Id',
  1595. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1596. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1597. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1598. subscribingForum: 'Subscribing the Steam Forum',
  1599. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1600. gettingForumId: 'Getting Steam Forum Id',
  1601. followingCurator: 'Following Steam Curator',
  1602. unfollowingCurator: 'Unfollowing Steam Curator',
  1603. gettingCuratorId: 'Getting Steam Curator Id',
  1604. addingToWishlist: 'Adding the game to the Steam wishlist',
  1605. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1606. followingGame: 'Following Steam games',
  1607. unfollowingGame: 'Unfollowing Steam games',
  1608. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1609. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1610. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1611. votingUpWorkshop: 'Liking Steam workshop items',
  1612. gettingAnnouncementParams: 'Getting Steam announcement information',
  1613. likingAnnouncement: 'Liking Steam announcement',
  1614. changingArea: 'Changing Steam area: %0...',
  1615. notNeededChangeArea: 'The current area does not need to be changed',
  1616. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1617. gettingAreaInfo: 'Getting Steam area information...',
  1618. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1619. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1620. gettingSubid: 'Getting subid',
  1621. addingFreeLicense: 'Adding free license',
  1622. missParams: 'Missing parameters',
  1623. gettingLicenses: 'Getting licenses...',
  1624. requestingPlayTestAccess: 'Requesting play test access',
  1625. 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.',
  1626. servers: 'Server',
  1627. joiningDiscordServer: 'Joining Discord Server',
  1628. leavingDiscordServer: 'Leaving Discord Server',
  1629. gettingDiscordGuild: 'Getting Discord server Id',
  1630. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1631. discordImportantNotice: 'Important Reminder! ! !',
  1632. 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! ! !',
  1633. continue: 'Continue',
  1634. skipDiscordTask: 'Skip',
  1635. continueAndDontRemindAgain: 'Continue without Reminders',
  1636. users: 'User',
  1637. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1638. insBanned: 'Your Instagram account has been banned',
  1639. verifyingInsAuth: 'Verifying Instagram token...',
  1640. gettingInsUserId: 'Getting Instagram user Id',
  1641. followingIns: 'Following Instagram user',
  1642. unfollowingIns: 'Unfollowing Instagram user',
  1643. reddits: 'Reddit/User',
  1644. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1645. changingRedditVersion: 'Switching Reddit to a new version page...',
  1646. joiningReddit: 'Joining the Reddit',
  1647. leavingReddit: 'Leaving the Reddit',
  1648. followingRedditUser: 'Following Reddit User',
  1649. unfollowingRedditUser: 'Unfollowing Reddit User',
  1650. channels: 'Channel',
  1651. followingTwitchChannel: 'Following Twitch Channel',
  1652. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1653. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1654. twitterUser: 'Twitter User',
  1655. retweets: 'Retweet',
  1656. gettingTwitterUserId: 'Getting Twitter User Id',
  1657. followingTwitterUser: 'Following Twitter User',
  1658. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1659. retweetting: 'Retweetting',
  1660. unretweetting: 'Unretweetting',
  1661. names: 'Group/Public/Wall',
  1662. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1663. gettingVkId: 'Getting Vk task Id',
  1664. joiningVkGroup: 'Joining Vk Group',
  1665. leavingVkGroup: 'Leaving Vk Group',
  1666. joiningVkPublic: 'Joining Vk Public',
  1667. leavingVkPublic: 'Leaving Vk Public',
  1668. sendingVkWall: 'Sending Vk Wall',
  1669. deletingVkWall: 'Deleting Vk Wall',
  1670. youtubeChannel: 'YouTube Channel',
  1671. likes: 'Like',
  1672. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1673. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1674. gettingYtbToken: 'Getting YouTube Token...',
  1675. followingYtbChannel: 'Subscribing to YouTube channel',
  1676. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1677. likingYtbVideo: 'Liking YouTube video',
  1678. unlikingYtbVideo: 'Unliking YouTube video',
  1679. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1680. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1681. noPoints: 'Not enough points, skip the lottery',
  1682. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1683. joiningLottery: 'Joining the lottery',
  1684. doingGleamTask: 'Doing Gleam Task...',
  1685. gettingGleamLink: 'Getting Gleam task link...',
  1686. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1687. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1688. 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!',
  1689. giveeClubVerifyNotice: 'Verifying task...',
  1690. giveeClubVerifyFinished: 'Wait for the verification to complete and join it by yourself',
  1691. doingKeyhubTask: 'Doing Keyhub Task...',
  1692. 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...'
  1693. };
  1694. const en_US = en_US_data;
  1695. const languages = {
  1696. zh: zh_CN,
  1697. en: en_US
  1698. };
  1699. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1700. const I18n = function(key) {
  1701. var _languages$language;
  1702. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1703. argvs[_key - 1] = arguments[_key];
  1704. }
  1705. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1706. return key;
  1707. }
  1708. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1709. };
  1710. const i18n = I18n;
  1711. function throwError(error, name) {
  1712. if (window.TRACE) {
  1713. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1714. }
  1715. external_Swal_default().fire({
  1716. title: i18n('errorReport'),
  1717. icon: 'error',
  1718. showCancelButton: true,
  1719. confirmButtonText: i18n('toGithub'),
  1720. showDenyButton: true,
  1721. denyButtonText: i18n('toKeylol'),
  1722. cancelButtonText: i18n('close')
  1723. }).then(_ref => {
  1724. let {
  1725. isDenied,
  1726. isConfirmed
  1727. } = _ref;
  1728. if (isConfirmed) {
  1729. 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,
  1730. 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');
  1731. } else if (isDenied) {
  1732. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1733.  
  1734. 环境:
  1735.  
  1736. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1737.  
  1738. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1739. 脚本版本: ${GM_info.script.version}
  1740.  
  1741. 报错信息:
  1742. [code]${error.stack}[/code]
  1743.  
  1744. 执行日志:
  1745. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1746. GM_setClipboard(text);
  1747. external_Swal_default().fire({
  1748. title: i18n('copySuccess'),
  1749. icon: 'success',
  1750. confirmButtonText: i18n('ok')
  1751. }).then(() => {
  1752. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1753. });
  1754. }
  1755. });
  1756. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1757. }
  1758. function _defineProperty(obj, key, value) {
  1759. if (key in obj) {
  1760. Object.defineProperty(obj, key, {
  1761. value: value,
  1762. enumerable: true,
  1763. configurable: true,
  1764. writable: true
  1765. });
  1766. } else {
  1767. obj[key] = value;
  1768. }
  1769. return obj;
  1770. }
  1771. class Social {
  1772. constructor() {
  1773. _defineProperty(this, 'tasks', void 0);
  1774. }
  1775. getRealParams(name, links, doTask, link2param) {
  1776. try {
  1777. let realParams = [];
  1778. if (links.length > 0) {
  1779. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1780. }
  1781. if (!doTask && this.tasks[name].length > 0) {
  1782. realParams = [ ...realParams, ...this.tasks[name] ];
  1783. }
  1784. return unique(realParams);
  1785. } catch (error) {
  1786. throwError(error, 'Social.getRealParams');
  1787. return [];
  1788. }
  1789. }
  1790. }
  1791. const social_Social = Social;
  1792. function _classPrivateMethodInitSpec(obj, privateSet) {
  1793. _checkPrivateRedeclaration(obj, privateSet);
  1794. privateSet.add(obj);
  1795. }
  1796. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1797. _checkPrivateRedeclaration(obj, privateMap);
  1798. privateMap.set(obj, value);
  1799. }
  1800. function _checkPrivateRedeclaration(obj, privateCollection) {
  1801. if (privateCollection.has(obj)) {
  1802. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1803. }
  1804. }
  1805. function Discord_defineProperty(obj, key, value) {
  1806. if (key in obj) {
  1807. Object.defineProperty(obj, key, {
  1808. value: value,
  1809. enumerable: true,
  1810. configurable: true,
  1811. writable: true
  1812. });
  1813. } else {
  1814. obj[key] = value;
  1815. }
  1816. return obj;
  1817. }
  1818. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1819. if (!privateSet.has(receiver)) {
  1820. throw new TypeError('attempted to get private field on non-instance');
  1821. }
  1822. return fn;
  1823. }
  1824. function _classPrivateFieldGet(receiver, privateMap) {
  1825. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1826. return _classApplyDescriptorGet(receiver, descriptor);
  1827. }
  1828. function _classApplyDescriptorGet(receiver, descriptor) {
  1829. if (descriptor.get) {
  1830. return descriptor.get.call(receiver);
  1831. }
  1832. return descriptor.value;
  1833. }
  1834. function _classPrivateFieldSet(receiver, privateMap, value) {
  1835. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1836. _classApplyDescriptorSet(receiver, descriptor, value);
  1837. return value;
  1838. }
  1839. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1840. if (!privateMap.has(receiver)) {
  1841. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1842. }
  1843. return privateMap.get(receiver);
  1844. }
  1845. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1846. if (descriptor.set) {
  1847. descriptor.set.call(receiver, value);
  1848. } else {
  1849. if (!descriptor.writable) {
  1850. throw new TypeError('attempted to set read only private field');
  1851. }
  1852. descriptor.value = value;
  1853. }
  1854. }
  1855. const defaultTasksTemplate = {
  1856. servers: []
  1857. };
  1858. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1859. var _auth = new WeakMap();
  1860. var _cache = new WeakMap();
  1861. var _initialized = new WeakMap();
  1862. var _verifyAuth = new WeakSet();
  1863. var _updateAuth = new WeakSet();
  1864. var _joinServer = new WeakSet();
  1865. var _leaveServer = new WeakSet();
  1866. var _getGuild = new WeakSet();
  1867. var _setCache = new WeakSet();
  1868. class Discord extends social_Social {
  1869. constructor() {
  1870. var _GM_getValue;
  1871. super(...arguments);
  1872. _classPrivateMethodInitSpec(this, _setCache);
  1873. _classPrivateMethodInitSpec(this, _getGuild);
  1874. _classPrivateMethodInitSpec(this, _leaveServer);
  1875. _classPrivateMethodInitSpec(this, _joinServer);
  1876. _classPrivateMethodInitSpec(this, _updateAuth);
  1877. _classPrivateMethodInitSpec(this, _verifyAuth);
  1878. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1879. Discord_defineProperty(this, 'whiteList', {
  1880. ...JSON.parse(defaultTasks),
  1881. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1882. });
  1883. _classPrivateFieldInitSpec(this, _auth, {
  1884. writable: true,
  1885. value: GM_getValue('discordAuth') || {}
  1886. });
  1887. _classPrivateFieldInitSpec(this, _cache, {
  1888. writable: true,
  1889. value: GM_getValue('discordCache') || {}
  1890. });
  1891. _classPrivateFieldInitSpec(this, _initialized, {
  1892. writable: true,
  1893. value: false
  1894. });
  1895. }
  1896. async init() {
  1897. try {
  1898. if (!GM_getValue('dontRemindDiscordAgain')) {
  1899. const result = await external_Swal_default().fire({
  1900. title: i18n('discordImportantNotice'),
  1901. text: i18n('discordImportantNoticeText'),
  1902. showCancelButton: true,
  1903. showDenyButton: true,
  1904. confirmButtonText: i18n('continue'),
  1905. cancelButtonText: i18n('skipDiscordTask'),
  1906. denyButtonText: i18n('continueAndDontRemindAgain')
  1907. }).then(_ref => {
  1908. let {
  1909. isConfirmed,
  1910. isDenied
  1911. } = _ref;
  1912. if (isConfirmed) {
  1913. return true;
  1914. }
  1915. if (isDenied) {
  1916. GM_setValue('dontRemindDiscordAgain', true);
  1917. return true;
  1918. }
  1919. return false;
  1920. });
  1921. if (!result) {
  1922. _classPrivateFieldSet(this, _initialized, false);
  1923. return 'skip';
  1924. }
  1925. }
  1926. if (_classPrivateFieldGet(this, _initialized)) {
  1927. return true;
  1928. }
  1929. if (!_classPrivateFieldGet(this, _auth).auth) {
  1930. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1931. _classPrivateFieldSet(this, _initialized, true);
  1932. return true;
  1933. }
  1934. return false;
  1935. }
  1936. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1937. if (isVerified) {
  1938. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1939. _classPrivateFieldSet(this, _initialized, true);
  1940. return true;
  1941. }
  1942. GM_setValue('discordAuth', {
  1943. auth: null
  1944. });
  1945. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1946. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1947. _classPrivateFieldSet(this, _initialized, true);
  1948. return true;
  1949. }
  1950. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1951. return false;
  1952. } catch (error) {
  1953. throwError(error, 'Discord.init');
  1954. return false;
  1955. }
  1956. }
  1957. async toggle(_ref2) {
  1958. let {
  1959. doTask = true,
  1960. serverLinks = []
  1961. } = _ref2;
  1962. try {
  1963. if (!_classPrivateFieldGet(this, _initialized)) {
  1964. scripts_echoLog({
  1965. text: i18n('needInit')
  1966. });
  1967. return false;
  1968. }
  1969. const prom = [];
  1970. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1971. scripts_echoLog({
  1972. type: 'globalOptionsSkip',
  1973. text: 'discord.servers'
  1974. });
  1975. } else {
  1976. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1977. var _link$match;
  1978. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1979. });
  1980. if (realServers.length > 0) {
  1981. for (const server of realServers) {
  1982. if (doTask) {
  1983. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1984. } else {
  1985. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1986. }
  1987. await delay(1e3);
  1988. }
  1989. }
  1990. }
  1991. return await Promise.all(prom).then(() => true);
  1992. } catch (error) {
  1993. throwError(error, 'Discord.toggleServers');
  1994. return false;
  1995. }
  1996. }
  1997. }
  1998. async function _verifyAuth2() {
  1999. try {
  2000. const logStatus = scripts_echoLog({
  2001. text: i18n('verifyingAuth', 'Discord')
  2002. });
  2003. const {
  2004. result,
  2005. statusText,
  2006. status,
  2007. data
  2008. } = await tools_httpRequest({
  2009. url: 'https://discord.com/api/v6/users/@me',
  2010. method: 'HEAD',
  2011. headers: {
  2012. authorization: _classPrivateFieldGet(this, _auth).auth
  2013. }
  2014. });
  2015. if (result === 'Success') {
  2016. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2017. logStatus.success();
  2018. return true;
  2019. }
  2020. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2021. return false;
  2022. }
  2023. logStatus.error(`${result}:${statusText}(${status})`);
  2024. return false;
  2025. } catch (error) {
  2026. throwError(error, 'Discord.verifyAuth');
  2027. return false;
  2028. }
  2029. }
  2030. async function _updateAuth2() {
  2031. try {
  2032. const logStatus = scripts_echoLog({
  2033. text: i18n('updatingAuth', 'Discord')
  2034. });
  2035. return await new Promise(resolve => {
  2036. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  2037. active: true,
  2038. insert: true,
  2039. setParent: true
  2040. });
  2041. newTab.onclose = async () => {
  2042. var _GM_getValue2;
  2043. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  2044. if (auth) {
  2045. _classPrivateFieldSet(this, _auth, {
  2046. auth: auth
  2047. });
  2048. logStatus.success();
  2049. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  2050. } else {
  2051. logStatus.error('Error: Update discord auth failed!');
  2052. resolve(false);
  2053. }
  2054. };
  2055. });
  2056. } catch (error) {
  2057. throwError(error, 'Discord.updateAuth');
  2058. return false;
  2059. }
  2060. }
  2061. async function _joinServer2(inviteId) {
  2062. try {
  2063. const logStatus = scripts_echoLog({
  2064. type: 'joiningDiscordServer',
  2065. text: inviteId
  2066. });
  2067. const {
  2068. result,
  2069. statusText,
  2070. status,
  2071. data
  2072. } = await tools_httpRequest({
  2073. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2074. method: 'POST',
  2075. dataType: 'json',
  2076. headers: {
  2077. authorization: _classPrivateFieldGet(this, _auth).auth,
  2078. origin: 'https://discord.com',
  2079. referer: `https://discord.com/invite/${inviteId}`
  2080. }
  2081. });
  2082. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2083. var _data$response, _data$response$guild;
  2084. logStatus.success();
  2085. 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);
  2086. if (guild) {
  2087. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2088. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2089. }
  2090. return true;
  2091. }
  2092. logStatus.error(`${result}:${statusText}(${status})`);
  2093. return false;
  2094. } catch (error) {
  2095. throwError(error, 'Discord.joinServer');
  2096. return false;
  2097. }
  2098. }
  2099. async function _leaveServer2(inviteId) {
  2100. try {
  2101. if (this.whiteList.servers.includes(inviteId)) {
  2102. scripts_echoLog({
  2103. type: 'whiteList',
  2104. text: 'Discord.leaveServer',
  2105. id: inviteId
  2106. });
  2107. return true;
  2108. }
  2109. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2110. if (!guild) {
  2111. return false;
  2112. }
  2113. const logStatus = scripts_echoLog({
  2114. type: 'leavingDiscordServer',
  2115. text: guild
  2116. });
  2117. const {
  2118. result,
  2119. statusText,
  2120. status,
  2121. data
  2122. } = await tools_httpRequest({
  2123. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2124. method: 'DELETE',
  2125. headers: {
  2126. authorization: _classPrivateFieldGet(this, _auth).auth
  2127. }
  2128. });
  2129. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2130. logStatus.success();
  2131. return true;
  2132. }
  2133. logStatus.error(`${result}:${statusText}(${status})`);
  2134. return false;
  2135. } catch (error) {
  2136. throwError(error, 'Discord.leaveServer');
  2137. return false;
  2138. }
  2139. }
  2140. async function _getGuild2(inviteId) {
  2141. try {
  2142. const logStatus = scripts_echoLog({
  2143. type: 'gettingDiscordGuild',
  2144. text: inviteId
  2145. });
  2146. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2147. if (guild) {
  2148. logStatus.success();
  2149. return guild;
  2150. }
  2151. const {
  2152. result,
  2153. statusText,
  2154. status,
  2155. data
  2156. } = await tools_httpRequest({
  2157. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2158. responseType: 'json',
  2159. method: 'GET'
  2160. });
  2161. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2162. var _data$response2, _data$response2$guild;
  2163. 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;
  2164. if (guild) {
  2165. logStatus.success();
  2166. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2167. return guild;
  2168. }
  2169. logStatus.error(`${result}:${statusText}(${status})`);
  2170. return false;
  2171. }
  2172. logStatus.error(`${result}:${statusText}(${status})`);
  2173. return false;
  2174. } catch (error) {
  2175. throwError(error, 'Discord.getGuild');
  2176. return false;
  2177. }
  2178. }
  2179. function _setCache2(inviteId, guild) {
  2180. try {
  2181. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2182. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2183. } catch (error) {
  2184. throwError(error, 'Discord.setCache');
  2185. }
  2186. }
  2187. const social_Discord = Discord;
  2188. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2189. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2190. privateSet.add(obj);
  2191. }
  2192. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2193. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2194. privateMap.set(obj, value);
  2195. }
  2196. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2197. if (privateCollection.has(obj)) {
  2198. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2199. }
  2200. }
  2201. function Instagram_defineProperty(obj, key, value) {
  2202. if (key in obj) {
  2203. Object.defineProperty(obj, key, {
  2204. value: value,
  2205. enumerable: true,
  2206. configurable: true,
  2207. writable: true
  2208. });
  2209. } else {
  2210. obj[key] = value;
  2211. }
  2212. return obj;
  2213. }
  2214. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2215. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2216. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2217. return value;
  2218. }
  2219. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2220. if (descriptor.set) {
  2221. descriptor.set.call(receiver, value);
  2222. } else {
  2223. if (!descriptor.writable) {
  2224. throw new TypeError('attempted to set read only private field');
  2225. }
  2226. descriptor.value = value;
  2227. }
  2228. }
  2229. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2230. if (!privateSet.has(receiver)) {
  2231. throw new TypeError('attempted to get private field on non-instance');
  2232. }
  2233. return fn;
  2234. }
  2235. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2236. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2237. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2238. }
  2239. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2240. if (!privateMap.has(receiver)) {
  2241. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2242. }
  2243. return privateMap.get(receiver);
  2244. }
  2245. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2246. if (descriptor.get) {
  2247. return descriptor.get.call(receiver);
  2248. }
  2249. return descriptor.value;
  2250. }
  2251. const Instagram_defaultTasksTemplate = {
  2252. users: []
  2253. };
  2254. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2255. var Instagram_cache = new WeakMap();
  2256. var Instagram_auth = new WeakMap();
  2257. var Instagram_initialized = new WeakMap();
  2258. var _getUserInfo = new WeakSet();
  2259. var _followUser = new WeakSet();
  2260. var _unfollowUser = new WeakSet();
  2261. var Instagram_setCache = new WeakSet();
  2262. class Instagram extends social_Social {
  2263. constructor() {
  2264. var _GM_getValue;
  2265. super(...arguments);
  2266. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2267. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2268. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2269. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2270. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2271. Instagram_defineProperty(this, 'whiteList', {
  2272. ...JSON.parse(Instagram_defaultTasks),
  2273. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2274. });
  2275. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2276. writable: true,
  2277. value: GM_getValue('instagramCache') || {}
  2278. });
  2279. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2280. writable: true,
  2281. value: {}
  2282. });
  2283. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2284. writable: true,
  2285. value: false
  2286. });
  2287. }
  2288. async init() {
  2289. try {
  2290. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2291. return true;
  2292. }
  2293. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2294. if (isVerified) {
  2295. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2296. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2297. return true;
  2298. }
  2299. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2300. return false;
  2301. } catch (error) {
  2302. throwError(error, 'Instagram.init');
  2303. return false;
  2304. }
  2305. }
  2306. async toggle(_ref) {
  2307. let {
  2308. doTask = true,
  2309. userLinks = []
  2310. } = _ref;
  2311. try {
  2312. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2313. scripts_echoLog({
  2314. text: i18n('needInit')
  2315. });
  2316. return false;
  2317. }
  2318. const prom = [];
  2319. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2320. scripts_echoLog({
  2321. type: 'globalOptionsSkip',
  2322. text: 'instagram.users'
  2323. });
  2324. } else {
  2325. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2326. var _link$match;
  2327. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2328. });
  2329. if (realUsers.length > 0) {
  2330. for (const username of realUsers) {
  2331. if (doTask) {
  2332. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2333. } else {
  2334. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2335. }
  2336. await delay(1e3);
  2337. }
  2338. }
  2339. }
  2340. return await Promise.all(prom).then(() => true);
  2341. } catch (error) {
  2342. throwError(error, 'Instagram.toggleUsers');
  2343. return false;
  2344. }
  2345. }
  2346. }
  2347. async function _getUserInfo2() {
  2348. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2349. try {
  2350. const logStatus = scripts_echoLog({
  2351. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2352. text: name
  2353. });
  2354. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2355. if (userId && name !== 'instagram') {
  2356. logStatus.success();
  2357. return userId;
  2358. }
  2359. const {
  2360. result,
  2361. statusText,
  2362. status,
  2363. data
  2364. } = await tools_httpRequest({
  2365. url: `https://www.instagram.com/${name}/`,
  2366. method: 'GET'
  2367. });
  2368. if (result === 'Success') {
  2369. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2370. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2371. return false;
  2372. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2373. logStatus.error(`Error:${i18n('insBanned')}`);
  2374. return false;
  2375. }
  2376. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2377. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2378. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2379. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2380. if (name === 'instagram') {
  2381. if (csrftoken && hash) {
  2382. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2383. csrftoken: csrftoken,
  2384. hash: hash
  2385. });
  2386. return true;
  2387. }
  2388. return false;
  2389. }
  2390. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2391. if (id) {
  2392. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2393. logStatus.success();
  2394. return id;
  2395. }
  2396. logStatus.error('Error: Get ins data error!');
  2397. return false;
  2398. }
  2399. logStatus.error(`${result}:${statusText}(${status})`);
  2400. return false;
  2401. }
  2402. return false;
  2403. } catch (error) {
  2404. throwError(error, 'Instagram.getUserInfo');
  2405. return false;
  2406. }
  2407. }
  2408. async function _followUser2(name) {
  2409. try {
  2410. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2411. if (!id) {
  2412. return false;
  2413. }
  2414. const logStatus = scripts_echoLog({
  2415. type: 'followingIns',
  2416. text: name
  2417. });
  2418. const {
  2419. result,
  2420. statusText,
  2421. status,
  2422. data
  2423. } = await tools_httpRequest({
  2424. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2425. method: 'POST',
  2426. dataType: 'json',
  2427. headers: {
  2428. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2429. origin: 'https://www.instagram.com',
  2430. referer: `https://www.instagram.com/${name}/`,
  2431. 'content-type': 'application/x-www-form-urlencoded',
  2432. 'sec-fetch-site': 'same-origin',
  2433. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2434. }
  2435. });
  2436. if (result === 'Success') {
  2437. var _data$response, _data$response2;
  2438. 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') {
  2439. logStatus.success();
  2440. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2441. return true;
  2442. }
  2443. 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})`}`);
  2444. return false;
  2445. }
  2446. logStatus.error(`${result}:${statusText}(${status})`);
  2447. return false;
  2448. } catch (error) {
  2449. throwError(error, 'Instagram.followUser');
  2450. return false;
  2451. }
  2452. }
  2453. async function _unfollowUser2(name) {
  2454. try {
  2455. if (this.whiteList.users.includes(name)) {
  2456. scripts_echoLog({
  2457. type: 'whiteList',
  2458. text: 'Instagram.unfollowUser',
  2459. id: name
  2460. });
  2461. return true;
  2462. }
  2463. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2464. if (!id) {
  2465. return false;
  2466. }
  2467. const logStatus = scripts_echoLog({
  2468. type: 'unfollowingIns',
  2469. text: name
  2470. });
  2471. const {
  2472. result,
  2473. statusText,
  2474. status,
  2475. data
  2476. } = await tools_httpRequest({
  2477. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2478. method: 'POST',
  2479. dataType: 'json',
  2480. headers: {
  2481. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2482. origin: 'https://www.instagram.com',
  2483. referer: `https://www.instagram.com/${name}/`,
  2484. 'content-type': 'application/x-www-form-urlencoded',
  2485. 'sec-fetch-site': 'same-origin',
  2486. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2487. }
  2488. });
  2489. if (result === 'Success') {
  2490. var _data$response3;
  2491. 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') {
  2492. logStatus.success();
  2493. return true;
  2494. }
  2495. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2496. return false;
  2497. }
  2498. logStatus.error(`${result}:${statusText}(${status})`);
  2499. return false;
  2500. } catch (error) {
  2501. throwError(error, 'Instagram.unfollowUser');
  2502. return false;
  2503. }
  2504. }
  2505. function Instagram_setCache2(name, id) {
  2506. try {
  2507. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2508. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2509. } catch (error) {
  2510. throwError(error, 'Instagram.setCache');
  2511. }
  2512. }
  2513. const social_Instagram = Instagram;
  2514. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2515. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2516. privateSet.add(obj);
  2517. }
  2518. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2519. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2520. privateMap.set(obj, value);
  2521. }
  2522. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2523. if (privateCollection.has(obj)) {
  2524. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2525. }
  2526. }
  2527. function Reddit_defineProperty(obj, key, value) {
  2528. if (key in obj) {
  2529. Object.defineProperty(obj, key, {
  2530. value: value,
  2531. enumerable: true,
  2532. configurable: true,
  2533. writable: true
  2534. });
  2535. } else {
  2536. obj[key] = value;
  2537. }
  2538. return obj;
  2539. }
  2540. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2541. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2542. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2543. return value;
  2544. }
  2545. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2546. if (descriptor.set) {
  2547. descriptor.set.call(receiver, value);
  2548. } else {
  2549. if (!descriptor.writable) {
  2550. throw new TypeError('attempted to set read only private field');
  2551. }
  2552. descriptor.value = value;
  2553. }
  2554. }
  2555. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2556. if (!privateSet.has(receiver)) {
  2557. throw new TypeError('attempted to get private field on non-instance');
  2558. }
  2559. return fn;
  2560. }
  2561. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2562. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2563. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2564. }
  2565. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2566. if (!privateMap.has(receiver)) {
  2567. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2568. }
  2569. return privateMap.get(receiver);
  2570. }
  2571. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2572. if (descriptor.get) {
  2573. return descriptor.get.call(receiver);
  2574. }
  2575. return descriptor.value;
  2576. }
  2577. const Reddit_defaultTasksTemplate = {
  2578. reddits: []
  2579. };
  2580. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2581. var Reddit_auth = new WeakMap();
  2582. var Reddit_initialized = new WeakMap();
  2583. var _useBeta = new WeakSet();
  2584. var Reddit_updateAuth = new WeakSet();
  2585. class Reddit extends social_Social {
  2586. constructor() {
  2587. var _GM_getValue;
  2588. super(...arguments);
  2589. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2590. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2591. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2592. Reddit_defineProperty(this, 'whiteList', {
  2593. ...JSON.parse(Reddit_defaultTasks),
  2594. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2595. });
  2596. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2597. writable: true,
  2598. value: void 0
  2599. });
  2600. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2601. writable: true,
  2602. value: false
  2603. });
  2604. }
  2605. async init() {
  2606. try {
  2607. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2608. return true;
  2609. }
  2610. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2611. if (isVerified) {
  2612. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2613. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2614. return true;
  2615. }
  2616. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2617. return false;
  2618. } catch (error) {
  2619. throwError(error, 'Reddit.init');
  2620. return false;
  2621. }
  2622. }
  2623. async toggleTask(_ref) {
  2624. let {
  2625. name,
  2626. doTask = true
  2627. } = _ref;
  2628. try {
  2629. if (!doTask && this.whiteList.reddits.includes(name)) {
  2630. scripts_echoLog({
  2631. type: 'whiteList',
  2632. text: 'Reddit.undoTask',
  2633. id: name
  2634. });
  2635. return true;
  2636. }
  2637. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2638. if (/^u_/.test(name)) {
  2639. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2640. }
  2641. const logStatus = scripts_echoLog({
  2642. type: type,
  2643. text: name
  2644. });
  2645. const {
  2646. result,
  2647. statusText,
  2648. status,
  2649. data
  2650. } = await tools_httpRequest({
  2651. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2652. method: 'POST',
  2653. headers: {
  2654. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2655. 'content-type': 'application/x-www-form-urlencoded'
  2656. },
  2657. data: $.param({
  2658. action: doTask ? 'sub' : 'unsub',
  2659. sr_name: name,
  2660. api_type: 'json'
  2661. })
  2662. });
  2663. if (result === 'Success') {
  2664. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2665. logStatus.success();
  2666. if (doTask) {
  2667. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2668. }
  2669. return true;
  2670. }
  2671. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2672. return false;
  2673. }
  2674. logStatus.error(`${result}:${statusText}(${status})`);
  2675. return false;
  2676. } catch (error) {
  2677. throwError(error, 'Reddit.toggleTask');
  2678. return false;
  2679. }
  2680. }
  2681. async toggle(_ref2) {
  2682. let {
  2683. doTask = true,
  2684. redditLinks = []
  2685. } = _ref2;
  2686. try {
  2687. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2688. scripts_echoLog({
  2689. text: i18n('needInit')
  2690. });
  2691. return false;
  2692. }
  2693. const prom = [];
  2694. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2695. scripts_echoLog({
  2696. type: 'globalOptionsSkip',
  2697. text: 'reddit.reddits'
  2698. });
  2699. } else {
  2700. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2701. var _link$match, _link$match2;
  2702. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2703. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2704. if (userName) {
  2705. return name || userName;
  2706. }
  2707. return name;
  2708. });
  2709. if (realReddits.length > 0) {
  2710. for (const name of realReddits) {
  2711. prom.push(this.toggleTask({
  2712. name: name,
  2713. doTask: doTask
  2714. }));
  2715. await delay(1e3);
  2716. }
  2717. }
  2718. }
  2719. return await Promise.all(prom).then(() => true);
  2720. } catch (error) {
  2721. throwError(error, 'Reddit.toggle');
  2722. return false;
  2723. }
  2724. }
  2725. }
  2726. async function _useBeta2() {
  2727. try {
  2728. const logStatus = scripts_echoLog({
  2729. text: i18n('changingRedditVersion')
  2730. });
  2731. GM_setValue('redditAuth', null);
  2732. return await new Promise(resolve => {
  2733. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2734. active: true,
  2735. insert: true,
  2736. setParent: true
  2737. });
  2738. newTab.onclose = async () => {
  2739. logStatus.success();
  2740. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2741. };
  2742. });
  2743. } catch (error) {
  2744. throwError(error, 'Reddit.useBeta');
  2745. return false;
  2746. }
  2747. }
  2748. async function Reddit_updateAuth2() {
  2749. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2750. try {
  2751. const logStatus = scripts_echoLog({
  2752. text: i18n('updatingAuth', 'Reddit')
  2753. });
  2754. const {
  2755. result,
  2756. statusText,
  2757. status,
  2758. data
  2759. } = await tools_httpRequest({
  2760. url: 'https://www.reddit.com/',
  2761. method: 'GET',
  2762. nochche: true,
  2763. headers: {
  2764. 'Cache-Control': 'no-cache'
  2765. }
  2766. });
  2767. if (result === 'Success') {
  2768. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2769. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2770. return false;
  2771. }
  2772. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2773. var _data$responseText$ma;
  2774. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2775. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2776. }
  2777. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2778. if (accessToken) {
  2779. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2780. token: accessToken
  2781. });
  2782. logStatus.success();
  2783. return true;
  2784. }
  2785. logStatus.error('Error: Parameter "accessToken" not found!');
  2786. return false;
  2787. }
  2788. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2789. return false;
  2790. }
  2791. logStatus.error(`${result}:${statusText}(${status})`);
  2792. return false;
  2793. } catch (error) {
  2794. throwError(error, 'Reddit.updateAuth');
  2795. return false;
  2796. }
  2797. }
  2798. const social_Reddit = Reddit;
  2799. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2800. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2801. privateSet.add(obj);
  2802. }
  2803. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2804. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2805. privateMap.set(obj, value);
  2806. }
  2807. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2808. if (privateCollection.has(obj)) {
  2809. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2810. }
  2811. }
  2812. function Twitch_defineProperty(obj, key, value) {
  2813. if (key in obj) {
  2814. Object.defineProperty(obj, key, {
  2815. value: value,
  2816. enumerable: true,
  2817. configurable: true,
  2818. writable: true
  2819. });
  2820. } else {
  2821. obj[key] = value;
  2822. }
  2823. return obj;
  2824. }
  2825. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2826. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2827. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2828. return value;
  2829. }
  2830. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2831. if (descriptor.set) {
  2832. descriptor.set.call(receiver, value);
  2833. } else {
  2834. if (!descriptor.writable) {
  2835. throw new TypeError('attempted to set read only private field');
  2836. }
  2837. descriptor.value = value;
  2838. }
  2839. }
  2840. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2841. if (!privateSet.has(receiver)) {
  2842. throw new TypeError('attempted to get private field on non-instance');
  2843. }
  2844. return fn;
  2845. }
  2846. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2847. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2848. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2849. }
  2850. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2851. if (!privateMap.has(receiver)) {
  2852. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2853. }
  2854. return privateMap.get(receiver);
  2855. }
  2856. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2857. if (descriptor.get) {
  2858. return descriptor.get.call(receiver);
  2859. }
  2860. return descriptor.value;
  2861. }
  2862. const Twitch_defaultTasksTemplate = {
  2863. channels: []
  2864. };
  2865. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2866. var Twitch_auth = new WeakMap();
  2867. var Twitch_cache = new WeakMap();
  2868. var Twitch_initialized = new WeakMap();
  2869. var Twitch_verifyAuth = new WeakSet();
  2870. var Twitch_updateAuth = new WeakSet();
  2871. var _toggleChannel = new WeakSet();
  2872. var _getChannelId = new WeakSet();
  2873. var Twitch_setCache = new WeakSet();
  2874. class Twitch extends social_Social {
  2875. constructor() {
  2876. var _GM_getValue;
  2877. super(...arguments);
  2878. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2879. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2880. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2881. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2882. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2883. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2884. Twitch_defineProperty(this, 'whiteList', {
  2885. ...JSON.parse(Twitch_defaultTasks),
  2886. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2887. });
  2888. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2889. writable: true,
  2890. value: GM_getValue('twitchAuth') || {}
  2891. });
  2892. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2893. writable: true,
  2894. value: GM_getValue('twitchCache') || {}
  2895. });
  2896. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2897. writable: true,
  2898. value: false
  2899. });
  2900. }
  2901. async init() {
  2902. try {
  2903. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2904. return true;
  2905. }
  2906. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2907. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2908. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2909. return true;
  2910. }
  2911. return false;
  2912. }
  2913. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2914. if (isVerified) {
  2915. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2916. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2917. return true;
  2918. }
  2919. GM_setValue('twitchAuth', null);
  2920. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2921. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2922. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2923. return true;
  2924. }
  2925. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2926. return false;
  2927. } catch (error) {
  2928. throwError(error, 'Twitch.init');
  2929. return false;
  2930. }
  2931. }
  2932. async toggle(_ref) {
  2933. let {
  2934. doTask = true,
  2935. channelLinks = []
  2936. } = _ref;
  2937. try {
  2938. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2939. scripts_echoLog({
  2940. text: i18n('needInit')
  2941. });
  2942. return false;
  2943. }
  2944. const prom = [];
  2945. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2946. scripts_echoLog({
  2947. type: 'globalOptionsSkip',
  2948. text: 'twitch.channels'
  2949. });
  2950. } else {
  2951. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2952. var _link$match;
  2953. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2954. });
  2955. if (realChannels.length > 0) {
  2956. for (const channel of realChannels) {
  2957. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2958. name: channel,
  2959. doTask: doTask
  2960. }));
  2961. await delay(1e3);
  2962. }
  2963. }
  2964. }
  2965. return Promise.all(prom).then(() => true);
  2966. } catch (error) {
  2967. throwError(error, 'Twitch.toggle');
  2968. return false;
  2969. }
  2970. }
  2971. }
  2972. async function Twitch_verifyAuth2() {
  2973. try {
  2974. const logStatus = scripts_echoLog({
  2975. text: i18n('verifyingAuth', 'Twitch')
  2976. });
  2977. const {
  2978. result,
  2979. statusText,
  2980. status,
  2981. data
  2982. } = await tools_httpRequest({
  2983. url: 'https://gql.twitch.tv/gql',
  2984. method: 'POST',
  2985. dataType: 'json',
  2986. headers: {
  2987. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2988. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2989. },
  2990. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2991. });
  2992. if (result === 'Success') {
  2993. var _data$response, _data$response$, _data$response$$data;
  2994. 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) {
  2995. logStatus.success();
  2996. return true;
  2997. }
  2998. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2999. return false;
  3000. }
  3001. logStatus.error(`${result}:${statusText}(${status})`);
  3002. return false;
  3003. } catch (error) {
  3004. throwError(error, 'Twitch.verifyAuth');
  3005. return false;
  3006. }
  3007. }
  3008. async function Twitch_updateAuth2() {
  3009. try {
  3010. const logStatus = scripts_echoLog({
  3011. text: i18n('updatingAuth', 'Twitch')
  3012. });
  3013. return await new Promise(resolve => {
  3014. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  3015. active: true,
  3016. insert: true,
  3017. setParent: true
  3018. });
  3019. newTab.onclose = async () => {
  3020. const auth = GM_getValue('twitchAuth');
  3021. if (auth) {
  3022. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  3023. logStatus.success();
  3024. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  3025. } else {
  3026. logStatus.error('Error: Update twitch auth failed!');
  3027. resolve(false);
  3028. }
  3029. };
  3030. });
  3031. } catch (error) {
  3032. throwError(error, 'Twitch.updateAuth');
  3033. return false;
  3034. }
  3035. }
  3036. async function _toggleChannel2(_ref2) {
  3037. let {
  3038. name,
  3039. doTask = true
  3040. } = _ref2;
  3041. try {
  3042. if (!doTask && this.whiteList.channels.includes(name)) {
  3043. scripts_echoLog({
  3044. type: 'whiteList',
  3045. text: 'Twitch.unfollowChannel',
  3046. id: name
  3047. });
  3048. return true;
  3049. }
  3050. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  3051. if (!channelId) {
  3052. return false;
  3053. }
  3054. const logStatus = scripts_echoLog({
  3055. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  3056. text: name
  3057. });
  3058. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  3059. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  3060. const {
  3061. result,
  3062. statusText,
  3063. status,
  3064. data
  3065. } = await tools_httpRequest({
  3066. url: 'https://gql.twitch.tv/gql',
  3067. method: 'POST',
  3068. dataType: 'json',
  3069. headers: {
  3070. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  3071. },
  3072. data: doTask ? followData : unfollowData
  3073. });
  3074. if (result === 'Success') {
  3075. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3076. logStatus.success();
  3077. if (doTask) {
  3078. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3079. }
  3080. return true;
  3081. }
  3082. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3083. return false;
  3084. }
  3085. logStatus.error(`${result}:${statusText}(${status})`);
  3086. return false;
  3087. } catch (error) {
  3088. throwError(error, 'Twitch.toggleChannel');
  3089. return false;
  3090. }
  3091. }
  3092. async function _getChannelId2(name) {
  3093. try {
  3094. const logStatus = scripts_echoLog({
  3095. type: 'gettingTwitchChannelId',
  3096. text: name
  3097. });
  3098. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3099. if (channelId) {
  3100. logStatus.success();
  3101. return channelId;
  3102. }
  3103. const {
  3104. result,
  3105. statusText,
  3106. status,
  3107. data
  3108. } = await tools_httpRequest({
  3109. url: 'https://gql.twitch.tv/gql',
  3110. method: 'POST',
  3111. headers: {
  3112. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3113. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3114. },
  3115. responseType: 'json',
  3116. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3117. });
  3118. if (result === 'Success') {
  3119. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3120. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3121. 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);
  3122. if (channelId) {
  3123. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3124. logStatus.success();
  3125. return channelId;
  3126. }
  3127. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3128. return false;
  3129. }
  3130. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3131. return false;
  3132. }
  3133. logStatus.error(`${result}:${statusText}(${status})`);
  3134. return false;
  3135. } catch (error) {
  3136. throwError(error, 'Twitch.getChannelId');
  3137. return false;
  3138. }
  3139. }
  3140. function Twitch_setCache2(name, id) {
  3141. try {
  3142. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3143. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3144. } catch (error) {
  3145. throwError(error, 'Twitch.setCache');
  3146. }
  3147. }
  3148. const social_Twitch = Twitch;
  3149. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3150. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3151. privateSet.add(obj);
  3152. }
  3153. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3154. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3155. privateMap.set(obj, value);
  3156. }
  3157. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3158. if (privateCollection.has(obj)) {
  3159. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3160. }
  3161. }
  3162. function Twitter_defineProperty(obj, key, value) {
  3163. if (key in obj) {
  3164. Object.defineProperty(obj, key, {
  3165. value: value,
  3166. enumerable: true,
  3167. configurable: true,
  3168. writable: true
  3169. });
  3170. } else {
  3171. obj[key] = value;
  3172. }
  3173. return obj;
  3174. }
  3175. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3176. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3177. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3178. return value;
  3179. }
  3180. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3181. if (descriptor.set) {
  3182. descriptor.set.call(receiver, value);
  3183. } else {
  3184. if (!descriptor.writable) {
  3185. throw new TypeError('attempted to set read only private field');
  3186. }
  3187. descriptor.value = value;
  3188. }
  3189. }
  3190. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3191. if (!privateSet.has(receiver)) {
  3192. throw new TypeError('attempted to get private field on non-instance');
  3193. }
  3194. return fn;
  3195. }
  3196. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3197. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3198. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3199. }
  3200. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3201. if (!privateMap.has(receiver)) {
  3202. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3203. }
  3204. return privateMap.get(receiver);
  3205. }
  3206. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3207. if (descriptor.get) {
  3208. return descriptor.get.call(receiver);
  3209. }
  3210. return descriptor.value;
  3211. }
  3212. const Twitter_defaultTasksTemplate = {
  3213. users: [],
  3214. retweets: [],
  3215. likes: []
  3216. };
  3217. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3218. var _verifyId = new WeakMap();
  3219. var Twitter_auth = new WeakMap();
  3220. var Twitter_cache = new WeakMap();
  3221. var Twitter_initialized = new WeakMap();
  3222. var Twitter_verifyAuth = new WeakSet();
  3223. var Twitter_updateAuth = new WeakSet();
  3224. var _toggleUser = new WeakSet();
  3225. var _toggleRetweet = new WeakSet();
  3226. var Twitter_setCache = new WeakSet();
  3227. class Twitter extends social_Social {
  3228. constructor() {
  3229. var _GM_getValue;
  3230. super(...arguments);
  3231. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3232. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3233. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3234. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3235. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3236. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3237. Twitter_defineProperty(this, 'whiteList', {
  3238. ...JSON.parse(Twitter_defaultTasks),
  3239. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3240. });
  3241. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3242. writable: true,
  3243. value: globalOptions.other.twitterVerifyId
  3244. });
  3245. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3246. writable: true,
  3247. value: GM_getValue('twitterAuth') || {}
  3248. });
  3249. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3250. writable: true,
  3251. value: GM_getValue('twitterCache') || {}
  3252. });
  3253. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3254. writable: true,
  3255. value: false
  3256. });
  3257. }
  3258. async init() {
  3259. try {
  3260. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3261. return true;
  3262. }
  3263. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3264. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3265. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3266. return true;
  3267. }
  3268. return false;
  3269. }
  3270. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3271. if (isVerified) {
  3272. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3273. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3274. return true;
  3275. }
  3276. GM_setValue('twitterAuth', null);
  3277. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3278. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3279. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3280. return true;
  3281. }
  3282. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3283. return false;
  3284. } catch (error) {
  3285. throwError(error, 'Twitter.init');
  3286. return false;
  3287. }
  3288. }
  3289. async userName2id(name) {
  3290. try {
  3291. const logStatus = scripts_echoLog({
  3292. type: 'gettingTwitterUserId',
  3293. text: name
  3294. });
  3295. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3296. if (userId) {
  3297. logStatus.success();
  3298. return userId;
  3299. }
  3300. const {
  3301. result,
  3302. statusText,
  3303. status,
  3304. data
  3305. } = await tools_httpRequest({
  3306. 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`,
  3307. method: 'GET',
  3308. headers: {
  3309. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3310. 'content-type': 'application/json',
  3311. referer: `https://twitter.com/${name}`,
  3312. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3313. },
  3314. responseType: 'json'
  3315. });
  3316. if (result === 'Success') {
  3317. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3318. var _response, _response$data, _response$data$user, _response$data$user$r;
  3319. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3320. if (!response) {
  3321. try {
  3322. response = JSON.parse(data.responseText);
  3323. } catch (error) {
  3324. response = null;
  3325. }
  3326. }
  3327. 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);
  3328. if (userId) {
  3329. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3330. logStatus.success();
  3331. return userId;
  3332. }
  3333. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3334. return false;
  3335. }
  3336. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3337. return false;
  3338. }
  3339. logStatus.error(`${result}:${statusText}(${status})`);
  3340. return false;
  3341. } catch (error) {
  3342. throwError(error, 'Twitter.getUserId');
  3343. return false;
  3344. }
  3345. }
  3346. async toggle(_ref) {
  3347. let {
  3348. doTask = true,
  3349. userLinks = [],
  3350. retweetLinks = []
  3351. } = _ref;
  3352. try {
  3353. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3354. scripts_echoLog({
  3355. text: i18n('needInit')
  3356. });
  3357. return false;
  3358. }
  3359. const prom = [];
  3360. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3361. scripts_echoLog({
  3362. type: 'globalOptionsSkip',
  3363. text: 'twitter.users'
  3364. });
  3365. } else {
  3366. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3367. var _link$match;
  3368. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3369. });
  3370. if (realUsers.length > 0) {
  3371. for (const user of realUsers) {
  3372. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3373. name: user,
  3374. doTask: doTask
  3375. }));
  3376. await delay(1e3);
  3377. }
  3378. }
  3379. }
  3380. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3381. scripts_echoLog({
  3382. type: 'globalOptionsSkip',
  3383. text: 'twitter.retweets'
  3384. });
  3385. } else {
  3386. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3387. var _link$match2;
  3388. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3389. });
  3390. if (realRetweets.length > 0) {
  3391. for (const retweet of realRetweets) {
  3392. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3393. retweetId: retweet,
  3394. doTask: doTask
  3395. }));
  3396. await delay(1e3);
  3397. }
  3398. }
  3399. }
  3400. return Promise.all(prom).then(() => true);
  3401. } catch (error) {
  3402. throwError(error, 'Twitter.toggle');
  3403. return false;
  3404. }
  3405. }
  3406. }
  3407. async function Twitter_verifyAuth2() {
  3408. try {
  3409. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3410. name: 'verify',
  3411. doTask: true,
  3412. verify: true
  3413. });
  3414. } catch (error) {
  3415. throwError(error, 'Twitter.verifyAuth');
  3416. return false;
  3417. }
  3418. }
  3419. async function Twitter_updateAuth2() {
  3420. try {
  3421. const logStatus = scripts_echoLog({
  3422. text: i18n('updatingAuth', 'Twitter')
  3423. });
  3424. return await new Promise(resolve => {
  3425. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3426. active: true,
  3427. insert: true,
  3428. setParent: true
  3429. });
  3430. newTab.onclose = async () => {
  3431. const auth = GM_getValue('twitterAuth');
  3432. if (auth) {
  3433. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3434. logStatus.success();
  3435. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3436. } else {
  3437. logStatus.error('Error: Update twitter auth failed!');
  3438. resolve(false);
  3439. }
  3440. };
  3441. });
  3442. } catch (error) {
  3443. throwError(error, 'Twitter.updateToken');
  3444. return false;
  3445. }
  3446. }
  3447. async function _toggleUser2(_ref2) {
  3448. let {
  3449. name,
  3450. doTask = true,
  3451. verify = false
  3452. } = _ref2;
  3453. try {
  3454. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3455. scripts_echoLog({
  3456. type: 'whiteList',
  3457. text: 'Twitter.unfollowUser',
  3458. id: name
  3459. });
  3460. return true;
  3461. }
  3462. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3463. if (!userId) {
  3464. return false;
  3465. }
  3466. const logStatus = verify ? scripts_echoLog({
  3467. text: i18n('verifyingAuth', 'Twitter')
  3468. }) : scripts_echoLog({
  3469. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3470. text: name
  3471. });
  3472. const {
  3473. result,
  3474. statusText,
  3475. status,
  3476. data
  3477. } = await tools_httpRequest({
  3478. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3479. method: 'POST',
  3480. headers: {
  3481. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3482. 'Content-Type': 'application/x-www-form-urlencoded',
  3483. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3484. },
  3485. responseType: 'json',
  3486. data: $.param({
  3487. include_profile_interstitial_type: 1,
  3488. include_blocking: 1,
  3489. include_blocked_by: 1,
  3490. include_followed_by: 1,
  3491. include_want_retweets: 1,
  3492. include_mute_edge: 1,
  3493. include_can_dm: 1,
  3494. include_can_media_tag: 1,
  3495. skip_status: 1,
  3496. id: userId
  3497. })
  3498. });
  3499. if (result === 'Success') {
  3500. var _data$response, _data$response$errors, _data$response$errors2;
  3501. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3502. logStatus.success();
  3503. if (doTask && !verify) {
  3504. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3505. }
  3506. return true;
  3507. }
  3508. 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) {
  3509. logStatus.success();
  3510. return true;
  3511. }
  3512. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3513. return false;
  3514. }
  3515. logStatus.error(`${result}:${statusText}(${status})`);
  3516. return false;
  3517. } catch (error) {
  3518. throwError(error, 'Twitter.toggleUser');
  3519. return false;
  3520. }
  3521. }
  3522. async function _toggleRetweet2(_ref3) {
  3523. let {
  3524. retweetId,
  3525. doTask = true
  3526. } = _ref3;
  3527. try {
  3528. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3529. scripts_echoLog({
  3530. type: 'whiteList',
  3531. text: 'Twitter.unretweet',
  3532. id: retweetId
  3533. });
  3534. return true;
  3535. }
  3536. const logStatus = scripts_echoLog({
  3537. type: `${doTask ? '' : 'un'}retweetting`,
  3538. text: retweetId
  3539. });
  3540. const {
  3541. result,
  3542. statusText,
  3543. status,
  3544. data
  3545. } = await tools_httpRequest({
  3546. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3547. method: 'POST',
  3548. headers: {
  3549. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3550. 'Content-Type': 'application/x-www-form-urlencoded',
  3551. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3552. },
  3553. data: $.param({
  3554. tweet_mode: 'extended',
  3555. id: retweetId
  3556. }),
  3557. responseType: 'json'
  3558. });
  3559. if (result === 'Success') {
  3560. var _data$response2, _data$response2$error, _data$response2$error2;
  3561. 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) {
  3562. logStatus.success();
  3563. if (doTask) {
  3564. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3565. }
  3566. return true;
  3567. }
  3568. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3569. return false;
  3570. }
  3571. logStatus.error(`${result}:${statusText}(${status})`);
  3572. return false;
  3573. } catch (error) {
  3574. throwError(error, 'Twitter.toggleRetweet');
  3575. return false;
  3576. }
  3577. }
  3578. function Twitter_setCache2(name, id) {
  3579. try {
  3580. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3581. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3582. } catch (error) {
  3583. throwError(error, 'Twitter.setCache');
  3584. }
  3585. }
  3586. const social_Twitter = Twitter;
  3587. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3588. Vk_checkPrivateRedeclaration(obj, privateSet);
  3589. privateSet.add(obj);
  3590. }
  3591. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3592. Vk_checkPrivateRedeclaration(obj, privateMap);
  3593. privateMap.set(obj, value);
  3594. }
  3595. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3596. if (privateCollection.has(obj)) {
  3597. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3598. }
  3599. }
  3600. function Vk_defineProperty(obj, key, value) {
  3601. if (key in obj) {
  3602. Object.defineProperty(obj, key, {
  3603. value: value,
  3604. enumerable: true,
  3605. configurable: true,
  3606. writable: true
  3607. });
  3608. } else {
  3609. obj[key] = value;
  3610. }
  3611. return obj;
  3612. }
  3613. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3614. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3615. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3616. return value;
  3617. }
  3618. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3619. if (descriptor.set) {
  3620. descriptor.set.call(receiver, value);
  3621. } else {
  3622. if (!descriptor.writable) {
  3623. throw new TypeError('attempted to set read only private field');
  3624. }
  3625. descriptor.value = value;
  3626. }
  3627. }
  3628. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3629. if (!privateSet.has(receiver)) {
  3630. throw new TypeError('attempted to get private field on non-instance');
  3631. }
  3632. return fn;
  3633. }
  3634. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3635. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3636. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3637. }
  3638. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3639. if (!privateMap.has(receiver)) {
  3640. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3641. }
  3642. return privateMap.get(receiver);
  3643. }
  3644. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3645. if (descriptor.get) {
  3646. return descriptor.get.call(receiver);
  3647. }
  3648. return descriptor.value;
  3649. }
  3650. const Vk_defaultTasksTemplate = {
  3651. names: []
  3652. };
  3653. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3654. var _username = new WeakMap();
  3655. var Vk_cache = new WeakMap();
  3656. var Vk_initialized = new WeakMap();
  3657. var Vk_verifyAuth = new WeakSet();
  3658. var _toggleGroup = new WeakSet();
  3659. var _togglePublic = new WeakSet();
  3660. var _sendWall = new WeakSet();
  3661. var _deleteWall = new WeakSet();
  3662. var _getId = new WeakSet();
  3663. var _toggleVk = new WeakSet();
  3664. var Vk_setCache = new WeakSet();
  3665. class Vk extends social_Social {
  3666. constructor() {
  3667. var _GM_getValue;
  3668. super(...arguments);
  3669. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3670. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3671. Vk_classPrivateMethodInitSpec(this, _getId);
  3672. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3673. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3674. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3675. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3676. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3677. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3678. Vk_defineProperty(this, 'whiteList', {
  3679. ...JSON.parse(Vk_defaultTasks),
  3680. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3681. });
  3682. Vk_classPrivateFieldInitSpec(this, _username, {
  3683. writable: true,
  3684. value: ''
  3685. });
  3686. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3687. writable: true,
  3688. value: GM_getValue('vkCache') || {}
  3689. });
  3690. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3691. writable: true,
  3692. value: false
  3693. });
  3694. }
  3695. async init() {
  3696. try {
  3697. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3698. return true;
  3699. }
  3700. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3701. if (isVerified) {
  3702. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3703. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3704. return true;
  3705. }
  3706. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3707. return false;
  3708. } catch (error) {
  3709. throwError(error, 'Vk.init');
  3710. return false;
  3711. }
  3712. }
  3713. async toggle(_ref) {
  3714. let {
  3715. doTask = true,
  3716. nameLinks = []
  3717. } = _ref;
  3718. try {
  3719. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3720. scripts_echoLog({
  3721. text: i18n('needInit')
  3722. });
  3723. return false;
  3724. }
  3725. const prom = [];
  3726. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3727. scripts_echoLog({
  3728. type: 'globalOptionsSkip',
  3729. text: 'vk.names'
  3730. });
  3731. } else {
  3732. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3733. var _link$match;
  3734. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3735. });
  3736. if (realNames.length > 0) {
  3737. for (const name of realNames) {
  3738. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3739. name: name,
  3740. doTask: doTask
  3741. }));
  3742. await delay(1e3);
  3743. }
  3744. }
  3745. }
  3746. return Promise.all(prom).then(() => true);
  3747. } catch (error) {
  3748. throwError(error, 'Vk.toggle');
  3749. return false;
  3750. }
  3751. }
  3752. }
  3753. async function Vk_verifyAuth2() {
  3754. try {
  3755. const logStatus = scripts_echoLog({
  3756. text: i18n('verifyAuth', 'Vk')
  3757. });
  3758. const {
  3759. result,
  3760. statusText,
  3761. status,
  3762. data
  3763. } = await tools_httpRequest({
  3764. url: 'https://vk.com/im',
  3765. method: 'GET'
  3766. });
  3767. if (result === 'Success') {
  3768. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3769. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3770. return false;
  3771. }
  3772. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3773. var _data$responseText$ma;
  3774. 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]) || '');
  3775. logStatus.success();
  3776. return true;
  3777. }
  3778. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3779. return false;
  3780. }
  3781. logStatus.error(`${result}:${statusText}(${status})`);
  3782. return false;
  3783. } catch (error) {
  3784. throwError(error, 'Vk.verifyAuth');
  3785. return false;
  3786. }
  3787. }
  3788. async function _toggleGroup2(name, dataParam) {
  3789. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3790. try {
  3791. const logStatus = scripts_echoLog({
  3792. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3793. text: name
  3794. });
  3795. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3796. logStatus.success();
  3797. return true;
  3798. }
  3799. const reqData = {
  3800. act: doTask ? 'enter' : 'leave',
  3801. al: 1,
  3802. gid: dataParam.groupId,
  3803. hash: dataParam.groupHash
  3804. };
  3805. if (doTask) {
  3806. reqData.context = '_';
  3807. }
  3808. const {
  3809. result,
  3810. statusText,
  3811. status,
  3812. data
  3813. } = await tools_httpRequest({
  3814. url: 'https://vk.com/al_groups.php',
  3815. method: 'POST',
  3816. headers: {
  3817. origin: 'https://vk.com',
  3818. referer: `https://vk.com/${name}`,
  3819. 'content-type': 'application/x-www-form-urlencoded'
  3820. },
  3821. data: $.param(reqData)
  3822. });
  3823. if (result === 'Success') {
  3824. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3825. logStatus.success();
  3826. if (doTask) {
  3827. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3828. }
  3829. return true;
  3830. }
  3831. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3832. return false;
  3833. }
  3834. logStatus.error(`${result}:${statusText}(${status})`);
  3835. return false;
  3836. } catch (error) {
  3837. throwError(error, 'Vk.toggleGroup');
  3838. return false;
  3839. }
  3840. }
  3841. async function _togglePublic2(name, dataParam) {
  3842. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3843. try {
  3844. const logStatus = scripts_echoLog({
  3845. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3846. text: name
  3847. });
  3848. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3849. logStatus.success();
  3850. return true;
  3851. }
  3852. const {
  3853. result,
  3854. statusText,
  3855. status,
  3856. data
  3857. } = await tools_httpRequest({
  3858. url: 'https://vk.com/al_public.php',
  3859. method: 'POST',
  3860. headers: {
  3861. origin: 'https://vk.com',
  3862. referer: `https://vk.com/${name}`,
  3863. 'content-type': 'application/x-www-form-urlencoded'
  3864. },
  3865. data: $.param({
  3866. act: doTask ? 'a_enter' : 'a_leave',
  3867. al: 1,
  3868. pid: dataParam.publicPid,
  3869. hash: dataParam.publicHash
  3870. })
  3871. });
  3872. if (result === 'Success') {
  3873. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3874. logStatus.success();
  3875. if (doTask) {
  3876. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3877. }
  3878. return true;
  3879. }
  3880. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3881. return false;
  3882. }
  3883. logStatus.error(`${result}:${statusText}(${status})`);
  3884. return false;
  3885. } catch (error) {
  3886. throwError(error, 'Vk.togglePublic');
  3887. return false;
  3888. }
  3889. }
  3890. async function _sendWall2(name) {
  3891. try {
  3892. const logStatus = scripts_echoLog({
  3893. type: 'sendingVkWall',
  3894. text: name
  3895. });
  3896. const {
  3897. result,
  3898. statusText,
  3899. status,
  3900. data
  3901. } = await tools_httpRequest({
  3902. url: 'https://vk.com/like.php',
  3903. method: 'POST',
  3904. headers: {
  3905. origin: 'https://vk.com',
  3906. referer: `https://vk.com/${name}`,
  3907. 'content-type': 'application/x-www-form-urlencoded'
  3908. },
  3909. data: $.param({
  3910. act: 'publish_box',
  3911. al: 1,
  3912. object: name
  3913. })
  3914. });
  3915. if (result === 'Success') {
  3916. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3917. var _data$responseText$ma2;
  3918. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3919. if (hash) {
  3920. const {
  3921. result: resultR,
  3922. statusText: statusTextR,
  3923. status: statusR,
  3924. data: dataR
  3925. } = await tools_httpRequest({
  3926. url: 'https://vk.com/like.php',
  3927. method: 'POST',
  3928. headers: {
  3929. origin: 'https://vk.com',
  3930. referer: `https://vk.com/${name}`,
  3931. 'content-type': 'application/x-www-form-urlencoded'
  3932. },
  3933. data: $.param({
  3934. Message: '',
  3935. act: 'a_do_publish',
  3936. al: 1,
  3937. close_comments: 0,
  3938. friends_only: 0,
  3939. from: 'box',
  3940. hash: hash,
  3941. list: '',
  3942. mark_as_ads: 0,
  3943. mute_notifications: 0,
  3944. object: name,
  3945. ret_data: 1,
  3946. to: 0
  3947. })
  3948. });
  3949. if (resultR === 'Success') {
  3950. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3951. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3952. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3953. 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) {
  3954. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3955. logStatus.success();
  3956. 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);
  3957. 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);
  3958. if (postId && ownerId) {
  3959. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3960. }
  3961. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3962. return true;
  3963. }
  3964. }
  3965. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3966. return false;
  3967. }
  3968. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3969. return false;
  3970. }
  3971. logStatus.error('Error: Get "hash" failed');
  3972. return false;
  3973. }
  3974. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3975. return false;
  3976. }
  3977. logStatus.error(`${result}:${statusText}(${status})`);
  3978. return false;
  3979. } catch (error) {
  3980. throwError(error, 'Vk.sendWall');
  3981. return false;
  3982. }
  3983. }
  3984. async function _deleteWall2(name, dataParams) {
  3985. try {
  3986. const logStatus = scripts_echoLog({
  3987. type: 'deletingVkWall',
  3988. text: name
  3989. });
  3990. const {
  3991. result,
  3992. statusText,
  3993. status,
  3994. data
  3995. } = await tools_httpRequest({
  3996. url: 'https://vk.com/al_wall.php?act=delete',
  3997. method: 'POST',
  3998. headers: {
  3999. origin: 'https://vk.com',
  4000. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  4001. 'content-type': 'application/x-www-form-urlencoded'
  4002. },
  4003. data: $.param({
  4004. act: 'delete',
  4005. al: 1,
  4006. confirm: 0,
  4007. from: 'wkview',
  4008. hash: dataParams.wallHash,
  4009. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  4010. })
  4011. });
  4012. if (result === 'Success') {
  4013. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4014. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  4015. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  4016. 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]) {
  4017. logStatus.success();
  4018. return true;
  4019. }
  4020. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4021. return false;
  4022. }
  4023. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4024. return false;
  4025. }
  4026. logStatus.error(`${result}:${statusText}(${status})`);
  4027. return false;
  4028. } catch (error) {
  4029. throwError(error, 'Vk.deleteWall');
  4030. return false;
  4031. }
  4032. }
  4033. async function _getId2(name, doTask) {
  4034. try {
  4035. let url = `https://vk.com/${name}`;
  4036. if (/^wall-/.test(name)) {
  4037. if (doTask) {
  4038. return {
  4039. type: 'sendWall'
  4040. };
  4041. }
  4042. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  4043. return {
  4044. type: 'unSupport'
  4045. };
  4046. }
  4047. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  4048. }
  4049. const logStatus = scripts_echoLog({
  4050. type: 'gettingVkId',
  4051. text: name
  4052. });
  4053. const {
  4054. result,
  4055. statusText,
  4056. status,
  4057. data
  4058. } = await tools_httpRequest({
  4059. url: url,
  4060. method: 'GET'
  4061. });
  4062. if (result === 'Success') {
  4063. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4064. var _data$responseText$ma3, _data$responseText$ma4;
  4065. const [ , groupAct, groupId, , groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), (&#39;|')(.*?)(&#39;|')/) || [];
  4066. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4067. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4068. const publicJoined = !data.responseText.includes('Public.subscribe');
  4069. if (groupAct && groupId && groupHash) {
  4070. logStatus.success();
  4071. return {
  4072. groupAct: groupAct,
  4073. groupId: groupId,
  4074. groupHash: groupHash,
  4075. type: 'group'
  4076. };
  4077. } else if (publicHash && publicPid) {
  4078. logStatus.success();
  4079. return {
  4080. publicHash: publicHash,
  4081. publicPid: publicPid,
  4082. publicJoined: publicJoined,
  4083. type: 'public'
  4084. };
  4085. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4086. var _data$responseText$ma5;
  4087. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4088. if (wallHash) {
  4089. logStatus.success();
  4090. return {
  4091. type: 'deleteWall',
  4092. wallHash: wallHash
  4093. };
  4094. }
  4095. } else if (name.includes('wall') && doTask) {
  4096. logStatus.success();
  4097. return {
  4098. type: 'sendWall'
  4099. };
  4100. }
  4101. logStatus.error('Error: Parameters not found!');
  4102. return false;
  4103. }
  4104. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4105. return false;
  4106. }
  4107. logStatus.error(`${result}:${statusText}(${status})`);
  4108. return false;
  4109. } catch (error) {
  4110. throwError(error, 'Vk.getId');
  4111. return false;
  4112. }
  4113. }
  4114. async function _toggleVk2(_ref2) {
  4115. let {
  4116. name,
  4117. doTask = true
  4118. } = _ref2;
  4119. try {
  4120. if (!doTask && this.whiteList.names.includes(name)) {
  4121. scripts_echoLog({
  4122. type: 'whiteList',
  4123. text: 'Vk.undoTask',
  4124. id: name
  4125. });
  4126. return true;
  4127. }
  4128. const formatName = name.replace(/\/$/, '');
  4129. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4130. if (!data) {
  4131. return false;
  4132. }
  4133. switch (data.type) {
  4134. case 'group':
  4135. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4136.  
  4137. case 'public':
  4138. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4139.  
  4140. case 'sendWall':
  4141. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4142.  
  4143. case 'deleteWall':
  4144. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4145.  
  4146. default:
  4147. return false;
  4148. }
  4149. } catch (error) {
  4150. throwError(error, 'Vk.toggleVk');
  4151. return false;
  4152. }
  4153. }
  4154. function Vk_setCache2(name, postId) {
  4155. try {
  4156. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4157. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4158. } catch (error) {
  4159. throwError(error, 'Vk.setCache');
  4160. }
  4161. }
  4162. const social_Vk = Vk;
  4163. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4164. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4165. privateSet.add(obj);
  4166. }
  4167. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4168. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4169. privateMap.set(obj, value);
  4170. }
  4171. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4172. if (privateCollection.has(obj)) {
  4173. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4174. }
  4175. }
  4176. function Youtube_defineProperty(obj, key, value) {
  4177. if (key in obj) {
  4178. Object.defineProperty(obj, key, {
  4179. value: value,
  4180. enumerable: true,
  4181. configurable: true,
  4182. writable: true
  4183. });
  4184. } else {
  4185. obj[key] = value;
  4186. }
  4187. return obj;
  4188. }
  4189. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4190. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4191. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4192. return value;
  4193. }
  4194. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4195. if (descriptor.set) {
  4196. descriptor.set.call(receiver, value);
  4197. } else {
  4198. if (!descriptor.writable) {
  4199. throw new TypeError('attempted to set read only private field');
  4200. }
  4201. descriptor.value = value;
  4202. }
  4203. }
  4204. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4205. if (!privateSet.has(receiver)) {
  4206. throw new TypeError('attempted to get private field on non-instance');
  4207. }
  4208. return fn;
  4209. }
  4210. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4211. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4212. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4213. }
  4214. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4215. if (!privateMap.has(receiver)) {
  4216. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4217. }
  4218. return privateMap.get(receiver);
  4219. }
  4220. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4221. if (descriptor.get) {
  4222. return descriptor.get.call(receiver);
  4223. }
  4224. return descriptor.value;
  4225. }
  4226. const Youtube_defaultTasksTemplate = {
  4227. channels: [],
  4228. likes: []
  4229. };
  4230. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4231. const getInfo = async function(link, type) {
  4232. try {
  4233. const logStatus = scripts_echoLog({
  4234. text: i18n('gettingYtbToken')
  4235. });
  4236. const {
  4237. result,
  4238. statusText,
  4239. status,
  4240. data
  4241. } = await tools_httpRequest({
  4242. url: link,
  4243. method: 'GET'
  4244. });
  4245. if (result === 'Success') {
  4246. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4247. var _data$responseText$ma, _ref;
  4248. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4249. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4250. return {
  4251. needLogin: true
  4252. };
  4253. }
  4254. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4255. 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]) || '{}';
  4256. const {
  4257. client,
  4258. request
  4259. } = JSON.parse(context);
  4260. if (apiKey && client && request) {
  4261. client.hl = 'en';
  4262. if (type === 'channel') {
  4263. var _data$responseText$ma2;
  4264. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4265. if (channelId) {
  4266. logStatus.success();
  4267. return {
  4268. params: {
  4269. apiKey: apiKey,
  4270. client: client,
  4271. request: request,
  4272. channelId: channelId
  4273. }
  4274. };
  4275. }
  4276. logStatus.error('Error: Get "channelId" failed!');
  4277. return {};
  4278. } else if (type === 'likeVideo') {
  4279. var _data$responseText$ma3, _data$responseText$ma4;
  4280. 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];
  4281. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4282. if (videoId) {
  4283. logStatus.success();
  4284. return {
  4285. params: {
  4286. apiKey: apiKey,
  4287. client: client,
  4288. request: request,
  4289. videoId: videoId,
  4290. likeParams: likeParams
  4291. }
  4292. };
  4293. }
  4294. logStatus.error('Error: Get "videoId" failed!');
  4295. return {};
  4296. }
  4297. logStatus.error('Error: Unknown type');
  4298. return {};
  4299. }
  4300. logStatus.error('Error: Parameter "apiKey" not found!');
  4301. return {};
  4302. }
  4303. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4304. return {};
  4305. }
  4306. logStatus.error(`${result}:${statusText}(${status})`);
  4307. return {};
  4308. } catch (error) {
  4309. throwError(error, 'Youtube.getInfo');
  4310. return {};
  4311. }
  4312. };
  4313. var Youtube_auth = new WeakMap();
  4314. var Youtube_initialized = new WeakMap();
  4315. var _verifyChannel = new WeakMap();
  4316. var Youtube_verifyAuth = new WeakSet();
  4317. var Youtube_updateAuth = new WeakSet();
  4318. var _getInfo = new WeakSet();
  4319. var Youtube_toggleChannel = new WeakSet();
  4320. var _toggleLikeVideo = new WeakSet();
  4321. class Youtube extends social_Social {
  4322. constructor() {
  4323. var _GM_getValue;
  4324. super(...arguments);
  4325. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4326. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4327. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4328. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4329. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4330. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4331. Youtube_defineProperty(this, 'whiteList', {
  4332. ...JSON.parse(Youtube_defaultTasks),
  4333. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4334. });
  4335. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4336. writable: true,
  4337. value: GM_getValue('youtubeAuth') || {}
  4338. });
  4339. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4340. writable: true,
  4341. value: false
  4342. });
  4343. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4344. writable: true,
  4345. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4346. });
  4347. }
  4348. async init() {
  4349. try {
  4350. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4351. return true;
  4352. }
  4353. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4354. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4355. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4356. return true;
  4357. }
  4358. return false;
  4359. }
  4360. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4361. if (isVerified) {
  4362. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4363. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4364. return true;
  4365. }
  4366. GM_setValue('youtubeAuth', null);
  4367. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4368. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4369. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4370. return true;
  4371. }
  4372. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4373. return false;
  4374. } catch (error) {
  4375. throwError(error, 'Youtube.init');
  4376. return false;
  4377. }
  4378. }
  4379. async toggle(_ref2) {
  4380. let {
  4381. doTask = true,
  4382. channelLinks = [],
  4383. videoLinks = []
  4384. } = _ref2;
  4385. try {
  4386. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4387. scripts_echoLog({
  4388. text: i18n('needInit')
  4389. });
  4390. return false;
  4391. }
  4392. const prom = [];
  4393. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4394. scripts_echoLog({
  4395. type: 'globalOptionsSkip',
  4396. text: 'youtube.channels'
  4397. });
  4398. } else {
  4399. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4400. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4401. var _link$match;
  4402. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4403. }
  4404. return link;
  4405. });
  4406. if (realChannels.length > 0) {
  4407. for (const channel of realChannels) {
  4408. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4409. link: channel,
  4410. doTask: doTask
  4411. }));
  4412. await delay(1e3);
  4413. }
  4414. }
  4415. }
  4416. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4417. scripts_echoLog({
  4418. type: 'globalOptionsSkip',
  4419. text: 'youtube.likes'
  4420. });
  4421. } else {
  4422. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4423. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4424. var _link$match2;
  4425. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4426. }
  4427. return link;
  4428. });
  4429. if (realLikes.length > 0) {
  4430. for (const video of realLikes) {
  4431. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4432. link: video,
  4433. doTask: doTask
  4434. }));
  4435. await delay(1e3);
  4436. }
  4437. }
  4438. }
  4439. return Promise.all(prom).then(() => true);
  4440. } catch (error) {
  4441. throwError(error, 'Youtube.toggle');
  4442. return false;
  4443. }
  4444. }
  4445. }
  4446. async function Youtube_verifyAuth2() {
  4447. try {
  4448. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4449. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4450. doTask: true,
  4451. verify: true
  4452. });
  4453. } catch (error) {
  4454. throwError(error, 'Youtube.verifyAuth');
  4455. return false;
  4456. }
  4457. }
  4458. async function Youtube_updateAuth2() {
  4459. try {
  4460. const logStatus = scripts_echoLog({
  4461. text: i18n('updatingAuth', 'Youtube')
  4462. });
  4463. return await new Promise(resolve => {
  4464. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4465. active: true,
  4466. insert: true,
  4467. setParent: true
  4468. });
  4469. newTab.onclose = async () => {
  4470. const auth = GM_getValue('youtubeAuth');
  4471. if (auth) {
  4472. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4473. logStatus.success();
  4474. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4475. resolve(result);
  4476. });
  4477. } else {
  4478. logStatus.error('Error: Update youtube auth failed!');
  4479. resolve(false);
  4480. }
  4481. };
  4482. });
  4483. } catch (error) {
  4484. throwError(error, 'Discord.updateAuth');
  4485. return false;
  4486. }
  4487. }
  4488. function _getInfo2(link, type) {
  4489. return getInfo(link, type);
  4490. }
  4491. async function Youtube_toggleChannel2(_ref3) {
  4492. let {
  4493. link,
  4494. doTask = true,
  4495. verify = false
  4496. } = _ref3;
  4497. try {
  4498. const {
  4499. params,
  4500. needLogin
  4501. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4502. const {
  4503. apiKey,
  4504. client,
  4505. request,
  4506. channelId
  4507. } = params || {};
  4508. if (needLogin) {
  4509. scripts_echoLog({
  4510. html: i18n('loginYtb')
  4511. });
  4512. return false;
  4513. }
  4514. if (!(apiKey && client && request && channelId)) {
  4515. scripts_echoLog({
  4516. text: '"getYtbToken" failed'
  4517. });
  4518. return false;
  4519. }
  4520. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4521. scripts_echoLog({
  4522. type: 'whiteList',
  4523. text: 'Youtube.unfollowChannel',
  4524. id: channelId
  4525. });
  4526. return true;
  4527. }
  4528. const logStatus = verify ? scripts_echoLog({
  4529. text: i18n('verifyingAuth', 'Youtube')
  4530. }) : scripts_echoLog({
  4531. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4532. text: channelId
  4533. });
  4534. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4535. const {
  4536. result,
  4537. statusText,
  4538. status,
  4539. data
  4540. } = await tools_httpRequest({
  4541. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4542. method: 'POST',
  4543. headers: {
  4544. origin: 'https://www.youtube.com',
  4545. referer: `https://www.youtube.com/channel/${channelId}`,
  4546. 'content-type': 'application/json',
  4547. 'x-goog-authuser': '0',
  4548. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4549. 'x-origin': 'https://www.youtube.com',
  4550. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4551. },
  4552. data: JSON.stringify({
  4553. context: {
  4554. client: client,
  4555. request: {
  4556. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4557. internalExperimentFlags: [],
  4558. consistencyTokenJars: []
  4559. },
  4560. user: {}
  4561. },
  4562. channelIds: [ channelId ],
  4563. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4564. })
  4565. });
  4566. if (result === 'Success') {
  4567. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4568. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4569. logStatus.success();
  4570. if (doTask && !verify) {
  4571. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4572. }
  4573. return true;
  4574. }
  4575. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4576. logStatus.success();
  4577. return true;
  4578. }
  4579. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4580. return false;
  4581. }
  4582. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4583. return false;
  4584. }
  4585. logStatus.error(`${result}:${statusText}(${status})`);
  4586. return false;
  4587. } catch (error) {
  4588. throwError(error, 'Youtube.toggleChannel');
  4589. return false;
  4590. }
  4591. }
  4592. async function _toggleLikeVideo2(_ref4) {
  4593. let {
  4594. link,
  4595. doTask = true
  4596. } = _ref4;
  4597. try {
  4598. const {
  4599. params,
  4600. needLogin
  4601. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4602. const {
  4603. apiKey,
  4604. client,
  4605. request,
  4606. videoId,
  4607. likeParams
  4608. } = params || {};
  4609. if (needLogin) {
  4610. scripts_echoLog({
  4611. html: `${i18n('loginYtb')}`
  4612. });
  4613. return false;
  4614. }
  4615. if (!(apiKey && client && request && videoId && likeParams)) {
  4616. scripts_echoLog({
  4617. text: '"getYtbToken" failed'
  4618. });
  4619. return false;
  4620. }
  4621. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4622. scripts_echoLog({
  4623. type: 'whiteList',
  4624. text: 'Youtube.unlikeVideo',
  4625. id: videoId
  4626. });
  4627. return true;
  4628. }
  4629. const logStatus = scripts_echoLog({
  4630. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4631. text: videoId
  4632. });
  4633. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4634. const likeVideoData = {
  4635. context: {
  4636. client: client,
  4637. request: {
  4638. sessionId: request.sessionId,
  4639. internalExperimentFlags: [],
  4640. consistencyTokenJars: []
  4641. },
  4642. user: {}
  4643. },
  4644. target: {
  4645. videoId: videoId
  4646. }
  4647. };
  4648. if (doTask) {
  4649. if (likeParams) {
  4650. likeVideoData.params = likeParams;
  4651. } else {
  4652. logStatus.error('Empty likeParams');
  4653. return false;
  4654. }
  4655. }
  4656. const {
  4657. result,
  4658. statusText,
  4659. status,
  4660. data
  4661. } = await tools_httpRequest({
  4662. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4663. method: 'POST',
  4664. headers: {
  4665. origin: 'https://www.youtube.com',
  4666. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4667. 'content-type': 'application/json',
  4668. 'x-goog-authuser': '0',
  4669. 'x-goog-visitor-id': client.visitorData,
  4670. 'x-origin': 'https://www.youtube.com',
  4671. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4672. },
  4673. data: JSON.stringify(likeVideoData)
  4674. });
  4675. if (result === 'Success') {
  4676. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4677. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4678. logStatus.success();
  4679. if (doTask) {
  4680. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4681. }
  4682. return true;
  4683. }
  4684. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4685. return false;
  4686. }
  4687. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4688. return false;
  4689. }
  4690. logStatus.error(`${result}:${statusText}(${status})`);
  4691. return false;
  4692. } catch (error) {
  4693. throwError(error, 'Youtube.toggleLikeVideo');
  4694. return false;
  4695. }
  4696. }
  4697. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4698. Steam_checkPrivateRedeclaration(obj, privateSet);
  4699. privateSet.add(obj);
  4700. }
  4701. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4702. Steam_checkPrivateRedeclaration(obj, privateMap);
  4703. privateMap.set(obj, value);
  4704. }
  4705. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4706. if (privateCollection.has(obj)) {
  4707. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4708. }
  4709. }
  4710. function Steam_defineProperty(obj, key, value) {
  4711. if (key in obj) {
  4712. Object.defineProperty(obj, key, {
  4713. value: value,
  4714. enumerable: true,
  4715. configurable: true,
  4716. writable: true
  4717. });
  4718. } else {
  4719. obj[key] = value;
  4720. }
  4721. return obj;
  4722. }
  4723. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4724. if (!privateSet.has(receiver)) {
  4725. throw new TypeError('attempted to get private field on non-instance');
  4726. }
  4727. return fn;
  4728. }
  4729. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4730. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4731. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4732. return value;
  4733. }
  4734. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4735. if (descriptor.set) {
  4736. descriptor.set.call(receiver, value);
  4737. } else {
  4738. if (!descriptor.writable) {
  4739. throw new TypeError('attempted to set read only private field');
  4740. }
  4741. descriptor.value = value;
  4742. }
  4743. }
  4744. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4745. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4746. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4747. }
  4748. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4749. if (!privateMap.has(receiver)) {
  4750. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4751. }
  4752. return privateMap.get(receiver);
  4753. }
  4754. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4755. if (descriptor.get) {
  4756. return descriptor.get.call(receiver);
  4757. }
  4758. return descriptor.value;
  4759. }
  4760. const Steam_defaultTasksTemplate = {
  4761. groups: [],
  4762. officialGroups: [],
  4763. wishlists: [],
  4764. follows: [],
  4765. forums: [],
  4766. workshops: [],
  4767. workshopVotes: [],
  4768. curators: [],
  4769. curatorLikes: [],
  4770. announcements: [],
  4771. licenses: [],
  4772. playtests: []
  4773. };
  4774. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4775. var Steam_cache = new WeakMap();
  4776. var Steam_auth = new WeakMap();
  4777. var _storeInitialized = new WeakMap();
  4778. var _communityInitialized = new WeakMap();
  4779. var _area = new WeakMap();
  4780. var _areaStatus = new WeakMap();
  4781. var _updateStoreAuth = new WeakSet();
  4782. var _updateCommunityAuth = new WeakSet();
  4783. var _getAreaInfo = new WeakSet();
  4784. var _changeArea = new WeakSet();
  4785. var _joinGroup = new WeakSet();
  4786. var _leaveGroup = new WeakSet();
  4787. var _getGroupId = new WeakSet();
  4788. var _joinOfficialGroup = new WeakSet();
  4789. var _leaveOfficialGroup = new WeakSet();
  4790. var _getOfficialGroupId = new WeakSet();
  4791. var _addToWishlist = new WeakSet();
  4792. var _removeFromWishlist = new WeakSet();
  4793. var _toggleFollowGame = new WeakSet();
  4794. var _isFollowedGame = new WeakSet();
  4795. var _toggleForum = new WeakSet();
  4796. var _getForumId = new WeakSet();
  4797. var _toggleFavoriteWorkshop = new WeakSet();
  4798. var _getWorkshopAppId = new WeakSet();
  4799. var _voteUpWorkshop = new WeakSet();
  4800. var _toggleCurator = new WeakSet();
  4801. var _toggleCuratorLike = new WeakSet();
  4802. var _getAnnouncementParams = new WeakSet();
  4803. var _likeAnnouncement = new WeakSet();
  4804. var _appid2subid = new WeakSet();
  4805. var _getLicenses = new WeakSet();
  4806. var _addLicense = new WeakSet();
  4807. var _addFreeLicense = new WeakSet();
  4808. var _requestPlayTestAccess = new WeakSet();
  4809. var Steam_setCache = new WeakSet();
  4810. class Steam extends social_Social {
  4811. constructor() {
  4812. var _GM_getValue;
  4813. super(...arguments);
  4814. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4815. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4816. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4817. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4818. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4819. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4820. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4821. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4822. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4823. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4824. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4825. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4826. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4827. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4828. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4829. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4830. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4831. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4832. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4833. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4834. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4835. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4836. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4837. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4838. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4839. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4840. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4841. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4842. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4843. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4844. Steam_defineProperty(this, 'whiteList', {
  4845. ...JSON.parse(Steam_defaultTasks),
  4846. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4847. });
  4848. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4849. writable: true,
  4850. value: {
  4851. ...{
  4852. group: {},
  4853. officialGroup: {},
  4854. forum: {},
  4855. workshop: {},
  4856. curator: {}
  4857. },
  4858. ...GM_getValue('steamCache')
  4859. }
  4860. });
  4861. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4862. writable: true,
  4863. value: {}
  4864. });
  4865. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4866. writable: true,
  4867. value: false
  4868. });
  4869. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4870. writable: true,
  4871. value: false
  4872. });
  4873. Steam_classPrivateFieldInitSpec(this, _area, {
  4874. writable: true,
  4875. value: 'CN'
  4876. });
  4877. Steam_classPrivateFieldInitSpec(this, _areaStatus, {
  4878. writable: true,
  4879. value: 'end'
  4880. });
  4881. }
  4882. async init() {
  4883. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4884. try {
  4885. if (type === 'store') {
  4886. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4887. return true;
  4888. }
  4889. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4890. if (!Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4891. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4892. return false;
  4893. }
  4894. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4895. return true;
  4896. }
  4897. if (type === 'community') {
  4898. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4899. return true;
  4900. }
  4901. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4902. if (!Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4903. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4904. return false;
  4905. }
  4906. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4907. return true;
  4908. }
  4909. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4910. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4911. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4912. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4913. return true;
  4914. }
  4915. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4916. return false;
  4917. } catch (error) {
  4918. throwError(error, 'Steam.init');
  4919. return false;
  4920. }
  4921. }
  4922. async getCuratorId(path, name) {
  4923. try {
  4924. const logStatus = scripts_echoLog({
  4925. type: 'gettingCuratorId',
  4926. text: `${path}/${name}`
  4927. });
  4928. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4929. if (curatorId) {
  4930. logStatus.success();
  4931. return curatorId;
  4932. }
  4933. const {
  4934. result,
  4935. statusText,
  4936. status,
  4937. data
  4938. } = await tools_httpRequest({
  4939. url: `https://store.steampowered.com/${path}/${name}`,
  4940. method: 'GET',
  4941. headers: {
  4942. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4943. }
  4944. });
  4945. if (result === 'Success') {
  4946. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4947. var _data$responseText$ma;
  4948. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4949. if (curatorId) {
  4950. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4951. logStatus.success();
  4952. return curatorId;
  4953. }
  4954. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4955. return false;
  4956. }
  4957. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4958. return false;
  4959. }
  4960. logStatus.error(`${result}:${statusText}(${status})`);
  4961. return false;
  4962. } catch (error) {
  4963. throwError(error, 'Steam.getCuratorID');
  4964. return false;
  4965. }
  4966. }
  4967. async toggle(_ref) {
  4968. let {
  4969. doTask = true,
  4970. groupLinks = [],
  4971. officialGroupLinks = [],
  4972. wishlistLinks = [],
  4973. followLinks = [],
  4974. forumLinks = [],
  4975. workshopLinks = [],
  4976. workshopVoteLinks = [],
  4977. curatorLinks = [],
  4978. curatorLikeLinks = [],
  4979. announcementLinks = [],
  4980. licenseLinks = [],
  4981. playtestLinks = []
  4982. } = _ref;
  4983. try {
  4984. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4985. scripts_echoLog({
  4986. text: i18n('needInit')
  4987. });
  4988. return false;
  4989. }
  4990. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4991. scripts_echoLog({
  4992. text: i18n('needInit')
  4993. });
  4994. return false;
  4995. }
  4996. const prom = [];
  4997. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4998. scripts_echoLog({
  4999. type: 'globalOptionsSkip',
  5000. text: 'steam.groups'
  5001. });
  5002. } else {
  5003. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  5004. var _link$match;
  5005. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  5006. });
  5007. if (realGroups.length > 0) {
  5008. for (const group of realGroups) {
  5009. if (doTask) {
  5010. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  5011. } else {
  5012. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  5013. }
  5014. await delay(1e3);
  5015. }
  5016. }
  5017. }
  5018. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  5019. scripts_echoLog({
  5020. type: 'globalOptionsSkip',
  5021. text: 'steam.officialGroups'
  5022. });
  5023. } else {
  5024. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  5025. var _link$match2;
  5026. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  5027. });
  5028. if (realOfficialGroups.length > 0) {
  5029. for (const officialGroup of realOfficialGroups) {
  5030. if (doTask) {
  5031. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  5032. } else {
  5033. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  5034. }
  5035. await delay(1e3);
  5036. }
  5037. }
  5038. }
  5039. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  5040. scripts_echoLog({
  5041. type: 'globalOptionsSkip',
  5042. text: 'steam.wishlists'
  5043. });
  5044. } else {
  5045. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  5046. var _link$match3;
  5047. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5048. });
  5049. if (realWishlists.length > 0) {
  5050. for (const game of realWishlists) {
  5051. if (doTask) {
  5052. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  5053. } else {
  5054. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  5055. }
  5056. await delay(1e3);
  5057. }
  5058. }
  5059. }
  5060. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5061. scripts_echoLog({
  5062. type: 'globalOptionsSkip',
  5063. text: 'steam.follows'
  5064. });
  5065. } else {
  5066. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5067. var _link$match4;
  5068. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5069. });
  5070. if (realFollows.length > 0) {
  5071. for (const game of realFollows) {
  5072. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  5073. await delay(1e3);
  5074. }
  5075. }
  5076. }
  5077. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5078. scripts_echoLog({
  5079. type: 'globalOptionsSkip',
  5080. text: 'steam.forums'
  5081. });
  5082. } else {
  5083. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5084. var _link$match5;
  5085. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5086. });
  5087. if (realForums.length > 0) {
  5088. for (const forum of realForums) {
  5089. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5090. await delay(1e3);
  5091. }
  5092. }
  5093. }
  5094. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5095. scripts_echoLog({
  5096. type: 'globalOptionsSkip',
  5097. text: 'steam.workshops'
  5098. });
  5099. } else {
  5100. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5101. var _link$match6;
  5102. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5103. });
  5104. if (realWorkshops.length > 0) {
  5105. for (const workshop of realWorkshops) {
  5106. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5107. await delay(1e3);
  5108. }
  5109. }
  5110. }
  5111. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5112. scripts_echoLog({
  5113. type: 'globalOptionsSkip',
  5114. text: 'steam.workshopVotes'
  5115. });
  5116. } else {
  5117. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5118. var _link$match7;
  5119. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5120. });
  5121. if (doTask && realworkshopVotes.length > 0) {
  5122. for (const workshop of realworkshopVotes) {
  5123. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5124. await delay(1e3);
  5125. }
  5126. }
  5127. }
  5128. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5129. scripts_echoLog({
  5130. type: 'globalOptionsSkip',
  5131. text: 'steam.curators'
  5132. });
  5133. } else {
  5134. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5135. var _link$match8;
  5136. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5137. });
  5138. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5139. var _link$match9;
  5140. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5141. });
  5142. if (realCurators.length > 0) {
  5143. for (const curator of realCurators) {
  5144. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5145. await delay(1e3);
  5146. }
  5147. }
  5148. if (realCuratorLikes.length > 0) {
  5149. for (const curatorLike of realCuratorLikes) {
  5150. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5151. await delay(1e3);
  5152. }
  5153. }
  5154. }
  5155. if (doTask && !globalOptions.doTask.steam.announcements) {
  5156. scripts_echoLog({
  5157. type: 'globalOptionsSkip',
  5158. text: 'steam.announcements'
  5159. });
  5160. } else {
  5161. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5162. var _link$match11;
  5163. if (link.includes('store.steampowered.com')) {
  5164. var _link$match10;
  5165. 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('/');
  5166. }
  5167. 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('/');
  5168. });
  5169. if (doTask && realAnnouncements.length > 0) {
  5170. for (const id of realAnnouncements) {
  5171. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5172. await delay(1e3);
  5173. }
  5174. }
  5175. }
  5176. if (doTask && !globalOptions.doTask.steam.licenses) {
  5177. scripts_echoLog({
  5178. type: 'globalOptionsSkip',
  5179. text: 'steam.licenses'
  5180. });
  5181. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5182. for (const id of licenseLinks) {
  5183. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5184. await delay(1e3);
  5185. }
  5186. }
  5187. if (doTask && !globalOptions.doTask.steam.playtests) {
  5188. scripts_echoLog({
  5189. type: 'globalOptionsSkip',
  5190. text: 'steam.playtests'
  5191. });
  5192. } else {
  5193. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5194. var _link$match12;
  5195. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5196. });
  5197. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5198. for (const id of realPlaytests) {
  5199. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5200. await delay(1e3);
  5201. }
  5202. }
  5203. }
  5204. return Promise.all(prom).then(async () => {
  5205. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5206. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5207. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5208. }
  5209. return true;
  5210. });
  5211. } catch (error) {
  5212. throwError(error, 'Steam.toggle');
  5213. return false;
  5214. }
  5215. }
  5216. }
  5217. async function _updateStoreAuth2() {
  5218. try {
  5219. const logStatus = scripts_echoLog({
  5220. text: i18n('updatingAuth', i18n('steamStore'))
  5221. });
  5222. const {
  5223. result,
  5224. statusText,
  5225. status,
  5226. data
  5227. } = await tools_httpRequest({
  5228. url: 'https://store.steampowered.com/',
  5229. method: 'GET',
  5230. headers: {
  5231. Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  5232. 'Cache-Control': 'max-age=0',
  5233. 'Sec-Fetch-Dest': 'document',
  5234. 'Sec-Fetch-Mode': 'navigate',
  5235. 'Upgrade-Insecure-Requests': '1'
  5236. }
  5237. });
  5238. if (result === 'Success') {
  5239. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5240. var _data$responseText$ma2;
  5241. if (!data.responseText.includes('data-miniprofile=')) {
  5242. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5243. return false;
  5244. }
  5245. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5246. if (storeSessionID) {
  5247. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5248. logStatus.success();
  5249. return true;
  5250. }
  5251. logStatus.error('Error: Get "sessionID" failed');
  5252. return false;
  5253. }
  5254. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5255. return false;
  5256. }
  5257. logStatus.error(`${result}:${statusText}(${status})`);
  5258. return false;
  5259. } catch (error) {
  5260. throwError(error, 'Steam.updateStoreAuth');
  5261. return false;
  5262. }
  5263. }
  5264. async function _updateCommunityAuth2() {
  5265. try {
  5266. const logStatus = scripts_echoLog({
  5267. text: i18n('updatingAuth', i18n('steamCommunity'))
  5268. });
  5269. const {
  5270. result,
  5271. statusText,
  5272. status,
  5273. data
  5274. } = await tools_httpRequest({
  5275. url: 'https://steamcommunity.com/my',
  5276. method: 'GET',
  5277. headers: {
  5278. Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  5279. 'Cache-Control': 'max-age=0',
  5280. 'Sec-Fetch-Dest': 'document',
  5281. 'Sec-Fetch-Mode': 'navigate',
  5282. 'Upgrade-Insecure-Requests': '1'
  5283. }
  5284. });
  5285. if (result === 'Success') {
  5286. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5287. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5288. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5289. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5290. return false;
  5291. }
  5292. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5293. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5294. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5295. if (steam64Id) {
  5296. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5297. }
  5298. if (userName) {
  5299. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5300. }
  5301. if (communitySessionID) {
  5302. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5303. logStatus.success();
  5304. return true;
  5305. }
  5306. logStatus.error('Error: Get "sessionID" failed');
  5307. return false;
  5308. }
  5309. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5310. return false;
  5311. }
  5312. logStatus.error(`${result}:${statusText}(${status})`);
  5313. return false;
  5314. } catch (error) {
  5315. throwError(error, 'Steam.updateCommunityAuth');
  5316. return false;
  5317. }
  5318. }
  5319. async function _getAreaInfo2() {
  5320. try {
  5321. const logStatus = scripts_echoLog({
  5322. text: i18n('gettingAreaInfo')
  5323. });
  5324. const {
  5325. result,
  5326. statusText,
  5327. status,
  5328. data
  5329. } = await tools_httpRequest({
  5330. url: 'https://store.steampowered.com/cart/',
  5331. method: 'GET'
  5332. });
  5333. if (result === 'Success') {
  5334. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5335. var _data$responseText$ma6;
  5336. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5337. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5338. if (currentArea && areas.length > 0) {
  5339. Steam_classPrivateFieldSet(this, _area, currentArea);
  5340. logStatus.success();
  5341. return {
  5342. currentArea: currentArea,
  5343. areas: areas
  5344. };
  5345. }
  5346. logStatus.error('Error: get country info filed');
  5347. return {};
  5348. }
  5349. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5350. return {};
  5351. }
  5352. logStatus.error(`${result}:${statusText}(${status})`);
  5353. return {};
  5354. } catch (error) {
  5355. throwError(error, 'Steam.getAreaInfo');
  5356. return {};
  5357. }
  5358. }
  5359. async function _changeArea2(area) {
  5360. try {
  5361. if (Steam_classPrivateFieldGet(this, _areaStatus) === 'waiting') {
  5362. await new Promise(resolve => {
  5363. const checker = setInterval(() => {
  5364. if (Steam_classPrivateFieldGet(this, _areaStatus) !== 'waiting') {
  5365. clearInterval(checker);
  5366. resolve(true);
  5367. }
  5368. });
  5369. });
  5370. }
  5371. if (Steam_classPrivateFieldGet(this, _area) === area || !area && Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5372. return true;
  5373. }
  5374. Steam_classPrivateFieldSet(this, _areaStatus, 'waiting');
  5375. let aimedArea = area;
  5376. if (!aimedArea) {
  5377. const {
  5378. currentArea,
  5379. areas
  5380. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5381. if (!currentArea || !areas) {
  5382. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5383. return false;
  5384. }
  5385. if (currentArea !== 'CN') {
  5386. Steam_classPrivateFieldSet(this, _areaStatus, 'skip');
  5387. scripts_echoLog({
  5388. text: 'notNeededChangeArea'
  5389. });
  5390. return 'skip';
  5391. }
  5392. const anotherArea = areas.filter(area => area && area !== 'CN');
  5393. if (!anotherArea || anotherArea.length === 0) {
  5394. Steam_classPrivateFieldSet(this, _areaStatus, 'noAnotherArea');
  5395. scripts_echoLog({
  5396. text: 'noAnotherArea'
  5397. });
  5398. return false;
  5399. }
  5400. [ aimedArea ] = anotherArea;
  5401. }
  5402. const logStatus = scripts_echoLog({
  5403. text: i18n('changingArea', aimedArea)
  5404. });
  5405. const {
  5406. result,
  5407. statusText,
  5408. status,
  5409. data
  5410. } = await tools_httpRequest({
  5411. url: 'https://store.steampowered.com/account/setcountry',
  5412. method: 'POST',
  5413. headers: {
  5414. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5415. },
  5416. data: $.param({
  5417. cc: aimedArea,
  5418. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5419. })
  5420. });
  5421. if (result === 'Success') {
  5422. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5423. const {
  5424. currentArea
  5425. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5426. if (currentArea === aimedArea) {
  5427. Steam_classPrivateFieldSet(this, _areaStatus, 'success');
  5428. logStatus.success();
  5429. return currentArea;
  5430. }
  5431. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5432. logStatus.error('Error: change country filed');
  5433. return 'CN';
  5434. }
  5435. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5436. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5437. return 'CN';
  5438. }
  5439. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5440. logStatus.error(`${result}:${statusText}(${status})`);
  5441. return 'CN';
  5442. } catch (error) {
  5443. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5444. throwError(error, 'Steam.changeArea');
  5445. return false;
  5446. }
  5447. }
  5448. async function _joinGroup2(groupName) {
  5449. try {
  5450. const logStatus = scripts_echoLog({
  5451. type: 'joiningSteamGroup',
  5452. text: groupName
  5453. });
  5454. const {
  5455. result,
  5456. statusText,
  5457. status,
  5458. data
  5459. } = await tools_httpRequest({
  5460. url: `https://steamcommunity.com/groups/${groupName}`,
  5461. method: 'POST',
  5462. headers: {
  5463. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5464. },
  5465. data: $.param({
  5466. action: 'join',
  5467. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5468. })
  5469. });
  5470. if (result === 'Success') {
  5471. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5472. logStatus.success();
  5473. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5474. return true;
  5475. }
  5476. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5477. return false;
  5478. }
  5479. logStatus.error(`${result}:${statusText}(${status})`);
  5480. return false;
  5481. } catch (error) {
  5482. throwError(error, 'Steam.joinGroup');
  5483. return false;
  5484. }
  5485. }
  5486. async function _leaveGroup2(groupName) {
  5487. try {
  5488. if (this.whiteList.groups.includes(groupName)) {
  5489. scripts_echoLog({
  5490. type: 'whiteList',
  5491. text: 'Steam.leaveGroup',
  5492. id: groupName
  5493. });
  5494. return true;
  5495. }
  5496. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5497. if (!groupId) {
  5498. return false;
  5499. }
  5500. const logStatus = scripts_echoLog({
  5501. type: 'leavingSteamGroup',
  5502. text: groupName
  5503. });
  5504. const {
  5505. result,
  5506. statusText,
  5507. status,
  5508. data
  5509. } = await tools_httpRequest({
  5510. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5511. method: 'POST',
  5512. headers: {
  5513. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5514. },
  5515. data: $.param({
  5516. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5517. action: 'leaveGroup',
  5518. groupId: groupId
  5519. })
  5520. });
  5521. if (result === 'Success') {
  5522. 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) {
  5523. logStatus.success();
  5524. return true;
  5525. }
  5526. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5527. return false;
  5528. }
  5529. logStatus.error(`${result}:${statusText}(${status})`);
  5530. return false;
  5531. } catch (error) {
  5532. throwError(error, 'Steam.leaveGroup');
  5533. return false;
  5534. }
  5535. }
  5536. async function _getGroupId2(groupName) {
  5537. try {
  5538. const logStatus = scripts_echoLog({
  5539. type: 'gettingSteamGroupId',
  5540. text: groupName
  5541. });
  5542. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5543. if (groupId) {
  5544. logStatus.success();
  5545. return groupId;
  5546. }
  5547. const {
  5548. result,
  5549. statusText,
  5550. status,
  5551. data
  5552. } = await tools_httpRequest({
  5553. url: `https://steamcommunity.com/groups/${groupName}`,
  5554. method: 'GET',
  5555. headers: {
  5556. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5557. }
  5558. });
  5559. if (result === 'Success') {
  5560. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5561. var _data$responseText$ma7;
  5562. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5563. if (groupId) {
  5564. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5565. logStatus.success();
  5566. return groupId;
  5567. }
  5568. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5569. return false;
  5570. }
  5571. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5572. return false;
  5573. }
  5574. logStatus.error(`${result}:${statusText}(${status})`);
  5575. return false;
  5576. } catch (error) {
  5577. throwError(error, 'Steam.getGroupID');
  5578. return false;
  5579. }
  5580. }
  5581. async function _joinOfficialGroup2(gameId) {
  5582. try {
  5583. const logStatus = scripts_echoLog({
  5584. type: 'joiningSteamOfficialGroup',
  5585. text: gameId
  5586. });
  5587. const {
  5588. result,
  5589. statusText,
  5590. status,
  5591. data
  5592. } = await tools_httpRequest({
  5593. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5594. method: 'GET',
  5595. headers: {
  5596. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5597. }
  5598. });
  5599. if (result === 'Success') {
  5600. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5601. var _data$responseText$ma8;
  5602. logStatus.success();
  5603. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5604. 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];
  5605. if (groupId) {
  5606. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5607. }
  5608. return true;
  5609. }
  5610. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5611. return false;
  5612. }
  5613. logStatus.error(`${result}:${statusText}(${status})`);
  5614. return false;
  5615. } catch (error) {
  5616. throwError(error, 'Steam.joinOfficialGroup');
  5617. return false;
  5618. }
  5619. }
  5620. async function _leaveOfficialGroup2(gameId) {
  5621. try {
  5622. if (this.whiteList.officialGroups.includes(gameId)) {
  5623. scripts_echoLog({
  5624. type: 'whiteList',
  5625. text: 'Steam.leaveOfficialGroup',
  5626. id: gameId
  5627. });
  5628. return true;
  5629. }
  5630. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5631. if (!groupId) {
  5632. return false;
  5633. }
  5634. const logStatus = scripts_echoLog({
  5635. type: 'leavingSteamOfficialGroup',
  5636. text: gameId
  5637. });
  5638. const {
  5639. result,
  5640. statusText,
  5641. status,
  5642. data
  5643. } = await tools_httpRequest({
  5644. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5645. method: 'POST',
  5646. headers: {
  5647. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5648. },
  5649. data: $.param({
  5650. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5651. action: 'leaveGroup',
  5652. groupId: groupId
  5653. })
  5654. });
  5655. if (result === 'Success') {
  5656. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5657. const {
  5658. result: resultR,
  5659. statusText: statusTextR,
  5660. status: statusR,
  5661. data: dataR
  5662. } = await tools_httpRequest({
  5663. url: `https://steamcommunity.com/games/${gameId}`,
  5664. method: 'GET',
  5665. headers: {
  5666. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5667. }
  5668. });
  5669. if (resultR === 'Success') {
  5670. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5671. logStatus.success();
  5672. return true;
  5673. }
  5674. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5675. return false;
  5676. }
  5677. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5678. return false;
  5679. }
  5680. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5681. return false;
  5682. }
  5683. logStatus.error(`${result}:${statusText}(${status})`);
  5684. return false;
  5685. } catch (error) {
  5686. throwError(error, 'Steam.leaveOfficialGroup');
  5687. return false;
  5688. }
  5689. }
  5690. async function _getOfficialGroupId2(gameId) {
  5691. try {
  5692. const logStatus = scripts_echoLog({
  5693. type: 'gettingSteamOfficialGroupId',
  5694. text: gameId
  5695. });
  5696. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5697. if (groupId) {
  5698. logStatus.success();
  5699. return groupId;
  5700. }
  5701. const {
  5702. result,
  5703. statusText,
  5704. status,
  5705. data
  5706. } = await tools_httpRequest({
  5707. url: `https://steamcommunity.com/games/${gameId}`,
  5708. method: 'GET',
  5709. headers: {
  5710. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5711. }
  5712. });
  5713. if (result === 'Success') {
  5714. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5715. var _data$responseText$ma9;
  5716. 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];
  5717. if (groupId) {
  5718. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5719. logStatus.success();
  5720. return groupId;
  5721. }
  5722. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5723. return false;
  5724. }
  5725. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5726. return false;
  5727. }
  5728. logStatus.error(`${result}:${statusText}(${status})`);
  5729. return false;
  5730. } catch (error) {
  5731. throwError(error, 'Steam.getGroupID');
  5732. return false;
  5733. }
  5734. }
  5735. async function _addToWishlist2(gameId) {
  5736. try {
  5737. var _data$response;
  5738. const logStatus = scripts_echoLog({
  5739. type: 'addingToWishlist',
  5740. text: gameId
  5741. });
  5742. const {
  5743. result,
  5744. data
  5745. } = await tools_httpRequest({
  5746. url: 'https://store.steampowered.com/api/addtowishlist',
  5747. method: 'POST',
  5748. headers: {
  5749. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5750. },
  5751. data: $.param({
  5752. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5753. appid: gameId
  5754. }),
  5755. dataType: 'json'
  5756. });
  5757. 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) {
  5758. logStatus.success();
  5759. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5760. return true;
  5761. }
  5762. const {
  5763. result: resultR,
  5764. statusText: statusTextR,
  5765. status: statusR,
  5766. data: dataR
  5767. } = await tools_httpRequest({
  5768. url: `https://store.steampowered.com/app/${gameId}`,
  5769. method: 'GET'
  5770. });
  5771. if (resultR === 'Success') {
  5772. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5773. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5774. logStatus.warning(i18n('changeAreaNotice'));
  5775. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5776. return false;
  5777. }
  5778. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5779. }
  5780. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5781. logStatus.success();
  5782. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5783. return true;
  5784. } 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"')) {
  5785. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5786. return false;
  5787. }
  5788. logStatus.success();
  5789. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5790. return true;
  5791. }
  5792. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5793. return false;
  5794. }
  5795. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5796. return false;
  5797. } catch (error) {
  5798. throwError(error, 'Steam.addToWishlist');
  5799. return false;
  5800. }
  5801. }
  5802. async function _removeFromWishlist2(gameId) {
  5803. try {
  5804. var _data$response2;
  5805. if (this.whiteList.wishlists.includes(gameId)) {
  5806. scripts_echoLog({
  5807. type: 'whiteList',
  5808. text: 'Steam.removeFromWishlist',
  5809. id: gameId
  5810. });
  5811. return true;
  5812. }
  5813. const logStatus = scripts_echoLog({
  5814. type: 'removingFromWishlist',
  5815. text: gameId
  5816. });
  5817. const {
  5818. result,
  5819. data
  5820. } = await tools_httpRequest({
  5821. url: 'https://store.steampowered.com/api/removefromwishlist',
  5822. method: 'POST',
  5823. headers: {
  5824. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5825. },
  5826. data: $.param({
  5827. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5828. appid: gameId
  5829. }),
  5830. dataType: 'json'
  5831. });
  5832. 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) {
  5833. logStatus.success();
  5834. return true;
  5835. }
  5836. const {
  5837. result: resultR,
  5838. statusText: statusTextR,
  5839. status: statusR,
  5840. data: dataR
  5841. } = await tools_httpRequest({
  5842. url: `https://store.steampowered.com/app/${gameId}`,
  5843. method: 'GET'
  5844. });
  5845. if (resultR === 'Success') {
  5846. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5847. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5848. logStatus.warning(i18n('changeAreaNotice'));
  5849. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5850. if (!result || result === 'CN' || result === 'skip') {
  5851. return false;
  5852. }
  5853. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5854. }
  5855. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5856. logStatus.success();
  5857. return true;
  5858. }
  5859. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5860. return false;
  5861. }
  5862. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5863. return false;
  5864. }
  5865. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5866. return false;
  5867. } catch (error) {
  5868. throwError(error, 'Steam.removeFromWishlist');
  5869. return false;
  5870. }
  5871. }
  5872. async function _toggleFollowGame2(gameId, doTask) {
  5873. try {
  5874. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5875. scripts_echoLog({
  5876. type: 'whiteList',
  5877. text: 'Steam.unfollowGame',
  5878. id: gameId
  5879. });
  5880. return true;
  5881. }
  5882. const logStatus = scripts_echoLog({
  5883. type: `${doTask ? '' : 'un'}followingGame`,
  5884. text: gameId
  5885. });
  5886. const requestData = {
  5887. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5888. appid: gameId
  5889. };
  5890. if (!doTask) {
  5891. requestData.unfollow = '1';
  5892. }
  5893. const {
  5894. result,
  5895. data
  5896. } = await tools_httpRequest({
  5897. url: 'https://store.steampowered.com/explore/followgame/',
  5898. method: 'POST',
  5899. headers: {
  5900. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5901. },
  5902. data: $.param(requestData)
  5903. });
  5904. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5905. logStatus.success();
  5906. return true;
  5907. }
  5908. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5909. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5910. logStatus.warning(i18n('changeAreaNotice'));
  5911. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5912. return false;
  5913. }
  5914. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5915. }
  5916. if (doTask === followed) {
  5917. logStatus.success();
  5918. if (doTask) {
  5919. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5920. }
  5921. return true;
  5922. }
  5923. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5924. return false;
  5925. } catch (error) {
  5926. throwError(error, 'Steam.toggleFollowGame');
  5927. return false;
  5928. }
  5929. }
  5930. async function _isFollowedGame2(gameId) {
  5931. try {
  5932. const {
  5933. result,
  5934. data
  5935. } = await tools_httpRequest({
  5936. url: `https://store.steampowered.com/app/${gameId}`,
  5937. method: 'GET'
  5938. });
  5939. if (result === 'Success') {
  5940. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5941. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5942. return 'areaLocked';
  5943. }
  5944. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5945. return true;
  5946. }
  5947. return false;
  5948. }
  5949. return false;
  5950. }
  5951. return false;
  5952. } catch (error) {
  5953. throwError(error, 'Steam.isFollowedGame');
  5954. return false;
  5955. }
  5956. }
  5957. async function _toggleForum2(gameId) {
  5958. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5959. try {
  5960. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5961. scripts_echoLog({
  5962. type: 'whiteList',
  5963. text: 'Steam.unsubscribeForum',
  5964. id: gameId
  5965. });
  5966. return true;
  5967. }
  5968. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5969. if (!forumId) {
  5970. return false;
  5971. }
  5972. const logStatus = scripts_echoLog({
  5973. type: `${doTask ? '' : 'un'}subscribingForum`,
  5974. text: gameId
  5975. });
  5976. const [ id, feature ] = forumId.split('_');
  5977. const {
  5978. result,
  5979. statusText,
  5980. status,
  5981. data
  5982. } = await tools_httpRequest({
  5983. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5984. method: 'POST',
  5985. responseType: 'json',
  5986. headers: {
  5987. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5988. },
  5989. data: $.param({
  5990. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5991. })
  5992. });
  5993. if (result === 'Success') {
  5994. var _data$response3, _data$response4;
  5995. 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)) {
  5996. if (doTask) {
  5997. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5998. }
  5999. logStatus.success();
  6000. return true;
  6001. }
  6002. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6003. return true;
  6004. }
  6005. logStatus.error(`${result}:${statusText}(${status})`);
  6006. return true;
  6007. } catch (error) {
  6008. throwError(error, 'Steam.toggleForum');
  6009. return true;
  6010. }
  6011. }
  6012. async function _getForumId2(gameId) {
  6013. try {
  6014. const logStatus = scripts_echoLog({
  6015. type: 'gettingForumId',
  6016. text: gameId
  6017. });
  6018. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  6019. if (forumId) {
  6020. logStatus.success();
  6021. return forumId;
  6022. }
  6023. const {
  6024. result,
  6025. statusText,
  6026. status,
  6027. data
  6028. } = await tools_httpRequest({
  6029. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  6030. method: 'GET'
  6031. });
  6032. if (result === 'Success') {
  6033. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6034. var _data$responseText, _data$responseText$ma10;
  6035. 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];
  6036. if (forumId) {
  6037. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  6038. logStatus.success();
  6039. return forumId;
  6040. }
  6041. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6042. return false;
  6043. }
  6044. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6045. return false;
  6046. }
  6047. logStatus.error(`${result}:${statusText}(${status})`);
  6048. return false;
  6049. } catch (error) {
  6050. throwError(error, 'Steam.getForumId');
  6051. return false;
  6052. }
  6053. }
  6054. async function _toggleFavoriteWorkshop2(id) {
  6055. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6056. try {
  6057. if (!doTask && this.whiteList.workshops.includes(id)) {
  6058. scripts_echoLog({
  6059. type: 'whiteList',
  6060. text: 'Steam.unfavoriteWorkshop',
  6061. id: id
  6062. });
  6063. return true;
  6064. }
  6065. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  6066. if (!appid) {
  6067. return false;
  6068. }
  6069. const logStatus = scripts_echoLog({
  6070. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  6071. text: id
  6072. });
  6073. const {
  6074. result,
  6075. statusText,
  6076. status,
  6077. data
  6078. } = await tools_httpRequest({
  6079. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  6080. method: 'POST',
  6081. headers: {
  6082. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6083. },
  6084. data: $.param({
  6085. id: id,
  6086. appid: appid,
  6087. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6088. })
  6089. });
  6090. if (result === 'Success') {
  6091. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  6092. if (doTask) {
  6093. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  6094. }
  6095. logStatus.success();
  6096. return true;
  6097. }
  6098. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6099. return false;
  6100. }
  6101. logStatus.error(`${result}:${statusText}(${status})`);
  6102. return false;
  6103. } catch (error) {
  6104. throwError(error, 'Steam.toggleFavoriteWorkshop');
  6105. return false;
  6106. }
  6107. }
  6108. async function _getWorkshopAppId2(id) {
  6109. try {
  6110. const logStatus = scripts_echoLog({
  6111. type: 'gettingWorkshopAppId',
  6112. text: id
  6113. });
  6114. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  6115. if (appId) {
  6116. logStatus.success();
  6117. return appId;
  6118. }
  6119. const {
  6120. result,
  6121. statusText,
  6122. status,
  6123. data
  6124. } = await tools_httpRequest({
  6125. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6126. method: 'GET'
  6127. });
  6128. if (result === 'Success') {
  6129. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6130. var _data$responseText$ma11;
  6131. 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];
  6132. if (appId) {
  6133. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6134. logStatus.success();
  6135. return appId;
  6136. }
  6137. logStatus.error('Error: getWorkshopAppId failed');
  6138. return false;
  6139. }
  6140. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6141. return false;
  6142. }
  6143. logStatus.error(`${result}:${statusText}(${status})`);
  6144. return false;
  6145. } catch (error) {
  6146. throwError(error, 'Steam.getWorkshopAppId');
  6147. return false;
  6148. }
  6149. }
  6150. async function _voteUpWorkshop2(id) {
  6151. try {
  6152. const logStatus = scripts_echoLog({
  6153. type: 'votingUpWorkshop',
  6154. text: id
  6155. });
  6156. const {
  6157. result,
  6158. statusText,
  6159. status,
  6160. data
  6161. } = await tools_httpRequest({
  6162. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6163. method: 'POST',
  6164. responseType: 'json',
  6165. headers: {
  6166. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6167. },
  6168. data: $.param({
  6169. id: id,
  6170. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6171. })
  6172. });
  6173. if (result === 'Success') {
  6174. var _data$response5;
  6175. 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) {
  6176. logStatus.success();
  6177. return true;
  6178. }
  6179. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6180. return true;
  6181. }
  6182. logStatus.error(`${result}:${statusText}(${status})`);
  6183. return true;
  6184. } catch (error) {
  6185. throwError(error, 'Steam.voteupWorkshop');
  6186. return true;
  6187. }
  6188. }
  6189. async function _toggleCurator2(curatorId) {
  6190. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6191. try {
  6192. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6193. scripts_echoLog({
  6194. type: 'whiteList',
  6195. text: 'Steam.unfollowCurator',
  6196. id: curatorId
  6197. });
  6198. return true;
  6199. }
  6200. const logStatus = scripts_echoLog({
  6201. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6202. text: curatorId
  6203. });
  6204. const {
  6205. result,
  6206. statusText,
  6207. status,
  6208. data
  6209. } = await tools_httpRequest({
  6210. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6211. method: 'POST',
  6212. headers: {
  6213. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6214. },
  6215. data: $.param({
  6216. clanid: curatorId,
  6217. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6218. follow: doTask
  6219. }),
  6220. dataType: 'json'
  6221. });
  6222. if (result === 'Success') {
  6223. var _data$response6, _data$response6$succe, _data$response7;
  6224. 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) {
  6225. logStatus.success();
  6226. return true;
  6227. }
  6228. 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})`);
  6229. return false;
  6230. }
  6231. logStatus.error(`${result}:${statusText}(${status})`);
  6232. return false;
  6233. } catch (error) {
  6234. throwError(error, 'Steam.toggleCurator');
  6235. return false;
  6236. }
  6237. }
  6238. async function _toggleCuratorLike2(link) {
  6239. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6240. try {
  6241. const [ path, name ] = link.split('/');
  6242. if (!(path && name)) {
  6243. scripts_echoLog({
  6244. text: i18n('errorLink', link)
  6245. });
  6246. return false;
  6247. }
  6248. const curatorId = await this.getCuratorId(path, name);
  6249. if (curatorId) {
  6250. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6251. }
  6252. return false;
  6253. } catch (error) {
  6254. throwError(error, 'Steam.toggleCuratorLike');
  6255. return false;
  6256. }
  6257. }
  6258. async function _getAnnouncementParams2(appId, viewId) {
  6259. try {
  6260. const logStatus = scripts_echoLog({
  6261. type: 'gettingAnnouncementParams',
  6262. text: appId,
  6263. id: viewId
  6264. });
  6265. const {
  6266. result,
  6267. statusText,
  6268. status,
  6269. data
  6270. } = await tools_httpRequest({
  6271. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6272. method: 'GET',
  6273. headers: {
  6274. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6275. }
  6276. });
  6277. if (result === 'Success') {
  6278. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6279. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6280. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6281. logStatus.warning(i18n('changeAreaNotice'));
  6282. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6283. return {};
  6284. }
  6285. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6286. }
  6287. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6288. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6289. 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];
  6290. if (authWgToken && clanId) {
  6291. logStatus.success();
  6292. return {
  6293. authWgToken: authWgToken,
  6294. clanId: clanId,
  6295. gid: gid
  6296. };
  6297. }
  6298. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6299. return {};
  6300. }
  6301. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6302. return {};
  6303. }
  6304. logStatus.error(`${result}:${statusText}(${status})`);
  6305. return {};
  6306. } catch (error) {
  6307. throwError(error, 'Steam.likeAnnouncement');
  6308. return {};
  6309. }
  6310. }
  6311. async function _likeAnnouncement2(id) {
  6312. try {
  6313. const [ appId, viewId ] = id.split('/');
  6314. if (!(appId && viewId)) {
  6315. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6316. return false;
  6317. }
  6318. const {
  6319. authWgToken,
  6320. clanId,
  6321. gid
  6322. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6323. if (!(authWgToken && clanId)) {
  6324. return false;
  6325. }
  6326. const logStatus = scripts_echoLog({
  6327. type: 'likingAnnouncement',
  6328. text: appId,
  6329. id: viewId
  6330. });
  6331. const {
  6332. result,
  6333. statusText,
  6334. status,
  6335. data
  6336. } = await tools_httpRequest({
  6337. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6338. method: 'POST',
  6339. headers: {
  6340. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6341. Host: 'store.steampowered.com',
  6342. Origin: 'https://store.steampowered.com',
  6343. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6344. },
  6345. data: $.param({
  6346. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6347. wgauthtoken: authWgToken,
  6348. voteup: 1,
  6349. clanid: clanId,
  6350. ajax: 1
  6351. }),
  6352. dataType: 'json'
  6353. });
  6354. if (result === 'Success') {
  6355. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6356. logStatus.success();
  6357. return true;
  6358. }
  6359. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6360. return false;
  6361. }
  6362. logStatus.error(`${result}:${statusText}(${status})`);
  6363. return false;
  6364. } catch (error) {
  6365. throwError(error, 'Steam.likeAnnouncement');
  6366. return false;
  6367. }
  6368. }
  6369. async function _appid2subid2(id) {
  6370. try {
  6371. const logStatus = scripts_echoLog({
  6372. type: 'gettingSubid',
  6373. text: id
  6374. });
  6375. const {
  6376. result,
  6377. statusText,
  6378. status,
  6379. data
  6380. } = await tools_httpRequest({
  6381. url: `https://store.steampowered.com/app/${id}`,
  6382. method: 'GET',
  6383. headers: {
  6384. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6385. }
  6386. });
  6387. if (result === 'Success') {
  6388. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6389. var _data$responseText$ma15;
  6390. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6391. logStatus.warning(i18n('changeAreaNotice'));
  6392. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6393. if (!result || result === 'CN' || result === 'skip') {
  6394. return false;
  6395. }
  6396. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6397. }
  6398. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6399. if (subid) {
  6400. logStatus.success();
  6401. return subid;
  6402. }
  6403. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6404. return false;
  6405. }
  6406. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6407. return false;
  6408. }
  6409. logStatus.error(`${result}:${statusText}(${status})`);
  6410. return false;
  6411. } catch (error) {
  6412. throwError(error, 'Steam.appid2subid');
  6413. return false;
  6414. }
  6415. }
  6416. async function _getLicenses2() {
  6417. try {
  6418. const logStatus = scripts_echoLog({
  6419. text: i18n('gettingLicenses')
  6420. });
  6421. const {
  6422. result,
  6423. statusText,
  6424. status,
  6425. data
  6426. } = await tools_httpRequest({
  6427. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  6428. method: 'GET',
  6429. responseType: 'json'
  6430. });
  6431. if (result === 'Success') {
  6432. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6433. var _data$response8;
  6434. logStatus.success();
  6435. return (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.rgOwnedPackages;
  6436. }
  6437. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6438. return false;
  6439. }
  6440. logStatus.error(`${result}:${statusText}(${status})`);
  6441. return false;
  6442. } catch (error) {
  6443. throwError(error, 'Steam.getLicenses');
  6444. return false;
  6445. }
  6446. }
  6447. async function _addLicense2(id) {
  6448. try {
  6449. const [ type, ids ] = id.split('-');
  6450. if (type === 'appid') {
  6451. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6452. if (!subid) {
  6453. return false;
  6454. }
  6455. const logStatus = scripts_echoLog({
  6456. type: 'addingFreeLicense',
  6457. text: ids
  6458. });
  6459. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6460. return false;
  6461. }
  6462. const {
  6463. result,
  6464. statusText,
  6465. status,
  6466. data
  6467. } = await tools_httpRequest({
  6468. url: `https://store.steampowered.com/app/${ids}`,
  6469. method: 'GET'
  6470. });
  6471. if (result === 'Success') {
  6472. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6473. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6474. logStatus.success();
  6475. return true;
  6476. }
  6477. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6478. return false;
  6479. }
  6480. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6481. return false;
  6482. }
  6483. logStatus.error(`${result}:${statusText}(${status})`);
  6484. return false;
  6485. } else if (type === 'subid') {
  6486. if (Steam_classPrivateFieldGet(this, _area) === 'CN') {
  6487. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  6488. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6489. }
  6490. const logStatusArr = {};
  6491. const idsArr = ids.split(',');
  6492. for (const subid of idsArr) {
  6493. const logStatus = scripts_echoLog({
  6494. type: 'addingFreeLicenseSubid',
  6495. text: subid
  6496. });
  6497. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6498. return false;
  6499. }
  6500. logStatusArr[subid] = logStatus;
  6501. }
  6502. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6503. if (!licenses) {
  6504. return false;
  6505. }
  6506. for (const subid of idsArr) {
  6507. if (licenses.includes(parseInt(subid, 10))) {
  6508. logStatusArr[subid].success();
  6509. } else {
  6510. logStatusArr[subid].error();
  6511. }
  6512. }
  6513. return true;
  6514. }
  6515. return false;
  6516. } catch (error) {
  6517. throwError(error, 'Steam.addLicense');
  6518. return false;
  6519. }
  6520. }
  6521. async function _addFreeLicense2(id, logStatusPre) {
  6522. try {
  6523. const logStatus = logStatusPre || scripts_echoLog({
  6524. type: 'addingFreeLicenseSubid',
  6525. text: id
  6526. });
  6527. const {
  6528. result,
  6529. statusText,
  6530. status,
  6531. data
  6532. } = await tools_httpRequest({
  6533. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6534. method: 'POST',
  6535. headers: {
  6536. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6537. Host: 'store.steampowered.com',
  6538. Origin: 'https://store.steampowered.com',
  6539. Referer: 'https://store.steampowered.com/account/licenses/'
  6540. },
  6541. data: $.param({
  6542. action: 'add_to_cart',
  6543. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6544. subid: id
  6545. }),
  6546. dataType: 'json'
  6547. });
  6548. if (result === 'Success') {
  6549. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6550. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6551. logStatus.warning(i18n('changeAreaNotice'));
  6552. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6553. if (!result || result === 'CN') {
  6554. return false;
  6555. }
  6556. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6557. }
  6558. logStatus.success();
  6559. return true;
  6560. }
  6561. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6562. return false;
  6563. }
  6564. logStatus.error(`${result}:${statusText}(${status})`);
  6565. return false;
  6566. } catch (error) {
  6567. throwError(error, 'Steam.addFreeLicense');
  6568. return false;
  6569. }
  6570. }
  6571. async function _requestPlayTestAccess2(id) {
  6572. try {
  6573. const logStatus = scripts_echoLog({
  6574. type: 'requestingPlayTestAccess',
  6575. text: id
  6576. });
  6577. const {
  6578. result,
  6579. statusText,
  6580. status,
  6581. data
  6582. } = await tools_httpRequest({
  6583. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6584. method: 'POST',
  6585. headers: {
  6586. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6587. Host: 'store.steampowered.com',
  6588. Origin: 'https://store.steampowered.com',
  6589. Referer: `https://store.steampowered.com/app/${id}`
  6590. },
  6591. data: $.param({
  6592. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6593. }),
  6594. dataType: 'json'
  6595. });
  6596. if (result === 'Success') {
  6597. var _data$response9;
  6598. 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) {
  6599. logStatus.success();
  6600. return true;
  6601. }
  6602. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6603. return false;
  6604. }
  6605. logStatus.error(`${result}:${statusText}(${status})`);
  6606. return false;
  6607. } catch (error) {
  6608. throwError(error, 'Steam.requestPlayTestAccess');
  6609. return false;
  6610. }
  6611. }
  6612. function Steam_setCache2(type, name, id) {
  6613. try {
  6614. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6615. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6616. } catch (error) {
  6617. throwError(error, 'Steam.setCache');
  6618. }
  6619. }
  6620. const social_Steam = Steam;
  6621. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6622. Website_checkPrivateRedeclaration(obj, privateSet);
  6623. privateSet.add(obj);
  6624. }
  6625. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6626. if (privateCollection.has(obj)) {
  6627. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6628. }
  6629. }
  6630. function Website_defineProperty(obj, key, value) {
  6631. if (key in obj) {
  6632. Object.defineProperty(obj, key, {
  6633. value: value,
  6634. enumerable: true,
  6635. configurable: true,
  6636. writable: true
  6637. });
  6638. } else {
  6639. obj[key] = value;
  6640. }
  6641. return obj;
  6642. }
  6643. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6644. if (!privateSet.has(receiver)) {
  6645. throw new TypeError('attempted to get private field on non-instance');
  6646. }
  6647. return fn;
  6648. }
  6649. var _bind = new WeakSet();
  6650. class Website {
  6651. constructor() {
  6652. Website_classPrivateMethodInitSpec(this, _bind);
  6653. Website_defineProperty(this, 'undoneTasks', void 0);
  6654. Website_defineProperty(this, 'socialTasks', void 0);
  6655. Website_defineProperty(this, 'giveawayId', void 0);
  6656. Website_defineProperty(this, 'socialInitialized', {
  6657. discord: false,
  6658. instagram: false,
  6659. reddit: false,
  6660. twitch: false,
  6661. twitter: false,
  6662. vk: false,
  6663. youtube: false,
  6664. steamStore: false,
  6665. steamCommunity: false
  6666. });
  6667. Website_defineProperty(this, 'initialized', false);
  6668. Website_defineProperty(this, 'social', {});
  6669. }
  6670. async initSocial(action) {
  6671. try {
  6672. const pro = [];
  6673. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6674. if (tasks.discord) {
  6675. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6676. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6677. this.social.discord = new social_Discord();
  6678. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6679. }
  6680. }
  6681. if (tasks.instagram) {
  6682. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6683. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6684. this.social.instagram = new social_Instagram();
  6685. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6686. }
  6687. }
  6688. if (tasks.reddit) {
  6689. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6690. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6691. this.social.reddit = new social_Reddit();
  6692. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6693. }
  6694. }
  6695. if (tasks.twitch) {
  6696. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6697. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6698. this.social.twitch = new social_Twitch();
  6699. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6700. }
  6701. }
  6702. if (tasks.twitter) {
  6703. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6704. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6705. this.social.twitter = new social_Twitter();
  6706. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6707. }
  6708. }
  6709. if (tasks.vk) {
  6710. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6711. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6712. this.social.vk = new social_Vk();
  6713. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6714. }
  6715. }
  6716. if (tasks.youtube) {
  6717. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6718. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6719. this.social.youtube = new Youtube();
  6720. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6721. }
  6722. }
  6723. if (tasks.steam) {
  6724. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6725. if (steamLength > 0) {
  6726. if (!this.social.steam) {
  6727. this.social.steam = new social_Steam();
  6728. }
  6729. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6730. var _tasks$steam, _tasks$steam$type;
  6731. 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;
  6732. }).reduce((total, number) => total + number, 0);
  6733. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6734. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6735. }
  6736. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6737. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6738. }
  6739. }
  6740. }
  6741. if (tasks.links && tasks.links.length > 0) {
  6742. this.social.visitLink = visitLink;
  6743. }
  6744. return await Promise.all(pro).then(result => {
  6745. let checked = true;
  6746. for (const data of result) {
  6747. if (data.result) {
  6748. this.socialInitialized[data.name] = data.result;
  6749. } else {
  6750. checked = false;
  6751. }
  6752. }
  6753. return checked;
  6754. });
  6755. } catch (error) {
  6756. throwError(error, 'Website.initSocial');
  6757. return false;
  6758. }
  6759. }
  6760. uniqueTasks(allTasks) {
  6761. const result = {};
  6762. for (const [ social, types ] of Object.entries(allTasks)) {
  6763. result[social] = {};
  6764. for (const [ type, tasks ] of Object.entries(types)) {
  6765. result[social][type] = unique(tasks);
  6766. }
  6767. }
  6768. return result;
  6769. }
  6770. async toggleTask(action) {
  6771. try {
  6772. if (!this.initialized && !this.init()) {
  6773. return false;
  6774. }
  6775. if (!await this.classifyTask(action)) {
  6776. return false;
  6777. }
  6778. if (!await this.initSocial(action)) {
  6779. return false;
  6780. }
  6781. const pro = [];
  6782. const doTask = action === 'do';
  6783. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6784. if (this.socialInitialized.discord !== 'skip' && this.social.discord) {
  6785. pro.push(this.social.discord.toggle({
  6786. doTask: doTask,
  6787. ...tasks.discord
  6788. }));
  6789. }
  6790. if (this.social.instagram) {
  6791. pro.push(this.social.instagram.toggle({
  6792. doTask: doTask,
  6793. ...tasks.instagram
  6794. }));
  6795. }
  6796. if (this.social.reddit) {
  6797. pro.push(this.social.reddit.toggle({
  6798. doTask: doTask,
  6799. ...tasks.reddit
  6800. }));
  6801. }
  6802. if (this.social.twitch) {
  6803. pro.push(this.social.twitch.toggle({
  6804. doTask: doTask,
  6805. ...tasks.twitch
  6806. }));
  6807. }
  6808. if (this.social.twitter) {
  6809. pro.push(this.social.twitter.toggle({
  6810. doTask: doTask,
  6811. ...tasks.twitter
  6812. }));
  6813. }
  6814. if (this.social.vk) {
  6815. pro.push(this.social.vk.toggle({
  6816. doTask: doTask,
  6817. ...tasks.vk
  6818. }));
  6819. }
  6820. if (this.social.youtube) {
  6821. pro.push(this.social.youtube.toggle({
  6822. doTask: doTask,
  6823. ...tasks.youtube
  6824. }));
  6825. }
  6826. if (this.social.steam) {
  6827. pro.push(this.social.steam.toggle({
  6828. doTask: doTask,
  6829. ...tasks.steam
  6830. }));
  6831. }
  6832. if (this.social.visitLink && tasks.links && doTask) {
  6833. for (const link of tasks.links) {
  6834. pro.push(this.social.visitLink(link));
  6835. }
  6836. }
  6837. if (doTask && tasks.extra && this.extraDoTask) {
  6838. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6839. if (hasExtra) {
  6840. pro.push(this.extraDoTask(tasks.extra));
  6841. }
  6842. }
  6843. await Promise.all(pro);
  6844. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6845. return true;
  6846. } catch (error) {
  6847. throwError(error, 'Website.toggleTask');
  6848. return false;
  6849. }
  6850. }
  6851. async doTask() {
  6852. try {
  6853. return await this.toggleTask('do');
  6854. } catch (error) {
  6855. throwError(error, 'Website.doTask');
  6856. return false;
  6857. }
  6858. }
  6859. async undoTask() {
  6860. try {
  6861. return await this.toggleTask('undo');
  6862. } catch (error) {
  6863. throwError(error, 'Website.undoTask');
  6864. return false;
  6865. }
  6866. }
  6867. }
  6868. async function _bind2(name, init) {
  6869. try {
  6870. return {
  6871. name: name,
  6872. result: await init
  6873. };
  6874. } catch (error) {
  6875. throwError(error, 'Website.bind');
  6876. return {
  6877. name: name,
  6878. result: false
  6879. };
  6880. }
  6881. }
  6882. const website_Website = Website;
  6883. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6884. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6885. privateSet.add(obj);
  6886. }
  6887. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6888. if (privateCollection.has(obj)) {
  6889. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6890. }
  6891. }
  6892. function FreeAnyWhere_defineProperty(obj, key, value) {
  6893. if (key in obj) {
  6894. Object.defineProperty(obj, key, {
  6895. value: value,
  6896. enumerable: true,
  6897. configurable: true,
  6898. writable: true
  6899. });
  6900. } else {
  6901. obj[key] = value;
  6902. }
  6903. return obj;
  6904. }
  6905. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6906. if (!privateSet.has(receiver)) {
  6907. throw new TypeError('attempted to get private field on non-instance');
  6908. }
  6909. return fn;
  6910. }
  6911. const FreeAnyWhere_defaultTasksTemplate = {
  6912. steam: {
  6913. groupLinks: [],
  6914. wishlistLinks: [],
  6915. curatorLinks: [],
  6916. followLinks: []
  6917. },
  6918. vk: {
  6919. nameLinks: []
  6920. }
  6921. };
  6922. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6923. var _getGiveawayId = new WeakSet();
  6924. var _verify = new WeakSet();
  6925. class FreeAnyWhere extends website_Website {
  6926. constructor() {
  6927. super(...arguments);
  6928. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6929. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6930. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6931. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6932. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6933. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6934. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6935. }
  6936. static test() {
  6937. return window.location.host === 'freeanywhere.net';
  6938. }
  6939. init() {
  6940. try {
  6941. const logStatus = scripts_echoLog({
  6942. text: i18n('initing')
  6943. });
  6944. if ($('a[href="#/login"]').length > 0) {
  6945. window.open('/#/login', '_self');
  6946. logStatus.warning(i18n('needLogin'));
  6947. return false;
  6948. }
  6949. if (window.location.href.includes('/login')) {
  6950. logStatus.warning(i18n('needLogin'));
  6951. return false;
  6952. }
  6953. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6954. var _window$location$href;
  6955. 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];
  6956. if (!id) {
  6957. logStatus.error(i18n('getFailed', 'Id'));
  6958. return false;
  6959. }
  6960. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6961. }
  6962. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6963. return false;
  6964. }
  6965. this.initialized = true;
  6966. logStatus.success();
  6967. return true;
  6968. } catch (error) {
  6969. throwError(error, 'Freeanywhere.init');
  6970. return false;
  6971. }
  6972. }
  6973. async classifyTask(action) {
  6974. try {
  6975. const logStatus = scripts_echoLog({
  6976. text: i18n('getTasksInfo')
  6977. });
  6978. if (action === 'undo') {
  6979. var _GM_getValue;
  6980. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6981. }
  6982. const {
  6983. result,
  6984. statusText,
  6985. status,
  6986. data
  6987. } = await tools_httpRequest({
  6988. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6989. method: 'GET',
  6990. headers: {
  6991. authorization: `Token ${window.localStorage.getItem('token')}`,
  6992. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6993. },
  6994. responseType: 'json'
  6995. });
  6996. if (result === 'Success') {
  6997. var _data$response;
  6998. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6999. if (tasks) {
  7000. if (action === 'verify') {
  7001. this.tasks = [];
  7002. }
  7003. for (const task of tasks) {
  7004. const type = task.challenge;
  7005. const social = task.challenge_provider;
  7006. const taskInfo = {
  7007. id: task.id,
  7008. title: task.title
  7009. };
  7010. if (action === 'verify' && !task.is_success) {
  7011. this.tasks.push(taskInfo);
  7012. continue;
  7013. }
  7014. switch (social) {
  7015. case 'steam':
  7016. taskInfo.social = 'steam';
  7017. switch (type) {
  7018. case 'WL':
  7019. if (action === 'undo') {
  7020. this.socialTasks.steam.wishlistLinks.push(task.link);
  7021. }
  7022. if (action === 'do' && !task.is_success) {
  7023. this.undoneTasks.steam.wishlistLinks.push(task.link);
  7024. }
  7025. break;
  7026.  
  7027. case 'JTG':
  7028. if (action === 'undo') {
  7029. this.socialTasks.steam.groupLinks.push(task.link);
  7030. }
  7031. if (action === 'do' && !task.is_success) {
  7032. this.undoneTasks.steam.groupLinks.push(task.link);
  7033. }
  7034. break;
  7035.  
  7036. case 'STC':
  7037. if (action === 'undo') {
  7038. this.socialTasks.steam.curatorLinks.push(task.link);
  7039. }
  7040. if (action === 'do' && !task.is_success) {
  7041. this.undoneTasks.steam.curatorLinks.push(task.link);
  7042. }
  7043. break;
  7044.  
  7045. case 'GF':
  7046. if (action === 'undo') {
  7047. this.socialTasks.steam.followLinks.push(task.link);
  7048. }
  7049. if (action === 'do' && !task.is_success) {
  7050. this.undoneTasks.steam.followLinks.push(task.link);
  7051. }
  7052. break;
  7053. }
  7054. break;
  7055.  
  7056. case 'vk-oauth2':
  7057. if (action === 'undo') {
  7058. this.socialTasks.vk.nameLinks.push(task.link);
  7059. }
  7060. if (action === 'do' && !task.is_success) {
  7061. this.undoneTasks.vk.nameLinks.push(task.link);
  7062. }
  7063. break;
  7064.  
  7065. case 'website':
  7066. break;
  7067.  
  7068. default:
  7069. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  7070. break;
  7071. }
  7072. }
  7073. logStatus.success();
  7074. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7075. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7076. if (window.DEBUG) {
  7077. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7078. }
  7079. GM_setValue(`fawTasks-${this.giveawayId}`, {
  7080. tasks: this.socialTasks,
  7081. time: new Date().getTime()
  7082. });
  7083. return true;
  7084. }
  7085. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7086. return false;
  7087. }
  7088. logStatus.error(`${result}:${statusText}(${status})`);
  7089. return false;
  7090. } catch (error) {
  7091. throwError(error, 'Freeanywhere.classifyTask');
  7092. return false;
  7093. }
  7094. }
  7095. async verifyTask() {
  7096. try {
  7097. if (!this.initialized && !this.init()) {
  7098. return false;
  7099. }
  7100. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7101. return false;
  7102. }
  7103. const pro = [];
  7104. for (const task of this.tasks) {
  7105. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  7106. await delay(1e3);
  7107. }
  7108. await Promise.all(pro);
  7109. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7110. return !!await this.getKey(true);
  7111. } catch (error) {
  7112. throwError(error, 'Freeanywhere.verifyTask');
  7113. return false;
  7114. }
  7115. }
  7116. async getKey(initialized) {
  7117. try {
  7118. if (!initialized && !this.initialized && !this.init()) {
  7119. return false;
  7120. }
  7121. const logStatus = scripts_echoLog({
  7122. text: i18n('gettingKey')
  7123. });
  7124. const {
  7125. result,
  7126. statusText,
  7127. status,
  7128. data
  7129. } = await tools_httpRequest({
  7130. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7131. method: 'GET',
  7132. dataType: 'json',
  7133. headers: {
  7134. authorization: `Token ${window.localStorage.getItem('token')}`
  7135. }
  7136. });
  7137. if (result === 'Success') {
  7138. var _data$response2;
  7139. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7140. logStatus.success();
  7141. scripts_echoLog({}).success(data.response.reward);
  7142. return data.response.reward;
  7143. }
  7144. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7145. return false;
  7146. }
  7147. logStatus.error(`${result}:${statusText}(${status})`);
  7148. return false;
  7149. } catch (error) {
  7150. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7151. return false;
  7152. }
  7153. }
  7154. }
  7155. function _getGiveawayId2() {
  7156. try {
  7157. var _window$location$href2;
  7158. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7159. if (giveawayId) {
  7160. this.giveawayId = giveawayId;
  7161. return true;
  7162. }
  7163. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7164. return false;
  7165. } catch (error) {
  7166. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7167. }
  7168. }
  7169. async function _verify2(task) {
  7170. try {
  7171. const logStatus = scripts_echoLog({
  7172. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7173. });
  7174. const {
  7175. result,
  7176. statusText,
  7177. status,
  7178. data
  7179. } = await tools_httpRequest({
  7180. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7181. method: 'GET',
  7182. dataType: 'json',
  7183. headers: {
  7184. authorization: `Token ${window.localStorage.getItem('token')}`,
  7185. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7186. }
  7187. });
  7188. if (result === 'Success') {
  7189. var _data$response3;
  7190. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7191. logStatus.success();
  7192. return true;
  7193. }
  7194. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7195. return false;
  7196. }
  7197. logStatus.error(`${result}:${statusText}(${status})`);
  7198. return false;
  7199. } catch (error) {
  7200. throwError(error, 'Freeanywhere.verify');
  7201. return false;
  7202. }
  7203. }
  7204. const website_FreeAnyWhere = FreeAnyWhere;
  7205. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7206. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7207. privateSet.add(obj);
  7208. }
  7209. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7210. if (privateCollection.has(obj)) {
  7211. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7212. }
  7213. }
  7214. function GiveawaySu_defineProperty(obj, key, value) {
  7215. if (key in obj) {
  7216. Object.defineProperty(obj, key, {
  7217. value: value,
  7218. enumerable: true,
  7219. configurable: true,
  7220. writable: true
  7221. });
  7222. } else {
  7223. obj[key] = value;
  7224. }
  7225. return obj;
  7226. }
  7227. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7228. if (!privateSet.has(receiver)) {
  7229. throw new TypeError('attempted to get private field on non-instance');
  7230. }
  7231. return fn;
  7232. }
  7233. const GiveawaySu_defaultTasks = {
  7234. steam: {
  7235. groupLinks: [],
  7236. wishlistLinks: [],
  7237. curatorLinks: [],
  7238. curatorLikeLinks: [],
  7239. followLinks: [],
  7240. forumLinks: [],
  7241. announcementLinks: [],
  7242. workshopVoteLinks: [],
  7243. playtestLinks: []
  7244. },
  7245. discord: {
  7246. serverLinks: []
  7247. },
  7248. instagram: {
  7249. userLinks: []
  7250. },
  7251. vk: {
  7252. nameLinks: []
  7253. },
  7254. twitch: {
  7255. channelLinks: []
  7256. },
  7257. reddit: {
  7258. redditLinks: []
  7259. },
  7260. youtube: {
  7261. channelLinks: [],
  7262. likeLinks: []
  7263. }
  7264. };
  7265. var _checkLogin = new WeakSet();
  7266. var _checkLeftKey = new WeakSet();
  7267. var GiveawaySu_getGiveawayId = new WeakSet();
  7268. class GiveawaySu extends website_Website {
  7269. constructor() {
  7270. super(...arguments);
  7271. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7272. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  7273. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7274. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7275. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7276. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7277. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7278. }
  7279. static test() {
  7280. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7281. }
  7282. async after() {
  7283. try {
  7284. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7285. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7286. }
  7287. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7288. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7289. }
  7290. scripts_echoLog({}).warning(i18n('gsNotice'));
  7291. } catch (error) {
  7292. throwError(error, 'Giveawaysu.after');
  7293. }
  7294. }
  7295. init() {
  7296. try {
  7297. const logStatus = scripts_echoLog({
  7298. text: i18n('initing')
  7299. });
  7300. if ($('a.steam-login').length > 0) {
  7301. window.open('/steam/redirect', '_self');
  7302. logStatus.warning(i18n('needLogin'));
  7303. return false;
  7304. }
  7305. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7306. return false;
  7307. }
  7308. this.initialized = true;
  7309. logStatus.success();
  7310. return true;
  7311. } catch (error) {
  7312. throwError(error, 'Giveawaysu.init');
  7313. return false;
  7314. }
  7315. }
  7316. async classifyTask(action) {
  7317. try {
  7318. const logStatus = scripts_echoLog({
  7319. text: i18n('getTasksInfo')
  7320. });
  7321. if (action === 'undo') {
  7322. var _GM_getValue;
  7323. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7324. return true;
  7325. }
  7326. const pro = [];
  7327. const tasks = $('#actions tr');
  7328. if ($('div.bind-discord').is(':visible')) {
  7329. $('div.bind-discord a')[0].click();
  7330. }
  7331. if ($('div.bind-twitch').is(':visible')) {
  7332. $('div.bind-twitch a')[0].click();
  7333. }
  7334. for (const task of tasks) {
  7335. pro.push(new Promise(resolve => {
  7336. const td = $(task).find('td:not(".hidden")');
  7337. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7338. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7339. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7340. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7341. const taskName = taskDes.text().trim();
  7342. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7343. return resolve(true);
  7344. }
  7345. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7346. if (!taskLink) {
  7347. return resolve(false);
  7348. }
  7349. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7350. this.undoneTasks.steam.groupLinks.push(taskLink);
  7351. } else if (/like.*announcement/gi.test(taskName)) {
  7352. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7353. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7354. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7355. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7356. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7357. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7358. this.undoneTasks.steam.forumLinks.push(taskLink);
  7359. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7360. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7361. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7362. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7363. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7364. this.undoneTasks.discord.serverLinks.push(taskLink);
  7365. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7366. this.undoneTasks.instagram.userLinks.push(taskLink);
  7367. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7368. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7369. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7370. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7371. } else if (/watch.*art/gim.test(taskName)) {
  7372. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7373. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7374. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7375. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7376. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7377. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7378. this.undoneTasks.vk.nameLinks.push(taskLink);
  7379. } else {
  7380. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7381. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7382. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7383. }
  7384. if (/follow.*button/gim.test(taskName)) {
  7385. this.undoneTasks.steam.followLinks.push(taskLink);
  7386. }
  7387. }
  7388. }
  7389. resolve(true);
  7390. }).catch(error => {
  7391. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7392. return false;
  7393. });
  7394. }));
  7395. }
  7396. await Promise.all(pro);
  7397. logStatus.success();
  7398. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7399. this.socialTasks = this.undoneTasks;
  7400. if (window.DEBUG) {
  7401. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7402. }
  7403. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7404. tasks: this.socialTasks,
  7405. time: new Date().getTime()
  7406. });
  7407. return true;
  7408. } catch (error) {
  7409. throwError(error, 'Giveawaysu.classifyTask');
  7410. return false;
  7411. }
  7412. }
  7413. }
  7414. function _checkLogin2() {
  7415. try {
  7416. if (!globalOptions.other.checkLogin) {
  7417. return true;
  7418. }
  7419. if ($('a.steam-login').length > 0) {
  7420. window.open('/steam/redirect', '_self');
  7421. }
  7422. return true;
  7423. } catch (error) {
  7424. throwError(error, 'Giveawaysu.checkLogin');
  7425. return false;
  7426. }
  7427. }
  7428. async function _checkLeftKey2() {
  7429. try {
  7430. if (!globalOptions.other.checkLeftKey) {
  7431. return true;
  7432. }
  7433. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7434. await external_Swal_default().fire({
  7435. icon: 'warning',
  7436. title: i18n('notice'),
  7437. text: i18n('noKeysLeft'),
  7438. confirmButtonText: i18n('confirm'),
  7439. cancelButtonText: i18n('cancel'),
  7440. showCancelButton: true
  7441. }).then(_ref => {
  7442. let {
  7443. value
  7444. } = _ref;
  7445. if (value) {
  7446. window.close();
  7447. }
  7448. });
  7449. }
  7450. return true;
  7451. } catch (error) {
  7452. throwError(error, 'Giveawaysu.checkLeftKey');
  7453. return false;
  7454. }
  7455. }
  7456. function GiveawaySu_getGiveawayId2() {
  7457. var _window$location$href;
  7458. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7459. if (giveawayId) {
  7460. this.giveawayId = giveawayId;
  7461. return true;
  7462. }
  7463. scripts_echoLog({
  7464. text: i18n('getFailed', 'GiveawayId')
  7465. });
  7466. return false;
  7467. }
  7468. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7469. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7470. privateSet.add(obj);
  7471. }
  7472. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7473. if (privateCollection.has(obj)) {
  7474. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7475. }
  7476. }
  7477. function Indiedb_defineProperty(obj, key, value) {
  7478. if (key in obj) {
  7479. Object.defineProperty(obj, key, {
  7480. value: value,
  7481. enumerable: true,
  7482. configurable: true,
  7483. writable: true
  7484. });
  7485. } else {
  7486. obj[key] = value;
  7487. }
  7488. return obj;
  7489. }
  7490. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7491. if (!privateSet.has(receiver)) {
  7492. throw new TypeError('attempted to get private field on non-instance');
  7493. }
  7494. return fn;
  7495. }
  7496. var _join = new WeakSet();
  7497. var _do = new WeakSet();
  7498. var Indiedb_checkLogin = new WeakSet();
  7499. var Indiedb_checkLeftKey = new WeakSet();
  7500. class Indiedb {
  7501. constructor() {
  7502. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7503. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7504. Indiedb_classPrivateMethodInitSpec(this, _do);
  7505. Indiedb_classPrivateMethodInitSpec(this, _join);
  7506. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7507. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7508. }
  7509. static test() {
  7510. return window.location.host === 'www.indiedb.com';
  7511. }
  7512. async after() {
  7513. try {
  7514. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7515. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7516. }
  7517. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7518. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7519. }
  7520. } catch (error) {
  7521. throwError(error, 'Indiedb.after');
  7522. }
  7523. }
  7524. async doTask() {
  7525. try {
  7526. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7527. return false;
  7528. }
  7529. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7530. } catch (error) {
  7531. throwError(error, 'Indiedb.doTask');
  7532. return false;
  7533. }
  7534. }
  7535. }
  7536. async function _join2() {
  7537. try {
  7538. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7539. scripts_echoLog({}).error(i18n('needLogin'));
  7540. return false;
  7541. }
  7542. const currentoption = $('a.buttonenter.buttongiveaway');
  7543. if (/join giveaway/gim.test(currentoption.text())) {
  7544. const logStatus = scripts_echoLog({
  7545. text: `${i18n('joiningGiveaway')}...`
  7546. });
  7547. const {
  7548. result,
  7549. statusText,
  7550. status,
  7551. data
  7552. } = await tools_httpRequest({
  7553. url: currentoption.attr('href'),
  7554. method: 'POST',
  7555. data: 'ajax=t',
  7556. dataType: 'json',
  7557. headers: {
  7558. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7559. accept: 'application/json, text/javascript, */*; q=0.01',
  7560. origin: window.location.origin
  7561. }
  7562. });
  7563. if (result === 'Success') {
  7564. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7565. var _data$response, _data$response4, _data$response5;
  7566. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7567. var _data$response2, _data$response3;
  7568. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7569. $('#giveawaysjoined').slideDown();
  7570. $('#giveawaysrecommend').slideDown();
  7571. 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}` : ''}`);
  7572. return true;
  7573. }
  7574. 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}` : ''}`);
  7575. return false;
  7576. }
  7577. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7578. return false;
  7579. }
  7580. logStatus.error(`${result}:${statusText}(${status})`);
  7581. return false;
  7582. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7583. return true;
  7584. }
  7585. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7586. return false;
  7587. } catch (error) {
  7588. throwError(error, 'Indiedb.init');
  7589. return false;
  7590. }
  7591. }
  7592. async function _do2() {
  7593. try {
  7594. const id = $('script').map((index, script) => {
  7595. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7596. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7597. 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] ];
  7598. }
  7599. return null;
  7600. });
  7601. if (id.length === 2) {
  7602. const pro = [];
  7603. const tasks = $('#giveawaysjoined a[class*=promo]');
  7604. for (const task of tasks) {
  7605. const promo = $(task);
  7606. if (!promo.hasClass('buttonentered')) {
  7607. const status = scripts_echoLog({
  7608. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7609. });
  7610. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7611. let text = '';
  7612. if (promo.hasClass('facebookpromo')) {
  7613. text = 'facebookpromo';
  7614. } else if (promo.hasClass('twitterpromo')) {
  7615. text = 'twitterpromo';
  7616. } else {
  7617. text = 'visitpromo';
  7618. }
  7619. pro.push(new Promise(resolve => {
  7620. $.ajax({
  7621. type: 'POST',
  7622. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7623. timeout: 6e4,
  7624. dataType: 'json',
  7625. data: {
  7626. ajax: 't'
  7627. },
  7628. error(response, error, exception) {
  7629. if (window.DEBUG) {
  7630. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7631. response: response,
  7632. error: error,
  7633. exception: exception
  7634. });
  7635. }
  7636. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7637. resolve(true);
  7638. },
  7639. success(response) {
  7640. if (response.success) {
  7641. status.success(`Success:${response.text}`);
  7642. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7643. resolve(true);
  7644. } else {
  7645. status.error(`Error:${response.text}`);
  7646. resolve(true);
  7647. }
  7648. }
  7649. });
  7650. }));
  7651. } else if (promo.hasClass('emailoptinpromo')) {
  7652. pro.push(new Promise(resolve => {
  7653. $.ajax({
  7654. type: 'POST',
  7655. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7656. timeout: 6e4,
  7657. dataType: 'json',
  7658. data: {
  7659. ajax: 't',
  7660. emailsystoggle: 4
  7661. },
  7662. error(response, error, exception) {
  7663. if (window.DEBUG) {
  7664. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7665. response: response,
  7666. error: error,
  7667. exception: exception
  7668. });
  7669. }
  7670. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7671. resolve(true);
  7672. },
  7673. success(response) {
  7674. if (response.success) {
  7675. status.success(`Success:${response.text}`);
  7676. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7677. resolve(true);
  7678. } else {
  7679. status.error(`Error:${response.text}`);
  7680. resolve(true);
  7681. }
  7682. }
  7683. });
  7684. }));
  7685. } else if (promo.hasClass('watchingpromo')) {
  7686. pro.push(new Promise(resolve => {
  7687. var _promo$attr;
  7688. const data = getUrlQuery(promo.attr('href'));
  7689. data.ajax = 't';
  7690. $.ajax({
  7691. type: 'POST',
  7692. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7693. timeout: 6e4,
  7694. dataType: 'json',
  7695. data: data,
  7696. error(response, error, exception) {
  7697. if (window.DEBUG) {
  7698. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7699. response: response,
  7700. error: error,
  7701. exception: exception
  7702. });
  7703. }
  7704. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7705. resolve(true);
  7706. },
  7707. success(response) {
  7708. if (response.success) {
  7709. status.success(`Success:${response.text}`);
  7710. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7711. resolve(true);
  7712. } else {
  7713. status.error(`Error:${response.text}`);
  7714. resolve(true);
  7715. }
  7716. }
  7717. });
  7718. }));
  7719. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7720. pro.push(new Promise(resolve => {
  7721. $.ajax({
  7722. type: 'POST',
  7723. url: urlPath(promo.attr('href')),
  7724. timeout: 6e4,
  7725. dataType: 'json',
  7726. data: {
  7727. ajax: 't'
  7728. },
  7729. error(response, error, exception) {
  7730. if (window.DEBUG) {
  7731. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7732. response: response,
  7733. error: error,
  7734. exception: exception
  7735. });
  7736. }
  7737. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7738. resolve(true);
  7739. },
  7740. success(response) {
  7741. if (response.success) {
  7742. status.success(`Success:${response.text}`);
  7743. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7744. resolve(true);
  7745. } else {
  7746. status.error(`Error:${response.text}`);
  7747. resolve(true);
  7748. }
  7749. }
  7750. });
  7751. }));
  7752. } else {
  7753. status.error(`Error:${i18n('unKnownTaskType')}`);
  7754. }
  7755. }
  7756. }
  7757. await Promise.all(pro);
  7758. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7759. return true;
  7760. }
  7761. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7762. return false;
  7763. } catch (error) {
  7764. throwError(error, 'Indiedb.classifyTask');
  7765. return false;
  7766. }
  7767. }
  7768. function Indiedb_checkLogin2() {
  7769. try {
  7770. if (!globalOptions.other.checkLogin) {
  7771. return true;
  7772. }
  7773. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7774. window.open('/members/login', '_self');
  7775. }
  7776. return true;
  7777. } catch (error) {
  7778. throwError(error, 'Indiedb.checkLogin');
  7779. return false;
  7780. }
  7781. }
  7782. async function Indiedb_checkLeftKey2() {
  7783. try {
  7784. if (!globalOptions.other.checkLeftKey) {
  7785. return true;
  7786. }
  7787. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7788. await external_Swal_default().fire({
  7789. icon: 'warning',
  7790. title: i18n('notice'),
  7791. text: i18n('giveawayEnded'),
  7792. confirmButtonText: i18n('confirm'),
  7793. cancelButtonText: i18n('cancel'),
  7794. showCancelButton: true
  7795. }).then(_ref => {
  7796. let {
  7797. value
  7798. } = _ref;
  7799. if (value) {
  7800. window.close();
  7801. }
  7802. });
  7803. }
  7804. return true;
  7805. } catch (error) {
  7806. throwError(error, 'Indiedb.checkLeftKey');
  7807. return false;
  7808. }
  7809. }
  7810. const website_Indiedb = Indiedb;
  7811. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7812. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7813. privateSet.add(obj);
  7814. }
  7815. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7816. if (privateCollection.has(obj)) {
  7817. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7818. }
  7819. }
  7820. function Keyhub_defineProperty(obj, key, value) {
  7821. if (key in obj) {
  7822. Object.defineProperty(obj, key, {
  7823. value: value,
  7824. enumerable: true,
  7825. configurable: true,
  7826. writable: true
  7827. });
  7828. } else {
  7829. obj[key] = value;
  7830. }
  7831. return obj;
  7832. }
  7833. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7834. if (!privateSet.has(receiver)) {
  7835. throw new TypeError('attempted to get private field on non-instance');
  7836. }
  7837. return fn;
  7838. }
  7839. const Keyhub_defaultTasksTemplate = {
  7840. steam: {
  7841. groupLinks: [],
  7842. officialGroupLinks: [],
  7843. wishlistLinks: [],
  7844. curatorLinks: []
  7845. },
  7846. discord: {
  7847. serverLinks: []
  7848. },
  7849. extra: {
  7850. videoTasks: []
  7851. },
  7852. links: []
  7853. };
  7854. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7855. var _doScriptTask = new WeakSet();
  7856. var Keyhub_getGiveawayId = new WeakSet();
  7857. var Keyhub_checkLeftKey = new WeakSet();
  7858. var Keyhub_checkLogin = new WeakSet();
  7859. class Keyhub extends website_Website {
  7860. constructor() {
  7861. super(...arguments);
  7862. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7863. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7864. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7865. Keyhub_classPrivateMethodInitSpec(this, _doScriptTask);
  7866. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7867. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7868. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7869. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7870. }
  7871. static test() {
  7872. return window.location.host === 'key-hub.eu';
  7873. }
  7874. async after() {
  7875. try {
  7876. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7877. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7878. }
  7879. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7880. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7881. }
  7882. $('.NSFW').hide();
  7883. } catch (error) {
  7884. throwError(error, 'Keyhub.after');
  7885. }
  7886. }
  7887. init() {
  7888. try {
  7889. const logStatus = scripts_echoLog({
  7890. text: i18n('initing')
  7891. });
  7892. if ($('a[href*="/connect/steam"]').length > 0) {
  7893. window.open('/connect/steam', '_self');
  7894. logStatus.warning(i18n('needLogin'));
  7895. return false;
  7896. }
  7897. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7898. return false;
  7899. }
  7900. $('#VPNoverlay').hide();
  7901. $('#mainArticleSection').show();
  7902. this.initialized = true;
  7903. logStatus.success();
  7904. return true;
  7905. } catch (error) {
  7906. throwError(error, 'Keyhub.init');
  7907. return false;
  7908. }
  7909. }
  7910. async classifyTask(action) {
  7911. try {
  7912. const logStatus = scripts_echoLog({
  7913. text: i18n('getTasksInfo')
  7914. });
  7915. if (action === 'undo') {
  7916. var _GM_getValue;
  7917. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7918. }
  7919. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7920. for (const task of tasks) {
  7921. let link = $(task).attr('href');
  7922. const taskDes = $(task).text().trim();
  7923. if (!link) {
  7924. continue;
  7925. }
  7926. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7927. link = await getRedirectLink(link) || link;
  7928. }
  7929. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7930. window.open(link, '_blank');
  7931. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7932. if (action === 'undo') {
  7933. this.socialTasks.steam.groupLinks.push(link);
  7934. }
  7935. if (action === 'do') {
  7936. this.undoneTasks.steam.groupLinks.push(link);
  7937. }
  7938. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7939. if (action === 'undo') {
  7940. this.socialTasks.steam.officialGroupLinks.push(link);
  7941. }
  7942. if (action === 'do') {
  7943. this.undoneTasks.steam.officialGroupLinks.push(link);
  7944. }
  7945. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7946. if (action === 'undo') {
  7947. this.socialTasks.steam.wishlistLinks.push(link);
  7948. }
  7949. if (action === 'do') {
  7950. this.undoneTasks.steam.wishlistLinks.push(link);
  7951. }
  7952. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7953. if (action === 'undo') {
  7954. this.socialTasks.steam.curatorLinks.push(link);
  7955. }
  7956. if (action === 'do') {
  7957. this.undoneTasks.steam.curatorLinks.push(link);
  7958. }
  7959. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7960. if (action === 'undo') {
  7961. this.socialTasks.discord.serverLinks.push(link);
  7962. }
  7963. if (action === 'do') {
  7964. this.undoneTasks.discord.serverLinks.push(link);
  7965. }
  7966. } else if (/^javascript:videoTask.+/.test(link)) {
  7967. if (action === 'do') {
  7968. var _link$match;
  7969. const taskData = (_link$match = link.match(/javascript:videoTask\('.+?','(.+?)'/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  7970. if (taskData) {
  7971. this.undoneTasks.extra.videoTasks.push(taskData);
  7972. }
  7973. }
  7974. } 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 {
  7975. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7976. }
  7977. }
  7978. logStatus.success();
  7979. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7980. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7981. if (window.DEBUG) {
  7982. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7983. }
  7984. GM_setValue(`khTasks-${this.giveawayId}`, {
  7985. tasks: this.socialTasks,
  7986. time: new Date().getTime()
  7987. });
  7988. return true;
  7989. } catch (error) {
  7990. throwError(error, 'Keyhub.classifyTask');
  7991. return false;
  7992. }
  7993. }
  7994. async extraDoTask(_ref) {
  7995. let {
  7996. videoTasks
  7997. } = _ref;
  7998. try {
  7999. const pro = [];
  8000. for (const data of videoTasks) {
  8001. pro.push(Keyhub_classPrivateMethodGet(this, _doScriptTask, _doScriptTask2).call(this, data));
  8002. }
  8003. return Promise.all(pro).then(() => true);
  8004. } catch (error) {
  8005. throwError(error, 'Keyhub.extraDoTask');
  8006. return false;
  8007. }
  8008. }
  8009. }
  8010. async function _doScriptTask2(data) {
  8011. try {
  8012. const logStatus = scripts_echoLog({
  8013. text: i18n('doingKeyhubTask')
  8014. });
  8015. const {
  8016. result,
  8017. statusText,
  8018. status,
  8019. data: response
  8020. } = await tools_httpRequest({
  8021. url: `/away?data=${data}`,
  8022. method: 'GET',
  8023. headers: {
  8024. origin: 'https://key-hub.eu',
  8025. referer: 'https://key-hub.eu/'
  8026. }
  8027. });
  8028. if (result === 'Success') {
  8029. if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
  8030. logStatus.success();
  8031. return true;
  8032. }
  8033. logStatus.error(`Error:${response === null || response === void 0 ? void 0 : response.statusText}(${response === null || response === void 0 ? void 0 : response.status})`);
  8034. return false;
  8035. }
  8036. logStatus.error(`${result}:${statusText}(${status})`);
  8037. return false;
  8038. } catch (error) {
  8039. throwError(error, 'Keyhub.doScriptTask');
  8040. return false;
  8041. }
  8042. }
  8043. function Keyhub_getGiveawayId2() {
  8044. try {
  8045. var _window$location$href;
  8046. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8047. if (giveawayId) {
  8048. this.giveawayId = giveawayId;
  8049. return true;
  8050. }
  8051. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8052. return false;
  8053. } catch (error) {
  8054. throwError(error, 'Keyhub.getGiveawayId');
  8055. return false;
  8056. }
  8057. }
  8058. async function Keyhub_checkLeftKey2() {
  8059. try {
  8060. if (!globalOptions.other.checkLeftKey) {
  8061. return true;
  8062. }
  8063. const leftKey = $('#keysleft').text().trim();
  8064. if (leftKey === '0') {
  8065. await external_Swal_default().fire({
  8066. icon: 'warning',
  8067. title: i18n('notice'),
  8068. text: i18n('noKeysLeft'),
  8069. confirmButtonText: i18n('confirm'),
  8070. cancelButtonText: i18n('cancel'),
  8071. showCancelButton: true
  8072. }).then(_ref2 => {
  8073. let {
  8074. value
  8075. } = _ref2;
  8076. if (value) {
  8077. window.close();
  8078. }
  8079. });
  8080. }
  8081. return true;
  8082. } catch (error) {
  8083. throwError(error, 'Keyhub.checkLeftKey');
  8084. return false;
  8085. }
  8086. }
  8087. function Keyhub_checkLogin2() {
  8088. try {
  8089. if (!globalOptions.other.checkLogin) {
  8090. return true;
  8091. }
  8092. if ($('a[href*="/connect/steam"]').length > 0) {
  8093. window.open('/connect/steam', '_self');
  8094. }
  8095. return true;
  8096. } catch (error) {
  8097. throwError(error, 'Keyhub.checkLogin');
  8098. return false;
  8099. }
  8100. }
  8101. const website_Keyhub = Keyhub;
  8102. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  8103. Givekey_checkPrivateRedeclaration(obj, privateSet);
  8104. privateSet.add(obj);
  8105. }
  8106. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  8107. if (privateCollection.has(obj)) {
  8108. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8109. }
  8110. }
  8111. function Givekey_defineProperty(obj, key, value) {
  8112. if (key in obj) {
  8113. Object.defineProperty(obj, key, {
  8114. value: value,
  8115. enumerable: true,
  8116. configurable: true,
  8117. writable: true
  8118. });
  8119. } else {
  8120. obj[key] = value;
  8121. }
  8122. return obj;
  8123. }
  8124. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  8125. if (!privateSet.has(receiver)) {
  8126. throw new TypeError('attempted to get private field on non-instance');
  8127. }
  8128. return fn;
  8129. }
  8130. const Givekey_defaultTasksTemplate = {
  8131. steam: {
  8132. groupLinks: [],
  8133. wishlistLinks: [],
  8134. curatorLinks: [],
  8135. curatorLikeLinks: []
  8136. },
  8137. twitter: {
  8138. userLinks: []
  8139. },
  8140. vk: {
  8141. nameLinks: []
  8142. },
  8143. discord: {
  8144. serverLinks: []
  8145. }
  8146. };
  8147. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  8148. var Givekey_verify = new WeakSet();
  8149. var Givekey_getGiveawayId = new WeakSet();
  8150. var Givekey_checkLeftKey = new WeakSet();
  8151. class Givekey extends website_Website {
  8152. constructor() {
  8153. super(...arguments);
  8154. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  8155. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  8156. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  8157. Givekey_defineProperty(this, 'name', 'Givekey');
  8158. Givekey_defineProperty(this, 'tasks', []);
  8159. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  8160. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  8161. Givekey_defineProperty(this, 'userId', void 0);
  8162. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8163. }
  8164. static test() {
  8165. return window.location.host === 'givekey.ru';
  8166. }
  8167. async after() {
  8168. try {
  8169. await new Promise(resolve => {
  8170. const checker = setInterval(() => {
  8171. if ($('#navbarDropdown').length > 0) {
  8172. clearInterval(checker);
  8173. resolve(true);
  8174. }
  8175. });
  8176. });
  8177. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8178. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8179. }
  8180. } catch (error) {
  8181. throwError(error, 'Givekey.after');
  8182. return false;
  8183. }
  8184. }
  8185. init() {
  8186. try {
  8187. const logStatus = scripts_echoLog({
  8188. text: i18n('initing')
  8189. });
  8190. if ($('a[href*="/auth/steam"]').length > 0) {
  8191. window.open('/auth/steam', '_self');
  8192. logStatus.warning(i18n('needLogin'));
  8193. return false;
  8194. }
  8195. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8196. return false;
  8197. }
  8198. const userId = $('meta[name="user-id"]').attr('content');
  8199. if (!userId) {
  8200. logStatus.error(i18n('getFailed', i18n('userId')));
  8201. return false;
  8202. }
  8203. this.userId = userId;
  8204. this.initialized = true;
  8205. logStatus.success();
  8206. return true;
  8207. } catch (error) {
  8208. throwError(error, 'Givekey.init');
  8209. return false;
  8210. }
  8211. }
  8212. async classifyTask(action) {
  8213. try {
  8214. const logStatus = scripts_echoLog({
  8215. text: i18n('getTasksInfo')
  8216. });
  8217. if (action === 'undo') {
  8218. var _GM_getValue;
  8219. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8220. }
  8221. const tasks = $('.card-body:has("button") .row');
  8222. for (const task of tasks) {
  8223. const taskEle = $(task);
  8224. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8225. if (isSuccess && action !== 'undo') {
  8226. continue;
  8227. }
  8228. const checkButton = taskEle.find('#task_check');
  8229. const taskId = checkButton.attr('data-id');
  8230. if (taskId) {
  8231. this.tasks.push(taskId);
  8232. }
  8233. if (action === 'verify') {
  8234. continue;
  8235. }
  8236. let href = taskEle.find('a').attr('href') || null;
  8237. const text = taskEle.find('a').text().trim();
  8238. const icon = taskEle.find('i');
  8239. if (!href || !text) {
  8240. continue;
  8241. }
  8242. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8243. href = await getRedirectLink(href);
  8244. }
  8245. if (!href) {
  8246. continue;
  8247. }
  8248. if (/^https?:\/\/vk\.com\//.test(href)) {
  8249. this.socialTasks.vk.nameLinks.push(href);
  8250. if (action === 'do' && !isSuccess) {
  8251. this.undoneTasks.vk.nameLinks.push(href);
  8252. }
  8253. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8254. this.socialTasks.steam.groupLinks.push(href);
  8255. if (action === 'do' && !isSuccess) {
  8256. this.undoneTasks.steam.groupLinks.push(href);
  8257. }
  8258. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8259. this.socialTasks.steam.wishlistLinks.push(href);
  8260. if (action === 'do' && !isSuccess) {
  8261. this.undoneTasks.steam.wishlistLinks.push(href);
  8262. }
  8263. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8264. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8265. this.socialTasks.steam.curatorLinks.push(href);
  8266. if (action === 'do' && !isSuccess) {
  8267. this.undoneTasks.steam.curatorLinks.push(href);
  8268. }
  8269. } else {
  8270. this.socialTasks.steam.curatorLikeLinks.push(href);
  8271. if (action === 'do' && !isSuccess) {
  8272. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8273. }
  8274. }
  8275. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8276. this.socialTasks.twitter.userLinks.push(href);
  8277. if (action === 'do' && !isSuccess) {
  8278. this.undoneTasks.twitter.userLinks.push(href);
  8279. }
  8280. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8281. this.socialTasks.discord.serverLinks.push(href);
  8282. if (action === 'do' && !isSuccess) {
  8283. this.undoneTasks.discord.serverLinks.push(href);
  8284. }
  8285. } else {
  8286. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8287. }
  8288. }
  8289. logStatus.success();
  8290. this.tasks = unique(this.tasks);
  8291. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8292. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8293. if (window.DEBUG) {
  8294. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8295. }
  8296. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8297. tasks: this.socialTasks,
  8298. time: new Date().getTime()
  8299. });
  8300. return true;
  8301. } catch (error) {
  8302. throwError(error, 'Givekey.classifyTask');
  8303. return false;
  8304. }
  8305. }
  8306. async verifyTask() {
  8307. try {
  8308. if (!this.initialized && !this.init()) {
  8309. return false;
  8310. }
  8311. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8312. return false;
  8313. }
  8314. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8315. const taskLength = this.tasks.length;
  8316. for (let i = 0; i < taskLength; i++) {
  8317. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8318. if (i < taskLength - 1) {
  8319. await delay(15e3);
  8320. }
  8321. }
  8322. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8323. scripts_echoLog({
  8324. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8325. });
  8326. return true;
  8327. } catch (error) {
  8328. throwError(error, 'Givekey.verifyTask');
  8329. return false;
  8330. }
  8331. }
  8332. }
  8333. async function Givekey_verify2(task) {
  8334. try {
  8335. const logStatus = scripts_echoLog({
  8336. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8337. });
  8338. return await new Promise(resolve => {
  8339. $.ajax({
  8340. url: 'https://givekey.ru/giveaway/task',
  8341. method: 'POST',
  8342. data: `id=${task}&user_id=${this.userId}`,
  8343. dataType: 'json',
  8344. headers: {
  8345. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8346. },
  8347. success: data => {
  8348. if (data.btn) {
  8349. $(`button[data-id=${this.userId}]`).html(data.btn);
  8350. }
  8351. if (data.status === 'ok') {
  8352. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8353. logStatus.success();
  8354. resolve(true);
  8355. } else if (data.status === 'end') {
  8356. logStatus.success();
  8357. scripts_echoLog({}).success(data.key);
  8358. resolve(true);
  8359. } else {
  8360. logStatus.error(`Error:${data.msg}`);
  8361. resolve(false);
  8362. }
  8363. },
  8364. error: xhr => {
  8365. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8366. resolve(false);
  8367. }
  8368. });
  8369. });
  8370. } catch (error) {
  8371. throwError(error, 'Givekey.verify');
  8372. return false;
  8373. }
  8374. }
  8375. function Givekey_getGiveawayId2() {
  8376. try {
  8377. var _window$location$href;
  8378. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8379. if (giveawayId) {
  8380. this.giveawayId = giveawayId;
  8381. return true;
  8382. }
  8383. scripts_echoLog({
  8384. text: i18n('getFailed', 'GiveawayId')
  8385. });
  8386. return false;
  8387. } catch (error) {
  8388. throwError(error, 'Givekey.getGiveawayId');
  8389. return false;
  8390. }
  8391. }
  8392. async function Givekey_checkLeftKey2() {
  8393. try {
  8394. if (!globalOptions.other.checkLeftKey) {
  8395. return true;
  8396. }
  8397. if (!$('#keys_count').text()) {
  8398. await external_Swal_default().fire({
  8399. icon: 'warning',
  8400. title: i18n('notice'),
  8401. text: i18n('noKeysLeft'),
  8402. confirmButtonText: i18n('confirm'),
  8403. cancelButtonText: i18n('cancel'),
  8404. showCancelButton: true
  8405. }).then(_ref => {
  8406. let {
  8407. value
  8408. } = _ref;
  8409. if (value) {
  8410. window.close();
  8411. }
  8412. });
  8413. }
  8414. return true;
  8415. } catch (error) {
  8416. throwError(error, 'Givekey.checkLeftKey');
  8417. return false;
  8418. }
  8419. }
  8420. const website_Givekey = Givekey;
  8421. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8422. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8423. privateSet.add(obj);
  8424. }
  8425. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8426. if (privateCollection.has(obj)) {
  8427. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8428. }
  8429. }
  8430. function GiveeClub_defineProperty(obj, key, value) {
  8431. if (key in obj) {
  8432. Object.defineProperty(obj, key, {
  8433. value: value,
  8434. enumerable: true,
  8435. configurable: true,
  8436. writable: true
  8437. });
  8438. } else {
  8439. obj[key] = value;
  8440. }
  8441. return obj;
  8442. }
  8443. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8444. if (!privateSet.has(receiver)) {
  8445. throw new TypeError('attempted to get private field on non-instance');
  8446. }
  8447. return fn;
  8448. }
  8449. var GiveeClub_checkLogin = new WeakSet();
  8450. var GiveeClub_getGiveawayId = new WeakSet();
  8451. var GiveeClub_checkLeftKey = new WeakSet();
  8452. class GiveeClub extends GiveawaySu {
  8453. constructor() {
  8454. super(...arguments);
  8455. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8456. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8457. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8458. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8459. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8460. }
  8461. static test() {
  8462. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8463. }
  8464. async after() {
  8465. try {
  8466. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8467. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8468. }
  8469. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8470. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8471. }
  8472. } catch (error) {
  8473. throwError(error, 'GiveeClub.after');
  8474. }
  8475. }
  8476. init() {
  8477. try {
  8478. const logStatus = scripts_echoLog({
  8479. text: i18n('initing')
  8480. });
  8481. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8482. logStatus.warning(i18n('needLogin'));
  8483. return false;
  8484. }
  8485. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8486. return false;
  8487. }
  8488. this.initialized = true;
  8489. logStatus.success();
  8490. return true;
  8491. } catch (error) {
  8492. throwError(error, 'GiveeClub.init');
  8493. return false;
  8494. }
  8495. }
  8496. async classifyTask(action) {
  8497. try {
  8498. const logStatus = scripts_echoLog({
  8499. text: i18n('getTasksInfo')
  8500. });
  8501. if (action === 'undo') {
  8502. var _GM_getValue;
  8503. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8504. return true;
  8505. }
  8506. const pro = [];
  8507. const tasks = $('.event-actions tr');
  8508. for (const task of tasks) {
  8509. pro.push(new Promise(resolve => {
  8510. var _$$find;
  8511. const taskDes = $(task).find('.event-action-label a');
  8512. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8513. const taskName = taskDes.text().trim();
  8514. const taskType = (_$$find = $(task).find('button[data-type]')) === null || _$$find === void 0 ? void 0 : _$$find.attr('data-type');
  8515. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8516. return resolve(true);
  8517. }
  8518. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8519. if (!taskLink) {
  8520. return resolve(false);
  8521. }
  8522. if (taskType === 'steam.group.join' && /^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8523. this.undoneTasks.steam.groupLinks.push(taskLink);
  8524. } else if (/like.*announcement/gi.test(taskName)) {
  8525. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8526. } else if (taskType === 'steam.game.wishlist' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8527. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8528. } else if (taskType === 'steam.game.wishlist' && taskDes.attr('data-steam-wishlist-appid')) {
  8529. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8530. } else if (taskType === 'steam.game.follow' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8531. this.undoneTasks.steam.followLinks.push(taskLink);
  8532. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8533. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8534. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8535. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8536. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8537. this.undoneTasks.steam.forumLinks.push(taskLink);
  8538. } else if (taskIcon.includes('discord')) {
  8539. this.undoneTasks.discord.serverLinks.push(taskLink);
  8540. } else if (taskIcon.includes('instagram')) {
  8541. this.undoneTasks.instagram.userLinks.push(taskLink);
  8542. } else if (taskIcon.includes('twitch')) {
  8543. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8544. } else if (taskIcon.includes('reddit')) {
  8545. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8546. } else if (/watch.*art/gim.test(taskName)) {
  8547. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8548. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8549. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8550. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8551. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8552. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8553. this.undoneTasks.vk.nameLinks.push(taskLink);
  8554. } else {
  8555. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8556. if (/follow.*button/gim.test(taskName)) {
  8557. this.undoneTasks.steam.followLinks.push(taskLink);
  8558. }
  8559. }
  8560. }
  8561. resolve(true);
  8562. }).catch(error => {
  8563. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8564. return false;
  8565. });
  8566. }));
  8567. }
  8568. await Promise.all(pro);
  8569. logStatus.success();
  8570. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8571. this.socialTasks = this.undoneTasks;
  8572. if (window.DEBUG) {
  8573. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8574. }
  8575. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8576. tasks: this.socialTasks,
  8577. time: new Date().getTime()
  8578. });
  8579. return true;
  8580. } catch (error) {
  8581. throwError(error, 'GiveeClub.classifyTask');
  8582. return false;
  8583. }
  8584. }
  8585. async verifyTask() {
  8586. try {
  8587. const logStatus = scripts_echoLog({
  8588. text: i18n('giveeClubVerifyNotice')
  8589. });
  8590. const taskButtons = $('.event-actions tr button').has('i.glyphicon-refresh').not('[data-type="user.adblock"]');
  8591. for (const button of taskButtons) {
  8592. button.click();
  8593. if ($(button).attr('data-type') !== 'steam.game.wishlist') {
  8594. await delay(1e3);
  8595. }
  8596. }
  8597. logStatus.warning(i18n('giveeClubVerifyFinished'));
  8598. return true;
  8599. } catch (error) {
  8600. throwError(error, 'Givekey.verifyTask');
  8601. return false;
  8602. }
  8603. }
  8604. }
  8605. function GiveeClub_checkLogin2() {
  8606. try {
  8607. if (!globalOptions.other.checkLogin) {
  8608. return true;
  8609. }
  8610. if ($('a[href*="/account/auth"]').length > 0) {
  8611. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8612. }
  8613. return true;
  8614. } catch (error) {
  8615. throwError(error, 'GiveeClub.checkLogin');
  8616. return false;
  8617. }
  8618. }
  8619. function GiveeClub_getGiveawayId2() {
  8620. var _window$location$href;
  8621. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8622. if (giveawayId) {
  8623. this.giveawayId = giveawayId;
  8624. return true;
  8625. }
  8626. scripts_echoLog({
  8627. text: i18n('getFailed', 'GiveawayId')
  8628. });
  8629. return false;
  8630. }
  8631. async function GiveeClub_checkLeftKey2() {
  8632. try {
  8633. if (!globalOptions.other.checkLeftKey) {
  8634. return true;
  8635. }
  8636. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8637. await external_Swal_default().fire({
  8638. icon: 'warning',
  8639. title: i18n('notice'),
  8640. text: i18n('giveawayEnded'),
  8641. confirmButtonText: i18n('confirm'),
  8642. cancelButtonText: i18n('cancel'),
  8643. showCancelButton: true
  8644. }).then(_ref => {
  8645. let {
  8646. value
  8647. } = _ref;
  8648. if (value) {
  8649. window.close();
  8650. }
  8651. });
  8652. }
  8653. return true;
  8654. } catch (error) {
  8655. throwError(error, 'Giveawaysu.checkLeftKey');
  8656. return false;
  8657. }
  8658. }
  8659. const website_GiveeClub = GiveeClub;
  8660. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8661. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8662. privateSet.add(obj);
  8663. }
  8664. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8665. if (privateCollection.has(obj)) {
  8666. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8667. }
  8668. }
  8669. function OpiumPulses_defineProperty(obj, key, value) {
  8670. if (key in obj) {
  8671. Object.defineProperty(obj, key, {
  8672. value: value,
  8673. enumerable: true,
  8674. configurable: true,
  8675. writable: true
  8676. });
  8677. } else {
  8678. obj[key] = value;
  8679. }
  8680. return obj;
  8681. }
  8682. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8683. if (!privateSet.has(receiver)) {
  8684. throw new TypeError('attempted to get private field on non-instance');
  8685. }
  8686. return fn;
  8687. }
  8688. const defaultOptions = {
  8689. maxPoint: '99999999'
  8690. };
  8691. var _toggleTask = new WeakSet();
  8692. var OpiumPulses_checkLogin = new WeakSet();
  8693. class OpiumPulses {
  8694. constructor() {
  8695. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8696. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8697. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8698. OpiumPulses_defineProperty(this, 'options', {
  8699. ...defaultOptions,
  8700. ...GM_getValue('OpiumPulsesOptions')
  8701. });
  8702. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8703. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8704. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8705. }
  8706. static test() {
  8707. return window.location.host === 'www.opiumpulses.com';
  8708. }
  8709. async after() {
  8710. try {
  8711. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8712. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8713. }
  8714. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8715. } catch (error) {
  8716. throwError(error, 'OpiumPulses.after');
  8717. }
  8718. }
  8719. async doFreeTask() {
  8720. try {
  8721. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8722. } catch (error) {
  8723. throwError(error, 'OpiumPulses.doFreeTask');
  8724. }
  8725. }
  8726. async doPointTask() {
  8727. try {
  8728. var _$$text$match;
  8729. 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);
  8730. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8731. } catch (error) {
  8732. throwError(error, 'OpiumPulses.doPointTask');
  8733. }
  8734. }
  8735. init() {
  8736. return true;
  8737. }
  8738. classifyTask() {
  8739. return true;
  8740. }
  8741. }
  8742. async function _toggleTask2(type) {
  8743. try {
  8744. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8745. for (const item of items) {
  8746. var _$$find$text$match;
  8747. 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);
  8748. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8749. if (type === 'points' && needPoints > this.myPoints) {
  8750. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8751. } else if (type === 'points' && !needPoints) {
  8752. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8753. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8754. var _aElement$attr;
  8755. const logStatus = scripts_echoLog({
  8756. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8757. });
  8758. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8759. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8760. var _aElement$attr2, _aElement$attr2$match;
  8761. 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];
  8762. if (giveawayId) {
  8763. checkUser(giveawayId);
  8764. }
  8765. }
  8766. if (!aElement.attr('href')) {
  8767. logStatus.error('Error: No "href".');
  8768. continue;
  8769. }
  8770. const {
  8771. result,
  8772. statusText,
  8773. status,
  8774. data
  8775. } = await tools_httpRequest({
  8776. url: aElement.attr('href'),
  8777. method: 'GET'
  8778. });
  8779. if (result === 'Success') {
  8780. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8781. var _data$responseText$ma;
  8782. logStatus.success();
  8783. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8784. if (type === 'points' && points) {
  8785. this.myPoints = parseInt(points, 10);
  8786. }
  8787. } else {
  8788. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8789. }
  8790. } else {
  8791. logStatus.error(`${result}:${statusText}(${status})`);
  8792. }
  8793. }
  8794. }
  8795. scripts_echoLog({
  8796. text: '-----END-----'
  8797. });
  8798. } catch (error) {
  8799. throwError(error, 'OpiumPulses.toggleTask');
  8800. }
  8801. }
  8802. function OpiumPulses_checkLogin2() {
  8803. try {
  8804. if (!globalOptions.other.checkLogin) {
  8805. return true;
  8806. }
  8807. if ($('a[href*="/site/login"]').length > 1) {
  8808. window.open('/site/login', '_self');
  8809. }
  8810. return true;
  8811. } catch (error) {
  8812. throwError(error, 'OpiumPulses.checkLogin');
  8813. return false;
  8814. }
  8815. }
  8816. const website_OpiumPulses = OpiumPulses;
  8817. const external_dayjs_namespaceObject = dayjs;
  8818. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8819. const leftKeyChecker = {
  8820. async classify(link) {
  8821. try {
  8822. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8823. return await this.giveawaySu(link);
  8824. }
  8825. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8826. return await this.giveeClub(link);
  8827. }
  8828. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8829. return await this.gleam(link);
  8830. }
  8831. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8832. return await this.indieDb(link);
  8833. }
  8834. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8835. return await this.keyhub(link);
  8836. }
  8837. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8838. return await this.opquests(link);
  8839. }
  8840. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8841. return await this.itch(link);
  8842. }
  8843. return false;
  8844. } catch (error) {
  8845. throwError(error, 'leftKeyChecker.classify');
  8846. return false;
  8847. }
  8848. },
  8849. async giveawaySu(link) {
  8850. try {
  8851. const {
  8852. result,
  8853. data
  8854. } = await tools_httpRequest({
  8855. url: link,
  8856. method: 'GET'
  8857. });
  8858. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8859. if (data.responseText.includes('class="steam-login"')) {
  8860. return false;
  8861. }
  8862. if (data.responseText.includes('class="giveaway-ended"')) {
  8863. return 'Ended';
  8864. }
  8865. return 'Active';
  8866. }
  8867. return false;
  8868. } catch (error) {
  8869. throwError(error, 'leftKeyChecker.giveawaySu');
  8870. return false;
  8871. }
  8872. },
  8873. async giveeClub(link) {
  8874. try {
  8875. const {
  8876. result,
  8877. data
  8878. } = await tools_httpRequest({
  8879. url: link,
  8880. method: 'GET'
  8881. });
  8882. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8883. if (data.responseText.includes('class="event-winner"')) {
  8884. return 'Won';
  8885. }
  8886. if (data.responseText.includes('class="event-ended"')) {
  8887. return 'Ended';
  8888. }
  8889. return 'Active';
  8890. }
  8891. return false;
  8892. } catch (error) {
  8893. throwError(error, 'leftKeyChecker.giveeClub');
  8894. return false;
  8895. }
  8896. },
  8897. async gleam(link) {
  8898. try {
  8899. const {
  8900. result,
  8901. data
  8902. } = await tools_httpRequest({
  8903. url: link,
  8904. method: 'GET'
  8905. });
  8906. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8907. var _data$responseText$ma, _$$attr, _$$attr$match;
  8908. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8909. return 'Won';
  8910. }
  8911. 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];
  8912. if (!campaignDiv) {
  8913. return false;
  8914. }
  8915. 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];
  8916. if (!campaignString) {
  8917. return false;
  8918. }
  8919. const {
  8920. campaign
  8921. } = JSON.parse(campaignString);
  8922. if (campaign.banned) {
  8923. return 'Banned';
  8924. }
  8925. if (campaign.finished) {
  8926. return 'Ended';
  8927. }
  8928. if (campaign.paused) {
  8929. return 'Paused';
  8930. }
  8931. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8932. return 'NotStart';
  8933. }
  8934. return 'Active';
  8935. }
  8936. return false;
  8937. } catch (error) {
  8938. throwError(error, 'leftKeyChecker.gleam');
  8939. return false;
  8940. }
  8941. },
  8942. async indieDb(link) {
  8943. try {
  8944. const {
  8945. result,
  8946. data
  8947. } = await tools_httpRequest({
  8948. url: link,
  8949. method: 'GET'
  8950. });
  8951. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8952. if (data.responseText.includes('Congrats you WON')) {
  8953. return 'Won';
  8954. }
  8955. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8956. return 'Ended';
  8957. }
  8958. return 'Active';
  8959. }
  8960. return false;
  8961. } catch (error) {
  8962. throwError(error, 'leftKeyChecker.indieDb');
  8963. return false;
  8964. }
  8965. },
  8966. async keyhub(link) {
  8967. try {
  8968. const {
  8969. result,
  8970. data
  8971. } = await tools_httpRequest({
  8972. url: link,
  8973. method: 'GET'
  8974. });
  8975. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8976. var _data$responseText$ma2;
  8977. 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];
  8978. if (!keysleft) {
  8979. return false;
  8980. }
  8981. if (keysleft === '0') {
  8982. return 'Ended';
  8983. }
  8984. return `Active(${keysleft})`;
  8985. }
  8986. return false;
  8987. } catch (error) {
  8988. throwError(error, 'leftKeyChecker.keyhub');
  8989. return false;
  8990. }
  8991. },
  8992. async opquests(link) {
  8993. try {
  8994. const {
  8995. result,
  8996. data
  8997. } = await tools_httpRequest({
  8998. url: link,
  8999. method: 'GET'
  9000. });
  9001. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9002. var _data$responseText$ma3;
  9003. 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];
  9004. if (!keysleft) {
  9005. return false;
  9006. }
  9007. if (keysleft === '0') {
  9008. return 'Ended';
  9009. }
  9010. return `Active(${keysleft})`;
  9011. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  9012. return 'Ended';
  9013. }
  9014. return false;
  9015. } catch (error) {
  9016. throwError(error, 'leftKeyChecker.opquests');
  9017. return false;
  9018. }
  9019. },
  9020. async itch(link) {
  9021. try {
  9022. const {
  9023. result,
  9024. data
  9025. } = await tools_httpRequest({
  9026. url: link,
  9027. method: 'GET'
  9028. });
  9029. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  9030. var _data$responseText$ma4;
  9031. 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];
  9032. if (!endDate) {
  9033. return false;
  9034. }
  9035. if (new Date().getTime() > new Date(endDate).getTime()) {
  9036. return 'Ended';
  9037. }
  9038. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  9039. }
  9040. return false;
  9041. } catch (error) {
  9042. throwError(error, 'leftKeyChecker.opquests');
  9043. return false;
  9044. }
  9045. }
  9046. };
  9047. const website_leftKeyChecker = leftKeyChecker;
  9048. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  9049. Keylol_checkPrivateRedeclaration(obj, privateSet);
  9050. privateSet.add(obj);
  9051. }
  9052. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  9053. if (privateCollection.has(obj)) {
  9054. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9055. }
  9056. }
  9057. function Keylol_defineProperty(obj, key, value) {
  9058. if (key in obj) {
  9059. Object.defineProperty(obj, key, {
  9060. value: value,
  9061. enumerable: true,
  9062. configurable: true,
  9063. writable: true
  9064. });
  9065. } else {
  9066. obj[key] = value;
  9067. }
  9068. return obj;
  9069. }
  9070. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  9071. if (!privateSet.has(receiver)) {
  9072. throw new TypeError('attempted to get private field on non-instance');
  9073. }
  9074. return fn;
  9075. }
  9076. const Keylol_defaultTasksTemplate = {
  9077. steam: {
  9078. groupLinks: [],
  9079. wishlistLinks: [],
  9080. curatorLinks: [],
  9081. curatorLikeLinks: [],
  9082. followLinks: [],
  9083. forumLinks: [],
  9084. announcementLinks: [],
  9085. workshopVoteLinks: [],
  9086. licenseLinks: []
  9087. },
  9088. discord: {
  9089. serverLinks: []
  9090. },
  9091. instagram: {
  9092. userLinks: []
  9093. },
  9094. vk: {
  9095. nameLinks: []
  9096. },
  9097. twitch: {
  9098. channelLinks: []
  9099. },
  9100. reddit: {
  9101. redditLinks: []
  9102. },
  9103. twitter: {
  9104. userLinks: [],
  9105. retweetLinks: []
  9106. },
  9107. youtube: {
  9108. channelLinks: [],
  9109. likeLinks: []
  9110. }
  9111. };
  9112. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  9113. var _addBtn = new WeakSet();
  9114. class Keylol extends website_Website {
  9115. constructor() {
  9116. super(...arguments);
  9117. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  9118. Keylol_defineProperty(this, 'name', 'Keylol');
  9119. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  9120. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  9121. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  9122. }
  9123. static test() {
  9124. var _$$eq$attr, _$$eq$attr2;
  9125. 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')));
  9126. }
  9127. init() {
  9128. return true;
  9129. }
  9130. after() {
  9131. try {
  9132. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  9133. const mainPost = $(selector);
  9134. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  9135. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  9136. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  9137. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  9138. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  9139. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  9140. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  9141. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  9142. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  9143. if (discordLinks.length > 0) {
  9144. for (const discordLink of discordLinks) {
  9145. const link = $(discordLink).attr('href');
  9146. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  9147. continue;
  9148. }
  9149. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  9150. }
  9151. }
  9152. if (redditLinks.length > 0) {
  9153. for (const redditLink of redditLinks) {
  9154. const link = $(redditLink).attr('href');
  9155. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  9156. continue;
  9157. }
  9158. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  9159. }
  9160. }
  9161. if (insLinks.length > 0) {
  9162. for (const insLink of insLinks) {
  9163. const link = $(insLink).attr('href');
  9164. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  9165. continue;
  9166. }
  9167. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  9168. }
  9169. }
  9170. if (twitterLinks.length > 0) {
  9171. for (const twitterLink of twitterLinks) {
  9172. const link = $(twitterLink).attr('href');
  9173. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  9174. continue;
  9175. }
  9176. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  9177. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  9178. } else {
  9179. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  9180. }
  9181. }
  9182. }
  9183. if (twitchLinks.length > 0) {
  9184. for (const twitchLink of twitchLinks) {
  9185. const link = $(twitchLink).attr('href');
  9186. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  9187. continue;
  9188. }
  9189. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9190. }
  9191. }
  9192. if (vkLinks.length > 0) {
  9193. for (const vkLink of vkLinks) {
  9194. const link = $(vkLink).attr('href');
  9195. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9196. continue;
  9197. }
  9198. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9199. }
  9200. }
  9201. if (steamStoreLinks.length > 0) {
  9202. for (const steamStoreLink of steamStoreLinks) {
  9203. const link = $(steamStoreLink).attr('href');
  9204. if (!link) {
  9205. continue;
  9206. }
  9207. if (/curator\/[\d]+/.test(link)) {
  9208. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9209. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9210. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9211. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9212. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9213. } else if (/app\/[\d]+/.test(link)) {
  9214. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9215. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9216. }
  9217. }
  9218. }
  9219. if (steamCommunityLinks.length > 0) {
  9220. for (const steamCommunityLink of steamCommunityLinks) {
  9221. const link = $(steamCommunityLink).attr('href');
  9222. if (!link) {
  9223. continue;
  9224. }
  9225. if (/groups\/.+/.test(link)) {
  9226. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9227. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9228. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9229. }
  9230. }
  9231. }
  9232. if (ytbLinks.length > 0) {
  9233. for (const ytbLink of ytbLinks) {
  9234. const link = $(ytbLink).attr('href');
  9235. if (!link) {
  9236. continue;
  9237. }
  9238. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9239. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9240. }
  9241. }
  9242. 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');
  9243. if (giveawayLinks.length > 0) {
  9244. for (const giveawayLink of giveawayLinks) {
  9245. const link = $(giveawayLink).attr('href');
  9246. if (!link) {
  9247. continue;
  9248. }
  9249. website_leftKeyChecker.classify(link).then(status => {
  9250. if (!status) {
  9251. return;
  9252. }
  9253. if (/^Active/.test(status)) {
  9254. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9255. return;
  9256. }
  9257. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9258. }).catch(error => {
  9259. throwError(error, 'keylol.after -> leftKeyChecker');
  9260. });
  9261. }
  9262. }
  9263. if (this.name === 'Keylol') {
  9264. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9265. if (asfLinks.length > 0) {
  9266. for (const asfLink of asfLinks) {
  9267. const link = $(asfLink).attr('href');
  9268. if (!link) {
  9269. continue;
  9270. }
  9271. 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', '')}`);
  9272. }
  9273. }
  9274. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9275. if (subLinks.length > 0) {
  9276. for (const subLink of subLinks) {
  9277. var _link$match;
  9278. const link = $(subLink).attr('href');
  9279. if (!link) {
  9280. continue;
  9281. }
  9282. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9283. if (!subid) {
  9284. continue;
  9285. }
  9286. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9287. }
  9288. }
  9289. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9290. if (asfLinks2.length > 0) {
  9291. for (const asfLink of asfLinks2) {
  9292. const subid = asfLink.innerText.match(/[\d]+/g);
  9293. if (!subid || subid.length === 0) {
  9294. continue;
  9295. }
  9296. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9297. }
  9298. }
  9299. }
  9300. } catch (error) {
  9301. throwError(error, 'keylol.after');
  9302. }
  9303. }
  9304. classifyTask(action) {
  9305. try {
  9306. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9307. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9308. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9309. for (const btn of selectedBtns) {
  9310. const button = $(btn);
  9311. const social = button.attr('data-social');
  9312. const type = button.attr('data-type');
  9313. const link = button.attr('data-link');
  9314. if (!(social && type && link)) {
  9315. continue;
  9316. }
  9317. if (action === 'do') {
  9318. this.undoneTasks[social][type].push(link);
  9319. }
  9320. if (action === 'undo') {
  9321. this.socialTasks[social][type].push(link);
  9322. }
  9323. }
  9324. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9325. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9326. if (window.DEBUG) {
  9327. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9328. }
  9329. return true;
  9330. } catch (error) {
  9331. throwError(error, 'Keylol.classifyTask');
  9332. return false;
  9333. }
  9334. }
  9335. selectAll() {
  9336. try {
  9337. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9338. } catch (error) {
  9339. throwError(error, 'Keylol.selectAll');
  9340. }
  9341. }
  9342. selectNone() {
  9343. try {
  9344. $('.auto-task-keylol:visible').removeAttr('selected');
  9345. } catch (error) {
  9346. throwError(error, 'Keylol.selectNone');
  9347. }
  9348. }
  9349. invertSelect() {
  9350. try {
  9351. $('.auto-task-keylol:visible').each((index, element) => {
  9352. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9353. });
  9354. } catch (error) {
  9355. throwError(error, 'Keylol.invertSelect');
  9356. }
  9357. }
  9358. }
  9359. function _addBtn2(before, social, linkType, link) {
  9360. try {
  9361. $(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>`);
  9362. } catch (error) {
  9363. throwError(error, 'keylol.addBtn');
  9364. }
  9365. }
  9366. const website_Keylol = Keylol;
  9367. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9368. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9369. privateSet.add(obj);
  9370. }
  9371. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9372. if (privateCollection.has(obj)) {
  9373. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9374. }
  9375. }
  9376. function Opquests_defineProperty(obj, key, value) {
  9377. if (key in obj) {
  9378. Object.defineProperty(obj, key, {
  9379. value: value,
  9380. enumerable: true,
  9381. configurable: true,
  9382. writable: true
  9383. });
  9384. } else {
  9385. obj[key] = value;
  9386. }
  9387. return obj;
  9388. }
  9389. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9390. if (!privateSet.has(receiver)) {
  9391. throw new TypeError('attempted to get private field on non-instance');
  9392. }
  9393. return fn;
  9394. }
  9395. const Opquests_defaultTasks = {
  9396. steam: {
  9397. groupLinks: [],
  9398. wishlistLinks: [],
  9399. followLinks: [],
  9400. curatorLikeLinks: []
  9401. }
  9402. };
  9403. var Opquests_getGiveawayId = new WeakSet();
  9404. var Opquests_checkLogin = new WeakSet();
  9405. class Opquests extends website_Website {
  9406. constructor() {
  9407. super(...arguments);
  9408. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9409. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9410. Opquests_defineProperty(this, 'name', 'Opquests');
  9411. Opquests_defineProperty(this, 'undoneTasks', {
  9412. ...Opquests_defaultTasks
  9413. });
  9414. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9415. }
  9416. static test() {
  9417. return window.location.host === 'opquests.com';
  9418. }
  9419. async after() {
  9420. try {
  9421. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9422. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9423. }
  9424. } catch (error) {
  9425. throwError(error, 'Opquests.after');
  9426. }
  9427. }
  9428. init() {
  9429. try {
  9430. const logStatus = scripts_echoLog({
  9431. text: i18n('initing')
  9432. });
  9433. if ($('a[href*="/auth/redirect"]').length > 0) {
  9434. window.open('/auth/redirect', '_self');
  9435. logStatus.warning(i18n('needLogin'));
  9436. return false;
  9437. }
  9438. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9439. return false;
  9440. }
  9441. this.initialized = true;
  9442. logStatus.success();
  9443. return true;
  9444. } catch (error) {
  9445. throwError(error, 'Opquests.init');
  9446. return false;
  9447. }
  9448. }
  9449. async classifyTask(action) {
  9450. try {
  9451. if (action === 'undo') {
  9452. scripts_echoLog({
  9453. text: i18n('cannotUndo')
  9454. });
  9455. return false;
  9456. }
  9457. const logStatus = scripts_echoLog({
  9458. text: i18n('getTasksInfo')
  9459. });
  9460. const tasks = $('.w-full:contains("Validate") .items-center');
  9461. for (const task of tasks) {
  9462. const link = $(task).find('a:contains("Open")').attr('href');
  9463. const taskDes = $(task).find('div').eq(1).text().trim();
  9464. if (!link) {
  9465. continue;
  9466. }
  9467. if (/steamcommunity\.com\/groups\//.test(link)) {
  9468. this.undoneTasks.steam.groupLinks.push(link);
  9469. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9470. if (/wishlist/gim.test(taskDes)) {
  9471. this.undoneTasks.steam.wishlistLinks.push(link);
  9472. } else if (/follow/gim.test(taskDes)) {
  9473. this.undoneTasks.steam.followLinks.push(link);
  9474. }
  9475. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9476. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9477. } else {
  9478. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9479. }
  9480. }
  9481. logStatus.success();
  9482. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9483. if (window.DEBUG) {
  9484. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9485. }
  9486. return true;
  9487. } catch (error) {
  9488. throwError(error, 'Opquests.classifyTask');
  9489. return false;
  9490. }
  9491. }
  9492. }
  9493. function Opquests_getGiveawayId2() {
  9494. try {
  9495. var _window$location$href;
  9496. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9497. if (giveawayId) {
  9498. this.giveawayId = giveawayId;
  9499. return true;
  9500. }
  9501. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9502. return false;
  9503. } catch (error) {
  9504. throwError(error, 'Opquests.getGiveawayId');
  9505. return false;
  9506. }
  9507. }
  9508. function Opquests_checkLogin2() {
  9509. try {
  9510. if (!globalOptions.other.checkLogin) {
  9511. return true;
  9512. }
  9513. if ($('a[href*="/auth/redirect"]').length > 0) {
  9514. window.open('/auth/redirect', '_self');
  9515. }
  9516. return true;
  9517. } catch (error) {
  9518. throwError(error, 'Opquests.checkLogin');
  9519. return false;
  9520. }
  9521. }
  9522. const website_Opquests = Opquests;
  9523. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9524. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9525. privateSet.add(obj);
  9526. }
  9527. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9528. if (privateCollection.has(obj)) {
  9529. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9530. }
  9531. }
  9532. function Gleam_defineProperty(obj, key, value) {
  9533. if (key in obj) {
  9534. Object.defineProperty(obj, key, {
  9535. value: value,
  9536. enumerable: true,
  9537. configurable: true,
  9538. writable: true
  9539. });
  9540. } else {
  9541. obj[key] = value;
  9542. }
  9543. return obj;
  9544. }
  9545. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9546. if (!privateSet.has(receiver)) {
  9547. throw new TypeError('attempted to get private field on non-instance');
  9548. }
  9549. return fn;
  9550. }
  9551. const Gleam_defaultTasksTemplate = {
  9552. steam: {
  9553. groupLinks: [],
  9554. wishlistLinks: [],
  9555. followLinks: [],
  9556. curatorLinks: [],
  9557. curatorLikeLinks: []
  9558. },
  9559. twitter: {
  9560. userLinks: [],
  9561. retweetLinks: []
  9562. },
  9563. twitch: {
  9564. channelLinks: []
  9565. },
  9566. discord: {
  9567. serverLinks: []
  9568. },
  9569. youtube: {
  9570. channelLinks: []
  9571. },
  9572. extra: {
  9573. gleam: []
  9574. }
  9575. };
  9576. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9577. const Gleam_defaultOptions = {
  9578. vlootUsername: '',
  9579. gameroundUsername: ''
  9580. };
  9581. var _checkSync = new WeakSet();
  9582. var _doGleamTask = new WeakSet();
  9583. var Gleam_getGiveawayId = new WeakSet();
  9584. var _getGleamLink = new WeakSet();
  9585. var Gleam_checkLeftKey = new WeakSet();
  9586. class Gleam extends website_Website {
  9587. constructor() {
  9588. super(...arguments);
  9589. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9590. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9591. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9592. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9593. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9594. Gleam_defineProperty(this, 'name', 'Gleam');
  9595. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9596. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9597. Gleam_defineProperty(this, 'options', {
  9598. ...Gleam_defaultOptions,
  9599. ...GM_getValue('GleamOptions')
  9600. });
  9601. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9602. }
  9603. static test() {
  9604. return window.location.host === 'gleam.io';
  9605. }
  9606. async after() {
  9607. try {
  9608. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9609. const checkComplete = setInterval(() => {
  9610. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9611. clearInterval(checkComplete);
  9612. window.close();
  9613. }
  9614. });
  9615. for (const task of $('.entry-content .entry-method')) {
  9616. const taskInfo = $(task).find('.user-links');
  9617. const expandInfo = $(task).find('.expandable');
  9618. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9619. if (aElements.length > 0) {
  9620. for (const element of aElements) {
  9621. const $element = $(element);
  9622. const href = $element.attr('href');
  9623. $element.removeAttr('href')[0].click();
  9624. $element.attr('href', href);
  9625. await delay(1e3);
  9626. }
  9627. }
  9628. taskInfo[0].click();
  9629. await delay(1e3);
  9630. }
  9631. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9632. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9633. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9634. }
  9635. } catch (error) {
  9636. throwError(error, 'Gleam.after');
  9637. return false;
  9638. }
  9639. }
  9640. init() {
  9641. try {
  9642. const logStatus = scripts_echoLog({
  9643. text: i18n('initing')
  9644. });
  9645. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9646. return false;
  9647. }
  9648. this.initialized = true;
  9649. logStatus.success();
  9650. return true;
  9651. } catch (error) {
  9652. throwError(error, 'Gleam.init');
  9653. return false;
  9654. }
  9655. }
  9656. async classifyTask(action) {
  9657. try {
  9658. const logStatus = scripts_echoLog({
  9659. text: i18n('getTasksInfo')
  9660. });
  9661. if (action === 'undo') {
  9662. var _GM_getValue;
  9663. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9664. }
  9665. const tasks = $('.entry-content .entry-method');
  9666. for (const task of tasks) {
  9667. var _socialIcon$attr;
  9668. const $task = $(task);
  9669. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9670. continue;
  9671. }
  9672. const socialIcon = $task.find('.icon-wrapper i');
  9673. const taskInfo = $task.find('.user-links');
  9674. const taskText = taskInfo.text().trim();
  9675. const expandInfo = $task.find('.expandable');
  9676. const aElements = expandInfo.find('a.btn');
  9677. if (aElements.length > 0) {
  9678. for (const element of aElements) {
  9679. const $element = $(element);
  9680. const href = $element.attr('href');
  9681. $element.removeAttr('href')[0].click();
  9682. $element.attr('href', href);
  9683. }
  9684. }
  9685. if (socialIcon.hasClass('fa-twitter')) {
  9686. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9687. if (!link) {
  9688. continue;
  9689. }
  9690. if (/follow/gi.test(taskText)) {
  9691. if (action === 'undo') {
  9692. this.socialTasks.twitter.userLinks.push(link);
  9693. }
  9694. if (action === 'do') {
  9695. this.undoneTasks.twitter.userLinks.push(link);
  9696. }
  9697. } else if (/retweet/gim.test(taskText)) {
  9698. if (action === 'undo') {
  9699. this.socialTasks.twitter.retweetLinks.push(link);
  9700. }
  9701. if (action === 'do') {
  9702. this.undoneTasks.twitter.retweetLinks.push(link);
  9703. }
  9704. }
  9705. } else if (socialIcon.hasClass('fa-twitch')) {
  9706. if (/follow/gim.test(taskText)) {
  9707. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9708. if (!link) {
  9709. continue;
  9710. }
  9711. if (action === 'undo') {
  9712. this.socialTasks.twitch.channelLinks.push(link);
  9713. }
  9714. if (action === 'do') {
  9715. this.undoneTasks.twitch.channelLinks.push(link);
  9716. }
  9717. }
  9718. } else if (socialIcon.hasClass('fa-discord')) {
  9719. if (/join/gim.test(taskText)) {
  9720. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9721. if (!link) {
  9722. var _$task$find$attr, _$task$find$attr$matc;
  9723. 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];
  9724. if (!ggLink) {
  9725. continue;
  9726. }
  9727. link = `https://discord.com/invite/${ggLink}`;
  9728. }
  9729. if (action === 'undo') {
  9730. this.socialTasks.discord.serverLinks.push(link);
  9731. }
  9732. if (action === 'do') {
  9733. this.undoneTasks.discord.serverLinks.push(link);
  9734. }
  9735. }
  9736. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9737. continue;
  9738. } else if (socialIcon.hasClass('fa-youtube')) {
  9739. if (/subscribe/gim.test(taskText)) {
  9740. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9741. if (!link) {
  9742. continue;
  9743. }
  9744. if (action === 'undo') {
  9745. this.socialTasks.youtube.channelLinks.push(link);
  9746. }
  9747. if (action === 'do') {
  9748. this.undoneTasks.youtube.channelLinks.push(link);
  9749. }
  9750. }
  9751. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9752. if (/join.*group/gi.test(taskText)) {
  9753. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9754. if (!link) {
  9755. continue;
  9756. }
  9757. if (action === 'undo') {
  9758. this.socialTasks.steam.groupLinks.push(link);
  9759. }
  9760. if (action === 'do') {
  9761. this.undoneTasks.steam.groupLinks.push(link);
  9762. }
  9763. } else if (/follow.*curator/gi.test(taskText)) {
  9764. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9765. if (!link) {
  9766. continue;
  9767. }
  9768. if (action === 'undo') {
  9769. this.socialTasks.steam.curatorLinks.push(link);
  9770. }
  9771. if (action === 'do') {
  9772. this.undoneTasks.steam.curatorLinks.push(link);
  9773. }
  9774. }
  9775. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('vloot.io') || socialIcon.hasClass('fa-tiktok')) {
  9776. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9777. for (const button of continueBtn) {
  9778. button.click();
  9779. await delay(500);
  9780. expandInfo.find('input').val(this.options.vlootUsername);
  9781. }
  9782. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9783. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9784. for (const button of continueBtn) {
  9785. button.click();
  9786. await delay(500);
  9787. expandInfo.find('input').val(this.options.gameroundUsername);
  9788. }
  9789. } else if (socialIcon.hasClass('fa-bullhorn') && /Complete/gi.test(taskText)) {
  9790. if (action !== 'do') {
  9791. continue;
  9792. }
  9793. const link = aElements.attr('href');
  9794. if (!link) {
  9795. continue;
  9796. }
  9797. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9798. if (!gleamLink) {
  9799. continue;
  9800. }
  9801. this.undoneTasks.extra.gleam.push(gleamLink);
  9802. } 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 {
  9803. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9804. }
  9805. }
  9806. logStatus.success();
  9807. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9808. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9809. if (window.DEBUG) {
  9810. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9811. }
  9812. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9813. tasks: this.socialTasks,
  9814. time: new Date().getTime()
  9815. });
  9816. return true;
  9817. } catch (error) {
  9818. throwError(error, 'Gleam.classifyTask');
  9819. return false;
  9820. }
  9821. }
  9822. async extraDoTask(_ref) {
  9823. let {
  9824. gleam
  9825. } = _ref;
  9826. try {
  9827. const pro = [];
  9828. for (const link of gleam) {
  9829. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9830. }
  9831. return Promise.all(pro).then(() => true);
  9832. } catch (error) {
  9833. throwError(error, 'Gleam.extraDoTask');
  9834. return false;
  9835. }
  9836. }
  9837. async verifyTask() {
  9838. try {
  9839. scripts_echoLog({
  9840. text: `${i18n('verifyingTask')}...`
  9841. });
  9842. const tasks = $('.entry-content .entry-method');
  9843. for (const task of tasks) {
  9844. const $task = $(task);
  9845. if ($task.find('i.fa-question').length === 0) {
  9846. continue;
  9847. }
  9848. const taskInfo = $task.find('.user-links');
  9849. taskInfo[0].click();
  9850. await delay(500);
  9851. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9852. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9853. for (const button of continueBtn) {
  9854. button.click();
  9855. await delay(500);
  9856. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9857. }
  9858. }
  9859. scripts_echoLog({
  9860. text: i18n('verifiedGleamTasks')
  9861. });
  9862. } catch (error) {
  9863. throwError(error, 'Gleam.verifyTask');
  9864. return false;
  9865. }
  9866. }
  9867. }
  9868. async function _checkSync2() {
  9869. try {
  9870. return await new Promise(resolve => {
  9871. const checker = setInterval(() => {
  9872. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9873. clearInterval(checker);
  9874. resolve(true);
  9875. }
  9876. }, 500);
  9877. });
  9878. } catch (error) {
  9879. throwError(error, 'Gleam.checkSync');
  9880. return false;
  9881. }
  9882. }
  9883. async function _doGleamTask2(link) {
  9884. try {
  9885. const logStatus = scripts_echoLog({
  9886. text: i18n('doingGleamTask')
  9887. });
  9888. return await new Promise(resolve => {
  9889. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9890. active: true,
  9891. insert: true,
  9892. setParent: true
  9893. }).onclose = () => {
  9894. logStatus.success();
  9895. resolve(true);
  9896. };
  9897. });
  9898. } catch (error) {
  9899. throwError(error, 'Gleam.doGleamTask');
  9900. return false;
  9901. }
  9902. }
  9903. function Gleam_getGiveawayId2() {
  9904. try {
  9905. const giveawayId = window.location.pathname;
  9906. if (giveawayId) {
  9907. this.giveawayId = giveawayId;
  9908. return true;
  9909. }
  9910. scripts_echoLog({
  9911. text: i18n('getFailed', 'GiveawayId')
  9912. });
  9913. return false;
  9914. } catch (error) {
  9915. throwError(error, 'Gleam.getGiveawayId');
  9916. return false;
  9917. }
  9918. }
  9919. async function _getGleamLink2(link) {
  9920. try {
  9921. const logStatus = scripts_echoLog({
  9922. text: i18n('gettingGleamLink')
  9923. });
  9924. const {
  9925. result,
  9926. statusText,
  9927. status,
  9928. data
  9929. } = await tools_httpRequest({
  9930. url: link,
  9931. method: 'GET'
  9932. });
  9933. if (result === 'Success') {
  9934. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9935. var _data$responseText$ma;
  9936. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9937. if (gleamLink) {
  9938. logStatus.success();
  9939. return gleamLink;
  9940. }
  9941. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9942. return false;
  9943. }
  9944. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9945. return false;
  9946. }
  9947. logStatus.error(`${result}:${statusText}(${status})`);
  9948. return false;
  9949. } catch (error) {
  9950. throwError(error, 'Gleam.getGleamLink');
  9951. return false;
  9952. }
  9953. }
  9954. async function Gleam_checkLeftKey2() {
  9955. try {
  9956. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9957. if (!globalOptions.other.checkLeftKey) {
  9958. return true;
  9959. }
  9960. 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];
  9961. if (!campaignString) {
  9962. return false;
  9963. }
  9964. const {
  9965. campaign,
  9966. incentive
  9967. } = JSON.parse(campaignString);
  9968. 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];
  9969. let ownedKey = false;
  9970. if (controllerString) {
  9971. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9972. 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) {
  9973. ownedKey = true;
  9974. }
  9975. }
  9976. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9977. await external_Swal_default().fire({
  9978. icon: 'warning',
  9979. title: i18n('notice'),
  9980. text: i18n('giveawayNotWork'),
  9981. confirmButtonText: i18n('confirm'),
  9982. cancelButtonText: i18n('cancel'),
  9983. showCancelButton: true
  9984. }).then(_ref2 => {
  9985. let {
  9986. value
  9987. } = _ref2;
  9988. if (value) {
  9989. window.close();
  9990. }
  9991. });
  9992. }
  9993. return true;
  9994. } catch (error) {
  9995. throwError(error, 'Gleam.checkLeftKey');
  9996. return false;
  9997. }
  9998. }
  9999. const website_Gleam = Gleam;
  10000. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  10001. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  10002. privateSet.add(obj);
  10003. }
  10004. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  10005. if (privateCollection.has(obj)) {
  10006. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10007. }
  10008. }
  10009. function SweepWidget_defineProperty(obj, key, value) {
  10010. if (key in obj) {
  10011. Object.defineProperty(obj, key, {
  10012. value: value,
  10013. enumerable: true,
  10014. configurable: true,
  10015. writable: true
  10016. });
  10017. } else {
  10018. obj[key] = value;
  10019. }
  10020. return obj;
  10021. }
  10022. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  10023. if (!privateSet.has(receiver)) {
  10024. throw new TypeError('attempted to get private field on non-instance');
  10025. }
  10026. return fn;
  10027. }
  10028. const SweepWidget_defaultOptions = {
  10029. username: '',
  10030. email: ''
  10031. };
  10032. var SweepWidget_checkLogin = new WeakSet();
  10033. var SweepWidget_getGiveawayId = new WeakSet();
  10034. var _checkEnter = new WeakSet();
  10035. var _checkFinish = new WeakSet();
  10036. class SweepWidget extends website_Website {
  10037. constructor() {
  10038. super(...arguments);
  10039. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  10040. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  10041. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  10042. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  10043. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  10044. SweepWidget_defineProperty(this, 'options', {
  10045. ...SweepWidget_defaultOptions,
  10046. ...GM_getValue('SweepWidgetOptions')
  10047. });
  10048. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  10049. }
  10050. static test() {
  10051. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  10052. }
  10053. async after() {
  10054. try {
  10055. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  10056. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  10057. }
  10058. } catch (error) {
  10059. throwError(error, 'SweepWidget.after');
  10060. }
  10061. }
  10062. init() {
  10063. try {
  10064. const logStatus = scripts_echoLog({
  10065. text: i18n('initing')
  10066. });
  10067. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  10068. logStatus.warning(i18n('needLogin'));
  10069. return false;
  10070. }
  10071. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  10072. return false;
  10073. }
  10074. this.initialized = true;
  10075. logStatus.success();
  10076. return true;
  10077. } catch (error) {
  10078. throwError(error, 'SweepWidget.init');
  10079. return false;
  10080. }
  10081. }
  10082. classifyTask() {
  10083. return true;
  10084. }
  10085. async doTask() {
  10086. try {
  10087. if ($('#unlock_rewards_main_wrapper').length === 0) {
  10088. if ($('input[name="sw__login_name"]:visible').length > 0) {
  10089. $('input[name="sw__login_name"]').val(this.options.username);
  10090. }
  10091. if ($('input[name="sw__login_email"]:visible').length > 0) {
  10092. $('input[name="sw__login_email"]').val(this.options.email);
  10093. }
  10094. if ($('#sw_login_button:visible').length > 0) {
  10095. $('#sw_login_button')[0].click();
  10096. }
  10097. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  10098. return false;
  10099. }
  10100. }
  10101. const logStatus = scripts_echoLog({
  10102. text: i18n('SweepWidgetNotice')
  10103. });
  10104. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  10105. for (const task of tasks) {
  10106. var _aElement$, _$task$find$removeAtt;
  10107. const $task = $(task);
  10108. if ($task.find('i.fa-check:visible').length > 0) {
  10109. continue;
  10110. }
  10111. const title = $task.find('.sw_text_inner');
  10112. title[0].click();
  10113. const aElement = $task.find('a.sw_link');
  10114. const link = aElement.attr('href');
  10115. aElement.attr('href', '#a').attr('target', '_self');
  10116. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  10117. await delay(300);
  10118. aElement.attr('href', link).attr('target', '_blank');
  10119. $task.find('input[type="text"]').val('test');
  10120. const verifyBtn = $task.find('input.sw_verify');
  10121. if (verifyBtn.prop('disabled') === true) {
  10122. title[0].click();
  10123. await delay(300);
  10124. title[0].click();
  10125. await delay(300);
  10126. }
  10127. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  10128. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  10129. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  10130. }
  10131. logStatus.success();
  10132. return true;
  10133. } catch (error) {
  10134. throwError(error, 'SweepWidget.doTask');
  10135. return false;
  10136. }
  10137. }
  10138. }
  10139. function SweepWidget_checkLogin2() {
  10140. try {
  10141. if ($('#twitter_login_button').length > 0) {
  10142. $('#twitter_login_button')[0].click();
  10143. }
  10144. return true;
  10145. } catch (error) {
  10146. throwError(error, 'SweepWidget.checkLogin');
  10147. return false;
  10148. }
  10149. }
  10150. function SweepWidget_getGiveawayId2() {
  10151. try {
  10152. var _window$location$href;
  10153. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  10154. if (giveawayId) {
  10155. this.giveawayId = giveawayId;
  10156. return true;
  10157. }
  10158. scripts_echoLog({
  10159. text: i18n('getFailed', 'GiveawayId')
  10160. });
  10161. return false;
  10162. } catch (error) {
  10163. throwError(error, 'SweepWidget.getGiveawayId');
  10164. return false;
  10165. }
  10166. }
  10167. async function _checkEnter2() {
  10168. try {
  10169. return new Promise(resolve => {
  10170. const checker = setInterval(() => {
  10171. if ($('#unlock_rewards_main_wrapper').length > 0) {
  10172. clearInterval(checker);
  10173. resolve(true);
  10174. }
  10175. });
  10176. });
  10177. } catch (error) {
  10178. throwError(error, 'SweepWidget.checkEnter');
  10179. return false;
  10180. }
  10181. }
  10182. async function _checkFinish2($task) {
  10183. try {
  10184. return new Promise(resolve => {
  10185. const checker = setInterval(() => {
  10186. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  10187. clearInterval(checker);
  10188. resolve(true);
  10189. }
  10190. });
  10191. });
  10192. } catch (error) {
  10193. throwError(error, 'SweepWidget.checkFinish');
  10194. return false;
  10195. }
  10196. }
  10197. const website_SweepWidget = SweepWidget;
  10198. const defaultWhiteList = {
  10199. discord: {
  10200. servers: []
  10201. },
  10202. instagram: {
  10203. users: []
  10204. },
  10205. twitch: {
  10206. channels: []
  10207. },
  10208. twitter: {
  10209. users: [],
  10210. retweets: [],
  10211. likes: []
  10212. },
  10213. vk: {
  10214. names: []
  10215. },
  10216. youtube: {
  10217. channels: [],
  10218. likes: []
  10219. },
  10220. reddit: {
  10221. reddits: []
  10222. },
  10223. steam: {
  10224. groups: [],
  10225. officialGroups: [],
  10226. wishlists: [],
  10227. follows: [],
  10228. forums: [],
  10229. workshops: [],
  10230. curators: [],
  10231. workshopVotes: [],
  10232. curatorLikes: [],
  10233. announcements: [],
  10234. licenses: [],
  10235. playtests: []
  10236. }
  10237. };
  10238. const link2id = async function(type) {
  10239. 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;
  10240. try {
  10241. const link = $('#socialLink').val();
  10242. let id = '';
  10243. switch (type) {
  10244. case 'discord.servers':
  10245. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10246. break;
  10247.  
  10248. case 'instagram.users':
  10249. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10250. break;
  10251.  
  10252. case 'twitch.channels':
  10253. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10254. break;
  10255.  
  10256. case 'twitter.users':
  10257. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10258. break;
  10259.  
  10260. case 'twitter.retweets':
  10261. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10262. break;
  10263.  
  10264. case 'vk.names':
  10265. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10266. break;
  10267.  
  10268. case 'youtube.channels':
  10269. 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) || '';
  10270. break;
  10271.  
  10272. case 'youtube.likes':
  10273. 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) || '';
  10274. break;
  10275.  
  10276. case 'reddit.reddits':
  10277. 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]) || '';
  10278. break;
  10279.  
  10280. case 'steam.groups':
  10281. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10282. break;
  10283.  
  10284. case 'steam.wishlists':
  10285. case 'steam.follows':
  10286. case 'steam.forums':
  10287. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10288. break;
  10289.  
  10290. case 'steam.workshops':
  10291. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10292. break;
  10293.  
  10294. case 'steam.curators':
  10295. {
  10296. if (link.includes('curator')) {
  10297. var _link$match12;
  10298. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10299. } else {
  10300. var _link$match13;
  10301. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10302. if (!param || param.length !== 2) {
  10303. break;
  10304. }
  10305. const steam = new social_Steam();
  10306. if (await steam.init()) {
  10307. id = await steam.getCuratorId(param[0], param[1]) || '';
  10308. }
  10309. }
  10310. }
  10311. break;
  10312. }
  10313. return id;
  10314. } catch (error) {
  10315. throwError(error, 'link2id');
  10316. return i18n('getFailed', 'id');
  10317. }
  10318. };
  10319. const disabledType = {
  10320. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10321. twitter: [ 'likes' ]
  10322. };
  10323. const assignWhiteList = whiteList => {
  10324. try {
  10325. const newWhiteList = {};
  10326. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10327. newWhiteList[key] = {
  10328. ...value,
  10329. ...whiteList[key]
  10330. };
  10331. }
  10332. return newWhiteList;
  10333. } catch (error) {
  10334. throwError(error, 'assignWhiteList');
  10335. return defaultWhiteList;
  10336. }
  10337. };
  10338. const whiteListOptions = function(showType) {
  10339. try {
  10340. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10341. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10342. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10343. for (const [ social, types ] of Object.entries(whiteList)) {
  10344. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10345. var _disabledType$social;
  10346. 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>`;
  10347. }).join('');
  10348. }
  10349. whiteListOptionsForm += '</tbody></table></form>';
  10350. if (showType === 'swal') {
  10351. external_Swal_default().fire({
  10352. title: i18n('whiteListOptions'),
  10353. html: whiteListOptionsForm,
  10354. showConfirmButton: false,
  10355. showCloseButton: true
  10356. });
  10357. } else {
  10358. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10359. }
  10360. $('.editWhiteList').on('click', function() {
  10361. var _whiteList$social;
  10362. const value = $(this).attr('data-value');
  10363. if (!value) {
  10364. return;
  10365. }
  10366. const [ social, type ] = value.split('.');
  10367. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10368. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10369. return;
  10370. }
  10371. external_Swal_default().fire({
  10372. title: i18n('changeWhiteListOption', value),
  10373. input: 'textarea',
  10374. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10375. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10376. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10377. inputValue: whiteList[social][type].join('\n'),
  10378. showConfirmButton: true,
  10379. confirmButtonText: i18n('save'),
  10380. showCancelButton: true,
  10381. cancelButtonText: i18n('close'),
  10382. showDenyButton: true,
  10383. denyButtonText: i18n('return')
  10384. }).then(_ref => {
  10385. let {
  10386. isDenied,
  10387. isConfirmed,
  10388. value
  10389. } = _ref;
  10390. if (isDenied) {
  10391. if (showType === 'swal') {
  10392. whiteListOptions(showType);
  10393. }
  10394. return;
  10395. } else if (isConfirmed) {
  10396. whiteList[social][type] = value.split('\n');
  10397. GM_setValue('whiteList', whiteList);
  10398. external_Swal_default().fire({
  10399. title: i18n('changeWhiteListSuccess'),
  10400. icon: 'success'
  10401. });
  10402. }
  10403. });
  10404. $('#link2id').on('click', async function() {
  10405. const type = $(this).attr('data-type');
  10406. $('#socialLink').val(await link2id(type));
  10407. });
  10408. });
  10409. } catch (error) {
  10410. throwError(error, 'whiteListOptions');
  10411. }
  10412. };
  10413. const whiteList = whiteListOptions;
  10414. const setGistData = async (token, gistId, fileName, content) => {
  10415. try {
  10416. const logStatus = scripts_echoLog({
  10417. text: i18n('settingData')
  10418. });
  10419. const contentData = JSON.stringify({
  10420. files: {
  10421. [fileName]: {
  10422. content: JSON.stringify(content)
  10423. }
  10424. }
  10425. });
  10426. const {
  10427. result,
  10428. statusText,
  10429. status,
  10430. data
  10431. } = await tools_httpRequest({
  10432. url: `https://api.github.com/gists/${gistId}`,
  10433. headers: {
  10434. Accept: 'application/vnd.github.v3+json',
  10435. Authorization: `token ${token}`
  10436. },
  10437. data: contentData,
  10438. responseType: 'json',
  10439. method: 'POST',
  10440. timeout: 3e4
  10441. });
  10442. if (result === 'Success') {
  10443. var _data$response$files, _data$response$files$;
  10444. 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)) {
  10445. logStatus.success();
  10446. return true;
  10447. }
  10448. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10449. return false;
  10450. }
  10451. logStatus.error(`${result}:${statusText}(${status})`);
  10452. return false;
  10453. } catch (error) {
  10454. throwError(error, 'setGistData');
  10455. return false;
  10456. }
  10457. };
  10458. const getGistData = async function(token, gistId, fileName) {
  10459. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10460. try {
  10461. const logStatus = scripts_echoLog({
  10462. text: i18n('gettingData')
  10463. });
  10464. const {
  10465. result,
  10466. statusText,
  10467. status,
  10468. data
  10469. } = await tools_httpRequest({
  10470. url: `https://api.github.com/gists/${gistId}`,
  10471. headers: {
  10472. Accept: 'application/vnd.github.v3+json',
  10473. Authorization: `token ${token}`
  10474. },
  10475. responseType: 'json',
  10476. method: 'GET',
  10477. timeout: 3e4
  10478. });
  10479. if (result === 'Success') {
  10480. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10481. var _data$response, _data$response$files2, _data$response$files3;
  10482. 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;
  10483. let formatedContent;
  10484. if (!content) {
  10485. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10486. return false;
  10487. }
  10488. if (test) {
  10489. logStatus.success();
  10490. return true;
  10491. }
  10492. try {
  10493. formatedContent = JSON.parse(content);
  10494. } catch (error) {
  10495. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10496. return false;
  10497. }
  10498. logStatus.success();
  10499. return formatedContent;
  10500. }
  10501. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10502. return false;
  10503. }
  10504. logStatus.error(`${result}:${statusText}(${status})`);
  10505. return false;
  10506. } catch (error) {
  10507. throwError(error, 'getGistData');
  10508. return false;
  10509. }
  10510. };
  10511. const syncOptions = () => {
  10512. try {
  10513. const {
  10514. TOKEN,
  10515. GIST_ID,
  10516. FILE_NAME,
  10517. SYNC_HISTORY
  10518. } = GM_getValue('gistOptions') || {
  10519. TOKEN: '',
  10520. GIST_ID: '',
  10521. FILE_NAME: '',
  10522. SYNC_HISTORY: true
  10523. };
  10524. external_Swal_default().fire({
  10525. title: i18n('gistOptions'),
  10526. 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;">
  10527. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10528. ${i18n('downloadFromGist')}</button></p>`,
  10529. focusConfirm: false,
  10530. showLoaderOnConfirm: true,
  10531. 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>`,
  10532. preConfirm: async () => {
  10533. const token = $('#github-token').val();
  10534. const gistId = $('#gist-id').val();
  10535. const fileName = $('#file-name').val();
  10536. const syncHistory = $('#sync-history').prop('checked');
  10537. GM_setValue('gistOptions', {
  10538. TOKEN: token,
  10539. GIST_ID: gistId,
  10540. FILE_NAME: fileName,
  10541. SYNC_HISTORY: syncHistory
  10542. });
  10543. return await getGistData(token, gistId, fileName, true);
  10544. },
  10545. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10546. confirmButtonText: i18n('saveAndTest'),
  10547. showCancelButton: true,
  10548. cancelButtonText: i18n('close')
  10549. }).then(_ref => {
  10550. let {
  10551. value
  10552. } = _ref;
  10553. if (value) {
  10554. external_Swal_default().fire({
  10555. icon: 'success',
  10556. title: i18n('testSuccess')
  10557. }).then(syncOptions);
  10558. } else if (value !== undefined) {
  10559. external_Swal_default().fire({
  10560. icon: 'error',
  10561. title: i18n('testFailed')
  10562. }).then(syncOptions);
  10563. }
  10564. });
  10565. $('#upload-data').on('click', async () => {
  10566. const {
  10567. TOKEN,
  10568. GIST_ID,
  10569. FILE_NAME
  10570. } = GM_getValue('gistOptions') || {};
  10571. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10572. return external_Swal_default().fire({
  10573. icon: 'error',
  10574. title: i18n('saveAndTestNotice')
  10575. }).then(syncOptions);
  10576. }
  10577. external_Swal_default().fire({
  10578. icon: 'info',
  10579. title: i18n('processingData')
  10580. });
  10581. const data = {};
  10582. const names = GM_listValues();
  10583. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10584. for (const name of names) {
  10585. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10586. continue;
  10587. }
  10588. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10589. continue;
  10590. }
  10591. data[name] = GM_getValue(name);
  10592. }
  10593. external_Swal_default().update({
  10594. icon: 'info',
  10595. title: i18n('updatingData')
  10596. });
  10597. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10598. external_Swal_default().fire({
  10599. icon: 'success',
  10600. title: i18n('syncDataSuccess')
  10601. });
  10602. } else {
  10603. external_Swal_default().fire({
  10604. icon: 'error',
  10605. title: i18n('syncDataFailed')
  10606. });
  10607. }
  10608. });
  10609. $('#download-data').on('click', async () => {
  10610. const {
  10611. TOKEN,
  10612. GIST_ID,
  10613. FILE_NAME
  10614. } = GM_getValue('gistOptions') || {};
  10615. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10616. return external_Swal_default().fire({
  10617. icon: 'error',
  10618. title: i18n('saveAndTestNotice')
  10619. }).then(syncOptions);
  10620. }
  10621. external_Swal_default().fire({
  10622. icon: 'info',
  10623. title: i18n('downloadingData')
  10624. });
  10625. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10626. if (!data) {
  10627. return external_Swal_default().fire({
  10628. icon: 'error',
  10629. title: i18n('checkedNoData')
  10630. }).then(syncOptions);
  10631. }
  10632. external_Swal_default().update({
  10633. icon: 'info',
  10634. title: i18n('savingData')
  10635. });
  10636. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10637. for (const [ name, value ] of Object.entries(data)) {
  10638. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10639. continue;
  10640. }
  10641. GM_setValue(name, value);
  10642. }
  10643. external_Swal_default().fire({
  10644. icon: 'success',
  10645. title: i18n('syncDataSuccess')
  10646. });
  10647. });
  10648. } catch (error) {
  10649. throwError(error, 'syncOptions');
  10650. }
  10651. };
  10652. const dataSync = syncOptions;
  10653. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10654. Setting_checkPrivateRedeclaration(obj, privateSet);
  10655. privateSet.add(obj);
  10656. }
  10657. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10658. if (privateCollection.has(obj)) {
  10659. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10660. }
  10661. }
  10662. function Setting_defineProperty(obj, key, value) {
  10663. if (key in obj) {
  10664. Object.defineProperty(obj, key, {
  10665. value: value,
  10666. enumerable: true,
  10667. configurable: true,
  10668. writable: true
  10669. });
  10670. } else {
  10671. obj[key] = value;
  10672. }
  10673. return obj;
  10674. }
  10675. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10676. if (!privateSet.has(receiver)) {
  10677. throw new TypeError('attempted to get private field on non-instance');
  10678. }
  10679. return fn;
  10680. }
  10681. var Setting_getId = new WeakSet();
  10682. var _environment = new WeakSet();
  10683. class Setting {
  10684. constructor() {
  10685. Setting_classPrivateMethodInitSpec(this, _environment);
  10686. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10687. Setting_defineProperty(this, 'name', 'Setting');
  10688. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10689. Setting_defineProperty(this, 'syncData', dataSync);
  10690. }
  10691. tasksHistory() {
  10692. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10693. }
  10694. static test() {
  10695. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10696. }
  10697. before() {
  10698. $('body').html('').addClass('auto-task-options');
  10699. }
  10700. after() {
  10701. try {
  10702. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10703. changeGlobalOptions('page');
  10704. whiteList('page');
  10705. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10706. $('#getTwitterUserId').on('click', () => {
  10707. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10708. });
  10709. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10710. $('#getYoutubeChannelId').on('click', () => {
  10711. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10712. });
  10713. $('input[name^="position"]').on('input', function() {
  10714. const type = $(this).attr('name').replace('position.', '');
  10715. const xLabel = 'rightleft';
  10716. const yLabel = 'topbottpm';
  10717. switch (type) {
  10718. case 'buttonSideX':
  10719. case 'buttonSideY':
  10720. case 'buttonDistance':
  10721. {
  10722. const distance = $('input[name="position.buttonDistance"]').val();
  10723. const sideX = $('input[name="position.buttonSideX"]').val();
  10724. const sideY = $('input[name="position.buttonSideY"]').val();
  10725. if (![ 'right', 'left' ].includes(sideX)) {
  10726. break;
  10727. }
  10728. if (![ 'top', 'bottom' ].includes(sideY)) {
  10729. break;
  10730. }
  10731. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10732. break;
  10733. }
  10734. const distanceArr = distance.split(',');
  10735. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10736. break;
  10737. }
  10738.  
  10739. case 'showButtonSideX':
  10740. case 'showButtonSideY':
  10741. case 'showButtonDistance':
  10742. {
  10743. const distance = $('input[name="position.showButtonDistance"]').val();
  10744. const sideX = $('input[name="position.showButtonSideX"]').val();
  10745. const sideY = $('input[name="position.showButtonSideY"]').val();
  10746. if (![ 'right', 'left' ].includes(sideX)) {
  10747. break;
  10748. }
  10749. if (![ 'top', 'bottom' ].includes(sideY)) {
  10750. break;
  10751. }
  10752. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10753. break;
  10754. }
  10755. const distanceArr = distance.split(',');
  10756. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10757. break;
  10758. }
  10759.  
  10760. case 'logSideX':
  10761. case 'logSideY':
  10762. case 'logDistance':
  10763. {
  10764. const distance = $('input[name="position.logDistance"]').val();
  10765. const sideX = $('input[name="position.logSideX"]').val();
  10766. const sideY = $('input[name="position.logSideY"]').val();
  10767. if (![ 'right', 'left' ].includes(sideX)) {
  10768. break;
  10769. }
  10770. if (![ 'top', 'bottom' ].includes(sideY)) {
  10771. break;
  10772. }
  10773. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10774. break;
  10775. }
  10776. const distanceArr = distance.split(',');
  10777. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10778. break;
  10779. }
  10780.  
  10781. default:
  10782. break;
  10783. }
  10784. });
  10785. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10786. let functionKey = '';
  10787. if (event.altKey) {
  10788. functionKey += 'alt + ';
  10789. } else if (event.ctrlKey) {
  10790. functionKey += 'ctrl + ';
  10791. } else if (event.shiftKey) {
  10792. functionKey += 'shift + ';
  10793. }
  10794. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10795. });
  10796. } catch (error) {
  10797. throwError(error, 'Setting.after');
  10798. }
  10799. }
  10800. saveGlobalOptions() {
  10801. saveData();
  10802. }
  10803. }
  10804. function Setting_getId2(social) {
  10805. try {
  10806. external_Swal_default().fire({
  10807. title: i18n('getId', i18n(social)),
  10808. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10809. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10810. showCancelButton: true,
  10811. cancelButtonText: i18n('close'),
  10812. showConfirmButton: false
  10813. });
  10814. $('#link2id').on('click', async function() {
  10815. const link = $('#socialLink').val();
  10816. if (!link) {
  10817. return;
  10818. }
  10819. const type = $(this).attr('data-type');
  10820. if (type === 'twitterUser') {
  10821. var _link$match;
  10822. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10823. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10824. } else if (type === 'youtubeChannel') {
  10825. var _link$match2, _await$getInfo, _await$getInfo$params;
  10826. 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;
  10827. $('#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) || '');
  10828. }
  10829. });
  10830. } catch (error) {
  10831. throwError(error, 'Setting.getId');
  10832. }
  10833. }
  10834. function _environment2() {
  10835. try {
  10836. const userAgent = (0, javascript_utils_umd_min.ua)();
  10837. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10838. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10839. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10840. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10841. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10842. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10843. </tbody></table></form>`;
  10844. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10845. } catch (error) {
  10846. throwError(error, 'Setting.environment');
  10847. }
  10848. }
  10849. const website_Setting = Setting;
  10850. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10851. History_checkPrivateRedeclaration(obj, privateSet);
  10852. privateSet.add(obj);
  10853. }
  10854. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10855. if (privateCollection.has(obj)) {
  10856. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10857. }
  10858. }
  10859. function History_defineProperty(obj, key, value) {
  10860. if (key in obj) {
  10861. Object.defineProperty(obj, key, {
  10862. value: value,
  10863. enumerable: true,
  10864. configurable: true,
  10865. writable: true
  10866. });
  10867. } else {
  10868. obj[key] = value;
  10869. }
  10870. return obj;
  10871. }
  10872. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10873. if (!privateSet.has(receiver)) {
  10874. throw new TypeError('attempted to get private field on non-instance');
  10875. }
  10876. return fn;
  10877. }
  10878. var _addItem = new WeakSet();
  10879. class History extends website_Keylol {
  10880. constructor() {
  10881. super(...arguments);
  10882. History_classPrivateMethodInitSpec(this, _addItem);
  10883. History_defineProperty(this, 'name', 'History');
  10884. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10885. }
  10886. static test() {
  10887. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10888. }
  10889. before() {
  10890. try {
  10891. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10892. const data = GM_listValues() || [];
  10893. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10894. for (const item of tasksHistory) {
  10895. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10896. }
  10897. } catch (error) {
  10898. throwError(error, 'History.before');
  10899. }
  10900. }
  10901. clearHistory() {
  10902. try {
  10903. const data = GM_listValues() || [];
  10904. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10905. for (const item of tasksHistory) {
  10906. GM_deleteValue(item);
  10907. }
  10908. external_Swal_default().fire({
  10909. title: i18n('clearHistoryFinished'),
  10910. icon: 'success'
  10911. });
  10912. } catch (error) {
  10913. throwError(error, 'History.after');
  10914. }
  10915. }
  10916. }
  10917. function _addItem2(item) {
  10918. try {
  10919. const tasksData = GM_getValue(item);
  10920. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10921. return;
  10922. }
  10923. let html = '';
  10924. let title = '';
  10925. let link = '';
  10926. const [ website, id ] = item.split('-');
  10927. switch (website) {
  10928. case 'fawTasks':
  10929. title = `Freeanywhere[${id}]`;
  10930. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10931. break;
  10932.  
  10933. case 'gasTasks':
  10934. title = `Giveawaysu[${id}]`;
  10935. link = `https://giveaway.su/giveaway/view/${id}`;
  10936. break;
  10937.  
  10938. case 'gcTasks':
  10939. title = `GiveeClub[${id}]`;
  10940. link = `https://givee.club/event/${id}`;
  10941. break;
  10942.  
  10943. case 'gkTasks':
  10944. title = `Givekey[${id}]`;
  10945. link = `https://givekey.ru/giveaway/${id}`;
  10946. break;
  10947.  
  10948. case 'gleamTasks':
  10949. title = `Gleam[${id}]`;
  10950. link = `https://gleam.io${id}`;
  10951. break;
  10952.  
  10953. case 'khTasks':
  10954. title = `keyhub[${id}]`;
  10955. link = `https://key-hub.eu/giveaway/${id}`;
  10956. break;
  10957.  
  10958. case 'prysTasks':
  10959. title = `Prys[${id}]`;
  10960. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10961. break;
  10962.  
  10963. default:
  10964. return;
  10965. }
  10966. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10967. for (const [ type, tasks ] of Object.entries(types)) {
  10968. for (const task of tasks) {
  10969. 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>`;
  10970. }
  10971. }
  10972. }
  10973. $('.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>`);
  10974. $('span.delete-task').on('click', function() {
  10975. const itemName = $(this).attr('data-name');
  10976. if (itemName) {
  10977. GM_deleteValue(itemName);
  10978. $(`div.card[data-name="${itemName}"]`).remove();
  10979. external_Swal_default().fire({
  10980. title: i18n('clearTaskFinished'),
  10981. text: itemName,
  10982. icon: 'success'
  10983. });
  10984. } else {
  10985. external_Swal_default().fire({
  10986. title: i18n('clearTaskFailed'),
  10987. icon: 'error'
  10988. });
  10989. }
  10990. });
  10991. } catch (error) {
  10992. throwError(error, 'History.addItem');
  10993. }
  10994. }
  10995. const website_History = History;
  10996. 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 ];
  10997. const websiteOptions = function(website, options) {
  10998. try {
  10999. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  11000. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  11001. for (const [ option, value ] of Object.entries(options)) {
  11002. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  11003. }
  11004. websiteOptionsForm += '</tbody></table></form>';
  11005. external_Swal_default().fire({
  11006. title: i18n('websiteOptions'),
  11007. html: websiteOptionsForm,
  11008. showConfirmButton: true,
  11009. confirmButtonText: i18n('save'),
  11010. showCancelButton: true,
  11011. cancelButtonText: i18n('close')
  11012. }).then(_ref => {
  11013. let {
  11014. isConfirmed
  11015. } = _ref;
  11016. if (isConfirmed) {
  11017. $('#websiteOptionsForm').serializeArray().map(value => {
  11018. options[value.name] = value.value;
  11019. return value;
  11020. });
  11021. GM_setValue(`${website}Options`, options);
  11022. external_Swal_default().fire({
  11023. title: i18n('changeWebsiteOptionsSuccess'),
  11024. icon: 'success'
  11025. });
  11026. }
  11027. });
  11028. } catch (error) {
  11029. throwError(error, 'websiteOptions');
  11030. }
  11031. };
  11032. const options = websiteOptions;
  11033. const external_keyboardJS_namespaceObject = keyboardJS;
  11034. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  11035. const checkUpdate = async (updateLink, auto) => {
  11036. try {
  11037. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  11038. const {
  11039. result,
  11040. statusText,
  11041. status,
  11042. data
  11043. } = await tools_httpRequest({
  11044. url: checkUrl,
  11045. responseType: 'json',
  11046. method: 'GET',
  11047. timeout: 3e4
  11048. });
  11049. if (result === 'Success') {
  11050. var _data$response;
  11051. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  11052. return data.response;
  11053. }
  11054. if (!auto) {
  11055. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  11056. }
  11057. return false;
  11058. }
  11059. if (!auto) {
  11060. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  11061. }
  11062. return false;
  11063. } catch (error) {
  11064. throwError(error, 'checkUpdate');
  11065. return false;
  11066. }
  11067. };
  11068. const hasNewVersion = (currentVersion, remoteVersion) => {
  11069. try {
  11070. const [ currentRealVersion ] = currentVersion.split('-');
  11071. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  11072. if (isPreview && !globalOptions.other.receivePreview) {
  11073. return false;
  11074. }
  11075. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  11076. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  11077. if (remoteVersion1 > currentVersion1) {
  11078. return true;
  11079. }
  11080. if (remoteVersion1 < currentVersion1) {
  11081. return false;
  11082. }
  11083. if (remoteVersion2 > currentVersion2) {
  11084. return true;
  11085. }
  11086. if (remoteVersion2 < currentVersion2) {
  11087. return false;
  11088. }
  11089. if (remoteVersion3 > currentVersion3) {
  11090. return true;
  11091. }
  11092. return false;
  11093. } catch (error) {
  11094. throwError(error, 'compareVersion');
  11095. return false;
  11096. }
  11097. };
  11098. const updateChecker = async () => {
  11099. try {
  11100. const currentVersion = GM_info.script.version;
  11101. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  11102. const updateLinks = {
  11103. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  11104. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  11105. standby: 'https://auto-task-v4.hclonely.com/'
  11106. };
  11107. let version;
  11108. let updateLink = '';
  11109. let packageData;
  11110. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  11111. updateLink = updateLinks[updateSource];
  11112. packageData = await checkUpdate(updateLink, false);
  11113. } else {
  11114. updateLink = updateLinks.github;
  11115. packageData = await checkUpdate(updateLink, true);
  11116. if (!packageData) {
  11117. updateLink = updateLinks.jsdelivr;
  11118. packageData = await checkUpdate(updateLink, true);
  11119. if (!packageData) {
  11120. updateLink = updateLinks.standby;
  11121. packageData = await checkUpdate(updateLink, true);
  11122. }
  11123. }
  11124. }
  11125. if (packageData) {
  11126. version = packageData.version || currentVersion;
  11127. } else {
  11128. version = currentVersion;
  11129. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  11130. }
  11131. if (packageData && hasNewVersion(currentVersion, version)) {
  11132. var _packageData$change;
  11133. scripts_echoLog({
  11134. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  11135. });
  11136. scripts_echoLog({
  11137. 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>`
  11138. });
  11139. }
  11140. } catch (error) {
  11141. throwError(error, 'updateChecker');
  11142. }
  11143. };
  11144. const scripts_updateChecker = updateChecker;
  11145. var _globalOptions$other, _globalOptions$other2;
  11146. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  11147. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  11148. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  11149. const loadScript = async () => {
  11150. var _website, _website2, _website3, _website4, _website5, _website6;
  11151. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  11152. const authToken = external_Cookies_namespaceObject.get('auth-token');
  11153. const isLogin = !!external_Cookies_namespaceObject.get('login');
  11154. if (isLogin) {
  11155. var _commonOptions, _commonOptions$header;
  11156. GM_setValue('twitchAuth', {
  11157. authToken: authToken,
  11158. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  11159. });
  11160. window.close();
  11161. external_Swal_default().fire('', i18n('closePageNotice'));
  11162. } else {
  11163. external_Swal_default().fire('', i18n('needLogin'));
  11164. }
  11165. return;
  11166. }
  11167. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  11168. const ct0 = external_Cookies_namespaceObject.get('ct0');
  11169. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  11170. if (isLogin && ct0) {
  11171. GM_setValue('twitterAuth', {
  11172. ct0: ct0
  11173. });
  11174. window.close();
  11175. external_Swal_default().fire('', i18n('closePageNotice'));
  11176. } else {
  11177. external_Swal_default().fire('', i18n('needLogin'));
  11178. }
  11179. return;
  11180. }
  11181. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  11182. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  11183. if (PAPISID) {
  11184. GM_setValue('youtubeAuth', {
  11185. PAPISID: PAPISID
  11186. });
  11187. window.close();
  11188. external_Swal_default().fire('', i18n('closePageNotice'));
  11189. } else {
  11190. external_Swal_default().fire('', i18n('needLogin'));
  11191. }
  11192. return;
  11193. }
  11194. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11195. const betaButton = $('#redesign-beta-optin-btn');
  11196. if (betaButton.length > 0) {
  11197. GM_setValue('redditAuth', '#auth');
  11198. return betaButton[0].click();
  11199. }
  11200. GM_setValue('redditAuth', null);
  11201. window.close();
  11202. external_Swal_default().fire('', i18n('closePageNotice'));
  11203. return;
  11204. }
  11205. let website;
  11206. for (const Website of Websites) {
  11207. if (Website.test()) {
  11208. website = new Website();
  11209. break;
  11210. }
  11211. }
  11212. if (!website) {
  11213. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11214. return;
  11215. }
  11216. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11217. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11218. }
  11219. $('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>`);
  11220. $('div.show-button-div').on('click', () => {
  11221. $('#auto-task-buttons').show();
  11222. $('div.show-button-div').hide();
  11223. });
  11224. const toggleLog = () => {
  11225. const $this = $('#toggle-log');
  11226. const status = $this.attr('data-status');
  11227. if (status === 'show') {
  11228. $('#auto-task-info').hide();
  11229. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11230. } else {
  11231. $('#auto-task-info').show();
  11232. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11233. }
  11234. };
  11235. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11236. if (website.doTask) {
  11237. website.doTask();
  11238. }
  11239. });
  11240. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11241. if (website.undoTask) {
  11242. website.doTask();
  11243. }
  11244. });
  11245. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11246. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11247. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11248. }
  11249. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11250. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11251. for (const button of website.buttons) {
  11252. if (website[button]) {
  11253. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11254. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11255. website[button]();
  11256. });
  11257. $('#auto-task-buttons').append(btnElement);
  11258. }
  11259. }
  11260. }
  11261. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11262. ${i18n('hideButton')}</a></p>`);
  11263. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11264. $('#auto-task-buttons').hide();
  11265. $('div.show-button-div').show();
  11266. });
  11267. 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'}">
  11268. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11269. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11270. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11271. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11272. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11273. options(website.name, website.options);
  11274. });
  11275. }
  11276. if (website.name !== 'Setting') {
  11277. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11278. changeGlobalOptions('swal');
  11279. });
  11280. GM_registerMenuCommand(i18n('settingPage'), () => {
  11281. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11282. });
  11283. }
  11284. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11285. if (!GM_getValue('notice')) {
  11286. var _echoLog$font;
  11287. external_Swal_default().fire({
  11288. title: i18n('swalNotice'),
  11289. icon: 'warning'
  11290. }).then(() => {
  11291. window.open(i18n('noticeLink'), '_blank');
  11292. GM_setValue('notice', new Date().getTime());
  11293. });
  11294. (_echoLog$font = scripts_echoLog({
  11295. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11296. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11297. GM_setValue('notice', new Date().getTime());
  11298. });
  11299. }
  11300. scripts_updateChecker();
  11301. };
  11302. if (window.location.hostname === 'discord.com') {
  11303. const LocalStorage = window.localStorage;
  11304. if (window.location.hash === '#auth') {
  11305. var _LocalStorage$getItem;
  11306. window.localStorage.removeItem = () => true;
  11307. 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, '');
  11308. if (discordAuth && discordAuth.length > 0) {
  11309. GM_setValue('discordAuth', {
  11310. auth: discordAuth
  11311. });
  11312. window.close();
  11313. external_Swal_default().fire('', i18n('closePageNotice'));
  11314. } else {
  11315. external_Swal_default().fire({
  11316. text: i18n('getDiscordAuthFailed'),
  11317. icon: 'error'
  11318. });
  11319. }
  11320. } else {
  11321. var _LocalStorage$getItem2;
  11322. 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, '');
  11323. if (discordAuth && discordAuth.length > 0) {
  11324. GM_setValue('discordAuth', {
  11325. auth: discordAuth
  11326. });
  11327. }
  11328. }
  11329. } else if (window.location.hostname === 'opquests.com') {
  11330. loadScript();
  11331. } else {
  11332. $(loadScript);
  11333. }
  11334. }();
  11335. })();