auto-task-v4

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

目前為 2022-02-06 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.2
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12. // @icon https://auto-task-v4.hclonely.com/favicon.ico
  13.  
  14. // @include *://freeanywhere.net/*
  15. // @include *://giveaway.su/giveaway/view/*
  16. // @include *://givee.club/*/event/*
  17. // @include *://givekey.ru/giveaway/*
  18. // @include *://www.indiedb.com/giveaways*
  19. // @include *://key-hub.eu/giveaway/*
  20. // @include *://keylol.com/*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://prys.revadike.com/giveaway/?id=*
  23. // @include *://opquests.com/quests/*
  24. // @include *://gleam.io/*
  25. // @include *://sweepwidget.com/view/*
  26. // @include *://discord.com/*
  27. // @include *://www.twitch.tv/*
  28. // @include *://www.youtube.com/*
  29. // @include *://*.reddit.com/*
  30. // @include *://twitter.com/settings/account?k*
  31. // @include https://auto-task-v4.hclonely.com/setting.html
  32. // @include https://auto-task-v4.hclonely.com/history.html
  33.  
  34. // @grant GM_setValue
  35. // @grant GM_getValue
  36. // @grant GM_listValues
  37. // @grant GM_deleteValue
  38. // @grant GM_addStyle
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_info
  42. // @grant GM_openInTab
  43. // @grant GM_setClipboard
  44. // @grant GM_getResourceText
  45. // @grant unsafeWindow
  46. // @grant window.close
  47. // @grant window.localStorage
  48.  
  49. // @connect cdn.jsdelivr.net
  50. // @connect store.steampowered.com
  51. // @connect steamcommunity.com
  52. // @connect twitter.com
  53. // @connect api.twitter.com
  54. // @connect youtube.com
  55. // @connect www.youtube.com
  56. // @connect facebook.com
  57. // @connect instagram.com
  58. // @connect vk.com
  59. // @connect twitch.tv
  60. // @connect www.twitch.tv
  61. // @connect gql.twitch.tv
  62. // @connect github.com
  63. // @connect discordapp.com
  64. // @connect discord.gg
  65. // @connect discord.com
  66. // @connect www.reddit.com
  67. // @connect oauth.reddit.com
  68. // @connect raw.githubusercontent.com
  69. // @connect t.me
  70. // @connect bit.ly
  71. // @connect giveaway.su
  72. // @connect google.com
  73. // @connect www.vloot.io
  74. // @connect givee.club
  75. // @connect gleam.io
  76. // @connect www.indiedb.com
  77. // @connect key-hub.eu
  78. // @connect opquests.com
  79. // @connect itch.io
  80. // @connect auto-task-v4.hclonely.com
  81. // @connect *
  82. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  83. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  84. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  85. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  86. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  87. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  88. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  89. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  90.  
  91. // @noframes
  92. // ==/UserScript==
  93.  
  94. console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
  95.  
  96. (function() {
  97. var __webpack_modules__ = {
  98. 514: function(__unused_webpack_module, exports) {
  99. !function(e, n) {
  100. true ? n(exports) : 0;
  101. }(this, function(e) {
  102. 'use strict';
  103. var t = function() {
  104. return (t = Object.assign || function(e) {
  105. for (var n, o = 1, t = arguments.length; o < t; o++) {
  106. for (var r in n = arguments[o]) {
  107. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  108. }
  109. }
  110. return e;
  111. }).apply(this, arguments);
  112. };
  113. function r(e, n, o) {
  114. if (o || 2 === arguments.length) {
  115. for (var t, r = 0, i = n.length; r < i; r++) {
  116. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  117. }
  118. }
  119. return e.concat(t || Array.prototype.slice.call(n));
  120. }
  121. function d(e) {
  122. return '[object Object]' === n(e);
  123. }
  124. function l(e, n) {
  125. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  126. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  127. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  128. });
  129. }
  130. var n = function(e) {
  131. return Object.prototype.toString.call(e);
  132. };
  133. var o = (i.prototype.init = function() {
  134. try {
  135. this.getSystemName(), this.getBrowserName();
  136. } catch (e) {
  137. console.warn('[UA formatter error] '.concat(e));
  138. }
  139. }, i.prototype.getEngine = function() {
  140. var e = this.agent;
  141. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  142. }, i.prototype.getSystemName = function() {
  143. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  144. try {
  145. var o = '';
  146. if (/Windows/i.test(n)) {
  147. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  148. switch (this.info.os = 'Windows', t) {
  149. case '6.3':
  150. o = '8.1';
  151. break;
  152.  
  153. case '6.2':
  154. o = '8';
  155. break;
  156.  
  157. case '6.1':
  158. o = '7';
  159. break;
  160.  
  161. case '5.2':
  162. case '5.1':
  163. o = 'XP';
  164. break;
  165.  
  166. default:
  167. o = t;
  168. }
  169. return this.info.device = 'PC', void (this.info.osVersion = o);
  170. }
  171. if (/^Macintosh/i.test(n)) {
  172. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  173. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  174. }
  175. if (/^iPad/i.test(n)) {
  176. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  177. void (this.info.osVersion = o.replace(/_/g, '.'));
  178. }
  179. if (/^iPhone/i.test(n)) {
  180. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  181. void (this.info.osVersion = o.replace(/_/g, '.'));
  182. }
  183. if (-1 !== n.indexOf('Android')) {
  184. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  185. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  186. }
  187. if (/Linux\s[a-z\d_]+/.test(n)) {
  188. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  189. }
  190. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  191. } catch (e) {
  192. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  193. }
  194. }, i.prototype.getBrowserName = function() {
  195. var e = Object.keys(this.browserNameMap).map(function(e) {
  196. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  197. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  198. return -1 !== e.findIndex(function(e) {
  199. return e.test(n);
  200. });
  201. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  202. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  203. }, i.prototype._formatBrowserVersion = function(e) {
  204. var n, o, t, r;
  205. try {
  206. for (var i = null !== (o = null === (n = e.match(/(?<name>[a-z\d]+)(\/|\s)(?<version>(\d+\.)+\d+)/i)) || void 0 === n ? void 0 : n.groups) && void 0 !== o ? o : {}, s = i.name, a = i.version, c = {}, f = 0, u = Object.entries(this.browserNameMap); f < u.length; f++) {
  207. var d = u[f], l = d[0], h = d[1];
  208. if (new RegExp(l).test(s)) {
  209. c = h;
  210. break;
  211. }
  212. }
  213. var p = {
  214. browserVersion: null != a ? a : 'Unknown',
  215. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  216. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  217. };
  218. return 'Trident' === s && (p.browserVersion = {
  219. '4.0': 8,
  220. '5.0': 9,
  221. '6.0': 10,
  222. '7.0': 11
  223. }[a]), p;
  224. } catch (e) {
  225. return console.warn('[UA formatter error] '.concat(e)), {
  226. browser: 'Unknown',
  227. browserVersion: 'Unknown'
  228. };
  229. }
  230. }, i);
  231. function i(e) {
  232. this.agent = '', this.info = {
  233. browser: '',
  234. browserZH: '',
  235. browserVersion: '',
  236. os: '',
  237. osVersion: '',
  238. device: 'Unknown',
  239. engine: 'WebKit'
  240. }, this.browserNameMap = {
  241. MicroMessenger: {
  242. en: 'MicroMessenger',
  243. zh: '微信'
  244. },
  245. MetaSr: {
  246. en: 'MetaSr',
  247. zh: '搜狗浏览器'
  248. },
  249. 'QQ(Browser)?': {
  250. en: 'QQBrowser',
  251. zh: 'QQ浏览器'
  252. },
  253. UCBrowser: {
  254. en: 'UCBrowser',
  255. zh: 'UC浏览器'
  256. },
  257. '2345Explorer': {
  258. en: '2345Explorer',
  259. zh: '2345极速浏览器'
  260. },
  261. Mb2345Browser: {
  262. en: 'Mb2345Browser',
  263. zh: '2345手机浏览器'
  264. },
  265. Trident: {
  266. en: 'Internet Explorer'
  267. },
  268. 'Edge?': {
  269. en: 'Edge'
  270. },
  271. OPR: {
  272. en: 'Opera'
  273. },
  274. Vivaldi: {
  275. en: 'Vivaldi'
  276. },
  277. Firefox: {
  278. en: 'Firefox'
  279. },
  280. Chrome: {
  281. en: 'Chrome'
  282. },
  283. Safari: {
  284. en: 'Safari'
  285. }
  286. }, this.agent = e, this.init();
  287. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  288. this.info = t(t({}, this.info), {
  289. engine: this.getEngine(),
  290. browserVersion: 'Safari' === o ? n : e
  291. });
  292. }
  293. function s() {
  294. this.cookies = {}, this.init();
  295. }
  296. var a = new (s.prototype.init = function() {
  297. var o = {};
  298. document.cookie.split(/;\s/).forEach(function(e) {
  299. var n = e.split(/=/), e = n[0], n = n[1];
  300. o[e] = n;
  301. }), this.cookies = o;
  302. }, s.prototype.getItem = function(e) {
  303. return this.cookies[e];
  304. }, s.prototype.getAllItems = function() {
  305. return this.cookies;
  306. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  307. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  308. }, s)();
  309. e.countDown = function e(n, o, t, r) {
  310. if (!window) {
  311. throw new Error('window is not defind.');
  312. }
  313. if (0 < n) {
  314. return r && r(), n--, window[o] = window.setTimeout(function() {
  315. e(n, o, t, r);
  316. }, 1e3), function() {
  317. return clearTimeout(window[o]);
  318. };
  319. }
  320. clearTimeout(window[o]), t && t();
  321. }, e.createRandomID = function(e) {
  322. void 0 === e && (e = 12);
  323. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  324. n.push(o[Math.round(Math.random() * t)]);
  325. }
  326. return n.join('');
  327. }, e.dCookie = a, e.debounce = function(o, t, r) {
  328. var i;
  329. void 0 === t && (t = 0);
  330. var s = r = void 0 === r ? !1 : r;
  331. return function() {
  332. var e = this, n = arguments;
  333. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  334. r ? s = !0 : o.apply(e, n);
  335. }, t);
  336. };
  337. }, e.deepCopy = function e(n) {
  338. if (d(n) || Array.isArray(n)) {
  339. var o, t = Array.isArray(n) ? [] : {};
  340. for (o in n) {
  341. t[o] = e(n[o]);
  342. }
  343. return t;
  344. }
  345. return n;
  346. }, e.formatQueryParams = function(e) {
  347. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  348. if (!e) {
  349. return {};
  350. }
  351. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  352. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  353. return t[n] = o, e;
  354. });
  355. }
  356. return t;
  357. }, e.formatThousandth = function(e) {
  358. var n = ''.concat(e).split('.'), e = n[0], n = n[1], n = void 0 === n ? '' : n, e = e.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
  359. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  360. }, e.generateTree = function e(n, o, t, r) {
  361. for (var i = [], s = 0; s < n.length; s++) {
  362. var a = n[s];
  363. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  364. }
  365. return i;
  366. }, e.isEmpty = function(e) {
  367. return Array.isArray(e) ? 0 === e.length : d(e) ? 0 === Object.keys(e).length : [ '[object Set]', '[object Map]' ].includes(n(e)) ? 0 === e.size : [ null, void 0, '' ].includes(e);
  368. }, e.isFunction = function(e) {
  369. return '[object Function]' === n(e);
  370. }, e.isImageUrl = function(e) {
  371. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  372. }, e.isObject = d, e.isRegexp = function(e) {
  373. return '[object RegExp]' === n(e);
  374. }, e.objectKeyToCamelCase = function e(n, o, t) {
  375. if (Array.isArray(n)) {
  376. for (var r = [], i = 0; i < n.length; i++) {
  377. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  378. }
  379. } else if (d(n)) {
  380. r = {};
  381. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  382. var f = (u = c[a])[0], u = u[1];
  383. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  384. }
  385. } else {
  386. r = n;
  387. }
  388. return r;
  389. }, e.realType = n, e.searchParams = function(e, n) {
  390. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  391. new URLSearchParams(e).get(n);
  392. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  393. return e.replace(/([A-Z])/g, function(e) {
  394. return '_'.concat(e.toLocaleLowerCase());
  395. });
  396. }, e.ua = function(e) {
  397. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  398. }, Object.defineProperty(e, '__esModule', {
  399. value: !0
  400. });
  401. });
  402. },
  403. 786: function(module, __webpack_exports__, __webpack_require__) {
  404. 'use strict';
  405. __webpack_require__.d(__webpack_exports__, {
  406. Z: function() {
  407. return __WEBPACK_DEFAULT_EXPORT__;
  408. }
  409. });
  410. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  411. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  412. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  413. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  414. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default());
  415. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(10px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px rgba(5,190,5,0.4)}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 rgba(254,0,0,0.4)}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:rgba(118,118,118,0.10196);border-top:1px solid rgba(255,255,255,0.50196);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px rgba(0,0,0,0.10196);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}.left-keys.lk-green,.left-keys.lk-yellow,.left-keys.lk-red,.left-keys.lk-black{display:none !important}', '' ]);
  416. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  417. },
  418. 400: function(module) {
  419. 'use strict';
  420. module.exports = function(cssWithMappingToString) {
  421. var list = [];
  422. list.toString = function toString() {
  423. return this.map(function(item) {
  424. var content = '';
  425. var needLayer = typeof item[5] !== 'undefined';
  426. if (item[4]) {
  427. content += '@supports ('.concat(item[4], ') {');
  428. }
  429. if (item[2]) {
  430. content += '@media '.concat(item[2], ' {');
  431. }
  432. if (needLayer) {
  433. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  434. }
  435. content += cssWithMappingToString(item);
  436. if (needLayer) {
  437. content += '}';
  438. }
  439. if (item[2]) {
  440. content += '}';
  441. }
  442. if (item[4]) {
  443. content += '}';
  444. }
  445. return content;
  446. }).join('');
  447. };
  448. list.i = function i(modules, media, dedupe, supports, layer) {
  449. if (typeof modules === 'string') {
  450. modules = [ [ null, modules, undefined ] ];
  451. }
  452. var alreadyImportedModules = {};
  453. if (dedupe) {
  454. for (var k = 0; k < this.length; k++) {
  455. var id = this[k][0];
  456. if (id != null) {
  457. alreadyImportedModules[id] = true;
  458. }
  459. }
  460. }
  461. for (var _k = 0; _k < modules.length; _k++) {
  462. var item = [].concat(modules[_k]);
  463. if (dedupe && alreadyImportedModules[item[0]]) {
  464. continue;
  465. }
  466. if (typeof layer !== 'undefined') {
  467. if (typeof item[5] === 'undefined') {
  468. item[5] = layer;
  469. } else {
  470. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  471. item[5] = layer;
  472. }
  473. }
  474. if (media) {
  475. if (!item[2]) {
  476. item[2] = media;
  477. } else {
  478. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  479. item[2] = media;
  480. }
  481. }
  482. if (supports) {
  483. if (!item[4]) {
  484. item[4] = ''.concat(supports);
  485. } else {
  486. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  487. item[4] = supports;
  488. }
  489. }
  490. list.push(item);
  491. }
  492. };
  493. return list;
  494. };
  495. },
  496. 220: function(module) {
  497. 'use strict';
  498. module.exports = function(i) {
  499. return i[1];
  500. };
  501. }
  502. };
  503. var __webpack_module_cache__ = {};
  504. function __webpack_require__(moduleId) {
  505. var cachedModule = __webpack_module_cache__[moduleId];
  506. if (cachedModule !== undefined) {
  507. return cachedModule.exports;
  508. }
  509. var module = __webpack_module_cache__[moduleId] = {
  510. id: moduleId,
  511. exports: {}
  512. };
  513. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  514. return module.exports;
  515. }
  516. !function() {
  517. __webpack_require__.n = function(module) {
  518. var getter = module && module.__esModule ? function() {
  519. return module['default'];
  520. } : function() {
  521. return module;
  522. };
  523. __webpack_require__.d(getter, {
  524. a: getter
  525. });
  526. return getter;
  527. };
  528. }();
  529. !function() {
  530. __webpack_require__.d = function(exports, definition) {
  531. for (var key in definition) {
  532. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  533. Object.defineProperty(exports, key, {
  534. enumerable: true,
  535. get: definition[key]
  536. });
  537. }
  538. }
  539. };
  540. }();
  541. !function() {
  542. __webpack_require__.o = function(obj, prop) {
  543. return Object.prototype.hasOwnProperty.call(obj, prop);
  544. };
  545. }();
  546. var __webpack_exports__ = {};
  547. !function() {
  548. 'use strict';
  549. const external_Swal_namespaceObject = Swal;
  550. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  551. const external_Cookies_namespaceObject = Cookies;
  552. var auto_task = __webpack_require__(786);
  553. var javascript_utils_umd_min = __webpack_require__(514);
  554. const httpRequest = async function(options) {
  555. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  556. if (window.TRACE) {
  557. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  558. }
  559. try {
  560. const result = await new Promise(resolve => {
  561. if (options.dataType) {
  562. options.responseType = options.dataType;
  563. }
  564. const requestObj = {
  565. ...{
  566. timeout: 3e4,
  567. ontimeout(data) {
  568. resolve({
  569. result: 'Error',
  570. statusText: 'Timeout',
  571. status: 601,
  572. data: data,
  573. options: options
  574. });
  575. },
  576. onabort(data) {
  577. resolve({
  578. result: 'Error',
  579. statusText: 'Aborted',
  580. status: 602,
  581. data: data,
  582. options: options
  583. });
  584. },
  585. onerror(data) {
  586. resolve({
  587. result: 'Error',
  588. statusText: 'Error',
  589. status: 603,
  590. data: data,
  591. options: options
  592. });
  593. },
  594. onload(data) {
  595. resolve({
  596. result: 'Success',
  597. statusText: 'Load',
  598. status: 600,
  599. data: data,
  600. options: options
  601. });
  602. }
  603. },
  604. ...options
  605. };
  606. GM_xmlhttpRequest(requestObj);
  607. });
  608. if (window.DEBUG) {
  609. console.log('%cAuto-Task[httpRequest]:', 'color:blue', JSON.stringify(result));
  610. }
  611. if (result.status !== 600 && times < 2) {
  612. return await httpRequest(options, times + 1);
  613. }
  614. return result;
  615. } catch (error) {
  616. console.log('%cAuto-Task[httpRequest]:', 'color:red', JSON.stringify({
  617. errorMsg: error,
  618. options: options
  619. }));
  620. throwError(error, 'httpRequest');
  621. return {
  622. result: 'JsError',
  623. statusText: 'Error',
  624. status: 604,
  625. error: error,
  626. options: options
  627. };
  628. }
  629. };
  630. const tools_httpRequest = httpRequest;
  631. const echoLog = _ref => {
  632. let {
  633. type,
  634. text,
  635. html,
  636. id
  637. } = _ref;
  638. const emptyStatus = {
  639. success: () => emptyStatus,
  640. error: () => emptyStatus,
  641. warning: () => emptyStatus,
  642. info: () => emptyStatus,
  643. view: () => emptyStatus
  644. };
  645. try {
  646. var _ele$;
  647. let ele;
  648. if (type) {
  649. switch (type) {
  650. case 'joiningSteamGroup':
  651. case 'leavingSteamGroup':
  652. case 'gettingSteamGroupId':
  653. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  654. break;
  655.  
  656. case 'joiningSteamOfficialGroup':
  657. case 'leavingSteamOfficialGroup':
  658. case 'gettingSteamOfficialGroupId':
  659. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/games/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  660. break;
  661.  
  662. case 'subscribingForum':
  663. case 'unsubscribingForum':
  664. case 'gettingForumId':
  665. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>]...<font></font></li>`);
  666. break;
  667.  
  668. case 'followingCurator':
  669. case 'unfollowingCurator':
  670. case 'getCuratorId':
  671. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/${text !== null && text !== void 0 && text.includes('/') ? text : `curator/${text}`}" target="_blank">${text}</a>]...<font></font></li>`);
  672. break;
  673.  
  674. case 'addingToWishlist':
  675. case 'removingFromWishlist':
  676. case 'followingGame':
  677. case 'unfollowingGame':
  678. case 'gettingSubid':
  679. case 'addingFreeLicense':
  680. case 'requestingPlayTestAccess':
  681. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  682. break;
  683.  
  684. case 'addingFreeLicenseSubid':
  685. ele = $(`<li>${i18n('addingFreeLicense')}[<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  686. break;
  687.  
  688. case 'favoritingWorkshop':
  689. case 'unfavoritingWorkshop':
  690. case 'gettingWorkshopAppId':
  691. case 'votingUpWorkshop':
  692. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  693. ${text}</a>]...<font></font></li>`);
  694. break;
  695.  
  696. case 'gettingAnnouncementParams':
  697. case 'likingAnnouncement':
  698. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  699. ${id}</a>]...<font></font></li>`);
  700. break;
  701.  
  702. case 'joiningDiscordServer':
  703. case 'gettingDiscordGuild':
  704. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  705. break;
  706.  
  707. case 'leavingDiscordServer':
  708. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  709. break;
  710.  
  711. case 'updateDiscordAuth':
  712. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  713. break;
  714.  
  715. case 'followingTwitchChannel':
  716. case 'unfollowingTwitchChannel':
  717. case 'gettingTwitchChannelId':
  718. ele = $(`<li>${i18n(type)}[<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  719. break;
  720.  
  721. case 'gettingInsUserId':
  722. case 'followingIns':
  723. case 'unfollowingIns':
  724. ele = $(`<li>${i18n(type)}[<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  725. break;
  726.  
  727. case 'gettingTwitterUserId':
  728. case 'followingTwitterUser':
  729. case 'unfollowingTwitterUser':
  730. ele = $(`<li>${i18n(type)}[<a href="https://twitter.com/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  731. break;
  732.  
  733. case 'retweetting':
  734. case 'unretweetting':
  735. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  736. break;
  737.  
  738. case 'joiningReddit':
  739. case 'leavingReddit':
  740. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  741. break;
  742.  
  743. case 'followingRedditUser':
  744. case 'unfollowingRedditUser':
  745. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  746. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>]...<font></font></li>`);
  747. break;
  748.  
  749. case 'followingYtbChannel':
  750. case 'unfollowingYtbChannel':
  751. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  752. break;
  753.  
  754. case 'likingYtbVideo':
  755. case 'unlikingYtbVideo':
  756. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>]...<font></font></li>`);
  757. break;
  758.  
  759. case 'gettingVkId':
  760. case 'joiningVkGroup':
  761. case 'leavingVkGroup':
  762. case 'joiningVkPublic':
  763. case 'leavingVkPublic':
  764. case 'sendingVkWall':
  765. case 'deletingVkWall':
  766. ele = $(`<li>${i18n(type)}[<a href="https://vk.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  767. break;
  768.  
  769. case 'visitingLink':
  770. ele = $(`<li>${i18n('visitingLink')}[<a href="${text}" target="_blank">${text}</a>]...<font></font></li>`);
  771. break;
  772.  
  773. case 'verifyingInsAuth':
  774. case 'text':
  775. ele = $(`<li>${i18n(text)}<font></font></li>`);
  776. break;
  777.  
  778. case 'html':
  779. ele = $(text || html);
  780. break;
  781.  
  782. case 'whiteList':
  783. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  784. break;
  785.  
  786. case 'globalOptionsSkip':
  787. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  788. break;
  789.  
  790. default:
  791. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  792. break;
  793. }
  794. } else if (text) {
  795. ele = $(`<li>${i18n(text)}<font></font></li>`);
  796. } else if (html) {
  797. ele = $(html);
  798. } else {
  799. ele = $('<li><font></font></li>');
  800. }
  801. ele.addClass('card-text');
  802. $('#auto-task-info').append(ele);
  803. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  804. const font = ele.find('font');
  805. const status = {
  806. font: font,
  807. success() {
  808. var _this$font, _this$font2, _this$font3;
  809. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  810. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  811. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  812. html ? (_this$font2 = this.font) === null || _this$font2 === void 0 ? void 0 : _this$font2.html(text) : (_this$font3 = this.font) === null || _this$font3 === void 0 ? void 0 : _this$font3.text(text);
  813. return this;
  814. },
  815. error() {
  816. var _this$font4, _this$font5, _this$font6;
  817. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  818. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  819. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  820. html ? (_this$font5 = this.font) === null || _this$font5 === void 0 ? void 0 : _this$font5.html(text) : (_this$font6 = this.font) === null || _this$font6 === void 0 ? void 0 : _this$font6.text(text);
  821. return this;
  822. },
  823. warning() {
  824. var _this$font7, _this$font8, _this$font9;
  825. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  826. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  827. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  828. html ? (_this$font8 = this.font) === null || _this$font8 === void 0 ? void 0 : _this$font8.html(text) : (_this$font9 = this.font) === null || _this$font9 === void 0 ? void 0 : _this$font9.text(text);
  829. return this;
  830. },
  831. info() {
  832. var _this$font10, _this$font11, _this$font12;
  833. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  834. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  835. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  836. html ? (_this$font11 = this.font) === null || _this$font11 === void 0 ? void 0 : _this$font11.html(text) : (_this$font12 = this.font) === null || _this$font12 === void 0 ? void 0 : _this$font12.text(text);
  837. return this;
  838. },
  839. view() {
  840. var _this$font13;
  841. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  842. return this;
  843. }
  844. };
  845. return status;
  846. } catch (error) {
  847. throwError(error, 'echoLog');
  848. return emptyStatus;
  849. }
  850. };
  851. const scripts_echoLog = echoLog;
  852. const unique = array => {
  853. try {
  854. return [ ...new Set(array) ];
  855. } catch (error) {
  856. throwError(error, 'unique');
  857. return [];
  858. }
  859. };
  860. const delay = function() {
  861. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  862. return new Promise(resolve => {
  863. setTimeout(() => {
  864. resolve(true);
  865. }, time);
  866. });
  867. };
  868. const getRedirectLink = async link => {
  869. try {
  870. if (!link) {
  871. return null;
  872. }
  873. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  874. if (redirectLinksCache[link]) {
  875. redirectLinksCache[link];
  876. }
  877. return await tools_httpRequest({
  878. url: link,
  879. method: 'GET'
  880. }).then(_ref => {
  881. let {
  882. data
  883. } = _ref;
  884. if (data !== null && data !== void 0 && data.finalUrl) {
  885. redirectLinksCache[link] = data.finalUrl;
  886. GM_setValue('redirectLinks', redirectLinksCache);
  887. return data.finalUrl;
  888. }
  889. return null;
  890. });
  891. } catch (error) {
  892. throwError(error, 'getRedirectLink');
  893. return null;
  894. }
  895. };
  896. const visitLink = async (link, options) => {
  897. try {
  898. const logStatus = scripts_echoLog({
  899. type: 'visitLink',
  900. text: link
  901. });
  902. return await tools_httpRequest({
  903. url: link,
  904. method: 'GET',
  905. ...options
  906. }).then(_ref2 => {
  907. let {
  908. result,
  909. statusText,
  910. status
  911. } = _ref2;
  912. if (result === 'Success') {
  913. logStatus.success();
  914. return true;
  915. }
  916. logStatus.error(`${result}:${statusText}(${status})`);
  917. return false;
  918. });
  919. } catch (error) {
  920. throwError(error, 'visitLink');
  921. return false;
  922. }
  923. };
  924. const getUrlQuery = url => {
  925. try {
  926. const query = {};
  927. if (url) {
  928. if (url.includes('?')) {
  929. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  930. query[key] = value;
  931. return str;
  932. });
  933. }
  934. } else {
  935. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  936. query[key] = value;
  937. return str;
  938. });
  939. }
  940. return query;
  941. } catch (error) {
  942. throwError(error, 'getUrlQuery');
  943. return {};
  944. }
  945. };
  946. const getUuid = () => {
  947. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  948. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  949. };
  950. const stringToColour = str => {
  951. try {
  952. let hash = 0;
  953. for (let i = 0; i < str.length; i++) {
  954. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  955. }
  956. let colour = '#';
  957. for (let i = 0; i < 3; i++) {
  958. const value = hash >> i * 8 & 255;
  959. colour += `00${value.toString(16)}`.slice(-2);
  960. }
  961. return colour;
  962. } catch (error) {
  963. throwError(error, 'stringToColour');
  964. return '#fff';
  965. }
  966. };
  967. const defaultGlobalOptions = {
  968. doTask: {
  969. discord: {
  970. servers: true
  971. },
  972. instagram: {
  973. users: true
  974. },
  975. twitch: {
  976. channels: true
  977. },
  978. twitter: {
  979. users: true,
  980. retweets: true
  981. },
  982. vk: {
  983. names: true
  984. },
  985. youtube: {
  986. channels: true,
  987. likes: true
  988. },
  989. reddit: {
  990. reddits: true
  991. },
  992. steam: {
  993. groups: true,
  994. officialGroups: true,
  995. wishlists: true,
  996. follows: true,
  997. forums: true,
  998. workshops: true,
  999. curators: true,
  1000. workshopVotes: true,
  1001. announcements: true,
  1002. licenses: true,
  1003. playtests: true
  1004. }
  1005. },
  1006. undoTask: {
  1007. discord: {
  1008. servers: true
  1009. },
  1010. instagram: {
  1011. users: true
  1012. },
  1013. twitch: {
  1014. channels: true
  1015. },
  1016. twitter: {
  1017. users: true,
  1018. retweets: true
  1019. },
  1020. vk: {
  1021. names: true
  1022. },
  1023. youtube: {
  1024. channels: true,
  1025. likes: true
  1026. },
  1027. reddit: {
  1028. reddits: true
  1029. },
  1030. steam: {
  1031. groups: true,
  1032. officialGroups: true,
  1033. wishlists: true,
  1034. follows: true,
  1035. forums: true,
  1036. workshops: true,
  1037. curators: true
  1038. }
  1039. },
  1040. position: {
  1041. buttonSideX: 'right',
  1042. buttonSideY: 'top',
  1043. buttonDistance: '15,30',
  1044. showButtonSideX: 'right',
  1045. showButtonSideY: 'top',
  1046. showButtonDistance: '15,30',
  1047. logSideX: 'right',
  1048. logSideY: 'bottom',
  1049. logDistance: '10,10'
  1050. },
  1051. hotKey: {
  1052. doTaskKey: 'alt + d',
  1053. undoTaskKey: 'alt + u',
  1054. toggleLogKey: 'alt + l'
  1055. },
  1056. other: {
  1057. twitterVerifyId: '783214',
  1058. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1059. autoUpdateSource: 'jsdelivr',
  1060. language: 'zh',
  1061. checkLogin: true,
  1062. checkLeftKey: true,
  1063. defaultShowButton: true,
  1064. defaultShowLog: true,
  1065. debug: false
  1066. }
  1067. };
  1068. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1069. const assignObject = (obj1, obj2) => {
  1070. try {
  1071. const newObj = {};
  1072. for (const [ key, value ] of Object.entries(obj1)) {
  1073. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1074. newObj[key] = assignObject(value, obj2[key]);
  1075. } else {
  1076. newObj[key] = obj2[key] ?? value;
  1077. }
  1078. }
  1079. return newObj;
  1080. } catch (error) {
  1081. throwError(error, 'assignObject');
  1082. return defaultGlobalOptions;
  1083. }
  1084. };
  1085. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1086. const saveData = () => {
  1087. try {
  1088. const data = {};
  1089. $('#globalOptionsForm').serializeArray().map(value => {
  1090. data[value.name] = value.value;
  1091. return value;
  1092. });
  1093. $.makeArray($('#globalOptionsForm input')).map(element => {
  1094. const name = $(element).attr('name');
  1095. const keys = name.split('.');
  1096. if (keys.length === 3) {
  1097. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1098. } else if (keys.length === 2) {
  1099. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1100. }
  1101. return element;
  1102. });
  1103. GM_setValue('globalOptions', globalOptions);
  1104. external_Swal_default().fire({
  1105. title: i18n('changeGlobalOptionsSuccess'),
  1106. icon: 'success'
  1107. });
  1108. } catch (error) {
  1109. throwError(error, 'saveData');
  1110. }
  1111. };
  1112. const changeGlobalOptions = showType => {
  1113. try {
  1114. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1115. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1116. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1117. for (const [ option, data2 ] of Object.entries(data1)) {
  1118. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1119. if (typeof data2 === 'boolean') {
  1120. 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>`;
  1121. } else {
  1122. 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>`;
  1123. }
  1124. } else {
  1125. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1126. 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>`;
  1127. }
  1128. }
  1129. }
  1130. }
  1131. globalOptionsForm += '</tbody></table></form>';
  1132. if (showType === 'swal') {
  1133. external_Swal_default().fire({
  1134. title: i18n('globalOptions'),
  1135. html: globalOptionsForm,
  1136. showConfirmButton: true,
  1137. confirmButtonText: i18n('save'),
  1138. showCancelButton: true,
  1139. cancelButtonText: i18n('close')
  1140. }).then(_ref => {
  1141. let {
  1142. isConfirmed
  1143. } = _ref;
  1144. if (isConfirmed) {
  1145. saveData();
  1146. }
  1147. });
  1148. } else {
  1149. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1150. }
  1151. } catch (error) {
  1152. throwError(error, 'changeGlobalOptions');
  1153. }
  1154. };
  1155. const data = {
  1156. website: '网站',
  1157. type: '类型',
  1158. edit: '编辑',
  1159. whiteList: '白名单',
  1160. skipTask: '跳过撤销任务',
  1161. whiteListOptions: '白名单设置',
  1162. changeWhiteListOption: '设置白名单(%0)',
  1163. whiteListNotFound: '找不到此项白名单: %0',
  1164. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1165. changeWebsiteOptions: '网站设置',
  1166. changeGlobalOptions: '全局设置',
  1167. ok: '是',
  1168. save: '保存',
  1169. close: '关闭',
  1170. return: '返回',
  1171. option: '选项',
  1172. value: '值',
  1173. websiteOptions: '当前网站设置',
  1174. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1175. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1176. needLogin: '请先登录!',
  1177. getTasksInfo: '正在获取并处理任务信息...',
  1178. gettingKey: '正在获取Key...',
  1179. verifyingTask: '正在验证任务',
  1180. notice: '自动任务脚本提醒',
  1181. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1182. giveawayEnded: '此活动已结束,是否关闭?',
  1183. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1184. confirm: '确定',
  1185. cancel: '取消',
  1186. unKnown: '未知',
  1187. unKnownTaskType: '未识别的任务',
  1188. doing: '正在做任务',
  1189. allTasksComplete: '所有任务已完成!',
  1190. getTaskIdFailed: '获取任务Id失败!',
  1191. initSuccess: '%0 初始化成功!',
  1192. initFailed: '%0 初始化失败!',
  1193. errorLink: '链接错误: %0',
  1194. needInit: '请先初始化',
  1195. verifyingAuth: '正在验证%0凭证...',
  1196. updatingAuth: '正在更新%0凭证...',
  1197. initing: '正在初始化...',
  1198. getFailed: '获取%0失败!',
  1199. checkLoginFailed: '检测登录状态失败!',
  1200. checkLeftKeyFailed: '检测剩余Key失败!',
  1201. userId: '用户Id',
  1202. joiningGiveaway: '正在加入赠Key',
  1203. needJoinGiveaway: '需要先加入赠Key',
  1204. cannotUndo: '此网站不支持取消任务',
  1205. verifyAuth: '正在验证 %0 凭证...',
  1206. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1207. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1208. visitingLink: '正在访问链接: ',
  1209. doTask: '做任务',
  1210. undoTask: '撤销任务',
  1211. verifyTask: '验证任务',
  1212. getKey: '获取Key',
  1213. selectAll: '全选',
  1214. selectNone: '全不选',
  1215. invertSelect: '反选',
  1216. doFreeTask: '加入免费赠品',
  1217. doPointTask: '加入点数赠品',
  1218. skipTaskOption: '设置中已配置跳过任务',
  1219. other: '其他',
  1220. globalOptions: '全局设置',
  1221. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1222. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1223. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1224. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1225. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1226. saveGlobalOptions: '保存全局设置',
  1227. settingPage: '设置页面',
  1228. name: '名称',
  1229. version: '版本',
  1230. scriptManager: '脚本管理器',
  1231. script: '脚本',
  1232. environment: '环境',
  1233. os: '系统',
  1234. browser: '浏览器',
  1235. getId: '获取 %0 id',
  1236. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1237. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1238. showButton: '显示按钮',
  1239. hideButton: '隐藏按钮',
  1240. showLog: '显示日志',
  1241. hideLog: '隐藏日志',
  1242. defaultShowButton: '默认显示按钮',
  1243. defaultShowLog: '默认显示日志',
  1244. debug: '输出调试日志,不要开启此选项!',
  1245. position: '组件位置',
  1246. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1247. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1248. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1249. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1250. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1251. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1252. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1253. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1254. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1255. hotKey: '快捷键',
  1256. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1257. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1258. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1259. tasksHistory: '任务历史',
  1260. clearHistory: '清空历史',
  1261. clearHistoryFinished: '已清空任务历史!',
  1262. deleteTask: '删除任务',
  1263. lastChangeTime: '最后一次修改时间',
  1264. clearTaskFinished: '删除以下任务完成!',
  1265. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1266. syncData: '数据同步',
  1267. settingData: '正在上传数据...',
  1268. gettingData: '正在获取数据...',
  1269. help: '帮助',
  1270. fileName: '文件名',
  1271. upload2gist: '同步到Gist',
  1272. downloadFromGist: '从Gist同步',
  1273. saveAndTest: '保存配置并测试',
  1274. testSuccess: '测试成功!',
  1275. testFailed: '测试失败!',
  1276. saveAndTestNotice: '请先保存配置并测试!',
  1277. processingData: '正在处理数据...',
  1278. updatingData: '正在上传数据...',
  1279. syncDataSuccess: '同步数据成功!',
  1280. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1281. downloadingData: '正在下载数据...',
  1282. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1283. savingData: '正在保存数据...',
  1284. syncHistory: '同步任务历史',
  1285. checkUpdateFailed: '检测更新失败',
  1286. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1287. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1288. gistOptions: 'Gist 设置',
  1289. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1290. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1291. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1292. toGithub: '前往Github反馈',
  1293. toKeylol: '前往其乐论坛反馈',
  1294. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1295. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1296. updateText: '%0 版本更新内容:',
  1297. Active: '进行中',
  1298. Ended: '已结束',
  1299. Banned: '已封禁',
  1300. Paused: '已暂停',
  1301. notStart: '未开始',
  1302. noRemoteData: '检测到远程无数据',
  1303. errorRemoteDataFormat: '远程数据格式错误',
  1304. groups: '组',
  1305. officialGroups: '官方组',
  1306. wishlists: '愿望单',
  1307. follows: '游戏关注',
  1308. forums: '论坛',
  1309. workshops: '创意工坊收藏',
  1310. curators: '鉴赏家',
  1311. workshopVotes: '创意工坊点赞',
  1312. announcements: '社区通知',
  1313. steamCommunity: 'Steam社区',
  1314. steamStore: 'Steam商店',
  1315. licenses: '入库免费游戏',
  1316. playtests: '请求访问权限',
  1317. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1318. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1319. joiningSteamGroup: '正在加入Steam组',
  1320. leavingSteamGroup: '正在退出Steam组',
  1321. gettingSteamGroupId: '正在获取Steam组Id',
  1322. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1323. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1324. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1325. subscribingForum: '正在订阅Steam论坛',
  1326. unsubscribingForum: '正在取消订阅Steam论坛',
  1327. gettingForumId: '正在获取Steam论坛Id',
  1328. followingCurator: '正在关注Steam鉴赏家',
  1329. unfollowingCurator: '正在取关Steam鉴赏家',
  1330. addingToWishlist: '正在添加游戏到Steam愿望单',
  1331. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1332. followingGame: '正在关注Steam游戏',
  1333. unfollowingGame: '正在取关Steam游戏',
  1334. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1335. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1336. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1337. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1338. gettingAnnouncementParams: '正在获取Steam通知信息',
  1339. likingAnnouncement: '正在点赞Steam通知',
  1340. changingArea: '正在更换Steam地区: %0...',
  1341. notNeededChangeArea: '当前地区不需要更换',
  1342. noAnotherArea: '请检测是否开启正确开启代理',
  1343. gettingAreaInfo: '正在获取Steam地区信息...',
  1344. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1345. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1346. gettingSubid: '正在获取游戏subid',
  1347. addingFreeLicense: '正在入库',
  1348. missParams: '缺少参数',
  1349. gettingLicenses: '正在获取Licenses...',
  1350. requestingPlayTestAccess: '正在请求访问权限',
  1351. servers: '服务器',
  1352. joiningDiscordServer: '正在加入Discord服务器',
  1353. leavingDiscordServer: '正在退出Discord服务器',
  1354. gettingDiscordGuild: '正在获取Discord服务器Id',
  1355. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1356. users: '用户',
  1357. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1358. insBanned: '您的Instagram账户已被封禁',
  1359. verifyingInsAuth: '正在验证Instagram凭证...',
  1360. gettingInsUserId: '正在获取Instagram用户Id',
  1361. followingIns: '正在关注Instagram用户',
  1362. unfollowingIns: '正在取关Instagram用户',
  1363. reddits: '社区/用户',
  1364. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1365. changingRedditVersion: '正在切换Reddit为新版页面...',
  1366. joiningReddit: '正在加入Reddit社区',
  1367. leavingReddit: '正在退出Reddit社区',
  1368. followingRedditUser: '正在关注Reddit用户',
  1369. unfollowingRedditUser: '正在取关Reddit用户',
  1370. channels: '频道',
  1371. followingTwitchChannel: '正在关注Twitch频道',
  1372. unfollowingTwitchChannel: '正在取关Twitch频道',
  1373. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1374. twitterUser: '推特用户',
  1375. retweets: '转推',
  1376. followingTwitterUser: '正在关注推特用户',
  1377. unfollowingTwitterUser: '正在取关推特用户',
  1378. retweetting: '正在转推',
  1379. unretweetting: '正在撤销转推',
  1380. names: '组/社区/动态',
  1381. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1382. gettingVkId: '正在获取Vk任务Id',
  1383. joiningVkGroup: '正在加入Vk组',
  1384. leavingVkGroup: '正在退出Vk组',
  1385. joiningVkPublic: '正在加入Vk社区',
  1386. leavingVkPublic: '正在退出Vk社区',
  1387. sendingVkWall: '正在转发Vk动态',
  1388. deletingVkWall: '正在撤销转发Vk动态',
  1389. youtubeChannel: 'YouTube频道',
  1390. likes: '点赞',
  1391. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1392. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1393. gettingYtbToken: '正在获取YouTube Token...',
  1394. followingYtbChannel: '正在订阅YouTube频道',
  1395. unfollowingYtbChannel: '正在退订YouTube频道',
  1396. likingYtbVideo: '正在点赞YouTube视频',
  1397. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1398. giveKeyNoticeBefore: '每次验证间隔15s',
  1399. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1400. noPoints: '点数不够,跳过抽奖',
  1401. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1402. joiningLottery: '正在加入抽奖',
  1403. doingGleamTask: '正在做Gleam任务...',
  1404. gettingGleamLink: '正在获取Gleam任务链接...',
  1405. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1406. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1407. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1408. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1409. };
  1410. const zh_CN = data;
  1411. const en_US_data = {
  1412. website: 'Website',
  1413. type: 'Type',
  1414. edit: 'Edit',
  1415. whiteList: 'Whitelist',
  1416. skipTask: 'Skip undo task',
  1417. whiteListOptions: 'Whitelist options',
  1418. changeWhiteListOption: 'Whitelist option(%0)',
  1419. whiteListNotFound: 'Cannot find this whitelist: %0',
  1420. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1421. changeWebsiteOptions: 'Website options',
  1422. changeGlobalOptions: 'Global options',
  1423. ok: 'OK',
  1424. save: 'Save',
  1425. close: 'Close',
  1426. return: 'Return',
  1427. option: 'Option',
  1428. value: 'Value',
  1429. websiteOptions: 'Current website settings',
  1430. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1431. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1432. needLogin: 'Please log in first!',
  1433. getTasksInfo: 'Obtaining and processing task information...',
  1434. gettingKey: 'Getting Key...',
  1435. verifyingTask: 'Verifying task',
  1436. notice: 'Automatic task script notice',
  1437. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1438. giveawayEnded: 'This event has ended, do you want to close it?',
  1439. 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?',
  1440. confirm: 'Confirm',
  1441. cancel: 'Cancel',
  1442. unKnown: 'Unknown',
  1443. unKnownTaskType: 'Unrecognized task',
  1444. doing: 'Doing a task',
  1445. allTasksComplete: 'All tasks have been completed!',
  1446. getTaskIdFailed: 'Failed to obtain task Id!',
  1447. initSuccess: '%0 was initialized successfully!',
  1448. initFailed: '%0 initialization failed!',
  1449. errorLink: 'Link error: %0',
  1450. needInit: 'Please initialize first',
  1451. verifyingAuth: 'Verifying %0 token...',
  1452. updatingAuth: 'Update %0 token...',
  1453. initing: 'Initializing...',
  1454. getFailed: 'Failed to get %0!',
  1455. checkLoginFailed: 'Failed to detect login status!',
  1456. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1457. userId: 'User Id',
  1458. joiningGiveaway: 'Joining giveaway',
  1459. needJoinGiveaway: 'Need to join the giveaway first',
  1460. cannotUndo: 'This website does not support canceling tasks',
  1461. verifyAuth: 'Verifying %0 token...',
  1462. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1463. errorReport: 'A script error is detected, do you want to report the BUG?',
  1464. visitingLink: 'Visiting link: ',
  1465. doTask: 'DoTask',
  1466. undoTask: 'UndoTask',
  1467. verifyTask: 'Verify',
  1468. getKey: 'GetKey',
  1469. selectAll: 'SelectAll',
  1470. selectNone: 'SelectNone',
  1471. invertSelect: 'InvertSelect',
  1472. doFreeTask: 'FreeTask',
  1473. doPointTask: 'PointTask',
  1474. skipTaskOption: 'Skip task has been configured in the settings',
  1475. other: 'Other',
  1476. globalOptions: 'Global Options',
  1477. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1478. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1479. 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.',
  1480. 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.',
  1481. 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.',
  1482. saveGlobalOptions: 'SaveSettings',
  1483. settingPage: 'Setting Page',
  1484. name: 'Name',
  1485. version: 'Version',
  1486. scriptManager: 'Script Manager',
  1487. script: 'Script',
  1488. environment: 'Environment',
  1489. os: 'OS',
  1490. browser: 'Browser',
  1491. getId: 'Get %0 id',
  1492. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1493. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1494. showButton: 'ShowButton',
  1495. hideButton: 'HideButton',
  1496. showLog: 'ShowLog',
  1497. hideLog: 'HideLog',
  1498. defaultShowButton: 'Default display button',
  1499. defaultShowLog: 'Display log by default',
  1500. debug: 'Output debug log, do not enable this option!',
  1501. position: 'Component position',
  1502. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1503. 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',
  1504. 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',
  1505. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1506. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1507. 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',
  1508. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1509. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1510. 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',
  1511. hotKey: 'Shortcut key',
  1512. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1513. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1514. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1515. tasksHistory: 'TasksHistory',
  1516. clearHistory: 'Clear history',
  1517. clearHistoryFinished: 'The mission history has been cleared!',
  1518. deleteTask: 'Delete task',
  1519. lastChangeTime: 'Last Change Time',
  1520. clearTaskFinished: 'Delete the following tasks completed!',
  1521. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1522. syncData: 'DataSync',
  1523. settingData: 'Uploading data...',
  1524. gettingData: 'Getting data...',
  1525. help: 'Help',
  1526. fileName: 'Filename',
  1527. upload2gist: 'Sync to Gist',
  1528. downloadFromGist: 'Sync from Gist',
  1529. saveAndTest: 'Save configuration and test',
  1530. testSuccess: 'Test success!',
  1531. testFailed: 'Test failed!',
  1532. saveAndTestNotice: 'Please save the configuration and test first!',
  1533. processingData: 'Processing data...',
  1534. updatingData: 'Uploading data...',
  1535. syncDataSuccess: 'Synchronized data successfully!',
  1536. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1537. downloadingData: 'Downloading data...',
  1538. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1539. savingData: 'Saving data...',
  1540. syncHistory: 'Synchronize tasks history',
  1541. checkUpdateFailed: 'Check update failed',
  1542. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1543. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1544. gistOptions: 'Gist Settings',
  1545. 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!',
  1546. 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!',
  1547. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1548. toGithub: 'Feedback(Github)',
  1549. toKeylol: 'Feedback(Keylol)',
  1550. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1551. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1552. updateText: 'Updates in version %0:',
  1553. Active: 'Active',
  1554. Ended: 'Ended',
  1555. Banned: 'Banned',
  1556. Paused: 'Paused',
  1557. notStart: 'notStart',
  1558. noRemoteData: 'No data remotely',
  1559. errorRemoteDataFormat: 'Remote data has wrong format',
  1560. groups: 'Group',
  1561. officialGroups: 'Official Group',
  1562. wishlists: 'Wishlist',
  1563. follows: 'Follow Game',
  1564. forums: 'Forum',
  1565. workshops: 'Favorite Workshop',
  1566. curators: 'Curator',
  1567. workshopVotes: 'Voteup Workshop',
  1568. announcements: 'Announcement',
  1569. steamCommunity: 'Steam Community',
  1570. steamStore: 'Steam Store',
  1571. licenses: 'Add License',
  1572. playtests: 'Playtest Access',
  1573. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1574. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1575. joiningSteamGroup: 'Joining Steam Group',
  1576. leavingSteamGroup: 'Leaving Steam Group',
  1577. gettingSteamGroupId: 'Getting Steam Group Id',
  1578. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1579. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1580. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1581. subscribingForum: 'Subscribing the Steam Forum',
  1582. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1583. gettingForumId: 'Getting Steam Forum Id',
  1584. followingCurator: 'Following Steam Curator',
  1585. unfollowingCurator: 'Unfollowing Steam Curator',
  1586. addingToWishlist: 'Adding the game to the Steam wishlist',
  1587. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1588. followingGame: 'Following Steam games',
  1589. unfollowingGame: 'Unfollowing Steam games',
  1590. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1591. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1592. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1593. votingUpWorkshop: 'Liking Steam workshop items',
  1594. gettingAnnouncementParams: 'Getting Steam announcement information',
  1595. likingAnnouncement: 'Liking Steam announcement',
  1596. changingArea: 'Changing Steam area: %0...',
  1597. notNeededChangeArea: 'The current area does not need to be changed',
  1598. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1599. gettingAreaInfo: 'Getting Steam area information...',
  1600. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1601. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1602. gettingSubid: 'Getting subid',
  1603. addingFreeLicense: 'Adding free license',
  1604. missParams: 'Missing parameters',
  1605. gettingLicenses: 'Getting licenses...',
  1606. requestingPlayTestAccess: 'Requesting play test access',
  1607. servers: 'Server',
  1608. joiningDiscordServer: 'Joining Discord Server',
  1609. leavingDiscordServer: 'Leaving Discord Server',
  1610. gettingDiscordGuild: 'Getting Discord server Id',
  1611. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1612. users: 'User',
  1613. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1614. insBanned: 'Your Instagram account has been banned',
  1615. verifyingInsAuth: 'Verifying Instagram token...',
  1616. gettingInsUserId: 'Getting Instagram user Id',
  1617. followingIns: 'Following Instagram user',
  1618. unfollowingIns: 'Unfollowing Instagram user',
  1619. reddits: 'Reddit/User',
  1620. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1621. changingRedditVersion: 'Switching Reddit to a new version page...',
  1622. joiningReddit: 'Joining the Reddit',
  1623. leavingReddit: 'Leaving the Reddit',
  1624. followingRedditUser: 'Following Reddit User',
  1625. unfollowingRedditUser: 'Unfollowing Reddit User',
  1626. channels: 'Channel',
  1627. followingTwitchChannel: 'Following Twitch Channel',
  1628. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1629. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1630. twitterUser: 'Twitter User',
  1631. retweets: 'Retweet',
  1632. followingTwitterUser: 'Following Twitter User',
  1633. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1634. retweetting: 'Retweetting',
  1635. unretweetting: 'Unretweetting',
  1636. names: 'Group/Public/Wall',
  1637. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1638. gettingVkId: 'Getting Vk task Id',
  1639. joiningVkGroup: 'Joining Vk Group',
  1640. leavingVkGroup: 'Leaving Vk Group',
  1641. joiningVkPublic: 'Joining Vk Public',
  1642. leavingVkPublic: 'Leaving Vk Public',
  1643. sendingVkWall: 'Sending Vk Wall',
  1644. deletingVkWall: 'Deleting Vk Wall',
  1645. youtubeChannel: 'YouTube Channel',
  1646. likes: 'Like',
  1647. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1648. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1649. gettingYtbToken: 'Getting YouTube Token...',
  1650. followingYtbChannel: 'Subscribing to YouTube channel',
  1651. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1652. likingYtbVideo: 'Liking YouTube video',
  1653. unlikingYtbVideo: 'Unliking YouTube video',
  1654. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1655. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1656. noPoints: 'Not enough points, skip the lottery',
  1657. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1658. joiningLottery: 'Joining the lottery',
  1659. doingGleamTask: 'Doing Gleam Task...',
  1660. gettingGleamLink: 'Getting Gleam task link...',
  1661. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1662. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1663. 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!',
  1664. 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...'
  1665. };
  1666. const en_US = en_US_data;
  1667. const languages = {
  1668. zh: zh_CN,
  1669. en: en_US
  1670. };
  1671. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1672. const I18n = function(key) {
  1673. var _languages$language;
  1674. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1675. argvs[_key - 1] = arguments[_key];
  1676. }
  1677. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1678. return key;
  1679. }
  1680. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1681. };
  1682. const i18n = I18n;
  1683. function throwError(error, name) {
  1684. if (window.TRACE) {
  1685. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1686. }
  1687. external_Swal_default().fire({
  1688. title: i18n('errorReport'),
  1689. icon: 'error',
  1690. showCancelButton: true,
  1691. confirmButtonText: i18n('toGithub'),
  1692. showDenyButton: true,
  1693. denyButtonText: i18n('toKeylol'),
  1694. cancelButtonText: i18n('close')
  1695. }).then(_ref => {
  1696. let {
  1697. isDenied,
  1698. isConfirmed
  1699. } = _ref;
  1700. if (isConfirmed) {
  1701. 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,
  1702. 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');
  1703. } else if (isDenied) {
  1704. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1705.  
  1706. 环境:
  1707.  
  1708. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1709.  
  1710. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1711. 脚本版本: ${GM_info.script.version}
  1712.  
  1713. 报错信息:
  1714. [code]${error.stack}[/code]
  1715.  
  1716. 执行日志:
  1717. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1718. GM_setClipboard(text);
  1719. external_Swal_default().fire({
  1720. title: i18n('copySuccess'),
  1721. icon: 'success',
  1722. confirmButtonText: i18n('ok')
  1723. }).then(() => {
  1724. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1725. });
  1726. }
  1727. });
  1728. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1729. }
  1730. function _defineProperty(obj, key, value) {
  1731. if (key in obj) {
  1732. Object.defineProperty(obj, key, {
  1733. value: value,
  1734. enumerable: true,
  1735. configurable: true,
  1736. writable: true
  1737. });
  1738. } else {
  1739. obj[key] = value;
  1740. }
  1741. return obj;
  1742. }
  1743. class Social {
  1744. constructor() {
  1745. _defineProperty(this, 'tasks', void 0);
  1746. }
  1747. getRealParams(name, links, doTask, link2param) {
  1748. try {
  1749. let realParams = [];
  1750. if (links.length > 0) {
  1751. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1752. }
  1753. if (!doTask && this.tasks[name].length > 0) {
  1754. realParams = [ ...realParams, ...this.tasks[name] ];
  1755. }
  1756. return unique(realParams);
  1757. } catch (error) {
  1758. throwError(error, 'Social.getRealParams');
  1759. return [];
  1760. }
  1761. }
  1762. }
  1763. const social_Social = Social;
  1764. function _classPrivateMethodInitSpec(obj, privateSet) {
  1765. _checkPrivateRedeclaration(obj, privateSet);
  1766. privateSet.add(obj);
  1767. }
  1768. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1769. _checkPrivateRedeclaration(obj, privateMap);
  1770. privateMap.set(obj, value);
  1771. }
  1772. function _checkPrivateRedeclaration(obj, privateCollection) {
  1773. if (privateCollection.has(obj)) {
  1774. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1775. }
  1776. }
  1777. function Discord_defineProperty(obj, key, value) {
  1778. if (key in obj) {
  1779. Object.defineProperty(obj, key, {
  1780. value: value,
  1781. enumerable: true,
  1782. configurable: true,
  1783. writable: true
  1784. });
  1785. } else {
  1786. obj[key] = value;
  1787. }
  1788. return obj;
  1789. }
  1790. function _classPrivateFieldSet(receiver, privateMap, value) {
  1791. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1792. _classApplyDescriptorSet(receiver, descriptor, value);
  1793. return value;
  1794. }
  1795. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1796. if (descriptor.set) {
  1797. descriptor.set.call(receiver, value);
  1798. } else {
  1799. if (!descriptor.writable) {
  1800. throw new TypeError('attempted to set read only private field');
  1801. }
  1802. descriptor.value = value;
  1803. }
  1804. }
  1805. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1806. if (!privateSet.has(receiver)) {
  1807. throw new TypeError('attempted to get private field on non-instance');
  1808. }
  1809. return fn;
  1810. }
  1811. function _classPrivateFieldGet(receiver, privateMap) {
  1812. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1813. return _classApplyDescriptorGet(receiver, descriptor);
  1814. }
  1815. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1816. if (!privateMap.has(receiver)) {
  1817. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1818. }
  1819. return privateMap.get(receiver);
  1820. }
  1821. function _classApplyDescriptorGet(receiver, descriptor) {
  1822. if (descriptor.get) {
  1823. return descriptor.get.call(receiver);
  1824. }
  1825. return descriptor.value;
  1826. }
  1827. const defaultTasksTemplate = {
  1828. servers: []
  1829. };
  1830. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1831. var _auth = new WeakMap();
  1832. var _cache = new WeakMap();
  1833. var _initialized = new WeakMap();
  1834. var _verifyAuth = new WeakSet();
  1835. var _updateAuth = new WeakSet();
  1836. var _joinServer = new WeakSet();
  1837. var _leaveServer = new WeakSet();
  1838. var _getGuild = new WeakSet();
  1839. var _setCache = new WeakSet();
  1840. class Discord extends social_Social {
  1841. constructor() {
  1842. var _GM_getValue;
  1843. super(...arguments);
  1844. _classPrivateMethodInitSpec(this, _setCache);
  1845. _classPrivateMethodInitSpec(this, _getGuild);
  1846. _classPrivateMethodInitSpec(this, _leaveServer);
  1847. _classPrivateMethodInitSpec(this, _joinServer);
  1848. _classPrivateMethodInitSpec(this, _updateAuth);
  1849. _classPrivateMethodInitSpec(this, _verifyAuth);
  1850. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1851. Discord_defineProperty(this, 'whiteList', {
  1852. ...JSON.parse(defaultTasks),
  1853. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1854. });
  1855. _classPrivateFieldInitSpec(this, _auth, {
  1856. writable: true,
  1857. value: GM_getValue('discordAuth') || {}
  1858. });
  1859. _classPrivateFieldInitSpec(this, _cache, {
  1860. writable: true,
  1861. value: GM_getValue('discordCache') || {}
  1862. });
  1863. _classPrivateFieldInitSpec(this, _initialized, {
  1864. writable: true,
  1865. value: false
  1866. });
  1867. }
  1868. async init() {
  1869. try {
  1870. if (_classPrivateFieldGet(this, _initialized)) {
  1871. return true;
  1872. }
  1873. if (!_classPrivateFieldGet(this, _auth).auth) {
  1874. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1875. _classPrivateFieldSet(this, _initialized, true);
  1876. return true;
  1877. }
  1878. return false;
  1879. }
  1880. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1881. if (isVerified) {
  1882. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1883. _classPrivateFieldSet(this, _initialized, true);
  1884. return true;
  1885. }
  1886. GM_setValue('discordAuth', {
  1887. auth: null
  1888. });
  1889. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1890. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1891. _classPrivateFieldSet(this, _initialized, true);
  1892. return true;
  1893. }
  1894. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1895. return false;
  1896. } catch (error) {
  1897. throwError(error, 'Discord.init');
  1898. return false;
  1899. }
  1900. }
  1901. async toggle(_ref) {
  1902. let {
  1903. doTask = true,
  1904. serverLinks = []
  1905. } = _ref;
  1906. try {
  1907. if (!_classPrivateFieldGet(this, _initialized)) {
  1908. scripts_echoLog({
  1909. text: i18n('needInit')
  1910. });
  1911. return false;
  1912. }
  1913. const prom = [];
  1914. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1915. scripts_echoLog({
  1916. type: 'globalOptionsSkip',
  1917. text: 'discord.servers'
  1918. });
  1919. } else {
  1920. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1921. var _link$match;
  1922. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1923. });
  1924. if (realServers.length > 0) {
  1925. for (const server of realServers) {
  1926. if (doTask) {
  1927. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1928. } else {
  1929. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1930. }
  1931. await delay(1e3);
  1932. }
  1933. }
  1934. }
  1935. return await Promise.all(prom).then(() => true);
  1936. } catch (error) {
  1937. throwError(error, 'Discord.toggleServers');
  1938. return false;
  1939. }
  1940. }
  1941. }
  1942. async function _verifyAuth2() {
  1943. try {
  1944. const logStatus = scripts_echoLog({
  1945. text: i18n('verifyingAuth', 'Discord')
  1946. });
  1947. const {
  1948. result,
  1949. statusText,
  1950. status,
  1951. data
  1952. } = await tools_httpRequest({
  1953. url: 'https://discord.com/api/v6/users/@me',
  1954. method: 'HEAD',
  1955. headers: {
  1956. authorization: _classPrivateFieldGet(this, _auth).auth
  1957. }
  1958. });
  1959. if (result === 'Success') {
  1960. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1961. logStatus.success();
  1962. return true;
  1963. }
  1964. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1965. return false;
  1966. }
  1967. logStatus.error(`${result}:${statusText}(${status})`);
  1968. return false;
  1969. } catch (error) {
  1970. throwError(error, 'Discord.verifyAuth');
  1971. return false;
  1972. }
  1973. }
  1974. async function _updateAuth2() {
  1975. try {
  1976. const logStatus = scripts_echoLog({
  1977. text: i18n('updatingAuth', 'Discord')
  1978. });
  1979. return await new Promise(resolve => {
  1980. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1981. active: true,
  1982. insert: true,
  1983. setParent: true
  1984. });
  1985. newTab.onclose = async () => {
  1986. var _GM_getValue2;
  1987. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1988. if (auth) {
  1989. _classPrivateFieldSet(this, _auth, {
  1990. auth: auth
  1991. });
  1992. logStatus.success();
  1993. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1994. } else {
  1995. logStatus.error('Error: Update discord auth failed!');
  1996. resolve(false);
  1997. }
  1998. };
  1999. });
  2000. } catch (error) {
  2001. throwError(error, 'Discord.updateAuth');
  2002. return false;
  2003. }
  2004. }
  2005. async function _joinServer2(inviteId) {
  2006. try {
  2007. const logStatus = scripts_echoLog({
  2008. type: 'joiningDiscordServer',
  2009. text: inviteId
  2010. });
  2011. const {
  2012. result,
  2013. statusText,
  2014. status,
  2015. data
  2016. } = await tools_httpRequest({
  2017. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2018. method: 'POST',
  2019. dataType: 'json',
  2020. headers: {
  2021. authorization: _classPrivateFieldGet(this, _auth).auth
  2022. }
  2023. });
  2024. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2025. var _data$response, _data$response$guild;
  2026. logStatus.success();
  2027. 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);
  2028. if (guild) {
  2029. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2030. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2031. }
  2032. return true;
  2033. }
  2034. logStatus.error(`${result}:${statusText}(${status})`);
  2035. return false;
  2036. } catch (error) {
  2037. throwError(error, 'Discord.joinServer');
  2038. return false;
  2039. }
  2040. }
  2041. async function _leaveServer2(inviteId) {
  2042. try {
  2043. if (this.whiteList.servers.includes(inviteId)) {
  2044. scripts_echoLog({
  2045. type: 'whiteList',
  2046. text: 'Discord.leaveServer',
  2047. id: inviteId
  2048. });
  2049. return true;
  2050. }
  2051. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2052. if (!guild) {
  2053. return false;
  2054. }
  2055. const logStatus = scripts_echoLog({
  2056. type: 'leavingDiscordServer',
  2057. text: guild
  2058. });
  2059. const {
  2060. result,
  2061. statusText,
  2062. status,
  2063. data
  2064. } = await tools_httpRequest({
  2065. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2066. method: 'DELETE',
  2067. headers: {
  2068. authorization: _classPrivateFieldGet(this, _auth).auth
  2069. }
  2070. });
  2071. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2072. logStatus.success();
  2073. return true;
  2074. }
  2075. logStatus.error(`${result}:${statusText}(${status})`);
  2076. return false;
  2077. } catch (error) {
  2078. throwError(error, 'Discord.leaveServer');
  2079. return false;
  2080. }
  2081. }
  2082. async function _getGuild2(inviteId) {
  2083. try {
  2084. const logStatus = scripts_echoLog({
  2085. type: 'gettingDiscordGuild',
  2086. text: inviteId
  2087. });
  2088. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2089. if (guild) {
  2090. logStatus.success();
  2091. return guild;
  2092. }
  2093. const {
  2094. result,
  2095. statusText,
  2096. status,
  2097. data
  2098. } = await tools_httpRequest({
  2099. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2100. responseType: 'json',
  2101. method: 'GET'
  2102. });
  2103. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2104. var _data$response2, _data$response2$guild;
  2105. 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;
  2106. if (guild) {
  2107. logStatus.success();
  2108. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2109. return guild;
  2110. }
  2111. logStatus.error(`${result}:${statusText}(${status})`);
  2112. return false;
  2113. }
  2114. logStatus.error(`${result}:${statusText}(${status})`);
  2115. return false;
  2116. } catch (error) {
  2117. throwError(error, 'Discord.getGuild');
  2118. return false;
  2119. }
  2120. }
  2121. function _setCache2(inviteId, guild) {
  2122. try {
  2123. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2124. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2125. } catch (error) {
  2126. throwError(error, 'Discord.setCache');
  2127. }
  2128. }
  2129. const social_Discord = Discord;
  2130. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2131. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2132. privateSet.add(obj);
  2133. }
  2134. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2135. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2136. privateMap.set(obj, value);
  2137. }
  2138. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2139. if (privateCollection.has(obj)) {
  2140. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2141. }
  2142. }
  2143. function Instagram_defineProperty(obj, key, value) {
  2144. if (key in obj) {
  2145. Object.defineProperty(obj, key, {
  2146. value: value,
  2147. enumerable: true,
  2148. configurable: true,
  2149. writable: true
  2150. });
  2151. } else {
  2152. obj[key] = value;
  2153. }
  2154. return obj;
  2155. }
  2156. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2157. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2158. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2159. return value;
  2160. }
  2161. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2162. if (descriptor.set) {
  2163. descriptor.set.call(receiver, value);
  2164. } else {
  2165. if (!descriptor.writable) {
  2166. throw new TypeError('attempted to set read only private field');
  2167. }
  2168. descriptor.value = value;
  2169. }
  2170. }
  2171. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2172. if (!privateSet.has(receiver)) {
  2173. throw new TypeError('attempted to get private field on non-instance');
  2174. }
  2175. return fn;
  2176. }
  2177. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2178. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2179. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2180. }
  2181. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2182. if (!privateMap.has(receiver)) {
  2183. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2184. }
  2185. return privateMap.get(receiver);
  2186. }
  2187. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2188. if (descriptor.get) {
  2189. return descriptor.get.call(receiver);
  2190. }
  2191. return descriptor.value;
  2192. }
  2193. const Instagram_defaultTasksTemplate = {
  2194. users: []
  2195. };
  2196. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2197. var Instagram_cache = new WeakMap();
  2198. var Instagram_auth = new WeakMap();
  2199. var Instagram_initialized = new WeakMap();
  2200. var _getUserInfo = new WeakSet();
  2201. var _followUser = new WeakSet();
  2202. var _unfollowUser = new WeakSet();
  2203. var Instagram_setCache = new WeakSet();
  2204. class Instagram extends social_Social {
  2205. constructor() {
  2206. var _GM_getValue;
  2207. super(...arguments);
  2208. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2209. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2210. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2211. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2212. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2213. Instagram_defineProperty(this, 'whiteList', {
  2214. ...JSON.parse(Instagram_defaultTasks),
  2215. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2216. });
  2217. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2218. writable: true,
  2219. value: GM_getValue('instagramCache') || {}
  2220. });
  2221. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2222. writable: true,
  2223. value: {}
  2224. });
  2225. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2226. writable: true,
  2227. value: false
  2228. });
  2229. }
  2230. async init() {
  2231. try {
  2232. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2233. return true;
  2234. }
  2235. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2236. if (isVerified) {
  2237. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2238. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2239. return true;
  2240. }
  2241. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2242. return false;
  2243. } catch (error) {
  2244. throwError(error, 'Instagram.init');
  2245. return false;
  2246. }
  2247. }
  2248. async toggle(_ref) {
  2249. let {
  2250. doTask = true,
  2251. userLinks = []
  2252. } = _ref;
  2253. try {
  2254. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2255. scripts_echoLog({
  2256. text: i18n('needInit')
  2257. });
  2258. return false;
  2259. }
  2260. const prom = [];
  2261. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2262. scripts_echoLog({
  2263. type: 'globalOptionsSkip',
  2264. text: 'instagram.users'
  2265. });
  2266. } else {
  2267. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2268. var _link$match;
  2269. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2270. });
  2271. if (realUsers.length > 0) {
  2272. for (const username of realUsers) {
  2273. if (doTask) {
  2274. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2275. } else {
  2276. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2277. }
  2278. await delay(1e3);
  2279. }
  2280. }
  2281. }
  2282. return await Promise.all(prom).then(() => true);
  2283. } catch (error) {
  2284. throwError(error, 'Instagram.toggleUsers');
  2285. return false;
  2286. }
  2287. }
  2288. }
  2289. async function _getUserInfo2() {
  2290. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2291. try {
  2292. const logStatus = scripts_echoLog({
  2293. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2294. text: name
  2295. });
  2296. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2297. if (userId && name !== 'instagram') {
  2298. logStatus.success();
  2299. return userId;
  2300. }
  2301. const {
  2302. result,
  2303. statusText,
  2304. status,
  2305. data
  2306. } = await tools_httpRequest({
  2307. url: `https://www.instagram.com/${name}/`,
  2308. method: 'GET'
  2309. });
  2310. if (result === 'Success') {
  2311. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2312. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2313. return false;
  2314. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2315. logStatus.error(`Error:${i18n('insBanned')}`);
  2316. return false;
  2317. }
  2318. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2319. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2320. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2321. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2322. if (name === 'instagram') {
  2323. if (csrftoken && hash) {
  2324. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2325. csrftoken: csrftoken,
  2326. hash: hash
  2327. });
  2328. return true;
  2329. }
  2330. return false;
  2331. }
  2332. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2333. if (id) {
  2334. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2335. logStatus.success();
  2336. return id;
  2337. }
  2338. logStatus.error('Error: Get ins data error!');
  2339. return false;
  2340. }
  2341. logStatus.error(`${result}:${statusText}(${status})`);
  2342. return false;
  2343. }
  2344. return false;
  2345. } catch (error) {
  2346. throwError(error, 'Instagram.getUserInfo');
  2347. return false;
  2348. }
  2349. }
  2350. async function _followUser2(name) {
  2351. try {
  2352. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2353. if (!id) {
  2354. return false;
  2355. }
  2356. const logStatus = scripts_echoLog({
  2357. type: 'followingIns',
  2358. text: name
  2359. });
  2360. const {
  2361. result,
  2362. statusText,
  2363. status,
  2364. data
  2365. } = await tools_httpRequest({
  2366. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2367. method: 'POST',
  2368. dataType: 'json',
  2369. headers: {
  2370. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2371. origin: 'https://www.instagram.com',
  2372. referer: `https://www.instagram.com/${name}/`,
  2373. 'content-type': 'application/x-www-form-urlencoded',
  2374. 'sec-fetch-site': 'same-origin',
  2375. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2376. }
  2377. });
  2378. if (result === 'Success') {
  2379. var _data$response, _data$response2;
  2380. 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') {
  2381. logStatus.success();
  2382. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2383. return true;
  2384. }
  2385. 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})`}`);
  2386. return false;
  2387. }
  2388. logStatus.error(`${result}:${statusText}(${status})`);
  2389. return false;
  2390. } catch (error) {
  2391. throwError(error, 'Instagram.followUser');
  2392. return false;
  2393. }
  2394. }
  2395. async function _unfollowUser2(name) {
  2396. try {
  2397. if (this.whiteList.users.includes(name)) {
  2398. scripts_echoLog({
  2399. type: 'whiteList',
  2400. text: 'Instagram.unfollowUser',
  2401. id: name
  2402. });
  2403. return true;
  2404. }
  2405. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2406. if (!id) {
  2407. return false;
  2408. }
  2409. const logStatus = scripts_echoLog({
  2410. type: 'unfollowingIns',
  2411. text: name
  2412. });
  2413. const {
  2414. result,
  2415. statusText,
  2416. status,
  2417. data
  2418. } = await tools_httpRequest({
  2419. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2420. method: 'POST',
  2421. dataType: 'json',
  2422. headers: {
  2423. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2424. origin: 'https://www.instagram.com',
  2425. referer: `https://www.instagram.com/${name}/`,
  2426. 'content-type': 'application/x-www-form-urlencoded',
  2427. 'sec-fetch-site': 'same-origin',
  2428. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2429. }
  2430. });
  2431. if (result === 'Success') {
  2432. var _data$response3;
  2433. 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') {
  2434. logStatus.success();
  2435. return true;
  2436. }
  2437. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2438. return false;
  2439. }
  2440. logStatus.error(`${result}:${statusText}(${status})`);
  2441. return false;
  2442. } catch (error) {
  2443. throwError(error, 'Instagram.unfollowUser');
  2444. return false;
  2445. }
  2446. }
  2447. function Instagram_setCache2(name, id) {
  2448. try {
  2449. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2450. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2451. } catch (error) {
  2452. throwError(error, 'Instagram.setCache');
  2453. }
  2454. }
  2455. const social_Instagram = Instagram;
  2456. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2457. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2458. privateSet.add(obj);
  2459. }
  2460. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2461. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2462. privateMap.set(obj, value);
  2463. }
  2464. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2465. if (privateCollection.has(obj)) {
  2466. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2467. }
  2468. }
  2469. function Reddit_defineProperty(obj, key, value) {
  2470. if (key in obj) {
  2471. Object.defineProperty(obj, key, {
  2472. value: value,
  2473. enumerable: true,
  2474. configurable: true,
  2475. writable: true
  2476. });
  2477. } else {
  2478. obj[key] = value;
  2479. }
  2480. return obj;
  2481. }
  2482. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2483. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2484. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2485. return value;
  2486. }
  2487. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2488. if (descriptor.set) {
  2489. descriptor.set.call(receiver, value);
  2490. } else {
  2491. if (!descriptor.writable) {
  2492. throw new TypeError('attempted to set read only private field');
  2493. }
  2494. descriptor.value = value;
  2495. }
  2496. }
  2497. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2498. if (!privateSet.has(receiver)) {
  2499. throw new TypeError('attempted to get private field on non-instance');
  2500. }
  2501. return fn;
  2502. }
  2503. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2504. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2505. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2506. }
  2507. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2508. if (!privateMap.has(receiver)) {
  2509. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2510. }
  2511. return privateMap.get(receiver);
  2512. }
  2513. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2514. if (descriptor.get) {
  2515. return descriptor.get.call(receiver);
  2516. }
  2517. return descriptor.value;
  2518. }
  2519. const Reddit_defaultTasksTemplate = {
  2520. reddits: []
  2521. };
  2522. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2523. var Reddit_auth = new WeakMap();
  2524. var Reddit_initialized = new WeakMap();
  2525. var _useBeta = new WeakSet();
  2526. var Reddit_updateAuth = new WeakSet();
  2527. class Reddit extends social_Social {
  2528. constructor() {
  2529. var _GM_getValue;
  2530. super(...arguments);
  2531. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2532. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2533. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2534. Reddit_defineProperty(this, 'whiteList', {
  2535. ...JSON.parse(Reddit_defaultTasks),
  2536. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2537. });
  2538. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2539. writable: true,
  2540. value: void 0
  2541. });
  2542. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2543. writable: true,
  2544. value: false
  2545. });
  2546. }
  2547. async init() {
  2548. try {
  2549. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2550. return true;
  2551. }
  2552. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2553. if (isVerified) {
  2554. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2555. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2556. return true;
  2557. }
  2558. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2559. return false;
  2560. } catch (error) {
  2561. throwError(error, 'Reddit.init');
  2562. return false;
  2563. }
  2564. }
  2565. async toggleTask(_ref) {
  2566. let {
  2567. name,
  2568. doTask = true
  2569. } = _ref;
  2570. try {
  2571. if (!doTask && this.whiteList.reddits.includes(name)) {
  2572. scripts_echoLog({
  2573. type: 'whiteList',
  2574. text: 'Reddit.undoTask',
  2575. id: name
  2576. });
  2577. return true;
  2578. }
  2579. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2580. if (/^u_/.test(name)) {
  2581. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2582. }
  2583. const logStatus = scripts_echoLog({
  2584. type: type,
  2585. text: name
  2586. });
  2587. const {
  2588. result,
  2589. statusText,
  2590. status,
  2591. data
  2592. } = await tools_httpRequest({
  2593. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2594. method: 'POST',
  2595. headers: {
  2596. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2597. 'content-type': 'application/x-www-form-urlencoded'
  2598. },
  2599. data: $.param({
  2600. action: doTask ? 'sub' : 'unsub',
  2601. sr_name: name,
  2602. api_type: 'json'
  2603. })
  2604. });
  2605. if (result === 'Success') {
  2606. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2607. logStatus.success();
  2608. if (doTask) {
  2609. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2610. }
  2611. return true;
  2612. }
  2613. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2614. return false;
  2615. }
  2616. logStatus.error(`${result}:${statusText}(${status})`);
  2617. return false;
  2618. } catch (error) {
  2619. throwError(error, 'Reddit.toggleTask');
  2620. return false;
  2621. }
  2622. }
  2623. async toggle(_ref2) {
  2624. let {
  2625. doTask = true,
  2626. redditLinks = []
  2627. } = _ref2;
  2628. try {
  2629. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2630. scripts_echoLog({
  2631. text: i18n('needInit')
  2632. });
  2633. return false;
  2634. }
  2635. const prom = [];
  2636. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2637. scripts_echoLog({
  2638. type: 'globalOptionsSkip',
  2639. text: 'reddit.reddits'
  2640. });
  2641. } else {
  2642. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2643. var _link$match, _link$match2;
  2644. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2645. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2646. if (userName) {
  2647. return name || userName;
  2648. }
  2649. return name;
  2650. });
  2651. if (realReddits.length > 0) {
  2652. for (const name of realReddits) {
  2653. prom.push(this.toggleTask({
  2654. name: name,
  2655. doTask: doTask
  2656. }));
  2657. await delay(1e3);
  2658. }
  2659. }
  2660. }
  2661. return await Promise.all(prom).then(() => true);
  2662. } catch (error) {
  2663. throwError(error, 'Reddit.toggle');
  2664. return false;
  2665. }
  2666. }
  2667. }
  2668. async function _useBeta2() {
  2669. try {
  2670. const logStatus = scripts_echoLog({
  2671. text: i18n('changingRedditVersion')
  2672. });
  2673. GM_setValue('redditAuth', null);
  2674. return await new Promise(resolve => {
  2675. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2676. active: true,
  2677. insert: true,
  2678. setParent: true
  2679. });
  2680. newTab.onclose = async () => {
  2681. logStatus.success();
  2682. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2683. };
  2684. });
  2685. } catch (error) {
  2686. throwError(error, 'Reddit.useBeta');
  2687. return false;
  2688. }
  2689. }
  2690. async function Reddit_updateAuth2() {
  2691. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2692. try {
  2693. const logStatus = scripts_echoLog({
  2694. text: i18n('updatingAuth', 'Reddit')
  2695. });
  2696. const {
  2697. result,
  2698. statusText,
  2699. status,
  2700. data
  2701. } = await tools_httpRequest({
  2702. url: 'https://www.reddit.com/',
  2703. method: 'GET',
  2704. nochche: true,
  2705. headers: {
  2706. 'Cache-Control': 'no-cache'
  2707. }
  2708. });
  2709. if (result === 'Success') {
  2710. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2711. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2712. return false;
  2713. }
  2714. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2715. var _data$responseText$ma;
  2716. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2717. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2718. }
  2719. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2720. if (accessToken) {
  2721. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2722. token: accessToken
  2723. });
  2724. logStatus.success();
  2725. return true;
  2726. }
  2727. logStatus.error('Error: Parameter "accessToken" not found!');
  2728. return false;
  2729. }
  2730. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2731. return false;
  2732. }
  2733. logStatus.error(`${result}:${statusText}(${status})`);
  2734. return false;
  2735. } catch (error) {
  2736. throwError(error, 'Reddit.updateAuth');
  2737. return false;
  2738. }
  2739. }
  2740. const social_Reddit = Reddit;
  2741. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2742. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2743. privateSet.add(obj);
  2744. }
  2745. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2746. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2747. privateMap.set(obj, value);
  2748. }
  2749. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2750. if (privateCollection.has(obj)) {
  2751. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2752. }
  2753. }
  2754. function Twitch_defineProperty(obj, key, value) {
  2755. if (key in obj) {
  2756. Object.defineProperty(obj, key, {
  2757. value: value,
  2758. enumerable: true,
  2759. configurable: true,
  2760. writable: true
  2761. });
  2762. } else {
  2763. obj[key] = value;
  2764. }
  2765. return obj;
  2766. }
  2767. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2768. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2769. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2770. return value;
  2771. }
  2772. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2773. if (descriptor.set) {
  2774. descriptor.set.call(receiver, value);
  2775. } else {
  2776. if (!descriptor.writable) {
  2777. throw new TypeError('attempted to set read only private field');
  2778. }
  2779. descriptor.value = value;
  2780. }
  2781. }
  2782. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2783. if (!privateSet.has(receiver)) {
  2784. throw new TypeError('attempted to get private field on non-instance');
  2785. }
  2786. return fn;
  2787. }
  2788. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2789. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2790. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2791. }
  2792. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2793. if (!privateMap.has(receiver)) {
  2794. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2795. }
  2796. return privateMap.get(receiver);
  2797. }
  2798. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2799. if (descriptor.get) {
  2800. return descriptor.get.call(receiver);
  2801. }
  2802. return descriptor.value;
  2803. }
  2804. const Twitch_defaultTasksTemplate = {
  2805. channels: []
  2806. };
  2807. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2808. var Twitch_auth = new WeakMap();
  2809. var Twitch_cache = new WeakMap();
  2810. var Twitch_initialized = new WeakMap();
  2811. var Twitch_verifyAuth = new WeakSet();
  2812. var Twitch_updateAuth = new WeakSet();
  2813. var _toggleChannel = new WeakSet();
  2814. var _getChannelId = new WeakSet();
  2815. var Twitch_setCache = new WeakSet();
  2816. class Twitch extends social_Social {
  2817. constructor() {
  2818. var _GM_getValue;
  2819. super(...arguments);
  2820. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2821. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2822. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2823. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2824. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2825. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2826. Twitch_defineProperty(this, 'whiteList', {
  2827. ...JSON.parse(Twitch_defaultTasks),
  2828. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2829. });
  2830. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2831. writable: true,
  2832. value: GM_getValue('twitchAuth') || {}
  2833. });
  2834. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2835. writable: true,
  2836. value: GM_getValue('twitchCache') || {}
  2837. });
  2838. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2839. writable: true,
  2840. value: false
  2841. });
  2842. }
  2843. async init() {
  2844. try {
  2845. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2846. return true;
  2847. }
  2848. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2849. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2850. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2851. return true;
  2852. }
  2853. return false;
  2854. }
  2855. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2856. if (isVerified) {
  2857. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2858. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2859. return true;
  2860. }
  2861. GM_setValue('twitchAuth', null);
  2862. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2863. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2864. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2865. return true;
  2866. }
  2867. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2868. return false;
  2869. } catch (error) {
  2870. throwError(error, 'Twitch.init');
  2871. return false;
  2872. }
  2873. }
  2874. async toggle(_ref) {
  2875. let {
  2876. doTask = true,
  2877. channelLinks = []
  2878. } = _ref;
  2879. try {
  2880. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2881. scripts_echoLog({
  2882. text: i18n('needInit')
  2883. });
  2884. return false;
  2885. }
  2886. const prom = [];
  2887. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2888. scripts_echoLog({
  2889. type: 'globalOptionsSkip',
  2890. text: 'twitch.channels'
  2891. });
  2892. } else {
  2893. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2894. var _link$match;
  2895. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2896. });
  2897. if (realChannels.length > 0) {
  2898. for (const channel of realChannels) {
  2899. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2900. name: channel,
  2901. doTask: doTask
  2902. }));
  2903. await delay(1e3);
  2904. }
  2905. }
  2906. }
  2907. return Promise.all(prom).then(() => true);
  2908. } catch (error) {
  2909. throwError(error, 'Twitch.toggle');
  2910. return false;
  2911. }
  2912. }
  2913. }
  2914. async function Twitch_verifyAuth2() {
  2915. try {
  2916. const logStatus = scripts_echoLog({
  2917. text: i18n('verifyingAuth', 'Twitch')
  2918. });
  2919. const {
  2920. result,
  2921. statusText,
  2922. status,
  2923. data
  2924. } = await tools_httpRequest({
  2925. url: 'https://gql.twitch.tv/gql',
  2926. method: 'POST',
  2927. dataType: 'json',
  2928. headers: {
  2929. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2930. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2931. },
  2932. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2933. });
  2934. if (result === 'Success') {
  2935. var _data$response, _data$response$, _data$response$$data;
  2936. 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) {
  2937. logStatus.success();
  2938. return true;
  2939. }
  2940. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2941. return false;
  2942. }
  2943. logStatus.error(`${result}:${statusText}(${status})`);
  2944. return false;
  2945. } catch (error) {
  2946. throwError(error, 'Twitch.verifyAuth');
  2947. return false;
  2948. }
  2949. }
  2950. async function Twitch_updateAuth2() {
  2951. try {
  2952. const logStatus = scripts_echoLog({
  2953. text: i18n('updatingAuth', 'Twitch')
  2954. });
  2955. return await new Promise(resolve => {
  2956. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2957. active: true,
  2958. insert: true,
  2959. setParent: true
  2960. });
  2961. newTab.onclose = async () => {
  2962. const auth = GM_getValue('twitchAuth');
  2963. if (auth) {
  2964. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2965. logStatus.success();
  2966. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2967. } else {
  2968. logStatus.error('Error: Update twitch auth failed!');
  2969. resolve(false);
  2970. }
  2971. };
  2972. });
  2973. } catch (error) {
  2974. throwError(error, 'Twitch.updateAuth');
  2975. return false;
  2976. }
  2977. }
  2978. async function _toggleChannel2(_ref2) {
  2979. let {
  2980. name,
  2981. doTask = true
  2982. } = _ref2;
  2983. try {
  2984. if (!doTask && this.whiteList.channels.includes(name)) {
  2985. scripts_echoLog({
  2986. type: 'whiteList',
  2987. text: 'Twitch.unfollowChannel',
  2988. id: name
  2989. });
  2990. return true;
  2991. }
  2992. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2993. if (!channelId) {
  2994. return false;
  2995. }
  2996. const logStatus = scripts_echoLog({
  2997. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2998. text: name
  2999. });
  3000. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  3001. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  3002. const {
  3003. result,
  3004. statusText,
  3005. status,
  3006. data
  3007. } = await tools_httpRequest({
  3008. url: 'https://gql.twitch.tv/gql',
  3009. method: 'POST',
  3010. dataType: 'json',
  3011. headers: {
  3012. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  3013. },
  3014. data: doTask ? followData : unfollowData
  3015. });
  3016. if (result === 'Success') {
  3017. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3018. logStatus.success();
  3019. if (doTask) {
  3020. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3021. }
  3022. return true;
  3023. }
  3024. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3025. return false;
  3026. }
  3027. logStatus.error(`${result}:${statusText}(${status})`);
  3028. return false;
  3029. } catch (error) {
  3030. throwError(error, 'Twitch.toggleChannel');
  3031. return false;
  3032. }
  3033. }
  3034. async function _getChannelId2(name) {
  3035. try {
  3036. const logStatus = scripts_echoLog({
  3037. type: 'gettingTwitchChannelId',
  3038. text: name
  3039. });
  3040. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3041. if (channelId) {
  3042. logStatus.success();
  3043. return channelId;
  3044. }
  3045. const {
  3046. result,
  3047. statusText,
  3048. status,
  3049. data
  3050. } = await tools_httpRequest({
  3051. url: 'https://gql.twitch.tv/gql',
  3052. method: 'POST',
  3053. headers: {
  3054. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3055. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3056. },
  3057. responseType: 'json',
  3058. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3059. });
  3060. if (result === 'Success') {
  3061. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3062. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3063. 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);
  3064. if (channelId) {
  3065. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3066. logStatus.success();
  3067. return channelId;
  3068. }
  3069. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3070. return false;
  3071. }
  3072. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3073. return false;
  3074. }
  3075. logStatus.error(`${result}:${statusText}(${status})`);
  3076. return false;
  3077. } catch (error) {
  3078. throwError(error, 'Twitch.getChannelId');
  3079. return false;
  3080. }
  3081. }
  3082. function Twitch_setCache2(name, id) {
  3083. try {
  3084. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3085. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3086. } catch (error) {
  3087. throwError(error, 'Twitch.setCache');
  3088. }
  3089. }
  3090. const social_Twitch = Twitch;
  3091. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3092. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3093. privateSet.add(obj);
  3094. }
  3095. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3096. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3097. privateMap.set(obj, value);
  3098. }
  3099. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3100. if (privateCollection.has(obj)) {
  3101. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3102. }
  3103. }
  3104. function Twitter_defineProperty(obj, key, value) {
  3105. if (key in obj) {
  3106. Object.defineProperty(obj, key, {
  3107. value: value,
  3108. enumerable: true,
  3109. configurable: true,
  3110. writable: true
  3111. });
  3112. } else {
  3113. obj[key] = value;
  3114. }
  3115. return obj;
  3116. }
  3117. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3118. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3119. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3120. return value;
  3121. }
  3122. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3123. if (descriptor.set) {
  3124. descriptor.set.call(receiver, value);
  3125. } else {
  3126. if (!descriptor.writable) {
  3127. throw new TypeError('attempted to set read only private field');
  3128. }
  3129. descriptor.value = value;
  3130. }
  3131. }
  3132. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3133. if (!privateSet.has(receiver)) {
  3134. throw new TypeError('attempted to get private field on non-instance');
  3135. }
  3136. return fn;
  3137. }
  3138. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3139. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3140. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3141. }
  3142. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3143. if (!privateMap.has(receiver)) {
  3144. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3145. }
  3146. return privateMap.get(receiver);
  3147. }
  3148. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3149. if (descriptor.get) {
  3150. return descriptor.get.call(receiver);
  3151. }
  3152. return descriptor.value;
  3153. }
  3154. const Twitter_defaultTasksTemplate = {
  3155. users: [],
  3156. retweets: [],
  3157. likes: []
  3158. };
  3159. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3160. var _verifyId = new WeakMap();
  3161. var Twitter_auth = new WeakMap();
  3162. var Twitter_cache = new WeakMap();
  3163. var Twitter_initialized = new WeakMap();
  3164. var Twitter_verifyAuth = new WeakSet();
  3165. var Twitter_updateAuth = new WeakSet();
  3166. var _toggleUser = new WeakSet();
  3167. var _toggleRetweet = new WeakSet();
  3168. var Twitter_setCache = new WeakSet();
  3169. class Twitter extends social_Social {
  3170. constructor() {
  3171. var _GM_getValue;
  3172. super(...arguments);
  3173. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3174. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3175. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3176. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3177. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3178. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3179. Twitter_defineProperty(this, 'whiteList', {
  3180. ...JSON.parse(Twitter_defaultTasks),
  3181. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3182. });
  3183. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3184. writable: true,
  3185. value: globalOptions.other.twitterVerifyId
  3186. });
  3187. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3188. writable: true,
  3189. value: GM_getValue('twitterAuth') || {}
  3190. });
  3191. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3192. writable: true,
  3193. value: GM_getValue('twitterCache') || {}
  3194. });
  3195. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3196. writable: true,
  3197. value: false
  3198. });
  3199. }
  3200. async init() {
  3201. try {
  3202. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3203. return true;
  3204. }
  3205. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3206. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3207. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3208. return true;
  3209. }
  3210. return false;
  3211. }
  3212. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3213. if (isVerified) {
  3214. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3215. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3216. return true;
  3217. }
  3218. GM_setValue('twitterAuth', null);
  3219. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3220. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3221. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3222. return true;
  3223. }
  3224. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3225. return false;
  3226. } catch (error) {
  3227. throwError(error, 'Twitter.init');
  3228. return false;
  3229. }
  3230. }
  3231. async userName2id(name) {
  3232. try {
  3233. const logStatus = scripts_echoLog({
  3234. type: 'gettingTwitterUserId',
  3235. text: name
  3236. });
  3237. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3238. if (userId) {
  3239. logStatus.success();
  3240. return userId;
  3241. }
  3242. const {
  3243. result,
  3244. statusText,
  3245. status,
  3246. data
  3247. } = await tools_httpRequest({
  3248. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3249. method: 'GET',
  3250. headers: {
  3251. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3252. 'content-type': 'application/json'
  3253. },
  3254. responseType: 'json',
  3255. anonymous: true
  3256. });
  3257. if (result === 'Success') {
  3258. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3259. var _response, _response$data, _response$data$user;
  3260. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3261. if (!response) {
  3262. try {
  3263. response = JSON.parse(data.responseText);
  3264. } catch (error) {
  3265. response = null;
  3266. }
  3267. }
  3268. 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.rest_id);
  3269. if (userId) {
  3270. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3271. logStatus.success();
  3272. return userId;
  3273. }
  3274. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3275. return false;
  3276. }
  3277. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3278. return false;
  3279. }
  3280. logStatus.error(`${result}:${statusText}(${status})`);
  3281. return false;
  3282. } catch (error) {
  3283. throwError(error, 'Twitter.getUserId');
  3284. return false;
  3285. }
  3286. }
  3287. async toggle(_ref) {
  3288. let {
  3289. doTask = true,
  3290. userLinks = [],
  3291. retweetLinks = []
  3292. } = _ref;
  3293. try {
  3294. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3295. scripts_echoLog({
  3296. text: i18n('needInit')
  3297. });
  3298. return false;
  3299. }
  3300. const prom = [];
  3301. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3302. scripts_echoLog({
  3303. type: 'globalOptionsSkip',
  3304. text: 'twitter.users'
  3305. });
  3306. } else {
  3307. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3308. var _link$match;
  3309. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3310. });
  3311. if (realUsers.length > 0) {
  3312. for (const user of realUsers) {
  3313. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3314. name: user,
  3315. doTask: doTask
  3316. }));
  3317. await delay(1e3);
  3318. }
  3319. }
  3320. }
  3321. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3322. scripts_echoLog({
  3323. type: 'globalOptionsSkip',
  3324. text: 'twitter.retweets'
  3325. });
  3326. } else {
  3327. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3328. var _link$match2;
  3329. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3330. });
  3331. if (realRetweets.length > 0) {
  3332. for (const retweet of realRetweets) {
  3333. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3334. retweetId: retweet,
  3335. doTask: doTask
  3336. }));
  3337. await delay(1e3);
  3338. }
  3339. }
  3340. }
  3341. return Promise.all(prom).then(() => true);
  3342. } catch (error) {
  3343. throwError(error, 'Twitter.toggle');
  3344. return false;
  3345. }
  3346. }
  3347. }
  3348. async function Twitter_verifyAuth2() {
  3349. try {
  3350. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3351. name: 'verify',
  3352. doTask: true,
  3353. verify: true
  3354. });
  3355. } catch (error) {
  3356. throwError(error, 'Twitter.verifyAuth');
  3357. return false;
  3358. }
  3359. }
  3360. async function Twitter_updateAuth2() {
  3361. try {
  3362. const logStatus = scripts_echoLog({
  3363. text: i18n('updatingAuth', 'Twitter')
  3364. });
  3365. return await new Promise(resolve => {
  3366. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3367. active: true,
  3368. insert: true,
  3369. setParent: true
  3370. });
  3371. newTab.onclose = async () => {
  3372. const auth = GM_getValue('twitterAuth');
  3373. if (auth) {
  3374. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3375. logStatus.success();
  3376. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3377. } else {
  3378. logStatus.error('Error: Update twitter auth failed!');
  3379. resolve(false);
  3380. }
  3381. };
  3382. });
  3383. } catch (error) {
  3384. throwError(error, 'Twitter.updateToken');
  3385. return false;
  3386. }
  3387. }
  3388. async function _toggleUser2(_ref2) {
  3389. let {
  3390. name,
  3391. doTask = true,
  3392. verify = false
  3393. } = _ref2;
  3394. try {
  3395. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3396. scripts_echoLog({
  3397. type: 'whiteList',
  3398. text: 'Twitter.unfollowUser',
  3399. id: name
  3400. });
  3401. return true;
  3402. }
  3403. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3404. if (!userId) {
  3405. return false;
  3406. }
  3407. const logStatus = verify ? scripts_echoLog({
  3408. text: i18n('verifyingAuth', 'Twitter')
  3409. }) : scripts_echoLog({
  3410. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3411. text: name
  3412. });
  3413. const {
  3414. result,
  3415. statusText,
  3416. status,
  3417. data
  3418. } = await tools_httpRequest({
  3419. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3420. method: 'POST',
  3421. headers: {
  3422. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3423. 'Content-Type': 'application/x-www-form-urlencoded',
  3424. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3425. },
  3426. responseType: 'json',
  3427. data: $.param({
  3428. include_profile_interstitial_type: 1,
  3429. include_blocking: 1,
  3430. include_blocked_by: 1,
  3431. include_followed_by: 1,
  3432. include_want_retweets: 1,
  3433. include_mute_edge: 1,
  3434. include_can_dm: 1,
  3435. include_can_media_tag: 1,
  3436. skip_status: 1,
  3437. id: userId
  3438. })
  3439. });
  3440. if (result === 'Success') {
  3441. var _data$response, _data$response$errors, _data$response$errors2;
  3442. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3443. logStatus.success();
  3444. if (doTask && !verify) {
  3445. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3446. }
  3447. return true;
  3448. }
  3449. 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) {
  3450. logStatus.success();
  3451. return true;
  3452. }
  3453. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3454. return false;
  3455. }
  3456. logStatus.error(`${result}:${statusText}(${status})`);
  3457. return false;
  3458. } catch (error) {
  3459. throwError(error, 'Twitter.toggleUser');
  3460. return false;
  3461. }
  3462. }
  3463. async function _toggleRetweet2(_ref3) {
  3464. let {
  3465. retweetId,
  3466. doTask = true
  3467. } = _ref3;
  3468. try {
  3469. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3470. scripts_echoLog({
  3471. type: 'whiteList',
  3472. text: 'Twitter.unretweet',
  3473. id: retweetId
  3474. });
  3475. return true;
  3476. }
  3477. const logStatus = scripts_echoLog({
  3478. type: `${doTask ? '' : 'un'}retweetting`,
  3479. text: retweetId
  3480. });
  3481. const {
  3482. result,
  3483. statusText,
  3484. status,
  3485. data
  3486. } = await tools_httpRequest({
  3487. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3488. method: 'POST',
  3489. headers: {
  3490. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3491. 'Content-Type': 'application/x-www-form-urlencoded',
  3492. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3493. },
  3494. data: $.param({
  3495. tweet_mode: 'extended',
  3496. id: retweetId
  3497. }),
  3498. responseType: 'json'
  3499. });
  3500. if (result === 'Success') {
  3501. var _data$response2, _data$response2$error, _data$response2$error2;
  3502. 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) {
  3503. logStatus.success();
  3504. if (doTask) {
  3505. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3506. }
  3507. return true;
  3508. }
  3509. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3510. return false;
  3511. }
  3512. logStatus.error(`${result}:${statusText}(${status})`);
  3513. return false;
  3514. } catch (error) {
  3515. throwError(error, 'Twitter.toggleRetweet');
  3516. return false;
  3517. }
  3518. }
  3519. function Twitter_setCache2(name, id) {
  3520. try {
  3521. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3522. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3523. } catch (error) {
  3524. throwError(error, 'Twitter.setCache');
  3525. }
  3526. }
  3527. const social_Twitter = Twitter;
  3528. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3529. Vk_checkPrivateRedeclaration(obj, privateSet);
  3530. privateSet.add(obj);
  3531. }
  3532. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3533. Vk_checkPrivateRedeclaration(obj, privateMap);
  3534. privateMap.set(obj, value);
  3535. }
  3536. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3537. if (privateCollection.has(obj)) {
  3538. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3539. }
  3540. }
  3541. function Vk_defineProperty(obj, key, value) {
  3542. if (key in obj) {
  3543. Object.defineProperty(obj, key, {
  3544. value: value,
  3545. enumerable: true,
  3546. configurable: true,
  3547. writable: true
  3548. });
  3549. } else {
  3550. obj[key] = value;
  3551. }
  3552. return obj;
  3553. }
  3554. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3555. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3556. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3557. return value;
  3558. }
  3559. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3560. if (descriptor.set) {
  3561. descriptor.set.call(receiver, value);
  3562. } else {
  3563. if (!descriptor.writable) {
  3564. throw new TypeError('attempted to set read only private field');
  3565. }
  3566. descriptor.value = value;
  3567. }
  3568. }
  3569. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3570. if (!privateSet.has(receiver)) {
  3571. throw new TypeError('attempted to get private field on non-instance');
  3572. }
  3573. return fn;
  3574. }
  3575. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3576. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3577. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3578. }
  3579. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3580. if (!privateMap.has(receiver)) {
  3581. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3582. }
  3583. return privateMap.get(receiver);
  3584. }
  3585. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3586. if (descriptor.get) {
  3587. return descriptor.get.call(receiver);
  3588. }
  3589. return descriptor.value;
  3590. }
  3591. const Vk_defaultTasksTemplate = {
  3592. names: []
  3593. };
  3594. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3595. var _username = new WeakMap();
  3596. var Vk_cache = new WeakMap();
  3597. var Vk_initialized = new WeakMap();
  3598. var Vk_verifyAuth = new WeakSet();
  3599. var _toggleGroup = new WeakSet();
  3600. var _togglePublic = new WeakSet();
  3601. var _sendWall = new WeakSet();
  3602. var _deleteWall = new WeakSet();
  3603. var _getId = new WeakSet();
  3604. var _toggleVk = new WeakSet();
  3605. var Vk_setCache = new WeakSet();
  3606. class Vk extends social_Social {
  3607. constructor() {
  3608. var _GM_getValue;
  3609. super(...arguments);
  3610. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3611. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3612. Vk_classPrivateMethodInitSpec(this, _getId);
  3613. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3614. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3615. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3616. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3617. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3618. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3619. Vk_defineProperty(this, 'whiteList', {
  3620. ...JSON.parse(Vk_defaultTasks),
  3621. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3622. });
  3623. Vk_classPrivateFieldInitSpec(this, _username, {
  3624. writable: true,
  3625. value: ''
  3626. });
  3627. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3628. writable: true,
  3629. value: GM_getValue('vkCache') || {}
  3630. });
  3631. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3632. writable: true,
  3633. value: false
  3634. });
  3635. }
  3636. async init() {
  3637. try {
  3638. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3639. return true;
  3640. }
  3641. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3642. if (isVerified) {
  3643. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3644. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3645. return true;
  3646. }
  3647. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3648. return false;
  3649. } catch (error) {
  3650. throwError(error, 'Vk.init');
  3651. return false;
  3652. }
  3653. }
  3654. async toggle(_ref) {
  3655. let {
  3656. doTask = true,
  3657. nameLinks = []
  3658. } = _ref;
  3659. try {
  3660. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3661. scripts_echoLog({
  3662. text: i18n('needInit')
  3663. });
  3664. return false;
  3665. }
  3666. const prom = [];
  3667. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3668. scripts_echoLog({
  3669. type: 'globalOptionsSkip',
  3670. text: 'vk.names'
  3671. });
  3672. } else {
  3673. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3674. var _link$match;
  3675. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3676. });
  3677. if (realNames.length > 0) {
  3678. for (const name of realNames) {
  3679. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3680. name: name,
  3681. doTask: doTask
  3682. }));
  3683. await delay(1e3);
  3684. }
  3685. }
  3686. }
  3687. return Promise.all(prom).then(() => true);
  3688. } catch (error) {
  3689. throwError(error, 'Vk.toggle');
  3690. return false;
  3691. }
  3692. }
  3693. }
  3694. async function Vk_verifyAuth2() {
  3695. try {
  3696. const logStatus = scripts_echoLog({
  3697. text: i18n('verifyAuth', 'Vk')
  3698. });
  3699. const {
  3700. result,
  3701. statusText,
  3702. status,
  3703. data
  3704. } = await tools_httpRequest({
  3705. url: 'https://vk.com/im',
  3706. method: 'GET'
  3707. });
  3708. if (result === 'Success') {
  3709. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3710. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3711. return false;
  3712. }
  3713. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3714. var _data$responseText$ma;
  3715. 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]) || '');
  3716. logStatus.success();
  3717. return true;
  3718. }
  3719. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3720. return false;
  3721. }
  3722. logStatus.error(`${result}:${statusText}(${status})`);
  3723. return false;
  3724. } catch (error) {
  3725. throwError(error, 'Vk.verifyAuth');
  3726. return false;
  3727. }
  3728. }
  3729. async function _toggleGroup2(name, dataParam) {
  3730. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3731. try {
  3732. const logStatus = scripts_echoLog({
  3733. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3734. text: name
  3735. });
  3736. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3737. logStatus.success();
  3738. return true;
  3739. }
  3740. const reqData = {
  3741. act: doTask ? 'enter' : 'leave',
  3742. al: 1,
  3743. gid: dataParam.groupId,
  3744. hash: dataParam.groupHash
  3745. };
  3746. if (doTask) {
  3747. reqData.context = '_';
  3748. }
  3749. const {
  3750. result,
  3751. statusText,
  3752. status,
  3753. data
  3754. } = await tools_httpRequest({
  3755. url: 'https://vk.com/al_groups.php',
  3756. method: 'POST',
  3757. headers: {
  3758. origin: 'https://vk.com',
  3759. referer: `https://vk.com/${name}`,
  3760. 'content-type': 'application/x-www-form-urlencoded'
  3761. },
  3762. data: $.param(reqData)
  3763. });
  3764. if (result === 'Success') {
  3765. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3766. logStatus.success();
  3767. if (doTask) {
  3768. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3769. }
  3770. return true;
  3771. }
  3772. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3773. return false;
  3774. }
  3775. logStatus.error(`${result}:${statusText}(${status})`);
  3776. return false;
  3777. } catch (error) {
  3778. throwError(error, 'Vk.toggleGroup');
  3779. return false;
  3780. }
  3781. }
  3782. async function _togglePublic2(name, dataParam) {
  3783. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3784. try {
  3785. const logStatus = scripts_echoLog({
  3786. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3787. text: name
  3788. });
  3789. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3790. logStatus.success();
  3791. return true;
  3792. }
  3793. const {
  3794. result,
  3795. statusText,
  3796. status,
  3797. data
  3798. } = await tools_httpRequest({
  3799. url: 'https://vk.com/al_public.php',
  3800. method: 'POST',
  3801. headers: {
  3802. origin: 'https://vk.com',
  3803. referer: `https://vk.com/${name}`,
  3804. 'content-type': 'application/x-www-form-urlencoded'
  3805. },
  3806. data: $.param({
  3807. act: doTask ? 'a_enter' : 'a_leave',
  3808. al: 1,
  3809. pid: dataParam.publicPid,
  3810. hash: dataParam.publicHash
  3811. })
  3812. });
  3813. if (result === 'Success') {
  3814. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3815. logStatus.success();
  3816. if (doTask) {
  3817. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3818. }
  3819. return true;
  3820. }
  3821. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3822. return false;
  3823. }
  3824. logStatus.error(`${result}:${statusText}(${status})`);
  3825. return false;
  3826. } catch (error) {
  3827. throwError(error, 'Vk.togglePublic');
  3828. return false;
  3829. }
  3830. }
  3831. async function _sendWall2(name) {
  3832. try {
  3833. const logStatus = scripts_echoLog({
  3834. type: 'sendingVkWall',
  3835. text: name
  3836. });
  3837. const {
  3838. result,
  3839. statusText,
  3840. status,
  3841. data
  3842. } = await tools_httpRequest({
  3843. url: 'https://vk.com/like.php',
  3844. method: 'POST',
  3845. headers: {
  3846. origin: 'https://vk.com',
  3847. referer: `https://vk.com/${name}`,
  3848. 'content-type': 'application/x-www-form-urlencoded'
  3849. },
  3850. data: $.param({
  3851. act: 'publish_box',
  3852. al: 1,
  3853. object: name
  3854. })
  3855. });
  3856. if (result === 'Success') {
  3857. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3858. var _data$responseText$ma2;
  3859. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3860. if (hash) {
  3861. const {
  3862. result: resultR,
  3863. statusText: statusTextR,
  3864. status: statusR,
  3865. data: dataR
  3866. } = await tools_httpRequest({
  3867. url: 'https://vk.com/like.php',
  3868. method: 'POST',
  3869. headers: {
  3870. origin: 'https://vk.com',
  3871. referer: `https://vk.com/${name}`,
  3872. 'content-type': 'application/x-www-form-urlencoded'
  3873. },
  3874. data: $.param({
  3875. Message: '',
  3876. act: 'a_do_publish',
  3877. al: 1,
  3878. close_comments: 0,
  3879. friends_only: 0,
  3880. from: 'box',
  3881. hash: hash,
  3882. list: '',
  3883. mark_as_ads: 0,
  3884. mute_notifications: 0,
  3885. object: name,
  3886. ret_data: 1,
  3887. to: 0
  3888. })
  3889. });
  3890. if (resultR === 'Success') {
  3891. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3892. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3893. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3894. 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) {
  3895. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3896. logStatus.success();
  3897. 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);
  3898. 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);
  3899. if (postId && ownerId) {
  3900. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3901. }
  3902. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3903. return true;
  3904. }
  3905. }
  3906. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3907. return false;
  3908. }
  3909. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3910. return false;
  3911. }
  3912. logStatus.error('Error: Get "hash" failed');
  3913. return false;
  3914. }
  3915. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3916. return false;
  3917. }
  3918. logStatus.error(`${result}:${statusText}(${status})`);
  3919. return false;
  3920. } catch (error) {
  3921. throwError(error, 'Vk.sendWall');
  3922. return false;
  3923. }
  3924. }
  3925. async function _deleteWall2(name, dataParams) {
  3926. try {
  3927. const logStatus = scripts_echoLog({
  3928. type: 'deletingVkWall',
  3929. text: name
  3930. });
  3931. const {
  3932. result,
  3933. statusText,
  3934. status,
  3935. data
  3936. } = await tools_httpRequest({
  3937. url: 'https://vk.com/al_wall.php?act=delete',
  3938. method: 'POST',
  3939. headers: {
  3940. origin: 'https://vk.com',
  3941. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3942. 'content-type': 'application/x-www-form-urlencoded'
  3943. },
  3944. data: $.param({
  3945. act: 'delete',
  3946. al: 1,
  3947. confirm: 0,
  3948. from: 'wkview',
  3949. hash: dataParams.wallHash,
  3950. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3951. })
  3952. });
  3953. if (result === 'Success') {
  3954. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3955. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3956. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3957. 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]) {
  3958. logStatus.success();
  3959. return true;
  3960. }
  3961. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3962. return false;
  3963. }
  3964. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3965. return false;
  3966. }
  3967. logStatus.error(`${result}:${statusText}(${status})`);
  3968. return false;
  3969. } catch (error) {
  3970. throwError(error, 'Vk.deleteWall');
  3971. return false;
  3972. }
  3973. }
  3974. async function _getId2(name, doTask) {
  3975. try {
  3976. let url = `https://vk.com/${name}`;
  3977. if (/^wall-/.test(name)) {
  3978. if (doTask) {
  3979. return {
  3980. type: 'sendWall'
  3981. };
  3982. }
  3983. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3984. return {
  3985. type: 'unSupport'
  3986. };
  3987. }
  3988. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3989. }
  3990. const logStatus = scripts_echoLog({
  3991. type: 'gettingVkId',
  3992. text: name
  3993. });
  3994. const {
  3995. result,
  3996. statusText,
  3997. status,
  3998. data
  3999. } = await tools_httpRequest({
  4000. url: url,
  4001. method: 'GET'
  4002. });
  4003. if (result === 'Success') {
  4004. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4005. var _data$responseText$ma3, _data$responseText$ma4;
  4006. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  4007. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4008. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4009. const publicJoined = !data.responseText.includes('Public.subscribe');
  4010. if (groupAct && groupId && groupHash) {
  4011. logStatus.success();
  4012. return {
  4013. groupAct: groupAct,
  4014. groupId: groupId,
  4015. groupHash: groupHash,
  4016. type: 'group'
  4017. };
  4018. } else if (publicHash && publicPid) {
  4019. logStatus.success();
  4020. return {
  4021. publicHash: publicHash,
  4022. publicPid: publicPid,
  4023. publicJoined: publicJoined,
  4024. type: 'public'
  4025. };
  4026. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4027. var _data$responseText$ma5;
  4028. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4029. if (wallHash) {
  4030. logStatus.success();
  4031. return {
  4032. type: 'deleteWall',
  4033. wallHash: wallHash
  4034. };
  4035. }
  4036. } else if (name.includes('wall') && doTask) {
  4037. logStatus.success();
  4038. return {
  4039. type: 'sendWall'
  4040. };
  4041. }
  4042. logStatus.error('Error: Parameters not found!');
  4043. return false;
  4044. }
  4045. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4046. return false;
  4047. }
  4048. logStatus.error(`${result}:${statusText}(${status})`);
  4049. return false;
  4050. } catch (error) {
  4051. throwError(error, 'Vk.getId');
  4052. return false;
  4053. }
  4054. }
  4055. async function _toggleVk2(_ref2) {
  4056. let {
  4057. name,
  4058. doTask = true
  4059. } = _ref2;
  4060. try {
  4061. if (!doTask && this.whiteList.names.includes(name)) {
  4062. scripts_echoLog({
  4063. type: 'whiteList',
  4064. text: 'Vk.undoTask',
  4065. id: name
  4066. });
  4067. return true;
  4068. }
  4069. const formatName = name.replace(/\/$/, '');
  4070. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4071. if (!data) {
  4072. return false;
  4073. }
  4074. switch (data.type) {
  4075. case 'group':
  4076. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4077.  
  4078. case 'public':
  4079. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4080.  
  4081. case 'sendWall':
  4082. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4083.  
  4084. case 'deleteWall':
  4085. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4086.  
  4087. default:
  4088. return false;
  4089. }
  4090. } catch (error) {
  4091. throwError(error, 'Vk.toggleVk');
  4092. return false;
  4093. }
  4094. }
  4095. function Vk_setCache2(name, postId) {
  4096. try {
  4097. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4098. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4099. } catch (error) {
  4100. throwError(error, 'Vk.setCache');
  4101. }
  4102. }
  4103. const social_Vk = Vk;
  4104. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4105. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4106. privateSet.add(obj);
  4107. }
  4108. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4109. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4110. privateMap.set(obj, value);
  4111. }
  4112. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4113. if (privateCollection.has(obj)) {
  4114. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4115. }
  4116. }
  4117. function Youtube_defineProperty(obj, key, value) {
  4118. if (key in obj) {
  4119. Object.defineProperty(obj, key, {
  4120. value: value,
  4121. enumerable: true,
  4122. configurable: true,
  4123. writable: true
  4124. });
  4125. } else {
  4126. obj[key] = value;
  4127. }
  4128. return obj;
  4129. }
  4130. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4131. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4132. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4133. return value;
  4134. }
  4135. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4136. if (descriptor.set) {
  4137. descriptor.set.call(receiver, value);
  4138. } else {
  4139. if (!descriptor.writable) {
  4140. throw new TypeError('attempted to set read only private field');
  4141. }
  4142. descriptor.value = value;
  4143. }
  4144. }
  4145. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4146. if (!privateSet.has(receiver)) {
  4147. throw new TypeError('attempted to get private field on non-instance');
  4148. }
  4149. return fn;
  4150. }
  4151. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4152. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4153. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4154. }
  4155. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4156. if (!privateMap.has(receiver)) {
  4157. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4158. }
  4159. return privateMap.get(receiver);
  4160. }
  4161. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4162. if (descriptor.get) {
  4163. return descriptor.get.call(receiver);
  4164. }
  4165. return descriptor.value;
  4166. }
  4167. const Youtube_defaultTasksTemplate = {
  4168. channels: [],
  4169. likes: []
  4170. };
  4171. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4172. const getInfo = async function(link, type) {
  4173. try {
  4174. const logStatus = scripts_echoLog({
  4175. text: i18n('gettingYtbToken')
  4176. });
  4177. const {
  4178. result,
  4179. statusText,
  4180. status,
  4181. data
  4182. } = await tools_httpRequest({
  4183. url: link,
  4184. method: 'GET'
  4185. });
  4186. if (result === 'Success') {
  4187. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4188. var _data$responseText$ma, _ref;
  4189. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4190. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4191. return {
  4192. needLogin: true
  4193. };
  4194. }
  4195. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4196. 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]) || '{}';
  4197. const {
  4198. client,
  4199. request
  4200. } = JSON.parse(context);
  4201. if (apiKey && client && request) {
  4202. client.hl = 'en';
  4203. if (type === 'channel') {
  4204. var _data$responseText$ma2;
  4205. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4206. if (channelId) {
  4207. logStatus.success();
  4208. return {
  4209. params: {
  4210. apiKey: apiKey,
  4211. client: client,
  4212. request: request,
  4213. channelId: channelId
  4214. }
  4215. };
  4216. }
  4217. logStatus.error('Error: Get "channelId" failed!');
  4218. return {};
  4219. } else if (type === 'likeVideo') {
  4220. var _data$responseText$ma3, _data$responseText$ma4;
  4221. 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];
  4222. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4223. if (videoId) {
  4224. logStatus.success();
  4225. return {
  4226. params: {
  4227. apiKey: apiKey,
  4228. client: client,
  4229. request: request,
  4230. videoId: videoId,
  4231. likeParams: likeParams
  4232. }
  4233. };
  4234. }
  4235. logStatus.error('Error: Get "videoId" failed!');
  4236. return {};
  4237. }
  4238. logStatus.error('Error: Unknown type');
  4239. return {};
  4240. }
  4241. logStatus.error('Error: Parameter "apiKey" not found!');
  4242. return {};
  4243. }
  4244. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4245. return {};
  4246. }
  4247. logStatus.error(`${result}:${statusText}(${status})`);
  4248. return {};
  4249. } catch (error) {
  4250. throwError(error, 'Youtube.getInfo');
  4251. return {};
  4252. }
  4253. };
  4254. var Youtube_auth = new WeakMap();
  4255. var Youtube_initialized = new WeakMap();
  4256. var _verifyChannel = new WeakMap();
  4257. var Youtube_verifyAuth = new WeakSet();
  4258. var Youtube_updateAuth = new WeakSet();
  4259. var _getInfo = new WeakSet();
  4260. var Youtube_toggleChannel = new WeakSet();
  4261. var _toggleLikeVideo = new WeakSet();
  4262. class Youtube extends social_Social {
  4263. constructor() {
  4264. var _GM_getValue;
  4265. super(...arguments);
  4266. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4267. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4268. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4269. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4270. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4271. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4272. Youtube_defineProperty(this, 'whiteList', {
  4273. ...JSON.parse(Youtube_defaultTasks),
  4274. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4275. });
  4276. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4277. writable: true,
  4278. value: GM_getValue('youtubeAuth') || {}
  4279. });
  4280. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4281. writable: true,
  4282. value: false
  4283. });
  4284. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4285. writable: true,
  4286. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4287. });
  4288. }
  4289. async init() {
  4290. try {
  4291. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4292. return true;
  4293. }
  4294. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4295. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4296. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4297. return true;
  4298. }
  4299. return false;
  4300. }
  4301. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4302. if (isVerified) {
  4303. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4304. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4305. return true;
  4306. }
  4307. GM_setValue('youtubeAuth', null);
  4308. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4309. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4310. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4311. return true;
  4312. }
  4313. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4314. return false;
  4315. } catch (error) {
  4316. throwError(error, 'Youtube.init');
  4317. return false;
  4318. }
  4319. }
  4320. async toggle(_ref2) {
  4321. let {
  4322. doTask = true,
  4323. channelLinks = [],
  4324. videoLinks = []
  4325. } = _ref2;
  4326. try {
  4327. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4328. scripts_echoLog({
  4329. text: i18n('needInit')
  4330. });
  4331. return false;
  4332. }
  4333. const prom = [];
  4334. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4335. scripts_echoLog({
  4336. type: 'globalOptionsSkip',
  4337. text: 'youtube.channels'
  4338. });
  4339. } else {
  4340. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4341. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4342. var _link$match;
  4343. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4344. }
  4345. return link;
  4346. });
  4347. if (realChannels.length > 0) {
  4348. for (const channel of realChannels) {
  4349. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4350. link: channel,
  4351. doTask: doTask
  4352. }));
  4353. await delay(1e3);
  4354. }
  4355. }
  4356. }
  4357. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4358. scripts_echoLog({
  4359. type: 'globalOptionsSkip',
  4360. text: 'youtube.likes'
  4361. });
  4362. } else {
  4363. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4364. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4365. var _link$match2;
  4366. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4367. }
  4368. return link;
  4369. });
  4370. if (realLikes.length > 0) {
  4371. for (const video of realLikes) {
  4372. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4373. link: video,
  4374. doTask: doTask
  4375. }));
  4376. await delay(1e3);
  4377. }
  4378. }
  4379. }
  4380. return Promise.all(prom).then(() => true);
  4381. } catch (error) {
  4382. throwError(error, 'Youtube.toggle');
  4383. return false;
  4384. }
  4385. }
  4386. }
  4387. async function Youtube_verifyAuth2() {
  4388. try {
  4389. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4390. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4391. doTask: true,
  4392. verify: true
  4393. });
  4394. } catch (error) {
  4395. throwError(error, 'Youtube.verifyAuth');
  4396. return false;
  4397. }
  4398. }
  4399. async function Youtube_updateAuth2() {
  4400. try {
  4401. const logStatus = scripts_echoLog({
  4402. text: i18n('updatingAuth', 'Youtube')
  4403. });
  4404. return await new Promise(resolve => {
  4405. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4406. active: true,
  4407. insert: true,
  4408. setParent: true
  4409. });
  4410. newTab.onclose = async () => {
  4411. const auth = GM_getValue('youtubeAuth');
  4412. if (auth) {
  4413. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4414. logStatus.success();
  4415. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4416. resolve(result);
  4417. });
  4418. } else {
  4419. logStatus.error('Error: Update youtube auth failed!');
  4420. resolve(false);
  4421. }
  4422. };
  4423. });
  4424. } catch (error) {
  4425. throwError(error, 'Discord.updateAuth');
  4426. return false;
  4427. }
  4428. }
  4429. function _getInfo2(link, type) {
  4430. return getInfo(link, type);
  4431. }
  4432. async function Youtube_toggleChannel2(_ref3) {
  4433. let {
  4434. link,
  4435. doTask = true,
  4436. verify = false
  4437. } = _ref3;
  4438. try {
  4439. const {
  4440. params,
  4441. needLogin
  4442. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4443. const {
  4444. apiKey,
  4445. client,
  4446. request,
  4447. channelId
  4448. } = params || {};
  4449. if (needLogin) {
  4450. scripts_echoLog({
  4451. html: i18n('loginYtb')
  4452. });
  4453. return false;
  4454. }
  4455. if (!(apiKey && client && request && channelId)) {
  4456. scripts_echoLog({
  4457. text: '"getYtbToken" failed'
  4458. });
  4459. return false;
  4460. }
  4461. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4462. scripts_echoLog({
  4463. type: 'whiteList',
  4464. text: 'Youtube.unfollowChannel',
  4465. id: channelId
  4466. });
  4467. return true;
  4468. }
  4469. const logStatus = verify ? scripts_echoLog({
  4470. text: i18n('verifyingAuth', 'Youtube')
  4471. }) : scripts_echoLog({
  4472. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4473. text: channelId
  4474. });
  4475. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4476. const {
  4477. result,
  4478. statusText,
  4479. status,
  4480. data
  4481. } = await tools_httpRequest({
  4482. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4483. method: 'POST',
  4484. headers: {
  4485. origin: 'https://www.youtube.com',
  4486. referer: `https://www.youtube.com/channel/${channelId}`,
  4487. 'content-type': 'application/json',
  4488. 'x-goog-authuser': '0',
  4489. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4490. 'x-origin': 'https://www.youtube.com',
  4491. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4492. },
  4493. data: JSON.stringify({
  4494. context: {
  4495. client: client,
  4496. request: {
  4497. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4498. internalExperimentFlags: [],
  4499. consistencyTokenJars: []
  4500. },
  4501. user: {}
  4502. },
  4503. channelIds: [ channelId ],
  4504. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4505. })
  4506. });
  4507. if (result === 'Success') {
  4508. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4509. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4510. logStatus.success();
  4511. if (doTask && !verify) {
  4512. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4513. }
  4514. return true;
  4515. }
  4516. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4517. logStatus.success();
  4518. return true;
  4519. }
  4520. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4521. return false;
  4522. }
  4523. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4524. return false;
  4525. }
  4526. logStatus.error(`${result}:${statusText}(${status})`);
  4527. return false;
  4528. } catch (error) {
  4529. throwError(error, 'Youtube.toggleChannel');
  4530. return false;
  4531. }
  4532. }
  4533. async function _toggleLikeVideo2(_ref4) {
  4534. let {
  4535. link,
  4536. doTask = true
  4537. } = _ref4;
  4538. try {
  4539. const {
  4540. params,
  4541. needLogin
  4542. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4543. const {
  4544. apiKey,
  4545. client,
  4546. request,
  4547. videoId,
  4548. likeParams
  4549. } = params || {};
  4550. if (needLogin) {
  4551. scripts_echoLog({
  4552. html: `${i18n('loginYtb')}`
  4553. });
  4554. return false;
  4555. }
  4556. if (!(apiKey && client && request && videoId && likeParams)) {
  4557. scripts_echoLog({
  4558. text: '"getYtbToken" failed'
  4559. });
  4560. return false;
  4561. }
  4562. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4563. scripts_echoLog({
  4564. type: 'whiteList',
  4565. text: 'Youtube.unlikeVideo',
  4566. id: videoId
  4567. });
  4568. return true;
  4569. }
  4570. const logStatus = scripts_echoLog({
  4571. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4572. text: videoId
  4573. });
  4574. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4575. const likeVideoData = {
  4576. context: {
  4577. client: client,
  4578. request: {
  4579. sessionId: request.sessionId,
  4580. internalExperimentFlags: [],
  4581. consistencyTokenJars: []
  4582. },
  4583. user: {}
  4584. },
  4585. target: {
  4586. videoId: videoId
  4587. }
  4588. };
  4589. if (doTask) {
  4590. if (likeParams) {
  4591. likeVideoData.params = likeParams;
  4592. } else {
  4593. logStatus.error('Empty likeParams');
  4594. return false;
  4595. }
  4596. }
  4597. const {
  4598. result,
  4599. statusText,
  4600. status,
  4601. data
  4602. } = await tools_httpRequest({
  4603. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4604. method: 'POST',
  4605. headers: {
  4606. origin: 'https://www.youtube.com',
  4607. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4608. 'content-type': 'application/json',
  4609. 'x-goog-authuser': '0',
  4610. 'x-goog-visitor-id': client.visitorData,
  4611. 'x-origin': 'https://www.youtube.com',
  4612. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4613. },
  4614. data: JSON.stringify(likeVideoData)
  4615. });
  4616. if (result === 'Success') {
  4617. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4618. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4619. logStatus.success();
  4620. if (doTask) {
  4621. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4622. }
  4623. return true;
  4624. }
  4625. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4626. return false;
  4627. }
  4628. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4629. return false;
  4630. }
  4631. logStatus.error(`${result}:${statusText}(${status})`);
  4632. return false;
  4633. } catch (error) {
  4634. throwError(error, 'Youtube.toggleLikeVideo');
  4635. return false;
  4636. }
  4637. }
  4638. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4639. Steam_checkPrivateRedeclaration(obj, privateSet);
  4640. privateSet.add(obj);
  4641. }
  4642. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4643. Steam_checkPrivateRedeclaration(obj, privateMap);
  4644. privateMap.set(obj, value);
  4645. }
  4646. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4647. if (privateCollection.has(obj)) {
  4648. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4649. }
  4650. }
  4651. function Steam_defineProperty(obj, key, value) {
  4652. if (key in obj) {
  4653. Object.defineProperty(obj, key, {
  4654. value: value,
  4655. enumerable: true,
  4656. configurable: true,
  4657. writable: true
  4658. });
  4659. } else {
  4660. obj[key] = value;
  4661. }
  4662. return obj;
  4663. }
  4664. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4665. if (!privateSet.has(receiver)) {
  4666. throw new TypeError('attempted to get private field on non-instance');
  4667. }
  4668. return fn;
  4669. }
  4670. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4671. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4672. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4673. return value;
  4674. }
  4675. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4676. if (descriptor.set) {
  4677. descriptor.set.call(receiver, value);
  4678. } else {
  4679. if (!descriptor.writable) {
  4680. throw new TypeError('attempted to set read only private field');
  4681. }
  4682. descriptor.value = value;
  4683. }
  4684. }
  4685. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4686. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4687. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4688. }
  4689. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4690. if (!privateMap.has(receiver)) {
  4691. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4692. }
  4693. return privateMap.get(receiver);
  4694. }
  4695. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4696. if (descriptor.get) {
  4697. return descriptor.get.call(receiver);
  4698. }
  4699. return descriptor.value;
  4700. }
  4701. const Steam_defaultTasksTemplate = {
  4702. groups: [],
  4703. officialGroups: [],
  4704. wishlists: [],
  4705. follows: [],
  4706. forums: [],
  4707. workshops: [],
  4708. workshopVotes: [],
  4709. curators: [],
  4710. curatorLikes: [],
  4711. announcements: [],
  4712. licenses: [],
  4713. playtests: []
  4714. };
  4715. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4716. var Steam_cache = new WeakMap();
  4717. var Steam_auth = new WeakMap();
  4718. var _storeInitialized = new WeakMap();
  4719. var _communityInitialized = new WeakMap();
  4720. var _area = new WeakMap();
  4721. var _updateStoreAuth = new WeakSet();
  4722. var _updateCommunityAuth = new WeakSet();
  4723. var _getAreaInfo = new WeakSet();
  4724. var _changeArea = new WeakSet();
  4725. var _joinGroup = new WeakSet();
  4726. var _leaveGroup = new WeakSet();
  4727. var _getGroupId = new WeakSet();
  4728. var _joinOfficialGroup = new WeakSet();
  4729. var _leaveOfficialGroup = new WeakSet();
  4730. var _getOfficialGroupId = new WeakSet();
  4731. var _addToWishlist = new WeakSet();
  4732. var _removeFromWishlist = new WeakSet();
  4733. var _toggleFollowGame = new WeakSet();
  4734. var _isFollowedGame = new WeakSet();
  4735. var _toggleForum = new WeakSet();
  4736. var _getForumId = new WeakSet();
  4737. var _toggleFavoriteWorkshop = new WeakSet();
  4738. var _getWorkshopAppId = new WeakSet();
  4739. var _voteUpWorkshop = new WeakSet();
  4740. var _toggleCurator = new WeakSet();
  4741. var _toggleCuratorLike = new WeakSet();
  4742. var _getAnnouncementParams = new WeakSet();
  4743. var _likeAnnouncement = new WeakSet();
  4744. var _appid2subid = new WeakSet();
  4745. var _getLicenses = new WeakSet();
  4746. var _addLicense = new WeakSet();
  4747. var _addFreeLicense = new WeakSet();
  4748. var _requestPlayTestAccess = new WeakSet();
  4749. var Steam_setCache = new WeakSet();
  4750. class Steam extends social_Social {
  4751. constructor() {
  4752. var _GM_getValue;
  4753. super(...arguments);
  4754. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4755. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4756. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4757. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4758. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4759. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4760. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4761. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4762. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4763. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4764. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4765. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4766. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4767. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4768. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4769. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4770. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4771. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4772. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4773. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4774. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4775. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4776. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4777. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4778. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4779. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4780. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4781. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4782. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4783. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4784. Steam_defineProperty(this, 'whiteList', {
  4785. ...JSON.parse(Steam_defaultTasks),
  4786. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4787. });
  4788. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4789. writable: true,
  4790. value: {
  4791. ...{
  4792. group: {},
  4793. officialGroup: {},
  4794. forum: {},
  4795. workshop: {},
  4796. curator: {}
  4797. },
  4798. ...GM_getValue('steamCache')
  4799. }
  4800. });
  4801. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4802. writable: true,
  4803. value: {}
  4804. });
  4805. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4806. writable: true,
  4807. value: false
  4808. });
  4809. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4810. writable: true,
  4811. value: false
  4812. });
  4813. Steam_classPrivateFieldInitSpec(this, _area, {
  4814. writable: true,
  4815. value: 'CN'
  4816. });
  4817. }
  4818. async init() {
  4819. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4820. try {
  4821. if (type === 'store') {
  4822. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4823. return true;
  4824. }
  4825. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4826. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4827. return true;
  4828. }
  4829. if (type === 'community') {
  4830. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4831. return true;
  4832. }
  4833. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4834. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4835. return true;
  4836. }
  4837. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4838. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4839. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4840. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4841. return true;
  4842. }
  4843. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4844. return false;
  4845. } catch (error) {
  4846. throwError(error, 'Steam.init');
  4847. return false;
  4848. }
  4849. }
  4850. async getCuratorId(path, name) {
  4851. try {
  4852. const logStatus = scripts_echoLog({
  4853. type: 'gettingCuratorId',
  4854. text: `${path}/${name}`
  4855. });
  4856. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4857. if (curatorId) {
  4858. logStatus.success();
  4859. return curatorId;
  4860. }
  4861. const {
  4862. result,
  4863. statusText,
  4864. status,
  4865. data
  4866. } = await tools_httpRequest({
  4867. url: `https://store.steampowered.com/${path}/${name}`,
  4868. method: 'GET',
  4869. headers: {
  4870. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4871. }
  4872. });
  4873. if (result === 'Success') {
  4874. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4875. var _data$responseText$ma;
  4876. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4877. if (curatorId) {
  4878. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4879. logStatus.success();
  4880. return curatorId;
  4881. }
  4882. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4883. return false;
  4884. }
  4885. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4886. return false;
  4887. }
  4888. logStatus.error(`${result}:${statusText}(${status})`);
  4889. return false;
  4890. } catch (error) {
  4891. throwError(error, 'Steam.getCuratorID');
  4892. return false;
  4893. }
  4894. }
  4895. async toggle(_ref) {
  4896. let {
  4897. doTask = true,
  4898. groupLinks = [],
  4899. officialGroupLinks = [],
  4900. wishlistLinks = [],
  4901. followLinks = [],
  4902. forumLinks = [],
  4903. workshopLinks = [],
  4904. workshopVoteLinks = [],
  4905. curatorLinks = [],
  4906. curatorLikeLinks = [],
  4907. announcementLinks = [],
  4908. licenseLinks = [],
  4909. playtestLinks = []
  4910. } = _ref;
  4911. try {
  4912. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4913. scripts_echoLog({
  4914. text: i18n('needInit')
  4915. });
  4916. return false;
  4917. }
  4918. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4919. scripts_echoLog({
  4920. text: i18n('needInit')
  4921. });
  4922. return false;
  4923. }
  4924. const prom = [];
  4925. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4926. scripts_echoLog({
  4927. type: 'globalOptionsSkip',
  4928. text: 'steam.groups'
  4929. });
  4930. } else {
  4931. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4932. var _link$match;
  4933. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4934. });
  4935. if (realGroups.length > 0) {
  4936. for (const group of realGroups) {
  4937. if (doTask) {
  4938. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4939. } else {
  4940. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4941. }
  4942. await delay(1e3);
  4943. }
  4944. }
  4945. }
  4946. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  4947. scripts_echoLog({
  4948. type: 'globalOptionsSkip',
  4949. text: 'steam.officialGroups'
  4950. });
  4951. } else {
  4952. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  4953. var _link$match2;
  4954. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4955. });
  4956. if (realOfficialGroups.length > 0) {
  4957. for (const officialGroup of realOfficialGroups) {
  4958. if (doTask) {
  4959. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  4960. } else {
  4961. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  4962. }
  4963. await delay(1e3);
  4964. }
  4965. }
  4966. }
  4967. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4968. scripts_echoLog({
  4969. type: 'globalOptionsSkip',
  4970. text: 'steam.wishlists'
  4971. });
  4972. } else {
  4973. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4974. var _link$match3;
  4975. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4976. });
  4977. if (realWishlists.length > 0) {
  4978. for (const game of realWishlists) {
  4979. if (doTask) {
  4980. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4981. } else {
  4982. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4983. }
  4984. await delay(1e3);
  4985. }
  4986. }
  4987. }
  4988. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4989. scripts_echoLog({
  4990. type: 'globalOptionsSkip',
  4991. text: 'steam.follows'
  4992. });
  4993. } else {
  4994. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4995. var _link$match4;
  4996. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4997. });
  4998. if (realFollows.length > 0) {
  4999. for (const game of realFollows) {
  5000. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  5001. await delay(1e3);
  5002. }
  5003. }
  5004. }
  5005. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5006. scripts_echoLog({
  5007. type: 'globalOptionsSkip',
  5008. text: 'steam.forums'
  5009. });
  5010. } else {
  5011. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5012. var _link$match5;
  5013. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5014. });
  5015. if (realForums.length > 0) {
  5016. for (const forum of realForums) {
  5017. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5018. await delay(1e3);
  5019. }
  5020. }
  5021. }
  5022. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5023. scripts_echoLog({
  5024. type: 'globalOptionsSkip',
  5025. text: 'steam.workshops'
  5026. });
  5027. } else {
  5028. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5029. var _link$match6;
  5030. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5031. });
  5032. if (realWorkshops.length > 0) {
  5033. for (const workshop of realWorkshops) {
  5034. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5035. await delay(1e3);
  5036. }
  5037. }
  5038. }
  5039. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5040. scripts_echoLog({
  5041. type: 'globalOptionsSkip',
  5042. text: 'steam.workshopVotes'
  5043. });
  5044. } else {
  5045. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5046. var _link$match7;
  5047. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5048. });
  5049. if (doTask && realworkshopVotes.length > 0) {
  5050. for (const workshop of realworkshopVotes) {
  5051. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5052. await delay(1e3);
  5053. }
  5054. }
  5055. }
  5056. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5057. scripts_echoLog({
  5058. type: 'globalOptionsSkip',
  5059. text: 'steam.curators'
  5060. });
  5061. } else {
  5062. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5063. var _link$match8;
  5064. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5065. });
  5066. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5067. var _link$match9;
  5068. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5069. });
  5070. if (realCurators.length > 0) {
  5071. for (const curator of realCurators) {
  5072. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5073. await delay(1e3);
  5074. }
  5075. }
  5076. if (realCuratorLikes.length > 0) {
  5077. for (const curatorLike of realCuratorLikes) {
  5078. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5079. await delay(1e3);
  5080. }
  5081. }
  5082. }
  5083. if (doTask && !globalOptions.doTask.steam.announcements) {
  5084. scripts_echoLog({
  5085. type: 'globalOptionsSkip',
  5086. text: 'steam.announcements'
  5087. });
  5088. } else {
  5089. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5090. var _link$match11;
  5091. if (link.includes('store.steampowered.com')) {
  5092. var _link$match10;
  5093. 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('/');
  5094. }
  5095. 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('/');
  5096. });
  5097. if (doTask && realAnnouncements.length > 0) {
  5098. for (const id of realAnnouncements) {
  5099. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5100. await delay(1e3);
  5101. }
  5102. }
  5103. }
  5104. if (doTask && !globalOptions.doTask.steam.licenses) {
  5105. scripts_echoLog({
  5106. type: 'globalOptionsSkip',
  5107. text: 'steam.licenses'
  5108. });
  5109. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5110. for (const id of licenseLinks) {
  5111. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5112. await delay(1e3);
  5113. }
  5114. }
  5115. if (doTask && !globalOptions.doTask.steam.playtests) {
  5116. scripts_echoLog({
  5117. type: 'globalOptionsSkip',
  5118. text: 'steam.playtests'
  5119. });
  5120. } else {
  5121. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5122. var _link$match12;
  5123. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5124. });
  5125. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5126. for (const id of realPlaytests) {
  5127. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5128. await delay(1e3);
  5129. }
  5130. }
  5131. }
  5132. return Promise.all(prom).then(async () => {
  5133. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5134. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5135. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5136. }
  5137. return true;
  5138. });
  5139. } catch (error) {
  5140. throwError(error, 'Steam.toggle');
  5141. return false;
  5142. }
  5143. }
  5144. }
  5145. async function _updateStoreAuth2() {
  5146. try {
  5147. const logStatus = scripts_echoLog({
  5148. text: i18n('updatingAuth', i18n('steamStore'))
  5149. });
  5150. const {
  5151. result,
  5152. statusText,
  5153. status,
  5154. data
  5155. } = await tools_httpRequest({
  5156. url: 'https://store.steampowered.com/stats/',
  5157. method: 'GET'
  5158. });
  5159. if (result === 'Success') {
  5160. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5161. var _data$responseText$ma2;
  5162. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5163. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5164. return false;
  5165. }
  5166. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5167. if (storeSessionID) {
  5168. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5169. logStatus.success();
  5170. return true;
  5171. }
  5172. logStatus.error('Error: Get "sessionID" failed');
  5173. return false;
  5174. }
  5175. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5176. return false;
  5177. }
  5178. logStatus.error(`${result}:${statusText}(${status})`);
  5179. return false;
  5180. } catch (error) {
  5181. throwError(error, 'Steam.updateStoreAuth');
  5182. return false;
  5183. }
  5184. }
  5185. async function _updateCommunityAuth2() {
  5186. try {
  5187. const logStatus = scripts_echoLog({
  5188. text: i18n('updatingAuth', i18n('steamCommunity'))
  5189. });
  5190. const {
  5191. result,
  5192. statusText,
  5193. status,
  5194. data
  5195. } = await tools_httpRequest({
  5196. url: 'https://steamcommunity.com/my',
  5197. method: 'GET'
  5198. });
  5199. if (result === 'Success') {
  5200. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5201. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5202. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5203. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5204. return false;
  5205. }
  5206. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5207. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5208. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5209. if (steam64Id) {
  5210. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5211. }
  5212. if (userName) {
  5213. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5214. }
  5215. if (communitySessionID) {
  5216. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5217. logStatus.success();
  5218. return true;
  5219. }
  5220. logStatus.error('Error: Get "sessionID" failed');
  5221. return false;
  5222. }
  5223. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5224. return false;
  5225. }
  5226. logStatus.error(`${result}:${statusText}(${status})`);
  5227. return false;
  5228. } catch (error) {
  5229. throwError(error, 'Steam.updateCommunityAuth');
  5230. return false;
  5231. }
  5232. }
  5233. async function _getAreaInfo2() {
  5234. try {
  5235. const logStatus = scripts_echoLog({
  5236. text: i18n('gettingAreaInfo')
  5237. });
  5238. const {
  5239. result,
  5240. statusText,
  5241. status,
  5242. data
  5243. } = await tools_httpRequest({
  5244. url: 'https://store.steampowered.com/cart/',
  5245. method: 'GET'
  5246. });
  5247. if (result === 'Success') {
  5248. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5249. var _data$responseText$ma6;
  5250. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5251. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5252. if (currentArea && areas.length > 0) {
  5253. Steam_classPrivateFieldSet(this, _area, currentArea);
  5254. logStatus.success();
  5255. return {
  5256. currentArea: currentArea,
  5257. areas: areas
  5258. };
  5259. }
  5260. logStatus.error('Error: get country info filed');
  5261. return {};
  5262. }
  5263. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5264. return {};
  5265. }
  5266. logStatus.error(`${result}:${statusText}(${status})`);
  5267. return {};
  5268. } catch (error) {
  5269. throwError(error, 'Steam.getAreaInfo');
  5270. return {};
  5271. }
  5272. }
  5273. async function _changeArea2(area) {
  5274. try {
  5275. let aimedArea = area;
  5276. if (!aimedArea) {
  5277. const {
  5278. currentArea,
  5279. areas
  5280. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5281. if (!currentArea || !areas) {
  5282. return false;
  5283. }
  5284. if (currentArea !== 'CN') {
  5285. scripts_echoLog({
  5286. text: 'notNeededChangeArea'
  5287. });
  5288. return 'skip';
  5289. }
  5290. const anotherArea = areas.filter(area => area && area !== 'CN');
  5291. if (!anotherArea || anotherArea.length === 0) {
  5292. scripts_echoLog({
  5293. text: 'noAnotherArea'
  5294. });
  5295. return false;
  5296. }
  5297. [ aimedArea ] = anotherArea;
  5298. }
  5299. const logStatus = scripts_echoLog({
  5300. text: i18n('changingArea', aimedArea)
  5301. });
  5302. const {
  5303. result,
  5304. statusText,
  5305. status,
  5306. data
  5307. } = await tools_httpRequest({
  5308. url: 'https://store.steampowered.com/account/setcountry',
  5309. method: 'POST',
  5310. headers: {
  5311. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5312. },
  5313. data: $.param({
  5314. cc: aimedArea,
  5315. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5316. })
  5317. });
  5318. if (result === 'Success') {
  5319. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5320. const {
  5321. currentArea
  5322. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5323. if (currentArea === aimedArea) {
  5324. logStatus.success();
  5325. return currentArea;
  5326. }
  5327. logStatus.error('Error: change country filed');
  5328. return 'CN';
  5329. }
  5330. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5331. return 'CN';
  5332. }
  5333. logStatus.error(`${result}:${statusText}(${status})`);
  5334. return 'CN';
  5335. } catch (error) {
  5336. throwError(error, 'Steam.changeArea');
  5337. return false;
  5338. }
  5339. }
  5340. async function _joinGroup2(groupName) {
  5341. try {
  5342. const logStatus = scripts_echoLog({
  5343. type: 'joiningSteamGroup',
  5344. text: groupName
  5345. });
  5346. const {
  5347. result,
  5348. statusText,
  5349. status,
  5350. data
  5351. } = await tools_httpRequest({
  5352. url: `https://steamcommunity.com/groups/${groupName}`,
  5353. method: 'POST',
  5354. headers: {
  5355. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5356. },
  5357. data: $.param({
  5358. action: 'join',
  5359. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5360. })
  5361. });
  5362. if (result === 'Success') {
  5363. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5364. logStatus.success();
  5365. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5366. return true;
  5367. }
  5368. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5369. return false;
  5370. }
  5371. logStatus.error(`${result}:${statusText}(${status})`);
  5372. return false;
  5373. } catch (error) {
  5374. throwError(error, 'Steam.joinGroup');
  5375. return false;
  5376. }
  5377. }
  5378. async function _leaveGroup2(groupName) {
  5379. try {
  5380. if (this.whiteList.groups.includes(groupName)) {
  5381. scripts_echoLog({
  5382. type: 'whiteList',
  5383. text: 'Steam.leaveGroup',
  5384. id: groupName
  5385. });
  5386. return true;
  5387. }
  5388. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5389. if (!groupId) {
  5390. return false;
  5391. }
  5392. const logStatus = scripts_echoLog({
  5393. type: 'leavingSteamGroup',
  5394. text: groupName
  5395. });
  5396. const {
  5397. result,
  5398. statusText,
  5399. status,
  5400. data
  5401. } = await tools_httpRequest({
  5402. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5403. method: 'POST',
  5404. headers: {
  5405. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5406. },
  5407. data: $.param({
  5408. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5409. action: 'leaveGroup',
  5410. groupId: groupId
  5411. })
  5412. });
  5413. if (result === 'Success') {
  5414. 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) {
  5415. logStatus.success();
  5416. return true;
  5417. }
  5418. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5419. return false;
  5420. }
  5421. logStatus.error(`${result}:${statusText}(${status})`);
  5422. return false;
  5423. } catch (error) {
  5424. throwError(error, 'Steam.leaveGroup');
  5425. return false;
  5426. }
  5427. }
  5428. async function _getGroupId2(groupName) {
  5429. try {
  5430. const logStatus = scripts_echoLog({
  5431. type: 'gettingSteamGroupId',
  5432. text: groupName
  5433. });
  5434. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5435. if (groupId) {
  5436. logStatus.success();
  5437. return groupId;
  5438. }
  5439. const {
  5440. result,
  5441. statusText,
  5442. status,
  5443. data
  5444. } = await tools_httpRequest({
  5445. url: `https://steamcommunity.com/groups/${groupName}`,
  5446. method: 'GET',
  5447. headers: {
  5448. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5449. }
  5450. });
  5451. if (result === 'Success') {
  5452. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5453. var _data$responseText$ma7;
  5454. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5455. if (groupId) {
  5456. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5457. logStatus.success();
  5458. return groupId;
  5459. }
  5460. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5461. return false;
  5462. }
  5463. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5464. return false;
  5465. }
  5466. logStatus.error(`${result}:${statusText}(${status})`);
  5467. return false;
  5468. } catch (error) {
  5469. throwError(error, 'Steam.getGroupID');
  5470. return false;
  5471. }
  5472. }
  5473. async function _joinOfficialGroup2(gameId) {
  5474. try {
  5475. const logStatus = scripts_echoLog({
  5476. type: 'joiningSteamOfficialGroup',
  5477. text: gameId
  5478. });
  5479. const {
  5480. result,
  5481. statusText,
  5482. status,
  5483. data
  5484. } = await tools_httpRequest({
  5485. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5486. method: 'GET',
  5487. headers: {
  5488. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5489. }
  5490. });
  5491. if (result === 'Success') {
  5492. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5493. var _data$responseText$ma8;
  5494. logStatus.success();
  5495. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5496. 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];
  5497. if (groupId) {
  5498. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5499. }
  5500. return true;
  5501. }
  5502. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5503. return false;
  5504. }
  5505. logStatus.error(`${result}:${statusText}(${status})`);
  5506. return false;
  5507. } catch (error) {
  5508. throwError(error, 'Steam.joinOfficialGroup');
  5509. return false;
  5510. }
  5511. }
  5512. async function _leaveOfficialGroup2(gameId) {
  5513. try {
  5514. if (this.whiteList.officialGroups.includes(gameId)) {
  5515. scripts_echoLog({
  5516. type: 'whiteList',
  5517. text: 'Steam.leaveOfficialGroup',
  5518. id: gameId
  5519. });
  5520. return true;
  5521. }
  5522. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5523. if (!groupId) {
  5524. return false;
  5525. }
  5526. const logStatus = scripts_echoLog({
  5527. type: 'leavingSteamOfficialGroup',
  5528. text: gameId
  5529. });
  5530. const {
  5531. result,
  5532. statusText,
  5533. status,
  5534. data
  5535. } = await tools_httpRequest({
  5536. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5537. method: 'POST',
  5538. headers: {
  5539. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5540. },
  5541. data: $.param({
  5542. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5543. action: 'leaveGroup',
  5544. groupId: groupId
  5545. })
  5546. });
  5547. if (result === 'Success') {
  5548. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5549. const {
  5550. result: resultR,
  5551. statusText: statusTextR,
  5552. status: statusR,
  5553. data: dataR
  5554. } = await tools_httpRequest({
  5555. url: `https://steamcommunity.com/games/${gameId}`,
  5556. method: 'GET',
  5557. headers: {
  5558. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5559. }
  5560. });
  5561. if (resultR === 'Success') {
  5562. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5563. logStatus.success();
  5564. return true;
  5565. }
  5566. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5567. return false;
  5568. }
  5569. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5570. return false;
  5571. }
  5572. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5573. return false;
  5574. }
  5575. logStatus.error(`${result}:${statusText}(${status})`);
  5576. return false;
  5577. } catch (error) {
  5578. throwError(error, 'Steam.leaveOfficialGroup');
  5579. return false;
  5580. }
  5581. }
  5582. async function _getOfficialGroupId2(gameId) {
  5583. try {
  5584. const logStatus = scripts_echoLog({
  5585. type: 'gettingSteamOfficialGroupId',
  5586. text: gameId
  5587. });
  5588. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5589. if (groupId) {
  5590. logStatus.success();
  5591. return groupId;
  5592. }
  5593. const {
  5594. result,
  5595. statusText,
  5596. status,
  5597. data
  5598. } = await tools_httpRequest({
  5599. url: `https://steamcommunity.com/games/${gameId}`,
  5600. method: 'GET',
  5601. headers: {
  5602. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5603. }
  5604. });
  5605. if (result === 'Success') {
  5606. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5607. var _data$responseText$ma9;
  5608. 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];
  5609. if (groupId) {
  5610. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5611. logStatus.success();
  5612. return groupId;
  5613. }
  5614. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5615. return false;
  5616. }
  5617. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5618. return false;
  5619. }
  5620. logStatus.error(`${result}:${statusText}(${status})`);
  5621. return false;
  5622. } catch (error) {
  5623. throwError(error, 'Steam.getGroupID');
  5624. return false;
  5625. }
  5626. }
  5627. async function _addToWishlist2(gameId) {
  5628. try {
  5629. var _data$response;
  5630. const logStatus = scripts_echoLog({
  5631. type: 'addingToWishlist',
  5632. text: gameId
  5633. });
  5634. const {
  5635. result,
  5636. data
  5637. } = await tools_httpRequest({
  5638. url: 'https://store.steampowered.com/api/addtowishlist',
  5639. method: 'POST',
  5640. headers: {
  5641. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5642. },
  5643. data: $.param({
  5644. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5645. appid: gameId
  5646. }),
  5647. dataType: 'json'
  5648. });
  5649. 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) {
  5650. logStatus.success();
  5651. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5652. return true;
  5653. }
  5654. const {
  5655. result: resultR,
  5656. statusText: statusTextR,
  5657. status: statusR,
  5658. data: dataR
  5659. } = await tools_httpRequest({
  5660. url: `https://store.steampowered.com/app/${gameId}`,
  5661. method: 'GET'
  5662. });
  5663. if (resultR === 'Success') {
  5664. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5665. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5666. logStatus.warning(i18n('changeAreaNotice'));
  5667. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5668. return false;
  5669. }
  5670. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5671. }
  5672. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5673. logStatus.success();
  5674. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5675. return true;
  5676. } 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"')) {
  5677. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5678. return false;
  5679. }
  5680. logStatus.success();
  5681. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5682. return true;
  5683. }
  5684. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5685. return false;
  5686. }
  5687. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5688. return false;
  5689. } catch (error) {
  5690. throwError(error, 'Steam.addToWishlist');
  5691. return false;
  5692. }
  5693. }
  5694. async function _removeFromWishlist2(gameId) {
  5695. try {
  5696. var _data$response2;
  5697. if (this.whiteList.wishlists.includes(gameId)) {
  5698. scripts_echoLog({
  5699. type: 'whiteList',
  5700. text: 'Steam.removeFromWishlist',
  5701. id: gameId
  5702. });
  5703. return true;
  5704. }
  5705. const logStatus = scripts_echoLog({
  5706. type: 'removingFromWishlist',
  5707. text: gameId
  5708. });
  5709. const {
  5710. result,
  5711. data
  5712. } = await tools_httpRequest({
  5713. url: 'https://store.steampowered.com/api/removefromwishlist',
  5714. method: 'POST',
  5715. headers: {
  5716. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5717. },
  5718. data: $.param({
  5719. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5720. appid: gameId
  5721. }),
  5722. dataType: 'json'
  5723. });
  5724. 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) {
  5725. logStatus.success();
  5726. return true;
  5727. }
  5728. const {
  5729. result: resultR,
  5730. statusText: statusTextR,
  5731. status: statusR,
  5732. data: dataR
  5733. } = await tools_httpRequest({
  5734. url: `https://store.steampowered.com/app/${gameId}`,
  5735. method: 'GET'
  5736. });
  5737. if (resultR === 'Success') {
  5738. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5739. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5740. logStatus.warning(i18n('changeAreaNotice'));
  5741. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5742. if (!result || result === 'CN' || result === 'skip') {
  5743. return false;
  5744. }
  5745. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5746. }
  5747. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5748. logStatus.success();
  5749. return true;
  5750. }
  5751. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5752. return false;
  5753. }
  5754. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5755. return false;
  5756. }
  5757. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5758. return false;
  5759. } catch (error) {
  5760. throwError(error, 'Steam.removeFromWishlist');
  5761. return false;
  5762. }
  5763. }
  5764. async function _toggleFollowGame2(gameId, doTask) {
  5765. try {
  5766. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5767. scripts_echoLog({
  5768. type: 'whiteList',
  5769. text: 'Steam.unfollowGame',
  5770. id: gameId
  5771. });
  5772. return true;
  5773. }
  5774. const logStatus = scripts_echoLog({
  5775. type: `${doTask ? '' : 'un'}followingGame`,
  5776. text: gameId
  5777. });
  5778. const requestData = {
  5779. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5780. appid: gameId
  5781. };
  5782. if (!doTask) {
  5783. requestData.unfollow = '1';
  5784. }
  5785. const {
  5786. result,
  5787. data
  5788. } = await tools_httpRequest({
  5789. url: 'https://store.steampowered.com/explore/followgame/',
  5790. method: 'POST',
  5791. headers: {
  5792. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5793. },
  5794. data: $.param(requestData)
  5795. });
  5796. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5797. logStatus.success();
  5798. return true;
  5799. }
  5800. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5801. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5802. logStatus.warning(i18n('changeAreaNotice'));
  5803. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5804. return false;
  5805. }
  5806. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5807. }
  5808. if (doTask === followed) {
  5809. logStatus.success();
  5810. if (doTask) {
  5811. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5812. }
  5813. return true;
  5814. }
  5815. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5816. return false;
  5817. } catch (error) {
  5818. throwError(error, 'Steam.toggleFollowGame');
  5819. return false;
  5820. }
  5821. }
  5822. async function _isFollowedGame2(gameId) {
  5823. try {
  5824. const {
  5825. result,
  5826. data
  5827. } = await tools_httpRequest({
  5828. url: `https://store.steampowered.com/app/${gameId}`,
  5829. method: 'GET'
  5830. });
  5831. if (result === 'Success') {
  5832. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5833. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5834. return 'areaLocked';
  5835. }
  5836. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5837. return true;
  5838. }
  5839. return false;
  5840. }
  5841. return false;
  5842. }
  5843. return false;
  5844. } catch (error) {
  5845. throwError(error, 'Steam.isFollowedGame');
  5846. return false;
  5847. }
  5848. }
  5849. async function _toggleForum2(gameId) {
  5850. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5851. try {
  5852. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5853. scripts_echoLog({
  5854. type: 'whiteList',
  5855. text: 'Steam.unsubscribeForum',
  5856. id: gameId
  5857. });
  5858. return true;
  5859. }
  5860. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5861. if (!forumId) {
  5862. return false;
  5863. }
  5864. const logStatus = scripts_echoLog({
  5865. type: `${doTask ? '' : 'un'}subscribingForum`,
  5866. text: gameId
  5867. });
  5868. const [ id, feature ] = forumId.split('_');
  5869. const {
  5870. result,
  5871. statusText,
  5872. status,
  5873. data
  5874. } = await tools_httpRequest({
  5875. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5876. method: 'POST',
  5877. responseType: 'json',
  5878. headers: {
  5879. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5880. },
  5881. data: $.param({
  5882. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5883. })
  5884. });
  5885. if (result === 'Success') {
  5886. var _data$response3, _data$response4;
  5887. 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)) {
  5888. if (doTask) {
  5889. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5890. }
  5891. logStatus.success();
  5892. return true;
  5893. }
  5894. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5895. return true;
  5896. }
  5897. logStatus.error(`${result}:${statusText}(${status})`);
  5898. return true;
  5899. } catch (error) {
  5900. throwError(error, 'Steam.toggleForum');
  5901. return true;
  5902. }
  5903. }
  5904. async function _getForumId2(gameId) {
  5905. try {
  5906. const logStatus = scripts_echoLog({
  5907. type: 'gettingForumId',
  5908. text: gameId
  5909. });
  5910. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5911. if (forumId) {
  5912. logStatus.success();
  5913. return forumId;
  5914. }
  5915. const {
  5916. result,
  5917. statusText,
  5918. status,
  5919. data
  5920. } = await tools_httpRequest({
  5921. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5922. method: 'GET'
  5923. });
  5924. if (result === 'Success') {
  5925. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5926. var _data$responseText, _data$responseText$ma10;
  5927. 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];
  5928. if (forumId) {
  5929. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5930. logStatus.success();
  5931. return forumId;
  5932. }
  5933. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5934. return false;
  5935. }
  5936. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5937. return false;
  5938. }
  5939. logStatus.error(`${result}:${statusText}(${status})`);
  5940. return false;
  5941. } catch (error) {
  5942. throwError(error, 'Steam.getForumId');
  5943. return false;
  5944. }
  5945. }
  5946. async function _toggleFavoriteWorkshop2(id) {
  5947. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5948. try {
  5949. if (!doTask && this.whiteList.workshops.includes(id)) {
  5950. scripts_echoLog({
  5951. type: 'whiteList',
  5952. text: 'Steam.unfavoriteWorkshop',
  5953. id: id
  5954. });
  5955. return true;
  5956. }
  5957. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5958. if (!appid) {
  5959. return false;
  5960. }
  5961. const logStatus = scripts_echoLog({
  5962. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5963. text: id
  5964. });
  5965. const {
  5966. result,
  5967. statusText,
  5968. status,
  5969. data
  5970. } = await tools_httpRequest({
  5971. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5972. method: 'POST',
  5973. headers: {
  5974. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5975. },
  5976. data: $.param({
  5977. id: id,
  5978. appid: appid,
  5979. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5980. })
  5981. });
  5982. if (result === 'Success') {
  5983. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5984. if (doTask) {
  5985. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5986. }
  5987. logStatus.success();
  5988. return true;
  5989. }
  5990. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5991. return false;
  5992. }
  5993. logStatus.error(`${result}:${statusText}(${status})`);
  5994. return false;
  5995. } catch (error) {
  5996. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5997. return false;
  5998. }
  5999. }
  6000. async function _getWorkshopAppId2(id) {
  6001. try {
  6002. const logStatus = scripts_echoLog({
  6003. type: 'gettingWorkshopAppId',
  6004. text: id
  6005. });
  6006. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  6007. if (appId) {
  6008. logStatus.success();
  6009. return appId;
  6010. }
  6011. const {
  6012. result,
  6013. statusText,
  6014. status,
  6015. data
  6016. } = await tools_httpRequest({
  6017. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6018. method: 'GET'
  6019. });
  6020. if (result === 'Success') {
  6021. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6022. var _data$responseText$ma11;
  6023. 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];
  6024. if (appId) {
  6025. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6026. logStatus.success();
  6027. return appId;
  6028. }
  6029. logStatus.error('Error: getWorkshopAppId failed');
  6030. return false;
  6031. }
  6032. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6033. return false;
  6034. }
  6035. logStatus.error(`${result}:${statusText}(${status})`);
  6036. return false;
  6037. } catch (error) {
  6038. throwError(error, 'Steam.getWorkshopAppId');
  6039. return false;
  6040. }
  6041. }
  6042. async function _voteUpWorkshop2(id) {
  6043. try {
  6044. const logStatus = scripts_echoLog({
  6045. type: 'votingUpWorkshop',
  6046. text: id
  6047. });
  6048. const {
  6049. result,
  6050. statusText,
  6051. status,
  6052. data
  6053. } = await tools_httpRequest({
  6054. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6055. method: 'POST',
  6056. responseType: 'json',
  6057. headers: {
  6058. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6059. },
  6060. data: $.param({
  6061. id: id,
  6062. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6063. })
  6064. });
  6065. if (result === 'Success') {
  6066. var _data$response5;
  6067. 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) {
  6068. logStatus.success();
  6069. return true;
  6070. }
  6071. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6072. return true;
  6073. }
  6074. logStatus.error(`${result}:${statusText}(${status})`);
  6075. return true;
  6076. } catch (error) {
  6077. throwError(error, 'Steam.voteupWorkshop');
  6078. return true;
  6079. }
  6080. }
  6081. async function _toggleCurator2(curatorId) {
  6082. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6083. try {
  6084. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6085. scripts_echoLog({
  6086. type: 'whiteList',
  6087. text: 'Steam.unfollowCurator',
  6088. id: curatorId
  6089. });
  6090. return true;
  6091. }
  6092. const logStatus = scripts_echoLog({
  6093. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6094. text: curatorId
  6095. });
  6096. const {
  6097. result,
  6098. statusText,
  6099. status,
  6100. data
  6101. } = await tools_httpRequest({
  6102. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6103. method: 'POST',
  6104. headers: {
  6105. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6106. },
  6107. data: $.param({
  6108. clanid: curatorId,
  6109. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6110. follow: doTask
  6111. }),
  6112. dataType: 'json'
  6113. });
  6114. if (result === 'Success') {
  6115. var _data$response6, _data$response6$succe, _data$response7;
  6116. 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) {
  6117. logStatus.success();
  6118. return true;
  6119. }
  6120. 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})`);
  6121. return false;
  6122. }
  6123. logStatus.error(`${result}:${statusText}(${status})`);
  6124. return false;
  6125. } catch (error) {
  6126. throwError(error, 'Steam.toggleCurator');
  6127. return false;
  6128. }
  6129. }
  6130. async function _toggleCuratorLike2(link) {
  6131. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6132. try {
  6133. const [ path, name ] = link.split('/');
  6134. if (!(path && name)) {
  6135. scripts_echoLog({
  6136. text: i18n('errorLink', link)
  6137. });
  6138. return false;
  6139. }
  6140. const curatorId = await this.getCuratorId(path, name);
  6141. if (curatorId) {
  6142. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6143. }
  6144. return false;
  6145. } catch (error) {
  6146. throwError(error, 'Steam.toggleCuratorLike');
  6147. return false;
  6148. }
  6149. }
  6150. async function _getAnnouncementParams2(appId, viewId) {
  6151. try {
  6152. const logStatus = scripts_echoLog({
  6153. type: 'gettingAnnouncementParams',
  6154. text: appId,
  6155. id: viewId
  6156. });
  6157. const {
  6158. result,
  6159. statusText,
  6160. status,
  6161. data
  6162. } = await tools_httpRequest({
  6163. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6164. method: 'GET',
  6165. headers: {
  6166. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6167. }
  6168. });
  6169. if (result === 'Success') {
  6170. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6171. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6172. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6173. logStatus.warning(i18n('changeAreaNotice'));
  6174. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6175. return {};
  6176. }
  6177. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6178. }
  6179. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6180. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6181. 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];
  6182. if (authWgToken && clanId) {
  6183. logStatus.success();
  6184. return {
  6185. authWgToken: authWgToken,
  6186. clanId: clanId,
  6187. gid: gid
  6188. };
  6189. }
  6190. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6191. return {};
  6192. }
  6193. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6194. return {};
  6195. }
  6196. logStatus.error(`${result}:${statusText}(${status})`);
  6197. return {};
  6198. } catch (error) {
  6199. throwError(error, 'Steam.likeAnnouncement');
  6200. return {};
  6201. }
  6202. }
  6203. async function _likeAnnouncement2(id) {
  6204. try {
  6205. const [ appId, viewId ] = id.split('/');
  6206. if (!(appId && viewId)) {
  6207. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6208. return false;
  6209. }
  6210. const {
  6211. authWgToken,
  6212. clanId,
  6213. gid
  6214. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6215. if (!(authWgToken && clanId)) {
  6216. return false;
  6217. }
  6218. const logStatus = scripts_echoLog({
  6219. type: 'likingAnnouncement',
  6220. text: appId,
  6221. id: viewId
  6222. });
  6223. const {
  6224. result,
  6225. statusText,
  6226. status,
  6227. data
  6228. } = await tools_httpRequest({
  6229. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6230. method: 'POST',
  6231. headers: {
  6232. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6233. Host: 'store.steampowered.com',
  6234. Origin: 'https://store.steampowered.com',
  6235. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6236. },
  6237. data: $.param({
  6238. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6239. wgauthtoken: authWgToken,
  6240. voteup: 1,
  6241. clanid: clanId,
  6242. ajax: 1
  6243. }),
  6244. dataType: 'json'
  6245. });
  6246. if (result === 'Success') {
  6247. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6248. logStatus.success();
  6249. return true;
  6250. }
  6251. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6252. return false;
  6253. }
  6254. logStatus.error(`${result}:${statusText}(${status})`);
  6255. return false;
  6256. } catch (error) {
  6257. throwError(error, 'Steam.likeAnnouncement');
  6258. return false;
  6259. }
  6260. }
  6261. async function _appid2subid2(id) {
  6262. try {
  6263. const logStatus = scripts_echoLog({
  6264. type: 'gettingSubid',
  6265. text: id
  6266. });
  6267. const {
  6268. result,
  6269. statusText,
  6270. status,
  6271. data
  6272. } = await tools_httpRequest({
  6273. url: `https://store.steampowered.com/app/${id}`,
  6274. method: 'GET',
  6275. headers: {
  6276. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6277. }
  6278. });
  6279. if (result === 'Success') {
  6280. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6281. var _data$responseText$ma15;
  6282. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6283. logStatus.warning(i18n('changeAreaNotice'));
  6284. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6285. if (!result || result === 'CN' || result === 'skip') {
  6286. return false;
  6287. }
  6288. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6289. }
  6290. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6291. if (subid) {
  6292. logStatus.success();
  6293. return subid;
  6294. }
  6295. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6296. return false;
  6297. }
  6298. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6299. return false;
  6300. }
  6301. logStatus.error(`${result}:${statusText}(${status})`);
  6302. return false;
  6303. } catch (error) {
  6304. throwError(error, 'Steam.appid2subid');
  6305. return false;
  6306. }
  6307. }
  6308. async function _getLicenses2() {
  6309. try {
  6310. const logStatus = scripts_echoLog({
  6311. text: i18n('gettingLicenses')
  6312. });
  6313. const {
  6314. result,
  6315. statusText,
  6316. status,
  6317. data
  6318. } = await tools_httpRequest({
  6319. url: 'https://store.steampowered.com/account/licenses/',
  6320. method: 'GET'
  6321. });
  6322. if (result === 'Success') {
  6323. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6324. logStatus.success();
  6325. return [ ...data.responseText.matchAll(/RemoveFreeLicense\([\s]*?([\d]+)/g) ].map(arr => arr[1]).filter(subid => subid);
  6326. }
  6327. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6328. return false;
  6329. }
  6330. logStatus.error(`${result}:${statusText}(${status})`);
  6331. return false;
  6332. } catch (error) {
  6333. throwError(error, 'Steam.getLicenses');
  6334. return false;
  6335. }
  6336. }
  6337. async function _addLicense2(id) {
  6338. try {
  6339. const [ type, ids ] = id.split('-');
  6340. if (type === 'appid') {
  6341. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6342. if (!subid) {
  6343. return false;
  6344. }
  6345. const logStatus = scripts_echoLog({
  6346. type: 'addingFreeLicense',
  6347. text: ids
  6348. });
  6349. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6350. return false;
  6351. }
  6352. const {
  6353. result,
  6354. statusText,
  6355. status,
  6356. data
  6357. } = await tools_httpRequest({
  6358. url: `https://store.steampowered.com/app/${ids}`,
  6359. method: 'GET'
  6360. });
  6361. if (result === 'Success') {
  6362. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6363. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6364. logStatus.success();
  6365. return true;
  6366. }
  6367. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6368. return false;
  6369. }
  6370. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6371. return false;
  6372. }
  6373. logStatus.error(`${result}:${statusText}(${status})`);
  6374. return false;
  6375. } else if (type === 'subid') {
  6376. const logStatusArr = {};
  6377. for (const subid of ids.split(',')) {
  6378. const logStatus = scripts_echoLog({
  6379. type: 'addingFreeLicenseSubid',
  6380. text: subid
  6381. });
  6382. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6383. return false;
  6384. }
  6385. logStatusArr[subid] = logStatus;
  6386. }
  6387. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6388. if (!licenses) {
  6389. return false;
  6390. }
  6391. for (const subid of ids.split(',')) {
  6392. if (licenses.includes(subid)) {
  6393. logStatusArr[subid].success();
  6394. } else {
  6395. logStatusArr[subid].error();
  6396. }
  6397. }
  6398. return true;
  6399. }
  6400. return false;
  6401. } catch (error) {
  6402. throwError(error, 'Steam.addLicense');
  6403. return false;
  6404. }
  6405. }
  6406. async function _addFreeLicense2(id, logStatusPre) {
  6407. try {
  6408. const logStatus = logStatusPre || scripts_echoLog({
  6409. type: 'addingFreeLicenseSubid',
  6410. text: id
  6411. });
  6412. const {
  6413. result,
  6414. statusText,
  6415. status,
  6416. data
  6417. } = await tools_httpRequest({
  6418. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6419. method: 'POST',
  6420. headers: {
  6421. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6422. Host: 'store.steampowered.com',
  6423. Origin: 'https://store.steampowered.com',
  6424. Referer: 'https://store.steampowered.com/account/licenses/'
  6425. },
  6426. data: $.param({
  6427. action: 'add_to_cart',
  6428. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6429. subid: id
  6430. }),
  6431. dataType: 'json'
  6432. });
  6433. if (result === 'Success') {
  6434. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6435. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6436. logStatus.warning(i18n('changeAreaNotice'));
  6437. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6438. if (!result || result === 'CN') {
  6439. return false;
  6440. }
  6441. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6442. }
  6443. logStatus.success();
  6444. return true;
  6445. }
  6446. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6447. return false;
  6448. }
  6449. logStatus.error(`${result}:${statusText}(${status})`);
  6450. return false;
  6451. } catch (error) {
  6452. throwError(error, 'Steam.addFreeLicense');
  6453. return false;
  6454. }
  6455. }
  6456. async function _requestPlayTestAccess2(id) {
  6457. try {
  6458. const logStatus = scripts_echoLog({
  6459. type: 'requestingPlayTestAccess',
  6460. text: id
  6461. });
  6462. const {
  6463. result,
  6464. statusText,
  6465. status,
  6466. data
  6467. } = await tools_httpRequest({
  6468. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6469. method: 'POST',
  6470. headers: {
  6471. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6472. Host: 'store.steampowered.com',
  6473. Origin: 'https://store.steampowered.com',
  6474. Referer: `https://store.steampowered.com/app/${id}`
  6475. },
  6476. data: $.param({
  6477. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6478. }),
  6479. dataType: 'json'
  6480. });
  6481. if (result === 'Success') {
  6482. var _data$response8;
  6483. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.success) === 1) {
  6484. logStatus.success();
  6485. return true;
  6486. }
  6487. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6488. return false;
  6489. }
  6490. logStatus.error(`${result}:${statusText}(${status})`);
  6491. return false;
  6492. } catch (error) {
  6493. throwError(error, 'Steam.requestPlayTestAccess');
  6494. return false;
  6495. }
  6496. }
  6497. function Steam_setCache2(type, name, id) {
  6498. try {
  6499. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6500. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6501. } catch (error) {
  6502. throwError(error, 'Steam.setCache');
  6503. }
  6504. }
  6505. const social_Steam = Steam;
  6506. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6507. Website_checkPrivateRedeclaration(obj, privateSet);
  6508. privateSet.add(obj);
  6509. }
  6510. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6511. if (privateCollection.has(obj)) {
  6512. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6513. }
  6514. }
  6515. function Website_defineProperty(obj, key, value) {
  6516. if (key in obj) {
  6517. Object.defineProperty(obj, key, {
  6518. value: value,
  6519. enumerable: true,
  6520. configurable: true,
  6521. writable: true
  6522. });
  6523. } else {
  6524. obj[key] = value;
  6525. }
  6526. return obj;
  6527. }
  6528. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6529. if (!privateSet.has(receiver)) {
  6530. throw new TypeError('attempted to get private field on non-instance');
  6531. }
  6532. return fn;
  6533. }
  6534. var _bind = new WeakSet();
  6535. class Website {
  6536. constructor() {
  6537. Website_classPrivateMethodInitSpec(this, _bind);
  6538. Website_defineProperty(this, 'undoneTasks', void 0);
  6539. Website_defineProperty(this, 'socialTasks', void 0);
  6540. Website_defineProperty(this, 'giveawayId', void 0);
  6541. Website_defineProperty(this, 'socialInitialized', {
  6542. discord: false,
  6543. instagram: false,
  6544. reddit: false,
  6545. twitch: false,
  6546. twitter: false,
  6547. vk: false,
  6548. youtube: false,
  6549. steamStore: false,
  6550. steamCommunity: false
  6551. });
  6552. Website_defineProperty(this, 'initialized', false);
  6553. Website_defineProperty(this, 'social', {});
  6554. }
  6555. async initSocial(action) {
  6556. try {
  6557. const pro = [];
  6558. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6559. if (tasks.discord) {
  6560. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6561. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6562. this.social.discord = new social_Discord();
  6563. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6564. }
  6565. }
  6566. if (tasks.instagram) {
  6567. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6568. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6569. this.social.instagram = new social_Instagram();
  6570. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6571. }
  6572. }
  6573. if (tasks.reddit) {
  6574. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6575. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6576. this.social.reddit = new social_Reddit();
  6577. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6578. }
  6579. }
  6580. if (tasks.twitch) {
  6581. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6582. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6583. this.social.twitch = new social_Twitch();
  6584. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6585. }
  6586. }
  6587. if (tasks.twitter) {
  6588. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6589. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6590. this.social.twitter = new social_Twitter();
  6591. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6592. }
  6593. }
  6594. if (tasks.vk) {
  6595. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6596. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6597. this.social.vk = new social_Vk();
  6598. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6599. }
  6600. }
  6601. if (tasks.youtube) {
  6602. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6603. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6604. this.social.youtube = new Youtube();
  6605. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6606. }
  6607. }
  6608. if (tasks.steam) {
  6609. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6610. if (steamLength > 0) {
  6611. if (!this.social.steam) {
  6612. this.social.steam = new social_Steam();
  6613. }
  6614. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6615. var _tasks$steam, _tasks$steam$type;
  6616. 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;
  6617. }).reduce((total, number) => total + number, 0);
  6618. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6619. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6620. }
  6621. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6622. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6623. }
  6624. }
  6625. }
  6626. if (tasks.links && tasks.links.length > 0) {
  6627. this.social.visitLink = visitLink;
  6628. }
  6629. return await Promise.all(pro).then(result => {
  6630. let checked = true;
  6631. for (const data of result) {
  6632. if (data.result) {
  6633. this.socialInitialized[data.name] = data.result;
  6634. } else {
  6635. checked = false;
  6636. }
  6637. }
  6638. return checked;
  6639. });
  6640. } catch (error) {
  6641. throwError(error, 'Website.initSocial');
  6642. return false;
  6643. }
  6644. }
  6645. uniqueTasks(allTasks) {
  6646. const result = {};
  6647. for (const [ social, types ] of Object.entries(allTasks)) {
  6648. result[social] = {};
  6649. for (const [ type, tasks ] of Object.entries(types)) {
  6650. result[social][type] = unique(tasks);
  6651. }
  6652. }
  6653. return result;
  6654. }
  6655. async toggleTask(action) {
  6656. try {
  6657. if (!this.initialized && !this.init()) {
  6658. return false;
  6659. }
  6660. if (!await this.classifyTask(action)) {
  6661. return false;
  6662. }
  6663. if (!await this.initSocial(action)) {
  6664. return false;
  6665. }
  6666. const pro = [];
  6667. const doTask = action === 'do';
  6668. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6669. if (this.social.discord) {
  6670. pro.push(this.social.discord.toggle({
  6671. doTask: doTask,
  6672. ...tasks.discord
  6673. }));
  6674. }
  6675. if (this.social.instagram) {
  6676. pro.push(this.social.instagram.toggle({
  6677. doTask: doTask,
  6678. ...tasks.instagram
  6679. }));
  6680. }
  6681. if (this.social.reddit) {
  6682. pro.push(this.social.reddit.toggle({
  6683. doTask: doTask,
  6684. ...tasks.reddit
  6685. }));
  6686. }
  6687. if (this.social.twitch) {
  6688. pro.push(this.social.twitch.toggle({
  6689. doTask: doTask,
  6690. ...tasks.twitch
  6691. }));
  6692. }
  6693. if (this.social.twitter) {
  6694. pro.push(this.social.twitter.toggle({
  6695. doTask: doTask,
  6696. ...tasks.twitter
  6697. }));
  6698. }
  6699. if (this.social.vk) {
  6700. pro.push(this.social.vk.toggle({
  6701. doTask: doTask,
  6702. ...tasks.vk
  6703. }));
  6704. }
  6705. if (this.social.youtube) {
  6706. pro.push(this.social.youtube.toggle({
  6707. doTask: doTask,
  6708. ...tasks.youtube
  6709. }));
  6710. }
  6711. if (this.social.steam) {
  6712. pro.push(this.social.steam.toggle({
  6713. doTask: doTask,
  6714. ...tasks.steam
  6715. }));
  6716. }
  6717. if (this.social.visitLink && tasks.links && doTask) {
  6718. for (const link of tasks.links) {
  6719. pro.push(this.social.visitLink(link));
  6720. }
  6721. }
  6722. if (doTask && tasks.extra && this.extraDoTask) {
  6723. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6724. if (hasExtra) {
  6725. pro.push(this.extraDoTask(tasks.extra));
  6726. }
  6727. }
  6728. await Promise.all(pro);
  6729. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6730. return true;
  6731. } catch (error) {
  6732. throwError(error, 'Website.toggleTask');
  6733. return false;
  6734. }
  6735. }
  6736. async doTask() {
  6737. try {
  6738. return await this.toggleTask('do');
  6739. } catch (error) {
  6740. throwError(error, 'Website.doTask');
  6741. return false;
  6742. }
  6743. }
  6744. async undoTask() {
  6745. try {
  6746. return await this.toggleTask('undo');
  6747. } catch (error) {
  6748. throwError(error, 'Website.undoTask');
  6749. return false;
  6750. }
  6751. }
  6752. }
  6753. async function _bind2(name, init) {
  6754. try {
  6755. return {
  6756. name: name,
  6757. result: await init
  6758. };
  6759. } catch (error) {
  6760. throwError(error, 'Website.bind');
  6761. return {
  6762. name: name,
  6763. result: false
  6764. };
  6765. }
  6766. }
  6767. const website_Website = Website;
  6768. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6769. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6770. privateSet.add(obj);
  6771. }
  6772. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6773. if (privateCollection.has(obj)) {
  6774. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6775. }
  6776. }
  6777. function FreeAnyWhere_defineProperty(obj, key, value) {
  6778. if (key in obj) {
  6779. Object.defineProperty(obj, key, {
  6780. value: value,
  6781. enumerable: true,
  6782. configurable: true,
  6783. writable: true
  6784. });
  6785. } else {
  6786. obj[key] = value;
  6787. }
  6788. return obj;
  6789. }
  6790. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6791. if (!privateSet.has(receiver)) {
  6792. throw new TypeError('attempted to get private field on non-instance');
  6793. }
  6794. return fn;
  6795. }
  6796. const FreeAnyWhere_defaultTasksTemplate = {
  6797. steam: {
  6798. groupLinks: [],
  6799. wishlistLinks: [],
  6800. curatorLinks: [],
  6801. followLinks: []
  6802. },
  6803. vk: {
  6804. nameLinks: []
  6805. }
  6806. };
  6807. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6808. var _getGiveawayId = new WeakSet();
  6809. var _verify = new WeakSet();
  6810. class FreeAnyWhere extends website_Website {
  6811. constructor() {
  6812. super(...arguments);
  6813. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6814. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6815. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6816. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6817. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6818. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6819. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6820. }
  6821. static test() {
  6822. return window.location.host === 'freeanywhere.net';
  6823. }
  6824. init() {
  6825. try {
  6826. const logStatus = scripts_echoLog({
  6827. text: i18n('initing')
  6828. });
  6829. if ($('a[href="#/login"]').length > 0) {
  6830. window.open('/#/login', '_self');
  6831. logStatus.warning(i18n('needLogin'));
  6832. return false;
  6833. }
  6834. if (window.location.href.includes('/login')) {
  6835. logStatus.warning(i18n('needLogin'));
  6836. return false;
  6837. }
  6838. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6839. var _window$location$href;
  6840. 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];
  6841. if (!id) {
  6842. logStatus.error(i18n('getFailed', 'Id'));
  6843. return false;
  6844. }
  6845. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6846. }
  6847. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6848. return false;
  6849. }
  6850. this.initialized = true;
  6851. logStatus.success();
  6852. return true;
  6853. } catch (error) {
  6854. throwError(error, 'Freeanywhere.init');
  6855. return false;
  6856. }
  6857. }
  6858. async classifyTask(action) {
  6859. try {
  6860. const logStatus = scripts_echoLog({
  6861. text: i18n('getTasksInfo')
  6862. });
  6863. if (action === 'undo') {
  6864. var _GM_getValue;
  6865. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6866. }
  6867. const {
  6868. result,
  6869. statusText,
  6870. status,
  6871. data
  6872. } = await tools_httpRequest({
  6873. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6874. method: 'GET',
  6875. headers: {
  6876. authorization: `Token ${window.localStorage.getItem('token')}`,
  6877. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6878. },
  6879. responseType: 'json'
  6880. });
  6881. if (result === 'Success') {
  6882. var _data$response;
  6883. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6884. if (tasks) {
  6885. if (action === 'verify') {
  6886. this.tasks = [];
  6887. }
  6888. for (const task of tasks) {
  6889. const type = task.challenge;
  6890. const social = task.challenge_provider;
  6891. const taskInfo = {
  6892. id: task.id,
  6893. title: task.title
  6894. };
  6895. if (action === 'verify' && !task.is_success) {
  6896. this.tasks.push(taskInfo);
  6897. continue;
  6898. }
  6899. switch (social) {
  6900. case 'steam':
  6901. taskInfo.social = 'steam';
  6902. switch (type) {
  6903. case 'WL':
  6904. if (action === 'undo') {
  6905. this.socialTasks.steam.wishlistLinks.push(task.link);
  6906. }
  6907. if (action === 'do' && !task.is_success) {
  6908. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6909. }
  6910. break;
  6911.  
  6912. case 'JTG':
  6913. if (action === 'undo') {
  6914. this.socialTasks.steam.groupLinks.push(task.link);
  6915. }
  6916. if (action === 'do' && !task.is_success) {
  6917. this.undoneTasks.steam.groupLinks.push(task.link);
  6918. }
  6919. break;
  6920.  
  6921. case 'STC':
  6922. if (action === 'undo') {
  6923. this.socialTasks.steam.curatorLinks.push(task.link);
  6924. }
  6925. if (action === 'do' && !task.is_success) {
  6926. this.undoneTasks.steam.curatorLinks.push(task.link);
  6927. }
  6928. break;
  6929.  
  6930. case 'GF':
  6931. if (action === 'undo') {
  6932. this.socialTasks.steam.followLinks.push(task.link);
  6933. }
  6934. if (action === 'do' && !task.is_success) {
  6935. this.undoneTasks.steam.followLinks.push(task.link);
  6936. }
  6937. break;
  6938. }
  6939. break;
  6940.  
  6941. case 'vk-oauth2':
  6942. if (action === 'undo') {
  6943. this.socialTasks.vk.nameLinks.push(task.link);
  6944. }
  6945. if (action === 'do' && !task.is_success) {
  6946. this.undoneTasks.vk.nameLinks.push(task.link);
  6947. }
  6948. break;
  6949.  
  6950. case 'website':
  6951. break;
  6952.  
  6953. default:
  6954. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6955. break;
  6956. }
  6957. }
  6958. logStatus.success();
  6959. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6960. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6961. if (window.DEBUG) {
  6962. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  6963. }
  6964. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6965. tasks: this.socialTasks,
  6966. time: new Date().getTime()
  6967. });
  6968. return true;
  6969. }
  6970. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6971. return false;
  6972. }
  6973. logStatus.error(`${result}:${statusText}(${status})`);
  6974. return false;
  6975. } catch (error) {
  6976. throwError(error, 'Freeanywhere.classifyTask');
  6977. return false;
  6978. }
  6979. }
  6980. async verifyTask() {
  6981. try {
  6982. if (!this.initialized && !this.init()) {
  6983. return false;
  6984. }
  6985. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6986. return false;
  6987. }
  6988. const pro = [];
  6989. for (const task of this.tasks) {
  6990. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6991. await delay(1e3);
  6992. }
  6993. await Promise.all(pro);
  6994. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6995. return !!await this.getKey(true);
  6996. } catch (error) {
  6997. throwError(error, 'Freeanywhere.verifyTask');
  6998. return false;
  6999. }
  7000. }
  7001. async getKey(initialized) {
  7002. try {
  7003. if (!initialized && !this.initialized && !this.init()) {
  7004. return false;
  7005. }
  7006. const logStatus = scripts_echoLog({
  7007. text: i18n('gettingKey')
  7008. });
  7009. const {
  7010. result,
  7011. statusText,
  7012. status,
  7013. data
  7014. } = await tools_httpRequest({
  7015. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7016. method: 'GET',
  7017. dataType: 'json',
  7018. headers: {
  7019. authorization: `Token ${window.localStorage.getItem('token')}`
  7020. }
  7021. });
  7022. if (result === 'Success') {
  7023. var _data$response2;
  7024. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7025. logStatus.success();
  7026. scripts_echoLog({}).success(data.response.reward);
  7027. return data.response.reward;
  7028. }
  7029. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7030. return false;
  7031. }
  7032. logStatus.error(`${result}:${statusText}(${status})`);
  7033. return false;
  7034. } catch (error) {
  7035. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7036. return false;
  7037. }
  7038. }
  7039. }
  7040. function _getGiveawayId2() {
  7041. try {
  7042. var _window$location$href2;
  7043. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7044. if (giveawayId) {
  7045. this.giveawayId = giveawayId;
  7046. return true;
  7047. }
  7048. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7049. return false;
  7050. } catch (error) {
  7051. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7052. }
  7053. }
  7054. async function _verify2(task) {
  7055. try {
  7056. const logStatus = scripts_echoLog({
  7057. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7058. });
  7059. const {
  7060. result,
  7061. statusText,
  7062. status,
  7063. data
  7064. } = await tools_httpRequest({
  7065. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7066. method: 'GET',
  7067. dataType: 'json',
  7068. headers: {
  7069. authorization: `Token ${window.localStorage.getItem('token')}`,
  7070. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7071. }
  7072. });
  7073. if (result === 'Success') {
  7074. var _data$response3;
  7075. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7076. logStatus.success();
  7077. return true;
  7078. }
  7079. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7080. return false;
  7081. }
  7082. logStatus.error(`${result}:${statusText}(${status})`);
  7083. return false;
  7084. } catch (error) {
  7085. throwError(error, 'Freeanywhere.verify');
  7086. return false;
  7087. }
  7088. }
  7089. const website_FreeAnyWhere = FreeAnyWhere;
  7090. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7091. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7092. privateSet.add(obj);
  7093. }
  7094. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7095. if (privateCollection.has(obj)) {
  7096. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7097. }
  7098. }
  7099. function GiveawaySu_defineProperty(obj, key, value) {
  7100. if (key in obj) {
  7101. Object.defineProperty(obj, key, {
  7102. value: value,
  7103. enumerable: true,
  7104. configurable: true,
  7105. writable: true
  7106. });
  7107. } else {
  7108. obj[key] = value;
  7109. }
  7110. return obj;
  7111. }
  7112. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7113. if (!privateSet.has(receiver)) {
  7114. throw new TypeError('attempted to get private field on non-instance');
  7115. }
  7116. return fn;
  7117. }
  7118. const GiveawaySu_defaultTasks = {
  7119. steam: {
  7120. groupLinks: [],
  7121. wishlistLinks: [],
  7122. curatorLinks: [],
  7123. curatorLikeLinks: [],
  7124. followLinks: [],
  7125. forumLinks: [],
  7126. announcementLinks: [],
  7127. workshopVoteLinks: [],
  7128. playtestLinks: []
  7129. },
  7130. discord: {
  7131. serverLinks: []
  7132. },
  7133. instagram: {
  7134. userLinks: []
  7135. },
  7136. vk: {
  7137. nameLinks: []
  7138. },
  7139. twitch: {
  7140. channelLinks: []
  7141. },
  7142. reddit: {
  7143. redditLinks: []
  7144. },
  7145. youtube: {
  7146. channelLinks: [],
  7147. likeLinks: []
  7148. }
  7149. };
  7150. var _checkLogin = new WeakSet();
  7151. var _checkLeftKey = new WeakSet();
  7152. var GiveawaySu_getGiveawayId = new WeakSet();
  7153. class GiveawaySu extends website_Website {
  7154. constructor() {
  7155. super(...arguments);
  7156. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7157. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  7158. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7159. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7160. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7161. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7162. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7163. }
  7164. static test() {
  7165. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7166. }
  7167. async after() {
  7168. try {
  7169. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7170. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7171. }
  7172. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7173. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7174. }
  7175. scripts_echoLog({}).warning(i18n('gsNotice'));
  7176. } catch (error) {
  7177. throwError(error, 'Giveawaysu.after');
  7178. }
  7179. }
  7180. init() {
  7181. try {
  7182. const logStatus = scripts_echoLog({
  7183. text: i18n('initing')
  7184. });
  7185. if ($('a.steam-login').length > 0) {
  7186. window.open('/steam/redirect', '_self');
  7187. logStatus.warning(i18n('needLogin'));
  7188. return false;
  7189. }
  7190. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7191. return false;
  7192. }
  7193. this.initialized = true;
  7194. logStatus.success();
  7195. return true;
  7196. } catch (error) {
  7197. throwError(error, 'Giveawaysu.init');
  7198. return false;
  7199. }
  7200. }
  7201. async classifyTask(action) {
  7202. try {
  7203. const logStatus = scripts_echoLog({
  7204. text: i18n('getTasksInfo')
  7205. });
  7206. if (action === 'undo') {
  7207. var _GM_getValue;
  7208. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7209. return true;
  7210. }
  7211. const pro = [];
  7212. const tasks = $('#actions tr');
  7213. if ($('div.bind-discord').is(':visible')) {
  7214. $('div.bind-discord a')[0].click();
  7215. }
  7216. if ($('div.bind-twitch').is(':visible')) {
  7217. $('div.bind-twitch a')[0].click();
  7218. }
  7219. for (const task of tasks) {
  7220. pro.push(new Promise(resolve => {
  7221. const td = $(task).find('td:not(".hidden")');
  7222. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7223. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7224. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7225. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7226. const taskName = taskDes.text().trim();
  7227. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7228. return resolve(true);
  7229. }
  7230. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7231. if (!taskLink) {
  7232. return resolve(false);
  7233. }
  7234. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7235. this.undoneTasks.steam.groupLinks.push(taskLink);
  7236. } else if (/like.*announcement/gi.test(taskName)) {
  7237. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7238. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7239. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7240. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7241. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7242. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7243. this.undoneTasks.steam.forumLinks.push(taskLink);
  7244. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7245. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7246. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7247. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7248. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7249. this.undoneTasks.discord.serverLinks.push(taskLink);
  7250. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7251. this.undoneTasks.instagram.userLinks.push(taskLink);
  7252. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7253. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7254. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7255. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7256. } else if (/watch.*art/gim.test(taskName)) {
  7257. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7258. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7259. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7260. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7261. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7262. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7263. this.undoneTasks.vk.nameLinks.push(taskLink);
  7264. } else {
  7265. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7266. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7267. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7268. }
  7269. if (/follow.*button/gim.test(taskName)) {
  7270. this.undoneTasks.steam.followLinks.push(taskLink);
  7271. }
  7272. }
  7273. }
  7274. resolve(true);
  7275. }).catch(error => {
  7276. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7277. return false;
  7278. });
  7279. }));
  7280. }
  7281. await Promise.all(pro);
  7282. logStatus.success();
  7283. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7284. this.socialTasks = this.undoneTasks;
  7285. if (window.DEBUG) {
  7286. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7287. }
  7288. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7289. tasks: this.socialTasks,
  7290. time: new Date().getTime()
  7291. });
  7292. return true;
  7293. } catch (error) {
  7294. throwError(error, 'Giveawaysu.classifyTask');
  7295. return false;
  7296. }
  7297. }
  7298. }
  7299. function _checkLogin2() {
  7300. try {
  7301. if (!globalOptions.other.checkLogin) {
  7302. return true;
  7303. }
  7304. if ($('a.steam-login').length > 0) {
  7305. window.open('/steam/redirect', '_self');
  7306. }
  7307. return true;
  7308. } catch (error) {
  7309. throwError(error, 'Giveawaysu.checkLogin');
  7310. return false;
  7311. }
  7312. }
  7313. async function _checkLeftKey2() {
  7314. try {
  7315. if (!globalOptions.other.checkLeftKey) {
  7316. return true;
  7317. }
  7318. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7319. await external_Swal_default().fire({
  7320. icon: 'warning',
  7321. title: i18n('notice'),
  7322. text: i18n('noKeysLeft'),
  7323. confirmButtonText: i18n('confirm'),
  7324. cancelButtonText: i18n('cancel'),
  7325. showCancelButton: true
  7326. }).then(_ref => {
  7327. let {
  7328. value
  7329. } = _ref;
  7330. if (value) {
  7331. window.close();
  7332. }
  7333. });
  7334. }
  7335. return true;
  7336. } catch (error) {
  7337. throwError(error, 'Giveawaysu.checkLeftKey');
  7338. return false;
  7339. }
  7340. }
  7341. function GiveawaySu_getGiveawayId2() {
  7342. var _window$location$href;
  7343. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7344. if (giveawayId) {
  7345. this.giveawayId = giveawayId;
  7346. return true;
  7347. }
  7348. scripts_echoLog({
  7349. text: i18n('getFailed', 'GiveawayId')
  7350. });
  7351. return false;
  7352. }
  7353. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7354. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7355. privateSet.add(obj);
  7356. }
  7357. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7358. if (privateCollection.has(obj)) {
  7359. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7360. }
  7361. }
  7362. function Indiedb_defineProperty(obj, key, value) {
  7363. if (key in obj) {
  7364. Object.defineProperty(obj, key, {
  7365. value: value,
  7366. enumerable: true,
  7367. configurable: true,
  7368. writable: true
  7369. });
  7370. } else {
  7371. obj[key] = value;
  7372. }
  7373. return obj;
  7374. }
  7375. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7376. if (!privateSet.has(receiver)) {
  7377. throw new TypeError('attempted to get private field on non-instance');
  7378. }
  7379. return fn;
  7380. }
  7381. var _join = new WeakSet();
  7382. var _do = new WeakSet();
  7383. var Indiedb_checkLogin = new WeakSet();
  7384. var Indiedb_checkLeftKey = new WeakSet();
  7385. class Indiedb {
  7386. constructor() {
  7387. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7388. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7389. Indiedb_classPrivateMethodInitSpec(this, _do);
  7390. Indiedb_classPrivateMethodInitSpec(this, _join);
  7391. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7392. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7393. }
  7394. static test() {
  7395. return window.location.host === 'www.indiedb.com';
  7396. }
  7397. async after() {
  7398. try {
  7399. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7400. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7401. }
  7402. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7403. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7404. }
  7405. } catch (error) {
  7406. throwError(error, 'Indiedb.after');
  7407. }
  7408. }
  7409. async doTask() {
  7410. try {
  7411. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7412. return false;
  7413. }
  7414. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7415. } catch (error) {
  7416. throwError(error, 'Indiedb.doTask');
  7417. return false;
  7418. }
  7419. }
  7420. }
  7421. async function _join2() {
  7422. try {
  7423. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7424. scripts_echoLog({}).error(i18n('needLogin'));
  7425. return false;
  7426. }
  7427. const currentoption = $('a.buttonenter.buttongiveaway');
  7428. if (/join giveaway/gim.test(currentoption.text())) {
  7429. const logStatus = scripts_echoLog({
  7430. text: `${i18n('joiningGiveaway')}...`
  7431. });
  7432. const {
  7433. result,
  7434. statusText,
  7435. status,
  7436. data
  7437. } = await tools_httpRequest({
  7438. url: currentoption.attr('href'),
  7439. method: 'POST',
  7440. data: 'ajax=t',
  7441. dataType: 'json',
  7442. headers: {
  7443. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7444. accept: 'application/json, text/javascript, */*; q=0.01',
  7445. origin: window.location.origin
  7446. }
  7447. });
  7448. if (result === 'Success') {
  7449. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7450. var _data$response, _data$response4, _data$response5;
  7451. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7452. var _data$response2, _data$response3;
  7453. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7454. $('#giveawaysjoined').slideDown();
  7455. $('#giveawaysrecommend').slideDown();
  7456. 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}` : ''}`);
  7457. return true;
  7458. }
  7459. 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}` : ''}`);
  7460. return false;
  7461. }
  7462. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7463. return false;
  7464. }
  7465. logStatus.error(`${result}:${statusText}(${status})`);
  7466. return false;
  7467. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7468. return true;
  7469. }
  7470. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7471. return false;
  7472. } catch (error) {
  7473. throwError(error, 'Indiedb.init');
  7474. return false;
  7475. }
  7476. }
  7477. async function _do2() {
  7478. try {
  7479. const id = $('script').map((index, script) => {
  7480. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7481. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7482. 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] ];
  7483. }
  7484. return null;
  7485. });
  7486. if (id.length === 2) {
  7487. const pro = [];
  7488. const tasks = $('#giveawaysjoined a[class*=promo]');
  7489. for (const task of tasks) {
  7490. const promo = $(task);
  7491. if (!promo.hasClass('buttonentered')) {
  7492. const status = scripts_echoLog({
  7493. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7494. });
  7495. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7496. let text = '';
  7497. if (promo.hasClass('facebookpromo')) {
  7498. text = 'facebookpromo';
  7499. } else if (promo.hasClass('twitterpromo')) {
  7500. text = 'twitterpromo';
  7501. } else {
  7502. text = 'visitpromo';
  7503. }
  7504. pro.push(new Promise(resolve => {
  7505. $.ajax({
  7506. type: 'POST',
  7507. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7508. timeout: 6e4,
  7509. dataType: 'json',
  7510. data: {
  7511. ajax: 't'
  7512. },
  7513. error(response, error, exception) {
  7514. if (window.DEBUG) {
  7515. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7516. response: response,
  7517. error: error,
  7518. exception: exception
  7519. });
  7520. }
  7521. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7522. resolve(true);
  7523. },
  7524. success(response) {
  7525. if (response.success) {
  7526. status.success(`Success:${response.text}`);
  7527. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7528. resolve(true);
  7529. } else {
  7530. status.error(`Error:${response.text}`);
  7531. resolve(true);
  7532. }
  7533. }
  7534. });
  7535. }));
  7536. } else if (promo.hasClass('emailoptinpromo')) {
  7537. pro.push(new Promise(resolve => {
  7538. $.ajax({
  7539. type: 'POST',
  7540. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7541. timeout: 6e4,
  7542. dataType: 'json',
  7543. data: {
  7544. ajax: 't',
  7545. emailsystoggle: 4
  7546. },
  7547. error(response, error, exception) {
  7548. if (window.DEBUG) {
  7549. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7550. response: response,
  7551. error: error,
  7552. exception: exception
  7553. });
  7554. }
  7555. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7556. resolve(true);
  7557. },
  7558. success(response) {
  7559. if (response.success) {
  7560. status.success(`Success:${response.text}`);
  7561. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7562. resolve(true);
  7563. } else {
  7564. status.error(`Error:${response.text}`);
  7565. resolve(true);
  7566. }
  7567. }
  7568. });
  7569. }));
  7570. } else if (promo.hasClass('watchingpromo')) {
  7571. pro.push(new Promise(resolve => {
  7572. var _promo$attr;
  7573. const data = getUrlQuery(promo.attr('href'));
  7574. data.ajax = 't';
  7575. $.ajax({
  7576. type: 'POST',
  7577. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7578. timeout: 6e4,
  7579. dataType: 'json',
  7580. data: data,
  7581. error(response, error, exception) {
  7582. if (window.DEBUG) {
  7583. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7584. response: response,
  7585. error: error,
  7586. exception: exception
  7587. });
  7588. }
  7589. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7590. resolve(true);
  7591. },
  7592. success(response) {
  7593. if (response.success) {
  7594. status.success(`Success:${response.text}`);
  7595. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7596. resolve(true);
  7597. } else {
  7598. status.error(`Error:${response.text}`);
  7599. resolve(true);
  7600. }
  7601. }
  7602. });
  7603. }));
  7604. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7605. pro.push(new Promise(resolve => {
  7606. $.ajax({
  7607. type: 'POST',
  7608. url: urlPath(promo.attr('href')),
  7609. timeout: 6e4,
  7610. dataType: 'json',
  7611. data: {
  7612. ajax: 't'
  7613. },
  7614. error(response, error, exception) {
  7615. if (window.DEBUG) {
  7616. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7617. response: response,
  7618. error: error,
  7619. exception: exception
  7620. });
  7621. }
  7622. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7623. resolve(true);
  7624. },
  7625. success(response) {
  7626. if (response.success) {
  7627. status.success(`Success:${response.text}`);
  7628. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7629. resolve(true);
  7630. } else {
  7631. status.error(`Error:${response.text}`);
  7632. resolve(true);
  7633. }
  7634. }
  7635. });
  7636. }));
  7637. } else {
  7638. status.error(`Error:${i18n('unKnownTaskType')}`);
  7639. }
  7640. }
  7641. }
  7642. await Promise.all(pro);
  7643. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7644. return true;
  7645. }
  7646. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7647. return false;
  7648. } catch (error) {
  7649. throwError(error, 'Indiedb.classifyTask');
  7650. return false;
  7651. }
  7652. }
  7653. function Indiedb_checkLogin2() {
  7654. try {
  7655. if (!globalOptions.other.checkLogin) {
  7656. return true;
  7657. }
  7658. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7659. window.open('/members/login', '_self');
  7660. }
  7661. return true;
  7662. } catch (error) {
  7663. throwError(error, 'Indiedb.checkLogin');
  7664. return false;
  7665. }
  7666. }
  7667. async function Indiedb_checkLeftKey2() {
  7668. try {
  7669. if (!globalOptions.other.checkLeftKey) {
  7670. return true;
  7671. }
  7672. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7673. await external_Swal_default().fire({
  7674. icon: 'warning',
  7675. title: i18n('notice'),
  7676. text: i18n('giveawayEnded'),
  7677. confirmButtonText: i18n('confirm'),
  7678. cancelButtonText: i18n('cancel'),
  7679. showCancelButton: true
  7680. }).then(_ref => {
  7681. let {
  7682. value
  7683. } = _ref;
  7684. if (value) {
  7685. window.close();
  7686. }
  7687. });
  7688. }
  7689. return true;
  7690. } catch (error) {
  7691. throwError(error, 'Indiedb.checkLeftKey');
  7692. return false;
  7693. }
  7694. }
  7695. const website_Indiedb = Indiedb;
  7696. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7697. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7698. privateSet.add(obj);
  7699. }
  7700. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7701. if (privateCollection.has(obj)) {
  7702. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7703. }
  7704. }
  7705. function Keyhub_defineProperty(obj, key, value) {
  7706. if (key in obj) {
  7707. Object.defineProperty(obj, key, {
  7708. value: value,
  7709. enumerable: true,
  7710. configurable: true,
  7711. writable: true
  7712. });
  7713. } else {
  7714. obj[key] = value;
  7715. }
  7716. return obj;
  7717. }
  7718. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7719. if (!privateSet.has(receiver)) {
  7720. throw new TypeError('attempted to get private field on non-instance');
  7721. }
  7722. return fn;
  7723. }
  7724. const Keyhub_defaultTasksTemplate = {
  7725. steam: {
  7726. groupLinks: [],
  7727. officialGroupLinks: [],
  7728. wishlistLinks: [],
  7729. curatorLinks: []
  7730. },
  7731. discord: {
  7732. serverLinks: []
  7733. },
  7734. links: []
  7735. };
  7736. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7737. var Keyhub_getGiveawayId = new WeakSet();
  7738. var Keyhub_checkLeftKey = new WeakSet();
  7739. var Keyhub_checkLogin = new WeakSet();
  7740. class Keyhub extends website_Website {
  7741. constructor() {
  7742. super(...arguments);
  7743. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7744. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7745. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7746. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7747. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7748. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7749. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7750. }
  7751. static test() {
  7752. return window.location.host === 'key-hub.eu';
  7753. }
  7754. async after() {
  7755. try {
  7756. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7757. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7758. }
  7759. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7760. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7761. }
  7762. } catch (error) {
  7763. throwError(error, 'Keyhub.after');
  7764. }
  7765. }
  7766. init() {
  7767. try {
  7768. const logStatus = scripts_echoLog({
  7769. text: i18n('initing')
  7770. });
  7771. if ($('a[href*="/connect/steam"]').length > 0) {
  7772. window.open('/connect/steam', '_self');
  7773. logStatus.warning(i18n('needLogin'));
  7774. return false;
  7775. }
  7776. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7777. return false;
  7778. }
  7779. $('#VPNoverlay').hide();
  7780. $('#mainArticleSection').show();
  7781. this.initialized = true;
  7782. logStatus.success();
  7783. return true;
  7784. } catch (error) {
  7785. throwError(error, 'Keyhub.init');
  7786. return false;
  7787. }
  7788. }
  7789. async classifyTask(action) {
  7790. try {
  7791. const logStatus = scripts_echoLog({
  7792. text: i18n('getTasksInfo')
  7793. });
  7794. if (action === 'undo') {
  7795. var _GM_getValue;
  7796. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7797. }
  7798. const tasks = $('.task a');
  7799. for (const task of tasks) {
  7800. let link = $(task).attr('href');
  7801. const taskDes = $(task).text().trim();
  7802. if (!link) {
  7803. continue;
  7804. }
  7805. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7806. link = await getRedirectLink(link) || link;
  7807. }
  7808. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7809. window.open(link, '_blank');
  7810. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7811. if (action === 'undo') {
  7812. this.socialTasks.steam.groupLinks.push(link);
  7813. }
  7814. if (action === 'do') {
  7815. this.undoneTasks.steam.groupLinks.push(link);
  7816. }
  7817. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7818. if (action === 'undo') {
  7819. this.socialTasks.steam.officialGroupLinks.push(link);
  7820. }
  7821. if (action === 'do') {
  7822. this.undoneTasks.steam.officialGroupLinks.push(link);
  7823. }
  7824. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7825. if (action === 'undo') {
  7826. this.socialTasks.steam.wishlistLinks.push(link);
  7827. }
  7828. if (action === 'do') {
  7829. this.undoneTasks.steam.wishlistLinks.push(link);
  7830. }
  7831. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7832. if (action === 'undo') {
  7833. this.socialTasks.steam.curatorLinks.push(link);
  7834. }
  7835. if (action === 'do') {
  7836. this.undoneTasks.steam.curatorLinks.push(link);
  7837. }
  7838. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7839. if (action === 'undo') {
  7840. this.socialTasks.discord.serverLinks.push(link);
  7841. }
  7842. if (action === 'do') {
  7843. this.undoneTasks.discord.serverLinks.push(link);
  7844. }
  7845. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link) || /^https?:\/\/www\.facebook\.com\/.*/.test(link)) {} else {
  7846. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7847. }
  7848. }
  7849. logStatus.success();
  7850. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7851. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7852. if (window.DEBUG) {
  7853. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7854. }
  7855. GM_setValue(`khTasks-${this.giveawayId}`, {
  7856. tasks: this.socialTasks,
  7857. time: new Date().getTime()
  7858. });
  7859. return true;
  7860. } catch (error) {
  7861. throwError(error, 'Keyhub.classifyTask');
  7862. return false;
  7863. }
  7864. }
  7865. verifyTask() {
  7866. try {
  7867. scripts_echoLog({
  7868. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7869. });
  7870. $.get(window.location.href, res => {
  7871. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7872. });
  7873. } catch (error) {
  7874. throwError(error, 'keyhub.verifyTask');
  7875. }
  7876. }
  7877. }
  7878. function Keyhub_getGiveawayId2() {
  7879. try {
  7880. var _window$location$href;
  7881. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7882. if (giveawayId) {
  7883. this.giveawayId = giveawayId;
  7884. return true;
  7885. }
  7886. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7887. return false;
  7888. } catch (error) {
  7889. throwError(error, 'Keyhub.getGiveawayId');
  7890. return false;
  7891. }
  7892. }
  7893. async function Keyhub_checkLeftKey2() {
  7894. try {
  7895. if (!globalOptions.other.checkLeftKey) {
  7896. return true;
  7897. }
  7898. const leftKey = $('#keysleft').text().trim();
  7899. if (leftKey === '0') {
  7900. await external_Swal_default().fire({
  7901. icon: 'warning',
  7902. title: i18n('notice'),
  7903. text: i18n('noKeysLeft'),
  7904. confirmButtonText: i18n('confirm'),
  7905. cancelButtonText: i18n('cancel'),
  7906. showCancelButton: true
  7907. }).then(_ref => {
  7908. let {
  7909. value
  7910. } = _ref;
  7911. if (value) {
  7912. window.close();
  7913. }
  7914. });
  7915. }
  7916. return true;
  7917. } catch (error) {
  7918. throwError(error, 'Keyhub.checkLeftKey');
  7919. return false;
  7920. }
  7921. }
  7922. function Keyhub_checkLogin2() {
  7923. try {
  7924. if (!globalOptions.other.checkLogin) {
  7925. return true;
  7926. }
  7927. if ($('a[href*="/connect/steam"]').length > 0) {
  7928. window.open('/connect/steam', '_self');
  7929. }
  7930. return true;
  7931. } catch (error) {
  7932. throwError(error, 'Keyhub.checkLogin');
  7933. return false;
  7934. }
  7935. }
  7936. const website_Keyhub = Keyhub;
  7937. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7938. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7939. privateSet.add(obj);
  7940. }
  7941. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7942. if (privateCollection.has(obj)) {
  7943. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7944. }
  7945. }
  7946. function Givekey_defineProperty(obj, key, value) {
  7947. if (key in obj) {
  7948. Object.defineProperty(obj, key, {
  7949. value: value,
  7950. enumerable: true,
  7951. configurable: true,
  7952. writable: true
  7953. });
  7954. } else {
  7955. obj[key] = value;
  7956. }
  7957. return obj;
  7958. }
  7959. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7960. if (!privateSet.has(receiver)) {
  7961. throw new TypeError('attempted to get private field on non-instance');
  7962. }
  7963. return fn;
  7964. }
  7965. const Givekey_defaultTasksTemplate = {
  7966. steam: {
  7967. groupLinks: [],
  7968. wishlistLinks: [],
  7969. curatorLinks: [],
  7970. curatorLikeLinks: []
  7971. },
  7972. twitter: {
  7973. userLinks: []
  7974. },
  7975. vk: {
  7976. nameLinks: []
  7977. },
  7978. discord: {
  7979. serverLinks: []
  7980. }
  7981. };
  7982. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  7983. var Givekey_verify = new WeakSet();
  7984. var Givekey_getGiveawayId = new WeakSet();
  7985. var Givekey_checkLeftKey = new WeakSet();
  7986. class Givekey extends website_Website {
  7987. constructor() {
  7988. super(...arguments);
  7989. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7990. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7991. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7992. Givekey_defineProperty(this, 'name', 'Givekey');
  7993. Givekey_defineProperty(this, 'tasks', []);
  7994. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  7995. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  7996. Givekey_defineProperty(this, 'userId', void 0);
  7997. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7998. }
  7999. static test() {
  8000. return window.location.host === 'givekey.ru';
  8001. }
  8002. async after() {
  8003. try {
  8004. await new Promise(resolve => {
  8005. const checker = setInterval(() => {
  8006. if ($('#navbarDropdown').length > 0) {
  8007. clearInterval(checker);
  8008. resolve(true);
  8009. }
  8010. });
  8011. });
  8012. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8013. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8014. }
  8015. } catch (error) {
  8016. throwError(error, 'Givekey.after');
  8017. return false;
  8018. }
  8019. }
  8020. init() {
  8021. try {
  8022. const logStatus = scripts_echoLog({
  8023. text: i18n('initing')
  8024. });
  8025. if ($('a[href*="/auth/steam"]').length > 0) {
  8026. window.open('/auth/steam', '_self');
  8027. logStatus.warning(i18n('needLogin'));
  8028. return false;
  8029. }
  8030. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8031. return false;
  8032. }
  8033. const userId = $('meta[name="user-id"]').attr('content');
  8034. if (!userId) {
  8035. logStatus.error(i18n('getFailed', i18n('userId')));
  8036. return false;
  8037. }
  8038. this.userId = userId;
  8039. this.initialized = true;
  8040. logStatus.success();
  8041. return true;
  8042. } catch (error) {
  8043. throwError(error, 'Givekey.init');
  8044. return false;
  8045. }
  8046. }
  8047. async classifyTask(action) {
  8048. try {
  8049. const logStatus = scripts_echoLog({
  8050. text: i18n('getTasksInfo')
  8051. });
  8052. if (action === 'undo') {
  8053. var _GM_getValue;
  8054. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8055. }
  8056. const tasks = $('.card-body:has("button") .row');
  8057. for (const task of tasks) {
  8058. const taskEle = $(task);
  8059. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8060. if (isSuccess && action !== 'undo') {
  8061. continue;
  8062. }
  8063. const checkButton = taskEle.find('#task_check');
  8064. const taskId = checkButton.attr('data-id');
  8065. if (taskId) {
  8066. this.tasks.push(taskId);
  8067. }
  8068. if (action === 'verify') {
  8069. continue;
  8070. }
  8071. let href = taskEle.find('a').attr('href') || null;
  8072. const text = taskEle.find('a').text().trim();
  8073. const icon = taskEle.find('i');
  8074. if (!href || !text) {
  8075. continue;
  8076. }
  8077. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8078. href = await getRedirectLink(href);
  8079. }
  8080. if (!href) {
  8081. continue;
  8082. }
  8083. if (/^https?:\/\/vk\.com\//.test(href)) {
  8084. this.socialTasks.vk.nameLinks.push(href);
  8085. if (action === 'do' && !isSuccess) {
  8086. this.undoneTasks.vk.nameLinks.push(href);
  8087. }
  8088. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8089. this.socialTasks.steam.groupLinks.push(href);
  8090. if (action === 'do' && !isSuccess) {
  8091. this.undoneTasks.steam.groupLinks.push(href);
  8092. }
  8093. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8094. this.socialTasks.steam.wishlistLinks.push(href);
  8095. if (action === 'do' && !isSuccess) {
  8096. this.undoneTasks.steam.wishlistLinks.push(href);
  8097. }
  8098. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8099. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8100. this.socialTasks.steam.curatorLinks.push(href);
  8101. if (action === 'do' && !isSuccess) {
  8102. this.undoneTasks.steam.curatorLinks.push(href);
  8103. }
  8104. } else {
  8105. this.socialTasks.steam.curatorLikeLinks.push(href);
  8106. if (action === 'do' && !isSuccess) {
  8107. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8108. }
  8109. }
  8110. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8111. this.socialTasks.twitter.userLinks.push(href);
  8112. if (action === 'do' && !isSuccess) {
  8113. this.undoneTasks.twitter.userLinks.push(href);
  8114. }
  8115. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8116. this.socialTasks.discord.serverLinks.push(href);
  8117. if (action === 'do' && !isSuccess) {
  8118. this.undoneTasks.discord.serverLinks.push(href);
  8119. }
  8120. } else {
  8121. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8122. }
  8123. }
  8124. logStatus.success();
  8125. this.tasks = unique(this.tasks);
  8126. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8127. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8128. if (window.DEBUG) {
  8129. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8130. }
  8131. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8132. tasks: this.socialTasks,
  8133. time: new Date().getTime()
  8134. });
  8135. return true;
  8136. } catch (error) {
  8137. throwError(error, 'Givekey.classifyTask');
  8138. return false;
  8139. }
  8140. }
  8141. async verifyTask() {
  8142. try {
  8143. if (!this.initialized && !this.init()) {
  8144. return false;
  8145. }
  8146. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8147. return false;
  8148. }
  8149. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8150. const taskLength = this.tasks.length;
  8151. for (let i = 0; i < taskLength; i++) {
  8152. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8153. if (i < taskLength - 1) {
  8154. await delay(15e3);
  8155. }
  8156. }
  8157. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8158. scripts_echoLog({
  8159. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8160. });
  8161. return true;
  8162. } catch (error) {
  8163. throwError(error, 'Givekey.verifyTask');
  8164. return false;
  8165. }
  8166. }
  8167. }
  8168. async function Givekey_verify2(task) {
  8169. try {
  8170. const logStatus = scripts_echoLog({
  8171. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8172. });
  8173. return await new Promise(resolve => {
  8174. $.ajax({
  8175. url: 'https://givekey.ru/giveaway/task',
  8176. method: 'POST',
  8177. data: `id=${task}&user_id=${this.userId}`,
  8178. dataType: 'json',
  8179. headers: {
  8180. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8181. },
  8182. success: data => {
  8183. if (data.btn) {
  8184. $(`button[data-id=${this.userId}]`).html(data.btn);
  8185. }
  8186. if (data.status === 'ok') {
  8187. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8188. logStatus.success();
  8189. resolve(true);
  8190. } else if (data.status === 'end') {
  8191. logStatus.success();
  8192. scripts_echoLog({}).success(data.key);
  8193. resolve(true);
  8194. } else {
  8195. logStatus.error(`Error:${data.msg}`);
  8196. resolve(false);
  8197. }
  8198. },
  8199. error: xhr => {
  8200. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8201. resolve(false);
  8202. }
  8203. });
  8204. });
  8205. } catch (error) {
  8206. throwError(error, 'Givekey.verify');
  8207. return false;
  8208. }
  8209. }
  8210. function Givekey_getGiveawayId2() {
  8211. try {
  8212. var _window$location$href;
  8213. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8214. if (giveawayId) {
  8215. this.giveawayId = giveawayId;
  8216. return true;
  8217. }
  8218. scripts_echoLog({
  8219. text: i18n('getFailed', 'GiveawayId')
  8220. });
  8221. return false;
  8222. } catch (error) {
  8223. throwError(error, 'Givekey.getGiveawayId');
  8224. return false;
  8225. }
  8226. }
  8227. async function Givekey_checkLeftKey2() {
  8228. try {
  8229. if (!globalOptions.other.checkLeftKey) {
  8230. return true;
  8231. }
  8232. if (!$('#keys_count').text()) {
  8233. await external_Swal_default().fire({
  8234. icon: 'warning',
  8235. title: i18n('notice'),
  8236. text: i18n('noKeysLeft'),
  8237. confirmButtonText: i18n('confirm'),
  8238. cancelButtonText: i18n('cancel'),
  8239. showCancelButton: true
  8240. }).then(_ref => {
  8241. let {
  8242. value
  8243. } = _ref;
  8244. if (value) {
  8245. window.close();
  8246. }
  8247. });
  8248. }
  8249. return true;
  8250. } catch (error) {
  8251. throwError(error, 'Givekey.checkLeftKey');
  8252. return false;
  8253. }
  8254. }
  8255. const website_Givekey = Givekey;
  8256. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8257. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8258. privateSet.add(obj);
  8259. }
  8260. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8261. if (privateCollection.has(obj)) {
  8262. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8263. }
  8264. }
  8265. function GiveeClub_defineProperty(obj, key, value) {
  8266. if (key in obj) {
  8267. Object.defineProperty(obj, key, {
  8268. value: value,
  8269. enumerable: true,
  8270. configurable: true,
  8271. writable: true
  8272. });
  8273. } else {
  8274. obj[key] = value;
  8275. }
  8276. return obj;
  8277. }
  8278. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8279. if (!privateSet.has(receiver)) {
  8280. throw new TypeError('attempted to get private field on non-instance');
  8281. }
  8282. return fn;
  8283. }
  8284. var GiveeClub_checkLogin = new WeakSet();
  8285. var GiveeClub_getGiveawayId = new WeakSet();
  8286. var GiveeClub_checkLeftKey = new WeakSet();
  8287. class GiveeClub extends GiveawaySu {
  8288. constructor() {
  8289. super(...arguments);
  8290. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8291. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8292. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8293. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8294. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  8295. }
  8296. static test() {
  8297. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8298. }
  8299. async after() {
  8300. try {
  8301. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8302. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8303. }
  8304. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8305. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8306. }
  8307. } catch (error) {
  8308. throwError(error, 'GiveeClub.after');
  8309. }
  8310. }
  8311. init() {
  8312. try {
  8313. const logStatus = scripts_echoLog({
  8314. text: i18n('initing')
  8315. });
  8316. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8317. logStatus.warning(i18n('needLogin'));
  8318. return false;
  8319. }
  8320. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8321. return false;
  8322. }
  8323. this.initialized = true;
  8324. logStatus.success();
  8325. return true;
  8326. } catch (error) {
  8327. throwError(error, 'GiveeClub.init');
  8328. return false;
  8329. }
  8330. }
  8331. async classifyTask(action) {
  8332. try {
  8333. const logStatus = scripts_echoLog({
  8334. text: i18n('getTasksInfo')
  8335. });
  8336. if (action === 'undo') {
  8337. var _GM_getValue;
  8338. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8339. return true;
  8340. }
  8341. const pro = [];
  8342. const tasks = $('.event-actions tr');
  8343. for (const task of tasks) {
  8344. pro.push(new Promise(resolve => {
  8345. const taskDes = $(task).find('.event-action-label a');
  8346. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8347. const taskName = taskDes.text().trim();
  8348. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8349. return resolve(true);
  8350. }
  8351. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8352. if (!taskLink) {
  8353. return resolve(false);
  8354. }
  8355. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8356. this.undoneTasks.steam.groupLinks.push(taskLink);
  8357. } else if (/like.*announcement/gi.test(taskName)) {
  8358. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8359. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8360. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8361. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  8362. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8363. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8364. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8365. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8366. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8367. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8368. this.undoneTasks.steam.forumLinks.push(taskLink);
  8369. } else if (taskIcon.includes('discord')) {
  8370. this.undoneTasks.discord.serverLinks.push(taskLink);
  8371. } else if (taskIcon.includes('instagram')) {
  8372. this.undoneTasks.instagram.userLinks.push(taskLink);
  8373. } else if (taskIcon.includes('twitch')) {
  8374. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8375. } else if (taskIcon.includes('reddit')) {
  8376. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8377. } else if (/watch.*art/gim.test(taskName)) {
  8378. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8379. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8380. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8381. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8382. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8383. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8384. this.undoneTasks.vk.nameLinks.push(taskLink);
  8385. } else {
  8386. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8387. if (/follow.*button/gim.test(taskName)) {
  8388. this.undoneTasks.steam.followLinks.push(taskLink);
  8389. }
  8390. }
  8391. }
  8392. resolve(true);
  8393. }).catch(error => {
  8394. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8395. return false;
  8396. });
  8397. }));
  8398. }
  8399. await Promise.all(pro);
  8400. logStatus.success();
  8401. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8402. this.socialTasks = this.undoneTasks;
  8403. if (window.DEBUG) {
  8404. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8405. }
  8406. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8407. tasks: this.socialTasks,
  8408. time: new Date().getTime()
  8409. });
  8410. return true;
  8411. } catch (error) {
  8412. throwError(error, 'GiveeClub.classifyTask');
  8413. return false;
  8414. }
  8415. }
  8416. }
  8417. function GiveeClub_checkLogin2() {
  8418. try {
  8419. if (!globalOptions.other.checkLogin) {
  8420. return true;
  8421. }
  8422. if ($('a[href*="/account/auth"]').length > 0) {
  8423. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8424. }
  8425. return true;
  8426. } catch (error) {
  8427. throwError(error, 'GiveeClub.checkLogin');
  8428. return false;
  8429. }
  8430. }
  8431. function GiveeClub_getGiveawayId2() {
  8432. var _window$location$href;
  8433. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8434. if (giveawayId) {
  8435. this.giveawayId = giveawayId;
  8436. return true;
  8437. }
  8438. scripts_echoLog({
  8439. text: i18n('getFailed', 'GiveawayId')
  8440. });
  8441. return false;
  8442. }
  8443. async function GiveeClub_checkLeftKey2() {
  8444. try {
  8445. if (!globalOptions.other.checkLeftKey) {
  8446. return true;
  8447. }
  8448. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8449. await external_Swal_default().fire({
  8450. icon: 'warning',
  8451. title: i18n('notice'),
  8452. text: i18n('giveawayEnded'),
  8453. confirmButtonText: i18n('confirm'),
  8454. cancelButtonText: i18n('cancel'),
  8455. showCancelButton: true
  8456. }).then(_ref => {
  8457. let {
  8458. value
  8459. } = _ref;
  8460. if (value) {
  8461. window.close();
  8462. }
  8463. });
  8464. }
  8465. return true;
  8466. } catch (error) {
  8467. throwError(error, 'Giveawaysu.checkLeftKey');
  8468. return false;
  8469. }
  8470. }
  8471. const website_GiveeClub = GiveeClub;
  8472. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8473. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8474. privateSet.add(obj);
  8475. }
  8476. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8477. if (privateCollection.has(obj)) {
  8478. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8479. }
  8480. }
  8481. function OpiumPulses_defineProperty(obj, key, value) {
  8482. if (key in obj) {
  8483. Object.defineProperty(obj, key, {
  8484. value: value,
  8485. enumerable: true,
  8486. configurable: true,
  8487. writable: true
  8488. });
  8489. } else {
  8490. obj[key] = value;
  8491. }
  8492. return obj;
  8493. }
  8494. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8495. if (!privateSet.has(receiver)) {
  8496. throw new TypeError('attempted to get private field on non-instance');
  8497. }
  8498. return fn;
  8499. }
  8500. const defaultOptions = {
  8501. maxPoint: '99999999'
  8502. };
  8503. var _toggleTask = new WeakSet();
  8504. var OpiumPulses_checkLogin = new WeakSet();
  8505. class OpiumPulses {
  8506. constructor() {
  8507. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8508. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8509. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8510. OpiumPulses_defineProperty(this, 'options', {
  8511. ...defaultOptions,
  8512. ...GM_getValue('OpiumPulsesOptions')
  8513. });
  8514. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8515. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8516. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8517. }
  8518. static test() {
  8519. return window.location.host === 'www.opiumpulses.com';
  8520. }
  8521. async after() {
  8522. try {
  8523. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8524. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8525. }
  8526. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8527. } catch (error) {
  8528. throwError(error, 'OpiumPulses.after');
  8529. }
  8530. }
  8531. async doFreeTask() {
  8532. try {
  8533. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8534. } catch (error) {
  8535. throwError(error, 'OpiumPulses.doFreeTask');
  8536. }
  8537. }
  8538. async doPointTask() {
  8539. try {
  8540. var _$$text$match;
  8541. 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);
  8542. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8543. } catch (error) {
  8544. throwError(error, 'OpiumPulses.doPointTask');
  8545. }
  8546. }
  8547. init() {
  8548. return true;
  8549. }
  8550. classifyTask() {
  8551. return true;
  8552. }
  8553. }
  8554. async function _toggleTask2(type) {
  8555. try {
  8556. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8557. for (const item of items) {
  8558. var _$$find$text$match;
  8559. 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);
  8560. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8561. if (type === 'points' && needPoints > this.myPoints) {
  8562. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8563. } else if (type === 'points' && !needPoints) {
  8564. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8565. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8566. var _aElement$attr;
  8567. const logStatus = scripts_echoLog({
  8568. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8569. });
  8570. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8571. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8572. var _aElement$attr2, _aElement$attr2$match;
  8573. 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];
  8574. if (giveawayId) {
  8575. checkUser(giveawayId);
  8576. }
  8577. }
  8578. if (!aElement.attr('href')) {
  8579. logStatus.error('Error: No "href".');
  8580. continue;
  8581. }
  8582. const {
  8583. result,
  8584. statusText,
  8585. status,
  8586. data
  8587. } = await tools_httpRequest({
  8588. url: aElement.attr('href'),
  8589. method: 'GET'
  8590. });
  8591. if (result === 'Success') {
  8592. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8593. var _data$responseText$ma;
  8594. logStatus.success();
  8595. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8596. if (type === 'points' && points) {
  8597. this.myPoints = parseInt(points, 10);
  8598. }
  8599. } else {
  8600. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8601. }
  8602. } else {
  8603. logStatus.error(`${result}:${statusText}(${status})`);
  8604. }
  8605. }
  8606. }
  8607. scripts_echoLog({
  8608. text: '-----END-----'
  8609. });
  8610. } catch (error) {
  8611. throwError(error, 'OpiumPulses.toggleTask');
  8612. }
  8613. }
  8614. function OpiumPulses_checkLogin2() {
  8615. try {
  8616. if (!globalOptions.other.checkLogin) {
  8617. return true;
  8618. }
  8619. if ($('a[href*="/site/login"]').length > 1) {
  8620. window.open('/site/login', '_self');
  8621. }
  8622. return true;
  8623. } catch (error) {
  8624. throwError(error, 'OpiumPulses.checkLogin');
  8625. return false;
  8626. }
  8627. }
  8628. const website_OpiumPulses = OpiumPulses;
  8629. const external_dayjs_namespaceObject = dayjs;
  8630. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8631. const leftKeyChecker = {
  8632. async classify(link) {
  8633. try {
  8634. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8635. return await this.giveawaySu(link);
  8636. }
  8637. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8638. return await this.giveeClub(link);
  8639. }
  8640. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8641. return await this.gleam(link);
  8642. }
  8643. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8644. return await this.indieDb(link);
  8645. }
  8646. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8647. return await this.keyhub(link);
  8648. }
  8649. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8650. return await this.opquests(link);
  8651. }
  8652. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8653. return await this.itch(link);
  8654. }
  8655. return false;
  8656. } catch (error) {
  8657. throwError(error, 'leftKeyChecker.classify');
  8658. return false;
  8659. }
  8660. },
  8661. async giveawaySu(link) {
  8662. try {
  8663. const {
  8664. result,
  8665. data
  8666. } = await tools_httpRequest({
  8667. url: link,
  8668. method: 'GET'
  8669. });
  8670. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8671. if (data.responseText.includes('class="steam-login"')) {
  8672. return false;
  8673. }
  8674. if (data.responseText.includes('class="giveaway-ended"')) {
  8675. return 'Ended';
  8676. }
  8677. return 'Active';
  8678. }
  8679. return false;
  8680. } catch (error) {
  8681. throwError(error, 'leftKeyChecker.giveawaySu');
  8682. return false;
  8683. }
  8684. },
  8685. async giveeClub(link) {
  8686. try {
  8687. const {
  8688. result,
  8689. data
  8690. } = await tools_httpRequest({
  8691. url: link,
  8692. method: 'GET'
  8693. });
  8694. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8695. if (data.responseText.includes('class="event-winner"')) {
  8696. return 'Won';
  8697. }
  8698. if (data.responseText.includes('class="event-ended"')) {
  8699. return 'Ended';
  8700. }
  8701. return 'Active';
  8702. }
  8703. return false;
  8704. } catch (error) {
  8705. throwError(error, 'leftKeyChecker.giveeClub');
  8706. return false;
  8707. }
  8708. },
  8709. async gleam(link) {
  8710. try {
  8711. const {
  8712. result,
  8713. data
  8714. } = await tools_httpRequest({
  8715. url: link,
  8716. method: 'GET'
  8717. });
  8718. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8719. var _data$responseText$ma, _$$attr, _$$attr$match;
  8720. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8721. return 'Won';
  8722. }
  8723. 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];
  8724. if (!campaignDiv) {
  8725. return false;
  8726. }
  8727. 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];
  8728. if (!campaignString) {
  8729. return false;
  8730. }
  8731. const {
  8732. campaign
  8733. } = JSON.parse(campaignString);
  8734. if (campaign.banned) {
  8735. return 'Banned';
  8736. }
  8737. if (campaign.finished) {
  8738. return 'Ended';
  8739. }
  8740. if (campaign.paused) {
  8741. return 'Paused';
  8742. }
  8743. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8744. return 'NotStart';
  8745. }
  8746. return 'Active';
  8747. }
  8748. return false;
  8749. } catch (error) {
  8750. throwError(error, 'leftKeyChecker.gleam');
  8751. return false;
  8752. }
  8753. },
  8754. async indieDb(link) {
  8755. try {
  8756. const {
  8757. result,
  8758. data
  8759. } = await tools_httpRequest({
  8760. url: link,
  8761. method: 'GET'
  8762. });
  8763. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8764. if (data.responseText.includes('Congrats you WON')) {
  8765. return 'Won';
  8766. }
  8767. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8768. return 'Ended';
  8769. }
  8770. return 'Active';
  8771. }
  8772. return false;
  8773. } catch (error) {
  8774. throwError(error, 'leftKeyChecker.indieDb');
  8775. return false;
  8776. }
  8777. },
  8778. async keyhub(link) {
  8779. try {
  8780. const {
  8781. result,
  8782. data
  8783. } = await tools_httpRequest({
  8784. url: link,
  8785. method: 'GET'
  8786. });
  8787. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8788. var _data$responseText$ma2;
  8789. 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];
  8790. if (!keysleft) {
  8791. return false;
  8792. }
  8793. if (keysleft === '0') {
  8794. return 'Ended';
  8795. }
  8796. return `Active(${keysleft})`;
  8797. }
  8798. return false;
  8799. } catch (error) {
  8800. throwError(error, 'leftKeyChecker.keyhub');
  8801. return false;
  8802. }
  8803. },
  8804. async opquests(link) {
  8805. try {
  8806. const {
  8807. result,
  8808. data
  8809. } = await tools_httpRequest({
  8810. url: link,
  8811. method: 'GET'
  8812. });
  8813. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8814. var _data$responseText$ma3;
  8815. 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];
  8816. if (!keysleft) {
  8817. return false;
  8818. }
  8819. if (keysleft === '0') {
  8820. return 'Ended';
  8821. }
  8822. return `Active(${keysleft})`;
  8823. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8824. return 'Ended';
  8825. }
  8826. return false;
  8827. } catch (error) {
  8828. throwError(error, 'leftKeyChecker.opquests');
  8829. return false;
  8830. }
  8831. },
  8832. async itch(link) {
  8833. try {
  8834. const {
  8835. result,
  8836. data
  8837. } = await tools_httpRequest({
  8838. url: link,
  8839. method: 'GET'
  8840. });
  8841. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8842. var _data$responseText$ma4;
  8843. 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];
  8844. if (!endDate) {
  8845. return false;
  8846. }
  8847. if (new Date().getTime() > new Date(endDate).getTime()) {
  8848. return 'Ended';
  8849. }
  8850. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8851. }
  8852. return false;
  8853. } catch (error) {
  8854. throwError(error, 'leftKeyChecker.opquests');
  8855. return false;
  8856. }
  8857. }
  8858. };
  8859. const website_leftKeyChecker = leftKeyChecker;
  8860. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8861. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8862. privateSet.add(obj);
  8863. }
  8864. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8865. if (privateCollection.has(obj)) {
  8866. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8867. }
  8868. }
  8869. function Keylol_defineProperty(obj, key, value) {
  8870. if (key in obj) {
  8871. Object.defineProperty(obj, key, {
  8872. value: value,
  8873. enumerable: true,
  8874. configurable: true,
  8875. writable: true
  8876. });
  8877. } else {
  8878. obj[key] = value;
  8879. }
  8880. return obj;
  8881. }
  8882. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8883. if (!privateSet.has(receiver)) {
  8884. throw new TypeError('attempted to get private field on non-instance');
  8885. }
  8886. return fn;
  8887. }
  8888. const Keylol_defaultTasksTemplate = {
  8889. steam: {
  8890. groupLinks: [],
  8891. wishlistLinks: [],
  8892. curatorLinks: [],
  8893. curatorLikeLinks: [],
  8894. followLinks: [],
  8895. forumLinks: [],
  8896. announcementLinks: [],
  8897. workshopVoteLinks: [],
  8898. licenseLinks: []
  8899. },
  8900. discord: {
  8901. serverLinks: []
  8902. },
  8903. instagram: {
  8904. userLinks: []
  8905. },
  8906. vk: {
  8907. nameLinks: []
  8908. },
  8909. twitch: {
  8910. channelLinks: []
  8911. },
  8912. reddit: {
  8913. redditLinks: []
  8914. },
  8915. twitter: {
  8916. userLinks: [],
  8917. retweetLinks: []
  8918. },
  8919. youtube: {
  8920. channelLinks: [],
  8921. likeLinks: []
  8922. }
  8923. };
  8924. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  8925. var _addBtn = new WeakSet();
  8926. class Keylol extends website_Website {
  8927. constructor() {
  8928. super(...arguments);
  8929. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8930. Keylol_defineProperty(this, 'name', 'Keylol');
  8931. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  8932. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  8933. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8934. }
  8935. static test() {
  8936. var _$$eq$attr, _$$eq$attr2;
  8937. 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')));
  8938. }
  8939. init() {
  8940. return true;
  8941. }
  8942. after() {
  8943. try {
  8944. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8945. const mainPost = $(selector);
  8946. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  8947. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  8948. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  8949. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  8950. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  8951. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  8952. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  8953. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  8954. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  8955. if (discordLinks.length > 0) {
  8956. for (const discordLink of discordLinks) {
  8957. const link = $(discordLink).attr('href');
  8958. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8959. continue;
  8960. }
  8961. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8962. }
  8963. }
  8964. if (redditLinks.length > 0) {
  8965. for (const redditLink of redditLinks) {
  8966. const link = $(redditLink).attr('href');
  8967. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8968. continue;
  8969. }
  8970. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8971. }
  8972. }
  8973. if (insLinks.length > 0) {
  8974. for (const insLink of insLinks) {
  8975. const link = $(insLink).attr('href');
  8976. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8977. continue;
  8978. }
  8979. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8980. }
  8981. }
  8982. if (twitterLinks.length > 0) {
  8983. for (const twitterLink of twitterLinks) {
  8984. const link = $(twitterLink).attr('href');
  8985. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8986. continue;
  8987. }
  8988. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8989. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8990. } else {
  8991. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8992. }
  8993. }
  8994. }
  8995. if (twitchLinks.length > 0) {
  8996. for (const twitchLink of twitchLinks) {
  8997. const link = $(twitchLink).attr('href');
  8998. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8999. continue;
  9000. }
  9001. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9002. }
  9003. }
  9004. if (vkLinks.length > 0) {
  9005. for (const vkLink of vkLinks) {
  9006. const link = $(vkLink).attr('href');
  9007. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9008. continue;
  9009. }
  9010. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9011. }
  9012. }
  9013. if (steamStoreLinks.length > 0) {
  9014. for (const steamStoreLink of steamStoreLinks) {
  9015. const link = $(steamStoreLink).attr('href');
  9016. if (!link) {
  9017. continue;
  9018. }
  9019. if (/curator\/[\d]+/.test(link)) {
  9020. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9021. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9022. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9023. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9024. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9025. } else if (/app\/[\d]+/.test(link)) {
  9026. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9027. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9028. }
  9029. }
  9030. }
  9031. if (steamCommunityLinks.length > 0) {
  9032. for (const steamCommunityLink of steamCommunityLinks) {
  9033. const link = $(steamCommunityLink).attr('href');
  9034. if (!link) {
  9035. continue;
  9036. }
  9037. if (/groups\/.+/.test(link)) {
  9038. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9039. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9040. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9041. }
  9042. }
  9043. }
  9044. if (ytbLinks.length > 0) {
  9045. for (const ytbLink of ytbLinks) {
  9046. const link = $(ytbLink).attr('href');
  9047. if (!link) {
  9048. continue;
  9049. }
  9050. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9051. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9052. }
  9053. }
  9054. 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');
  9055. if (giveawayLinks.length > 0) {
  9056. for (const giveawayLink of giveawayLinks) {
  9057. const link = $(giveawayLink).attr('href');
  9058. if (!link) {
  9059. continue;
  9060. }
  9061. website_leftKeyChecker.classify(link).then(status => {
  9062. if (!status) {
  9063. return;
  9064. }
  9065. if (/^Active/.test(status)) {
  9066. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9067. return;
  9068. }
  9069. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9070. }).catch(error => {
  9071. throwError(error, 'keylol.after -> leftKeyChecker');
  9072. });
  9073. }
  9074. }
  9075. if (this.name === 'Keylol') {
  9076. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9077. if (asfLinks.length > 0) {
  9078. for (const asfLink of asfLinks) {
  9079. const link = $(asfLink).attr('href');
  9080. if (!link) {
  9081. continue;
  9082. }
  9083. 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', '')}`);
  9084. }
  9085. }
  9086. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9087. if (subLinks.length > 0) {
  9088. for (const subLink of subLinks) {
  9089. var _link$match;
  9090. const link = $(subLink).attr('href');
  9091. if (!link) {
  9092. continue;
  9093. }
  9094. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9095. if (!subid) {
  9096. continue;
  9097. }
  9098. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9099. }
  9100. }
  9101. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9102. if (asfLinks2.length > 0) {
  9103. for (const asfLink of asfLinks2) {
  9104. const subid = [ ...asfLink.innerText.matchAll(/s\/([\d]+)/g) ].map(arr => arr[1]);
  9105. if (subid.length === 0) {
  9106. continue;
  9107. }
  9108. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9109. }
  9110. }
  9111. }
  9112. } catch (error) {
  9113. throwError(error, 'keylol.after');
  9114. }
  9115. }
  9116. classifyTask(action) {
  9117. try {
  9118. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9119. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9120. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9121. for (const btn of selectedBtns) {
  9122. const button = $(btn);
  9123. const social = button.attr('data-social');
  9124. const type = button.attr('data-type');
  9125. const link = button.attr('data-link');
  9126. if (!(social && type && link)) {
  9127. continue;
  9128. }
  9129. if (action === 'do') {
  9130. this.undoneTasks[social][type].push(link);
  9131. }
  9132. if (action === 'undo') {
  9133. this.socialTasks[social][type].push(link);
  9134. }
  9135. }
  9136. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9137. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9138. if (window.DEBUG) {
  9139. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9140. }
  9141. return true;
  9142. } catch (error) {
  9143. throwError(error, 'Keylol.classifyTask');
  9144. return false;
  9145. }
  9146. }
  9147. selectAll() {
  9148. try {
  9149. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9150. } catch (error) {
  9151. throwError(error, 'Keylol.selectAll');
  9152. }
  9153. }
  9154. selectNone() {
  9155. try {
  9156. $('.auto-task-keylol:visible').removeAttr('selected');
  9157. } catch (error) {
  9158. throwError(error, 'Keylol.selectNone');
  9159. }
  9160. }
  9161. invertSelect() {
  9162. try {
  9163. $('.auto-task-keylol:visible').each((index, element) => {
  9164. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9165. });
  9166. } catch (error) {
  9167. throwError(error, 'Keylol.invertSelect');
  9168. }
  9169. }
  9170. }
  9171. function _addBtn2(before, social, linkType, link) {
  9172. try {
  9173. $(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>`);
  9174. } catch (error) {
  9175. throwError(error, 'keylol.addBtn');
  9176. }
  9177. }
  9178. const website_Keylol = Keylol;
  9179. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9180. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9181. privateSet.add(obj);
  9182. }
  9183. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9184. if (privateCollection.has(obj)) {
  9185. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9186. }
  9187. }
  9188. function Opquests_defineProperty(obj, key, value) {
  9189. if (key in obj) {
  9190. Object.defineProperty(obj, key, {
  9191. value: value,
  9192. enumerable: true,
  9193. configurable: true,
  9194. writable: true
  9195. });
  9196. } else {
  9197. obj[key] = value;
  9198. }
  9199. return obj;
  9200. }
  9201. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9202. if (!privateSet.has(receiver)) {
  9203. throw new TypeError('attempted to get private field on non-instance');
  9204. }
  9205. return fn;
  9206. }
  9207. const Opquests_defaultTasks = {
  9208. steam: {
  9209. groupLinks: [],
  9210. wishlistLinks: [],
  9211. followLinks: [],
  9212. curatorLikeLinks: []
  9213. }
  9214. };
  9215. var Opquests_getGiveawayId = new WeakSet();
  9216. var Opquests_checkLogin = new WeakSet();
  9217. class Opquests extends website_Website {
  9218. constructor() {
  9219. super(...arguments);
  9220. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9221. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9222. Opquests_defineProperty(this, 'name', 'Opquests');
  9223. Opquests_defineProperty(this, 'undoneTasks', {
  9224. ...Opquests_defaultTasks
  9225. });
  9226. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9227. }
  9228. static test() {
  9229. return window.location.host === 'opquests.com';
  9230. }
  9231. async after() {
  9232. try {
  9233. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9234. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9235. }
  9236. } catch (error) {
  9237. throwError(error, 'Opquests.after');
  9238. }
  9239. }
  9240. init() {
  9241. try {
  9242. const logStatus = scripts_echoLog({
  9243. text: i18n('initing')
  9244. });
  9245. if ($('a[href*="/auth/redirect"]').length > 0) {
  9246. window.open('/auth/redirect', '_self');
  9247. logStatus.warning(i18n('needLogin'));
  9248. return false;
  9249. }
  9250. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9251. return false;
  9252. }
  9253. this.initialized = true;
  9254. logStatus.success();
  9255. return true;
  9256. } catch (error) {
  9257. throwError(error, 'Opquests.init');
  9258. return false;
  9259. }
  9260. }
  9261. async classifyTask(action) {
  9262. try {
  9263. if (action === 'undo') {
  9264. scripts_echoLog({
  9265. text: i18n('cannotUndo')
  9266. });
  9267. return false;
  9268. }
  9269. const logStatus = scripts_echoLog({
  9270. text: i18n('getTasksInfo')
  9271. });
  9272. const tasks = $('.w-full:contains("Validate") .items-center');
  9273. for (const task of tasks) {
  9274. const link = $(task).find('a:contains("Open")').attr('href');
  9275. const taskDes = $(task).find('div').eq(1).text().trim();
  9276. if (!link) {
  9277. continue;
  9278. }
  9279. if (/steamcommunity\.com\/groups\//.test(link)) {
  9280. this.undoneTasks.steam.groupLinks.push(link);
  9281. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9282. if (/wishlist/gim.test(taskDes)) {
  9283. this.undoneTasks.steam.wishlistLinks.push(link);
  9284. } else if (/follow/gim.test(taskDes)) {
  9285. this.undoneTasks.steam.followLinks.push(link);
  9286. }
  9287. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9288. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9289. } else {
  9290. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9291. }
  9292. }
  9293. logStatus.success();
  9294. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9295. if (window.DEBUG) {
  9296. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9297. }
  9298. return true;
  9299. } catch (error) {
  9300. throwError(error, 'Opquests.classifyTask');
  9301. return false;
  9302. }
  9303. }
  9304. }
  9305. function Opquests_getGiveawayId2() {
  9306. try {
  9307. var _window$location$href;
  9308. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9309. if (giveawayId) {
  9310. this.giveawayId = giveawayId;
  9311. return true;
  9312. }
  9313. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9314. return false;
  9315. } catch (error) {
  9316. throwError(error, 'Opquests.getGiveawayId');
  9317. return false;
  9318. }
  9319. }
  9320. function Opquests_checkLogin2() {
  9321. try {
  9322. if (!globalOptions.other.checkLogin) {
  9323. return true;
  9324. }
  9325. if ($('a[href*="/auth/redirect"]').length > 0) {
  9326. window.open('/auth/redirect', '_self');
  9327. }
  9328. return true;
  9329. } catch (error) {
  9330. throwError(error, 'Opquests.checkLogin');
  9331. return false;
  9332. }
  9333. }
  9334. const website_Opquests = Opquests;
  9335. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9336. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9337. privateSet.add(obj);
  9338. }
  9339. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9340. if (privateCollection.has(obj)) {
  9341. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9342. }
  9343. }
  9344. function Gleam_defineProperty(obj, key, value) {
  9345. if (key in obj) {
  9346. Object.defineProperty(obj, key, {
  9347. value: value,
  9348. enumerable: true,
  9349. configurable: true,
  9350. writable: true
  9351. });
  9352. } else {
  9353. obj[key] = value;
  9354. }
  9355. return obj;
  9356. }
  9357. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9358. if (!privateSet.has(receiver)) {
  9359. throw new TypeError('attempted to get private field on non-instance');
  9360. }
  9361. return fn;
  9362. }
  9363. const Gleam_defaultTasksTemplate = {
  9364. steam: {
  9365. groupLinks: [],
  9366. wishlistLinks: [],
  9367. followLinks: [],
  9368. curatorLinks: [],
  9369. curatorLikeLinks: []
  9370. },
  9371. twitter: {
  9372. userLinks: [],
  9373. retweetLinks: []
  9374. },
  9375. twitch: {
  9376. channelLinks: []
  9377. },
  9378. discord: {
  9379. serverLinks: []
  9380. },
  9381. youtube: {
  9382. channelLinks: []
  9383. },
  9384. extra: {
  9385. gleam: []
  9386. }
  9387. };
  9388. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9389. const Gleam_defaultOptions = {
  9390. vlootUsername: '',
  9391. gameroundUsername: ''
  9392. };
  9393. var _checkSync = new WeakSet();
  9394. var _doGleamTask = new WeakSet();
  9395. var Gleam_getGiveawayId = new WeakSet();
  9396. var _getGleamLink = new WeakSet();
  9397. var Gleam_checkLeftKey = new WeakSet();
  9398. class Gleam extends website_Website {
  9399. constructor() {
  9400. super(...arguments);
  9401. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9402. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9403. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9404. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9405. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9406. Gleam_defineProperty(this, 'name', 'Gleam');
  9407. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9408. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9409. Gleam_defineProperty(this, 'options', {
  9410. ...Gleam_defaultOptions,
  9411. ...GM_getValue('GleamOptions')
  9412. });
  9413. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9414. }
  9415. static test() {
  9416. return window.location.host === 'gleam.io';
  9417. }
  9418. async after() {
  9419. try {
  9420. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9421. const checkComplete = setInterval(() => {
  9422. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9423. clearInterval(checkComplete);
  9424. window.close();
  9425. }
  9426. });
  9427. for (const task of $('.entry-content .entry-method')) {
  9428. const taskInfo = $(task).find('.user-links');
  9429. const expandInfo = $(task).find('.expandable');
  9430. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9431. if (aElements.length > 0) {
  9432. for (const element of aElements) {
  9433. const $element = $(element);
  9434. const href = $element.attr('href');
  9435. $element.removeAttr('href')[0].click();
  9436. $element.attr('href', href);
  9437. await delay(1e3);
  9438. }
  9439. }
  9440. taskInfo[0].click();
  9441. await delay(1e3);
  9442. }
  9443. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9444. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9445. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9446. }
  9447. } catch (error) {
  9448. throwError(error, 'Gleam.after');
  9449. return false;
  9450. }
  9451. }
  9452. init() {
  9453. try {
  9454. const logStatus = scripts_echoLog({
  9455. text: i18n('initing')
  9456. });
  9457. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9458. return false;
  9459. }
  9460. this.initialized = true;
  9461. logStatus.success();
  9462. return true;
  9463. } catch (error) {
  9464. throwError(error, 'Gleam.init');
  9465. return false;
  9466. }
  9467. }
  9468. async classifyTask(action) {
  9469. try {
  9470. const logStatus = scripts_echoLog({
  9471. text: i18n('getTasksInfo')
  9472. });
  9473. if (action === 'undo') {
  9474. var _GM_getValue;
  9475. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9476. }
  9477. const tasks = $('.entry-content .entry-method');
  9478. for (const task of tasks) {
  9479. var _socialIcon$attr;
  9480. const $task = $(task);
  9481. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9482. continue;
  9483. }
  9484. const socialIcon = $task.find('.icon-wrapper i');
  9485. const taskInfo = $task.find('.user-links');
  9486. const taskText = taskInfo.text().trim();
  9487. const expandInfo = $task.find('.expandable');
  9488. const aElements = expandInfo.find('a.btn');
  9489. if (aElements.length > 0) {
  9490. for (const element of aElements) {
  9491. const $element = $(element);
  9492. const href = $element.attr('href');
  9493. $element.removeAttr('href')[0].click();
  9494. $element.attr('href', href);
  9495. }
  9496. }
  9497. if (socialIcon.hasClass('fa-twitter')) {
  9498. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9499. if (!link) {
  9500. continue;
  9501. }
  9502. if (/follow/gi.test(taskText)) {
  9503. if (action === 'undo') {
  9504. this.socialTasks.twitter.userLinks.push(link);
  9505. }
  9506. if (action === 'do') {
  9507. this.undoneTasks.twitter.userLinks.push(link);
  9508. }
  9509. } else if (/retweet/gim.test(taskText)) {
  9510. if (action === 'undo') {
  9511. this.socialTasks.twitter.retweetLinks.push(link);
  9512. }
  9513. if (action === 'do') {
  9514. this.undoneTasks.twitter.retweetLinks.push(link);
  9515. }
  9516. }
  9517. } else if (socialIcon.hasClass('fa-twitch')) {
  9518. if (/follow/gim.test(taskText)) {
  9519. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9520. if (!link) {
  9521. continue;
  9522. }
  9523. if (action === 'undo') {
  9524. this.socialTasks.twitch.channelLinks.push(link);
  9525. }
  9526. if (action === 'do') {
  9527. this.undoneTasks.twitch.channelLinks.push(link);
  9528. }
  9529. }
  9530. } else if (socialIcon.hasClass('fa-discord')) {
  9531. if (/join/gim.test(taskText)) {
  9532. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9533. if (!link) {
  9534. var _$task$find$attr, _$task$find$attr$matc;
  9535. 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];
  9536. if (!ggLink) {
  9537. continue;
  9538. }
  9539. link = `https://discord.com/invite/${ggLink}`;
  9540. }
  9541. if (action === 'undo') {
  9542. this.socialTasks.discord.serverLinks.push(link);
  9543. }
  9544. if (action === 'do') {
  9545. this.undoneTasks.discord.serverLinks.push(link);
  9546. }
  9547. }
  9548. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9549. continue;
  9550. } else if (socialIcon.hasClass('fa-youtube')) {
  9551. if (/subscribe/gim.test(taskText)) {
  9552. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9553. if (!link) {
  9554. continue;
  9555. }
  9556. if (action === 'undo') {
  9557. this.socialTasks.youtube.channelLinks.push(link);
  9558. }
  9559. if (action === 'do') {
  9560. this.undoneTasks.youtube.channelLinks.push(link);
  9561. }
  9562. }
  9563. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9564. if (/join.*group/gi.test(taskText)) {
  9565. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9566. if (!link) {
  9567. continue;
  9568. }
  9569. if (action === 'undo') {
  9570. this.socialTasks.steam.groupLinks.push(link);
  9571. }
  9572. if (action === 'do') {
  9573. this.undoneTasks.steam.groupLinks.push(link);
  9574. }
  9575. } else if (/follow.*curator/gi.test(taskText)) {
  9576. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9577. if (!link) {
  9578. continue;
  9579. }
  9580. if (action === 'undo') {
  9581. this.socialTasks.steam.curatorLinks.push(link);
  9582. }
  9583. if (action === 'do') {
  9584. this.undoneTasks.steam.curatorLinks.push(link);
  9585. }
  9586. }
  9587. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9588. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9589. for (const button of continueBtn) {
  9590. button.click();
  9591. await delay(500);
  9592. expandInfo.find('input').val(this.options.vlootUsername);
  9593. }
  9594. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9595. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9596. for (const button of continueBtn) {
  9597. button.click();
  9598. await delay(500);
  9599. expandInfo.find('input').val(this.options.gameroundUsername);
  9600. }
  9601. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9602. if (action !== 'do') {
  9603. continue;
  9604. }
  9605. const link = aElements.attr('href');
  9606. if (!link) {
  9607. continue;
  9608. }
  9609. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9610. if (!gleamLink) {
  9611. continue;
  9612. }
  9613. this.undoneTasks.extra.gleam.push(gleamLink);
  9614. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-telegram-plane') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  9615. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9616. }
  9617. }
  9618. logStatus.success();
  9619. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9620. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9621. if (window.DEBUG) {
  9622. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9623. }
  9624. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9625. tasks: this.socialTasks,
  9626. time: new Date().getTime()
  9627. });
  9628. return true;
  9629. } catch (error) {
  9630. throwError(error, 'Gleam.classifyTask');
  9631. return false;
  9632. }
  9633. }
  9634. async extraDoTask(_ref) {
  9635. let {
  9636. gleam
  9637. } = _ref;
  9638. try {
  9639. const pro = [];
  9640. for (const link of gleam) {
  9641. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9642. }
  9643. return Promise.all(pro).then(() => true);
  9644. } catch (error) {
  9645. throwError(error, 'Gleam.extraDoTask');
  9646. return false;
  9647. }
  9648. }
  9649. async verifyTask() {
  9650. try {
  9651. scripts_echoLog({
  9652. text: `${i18n('verifyingTask')}...`
  9653. });
  9654. const tasks = $('.entry-content .entry-method');
  9655. for (const task of tasks) {
  9656. const $task = $(task);
  9657. if ($task.find('i.fa-question').length === 0) {
  9658. continue;
  9659. }
  9660. const taskInfo = $task.find('.user-links');
  9661. taskInfo[0].click();
  9662. await delay(500);
  9663. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9664. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9665. for (const button of continueBtn) {
  9666. button.click();
  9667. await delay(500);
  9668. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9669. }
  9670. }
  9671. scripts_echoLog({
  9672. text: i18n('verifiedGleamTasks')
  9673. });
  9674. } catch (error) {
  9675. throwError(error, 'Gleam.verifyTask');
  9676. return false;
  9677. }
  9678. }
  9679. }
  9680. async function _checkSync2() {
  9681. try {
  9682. return await new Promise(resolve => {
  9683. const checker = setInterval(() => {
  9684. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9685. clearInterval(checker);
  9686. resolve(true);
  9687. }
  9688. }, 500);
  9689. });
  9690. } catch (error) {
  9691. throwError(error, 'Gleam.checkSync');
  9692. return false;
  9693. }
  9694. }
  9695. async function _doGleamTask2(link) {
  9696. try {
  9697. const logStatus = scripts_echoLog({
  9698. text: i18n('doingGleamTask')
  9699. });
  9700. return await new Promise(resolve => {
  9701. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9702. active: true,
  9703. insert: true,
  9704. setParent: true
  9705. }).onclose = () => {
  9706. logStatus.success();
  9707. resolve(true);
  9708. };
  9709. });
  9710. } catch (error) {
  9711. throwError(error, 'Gleam.doGleamTask');
  9712. return false;
  9713. }
  9714. }
  9715. function Gleam_getGiveawayId2() {
  9716. try {
  9717. const giveawayId = window.location.pathname;
  9718. if (giveawayId) {
  9719. this.giveawayId = giveawayId;
  9720. return true;
  9721. }
  9722. scripts_echoLog({
  9723. text: i18n('getFailed', 'GiveawayId')
  9724. });
  9725. return false;
  9726. } catch (error) {
  9727. throwError(error, 'Gleam.getGiveawayId');
  9728. return false;
  9729. }
  9730. }
  9731. async function _getGleamLink2(link) {
  9732. try {
  9733. const logStatus = scripts_echoLog({
  9734. text: i18n('gettingGleamLink')
  9735. });
  9736. const {
  9737. result,
  9738. statusText,
  9739. status,
  9740. data
  9741. } = await tools_httpRequest({
  9742. url: link,
  9743. method: 'GET'
  9744. });
  9745. if (result === 'Success') {
  9746. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9747. var _data$responseText$ma;
  9748. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9749. if (gleamLink) {
  9750. logStatus.success();
  9751. return gleamLink;
  9752. }
  9753. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9754. return false;
  9755. }
  9756. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9757. return false;
  9758. }
  9759. logStatus.error(`${result}:${statusText}(${status})`);
  9760. return false;
  9761. } catch (error) {
  9762. throwError(error, 'Gleam.getGleamLink');
  9763. return false;
  9764. }
  9765. }
  9766. async function Gleam_checkLeftKey2() {
  9767. try {
  9768. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9769. if (!globalOptions.other.checkLeftKey) {
  9770. return true;
  9771. }
  9772. 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];
  9773. if (!campaignString) {
  9774. return false;
  9775. }
  9776. const {
  9777. campaign,
  9778. incentive
  9779. } = JSON.parse(campaignString);
  9780. 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];
  9781. let ownedKey = false;
  9782. if (controllerString) {
  9783. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9784. 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) {
  9785. ownedKey = true;
  9786. }
  9787. }
  9788. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9789. await external_Swal_default().fire({
  9790. icon: 'warning',
  9791. title: i18n('notice'),
  9792. text: i18n('giveawayNotWork'),
  9793. confirmButtonText: i18n('confirm'),
  9794. cancelButtonText: i18n('cancel'),
  9795. showCancelButton: true
  9796. }).then(_ref2 => {
  9797. let {
  9798. value
  9799. } = _ref2;
  9800. if (value) {
  9801. window.close();
  9802. }
  9803. });
  9804. }
  9805. return true;
  9806. } catch (error) {
  9807. throwError(error, 'Gleam.checkLeftKey');
  9808. return false;
  9809. }
  9810. }
  9811. const website_Gleam = Gleam;
  9812. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9813. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9814. privateSet.add(obj);
  9815. }
  9816. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9817. if (privateCollection.has(obj)) {
  9818. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9819. }
  9820. }
  9821. function SweepWidget_defineProperty(obj, key, value) {
  9822. if (key in obj) {
  9823. Object.defineProperty(obj, key, {
  9824. value: value,
  9825. enumerable: true,
  9826. configurable: true,
  9827. writable: true
  9828. });
  9829. } else {
  9830. obj[key] = value;
  9831. }
  9832. return obj;
  9833. }
  9834. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9835. if (!privateSet.has(receiver)) {
  9836. throw new TypeError('attempted to get private field on non-instance');
  9837. }
  9838. return fn;
  9839. }
  9840. const SweepWidget_defaultOptions = {
  9841. username: '',
  9842. email: ''
  9843. };
  9844. var SweepWidget_checkLogin = new WeakSet();
  9845. var SweepWidget_getGiveawayId = new WeakSet();
  9846. var _checkEnter = new WeakSet();
  9847. var _checkFinish = new WeakSet();
  9848. class SweepWidget extends website_Website {
  9849. constructor() {
  9850. super(...arguments);
  9851. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9852. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9853. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9854. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9855. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9856. SweepWidget_defineProperty(this, 'options', {
  9857. ...SweepWidget_defaultOptions,
  9858. ...GM_getValue('SweepWidgetOptions')
  9859. });
  9860. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9861. }
  9862. static test() {
  9863. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9864. }
  9865. async after() {
  9866. try {
  9867. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9868. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9869. }
  9870. } catch (error) {
  9871. throwError(error, 'SweepWidget.after');
  9872. }
  9873. }
  9874. init() {
  9875. try {
  9876. const logStatus = scripts_echoLog({
  9877. text: i18n('initing')
  9878. });
  9879. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9880. logStatus.warning(i18n('needLogin'));
  9881. return false;
  9882. }
  9883. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9884. return false;
  9885. }
  9886. this.initialized = true;
  9887. logStatus.success();
  9888. return true;
  9889. } catch (error) {
  9890. throwError(error, 'SweepWidget.init');
  9891. return false;
  9892. }
  9893. }
  9894. classifyTask() {
  9895. return true;
  9896. }
  9897. async doTask() {
  9898. try {
  9899. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9900. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9901. $('input[name="sw__login_name"]').val(this.options.username);
  9902. }
  9903. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9904. $('input[name="sw__login_email"]').val(this.options.email);
  9905. }
  9906. if ($('#sw_login_button:visible').length > 0) {
  9907. $('#sw_login_button')[0].click();
  9908. }
  9909. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9910. return false;
  9911. }
  9912. }
  9913. const logStatus = scripts_echoLog({
  9914. text: i18n('SweepWidgetNotice')
  9915. });
  9916. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9917. for (const task of tasks) {
  9918. var _aElement$, _$task$find$removeAtt;
  9919. const $task = $(task);
  9920. if ($task.find('i.fa-check:visible').length > 0) {
  9921. continue;
  9922. }
  9923. const title = $task.find('.sw_text_inner');
  9924. title[0].click();
  9925. const aElement = $task.find('a.sw_link');
  9926. const link = aElement.attr('href');
  9927. aElement.attr('href', '#a').attr('target', '_self');
  9928. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9929. await delay(300);
  9930. aElement.attr('href', link).attr('target', '_blank');
  9931. $task.find('input[type="text"]').val('test');
  9932. const verifyBtn = $task.find('input.sw_verify');
  9933. if (verifyBtn.prop('disabled') === true) {
  9934. title[0].click();
  9935. await delay(300);
  9936. title[0].click();
  9937. await delay(300);
  9938. }
  9939. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9940. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9941. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9942. }
  9943. logStatus.success();
  9944. return true;
  9945. } catch (error) {
  9946. throwError(error, 'SweepWidget.doTask');
  9947. return false;
  9948. }
  9949. }
  9950. }
  9951. function SweepWidget_checkLogin2() {
  9952. try {
  9953. if ($('#twitter_login_button').length > 0) {
  9954. $('#twitter_login_button')[0].click();
  9955. }
  9956. return true;
  9957. } catch (error) {
  9958. throwError(error, 'SweepWidget.checkLogin');
  9959. return false;
  9960. }
  9961. }
  9962. function SweepWidget_getGiveawayId2() {
  9963. try {
  9964. var _window$location$href;
  9965. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9966. if (giveawayId) {
  9967. this.giveawayId = giveawayId;
  9968. return true;
  9969. }
  9970. scripts_echoLog({
  9971. text: i18n('getFailed', 'GiveawayId')
  9972. });
  9973. return false;
  9974. } catch (error) {
  9975. throwError(error, 'SweepWidget.getGiveawayId');
  9976. return false;
  9977. }
  9978. }
  9979. async function _checkEnter2() {
  9980. try {
  9981. return new Promise(resolve => {
  9982. const checker = setInterval(() => {
  9983. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9984. clearInterval(checker);
  9985. resolve(true);
  9986. }
  9987. });
  9988. });
  9989. } catch (error) {
  9990. throwError(error, 'SweepWidget.checkEnter');
  9991. return false;
  9992. }
  9993. }
  9994. async function _checkFinish2($task) {
  9995. try {
  9996. return new Promise(resolve => {
  9997. const checker = setInterval(() => {
  9998. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9999. clearInterval(checker);
  10000. resolve(true);
  10001. }
  10002. });
  10003. });
  10004. } catch (error) {
  10005. throwError(error, 'SweepWidget.checkFinish');
  10006. return false;
  10007. }
  10008. }
  10009. const website_SweepWidget = SweepWidget;
  10010. const defaultWhiteList = {
  10011. discord: {
  10012. servers: []
  10013. },
  10014. instagram: {
  10015. users: []
  10016. },
  10017. twitch: {
  10018. channels: []
  10019. },
  10020. twitter: {
  10021. users: [],
  10022. retweets: [],
  10023. likes: []
  10024. },
  10025. vk: {
  10026. names: []
  10027. },
  10028. youtube: {
  10029. channels: [],
  10030. likes: []
  10031. },
  10032. reddit: {
  10033. reddits: []
  10034. },
  10035. steam: {
  10036. groups: [],
  10037. officialGroups: [],
  10038. wishlists: [],
  10039. follows: [],
  10040. forums: [],
  10041. workshops: [],
  10042. curators: [],
  10043. workshopVotes: [],
  10044. curatorLikes: [],
  10045. announcements: [],
  10046. licenses: [],
  10047. playtests: []
  10048. }
  10049. };
  10050. const link2id = async function(type) {
  10051. 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;
  10052. try {
  10053. const link = $('#socialLink').val();
  10054. let id = '';
  10055. switch (type) {
  10056. case 'discord.servers':
  10057. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10058. break;
  10059.  
  10060. case 'instagram.users':
  10061. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10062. break;
  10063.  
  10064. case 'twitch.channels':
  10065. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10066. break;
  10067.  
  10068. case 'twitter.users':
  10069. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10070. break;
  10071.  
  10072. case 'twitter.retweets':
  10073. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10074. break;
  10075.  
  10076. case 'vk.names':
  10077. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10078. break;
  10079.  
  10080. case 'youtube.channels':
  10081. 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) || '';
  10082. break;
  10083.  
  10084. case 'youtube.likes':
  10085. 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) || '';
  10086. break;
  10087.  
  10088. case 'reddit.reddits':
  10089. 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]) || '';
  10090. break;
  10091.  
  10092. case 'steam.groups':
  10093. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10094. break;
  10095.  
  10096. case 'steam.wishlists':
  10097. case 'steam.follows':
  10098. case 'steam.forums':
  10099. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10100. break;
  10101.  
  10102. case 'steam.workshops':
  10103. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10104. break;
  10105.  
  10106. case 'steam.curators':
  10107. {
  10108. if (link.includes('curator')) {
  10109. var _link$match12;
  10110. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10111. } else {
  10112. var _link$match13;
  10113. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10114. if (!param || param.length !== 2) {
  10115. break;
  10116. }
  10117. const steam = new social_Steam();
  10118. if (await steam.init()) {
  10119. id = await steam.getCuratorId(param[0], param[1]) || '';
  10120. }
  10121. }
  10122. }
  10123. break;
  10124. }
  10125. return id;
  10126. } catch (error) {
  10127. throwError(error, 'link2id');
  10128. return i18n('getFailed', 'id');
  10129. }
  10130. };
  10131. const disabledType = {
  10132. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10133. twitter: [ 'likes' ]
  10134. };
  10135. const assignWhiteList = whiteList => {
  10136. try {
  10137. const newWhiteList = {};
  10138. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10139. newWhiteList[key] = {
  10140. ...value,
  10141. ...whiteList[key]
  10142. };
  10143. }
  10144. return newWhiteList;
  10145. } catch (error) {
  10146. throwError(error, 'assignWhiteList');
  10147. return defaultWhiteList;
  10148. }
  10149. };
  10150. const whiteListOptions = function(showType) {
  10151. try {
  10152. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10153. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10154. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10155. for (const [ social, types ] of Object.entries(whiteList)) {
  10156. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10157. var _disabledType$social;
  10158. 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>`;
  10159. }).join('');
  10160. }
  10161. whiteListOptionsForm += '</tbody></table></form>';
  10162. if (showType === 'swal') {
  10163. external_Swal_default().fire({
  10164. title: i18n('whiteListOptions'),
  10165. html: whiteListOptionsForm,
  10166. showConfirmButton: false,
  10167. showCloseButton: true
  10168. });
  10169. } else {
  10170. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10171. }
  10172. $('.editWhiteList').on('click', function() {
  10173. var _whiteList$social;
  10174. const value = $(this).attr('data-value');
  10175. if (!value) {
  10176. return;
  10177. }
  10178. const [ social, type ] = value.split('.');
  10179. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10180. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10181. return;
  10182. }
  10183. external_Swal_default().fire({
  10184. title: i18n('changeWhiteListOption', value),
  10185. input: 'textarea',
  10186. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10187. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10188. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10189. inputValue: whiteList[social][type].join('\n'),
  10190. showConfirmButton: true,
  10191. confirmButtonText: i18n('save'),
  10192. showCancelButton: true,
  10193. cancelButtonText: i18n('close'),
  10194. showDenyButton: true,
  10195. denyButtonText: i18n('return')
  10196. }).then(_ref => {
  10197. let {
  10198. isDenied,
  10199. isConfirmed,
  10200. value
  10201. } = _ref;
  10202. if (isDenied) {
  10203. if (showType === 'swal') {
  10204. whiteListOptions(showType);
  10205. }
  10206. return;
  10207. } else if (isConfirmed) {
  10208. whiteList[social][type] = value.split('\n');
  10209. GM_setValue('whiteList', whiteList);
  10210. external_Swal_default().fire({
  10211. title: i18n('changeWhiteListSuccess'),
  10212. icon: 'success'
  10213. });
  10214. }
  10215. });
  10216. $('#link2id').on('click', async function() {
  10217. const type = $(this).attr('data-type');
  10218. $('#socialLink').val(await link2id(type));
  10219. });
  10220. });
  10221. } catch (error) {
  10222. throwError(error, 'whiteListOptions');
  10223. }
  10224. };
  10225. const whiteList = whiteListOptions;
  10226. const setGistData = async (token, gistId, fileName, content) => {
  10227. try {
  10228. const logStatus = scripts_echoLog({
  10229. text: i18n('settingData')
  10230. });
  10231. const contentData = JSON.stringify({
  10232. files: {
  10233. [fileName]: {
  10234. content: JSON.stringify(content)
  10235. }
  10236. }
  10237. });
  10238. const {
  10239. result,
  10240. statusText,
  10241. status,
  10242. data
  10243. } = await tools_httpRequest({
  10244. url: `https://api.github.com/gists/${gistId}`,
  10245. headers: {
  10246. Accept: 'application/vnd.github.v3+json',
  10247. Authorization: `token ${token}`
  10248. },
  10249. data: contentData,
  10250. responseType: 'json',
  10251. method: 'POST',
  10252. timeout: 3e4
  10253. });
  10254. if (result === 'Success') {
  10255. var _data$response$files, _data$response$files$;
  10256. 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)) {
  10257. logStatus.success();
  10258. return true;
  10259. }
  10260. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10261. return false;
  10262. }
  10263. logStatus.error(`${result}:${statusText}(${status})`);
  10264. return false;
  10265. } catch (error) {
  10266. throwError(error, 'setGistData');
  10267. return false;
  10268. }
  10269. };
  10270. const getGistData = async function(token, gistId, fileName) {
  10271. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10272. try {
  10273. const logStatus = scripts_echoLog({
  10274. text: i18n('gettingData')
  10275. });
  10276. const {
  10277. result,
  10278. statusText,
  10279. status,
  10280. data
  10281. } = await tools_httpRequest({
  10282. url: `https://api.github.com/gists/${gistId}`,
  10283. headers: {
  10284. Accept: 'application/vnd.github.v3+json',
  10285. Authorization: `token ${token}`
  10286. },
  10287. responseType: 'json',
  10288. method: 'GET',
  10289. timeout: 3e4
  10290. });
  10291. if (result === 'Success') {
  10292. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10293. var _data$response, _data$response$files2, _data$response$files3;
  10294. 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;
  10295. let formatedContent;
  10296. if (!content) {
  10297. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10298. return false;
  10299. }
  10300. if (test) {
  10301. logStatus.success();
  10302. return true;
  10303. }
  10304. try {
  10305. formatedContent = JSON.parse(content);
  10306. } catch (error) {
  10307. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10308. return false;
  10309. }
  10310. logStatus.success();
  10311. return formatedContent;
  10312. }
  10313. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10314. return false;
  10315. }
  10316. logStatus.error(`${result}:${statusText}(${status})`);
  10317. return false;
  10318. } catch (error) {
  10319. throwError(error, 'getGistData');
  10320. return false;
  10321. }
  10322. };
  10323. const syncOptions = () => {
  10324. try {
  10325. const {
  10326. TOKEN,
  10327. GIST_ID,
  10328. FILE_NAME,
  10329. SYNC_HISTORY
  10330. } = GM_getValue('gistOptions') || {
  10331. TOKEN: '',
  10332. GIST_ID: '',
  10333. FILE_NAME: '',
  10334. SYNC_HISTORY: true
  10335. };
  10336. external_Swal_default().fire({
  10337. title: i18n('gistOptions'),
  10338. 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;">
  10339. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10340. ${i18n('downloadFromGist')}</button></p>`,
  10341. focusConfirm: false,
  10342. showLoaderOnConfirm: true,
  10343. 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>`,
  10344. preConfirm: async () => {
  10345. const token = $('#github-token').val();
  10346. const gistId = $('#gist-id').val();
  10347. const fileName = $('#file-name').val();
  10348. const syncHistory = $('#sync-history').prop('checked');
  10349. GM_setValue('gistOptions', {
  10350. TOKEN: token,
  10351. GIST_ID: gistId,
  10352. FILE_NAME: fileName,
  10353. SYNC_HISTORY: syncHistory
  10354. });
  10355. return await getGistData(token, gistId, fileName, true);
  10356. },
  10357. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10358. confirmButtonText: i18n('saveAndTest'),
  10359. showCancelButton: true,
  10360. cancelButtonText: i18n('close')
  10361. }).then(_ref => {
  10362. let {
  10363. value
  10364. } = _ref;
  10365. if (value) {
  10366. external_Swal_default().fire({
  10367. icon: 'success',
  10368. title: i18n('testSuccess')
  10369. }).then(syncOptions);
  10370. } else if (value !== undefined) {
  10371. external_Swal_default().fire({
  10372. icon: 'error',
  10373. title: i18n('testFailed')
  10374. }).then(syncOptions);
  10375. }
  10376. });
  10377. $('#upload-data').on('click', async () => {
  10378. const {
  10379. TOKEN,
  10380. GIST_ID,
  10381. FILE_NAME
  10382. } = GM_getValue('gistOptions') || {};
  10383. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10384. return external_Swal_default().fire({
  10385. icon: 'error',
  10386. title: i18n('saveAndTestNotice')
  10387. }).then(syncOptions);
  10388. }
  10389. external_Swal_default().fire({
  10390. icon: 'info',
  10391. title: i18n('processingData')
  10392. });
  10393. const data = {};
  10394. const names = GM_listValues();
  10395. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10396. for (const name of names) {
  10397. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10398. continue;
  10399. }
  10400. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10401. continue;
  10402. }
  10403. data[name] = GM_getValue(name);
  10404. }
  10405. external_Swal_default().update({
  10406. icon: 'info',
  10407. title: i18n('updatingData')
  10408. });
  10409. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10410. external_Swal_default().fire({
  10411. icon: 'success',
  10412. title: i18n('syncDataSuccess')
  10413. });
  10414. } else {
  10415. external_Swal_default().fire({
  10416. icon: 'error',
  10417. title: i18n('syncDataFailed')
  10418. });
  10419. }
  10420. });
  10421. $('#download-data').on('click', async () => {
  10422. const {
  10423. TOKEN,
  10424. GIST_ID,
  10425. FILE_NAME
  10426. } = GM_getValue('gistOptions') || {};
  10427. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10428. return external_Swal_default().fire({
  10429. icon: 'error',
  10430. title: i18n('saveAndTestNotice')
  10431. }).then(syncOptions);
  10432. }
  10433. external_Swal_default().fire({
  10434. icon: 'info',
  10435. title: i18n('downloadingData')
  10436. });
  10437. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10438. if (!data) {
  10439. return external_Swal_default().fire({
  10440. icon: 'error',
  10441. title: i18n('checkedNoData')
  10442. }).then(syncOptions);
  10443. }
  10444. external_Swal_default().update({
  10445. icon: 'info',
  10446. title: i18n('savingData')
  10447. });
  10448. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10449. for (const [ name, value ] of Object.entries(data)) {
  10450. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10451. continue;
  10452. }
  10453. GM_setValue(name, value);
  10454. }
  10455. external_Swal_default().fire({
  10456. icon: 'success',
  10457. title: i18n('syncDataSuccess')
  10458. });
  10459. });
  10460. } catch (error) {
  10461. throwError(error, 'syncOptions');
  10462. }
  10463. };
  10464. const dataSync = syncOptions;
  10465. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10466. Setting_checkPrivateRedeclaration(obj, privateSet);
  10467. privateSet.add(obj);
  10468. }
  10469. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10470. if (privateCollection.has(obj)) {
  10471. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10472. }
  10473. }
  10474. function Setting_defineProperty(obj, key, value) {
  10475. if (key in obj) {
  10476. Object.defineProperty(obj, key, {
  10477. value: value,
  10478. enumerable: true,
  10479. configurable: true,
  10480. writable: true
  10481. });
  10482. } else {
  10483. obj[key] = value;
  10484. }
  10485. return obj;
  10486. }
  10487. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10488. if (!privateSet.has(receiver)) {
  10489. throw new TypeError('attempted to get private field on non-instance');
  10490. }
  10491. return fn;
  10492. }
  10493. var Setting_getId = new WeakSet();
  10494. var _environment = new WeakSet();
  10495. class Setting {
  10496. constructor() {
  10497. Setting_classPrivateMethodInitSpec(this, _environment);
  10498. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10499. Setting_defineProperty(this, 'name', 'Setting');
  10500. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10501. Setting_defineProperty(this, 'syncData', dataSync);
  10502. }
  10503. tasksHistory() {
  10504. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10505. }
  10506. static test() {
  10507. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10508. }
  10509. before() {
  10510. $('body').html('').addClass('auto-task-options');
  10511. }
  10512. after() {
  10513. try {
  10514. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10515. changeGlobalOptions('page');
  10516. whiteList('page');
  10517. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10518. $('#getTwitterUserId').on('click', () => {
  10519. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10520. });
  10521. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10522. $('#getYoutubeChannelId').on('click', () => {
  10523. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10524. });
  10525. $('input[name^="position"]').on('input', function() {
  10526. const type = $(this).attr('name').replace('position.', '');
  10527. const xLabel = 'rightleft';
  10528. const yLabel = 'topbottpm';
  10529. switch (type) {
  10530. case 'buttonSideX':
  10531. case 'buttonSideY':
  10532. case 'buttonDistance':
  10533. {
  10534. const distance = $('input[name="position.buttonDistance"]').val();
  10535. const sideX = $('input[name="position.buttonSideX"]').val();
  10536. const sideY = $('input[name="position.buttonSideY"]').val();
  10537. if (![ 'right', 'left' ].includes(sideX)) {
  10538. break;
  10539. }
  10540. if (![ 'top', 'bottom' ].includes(sideY)) {
  10541. break;
  10542. }
  10543. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10544. break;
  10545. }
  10546. const distanceArr = distance.split(',');
  10547. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10548. break;
  10549. }
  10550.  
  10551. case 'showButtonSideX':
  10552. case 'showButtonSideY':
  10553. case 'showButtonDistance':
  10554. {
  10555. const distance = $('input[name="position.showButtonDistance"]').val();
  10556. const sideX = $('input[name="position.showButtonSideX"]').val();
  10557. const sideY = $('input[name="position.showButtonSideY"]').val();
  10558. if (![ 'right', 'left' ].includes(sideX)) {
  10559. break;
  10560. }
  10561. if (![ 'top', 'bottom' ].includes(sideY)) {
  10562. break;
  10563. }
  10564. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10565. break;
  10566. }
  10567. const distanceArr = distance.split(',');
  10568. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10569. break;
  10570. }
  10571.  
  10572. case 'logSideX':
  10573. case 'logSideY':
  10574. case 'logDistance':
  10575. {
  10576. const distance = $('input[name="position.logDistance"]').val();
  10577. const sideX = $('input[name="position.logSideX"]').val();
  10578. const sideY = $('input[name="position.logSideY"]').val();
  10579. if (![ 'right', 'left' ].includes(sideX)) {
  10580. break;
  10581. }
  10582. if (![ 'top', 'bottom' ].includes(sideY)) {
  10583. break;
  10584. }
  10585. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10586. break;
  10587. }
  10588. const distanceArr = distance.split(',');
  10589. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10590. break;
  10591. }
  10592.  
  10593. default:
  10594. break;
  10595. }
  10596. });
  10597. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10598. let functionKey = '';
  10599. if (event.altKey) {
  10600. functionKey += 'alt + ';
  10601. } else if (event.ctrlKey) {
  10602. functionKey += 'ctrl + ';
  10603. } else if (event.shiftKey) {
  10604. functionKey += 'shift + ';
  10605. }
  10606. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10607. });
  10608. } catch (error) {
  10609. throwError(error, 'Setting.after');
  10610. }
  10611. }
  10612. saveGlobalOptions() {
  10613. saveData();
  10614. }
  10615. }
  10616. function Setting_getId2(social) {
  10617. try {
  10618. external_Swal_default().fire({
  10619. title: i18n('getId', i18n(social)),
  10620. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10621. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10622. showCancelButton: true,
  10623. cancelButtonText: i18n('close'),
  10624. showConfirmButton: false
  10625. });
  10626. $('#link2id').on('click', async function() {
  10627. const link = $('#socialLink').val();
  10628. if (!link) {
  10629. return;
  10630. }
  10631. const type = $(this).attr('data-type');
  10632. if (type === 'twitterUser') {
  10633. var _link$match;
  10634. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10635. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10636. } else if (type === 'youtubeChannel') {
  10637. var _link$match2, _await$getInfo, _await$getInfo$params;
  10638. 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;
  10639. $('#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) || '');
  10640. }
  10641. });
  10642. } catch (error) {
  10643. throwError(error, 'Setting.getId');
  10644. }
  10645. }
  10646. function _environment2() {
  10647. try {
  10648. const userAgent = (0, javascript_utils_umd_min.ua)();
  10649. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10650. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10651. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10652. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10653. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10654. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10655. </tbody></table></form>`;
  10656. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10657. } catch (error) {
  10658. throwError(error, 'Setting.environment');
  10659. }
  10660. }
  10661. const website_Setting = Setting;
  10662. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10663. History_checkPrivateRedeclaration(obj, privateSet);
  10664. privateSet.add(obj);
  10665. }
  10666. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10667. if (privateCollection.has(obj)) {
  10668. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10669. }
  10670. }
  10671. function History_defineProperty(obj, key, value) {
  10672. if (key in obj) {
  10673. Object.defineProperty(obj, key, {
  10674. value: value,
  10675. enumerable: true,
  10676. configurable: true,
  10677. writable: true
  10678. });
  10679. } else {
  10680. obj[key] = value;
  10681. }
  10682. return obj;
  10683. }
  10684. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10685. if (!privateSet.has(receiver)) {
  10686. throw new TypeError('attempted to get private field on non-instance');
  10687. }
  10688. return fn;
  10689. }
  10690. var _addItem = new WeakSet();
  10691. class History extends website_Keylol {
  10692. constructor() {
  10693. super(...arguments);
  10694. History_classPrivateMethodInitSpec(this, _addItem);
  10695. History_defineProperty(this, 'name', 'History');
  10696. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10697. }
  10698. static test() {
  10699. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10700. }
  10701. before() {
  10702. try {
  10703. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10704. const data = GM_listValues() || [];
  10705. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10706. for (const item of tasksHistory) {
  10707. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10708. }
  10709. } catch (error) {
  10710. throwError(error, 'History.before');
  10711. }
  10712. }
  10713. clearHistory() {
  10714. try {
  10715. const data = GM_listValues() || [];
  10716. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10717. for (const item of tasksHistory) {
  10718. GM_deleteValue(item);
  10719. }
  10720. external_Swal_default().fire({
  10721. title: i18n('clearHistoryFinished'),
  10722. icon: 'success'
  10723. });
  10724. } catch (error) {
  10725. throwError(error, 'History.after');
  10726. }
  10727. }
  10728. }
  10729. function _addItem2(item) {
  10730. try {
  10731. const tasksData = GM_getValue(item);
  10732. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10733. return;
  10734. }
  10735. let html = '';
  10736. let title = '';
  10737. let link = '';
  10738. const [ website, id ] = item.split('-');
  10739. switch (website) {
  10740. case 'fawTasks':
  10741. title = `Freeanywhere[${id}]`;
  10742. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10743. break;
  10744.  
  10745. case 'gasTasks':
  10746. title = `Giveawaysu[${id}]`;
  10747. link = `https://giveaway.su/giveaway/view/${id}`;
  10748. break;
  10749.  
  10750. case 'gcTasks':
  10751. title = `GiveeClub[${id}]`;
  10752. link = `https://givee.club/event/${id}`;
  10753. break;
  10754.  
  10755. case 'gkTasks':
  10756. title = `Givekey[${id}]`;
  10757. link = `https://givekey.ru/giveaway/${id}`;
  10758. break;
  10759.  
  10760. case 'gleamTasks':
  10761. title = `Gleam[${id}]`;
  10762. link = `https://gleam.io${id}`;
  10763. break;
  10764.  
  10765. case 'khTasks':
  10766. title = `keyhub[${id}]`;
  10767. link = `https://key-hub.eu/giveaway/${id}`;
  10768. break;
  10769.  
  10770. case 'prysTasks':
  10771. title = `Prys[${id}]`;
  10772. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10773. break;
  10774.  
  10775. default:
  10776. return;
  10777. }
  10778. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10779. for (const [ type, tasks ] of Object.entries(types)) {
  10780. for (const task of tasks) {
  10781. 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>`;
  10782. }
  10783. }
  10784. }
  10785. $('.container').append(`<div class="card"><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>`);
  10786. $('span.delete-task').on('click', function() {
  10787. const itemName = $(this).attr('data-name');
  10788. if (itemName) {
  10789. GM_deleteValue(itemName);
  10790. external_Swal_default().fire({
  10791. title: i18n('clearTaskFinished'),
  10792. text: itemName,
  10793. icon: 'success'
  10794. });
  10795. } else {
  10796. external_Swal_default().fire({
  10797. title: i18n('clearTaskFailed'),
  10798. icon: 'error'
  10799. });
  10800. }
  10801. });
  10802. } catch (error) {
  10803. throwError(error, 'History.addItem');
  10804. }
  10805. }
  10806. const website_History = History;
  10807. 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 ];
  10808. const websiteOptions = function(website, options) {
  10809. try {
  10810. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10811. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10812. for (const [ option, value ] of Object.entries(options)) {
  10813. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10814. }
  10815. websiteOptionsForm += '</tbody></table></form>';
  10816. external_Swal_default().fire({
  10817. title: i18n('websiteOptions'),
  10818. html: websiteOptionsForm,
  10819. showConfirmButton: true,
  10820. confirmButtonText: i18n('save'),
  10821. showCancelButton: true,
  10822. cancelButtonText: i18n('close')
  10823. }).then(_ref => {
  10824. let {
  10825. isConfirmed
  10826. } = _ref;
  10827. if (isConfirmed) {
  10828. $('#websiteOptionsForm').serializeArray().map(value => {
  10829. options[value.name] = value.value;
  10830. return value;
  10831. });
  10832. GM_setValue(`${website}Options`, options);
  10833. external_Swal_default().fire({
  10834. title: i18n('changeWebsiteOptionsSuccess'),
  10835. icon: 'success'
  10836. });
  10837. }
  10838. });
  10839. } catch (error) {
  10840. throwError(error, 'websiteOptions');
  10841. }
  10842. };
  10843. const options = websiteOptions;
  10844. const external_keyboardJS_namespaceObject = keyboardJS;
  10845. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10846. const checkUpdate = async (updateLink, auto) => {
  10847. try {
  10848. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10849. const {
  10850. result,
  10851. statusText,
  10852. status,
  10853. data
  10854. } = await tools_httpRequest({
  10855. url: checkUrl,
  10856. responseType: 'json',
  10857. method: 'GET',
  10858. timeout: 3e4
  10859. });
  10860. if (result === 'Success') {
  10861. var _data$response;
  10862. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10863. return data.response;
  10864. }
  10865. if (!auto) {
  10866. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10867. }
  10868. return false;
  10869. }
  10870. if (!auto) {
  10871. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10872. }
  10873. return false;
  10874. } catch (error) {
  10875. throwError(error, 'checkUpdate');
  10876. return false;
  10877. }
  10878. };
  10879. const hasNewVersion = (currentVersion, remoteVersion) => {
  10880. try {
  10881. const [ currentRealVersion ] = currentVersion.split('-');
  10882. const [ remoteRealVersion ] = remoteVersion.split('-');
  10883. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10884. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10885. if (remoteVersion1 > currentVersion1) {
  10886. return true;
  10887. }
  10888. if (remoteVersion1 < currentVersion1) {
  10889. return false;
  10890. }
  10891. if (remoteVersion2 > currentVersion2) {
  10892. return true;
  10893. }
  10894. if (remoteVersion2 < currentVersion2) {
  10895. return false;
  10896. }
  10897. if (remoteVersion3 > currentVersion3) {
  10898. return true;
  10899. }
  10900. return false;
  10901. } catch (error) {
  10902. throwError(error, 'compareVersion');
  10903. return false;
  10904. }
  10905. };
  10906. const updateChecker = async () => {
  10907. try {
  10908. const currentVersion = GM_info.script.version;
  10909. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10910. const updateLinks = {
  10911. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10912. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10913. standby: 'https://auto-task-v4.hclonely.com/'
  10914. };
  10915. let version;
  10916. let updateLink = '';
  10917. let packageData;
  10918. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10919. updateLink = updateLinks[updateSource];
  10920. packageData = await checkUpdate(updateLink, false);
  10921. } else {
  10922. updateLink = updateLinks.github;
  10923. packageData = await checkUpdate(updateLink, true);
  10924. if (!packageData) {
  10925. updateLink = updateLinks.jsdelivr;
  10926. packageData = await checkUpdate(updateLink, true);
  10927. if (!packageData) {
  10928. updateLink = updateLinks.standby;
  10929. packageData = await checkUpdate(updateLink, true);
  10930. }
  10931. }
  10932. }
  10933. if (packageData) {
  10934. version = packageData.version || currentVersion;
  10935. } else {
  10936. version = currentVersion;
  10937. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10938. }
  10939. if (packageData && hasNewVersion(currentVersion, version)) {
  10940. var _packageData$change;
  10941. scripts_echoLog({
  10942. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10943. });
  10944. scripts_echoLog({
  10945. 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('')}</ol>`
  10946. });
  10947. }
  10948. } catch (error) {
  10949. throwError(error, 'updateChecker');
  10950. }
  10951. };
  10952. const scripts_updateChecker = updateChecker;
  10953. var _globalOptions$other, _globalOptions$other2;
  10954. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  10955. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  10956. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  10957. const loadScript = async () => {
  10958. var _website, _website2, _website3, _website4, _website5, _website6;
  10959. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10960. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10961. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10962. if (isLogin) {
  10963. var _commonOptions, _commonOptions$header;
  10964. GM_setValue('twitchAuth', {
  10965. authToken: authToken,
  10966. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10967. });
  10968. window.close();
  10969. external_Swal_default().fire('', i18n('closePageNotice'));
  10970. } else {
  10971. external_Swal_default().fire('', i18n('needLogin'));
  10972. }
  10973. return;
  10974. }
  10975. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10976. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10977. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10978. if (isLogin && ct0) {
  10979. GM_setValue('twitterAuth', {
  10980. ct0: ct0
  10981. });
  10982. window.close();
  10983. external_Swal_default().fire('', i18n('closePageNotice'));
  10984. } else {
  10985. external_Swal_default().fire('', i18n('needLogin'));
  10986. }
  10987. return;
  10988. }
  10989. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10990. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10991. if (PAPISID) {
  10992. GM_setValue('youtubeAuth', {
  10993. PAPISID: PAPISID
  10994. });
  10995. window.close();
  10996. external_Swal_default().fire('', i18n('closePageNotice'));
  10997. } else {
  10998. external_Swal_default().fire('', i18n('needLogin'));
  10999. }
  11000. return;
  11001. }
  11002. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11003. const betaButton = $('#redesign-beta-optin-btn');
  11004. if (betaButton.length > 0) {
  11005. GM_setValue('redditAuth', '#auth');
  11006. return betaButton[0].click();
  11007. }
  11008. GM_setValue('redditAuth', null);
  11009. window.close();
  11010. external_Swal_default().fire('', i18n('closePageNotice'));
  11011. return;
  11012. }
  11013. let website;
  11014. for (const Website of Websites) {
  11015. if (Website.test()) {
  11016. website = new Website();
  11017. break;
  11018. }
  11019. }
  11020. if (!website) {
  11021. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11022. return;
  11023. }
  11024. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11025. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11026. }
  11027. $('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>`);
  11028. $('div.show-button-div').on('click', () => {
  11029. $('#auto-task-buttons').show();
  11030. $('div.show-button-div').hide();
  11031. });
  11032. const toggleLog = () => {
  11033. const $this = $('#toggle-log');
  11034. const status = $this.attr('data-status');
  11035. if (status === 'show') {
  11036. $('#auto-task-info').hide();
  11037. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11038. } else {
  11039. $('#auto-task-info').show();
  11040. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11041. }
  11042. };
  11043. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11044. if (website.doTask) {
  11045. website.doTask();
  11046. }
  11047. });
  11048. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11049. if (website.undoTask) {
  11050. website.doTask();
  11051. }
  11052. });
  11053. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11054. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11055. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11056. }
  11057. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11058. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11059. for (const button of website.buttons) {
  11060. if (website[button]) {
  11061. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11062. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11063. website[button]();
  11064. });
  11065. $('#auto-task-buttons').append(btnElement);
  11066. }
  11067. }
  11068. }
  11069. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11070. ${i18n('hideButton')}</a></p>`);
  11071. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11072. $('#auto-task-buttons').hide();
  11073. $('div.show-button-div').show();
  11074. });
  11075. 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'}">
  11076. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11077. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11078. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11079. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11080. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11081. options(website.name, website.options);
  11082. });
  11083. }
  11084. if (website.name !== 'Setting') {
  11085. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11086. changeGlobalOptions('swal');
  11087. });
  11088. GM_registerMenuCommand(i18n('settingPage'), () => {
  11089. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11090. });
  11091. }
  11092. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11093. if (!GM_getValue('notice')) {
  11094. var _echoLog$font;
  11095. external_Swal_default().fire({
  11096. title: i18n('swalNotice'),
  11097. icon: 'warning'
  11098. }).then(() => {
  11099. window.open(i18n('noticeLink'), '_blank');
  11100. GM_setValue('notice', new Date().getTime());
  11101. });
  11102. (_echoLog$font = scripts_echoLog({
  11103. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11104. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11105. GM_setValue('notice', new Date().getTime());
  11106. });
  11107. }
  11108. scripts_updateChecker();
  11109. };
  11110. if (window.location.hostname === 'discord.com') {
  11111. const LocalStorage = window.localStorage;
  11112. if (window.location.hash === '#auth') {
  11113. var _LocalStorage$getItem;
  11114. window.localStorage.removeItem = () => true;
  11115. 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, '');
  11116. if (discordAuth && discordAuth.length > 0) {
  11117. GM_setValue('discordAuth', {
  11118. auth: discordAuth
  11119. });
  11120. window.close();
  11121. external_Swal_default().fire('', i18n('closePageNotice'));
  11122. } else {
  11123. external_Swal_default().fire({
  11124. text: i18n('getDiscordAuthFailed'),
  11125. icon: 'error'
  11126. });
  11127. }
  11128. } else {
  11129. var _LocalStorage$getItem2;
  11130. 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, '');
  11131. if (discordAuth && discordAuth.length > 0) {
  11132. GM_setValue('discordAuth', {
  11133. auth: discordAuth
  11134. });
  11135. }
  11136. }
  11137. } else if (window.location.hostname === 'opquests.com') {
  11138. loadScript();
  11139. } else {
  11140. $(loadScript);
  11141. }
  11142. }();
  11143. })();