auto-task-v4

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

当前为 2022-01-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.0
  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脚本开始加载');
  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. try {
  557. const result = await new Promise(resolve => {
  558. if (options.dataType) {
  559. options.responseType = options.dataType;
  560. }
  561. const requestObj = {
  562. ...{
  563. timeout: 3e4,
  564. ontimeout(data) {
  565. resolve({
  566. result: 'Error',
  567. statusText: 'Timeout',
  568. status: 601,
  569. data: data,
  570. options: options
  571. });
  572. },
  573. onabort(data) {
  574. resolve({
  575. result: 'Error',
  576. statusText: 'Aborted',
  577. status: 602,
  578. data: data,
  579. options: options
  580. });
  581. },
  582. onerror(data) {
  583. resolve({
  584. result: 'Error',
  585. statusText: 'Error',
  586. status: 603,
  587. data: data,
  588. options: options
  589. });
  590. },
  591. onload(data) {
  592. resolve({
  593. result: 'Success',
  594. statusText: 'Load',
  595. status: 600,
  596. data: data,
  597. options: options
  598. });
  599. }
  600. },
  601. ...options
  602. };
  603. GM_xmlhttpRequest(requestObj);
  604. });
  605. console.log('发送请求:', result);
  606. if (result.status !== 600 && times < 2) {
  607. return await httpRequest(options, times + 1);
  608. }
  609. return result;
  610. } catch (error) {
  611. throwError(error, 'httpRequest');
  612. console.log('发送请求:', {
  613. errorMsg: error,
  614. options: options
  615. });
  616. return {
  617. result: 'JsError',
  618. statusText: 'Error',
  619. status: 604,
  620. error: error,
  621. options: options
  622. };
  623. }
  624. };
  625. const tools_httpRequest = httpRequest;
  626. const echoLog = _ref => {
  627. let {
  628. type,
  629. text,
  630. html,
  631. id
  632. } = _ref;
  633. const emptyStatus = {
  634. success: () => emptyStatus,
  635. error: () => emptyStatus,
  636. warning: () => emptyStatus,
  637. info: () => emptyStatus,
  638. view: () => emptyStatus
  639. };
  640. try {
  641. var _ele$;
  642. let ele;
  643. if (type) {
  644. switch (type) {
  645. case 'joiningSteamGroup':
  646. case 'leavingSteamGroup':
  647. case 'gettingSteamGroupId':
  648. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>...<font></font></li>`);
  649. break;
  650.  
  651. case 'joiningSteamOfficialGroup':
  652. case 'leavingSteamOfficialGroup':
  653. case 'gettingSteamOfficialGroupId':
  654. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/games/${text}" target="_blank">${text}</a>...<font></font></li>`);
  655. break;
  656.  
  657. case 'subscribingForum':
  658. case 'unsubscribingForum':
  659. case 'gettingForumId':
  660. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>...<font></font></li>`);
  661. break;
  662.  
  663. case 'followingCurator':
  664. case 'unfollowingCurator':
  665. case 'getCuratorId':
  666. 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>`);
  667. break;
  668.  
  669. case 'addingToWishlist':
  670. case 'removingFromWishlist':
  671. case 'followingGame':
  672. case 'unfollowingGame':
  673. case 'gettingSubid':
  674. case 'addingFreeLicense':
  675. case 'requestingPlayTestAccess':
  676. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>...<font></font></li>`);
  677. break;
  678.  
  679. case 'addingFreeLicenseSubid':
  680. ele = $(`<li>${i18n('addingFreeLicense')}<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  681. break;
  682.  
  683. case 'favoritingWorkshop':
  684. case 'unfavoritingWorkshop':
  685. case 'gettingWorkshopAppId':
  686. case 'votingUpWorkshop':
  687. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  688. ${text}</a>...<font></font></li>`);
  689. break;
  690.  
  691. case 'gettingAnnouncementParams':
  692. case 'likingAnnouncement':
  693. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  694. ${id}</a>...<font></font></li>`);
  695. break;
  696.  
  697. case 'joiningDiscordServer':
  698. case 'gettingDiscordGuild':
  699. ele = $(`<li>${i18n(type)}<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>...<font></font></li>`);
  700. break;
  701.  
  702. case 'leavingDiscordServer':
  703. ele = $(`<li>${i18n(type)}<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>...<font></font></li>`);
  704. break;
  705.  
  706. case 'updateDiscordAuth':
  707. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  708. break;
  709.  
  710. case 'followingTwitchChannel':
  711. case 'unfollowingTwitchChannel':
  712. case 'gettingTwitchChannelId':
  713. ele = $(`<li>${i18n(type)}<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>...<font></font></li>`);
  714. break;
  715.  
  716. case 'gettingInsUserId':
  717. case 'followingIns':
  718. case 'unfollowingIns':
  719. ele = $(`<li>${i18n(type)}<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  720. break;
  721.  
  722. case 'gettingTwitterUserId':
  723. case 'followingTwitterUser':
  724. case 'unfollowingTwitterUser':
  725. ele = $(`<li>${i18n(type)}<a href="https://twitter.com/${text}" target="_blank">${text}</a>...<font></font></li>`);
  726. break;
  727.  
  728. case 'retweetting':
  729. case 'unretweetting':
  730. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  731. break;
  732.  
  733. case 'joiningReddit':
  734. case 'leavingReddit':
  735. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  736. break;
  737.  
  738. case 'followingRedditUser':
  739. case 'unfollowingRedditUser':
  740. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  741. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>...<font></font></li>`);
  742. break;
  743.  
  744. case 'followingYtbChannel':
  745. case 'unfollowingYtbChannel':
  746. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>...<font></font></li>`);
  747. break;
  748.  
  749. case 'likingYtbVideo':
  750. case 'unlikingYtbVideo':
  751. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>...<font></font></li>`);
  752. break;
  753.  
  754. case 'gettingVkId':
  755. case 'joiningVkGroup':
  756. case 'leavingVkGroup':
  757. case 'joiningVkPublic':
  758. case 'leavingVkPublic':
  759. case 'sendingVkWall':
  760. case 'deletingVkWall':
  761. ele = $(`<li>${i18n(type)}<a href="https://vk.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  762. break;
  763.  
  764. case 'visitingLink':
  765. ele = $(`<li>${i18n('visitingLink')}<a href="${text}" target="_blank">${text}</a>...<font></font></li>`);
  766. break;
  767.  
  768. case 'verifyingInsAuth':
  769. case 'text':
  770. ele = $(`<li>${i18n(text)}<font></font></li>`);
  771. break;
  772.  
  773. case 'html':
  774. ele = $(text || html);
  775. break;
  776.  
  777. case 'whiteList':
  778. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  779. break;
  780.  
  781. case 'globalOptionsSkip':
  782. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  783. break;
  784.  
  785. default:
  786. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  787. break;
  788. }
  789. } else if (text) {
  790. ele = $(`<li>${i18n(text)}<font></font></li>`);
  791. } else if (html) {
  792. ele = $(html);
  793. } else {
  794. ele = $('<li><font></font></li>');
  795. }
  796. ele.addClass('card-text');
  797. $('#auto-task-info').append(ele);
  798. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  799. const font = ele.find('font');
  800. const status = {
  801. font: font,
  802. success() {
  803. var _this$font, _this$font2, _this$font3;
  804. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  805. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  806. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  807. 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);
  808. return this;
  809. },
  810. error() {
  811. var _this$font4, _this$font5, _this$font6;
  812. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  813. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  814. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  815. 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);
  816. return this;
  817. },
  818. warning() {
  819. var _this$font7, _this$font8, _this$font9;
  820. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  821. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  822. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  823. 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);
  824. return this;
  825. },
  826. info() {
  827. var _this$font10, _this$font11, _this$font12;
  828. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  829. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  830. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  831. 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);
  832. return this;
  833. },
  834. view() {
  835. var _this$font13;
  836. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  837. return this;
  838. }
  839. };
  840. return status;
  841. } catch (error) {
  842. throwError(error, 'echoLog');
  843. return emptyStatus;
  844. }
  845. };
  846. const scripts_echoLog = echoLog;
  847. const unique = array => {
  848. try {
  849. return [ ...new Set(array) ];
  850. } catch (error) {
  851. throwError(error, 'unique');
  852. return [];
  853. }
  854. };
  855. const delay = function() {
  856. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  857. return new Promise(resolve => {
  858. setTimeout(() => {
  859. resolve(true);
  860. }, time);
  861. });
  862. };
  863. const getRedirectLink = async link => {
  864. try {
  865. if (!link) {
  866. return null;
  867. }
  868. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  869. if (redirectLinksCache[link]) {
  870. redirectLinksCache[link];
  871. }
  872. return await tools_httpRequest({
  873. url: link,
  874. method: 'GET'
  875. }).then(_ref => {
  876. let {
  877. data
  878. } = _ref;
  879. if (data !== null && data !== void 0 && data.finalUrl) {
  880. redirectLinksCache[link] = data.finalUrl;
  881. GM_setValue('redirectLinks', redirectLinksCache);
  882. return data.finalUrl;
  883. }
  884. return null;
  885. });
  886. } catch (error) {
  887. throwError(error, 'getRedirectLink');
  888. return null;
  889. }
  890. };
  891. const visitLink = async (link, options) => {
  892. try {
  893. const logStatus = scripts_echoLog({
  894. type: 'visitLink',
  895. text: link
  896. });
  897. return await tools_httpRequest({
  898. url: link,
  899. method: 'GET',
  900. ...options
  901. }).then(_ref2 => {
  902. let {
  903. result,
  904. statusText,
  905. status
  906. } = _ref2;
  907. if (result === 'Success') {
  908. logStatus.success();
  909. return true;
  910. }
  911. logStatus.error(`${result}:${statusText}(${status})`);
  912. return false;
  913. });
  914. } catch (error) {
  915. throwError(error, 'visitLink');
  916. return false;
  917. }
  918. };
  919. const getUrlQuery = url => {
  920. try {
  921. const query = {};
  922. if (url) {
  923. if (url.includes('?')) {
  924. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  925. query[key] = value;
  926. return str;
  927. });
  928. }
  929. } else {
  930. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  931. query[key] = value;
  932. return str;
  933. });
  934. }
  935. return query;
  936. } catch (error) {
  937. throwError(error, 'getUrlQuery');
  938. return {};
  939. }
  940. };
  941. const getUuid = () => {
  942. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  943. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  944. };
  945. const stringToColour = str => {
  946. try {
  947. let hash = 0;
  948. for (let i = 0; i < str.length; i++) {
  949. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  950. }
  951. let colour = '#';
  952. for (let i = 0; i < 3; i++) {
  953. const value = hash >> i * 8 & 255;
  954. colour += `00${value.toString(16)}`.slice(-2);
  955. }
  956. return colour;
  957. } catch (error) {
  958. throwError(error, 'stringToColour');
  959. return '#fff';
  960. }
  961. };
  962. const defaultGlobalOptions = {
  963. doTask: {
  964. discord: {
  965. servers: true
  966. },
  967. instagram: {
  968. users: true
  969. },
  970. twitch: {
  971. channels: true
  972. },
  973. twitter: {
  974. users: true,
  975. retweets: true
  976. },
  977. vk: {
  978. names: true
  979. },
  980. youtube: {
  981. channels: true,
  982. likes: true
  983. },
  984. reddit: {
  985. reddits: true
  986. },
  987. steam: {
  988. groups: true,
  989. officialGroups: true,
  990. wishlists: true,
  991. follows: true,
  992. forums: true,
  993. workshops: true,
  994. curators: true,
  995. workshopVotes: true,
  996. announcements: true,
  997. licenses: true,
  998. playtests: true
  999. }
  1000. },
  1001. undoTask: {
  1002. discord: {
  1003. servers: true
  1004. },
  1005. instagram: {
  1006. users: true
  1007. },
  1008. twitch: {
  1009. channels: true
  1010. },
  1011. twitter: {
  1012. users: true,
  1013. retweets: true
  1014. },
  1015. vk: {
  1016. names: true
  1017. },
  1018. youtube: {
  1019. channels: true,
  1020. likes: true
  1021. },
  1022. reddit: {
  1023. reddits: true
  1024. },
  1025. steam: {
  1026. groups: true,
  1027. officialGroups: true,
  1028. wishlists: true,
  1029. follows: true,
  1030. forums: true,
  1031. workshops: true,
  1032. curators: true
  1033. }
  1034. },
  1035. position: {
  1036. buttonSideX: 'right',
  1037. buttonSideY: 'top',
  1038. buttonDistance: '15,30',
  1039. showButtonSideX: 'right',
  1040. showButtonSideY: 'top',
  1041. showButtonDistance: '15,30',
  1042. logSideX: 'right',
  1043. logSideY: 'bottom',
  1044. logDistance: '10,10'
  1045. },
  1046. hotKey: {
  1047. doTaskKey: 'alt + d',
  1048. undoTaskKey: 'alt + u',
  1049. toggleLogKey: 'alt + l'
  1050. },
  1051. other: {
  1052. twitterVerifyId: '783214',
  1053. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1054. autoUpdateSource: 'jsdelivr',
  1055. language: 'zh',
  1056. checkLogin: true,
  1057. checkLeftKey: true,
  1058. defaultShowButton: true,
  1059. defaultShowLog: true
  1060. }
  1061. };
  1062. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1063. const assignObject = (obj1, obj2) => {
  1064. try {
  1065. const newObj = {};
  1066. for (const [ key, value ] of Object.entries(obj1)) {
  1067. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1068. newObj[key] = assignObject(value, obj2[key]);
  1069. } else {
  1070. newObj[key] = obj2[key] ?? value;
  1071. }
  1072. }
  1073. return newObj;
  1074. } catch (error) {
  1075. throwError(error, 'assignObject');
  1076. return defaultGlobalOptions;
  1077. }
  1078. };
  1079. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1080. const saveData = () => {
  1081. try {
  1082. const data = {};
  1083. $('#globalOptionsForm').serializeArray().map(value => {
  1084. data[value.name] = value.value;
  1085. return value;
  1086. });
  1087. $.makeArray($('#globalOptionsForm input')).map(element => {
  1088. const name = $(element).attr('name');
  1089. const keys = name.split('.');
  1090. if (keys.length === 3) {
  1091. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1092. } else if (keys.length === 2) {
  1093. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1094. }
  1095. return element;
  1096. });
  1097. GM_setValue('globalOptions', globalOptions);
  1098. external_Swal_default().fire({
  1099. title: i18n('changeGlobalOptionsSuccess'),
  1100. icon: 'success'
  1101. });
  1102. } catch (error) {
  1103. throwError(error, 'saveData');
  1104. }
  1105. };
  1106. const changeGlobalOptions = showType => {
  1107. try {
  1108. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1109. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1110. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1111. for (const [ option, data2 ] of Object.entries(data1)) {
  1112. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1113. if (typeof data2 === 'boolean') {
  1114. 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>`;
  1115. } else {
  1116. 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>`;
  1117. }
  1118. } else {
  1119. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1120. 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>`;
  1121. }
  1122. }
  1123. }
  1124. }
  1125. globalOptionsForm += '</tbody></table></form>';
  1126. if (showType === 'swal') {
  1127. external_Swal_default().fire({
  1128. title: i18n('globalOptions'),
  1129. html: globalOptionsForm,
  1130. showConfirmButton: true,
  1131. confirmButtonText: i18n('save'),
  1132. showCancelButton: true,
  1133. cancelButtonText: i18n('close')
  1134. }).then(_ref => {
  1135. let {
  1136. isConfirmed
  1137. } = _ref;
  1138. if (isConfirmed) {
  1139. saveData();
  1140. }
  1141. });
  1142. } else {
  1143. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1144. }
  1145. } catch (error) {
  1146. throwError(error, 'changeGlobalOptions');
  1147. }
  1148. };
  1149. const data = {
  1150. website: '网站',
  1151. type: '类型',
  1152. edit: '编辑',
  1153. whiteList: '白名单',
  1154. skipTask: '跳过撤销任务',
  1155. whiteListOptions: '白名单设置',
  1156. changeWhiteListOption: '设置白名单(%0)',
  1157. whiteListNotFound: '找不到此项白名单: %0',
  1158. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1159. changeWebsiteOptions: '网站设置',
  1160. changeGlobalOptions: '全局设置',
  1161. ok: '是',
  1162. save: '保存',
  1163. close: '关闭',
  1164. return: '返回',
  1165. option: '选项',
  1166. value: '值',
  1167. websiteOptions: '当前网站设置',
  1168. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1169. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1170. needLogin: '请先登录!',
  1171. getTasksInfo: '正在获取并处理任务信息...',
  1172. gettingKey: '正在获取Key...',
  1173. verifyingTask: '正在验证任务',
  1174. notice: '自动任务脚本提醒',
  1175. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1176. giveawayEnded: '此活动已结束,是否关闭?',
  1177. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1178. confirm: '确定',
  1179. cancel: '取消',
  1180. unKnown: '未知',
  1181. unKnownTaskType: '未识别的任务',
  1182. doing: '正在做任务',
  1183. allTasksComplete: '所有任务已完成!',
  1184. getTaskIdFailed: '获取任务Id失败!',
  1185. initSuccess: '%0 初始化成功!',
  1186. initFailed: '%0 初始化失败!',
  1187. errorLink: '链接错误: %0',
  1188. needInit: '请先初始化',
  1189. verifyingAuth: '正在验证%0凭证...',
  1190. updatingAuth: '正在更新%0凭证...',
  1191. initing: '正在初始化...',
  1192. getFailed: '获取%0失败!',
  1193. checkLoginFailed: '检测登录状态失败!',
  1194. checkLeftKeyFailed: '检测剩余Key失败!',
  1195. userId: '用户Id',
  1196. joiningGiveaway: '正在加入赠Key',
  1197. needJoinGiveaway: '需要先加入赠Key',
  1198. cannotUndo: '此网站不支持取消任务',
  1199. verifyAuth: '正在验证 %0 凭证...',
  1200. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1201. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1202. visitingLink: '正在访问链接: ',
  1203. doTask: '做任务',
  1204. undoTask: '撤销任务',
  1205. verifyTask: '验证任务',
  1206. getKey: '获取Key',
  1207. selectAll: '全选',
  1208. selectNone: '全不选',
  1209. invertSelect: '反选',
  1210. doFreeTask: '加入免费赠品',
  1211. doPointTask: '加入点数赠品',
  1212. skipTaskOption: '设置中已配置跳过任务',
  1213. other: '其他',
  1214. globalOptions: '全局设置',
  1215. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1216. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1217. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1218. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1219. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1220. saveGlobalOptions: '保存全局设置',
  1221. settingPage: '设置页面',
  1222. name: '名称',
  1223. version: '版本',
  1224. scriptManager: '脚本管理器',
  1225. script: '脚本',
  1226. environment: '环境',
  1227. os: '系统',
  1228. browser: '浏览器',
  1229. getId: '获取 %0 id',
  1230. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1231. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1232. showButton: '显示按钮',
  1233. hideButton: '隐藏按钮',
  1234. showLog: '显示日志',
  1235. hideLog: '隐藏日志',
  1236. defaultShowButton: '默认显示按钮',
  1237. defaultShowLog: '默认显示日志',
  1238. position: '组件位置',
  1239. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1240. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1241. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1242. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1243. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1244. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1245. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1246. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1247. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1248. hotKey: '快捷键',
  1249. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1250. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1251. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1252. tasksHistory: '任务历史',
  1253. clearHistory: '清空历史',
  1254. clearHistoryFinished: '已清空任务历史!',
  1255. deleteTask: '删除任务',
  1256. lastChangeTime: '最后一次修改时间',
  1257. clearTaskFinished: '删除以下任务完成!',
  1258. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1259. syncData: '数据同步',
  1260. settingData: '正在上传数据...',
  1261. gettingData: '正在获取数据...',
  1262. help: '帮助',
  1263. fileName: '文件名',
  1264. upload2gist: '同步到Gist',
  1265. downloadFromGist: '从Gist同步',
  1266. saveAndTest: '保存配置并测试',
  1267. testSuccess: '测试成功!',
  1268. testFailed: '测试失败!',
  1269. saveAndTestNotice: '请先保存配置并测试!',
  1270. processingData: '正在处理数据...',
  1271. updatingData: '正在上传数据...',
  1272. syncDataSuccess: '同步数据成功!',
  1273. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1274. downloadingData: '正在下载数据...',
  1275. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1276. savingData: '正在保存数据...',
  1277. syncHistory: '同步任务历史',
  1278. checkUpdateFailed: '检测更新失败',
  1279. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1280. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1281. gistOptions: 'Gist 设置',
  1282. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1283. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1284. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1285. toGithub: '前往Github反馈',
  1286. toKeylol: '前往其乐论坛反馈',
  1287. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1288. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1289. updateText: '%0 版本更新内容:',
  1290. Active: '进行中',
  1291. Ended: '已结束',
  1292. Banned: '已封禁',
  1293. Paused: '已暂停',
  1294. notStart: '未开始',
  1295. noRemoteData: '检测到远程无数据',
  1296. errorRemoteDataFormat: '远程数据格式错误',
  1297. groups: '组',
  1298. officialGroups: '官方组',
  1299. wishlists: '愿望单',
  1300. follows: '游戏关注',
  1301. forums: '论坛',
  1302. workshops: '创意工坊收藏',
  1303. curators: '鉴赏家',
  1304. workshopVotes: '创意工坊点赞',
  1305. announcements: '社区通知',
  1306. steamCommunity: 'Steam社区',
  1307. steamStore: 'Steam商店',
  1308. licenses: '入库免费游戏',
  1309. playtests: '请求访问权限',
  1310. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1311. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1312. joiningSteamGroup: '正在加入Steam组',
  1313. leavingSteamGroup: '正在退出Steam组',
  1314. gettingSteamGroupId: '正在获取Steam组Id',
  1315. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1316. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1317. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1318. subscribingForum: '正在订阅Steam论坛',
  1319. unsubscribingForum: '正在取消订阅Steam论坛',
  1320. gettingForumId: '正在获取Steam论坛Id',
  1321. followingCurator: '正在关注Steam鉴赏家',
  1322. unfollowingCurator: '正在取关Steam鉴赏家',
  1323. addingToWishlist: '正在添加游戏到Steam愿望单',
  1324. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1325. followingGame: '正在关注Steam游戏',
  1326. unfollowingGame: '正在取关Steam游戏',
  1327. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1328. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1329. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1330. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1331. gettingAnnouncementParams: '正在获取Steam通知信息',
  1332. likingAnnouncement: '正在点赞Steam通知',
  1333. changingArea: '正在更换Steam地区: %0...',
  1334. notNeededChangeArea: '当前地区不需要更换',
  1335. noAnotherArea: '请检测是否开启正确开启代理',
  1336. gettingAreaInfo: '正在获取Steam地区信息...',
  1337. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1338. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1339. gettingSubid: '正在获取游戏subid',
  1340. addingFreeLicense: '正在入库',
  1341. missParams: '缺少参数',
  1342. gettingLicenses: '正在获取Licenses...',
  1343. requestingPlayTestAccess: '正在请求访问权限',
  1344. servers: '服务器',
  1345. joiningDiscordServer: '正在加入Discord服务器',
  1346. leavingDiscordServer: '正在退出Discord服务器',
  1347. gettingDiscordGuild: '正在获取Discord服务器Id',
  1348. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1349. users: '用户',
  1350. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1351. insBanned: '您的Instagram账户已被封禁',
  1352. verifyingInsAuth: '正在验证Instagram凭证...',
  1353. gettingInsUserId: '正在获取Instagram用户Id',
  1354. followingIns: '正在关注Instagram用户',
  1355. unfollowingIns: '正在取关Instagram用户',
  1356. reddits: '社区/用户',
  1357. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1358. changingRedditVersion: '正在切换Reddit为新版页面...',
  1359. joiningReddit: '正在加入Reddit社区',
  1360. leavingReddit: '正在退出Reddit社区',
  1361. followingRedditUser: '正在关注Reddit用户',
  1362. unfollowingRedditUser: '正在取关Reddit用户',
  1363. channels: '频道',
  1364. followingTwitchChannel: '正在关注Twitch频道',
  1365. unfollowingTwitchChannel: '正在取关Twitch频道',
  1366. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1367. twitterUser: '推特用户',
  1368. retweets: '转推',
  1369. followingTwitterUser: '正在关注推特用户',
  1370. unfollowingTwitterUser: '正在取关推特用户',
  1371. retweetting: '正在转推',
  1372. unretweetting: '正在撤销转推',
  1373. names: '组/社区/动态',
  1374. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1375. gettingVkId: '正在获取Vk任务Id',
  1376. joiningVkGroup: '正在加入Vk组',
  1377. leavingVkGroup: '正在退出Vk组',
  1378. joiningVkPublic: '正在加入Vk社区',
  1379. leavingVkPublic: '正在退出Vk社区',
  1380. sendingVkWall: '正在转发Vk动态',
  1381. deletingVkWall: '正在撤销转发Vk动态',
  1382. youtubeChannel: 'YouTube频道',
  1383. likes: '点赞',
  1384. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1385. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1386. gettingYtbToken: '正在获取YouTube Token...',
  1387. followingYtbChannel: '正在订阅YouTube频道',
  1388. unfollowingYtbChannel: '正在退订YouTube频道',
  1389. likingYtbVideo: '正在点赞YouTube视频',
  1390. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1391. giveKeyNoticeBefore: '每次验证间隔15s',
  1392. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1393. noPoints: '点数不够,跳过抽奖',
  1394. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1395. joiningLottery: '正在加入抽奖',
  1396. doingGleamTask: '正在做Gleam任务...',
  1397. gettingGleamLink: '正在获取Gleam任务链接...',
  1398. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1399. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1400. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1401. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1402. };
  1403. const zh_CN = data;
  1404. const en_US_data = {
  1405. website: 'Website',
  1406. type: 'Type',
  1407. edit: 'Edit',
  1408. whiteList: 'Whitelist',
  1409. skipTask: 'Skip undo task',
  1410. whiteListOptions: 'Whitelist options',
  1411. changeWhiteListOption: 'Whitelist option(%0)',
  1412. whiteListNotFound: 'Cannot find this whitelist: %0',
  1413. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1414. changeWebsiteOptions: 'Website options',
  1415. changeGlobalOptions: 'Global options',
  1416. ok: 'OK',
  1417. save: 'Save',
  1418. close: 'Close',
  1419. return: 'Return',
  1420. option: 'Option',
  1421. value: 'Value',
  1422. websiteOptions: 'Current website settings',
  1423. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1424. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1425. needLogin: 'Please log in first!',
  1426. getTasksInfo: 'Obtaining and processing task information...',
  1427. gettingKey: 'Getting Key...',
  1428. verifyingTask: 'Verifying task',
  1429. notice: 'Automatic task script notice',
  1430. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1431. giveawayEnded: 'This event has ended, do you want to close it?',
  1432. 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?',
  1433. confirm: 'Confirm',
  1434. cancel: 'Cancel',
  1435. unKnown: 'Unknown',
  1436. unKnownTaskType: 'Unrecognized task',
  1437. doing: 'Doing a task',
  1438. allTasksComplete: 'All tasks have been completed!',
  1439. getTaskIdFailed: 'Failed to obtain task Id!',
  1440. initSuccess: '%0 was initialized successfully!',
  1441. initFailed: '%0 initialization failed!',
  1442. errorLink: 'Link error: %0',
  1443. needInit: 'Please initialize first',
  1444. verifyingAuth: 'Verifying %0 token...',
  1445. updatingAuth: 'Update %0 token...',
  1446. initing: 'Initializing...',
  1447. getFailed: 'Failed to get %0!',
  1448. checkLoginFailed: 'Failed to detect login status!',
  1449. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1450. userId: 'User Id',
  1451. joiningGiveaway: 'Joining giveaway',
  1452. needJoinGiveaway: 'Need to join the giveaway first',
  1453. cannotUndo: 'This website does not support canceling tasks',
  1454. verifyAuth: 'Verifying %0 token...',
  1455. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1456. errorReport: 'A script error is detected, do you want to report the BUG?',
  1457. visitingLink: 'Visiting link: ',
  1458. doTask: 'DoTask',
  1459. undoTask: 'UndoTask',
  1460. verifyTask: 'Verify',
  1461. getKey: 'GetKey',
  1462. selectAll: 'SelectAll',
  1463. selectNone: 'SelectNone',
  1464. invertSelect: 'InvertSelect',
  1465. doFreeTask: 'FreeTask',
  1466. doPointTask: 'PointTask',
  1467. skipTaskOption: 'Skip task has been configured in the settings',
  1468. other: 'Other',
  1469. globalOptions: 'Global Options',
  1470. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1471. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1472. 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.',
  1473. 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.',
  1474. 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.',
  1475. saveGlobalOptions: 'SaveSettings',
  1476. settingPage: 'Setting Page',
  1477. name: 'Name',
  1478. version: 'Version',
  1479. scriptManager: 'Script Manager',
  1480. script: 'Script',
  1481. environment: 'Environment',
  1482. os: 'OS',
  1483. browser: 'Browser',
  1484. getId: 'Get %0 id',
  1485. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1486. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1487. showButton: 'ShowButton',
  1488. hideButton: 'HideButton',
  1489. showLog: 'ShowLog',
  1490. hideLog: 'HideLog',
  1491. defaultShowButton: 'Default display button',
  1492. defaultShowLog: 'Display log by default',
  1493. position: 'Component position',
  1494. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1495. 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',
  1496. 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',
  1497. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1498. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1499. 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',
  1500. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1501. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1502. 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',
  1503. hotKey: 'Shortcut key',
  1504. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1505. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1506. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1507. tasksHistory: 'TasksHistory',
  1508. clearHistory: 'Clear history',
  1509. clearHistoryFinished: 'The mission history has been cleared!',
  1510. deleteTask: 'Delete task',
  1511. lastChangeTime: 'Last Change Time',
  1512. clearTaskFinished: 'Delete the following tasks completed!',
  1513. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1514. syncData: 'DataSync',
  1515. settingData: 'Uploading data...',
  1516. gettingData: 'Getting data...',
  1517. help: 'Help',
  1518. fileName: 'Filename',
  1519. upload2gist: 'Sync to Gist',
  1520. downloadFromGist: 'Sync from Gist',
  1521. saveAndTest: 'Save configuration and test',
  1522. testSuccess: 'Test success!',
  1523. testFailed: 'Test failed!',
  1524. saveAndTestNotice: 'Please save the configuration and test first!',
  1525. processingData: 'Processing data...',
  1526. updatingData: 'Uploading data...',
  1527. syncDataSuccess: 'Synchronized data successfully!',
  1528. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1529. downloadingData: 'Downloading data...',
  1530. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1531. savingData: 'Saving data...',
  1532. syncHistory: 'Synchronize tasks history',
  1533. checkUpdateFailed: 'Check update failed',
  1534. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1535. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1536. gistOptions: 'Gist Settings',
  1537. 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!',
  1538. 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!',
  1539. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1540. toGithub: 'Feedback(Github)',
  1541. toKeylol: 'Feedback(Keylol)',
  1542. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1543. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1544. updateText: 'Updates in version %0:',
  1545. Active: 'Active',
  1546. Ended: 'Ended',
  1547. Banned: 'Banned',
  1548. Paused: 'Paused',
  1549. notStart: 'notStart',
  1550. noRemoteData: 'No data remotely',
  1551. errorRemoteDataFormat: 'Remote data has wrong format',
  1552. groups: 'Group',
  1553. officialGroups: 'Official Group',
  1554. wishlists: 'Wishlist',
  1555. follows: 'Follow Game',
  1556. forums: 'Forum',
  1557. workshops: 'Favorite Workshop',
  1558. curators: 'Curator',
  1559. workshopVotes: 'Voteup Workshop',
  1560. announcements: 'Announcement',
  1561. steamCommunity: 'Steam Community',
  1562. steamStore: 'Steam Store',
  1563. licenses: 'Add License',
  1564. playtests: 'Playtest Access',
  1565. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1566. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1567. joiningSteamGroup: 'Joining Steam Group',
  1568. leavingSteamGroup: 'Leaving Steam Group',
  1569. gettingSteamGroupId: 'Getting Steam Group Id',
  1570. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1571. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1572. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1573. subscribingForum: 'Subscribing the Steam Forum',
  1574. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1575. gettingForumId: 'Getting Steam Forum Id',
  1576. followingCurator: 'Following Steam Curator',
  1577. unfollowingCurator: 'Unfollowing Steam Curator',
  1578. addingToWishlist: 'Adding the game to the Steam wishlist',
  1579. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1580. followingGame: 'Following Steam games',
  1581. unfollowingGame: 'Unfollowing Steam games',
  1582. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1583. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1584. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1585. votingUpWorkshop: 'Liking Steam workshop items',
  1586. gettingAnnouncementParams: 'Getting Steam announcement information',
  1587. likingAnnouncement: 'Liking Steam announcement',
  1588. changingArea: 'Changing Steam area: %0...',
  1589. notNeededChangeArea: 'The current area does not need to be changed',
  1590. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1591. gettingAreaInfo: 'Getting Steam area information...',
  1592. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1593. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1594. gettingSubid: 'Getting subid',
  1595. addingFreeLicense: 'Adding free license',
  1596. missParams: 'Missing parameters',
  1597. gettingLicenses: 'Getting licenses...',
  1598. requestingPlayTestAccess: 'Requesting play test access',
  1599. servers: 'Server',
  1600. joiningDiscordServer: 'Joining Discord Server',
  1601. leavingDiscordServer: 'Leaving Discord Server',
  1602. gettingDiscordGuild: 'Getting Discord server Id',
  1603. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1604. users: 'User',
  1605. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1606. insBanned: 'Your Instagram account has been banned',
  1607. verifyingInsAuth: 'Verifying Instagram token...',
  1608. gettingInsUserId: 'Getting Instagram user Id',
  1609. followingIns: 'Following Instagram user',
  1610. unfollowingIns: 'Unfollowing Instagram user',
  1611. reddits: 'Reddit/User',
  1612. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1613. changingRedditVersion: 'Switching Reddit to a new version page...',
  1614. joiningReddit: 'Joining the Reddit',
  1615. leavingReddit: 'Leaving the Reddit',
  1616. followingRedditUser: 'Following Reddit User',
  1617. unfollowingRedditUser: 'Unfollowing Reddit User',
  1618. channels: 'Channel',
  1619. followingTwitchChannel: 'Following Twitch Channel',
  1620. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1621. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1622. twitterUser: 'Twitter User',
  1623. retweets: 'Retweet',
  1624. followingTwitterUser: 'Following Twitter User',
  1625. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1626. retweetting: 'Retweetting',
  1627. unretweetting: 'Unretweetting',
  1628. names: 'Group/Public/Wall',
  1629. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1630. gettingVkId: 'Getting Vk task Id',
  1631. joiningVkGroup: 'Joining Vk Group',
  1632. leavingVkGroup: 'Leaving Vk Group',
  1633. joiningVkPublic: 'Joining Vk Public',
  1634. leavingVkPublic: 'Leaving Vk Public',
  1635. sendingVkWall: 'Sending Vk Wall',
  1636. deletingVkWall: 'Deleting Vk Wall',
  1637. youtubeChannel: 'YouTube Channel',
  1638. likes: 'Like',
  1639. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1640. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1641. gettingYtbToken: 'Getting YouTube Token...',
  1642. followingYtbChannel: 'Subscribing to YouTube channel',
  1643. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1644. likingYtbVideo: 'Liking YouTube video',
  1645. unlikingYtbVideo: 'Unliking YouTube video',
  1646. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1647. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1648. noPoints: 'Not enough points, skip the lottery',
  1649. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1650. joiningLottery: 'Joining the lottery',
  1651. doingGleamTask: 'Doing Gleam Task...',
  1652. gettingGleamLink: 'Getting Gleam task link...',
  1653. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1654. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1655. 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!',
  1656. 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...'
  1657. };
  1658. const en_US = en_US_data;
  1659. const languages = {
  1660. zh: zh_CN,
  1661. en: en_US
  1662. };
  1663. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1664. const I18n = function(key) {
  1665. var _languages$language;
  1666. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1667. argvs[_key - 1] = arguments[_key];
  1668. }
  1669. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1670. return key;
  1671. }
  1672. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1673. };
  1674. const i18n = I18n;
  1675. function throwError(error, name) {
  1676. external_Swal_default().fire({
  1677. title: i18n('errorReport'),
  1678. icon: 'error',
  1679. showCancelButton: true,
  1680. confirmButtonText: i18n('toGithub'),
  1681. showDenyButton: true,
  1682. denyButtonText: i18n('toKeylol'),
  1683. cancelButtonText: i18n('close')
  1684. }).then(_ref => {
  1685. let {
  1686. isDenied,
  1687. isConfirmed
  1688. } = _ref;
  1689. if (isConfirmed) {
  1690. 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,
  1691. 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');
  1692. } else if (isDenied) {
  1693. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1694.  
  1695. 环境:
  1696.  
  1697. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1698.  
  1699. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1700. 脚本版本: ${GM_info.script.version}
  1701.  
  1702. 报错信息:
  1703. [code]${error.stack}[/code]
  1704.  
  1705. 执行日志:
  1706. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1707. GM_setClipboard(text);
  1708. external_Swal_default().fire({
  1709. title: i18n('copySuccess'),
  1710. icon: 'success',
  1711. confirmButtonText: i18n('ok')
  1712. }).then(() => {
  1713. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1714. });
  1715. }
  1716. });
  1717. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1718. }
  1719. function _defineProperty(obj, key, value) {
  1720. if (key in obj) {
  1721. Object.defineProperty(obj, key, {
  1722. value: value,
  1723. enumerable: true,
  1724. configurable: true,
  1725. writable: true
  1726. });
  1727. } else {
  1728. obj[key] = value;
  1729. }
  1730. return obj;
  1731. }
  1732. class Social {
  1733. constructor() {
  1734. _defineProperty(this, 'tasks', void 0);
  1735. }
  1736. getRealParams(name, links, doTask, link2param) {
  1737. try {
  1738. let realParams = [];
  1739. if (links.length > 0) {
  1740. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1741. }
  1742. if (!doTask && this.tasks[name].length > 0) {
  1743. realParams = [ ...realParams, ...this.tasks[name] ];
  1744. }
  1745. return unique(realParams);
  1746. } catch (error) {
  1747. throwError(error, 'Social.getRealParams');
  1748. return [];
  1749. }
  1750. }
  1751. }
  1752. const social_Social = Social;
  1753. function _classPrivateMethodInitSpec(obj, privateSet) {
  1754. _checkPrivateRedeclaration(obj, privateSet);
  1755. privateSet.add(obj);
  1756. }
  1757. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1758. _checkPrivateRedeclaration(obj, privateMap);
  1759. privateMap.set(obj, value);
  1760. }
  1761. function _checkPrivateRedeclaration(obj, privateCollection) {
  1762. if (privateCollection.has(obj)) {
  1763. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1764. }
  1765. }
  1766. function Discord_defineProperty(obj, key, value) {
  1767. if (key in obj) {
  1768. Object.defineProperty(obj, key, {
  1769. value: value,
  1770. enumerable: true,
  1771. configurable: true,
  1772. writable: true
  1773. });
  1774. } else {
  1775. obj[key] = value;
  1776. }
  1777. return obj;
  1778. }
  1779. function _classPrivateFieldSet(receiver, privateMap, value) {
  1780. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1781. _classApplyDescriptorSet(receiver, descriptor, value);
  1782. return value;
  1783. }
  1784. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1785. if (descriptor.set) {
  1786. descriptor.set.call(receiver, value);
  1787. } else {
  1788. if (!descriptor.writable) {
  1789. throw new TypeError('attempted to set read only private field');
  1790. }
  1791. descriptor.value = value;
  1792. }
  1793. }
  1794. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1795. if (!privateSet.has(receiver)) {
  1796. throw new TypeError('attempted to get private field on non-instance');
  1797. }
  1798. return fn;
  1799. }
  1800. function _classPrivateFieldGet(receiver, privateMap) {
  1801. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1802. return _classApplyDescriptorGet(receiver, descriptor);
  1803. }
  1804. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1805. if (!privateMap.has(receiver)) {
  1806. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1807. }
  1808. return privateMap.get(receiver);
  1809. }
  1810. function _classApplyDescriptorGet(receiver, descriptor) {
  1811. if (descriptor.get) {
  1812. return descriptor.get.call(receiver);
  1813. }
  1814. return descriptor.value;
  1815. }
  1816. const defaultTasksTemplate = {
  1817. servers: []
  1818. };
  1819. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1820. var _auth = new WeakMap();
  1821. var _cache = new WeakMap();
  1822. var _initialized = new WeakMap();
  1823. var _verifyAuth = new WeakSet();
  1824. var _updateAuth = new WeakSet();
  1825. var _joinServer = new WeakSet();
  1826. var _leaveServer = new WeakSet();
  1827. var _getGuild = new WeakSet();
  1828. var _setCache = new WeakSet();
  1829. class Discord extends social_Social {
  1830. constructor() {
  1831. var _GM_getValue;
  1832. super(...arguments);
  1833. _classPrivateMethodInitSpec(this, _setCache);
  1834. _classPrivateMethodInitSpec(this, _getGuild);
  1835. _classPrivateMethodInitSpec(this, _leaveServer);
  1836. _classPrivateMethodInitSpec(this, _joinServer);
  1837. _classPrivateMethodInitSpec(this, _updateAuth);
  1838. _classPrivateMethodInitSpec(this, _verifyAuth);
  1839. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1840. Discord_defineProperty(this, 'whiteList', {
  1841. ...JSON.parse(defaultTasks),
  1842. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1843. });
  1844. _classPrivateFieldInitSpec(this, _auth, {
  1845. writable: true,
  1846. value: GM_getValue('discordAuth') || {}
  1847. });
  1848. _classPrivateFieldInitSpec(this, _cache, {
  1849. writable: true,
  1850. value: GM_getValue('discordCache') || {}
  1851. });
  1852. _classPrivateFieldInitSpec(this, _initialized, {
  1853. writable: true,
  1854. value: false
  1855. });
  1856. }
  1857. async init() {
  1858. try {
  1859. if (_classPrivateFieldGet(this, _initialized)) {
  1860. return true;
  1861. }
  1862. if (!_classPrivateFieldGet(this, _auth).auth) {
  1863. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1864. _classPrivateFieldSet(this, _initialized, true);
  1865. return true;
  1866. }
  1867. return false;
  1868. }
  1869. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1870. if (isVerified) {
  1871. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1872. _classPrivateFieldSet(this, _initialized, true);
  1873. return true;
  1874. }
  1875. GM_setValue('discordAuth', {
  1876. auth: null
  1877. });
  1878. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1879. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1880. _classPrivateFieldSet(this, _initialized, true);
  1881. return true;
  1882. }
  1883. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1884. return false;
  1885. } catch (error) {
  1886. throwError(error, 'Discord.init');
  1887. return false;
  1888. }
  1889. }
  1890. async toggle(_ref) {
  1891. let {
  1892. doTask = true,
  1893. serverLinks = []
  1894. } = _ref;
  1895. try {
  1896. if (!_classPrivateFieldGet(this, _initialized)) {
  1897. scripts_echoLog({
  1898. text: i18n('needInit')
  1899. });
  1900. return false;
  1901. }
  1902. const prom = [];
  1903. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1904. scripts_echoLog({
  1905. type: 'globalOptionsSkip',
  1906. text: 'discord.servers'
  1907. });
  1908. } else {
  1909. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1910. var _link$match;
  1911. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1912. });
  1913. if (realServers.length > 0) {
  1914. for (const server of realServers) {
  1915. if (doTask) {
  1916. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1917. } else {
  1918. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1919. }
  1920. await delay(1e3);
  1921. }
  1922. }
  1923. }
  1924. return await Promise.all(prom).then(() => true);
  1925. } catch (error) {
  1926. throwError(error, 'Discord.toggleServers');
  1927. return false;
  1928. }
  1929. }
  1930. }
  1931. async function _verifyAuth2() {
  1932. try {
  1933. const logStatus = scripts_echoLog({
  1934. text: i18n('verifyingAuth', 'Discord')
  1935. });
  1936. const {
  1937. result,
  1938. statusText,
  1939. status,
  1940. data
  1941. } = await tools_httpRequest({
  1942. url: 'https://discord.com/api/v6/users/@me',
  1943. method: 'HEAD',
  1944. headers: {
  1945. authorization: _classPrivateFieldGet(this, _auth).auth
  1946. }
  1947. });
  1948. if (result === 'Success') {
  1949. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1950. logStatus.success();
  1951. return true;
  1952. }
  1953. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1954. return false;
  1955. }
  1956. logStatus.error(`${result}:${statusText}(${status})`);
  1957. return false;
  1958. } catch (error) {
  1959. throwError(error, 'Discord.verifyAuth');
  1960. return false;
  1961. }
  1962. }
  1963. async function _updateAuth2() {
  1964. try {
  1965. const logStatus = scripts_echoLog({
  1966. text: i18n('updatingAuth', 'Discord')
  1967. });
  1968. return await new Promise(resolve => {
  1969. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1970. active: true,
  1971. insert: true,
  1972. setParent: true
  1973. });
  1974. newTab.onclose = async () => {
  1975. var _GM_getValue2;
  1976. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1977. if (auth) {
  1978. _classPrivateFieldSet(this, _auth, {
  1979. auth: auth
  1980. });
  1981. logStatus.success();
  1982. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1983. } else {
  1984. logStatus.error('Error: Update discord auth failed!');
  1985. resolve(false);
  1986. }
  1987. };
  1988. });
  1989. } catch (error) {
  1990. throwError(error, 'Discord.updateAuth');
  1991. return false;
  1992. }
  1993. }
  1994. async function _joinServer2(inviteId) {
  1995. try {
  1996. const logStatus = scripts_echoLog({
  1997. type: 'joiningDiscordServer',
  1998. text: inviteId
  1999. });
  2000. const {
  2001. result,
  2002. statusText,
  2003. status,
  2004. data
  2005. } = await tools_httpRequest({
  2006. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2007. method: 'POST',
  2008. dataType: 'json',
  2009. headers: {
  2010. authorization: _classPrivateFieldGet(this, _auth).auth
  2011. }
  2012. });
  2013. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2014. var _data$response, _data$response$guild;
  2015. logStatus.success();
  2016. 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);
  2017. if (guild) {
  2018. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2019. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2020. }
  2021. return true;
  2022. }
  2023. logStatus.error(`${result}:${statusText}(${status})`);
  2024. return false;
  2025. } catch (error) {
  2026. throwError(error, 'Discord.joinServer');
  2027. return false;
  2028. }
  2029. }
  2030. async function _leaveServer2(inviteId) {
  2031. try {
  2032. if (this.whiteList.servers.includes(inviteId)) {
  2033. scripts_echoLog({
  2034. type: 'whiteList',
  2035. text: 'Discord.leaveServer',
  2036. id: inviteId
  2037. });
  2038. return true;
  2039. }
  2040. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2041. if (!guild) {
  2042. return false;
  2043. }
  2044. const logStatus = scripts_echoLog({
  2045. type: 'leavingDiscordServer',
  2046. text: guild
  2047. });
  2048. const {
  2049. result,
  2050. statusText,
  2051. status,
  2052. data
  2053. } = await tools_httpRequest({
  2054. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2055. method: 'DELETE',
  2056. headers: {
  2057. authorization: _classPrivateFieldGet(this, _auth).auth
  2058. }
  2059. });
  2060. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2061. logStatus.success();
  2062. return true;
  2063. }
  2064. logStatus.error(`${result}:${statusText}(${status})`);
  2065. return false;
  2066. } catch (error) {
  2067. throwError(error, 'Discord.leaveServer');
  2068. return false;
  2069. }
  2070. }
  2071. async function _getGuild2(inviteId) {
  2072. try {
  2073. const logStatus = scripts_echoLog({
  2074. type: 'gettingDiscordGuild',
  2075. text: inviteId
  2076. });
  2077. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2078. if (guild) {
  2079. logStatus.success();
  2080. return guild;
  2081. }
  2082. const {
  2083. result,
  2084. statusText,
  2085. status,
  2086. data
  2087. } = await tools_httpRequest({
  2088. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2089. responseType: 'json',
  2090. method: 'GET'
  2091. });
  2092. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2093. var _data$response2, _data$response2$guild;
  2094. 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;
  2095. if (guild) {
  2096. logStatus.success();
  2097. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2098. return guild;
  2099. }
  2100. logStatus.error(`${result}:${statusText}(${status})`);
  2101. return false;
  2102. }
  2103. logStatus.error(`${result}:${statusText}(${status})`);
  2104. return false;
  2105. } catch (error) {
  2106. throwError(error, 'Discord.getGuild');
  2107. return false;
  2108. }
  2109. }
  2110. function _setCache2(inviteId, guild) {
  2111. try {
  2112. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2113. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2114. } catch (error) {
  2115. throwError(error, 'Discord.setCache');
  2116. }
  2117. }
  2118. unsafeWindow.Discord = Discord;
  2119. const social_Discord = Discord;
  2120. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2121. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2122. privateSet.add(obj);
  2123. }
  2124. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2125. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2126. privateMap.set(obj, value);
  2127. }
  2128. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2129. if (privateCollection.has(obj)) {
  2130. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2131. }
  2132. }
  2133. function Instagram_defineProperty(obj, key, value) {
  2134. if (key in obj) {
  2135. Object.defineProperty(obj, key, {
  2136. value: value,
  2137. enumerable: true,
  2138. configurable: true,
  2139. writable: true
  2140. });
  2141. } else {
  2142. obj[key] = value;
  2143. }
  2144. return obj;
  2145. }
  2146. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2147. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2148. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2149. return value;
  2150. }
  2151. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2152. if (descriptor.set) {
  2153. descriptor.set.call(receiver, value);
  2154. } else {
  2155. if (!descriptor.writable) {
  2156. throw new TypeError('attempted to set read only private field');
  2157. }
  2158. descriptor.value = value;
  2159. }
  2160. }
  2161. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2162. if (!privateSet.has(receiver)) {
  2163. throw new TypeError('attempted to get private field on non-instance');
  2164. }
  2165. return fn;
  2166. }
  2167. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2168. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2169. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2170. }
  2171. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2172. if (!privateMap.has(receiver)) {
  2173. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2174. }
  2175. return privateMap.get(receiver);
  2176. }
  2177. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2178. if (descriptor.get) {
  2179. return descriptor.get.call(receiver);
  2180. }
  2181. return descriptor.value;
  2182. }
  2183. const Instagram_defaultTasksTemplate = {
  2184. users: []
  2185. };
  2186. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2187. var Instagram_cache = new WeakMap();
  2188. var Instagram_auth = new WeakMap();
  2189. var Instagram_initialized = new WeakMap();
  2190. var _getUserInfo = new WeakSet();
  2191. var _followUser = new WeakSet();
  2192. var _unfollowUser = new WeakSet();
  2193. var Instagram_setCache = new WeakSet();
  2194. class Instagram extends social_Social {
  2195. constructor() {
  2196. var _GM_getValue;
  2197. super(...arguments);
  2198. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2199. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2200. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2201. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2202. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2203. Instagram_defineProperty(this, 'whiteList', {
  2204. ...JSON.parse(Instagram_defaultTasks),
  2205. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2206. });
  2207. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2208. writable: true,
  2209. value: GM_getValue('instagramCache') || {}
  2210. });
  2211. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2212. writable: true,
  2213. value: {}
  2214. });
  2215. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2216. writable: true,
  2217. value: false
  2218. });
  2219. }
  2220. async init() {
  2221. try {
  2222. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2223. return true;
  2224. }
  2225. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2226. if (isVerified) {
  2227. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2228. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2229. return true;
  2230. }
  2231. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2232. return false;
  2233. } catch (error) {
  2234. throwError(error, 'Instagram.init');
  2235. return false;
  2236. }
  2237. }
  2238. async toggle(_ref) {
  2239. let {
  2240. doTask = true,
  2241. userLinks = []
  2242. } = _ref;
  2243. try {
  2244. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2245. scripts_echoLog({
  2246. text: i18n('needInit')
  2247. });
  2248. return false;
  2249. }
  2250. const prom = [];
  2251. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2252. scripts_echoLog({
  2253. type: 'globalOptionsSkip',
  2254. text: 'instagram.users'
  2255. });
  2256. } else {
  2257. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2258. var _link$match;
  2259. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2260. });
  2261. if (realUsers.length > 0) {
  2262. for (const username of realUsers) {
  2263. if (doTask) {
  2264. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2265. } else {
  2266. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2267. }
  2268. await delay(1e3);
  2269. }
  2270. }
  2271. }
  2272. return await Promise.all(prom).then(() => true);
  2273. } catch (error) {
  2274. throwError(error, 'Instagram.toggleUsers');
  2275. return false;
  2276. }
  2277. }
  2278. }
  2279. async function _getUserInfo2() {
  2280. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2281. try {
  2282. const logStatus = scripts_echoLog({
  2283. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2284. text: name
  2285. });
  2286. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2287. if (userId && name !== 'instagram') {
  2288. logStatus.success();
  2289. return userId;
  2290. }
  2291. const {
  2292. result,
  2293. statusText,
  2294. status,
  2295. data
  2296. } = await tools_httpRequest({
  2297. url: `https://www.instagram.com/${name}/`,
  2298. method: 'GET'
  2299. });
  2300. if (result === 'Success') {
  2301. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2302. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2303. return false;
  2304. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2305. logStatus.error(`Error:${i18n('insBanned')}`);
  2306. return false;
  2307. }
  2308. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2309. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2310. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2311. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2312. if (name === 'instagram') {
  2313. if (csrftoken && hash) {
  2314. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2315. csrftoken: csrftoken,
  2316. hash: hash
  2317. });
  2318. return true;
  2319. }
  2320. return false;
  2321. }
  2322. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2323. if (id) {
  2324. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2325. logStatus.success();
  2326. return id;
  2327. }
  2328. logStatus.error('Error: Get ins data error!');
  2329. return false;
  2330. }
  2331. logStatus.error(`${result}:${statusText}(${status})`);
  2332. return false;
  2333. }
  2334. return false;
  2335. } catch (error) {
  2336. throwError(error, 'Instagram.getUserInfo');
  2337. return false;
  2338. }
  2339. }
  2340. async function _followUser2(name) {
  2341. try {
  2342. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2343. if (!id) {
  2344. return false;
  2345. }
  2346. const logStatus = scripts_echoLog({
  2347. type: 'followingIns',
  2348. text: name
  2349. });
  2350. const {
  2351. result,
  2352. statusText,
  2353. status,
  2354. data
  2355. } = await tools_httpRequest({
  2356. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2357. method: 'POST',
  2358. dataType: 'json',
  2359. headers: {
  2360. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2361. origin: 'https://www.instagram.com',
  2362. referer: `https://www.instagram.com/${name}/`,
  2363. 'content-type': 'application/x-www-form-urlencoded',
  2364. 'sec-fetch-site': 'same-origin',
  2365. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2366. }
  2367. });
  2368. if (result === 'Success') {
  2369. var _data$response, _data$response2;
  2370. 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') {
  2371. logStatus.success();
  2372. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2373. return true;
  2374. }
  2375. 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})`}`);
  2376. return false;
  2377. }
  2378. logStatus.error(`${result}:${statusText}(${status})`);
  2379. return false;
  2380. } catch (error) {
  2381. throwError(error, 'Instagram.followUser');
  2382. return false;
  2383. }
  2384. }
  2385. async function _unfollowUser2(name) {
  2386. try {
  2387. if (this.whiteList.users.includes(name)) {
  2388. scripts_echoLog({
  2389. type: 'whiteList',
  2390. text: 'Instagram.unfollowUser',
  2391. id: name
  2392. });
  2393. return true;
  2394. }
  2395. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2396. if (!id) {
  2397. return false;
  2398. }
  2399. const logStatus = scripts_echoLog({
  2400. type: 'unfollowingIns',
  2401. text: name
  2402. });
  2403. const {
  2404. result,
  2405. statusText,
  2406. status,
  2407. data
  2408. } = await tools_httpRequest({
  2409. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2410. method: 'POST',
  2411. dataType: 'json',
  2412. headers: {
  2413. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2414. origin: 'https://www.instagram.com',
  2415. referer: `https://www.instagram.com/${name}/`,
  2416. 'content-type': 'application/x-www-form-urlencoded',
  2417. 'sec-fetch-site': 'same-origin',
  2418. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2419. }
  2420. });
  2421. if (result === 'Success') {
  2422. var _data$response3;
  2423. 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') {
  2424. logStatus.success();
  2425. return true;
  2426. }
  2427. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2428. return false;
  2429. }
  2430. logStatus.error(`${result}:${statusText}(${status})`);
  2431. return false;
  2432. } catch (error) {
  2433. throwError(error, 'Instagram.unfollowUser');
  2434. return false;
  2435. }
  2436. }
  2437. function Instagram_setCache2(name, id) {
  2438. try {
  2439. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2440. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2441. } catch (error) {
  2442. throwError(error, 'Instagram.setCache');
  2443. }
  2444. }
  2445. const social_Instagram = Instagram;
  2446. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2447. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2448. privateSet.add(obj);
  2449. }
  2450. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2451. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2452. privateMap.set(obj, value);
  2453. }
  2454. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2455. if (privateCollection.has(obj)) {
  2456. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2457. }
  2458. }
  2459. function Reddit_defineProperty(obj, key, value) {
  2460. if (key in obj) {
  2461. Object.defineProperty(obj, key, {
  2462. value: value,
  2463. enumerable: true,
  2464. configurable: true,
  2465. writable: true
  2466. });
  2467. } else {
  2468. obj[key] = value;
  2469. }
  2470. return obj;
  2471. }
  2472. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2473. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2474. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2475. return value;
  2476. }
  2477. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2478. if (descriptor.set) {
  2479. descriptor.set.call(receiver, value);
  2480. } else {
  2481. if (!descriptor.writable) {
  2482. throw new TypeError('attempted to set read only private field');
  2483. }
  2484. descriptor.value = value;
  2485. }
  2486. }
  2487. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2488. if (!privateSet.has(receiver)) {
  2489. throw new TypeError('attempted to get private field on non-instance');
  2490. }
  2491. return fn;
  2492. }
  2493. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2494. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2495. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2496. }
  2497. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2498. if (!privateMap.has(receiver)) {
  2499. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2500. }
  2501. return privateMap.get(receiver);
  2502. }
  2503. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2504. if (descriptor.get) {
  2505. return descriptor.get.call(receiver);
  2506. }
  2507. return descriptor.value;
  2508. }
  2509. const Reddit_defaultTasksTemplate = {
  2510. reddits: []
  2511. };
  2512. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2513. var Reddit_auth = new WeakMap();
  2514. var Reddit_initialized = new WeakMap();
  2515. var _useBeta = new WeakSet();
  2516. var Reddit_updateAuth = new WeakSet();
  2517. class Reddit extends social_Social {
  2518. constructor() {
  2519. var _GM_getValue;
  2520. super(...arguments);
  2521. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2522. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2523. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2524. Reddit_defineProperty(this, 'whiteList', {
  2525. ...JSON.parse(Reddit_defaultTasks),
  2526. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2527. });
  2528. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2529. writable: true,
  2530. value: void 0
  2531. });
  2532. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2533. writable: true,
  2534. value: false
  2535. });
  2536. }
  2537. async init() {
  2538. try {
  2539. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2540. return true;
  2541. }
  2542. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2543. if (isVerified) {
  2544. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2545. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2546. return true;
  2547. }
  2548. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2549. return false;
  2550. } catch (error) {
  2551. throwError(error, 'Reddit.init');
  2552. return false;
  2553. }
  2554. }
  2555. async toggleTask(_ref) {
  2556. let {
  2557. name,
  2558. doTask = true
  2559. } = _ref;
  2560. try {
  2561. if (!doTask && this.whiteList.reddits.includes(name)) {
  2562. scripts_echoLog({
  2563. type: 'whiteList',
  2564. text: 'Reddit.undoTask',
  2565. id: name
  2566. });
  2567. return true;
  2568. }
  2569. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2570. if (/^u_/.test(name)) {
  2571. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2572. }
  2573. const logStatus = scripts_echoLog({
  2574. type: type,
  2575. text: name
  2576. });
  2577. const {
  2578. result,
  2579. statusText,
  2580. status,
  2581. data
  2582. } = await tools_httpRequest({
  2583. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2584. method: 'POST',
  2585. headers: {
  2586. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2587. 'content-type': 'application/x-www-form-urlencoded'
  2588. },
  2589. data: $.param({
  2590. action: doTask ? 'sub' : 'unsub',
  2591. sr_name: name,
  2592. api_type: 'json'
  2593. })
  2594. });
  2595. if (result === 'Success') {
  2596. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2597. logStatus.success();
  2598. if (doTask) {
  2599. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2600. }
  2601. return true;
  2602. }
  2603. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2604. return false;
  2605. }
  2606. logStatus.error(`${result}:${statusText}(${status})`);
  2607. return false;
  2608. } catch (error) {
  2609. throwError(error, 'Reddit.toggleTask');
  2610. return false;
  2611. }
  2612. }
  2613. async toggle(_ref2) {
  2614. let {
  2615. doTask = true,
  2616. redditLinks = []
  2617. } = _ref2;
  2618. try {
  2619. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2620. scripts_echoLog({
  2621. text: i18n('needInit')
  2622. });
  2623. return false;
  2624. }
  2625. const prom = [];
  2626. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2627. scripts_echoLog({
  2628. type: 'globalOptionsSkip',
  2629. text: 'reddit.reddits'
  2630. });
  2631. } else {
  2632. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2633. var _link$match, _link$match2;
  2634. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2635. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2636. if (userName) {
  2637. return name || userName;
  2638. }
  2639. return name;
  2640. });
  2641. if (realReddits.length > 0) {
  2642. for (const name of realReddits) {
  2643. prom.push(this.toggleTask({
  2644. name: name,
  2645. doTask: doTask
  2646. }));
  2647. await delay(1e3);
  2648. }
  2649. }
  2650. }
  2651. return await Promise.all(prom).then(() => true);
  2652. } catch (error) {
  2653. throwError(error, 'Reddit.toggle');
  2654. return false;
  2655. }
  2656. }
  2657. }
  2658. async function _useBeta2() {
  2659. try {
  2660. const logStatus = scripts_echoLog({
  2661. text: i18n('changingRedditVersion')
  2662. });
  2663. GM_setValue('redditAuth', null);
  2664. return await new Promise(resolve => {
  2665. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2666. active: true,
  2667. insert: true,
  2668. setParent: true
  2669. });
  2670. newTab.onclose = async () => {
  2671. logStatus.success();
  2672. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2673. };
  2674. });
  2675. } catch (error) {
  2676. throwError(error, 'Reddit.useBeta');
  2677. return false;
  2678. }
  2679. }
  2680. async function Reddit_updateAuth2() {
  2681. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2682. try {
  2683. const logStatus = scripts_echoLog({
  2684. text: i18n('updatingAuth', 'Reddit')
  2685. });
  2686. const {
  2687. result,
  2688. statusText,
  2689. status,
  2690. data
  2691. } = await tools_httpRequest({
  2692. url: 'https://www.reddit.com/',
  2693. method: 'GET',
  2694. nochche: true,
  2695. headers: {
  2696. 'Cache-Control': 'no-cache'
  2697. }
  2698. });
  2699. if (result === 'Success') {
  2700. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2701. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2702. return false;
  2703. }
  2704. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2705. var _data$responseText$ma;
  2706. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2707. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2708. }
  2709. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2710. if (accessToken) {
  2711. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2712. token: accessToken
  2713. });
  2714. logStatus.success();
  2715. return true;
  2716. }
  2717. logStatus.error('Error: Parameter "accessToken" not found!');
  2718. return false;
  2719. }
  2720. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2721. return false;
  2722. }
  2723. logStatus.error(`${result}:${statusText}(${status})`);
  2724. return false;
  2725. } catch (error) {
  2726. throwError(error, 'Reddit.updateAuth');
  2727. return false;
  2728. }
  2729. }
  2730. const social_Reddit = Reddit;
  2731. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2732. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2733. privateSet.add(obj);
  2734. }
  2735. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2736. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2737. privateMap.set(obj, value);
  2738. }
  2739. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2740. if (privateCollection.has(obj)) {
  2741. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2742. }
  2743. }
  2744. function Twitch_defineProperty(obj, key, value) {
  2745. if (key in obj) {
  2746. Object.defineProperty(obj, key, {
  2747. value: value,
  2748. enumerable: true,
  2749. configurable: true,
  2750. writable: true
  2751. });
  2752. } else {
  2753. obj[key] = value;
  2754. }
  2755. return obj;
  2756. }
  2757. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2758. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2759. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2760. return value;
  2761. }
  2762. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2763. if (descriptor.set) {
  2764. descriptor.set.call(receiver, value);
  2765. } else {
  2766. if (!descriptor.writable) {
  2767. throw new TypeError('attempted to set read only private field');
  2768. }
  2769. descriptor.value = value;
  2770. }
  2771. }
  2772. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2773. if (!privateSet.has(receiver)) {
  2774. throw new TypeError('attempted to get private field on non-instance');
  2775. }
  2776. return fn;
  2777. }
  2778. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2779. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2780. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2781. }
  2782. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2783. if (!privateMap.has(receiver)) {
  2784. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2785. }
  2786. return privateMap.get(receiver);
  2787. }
  2788. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2789. if (descriptor.get) {
  2790. return descriptor.get.call(receiver);
  2791. }
  2792. return descriptor.value;
  2793. }
  2794. const Twitch_defaultTasksTemplate = {
  2795. channels: []
  2796. };
  2797. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2798. var Twitch_auth = new WeakMap();
  2799. var Twitch_cache = new WeakMap();
  2800. var Twitch_initialized = new WeakMap();
  2801. var Twitch_verifyAuth = new WeakSet();
  2802. var Twitch_updateAuth = new WeakSet();
  2803. var _toggleChannel = new WeakSet();
  2804. var _getChannelId = new WeakSet();
  2805. var Twitch_setCache = new WeakSet();
  2806. class Twitch extends social_Social {
  2807. constructor() {
  2808. var _GM_getValue;
  2809. super(...arguments);
  2810. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2811. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2812. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2813. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2814. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2815. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2816. Twitch_defineProperty(this, 'whiteList', {
  2817. ...JSON.parse(Twitch_defaultTasks),
  2818. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2819. });
  2820. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2821. writable: true,
  2822. value: GM_getValue('twitchAuth') || {}
  2823. });
  2824. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2825. writable: true,
  2826. value: GM_getValue('twitchCache') || {}
  2827. });
  2828. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2829. writable: true,
  2830. value: false
  2831. });
  2832. }
  2833. async init() {
  2834. try {
  2835. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2836. return true;
  2837. }
  2838. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2839. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2840. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2841. return true;
  2842. }
  2843. return false;
  2844. }
  2845. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2846. if (isVerified) {
  2847. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2848. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2849. return true;
  2850. }
  2851. GM_setValue('twitchAuth', null);
  2852. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2853. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2854. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2855. return true;
  2856. }
  2857. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2858. return false;
  2859. } catch (error) {
  2860. throwError(error, 'Twitch.init');
  2861. return false;
  2862. }
  2863. }
  2864. async toggle(_ref) {
  2865. let {
  2866. doTask = true,
  2867. channelLinks = []
  2868. } = _ref;
  2869. try {
  2870. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2871. scripts_echoLog({
  2872. text: i18n('needInit')
  2873. });
  2874. return false;
  2875. }
  2876. const prom = [];
  2877. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2878. scripts_echoLog({
  2879. type: 'globalOptionsSkip',
  2880. text: 'twitch.channels'
  2881. });
  2882. } else {
  2883. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2884. var _link$match;
  2885. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2886. });
  2887. if (realChannels.length > 0) {
  2888. for (const channel of realChannels) {
  2889. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2890. name: channel,
  2891. doTask: doTask
  2892. }));
  2893. await delay(1e3);
  2894. }
  2895. }
  2896. }
  2897. return Promise.all(prom).then(() => true);
  2898. } catch (error) {
  2899. throwError(error, 'Twitch.toggle');
  2900. return false;
  2901. }
  2902. }
  2903. }
  2904. async function Twitch_verifyAuth2() {
  2905. try {
  2906. const logStatus = scripts_echoLog({
  2907. text: i18n('verifyingAuth', 'Twitch')
  2908. });
  2909. const {
  2910. result,
  2911. statusText,
  2912. status,
  2913. data
  2914. } = await tools_httpRequest({
  2915. url: 'https://gql.twitch.tv/gql',
  2916. method: 'POST',
  2917. dataType: 'json',
  2918. headers: {
  2919. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2920. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2921. },
  2922. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2923. });
  2924. if (result === 'Success') {
  2925. var _data$response, _data$response$, _data$response$$data;
  2926. 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) {
  2927. logStatus.success();
  2928. return true;
  2929. }
  2930. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2931. return false;
  2932. }
  2933. logStatus.error(`${result}:${statusText}(${status})`);
  2934. return false;
  2935. } catch (error) {
  2936. throwError(error, 'Twitch.verifyAuth');
  2937. return false;
  2938. }
  2939. }
  2940. async function Twitch_updateAuth2() {
  2941. try {
  2942. const logStatus = scripts_echoLog({
  2943. text: i18n('updatingAuth', 'Twitch')
  2944. });
  2945. return await new Promise(resolve => {
  2946. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2947. active: true,
  2948. insert: true,
  2949. setParent: true
  2950. });
  2951. newTab.onclose = async () => {
  2952. const auth = GM_getValue('twitchAuth');
  2953. if (auth) {
  2954. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2955. logStatus.success();
  2956. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2957. } else {
  2958. logStatus.error('Error: Update twitch auth failed!');
  2959. resolve(false);
  2960. }
  2961. };
  2962. });
  2963. } catch (error) {
  2964. throwError(error, 'Twitch.updateAuth');
  2965. return false;
  2966. }
  2967. }
  2968. async function _toggleChannel2(_ref2) {
  2969. let {
  2970. name,
  2971. doTask = true
  2972. } = _ref2;
  2973. try {
  2974. if (!doTask && this.whiteList.channels.includes(name)) {
  2975. scripts_echoLog({
  2976. type: 'whiteList',
  2977. text: 'Twitch.unfollowChannel',
  2978. id: name
  2979. });
  2980. return true;
  2981. }
  2982. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2983. if (!channelId) {
  2984. return false;
  2985. }
  2986. const logStatus = scripts_echoLog({
  2987. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2988. text: name
  2989. });
  2990. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2991. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2992. const {
  2993. result,
  2994. statusText,
  2995. status,
  2996. data
  2997. } = await tools_httpRequest({
  2998. url: 'https://gql.twitch.tv/gql',
  2999. method: 'POST',
  3000. dataType: 'json',
  3001. headers: {
  3002. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  3003. },
  3004. data: doTask ? followData : unfollowData
  3005. });
  3006. if (result === 'Success') {
  3007. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3008. logStatus.success();
  3009. if (doTask) {
  3010. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3011. }
  3012. return true;
  3013. }
  3014. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3015. return false;
  3016. }
  3017. logStatus.error(`${result}:${statusText}(${status})`);
  3018. return false;
  3019. } catch (error) {
  3020. throwError(error, 'Twitch.toggleChannel');
  3021. return false;
  3022. }
  3023. }
  3024. async function _getChannelId2(name) {
  3025. try {
  3026. const logStatus = scripts_echoLog({
  3027. type: 'gettingTwitchChannelId',
  3028. text: name
  3029. });
  3030. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3031. if (channelId) {
  3032. logStatus.success();
  3033. return channelId;
  3034. }
  3035. const {
  3036. result,
  3037. statusText,
  3038. status,
  3039. data
  3040. } = await tools_httpRequest({
  3041. url: 'https://gql.twitch.tv/gql',
  3042. method: 'POST',
  3043. headers: {
  3044. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3045. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3046. },
  3047. responseType: 'json',
  3048. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3049. });
  3050. if (result === 'Success') {
  3051. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3052. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3053. 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);
  3054. if (channelId) {
  3055. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3056. logStatus.success();
  3057. return channelId;
  3058. }
  3059. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3060. return false;
  3061. }
  3062. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3063. return false;
  3064. }
  3065. logStatus.error(`${result}:${statusText}(${status})`);
  3066. return false;
  3067. } catch (error) {
  3068. throwError(error, 'Twitch.getChannelId');
  3069. return false;
  3070. }
  3071. }
  3072. function Twitch_setCache2(name, id) {
  3073. try {
  3074. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3075. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3076. } catch (error) {
  3077. throwError(error, 'Twitch.setCache');
  3078. }
  3079. }
  3080. const social_Twitch = Twitch;
  3081. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3082. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3083. privateSet.add(obj);
  3084. }
  3085. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3086. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3087. privateMap.set(obj, value);
  3088. }
  3089. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3090. if (privateCollection.has(obj)) {
  3091. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3092. }
  3093. }
  3094. function Twitter_defineProperty(obj, key, value) {
  3095. if (key in obj) {
  3096. Object.defineProperty(obj, key, {
  3097. value: value,
  3098. enumerable: true,
  3099. configurable: true,
  3100. writable: true
  3101. });
  3102. } else {
  3103. obj[key] = value;
  3104. }
  3105. return obj;
  3106. }
  3107. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3108. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3109. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3110. return value;
  3111. }
  3112. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3113. if (descriptor.set) {
  3114. descriptor.set.call(receiver, value);
  3115. } else {
  3116. if (!descriptor.writable) {
  3117. throw new TypeError('attempted to set read only private field');
  3118. }
  3119. descriptor.value = value;
  3120. }
  3121. }
  3122. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3123. if (!privateSet.has(receiver)) {
  3124. throw new TypeError('attempted to get private field on non-instance');
  3125. }
  3126. return fn;
  3127. }
  3128. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3129. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3130. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3131. }
  3132. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3133. if (!privateMap.has(receiver)) {
  3134. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3135. }
  3136. return privateMap.get(receiver);
  3137. }
  3138. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3139. if (descriptor.get) {
  3140. return descriptor.get.call(receiver);
  3141. }
  3142. return descriptor.value;
  3143. }
  3144. const Twitter_defaultTasksTemplate = {
  3145. users: [],
  3146. retweets: [],
  3147. likes: []
  3148. };
  3149. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3150. var _verifyId = new WeakMap();
  3151. var Twitter_auth = new WeakMap();
  3152. var Twitter_cache = new WeakMap();
  3153. var Twitter_initialized = new WeakMap();
  3154. var Twitter_verifyAuth = new WeakSet();
  3155. var Twitter_updateAuth = new WeakSet();
  3156. var _toggleUser = new WeakSet();
  3157. var _toggleRetweet = new WeakSet();
  3158. var Twitter_setCache = new WeakSet();
  3159. class Twitter extends social_Social {
  3160. constructor() {
  3161. var _GM_getValue;
  3162. super(...arguments);
  3163. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3164. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3165. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3166. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3167. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3168. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3169. Twitter_defineProperty(this, 'whiteList', {
  3170. ...JSON.parse(Twitter_defaultTasks),
  3171. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3172. });
  3173. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3174. writable: true,
  3175. value: globalOptions.other.twitterVerifyId
  3176. });
  3177. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3178. writable: true,
  3179. value: GM_getValue('twitterAuth') || {}
  3180. });
  3181. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3182. writable: true,
  3183. value: GM_getValue('twitterCache') || {}
  3184. });
  3185. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3186. writable: true,
  3187. value: false
  3188. });
  3189. }
  3190. async init() {
  3191. try {
  3192. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3193. return true;
  3194. }
  3195. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3196. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3197. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3198. return true;
  3199. }
  3200. return false;
  3201. }
  3202. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3203. if (isVerified) {
  3204. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3205. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3206. return true;
  3207. }
  3208. GM_setValue('twitterAuth', null);
  3209. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3210. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3211. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3212. return true;
  3213. }
  3214. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3215. return false;
  3216. } catch (error) {
  3217. throwError(error, 'Twitter.init');
  3218. return false;
  3219. }
  3220. }
  3221. async userName2id(name) {
  3222. try {
  3223. const logStatus = scripts_echoLog({
  3224. type: 'gettingTwitterUserId',
  3225. text: name
  3226. });
  3227. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3228. if (userId) {
  3229. logStatus.success();
  3230. return userId;
  3231. }
  3232. const {
  3233. result,
  3234. statusText,
  3235. status,
  3236. data
  3237. } = await tools_httpRequest({
  3238. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3239. method: 'GET',
  3240. headers: {
  3241. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3242. 'content-type': 'application/json'
  3243. },
  3244. responseType: 'json',
  3245. anonymous: true
  3246. });
  3247. if (result === 'Success') {
  3248. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3249. var _response, _response$data, _response$data$user;
  3250. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3251. if (!response) {
  3252. try {
  3253. response = JSON.parse(data.responseText);
  3254. } catch (error) {
  3255. response = null;
  3256. }
  3257. }
  3258. 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);
  3259. if (userId) {
  3260. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3261. logStatus.success();
  3262. return userId;
  3263. }
  3264. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3265. return false;
  3266. }
  3267. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3268. return false;
  3269. }
  3270. logStatus.error(`${result}:${statusText}(${status})`);
  3271. return false;
  3272. } catch (error) {
  3273. throwError(error, 'Twitter.getUserId');
  3274. return false;
  3275. }
  3276. }
  3277. async toggle(_ref) {
  3278. let {
  3279. doTask = true,
  3280. userLinks = [],
  3281. retweetLinks = []
  3282. } = _ref;
  3283. try {
  3284. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3285. scripts_echoLog({
  3286. text: i18n('needInit')
  3287. });
  3288. return false;
  3289. }
  3290. const prom = [];
  3291. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3292. scripts_echoLog({
  3293. type: 'globalOptionsSkip',
  3294. text: 'twitter.users'
  3295. });
  3296. } else {
  3297. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3298. var _link$match;
  3299. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3300. });
  3301. if (realUsers.length > 0) {
  3302. for (const user of realUsers) {
  3303. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3304. name: user,
  3305. doTask: doTask
  3306. }));
  3307. await delay(1e3);
  3308. }
  3309. }
  3310. }
  3311. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3312. scripts_echoLog({
  3313. type: 'globalOptionsSkip',
  3314. text: 'twitter.retweets'
  3315. });
  3316. } else {
  3317. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3318. var _link$match2;
  3319. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3320. });
  3321. if (realRetweets.length > 0) {
  3322. for (const retweet of realRetweets) {
  3323. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3324. retweetId: retweet,
  3325. doTask: doTask
  3326. }));
  3327. await delay(1e3);
  3328. }
  3329. }
  3330. }
  3331. return Promise.all(prom).then(() => true);
  3332. } catch (error) {
  3333. throwError(error, 'Twitter.toggle');
  3334. return false;
  3335. }
  3336. }
  3337. }
  3338. async function Twitter_verifyAuth2() {
  3339. try {
  3340. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3341. name: 'verify',
  3342. doTask: true,
  3343. verify: true
  3344. });
  3345. } catch (error) {
  3346. throwError(error, 'Twitter.verifyAuth');
  3347. return false;
  3348. }
  3349. }
  3350. async function Twitter_updateAuth2() {
  3351. try {
  3352. const logStatus = scripts_echoLog({
  3353. text: i18n('updatingAuth', 'Twitter')
  3354. });
  3355. return await new Promise(resolve => {
  3356. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3357. active: true,
  3358. insert: true,
  3359. setParent: true
  3360. });
  3361. newTab.onclose = async () => {
  3362. const auth = GM_getValue('twitterAuth');
  3363. if (auth) {
  3364. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3365. logStatus.success();
  3366. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3367. } else {
  3368. logStatus.error('Error: Update twitter auth failed!');
  3369. resolve(false);
  3370. }
  3371. };
  3372. });
  3373. } catch (error) {
  3374. throwError(error, 'Twitter.updateToken');
  3375. return false;
  3376. }
  3377. }
  3378. async function _toggleUser2(_ref2) {
  3379. let {
  3380. name,
  3381. doTask = true,
  3382. verify = false
  3383. } = _ref2;
  3384. try {
  3385. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3386. scripts_echoLog({
  3387. type: 'whiteList',
  3388. text: 'Twitter.unfollowUser',
  3389. id: name
  3390. });
  3391. return true;
  3392. }
  3393. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3394. if (!userId) {
  3395. return false;
  3396. }
  3397. const logStatus = verify ? scripts_echoLog({
  3398. text: i18n('verifyingAuth', 'Twitter')
  3399. }) : scripts_echoLog({
  3400. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3401. text: name
  3402. });
  3403. const {
  3404. result,
  3405. statusText,
  3406. status,
  3407. data
  3408. } = await tools_httpRequest({
  3409. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3410. method: 'POST',
  3411. headers: {
  3412. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3413. 'Content-Type': 'application/x-www-form-urlencoded',
  3414. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3415. },
  3416. responseType: 'json',
  3417. data: $.param({
  3418. include_profile_interstitial_type: 1,
  3419. include_blocking: 1,
  3420. include_blocked_by: 1,
  3421. include_followed_by: 1,
  3422. include_want_retweets: 1,
  3423. include_mute_edge: 1,
  3424. include_can_dm: 1,
  3425. include_can_media_tag: 1,
  3426. skip_status: 1,
  3427. id: userId
  3428. })
  3429. });
  3430. if (result === 'Success') {
  3431. var _data$response, _data$response$errors, _data$response$errors2;
  3432. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3433. logStatus.success();
  3434. if (doTask && !verify) {
  3435. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3436. }
  3437. return true;
  3438. }
  3439. 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) {
  3440. logStatus.success();
  3441. return true;
  3442. }
  3443. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3444. return false;
  3445. }
  3446. logStatus.error(`${result}:${statusText}(${status})`);
  3447. return false;
  3448. } catch (error) {
  3449. throwError(error, 'Twitter.toggleUser');
  3450. return false;
  3451. }
  3452. }
  3453. async function _toggleRetweet2(_ref3) {
  3454. let {
  3455. retweetId,
  3456. doTask = true
  3457. } = _ref3;
  3458. try {
  3459. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3460. scripts_echoLog({
  3461. type: 'whiteList',
  3462. text: 'Twitter.unretweet',
  3463. id: retweetId
  3464. });
  3465. return true;
  3466. }
  3467. const logStatus = scripts_echoLog({
  3468. type: `${doTask ? '' : 'un'}retweetting`,
  3469. text: retweetId
  3470. });
  3471. const {
  3472. result,
  3473. statusText,
  3474. status,
  3475. data
  3476. } = await tools_httpRequest({
  3477. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3478. method: 'POST',
  3479. headers: {
  3480. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3481. 'Content-Type': 'application/x-www-form-urlencoded',
  3482. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3483. },
  3484. data: $.param({
  3485. tweet_mode: 'extended',
  3486. id: retweetId
  3487. }),
  3488. responseType: 'json'
  3489. });
  3490. if (result === 'Success') {
  3491. var _data$response2, _data$response2$error, _data$response2$error2;
  3492. 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) {
  3493. logStatus.success();
  3494. if (doTask) {
  3495. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3496. }
  3497. return true;
  3498. }
  3499. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3500. return false;
  3501. }
  3502. logStatus.error(`${result}:${statusText}(${status})`);
  3503. return false;
  3504. } catch (error) {
  3505. throwError(error, 'Twitter.toggleRetweet');
  3506. return false;
  3507. }
  3508. }
  3509. function Twitter_setCache2(name, id) {
  3510. try {
  3511. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3512. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3513. } catch (error) {
  3514. throwError(error, 'Twitter.setCache');
  3515. }
  3516. }
  3517. const social_Twitter = Twitter;
  3518. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3519. Vk_checkPrivateRedeclaration(obj, privateSet);
  3520. privateSet.add(obj);
  3521. }
  3522. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3523. Vk_checkPrivateRedeclaration(obj, privateMap);
  3524. privateMap.set(obj, value);
  3525. }
  3526. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3527. if (privateCollection.has(obj)) {
  3528. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3529. }
  3530. }
  3531. function Vk_defineProperty(obj, key, value) {
  3532. if (key in obj) {
  3533. Object.defineProperty(obj, key, {
  3534. value: value,
  3535. enumerable: true,
  3536. configurable: true,
  3537. writable: true
  3538. });
  3539. } else {
  3540. obj[key] = value;
  3541. }
  3542. return obj;
  3543. }
  3544. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3545. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3546. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3547. return value;
  3548. }
  3549. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3550. if (descriptor.set) {
  3551. descriptor.set.call(receiver, value);
  3552. } else {
  3553. if (!descriptor.writable) {
  3554. throw new TypeError('attempted to set read only private field');
  3555. }
  3556. descriptor.value = value;
  3557. }
  3558. }
  3559. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3560. if (!privateSet.has(receiver)) {
  3561. throw new TypeError('attempted to get private field on non-instance');
  3562. }
  3563. return fn;
  3564. }
  3565. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3566. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3567. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3568. }
  3569. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3570. if (!privateMap.has(receiver)) {
  3571. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3572. }
  3573. return privateMap.get(receiver);
  3574. }
  3575. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3576. if (descriptor.get) {
  3577. return descriptor.get.call(receiver);
  3578. }
  3579. return descriptor.value;
  3580. }
  3581. const Vk_defaultTasksTemplate = {
  3582. names: []
  3583. };
  3584. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3585. var _username = new WeakMap();
  3586. var Vk_cache = new WeakMap();
  3587. var Vk_initialized = new WeakMap();
  3588. var Vk_verifyAuth = new WeakSet();
  3589. var _toggleGroup = new WeakSet();
  3590. var _togglePublic = new WeakSet();
  3591. var _sendWall = new WeakSet();
  3592. var _deleteWall = new WeakSet();
  3593. var _getId = new WeakSet();
  3594. var _toggleVk = new WeakSet();
  3595. var Vk_setCache = new WeakSet();
  3596. class Vk extends social_Social {
  3597. constructor() {
  3598. var _GM_getValue;
  3599. super(...arguments);
  3600. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3601. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3602. Vk_classPrivateMethodInitSpec(this, _getId);
  3603. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3604. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3605. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3606. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3607. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3608. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3609. Vk_defineProperty(this, 'whiteList', {
  3610. ...JSON.parse(Vk_defaultTasks),
  3611. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3612. });
  3613. Vk_classPrivateFieldInitSpec(this, _username, {
  3614. writable: true,
  3615. value: ''
  3616. });
  3617. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3618. writable: true,
  3619. value: GM_getValue('vkCache') || {}
  3620. });
  3621. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3622. writable: true,
  3623. value: false
  3624. });
  3625. }
  3626. async init() {
  3627. try {
  3628. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3629. return true;
  3630. }
  3631. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3632. if (isVerified) {
  3633. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3634. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3635. return true;
  3636. }
  3637. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3638. return false;
  3639. } catch (error) {
  3640. throwError(error, 'Vk.init');
  3641. return false;
  3642. }
  3643. }
  3644. async toggle(_ref) {
  3645. let {
  3646. doTask = true,
  3647. nameLinks = []
  3648. } = _ref;
  3649. try {
  3650. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3651. scripts_echoLog({
  3652. text: i18n('needInit')
  3653. });
  3654. return false;
  3655. }
  3656. const prom = [];
  3657. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3658. scripts_echoLog({
  3659. type: 'globalOptionsSkip',
  3660. text: 'vk.names'
  3661. });
  3662. } else {
  3663. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3664. var _link$match;
  3665. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3666. });
  3667. if (realNames.length > 0) {
  3668. for (const name of realNames) {
  3669. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3670. name: name,
  3671. doTask: doTask
  3672. }));
  3673. await delay(1e3);
  3674. }
  3675. }
  3676. }
  3677. return Promise.all(prom).then(() => true);
  3678. } catch (error) {
  3679. throwError(error, 'Vk.toggle');
  3680. return false;
  3681. }
  3682. }
  3683. }
  3684. async function Vk_verifyAuth2() {
  3685. try {
  3686. const logStatus = scripts_echoLog({
  3687. text: i18n('verifyAuth', 'Vk')
  3688. });
  3689. const {
  3690. result,
  3691. statusText,
  3692. status,
  3693. data
  3694. } = await tools_httpRequest({
  3695. url: 'https://vk.com/im',
  3696. method: 'GET'
  3697. });
  3698. if (result === 'Success') {
  3699. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3700. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3701. return false;
  3702. }
  3703. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3704. var _data$responseText$ma;
  3705. 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]) || '');
  3706. logStatus.success();
  3707. return true;
  3708. }
  3709. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3710. return false;
  3711. }
  3712. logStatus.error(`${result}:${statusText}(${status})`);
  3713. return false;
  3714. } catch (error) {
  3715. throwError(error, 'Vk.verifyAuth');
  3716. return false;
  3717. }
  3718. }
  3719. async function _toggleGroup2(name, dataParam) {
  3720. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3721. try {
  3722. const logStatus = scripts_echoLog({
  3723. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3724. text: name
  3725. });
  3726. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3727. logStatus.success();
  3728. return true;
  3729. }
  3730. const reqData = {
  3731. act: doTask ? 'enter' : 'leave',
  3732. al: 1,
  3733. gid: dataParam.groupId,
  3734. hash: dataParam.groupHash
  3735. };
  3736. if (doTask) {
  3737. reqData.context = '_';
  3738. }
  3739. const {
  3740. result,
  3741. statusText,
  3742. status,
  3743. data
  3744. } = await tools_httpRequest({
  3745. url: 'https://vk.com/al_groups.php',
  3746. method: 'POST',
  3747. headers: {
  3748. origin: 'https://vk.com',
  3749. referer: `https://vk.com/${name}`,
  3750. 'content-type': 'application/x-www-form-urlencoded'
  3751. },
  3752. data: $.param(reqData)
  3753. });
  3754. if (result === 'Success') {
  3755. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3756. logStatus.success();
  3757. if (doTask) {
  3758. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3759. }
  3760. return true;
  3761. }
  3762. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3763. return false;
  3764. }
  3765. logStatus.error(`${result}:${statusText}(${status})`);
  3766. return false;
  3767. } catch (error) {
  3768. throwError(error, 'Vk.toggleGroup');
  3769. return false;
  3770. }
  3771. }
  3772. async function _togglePublic2(name, dataParam) {
  3773. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3774. try {
  3775. const logStatus = scripts_echoLog({
  3776. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3777. text: name
  3778. });
  3779. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3780. logStatus.success();
  3781. return true;
  3782. }
  3783. const {
  3784. result,
  3785. statusText,
  3786. status,
  3787. data
  3788. } = await tools_httpRequest({
  3789. url: 'https://vk.com/al_public.php',
  3790. method: 'POST',
  3791. headers: {
  3792. origin: 'https://vk.com',
  3793. referer: `https://vk.com/${name}`,
  3794. 'content-type': 'application/x-www-form-urlencoded'
  3795. },
  3796. data: $.param({
  3797. act: doTask ? 'a_enter' : 'a_leave',
  3798. al: 1,
  3799. pid: dataParam.publicPid,
  3800. hash: dataParam.publicHash
  3801. })
  3802. });
  3803. if (result === 'Success') {
  3804. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3805. logStatus.success();
  3806. if (doTask) {
  3807. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3808. }
  3809. return true;
  3810. }
  3811. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3812. return false;
  3813. }
  3814. logStatus.error(`${result}:${statusText}(${status})`);
  3815. return false;
  3816. } catch (error) {
  3817. throwError(error, 'Vk.togglePublic');
  3818. return false;
  3819. }
  3820. }
  3821. async function _sendWall2(name) {
  3822. try {
  3823. const logStatus = scripts_echoLog({
  3824. type: 'sendingVkWall',
  3825. text: name
  3826. });
  3827. const {
  3828. result,
  3829. statusText,
  3830. status,
  3831. data
  3832. } = await tools_httpRequest({
  3833. url: 'https://vk.com/like.php',
  3834. method: 'POST',
  3835. headers: {
  3836. origin: 'https://vk.com',
  3837. referer: `https://vk.com/${name}`,
  3838. 'content-type': 'application/x-www-form-urlencoded'
  3839. },
  3840. data: $.param({
  3841. act: 'publish_box',
  3842. al: 1,
  3843. object: name
  3844. })
  3845. });
  3846. if (result === 'Success') {
  3847. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3848. var _data$responseText$ma2;
  3849. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3850. if (hash) {
  3851. const {
  3852. result: resultR,
  3853. statusText: statusTextR,
  3854. status: statusR,
  3855. data: dataR
  3856. } = await tools_httpRequest({
  3857. url: 'https://vk.com/like.php',
  3858. method: 'POST',
  3859. headers: {
  3860. origin: 'https://vk.com',
  3861. referer: `https://vk.com/${name}`,
  3862. 'content-type': 'application/x-www-form-urlencoded'
  3863. },
  3864. data: $.param({
  3865. Message: '',
  3866. act: 'a_do_publish',
  3867. al: 1,
  3868. close_comments: 0,
  3869. friends_only: 0,
  3870. from: 'box',
  3871. hash: hash,
  3872. list: '',
  3873. mark_as_ads: 0,
  3874. mute_notifications: 0,
  3875. object: name,
  3876. ret_data: 1,
  3877. to: 0
  3878. })
  3879. });
  3880. if (resultR === 'Success') {
  3881. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3882. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3883. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3884. 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) {
  3885. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3886. logStatus.success();
  3887. 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);
  3888. 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);
  3889. if (postId && ownerId) {
  3890. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3891. }
  3892. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3893. return true;
  3894. }
  3895. }
  3896. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3897. return false;
  3898. }
  3899. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3900. return false;
  3901. }
  3902. logStatus.error('Error: Get "hash" failed');
  3903. return false;
  3904. }
  3905. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3906. return false;
  3907. }
  3908. logStatus.error(`${result}:${statusText}(${status})`);
  3909. return false;
  3910. } catch (error) {
  3911. throwError(error, 'Vk.sendWall');
  3912. return false;
  3913. }
  3914. }
  3915. async function _deleteWall2(name, dataParams) {
  3916. try {
  3917. const logStatus = scripts_echoLog({
  3918. type: 'deletingVkWall',
  3919. text: name
  3920. });
  3921. const {
  3922. result,
  3923. statusText,
  3924. status,
  3925. data
  3926. } = await tools_httpRequest({
  3927. url: 'https://vk.com/al_wall.php?act=delete',
  3928. method: 'POST',
  3929. headers: {
  3930. origin: 'https://vk.com',
  3931. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3932. 'content-type': 'application/x-www-form-urlencoded'
  3933. },
  3934. data: $.param({
  3935. act: 'delete',
  3936. al: 1,
  3937. confirm: 0,
  3938. from: 'wkview',
  3939. hash: dataParams.wallHash,
  3940. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3941. })
  3942. });
  3943. if (result === 'Success') {
  3944. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3945. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3946. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3947. 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]) {
  3948. logStatus.success();
  3949. return true;
  3950. }
  3951. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3952. return false;
  3953. }
  3954. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3955. return false;
  3956. }
  3957. logStatus.error(`${result}:${statusText}(${status})`);
  3958. return false;
  3959. } catch (error) {
  3960. throwError(error, 'Vk.deleteWall');
  3961. return false;
  3962. }
  3963. }
  3964. async function _getId2(name, doTask) {
  3965. try {
  3966. let url = `https://vk.com/${name}`;
  3967. if (/^wall-/.test(name)) {
  3968. if (doTask) {
  3969. return {
  3970. type: 'sendWall'
  3971. };
  3972. }
  3973. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3974. return {
  3975. type: 'unSupport'
  3976. };
  3977. }
  3978. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3979. }
  3980. const logStatus = scripts_echoLog({
  3981. type: 'gettingVkId',
  3982. text: name
  3983. });
  3984. const {
  3985. result,
  3986. statusText,
  3987. status,
  3988. data
  3989. } = await tools_httpRequest({
  3990. url: url,
  3991. method: 'GET'
  3992. });
  3993. if (result === 'Success') {
  3994. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3995. var _data$responseText$ma3, _data$responseText$ma4;
  3996. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3997. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3998. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3999. const publicJoined = !data.responseText.includes('Public.subscribe');
  4000. if (groupAct && groupId && groupHash) {
  4001. logStatus.success();
  4002. return {
  4003. groupAct: groupAct,
  4004. groupId: groupId,
  4005. groupHash: groupHash,
  4006. type: 'group'
  4007. };
  4008. } else if (publicHash && publicPid) {
  4009. logStatus.success();
  4010. return {
  4011. publicHash: publicHash,
  4012. publicPid: publicPid,
  4013. publicJoined: publicJoined,
  4014. type: 'public'
  4015. };
  4016. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4017. var _data$responseText$ma5;
  4018. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4019. if (wallHash) {
  4020. logStatus.success();
  4021. return {
  4022. type: 'deleteWall',
  4023. wallHash: wallHash
  4024. };
  4025. }
  4026. } else if (name.includes('wall') && doTask) {
  4027. logStatus.success();
  4028. return {
  4029. type: 'sendWall'
  4030. };
  4031. }
  4032. logStatus.error('Error: Parameters not found!');
  4033. return false;
  4034. }
  4035. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4036. return false;
  4037. }
  4038. logStatus.error(`${result}:${statusText}(${status})`);
  4039. return false;
  4040. } catch (error) {
  4041. throwError(error, 'Vk.getId');
  4042. return false;
  4043. }
  4044. }
  4045. async function _toggleVk2(_ref2) {
  4046. let {
  4047. name,
  4048. doTask = true
  4049. } = _ref2;
  4050. try {
  4051. if (!doTask && this.whiteList.names.includes(name)) {
  4052. scripts_echoLog({
  4053. type: 'whiteList',
  4054. text: 'Vk.undoTask',
  4055. id: name
  4056. });
  4057. return true;
  4058. }
  4059. const formatName = name.replace(/\/$/, '');
  4060. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4061. if (!data) {
  4062. return false;
  4063. }
  4064. switch (data.type) {
  4065. case 'group':
  4066. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4067.  
  4068. case 'public':
  4069. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4070.  
  4071. case 'sendWall':
  4072. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4073.  
  4074. case 'deleteWall':
  4075. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4076.  
  4077. default:
  4078. return false;
  4079. }
  4080. } catch (error) {
  4081. throwError(error, 'Vk.toggleVk');
  4082. return false;
  4083. }
  4084. }
  4085. function Vk_setCache2(name, postId) {
  4086. try {
  4087. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4088. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4089. } catch (error) {
  4090. throwError(error, 'Vk.setCache');
  4091. }
  4092. }
  4093. const social_Vk = Vk;
  4094. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4095. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4096. privateSet.add(obj);
  4097. }
  4098. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4099. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4100. privateMap.set(obj, value);
  4101. }
  4102. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4103. if (privateCollection.has(obj)) {
  4104. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4105. }
  4106. }
  4107. function Youtube_defineProperty(obj, key, value) {
  4108. if (key in obj) {
  4109. Object.defineProperty(obj, key, {
  4110. value: value,
  4111. enumerable: true,
  4112. configurable: true,
  4113. writable: true
  4114. });
  4115. } else {
  4116. obj[key] = value;
  4117. }
  4118. return obj;
  4119. }
  4120. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4121. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4122. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4123. return value;
  4124. }
  4125. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4126. if (descriptor.set) {
  4127. descriptor.set.call(receiver, value);
  4128. } else {
  4129. if (!descriptor.writable) {
  4130. throw new TypeError('attempted to set read only private field');
  4131. }
  4132. descriptor.value = value;
  4133. }
  4134. }
  4135. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4136. if (!privateSet.has(receiver)) {
  4137. throw new TypeError('attempted to get private field on non-instance');
  4138. }
  4139. return fn;
  4140. }
  4141. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4142. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4143. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4144. }
  4145. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4146. if (!privateMap.has(receiver)) {
  4147. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4148. }
  4149. return privateMap.get(receiver);
  4150. }
  4151. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4152. if (descriptor.get) {
  4153. return descriptor.get.call(receiver);
  4154. }
  4155. return descriptor.value;
  4156. }
  4157. const Youtube_defaultTasksTemplate = {
  4158. channels: [],
  4159. likes: []
  4160. };
  4161. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4162. const getInfo = async function(link, type) {
  4163. try {
  4164. const logStatus = scripts_echoLog({
  4165. text: i18n('gettingYtbToken')
  4166. });
  4167. const {
  4168. result,
  4169. statusText,
  4170. status,
  4171. data
  4172. } = await tools_httpRequest({
  4173. url: link,
  4174. method: 'GET'
  4175. });
  4176. if (result === 'Success') {
  4177. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4178. var _data$responseText$ma, _ref;
  4179. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4180. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4181. return {
  4182. needLogin: true
  4183. };
  4184. }
  4185. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4186. 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]) || '{}';
  4187. const {
  4188. client,
  4189. request
  4190. } = JSON.parse(context);
  4191. if (apiKey && client && request) {
  4192. client.hl = 'en';
  4193. if (type === 'channel') {
  4194. var _data$responseText$ma2;
  4195. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4196. if (channelId) {
  4197. logStatus.success();
  4198. return {
  4199. params: {
  4200. apiKey: apiKey,
  4201. client: client,
  4202. request: request,
  4203. channelId: channelId
  4204. }
  4205. };
  4206. }
  4207. logStatus.error('Error: Get "channelId" failed!');
  4208. return {};
  4209. } else if (type === 'likeVideo') {
  4210. var _data$responseText$ma3, _data$responseText$ma4;
  4211. 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];
  4212. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4213. if (videoId) {
  4214. logStatus.success();
  4215. return {
  4216. params: {
  4217. apiKey: apiKey,
  4218. client: client,
  4219. request: request,
  4220. videoId: videoId,
  4221. likeParams: likeParams
  4222. }
  4223. };
  4224. }
  4225. logStatus.error('Error: Get "videoId" failed!');
  4226. return {};
  4227. }
  4228. logStatus.error('Error: Unknown type');
  4229. return {};
  4230. }
  4231. logStatus.error('Error: Parameter "apiKey" not found!');
  4232. return {};
  4233. }
  4234. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4235. return {};
  4236. }
  4237. logStatus.error(`${result}:${statusText}(${status})`);
  4238. return {};
  4239. } catch (error) {
  4240. throwError(error, 'Youtube.getInfo');
  4241. return {};
  4242. }
  4243. };
  4244. var Youtube_auth = new WeakMap();
  4245. var Youtube_initialized = new WeakMap();
  4246. var _verifyChannel = new WeakMap();
  4247. var Youtube_verifyAuth = new WeakSet();
  4248. var Youtube_updateAuth = new WeakSet();
  4249. var _getInfo = new WeakSet();
  4250. var Youtube_toggleChannel = new WeakSet();
  4251. var _toggleLikeVideo = new WeakSet();
  4252. class Youtube extends social_Social {
  4253. constructor() {
  4254. var _GM_getValue;
  4255. super(...arguments);
  4256. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4257. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4258. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4259. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4260. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4261. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4262. Youtube_defineProperty(this, 'whiteList', {
  4263. ...JSON.parse(Youtube_defaultTasks),
  4264. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4265. });
  4266. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4267. writable: true,
  4268. value: GM_getValue('youtubeAuth') || {}
  4269. });
  4270. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4271. writable: true,
  4272. value: false
  4273. });
  4274. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4275. writable: true,
  4276. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4277. });
  4278. }
  4279. async init() {
  4280. try {
  4281. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4282. return true;
  4283. }
  4284. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4285. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4286. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4287. return true;
  4288. }
  4289. return false;
  4290. }
  4291. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4292. if (isVerified) {
  4293. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4294. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4295. return true;
  4296. }
  4297. GM_setValue('youtubeAuth', null);
  4298. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4299. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4300. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4301. return true;
  4302. }
  4303. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4304. return false;
  4305. } catch (error) {
  4306. throwError(error, 'Youtube.init');
  4307. return false;
  4308. }
  4309. }
  4310. async toggle(_ref2) {
  4311. let {
  4312. doTask = true,
  4313. channelLinks = [],
  4314. videoLinks = []
  4315. } = _ref2;
  4316. try {
  4317. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4318. scripts_echoLog({
  4319. text: i18n('needInit')
  4320. });
  4321. return false;
  4322. }
  4323. const prom = [];
  4324. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4325. scripts_echoLog({
  4326. type: 'globalOptionsSkip',
  4327. text: 'youtube.channels'
  4328. });
  4329. } else {
  4330. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4331. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4332. var _link$match;
  4333. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4334. }
  4335. return link;
  4336. });
  4337. if (realChannels.length > 0) {
  4338. for (const channel of realChannels) {
  4339. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4340. link: channel,
  4341. doTask: doTask
  4342. }));
  4343. await delay(1e3);
  4344. }
  4345. }
  4346. }
  4347. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4348. scripts_echoLog({
  4349. type: 'globalOptionsSkip',
  4350. text: 'youtube.likes'
  4351. });
  4352. } else {
  4353. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4354. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4355. var _link$match2;
  4356. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4357. }
  4358. return link;
  4359. });
  4360. if (realLikes.length > 0) {
  4361. for (const video of realLikes) {
  4362. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4363. link: video,
  4364. doTask: doTask
  4365. }));
  4366. await delay(1e3);
  4367. }
  4368. }
  4369. }
  4370. return Promise.all(prom).then(() => true);
  4371. } catch (error) {
  4372. throwError(error, 'Youtube.toggle');
  4373. return false;
  4374. }
  4375. }
  4376. }
  4377. async function Youtube_verifyAuth2() {
  4378. try {
  4379. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4380. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4381. doTask: true,
  4382. verify: true
  4383. });
  4384. } catch (error) {
  4385. throwError(error, 'Youtube.verifyAuth');
  4386. return false;
  4387. }
  4388. }
  4389. async function Youtube_updateAuth2() {
  4390. try {
  4391. const logStatus = scripts_echoLog({
  4392. text: i18n('updatingAuth', 'Youtube')
  4393. });
  4394. return await new Promise(resolve => {
  4395. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4396. active: true,
  4397. insert: true,
  4398. setParent: true
  4399. });
  4400. newTab.onclose = async () => {
  4401. const auth = GM_getValue('youtubeAuth');
  4402. if (auth) {
  4403. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4404. logStatus.success();
  4405. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4406. resolve(result);
  4407. });
  4408. } else {
  4409. logStatus.error('Error: Update youtube auth failed!');
  4410. resolve(false);
  4411. }
  4412. };
  4413. });
  4414. } catch (error) {
  4415. throwError(error, 'Discord.updateAuth');
  4416. return false;
  4417. }
  4418. }
  4419. function _getInfo2(link, type) {
  4420. return getInfo(link, type);
  4421. }
  4422. async function Youtube_toggleChannel2(_ref3) {
  4423. let {
  4424. link,
  4425. doTask = true,
  4426. verify = false
  4427. } = _ref3;
  4428. try {
  4429. const {
  4430. params,
  4431. needLogin
  4432. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4433. const {
  4434. apiKey,
  4435. client,
  4436. request,
  4437. channelId
  4438. } = params || {};
  4439. if (needLogin) {
  4440. scripts_echoLog({
  4441. html: i18n('loginYtb')
  4442. });
  4443. return false;
  4444. }
  4445. if (!(apiKey && client && request && channelId)) {
  4446. scripts_echoLog({
  4447. text: '"getYtbToken" failed'
  4448. });
  4449. return false;
  4450. }
  4451. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4452. scripts_echoLog({
  4453. type: 'whiteList',
  4454. text: 'Youtube.unfollowChannel',
  4455. id: channelId
  4456. });
  4457. return true;
  4458. }
  4459. const logStatus = verify ? scripts_echoLog({
  4460. text: i18n('verifyingAuth', 'Youtube')
  4461. }) : scripts_echoLog({
  4462. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4463. text: channelId
  4464. });
  4465. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4466. const {
  4467. result,
  4468. statusText,
  4469. status,
  4470. data
  4471. } = await tools_httpRequest({
  4472. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4473. method: 'POST',
  4474. headers: {
  4475. origin: 'https://www.youtube.com',
  4476. referer: `https://www.youtube.com/channel/${channelId}`,
  4477. 'content-type': 'application/json',
  4478. 'x-goog-authuser': '0',
  4479. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4480. 'x-origin': 'https://www.youtube.com',
  4481. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4482. },
  4483. data: JSON.stringify({
  4484. context: {
  4485. client: client,
  4486. request: {
  4487. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4488. internalExperimentFlags: [],
  4489. consistencyTokenJars: []
  4490. },
  4491. user: {}
  4492. },
  4493. channelIds: [ channelId ],
  4494. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4495. })
  4496. });
  4497. if (result === 'Success') {
  4498. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4499. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4500. logStatus.success();
  4501. if (doTask && !verify) {
  4502. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4503. }
  4504. return true;
  4505. }
  4506. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4507. logStatus.success();
  4508. return true;
  4509. }
  4510. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4511. return false;
  4512. }
  4513. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4514. return false;
  4515. }
  4516. logStatus.error(`${result}:${statusText}(${status})`);
  4517. return false;
  4518. } catch (error) {
  4519. throwError(error, 'Youtube.toggleChannel');
  4520. return false;
  4521. }
  4522. }
  4523. async function _toggleLikeVideo2(_ref4) {
  4524. let {
  4525. link,
  4526. doTask = true
  4527. } = _ref4;
  4528. try {
  4529. const {
  4530. params,
  4531. needLogin
  4532. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4533. const {
  4534. apiKey,
  4535. client,
  4536. request,
  4537. videoId,
  4538. likeParams
  4539. } = params || {};
  4540. if (needLogin) {
  4541. scripts_echoLog({
  4542. html: `${i18n('loginYtb')}`
  4543. });
  4544. return false;
  4545. }
  4546. if (!(apiKey && client && request && videoId && likeParams)) {
  4547. scripts_echoLog({
  4548. text: '"getYtbToken" failed'
  4549. });
  4550. return false;
  4551. }
  4552. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4553. scripts_echoLog({
  4554. type: 'whiteList',
  4555. text: 'Youtube.unlikeVideo',
  4556. id: videoId
  4557. });
  4558. return true;
  4559. }
  4560. const logStatus = scripts_echoLog({
  4561. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4562. text: videoId
  4563. });
  4564. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4565. const likeVideoData = {
  4566. context: {
  4567. client: client,
  4568. request: {
  4569. sessionId: request.sessionId,
  4570. internalExperimentFlags: [],
  4571. consistencyTokenJars: []
  4572. },
  4573. user: {}
  4574. },
  4575. target: {
  4576. videoId: videoId
  4577. }
  4578. };
  4579. if (doTask) {
  4580. if (likeParams) {
  4581. likeVideoData.params = likeParams;
  4582. } else {
  4583. logStatus.error('Empty likeParams');
  4584. return false;
  4585. }
  4586. }
  4587. const {
  4588. result,
  4589. statusText,
  4590. status,
  4591. data
  4592. } = await tools_httpRequest({
  4593. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4594. method: 'POST',
  4595. headers: {
  4596. origin: 'https://www.youtube.com',
  4597. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4598. 'content-type': 'application/json',
  4599. 'x-goog-authuser': '0',
  4600. 'x-goog-visitor-id': client.visitorData,
  4601. 'x-origin': 'https://www.youtube.com',
  4602. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4603. },
  4604. data: JSON.stringify(likeVideoData)
  4605. });
  4606. if (result === 'Success') {
  4607. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4608. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4609. logStatus.success();
  4610. if (doTask) {
  4611. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4612. }
  4613. return true;
  4614. }
  4615. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4616. return false;
  4617. }
  4618. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4619. return false;
  4620. }
  4621. logStatus.error(`${result}:${statusText}(${status})`);
  4622. return false;
  4623. } catch (error) {
  4624. throwError(error, 'Youtube.toggleLikeVideo');
  4625. return false;
  4626. }
  4627. }
  4628. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4629. Steam_checkPrivateRedeclaration(obj, privateSet);
  4630. privateSet.add(obj);
  4631. }
  4632. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4633. Steam_checkPrivateRedeclaration(obj, privateMap);
  4634. privateMap.set(obj, value);
  4635. }
  4636. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4637. if (privateCollection.has(obj)) {
  4638. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4639. }
  4640. }
  4641. function Steam_defineProperty(obj, key, value) {
  4642. if (key in obj) {
  4643. Object.defineProperty(obj, key, {
  4644. value: value,
  4645. enumerable: true,
  4646. configurable: true,
  4647. writable: true
  4648. });
  4649. } else {
  4650. obj[key] = value;
  4651. }
  4652. return obj;
  4653. }
  4654. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4655. if (!privateSet.has(receiver)) {
  4656. throw new TypeError('attempted to get private field on non-instance');
  4657. }
  4658. return fn;
  4659. }
  4660. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4661. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4662. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4663. return value;
  4664. }
  4665. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4666. if (descriptor.set) {
  4667. descriptor.set.call(receiver, value);
  4668. } else {
  4669. if (!descriptor.writable) {
  4670. throw new TypeError('attempted to set read only private field');
  4671. }
  4672. descriptor.value = value;
  4673. }
  4674. }
  4675. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4676. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4677. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4678. }
  4679. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4680. if (!privateMap.has(receiver)) {
  4681. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4682. }
  4683. return privateMap.get(receiver);
  4684. }
  4685. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4686. if (descriptor.get) {
  4687. return descriptor.get.call(receiver);
  4688. }
  4689. return descriptor.value;
  4690. }
  4691. const Steam_defaultTasksTemplate = {
  4692. groups: [],
  4693. officialGroups: [],
  4694. wishlists: [],
  4695. follows: [],
  4696. forums: [],
  4697. workshops: [],
  4698. workshopVotes: [],
  4699. curators: [],
  4700. curatorLikes: [],
  4701. announcements: [],
  4702. licenses: [],
  4703. playtests: []
  4704. };
  4705. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4706. var Steam_cache = new WeakMap();
  4707. var Steam_auth = new WeakMap();
  4708. var _storeInitialized = new WeakMap();
  4709. var _communityInitialized = new WeakMap();
  4710. var _area = new WeakMap();
  4711. var _updateStoreAuth = new WeakSet();
  4712. var _updateCommunityAuth = new WeakSet();
  4713. var _getAreaInfo = new WeakSet();
  4714. var _changeArea = new WeakSet();
  4715. var _joinGroup = new WeakSet();
  4716. var _leaveGroup = new WeakSet();
  4717. var _getGroupId = new WeakSet();
  4718. var _joinOfficialGroup = new WeakSet();
  4719. var _leaveOfficialGroup = new WeakSet();
  4720. var _getOfficialGroupId = new WeakSet();
  4721. var _addToWishlist = new WeakSet();
  4722. var _removeFromWishlist = new WeakSet();
  4723. var _toggleFollowGame = new WeakSet();
  4724. var _isFollowedGame = new WeakSet();
  4725. var _toggleForum = new WeakSet();
  4726. var _getForumId = new WeakSet();
  4727. var _toggleFavoriteWorkshop = new WeakSet();
  4728. var _getWorkshopAppId = new WeakSet();
  4729. var _voteUpWorkshop = new WeakSet();
  4730. var _toggleCurator = new WeakSet();
  4731. var _toggleCuratorLike = new WeakSet();
  4732. var _getAnnouncementParams = new WeakSet();
  4733. var _likeAnnouncement = new WeakSet();
  4734. var _appid2subid = new WeakSet();
  4735. var _getLicenses = new WeakSet();
  4736. var _addLicense = new WeakSet();
  4737. var _addFreeLicense = new WeakSet();
  4738. var _requestPlayTestAccess = new WeakSet();
  4739. var Steam_setCache = new WeakSet();
  4740. class Steam extends social_Social {
  4741. constructor() {
  4742. var _GM_getValue;
  4743. super(...arguments);
  4744. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4745. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4746. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4747. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4748. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4749. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4750. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4751. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4752. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4753. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4754. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4755. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4756. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4757. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4758. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4759. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4760. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4761. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4762. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4763. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4764. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4765. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4766. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4767. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4768. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4769. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4770. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4771. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4772. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4773. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4774. Steam_defineProperty(this, 'whiteList', {
  4775. ...JSON.parse(Steam_defaultTasks),
  4776. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4777. });
  4778. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4779. writable: true,
  4780. value: {
  4781. ...{
  4782. group: {},
  4783. officialGroup: {},
  4784. forum: {},
  4785. workshop: {},
  4786. curator: {}
  4787. },
  4788. ...GM_getValue('steamCache')
  4789. }
  4790. });
  4791. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4792. writable: true,
  4793. value: {}
  4794. });
  4795. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4796. writable: true,
  4797. value: false
  4798. });
  4799. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4800. writable: true,
  4801. value: false
  4802. });
  4803. Steam_classPrivateFieldInitSpec(this, _area, {
  4804. writable: true,
  4805. value: 'CN'
  4806. });
  4807. }
  4808. async init() {
  4809. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4810. try {
  4811. if (type === 'store') {
  4812. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4813. return true;
  4814. }
  4815. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4816. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4817. return true;
  4818. }
  4819. if (type === 'community') {
  4820. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4821. return true;
  4822. }
  4823. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4824. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4825. return true;
  4826. }
  4827. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4828. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4829. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4830. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4831. return true;
  4832. }
  4833. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4834. return false;
  4835. } catch (error) {
  4836. throwError(error, 'Steam.init');
  4837. return false;
  4838. }
  4839. }
  4840. async getCuratorId(path, name) {
  4841. try {
  4842. const logStatus = scripts_echoLog({
  4843. type: 'gettingCuratorId',
  4844. text: `${path}/${name}`
  4845. });
  4846. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4847. if (curatorId) {
  4848. logStatus.success();
  4849. return curatorId;
  4850. }
  4851. const {
  4852. result,
  4853. statusText,
  4854. status,
  4855. data
  4856. } = await tools_httpRequest({
  4857. url: `https://store.steampowered.com/${path}/${name}`,
  4858. method: 'GET',
  4859. headers: {
  4860. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4861. }
  4862. });
  4863. if (result === 'Success') {
  4864. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4865. var _data$responseText$ma;
  4866. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4867. if (curatorId) {
  4868. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4869. logStatus.success();
  4870. return curatorId;
  4871. }
  4872. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4873. return false;
  4874. }
  4875. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4876. return false;
  4877. }
  4878. logStatus.error(`${result}:${statusText}(${status})`);
  4879. return false;
  4880. } catch (error) {
  4881. throwError(error, 'Steam.getCuratorID');
  4882. return false;
  4883. }
  4884. }
  4885. async toggle(_ref) {
  4886. let {
  4887. doTask = true,
  4888. groupLinks = [],
  4889. officialGroupLinks = [],
  4890. wishlistLinks = [],
  4891. followLinks = [],
  4892. forumLinks = [],
  4893. workshopLinks = [],
  4894. workshopVoteLinks = [],
  4895. curatorLinks = [],
  4896. curatorLikeLinks = [],
  4897. announcementLinks = [],
  4898. licenseLinks = [],
  4899. playtestLinks = []
  4900. } = _ref;
  4901. try {
  4902. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4903. scripts_echoLog({
  4904. text: i18n('needInit')
  4905. });
  4906. return false;
  4907. }
  4908. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4909. scripts_echoLog({
  4910. text: i18n('needInit')
  4911. });
  4912. return false;
  4913. }
  4914. const prom = [];
  4915. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4916. scripts_echoLog({
  4917. type: 'globalOptionsSkip',
  4918. text: 'steam.groups'
  4919. });
  4920. } else {
  4921. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4922. var _link$match;
  4923. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4924. });
  4925. if (realGroups.length > 0) {
  4926. for (const group of realGroups) {
  4927. if (doTask) {
  4928. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4929. } else {
  4930. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4931. }
  4932. await delay(1e3);
  4933. }
  4934. }
  4935. }
  4936. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  4937. scripts_echoLog({
  4938. type: 'globalOptionsSkip',
  4939. text: 'steam.officialGroups'
  4940. });
  4941. } else {
  4942. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  4943. var _link$match2;
  4944. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4945. });
  4946. if (realOfficialGroups.length > 0) {
  4947. for (const officialGroup of realOfficialGroups) {
  4948. if (doTask) {
  4949. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  4950. } else {
  4951. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  4952. }
  4953. await delay(1e3);
  4954. }
  4955. }
  4956. }
  4957. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4958. scripts_echoLog({
  4959. type: 'globalOptionsSkip',
  4960. text: 'steam.wishlists'
  4961. });
  4962. } else {
  4963. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4964. var _link$match3;
  4965. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4966. });
  4967. if (realWishlists.length > 0) {
  4968. for (const game of realWishlists) {
  4969. if (doTask) {
  4970. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4971. } else {
  4972. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4973. }
  4974. await delay(1e3);
  4975. }
  4976. }
  4977. }
  4978. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4979. scripts_echoLog({
  4980. type: 'globalOptionsSkip',
  4981. text: 'steam.follows'
  4982. });
  4983. } else {
  4984. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4985. var _link$match4;
  4986. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4987. });
  4988. if (realFollows.length > 0) {
  4989. for (const game of realFollows) {
  4990. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4991. await delay(1e3);
  4992. }
  4993. }
  4994. }
  4995. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4996. scripts_echoLog({
  4997. type: 'globalOptionsSkip',
  4998. text: 'steam.forums'
  4999. });
  5000. } else {
  5001. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5002. var _link$match5;
  5003. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5004. });
  5005. if (realForums.length > 0) {
  5006. for (const forum of realForums) {
  5007. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5008. await delay(1e3);
  5009. }
  5010. }
  5011. }
  5012. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5013. scripts_echoLog({
  5014. type: 'globalOptionsSkip',
  5015. text: 'steam.workshops'
  5016. });
  5017. } else {
  5018. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5019. var _link$match6;
  5020. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5021. });
  5022. if (realWorkshops.length > 0) {
  5023. for (const workshop of realWorkshops) {
  5024. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5025. await delay(1e3);
  5026. }
  5027. }
  5028. }
  5029. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5030. scripts_echoLog({
  5031. type: 'globalOptionsSkip',
  5032. text: 'steam.workshopVotes'
  5033. });
  5034. } else {
  5035. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5036. var _link$match7;
  5037. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5038. });
  5039. if (doTask && realworkshopVotes.length > 0) {
  5040. for (const workshop of realworkshopVotes) {
  5041. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5042. await delay(1e3);
  5043. }
  5044. }
  5045. }
  5046. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5047. scripts_echoLog({
  5048. type: 'globalOptionsSkip',
  5049. text: 'steam.curators'
  5050. });
  5051. } else {
  5052. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5053. var _link$match8;
  5054. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5055. });
  5056. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5057. var _link$match9;
  5058. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5059. });
  5060. if (realCurators.length > 0) {
  5061. for (const curator of realCurators) {
  5062. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5063. await delay(1e3);
  5064. }
  5065. }
  5066. if (realCuratorLikes.length > 0) {
  5067. for (const curatorLike of realCuratorLikes) {
  5068. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5069. await delay(1e3);
  5070. }
  5071. }
  5072. }
  5073. if (doTask && !globalOptions.doTask.steam.announcements) {
  5074. scripts_echoLog({
  5075. type: 'globalOptionsSkip',
  5076. text: 'steam.announcements'
  5077. });
  5078. } else {
  5079. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5080. var _link$match11;
  5081. if (link.includes('store.steampowered.com')) {
  5082. var _link$match10;
  5083. 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('/');
  5084. }
  5085. 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('/');
  5086. });
  5087. if (doTask && realAnnouncements.length > 0) {
  5088. for (const id of realAnnouncements) {
  5089. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5090. await delay(1e3);
  5091. }
  5092. }
  5093. }
  5094. if (doTask && !globalOptions.doTask.steam.licenses) {
  5095. scripts_echoLog({
  5096. type: 'globalOptionsSkip',
  5097. text: 'steam.licenses'
  5098. });
  5099. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5100. for (const id of licenseLinks) {
  5101. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5102. await delay(1e3);
  5103. }
  5104. }
  5105. if (doTask && !globalOptions.doTask.steam.playtests) {
  5106. scripts_echoLog({
  5107. type: 'globalOptionsSkip',
  5108. text: 'steam.playtests'
  5109. });
  5110. } else {
  5111. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5112. var _link$match12;
  5113. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5114. });
  5115. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5116. for (const id of realPlaytests) {
  5117. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5118. await delay(1e3);
  5119. }
  5120. }
  5121. }
  5122. return Promise.all(prom).then(async () => {
  5123. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5124. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5125. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5126. }
  5127. return true;
  5128. });
  5129. } catch (error) {
  5130. throwError(error, 'Steam.toggle');
  5131. return false;
  5132. }
  5133. }
  5134. }
  5135. async function _updateStoreAuth2() {
  5136. try {
  5137. const logStatus = scripts_echoLog({
  5138. text: i18n('updatingAuth', i18n('steamStore'))
  5139. });
  5140. const {
  5141. result,
  5142. statusText,
  5143. status,
  5144. data
  5145. } = await tools_httpRequest({
  5146. url: 'https://store.steampowered.com/stats/',
  5147. method: 'GET'
  5148. });
  5149. if (result === 'Success') {
  5150. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5151. var _data$responseText$ma2;
  5152. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5153. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5154. return false;
  5155. }
  5156. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5157. if (storeSessionID) {
  5158. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5159. logStatus.success();
  5160. return true;
  5161. }
  5162. logStatus.error('Error: Get "sessionID" failed');
  5163. return false;
  5164. }
  5165. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5166. return false;
  5167. }
  5168. logStatus.error(`${result}:${statusText}(${status})`);
  5169. return false;
  5170. } catch (error) {
  5171. throwError(error, 'Steam.updateStoreAuth');
  5172. return false;
  5173. }
  5174. }
  5175. async function _updateCommunityAuth2() {
  5176. try {
  5177. const logStatus = scripts_echoLog({
  5178. text: i18n('updatingAuth', i18n('steamCommunity'))
  5179. });
  5180. const {
  5181. result,
  5182. statusText,
  5183. status,
  5184. data
  5185. } = await tools_httpRequest({
  5186. url: 'https://steamcommunity.com/my',
  5187. method: 'GET'
  5188. });
  5189. if (result === 'Success') {
  5190. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5191. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5192. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5193. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5194. return false;
  5195. }
  5196. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5197. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5198. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5199. if (steam64Id) {
  5200. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5201. }
  5202. if (userName) {
  5203. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5204. }
  5205. if (communitySessionID) {
  5206. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5207. logStatus.success();
  5208. return true;
  5209. }
  5210. logStatus.error('Error: Get "sessionID" failed');
  5211. return false;
  5212. }
  5213. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5214. return false;
  5215. }
  5216. logStatus.error(`${result}:${statusText}(${status})`);
  5217. return false;
  5218. } catch (error) {
  5219. throwError(error, 'Steam.updateCommunityAuth');
  5220. return false;
  5221. }
  5222. }
  5223. async function _getAreaInfo2() {
  5224. try {
  5225. const logStatus = scripts_echoLog({
  5226. text: i18n('gettingAreaInfo')
  5227. });
  5228. const {
  5229. result,
  5230. statusText,
  5231. status,
  5232. data
  5233. } = await tools_httpRequest({
  5234. url: 'https://store.steampowered.com/cart/',
  5235. method: 'GET'
  5236. });
  5237. if (result === 'Success') {
  5238. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5239. var _data$responseText$ma6;
  5240. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5241. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5242. if (currentArea && areas.length > 0) {
  5243. Steam_classPrivateFieldSet(this, _area, currentArea);
  5244. logStatus.success();
  5245. return {
  5246. currentArea: currentArea,
  5247. areas: areas
  5248. };
  5249. }
  5250. logStatus.error('Error: get country info filed');
  5251. return {};
  5252. }
  5253. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5254. return {};
  5255. }
  5256. logStatus.error(`${result}:${statusText}(${status})`);
  5257. return {};
  5258. } catch (error) {
  5259. throwError(error, 'Steam.getAreaInfo');
  5260. return {};
  5261. }
  5262. }
  5263. async function _changeArea2(area) {
  5264. try {
  5265. let aimedArea = area;
  5266. if (!aimedArea) {
  5267. const {
  5268. currentArea,
  5269. areas
  5270. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5271. if (!currentArea || !areas) {
  5272. return false;
  5273. }
  5274. if (currentArea !== 'CN') {
  5275. scripts_echoLog({
  5276. text: 'notNeededChangeArea'
  5277. });
  5278. return 'skip';
  5279. }
  5280. const anotherArea = areas.filter(area => area && area !== 'CN');
  5281. if (!anotherArea || anotherArea.length === 0) {
  5282. scripts_echoLog({
  5283. text: 'noAnotherArea'
  5284. });
  5285. return false;
  5286. }
  5287. [ aimedArea ] = anotherArea;
  5288. }
  5289. const logStatus = scripts_echoLog({
  5290. text: i18n('changingArea', aimedArea)
  5291. });
  5292. const {
  5293. result,
  5294. statusText,
  5295. status,
  5296. data
  5297. } = await tools_httpRequest({
  5298. url: 'https://store.steampowered.com/account/setcountry',
  5299. method: 'POST',
  5300. headers: {
  5301. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5302. },
  5303. data: $.param({
  5304. cc: aimedArea,
  5305. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5306. })
  5307. });
  5308. if (result === 'Success') {
  5309. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5310. const {
  5311. currentArea
  5312. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5313. if (currentArea === aimedArea) {
  5314. logStatus.success();
  5315. return currentArea;
  5316. }
  5317. logStatus.error('Error: change country filed');
  5318. return 'CN';
  5319. }
  5320. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5321. return 'CN';
  5322. }
  5323. logStatus.error(`${result}:${statusText}(${status})`);
  5324. return 'CN';
  5325. } catch (error) {
  5326. throwError(error, 'Steam.changeArea');
  5327. return false;
  5328. }
  5329. }
  5330. async function _joinGroup2(groupName) {
  5331. try {
  5332. const logStatus = scripts_echoLog({
  5333. type: 'joiningSteamGroup',
  5334. text: groupName
  5335. });
  5336. const {
  5337. result,
  5338. statusText,
  5339. status,
  5340. data
  5341. } = await tools_httpRequest({
  5342. url: `https://steamcommunity.com/groups/${groupName}`,
  5343. method: 'POST',
  5344. headers: {
  5345. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5346. },
  5347. data: $.param({
  5348. action: 'join',
  5349. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5350. })
  5351. });
  5352. if (result === 'Success') {
  5353. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5354. logStatus.success();
  5355. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5356. return true;
  5357. }
  5358. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5359. return false;
  5360. }
  5361. logStatus.error(`${result}:${statusText}(${status})`);
  5362. return false;
  5363. } catch (error) {
  5364. throwError(error, 'Steam.joinGroup');
  5365. return false;
  5366. }
  5367. }
  5368. async function _leaveGroup2(groupName) {
  5369. try {
  5370. if (this.whiteList.groups.includes(groupName)) {
  5371. scripts_echoLog({
  5372. type: 'whiteList',
  5373. text: 'Steam.leaveGroup',
  5374. id: groupName
  5375. });
  5376. return true;
  5377. }
  5378. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5379. if (!groupId) {
  5380. return false;
  5381. }
  5382. const logStatus = scripts_echoLog({
  5383. type: 'leavingSteamGroup',
  5384. text: groupName
  5385. });
  5386. const {
  5387. result,
  5388. statusText,
  5389. status,
  5390. data
  5391. } = await tools_httpRequest({
  5392. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5393. method: 'POST',
  5394. headers: {
  5395. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5396. },
  5397. data: $.param({
  5398. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5399. action: 'leaveGroup',
  5400. groupId: groupId
  5401. })
  5402. });
  5403. if (result === 'Success') {
  5404. 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) {
  5405. logStatus.success();
  5406. return true;
  5407. }
  5408. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5409. return false;
  5410. }
  5411. logStatus.error(`${result}:${statusText}(${status})`);
  5412. return false;
  5413. } catch (error) {
  5414. throwError(error, 'Steam.leaveGroup');
  5415. return false;
  5416. }
  5417. }
  5418. async function _getGroupId2(groupName) {
  5419. try {
  5420. const logStatus = scripts_echoLog({
  5421. type: 'gettingSteamGroupId',
  5422. text: groupName
  5423. });
  5424. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5425. if (groupId) {
  5426. logStatus.success();
  5427. return groupId;
  5428. }
  5429. const {
  5430. result,
  5431. statusText,
  5432. status,
  5433. data
  5434. } = await tools_httpRequest({
  5435. url: `https://steamcommunity.com/groups/${groupName}`,
  5436. method: 'GET',
  5437. headers: {
  5438. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5439. }
  5440. });
  5441. if (result === 'Success') {
  5442. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5443. var _data$responseText$ma7;
  5444. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5445. if (groupId) {
  5446. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5447. logStatus.success();
  5448. return groupId;
  5449. }
  5450. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5451. return false;
  5452. }
  5453. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5454. return false;
  5455. }
  5456. logStatus.error(`${result}:${statusText}(${status})`);
  5457. return false;
  5458. } catch (error) {
  5459. throwError(error, 'Steam.getGroupID');
  5460. return false;
  5461. }
  5462. }
  5463. async function _joinOfficialGroup2(gameId) {
  5464. try {
  5465. const logStatus = scripts_echoLog({
  5466. type: 'joiningSteamOfficialGroup',
  5467. text: gameId
  5468. });
  5469. const {
  5470. result,
  5471. statusText,
  5472. status,
  5473. data
  5474. } = await tools_httpRequest({
  5475. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5476. method: 'GET',
  5477. headers: {
  5478. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5479. }
  5480. });
  5481. if (result === 'Success') {
  5482. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5483. var _data$responseText$ma8;
  5484. logStatus.success();
  5485. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5486. 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];
  5487. if (groupId) {
  5488. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5489. }
  5490. return true;
  5491. }
  5492. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5493. return false;
  5494. }
  5495. logStatus.error(`${result}:${statusText}(${status})`);
  5496. return false;
  5497. } catch (error) {
  5498. throwError(error, 'Steam.joinOfficialGroup');
  5499. return false;
  5500. }
  5501. }
  5502. async function _leaveOfficialGroup2(gameId) {
  5503. try {
  5504. if (this.whiteList.officialGroups.includes(gameId)) {
  5505. scripts_echoLog({
  5506. type: 'whiteList',
  5507. text: 'Steam.leaveOfficialGroup',
  5508. id: gameId
  5509. });
  5510. return true;
  5511. }
  5512. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5513. if (!groupId) {
  5514. return false;
  5515. }
  5516. const logStatus = scripts_echoLog({
  5517. type: 'leavingSteamOfficialGroup',
  5518. text: gameId
  5519. });
  5520. const {
  5521. result,
  5522. statusText,
  5523. status,
  5524. data
  5525. } = await tools_httpRequest({
  5526. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5527. method: 'POST',
  5528. headers: {
  5529. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5530. },
  5531. data: $.param({
  5532. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5533. action: 'leaveGroup',
  5534. groupId: groupId
  5535. })
  5536. });
  5537. if (result === 'Success') {
  5538. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5539. const {
  5540. result: resultR,
  5541. statusText: statusTextR,
  5542. status: statusR,
  5543. data: dataR
  5544. } = await tools_httpRequest({
  5545. url: `https://steamcommunity.com/games/${gameId}`,
  5546. method: 'GET',
  5547. headers: {
  5548. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5549. }
  5550. });
  5551. if (resultR === 'Success') {
  5552. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5553. logStatus.success();
  5554. return true;
  5555. }
  5556. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5557. return false;
  5558. }
  5559. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5560. return false;
  5561. }
  5562. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5563. return false;
  5564. }
  5565. logStatus.error(`${result}:${statusText}(${status})`);
  5566. return false;
  5567. } catch (error) {
  5568. throwError(error, 'Steam.leaveOfficialGroup');
  5569. return false;
  5570. }
  5571. }
  5572. async function _getOfficialGroupId2(gameId) {
  5573. try {
  5574. const logStatus = scripts_echoLog({
  5575. type: 'gettingSteamOfficialGroupId',
  5576. text: gameId
  5577. });
  5578. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5579. if (groupId) {
  5580. logStatus.success();
  5581. return groupId;
  5582. }
  5583. const {
  5584. result,
  5585. statusText,
  5586. status,
  5587. data
  5588. } = await tools_httpRequest({
  5589. url: `https://steamcommunity.com/games/${gameId}`,
  5590. method: 'GET',
  5591. headers: {
  5592. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5593. }
  5594. });
  5595. if (result === 'Success') {
  5596. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5597. var _data$responseText$ma9;
  5598. 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];
  5599. if (groupId) {
  5600. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5601. logStatus.success();
  5602. return groupId;
  5603. }
  5604. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5605. return false;
  5606. }
  5607. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5608. return false;
  5609. }
  5610. logStatus.error(`${result}:${statusText}(${status})`);
  5611. return false;
  5612. } catch (error) {
  5613. throwError(error, 'Steam.getGroupID');
  5614. return false;
  5615. }
  5616. }
  5617. async function _addToWishlist2(gameId) {
  5618. try {
  5619. var _data$response;
  5620. const logStatus = scripts_echoLog({
  5621. type: 'addingToWishlist',
  5622. text: gameId
  5623. });
  5624. const {
  5625. result,
  5626. data
  5627. } = await tools_httpRequest({
  5628. url: 'https://store.steampowered.com/api/addtowishlist',
  5629. method: 'POST',
  5630. headers: {
  5631. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5632. },
  5633. data: $.param({
  5634. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5635. appid: gameId
  5636. }),
  5637. dataType: 'json'
  5638. });
  5639. 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) {
  5640. logStatus.success();
  5641. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5642. return true;
  5643. }
  5644. const {
  5645. result: resultR,
  5646. statusText: statusTextR,
  5647. status: statusR,
  5648. data: dataR
  5649. } = await tools_httpRequest({
  5650. url: `https://store.steampowered.com/app/${gameId}`,
  5651. method: 'GET'
  5652. });
  5653. if (resultR === 'Success') {
  5654. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5655. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5656. logStatus.warning(i18n('changeAreaNotice'));
  5657. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5658. return false;
  5659. }
  5660. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5661. }
  5662. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5663. logStatus.success();
  5664. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5665. return true;
  5666. } 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"')) {
  5667. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5668. return false;
  5669. }
  5670. logStatus.success();
  5671. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5672. return true;
  5673. }
  5674. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5675. return false;
  5676. }
  5677. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5678. return false;
  5679. } catch (error) {
  5680. throwError(error, 'Steam.addToWishlist');
  5681. return false;
  5682. }
  5683. }
  5684. async function _removeFromWishlist2(gameId) {
  5685. try {
  5686. var _data$response2;
  5687. if (this.whiteList.wishlists.includes(gameId)) {
  5688. scripts_echoLog({
  5689. type: 'whiteList',
  5690. text: 'Steam.removeFromWishlist',
  5691. id: gameId
  5692. });
  5693. return true;
  5694. }
  5695. const logStatus = scripts_echoLog({
  5696. type: 'removingFromWishlist',
  5697. text: gameId
  5698. });
  5699. const {
  5700. result,
  5701. data
  5702. } = await tools_httpRequest({
  5703. url: 'https://store.steampowered.com/api/removefromwishlist',
  5704. method: 'POST',
  5705. headers: {
  5706. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5707. },
  5708. data: $.param({
  5709. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5710. appid: gameId
  5711. }),
  5712. dataType: 'json'
  5713. });
  5714. 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) {
  5715. logStatus.success();
  5716. return true;
  5717. }
  5718. const {
  5719. result: resultR,
  5720. statusText: statusTextR,
  5721. status: statusR,
  5722. data: dataR
  5723. } = await tools_httpRequest({
  5724. url: `https://store.steampowered.com/app/${gameId}`,
  5725. method: 'GET'
  5726. });
  5727. if (resultR === 'Success') {
  5728. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5729. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5730. logStatus.warning(i18n('changeAreaNotice'));
  5731. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5732. if (!result || result === 'CN' || result === 'skip') {
  5733. return false;
  5734. }
  5735. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5736. }
  5737. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5738. logStatus.success();
  5739. return true;
  5740. }
  5741. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5742. return false;
  5743. }
  5744. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5745. return false;
  5746. }
  5747. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5748. return false;
  5749. } catch (error) {
  5750. throwError(error, 'Steam.removeFromWishlist');
  5751. return false;
  5752. }
  5753. }
  5754. async function _toggleFollowGame2(gameId, doTask) {
  5755. try {
  5756. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5757. scripts_echoLog({
  5758. type: 'whiteList',
  5759. text: 'Steam.unfollowGame',
  5760. id: gameId
  5761. });
  5762. return true;
  5763. }
  5764. const logStatus = scripts_echoLog({
  5765. type: `${doTask ? '' : 'un'}followingGame`,
  5766. text: gameId
  5767. });
  5768. const requestData = {
  5769. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5770. appid: gameId
  5771. };
  5772. if (!doTask) {
  5773. requestData.unfollow = '1';
  5774. }
  5775. const {
  5776. result,
  5777. data
  5778. } = await tools_httpRequest({
  5779. url: 'https://store.steampowered.com/explore/followgame/',
  5780. method: 'POST',
  5781. headers: {
  5782. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5783. },
  5784. data: $.param(requestData)
  5785. });
  5786. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5787. logStatus.success();
  5788. return true;
  5789. }
  5790. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5791. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5792. logStatus.warning(i18n('changeAreaNotice'));
  5793. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5794. return false;
  5795. }
  5796. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5797. }
  5798. if (doTask === followed) {
  5799. logStatus.success();
  5800. if (doTask) {
  5801. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5802. }
  5803. return true;
  5804. }
  5805. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5806. return false;
  5807. } catch (error) {
  5808. throwError(error, 'Steam.toggleFollowGame');
  5809. return false;
  5810. }
  5811. }
  5812. async function _isFollowedGame2(gameId) {
  5813. try {
  5814. const {
  5815. result,
  5816. data
  5817. } = await tools_httpRequest({
  5818. url: `https://store.steampowered.com/app/${gameId}`,
  5819. method: 'GET'
  5820. });
  5821. if (result === 'Success') {
  5822. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5823. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5824. return 'areaLocked';
  5825. }
  5826. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5827. return true;
  5828. }
  5829. return false;
  5830. }
  5831. return false;
  5832. }
  5833. return false;
  5834. } catch (error) {
  5835. throwError(error, 'Steam.isFollowedGame');
  5836. return false;
  5837. }
  5838. }
  5839. async function _toggleForum2(gameId) {
  5840. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5841. try {
  5842. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5843. scripts_echoLog({
  5844. type: 'whiteList',
  5845. text: 'Steam.unsubscribeForum',
  5846. id: gameId
  5847. });
  5848. return true;
  5849. }
  5850. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5851. if (!forumId) {
  5852. return false;
  5853. }
  5854. const logStatus = scripts_echoLog({
  5855. type: `${doTask ? '' : 'un'}subscribingForum`,
  5856. text: gameId
  5857. });
  5858. const [ id, feature ] = forumId.split('_');
  5859. const {
  5860. result,
  5861. statusText,
  5862. status,
  5863. data
  5864. } = await tools_httpRequest({
  5865. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5866. method: 'POST',
  5867. responseType: 'json',
  5868. headers: {
  5869. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5870. },
  5871. data: $.param({
  5872. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5873. })
  5874. });
  5875. if (result === 'Success') {
  5876. var _data$response3, _data$response4;
  5877. 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)) {
  5878. if (doTask) {
  5879. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5880. }
  5881. logStatus.success();
  5882. return true;
  5883. }
  5884. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5885. return true;
  5886. }
  5887. logStatus.error(`${result}:${statusText}(${status})`);
  5888. return true;
  5889. } catch (error) {
  5890. throwError(error, 'Steam.toggleForum');
  5891. return true;
  5892. }
  5893. }
  5894. async function _getForumId2(gameId) {
  5895. try {
  5896. const logStatus = scripts_echoLog({
  5897. type: 'gettingForumId',
  5898. text: gameId
  5899. });
  5900. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5901. if (forumId) {
  5902. logStatus.success();
  5903. return forumId;
  5904. }
  5905. const {
  5906. result,
  5907. statusText,
  5908. status,
  5909. data
  5910. } = await tools_httpRequest({
  5911. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5912. method: 'GET'
  5913. });
  5914. if (result === 'Success') {
  5915. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5916. var _data$responseText, _data$responseText$ma10;
  5917. 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];
  5918. if (forumId) {
  5919. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5920. logStatus.success();
  5921. return forumId;
  5922. }
  5923. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5924. return false;
  5925. }
  5926. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5927. return false;
  5928. }
  5929. logStatus.error(`${result}:${statusText}(${status})`);
  5930. return false;
  5931. } catch (error) {
  5932. throwError(error, 'Steam.getForumId');
  5933. return false;
  5934. }
  5935. }
  5936. async function _toggleFavoriteWorkshop2(id) {
  5937. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5938. try {
  5939. if (!doTask && this.whiteList.workshops.includes(id)) {
  5940. scripts_echoLog({
  5941. type: 'whiteList',
  5942. text: 'Steam.unfavoriteWorkshop',
  5943. id: id
  5944. });
  5945. return true;
  5946. }
  5947. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5948. if (!appid) {
  5949. return false;
  5950. }
  5951. const logStatus = scripts_echoLog({
  5952. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5953. text: id
  5954. });
  5955. const {
  5956. result,
  5957. statusText,
  5958. status,
  5959. data
  5960. } = await tools_httpRequest({
  5961. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5962. method: 'POST',
  5963. headers: {
  5964. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5965. },
  5966. data: $.param({
  5967. id: id,
  5968. appid: appid,
  5969. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5970. })
  5971. });
  5972. if (result === 'Success') {
  5973. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5974. if (doTask) {
  5975. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5976. }
  5977. logStatus.success();
  5978. return true;
  5979. }
  5980. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5981. return false;
  5982. }
  5983. logStatus.error(`${result}:${statusText}(${status})`);
  5984. return false;
  5985. } catch (error) {
  5986. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5987. return false;
  5988. }
  5989. }
  5990. async function _getWorkshopAppId2(id) {
  5991. try {
  5992. const logStatus = scripts_echoLog({
  5993. type: 'gettingWorkshopAppId',
  5994. text: id
  5995. });
  5996. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5997. if (appId) {
  5998. logStatus.success();
  5999. return appId;
  6000. }
  6001. const {
  6002. result,
  6003. statusText,
  6004. status,
  6005. data
  6006. } = await tools_httpRequest({
  6007. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6008. method: 'GET'
  6009. });
  6010. if (result === 'Success') {
  6011. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6012. var _data$responseText$ma11;
  6013. 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];
  6014. if (appId) {
  6015. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6016. logStatus.success();
  6017. return appId;
  6018. }
  6019. logStatus.error('Error: getWorkshopAppId failed');
  6020. return false;
  6021. }
  6022. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6023. return false;
  6024. }
  6025. logStatus.error(`${result}:${statusText}(${status})`);
  6026. return false;
  6027. } catch (error) {
  6028. throwError(error, 'Steam.getWorkshopAppId');
  6029. return false;
  6030. }
  6031. }
  6032. async function _voteUpWorkshop2(id) {
  6033. try {
  6034. const logStatus = scripts_echoLog({
  6035. type: 'votingUpWorkshop',
  6036. text: id
  6037. });
  6038. const {
  6039. result,
  6040. statusText,
  6041. status,
  6042. data
  6043. } = await tools_httpRequest({
  6044. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6045. method: 'POST',
  6046. responseType: 'json',
  6047. headers: {
  6048. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6049. },
  6050. data: $.param({
  6051. id: id,
  6052. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6053. })
  6054. });
  6055. if (result === 'Success') {
  6056. var _data$response5;
  6057. 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) {
  6058. logStatus.success();
  6059. return true;
  6060. }
  6061. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6062. return true;
  6063. }
  6064. logStatus.error(`${result}:${statusText}(${status})`);
  6065. return true;
  6066. } catch (error) {
  6067. throwError(error, 'Steam.voteupWorkshop');
  6068. return true;
  6069. }
  6070. }
  6071. async function _toggleCurator2(curatorId) {
  6072. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6073. try {
  6074. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6075. scripts_echoLog({
  6076. type: 'whiteList',
  6077. text: 'Steam.unfollowCurator',
  6078. id: curatorId
  6079. });
  6080. return true;
  6081. }
  6082. const logStatus = scripts_echoLog({
  6083. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6084. text: curatorId
  6085. });
  6086. const {
  6087. result,
  6088. statusText,
  6089. status,
  6090. data
  6091. } = await tools_httpRequest({
  6092. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6093. method: 'POST',
  6094. headers: {
  6095. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6096. },
  6097. data: $.param({
  6098. clanid: curatorId,
  6099. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6100. follow: doTask
  6101. }),
  6102. dataType: 'json'
  6103. });
  6104. if (result === 'Success') {
  6105. var _data$response6, _data$response6$succe, _data$response7;
  6106. 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) {
  6107. logStatus.success();
  6108. return true;
  6109. }
  6110. 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})`);
  6111. return false;
  6112. }
  6113. logStatus.error(`${result}:${statusText}(${status})`);
  6114. return false;
  6115. } catch (error) {
  6116. throwError(error, 'Steam.toggleCurator');
  6117. return false;
  6118. }
  6119. }
  6120. async function _toggleCuratorLike2(link) {
  6121. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6122. try {
  6123. const [ path, name ] = link.split('/');
  6124. if (!(path && name)) {
  6125. scripts_echoLog({
  6126. text: i18n('errorLink', link)
  6127. });
  6128. return false;
  6129. }
  6130. const curatorId = await this.getCuratorId(path, name);
  6131. if (curatorId) {
  6132. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6133. }
  6134. return false;
  6135. } catch (error) {
  6136. throwError(error, 'Steam.toggleCuratorLike');
  6137. return false;
  6138. }
  6139. }
  6140. async function _getAnnouncementParams2(appId, viewId) {
  6141. try {
  6142. const logStatus = scripts_echoLog({
  6143. type: 'gettingAnnouncementParams',
  6144. text: appId,
  6145. id: viewId
  6146. });
  6147. const {
  6148. result,
  6149. statusText,
  6150. status,
  6151. data
  6152. } = await tools_httpRequest({
  6153. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6154. method: 'GET',
  6155. headers: {
  6156. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6157. }
  6158. });
  6159. if (result === 'Success') {
  6160. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6161. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6162. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6163. logStatus.warning(i18n('changeAreaNotice'));
  6164. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6165. return {};
  6166. }
  6167. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6168. }
  6169. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6170. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6171. 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];
  6172. if (authWgToken && clanId) {
  6173. logStatus.success();
  6174. return {
  6175. authWgToken: authWgToken,
  6176. clanId: clanId,
  6177. gid: gid
  6178. };
  6179. }
  6180. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6181. return {};
  6182. }
  6183. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6184. return {};
  6185. }
  6186. logStatus.error(`${result}:${statusText}(${status})`);
  6187. return {};
  6188. } catch (error) {
  6189. throwError(error, 'Steam.likeAnnouncement');
  6190. return {};
  6191. }
  6192. }
  6193. async function _likeAnnouncement2(id) {
  6194. try {
  6195. const [ appId, viewId ] = id.split('/');
  6196. if (!(appId && viewId)) {
  6197. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6198. return false;
  6199. }
  6200. const {
  6201. authWgToken,
  6202. clanId,
  6203. gid
  6204. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6205. if (!(authWgToken && clanId)) {
  6206. return false;
  6207. }
  6208. const logStatus = scripts_echoLog({
  6209. type: 'likingAnnouncement',
  6210. text: appId,
  6211. id: viewId
  6212. });
  6213. const {
  6214. result,
  6215. statusText,
  6216. status,
  6217. data
  6218. } = await tools_httpRequest({
  6219. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6220. method: 'POST',
  6221. headers: {
  6222. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6223. Host: 'store.steampowered.com',
  6224. Origin: 'https://store.steampowered.com',
  6225. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6226. },
  6227. data: $.param({
  6228. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6229. wgauthtoken: authWgToken,
  6230. voteup: 1,
  6231. clanid: clanId,
  6232. ajax: 1
  6233. }),
  6234. dataType: 'json'
  6235. });
  6236. if (result === 'Success') {
  6237. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6238. logStatus.success();
  6239. return true;
  6240. }
  6241. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6242. return false;
  6243. }
  6244. logStatus.error(`${result}:${statusText}(${status})`);
  6245. return false;
  6246. } catch (error) {
  6247. throwError(error, 'Steam.likeAnnouncement');
  6248. return false;
  6249. }
  6250. }
  6251. async function _appid2subid2(id) {
  6252. try {
  6253. const logStatus = scripts_echoLog({
  6254. type: 'gettingSubid',
  6255. text: id
  6256. });
  6257. const {
  6258. result,
  6259. statusText,
  6260. status,
  6261. data
  6262. } = await tools_httpRequest({
  6263. url: `https://store.steampowered.com/app/${id}`,
  6264. method: 'GET',
  6265. headers: {
  6266. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6267. }
  6268. });
  6269. if (result === 'Success') {
  6270. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6271. var _data$responseText$ma15;
  6272. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6273. logStatus.warning(i18n('changeAreaNotice'));
  6274. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6275. if (!result || result === 'CN' || result === 'skip') {
  6276. return false;
  6277. }
  6278. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6279. }
  6280. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6281. if (subid) {
  6282. logStatus.success();
  6283. return subid;
  6284. }
  6285. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6286. return false;
  6287. }
  6288. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6289. return false;
  6290. }
  6291. logStatus.error(`${result}:${statusText}(${status})`);
  6292. return false;
  6293. } catch (error) {
  6294. throwError(error, 'Steam.appid2subid');
  6295. return false;
  6296. }
  6297. }
  6298. async function _getLicenses2() {
  6299. try {
  6300. const logStatus = scripts_echoLog({
  6301. text: i18n('gettingLicenses')
  6302. });
  6303. const {
  6304. result,
  6305. statusText,
  6306. status,
  6307. data
  6308. } = await tools_httpRequest({
  6309. url: 'https://store.steampowered.com/account/licenses/',
  6310. method: 'GET'
  6311. });
  6312. if (result === 'Success') {
  6313. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6314. logStatus.success();
  6315. return [ ...data.responseText.matchAll(/RemoveFreeLicense\([\s]*?([\d]+)/g) ].map(arr => arr[1]).filter(subid => subid);
  6316. }
  6317. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6318. return false;
  6319. }
  6320. logStatus.error(`${result}:${statusText}(${status})`);
  6321. return false;
  6322. } catch (error) {
  6323. throwError(error, 'Steam.getLicenses');
  6324. return false;
  6325. }
  6326. }
  6327. async function _addLicense2(id) {
  6328. try {
  6329. const [ type, ids ] = id.split('-');
  6330. if (type === 'appid') {
  6331. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6332. if (!subid) {
  6333. return false;
  6334. }
  6335. const logStatus = scripts_echoLog({
  6336. type: 'addingFreeLicense',
  6337. text: ids
  6338. });
  6339. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6340. return false;
  6341. }
  6342. const {
  6343. result,
  6344. statusText,
  6345. status,
  6346. data
  6347. } = await tools_httpRequest({
  6348. url: `https://store.steampowered.com/app/${ids}`,
  6349. method: 'GET'
  6350. });
  6351. if (result === 'Success') {
  6352. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6353. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6354. logStatus.success();
  6355. return true;
  6356. }
  6357. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6358. return false;
  6359. }
  6360. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6361. return false;
  6362. }
  6363. logStatus.error(`${result}:${statusText}(${status})`);
  6364. return false;
  6365. } else if (type === 'subid') {
  6366. const logStatusArr = {};
  6367. for (const subid of ids.split(',')) {
  6368. const logStatus = scripts_echoLog({
  6369. type: 'addingFreeLicenseSubid',
  6370. text: subid
  6371. });
  6372. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6373. return false;
  6374. }
  6375. logStatusArr[subid] = logStatus;
  6376. }
  6377. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6378. if (!licenses) {
  6379. return false;
  6380. }
  6381. for (const subid of ids.split(',')) {
  6382. if (licenses.includes(subid)) {
  6383. logStatusArr[subid].success();
  6384. } else {
  6385. logStatusArr[subid].error();
  6386. }
  6387. }
  6388. return true;
  6389. }
  6390. return false;
  6391. } catch (error) {
  6392. throwError(error, 'Steam.addLicense');
  6393. return false;
  6394. }
  6395. }
  6396. async function _addFreeLicense2(id, logStatusPre) {
  6397. try {
  6398. const logStatus = logStatusPre || scripts_echoLog({
  6399. type: 'addingFreeLicenseSubid',
  6400. text: id
  6401. });
  6402. const {
  6403. result,
  6404. statusText,
  6405. status,
  6406. data
  6407. } = await tools_httpRequest({
  6408. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6409. method: 'POST',
  6410. headers: {
  6411. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6412. Host: 'store.steampowered.com',
  6413. Origin: 'https://store.steampowered.com',
  6414. Referer: 'https://store.steampowered.com/account/licenses/'
  6415. },
  6416. data: $.param({
  6417. action: 'add_to_cart',
  6418. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6419. subid: id
  6420. }),
  6421. dataType: 'json'
  6422. });
  6423. if (result === 'Success') {
  6424. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6425. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6426. logStatus.warning(i18n('changeAreaNotice'));
  6427. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6428. if (!result || result === 'CN') {
  6429. return false;
  6430. }
  6431. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6432. }
  6433. logStatus.success();
  6434. return true;
  6435. }
  6436. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6437. return false;
  6438. }
  6439. logStatus.error(`${result}:${statusText}(${status})`);
  6440. return false;
  6441. } catch (error) {
  6442. throwError(error, 'Steam.addFreeLicense');
  6443. return false;
  6444. }
  6445. }
  6446. async function _requestPlayTestAccess2(id) {
  6447. try {
  6448. const logStatus = scripts_echoLog({
  6449. type: 'requestingPlayTestAccess',
  6450. text: id
  6451. });
  6452. const {
  6453. result,
  6454. statusText,
  6455. status,
  6456. data
  6457. } = await tools_httpRequest({
  6458. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6459. method: 'POST',
  6460. headers: {
  6461. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6462. Host: 'store.steampowered.com',
  6463. Origin: 'https://store.steampowered.com',
  6464. Referer: `https://store.steampowered.com/app/${id}`
  6465. },
  6466. data: $.param({
  6467. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6468. }),
  6469. dataType: 'json'
  6470. });
  6471. if (result === 'Success') {
  6472. var _data$response8;
  6473. 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) {
  6474. logStatus.success();
  6475. return true;
  6476. }
  6477. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6478. return false;
  6479. }
  6480. logStatus.error(`${result}:${statusText}(${status})`);
  6481. return false;
  6482. } catch (error) {
  6483. throwError(error, 'Steam.requestPlayTestAccess');
  6484. return false;
  6485. }
  6486. }
  6487. function Steam_setCache2(type, name, id) {
  6488. try {
  6489. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6490. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6491. } catch (error) {
  6492. throwError(error, 'Steam.setCache');
  6493. }
  6494. }
  6495. unsafeWindow.Steam = Steam;
  6496. const social_Steam = Steam;
  6497. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6498. Website_checkPrivateRedeclaration(obj, privateSet);
  6499. privateSet.add(obj);
  6500. }
  6501. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6502. if (privateCollection.has(obj)) {
  6503. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6504. }
  6505. }
  6506. function Website_defineProperty(obj, key, value) {
  6507. if (key in obj) {
  6508. Object.defineProperty(obj, key, {
  6509. value: value,
  6510. enumerable: true,
  6511. configurable: true,
  6512. writable: true
  6513. });
  6514. } else {
  6515. obj[key] = value;
  6516. }
  6517. return obj;
  6518. }
  6519. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6520. if (!privateSet.has(receiver)) {
  6521. throw new TypeError('attempted to get private field on non-instance');
  6522. }
  6523. return fn;
  6524. }
  6525. var _bind = new WeakSet();
  6526. class Website {
  6527. constructor() {
  6528. Website_classPrivateMethodInitSpec(this, _bind);
  6529. Website_defineProperty(this, 'undoneTasks', void 0);
  6530. Website_defineProperty(this, 'socialTasks', void 0);
  6531. Website_defineProperty(this, 'giveawayId', void 0);
  6532. Website_defineProperty(this, 'socialInitialized', {
  6533. discord: false,
  6534. instagram: false,
  6535. reddit: false,
  6536. twitch: false,
  6537. twitter: false,
  6538. vk: false,
  6539. youtube: false,
  6540. steamStore: false,
  6541. steamCommunity: false
  6542. });
  6543. Website_defineProperty(this, 'initialized', false);
  6544. Website_defineProperty(this, 'social', {});
  6545. }
  6546. async initSocial(action) {
  6547. try {
  6548. const pro = [];
  6549. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6550. if (tasks.discord) {
  6551. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6552. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6553. this.social.discord = new social_Discord();
  6554. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6555. }
  6556. }
  6557. if (tasks.instagram) {
  6558. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6559. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6560. this.social.instagram = new social_Instagram();
  6561. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6562. }
  6563. }
  6564. if (tasks.reddit) {
  6565. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6566. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6567. this.social.reddit = new social_Reddit();
  6568. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6569. }
  6570. }
  6571. if (tasks.twitch) {
  6572. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6573. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6574. this.social.twitch = new social_Twitch();
  6575. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6576. }
  6577. }
  6578. if (tasks.twitter) {
  6579. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6580. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6581. this.social.twitter = new social_Twitter();
  6582. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6583. }
  6584. }
  6585. if (tasks.vk) {
  6586. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6587. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6588. this.social.vk = new social_Vk();
  6589. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6590. }
  6591. }
  6592. if (tasks.youtube) {
  6593. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6594. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6595. this.social.youtube = new Youtube();
  6596. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6597. }
  6598. }
  6599. if (tasks.steam) {
  6600. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6601. if (steamLength > 0) {
  6602. if (!this.social.steam) {
  6603. this.social.steam = new social_Steam();
  6604. }
  6605. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6606. var _tasks$steam, _tasks$steam$type;
  6607. 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;
  6608. }).reduce((total, number) => total + number, 0);
  6609. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6610. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6611. }
  6612. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6613. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6614. }
  6615. }
  6616. }
  6617. if (tasks.links && tasks.links.length > 0) {
  6618. this.social.visitLink = visitLink;
  6619. }
  6620. return await Promise.all(pro).then(result => {
  6621. let checked = true;
  6622. for (const data of result) {
  6623. if (data.result) {
  6624. this.socialInitialized[data.name] = data.result;
  6625. } else {
  6626. checked = false;
  6627. }
  6628. }
  6629. return checked;
  6630. });
  6631. } catch (error) {
  6632. throwError(error, 'Website.initSocial');
  6633. return false;
  6634. }
  6635. }
  6636. uniqueTasks(allTasks) {
  6637. const result = {};
  6638. for (const [ social, types ] of Object.entries(allTasks)) {
  6639. result[social] = {};
  6640. for (const [ type, tasks ] of Object.entries(types)) {
  6641. result[social][type] = unique(tasks);
  6642. }
  6643. }
  6644. return result;
  6645. }
  6646. async toggleTask(action) {
  6647. try {
  6648. if (!this.initialized && !this.init()) {
  6649. return false;
  6650. }
  6651. if (!await this.classifyTask(action)) {
  6652. return false;
  6653. }
  6654. if (!await this.initSocial(action)) {
  6655. return false;
  6656. }
  6657. const pro = [];
  6658. const doTask = action === 'do';
  6659. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6660. if (this.social.discord) {
  6661. pro.push(this.social.discord.toggle({
  6662. doTask: doTask,
  6663. ...tasks.discord
  6664. }));
  6665. }
  6666. if (this.social.instagram) {
  6667. pro.push(this.social.instagram.toggle({
  6668. doTask: doTask,
  6669. ...tasks.instagram
  6670. }));
  6671. }
  6672. if (this.social.reddit) {
  6673. pro.push(this.social.reddit.toggle({
  6674. doTask: doTask,
  6675. ...tasks.reddit
  6676. }));
  6677. }
  6678. if (this.social.twitch) {
  6679. pro.push(this.social.twitch.toggle({
  6680. doTask: doTask,
  6681. ...tasks.twitch
  6682. }));
  6683. }
  6684. if (this.social.twitter) {
  6685. pro.push(this.social.twitter.toggle({
  6686. doTask: doTask,
  6687. ...tasks.twitter
  6688. }));
  6689. }
  6690. if (this.social.vk) {
  6691. pro.push(this.social.vk.toggle({
  6692. doTask: doTask,
  6693. ...tasks.vk
  6694. }));
  6695. }
  6696. if (this.social.youtube) {
  6697. pro.push(this.social.youtube.toggle({
  6698. doTask: doTask,
  6699. ...tasks.youtube
  6700. }));
  6701. }
  6702. if (this.social.steam) {
  6703. pro.push(this.social.steam.toggle({
  6704. doTask: doTask,
  6705. ...tasks.steam
  6706. }));
  6707. }
  6708. if (this.social.visitLink && tasks.links && doTask) {
  6709. for (const link of tasks.links) {
  6710. pro.push(this.social.visitLink(link));
  6711. }
  6712. }
  6713. if (doTask && tasks.extra && this.extraDoTask) {
  6714. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6715. if (hasExtra) {
  6716. pro.push(this.extraDoTask(tasks.extra));
  6717. }
  6718. }
  6719. await Promise.all(pro);
  6720. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6721. return true;
  6722. } catch (error) {
  6723. throwError(error, 'Website.toggleTask');
  6724. return false;
  6725. }
  6726. }
  6727. async doTask() {
  6728. try {
  6729. return await this.toggleTask('do');
  6730. } catch (error) {
  6731. throwError(error, 'Website.doTask');
  6732. return false;
  6733. }
  6734. }
  6735. async undoTask() {
  6736. try {
  6737. return await this.toggleTask('undo');
  6738. } catch (error) {
  6739. throwError(error, 'Website.undoTask');
  6740. return false;
  6741. }
  6742. }
  6743. }
  6744. async function _bind2(name, init) {
  6745. try {
  6746. return {
  6747. name: name,
  6748. result: await init
  6749. };
  6750. } catch (error) {
  6751. throwError(error, 'Website.bind');
  6752. return {
  6753. name: name,
  6754. result: false
  6755. };
  6756. }
  6757. }
  6758. const website_Website = Website;
  6759. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6760. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6761. privateSet.add(obj);
  6762. }
  6763. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6764. if (privateCollection.has(obj)) {
  6765. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6766. }
  6767. }
  6768. function FreeAnyWhere_defineProperty(obj, key, value) {
  6769. if (key in obj) {
  6770. Object.defineProperty(obj, key, {
  6771. value: value,
  6772. enumerable: true,
  6773. configurable: true,
  6774. writable: true
  6775. });
  6776. } else {
  6777. obj[key] = value;
  6778. }
  6779. return obj;
  6780. }
  6781. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6782. if (!privateSet.has(receiver)) {
  6783. throw new TypeError('attempted to get private field on non-instance');
  6784. }
  6785. return fn;
  6786. }
  6787. const FreeAnyWhere_defaultTasksTemplate = {
  6788. steam: {
  6789. groupLinks: [],
  6790. wishlistLinks: [],
  6791. curatorLinks: [],
  6792. followLinks: []
  6793. },
  6794. vk: {
  6795. nameLinks: []
  6796. }
  6797. };
  6798. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6799. var _getGiveawayId = new WeakSet();
  6800. var _verify = new WeakSet();
  6801. class FreeAnyWhere extends website_Website {
  6802. constructor() {
  6803. super(...arguments);
  6804. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6805. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6806. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6807. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6808. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6809. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6810. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6811. }
  6812. static test() {
  6813. return window.location.host === 'freeanywhere.net';
  6814. }
  6815. init() {
  6816. try {
  6817. const logStatus = scripts_echoLog({
  6818. text: i18n('initing')
  6819. });
  6820. if ($('a[href="#/login"]').length > 0) {
  6821. window.open('/#/login', '_self');
  6822. logStatus.warning(i18n('needLogin'));
  6823. return false;
  6824. }
  6825. if (window.location.href.includes('/login')) {
  6826. logStatus.warning(i18n('needLogin'));
  6827. return false;
  6828. }
  6829. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6830. var _window$location$href;
  6831. 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];
  6832. if (!id) {
  6833. logStatus.error(i18n('getFailed', 'Id'));
  6834. return false;
  6835. }
  6836. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6837. }
  6838. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6839. return false;
  6840. }
  6841. this.initialized = true;
  6842. logStatus.success();
  6843. return true;
  6844. } catch (error) {
  6845. throwError(error, 'Freeanywhere.init');
  6846. return false;
  6847. }
  6848. }
  6849. async classifyTask(action) {
  6850. try {
  6851. const logStatus = scripts_echoLog({
  6852. text: i18n('getTasksInfo')
  6853. });
  6854. if (action === 'undo') {
  6855. var _GM_getValue;
  6856. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6857. }
  6858. const {
  6859. result,
  6860. statusText,
  6861. status,
  6862. data
  6863. } = await tools_httpRequest({
  6864. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6865. method: 'GET',
  6866. headers: {
  6867. authorization: `Token ${window.localStorage.getItem('token')}`,
  6868. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6869. },
  6870. responseType: 'json'
  6871. });
  6872. if (result === 'Success') {
  6873. var _data$response;
  6874. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6875. if (tasks) {
  6876. if (action === 'verify') {
  6877. this.tasks = [];
  6878. }
  6879. for (const task of tasks) {
  6880. const type = task.challenge;
  6881. const social = task.challenge_provider;
  6882. const taskInfo = {
  6883. id: task.id,
  6884. title: task.title
  6885. };
  6886. if (action === 'verify' && !task.is_success) {
  6887. this.tasks.push(taskInfo);
  6888. continue;
  6889. }
  6890. switch (social) {
  6891. case 'steam':
  6892. taskInfo.social = 'steam';
  6893. switch (type) {
  6894. case 'WL':
  6895. if (action === 'undo') {
  6896. this.socialTasks.steam.wishlistLinks.push(task.link);
  6897. }
  6898. if (action === 'do' && !task.is_success) {
  6899. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6900. }
  6901. break;
  6902.  
  6903. case 'JTG':
  6904. if (action === 'undo') {
  6905. this.socialTasks.steam.groupLinks.push(task.link);
  6906. }
  6907. if (action === 'do' && !task.is_success) {
  6908. this.undoneTasks.steam.groupLinks.push(task.link);
  6909. }
  6910. break;
  6911.  
  6912. case 'STC':
  6913. if (action === 'undo') {
  6914. this.socialTasks.steam.curatorLinks.push(task.link);
  6915. }
  6916. if (action === 'do' && !task.is_success) {
  6917. this.undoneTasks.steam.curatorLinks.push(task.link);
  6918. }
  6919. break;
  6920.  
  6921. case 'GF':
  6922. if (action === 'undo') {
  6923. this.socialTasks.steam.followLinks.push(task.link);
  6924. }
  6925. if (action === 'do' && !task.is_success) {
  6926. this.undoneTasks.steam.followLinks.push(task.link);
  6927. }
  6928. break;
  6929. }
  6930. break;
  6931.  
  6932. case 'vk-oauth2':
  6933. if (action === 'undo') {
  6934. this.socialTasks.vk.nameLinks.push(task.link);
  6935. }
  6936. if (action === 'do' && !task.is_success) {
  6937. this.undoneTasks.vk.nameLinks.push(task.link);
  6938. }
  6939. break;
  6940.  
  6941. case 'website':
  6942. break;
  6943.  
  6944. default:
  6945. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6946. break;
  6947. }
  6948. }
  6949. logStatus.success();
  6950. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6951. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6952. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6953. tasks: this.socialTasks,
  6954. time: new Date().getTime()
  6955. });
  6956. return true;
  6957. }
  6958. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6959. console.error(data);
  6960. return false;
  6961. }
  6962. logStatus.error(`${result}:${statusText}(${status})`);
  6963. return false;
  6964. } catch (error) {
  6965. throwError(error, 'Freeanywhere.classifyTask');
  6966. return false;
  6967. }
  6968. }
  6969. async verifyTask() {
  6970. try {
  6971. if (!this.initialized && !this.init()) {
  6972. return false;
  6973. }
  6974. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6975. return false;
  6976. }
  6977. const pro = [];
  6978. for (const task of this.tasks) {
  6979. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6980. await delay(1e3);
  6981. }
  6982. await Promise.all(pro);
  6983. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6984. return !!await this.getKey(true);
  6985. } catch (error) {
  6986. throwError(error, 'Freeanywhere.verifyTask');
  6987. return false;
  6988. }
  6989. }
  6990. async getKey(initialized) {
  6991. try {
  6992. if (!initialized && !this.initialized && !this.init()) {
  6993. return false;
  6994. }
  6995. const logStatus = scripts_echoLog({
  6996. text: i18n('gettingKey')
  6997. });
  6998. const {
  6999. result,
  7000. statusText,
  7001. status,
  7002. data
  7003. } = await tools_httpRequest({
  7004. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7005. method: 'GET',
  7006. dataType: 'json',
  7007. headers: {
  7008. authorization: `Token ${window.localStorage.getItem('token')}`
  7009. }
  7010. });
  7011. if (result === 'Success') {
  7012. var _data$response2;
  7013. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7014. logStatus.success();
  7015. scripts_echoLog({}).success(data.response.reward);
  7016. return data.response.reward;
  7017. }
  7018. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7019. return false;
  7020. }
  7021. logStatus.error(`${result}:${statusText}(${status})`);
  7022. return false;
  7023. } catch (error) {
  7024. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7025. return false;
  7026. }
  7027. }
  7028. }
  7029. function _getGiveawayId2() {
  7030. try {
  7031. var _window$location$href2;
  7032. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7033. if (giveawayId) {
  7034. this.giveawayId = giveawayId;
  7035. return true;
  7036. }
  7037. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7038. return false;
  7039. } catch (error) {
  7040. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7041. }
  7042. }
  7043. async function _verify2(task) {
  7044. try {
  7045. const logStatus = scripts_echoLog({
  7046. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7047. });
  7048. const {
  7049. result,
  7050. statusText,
  7051. status,
  7052. data
  7053. } = await tools_httpRequest({
  7054. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7055. method: 'GET',
  7056. dataType: 'json',
  7057. headers: {
  7058. authorization: `Token ${window.localStorage.getItem('token')}`,
  7059. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7060. }
  7061. });
  7062. if (result === 'Success') {
  7063. var _data$response3;
  7064. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7065. logStatus.success();
  7066. return true;
  7067. }
  7068. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7069. return false;
  7070. }
  7071. logStatus.error(`${result}:${statusText}(${status})`);
  7072. return false;
  7073. } catch (error) {
  7074. throwError(error, 'Freeanywhere.verify');
  7075. return false;
  7076. }
  7077. }
  7078. const website_FreeAnyWhere = FreeAnyWhere;
  7079. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7080. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7081. privateSet.add(obj);
  7082. }
  7083. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7084. if (privateCollection.has(obj)) {
  7085. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7086. }
  7087. }
  7088. function GiveawaySu_defineProperty(obj, key, value) {
  7089. if (key in obj) {
  7090. Object.defineProperty(obj, key, {
  7091. value: value,
  7092. enumerable: true,
  7093. configurable: true,
  7094. writable: true
  7095. });
  7096. } else {
  7097. obj[key] = value;
  7098. }
  7099. return obj;
  7100. }
  7101. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7102. if (!privateSet.has(receiver)) {
  7103. throw new TypeError('attempted to get private field on non-instance');
  7104. }
  7105. return fn;
  7106. }
  7107. const GiveawaySu_defaultTasks = {
  7108. steam: {
  7109. groupLinks: [],
  7110. wishlistLinks: [],
  7111. curatorLinks: [],
  7112. curatorLikeLinks: [],
  7113. followLinks: [],
  7114. forumLinks: [],
  7115. announcementLinks: [],
  7116. workshopVoteLinks: [],
  7117. playtestLinks: []
  7118. },
  7119. discord: {
  7120. serverLinks: []
  7121. },
  7122. instagram: {
  7123. userLinks: []
  7124. },
  7125. vk: {
  7126. nameLinks: []
  7127. },
  7128. twitch: {
  7129. channelLinks: []
  7130. },
  7131. reddit: {
  7132. redditLinks: []
  7133. },
  7134. youtube: {
  7135. channelLinks: [],
  7136. likeLinks: []
  7137. }
  7138. };
  7139. var _checkLogin = new WeakSet();
  7140. var _checkLeftKey = new WeakSet();
  7141. var GiveawaySu_getGiveawayId = new WeakSet();
  7142. class GiveawaySu extends website_Website {
  7143. constructor() {
  7144. super(...arguments);
  7145. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7146. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  7147. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7148. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7149. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7150. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7151. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7152. }
  7153. static test() {
  7154. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7155. }
  7156. async after() {
  7157. try {
  7158. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7159. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7160. }
  7161. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7162. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7163. }
  7164. scripts_echoLog({}).warning(i18n('gsNotice'));
  7165. } catch (error) {
  7166. throwError(error, 'Giveawaysu.after');
  7167. }
  7168. }
  7169. init() {
  7170. try {
  7171. const logStatus = scripts_echoLog({
  7172. text: i18n('initing')
  7173. });
  7174. if ($('a.steam-login').length > 0) {
  7175. window.open('/steam/redirect', '_self');
  7176. logStatus.warning(i18n('needLogin'));
  7177. return false;
  7178. }
  7179. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7180. return false;
  7181. }
  7182. this.initialized = true;
  7183. logStatus.success();
  7184. return true;
  7185. } catch (error) {
  7186. throwError(error, 'Giveawaysu.init');
  7187. return false;
  7188. }
  7189. }
  7190. async classifyTask(action) {
  7191. try {
  7192. const logStatus = scripts_echoLog({
  7193. text: i18n('getTasksInfo')
  7194. });
  7195. if (action === 'undo') {
  7196. var _GM_getValue;
  7197. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7198. return true;
  7199. }
  7200. const pro = [];
  7201. const tasks = $('#actions tr');
  7202. if ($('div.bind-discord').is(':visible')) {
  7203. $('div.bind-discord a')[0].click();
  7204. }
  7205. if ($('div.bind-twitch').is(':visible')) {
  7206. $('div.bind-twitch a')[0].click();
  7207. }
  7208. for (const task of tasks) {
  7209. pro.push(new Promise(resolve => {
  7210. const td = $(task).find('td:not(".hidden")');
  7211. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7212. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7213. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7214. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7215. const taskName = taskDes.text().trim();
  7216. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7217. return resolve(true);
  7218. }
  7219. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7220. if (!taskLink) {
  7221. return resolve(false);
  7222. }
  7223. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7224. this.undoneTasks.steam.groupLinks.push(taskLink);
  7225. } else if (/like.*announcement/gi.test(taskName)) {
  7226. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7227. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7228. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7229. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7230. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7231. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7232. this.undoneTasks.steam.forumLinks.push(taskLink);
  7233. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7234. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7235. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7236. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7237. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7238. this.undoneTasks.discord.serverLinks.push(taskLink);
  7239. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7240. this.undoneTasks.instagram.userLinks.push(taskLink);
  7241. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7242. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7243. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7244. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7245. } else if (/watch.*art/gim.test(taskName)) {
  7246. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7247. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7248. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7249. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7250. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7251. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7252. this.undoneTasks.vk.nameLinks.push(taskLink);
  7253. } else {
  7254. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7255. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7256. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7257. }
  7258. if (/follow.*button/gim.test(taskName)) {
  7259. this.undoneTasks.steam.followLinks.push(taskLink);
  7260. }
  7261. }
  7262. }
  7263. resolve(true);
  7264. }).catch(error => {
  7265. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7266. return false;
  7267. });
  7268. }));
  7269. }
  7270. await Promise.all(pro);
  7271. logStatus.success();
  7272. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7273. this.socialTasks = this.undoneTasks;
  7274. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7275. tasks: this.socialTasks,
  7276. time: new Date().getTime()
  7277. });
  7278. return true;
  7279. } catch (error) {
  7280. throwError(error, 'Giveawaysu.classifyTask');
  7281. return false;
  7282. }
  7283. }
  7284. }
  7285. function _checkLogin2() {
  7286. try {
  7287. if (!globalOptions.other.checkLogin) {
  7288. return true;
  7289. }
  7290. if ($('a.steam-login').length > 0) {
  7291. window.open('/steam/redirect', '_self');
  7292. }
  7293. return true;
  7294. } catch (error) {
  7295. throwError(error, 'Giveawaysu.checkLogin');
  7296. return false;
  7297. }
  7298. }
  7299. async function _checkLeftKey2() {
  7300. try {
  7301. if (!globalOptions.other.checkLeftKey) {
  7302. return true;
  7303. }
  7304. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7305. await external_Swal_default().fire({
  7306. icon: 'warning',
  7307. title: i18n('notice'),
  7308. text: i18n('noKeysLeft'),
  7309. confirmButtonText: i18n('confirm'),
  7310. cancelButtonText: i18n('cancel'),
  7311. showCancelButton: true
  7312. }).then(_ref => {
  7313. let {
  7314. value
  7315. } = _ref;
  7316. if (value) {
  7317. window.close();
  7318. }
  7319. });
  7320. }
  7321. return true;
  7322. } catch (error) {
  7323. throwError(error, 'Giveawaysu.checkLeftKey');
  7324. return false;
  7325. }
  7326. }
  7327. function GiveawaySu_getGiveawayId2() {
  7328. var _window$location$href;
  7329. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7330. if (giveawayId) {
  7331. this.giveawayId = giveawayId;
  7332. return true;
  7333. }
  7334. scripts_echoLog({
  7335. text: i18n('getFailed', 'GiveawayId')
  7336. });
  7337. return false;
  7338. }
  7339. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7340. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7341. privateSet.add(obj);
  7342. }
  7343. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7344. if (privateCollection.has(obj)) {
  7345. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7346. }
  7347. }
  7348. function Indiedb_defineProperty(obj, key, value) {
  7349. if (key in obj) {
  7350. Object.defineProperty(obj, key, {
  7351. value: value,
  7352. enumerable: true,
  7353. configurable: true,
  7354. writable: true
  7355. });
  7356. } else {
  7357. obj[key] = value;
  7358. }
  7359. return obj;
  7360. }
  7361. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7362. if (!privateSet.has(receiver)) {
  7363. throw new TypeError('attempted to get private field on non-instance');
  7364. }
  7365. return fn;
  7366. }
  7367. var _join = new WeakSet();
  7368. var _do = new WeakSet();
  7369. var Indiedb_checkLogin = new WeakSet();
  7370. var Indiedb_checkLeftKey = new WeakSet();
  7371. class Indiedb {
  7372. constructor() {
  7373. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7374. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7375. Indiedb_classPrivateMethodInitSpec(this, _do);
  7376. Indiedb_classPrivateMethodInitSpec(this, _join);
  7377. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7378. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7379. }
  7380. static test() {
  7381. return window.location.host === 'www.indiedb.com';
  7382. }
  7383. async after() {
  7384. try {
  7385. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7386. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7387. }
  7388. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7389. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7390. }
  7391. } catch (error) {
  7392. throwError(error, 'Indiedb.after');
  7393. }
  7394. }
  7395. async doTask() {
  7396. try {
  7397. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7398. return false;
  7399. }
  7400. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7401. } catch (error) {
  7402. throwError(error, 'Indiedb.doTask');
  7403. return false;
  7404. }
  7405. }
  7406. }
  7407. async function _join2() {
  7408. try {
  7409. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7410. scripts_echoLog({}).error(i18n('needLogin'));
  7411. return false;
  7412. }
  7413. const currentoption = $('a.buttonenter.buttongiveaway');
  7414. if (/join giveaway/gim.test(currentoption.text())) {
  7415. const logStatus = scripts_echoLog({
  7416. text: `${i18n('joiningGiveaway')}...`
  7417. });
  7418. const {
  7419. result,
  7420. statusText,
  7421. status,
  7422. data
  7423. } = await tools_httpRequest({
  7424. url: currentoption.attr('href'),
  7425. method: 'POST',
  7426. data: 'ajax=t',
  7427. dataType: 'json',
  7428. headers: {
  7429. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7430. accept: 'application/json, text/javascript, */*; q=0.01',
  7431. origin: window.location.origin
  7432. }
  7433. });
  7434. if (result === 'Success') {
  7435. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7436. var _data$response, _data$response4, _data$response5;
  7437. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7438. var _data$response2, _data$response3;
  7439. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7440. $('#giveawaysjoined').slideDown();
  7441. $('#giveawaysrecommend').slideDown();
  7442. 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}` : ''}`);
  7443. return true;
  7444. }
  7445. 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}` : ''}`);
  7446. return false;
  7447. }
  7448. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7449. return false;
  7450. }
  7451. logStatus.error(`${result}:${statusText}(${status})`);
  7452. return false;
  7453. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7454. return true;
  7455. }
  7456. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7457. return false;
  7458. } catch (error) {
  7459. throwError(error, 'Indiedb.init');
  7460. return false;
  7461. }
  7462. }
  7463. async function _do2() {
  7464. try {
  7465. const id = $('script').map((index, script) => {
  7466. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7467. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7468. 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] ];
  7469. }
  7470. return null;
  7471. });
  7472. if (id.length === 2) {
  7473. const pro = [];
  7474. const tasks = $('#giveawaysjoined a[class*=promo]');
  7475. for (const task of tasks) {
  7476. const promo = $(task);
  7477. if (!promo.hasClass('buttonentered')) {
  7478. const status = scripts_echoLog({
  7479. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7480. });
  7481. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7482. let text = '';
  7483. if (promo.hasClass('facebookpromo')) {
  7484. text = 'facebookpromo';
  7485. } else if (promo.hasClass('twitterpromo')) {
  7486. text = 'twitterpromo';
  7487. } else {
  7488. text = 'visitpromo';
  7489. }
  7490. pro.push(new Promise(resolve => {
  7491. $.ajax({
  7492. type: 'POST',
  7493. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7494. timeout: 6e4,
  7495. dataType: 'json',
  7496. data: {
  7497. ajax: 't'
  7498. },
  7499. error(response, error, exception) {
  7500. console.log({
  7501. response: response,
  7502. error: error,
  7503. exception: exception
  7504. });
  7505. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7506. resolve(true);
  7507. },
  7508. success(response) {
  7509. console.log(response);
  7510. if (response.success) {
  7511. status.success(`Success:${response.text}`);
  7512. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7513. resolve(true);
  7514. } else {
  7515. status.error(`Error:${response.text}`);
  7516. resolve(true);
  7517. }
  7518. }
  7519. });
  7520. }));
  7521. } else if (promo.hasClass('emailoptinpromo')) {
  7522. pro.push(new Promise(resolve => {
  7523. $.ajax({
  7524. type: 'POST',
  7525. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7526. timeout: 6e4,
  7527. dataType: 'json',
  7528. data: {
  7529. ajax: 't',
  7530. emailsystoggle: 4
  7531. },
  7532. error(response, error, exception) {
  7533. console.log({
  7534. response: response,
  7535. error: error,
  7536. exception: exception
  7537. });
  7538. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7539. resolve(true);
  7540. },
  7541. success(response) {
  7542. console.log(response);
  7543. if (response.success) {
  7544. status.success(`Success:${response.text}`);
  7545. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7546. resolve(true);
  7547. } else {
  7548. status.error(`Error:${response.text}`);
  7549. resolve(true);
  7550. }
  7551. }
  7552. });
  7553. }));
  7554. } else if (promo.hasClass('watchingpromo')) {
  7555. pro.push(new Promise(resolve => {
  7556. var _promo$attr;
  7557. const data = getUrlQuery(promo.attr('href'));
  7558. data.ajax = 't';
  7559. $.ajax({
  7560. type: 'POST',
  7561. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7562. timeout: 6e4,
  7563. dataType: 'json',
  7564. data: data,
  7565. error(response, error, exception) {
  7566. console.log({
  7567. response: response,
  7568. error: error,
  7569. exception: exception
  7570. });
  7571. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7572. resolve(true);
  7573. },
  7574. success(response) {
  7575. console.log(response);
  7576. if (response.success) {
  7577. status.success(`Success:${response.text}`);
  7578. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7579. resolve(true);
  7580. } else {
  7581. status.error(`Error:${response.text}`);
  7582. resolve(true);
  7583. }
  7584. }
  7585. });
  7586. }));
  7587. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7588. pro.push(new Promise(resolve => {
  7589. $.ajax({
  7590. type: 'POST',
  7591. url: urlPath(promo.attr('href')),
  7592. timeout: 6e4,
  7593. dataType: 'json',
  7594. data: {
  7595. ajax: 't'
  7596. },
  7597. error(response, error, exception) {
  7598. console.log({
  7599. response: response,
  7600. error: error,
  7601. exception: exception
  7602. });
  7603. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7604. resolve(true);
  7605. },
  7606. success(response) {
  7607. console.log(response);
  7608. if (response.success) {
  7609. status.success(`Success:${response.text}`);
  7610. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7611. resolve(true);
  7612. } else {
  7613. status.error(`Error:${response.text}`);
  7614. resolve(true);
  7615. }
  7616. }
  7617. });
  7618. }));
  7619. } else {
  7620. status.error(`Error:${i18n('unKnownTaskType')}`);
  7621. }
  7622. }
  7623. }
  7624. await Promise.all(pro);
  7625. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7626. return true;
  7627. }
  7628. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7629. return false;
  7630. } catch (error) {
  7631. throwError(error, 'Indiedb.classifyTask');
  7632. return false;
  7633. }
  7634. }
  7635. function Indiedb_checkLogin2() {
  7636. try {
  7637. if (!globalOptions.other.checkLogin) {
  7638. return true;
  7639. }
  7640. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7641. window.open('/members/login', '_self');
  7642. }
  7643. return true;
  7644. } catch (error) {
  7645. throwError(error, 'Indiedb.checkLogin');
  7646. return false;
  7647. }
  7648. }
  7649. async function Indiedb_checkLeftKey2() {
  7650. try {
  7651. if (!globalOptions.other.checkLeftKey) {
  7652. return true;
  7653. }
  7654. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7655. await external_Swal_default().fire({
  7656. icon: 'warning',
  7657. title: i18n('notice'),
  7658. text: i18n('giveawayEnded'),
  7659. confirmButtonText: i18n('confirm'),
  7660. cancelButtonText: i18n('cancel'),
  7661. showCancelButton: true
  7662. }).then(_ref => {
  7663. let {
  7664. value
  7665. } = _ref;
  7666. if (value) {
  7667. window.close();
  7668. }
  7669. });
  7670. }
  7671. return true;
  7672. } catch (error) {
  7673. throwError(error, 'Indiedb.checkLeftKey');
  7674. return false;
  7675. }
  7676. }
  7677. const website_Indiedb = Indiedb;
  7678. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7679. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7680. privateSet.add(obj);
  7681. }
  7682. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7683. if (privateCollection.has(obj)) {
  7684. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7685. }
  7686. }
  7687. function Keyhub_defineProperty(obj, key, value) {
  7688. if (key in obj) {
  7689. Object.defineProperty(obj, key, {
  7690. value: value,
  7691. enumerable: true,
  7692. configurable: true,
  7693. writable: true
  7694. });
  7695. } else {
  7696. obj[key] = value;
  7697. }
  7698. return obj;
  7699. }
  7700. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7701. if (!privateSet.has(receiver)) {
  7702. throw new TypeError('attempted to get private field on non-instance');
  7703. }
  7704. return fn;
  7705. }
  7706. const Keyhub_defaultTasksTemplate = {
  7707. steam: {
  7708. groupLinks: [],
  7709. officialGroupLinks: [],
  7710. wishlistLinks: [],
  7711. curatorLinks: []
  7712. },
  7713. discord: {
  7714. serverLinks: []
  7715. },
  7716. links: []
  7717. };
  7718. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7719. var Keyhub_getGiveawayId = new WeakSet();
  7720. var Keyhub_checkLeftKey = new WeakSet();
  7721. var Keyhub_checkLogin = new WeakSet();
  7722. class Keyhub extends website_Website {
  7723. constructor() {
  7724. super(...arguments);
  7725. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7726. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7727. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7728. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7729. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7730. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7731. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7732. }
  7733. static test() {
  7734. return window.location.host === 'key-hub.eu';
  7735. }
  7736. async after() {
  7737. try {
  7738. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7739. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7740. }
  7741. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7742. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7743. }
  7744. } catch (error) {
  7745. throwError(error, 'Keyhub.after');
  7746. }
  7747. }
  7748. init() {
  7749. try {
  7750. const logStatus = scripts_echoLog({
  7751. text: i18n('initing')
  7752. });
  7753. if ($('a[href*="/connect/steam"]').length > 0) {
  7754. window.open('/connect/steam', '_self');
  7755. logStatus.warning(i18n('needLogin'));
  7756. return false;
  7757. }
  7758. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7759. return false;
  7760. }
  7761. $('#VPNoverlay').hide();
  7762. $('#mainArticleSection').show();
  7763. this.initialized = true;
  7764. logStatus.success();
  7765. return true;
  7766. } catch (error) {
  7767. throwError(error, 'Keyhub.init');
  7768. return false;
  7769. }
  7770. }
  7771. async classifyTask(action) {
  7772. try {
  7773. const logStatus = scripts_echoLog({
  7774. text: i18n('getTasksInfo')
  7775. });
  7776. if (action === 'undo') {
  7777. var _GM_getValue;
  7778. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7779. }
  7780. const tasks = $('.task a');
  7781. for (const task of tasks) {
  7782. let link = $(task).attr('href');
  7783. const taskDes = $(task).text().trim();
  7784. if (!link) {
  7785. continue;
  7786. }
  7787. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7788. link = await getRedirectLink(link) || link;
  7789. }
  7790. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7791. window.open(link, '_blank');
  7792. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7793. if (action === 'undo') {
  7794. this.socialTasks.steam.groupLinks.push(link);
  7795. }
  7796. if (action === 'do') {
  7797. this.undoneTasks.steam.groupLinks.push(link);
  7798. }
  7799. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7800. if (action === 'undo') {
  7801. this.socialTasks.steam.officialGroupLinks.push(link);
  7802. }
  7803. if (action === 'do') {
  7804. this.undoneTasks.steam.officialGroupLinks.push(link);
  7805. }
  7806. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7807. if (action === 'undo') {
  7808. this.socialTasks.steam.wishlistLinks.push(link);
  7809. }
  7810. if (action === 'do') {
  7811. this.undoneTasks.steam.wishlistLinks.push(link);
  7812. }
  7813. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7814. if (action === 'undo') {
  7815. this.socialTasks.steam.curatorLinks.push(link);
  7816. }
  7817. if (action === 'do') {
  7818. this.undoneTasks.steam.curatorLinks.push(link);
  7819. }
  7820. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7821. if (action === 'undo') {
  7822. this.socialTasks.discord.serverLinks.push(link);
  7823. }
  7824. if (action === 'do') {
  7825. this.undoneTasks.discord.serverLinks.push(link);
  7826. }
  7827. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link) || /^https?:\/\/www\.facebook\.com\/.*/.test(link)) {} else {
  7828. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7829. }
  7830. }
  7831. logStatus.success();
  7832. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7833. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7834. GM_setValue(`khTasks-${this.giveawayId}`, {
  7835. tasks: this.socialTasks,
  7836. time: new Date().getTime()
  7837. });
  7838. return true;
  7839. } catch (error) {
  7840. throwError(error, 'Keyhub.classifyTask');
  7841. return false;
  7842. }
  7843. }
  7844. verifyTask() {
  7845. try {
  7846. scripts_echoLog({
  7847. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7848. });
  7849. $.get(window.location.href, res => {
  7850. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7851. });
  7852. } catch (error) {
  7853. throwError(error, 'keyhub.verifyTask');
  7854. }
  7855. }
  7856. }
  7857. function Keyhub_getGiveawayId2() {
  7858. try {
  7859. var _window$location$href;
  7860. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7861. if (giveawayId) {
  7862. this.giveawayId = giveawayId;
  7863. return true;
  7864. }
  7865. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7866. return false;
  7867. } catch (error) {
  7868. throwError(error, 'Keyhub.getGiveawayId');
  7869. return false;
  7870. }
  7871. }
  7872. async function Keyhub_checkLeftKey2() {
  7873. try {
  7874. if (!globalOptions.other.checkLeftKey) {
  7875. return true;
  7876. }
  7877. const leftKey = $('#keysleft').text().trim();
  7878. if (leftKey === '0') {
  7879. await external_Swal_default().fire({
  7880. icon: 'warning',
  7881. title: i18n('notice'),
  7882. text: i18n('noKeysLeft'),
  7883. confirmButtonText: i18n('confirm'),
  7884. cancelButtonText: i18n('cancel'),
  7885. showCancelButton: true
  7886. }).then(_ref => {
  7887. let {
  7888. value
  7889. } = _ref;
  7890. if (value) {
  7891. window.close();
  7892. }
  7893. });
  7894. }
  7895. return true;
  7896. } catch (error) {
  7897. throwError(error, 'Keyhub.checkLeftKey');
  7898. return false;
  7899. }
  7900. }
  7901. function Keyhub_checkLogin2() {
  7902. try {
  7903. if (!globalOptions.other.checkLogin) {
  7904. return true;
  7905. }
  7906. if ($('a[href*="/connect/steam"]').length > 0) {
  7907. window.open('/connect/steam', '_self');
  7908. }
  7909. return true;
  7910. } catch (error) {
  7911. throwError(error, 'Keyhub.checkLogin');
  7912. return false;
  7913. }
  7914. }
  7915. const website_Keyhub = Keyhub;
  7916. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7917. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7918. privateSet.add(obj);
  7919. }
  7920. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7921. if (privateCollection.has(obj)) {
  7922. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7923. }
  7924. }
  7925. function Givekey_defineProperty(obj, key, value) {
  7926. if (key in obj) {
  7927. Object.defineProperty(obj, key, {
  7928. value: value,
  7929. enumerable: true,
  7930. configurable: true,
  7931. writable: true
  7932. });
  7933. } else {
  7934. obj[key] = value;
  7935. }
  7936. return obj;
  7937. }
  7938. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7939. if (!privateSet.has(receiver)) {
  7940. throw new TypeError('attempted to get private field on non-instance');
  7941. }
  7942. return fn;
  7943. }
  7944. const Givekey_defaultTasksTemplate = {
  7945. steam: {
  7946. groupLinks: [],
  7947. wishlistLinks: [],
  7948. curatorLinks: [],
  7949. curatorLikeLinks: []
  7950. },
  7951. twitter: {
  7952. userLinks: []
  7953. },
  7954. vk: {
  7955. nameLinks: []
  7956. },
  7957. discord: {
  7958. serverLinks: []
  7959. }
  7960. };
  7961. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  7962. var Givekey_verify = new WeakSet();
  7963. var Givekey_getGiveawayId = new WeakSet();
  7964. var Givekey_checkLeftKey = new WeakSet();
  7965. class Givekey extends website_Website {
  7966. constructor() {
  7967. super(...arguments);
  7968. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7969. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7970. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7971. Givekey_defineProperty(this, 'name', 'Givekey');
  7972. Givekey_defineProperty(this, 'tasks', []);
  7973. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  7974. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  7975. Givekey_defineProperty(this, 'userId', void 0);
  7976. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7977. }
  7978. static test() {
  7979. return window.location.host === 'givekey.ru';
  7980. }
  7981. async after() {
  7982. try {
  7983. await new Promise(resolve => {
  7984. const checker = setInterval(() => {
  7985. if ($('#navbarDropdown').length > 0) {
  7986. clearInterval(checker);
  7987. resolve(true);
  7988. }
  7989. });
  7990. });
  7991. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7992. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7993. }
  7994. } catch (error) {
  7995. throwError(error, 'Givekey.after');
  7996. return false;
  7997. }
  7998. }
  7999. init() {
  8000. try {
  8001. const logStatus = scripts_echoLog({
  8002. text: i18n('initing')
  8003. });
  8004. if ($('a[href*="/auth/steam"]').length > 0) {
  8005. window.open('/auth/steam', '_self');
  8006. logStatus.warning(i18n('needLogin'));
  8007. return false;
  8008. }
  8009. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8010. return false;
  8011. }
  8012. const userId = $('meta[name="user-id"]').attr('content');
  8013. if (!userId) {
  8014. logStatus.error(i18n('getFailed', i18n('userId')));
  8015. return false;
  8016. }
  8017. this.userId = userId;
  8018. this.initialized = true;
  8019. logStatus.success();
  8020. return true;
  8021. } catch (error) {
  8022. throwError(error, 'Givekey.init');
  8023. return false;
  8024. }
  8025. }
  8026. async classifyTask(action) {
  8027. try {
  8028. const logStatus = scripts_echoLog({
  8029. text: i18n('getTasksInfo')
  8030. });
  8031. if (action === 'undo') {
  8032. var _GM_getValue;
  8033. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8034. }
  8035. const tasks = $('.card-body:has("button") .row');
  8036. for (const task of tasks) {
  8037. const taskEle = $(task);
  8038. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8039. if (isSuccess && action !== 'undo') {
  8040. continue;
  8041. }
  8042. const checkButton = taskEle.find('#task_check');
  8043. const taskId = checkButton.attr('data-id');
  8044. if (taskId) {
  8045. this.tasks.push(taskId);
  8046. }
  8047. if (action === 'verify') {
  8048. continue;
  8049. }
  8050. let href = taskEle.find('a').attr('href') || null;
  8051. const text = taskEle.find('a').text().trim();
  8052. const icon = taskEle.find('i');
  8053. if (!href || !text) {
  8054. continue;
  8055. }
  8056. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8057. href = await getRedirectLink(href);
  8058. }
  8059. if (!href) {
  8060. continue;
  8061. }
  8062. if (/^https?:\/\/vk\.com\//.test(href)) {
  8063. this.socialTasks.vk.nameLinks.push(href);
  8064. if (action === 'do' && !isSuccess) {
  8065. this.undoneTasks.vk.nameLinks.push(href);
  8066. }
  8067. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8068. this.socialTasks.steam.groupLinks.push(href);
  8069. if (action === 'do' && !isSuccess) {
  8070. this.undoneTasks.steam.groupLinks.push(href);
  8071. }
  8072. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8073. this.socialTasks.steam.wishlistLinks.push(href);
  8074. if (action === 'do' && !isSuccess) {
  8075. this.undoneTasks.steam.wishlistLinks.push(href);
  8076. }
  8077. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8078. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8079. this.socialTasks.steam.curatorLinks.push(href);
  8080. if (action === 'do' && !isSuccess) {
  8081. this.undoneTasks.steam.curatorLinks.push(href);
  8082. }
  8083. } else {
  8084. this.socialTasks.steam.curatorLikeLinks.push(href);
  8085. if (action === 'do' && !isSuccess) {
  8086. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8087. }
  8088. }
  8089. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8090. this.socialTasks.twitter.userLinks.push(href);
  8091. if (action === 'do' && !isSuccess) {
  8092. this.undoneTasks.twitter.userLinks.push(href);
  8093. }
  8094. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8095. this.socialTasks.discord.serverLinks.push(href);
  8096. if (action === 'do' && !isSuccess) {
  8097. this.undoneTasks.discord.serverLinks.push(href);
  8098. }
  8099. } else {
  8100. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8101. }
  8102. }
  8103. logStatus.success();
  8104. this.tasks = unique(this.tasks);
  8105. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8106. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8107. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8108. tasks: this.socialTasks,
  8109. time: new Date().getTime()
  8110. });
  8111. return true;
  8112. } catch (error) {
  8113. throwError(error, 'Givekey.classifyTask');
  8114. return false;
  8115. }
  8116. }
  8117. async verifyTask() {
  8118. try {
  8119. if (!this.initialized && !this.init()) {
  8120. return false;
  8121. }
  8122. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8123. return false;
  8124. }
  8125. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8126. const taskLength = this.tasks.length;
  8127. for (let i = 0; i < taskLength; i++) {
  8128. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8129. if (i < taskLength - 1) {
  8130. await delay(15e3);
  8131. }
  8132. }
  8133. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8134. scripts_echoLog({
  8135. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8136. });
  8137. return true;
  8138. } catch (error) {
  8139. throwError(error, 'Givekey.verifyTask');
  8140. return false;
  8141. }
  8142. }
  8143. }
  8144. async function Givekey_verify2(task) {
  8145. try {
  8146. const logStatus = scripts_echoLog({
  8147. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8148. });
  8149. return await new Promise(resolve => {
  8150. $.ajax({
  8151. url: 'https://givekey.ru/giveaway/task',
  8152. method: 'POST',
  8153. data: `id=${task}&user_id=${this.userId}`,
  8154. dataType: 'json',
  8155. headers: {
  8156. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8157. },
  8158. success: data => {
  8159. if (data.btn) {
  8160. $(`button[data-id=${this.userId}]`).html(data.btn);
  8161. }
  8162. if (data.status === 'ok') {
  8163. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8164. logStatus.success();
  8165. resolve(true);
  8166. } else if (data.status === 'end') {
  8167. logStatus.success();
  8168. scripts_echoLog({}).success(data.key);
  8169. resolve(true);
  8170. } else {
  8171. logStatus.error(`Error:${data.msg}`);
  8172. resolve(false);
  8173. }
  8174. },
  8175. error: xhr => {
  8176. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8177. resolve(false);
  8178. }
  8179. });
  8180. });
  8181. } catch (error) {
  8182. throwError(error, 'Givekey.verify');
  8183. return false;
  8184. }
  8185. }
  8186. function Givekey_getGiveawayId2() {
  8187. try {
  8188. var _window$location$href;
  8189. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8190. if (giveawayId) {
  8191. this.giveawayId = giveawayId;
  8192. return true;
  8193. }
  8194. scripts_echoLog({
  8195. text: i18n('getFailed', 'GiveawayId')
  8196. });
  8197. return false;
  8198. } catch (error) {
  8199. throwError(error, 'Givekey.getGiveawayId');
  8200. return false;
  8201. }
  8202. }
  8203. async function Givekey_checkLeftKey2() {
  8204. try {
  8205. if (!globalOptions.other.checkLeftKey) {
  8206. return true;
  8207. }
  8208. if (!$('#keys_count').text()) {
  8209. await external_Swal_default().fire({
  8210. icon: 'warning',
  8211. title: i18n('notice'),
  8212. text: i18n('noKeysLeft'),
  8213. confirmButtonText: i18n('confirm'),
  8214. cancelButtonText: i18n('cancel'),
  8215. showCancelButton: true
  8216. }).then(_ref => {
  8217. let {
  8218. value
  8219. } = _ref;
  8220. if (value) {
  8221. window.close();
  8222. }
  8223. });
  8224. }
  8225. return true;
  8226. } catch (error) {
  8227. throwError(error, 'Givekey.checkLeftKey');
  8228. return false;
  8229. }
  8230. }
  8231. const website_Givekey = Givekey;
  8232. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8233. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8234. privateSet.add(obj);
  8235. }
  8236. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8237. if (privateCollection.has(obj)) {
  8238. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8239. }
  8240. }
  8241. function GiveeClub_defineProperty(obj, key, value) {
  8242. if (key in obj) {
  8243. Object.defineProperty(obj, key, {
  8244. value: value,
  8245. enumerable: true,
  8246. configurable: true,
  8247. writable: true
  8248. });
  8249. } else {
  8250. obj[key] = value;
  8251. }
  8252. return obj;
  8253. }
  8254. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8255. if (!privateSet.has(receiver)) {
  8256. throw new TypeError('attempted to get private field on non-instance');
  8257. }
  8258. return fn;
  8259. }
  8260. var GiveeClub_checkLogin = new WeakSet();
  8261. var GiveeClub_getGiveawayId = new WeakSet();
  8262. var GiveeClub_checkLeftKey = new WeakSet();
  8263. class GiveeClub extends GiveawaySu {
  8264. constructor() {
  8265. super(...arguments);
  8266. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8267. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8268. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8269. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8270. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  8271. }
  8272. static test() {
  8273. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8274. }
  8275. async after() {
  8276. try {
  8277. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8278. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8279. }
  8280. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8281. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8282. }
  8283. } catch (error) {
  8284. throwError(error, 'GiveeClub.after');
  8285. }
  8286. }
  8287. init() {
  8288. try {
  8289. const logStatus = scripts_echoLog({
  8290. text: i18n('initing')
  8291. });
  8292. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8293. logStatus.warning(i18n('needLogin'));
  8294. return false;
  8295. }
  8296. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8297. return false;
  8298. }
  8299. this.initialized = true;
  8300. logStatus.success();
  8301. return true;
  8302. } catch (error) {
  8303. throwError(error, 'GiveeClub.init');
  8304. return false;
  8305. }
  8306. }
  8307. async classifyTask(action) {
  8308. try {
  8309. const logStatus = scripts_echoLog({
  8310. text: i18n('getTasksInfo')
  8311. });
  8312. if (action === 'undo') {
  8313. var _GM_getValue;
  8314. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8315. return true;
  8316. }
  8317. const pro = [];
  8318. const tasks = $('.event-actions tr');
  8319. for (const task of tasks) {
  8320. pro.push(new Promise(resolve => {
  8321. const taskDes = $(task).find('.event-action-label a');
  8322. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8323. const taskName = taskDes.text().trim();
  8324. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8325. return resolve(true);
  8326. }
  8327. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8328. if (!taskLink) {
  8329. return resolve(false);
  8330. }
  8331. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8332. this.undoneTasks.steam.groupLinks.push(taskLink);
  8333. } else if (/like.*announcement/gi.test(taskName)) {
  8334. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8335. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8336. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8337. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  8338. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8339. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8340. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8341. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8342. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8343. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8344. this.undoneTasks.steam.forumLinks.push(taskLink);
  8345. } else if (taskIcon.includes('discord')) {
  8346. this.undoneTasks.discord.serverLinks.push(taskLink);
  8347. } else if (taskIcon.includes('instagram')) {
  8348. this.undoneTasks.instagram.userLinks.push(taskLink);
  8349. } else if (taskIcon.includes('twitch')) {
  8350. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8351. } else if (taskIcon.includes('reddit')) {
  8352. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8353. } else if (/watch.*art/gim.test(taskName)) {
  8354. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8355. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8356. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8357. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8358. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8359. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8360. this.undoneTasks.vk.nameLinks.push(taskLink);
  8361. } else {
  8362. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8363. if (/follow.*button/gim.test(taskName)) {
  8364. this.undoneTasks.steam.followLinks.push(taskLink);
  8365. }
  8366. }
  8367. }
  8368. resolve(true);
  8369. }).catch(error => {
  8370. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8371. return false;
  8372. });
  8373. }));
  8374. }
  8375. await Promise.all(pro);
  8376. logStatus.success();
  8377. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8378. this.socialTasks = this.undoneTasks;
  8379. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8380. tasks: this.socialTasks,
  8381. time: new Date().getTime()
  8382. });
  8383. return true;
  8384. } catch (error) {
  8385. throwError(error, 'GiveeClub.classifyTask');
  8386. return false;
  8387. }
  8388. }
  8389. }
  8390. function GiveeClub_checkLogin2() {
  8391. try {
  8392. if (!globalOptions.other.checkLogin) {
  8393. return true;
  8394. }
  8395. if ($('a[href*="/account/auth"]').length > 0) {
  8396. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8397. }
  8398. return true;
  8399. } catch (error) {
  8400. throwError(error, 'GiveeClub.checkLogin');
  8401. return false;
  8402. }
  8403. }
  8404. function GiveeClub_getGiveawayId2() {
  8405. var _window$location$href;
  8406. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8407. if (giveawayId) {
  8408. this.giveawayId = giveawayId;
  8409. return true;
  8410. }
  8411. scripts_echoLog({
  8412. text: i18n('getFailed', 'GiveawayId')
  8413. });
  8414. return false;
  8415. }
  8416. async function GiveeClub_checkLeftKey2() {
  8417. try {
  8418. if (!globalOptions.other.checkLeftKey) {
  8419. return true;
  8420. }
  8421. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8422. await external_Swal_default().fire({
  8423. icon: 'warning',
  8424. title: i18n('notice'),
  8425. text: i18n('giveawayEnded'),
  8426. confirmButtonText: i18n('confirm'),
  8427. cancelButtonText: i18n('cancel'),
  8428. showCancelButton: true
  8429. }).then(_ref => {
  8430. let {
  8431. value
  8432. } = _ref;
  8433. if (value) {
  8434. window.close();
  8435. }
  8436. });
  8437. }
  8438. return true;
  8439. } catch (error) {
  8440. throwError(error, 'Giveawaysu.checkLeftKey');
  8441. return false;
  8442. }
  8443. }
  8444. const website_GiveeClub = GiveeClub;
  8445. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8446. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8447. privateSet.add(obj);
  8448. }
  8449. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8450. if (privateCollection.has(obj)) {
  8451. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8452. }
  8453. }
  8454. function OpiumPulses_defineProperty(obj, key, value) {
  8455. if (key in obj) {
  8456. Object.defineProperty(obj, key, {
  8457. value: value,
  8458. enumerable: true,
  8459. configurable: true,
  8460. writable: true
  8461. });
  8462. } else {
  8463. obj[key] = value;
  8464. }
  8465. return obj;
  8466. }
  8467. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8468. if (!privateSet.has(receiver)) {
  8469. throw new TypeError('attempted to get private field on non-instance');
  8470. }
  8471. return fn;
  8472. }
  8473. const defaultOptions = {
  8474. maxPoint: '99999999'
  8475. };
  8476. var _toggleTask = new WeakSet();
  8477. var OpiumPulses_checkLogin = new WeakSet();
  8478. class OpiumPulses {
  8479. constructor() {
  8480. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8481. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8482. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8483. OpiumPulses_defineProperty(this, 'options', {
  8484. ...defaultOptions,
  8485. ...GM_getValue('OpiumPulsesOptions')
  8486. });
  8487. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8488. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8489. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8490. }
  8491. static test() {
  8492. return window.location.host === 'www.opiumpulses.com';
  8493. }
  8494. async after() {
  8495. try {
  8496. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8497. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8498. }
  8499. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8500. } catch (error) {
  8501. throwError(error, 'OpiumPulses.after');
  8502. }
  8503. }
  8504. async doFreeTask() {
  8505. try {
  8506. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8507. } catch (error) {
  8508. throwError(error, 'OpiumPulses.doFreeTask');
  8509. }
  8510. }
  8511. async doPointTask() {
  8512. try {
  8513. var _$$text$match;
  8514. 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);
  8515. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8516. } catch (error) {
  8517. throwError(error, 'OpiumPulses.doPointTask');
  8518. }
  8519. }
  8520. init() {
  8521. return true;
  8522. }
  8523. classifyTask() {
  8524. return true;
  8525. }
  8526. }
  8527. async function _toggleTask2(type) {
  8528. try {
  8529. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8530. for (const item of items) {
  8531. var _$$find$text$match;
  8532. 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);
  8533. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8534. if (type === 'points' && needPoints > this.myPoints) {
  8535. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8536. } else if (type === 'points' && !needPoints) {
  8537. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8538. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8539. var _aElement$attr;
  8540. const logStatus = scripts_echoLog({
  8541. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8542. });
  8543. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8544. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8545. var _aElement$attr2, _aElement$attr2$match;
  8546. 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];
  8547. if (giveawayId) {
  8548. checkUser(giveawayId);
  8549. }
  8550. }
  8551. if (!aElement.attr('href')) {
  8552. logStatus.error('Error: No "href".');
  8553. continue;
  8554. }
  8555. const {
  8556. result,
  8557. statusText,
  8558. status,
  8559. data
  8560. } = await tools_httpRequest({
  8561. url: aElement.attr('href'),
  8562. method: 'GET'
  8563. });
  8564. if (result === 'Success') {
  8565. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8566. var _data$responseText$ma;
  8567. logStatus.success();
  8568. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8569. if (type === 'points' && points) {
  8570. this.myPoints = parseInt(points, 10);
  8571. }
  8572. } else {
  8573. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8574. }
  8575. } else {
  8576. logStatus.error(`${result}:${statusText}(${status})`);
  8577. }
  8578. }
  8579. }
  8580. scripts_echoLog({
  8581. text: '-----END-----'
  8582. });
  8583. } catch (error) {
  8584. throwError(error, 'OpiumPulses.toggleTask');
  8585. }
  8586. }
  8587. function OpiumPulses_checkLogin2() {
  8588. try {
  8589. if (!globalOptions.other.checkLogin) {
  8590. return true;
  8591. }
  8592. if ($('a[href*="/site/login"]').length > 1) {
  8593. window.open('/site/login', '_self');
  8594. }
  8595. return true;
  8596. } catch (error) {
  8597. throwError(error, 'OpiumPulses.checkLogin');
  8598. return false;
  8599. }
  8600. }
  8601. const website_OpiumPulses = OpiumPulses;
  8602. const external_dayjs_namespaceObject = dayjs;
  8603. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8604. const leftKeyChecker = {
  8605. async classify(link) {
  8606. try {
  8607. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8608. return await this.giveawaySu(link);
  8609. }
  8610. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8611. return await this.giveeClub(link);
  8612. }
  8613. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8614. return await this.gleam(link);
  8615. }
  8616. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8617. return await this.indieDb(link);
  8618. }
  8619. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8620. return await this.keyhub(link);
  8621. }
  8622. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8623. return await this.opquests(link);
  8624. }
  8625. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8626. return await this.itch(link);
  8627. }
  8628. return false;
  8629. } catch (error) {
  8630. throwError(error, 'leftKeyChecker.classify');
  8631. return false;
  8632. }
  8633. },
  8634. async giveawaySu(link) {
  8635. try {
  8636. const {
  8637. result,
  8638. data
  8639. } = await tools_httpRequest({
  8640. url: link,
  8641. method: 'GET'
  8642. });
  8643. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8644. if (data.responseText.includes('class="steam-login"')) {
  8645. return false;
  8646. }
  8647. if (data.responseText.includes('class="giveaway-ended"')) {
  8648. return 'Ended';
  8649. }
  8650. return 'Active';
  8651. }
  8652. return false;
  8653. } catch (error) {
  8654. throwError(error, 'leftKeyChecker.giveawaySu');
  8655. return false;
  8656. }
  8657. },
  8658. async giveeClub(link) {
  8659. try {
  8660. const {
  8661. result,
  8662. data
  8663. } = await tools_httpRequest({
  8664. url: link,
  8665. method: 'GET'
  8666. });
  8667. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8668. if (data.responseText.includes('class="event-winner"')) {
  8669. return 'Won';
  8670. }
  8671. if (data.responseText.includes('class="event-ended"')) {
  8672. return 'Ended';
  8673. }
  8674. return 'Active';
  8675. }
  8676. return false;
  8677. } catch (error) {
  8678. throwError(error, 'leftKeyChecker.giveeClub');
  8679. return false;
  8680. }
  8681. },
  8682. async gleam(link) {
  8683. try {
  8684. const {
  8685. result,
  8686. data
  8687. } = await tools_httpRequest({
  8688. url: link,
  8689. method: 'GET'
  8690. });
  8691. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8692. var _data$responseText$ma, _$$attr, _$$attr$match;
  8693. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8694. return 'Won';
  8695. }
  8696. 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];
  8697. if (!campaignDiv) {
  8698. return false;
  8699. }
  8700. 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];
  8701. if (!campaignString) {
  8702. return false;
  8703. }
  8704. const {
  8705. campaign
  8706. } = JSON.parse(campaignString);
  8707. if (campaign.banned) {
  8708. return 'Banned';
  8709. }
  8710. if (campaign.finished) {
  8711. return 'Ended';
  8712. }
  8713. if (campaign.paused) {
  8714. return 'Paused';
  8715. }
  8716. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8717. return 'NotStart';
  8718. }
  8719. return 'Active';
  8720. }
  8721. return false;
  8722. } catch (error) {
  8723. throwError(error, 'leftKeyChecker.gleam');
  8724. return false;
  8725. }
  8726. },
  8727. async indieDb(link) {
  8728. try {
  8729. const {
  8730. result,
  8731. data
  8732. } = await tools_httpRequest({
  8733. url: link,
  8734. method: 'GET'
  8735. });
  8736. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8737. if (data.responseText.includes('Congrats you WON')) {
  8738. return 'Won';
  8739. }
  8740. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8741. return 'Ended';
  8742. }
  8743. return 'Active';
  8744. }
  8745. return false;
  8746. } catch (error) {
  8747. throwError(error, 'leftKeyChecker.indieDb');
  8748. return false;
  8749. }
  8750. },
  8751. async keyhub(link) {
  8752. try {
  8753. const {
  8754. result,
  8755. data
  8756. } = await tools_httpRequest({
  8757. url: link,
  8758. method: 'GET'
  8759. });
  8760. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8761. var _data$responseText$ma2;
  8762. 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];
  8763. if (!keysleft) {
  8764. return false;
  8765. }
  8766. if (keysleft === '0') {
  8767. return 'Ended';
  8768. }
  8769. return `Active(${keysleft})`;
  8770. }
  8771. return false;
  8772. } catch (error) {
  8773. throwError(error, 'leftKeyChecker.keyhub');
  8774. return false;
  8775. }
  8776. },
  8777. async opquests(link) {
  8778. try {
  8779. const {
  8780. result,
  8781. data
  8782. } = await tools_httpRequest({
  8783. url: link,
  8784. method: 'GET'
  8785. });
  8786. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8787. var _data$responseText$ma3;
  8788. 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];
  8789. if (!keysleft) {
  8790. return false;
  8791. }
  8792. if (keysleft === '0') {
  8793. return 'Ended';
  8794. }
  8795. return `Active(${keysleft})`;
  8796. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8797. return 'Ended';
  8798. }
  8799. return false;
  8800. } catch (error) {
  8801. throwError(error, 'leftKeyChecker.opquests');
  8802. return false;
  8803. }
  8804. },
  8805. async itch(link) {
  8806. try {
  8807. const {
  8808. result,
  8809. data
  8810. } = await tools_httpRequest({
  8811. url: link,
  8812. method: 'GET'
  8813. });
  8814. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8815. var _data$responseText$ma4;
  8816. 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];
  8817. if (!endDate) {
  8818. return false;
  8819. }
  8820. if (new Date().getTime() > new Date(endDate).getTime()) {
  8821. return 'Ended';
  8822. }
  8823. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8824. }
  8825. return false;
  8826. } catch (error) {
  8827. throwError(error, 'leftKeyChecker.opquests');
  8828. return false;
  8829. }
  8830. }
  8831. };
  8832. const website_leftKeyChecker = leftKeyChecker;
  8833. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8834. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8835. privateSet.add(obj);
  8836. }
  8837. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8838. if (privateCollection.has(obj)) {
  8839. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8840. }
  8841. }
  8842. function Keylol_defineProperty(obj, key, value) {
  8843. if (key in obj) {
  8844. Object.defineProperty(obj, key, {
  8845. value: value,
  8846. enumerable: true,
  8847. configurable: true,
  8848. writable: true
  8849. });
  8850. } else {
  8851. obj[key] = value;
  8852. }
  8853. return obj;
  8854. }
  8855. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8856. if (!privateSet.has(receiver)) {
  8857. throw new TypeError('attempted to get private field on non-instance');
  8858. }
  8859. return fn;
  8860. }
  8861. const Keylol_defaultTasksTemplate = {
  8862. steam: {
  8863. groupLinks: [],
  8864. wishlistLinks: [],
  8865. curatorLinks: [],
  8866. curatorLikeLinks: [],
  8867. followLinks: [],
  8868. forumLinks: [],
  8869. announcementLinks: [],
  8870. workshopVoteLinks: [],
  8871. licenseLinks: []
  8872. },
  8873. discord: {
  8874. serverLinks: []
  8875. },
  8876. instagram: {
  8877. userLinks: []
  8878. },
  8879. vk: {
  8880. nameLinks: []
  8881. },
  8882. twitch: {
  8883. channelLinks: []
  8884. },
  8885. reddit: {
  8886. redditLinks: []
  8887. },
  8888. twitter: {
  8889. userLinks: [],
  8890. retweetLinks: []
  8891. },
  8892. youtube: {
  8893. channelLinks: [],
  8894. likeLinks: []
  8895. }
  8896. };
  8897. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  8898. var _addBtn = new WeakSet();
  8899. class Keylol extends website_Website {
  8900. constructor() {
  8901. super(...arguments);
  8902. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8903. Keylol_defineProperty(this, 'name', 'Keylol');
  8904. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  8905. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  8906. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8907. }
  8908. static test() {
  8909. var _$$eq$attr, _$$eq$attr2;
  8910. 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')));
  8911. }
  8912. init() {
  8913. return true;
  8914. }
  8915. after() {
  8916. try {
  8917. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8918. const mainPost = $(selector);
  8919. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8920. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8921. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8922. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8923. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8924. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8925. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8926. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8927. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8928. if (discordLinks.length > 0) {
  8929. for (const discordLink of discordLinks) {
  8930. const link = $(discordLink).attr('href');
  8931. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8932. continue;
  8933. }
  8934. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8935. }
  8936. }
  8937. if (redditLinks.length > 0) {
  8938. for (const redditLink of redditLinks) {
  8939. const link = $(redditLink).attr('href');
  8940. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8941. continue;
  8942. }
  8943. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8944. }
  8945. }
  8946. if (insLinks.length > 0) {
  8947. for (const insLink of insLinks) {
  8948. const link = $(insLink).attr('href');
  8949. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8950. continue;
  8951. }
  8952. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8953. }
  8954. }
  8955. if (twitterLinks.length > 0) {
  8956. for (const twitterLink of twitterLinks) {
  8957. const link = $(twitterLink).attr('href');
  8958. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8959. continue;
  8960. }
  8961. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8962. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8963. } else {
  8964. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8965. }
  8966. }
  8967. }
  8968. if (twitchLinks.length > 0) {
  8969. for (const twitchLink of twitchLinks) {
  8970. const link = $(twitchLink).attr('href');
  8971. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8972. continue;
  8973. }
  8974. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8975. }
  8976. }
  8977. if (vkLinks.length > 0) {
  8978. for (const vkLink of vkLinks) {
  8979. const link = $(vkLink).attr('href');
  8980. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8981. continue;
  8982. }
  8983. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8984. }
  8985. }
  8986. if (steamStoreLinks.length > 0) {
  8987. for (const steamStoreLink of steamStoreLinks) {
  8988. const link = $(steamStoreLink).attr('href');
  8989. if (!link) {
  8990. continue;
  8991. }
  8992. if (/app\/[\d]+/.test(link)) {
  8993. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8994. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8995. } else if (/curator\/[\d]+/.test(link)) {
  8996. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8997. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8998. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8999. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9000. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9001. }
  9002. }
  9003. }
  9004. if (steamCommunityLinks.length > 0) {
  9005. for (const steamCommunityLink of steamCommunityLinks) {
  9006. const link = $(steamCommunityLink).attr('href');
  9007. if (!link) {
  9008. continue;
  9009. }
  9010. if (/groups\/.+/.test(link)) {
  9011. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9012. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9013. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9014. }
  9015. }
  9016. }
  9017. if (ytbLinks.length > 0) {
  9018. for (const ytbLink of ytbLinks) {
  9019. const link = $(ytbLink).attr('href');
  9020. if (!link) {
  9021. continue;
  9022. }
  9023. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9024. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  9025. }
  9026. }
  9027. const giveawayLinks = mainPost.find('a[href*="giveaway.su/giveaway/view/"],a[href*="givee.club/"],a[href*="gleam.io/"],a[href*="www.indiedb.com/giveaways/"],a[href*="key-hub.eu/giveaway/"],a[href*="opquests.com/quests/"],a[href*="itch.io/s/"]');
  9028. if (giveawayLinks.length > 0) {
  9029. for (const giveawayLink of giveawayLinks) {
  9030. const link = $(giveawayLink).attr('href');
  9031. if (!link) {
  9032. continue;
  9033. }
  9034. website_leftKeyChecker.classify(link).then(status => {
  9035. if (!status) {
  9036. return;
  9037. }
  9038. if (/^Active/.test(status)) {
  9039. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9040. return;
  9041. }
  9042. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9043. }).catch(error => {
  9044. throwError(error, 'keylol.after -> leftKeyChecker');
  9045. });
  9046. }
  9047. }
  9048. if (this.name === 'Keylol') {
  9049. const asfLinks = mainPost.find('a[href^="#asf"]');
  9050. if (asfLinks.length > 0) {
  9051. for (const asfLink of asfLinks) {
  9052. const link = $(asfLink).attr('href');
  9053. if (!link) {
  9054. continue;
  9055. }
  9056. 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', '')}`);
  9057. }
  9058. }
  9059. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]');
  9060. if (subLinks.length > 0) {
  9061. for (const subLink of subLinks) {
  9062. var _link$match;
  9063. const link = $(subLink).attr('href');
  9064. if (!link) {
  9065. continue;
  9066. }
  9067. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9068. if (!subid) {
  9069. continue;
  9070. }
  9071. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9072. }
  9073. }
  9074. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense")');
  9075. if (asfLinks2.length > 0) {
  9076. for (const asfLink of asfLinks2) {
  9077. const subid = [ ...asfLink.innerText.matchAll(/s\/([\d]+)/g) ].map(arr => arr[1]);
  9078. if (subid.length === 0) {
  9079. continue;
  9080. }
  9081. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9082. }
  9083. }
  9084. }
  9085. } catch (error) {
  9086. throwError(error, 'keylol.after');
  9087. }
  9088. }
  9089. classifyTask(action) {
  9090. try {
  9091. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9092. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9093. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  9094. for (const btn of selectedBtns) {
  9095. const button = $(btn);
  9096. const social = button.attr('data-social');
  9097. const type = button.attr('data-type');
  9098. const link = button.attr('data-link');
  9099. if (!(social && type && link)) {
  9100. continue;
  9101. }
  9102. if (action === 'do') {
  9103. this.undoneTasks[social][type].push(link);
  9104. }
  9105. if (action === 'undo') {
  9106. this.socialTasks[social][type].push(link);
  9107. }
  9108. }
  9109. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9110. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9111. return true;
  9112. } catch (error) {
  9113. throwError(error, 'Keylol.classifyTask');
  9114. return false;
  9115. }
  9116. }
  9117. selectAll() {
  9118. try {
  9119. $('.auto-task-keylol').attr('selected', 'selected');
  9120. } catch (error) {
  9121. throwError(error, 'Keylol.selectAll');
  9122. }
  9123. }
  9124. selectNone() {
  9125. try {
  9126. $('.auto-task-keylol').removeAttr('selected');
  9127. } catch (error) {
  9128. throwError(error, 'Keylol.selectNone');
  9129. }
  9130. }
  9131. invertSelect() {
  9132. try {
  9133. $('.auto-task-keylol').each((index, element) => {
  9134. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9135. });
  9136. } catch (error) {
  9137. throwError(error, 'Keylol.invertSelect');
  9138. }
  9139. }
  9140. }
  9141. function _addBtn2(before, social, linkType, link) {
  9142. try {
  9143. $(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>`);
  9144. } catch (error) {
  9145. throwError(error, 'keylol.addBtn');
  9146. }
  9147. }
  9148. const website_Keylol = Keylol;
  9149. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9150. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9151. privateSet.add(obj);
  9152. }
  9153. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9154. if (privateCollection.has(obj)) {
  9155. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9156. }
  9157. }
  9158. function Opquests_defineProperty(obj, key, value) {
  9159. if (key in obj) {
  9160. Object.defineProperty(obj, key, {
  9161. value: value,
  9162. enumerable: true,
  9163. configurable: true,
  9164. writable: true
  9165. });
  9166. } else {
  9167. obj[key] = value;
  9168. }
  9169. return obj;
  9170. }
  9171. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9172. if (!privateSet.has(receiver)) {
  9173. throw new TypeError('attempted to get private field on non-instance');
  9174. }
  9175. return fn;
  9176. }
  9177. const Opquests_defaultTasks = {
  9178. steam: {
  9179. groupLinks: [],
  9180. wishlistLinks: [],
  9181. followLinks: [],
  9182. curatorLikeLinks: []
  9183. }
  9184. };
  9185. var Opquests_getGiveawayId = new WeakSet();
  9186. var Opquests_checkLogin = new WeakSet();
  9187. class Opquests extends website_Website {
  9188. constructor() {
  9189. super(...arguments);
  9190. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9191. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9192. Opquests_defineProperty(this, 'name', 'Opquests');
  9193. Opquests_defineProperty(this, 'undoneTasks', {
  9194. ...Opquests_defaultTasks
  9195. });
  9196. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9197. }
  9198. static test() {
  9199. return window.location.host === 'opquests.com';
  9200. }
  9201. async after() {
  9202. try {
  9203. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9204. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9205. }
  9206. } catch (error) {
  9207. throwError(error, 'Opquests.after');
  9208. }
  9209. }
  9210. init() {
  9211. try {
  9212. const logStatus = scripts_echoLog({
  9213. text: i18n('initing')
  9214. });
  9215. if ($('a[href*="/auth/redirect"]').length > 0) {
  9216. window.open('/auth/redirect', '_self');
  9217. logStatus.warning(i18n('needLogin'));
  9218. return false;
  9219. }
  9220. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9221. return false;
  9222. }
  9223. this.initialized = true;
  9224. logStatus.success();
  9225. return true;
  9226. } catch (error) {
  9227. throwError(error, 'Opquests.init');
  9228. return false;
  9229. }
  9230. }
  9231. async classifyTask(action) {
  9232. try {
  9233. if (action === 'undo') {
  9234. scripts_echoLog({
  9235. text: i18n('cannotUndo')
  9236. });
  9237. return false;
  9238. }
  9239. const logStatus = scripts_echoLog({
  9240. text: i18n('getTasksInfo')
  9241. });
  9242. const tasks = $('.w-full:contains("Validate") .items-center');
  9243. for (const task of tasks) {
  9244. const link = $(task).find('a:contains("Open")').attr('href');
  9245. const taskDes = $(task).find('div').eq(1).text().trim();
  9246. if (!link) {
  9247. continue;
  9248. }
  9249. if (/steamcommunity\.com\/groups\//.test(link)) {
  9250. this.undoneTasks.steam.groupLinks.push(link);
  9251. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9252. if (/wishlist/gim.test(taskDes)) {
  9253. this.undoneTasks.steam.wishlistLinks.push(link);
  9254. } else if (/follow/gim.test(taskDes)) {
  9255. this.undoneTasks.steam.followLinks.push(link);
  9256. }
  9257. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9258. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9259. } else {
  9260. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9261. }
  9262. }
  9263. logStatus.success();
  9264. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9265. return true;
  9266. } catch (error) {
  9267. throwError(error, 'Opquests.classifyTask');
  9268. return false;
  9269. }
  9270. }
  9271. }
  9272. function Opquests_getGiveawayId2() {
  9273. try {
  9274. var _window$location$href;
  9275. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9276. if (giveawayId) {
  9277. this.giveawayId = giveawayId;
  9278. return true;
  9279. }
  9280. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9281. return false;
  9282. } catch (error) {
  9283. throwError(error, 'Opquests.getGiveawayId');
  9284. return false;
  9285. }
  9286. }
  9287. function Opquests_checkLogin2() {
  9288. try {
  9289. if (!globalOptions.other.checkLogin) {
  9290. return true;
  9291. }
  9292. if ($('a[href*="/auth/redirect"]').length > 0) {
  9293. window.open('/auth/redirect', '_self');
  9294. }
  9295. return true;
  9296. } catch (error) {
  9297. throwError(error, 'Opquests.checkLogin');
  9298. return false;
  9299. }
  9300. }
  9301. const website_Opquests = Opquests;
  9302. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9303. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9304. privateSet.add(obj);
  9305. }
  9306. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9307. if (privateCollection.has(obj)) {
  9308. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9309. }
  9310. }
  9311. function Gleam_defineProperty(obj, key, value) {
  9312. if (key in obj) {
  9313. Object.defineProperty(obj, key, {
  9314. value: value,
  9315. enumerable: true,
  9316. configurable: true,
  9317. writable: true
  9318. });
  9319. } else {
  9320. obj[key] = value;
  9321. }
  9322. return obj;
  9323. }
  9324. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9325. if (!privateSet.has(receiver)) {
  9326. throw new TypeError('attempted to get private field on non-instance');
  9327. }
  9328. return fn;
  9329. }
  9330. const Gleam_defaultTasksTemplate = {
  9331. steam: {
  9332. groupLinks: [],
  9333. wishlistLinks: [],
  9334. followLinks: [],
  9335. curatorLinks: [],
  9336. curatorLikeLinks: []
  9337. },
  9338. twitter: {
  9339. userLinks: [],
  9340. retweetLinks: []
  9341. },
  9342. twitch: {
  9343. channelLinks: []
  9344. },
  9345. discord: {
  9346. serverLinks: []
  9347. },
  9348. youtube: {
  9349. channelLinks: []
  9350. },
  9351. extra: {
  9352. gleam: []
  9353. }
  9354. };
  9355. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9356. const Gleam_defaultOptions = {
  9357. vlootUsername: '',
  9358. gameroundUsername: ''
  9359. };
  9360. var _checkSync = new WeakSet();
  9361. var _doGleamTask = new WeakSet();
  9362. var Gleam_getGiveawayId = new WeakSet();
  9363. var _getGleamLink = new WeakSet();
  9364. var Gleam_checkLeftKey = new WeakSet();
  9365. class Gleam extends website_Website {
  9366. constructor() {
  9367. super(...arguments);
  9368. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9369. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9370. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9371. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9372. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9373. Gleam_defineProperty(this, 'name', 'Gleam');
  9374. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9375. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9376. Gleam_defineProperty(this, 'options', {
  9377. ...Gleam_defaultOptions,
  9378. ...GM_getValue('GleamOptions')
  9379. });
  9380. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9381. }
  9382. static test() {
  9383. return window.location.host === 'gleam.io';
  9384. }
  9385. async after() {
  9386. try {
  9387. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9388. const checkComplete = setInterval(() => {
  9389. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9390. clearInterval(checkComplete);
  9391. window.close();
  9392. }
  9393. });
  9394. for (const task of $('.entry-content .entry-method')) {
  9395. const taskInfo = $(task).find('.user-links');
  9396. const expandInfo = $(task).find('.expandable');
  9397. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9398. if (aElements.length > 0) {
  9399. for (const element of aElements) {
  9400. const $element = $(element);
  9401. const href = $element.attr('href');
  9402. $element.removeAttr('href')[0].click();
  9403. $element.attr('href', href);
  9404. await delay(1e3);
  9405. }
  9406. }
  9407. taskInfo[0].click();
  9408. await delay(1e3);
  9409. }
  9410. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9411. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9412. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9413. }
  9414. } catch (error) {
  9415. throwError(error, 'Gleam.after');
  9416. return false;
  9417. }
  9418. }
  9419. init() {
  9420. try {
  9421. const logStatus = scripts_echoLog({
  9422. text: i18n('initing')
  9423. });
  9424. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9425. return false;
  9426. }
  9427. this.initialized = true;
  9428. logStatus.success();
  9429. return true;
  9430. } catch (error) {
  9431. throwError(error, 'Gleam.init');
  9432. return false;
  9433. }
  9434. }
  9435. async classifyTask(action) {
  9436. try {
  9437. const logStatus = scripts_echoLog({
  9438. text: i18n('getTasksInfo')
  9439. });
  9440. if (action === 'undo') {
  9441. var _GM_getValue;
  9442. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9443. }
  9444. const tasks = $('.entry-content .entry-method');
  9445. for (const task of tasks) {
  9446. var _socialIcon$attr;
  9447. const $task = $(task);
  9448. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9449. continue;
  9450. }
  9451. const socialIcon = $task.find('.icon-wrapper i');
  9452. const taskInfo = $task.find('.user-links');
  9453. const taskText = taskInfo.text().trim();
  9454. const expandInfo = $task.find('.expandable');
  9455. const aElements = expandInfo.find('a.btn');
  9456. if (aElements.length > 0) {
  9457. for (const element of aElements) {
  9458. const $element = $(element);
  9459. const href = $element.attr('href');
  9460. $element.removeAttr('href')[0].click();
  9461. $element.attr('href', href);
  9462. }
  9463. }
  9464. if (socialIcon.hasClass('fa-twitter')) {
  9465. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9466. if (!link) {
  9467. continue;
  9468. }
  9469. if (/follow/gi.test(taskText)) {
  9470. if (action === 'undo') {
  9471. this.socialTasks.twitter.userLinks.push(link);
  9472. }
  9473. if (action === 'do') {
  9474. this.undoneTasks.twitter.userLinks.push(link);
  9475. }
  9476. } else if (/retweet/gim.test(taskText)) {
  9477. if (action === 'undo') {
  9478. this.socialTasks.twitter.retweetLinks.push(link);
  9479. }
  9480. if (action === 'do') {
  9481. this.undoneTasks.twitter.retweetLinks.push(link);
  9482. }
  9483. }
  9484. } else if (socialIcon.hasClass('fa-twitch')) {
  9485. if (/follow/gim.test(taskText)) {
  9486. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9487. if (!link) {
  9488. continue;
  9489. }
  9490. if (action === 'undo') {
  9491. this.socialTasks.twitch.channelLinks.push(link);
  9492. }
  9493. if (action === 'do') {
  9494. this.undoneTasks.twitch.channelLinks.push(link);
  9495. }
  9496. }
  9497. } else if (socialIcon.hasClass('fa-discord')) {
  9498. if (/join/gim.test(taskText)) {
  9499. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9500. if (!link) {
  9501. var _$task$find$attr, _$task$find$attr$matc;
  9502. 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];
  9503. if (!ggLink) {
  9504. continue;
  9505. }
  9506. link = `https://discord.com/invite/${ggLink}`;
  9507. }
  9508. if (action === 'undo') {
  9509. this.socialTasks.discord.serverLinks.push(link);
  9510. }
  9511. if (action === 'do') {
  9512. this.undoneTasks.discord.serverLinks.push(link);
  9513. }
  9514. }
  9515. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9516. continue;
  9517. } else if (socialIcon.hasClass('fa-youtube')) {
  9518. if (/subscribe/gim.test(taskText)) {
  9519. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9520. if (!link) {
  9521. continue;
  9522. }
  9523. if (action === 'undo') {
  9524. this.socialTasks.youtube.channelLinks.push(link);
  9525. }
  9526. if (action === 'do') {
  9527. this.undoneTasks.youtube.channelLinks.push(link);
  9528. }
  9529. }
  9530. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9531. if (/join.*group/gi.test(taskText)) {
  9532. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9533. if (!link) {
  9534. continue;
  9535. }
  9536. if (action === 'undo') {
  9537. this.socialTasks.steam.groupLinks.push(link);
  9538. }
  9539. if (action === 'do') {
  9540. this.undoneTasks.steam.groupLinks.push(link);
  9541. }
  9542. } else if (/follow.*curator/gi.test(taskText)) {
  9543. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9544. if (!link) {
  9545. continue;
  9546. }
  9547. if (action === 'undo') {
  9548. this.socialTasks.steam.curatorLinks.push(link);
  9549. }
  9550. if (action === 'do') {
  9551. this.undoneTasks.steam.curatorLinks.push(link);
  9552. }
  9553. }
  9554. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9555. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9556. for (const button of continueBtn) {
  9557. button.click();
  9558. await delay(500);
  9559. expandInfo.find('input').val(this.options.vlootUsername);
  9560. }
  9561. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9562. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9563. for (const button of continueBtn) {
  9564. button.click();
  9565. await delay(500);
  9566. expandInfo.find('input').val(this.options.gameroundUsername);
  9567. }
  9568. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9569. if (action !== 'do') {
  9570. continue;
  9571. }
  9572. const link = aElements.attr('href');
  9573. if (!link) {
  9574. continue;
  9575. }
  9576. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9577. if (!gleamLink) {
  9578. continue;
  9579. }
  9580. this.undoneTasks.extra.gleam.push(gleamLink);
  9581. } 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 {
  9582. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9583. }
  9584. }
  9585. logStatus.success();
  9586. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9587. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9588. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9589. tasks: this.socialTasks,
  9590. time: new Date().getTime()
  9591. });
  9592. return true;
  9593. } catch (error) {
  9594. throwError(error, 'Gleam.classifyTask');
  9595. return false;
  9596. }
  9597. }
  9598. async extraDoTask(_ref) {
  9599. let {
  9600. gleam
  9601. } = _ref;
  9602. try {
  9603. const pro = [];
  9604. for (const link of gleam) {
  9605. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9606. }
  9607. return Promise.all(pro).then(() => true);
  9608. } catch (error) {
  9609. throwError(error, 'Gleam.extraDoTask');
  9610. return false;
  9611. }
  9612. }
  9613. async verifyTask() {
  9614. try {
  9615. scripts_echoLog({
  9616. text: `${i18n('verifyingTask')}...`
  9617. });
  9618. const tasks = $('.entry-content .entry-method');
  9619. for (const task of tasks) {
  9620. const $task = $(task);
  9621. if ($task.find('i.fa-question').length === 0) {
  9622. continue;
  9623. }
  9624. const taskInfo = $task.find('.user-links');
  9625. taskInfo[0].click();
  9626. await delay(500);
  9627. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9628. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9629. for (const button of continueBtn) {
  9630. button.click();
  9631. await delay(500);
  9632. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9633. }
  9634. }
  9635. scripts_echoLog({
  9636. text: i18n('verifiedGleamTasks')
  9637. });
  9638. } catch (error) {
  9639. throwError(error, 'Gleam.verifyTask');
  9640. return false;
  9641. }
  9642. }
  9643. }
  9644. async function _checkSync2() {
  9645. try {
  9646. return await new Promise(resolve => {
  9647. const checker = setInterval(() => {
  9648. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9649. clearInterval(checker);
  9650. resolve(true);
  9651. }
  9652. }, 500);
  9653. });
  9654. } catch (error) {
  9655. throwError(error, 'Gleam.checkSync');
  9656. return false;
  9657. }
  9658. }
  9659. async function _doGleamTask2(link) {
  9660. try {
  9661. const logStatus = scripts_echoLog({
  9662. text: i18n('doingGleamTask')
  9663. });
  9664. return await new Promise(resolve => {
  9665. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9666. active: true,
  9667. insert: true,
  9668. setParent: true
  9669. }).onclose = () => {
  9670. logStatus.success();
  9671. resolve(true);
  9672. };
  9673. });
  9674. } catch (error) {
  9675. throwError(error, 'Gleam.doGleamTask');
  9676. return false;
  9677. }
  9678. }
  9679. function Gleam_getGiveawayId2() {
  9680. try {
  9681. const giveawayId = window.location.pathname;
  9682. if (giveawayId) {
  9683. this.giveawayId = giveawayId;
  9684. return true;
  9685. }
  9686. scripts_echoLog({
  9687. text: i18n('getFailed', 'GiveawayId')
  9688. });
  9689. return false;
  9690. } catch (error) {
  9691. throwError(error, 'Gleam.getGiveawayId');
  9692. return false;
  9693. }
  9694. }
  9695. async function _getGleamLink2(link) {
  9696. try {
  9697. const logStatus = scripts_echoLog({
  9698. text: i18n('gettingGleamLink')
  9699. });
  9700. const {
  9701. result,
  9702. statusText,
  9703. status,
  9704. data
  9705. } = await tools_httpRequest({
  9706. url: link,
  9707. method: 'GET'
  9708. });
  9709. if (result === 'Success') {
  9710. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9711. var _data$responseText$ma;
  9712. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9713. if (gleamLink) {
  9714. logStatus.success();
  9715. return gleamLink;
  9716. }
  9717. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9718. return false;
  9719. }
  9720. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9721. return false;
  9722. }
  9723. logStatus.error(`${result}:${statusText}(${status})`);
  9724. return false;
  9725. } catch (error) {
  9726. throwError(error, 'Gleam.getGleamLink');
  9727. return false;
  9728. }
  9729. }
  9730. async function Gleam_checkLeftKey2() {
  9731. try {
  9732. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9733. if (!globalOptions.other.checkLeftKey) {
  9734. return true;
  9735. }
  9736. 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];
  9737. if (!campaignString) {
  9738. return false;
  9739. }
  9740. const {
  9741. campaign,
  9742. incentive
  9743. } = JSON.parse(campaignString);
  9744. 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];
  9745. let ownedKey = false;
  9746. if (controllerString) {
  9747. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9748. 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) {
  9749. ownedKey = true;
  9750. }
  9751. }
  9752. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9753. await external_Swal_default().fire({
  9754. icon: 'warning',
  9755. title: i18n('notice'),
  9756. text: i18n('giveawayNotWork'),
  9757. confirmButtonText: i18n('confirm'),
  9758. cancelButtonText: i18n('cancel'),
  9759. showCancelButton: true
  9760. }).then(_ref2 => {
  9761. let {
  9762. value
  9763. } = _ref2;
  9764. if (value) {
  9765. window.close();
  9766. }
  9767. });
  9768. }
  9769. return true;
  9770. } catch (error) {
  9771. throwError(error, 'Gleam.checkLeftKey');
  9772. return false;
  9773. }
  9774. }
  9775. const website_Gleam = Gleam;
  9776. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9777. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9778. privateSet.add(obj);
  9779. }
  9780. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9781. if (privateCollection.has(obj)) {
  9782. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9783. }
  9784. }
  9785. function SweepWidget_defineProperty(obj, key, value) {
  9786. if (key in obj) {
  9787. Object.defineProperty(obj, key, {
  9788. value: value,
  9789. enumerable: true,
  9790. configurable: true,
  9791. writable: true
  9792. });
  9793. } else {
  9794. obj[key] = value;
  9795. }
  9796. return obj;
  9797. }
  9798. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9799. if (!privateSet.has(receiver)) {
  9800. throw new TypeError('attempted to get private field on non-instance');
  9801. }
  9802. return fn;
  9803. }
  9804. const SweepWidget_defaultOptions = {
  9805. username: '',
  9806. email: ''
  9807. };
  9808. var SweepWidget_checkLogin = new WeakSet();
  9809. var SweepWidget_getGiveawayId = new WeakSet();
  9810. var _checkEnter = new WeakSet();
  9811. var _checkFinish = new WeakSet();
  9812. class SweepWidget extends website_Website {
  9813. constructor() {
  9814. super(...arguments);
  9815. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9816. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9817. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9818. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9819. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9820. SweepWidget_defineProperty(this, 'options', {
  9821. ...SweepWidget_defaultOptions,
  9822. ...GM_getValue('SweepWidgetOptions')
  9823. });
  9824. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9825. }
  9826. static test() {
  9827. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9828. }
  9829. async after() {
  9830. try {
  9831. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9832. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9833. }
  9834. } catch (error) {
  9835. throwError(error, 'SweepWidget.after');
  9836. }
  9837. }
  9838. init() {
  9839. try {
  9840. const logStatus = scripts_echoLog({
  9841. text: i18n('initing')
  9842. });
  9843. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9844. logStatus.warning(i18n('needLogin'));
  9845. return false;
  9846. }
  9847. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9848. return false;
  9849. }
  9850. this.initialized = true;
  9851. logStatus.success();
  9852. return true;
  9853. } catch (error) {
  9854. throwError(error, 'SweepWidget.init');
  9855. return false;
  9856. }
  9857. }
  9858. classifyTask() {
  9859. return true;
  9860. }
  9861. async doTask() {
  9862. try {
  9863. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9864. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9865. $('input[name="sw__login_name"]').val(this.options.username);
  9866. }
  9867. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9868. $('input[name="sw__login_email"]').val(this.options.email);
  9869. }
  9870. if ($('#sw_login_button:visible').length > 0) {
  9871. $('#sw_login_button')[0].click();
  9872. }
  9873. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9874. return false;
  9875. }
  9876. }
  9877. const logStatus = scripts_echoLog({
  9878. text: i18n('SweepWidgetNotice')
  9879. });
  9880. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9881. for (const task of tasks) {
  9882. var _aElement$, _$task$find$removeAtt;
  9883. const $task = $(task);
  9884. if ($task.find('i.fa-check:visible').length > 0) {
  9885. continue;
  9886. }
  9887. const title = $task.find('.sw_text_inner');
  9888. title[0].click();
  9889. const aElement = $task.find('a.sw_link');
  9890. const link = aElement.attr('href');
  9891. aElement.attr('href', '#a').attr('target', '_self');
  9892. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9893. await delay(300);
  9894. aElement.attr('href', link).attr('target', '_blank');
  9895. $task.find('input[type="text"]').val('test');
  9896. const verifyBtn = $task.find('input.sw_verify');
  9897. if (verifyBtn.prop('disabled') === true) {
  9898. title[0].click();
  9899. await delay(300);
  9900. title[0].click();
  9901. await delay(300);
  9902. }
  9903. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9904. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9905. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9906. }
  9907. logStatus.success();
  9908. return true;
  9909. } catch (error) {
  9910. throwError(error, 'SweepWidget.doTask');
  9911. return false;
  9912. }
  9913. }
  9914. }
  9915. function SweepWidget_checkLogin2() {
  9916. try {
  9917. if ($('#twitter_login_button').length > 0) {
  9918. $('#twitter_login_button')[0].click();
  9919. }
  9920. return true;
  9921. } catch (error) {
  9922. throwError(error, 'SweepWidget.checkLogin');
  9923. return false;
  9924. }
  9925. }
  9926. function SweepWidget_getGiveawayId2() {
  9927. try {
  9928. var _window$location$href;
  9929. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9930. if (giveawayId) {
  9931. this.giveawayId = giveawayId;
  9932. return true;
  9933. }
  9934. scripts_echoLog({
  9935. text: i18n('getFailed', 'GiveawayId')
  9936. });
  9937. return false;
  9938. } catch (error) {
  9939. throwError(error, 'SweepWidget.getGiveawayId');
  9940. return false;
  9941. }
  9942. }
  9943. async function _checkEnter2() {
  9944. try {
  9945. return new Promise(resolve => {
  9946. const checker = setInterval(() => {
  9947. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9948. clearInterval(checker);
  9949. resolve(true);
  9950. }
  9951. });
  9952. });
  9953. } catch (error) {
  9954. throwError(error, 'SweepWidget.checkEnter');
  9955. return false;
  9956. }
  9957. }
  9958. async function _checkFinish2($task) {
  9959. try {
  9960. return new Promise(resolve => {
  9961. const checker = setInterval(() => {
  9962. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9963. clearInterval(checker);
  9964. resolve(true);
  9965. }
  9966. });
  9967. });
  9968. } catch (error) {
  9969. throwError(error, 'SweepWidget.checkFinish');
  9970. return false;
  9971. }
  9972. }
  9973. const website_SweepWidget = SweepWidget;
  9974. const defaultWhiteList = {
  9975. discord: {
  9976. servers: []
  9977. },
  9978. instagram: {
  9979. users: []
  9980. },
  9981. twitch: {
  9982. channels: []
  9983. },
  9984. twitter: {
  9985. users: [],
  9986. retweets: [],
  9987. likes: []
  9988. },
  9989. vk: {
  9990. names: []
  9991. },
  9992. youtube: {
  9993. channels: [],
  9994. likes: []
  9995. },
  9996. reddit: {
  9997. reddits: []
  9998. },
  9999. steam: {
  10000. groups: [],
  10001. officialGroups: [],
  10002. wishlists: [],
  10003. follows: [],
  10004. forums: [],
  10005. workshops: [],
  10006. curators: [],
  10007. workshopVotes: [],
  10008. curatorLikes: [],
  10009. announcements: [],
  10010. licenses: [],
  10011. playtests: []
  10012. }
  10013. };
  10014. const link2id = async function(type) {
  10015. 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;
  10016. try {
  10017. const link = $('#socialLink').val();
  10018. let id = '';
  10019. switch (type) {
  10020. case 'discord.servers':
  10021. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10022. break;
  10023.  
  10024. case 'instagram.users':
  10025. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10026. break;
  10027.  
  10028. case 'twitch.channels':
  10029. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10030. break;
  10031.  
  10032. case 'twitter.users':
  10033. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10034. break;
  10035.  
  10036. case 'twitter.retweets':
  10037. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10038. break;
  10039.  
  10040. case 'vk.names':
  10041. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10042. break;
  10043.  
  10044. case 'youtube.channels':
  10045. 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) || '';
  10046. break;
  10047.  
  10048. case 'youtube.likes':
  10049. 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) || '';
  10050. break;
  10051.  
  10052. case 'reddit.reddits':
  10053. 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]) || '';
  10054. break;
  10055.  
  10056. case 'steam.groups':
  10057. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10058. break;
  10059.  
  10060. case 'steam.wishlists':
  10061. case 'steam.follows':
  10062. case 'steam.forums':
  10063. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10064. break;
  10065.  
  10066. case 'steam.workshops':
  10067. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10068. break;
  10069.  
  10070. case 'steam.curators':
  10071. {
  10072. if (link.includes('curator')) {
  10073. var _link$match12;
  10074. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10075. } else {
  10076. var _link$match13;
  10077. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10078. if (!param || param.length !== 2) {
  10079. break;
  10080. }
  10081. const steam = new social_Steam();
  10082. if (await steam.init()) {
  10083. id = await steam.getCuratorId(param[0], param[1]) || '';
  10084. }
  10085. }
  10086. }
  10087. break;
  10088. }
  10089. return id;
  10090. } catch (error) {
  10091. throwError(error, 'link2id');
  10092. return i18n('getFailed', 'id');
  10093. }
  10094. };
  10095. const disabledType = {
  10096. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10097. twitter: [ 'likes' ]
  10098. };
  10099. const assignWhiteList = whiteList => {
  10100. try {
  10101. const newWhiteList = {};
  10102. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10103. newWhiteList[key] = {
  10104. ...value,
  10105. ...whiteList[key]
  10106. };
  10107. }
  10108. return newWhiteList;
  10109. } catch (error) {
  10110. throwError(error, 'assignWhiteList');
  10111. return defaultWhiteList;
  10112. }
  10113. };
  10114. const whiteListOptions = function(showType) {
  10115. try {
  10116. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10117. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10118. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10119. for (const [ social, types ] of Object.entries(whiteList)) {
  10120. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10121. var _disabledType$social;
  10122. 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>`;
  10123. }).join('');
  10124. }
  10125. whiteListOptionsForm += '</tbody></table></form>';
  10126. if (showType === 'swal') {
  10127. external_Swal_default().fire({
  10128. title: i18n('whiteListOptions'),
  10129. html: whiteListOptionsForm,
  10130. showConfirmButton: false,
  10131. showCloseButton: true
  10132. });
  10133. } else {
  10134. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10135. }
  10136. $('.editWhiteList').on('click', function() {
  10137. var _whiteList$social;
  10138. const value = $(this).attr('data-value');
  10139. if (!value) {
  10140. return;
  10141. }
  10142. const [ social, type ] = value.split('.');
  10143. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10144. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10145. return;
  10146. }
  10147. external_Swal_default().fire({
  10148. title: i18n('changeWhiteListOption', value),
  10149. input: 'textarea',
  10150. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10151. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10152. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10153. inputValue: whiteList[social][type].join('\n'),
  10154. showConfirmButton: true,
  10155. confirmButtonText: i18n('save'),
  10156. showCancelButton: true,
  10157. cancelButtonText: i18n('close'),
  10158. showDenyButton: true,
  10159. denyButtonText: i18n('return')
  10160. }).then(_ref => {
  10161. let {
  10162. isDenied,
  10163. isConfirmed,
  10164. value
  10165. } = _ref;
  10166. if (isDenied) {
  10167. if (showType === 'swal') {
  10168. whiteListOptions(showType);
  10169. }
  10170. return;
  10171. } else if (isConfirmed) {
  10172. whiteList[social][type] = value.split('\n');
  10173. GM_setValue('whiteList', whiteList);
  10174. external_Swal_default().fire({
  10175. title: i18n('changeWhiteListSuccess'),
  10176. icon: 'success'
  10177. });
  10178. }
  10179. });
  10180. $('#link2id').on('click', async function() {
  10181. const type = $(this).attr('data-type');
  10182. $('#socialLink').val(await link2id(type));
  10183. });
  10184. });
  10185. } catch (error) {
  10186. throwError(error, 'whiteListOptions');
  10187. }
  10188. };
  10189. const whiteList = whiteListOptions;
  10190. const setGistData = async (token, gistId, fileName, content) => {
  10191. try {
  10192. const logStatus = scripts_echoLog({
  10193. text: i18n('settingData')
  10194. });
  10195. const contentData = JSON.stringify({
  10196. files: {
  10197. [fileName]: {
  10198. content: JSON.stringify(content)
  10199. }
  10200. }
  10201. });
  10202. const {
  10203. result,
  10204. statusText,
  10205. status,
  10206. data
  10207. } = await tools_httpRequest({
  10208. url: `https://api.github.com/gists/${gistId}`,
  10209. headers: {
  10210. Accept: 'application/vnd.github.v3+json',
  10211. Authorization: `token ${token}`
  10212. },
  10213. data: contentData,
  10214. responseType: 'json',
  10215. method: 'POST',
  10216. timeout: 3e4
  10217. });
  10218. if (result === 'Success') {
  10219. var _data$response$files, _data$response$files$;
  10220. 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)) {
  10221. logStatus.success();
  10222. return true;
  10223. }
  10224. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10225. return false;
  10226. }
  10227. logStatus.error(`${result}:${statusText}(${status})`);
  10228. return false;
  10229. } catch (error) {
  10230. throwError(error, 'setGistData');
  10231. return false;
  10232. }
  10233. };
  10234. const getGistData = async function(token, gistId, fileName) {
  10235. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10236. try {
  10237. const logStatus = scripts_echoLog({
  10238. text: i18n('gettingData')
  10239. });
  10240. const {
  10241. result,
  10242. statusText,
  10243. status,
  10244. data
  10245. } = await tools_httpRequest({
  10246. url: `https://api.github.com/gists/${gistId}`,
  10247. headers: {
  10248. Accept: 'application/vnd.github.v3+json',
  10249. Authorization: `token ${token}`
  10250. },
  10251. responseType: 'json',
  10252. method: 'GET',
  10253. timeout: 3e4
  10254. });
  10255. if (result === 'Success') {
  10256. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10257. var _data$response, _data$response$files2, _data$response$files3;
  10258. 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;
  10259. let formatedContent;
  10260. if (!content) {
  10261. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10262. return false;
  10263. }
  10264. if (test) {
  10265. logStatus.success();
  10266. return true;
  10267. }
  10268. try {
  10269. formatedContent = JSON.parse(content);
  10270. } catch (error) {
  10271. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10272. return false;
  10273. }
  10274. logStatus.success();
  10275. return formatedContent;
  10276. }
  10277. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10278. return false;
  10279. }
  10280. logStatus.error(`${result}:${statusText}(${status})`);
  10281. return false;
  10282. } catch (error) {
  10283. throwError(error, 'getGistData');
  10284. return false;
  10285. }
  10286. };
  10287. const syncOptions = () => {
  10288. try {
  10289. const {
  10290. TOKEN,
  10291. GIST_ID,
  10292. FILE_NAME,
  10293. SYNC_HISTORY
  10294. } = GM_getValue('gistOptions') || {
  10295. TOKEN: '',
  10296. GIST_ID: '',
  10297. FILE_NAME: '',
  10298. SYNC_HISTORY: true
  10299. };
  10300. external_Swal_default().fire({
  10301. title: i18n('gistOptions'),
  10302. 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;">
  10303. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10304. ${i18n('downloadFromGist')}</button></p>`,
  10305. focusConfirm: false,
  10306. showLoaderOnConfirm: true,
  10307. 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>`,
  10308. preConfirm: async () => {
  10309. const token = $('#github-token').val();
  10310. const gistId = $('#gist-id').val();
  10311. const fileName = $('#file-name').val();
  10312. const syncHistory = $('#sync-history').prop('checked');
  10313. GM_setValue('gistOptions', {
  10314. TOKEN: token,
  10315. GIST_ID: gistId,
  10316. FILE_NAME: fileName,
  10317. SYNC_HISTORY: syncHistory
  10318. });
  10319. return await getGistData(token, gistId, fileName, true);
  10320. },
  10321. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10322. confirmButtonText: i18n('saveAndTest'),
  10323. showCancelButton: true,
  10324. cancelButtonText: i18n('close')
  10325. }).then(_ref => {
  10326. let {
  10327. value
  10328. } = _ref;
  10329. if (value) {
  10330. external_Swal_default().fire({
  10331. icon: 'success',
  10332. title: i18n('testSuccess')
  10333. }).then(syncOptions);
  10334. } else if (value !== undefined) {
  10335. external_Swal_default().fire({
  10336. icon: 'error',
  10337. title: i18n('testFailed')
  10338. }).then(syncOptions);
  10339. }
  10340. });
  10341. $('#upload-data').on('click', async () => {
  10342. const {
  10343. TOKEN,
  10344. GIST_ID,
  10345. FILE_NAME
  10346. } = GM_getValue('gistOptions') || {};
  10347. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10348. return external_Swal_default().fire({
  10349. icon: 'error',
  10350. title: i18n('saveAndTestNotice')
  10351. }).then(syncOptions);
  10352. }
  10353. external_Swal_default().fire({
  10354. icon: 'info',
  10355. title: i18n('processingData')
  10356. });
  10357. const data = {};
  10358. const names = GM_listValues();
  10359. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10360. for (const name of names) {
  10361. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10362. continue;
  10363. }
  10364. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10365. continue;
  10366. }
  10367. data[name] = GM_getValue(name);
  10368. }
  10369. external_Swal_default().update({
  10370. icon: 'info',
  10371. title: i18n('updatingData')
  10372. });
  10373. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10374. external_Swal_default().fire({
  10375. icon: 'success',
  10376. title: i18n('syncDataSuccess')
  10377. });
  10378. } else {
  10379. external_Swal_default().fire({
  10380. icon: 'error',
  10381. title: i18n('syncDataFailed')
  10382. });
  10383. }
  10384. });
  10385. $('#download-data').on('click', async () => {
  10386. const {
  10387. TOKEN,
  10388. GIST_ID,
  10389. FILE_NAME
  10390. } = GM_getValue('gistOptions') || {};
  10391. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10392. return external_Swal_default().fire({
  10393. icon: 'error',
  10394. title: i18n('saveAndTestNotice')
  10395. }).then(syncOptions);
  10396. }
  10397. external_Swal_default().fire({
  10398. icon: 'info',
  10399. title: i18n('downloadingData')
  10400. });
  10401. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10402. if (!data) {
  10403. return external_Swal_default().fire({
  10404. icon: 'error',
  10405. title: i18n('checkedNoData')
  10406. }).then(syncOptions);
  10407. }
  10408. external_Swal_default().update({
  10409. icon: 'info',
  10410. title: i18n('savingData')
  10411. });
  10412. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10413. for (const [ name, value ] of Object.entries(data)) {
  10414. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10415. continue;
  10416. }
  10417. GM_setValue(name, value);
  10418. }
  10419. external_Swal_default().fire({
  10420. icon: 'success',
  10421. title: i18n('syncDataSuccess')
  10422. });
  10423. });
  10424. } catch (error) {
  10425. throwError(error, 'syncOptions');
  10426. }
  10427. };
  10428. const dataSync = syncOptions;
  10429. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10430. Setting_checkPrivateRedeclaration(obj, privateSet);
  10431. privateSet.add(obj);
  10432. }
  10433. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10434. if (privateCollection.has(obj)) {
  10435. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10436. }
  10437. }
  10438. function Setting_defineProperty(obj, key, value) {
  10439. if (key in obj) {
  10440. Object.defineProperty(obj, key, {
  10441. value: value,
  10442. enumerable: true,
  10443. configurable: true,
  10444. writable: true
  10445. });
  10446. } else {
  10447. obj[key] = value;
  10448. }
  10449. return obj;
  10450. }
  10451. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10452. if (!privateSet.has(receiver)) {
  10453. throw new TypeError('attempted to get private field on non-instance');
  10454. }
  10455. return fn;
  10456. }
  10457. var Setting_getId = new WeakSet();
  10458. var _environment = new WeakSet();
  10459. class Setting {
  10460. constructor() {
  10461. Setting_classPrivateMethodInitSpec(this, _environment);
  10462. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10463. Setting_defineProperty(this, 'name', 'Setting');
  10464. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10465. Setting_defineProperty(this, 'syncData', dataSync);
  10466. }
  10467. tasksHistory() {
  10468. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10469. }
  10470. static test() {
  10471. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10472. }
  10473. before() {
  10474. $('body').html('').addClass('auto-task-options');
  10475. }
  10476. after() {
  10477. try {
  10478. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10479. changeGlobalOptions('page');
  10480. whiteList('page');
  10481. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10482. $('#getTwitterUserId').on('click', () => {
  10483. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10484. });
  10485. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10486. $('#getYoutubeChannelId').on('click', () => {
  10487. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10488. });
  10489. $('input[name^="position"]').on('input', function() {
  10490. const type = $(this).attr('name').replace('position.', '');
  10491. const xLabel = 'rightleft';
  10492. const yLabel = 'topbottpm';
  10493. switch (type) {
  10494. case 'buttonSideX':
  10495. case 'buttonSideY':
  10496. case 'buttonDistance':
  10497. {
  10498. const distance = $('input[name="position.buttonDistance"]').val();
  10499. const sideX = $('input[name="position.buttonSideX"]').val();
  10500. const sideY = $('input[name="position.buttonSideY"]').val();
  10501. if (![ 'right', 'left' ].includes(sideX)) {
  10502. break;
  10503. }
  10504. if (![ 'top', 'bottom' ].includes(sideY)) {
  10505. break;
  10506. }
  10507. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10508. break;
  10509. }
  10510. const distanceArr = distance.split(',');
  10511. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10512. break;
  10513. }
  10514.  
  10515. case 'showButtonSideX':
  10516. case 'showButtonSideY':
  10517. case 'showButtonDistance':
  10518. {
  10519. const distance = $('input[name="position.showButtonDistance"]').val();
  10520. const sideX = $('input[name="position.showButtonSideX"]').val();
  10521. const sideY = $('input[name="position.showButtonSideY"]').val();
  10522. if (![ 'right', 'left' ].includes(sideX)) {
  10523. break;
  10524. }
  10525. if (![ 'top', 'bottom' ].includes(sideY)) {
  10526. break;
  10527. }
  10528. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10529. break;
  10530. }
  10531. const distanceArr = distance.split(',');
  10532. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10533. break;
  10534. }
  10535.  
  10536. case 'logSideX':
  10537. case 'logSideY':
  10538. case 'logDistance':
  10539. {
  10540. const distance = $('input[name="position.logDistance"]').val();
  10541. const sideX = $('input[name="position.logSideX"]').val();
  10542. const sideY = $('input[name="position.logSideY"]').val();
  10543. if (![ 'right', 'left' ].includes(sideX)) {
  10544. break;
  10545. }
  10546. if (![ 'top', 'bottom' ].includes(sideY)) {
  10547. break;
  10548. }
  10549. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10550. break;
  10551. }
  10552. const distanceArr = distance.split(',');
  10553. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10554. break;
  10555. }
  10556.  
  10557. default:
  10558. break;
  10559. }
  10560. });
  10561. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10562. let functionKey = '';
  10563. if (event.altKey) {
  10564. functionKey += 'alt + ';
  10565. } else if (event.ctrlKey) {
  10566. functionKey += 'ctrl + ';
  10567. } else if (event.shiftKey) {
  10568. functionKey += 'shift + ';
  10569. }
  10570. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10571. });
  10572. } catch (error) {
  10573. throwError(error, 'Setting.after');
  10574. }
  10575. }
  10576. saveGlobalOptions() {
  10577. saveData();
  10578. }
  10579. }
  10580. function Setting_getId2(social) {
  10581. try {
  10582. external_Swal_default().fire({
  10583. title: i18n('getId', i18n(social)),
  10584. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10585. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10586. showCancelButton: true,
  10587. cancelButtonText: i18n('close'),
  10588. showConfirmButton: false
  10589. });
  10590. $('#link2id').on('click', async function() {
  10591. const link = $('#socialLink').val();
  10592. if (!link) {
  10593. return;
  10594. }
  10595. const type = $(this).attr('data-type');
  10596. if (type === 'twitterUser') {
  10597. var _link$match;
  10598. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10599. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10600. } else if (type === 'youtubeChannel') {
  10601. var _link$match2, _await$getInfo, _await$getInfo$params;
  10602. 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;
  10603. $('#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) || '');
  10604. }
  10605. });
  10606. } catch (error) {
  10607. throwError(error, 'Setting.getId');
  10608. }
  10609. }
  10610. function _environment2() {
  10611. try {
  10612. const userAgent = (0, javascript_utils_umd_min.ua)();
  10613. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10614. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10615. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10616. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10617. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10618. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10619. </tbody></table></form>`;
  10620. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10621. } catch (error) {
  10622. throwError(error, 'Setting.environment');
  10623. }
  10624. }
  10625. const website_Setting = Setting;
  10626. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10627. History_checkPrivateRedeclaration(obj, privateSet);
  10628. privateSet.add(obj);
  10629. }
  10630. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10631. if (privateCollection.has(obj)) {
  10632. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10633. }
  10634. }
  10635. function History_defineProperty(obj, key, value) {
  10636. if (key in obj) {
  10637. Object.defineProperty(obj, key, {
  10638. value: value,
  10639. enumerable: true,
  10640. configurable: true,
  10641. writable: true
  10642. });
  10643. } else {
  10644. obj[key] = value;
  10645. }
  10646. return obj;
  10647. }
  10648. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10649. if (!privateSet.has(receiver)) {
  10650. throw new TypeError('attempted to get private field on non-instance');
  10651. }
  10652. return fn;
  10653. }
  10654. var _addItem = new WeakSet();
  10655. class History extends website_Keylol {
  10656. constructor() {
  10657. super(...arguments);
  10658. History_classPrivateMethodInitSpec(this, _addItem);
  10659. History_defineProperty(this, 'name', 'History');
  10660. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10661. }
  10662. static test() {
  10663. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10664. }
  10665. before() {
  10666. try {
  10667. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10668. const data = GM_listValues() || [];
  10669. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10670. for (const item of tasksHistory) {
  10671. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10672. }
  10673. } catch (error) {
  10674. throwError(error, 'History.before');
  10675. }
  10676. }
  10677. clearHistory() {
  10678. try {
  10679. const data = GM_listValues() || [];
  10680. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10681. for (const item of tasksHistory) {
  10682. GM_deleteValue(item);
  10683. }
  10684. external_Swal_default().fire({
  10685. title: i18n('clearHistoryFinished'),
  10686. icon: 'success'
  10687. });
  10688. } catch (error) {
  10689. throwError(error, 'History.after');
  10690. }
  10691. }
  10692. }
  10693. function _addItem2(item) {
  10694. try {
  10695. const tasksData = GM_getValue(item);
  10696. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10697. return;
  10698. }
  10699. let html = '';
  10700. let title = '';
  10701. let link = '';
  10702. const [ website, id ] = item.split('-');
  10703. switch (website) {
  10704. case 'fawTasks':
  10705. title = `Freeanywhere[${id}]`;
  10706. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10707. break;
  10708.  
  10709. case 'gasTasks':
  10710. title = `Giveawaysu[${id}]`;
  10711. link = `https://giveaway.su/giveaway/view/${id}`;
  10712. break;
  10713.  
  10714. case 'gcTasks':
  10715. title = `GiveeClub[${id}]`;
  10716. link = `https://givee.club/event/${id}`;
  10717. break;
  10718.  
  10719. case 'gkTasks':
  10720. title = `Givekey[${id}]`;
  10721. link = `https://givekey.ru/giveaway/${id}`;
  10722. break;
  10723.  
  10724. case 'gleamTasks':
  10725. title = `Gleam[${id}]`;
  10726. link = `https://gleam.io${id}`;
  10727. break;
  10728.  
  10729. case 'khTasks':
  10730. title = `keyhub[${id}]`;
  10731. link = `https://key-hub.eu/giveaway/${id}`;
  10732. break;
  10733.  
  10734. case 'prysTasks':
  10735. title = `Prys[${id}]`;
  10736. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10737. break;
  10738.  
  10739. default:
  10740. return;
  10741. }
  10742. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10743. for (const [ type, tasks ] of Object.entries(types)) {
  10744. for (const task of tasks) {
  10745. 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>`;
  10746. }
  10747. }
  10748. }
  10749. $('.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>`);
  10750. $('span.delete-task').on('click', function() {
  10751. const itemName = $(this).attr('data-name');
  10752. if (itemName) {
  10753. GM_deleteValue(itemName);
  10754. external_Swal_default().fire({
  10755. title: i18n('clearTaskFinished'),
  10756. text: itemName,
  10757. icon: 'success'
  10758. });
  10759. } else {
  10760. external_Swal_default().fire({
  10761. title: i18n('clearTaskFailed'),
  10762. icon: 'error'
  10763. });
  10764. }
  10765. });
  10766. } catch (error) {
  10767. throwError(error, 'History.addItem');
  10768. }
  10769. }
  10770. const website_History = History;
  10771. 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 ];
  10772. const websiteOptions = function(website, options) {
  10773. try {
  10774. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10775. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10776. for (const [ option, value ] of Object.entries(options)) {
  10777. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10778. }
  10779. websiteOptionsForm += '</tbody></table></form>';
  10780. external_Swal_default().fire({
  10781. title: i18n('websiteOptions'),
  10782. html: websiteOptionsForm,
  10783. showConfirmButton: true,
  10784. confirmButtonText: i18n('save'),
  10785. showCancelButton: true,
  10786. cancelButtonText: i18n('close')
  10787. }).then(_ref => {
  10788. let {
  10789. isConfirmed
  10790. } = _ref;
  10791. if (isConfirmed) {
  10792. $('#websiteOptionsForm').serializeArray().map(value => {
  10793. options[value.name] = value.value;
  10794. return value;
  10795. });
  10796. GM_setValue(`${website}Options`, options);
  10797. external_Swal_default().fire({
  10798. title: i18n('changeWebsiteOptionsSuccess'),
  10799. icon: 'success'
  10800. });
  10801. }
  10802. });
  10803. } catch (error) {
  10804. throwError(error, 'websiteOptions');
  10805. }
  10806. };
  10807. const options = websiteOptions;
  10808. const external_keyboardJS_namespaceObject = keyboardJS;
  10809. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10810. const checkUpdate = async (updateLink, auto) => {
  10811. try {
  10812. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10813. const {
  10814. result,
  10815. statusText,
  10816. status,
  10817. data
  10818. } = await tools_httpRequest({
  10819. url: checkUrl,
  10820. responseType: 'json',
  10821. method: 'GET',
  10822. timeout: 3e4
  10823. });
  10824. if (result === 'Success') {
  10825. var _data$response;
  10826. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10827. return data.response;
  10828. }
  10829. if (!auto) {
  10830. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10831. }
  10832. return false;
  10833. }
  10834. if (!auto) {
  10835. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10836. }
  10837. return false;
  10838. } catch (error) {
  10839. throwError(error, 'checkUpdate');
  10840. return false;
  10841. }
  10842. };
  10843. const hasNewVersion = (currentVersion, remoteVersion) => {
  10844. try {
  10845. const [ currentRealVersion ] = currentVersion.split('-');
  10846. const [ remoteRealVersion ] = remoteVersion.split('-');
  10847. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10848. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10849. if (remoteVersion1 > currentVersion1) {
  10850. return true;
  10851. }
  10852. if (remoteVersion1 < currentVersion1) {
  10853. return false;
  10854. }
  10855. if (remoteVersion2 > currentVersion2) {
  10856. return true;
  10857. }
  10858. if (remoteVersion2 < currentVersion2) {
  10859. return false;
  10860. }
  10861. if (remoteVersion3 > currentVersion3) {
  10862. return true;
  10863. }
  10864. return false;
  10865. } catch (error) {
  10866. throwError(error, 'compareVersion');
  10867. return false;
  10868. }
  10869. };
  10870. const updateChecker = async () => {
  10871. try {
  10872. const currentVersion = GM_info.script.version;
  10873. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10874. const updateLinks = {
  10875. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10876. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10877. standby: 'https://auto-task-v4.hclonely.com/'
  10878. };
  10879. let version;
  10880. let updateLink = '';
  10881. let packageData;
  10882. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10883. updateLink = updateLinks[updateSource];
  10884. packageData = await checkUpdate(updateLink, false);
  10885. } else {
  10886. updateLink = updateLinks.github;
  10887. packageData = await checkUpdate(updateLink, true);
  10888. if (!packageData) {
  10889. updateLink = updateLinks.jsdelivr;
  10890. packageData = await checkUpdate(updateLink, true);
  10891. if (!packageData) {
  10892. updateLink = updateLinks.standby;
  10893. packageData = await checkUpdate(updateLink, true);
  10894. }
  10895. }
  10896. }
  10897. if (packageData) {
  10898. version = packageData.version || currentVersion;
  10899. } else {
  10900. version = currentVersion;
  10901. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10902. }
  10903. if (packageData && hasNewVersion(currentVersion, version)) {
  10904. var _packageData$change;
  10905. scripts_echoLog({
  10906. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10907. });
  10908. scripts_echoLog({
  10909. 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>`
  10910. });
  10911. }
  10912. } catch (error) {
  10913. throwError(error, 'updateChecker');
  10914. }
  10915. };
  10916. const scripts_updateChecker = updateChecker;
  10917. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  10918. if (window.location.hostname === 'discord.com') {
  10919. const LocalStorage = window.localStorage;
  10920. if (window.location.hash === '#auth') {
  10921. var _LocalStorage$getItem;
  10922. window.localStorage.removeItem = () => true;
  10923. 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, '');
  10924. if (discordAuth && discordAuth.length > 0) {
  10925. GM_setValue('discordAuth', {
  10926. auth: discordAuth
  10927. });
  10928. window.close();
  10929. external_Swal_default().fire('', i18n('closePageNotice'));
  10930. } else {
  10931. external_Swal_default().fire({
  10932. text: i18n('getDiscordAuthFailed'),
  10933. icon: 'error'
  10934. });
  10935. }
  10936. } else {
  10937. var _LocalStorage$getItem2;
  10938. 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, '');
  10939. if (discordAuth && discordAuth.length > 0) {
  10940. GM_setValue('discordAuth', {
  10941. auth: discordAuth
  10942. });
  10943. }
  10944. }
  10945. }
  10946. const loadScript = async () => {
  10947. var _website, _website2, _website3, _website4, _website5, _website6;
  10948. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10949. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10950. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10951. if (isLogin) {
  10952. var _commonOptions, _commonOptions$header;
  10953. GM_setValue('twitchAuth', {
  10954. authToken: authToken,
  10955. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10956. });
  10957. window.close();
  10958. external_Swal_default().fire('', i18n('closePageNotice'));
  10959. } else {
  10960. external_Swal_default().fire('', i18n('needLogin'));
  10961. }
  10962. }
  10963. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10964. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10965. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10966. if (isLogin && ct0) {
  10967. GM_setValue('twitterAuth', {
  10968. ct0: ct0
  10969. });
  10970. window.close();
  10971. external_Swal_default().fire('', i18n('closePageNotice'));
  10972. } else {
  10973. external_Swal_default().fire('', i18n('needLogin'));
  10974. }
  10975. }
  10976. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10977. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10978. if (PAPISID) {
  10979. GM_setValue('youtubeAuth', {
  10980. PAPISID: PAPISID
  10981. });
  10982. window.close();
  10983. external_Swal_default().fire('', i18n('closePageNotice'));
  10984. } else {
  10985. external_Swal_default().fire('', i18n('needLogin'));
  10986. }
  10987. }
  10988. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10989. const betaButton = $('#redesign-beta-optin-btn');
  10990. if (betaButton.length > 0) {
  10991. GM_setValue('redditAuth', '#auth');
  10992. return betaButton[0].click();
  10993. }
  10994. GM_setValue('redditAuth', null);
  10995. window.close();
  10996. external_Swal_default().fire('', i18n('closePageNotice'));
  10997. }
  10998. let website;
  10999. for (const Website of Websites) {
  11000. if (Website.test()) {
  11001. website = new Website();
  11002. break;
  11003. }
  11004. }
  11005. if (!website) {
  11006. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  11007. return;
  11008. }
  11009. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11010. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11011. }
  11012. $('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>`);
  11013. $('div.show-button-div').on('click', () => {
  11014. $('#auto-task-buttons').show();
  11015. $('div.show-button-div').hide();
  11016. });
  11017. const toggleLog = () => {
  11018. const $this = $('#toggle-log');
  11019. const status = $this.attr('data-status');
  11020. if (status === 'show') {
  11021. $('#auto-task-info').hide();
  11022. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11023. } else {
  11024. $('#auto-task-info').show();
  11025. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11026. }
  11027. };
  11028. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11029. if (website.doTask) {
  11030. website.doTask();
  11031. }
  11032. });
  11033. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11034. if (website.undoTask) {
  11035. website.doTask();
  11036. }
  11037. });
  11038. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11039. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11040. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11041. }
  11042. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11043. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11044. for (const button of website.buttons) {
  11045. if (website[button]) {
  11046. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11047. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11048. website[button]();
  11049. });
  11050. $('#auto-task-buttons').append(btnElement);
  11051. }
  11052. }
  11053. }
  11054. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11055. ${i18n('hideButton')}</a></p>`);
  11056. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11057. $('#auto-task-buttons').hide();
  11058. $('div.show-button-div').show();
  11059. });
  11060. 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'}">
  11061. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11062. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11063. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11064. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11065. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11066. options(website.name, website.options);
  11067. });
  11068. }
  11069. if (website.name !== 'Setting') {
  11070. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11071. changeGlobalOptions('swal');
  11072. });
  11073. GM_registerMenuCommand(i18n('settingPage'), () => {
  11074. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11075. });
  11076. }
  11077. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  11078. if (!GM_getValue('notice')) {
  11079. var _echoLog$font;
  11080. external_Swal_default().fire({
  11081. title: i18n('swalNotice'),
  11082. icon: 'warning'
  11083. }).then(() => {
  11084. window.open(i18n('noticeLink'), '_blank');
  11085. GM_setValue('notice', new Date().getTime());
  11086. });
  11087. (_echoLog$font = scripts_echoLog({
  11088. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11089. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11090. GM_setValue('notice', new Date().getTime());
  11091. });
  11092. }
  11093. scripts_updateChecker();
  11094. };
  11095. if (window.location.hostname === 'opquests.com') {
  11096. loadScript();
  11097. } else {
  11098. $(loadScript);
  11099. }
  11100. }();
  11101. })();