auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.4
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12. // @icon https://auto-task-v4.hclonely.com/favicon.ico
  13.  
  14. // @include *://freeanywhere.net/*
  15. // @include *://giveaway.su/giveaway/view/*
  16. // @include *://givee.club/*/event/*
  17. // @include *://givekey.ru/giveaway/*
  18. // @include *://www.indiedb.com/giveaways*
  19. // @include *://key-hub.eu/giveaway/*
  20. // @include *://keylol.com/*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://prys.revadike.com/giveaway/?id=*
  23. // @include *://opquests.com/quests/*
  24. // @include *://gleam.io/*
  25. // @include *://sweepwidget.com/view/*
  26. // @include *://discord.com/*
  27. // @include *://www.twitch.tv/*
  28. // @include *://www.youtube.com/*
  29. // @include *://*.reddit.com/*
  30. // @include *://twitter.com/settings/account?k*
  31. // @include https://auto-task-v4.hclonely.com/setting.html
  32. // @include https://auto-task-v4.hclonely.com/history.html
  33.  
  34. // @grant GM_setValue
  35. // @grant GM_getValue
  36. // @grant GM_listValues
  37. // @grant GM_deleteValue
  38. // @grant GM_addStyle
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_info
  42. // @grant GM_openInTab
  43. // @grant GM_setClipboard
  44. // @grant GM_getResourceText
  45. // @grant unsafeWindow
  46. // @grant window.close
  47. // @grant window.localStorage
  48.  
  49. // @connect cdn.jsdelivr.net
  50. // @connect store.steampowered.com
  51. // @connect steamcommunity.com
  52. // @connect twitter.com
  53. // @connect api.twitter.com
  54. // @connect youtube.com
  55. // @connect www.youtube.com
  56. // @connect facebook.com
  57. // @connect instagram.com
  58. // @connect vk.com
  59. // @connect twitch.tv
  60. // @connect www.twitch.tv
  61. // @connect gql.twitch.tv
  62. // @connect github.com
  63. // @connect discordapp.com
  64. // @connect discord.gg
  65. // @connect discord.com
  66. // @connect www.reddit.com
  67. // @connect oauth.reddit.com
  68. // @connect raw.githubusercontent.com
  69. // @connect t.me
  70. // @connect bit.ly
  71. // @connect giveaway.su
  72. // @connect google.com
  73. // @connect www.vloot.io
  74. // @connect givee.club
  75. // @connect gleam.io
  76. // @connect www.indiedb.com
  77. // @connect key-hub.eu
  78. // @connect opquests.com
  79. // @connect itch.io
  80. // @connect auto-task-v4.hclonely.com
  81. // @connect *
  82. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  83. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  84. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  85. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  86. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  87. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  88. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  89. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  90.  
  91. // @noframes
  92. // ==/UserScript==
  93.  
  94. console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
  95.  
  96. (function() {
  97. var __webpack_modules__ = {
  98. 514: function(__unused_webpack_module, exports) {
  99. !function(e, n) {
  100. true ? n(exports) : 0;
  101. }(this, function(e) {
  102. 'use strict';
  103. var t = function() {
  104. return (t = Object.assign || function(e) {
  105. for (var n, o = 1, t = arguments.length; o < t; o++) {
  106. for (var r in n = arguments[o]) {
  107. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  108. }
  109. }
  110. return e;
  111. }).apply(this, arguments);
  112. };
  113. function r(e, n, o) {
  114. if (o || 2 === arguments.length) {
  115. for (var t, r = 0, i = n.length; r < i; r++) {
  116. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  117. }
  118. }
  119. return e.concat(t || Array.prototype.slice.call(n));
  120. }
  121. function d(e) {
  122. return '[object Object]' === n(e);
  123. }
  124. function l(e, n) {
  125. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  126. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  127. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  128. });
  129. }
  130. var n = function(e) {
  131. return Object.prototype.toString.call(e);
  132. };
  133. var o = (i.prototype.init = function() {
  134. try {
  135. this.getSystemName(), this.getBrowserName();
  136. } catch (e) {
  137. console.warn('[UA formatter error] '.concat(e));
  138. }
  139. }, i.prototype.getEngine = function() {
  140. var e = this.agent;
  141. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  142. }, i.prototype.getSystemName = function() {
  143. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  144. try {
  145. var o = '';
  146. if (/Windows/i.test(n)) {
  147. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  148. switch (this.info.os = 'Windows', t) {
  149. case '6.3':
  150. o = '8.1';
  151. break;
  152.  
  153. case '6.2':
  154. o = '8';
  155. break;
  156.  
  157. case '6.1':
  158. o = '7';
  159. break;
  160.  
  161. case '5.2':
  162. case '5.1':
  163. o = 'XP';
  164. break;
  165.  
  166. default:
  167. o = t;
  168. }
  169. return this.info.device = 'PC', void (this.info.osVersion = o);
  170. }
  171. if (/^Macintosh/i.test(n)) {
  172. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  173. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  174. }
  175. if (/^iPad/i.test(n)) {
  176. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  177. void (this.info.osVersion = o.replace(/_/g, '.'));
  178. }
  179. if (/^iPhone/i.test(n)) {
  180. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  181. void (this.info.osVersion = o.replace(/_/g, '.'));
  182. }
  183. if (-1 !== n.indexOf('Android')) {
  184. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  185. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  186. }
  187. if (/Linux\s[a-z\d_]+/.test(n)) {
  188. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  189. }
  190. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  191. } catch (e) {
  192. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  193. }
  194. }, i.prototype.getBrowserName = function() {
  195. var e = Object.keys(this.browserNameMap).map(function(e) {
  196. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  197. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  198. return -1 !== e.findIndex(function(e) {
  199. return e.test(n);
  200. });
  201. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  202. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  203. }, i.prototype._formatBrowserVersion = function(e) {
  204. var n, o, t, r;
  205. try {
  206. for (var i = null !== (o = null === (n = e.match(/(?<name>[a-z\d]+)(\/|\s)(?<version>(\d+\.)+\d+)/i)) || void 0 === n ? void 0 : n.groups) && void 0 !== o ? o : {}, s = i.name, a = i.version, c = {}, f = 0, u = Object.entries(this.browserNameMap); f < u.length; f++) {
  207. var d = u[f], l = d[0], h = d[1];
  208. if (new RegExp(l).test(s)) {
  209. c = h;
  210. break;
  211. }
  212. }
  213. var p = {
  214. browserVersion: null != a ? a : 'Unknown',
  215. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  216. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  217. };
  218. return 'Trident' === s && (p.browserVersion = {
  219. '4.0': 8,
  220. '5.0': 9,
  221. '6.0': 10,
  222. '7.0': 11
  223. }[a]), p;
  224. } catch (e) {
  225. return console.warn('[UA formatter error] '.concat(e)), {
  226. browser: 'Unknown',
  227. browserVersion: 'Unknown'
  228. };
  229. }
  230. }, i);
  231. function i(e) {
  232. this.agent = '', this.info = {
  233. browser: '',
  234. browserZH: '',
  235. browserVersion: '',
  236. os: '',
  237. osVersion: '',
  238. device: 'Unknown',
  239. engine: 'WebKit'
  240. }, this.browserNameMap = {
  241. MicroMessenger: {
  242. en: 'MicroMessenger',
  243. zh: '微信'
  244. },
  245. MetaSr: {
  246. en: 'MetaSr',
  247. zh: '搜狗浏览器'
  248. },
  249. 'QQ(Browser)?': {
  250. en: 'QQBrowser',
  251. zh: 'QQ浏览器'
  252. },
  253. UCBrowser: {
  254. en: 'UCBrowser',
  255. zh: 'UC浏览器'
  256. },
  257. '2345Explorer': {
  258. en: '2345Explorer',
  259. zh: '2345极速浏览器'
  260. },
  261. Mb2345Browser: {
  262. en: 'Mb2345Browser',
  263. zh: '2345手机浏览器'
  264. },
  265. Trident: {
  266. en: 'Internet Explorer'
  267. },
  268. 'Edge?': {
  269. en: 'Edge'
  270. },
  271. OPR: {
  272. en: 'Opera'
  273. },
  274. Vivaldi: {
  275. en: 'Vivaldi'
  276. },
  277. Firefox: {
  278. en: 'Firefox'
  279. },
  280. Chrome: {
  281. en: 'Chrome'
  282. },
  283. Safari: {
  284. en: 'Safari'
  285. }
  286. }, this.agent = e, this.init();
  287. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  288. this.info = t(t({}, this.info), {
  289. engine: this.getEngine(),
  290. browserVersion: 'Safari' === o ? n : e
  291. });
  292. }
  293. function s() {
  294. this.cookies = {}, this.init();
  295. }
  296. var a = new (s.prototype.init = function() {
  297. var o = {};
  298. document.cookie.split(/;\s/).forEach(function(e) {
  299. var n = e.split(/=/), e = n[0], n = n[1];
  300. o[e] = n;
  301. }), this.cookies = o;
  302. }, s.prototype.getItem = function(e) {
  303. return this.cookies[e];
  304. }, s.prototype.getAllItems = function() {
  305. return this.cookies;
  306. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  307. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  308. }, s)();
  309. e.countDown = function e(n, o, t, r) {
  310. if (!window) {
  311. throw new Error('window is not defind.');
  312. }
  313. if (0 < n) {
  314. return r && r(), n--, window[o] = window.setTimeout(function() {
  315. e(n, o, t, r);
  316. }, 1e3), function() {
  317. return clearTimeout(window[o]);
  318. };
  319. }
  320. clearTimeout(window[o]), t && t();
  321. }, e.createRandomID = function(e) {
  322. void 0 === e && (e = 12);
  323. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  324. n.push(o[Math.round(Math.random() * t)]);
  325. }
  326. return n.join('');
  327. }, e.dCookie = a, e.debounce = function(o, t, r) {
  328. var i;
  329. void 0 === t && (t = 0);
  330. var s = r = void 0 === r ? !1 : r;
  331. return function() {
  332. var e = this, n = arguments;
  333. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  334. r ? s = !0 : o.apply(e, n);
  335. }, t);
  336. };
  337. }, e.deepCopy = function e(n) {
  338. if (d(n) || Array.isArray(n)) {
  339. var o, t = Array.isArray(n) ? [] : {};
  340. for (o in n) {
  341. t[o] = e(n[o]);
  342. }
  343. return t;
  344. }
  345. return n;
  346. }, e.formatQueryParams = function(e) {
  347. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  348. if (!e) {
  349. return {};
  350. }
  351. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  352. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  353. return t[n] = o, e;
  354. });
  355. }
  356. return t;
  357. }, e.formatThousandth = function(e) {
  358. var n = ''.concat(e).split('.'), e = n[0], n = n[1], n = void 0 === n ? '' : n, e = e.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
  359. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  360. }, e.generateTree = function e(n, o, t, r) {
  361. for (var i = [], s = 0; s < n.length; s++) {
  362. var a = n[s];
  363. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  364. }
  365. return i;
  366. }, e.isEmpty = function(e) {
  367. return Array.isArray(e) ? 0 === e.length : d(e) ? 0 === Object.keys(e).length : [ '[object Set]', '[object Map]' ].includes(n(e)) ? 0 === e.size : [ null, void 0, '' ].includes(e);
  368. }, e.isFunction = function(e) {
  369. return '[object Function]' === n(e);
  370. }, e.isImageUrl = function(e) {
  371. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  372. }, e.isObject = d, e.isRegexp = function(e) {
  373. return '[object RegExp]' === n(e);
  374. }, e.objectKeyToCamelCase = function e(n, o, t) {
  375. if (Array.isArray(n)) {
  376. for (var r = [], i = 0; i < n.length; i++) {
  377. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  378. }
  379. } else if (d(n)) {
  380. r = {};
  381. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  382. var f = (u = c[a])[0], u = u[1];
  383. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  384. }
  385. } else {
  386. r = n;
  387. }
  388. return r;
  389. }, e.realType = n, e.searchParams = function(e, n) {
  390. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  391. new URLSearchParams(e).get(n);
  392. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  393. return e.replace(/([A-Z])/g, function(e) {
  394. return '_'.concat(e.toLocaleLowerCase());
  395. });
  396. }, e.ua = function(e) {
  397. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  398. }, Object.defineProperty(e, '__esModule', {
  399. value: !0
  400. });
  401. });
  402. },
  403. 786: function(module, __webpack_exports__, __webpack_require__) {
  404. 'use strict';
  405. __webpack_require__.d(__webpack_exports__, {
  406. Z: function() {
  407. return __WEBPACK_DEFAULT_EXPORT__;
  408. }
  409. });
  410. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  411. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  412. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  413. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  414. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default());
  415. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(10px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px rgba(5,190,5,0.4)}body.auto-task-options .auto-task-form table label input:checked~span i{left:84px}body.auto-task-options .auto-task-form table label input:checked~span i::before{background:#05be05;box-shadow:35px 0 0 #05be05}body.auto-task-options .auto-task-form table label input:checked~span i::after{bottom:12px;height:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;background:#05be05}body.auto-task-options .auto-task-form table label span{position:absolute;top:0;left:0;width:100%;height:100%;background:#fe0000;border-radius:80px;transition:.5s;box-shadow:0 15px 25px rgba(254,0,0,0.4)}body.auto-task-options .auto-task-form table label span i{position:absolute;top:4px;left:4px;width:72px;height:72px;background:#fff;border-radius:50%}body.auto-task-options .auto-task-form table label span i::before{content:"";position:absolute;top:22px;left:12px;width:12px;height:12px;border-radius:50%;background:#fe0000;box-shadow:35px 0 0 #fe0000;transition:.5s}body.auto-task-options .auto-task-form table label span i::after{content:"";position:absolute;bottom:15px;left:calc(50% - 15px);width:30px;height:6px;border-radius:6px;background:#fe0000;transition:.5s}body.auto-task-history{font-size:15px;font-weight:400;line-height:1.5}body.auto-task-history .container a{color:#007bff;text-decoration:none;background-color:transparent}body.auto-task-history .container .card{width:80%;max-width:800px;border-radius:10px;background:rgba(118,118,118,0.10196);border-top:1px solid rgba(255,255,255,0.50196);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px rgba(0,0,0,0.10196);margin:20px auto;position:relative;display:flex;flex-direction:column;word-wrap:break-word;-webkit-background-clip:border-box;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}body.auto-task-history .container .card .title{text-align:center;font-size:30px;font-weight:bold;margin:5px 0}body.auto-task-history .container .card .title a:hover{text-decoration:none;background:#93e1ff;border-radius:10px;padding:3px}body.auto-task-history .container .card ul{margin-bottom:25px}body.auto-task-history .container .card ul li{margin-bottom:5px;line-height:20px}body.auto-task-history .container .card ul a:hover{text-decoration:underline}body.auto-task-history .container .card .delete-task{right:10px;width:38px;height:35px;position:absolute;font-size:24px;cursor:pointer;border-radius:10px}body.auto-task-history .container .card .delete-task:hover{background:#fff}body.auto-task-history .container .card .time{right:5px;position:absolute;bottom:0;color:#e83e8c;font-family:\'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace\';font-size:15px}#auto-task-buttons,.show-button-div{position:fixed;top:30px;right:15px;width:170px;z-index:999999999 !important;transform:scale(0.9)}#auto-task-buttons p,.show-button-div p{line-height:30px;height:40px;text-align:center;margin:5px !important}#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn{width:150px;height:40px;line-height:30px;font-size:20px}.show-button-div{width:20px}.auto-task-capitalize{text-transform:capitalize !important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{box-shadow:inset 0px 0px 4px 1px rgba(100,150,200,.5) !important}.swal2-checkbox-custom{align-items:center;justify-content:center;background:#fff;color:inherit;margin:1em auto}.swal2-checkbox-custom input{flex-shrink:0;margin:0 .4em}.giveaway-actions #getKey{display:none !important}.auto-task-giveaway-status{color:#fff;border-radius:10px;padding:0 5px;margin-left:5px}.auto-task-giveaway-status.active{background-color:#5cb85c}.auto-task-giveaway-status.not-active{background-color:#d9534f}.left-keys.lk-green,.left-keys.lk-yellow,.left-keys.lk-red,.left-keys.lk-black{display:none !important}', '' ]);
  416. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  417. },
  418. 400: function(module) {
  419. 'use strict';
  420. module.exports = function(cssWithMappingToString) {
  421. var list = [];
  422. list.toString = function toString() {
  423. return this.map(function(item) {
  424. var content = '';
  425. var needLayer = typeof item[5] !== 'undefined';
  426. if (item[4]) {
  427. content += '@supports ('.concat(item[4], ') {');
  428. }
  429. if (item[2]) {
  430. content += '@media '.concat(item[2], ' {');
  431. }
  432. if (needLayer) {
  433. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  434. }
  435. content += cssWithMappingToString(item);
  436. if (needLayer) {
  437. content += '}';
  438. }
  439. if (item[2]) {
  440. content += '}';
  441. }
  442. if (item[4]) {
  443. content += '}';
  444. }
  445. return content;
  446. }).join('');
  447. };
  448. list.i = function i(modules, media, dedupe, supports, layer) {
  449. if (typeof modules === 'string') {
  450. modules = [ [ null, modules, undefined ] ];
  451. }
  452. var alreadyImportedModules = {};
  453. if (dedupe) {
  454. for (var k = 0; k < this.length; k++) {
  455. var id = this[k][0];
  456. if (id != null) {
  457. alreadyImportedModules[id] = true;
  458. }
  459. }
  460. }
  461. for (var _k = 0; _k < modules.length; _k++) {
  462. var item = [].concat(modules[_k]);
  463. if (dedupe && alreadyImportedModules[item[0]]) {
  464. continue;
  465. }
  466. if (typeof layer !== 'undefined') {
  467. if (typeof item[5] === 'undefined') {
  468. item[5] = layer;
  469. } else {
  470. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  471. item[5] = layer;
  472. }
  473. }
  474. if (media) {
  475. if (!item[2]) {
  476. item[2] = media;
  477. } else {
  478. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  479. item[2] = media;
  480. }
  481. }
  482. if (supports) {
  483. if (!item[4]) {
  484. item[4] = ''.concat(supports);
  485. } else {
  486. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  487. item[4] = supports;
  488. }
  489. }
  490. list.push(item);
  491. }
  492. };
  493. return list;
  494. };
  495. },
  496. 220: function(module) {
  497. 'use strict';
  498. module.exports = function(i) {
  499. return i[1];
  500. };
  501. }
  502. };
  503. var __webpack_module_cache__ = {};
  504. function __webpack_require__(moduleId) {
  505. var cachedModule = __webpack_module_cache__[moduleId];
  506. if (cachedModule !== undefined) {
  507. return cachedModule.exports;
  508. }
  509. var module = __webpack_module_cache__[moduleId] = {
  510. id: moduleId,
  511. exports: {}
  512. };
  513. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  514. return module.exports;
  515. }
  516. !function() {
  517. __webpack_require__.n = function(module) {
  518. var getter = module && module.__esModule ? function() {
  519. return module['default'];
  520. } : function() {
  521. return module;
  522. };
  523. __webpack_require__.d(getter, {
  524. a: getter
  525. });
  526. return getter;
  527. };
  528. }();
  529. !function() {
  530. __webpack_require__.d = function(exports, definition) {
  531. for (var key in definition) {
  532. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  533. Object.defineProperty(exports, key, {
  534. enumerable: true,
  535. get: definition[key]
  536. });
  537. }
  538. }
  539. };
  540. }();
  541. !function() {
  542. __webpack_require__.o = function(obj, prop) {
  543. return Object.prototype.hasOwnProperty.call(obj, prop);
  544. };
  545. }();
  546. var __webpack_exports__ = {};
  547. !function() {
  548. 'use strict';
  549. const external_Swal_namespaceObject = Swal;
  550. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  551. const external_Cookies_namespaceObject = Cookies;
  552. var auto_task = __webpack_require__(786);
  553. var javascript_utils_umd_min = __webpack_require__(514);
  554. const httpRequest = async function(options) {
  555. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  556. if (window.TRACE) {
  557. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  558. }
  559. try {
  560. const result = await new Promise(resolve => {
  561. if (options.dataType) {
  562. options.responseType = options.dataType;
  563. }
  564. const requestObj = {
  565. ...{
  566. timeout: 3e4,
  567. ontimeout(data) {
  568. resolve({
  569. result: 'Error',
  570. statusText: 'Timeout',
  571. status: 601,
  572. data: data,
  573. options: options
  574. });
  575. },
  576. onabort(data) {
  577. resolve({
  578. result: 'Error',
  579. statusText: 'Aborted',
  580. status: 602,
  581. data: data,
  582. options: options
  583. });
  584. },
  585. onerror(data) {
  586. resolve({
  587. result: 'Error',
  588. statusText: 'Error',
  589. status: 603,
  590. data: data,
  591. options: options
  592. });
  593. },
  594. onload(data) {
  595. resolve({
  596. result: 'Success',
  597. statusText: 'Load',
  598. status: 600,
  599. data: data,
  600. options: options
  601. });
  602. }
  603. },
  604. ...options
  605. };
  606. GM_xmlhttpRequest(requestObj);
  607. });
  608. if (window.DEBUG) {
  609. console.log('%cAuto-Task[httpRequest]:', 'color:blue', JSON.stringify(result));
  610. }
  611. if (result.status !== 600 && times < 2) {
  612. return await httpRequest(options, times + 1);
  613. }
  614. return result;
  615. } catch (error) {
  616. console.log('%cAuto-Task[httpRequest]:', 'color:red', JSON.stringify({
  617. errorMsg: error,
  618. options: options
  619. }));
  620. throwError(error, 'httpRequest');
  621. return {
  622. result: 'JsError',
  623. statusText: 'Error',
  624. status: 604,
  625. error: error,
  626. options: options
  627. };
  628. }
  629. };
  630. const tools_httpRequest = httpRequest;
  631. const echoLog = _ref => {
  632. let {
  633. type,
  634. text,
  635. html,
  636. id
  637. } = _ref;
  638. const emptyStatus = {
  639. success: () => emptyStatus,
  640. error: () => emptyStatus,
  641. warning: () => emptyStatus,
  642. info: () => emptyStatus,
  643. view: () => emptyStatus
  644. };
  645. try {
  646. var _ele$;
  647. let ele;
  648. if (type) {
  649. switch (type) {
  650. case 'joiningSteamGroup':
  651. case 'leavingSteamGroup':
  652. case 'gettingSteamGroupId':
  653. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  654. break;
  655.  
  656. case 'joiningSteamOfficialGroup':
  657. case 'leavingSteamOfficialGroup':
  658. case 'gettingSteamOfficialGroupId':
  659. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/games/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  660. break;
  661.  
  662. case 'subscribingForum':
  663. case 'unsubscribingForum':
  664. case 'gettingForumId':
  665. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>]...<font></font></li>`);
  666. break;
  667.  
  668. case 'followingCurator':
  669. case 'unfollowingCurator':
  670. case 'getCuratorId':
  671. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/${text !== null && text !== void 0 && text.includes('/') ? text : `curator/${text}`}" target="_blank">${text}</a>]...<font></font></li>`);
  672. break;
  673.  
  674. case 'addingToWishlist':
  675. case 'removingFromWishlist':
  676. case 'followingGame':
  677. case 'unfollowingGame':
  678. case 'gettingSubid':
  679. case 'addingFreeLicense':
  680. case 'requestingPlayTestAccess':
  681. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  682. break;
  683.  
  684. case 'addingFreeLicenseSubid':
  685. ele = $(`<li>${i18n('addingFreeLicense')}[<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  686. break;
  687.  
  688. case 'favoritingWorkshop':
  689. case 'unfavoritingWorkshop':
  690. case 'gettingWorkshopAppId':
  691. case 'votingUpWorkshop':
  692. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  693. ${text}</a>]...<font></font></li>`);
  694. break;
  695.  
  696. case 'gettingAnnouncementParams':
  697. case 'likingAnnouncement':
  698. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  699. ${id}</a>]...<font></font></li>`);
  700. break;
  701.  
  702. case 'joiningDiscordServer':
  703. case 'gettingDiscordGuild':
  704. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  705. break;
  706.  
  707. case 'leavingDiscordServer':
  708. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  709. break;
  710.  
  711. case 'updateDiscordAuth':
  712. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  713. break;
  714.  
  715. case 'followingTwitchChannel':
  716. case 'unfollowingTwitchChannel':
  717. case 'gettingTwitchChannelId':
  718. ele = $(`<li>${i18n(type)}[<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  719. break;
  720.  
  721. case 'gettingInsUserId':
  722. case 'followingIns':
  723. case 'unfollowingIns':
  724. ele = $(`<li>${i18n(type)}[<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  725. break;
  726.  
  727. case 'gettingTwitterUserId':
  728. case 'followingTwitterUser':
  729. case 'unfollowingTwitterUser':
  730. ele = $(`<li>${i18n(type)}[<a href="https://twitter.com/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  731. break;
  732.  
  733. case 'retweetting':
  734. case 'unretweetting':
  735. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  736. break;
  737.  
  738. case 'joiningReddit':
  739. case 'leavingReddit':
  740. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  741. break;
  742.  
  743. case 'followingRedditUser':
  744. case 'unfollowingRedditUser':
  745. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  746. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>]...<font></font></li>`);
  747. break;
  748.  
  749. case 'followingYtbChannel':
  750. case 'unfollowingYtbChannel':
  751. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  752. break;
  753.  
  754. case 'likingYtbVideo':
  755. case 'unlikingYtbVideo':
  756. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>]...<font></font></li>`);
  757. break;
  758.  
  759. case 'gettingVkId':
  760. case 'joiningVkGroup':
  761. case 'leavingVkGroup':
  762. case 'joiningVkPublic':
  763. case 'leavingVkPublic':
  764. case 'sendingVkWall':
  765. case 'deletingVkWall':
  766. ele = $(`<li>${i18n(type)}[<a href="https://vk.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  767. break;
  768.  
  769. case 'visitingLink':
  770. ele = $(`<li>${i18n('visitingLink')}[<a href="${text}" target="_blank">${text}</a>]...<font></font></li>`);
  771. break;
  772.  
  773. case 'verifyingInsAuth':
  774. case 'text':
  775. ele = $(`<li>${i18n(text)}<font></font></li>`);
  776. break;
  777.  
  778. case 'html':
  779. ele = $(text || html);
  780. break;
  781.  
  782. case 'whiteList':
  783. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  784. break;
  785.  
  786. case 'globalOptionsSkip':
  787. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  788. break;
  789.  
  790. default:
  791. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  792. break;
  793. }
  794. } else if (text) {
  795. ele = $(`<li>${i18n(text)}<font></font></li>`);
  796. } else if (html) {
  797. ele = $(html);
  798. } else {
  799. ele = $('<li><font></font></li>');
  800. }
  801. ele.addClass('card-text');
  802. $('#auto-task-info').append(ele);
  803. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  804. const font = ele.find('font');
  805. const status = {
  806. font: font,
  807. success() {
  808. var _this$font, _this$font2, _this$font3;
  809. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  810. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  811. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  812. html ? (_this$font2 = this.font) === null || _this$font2 === void 0 ? void 0 : _this$font2.html(text) : (_this$font3 = this.font) === null || _this$font3 === void 0 ? void 0 : _this$font3.text(text);
  813. return this;
  814. },
  815. error() {
  816. var _this$font4, _this$font5, _this$font6;
  817. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  818. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  819. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  820. html ? (_this$font5 = this.font) === null || _this$font5 === void 0 ? void 0 : _this$font5.html(text) : (_this$font6 = this.font) === null || _this$font6 === void 0 ? void 0 : _this$font6.text(text);
  821. return this;
  822. },
  823. warning() {
  824. var _this$font7, _this$font8, _this$font9;
  825. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  826. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  827. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  828. html ? (_this$font8 = this.font) === null || _this$font8 === void 0 ? void 0 : _this$font8.html(text) : (_this$font9 = this.font) === null || _this$font9 === void 0 ? void 0 : _this$font9.text(text);
  829. return this;
  830. },
  831. info() {
  832. var _this$font10, _this$font11, _this$font12;
  833. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  834. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  835. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  836. html ? (_this$font11 = this.font) === null || _this$font11 === void 0 ? void 0 : _this$font11.html(text) : (_this$font12 = this.font) === null || _this$font12 === void 0 ? void 0 : _this$font12.text(text);
  837. return this;
  838. },
  839. view() {
  840. var _this$font13;
  841. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  842. return this;
  843. }
  844. };
  845. return status;
  846. } catch (error) {
  847. throwError(error, 'echoLog');
  848. return emptyStatus;
  849. }
  850. };
  851. const scripts_echoLog = echoLog;
  852. const unique = array => {
  853. try {
  854. return [ ...new Set(array) ];
  855. } catch (error) {
  856. throwError(error, 'unique');
  857. return [];
  858. }
  859. };
  860. const delay = function() {
  861. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  862. return new Promise(resolve => {
  863. setTimeout(() => {
  864. resolve(true);
  865. }, time);
  866. });
  867. };
  868. const getRedirectLink = async link => {
  869. try {
  870. if (!link) {
  871. return null;
  872. }
  873. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  874. if (redirectLinksCache[link]) {
  875. redirectLinksCache[link];
  876. }
  877. return await tools_httpRequest({
  878. url: link,
  879. method: 'GET'
  880. }).then(_ref => {
  881. let {
  882. data
  883. } = _ref;
  884. if (data !== null && data !== void 0 && data.finalUrl) {
  885. redirectLinksCache[link] = data.finalUrl;
  886. GM_setValue('redirectLinks', redirectLinksCache);
  887. return data.finalUrl;
  888. }
  889. return null;
  890. });
  891. } catch (error) {
  892. throwError(error, 'getRedirectLink');
  893. return null;
  894. }
  895. };
  896. const visitLink = async (link, options) => {
  897. try {
  898. const logStatus = scripts_echoLog({
  899. type: 'visitLink',
  900. text: link
  901. });
  902. return await tools_httpRequest({
  903. url: link,
  904. method: 'GET',
  905. ...options
  906. }).then(_ref2 => {
  907. let {
  908. result,
  909. statusText,
  910. status
  911. } = _ref2;
  912. if (result === 'Success') {
  913. logStatus.success();
  914. return true;
  915. }
  916. logStatus.error(`${result}:${statusText}(${status})`);
  917. return false;
  918. });
  919. } catch (error) {
  920. throwError(error, 'visitLink');
  921. return false;
  922. }
  923. };
  924. const getUrlQuery = url => {
  925. try {
  926. const query = {};
  927. if (url) {
  928. if (url.includes('?')) {
  929. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  930. query[key] = value;
  931. return str;
  932. });
  933. }
  934. } else {
  935. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  936. query[key] = value;
  937. return str;
  938. });
  939. }
  940. return query;
  941. } catch (error) {
  942. throwError(error, 'getUrlQuery');
  943. return {};
  944. }
  945. };
  946. const getUuid = () => {
  947. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  948. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  949. };
  950. const stringToColour = str => {
  951. try {
  952. let hash = 0;
  953. for (let i = 0; i < str.length; i++) {
  954. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  955. }
  956. let colour = '#';
  957. for (let i = 0; i < 3; i++) {
  958. const value = hash >> i * 8 & 255;
  959. colour += `00${value.toString(16)}`.slice(-2);
  960. }
  961. return colour;
  962. } catch (error) {
  963. throwError(error, 'stringToColour');
  964. return '#fff';
  965. }
  966. };
  967. const defaultGlobalOptions = {
  968. doTask: {
  969. discord: {
  970. servers: true
  971. },
  972. instagram: {
  973. users: true
  974. },
  975. twitch: {
  976. channels: true
  977. },
  978. twitter: {
  979. users: true,
  980. retweets: true
  981. },
  982. vk: {
  983. names: true
  984. },
  985. youtube: {
  986. channels: true,
  987. likes: true
  988. },
  989. reddit: {
  990. reddits: true
  991. },
  992. steam: {
  993. groups: true,
  994. officialGroups: true,
  995. wishlists: true,
  996. follows: true,
  997. forums: true,
  998. workshops: true,
  999. curators: true,
  1000. workshopVotes: true,
  1001. announcements: true,
  1002. licenses: true,
  1003. playtests: true
  1004. }
  1005. },
  1006. undoTask: {
  1007. discord: {
  1008. servers: true
  1009. },
  1010. instagram: {
  1011. users: true
  1012. },
  1013. twitch: {
  1014. channels: true
  1015. },
  1016. twitter: {
  1017. users: true,
  1018. retweets: true
  1019. },
  1020. vk: {
  1021. names: true
  1022. },
  1023. youtube: {
  1024. channels: true,
  1025. likes: true
  1026. },
  1027. reddit: {
  1028. reddits: true
  1029. },
  1030. steam: {
  1031. groups: true,
  1032. officialGroups: true,
  1033. wishlists: true,
  1034. follows: true,
  1035. forums: true,
  1036. workshops: true,
  1037. curators: true
  1038. }
  1039. },
  1040. position: {
  1041. buttonSideX: 'right',
  1042. buttonSideY: 'top',
  1043. buttonDistance: '15,30',
  1044. showButtonSideX: 'right',
  1045. showButtonSideY: 'top',
  1046. showButtonDistance: '15,30',
  1047. logSideX: 'right',
  1048. logSideY: 'bottom',
  1049. logDistance: '10,10'
  1050. },
  1051. hotKey: {
  1052. doTaskKey: 'alt + d',
  1053. undoTaskKey: 'alt + u',
  1054. toggleLogKey: 'alt + l'
  1055. },
  1056. other: {
  1057. twitterVerifyId: '783214',
  1058. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1059. autoUpdateSource: 'jsdelivr',
  1060. language: 'zh',
  1061. checkLogin: true,
  1062. checkLeftKey: true,
  1063. defaultShowButton: true,
  1064. defaultShowLog: true,
  1065. debug: false,
  1066. receivePreview: true
  1067. }
  1068. };
  1069. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1070. const assignObject = (obj1, obj2) => {
  1071. try {
  1072. const newObj = {};
  1073. for (const [ key, value ] of Object.entries(obj1)) {
  1074. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1075. newObj[key] = assignObject(value, obj2[key]);
  1076. } else {
  1077. newObj[key] = obj2[key] ?? value;
  1078. }
  1079. }
  1080. return newObj;
  1081. } catch (error) {
  1082. throwError(error, 'assignObject');
  1083. return defaultGlobalOptions;
  1084. }
  1085. };
  1086. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1087. const saveData = () => {
  1088. try {
  1089. const data = {};
  1090. $('#globalOptionsForm').serializeArray().map(value => {
  1091. data[value.name] = value.value;
  1092. return value;
  1093. });
  1094. $.makeArray($('#globalOptionsForm input')).map(element => {
  1095. const name = $(element).attr('name');
  1096. const keys = name.split('.');
  1097. if (keys.length === 3) {
  1098. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1099. } else if (keys.length === 2) {
  1100. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1101. }
  1102. return element;
  1103. });
  1104. GM_setValue('globalOptions', globalOptions);
  1105. external_Swal_default().fire({
  1106. title: i18n('changeGlobalOptionsSuccess'),
  1107. icon: 'success'
  1108. });
  1109. } catch (error) {
  1110. throwError(error, 'saveData');
  1111. }
  1112. };
  1113. const changeGlobalOptions = showType => {
  1114. try {
  1115. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1116. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1117. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1118. for (const [ option, data2 ] of Object.entries(data1)) {
  1119. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1120. if (typeof data2 === 'boolean') {
  1121. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><label><input type="checkbox" name="${type}.${option}"${data2 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1122. } else {
  1123. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><input class="editOption" type="text" name="${type}.${option}" value="${data2}"/></td></tr>`;
  1124. }
  1125. } else {
  1126. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1127. globalOptionsForm += `<tr style="background-color: ${stringToColour(option)}66">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).map(key => Object.keys(data1[key]).length).reduce((acr, cur) => acr + cur)}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${option}.${i18n(socialType)}</td><td><label><input type="checkbox" name="${type}.${option}.${socialType}"${data3 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1128. }
  1129. }
  1130. }
  1131. }
  1132. globalOptionsForm += '</tbody></table></form>';
  1133. if (showType === 'swal') {
  1134. external_Swal_default().fire({
  1135. title: i18n('globalOptions'),
  1136. html: globalOptionsForm,
  1137. showConfirmButton: true,
  1138. confirmButtonText: i18n('save'),
  1139. showCancelButton: true,
  1140. cancelButtonText: i18n('close')
  1141. }).then(_ref => {
  1142. let {
  1143. isConfirmed
  1144. } = _ref;
  1145. if (isConfirmed) {
  1146. saveData();
  1147. }
  1148. });
  1149. } else {
  1150. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1151. }
  1152. } catch (error) {
  1153. throwError(error, 'changeGlobalOptions');
  1154. }
  1155. };
  1156. const data = {
  1157. website: '网站',
  1158. type: '类型',
  1159. edit: '编辑',
  1160. whiteList: '白名单',
  1161. skipTask: '跳过撤销任务',
  1162. whiteListOptions: '白名单设置',
  1163. changeWhiteListOption: '设置白名单(%0)',
  1164. whiteListNotFound: '找不到此项白名单: %0',
  1165. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1166. changeWebsiteOptions: '网站设置',
  1167. changeGlobalOptions: '全局设置',
  1168. ok: '是',
  1169. save: '保存',
  1170. close: '关闭',
  1171. return: '返回',
  1172. option: '选项',
  1173. value: '值',
  1174. websiteOptions: '当前网站设置',
  1175. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1176. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1177. needLogin: '请先登录!',
  1178. getTasksInfo: '正在获取并处理任务信息...',
  1179. gettingKey: '正在获取Key...',
  1180. verifyingTask: '正在验证任务',
  1181. notice: '自动任务脚本提醒',
  1182. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1183. giveawayEnded: '此活动已结束,是否关闭?',
  1184. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1185. confirm: '确定',
  1186. cancel: '取消',
  1187. unKnown: '未知',
  1188. unKnownTaskType: '未识别的任务',
  1189. doing: '正在做任务',
  1190. allTasksComplete: '所有任务已完成!',
  1191. getTaskIdFailed: '获取任务Id失败!',
  1192. initSuccess: '%0 初始化成功!',
  1193. initFailed: '%0 初始化失败!',
  1194. errorLink: '链接错误: %0',
  1195. needInit: '请先初始化',
  1196. verifyingAuth: '正在验证%0凭证...',
  1197. updatingAuth: '正在更新%0凭证...',
  1198. initing: '正在初始化...',
  1199. getFailed: '获取%0失败!',
  1200. checkLoginFailed: '检测登录状态失败!',
  1201. checkLeftKeyFailed: '检测剩余Key失败!',
  1202. userId: '用户Id',
  1203. joiningGiveaway: '正在加入赠Key',
  1204. needJoinGiveaway: '需要先加入赠Key',
  1205. cannotUndo: '此网站不支持取消任务',
  1206. verifyAuth: '正在验证 %0 凭证...',
  1207. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1208. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1209. visitingLink: '正在访问链接: ',
  1210. doTask: '做任务',
  1211. undoTask: '撤销任务',
  1212. verifyTask: '验证任务',
  1213. getKey: '获取Key',
  1214. selectAll: '全选',
  1215. selectNone: '全不选',
  1216. invertSelect: '反选',
  1217. doFreeTask: '加入免费赠品',
  1218. doPointTask: '加入点数赠品',
  1219. skipTaskOption: '设置中已配置跳过任务',
  1220. other: '其他',
  1221. globalOptions: '全局设置',
  1222. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1223. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1224. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1225. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1226. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1227. saveGlobalOptions: '保存全局设置',
  1228. settingPage: '设置页面',
  1229. name: '名称',
  1230. version: '版本',
  1231. scriptManager: '脚本管理器',
  1232. script: '脚本',
  1233. environment: '环境',
  1234. os: '系统',
  1235. browser: '浏览器',
  1236. getId: '获取 %0 id',
  1237. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1238. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1239. showButton: '显示按钮',
  1240. hideButton: '隐藏按钮',
  1241. showLog: '显示日志',
  1242. hideLog: '隐藏日志',
  1243. defaultShowButton: '默认显示按钮',
  1244. defaultShowLog: '默认显示日志',
  1245. debug: '输出调试日志,不要开启此选项!',
  1246. receivePreview: '接收预览版更新',
  1247. position: '组件位置',
  1248. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1249. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1250. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1251. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1252. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1253. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1254. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1255. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1256. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1257. hotKey: '快捷键',
  1258. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1259. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1260. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1261. tasksHistory: '任务历史',
  1262. clearHistory: '清空历史',
  1263. clearHistoryFinished: '已清空任务历史!',
  1264. deleteTask: '删除任务',
  1265. lastChangeTime: '最后一次修改时间',
  1266. clearTaskFinished: '删除以下任务完成!',
  1267. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1268. syncData: '数据同步',
  1269. settingData: '正在上传数据...',
  1270. gettingData: '正在获取数据...',
  1271. help: '帮助',
  1272. fileName: '文件名',
  1273. upload2gist: '同步到Gist',
  1274. downloadFromGist: '从Gist同步',
  1275. saveAndTest: '保存配置并测试',
  1276. testSuccess: '测试成功!',
  1277. testFailed: '测试失败!',
  1278. saveAndTestNotice: '请先保存配置并测试!',
  1279. processingData: '正在处理数据...',
  1280. updatingData: '正在上传数据...',
  1281. syncDataSuccess: '同步数据成功!',
  1282. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1283. downloadingData: '正在下载数据...',
  1284. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1285. savingData: '正在保存数据...',
  1286. syncHistory: '同步任务历史',
  1287. checkUpdateFailed: '检测更新失败',
  1288. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1289. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1290. gistOptions: 'Gist 设置',
  1291. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1292. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1293. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1294. toGithub: '前往Github反馈',
  1295. toKeylol: '前往其乐论坛反馈',
  1296. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1297. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1298. updateText: '%0 版本更新内容:',
  1299. Active: '进行中',
  1300. Ended: '已结束',
  1301. Banned: '已封禁',
  1302. Paused: '已暂停',
  1303. notStart: '未开始',
  1304. noRemoteData: '检测到远程无数据',
  1305. errorRemoteDataFormat: '远程数据格式错误',
  1306. updateHistory: '历史更新记录<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">点此查看</a>',
  1307. groups: '组',
  1308. officialGroups: '官方组',
  1309. wishlists: '愿望单',
  1310. follows: '游戏关注',
  1311. forums: '论坛',
  1312. workshops: '创意工坊收藏',
  1313. curators: '鉴赏家',
  1314. workshopVotes: '创意工坊点赞',
  1315. announcements: '社区通知',
  1316. steamCommunity: 'Steam社区',
  1317. steamStore: 'Steam商店',
  1318. licenses: '入库免费游戏',
  1319. playtests: '请求访问权限',
  1320. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1321. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1322. joiningSteamGroup: '正在加入Steam组',
  1323. leavingSteamGroup: '正在退出Steam组',
  1324. gettingSteamGroupId: '正在获取Steam组Id',
  1325. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1326. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1327. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1328. subscribingForum: '正在订阅Steam论坛',
  1329. unsubscribingForum: '正在取消订阅Steam论坛',
  1330. gettingForumId: '正在获取Steam论坛Id',
  1331. followingCurator: '正在关注Steam鉴赏家',
  1332. unfollowingCurator: '正在取关Steam鉴赏家',
  1333. gettingCuratorId: '正在获取Steam鉴赏家Id',
  1334. addingToWishlist: '正在添加游戏到Steam愿望单',
  1335. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1336. followingGame: '正在关注Steam游戏',
  1337. unfollowingGame: '正在取关Steam游戏',
  1338. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1339. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1340. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1341. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1342. gettingAnnouncementParams: '正在获取Steam通知信息',
  1343. likingAnnouncement: '正在点赞Steam通知',
  1344. changingArea: '正在更换Steam地区: %0...',
  1345. notNeededChangeArea: '当前地区不需要更换',
  1346. noAnotherArea: '请检测是否开启正确开启代理',
  1347. gettingAreaInfo: '正在获取Steam地区信息...',
  1348. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1349. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1350. gettingSubid: '正在获取游戏subid',
  1351. addingFreeLicense: '正在入库',
  1352. missParams: '缺少参数',
  1353. gettingLicenses: '正在获取Licenses...',
  1354. requestingPlayTestAccess: '正在请求访问权限',
  1355. tryChangeAreaNotice: '此功能无法检测游戏是否限区,因此会尝试换区后再入库,换区失败也不影响后续入库',
  1356. servers: '服务器',
  1357. joiningDiscordServer: '正在加入Discord服务器',
  1358. leavingDiscordServer: '正在退出Discord服务器',
  1359. gettingDiscordGuild: '正在获取Discord服务器Id',
  1360. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1361. users: '用户',
  1362. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1363. insBanned: '您的Instagram账户已被封禁',
  1364. verifyingInsAuth: '正在验证Instagram凭证...',
  1365. gettingInsUserId: '正在获取Instagram用户Id',
  1366. followingIns: '正在关注Instagram用户',
  1367. unfollowingIns: '正在取关Instagram用户',
  1368. reddits: '社区/用户',
  1369. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1370. changingRedditVersion: '正在切换Reddit为新版页面...',
  1371. joiningReddit: '正在加入Reddit社区',
  1372. leavingReddit: '正在退出Reddit社区',
  1373. followingRedditUser: '正在关注Reddit用户',
  1374. unfollowingRedditUser: '正在取关Reddit用户',
  1375. channels: '频道',
  1376. followingTwitchChannel: '正在关注Twitch频道',
  1377. unfollowingTwitchChannel: '正在取关Twitch频道',
  1378. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1379. twitterUser: '推特用户',
  1380. retweets: '转推',
  1381. followingTwitterUser: '正在关注推特用户',
  1382. unfollowingTwitterUser: '正在取关推特用户',
  1383. retweetting: '正在转推',
  1384. unretweetting: '正在撤销转推',
  1385. names: '组/社区/动态',
  1386. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1387. gettingVkId: '正在获取Vk任务Id',
  1388. joiningVkGroup: '正在加入Vk组',
  1389. leavingVkGroup: '正在退出Vk组',
  1390. joiningVkPublic: '正在加入Vk社区',
  1391. leavingVkPublic: '正在退出Vk社区',
  1392. sendingVkWall: '正在转发Vk动态',
  1393. deletingVkWall: '正在撤销转发Vk动态',
  1394. youtubeChannel: 'YouTube频道',
  1395. likes: '点赞',
  1396. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1397. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1398. gettingYtbToken: '正在获取YouTube Token...',
  1399. followingYtbChannel: '正在订阅YouTube频道',
  1400. unfollowingYtbChannel: '正在退订YouTube频道',
  1401. likingYtbVideo: '正在点赞YouTube视频',
  1402. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1403. giveKeyNoticeBefore: '每次验证间隔15s',
  1404. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1405. noPoints: '点数不够,跳过抽奖',
  1406. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1407. joiningLottery: '正在加入抽奖',
  1408. doingGleamTask: '正在做Gleam任务...',
  1409. gettingGleamLink: '正在获取Gleam任务链接...',
  1410. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1411. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1412. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1413. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1414. };
  1415. const zh_CN = data;
  1416. const en_US_data = {
  1417. website: 'Website',
  1418. type: 'Type',
  1419. edit: 'Edit',
  1420. whiteList: 'Whitelist',
  1421. skipTask: 'Skip undo task',
  1422. whiteListOptions: 'Whitelist options',
  1423. changeWhiteListOption: 'Whitelist option(%0)',
  1424. whiteListNotFound: 'Cannot find this whitelist: %0',
  1425. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1426. changeWebsiteOptions: 'Website options',
  1427. changeGlobalOptions: 'Global options',
  1428. ok: 'OK',
  1429. save: 'Save',
  1430. close: 'Close',
  1431. return: 'Return',
  1432. option: 'Option',
  1433. value: 'Value',
  1434. websiteOptions: 'Current website settings',
  1435. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1436. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1437. needLogin: 'Please log in first!',
  1438. getTasksInfo: 'Obtaining and processing task information...',
  1439. gettingKey: 'Getting Key...',
  1440. verifyingTask: 'Verifying task',
  1441. notice: 'Automatic task script notice',
  1442. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1443. giveawayEnded: 'This event has ended, do you want to close it?',
  1444. 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?',
  1445. confirm: 'Confirm',
  1446. cancel: 'Cancel',
  1447. unKnown: 'Unknown',
  1448. unKnownTaskType: 'Unrecognized task',
  1449. doing: 'Doing a task',
  1450. allTasksComplete: 'All tasks have been completed!',
  1451. getTaskIdFailed: 'Failed to obtain task Id!',
  1452. initSuccess: '%0 was initialized successfully!',
  1453. initFailed: '%0 initialization failed!',
  1454. errorLink: 'Link error: %0',
  1455. needInit: 'Please initialize first',
  1456. verifyingAuth: 'Verifying %0 token...',
  1457. updatingAuth: 'Update %0 token...',
  1458. initing: 'Initializing...',
  1459. getFailed: 'Failed to get %0!',
  1460. checkLoginFailed: 'Failed to detect login status!',
  1461. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1462. userId: 'User Id',
  1463. joiningGiveaway: 'Joining giveaway',
  1464. needJoinGiveaway: 'Need to join the giveaway first',
  1465. cannotUndo: 'This website does not support canceling tasks',
  1466. verifyAuth: 'Verifying %0 token...',
  1467. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1468. errorReport: 'A script error is detected, do you want to report the BUG?',
  1469. visitingLink: 'Visiting link: ',
  1470. doTask: 'DoTask',
  1471. undoTask: 'UndoTask',
  1472. verifyTask: 'Verify',
  1473. getKey: 'GetKey',
  1474. selectAll: 'SelectAll',
  1475. selectNone: 'SelectNone',
  1476. invertSelect: 'InvertSelect',
  1477. doFreeTask: 'FreeTask',
  1478. doPointTask: 'PointTask',
  1479. skipTaskOption: 'Skip task has been configured in the settings',
  1480. other: 'Other',
  1481. globalOptions: 'Global Options',
  1482. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1483. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1484. 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.',
  1485. 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.',
  1486. 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.',
  1487. saveGlobalOptions: 'SaveSettings',
  1488. settingPage: 'Setting Page',
  1489. name: 'Name',
  1490. version: 'Version',
  1491. scriptManager: 'Script Manager',
  1492. script: 'Script',
  1493. environment: 'Environment',
  1494. os: 'OS',
  1495. browser: 'Browser',
  1496. getId: 'Get %0 id',
  1497. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1498. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1499. showButton: 'ShowButton',
  1500. hideButton: 'HideButton',
  1501. showLog: 'ShowLog',
  1502. hideLog: 'HideLog',
  1503. defaultShowButton: 'Default display button',
  1504. defaultShowLog: 'Display log by default',
  1505. debug: 'Output debug log, do not enable this option!',
  1506. receivePreview: 'Receive preview updates',
  1507. position: 'Component position',
  1508. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1509. 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',
  1510. 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',
  1511. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1512. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1513. 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',
  1514. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1515. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1516. 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',
  1517. hotKey: 'Shortcut key',
  1518. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1519. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1520. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1521. tasksHistory: 'TasksHistory',
  1522. clearHistory: 'Clear history',
  1523. clearHistoryFinished: 'The mission history has been cleared!',
  1524. deleteTask: 'Delete task',
  1525. lastChangeTime: 'Last Change Time',
  1526. clearTaskFinished: 'Delete the following tasks completed!',
  1527. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1528. syncData: 'DataSync',
  1529. settingData: 'Uploading data...',
  1530. gettingData: 'Getting data...',
  1531. help: 'Help',
  1532. fileName: 'Filename',
  1533. upload2gist: 'Sync to Gist',
  1534. downloadFromGist: 'Sync from Gist',
  1535. saveAndTest: 'Save configuration and test',
  1536. testSuccess: 'Test success!',
  1537. testFailed: 'Test failed!',
  1538. saveAndTestNotice: 'Please save the configuration and test first!',
  1539. processingData: 'Processing data...',
  1540. updatingData: 'Uploading data...',
  1541. syncDataSuccess: 'Synchronized data successfully!',
  1542. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1543. downloadingData: 'Downloading data...',
  1544. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1545. savingData: 'Saving data...',
  1546. syncHistory: 'Synchronize tasks history',
  1547. checkUpdateFailed: 'Check update failed',
  1548. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1549. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1550. gistOptions: 'Gist Settings',
  1551. 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!',
  1552. 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!',
  1553. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1554. toGithub: 'Feedback(Github)',
  1555. toKeylol: 'Feedback(Keylol)',
  1556. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1557. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1558. updateText: 'Updates in version %0:',
  1559. Active: 'Active',
  1560. Ended: 'Ended',
  1561. Banned: 'Banned',
  1562. Paused: 'Paused',
  1563. notStart: 'notStart',
  1564. noRemoteData: 'No data remotely',
  1565. errorRemoteDataFormat: 'Remote data has wrong format',
  1566. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1567. groups: 'Group',
  1568. officialGroups: 'Official Group',
  1569. wishlists: 'Wishlist',
  1570. follows: 'Follow Game',
  1571. forums: 'Forum',
  1572. workshops: 'Favorite Workshop',
  1573. curators: 'Curator',
  1574. workshopVotes: 'Voteup Workshop',
  1575. announcements: 'Announcement',
  1576. steamCommunity: 'Steam Community',
  1577. steamStore: 'Steam Store',
  1578. licenses: 'Add License',
  1579. playtests: 'Playtest Access',
  1580. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1581. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1582. joiningSteamGroup: 'Joining Steam Group',
  1583. leavingSteamGroup: 'Leaving Steam Group',
  1584. gettingSteamGroupId: 'Getting Steam Group Id',
  1585. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1586. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1587. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1588. subscribingForum: 'Subscribing the Steam Forum',
  1589. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1590. gettingForumId: 'Getting Steam Forum Id',
  1591. followingCurator: 'Following Steam Curator',
  1592. unfollowingCurator: 'Unfollowing Steam Curator',
  1593. gettingCuratorId: 'Getting Steam Curator Id',
  1594. addingToWishlist: 'Adding the game to the Steam wishlist',
  1595. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1596. followingGame: 'Following Steam games',
  1597. unfollowingGame: 'Unfollowing Steam games',
  1598. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1599. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1600. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1601. votingUpWorkshop: 'Liking Steam workshop items',
  1602. gettingAnnouncementParams: 'Getting Steam announcement information',
  1603. likingAnnouncement: 'Liking Steam announcement',
  1604. changingArea: 'Changing Steam area: %0...',
  1605. notNeededChangeArea: 'The current area does not need to be changed',
  1606. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1607. gettingAreaInfo: 'Getting Steam area information...',
  1608. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1609. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1610. gettingSubid: 'Getting subid',
  1611. addingFreeLicense: 'Adding free license',
  1612. missParams: 'Missing parameters',
  1613. gettingLicenses: 'Getting licenses...',
  1614. requestingPlayTestAccess: 'Requesting play test access',
  1615. tryChangeAreaNotice: 'This function cannot detect whether the game is limited, so it will try to change the area before entering the library' + '. Failure to change the area will not affect the subsequent storage.',
  1616. servers: 'Server',
  1617. joiningDiscordServer: 'Joining Discord Server',
  1618. leavingDiscordServer: 'Leaving Discord Server',
  1619. gettingDiscordGuild: 'Getting Discord server Id',
  1620. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1621. users: 'User',
  1622. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1623. insBanned: 'Your Instagram account has been banned',
  1624. verifyingInsAuth: 'Verifying Instagram token...',
  1625. gettingInsUserId: 'Getting Instagram user Id',
  1626. followingIns: 'Following Instagram user',
  1627. unfollowingIns: 'Unfollowing Instagram user',
  1628. reddits: 'Reddit/User',
  1629. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1630. changingRedditVersion: 'Switching Reddit to a new version page...',
  1631. joiningReddit: 'Joining the Reddit',
  1632. leavingReddit: 'Leaving the Reddit',
  1633. followingRedditUser: 'Following Reddit User',
  1634. unfollowingRedditUser: 'Unfollowing Reddit User',
  1635. channels: 'Channel',
  1636. followingTwitchChannel: 'Following Twitch Channel',
  1637. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1638. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1639. twitterUser: 'Twitter User',
  1640. retweets: 'Retweet',
  1641. followingTwitterUser: 'Following Twitter User',
  1642. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1643. retweetting: 'Retweetting',
  1644. unretweetting: 'Unretweetting',
  1645. names: 'Group/Public/Wall',
  1646. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1647. gettingVkId: 'Getting Vk task Id',
  1648. joiningVkGroup: 'Joining Vk Group',
  1649. leavingVkGroup: 'Leaving Vk Group',
  1650. joiningVkPublic: 'Joining Vk Public',
  1651. leavingVkPublic: 'Leaving Vk Public',
  1652. sendingVkWall: 'Sending Vk Wall',
  1653. deletingVkWall: 'Deleting Vk Wall',
  1654. youtubeChannel: 'YouTube Channel',
  1655. likes: 'Like',
  1656. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1657. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1658. gettingYtbToken: 'Getting YouTube Token...',
  1659. followingYtbChannel: 'Subscribing to YouTube channel',
  1660. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1661. likingYtbVideo: 'Liking YouTube video',
  1662. unlikingYtbVideo: 'Unliking YouTube video',
  1663. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1664. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1665. noPoints: 'Not enough points, skip the lottery',
  1666. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1667. joiningLottery: 'Joining the lottery',
  1668. doingGleamTask: 'Doing Gleam Task...',
  1669. gettingGleamLink: 'Getting Gleam task link...',
  1670. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1671. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1672. 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!',
  1673. 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...'
  1674. };
  1675. const en_US = en_US_data;
  1676. const languages = {
  1677. zh: zh_CN,
  1678. en: en_US
  1679. };
  1680. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1681. const I18n = function(key) {
  1682. var _languages$language;
  1683. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1684. argvs[_key - 1] = arguments[_key];
  1685. }
  1686. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1687. return key;
  1688. }
  1689. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1690. };
  1691. const i18n = I18n;
  1692. function throwError(error, name) {
  1693. if (window.TRACE) {
  1694. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1695. }
  1696. external_Swal_default().fire({
  1697. title: i18n('errorReport'),
  1698. icon: 'error',
  1699. showCancelButton: true,
  1700. confirmButtonText: i18n('toGithub'),
  1701. showDenyButton: true,
  1702. denyButtonText: i18n('toKeylol'),
  1703. cancelButtonText: i18n('close')
  1704. }).then(_ref => {
  1705. let {
  1706. isDenied,
  1707. isConfirmed
  1708. } = _ref;
  1709. if (isConfirmed) {
  1710. 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,
  1711. 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');
  1712. } else if (isDenied) {
  1713. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1714.  
  1715. 环境:
  1716.  
  1717. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1718.  
  1719. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1720. 脚本版本: ${GM_info.script.version}
  1721.  
  1722. 报错信息:
  1723. [code]${error.stack}[/code]
  1724.  
  1725. 执行日志:
  1726. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1727. GM_setClipboard(text);
  1728. external_Swal_default().fire({
  1729. title: i18n('copySuccess'),
  1730. icon: 'success',
  1731. confirmButtonText: i18n('ok')
  1732. }).then(() => {
  1733. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1734. });
  1735. }
  1736. });
  1737. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1738. }
  1739. function _defineProperty(obj, key, value) {
  1740. if (key in obj) {
  1741. Object.defineProperty(obj, key, {
  1742. value: value,
  1743. enumerable: true,
  1744. configurable: true,
  1745. writable: true
  1746. });
  1747. } else {
  1748. obj[key] = value;
  1749. }
  1750. return obj;
  1751. }
  1752. class Social {
  1753. constructor() {
  1754. _defineProperty(this, 'tasks', void 0);
  1755. }
  1756. getRealParams(name, links, doTask, link2param) {
  1757. try {
  1758. let realParams = [];
  1759. if (links.length > 0) {
  1760. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1761. }
  1762. if (!doTask && this.tasks[name].length > 0) {
  1763. realParams = [ ...realParams, ...this.tasks[name] ];
  1764. }
  1765. return unique(realParams);
  1766. } catch (error) {
  1767. throwError(error, 'Social.getRealParams');
  1768. return [];
  1769. }
  1770. }
  1771. }
  1772. const social_Social = Social;
  1773. function _classPrivateMethodInitSpec(obj, privateSet) {
  1774. _checkPrivateRedeclaration(obj, privateSet);
  1775. privateSet.add(obj);
  1776. }
  1777. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1778. _checkPrivateRedeclaration(obj, privateMap);
  1779. privateMap.set(obj, value);
  1780. }
  1781. function _checkPrivateRedeclaration(obj, privateCollection) {
  1782. if (privateCollection.has(obj)) {
  1783. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1784. }
  1785. }
  1786. function Discord_defineProperty(obj, key, value) {
  1787. if (key in obj) {
  1788. Object.defineProperty(obj, key, {
  1789. value: value,
  1790. enumerable: true,
  1791. configurable: true,
  1792. writable: true
  1793. });
  1794. } else {
  1795. obj[key] = value;
  1796. }
  1797. return obj;
  1798. }
  1799. function _classPrivateFieldSet(receiver, privateMap, value) {
  1800. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1801. _classApplyDescriptorSet(receiver, descriptor, value);
  1802. return value;
  1803. }
  1804. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1805. if (descriptor.set) {
  1806. descriptor.set.call(receiver, value);
  1807. } else {
  1808. if (!descriptor.writable) {
  1809. throw new TypeError('attempted to set read only private field');
  1810. }
  1811. descriptor.value = value;
  1812. }
  1813. }
  1814. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1815. if (!privateSet.has(receiver)) {
  1816. throw new TypeError('attempted to get private field on non-instance');
  1817. }
  1818. return fn;
  1819. }
  1820. function _classPrivateFieldGet(receiver, privateMap) {
  1821. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1822. return _classApplyDescriptorGet(receiver, descriptor);
  1823. }
  1824. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1825. if (!privateMap.has(receiver)) {
  1826. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1827. }
  1828. return privateMap.get(receiver);
  1829. }
  1830. function _classApplyDescriptorGet(receiver, descriptor) {
  1831. if (descriptor.get) {
  1832. return descriptor.get.call(receiver);
  1833. }
  1834. return descriptor.value;
  1835. }
  1836. const defaultTasksTemplate = {
  1837. servers: []
  1838. };
  1839. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1840. var _auth = new WeakMap();
  1841. var _cache = new WeakMap();
  1842. var _initialized = new WeakMap();
  1843. var _verifyAuth = new WeakSet();
  1844. var _updateAuth = new WeakSet();
  1845. var _joinServer = new WeakSet();
  1846. var _leaveServer = new WeakSet();
  1847. var _getGuild = new WeakSet();
  1848. var _setCache = new WeakSet();
  1849. class Discord extends social_Social {
  1850. constructor() {
  1851. var _GM_getValue;
  1852. super(...arguments);
  1853. _classPrivateMethodInitSpec(this, _setCache);
  1854. _classPrivateMethodInitSpec(this, _getGuild);
  1855. _classPrivateMethodInitSpec(this, _leaveServer);
  1856. _classPrivateMethodInitSpec(this, _joinServer);
  1857. _classPrivateMethodInitSpec(this, _updateAuth);
  1858. _classPrivateMethodInitSpec(this, _verifyAuth);
  1859. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1860. Discord_defineProperty(this, 'whiteList', {
  1861. ...JSON.parse(defaultTasks),
  1862. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1863. });
  1864. _classPrivateFieldInitSpec(this, _auth, {
  1865. writable: true,
  1866. value: GM_getValue('discordAuth') || {}
  1867. });
  1868. _classPrivateFieldInitSpec(this, _cache, {
  1869. writable: true,
  1870. value: GM_getValue('discordCache') || {}
  1871. });
  1872. _classPrivateFieldInitSpec(this, _initialized, {
  1873. writable: true,
  1874. value: false
  1875. });
  1876. }
  1877. async init() {
  1878. try {
  1879. if (_classPrivateFieldGet(this, _initialized)) {
  1880. return true;
  1881. }
  1882. if (!_classPrivateFieldGet(this, _auth).auth) {
  1883. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1884. _classPrivateFieldSet(this, _initialized, true);
  1885. return true;
  1886. }
  1887. return false;
  1888. }
  1889. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1890. if (isVerified) {
  1891. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1892. _classPrivateFieldSet(this, _initialized, true);
  1893. return true;
  1894. }
  1895. GM_setValue('discordAuth', {
  1896. auth: null
  1897. });
  1898. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1899. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1900. _classPrivateFieldSet(this, _initialized, true);
  1901. return true;
  1902. }
  1903. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1904. return false;
  1905. } catch (error) {
  1906. throwError(error, 'Discord.init');
  1907. return false;
  1908. }
  1909. }
  1910. async toggle(_ref) {
  1911. let {
  1912. doTask = true,
  1913. serverLinks = []
  1914. } = _ref;
  1915. try {
  1916. if (!_classPrivateFieldGet(this, _initialized)) {
  1917. scripts_echoLog({
  1918. text: i18n('needInit')
  1919. });
  1920. return false;
  1921. }
  1922. const prom = [];
  1923. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1924. scripts_echoLog({
  1925. type: 'globalOptionsSkip',
  1926. text: 'discord.servers'
  1927. });
  1928. } else {
  1929. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1930. var _link$match;
  1931. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1932. });
  1933. if (realServers.length > 0) {
  1934. for (const server of realServers) {
  1935. if (doTask) {
  1936. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1937. } else {
  1938. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1939. }
  1940. await delay(1e3);
  1941. }
  1942. }
  1943. }
  1944. return await Promise.all(prom).then(() => true);
  1945. } catch (error) {
  1946. throwError(error, 'Discord.toggleServers');
  1947. return false;
  1948. }
  1949. }
  1950. }
  1951. async function _verifyAuth2() {
  1952. try {
  1953. const logStatus = scripts_echoLog({
  1954. text: i18n('verifyingAuth', 'Discord')
  1955. });
  1956. const {
  1957. result,
  1958. statusText,
  1959. status,
  1960. data
  1961. } = await tools_httpRequest({
  1962. url: 'https://discord.com/api/v6/users/@me',
  1963. method: 'HEAD',
  1964. headers: {
  1965. authorization: _classPrivateFieldGet(this, _auth).auth
  1966. }
  1967. });
  1968. if (result === 'Success') {
  1969. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1970. logStatus.success();
  1971. return true;
  1972. }
  1973. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1974. return false;
  1975. }
  1976. logStatus.error(`${result}:${statusText}(${status})`);
  1977. return false;
  1978. } catch (error) {
  1979. throwError(error, 'Discord.verifyAuth');
  1980. return false;
  1981. }
  1982. }
  1983. async function _updateAuth2() {
  1984. try {
  1985. const logStatus = scripts_echoLog({
  1986. text: i18n('updatingAuth', 'Discord')
  1987. });
  1988. return await new Promise(resolve => {
  1989. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1990. active: true,
  1991. insert: true,
  1992. setParent: true
  1993. });
  1994. newTab.onclose = async () => {
  1995. var _GM_getValue2;
  1996. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1997. if (auth) {
  1998. _classPrivateFieldSet(this, _auth, {
  1999. auth: auth
  2000. });
  2001. logStatus.success();
  2002. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  2003. } else {
  2004. logStatus.error('Error: Update discord auth failed!');
  2005. resolve(false);
  2006. }
  2007. };
  2008. });
  2009. } catch (error) {
  2010. throwError(error, 'Discord.updateAuth');
  2011. return false;
  2012. }
  2013. }
  2014. async function _joinServer2(inviteId) {
  2015. try {
  2016. const logStatus = scripts_echoLog({
  2017. type: 'joiningDiscordServer',
  2018. text: inviteId
  2019. });
  2020. const {
  2021. result,
  2022. statusText,
  2023. status,
  2024. data
  2025. } = await tools_httpRequest({
  2026. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2027. method: 'POST',
  2028. dataType: 'json',
  2029. headers: {
  2030. authorization: _classPrivateFieldGet(this, _auth).auth
  2031. }
  2032. });
  2033. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2034. var _data$response, _data$response$guild;
  2035. logStatus.success();
  2036. 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);
  2037. if (guild) {
  2038. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2039. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2040. }
  2041. return true;
  2042. }
  2043. logStatus.error(`${result}:${statusText}(${status})`);
  2044. return false;
  2045. } catch (error) {
  2046. throwError(error, 'Discord.joinServer');
  2047. return false;
  2048. }
  2049. }
  2050. async function _leaveServer2(inviteId) {
  2051. try {
  2052. if (this.whiteList.servers.includes(inviteId)) {
  2053. scripts_echoLog({
  2054. type: 'whiteList',
  2055. text: 'Discord.leaveServer',
  2056. id: inviteId
  2057. });
  2058. return true;
  2059. }
  2060. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2061. if (!guild) {
  2062. return false;
  2063. }
  2064. const logStatus = scripts_echoLog({
  2065. type: 'leavingDiscordServer',
  2066. text: guild
  2067. });
  2068. const {
  2069. result,
  2070. statusText,
  2071. status,
  2072. data
  2073. } = await tools_httpRequest({
  2074. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2075. method: 'DELETE',
  2076. headers: {
  2077. authorization: _classPrivateFieldGet(this, _auth).auth
  2078. }
  2079. });
  2080. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2081. logStatus.success();
  2082. return true;
  2083. }
  2084. logStatus.error(`${result}:${statusText}(${status})`);
  2085. return false;
  2086. } catch (error) {
  2087. throwError(error, 'Discord.leaveServer');
  2088. return false;
  2089. }
  2090. }
  2091. async function _getGuild2(inviteId) {
  2092. try {
  2093. const logStatus = scripts_echoLog({
  2094. type: 'gettingDiscordGuild',
  2095. text: inviteId
  2096. });
  2097. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2098. if (guild) {
  2099. logStatus.success();
  2100. return guild;
  2101. }
  2102. const {
  2103. result,
  2104. statusText,
  2105. status,
  2106. data
  2107. } = await tools_httpRequest({
  2108. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2109. responseType: 'json',
  2110. method: 'GET'
  2111. });
  2112. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2113. var _data$response2, _data$response2$guild;
  2114. 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;
  2115. if (guild) {
  2116. logStatus.success();
  2117. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2118. return guild;
  2119. }
  2120. logStatus.error(`${result}:${statusText}(${status})`);
  2121. return false;
  2122. }
  2123. logStatus.error(`${result}:${statusText}(${status})`);
  2124. return false;
  2125. } catch (error) {
  2126. throwError(error, 'Discord.getGuild');
  2127. return false;
  2128. }
  2129. }
  2130. function _setCache2(inviteId, guild) {
  2131. try {
  2132. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2133. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2134. } catch (error) {
  2135. throwError(error, 'Discord.setCache');
  2136. }
  2137. }
  2138. const social_Discord = Discord;
  2139. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2140. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2141. privateSet.add(obj);
  2142. }
  2143. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2144. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2145. privateMap.set(obj, value);
  2146. }
  2147. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2148. if (privateCollection.has(obj)) {
  2149. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2150. }
  2151. }
  2152. function Instagram_defineProperty(obj, key, value) {
  2153. if (key in obj) {
  2154. Object.defineProperty(obj, key, {
  2155. value: value,
  2156. enumerable: true,
  2157. configurable: true,
  2158. writable: true
  2159. });
  2160. } else {
  2161. obj[key] = value;
  2162. }
  2163. return obj;
  2164. }
  2165. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2166. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2167. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2168. return value;
  2169. }
  2170. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2171. if (descriptor.set) {
  2172. descriptor.set.call(receiver, value);
  2173. } else {
  2174. if (!descriptor.writable) {
  2175. throw new TypeError('attempted to set read only private field');
  2176. }
  2177. descriptor.value = value;
  2178. }
  2179. }
  2180. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2181. if (!privateSet.has(receiver)) {
  2182. throw new TypeError('attempted to get private field on non-instance');
  2183. }
  2184. return fn;
  2185. }
  2186. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2187. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2188. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2189. }
  2190. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2191. if (!privateMap.has(receiver)) {
  2192. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2193. }
  2194. return privateMap.get(receiver);
  2195. }
  2196. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2197. if (descriptor.get) {
  2198. return descriptor.get.call(receiver);
  2199. }
  2200. return descriptor.value;
  2201. }
  2202. const Instagram_defaultTasksTemplate = {
  2203. users: []
  2204. };
  2205. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2206. var Instagram_cache = new WeakMap();
  2207. var Instagram_auth = new WeakMap();
  2208. var Instagram_initialized = new WeakMap();
  2209. var _getUserInfo = new WeakSet();
  2210. var _followUser = new WeakSet();
  2211. var _unfollowUser = new WeakSet();
  2212. var Instagram_setCache = new WeakSet();
  2213. class Instagram extends social_Social {
  2214. constructor() {
  2215. var _GM_getValue;
  2216. super(...arguments);
  2217. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2218. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2219. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2220. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2221. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2222. Instagram_defineProperty(this, 'whiteList', {
  2223. ...JSON.parse(Instagram_defaultTasks),
  2224. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2225. });
  2226. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2227. writable: true,
  2228. value: GM_getValue('instagramCache') || {}
  2229. });
  2230. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2231. writable: true,
  2232. value: {}
  2233. });
  2234. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2235. writable: true,
  2236. value: false
  2237. });
  2238. }
  2239. async init() {
  2240. try {
  2241. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2242. return true;
  2243. }
  2244. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2245. if (isVerified) {
  2246. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2247. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2248. return true;
  2249. }
  2250. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2251. return false;
  2252. } catch (error) {
  2253. throwError(error, 'Instagram.init');
  2254. return false;
  2255. }
  2256. }
  2257. async toggle(_ref) {
  2258. let {
  2259. doTask = true,
  2260. userLinks = []
  2261. } = _ref;
  2262. try {
  2263. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2264. scripts_echoLog({
  2265. text: i18n('needInit')
  2266. });
  2267. return false;
  2268. }
  2269. const prom = [];
  2270. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2271. scripts_echoLog({
  2272. type: 'globalOptionsSkip',
  2273. text: 'instagram.users'
  2274. });
  2275. } else {
  2276. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2277. var _link$match;
  2278. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2279. });
  2280. if (realUsers.length > 0) {
  2281. for (const username of realUsers) {
  2282. if (doTask) {
  2283. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2284. } else {
  2285. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2286. }
  2287. await delay(1e3);
  2288. }
  2289. }
  2290. }
  2291. return await Promise.all(prom).then(() => true);
  2292. } catch (error) {
  2293. throwError(error, 'Instagram.toggleUsers');
  2294. return false;
  2295. }
  2296. }
  2297. }
  2298. async function _getUserInfo2() {
  2299. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2300. try {
  2301. const logStatus = scripts_echoLog({
  2302. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2303. text: name
  2304. });
  2305. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2306. if (userId && name !== 'instagram') {
  2307. logStatus.success();
  2308. return userId;
  2309. }
  2310. const {
  2311. result,
  2312. statusText,
  2313. status,
  2314. data
  2315. } = await tools_httpRequest({
  2316. url: `https://www.instagram.com/${name}/`,
  2317. method: 'GET'
  2318. });
  2319. if (result === 'Success') {
  2320. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2321. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2322. return false;
  2323. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2324. logStatus.error(`Error:${i18n('insBanned')}`);
  2325. return false;
  2326. }
  2327. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2328. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2329. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2330. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2331. if (name === 'instagram') {
  2332. if (csrftoken && hash) {
  2333. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2334. csrftoken: csrftoken,
  2335. hash: hash
  2336. });
  2337. return true;
  2338. }
  2339. return false;
  2340. }
  2341. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2342. if (id) {
  2343. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2344. logStatus.success();
  2345. return id;
  2346. }
  2347. logStatus.error('Error: Get ins data error!');
  2348. return false;
  2349. }
  2350. logStatus.error(`${result}:${statusText}(${status})`);
  2351. return false;
  2352. }
  2353. return false;
  2354. } catch (error) {
  2355. throwError(error, 'Instagram.getUserInfo');
  2356. return false;
  2357. }
  2358. }
  2359. async function _followUser2(name) {
  2360. try {
  2361. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2362. if (!id) {
  2363. return false;
  2364. }
  2365. const logStatus = scripts_echoLog({
  2366. type: 'followingIns',
  2367. text: name
  2368. });
  2369. const {
  2370. result,
  2371. statusText,
  2372. status,
  2373. data
  2374. } = await tools_httpRequest({
  2375. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2376. method: 'POST',
  2377. dataType: 'json',
  2378. headers: {
  2379. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2380. origin: 'https://www.instagram.com',
  2381. referer: `https://www.instagram.com/${name}/`,
  2382. 'content-type': 'application/x-www-form-urlencoded',
  2383. 'sec-fetch-site': 'same-origin',
  2384. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2385. }
  2386. });
  2387. if (result === 'Success') {
  2388. var _data$response, _data$response2;
  2389. 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') {
  2390. logStatus.success();
  2391. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2392. return true;
  2393. }
  2394. 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})`}`);
  2395. return false;
  2396. }
  2397. logStatus.error(`${result}:${statusText}(${status})`);
  2398. return false;
  2399. } catch (error) {
  2400. throwError(error, 'Instagram.followUser');
  2401. return false;
  2402. }
  2403. }
  2404. async function _unfollowUser2(name) {
  2405. try {
  2406. if (this.whiteList.users.includes(name)) {
  2407. scripts_echoLog({
  2408. type: 'whiteList',
  2409. text: 'Instagram.unfollowUser',
  2410. id: name
  2411. });
  2412. return true;
  2413. }
  2414. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2415. if (!id) {
  2416. return false;
  2417. }
  2418. const logStatus = scripts_echoLog({
  2419. type: 'unfollowingIns',
  2420. text: name
  2421. });
  2422. const {
  2423. result,
  2424. statusText,
  2425. status,
  2426. data
  2427. } = await tools_httpRequest({
  2428. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2429. method: 'POST',
  2430. dataType: 'json',
  2431. headers: {
  2432. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2433. origin: 'https://www.instagram.com',
  2434. referer: `https://www.instagram.com/${name}/`,
  2435. 'content-type': 'application/x-www-form-urlencoded',
  2436. 'sec-fetch-site': 'same-origin',
  2437. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2438. }
  2439. });
  2440. if (result === 'Success') {
  2441. var _data$response3;
  2442. 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') {
  2443. logStatus.success();
  2444. return true;
  2445. }
  2446. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2447. return false;
  2448. }
  2449. logStatus.error(`${result}:${statusText}(${status})`);
  2450. return false;
  2451. } catch (error) {
  2452. throwError(error, 'Instagram.unfollowUser');
  2453. return false;
  2454. }
  2455. }
  2456. function Instagram_setCache2(name, id) {
  2457. try {
  2458. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2459. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2460. } catch (error) {
  2461. throwError(error, 'Instagram.setCache');
  2462. }
  2463. }
  2464. const social_Instagram = Instagram;
  2465. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2466. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2467. privateSet.add(obj);
  2468. }
  2469. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2470. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2471. privateMap.set(obj, value);
  2472. }
  2473. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2474. if (privateCollection.has(obj)) {
  2475. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2476. }
  2477. }
  2478. function Reddit_defineProperty(obj, key, value) {
  2479. if (key in obj) {
  2480. Object.defineProperty(obj, key, {
  2481. value: value,
  2482. enumerable: true,
  2483. configurable: true,
  2484. writable: true
  2485. });
  2486. } else {
  2487. obj[key] = value;
  2488. }
  2489. return obj;
  2490. }
  2491. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2492. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2493. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2494. return value;
  2495. }
  2496. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2497. if (descriptor.set) {
  2498. descriptor.set.call(receiver, value);
  2499. } else {
  2500. if (!descriptor.writable) {
  2501. throw new TypeError('attempted to set read only private field');
  2502. }
  2503. descriptor.value = value;
  2504. }
  2505. }
  2506. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2507. if (!privateSet.has(receiver)) {
  2508. throw new TypeError('attempted to get private field on non-instance');
  2509. }
  2510. return fn;
  2511. }
  2512. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2513. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2514. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2515. }
  2516. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2517. if (!privateMap.has(receiver)) {
  2518. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2519. }
  2520. return privateMap.get(receiver);
  2521. }
  2522. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2523. if (descriptor.get) {
  2524. return descriptor.get.call(receiver);
  2525. }
  2526. return descriptor.value;
  2527. }
  2528. const Reddit_defaultTasksTemplate = {
  2529. reddits: []
  2530. };
  2531. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2532. var Reddit_auth = new WeakMap();
  2533. var Reddit_initialized = new WeakMap();
  2534. var _useBeta = new WeakSet();
  2535. var Reddit_updateAuth = new WeakSet();
  2536. class Reddit extends social_Social {
  2537. constructor() {
  2538. var _GM_getValue;
  2539. super(...arguments);
  2540. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2541. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2542. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2543. Reddit_defineProperty(this, 'whiteList', {
  2544. ...JSON.parse(Reddit_defaultTasks),
  2545. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2546. });
  2547. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2548. writable: true,
  2549. value: void 0
  2550. });
  2551. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2552. writable: true,
  2553. value: false
  2554. });
  2555. }
  2556. async init() {
  2557. try {
  2558. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2559. return true;
  2560. }
  2561. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2562. if (isVerified) {
  2563. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2564. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2565. return true;
  2566. }
  2567. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2568. return false;
  2569. } catch (error) {
  2570. throwError(error, 'Reddit.init');
  2571. return false;
  2572. }
  2573. }
  2574. async toggleTask(_ref) {
  2575. let {
  2576. name,
  2577. doTask = true
  2578. } = _ref;
  2579. try {
  2580. if (!doTask && this.whiteList.reddits.includes(name)) {
  2581. scripts_echoLog({
  2582. type: 'whiteList',
  2583. text: 'Reddit.undoTask',
  2584. id: name
  2585. });
  2586. return true;
  2587. }
  2588. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2589. if (/^u_/.test(name)) {
  2590. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2591. }
  2592. const logStatus = scripts_echoLog({
  2593. type: type,
  2594. text: name
  2595. });
  2596. const {
  2597. result,
  2598. statusText,
  2599. status,
  2600. data
  2601. } = await tools_httpRequest({
  2602. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2603. method: 'POST',
  2604. headers: {
  2605. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2606. 'content-type': 'application/x-www-form-urlencoded'
  2607. },
  2608. data: $.param({
  2609. action: doTask ? 'sub' : 'unsub',
  2610. sr_name: name,
  2611. api_type: 'json'
  2612. })
  2613. });
  2614. if (result === 'Success') {
  2615. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2616. logStatus.success();
  2617. if (doTask) {
  2618. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2619. }
  2620. return true;
  2621. }
  2622. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2623. return false;
  2624. }
  2625. logStatus.error(`${result}:${statusText}(${status})`);
  2626. return false;
  2627. } catch (error) {
  2628. throwError(error, 'Reddit.toggleTask');
  2629. return false;
  2630. }
  2631. }
  2632. async toggle(_ref2) {
  2633. let {
  2634. doTask = true,
  2635. redditLinks = []
  2636. } = _ref2;
  2637. try {
  2638. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2639. scripts_echoLog({
  2640. text: i18n('needInit')
  2641. });
  2642. return false;
  2643. }
  2644. const prom = [];
  2645. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2646. scripts_echoLog({
  2647. type: 'globalOptionsSkip',
  2648. text: 'reddit.reddits'
  2649. });
  2650. } else {
  2651. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2652. var _link$match, _link$match2;
  2653. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2654. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2655. if (userName) {
  2656. return name || userName;
  2657. }
  2658. return name;
  2659. });
  2660. if (realReddits.length > 0) {
  2661. for (const name of realReddits) {
  2662. prom.push(this.toggleTask({
  2663. name: name,
  2664. doTask: doTask
  2665. }));
  2666. await delay(1e3);
  2667. }
  2668. }
  2669. }
  2670. return await Promise.all(prom).then(() => true);
  2671. } catch (error) {
  2672. throwError(error, 'Reddit.toggle');
  2673. return false;
  2674. }
  2675. }
  2676. }
  2677. async function _useBeta2() {
  2678. try {
  2679. const logStatus = scripts_echoLog({
  2680. text: i18n('changingRedditVersion')
  2681. });
  2682. GM_setValue('redditAuth', null);
  2683. return await new Promise(resolve => {
  2684. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2685. active: true,
  2686. insert: true,
  2687. setParent: true
  2688. });
  2689. newTab.onclose = async () => {
  2690. logStatus.success();
  2691. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2692. };
  2693. });
  2694. } catch (error) {
  2695. throwError(error, 'Reddit.useBeta');
  2696. return false;
  2697. }
  2698. }
  2699. async function Reddit_updateAuth2() {
  2700. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2701. try {
  2702. const logStatus = scripts_echoLog({
  2703. text: i18n('updatingAuth', 'Reddit')
  2704. });
  2705. const {
  2706. result,
  2707. statusText,
  2708. status,
  2709. data
  2710. } = await tools_httpRequest({
  2711. url: 'https://www.reddit.com/',
  2712. method: 'GET',
  2713. nochche: true,
  2714. headers: {
  2715. 'Cache-Control': 'no-cache'
  2716. }
  2717. });
  2718. if (result === 'Success') {
  2719. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2720. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2721. return false;
  2722. }
  2723. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2724. var _data$responseText$ma;
  2725. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2726. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2727. }
  2728. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2729. if (accessToken) {
  2730. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2731. token: accessToken
  2732. });
  2733. logStatus.success();
  2734. return true;
  2735. }
  2736. logStatus.error('Error: Parameter "accessToken" not found!');
  2737. return false;
  2738. }
  2739. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2740. return false;
  2741. }
  2742. logStatus.error(`${result}:${statusText}(${status})`);
  2743. return false;
  2744. } catch (error) {
  2745. throwError(error, 'Reddit.updateAuth');
  2746. return false;
  2747. }
  2748. }
  2749. const social_Reddit = Reddit;
  2750. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2751. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2752. privateSet.add(obj);
  2753. }
  2754. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2755. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2756. privateMap.set(obj, value);
  2757. }
  2758. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2759. if (privateCollection.has(obj)) {
  2760. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2761. }
  2762. }
  2763. function Twitch_defineProperty(obj, key, value) {
  2764. if (key in obj) {
  2765. Object.defineProperty(obj, key, {
  2766. value: value,
  2767. enumerable: true,
  2768. configurable: true,
  2769. writable: true
  2770. });
  2771. } else {
  2772. obj[key] = value;
  2773. }
  2774. return obj;
  2775. }
  2776. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2777. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2778. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2779. return value;
  2780. }
  2781. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2782. if (descriptor.set) {
  2783. descriptor.set.call(receiver, value);
  2784. } else {
  2785. if (!descriptor.writable) {
  2786. throw new TypeError('attempted to set read only private field');
  2787. }
  2788. descriptor.value = value;
  2789. }
  2790. }
  2791. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2792. if (!privateSet.has(receiver)) {
  2793. throw new TypeError('attempted to get private field on non-instance');
  2794. }
  2795. return fn;
  2796. }
  2797. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2798. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2799. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2800. }
  2801. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2802. if (!privateMap.has(receiver)) {
  2803. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2804. }
  2805. return privateMap.get(receiver);
  2806. }
  2807. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2808. if (descriptor.get) {
  2809. return descriptor.get.call(receiver);
  2810. }
  2811. return descriptor.value;
  2812. }
  2813. const Twitch_defaultTasksTemplate = {
  2814. channels: []
  2815. };
  2816. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2817. var Twitch_auth = new WeakMap();
  2818. var Twitch_cache = new WeakMap();
  2819. var Twitch_initialized = new WeakMap();
  2820. var Twitch_verifyAuth = new WeakSet();
  2821. var Twitch_updateAuth = new WeakSet();
  2822. var _toggleChannel = new WeakSet();
  2823. var _getChannelId = new WeakSet();
  2824. var Twitch_setCache = new WeakSet();
  2825. class Twitch extends social_Social {
  2826. constructor() {
  2827. var _GM_getValue;
  2828. super(...arguments);
  2829. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2830. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2831. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2832. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2833. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2834. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2835. Twitch_defineProperty(this, 'whiteList', {
  2836. ...JSON.parse(Twitch_defaultTasks),
  2837. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2838. });
  2839. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2840. writable: true,
  2841. value: GM_getValue('twitchAuth') || {}
  2842. });
  2843. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2844. writable: true,
  2845. value: GM_getValue('twitchCache') || {}
  2846. });
  2847. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2848. writable: true,
  2849. value: false
  2850. });
  2851. }
  2852. async init() {
  2853. try {
  2854. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2855. return true;
  2856. }
  2857. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2858. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2859. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2860. return true;
  2861. }
  2862. return false;
  2863. }
  2864. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2865. if (isVerified) {
  2866. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2867. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2868. return true;
  2869. }
  2870. GM_setValue('twitchAuth', null);
  2871. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2872. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2873. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2874. return true;
  2875. }
  2876. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2877. return false;
  2878. } catch (error) {
  2879. throwError(error, 'Twitch.init');
  2880. return false;
  2881. }
  2882. }
  2883. async toggle(_ref) {
  2884. let {
  2885. doTask = true,
  2886. channelLinks = []
  2887. } = _ref;
  2888. try {
  2889. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2890. scripts_echoLog({
  2891. text: i18n('needInit')
  2892. });
  2893. return false;
  2894. }
  2895. const prom = [];
  2896. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2897. scripts_echoLog({
  2898. type: 'globalOptionsSkip',
  2899. text: 'twitch.channels'
  2900. });
  2901. } else {
  2902. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2903. var _link$match;
  2904. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2905. });
  2906. if (realChannels.length > 0) {
  2907. for (const channel of realChannels) {
  2908. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2909. name: channel,
  2910. doTask: doTask
  2911. }));
  2912. await delay(1e3);
  2913. }
  2914. }
  2915. }
  2916. return Promise.all(prom).then(() => true);
  2917. } catch (error) {
  2918. throwError(error, 'Twitch.toggle');
  2919. return false;
  2920. }
  2921. }
  2922. }
  2923. async function Twitch_verifyAuth2() {
  2924. try {
  2925. const logStatus = scripts_echoLog({
  2926. text: i18n('verifyingAuth', 'Twitch')
  2927. });
  2928. const {
  2929. result,
  2930. statusText,
  2931. status,
  2932. data
  2933. } = await tools_httpRequest({
  2934. url: 'https://gql.twitch.tv/gql',
  2935. method: 'POST',
  2936. dataType: 'json',
  2937. headers: {
  2938. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2939. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2940. },
  2941. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2942. });
  2943. if (result === 'Success') {
  2944. var _data$response, _data$response$, _data$response$$data;
  2945. 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) {
  2946. logStatus.success();
  2947. return true;
  2948. }
  2949. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2950. return false;
  2951. }
  2952. logStatus.error(`${result}:${statusText}(${status})`);
  2953. return false;
  2954. } catch (error) {
  2955. throwError(error, 'Twitch.verifyAuth');
  2956. return false;
  2957. }
  2958. }
  2959. async function Twitch_updateAuth2() {
  2960. try {
  2961. const logStatus = scripts_echoLog({
  2962. text: i18n('updatingAuth', 'Twitch')
  2963. });
  2964. return await new Promise(resolve => {
  2965. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2966. active: true,
  2967. insert: true,
  2968. setParent: true
  2969. });
  2970. newTab.onclose = async () => {
  2971. const auth = GM_getValue('twitchAuth');
  2972. if (auth) {
  2973. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2974. logStatus.success();
  2975. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2976. } else {
  2977. logStatus.error('Error: Update twitch auth failed!');
  2978. resolve(false);
  2979. }
  2980. };
  2981. });
  2982. } catch (error) {
  2983. throwError(error, 'Twitch.updateAuth');
  2984. return false;
  2985. }
  2986. }
  2987. async function _toggleChannel2(_ref2) {
  2988. let {
  2989. name,
  2990. doTask = true
  2991. } = _ref2;
  2992. try {
  2993. if (!doTask && this.whiteList.channels.includes(name)) {
  2994. scripts_echoLog({
  2995. type: 'whiteList',
  2996. text: 'Twitch.unfollowChannel',
  2997. id: name
  2998. });
  2999. return true;
  3000. }
  3001. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  3002. if (!channelId) {
  3003. return false;
  3004. }
  3005. const logStatus = scripts_echoLog({
  3006. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  3007. text: name
  3008. });
  3009. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  3010. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  3011. const {
  3012. result,
  3013. statusText,
  3014. status,
  3015. data
  3016. } = await tools_httpRequest({
  3017. url: 'https://gql.twitch.tv/gql',
  3018. method: 'POST',
  3019. dataType: 'json',
  3020. headers: {
  3021. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  3022. },
  3023. data: doTask ? followData : unfollowData
  3024. });
  3025. if (result === 'Success') {
  3026. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3027. logStatus.success();
  3028. if (doTask) {
  3029. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3030. }
  3031. return true;
  3032. }
  3033. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3034. return false;
  3035. }
  3036. logStatus.error(`${result}:${statusText}(${status})`);
  3037. return false;
  3038. } catch (error) {
  3039. throwError(error, 'Twitch.toggleChannel');
  3040. return false;
  3041. }
  3042. }
  3043. async function _getChannelId2(name) {
  3044. try {
  3045. const logStatus = scripts_echoLog({
  3046. type: 'gettingTwitchChannelId',
  3047. text: name
  3048. });
  3049. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3050. if (channelId) {
  3051. logStatus.success();
  3052. return channelId;
  3053. }
  3054. const {
  3055. result,
  3056. statusText,
  3057. status,
  3058. data
  3059. } = await tools_httpRequest({
  3060. url: 'https://gql.twitch.tv/gql',
  3061. method: 'POST',
  3062. headers: {
  3063. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3064. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3065. },
  3066. responseType: 'json',
  3067. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3068. });
  3069. if (result === 'Success') {
  3070. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3071. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3072. 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);
  3073. if (channelId) {
  3074. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3075. logStatus.success();
  3076. return channelId;
  3077. }
  3078. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3079. return false;
  3080. }
  3081. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3082. return false;
  3083. }
  3084. logStatus.error(`${result}:${statusText}(${status})`);
  3085. return false;
  3086. } catch (error) {
  3087. throwError(error, 'Twitch.getChannelId');
  3088. return false;
  3089. }
  3090. }
  3091. function Twitch_setCache2(name, id) {
  3092. try {
  3093. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3094. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3095. } catch (error) {
  3096. throwError(error, 'Twitch.setCache');
  3097. }
  3098. }
  3099. const social_Twitch = Twitch;
  3100. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3101. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3102. privateSet.add(obj);
  3103. }
  3104. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3105. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3106. privateMap.set(obj, value);
  3107. }
  3108. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3109. if (privateCollection.has(obj)) {
  3110. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3111. }
  3112. }
  3113. function Twitter_defineProperty(obj, key, value) {
  3114. if (key in obj) {
  3115. Object.defineProperty(obj, key, {
  3116. value: value,
  3117. enumerable: true,
  3118. configurable: true,
  3119. writable: true
  3120. });
  3121. } else {
  3122. obj[key] = value;
  3123. }
  3124. return obj;
  3125. }
  3126. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3127. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3128. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3129. return value;
  3130. }
  3131. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3132. if (descriptor.set) {
  3133. descriptor.set.call(receiver, value);
  3134. } else {
  3135. if (!descriptor.writable) {
  3136. throw new TypeError('attempted to set read only private field');
  3137. }
  3138. descriptor.value = value;
  3139. }
  3140. }
  3141. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3142. if (!privateSet.has(receiver)) {
  3143. throw new TypeError('attempted to get private field on non-instance');
  3144. }
  3145. return fn;
  3146. }
  3147. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3148. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3149. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3150. }
  3151. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3152. if (!privateMap.has(receiver)) {
  3153. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3154. }
  3155. return privateMap.get(receiver);
  3156. }
  3157. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3158. if (descriptor.get) {
  3159. return descriptor.get.call(receiver);
  3160. }
  3161. return descriptor.value;
  3162. }
  3163. const Twitter_defaultTasksTemplate = {
  3164. users: [],
  3165. retweets: [],
  3166. likes: []
  3167. };
  3168. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3169. var _verifyId = new WeakMap();
  3170. var Twitter_auth = new WeakMap();
  3171. var Twitter_cache = new WeakMap();
  3172. var Twitter_initialized = new WeakMap();
  3173. var Twitter_verifyAuth = new WeakSet();
  3174. var Twitter_updateAuth = new WeakSet();
  3175. var _toggleUser = new WeakSet();
  3176. var _toggleRetweet = new WeakSet();
  3177. var Twitter_setCache = new WeakSet();
  3178. class Twitter extends social_Social {
  3179. constructor() {
  3180. var _GM_getValue;
  3181. super(...arguments);
  3182. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3183. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3184. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3185. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3186. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3187. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3188. Twitter_defineProperty(this, 'whiteList', {
  3189. ...JSON.parse(Twitter_defaultTasks),
  3190. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3191. });
  3192. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3193. writable: true,
  3194. value: globalOptions.other.twitterVerifyId
  3195. });
  3196. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3197. writable: true,
  3198. value: GM_getValue('twitterAuth') || {}
  3199. });
  3200. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3201. writable: true,
  3202. value: GM_getValue('twitterCache') || {}
  3203. });
  3204. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3205. writable: true,
  3206. value: false
  3207. });
  3208. }
  3209. async init() {
  3210. try {
  3211. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3212. return true;
  3213. }
  3214. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3215. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3216. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3217. return true;
  3218. }
  3219. return false;
  3220. }
  3221. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3222. if (isVerified) {
  3223. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3224. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3225. return true;
  3226. }
  3227. GM_setValue('twitterAuth', null);
  3228. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3229. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3230. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3231. return true;
  3232. }
  3233. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3234. return false;
  3235. } catch (error) {
  3236. throwError(error, 'Twitter.init');
  3237. return false;
  3238. }
  3239. }
  3240. async userName2id(name) {
  3241. try {
  3242. const logStatus = scripts_echoLog({
  3243. type: 'gettingTwitterUserId',
  3244. text: name
  3245. });
  3246. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3247. if (userId) {
  3248. logStatus.success();
  3249. return userId;
  3250. }
  3251. const {
  3252. result,
  3253. statusText,
  3254. status,
  3255. data
  3256. } = await tools_httpRequest({
  3257. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3258. method: 'GET',
  3259. headers: {
  3260. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3261. 'content-type': 'application/json'
  3262. },
  3263. responseType: 'json',
  3264. anonymous: true
  3265. });
  3266. if (result === 'Success') {
  3267. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3268. var _response, _response$data, _response$data$user;
  3269. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3270. if (!response) {
  3271. try {
  3272. response = JSON.parse(data.responseText);
  3273. } catch (error) {
  3274. response = null;
  3275. }
  3276. }
  3277. 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);
  3278. if (userId) {
  3279. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3280. logStatus.success();
  3281. return userId;
  3282. }
  3283. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3284. return false;
  3285. }
  3286. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3287. return false;
  3288. }
  3289. logStatus.error(`${result}:${statusText}(${status})`);
  3290. return false;
  3291. } catch (error) {
  3292. throwError(error, 'Twitter.getUserId');
  3293. return false;
  3294. }
  3295. }
  3296. async toggle(_ref) {
  3297. let {
  3298. doTask = true,
  3299. userLinks = [],
  3300. retweetLinks = []
  3301. } = _ref;
  3302. try {
  3303. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3304. scripts_echoLog({
  3305. text: i18n('needInit')
  3306. });
  3307. return false;
  3308. }
  3309. const prom = [];
  3310. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3311. scripts_echoLog({
  3312. type: 'globalOptionsSkip',
  3313. text: 'twitter.users'
  3314. });
  3315. } else {
  3316. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3317. var _link$match;
  3318. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3319. });
  3320. if (realUsers.length > 0) {
  3321. for (const user of realUsers) {
  3322. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3323. name: user,
  3324. doTask: doTask
  3325. }));
  3326. await delay(1e3);
  3327. }
  3328. }
  3329. }
  3330. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3331. scripts_echoLog({
  3332. type: 'globalOptionsSkip',
  3333. text: 'twitter.retweets'
  3334. });
  3335. } else {
  3336. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3337. var _link$match2;
  3338. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3339. });
  3340. if (realRetweets.length > 0) {
  3341. for (const retweet of realRetweets) {
  3342. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3343. retweetId: retweet,
  3344. doTask: doTask
  3345. }));
  3346. await delay(1e3);
  3347. }
  3348. }
  3349. }
  3350. return Promise.all(prom).then(() => true);
  3351. } catch (error) {
  3352. throwError(error, 'Twitter.toggle');
  3353. return false;
  3354. }
  3355. }
  3356. }
  3357. async function Twitter_verifyAuth2() {
  3358. try {
  3359. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3360. name: 'verify',
  3361. doTask: true,
  3362. verify: true
  3363. });
  3364. } catch (error) {
  3365. throwError(error, 'Twitter.verifyAuth');
  3366. return false;
  3367. }
  3368. }
  3369. async function Twitter_updateAuth2() {
  3370. try {
  3371. const logStatus = scripts_echoLog({
  3372. text: i18n('updatingAuth', 'Twitter')
  3373. });
  3374. return await new Promise(resolve => {
  3375. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3376. active: true,
  3377. insert: true,
  3378. setParent: true
  3379. });
  3380. newTab.onclose = async () => {
  3381. const auth = GM_getValue('twitterAuth');
  3382. if (auth) {
  3383. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3384. logStatus.success();
  3385. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3386. } else {
  3387. logStatus.error('Error: Update twitter auth failed!');
  3388. resolve(false);
  3389. }
  3390. };
  3391. });
  3392. } catch (error) {
  3393. throwError(error, 'Twitter.updateToken');
  3394. return false;
  3395. }
  3396. }
  3397. async function _toggleUser2(_ref2) {
  3398. let {
  3399. name,
  3400. doTask = true,
  3401. verify = false
  3402. } = _ref2;
  3403. try {
  3404. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3405. scripts_echoLog({
  3406. type: 'whiteList',
  3407. text: 'Twitter.unfollowUser',
  3408. id: name
  3409. });
  3410. return true;
  3411. }
  3412. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3413. if (!userId) {
  3414. return false;
  3415. }
  3416. const logStatus = verify ? scripts_echoLog({
  3417. text: i18n('verifyingAuth', 'Twitter')
  3418. }) : scripts_echoLog({
  3419. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3420. text: name
  3421. });
  3422. const {
  3423. result,
  3424. statusText,
  3425. status,
  3426. data
  3427. } = await tools_httpRequest({
  3428. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3429. method: 'POST',
  3430. headers: {
  3431. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3432. 'Content-Type': 'application/x-www-form-urlencoded',
  3433. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3434. },
  3435. responseType: 'json',
  3436. data: $.param({
  3437. include_profile_interstitial_type: 1,
  3438. include_blocking: 1,
  3439. include_blocked_by: 1,
  3440. include_followed_by: 1,
  3441. include_want_retweets: 1,
  3442. include_mute_edge: 1,
  3443. include_can_dm: 1,
  3444. include_can_media_tag: 1,
  3445. skip_status: 1,
  3446. id: userId
  3447. })
  3448. });
  3449. if (result === 'Success') {
  3450. var _data$response, _data$response$errors, _data$response$errors2;
  3451. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3452. logStatus.success();
  3453. if (doTask && !verify) {
  3454. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3455. }
  3456. return true;
  3457. }
  3458. 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) {
  3459. logStatus.success();
  3460. return true;
  3461. }
  3462. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3463. return false;
  3464. }
  3465. logStatus.error(`${result}:${statusText}(${status})`);
  3466. return false;
  3467. } catch (error) {
  3468. throwError(error, 'Twitter.toggleUser');
  3469. return false;
  3470. }
  3471. }
  3472. async function _toggleRetweet2(_ref3) {
  3473. let {
  3474. retweetId,
  3475. doTask = true
  3476. } = _ref3;
  3477. try {
  3478. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3479. scripts_echoLog({
  3480. type: 'whiteList',
  3481. text: 'Twitter.unretweet',
  3482. id: retweetId
  3483. });
  3484. return true;
  3485. }
  3486. const logStatus = scripts_echoLog({
  3487. type: `${doTask ? '' : 'un'}retweetting`,
  3488. text: retweetId
  3489. });
  3490. const {
  3491. result,
  3492. statusText,
  3493. status,
  3494. data
  3495. } = await tools_httpRequest({
  3496. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3497. method: 'POST',
  3498. headers: {
  3499. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3500. 'Content-Type': 'application/x-www-form-urlencoded',
  3501. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3502. },
  3503. data: $.param({
  3504. tweet_mode: 'extended',
  3505. id: retweetId
  3506. }),
  3507. responseType: 'json'
  3508. });
  3509. if (result === 'Success') {
  3510. var _data$response2, _data$response2$error, _data$response2$error2;
  3511. 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) {
  3512. logStatus.success();
  3513. if (doTask) {
  3514. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3515. }
  3516. return true;
  3517. }
  3518. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3519. return false;
  3520. }
  3521. logStatus.error(`${result}:${statusText}(${status})`);
  3522. return false;
  3523. } catch (error) {
  3524. throwError(error, 'Twitter.toggleRetweet');
  3525. return false;
  3526. }
  3527. }
  3528. function Twitter_setCache2(name, id) {
  3529. try {
  3530. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3531. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3532. } catch (error) {
  3533. throwError(error, 'Twitter.setCache');
  3534. }
  3535. }
  3536. const social_Twitter = Twitter;
  3537. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3538. Vk_checkPrivateRedeclaration(obj, privateSet);
  3539. privateSet.add(obj);
  3540. }
  3541. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3542. Vk_checkPrivateRedeclaration(obj, privateMap);
  3543. privateMap.set(obj, value);
  3544. }
  3545. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3546. if (privateCollection.has(obj)) {
  3547. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3548. }
  3549. }
  3550. function Vk_defineProperty(obj, key, value) {
  3551. if (key in obj) {
  3552. Object.defineProperty(obj, key, {
  3553. value: value,
  3554. enumerable: true,
  3555. configurable: true,
  3556. writable: true
  3557. });
  3558. } else {
  3559. obj[key] = value;
  3560. }
  3561. return obj;
  3562. }
  3563. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3564. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3565. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3566. return value;
  3567. }
  3568. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3569. if (descriptor.set) {
  3570. descriptor.set.call(receiver, value);
  3571. } else {
  3572. if (!descriptor.writable) {
  3573. throw new TypeError('attempted to set read only private field');
  3574. }
  3575. descriptor.value = value;
  3576. }
  3577. }
  3578. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3579. if (!privateSet.has(receiver)) {
  3580. throw new TypeError('attempted to get private field on non-instance');
  3581. }
  3582. return fn;
  3583. }
  3584. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3585. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3586. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3587. }
  3588. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3589. if (!privateMap.has(receiver)) {
  3590. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3591. }
  3592. return privateMap.get(receiver);
  3593. }
  3594. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3595. if (descriptor.get) {
  3596. return descriptor.get.call(receiver);
  3597. }
  3598. return descriptor.value;
  3599. }
  3600. const Vk_defaultTasksTemplate = {
  3601. names: []
  3602. };
  3603. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3604. var _username = new WeakMap();
  3605. var Vk_cache = new WeakMap();
  3606. var Vk_initialized = new WeakMap();
  3607. var Vk_verifyAuth = new WeakSet();
  3608. var _toggleGroup = new WeakSet();
  3609. var _togglePublic = new WeakSet();
  3610. var _sendWall = new WeakSet();
  3611. var _deleteWall = new WeakSet();
  3612. var _getId = new WeakSet();
  3613. var _toggleVk = new WeakSet();
  3614. var Vk_setCache = new WeakSet();
  3615. class Vk extends social_Social {
  3616. constructor() {
  3617. var _GM_getValue;
  3618. super(...arguments);
  3619. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3620. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3621. Vk_classPrivateMethodInitSpec(this, _getId);
  3622. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3623. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3624. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3625. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3626. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3627. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3628. Vk_defineProperty(this, 'whiteList', {
  3629. ...JSON.parse(Vk_defaultTasks),
  3630. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3631. });
  3632. Vk_classPrivateFieldInitSpec(this, _username, {
  3633. writable: true,
  3634. value: ''
  3635. });
  3636. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3637. writable: true,
  3638. value: GM_getValue('vkCache') || {}
  3639. });
  3640. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3641. writable: true,
  3642. value: false
  3643. });
  3644. }
  3645. async init() {
  3646. try {
  3647. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3648. return true;
  3649. }
  3650. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3651. if (isVerified) {
  3652. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3653. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3654. return true;
  3655. }
  3656. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3657. return false;
  3658. } catch (error) {
  3659. throwError(error, 'Vk.init');
  3660. return false;
  3661. }
  3662. }
  3663. async toggle(_ref) {
  3664. let {
  3665. doTask = true,
  3666. nameLinks = []
  3667. } = _ref;
  3668. try {
  3669. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3670. scripts_echoLog({
  3671. text: i18n('needInit')
  3672. });
  3673. return false;
  3674. }
  3675. const prom = [];
  3676. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3677. scripts_echoLog({
  3678. type: 'globalOptionsSkip',
  3679. text: 'vk.names'
  3680. });
  3681. } else {
  3682. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3683. var _link$match;
  3684. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3685. });
  3686. if (realNames.length > 0) {
  3687. for (const name of realNames) {
  3688. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3689. name: name,
  3690. doTask: doTask
  3691. }));
  3692. await delay(1e3);
  3693. }
  3694. }
  3695. }
  3696. return Promise.all(prom).then(() => true);
  3697. } catch (error) {
  3698. throwError(error, 'Vk.toggle');
  3699. return false;
  3700. }
  3701. }
  3702. }
  3703. async function Vk_verifyAuth2() {
  3704. try {
  3705. const logStatus = scripts_echoLog({
  3706. text: i18n('verifyAuth', 'Vk')
  3707. });
  3708. const {
  3709. result,
  3710. statusText,
  3711. status,
  3712. data
  3713. } = await tools_httpRequest({
  3714. url: 'https://vk.com/im',
  3715. method: 'GET'
  3716. });
  3717. if (result === 'Success') {
  3718. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3719. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3720. return false;
  3721. }
  3722. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3723. var _data$responseText$ma;
  3724. 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]) || '');
  3725. logStatus.success();
  3726. return true;
  3727. }
  3728. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3729. return false;
  3730. }
  3731. logStatus.error(`${result}:${statusText}(${status})`);
  3732. return false;
  3733. } catch (error) {
  3734. throwError(error, 'Vk.verifyAuth');
  3735. return false;
  3736. }
  3737. }
  3738. async function _toggleGroup2(name, dataParam) {
  3739. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3740. try {
  3741. const logStatus = scripts_echoLog({
  3742. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3743. text: name
  3744. });
  3745. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3746. logStatus.success();
  3747. return true;
  3748. }
  3749. const reqData = {
  3750. act: doTask ? 'enter' : 'leave',
  3751. al: 1,
  3752. gid: dataParam.groupId,
  3753. hash: dataParam.groupHash
  3754. };
  3755. if (doTask) {
  3756. reqData.context = '_';
  3757. }
  3758. const {
  3759. result,
  3760. statusText,
  3761. status,
  3762. data
  3763. } = await tools_httpRequest({
  3764. url: 'https://vk.com/al_groups.php',
  3765. method: 'POST',
  3766. headers: {
  3767. origin: 'https://vk.com',
  3768. referer: `https://vk.com/${name}`,
  3769. 'content-type': 'application/x-www-form-urlencoded'
  3770. },
  3771. data: $.param(reqData)
  3772. });
  3773. if (result === 'Success') {
  3774. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3775. logStatus.success();
  3776. if (doTask) {
  3777. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3778. }
  3779. return true;
  3780. }
  3781. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3782. return false;
  3783. }
  3784. logStatus.error(`${result}:${statusText}(${status})`);
  3785. return false;
  3786. } catch (error) {
  3787. throwError(error, 'Vk.toggleGroup');
  3788. return false;
  3789. }
  3790. }
  3791. async function _togglePublic2(name, dataParam) {
  3792. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3793. try {
  3794. const logStatus = scripts_echoLog({
  3795. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3796. text: name
  3797. });
  3798. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3799. logStatus.success();
  3800. return true;
  3801. }
  3802. const {
  3803. result,
  3804. statusText,
  3805. status,
  3806. data
  3807. } = await tools_httpRequest({
  3808. url: 'https://vk.com/al_public.php',
  3809. method: 'POST',
  3810. headers: {
  3811. origin: 'https://vk.com',
  3812. referer: `https://vk.com/${name}`,
  3813. 'content-type': 'application/x-www-form-urlencoded'
  3814. },
  3815. data: $.param({
  3816. act: doTask ? 'a_enter' : 'a_leave',
  3817. al: 1,
  3818. pid: dataParam.publicPid,
  3819. hash: dataParam.publicHash
  3820. })
  3821. });
  3822. if (result === 'Success') {
  3823. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3824. logStatus.success();
  3825. if (doTask) {
  3826. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3827. }
  3828. return true;
  3829. }
  3830. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3831. return false;
  3832. }
  3833. logStatus.error(`${result}:${statusText}(${status})`);
  3834. return false;
  3835. } catch (error) {
  3836. throwError(error, 'Vk.togglePublic');
  3837. return false;
  3838. }
  3839. }
  3840. async function _sendWall2(name) {
  3841. try {
  3842. const logStatus = scripts_echoLog({
  3843. type: 'sendingVkWall',
  3844. text: name
  3845. });
  3846. const {
  3847. result,
  3848. statusText,
  3849. status,
  3850. data
  3851. } = await tools_httpRequest({
  3852. url: 'https://vk.com/like.php',
  3853. method: 'POST',
  3854. headers: {
  3855. origin: 'https://vk.com',
  3856. referer: `https://vk.com/${name}`,
  3857. 'content-type': 'application/x-www-form-urlencoded'
  3858. },
  3859. data: $.param({
  3860. act: 'publish_box',
  3861. al: 1,
  3862. object: name
  3863. })
  3864. });
  3865. if (result === 'Success') {
  3866. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3867. var _data$responseText$ma2;
  3868. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3869. if (hash) {
  3870. const {
  3871. result: resultR,
  3872. statusText: statusTextR,
  3873. status: statusR,
  3874. data: dataR
  3875. } = await tools_httpRequest({
  3876. url: 'https://vk.com/like.php',
  3877. method: 'POST',
  3878. headers: {
  3879. origin: 'https://vk.com',
  3880. referer: `https://vk.com/${name}`,
  3881. 'content-type': 'application/x-www-form-urlencoded'
  3882. },
  3883. data: $.param({
  3884. Message: '',
  3885. act: 'a_do_publish',
  3886. al: 1,
  3887. close_comments: 0,
  3888. friends_only: 0,
  3889. from: 'box',
  3890. hash: hash,
  3891. list: '',
  3892. mark_as_ads: 0,
  3893. mute_notifications: 0,
  3894. object: name,
  3895. ret_data: 1,
  3896. to: 0
  3897. })
  3898. });
  3899. if (resultR === 'Success') {
  3900. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3901. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3902. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3903. 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) {
  3904. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3905. logStatus.success();
  3906. 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);
  3907. 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);
  3908. if (postId && ownerId) {
  3909. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3910. }
  3911. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3912. return true;
  3913. }
  3914. }
  3915. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3916. return false;
  3917. }
  3918. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3919. return false;
  3920. }
  3921. logStatus.error('Error: Get "hash" failed');
  3922. return false;
  3923. }
  3924. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3925. return false;
  3926. }
  3927. logStatus.error(`${result}:${statusText}(${status})`);
  3928. return false;
  3929. } catch (error) {
  3930. throwError(error, 'Vk.sendWall');
  3931. return false;
  3932. }
  3933. }
  3934. async function _deleteWall2(name, dataParams) {
  3935. try {
  3936. const logStatus = scripts_echoLog({
  3937. type: 'deletingVkWall',
  3938. text: name
  3939. });
  3940. const {
  3941. result,
  3942. statusText,
  3943. status,
  3944. data
  3945. } = await tools_httpRequest({
  3946. url: 'https://vk.com/al_wall.php?act=delete',
  3947. method: 'POST',
  3948. headers: {
  3949. origin: 'https://vk.com',
  3950. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3951. 'content-type': 'application/x-www-form-urlencoded'
  3952. },
  3953. data: $.param({
  3954. act: 'delete',
  3955. al: 1,
  3956. confirm: 0,
  3957. from: 'wkview',
  3958. hash: dataParams.wallHash,
  3959. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3960. })
  3961. });
  3962. if (result === 'Success') {
  3963. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3964. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3965. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3966. 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]) {
  3967. logStatus.success();
  3968. return true;
  3969. }
  3970. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3971. return false;
  3972. }
  3973. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3974. return false;
  3975. }
  3976. logStatus.error(`${result}:${statusText}(${status})`);
  3977. return false;
  3978. } catch (error) {
  3979. throwError(error, 'Vk.deleteWall');
  3980. return false;
  3981. }
  3982. }
  3983. async function _getId2(name, doTask) {
  3984. try {
  3985. let url = `https://vk.com/${name}`;
  3986. if (/^wall-/.test(name)) {
  3987. if (doTask) {
  3988. return {
  3989. type: 'sendWall'
  3990. };
  3991. }
  3992. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3993. return {
  3994. type: 'unSupport'
  3995. };
  3996. }
  3997. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3998. }
  3999. const logStatus = scripts_echoLog({
  4000. type: 'gettingVkId',
  4001. text: name
  4002. });
  4003. const {
  4004. result,
  4005. statusText,
  4006. status,
  4007. data
  4008. } = await tools_httpRequest({
  4009. url: url,
  4010. method: 'GET'
  4011. });
  4012. if (result === 'Success') {
  4013. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4014. var _data$responseText$ma3, _data$responseText$ma4;
  4015. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  4016. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4017. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4018. const publicJoined = !data.responseText.includes('Public.subscribe');
  4019. if (groupAct && groupId && groupHash) {
  4020. logStatus.success();
  4021. return {
  4022. groupAct: groupAct,
  4023. groupId: groupId,
  4024. groupHash: groupHash,
  4025. type: 'group'
  4026. };
  4027. } else if (publicHash && publicPid) {
  4028. logStatus.success();
  4029. return {
  4030. publicHash: publicHash,
  4031. publicPid: publicPid,
  4032. publicJoined: publicJoined,
  4033. type: 'public'
  4034. };
  4035. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4036. var _data$responseText$ma5;
  4037. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4038. if (wallHash) {
  4039. logStatus.success();
  4040. return {
  4041. type: 'deleteWall',
  4042. wallHash: wallHash
  4043. };
  4044. }
  4045. } else if (name.includes('wall') && doTask) {
  4046. logStatus.success();
  4047. return {
  4048. type: 'sendWall'
  4049. };
  4050. }
  4051. logStatus.error('Error: Parameters not found!');
  4052. return false;
  4053. }
  4054. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4055. return false;
  4056. }
  4057. logStatus.error(`${result}:${statusText}(${status})`);
  4058. return false;
  4059. } catch (error) {
  4060. throwError(error, 'Vk.getId');
  4061. return false;
  4062. }
  4063. }
  4064. async function _toggleVk2(_ref2) {
  4065. let {
  4066. name,
  4067. doTask = true
  4068. } = _ref2;
  4069. try {
  4070. if (!doTask && this.whiteList.names.includes(name)) {
  4071. scripts_echoLog({
  4072. type: 'whiteList',
  4073. text: 'Vk.undoTask',
  4074. id: name
  4075. });
  4076. return true;
  4077. }
  4078. const formatName = name.replace(/\/$/, '');
  4079. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4080. if (!data) {
  4081. return false;
  4082. }
  4083. switch (data.type) {
  4084. case 'group':
  4085. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4086.  
  4087. case 'public':
  4088. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4089.  
  4090. case 'sendWall':
  4091. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4092.  
  4093. case 'deleteWall':
  4094. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4095.  
  4096. default:
  4097. return false;
  4098. }
  4099. } catch (error) {
  4100. throwError(error, 'Vk.toggleVk');
  4101. return false;
  4102. }
  4103. }
  4104. function Vk_setCache2(name, postId) {
  4105. try {
  4106. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4107. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4108. } catch (error) {
  4109. throwError(error, 'Vk.setCache');
  4110. }
  4111. }
  4112. const social_Vk = Vk;
  4113. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4114. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4115. privateSet.add(obj);
  4116. }
  4117. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4118. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4119. privateMap.set(obj, value);
  4120. }
  4121. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4122. if (privateCollection.has(obj)) {
  4123. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4124. }
  4125. }
  4126. function Youtube_defineProperty(obj, key, value) {
  4127. if (key in obj) {
  4128. Object.defineProperty(obj, key, {
  4129. value: value,
  4130. enumerable: true,
  4131. configurable: true,
  4132. writable: true
  4133. });
  4134. } else {
  4135. obj[key] = value;
  4136. }
  4137. return obj;
  4138. }
  4139. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4140. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4141. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4142. return value;
  4143. }
  4144. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4145. if (descriptor.set) {
  4146. descriptor.set.call(receiver, value);
  4147. } else {
  4148. if (!descriptor.writable) {
  4149. throw new TypeError('attempted to set read only private field');
  4150. }
  4151. descriptor.value = value;
  4152. }
  4153. }
  4154. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4155. if (!privateSet.has(receiver)) {
  4156. throw new TypeError('attempted to get private field on non-instance');
  4157. }
  4158. return fn;
  4159. }
  4160. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4161. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4162. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4163. }
  4164. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4165. if (!privateMap.has(receiver)) {
  4166. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4167. }
  4168. return privateMap.get(receiver);
  4169. }
  4170. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4171. if (descriptor.get) {
  4172. return descriptor.get.call(receiver);
  4173. }
  4174. return descriptor.value;
  4175. }
  4176. const Youtube_defaultTasksTemplate = {
  4177. channels: [],
  4178. likes: []
  4179. };
  4180. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4181. const getInfo = async function(link, type) {
  4182. try {
  4183. const logStatus = scripts_echoLog({
  4184. text: i18n('gettingYtbToken')
  4185. });
  4186. const {
  4187. result,
  4188. statusText,
  4189. status,
  4190. data
  4191. } = await tools_httpRequest({
  4192. url: link,
  4193. method: 'GET'
  4194. });
  4195. if (result === 'Success') {
  4196. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4197. var _data$responseText$ma, _ref;
  4198. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4199. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4200. return {
  4201. needLogin: true
  4202. };
  4203. }
  4204. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4205. 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]) || '{}';
  4206. const {
  4207. client,
  4208. request
  4209. } = JSON.parse(context);
  4210. if (apiKey && client && request) {
  4211. client.hl = 'en';
  4212. if (type === 'channel') {
  4213. var _data$responseText$ma2;
  4214. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4215. if (channelId) {
  4216. logStatus.success();
  4217. return {
  4218. params: {
  4219. apiKey: apiKey,
  4220. client: client,
  4221. request: request,
  4222. channelId: channelId
  4223. }
  4224. };
  4225. }
  4226. logStatus.error('Error: Get "channelId" failed!');
  4227. return {};
  4228. } else if (type === 'likeVideo') {
  4229. var _data$responseText$ma3, _data$responseText$ma4;
  4230. 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];
  4231. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4232. if (videoId) {
  4233. logStatus.success();
  4234. return {
  4235. params: {
  4236. apiKey: apiKey,
  4237. client: client,
  4238. request: request,
  4239. videoId: videoId,
  4240. likeParams: likeParams
  4241. }
  4242. };
  4243. }
  4244. logStatus.error('Error: Get "videoId" failed!');
  4245. return {};
  4246. }
  4247. logStatus.error('Error: Unknown type');
  4248. return {};
  4249. }
  4250. logStatus.error('Error: Parameter "apiKey" not found!');
  4251. return {};
  4252. }
  4253. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4254. return {};
  4255. }
  4256. logStatus.error(`${result}:${statusText}(${status})`);
  4257. return {};
  4258. } catch (error) {
  4259. throwError(error, 'Youtube.getInfo');
  4260. return {};
  4261. }
  4262. };
  4263. var Youtube_auth = new WeakMap();
  4264. var Youtube_initialized = new WeakMap();
  4265. var _verifyChannel = new WeakMap();
  4266. var Youtube_verifyAuth = new WeakSet();
  4267. var Youtube_updateAuth = new WeakSet();
  4268. var _getInfo = new WeakSet();
  4269. var Youtube_toggleChannel = new WeakSet();
  4270. var _toggleLikeVideo = new WeakSet();
  4271. class Youtube extends social_Social {
  4272. constructor() {
  4273. var _GM_getValue;
  4274. super(...arguments);
  4275. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4276. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4277. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4278. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4279. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4280. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4281. Youtube_defineProperty(this, 'whiteList', {
  4282. ...JSON.parse(Youtube_defaultTasks),
  4283. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4284. });
  4285. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4286. writable: true,
  4287. value: GM_getValue('youtubeAuth') || {}
  4288. });
  4289. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4290. writable: true,
  4291. value: false
  4292. });
  4293. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4294. writable: true,
  4295. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4296. });
  4297. }
  4298. async init() {
  4299. try {
  4300. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4301. return true;
  4302. }
  4303. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4304. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4305. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4306. return true;
  4307. }
  4308. return false;
  4309. }
  4310. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4311. if (isVerified) {
  4312. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4313. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4314. return true;
  4315. }
  4316. GM_setValue('youtubeAuth', null);
  4317. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4318. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4319. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4320. return true;
  4321. }
  4322. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4323. return false;
  4324. } catch (error) {
  4325. throwError(error, 'Youtube.init');
  4326. return false;
  4327. }
  4328. }
  4329. async toggle(_ref2) {
  4330. let {
  4331. doTask = true,
  4332. channelLinks = [],
  4333. videoLinks = []
  4334. } = _ref2;
  4335. try {
  4336. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4337. scripts_echoLog({
  4338. text: i18n('needInit')
  4339. });
  4340. return false;
  4341. }
  4342. const prom = [];
  4343. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4344. scripts_echoLog({
  4345. type: 'globalOptionsSkip',
  4346. text: 'youtube.channels'
  4347. });
  4348. } else {
  4349. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4350. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4351. var _link$match;
  4352. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4353. }
  4354. return link;
  4355. });
  4356. if (realChannels.length > 0) {
  4357. for (const channel of realChannels) {
  4358. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4359. link: channel,
  4360. doTask: doTask
  4361. }));
  4362. await delay(1e3);
  4363. }
  4364. }
  4365. }
  4366. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4367. scripts_echoLog({
  4368. type: 'globalOptionsSkip',
  4369. text: 'youtube.likes'
  4370. });
  4371. } else {
  4372. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4373. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4374. var _link$match2;
  4375. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4376. }
  4377. return link;
  4378. });
  4379. if (realLikes.length > 0) {
  4380. for (const video of realLikes) {
  4381. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4382. link: video,
  4383. doTask: doTask
  4384. }));
  4385. await delay(1e3);
  4386. }
  4387. }
  4388. }
  4389. return Promise.all(prom).then(() => true);
  4390. } catch (error) {
  4391. throwError(error, 'Youtube.toggle');
  4392. return false;
  4393. }
  4394. }
  4395. }
  4396. async function Youtube_verifyAuth2() {
  4397. try {
  4398. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4399. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4400. doTask: true,
  4401. verify: true
  4402. });
  4403. } catch (error) {
  4404. throwError(error, 'Youtube.verifyAuth');
  4405. return false;
  4406. }
  4407. }
  4408. async function Youtube_updateAuth2() {
  4409. try {
  4410. const logStatus = scripts_echoLog({
  4411. text: i18n('updatingAuth', 'Youtube')
  4412. });
  4413. return await new Promise(resolve => {
  4414. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4415. active: true,
  4416. insert: true,
  4417. setParent: true
  4418. });
  4419. newTab.onclose = async () => {
  4420. const auth = GM_getValue('youtubeAuth');
  4421. if (auth) {
  4422. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4423. logStatus.success();
  4424. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4425. resolve(result);
  4426. });
  4427. } else {
  4428. logStatus.error('Error: Update youtube auth failed!');
  4429. resolve(false);
  4430. }
  4431. };
  4432. });
  4433. } catch (error) {
  4434. throwError(error, 'Discord.updateAuth');
  4435. return false;
  4436. }
  4437. }
  4438. function _getInfo2(link, type) {
  4439. return getInfo(link, type);
  4440. }
  4441. async function Youtube_toggleChannel2(_ref3) {
  4442. let {
  4443. link,
  4444. doTask = true,
  4445. verify = false
  4446. } = _ref3;
  4447. try {
  4448. const {
  4449. params,
  4450. needLogin
  4451. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4452. const {
  4453. apiKey,
  4454. client,
  4455. request,
  4456. channelId
  4457. } = params || {};
  4458. if (needLogin) {
  4459. scripts_echoLog({
  4460. html: i18n('loginYtb')
  4461. });
  4462. return false;
  4463. }
  4464. if (!(apiKey && client && request && channelId)) {
  4465. scripts_echoLog({
  4466. text: '"getYtbToken" failed'
  4467. });
  4468. return false;
  4469. }
  4470. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4471. scripts_echoLog({
  4472. type: 'whiteList',
  4473. text: 'Youtube.unfollowChannel',
  4474. id: channelId
  4475. });
  4476. return true;
  4477. }
  4478. const logStatus = verify ? scripts_echoLog({
  4479. text: i18n('verifyingAuth', 'Youtube')
  4480. }) : scripts_echoLog({
  4481. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4482. text: channelId
  4483. });
  4484. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4485. const {
  4486. result,
  4487. statusText,
  4488. status,
  4489. data
  4490. } = await tools_httpRequest({
  4491. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4492. method: 'POST',
  4493. headers: {
  4494. origin: 'https://www.youtube.com',
  4495. referer: `https://www.youtube.com/channel/${channelId}`,
  4496. 'content-type': 'application/json',
  4497. 'x-goog-authuser': '0',
  4498. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4499. 'x-origin': 'https://www.youtube.com',
  4500. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4501. },
  4502. data: JSON.stringify({
  4503. context: {
  4504. client: client,
  4505. request: {
  4506. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4507. internalExperimentFlags: [],
  4508. consistencyTokenJars: []
  4509. },
  4510. user: {}
  4511. },
  4512. channelIds: [ channelId ],
  4513. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4514. })
  4515. });
  4516. if (result === 'Success') {
  4517. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4518. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4519. logStatus.success();
  4520. if (doTask && !verify) {
  4521. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4522. }
  4523. return true;
  4524. }
  4525. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4526. logStatus.success();
  4527. return true;
  4528. }
  4529. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4530. return false;
  4531. }
  4532. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4533. return false;
  4534. }
  4535. logStatus.error(`${result}:${statusText}(${status})`);
  4536. return false;
  4537. } catch (error) {
  4538. throwError(error, 'Youtube.toggleChannel');
  4539. return false;
  4540. }
  4541. }
  4542. async function _toggleLikeVideo2(_ref4) {
  4543. let {
  4544. link,
  4545. doTask = true
  4546. } = _ref4;
  4547. try {
  4548. const {
  4549. params,
  4550. needLogin
  4551. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4552. const {
  4553. apiKey,
  4554. client,
  4555. request,
  4556. videoId,
  4557. likeParams
  4558. } = params || {};
  4559. if (needLogin) {
  4560. scripts_echoLog({
  4561. html: `${i18n('loginYtb')}`
  4562. });
  4563. return false;
  4564. }
  4565. if (!(apiKey && client && request && videoId && likeParams)) {
  4566. scripts_echoLog({
  4567. text: '"getYtbToken" failed'
  4568. });
  4569. return false;
  4570. }
  4571. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4572. scripts_echoLog({
  4573. type: 'whiteList',
  4574. text: 'Youtube.unlikeVideo',
  4575. id: videoId
  4576. });
  4577. return true;
  4578. }
  4579. const logStatus = scripts_echoLog({
  4580. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4581. text: videoId
  4582. });
  4583. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4584. const likeVideoData = {
  4585. context: {
  4586. client: client,
  4587. request: {
  4588. sessionId: request.sessionId,
  4589. internalExperimentFlags: [],
  4590. consistencyTokenJars: []
  4591. },
  4592. user: {}
  4593. },
  4594. target: {
  4595. videoId: videoId
  4596. }
  4597. };
  4598. if (doTask) {
  4599. if (likeParams) {
  4600. likeVideoData.params = likeParams;
  4601. } else {
  4602. logStatus.error('Empty likeParams');
  4603. return false;
  4604. }
  4605. }
  4606. const {
  4607. result,
  4608. statusText,
  4609. status,
  4610. data
  4611. } = await tools_httpRequest({
  4612. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4613. method: 'POST',
  4614. headers: {
  4615. origin: 'https://www.youtube.com',
  4616. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4617. 'content-type': 'application/json',
  4618. 'x-goog-authuser': '0',
  4619. 'x-goog-visitor-id': client.visitorData,
  4620. 'x-origin': 'https://www.youtube.com',
  4621. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4622. },
  4623. data: JSON.stringify(likeVideoData)
  4624. });
  4625. if (result === 'Success') {
  4626. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4627. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4628. logStatus.success();
  4629. if (doTask) {
  4630. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4631. }
  4632. return true;
  4633. }
  4634. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4635. return false;
  4636. }
  4637. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4638. return false;
  4639. }
  4640. logStatus.error(`${result}:${statusText}(${status})`);
  4641. return false;
  4642. } catch (error) {
  4643. throwError(error, 'Youtube.toggleLikeVideo');
  4644. return false;
  4645. }
  4646. }
  4647. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4648. Steam_checkPrivateRedeclaration(obj, privateSet);
  4649. privateSet.add(obj);
  4650. }
  4651. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4652. Steam_checkPrivateRedeclaration(obj, privateMap);
  4653. privateMap.set(obj, value);
  4654. }
  4655. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4656. if (privateCollection.has(obj)) {
  4657. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4658. }
  4659. }
  4660. function Steam_defineProperty(obj, key, value) {
  4661. if (key in obj) {
  4662. Object.defineProperty(obj, key, {
  4663. value: value,
  4664. enumerable: true,
  4665. configurable: true,
  4666. writable: true
  4667. });
  4668. } else {
  4669. obj[key] = value;
  4670. }
  4671. return obj;
  4672. }
  4673. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4674. if (!privateSet.has(receiver)) {
  4675. throw new TypeError('attempted to get private field on non-instance');
  4676. }
  4677. return fn;
  4678. }
  4679. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4680. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4681. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4682. return value;
  4683. }
  4684. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4685. if (descriptor.set) {
  4686. descriptor.set.call(receiver, value);
  4687. } else {
  4688. if (!descriptor.writable) {
  4689. throw new TypeError('attempted to set read only private field');
  4690. }
  4691. descriptor.value = value;
  4692. }
  4693. }
  4694. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4695. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4696. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4697. }
  4698. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4699. if (!privateMap.has(receiver)) {
  4700. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4701. }
  4702. return privateMap.get(receiver);
  4703. }
  4704. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4705. if (descriptor.get) {
  4706. return descriptor.get.call(receiver);
  4707. }
  4708. return descriptor.value;
  4709. }
  4710. const Steam_defaultTasksTemplate = {
  4711. groups: [],
  4712. officialGroups: [],
  4713. wishlists: [],
  4714. follows: [],
  4715. forums: [],
  4716. workshops: [],
  4717. workshopVotes: [],
  4718. curators: [],
  4719. curatorLikes: [],
  4720. announcements: [],
  4721. licenses: [],
  4722. playtests: []
  4723. };
  4724. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4725. var Steam_cache = new WeakMap();
  4726. var Steam_auth = new WeakMap();
  4727. var _storeInitialized = new WeakMap();
  4728. var _communityInitialized = new WeakMap();
  4729. var _area = new WeakMap();
  4730. var _areaStatus = new WeakMap();
  4731. var _updateStoreAuth = new WeakSet();
  4732. var _updateCommunityAuth = new WeakSet();
  4733. var _getAreaInfo = new WeakSet();
  4734. var _changeArea = new WeakSet();
  4735. var _joinGroup = new WeakSet();
  4736. var _leaveGroup = new WeakSet();
  4737. var _getGroupId = new WeakSet();
  4738. var _joinOfficialGroup = new WeakSet();
  4739. var _leaveOfficialGroup = new WeakSet();
  4740. var _getOfficialGroupId = new WeakSet();
  4741. var _addToWishlist = new WeakSet();
  4742. var _removeFromWishlist = new WeakSet();
  4743. var _toggleFollowGame = new WeakSet();
  4744. var _isFollowedGame = new WeakSet();
  4745. var _toggleForum = new WeakSet();
  4746. var _getForumId = new WeakSet();
  4747. var _toggleFavoriteWorkshop = new WeakSet();
  4748. var _getWorkshopAppId = new WeakSet();
  4749. var _voteUpWorkshop = new WeakSet();
  4750. var _toggleCurator = new WeakSet();
  4751. var _toggleCuratorLike = new WeakSet();
  4752. var _getAnnouncementParams = new WeakSet();
  4753. var _likeAnnouncement = new WeakSet();
  4754. var _appid2subid = new WeakSet();
  4755. var _getLicenses = new WeakSet();
  4756. var _addLicense = new WeakSet();
  4757. var _addFreeLicense = new WeakSet();
  4758. var _requestPlayTestAccess = new WeakSet();
  4759. var Steam_setCache = new WeakSet();
  4760. class Steam extends social_Social {
  4761. constructor() {
  4762. var _GM_getValue;
  4763. super(...arguments);
  4764. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4765. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4766. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4767. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4768. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4769. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4770. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4771. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4772. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4773. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4774. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4775. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4776. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4777. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4778. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4779. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4780. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4781. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4782. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4783. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4784. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4785. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4786. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4787. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4788. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4789. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4790. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4791. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4792. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4793. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4794. Steam_defineProperty(this, 'whiteList', {
  4795. ...JSON.parse(Steam_defaultTasks),
  4796. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4797. });
  4798. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4799. writable: true,
  4800. value: {
  4801. ...{
  4802. group: {},
  4803. officialGroup: {},
  4804. forum: {},
  4805. workshop: {},
  4806. curator: {}
  4807. },
  4808. ...GM_getValue('steamCache')
  4809. }
  4810. });
  4811. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4812. writable: true,
  4813. value: {}
  4814. });
  4815. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4816. writable: true,
  4817. value: false
  4818. });
  4819. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4820. writable: true,
  4821. value: false
  4822. });
  4823. Steam_classPrivateFieldInitSpec(this, _area, {
  4824. writable: true,
  4825. value: 'CN'
  4826. });
  4827. Steam_classPrivateFieldInitSpec(this, _areaStatus, {
  4828. writable: true,
  4829. value: 'end'
  4830. });
  4831. }
  4832. async init() {
  4833. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4834. try {
  4835. if (type === 'store') {
  4836. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4837. return true;
  4838. }
  4839. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4840. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4841. return true;
  4842. }
  4843. if (type === 'community') {
  4844. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4845. return true;
  4846. }
  4847. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4848. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4849. return true;
  4850. }
  4851. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4852. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4853. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4854. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4855. return true;
  4856. }
  4857. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4858. return false;
  4859. } catch (error) {
  4860. throwError(error, 'Steam.init');
  4861. return false;
  4862. }
  4863. }
  4864. async getCuratorId(path, name) {
  4865. try {
  4866. const logStatus = scripts_echoLog({
  4867. type: 'gettingCuratorId',
  4868. text: `${path}/${name}`
  4869. });
  4870. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4871. if (curatorId) {
  4872. logStatus.success();
  4873. return curatorId;
  4874. }
  4875. const {
  4876. result,
  4877. statusText,
  4878. status,
  4879. data
  4880. } = await tools_httpRequest({
  4881. url: `https://store.steampowered.com/${path}/${name}`,
  4882. method: 'GET',
  4883. headers: {
  4884. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4885. }
  4886. });
  4887. if (result === 'Success') {
  4888. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4889. var _data$responseText$ma;
  4890. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4891. if (curatorId) {
  4892. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4893. logStatus.success();
  4894. return curatorId;
  4895. }
  4896. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4897. return false;
  4898. }
  4899. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4900. return false;
  4901. }
  4902. logStatus.error(`${result}:${statusText}(${status})`);
  4903. return false;
  4904. } catch (error) {
  4905. throwError(error, 'Steam.getCuratorID');
  4906. return false;
  4907. }
  4908. }
  4909. async toggle(_ref) {
  4910. let {
  4911. doTask = true,
  4912. groupLinks = [],
  4913. officialGroupLinks = [],
  4914. wishlistLinks = [],
  4915. followLinks = [],
  4916. forumLinks = [],
  4917. workshopLinks = [],
  4918. workshopVoteLinks = [],
  4919. curatorLinks = [],
  4920. curatorLikeLinks = [],
  4921. announcementLinks = [],
  4922. licenseLinks = [],
  4923. playtestLinks = []
  4924. } = _ref;
  4925. try {
  4926. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4927. scripts_echoLog({
  4928. text: i18n('needInit')
  4929. });
  4930. return false;
  4931. }
  4932. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4933. scripts_echoLog({
  4934. text: i18n('needInit')
  4935. });
  4936. return false;
  4937. }
  4938. const prom = [];
  4939. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4940. scripts_echoLog({
  4941. type: 'globalOptionsSkip',
  4942. text: 'steam.groups'
  4943. });
  4944. } else {
  4945. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4946. var _link$match;
  4947. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4948. });
  4949. if (realGroups.length > 0) {
  4950. for (const group of realGroups) {
  4951. if (doTask) {
  4952. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4953. } else {
  4954. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4955. }
  4956. await delay(1e3);
  4957. }
  4958. }
  4959. }
  4960. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  4961. scripts_echoLog({
  4962. type: 'globalOptionsSkip',
  4963. text: 'steam.officialGroups'
  4964. });
  4965. } else {
  4966. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  4967. var _link$match2;
  4968. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4969. });
  4970. if (realOfficialGroups.length > 0) {
  4971. for (const officialGroup of realOfficialGroups) {
  4972. if (doTask) {
  4973. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  4974. } else {
  4975. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  4976. }
  4977. await delay(1e3);
  4978. }
  4979. }
  4980. }
  4981. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4982. scripts_echoLog({
  4983. type: 'globalOptionsSkip',
  4984. text: 'steam.wishlists'
  4985. });
  4986. } else {
  4987. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4988. var _link$match3;
  4989. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4990. });
  4991. if (realWishlists.length > 0) {
  4992. for (const game of realWishlists) {
  4993. if (doTask) {
  4994. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4995. } else {
  4996. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4997. }
  4998. await delay(1e3);
  4999. }
  5000. }
  5001. }
  5002. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5003. scripts_echoLog({
  5004. type: 'globalOptionsSkip',
  5005. text: 'steam.follows'
  5006. });
  5007. } else {
  5008. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5009. var _link$match4;
  5010. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5011. });
  5012. if (realFollows.length > 0) {
  5013. for (const game of realFollows) {
  5014. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  5015. await delay(1e3);
  5016. }
  5017. }
  5018. }
  5019. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5020. scripts_echoLog({
  5021. type: 'globalOptionsSkip',
  5022. text: 'steam.forums'
  5023. });
  5024. } else {
  5025. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5026. var _link$match5;
  5027. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5028. });
  5029. if (realForums.length > 0) {
  5030. for (const forum of realForums) {
  5031. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5032. await delay(1e3);
  5033. }
  5034. }
  5035. }
  5036. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5037. scripts_echoLog({
  5038. type: 'globalOptionsSkip',
  5039. text: 'steam.workshops'
  5040. });
  5041. } else {
  5042. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5043. var _link$match6;
  5044. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5045. });
  5046. if (realWorkshops.length > 0) {
  5047. for (const workshop of realWorkshops) {
  5048. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5049. await delay(1e3);
  5050. }
  5051. }
  5052. }
  5053. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5054. scripts_echoLog({
  5055. type: 'globalOptionsSkip',
  5056. text: 'steam.workshopVotes'
  5057. });
  5058. } else {
  5059. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5060. var _link$match7;
  5061. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5062. });
  5063. if (doTask && realworkshopVotes.length > 0) {
  5064. for (const workshop of realworkshopVotes) {
  5065. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5066. await delay(1e3);
  5067. }
  5068. }
  5069. }
  5070. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5071. scripts_echoLog({
  5072. type: 'globalOptionsSkip',
  5073. text: 'steam.curators'
  5074. });
  5075. } else {
  5076. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5077. var _link$match8;
  5078. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5079. });
  5080. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5081. var _link$match9;
  5082. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5083. });
  5084. if (realCurators.length > 0) {
  5085. for (const curator of realCurators) {
  5086. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5087. await delay(1e3);
  5088. }
  5089. }
  5090. if (realCuratorLikes.length > 0) {
  5091. for (const curatorLike of realCuratorLikes) {
  5092. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5093. await delay(1e3);
  5094. }
  5095. }
  5096. }
  5097. if (doTask && !globalOptions.doTask.steam.announcements) {
  5098. scripts_echoLog({
  5099. type: 'globalOptionsSkip',
  5100. text: 'steam.announcements'
  5101. });
  5102. } else {
  5103. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5104. var _link$match11;
  5105. if (link.includes('store.steampowered.com')) {
  5106. var _link$match10;
  5107. 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('/');
  5108. }
  5109. 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('/');
  5110. });
  5111. if (doTask && realAnnouncements.length > 0) {
  5112. for (const id of realAnnouncements) {
  5113. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5114. await delay(1e3);
  5115. }
  5116. }
  5117. }
  5118. if (doTask && !globalOptions.doTask.steam.licenses) {
  5119. scripts_echoLog({
  5120. type: 'globalOptionsSkip',
  5121. text: 'steam.licenses'
  5122. });
  5123. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5124. for (const id of licenseLinks) {
  5125. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5126. await delay(1e3);
  5127. }
  5128. }
  5129. if (doTask && !globalOptions.doTask.steam.playtests) {
  5130. scripts_echoLog({
  5131. type: 'globalOptionsSkip',
  5132. text: 'steam.playtests'
  5133. });
  5134. } else {
  5135. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5136. var _link$match12;
  5137. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5138. });
  5139. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5140. for (const id of realPlaytests) {
  5141. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5142. await delay(1e3);
  5143. }
  5144. }
  5145. }
  5146. return Promise.all(prom).then(async () => {
  5147. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5148. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5149. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5150. }
  5151. return true;
  5152. });
  5153. } catch (error) {
  5154. throwError(error, 'Steam.toggle');
  5155. return false;
  5156. }
  5157. }
  5158. }
  5159. async function _updateStoreAuth2() {
  5160. try {
  5161. const logStatus = scripts_echoLog({
  5162. text: i18n('updatingAuth', i18n('steamStore'))
  5163. });
  5164. const {
  5165. result,
  5166. statusText,
  5167. status,
  5168. data
  5169. } = await tools_httpRequest({
  5170. url: 'https://store.steampowered.com/stats/',
  5171. method: 'GET'
  5172. });
  5173. if (result === 'Success') {
  5174. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5175. var _data$responseText$ma2;
  5176. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5177. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5178. return false;
  5179. }
  5180. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5181. if (storeSessionID) {
  5182. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5183. logStatus.success();
  5184. return true;
  5185. }
  5186. logStatus.error('Error: Get "sessionID" failed');
  5187. return false;
  5188. }
  5189. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5190. return false;
  5191. }
  5192. logStatus.error(`${result}:${statusText}(${status})`);
  5193. return false;
  5194. } catch (error) {
  5195. throwError(error, 'Steam.updateStoreAuth');
  5196. return false;
  5197. }
  5198. }
  5199. async function _updateCommunityAuth2() {
  5200. try {
  5201. const logStatus = scripts_echoLog({
  5202. text: i18n('updatingAuth', i18n('steamCommunity'))
  5203. });
  5204. const {
  5205. result,
  5206. statusText,
  5207. status,
  5208. data
  5209. } = await tools_httpRequest({
  5210. url: 'https://steamcommunity.com/my',
  5211. method: 'GET'
  5212. });
  5213. if (result === 'Success') {
  5214. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5215. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5216. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5217. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5218. return false;
  5219. }
  5220. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5221. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5222. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5223. if (steam64Id) {
  5224. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5225. }
  5226. if (userName) {
  5227. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5228. }
  5229. if (communitySessionID) {
  5230. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5231. logStatus.success();
  5232. return true;
  5233. }
  5234. logStatus.error('Error: Get "sessionID" failed');
  5235. return false;
  5236. }
  5237. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5238. return false;
  5239. }
  5240. logStatus.error(`${result}:${statusText}(${status})`);
  5241. return false;
  5242. } catch (error) {
  5243. throwError(error, 'Steam.updateCommunityAuth');
  5244. return false;
  5245. }
  5246. }
  5247. async function _getAreaInfo2() {
  5248. try {
  5249. const logStatus = scripts_echoLog({
  5250. text: i18n('gettingAreaInfo')
  5251. });
  5252. const {
  5253. result,
  5254. statusText,
  5255. status,
  5256. data
  5257. } = await tools_httpRequest({
  5258. url: 'https://store.steampowered.com/cart/',
  5259. method: 'GET'
  5260. });
  5261. if (result === 'Success') {
  5262. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5263. var _data$responseText$ma6;
  5264. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5265. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5266. if (currentArea && areas.length > 0) {
  5267. Steam_classPrivateFieldSet(this, _area, currentArea);
  5268. logStatus.success();
  5269. return {
  5270. currentArea: currentArea,
  5271. areas: areas
  5272. };
  5273. }
  5274. logStatus.error('Error: get country info filed');
  5275. return {};
  5276. }
  5277. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5278. return {};
  5279. }
  5280. logStatus.error(`${result}:${statusText}(${status})`);
  5281. return {};
  5282. } catch (error) {
  5283. throwError(error, 'Steam.getAreaInfo');
  5284. return {};
  5285. }
  5286. }
  5287. async function _changeArea2(area) {
  5288. try {
  5289. if (Steam_classPrivateFieldGet(this, _areaStatus) === 'waiting') {
  5290. await new Promise(resolve => {
  5291. const checker = setInterval(() => {
  5292. if (Steam_classPrivateFieldGet(this, _areaStatus) !== 'waiting') {
  5293. clearInterval(checker);
  5294. resolve(true);
  5295. }
  5296. });
  5297. });
  5298. }
  5299. if (Steam_classPrivateFieldGet(this, _area) === area || !area && Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5300. return true;
  5301. }
  5302. Steam_classPrivateFieldSet(this, _areaStatus, 'waiting');
  5303. let aimedArea = area;
  5304. if (!aimedArea) {
  5305. const {
  5306. currentArea,
  5307. areas
  5308. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5309. if (!currentArea || !areas) {
  5310. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5311. return false;
  5312. }
  5313. if (currentArea !== 'CN') {
  5314. Steam_classPrivateFieldSet(this, _areaStatus, 'skip');
  5315. scripts_echoLog({
  5316. text: 'notNeededChangeArea'
  5317. });
  5318. return 'skip';
  5319. }
  5320. const anotherArea = areas.filter(area => area && area !== 'CN');
  5321. if (!anotherArea || anotherArea.length === 0) {
  5322. Steam_classPrivateFieldSet(this, _areaStatus, 'noAnotherArea');
  5323. scripts_echoLog({
  5324. text: 'noAnotherArea'
  5325. });
  5326. return false;
  5327. }
  5328. [ aimedArea ] = anotherArea;
  5329. }
  5330. const logStatus = scripts_echoLog({
  5331. text: i18n('changingArea', aimedArea)
  5332. });
  5333. const {
  5334. result,
  5335. statusText,
  5336. status,
  5337. data
  5338. } = await tools_httpRequest({
  5339. url: 'https://store.steampowered.com/account/setcountry',
  5340. method: 'POST',
  5341. headers: {
  5342. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5343. },
  5344. data: $.param({
  5345. cc: aimedArea,
  5346. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5347. })
  5348. });
  5349. if (result === 'Success') {
  5350. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5351. const {
  5352. currentArea
  5353. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5354. if (currentArea === aimedArea) {
  5355. Steam_classPrivateFieldSet(this, _areaStatus, 'success');
  5356. logStatus.success();
  5357. return currentArea;
  5358. }
  5359. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5360. logStatus.error('Error: change country filed');
  5361. return 'CN';
  5362. }
  5363. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5364. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5365. return 'CN';
  5366. }
  5367. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5368. logStatus.error(`${result}:${statusText}(${status})`);
  5369. return 'CN';
  5370. } catch (error) {
  5371. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5372. throwError(error, 'Steam.changeArea');
  5373. return false;
  5374. }
  5375. }
  5376. async function _joinGroup2(groupName) {
  5377. try {
  5378. const logStatus = scripts_echoLog({
  5379. type: 'joiningSteamGroup',
  5380. text: groupName
  5381. });
  5382. const {
  5383. result,
  5384. statusText,
  5385. status,
  5386. data
  5387. } = await tools_httpRequest({
  5388. url: `https://steamcommunity.com/groups/${groupName}`,
  5389. method: 'POST',
  5390. headers: {
  5391. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5392. },
  5393. data: $.param({
  5394. action: 'join',
  5395. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5396. })
  5397. });
  5398. if (result === 'Success') {
  5399. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5400. logStatus.success();
  5401. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5402. return true;
  5403. }
  5404. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5405. return false;
  5406. }
  5407. logStatus.error(`${result}:${statusText}(${status})`);
  5408. return false;
  5409. } catch (error) {
  5410. throwError(error, 'Steam.joinGroup');
  5411. return false;
  5412. }
  5413. }
  5414. async function _leaveGroup2(groupName) {
  5415. try {
  5416. if (this.whiteList.groups.includes(groupName)) {
  5417. scripts_echoLog({
  5418. type: 'whiteList',
  5419. text: 'Steam.leaveGroup',
  5420. id: groupName
  5421. });
  5422. return true;
  5423. }
  5424. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5425. if (!groupId) {
  5426. return false;
  5427. }
  5428. const logStatus = scripts_echoLog({
  5429. type: 'leavingSteamGroup',
  5430. text: groupName
  5431. });
  5432. const {
  5433. result,
  5434. statusText,
  5435. status,
  5436. data
  5437. } = await tools_httpRequest({
  5438. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5439. method: 'POST',
  5440. headers: {
  5441. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5442. },
  5443. data: $.param({
  5444. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5445. action: 'leaveGroup',
  5446. groupId: groupId
  5447. })
  5448. });
  5449. if (result === 'Success') {
  5450. 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) {
  5451. logStatus.success();
  5452. return true;
  5453. }
  5454. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5455. return false;
  5456. }
  5457. logStatus.error(`${result}:${statusText}(${status})`);
  5458. return false;
  5459. } catch (error) {
  5460. throwError(error, 'Steam.leaveGroup');
  5461. return false;
  5462. }
  5463. }
  5464. async function _getGroupId2(groupName) {
  5465. try {
  5466. const logStatus = scripts_echoLog({
  5467. type: 'gettingSteamGroupId',
  5468. text: groupName
  5469. });
  5470. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5471. if (groupId) {
  5472. logStatus.success();
  5473. return groupId;
  5474. }
  5475. const {
  5476. result,
  5477. statusText,
  5478. status,
  5479. data
  5480. } = await tools_httpRequest({
  5481. url: `https://steamcommunity.com/groups/${groupName}`,
  5482. method: 'GET',
  5483. headers: {
  5484. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5485. }
  5486. });
  5487. if (result === 'Success') {
  5488. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5489. var _data$responseText$ma7;
  5490. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5491. if (groupId) {
  5492. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5493. logStatus.success();
  5494. return groupId;
  5495. }
  5496. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5497. return false;
  5498. }
  5499. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5500. return false;
  5501. }
  5502. logStatus.error(`${result}:${statusText}(${status})`);
  5503. return false;
  5504. } catch (error) {
  5505. throwError(error, 'Steam.getGroupID');
  5506. return false;
  5507. }
  5508. }
  5509. async function _joinOfficialGroup2(gameId) {
  5510. try {
  5511. const logStatus = scripts_echoLog({
  5512. type: 'joiningSteamOfficialGroup',
  5513. text: gameId
  5514. });
  5515. const {
  5516. result,
  5517. statusText,
  5518. status,
  5519. data
  5520. } = await tools_httpRequest({
  5521. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5522. method: 'GET',
  5523. headers: {
  5524. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5525. }
  5526. });
  5527. if (result === 'Success') {
  5528. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5529. var _data$responseText$ma8;
  5530. logStatus.success();
  5531. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5532. 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];
  5533. if (groupId) {
  5534. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5535. }
  5536. return true;
  5537. }
  5538. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5539. return false;
  5540. }
  5541. logStatus.error(`${result}:${statusText}(${status})`);
  5542. return false;
  5543. } catch (error) {
  5544. throwError(error, 'Steam.joinOfficialGroup');
  5545. return false;
  5546. }
  5547. }
  5548. async function _leaveOfficialGroup2(gameId) {
  5549. try {
  5550. if (this.whiteList.officialGroups.includes(gameId)) {
  5551. scripts_echoLog({
  5552. type: 'whiteList',
  5553. text: 'Steam.leaveOfficialGroup',
  5554. id: gameId
  5555. });
  5556. return true;
  5557. }
  5558. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5559. if (!groupId) {
  5560. return false;
  5561. }
  5562. const logStatus = scripts_echoLog({
  5563. type: 'leavingSteamOfficialGroup',
  5564. text: gameId
  5565. });
  5566. const {
  5567. result,
  5568. statusText,
  5569. status,
  5570. data
  5571. } = await tools_httpRequest({
  5572. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5573. method: 'POST',
  5574. headers: {
  5575. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5576. },
  5577. data: $.param({
  5578. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5579. action: 'leaveGroup',
  5580. groupId: groupId
  5581. })
  5582. });
  5583. if (result === 'Success') {
  5584. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5585. const {
  5586. result: resultR,
  5587. statusText: statusTextR,
  5588. status: statusR,
  5589. data: dataR
  5590. } = await tools_httpRequest({
  5591. url: `https://steamcommunity.com/games/${gameId}`,
  5592. method: 'GET',
  5593. headers: {
  5594. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5595. }
  5596. });
  5597. if (resultR === 'Success') {
  5598. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5599. logStatus.success();
  5600. return true;
  5601. }
  5602. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5603. return false;
  5604. }
  5605. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5606. return false;
  5607. }
  5608. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5609. return false;
  5610. }
  5611. logStatus.error(`${result}:${statusText}(${status})`);
  5612. return false;
  5613. } catch (error) {
  5614. throwError(error, 'Steam.leaveOfficialGroup');
  5615. return false;
  5616. }
  5617. }
  5618. async function _getOfficialGroupId2(gameId) {
  5619. try {
  5620. const logStatus = scripts_echoLog({
  5621. type: 'gettingSteamOfficialGroupId',
  5622. text: gameId
  5623. });
  5624. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5625. if (groupId) {
  5626. logStatus.success();
  5627. return groupId;
  5628. }
  5629. const {
  5630. result,
  5631. statusText,
  5632. status,
  5633. data
  5634. } = await tools_httpRequest({
  5635. url: `https://steamcommunity.com/games/${gameId}`,
  5636. method: 'GET',
  5637. headers: {
  5638. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5639. }
  5640. });
  5641. if (result === 'Success') {
  5642. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5643. var _data$responseText$ma9;
  5644. 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];
  5645. if (groupId) {
  5646. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5647. logStatus.success();
  5648. return groupId;
  5649. }
  5650. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5651. return false;
  5652. }
  5653. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5654. return false;
  5655. }
  5656. logStatus.error(`${result}:${statusText}(${status})`);
  5657. return false;
  5658. } catch (error) {
  5659. throwError(error, 'Steam.getGroupID');
  5660. return false;
  5661. }
  5662. }
  5663. async function _addToWishlist2(gameId) {
  5664. try {
  5665. var _data$response;
  5666. const logStatus = scripts_echoLog({
  5667. type: 'addingToWishlist',
  5668. text: gameId
  5669. });
  5670. const {
  5671. result,
  5672. data
  5673. } = await tools_httpRequest({
  5674. url: 'https://store.steampowered.com/api/addtowishlist',
  5675. method: 'POST',
  5676. headers: {
  5677. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5678. },
  5679. data: $.param({
  5680. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5681. appid: gameId
  5682. }),
  5683. dataType: 'json'
  5684. });
  5685. 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) {
  5686. logStatus.success();
  5687. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5688. return true;
  5689. }
  5690. const {
  5691. result: resultR,
  5692. statusText: statusTextR,
  5693. status: statusR,
  5694. data: dataR
  5695. } = await tools_httpRequest({
  5696. url: `https://store.steampowered.com/app/${gameId}`,
  5697. method: 'GET'
  5698. });
  5699. if (resultR === 'Success') {
  5700. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5701. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5702. logStatus.warning(i18n('changeAreaNotice'));
  5703. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5704. return false;
  5705. }
  5706. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5707. }
  5708. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5709. logStatus.success();
  5710. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5711. return true;
  5712. } 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"')) {
  5713. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5714. return false;
  5715. }
  5716. logStatus.success();
  5717. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5718. return true;
  5719. }
  5720. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5721. return false;
  5722. }
  5723. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5724. return false;
  5725. } catch (error) {
  5726. throwError(error, 'Steam.addToWishlist');
  5727. return false;
  5728. }
  5729. }
  5730. async function _removeFromWishlist2(gameId) {
  5731. try {
  5732. var _data$response2;
  5733. if (this.whiteList.wishlists.includes(gameId)) {
  5734. scripts_echoLog({
  5735. type: 'whiteList',
  5736. text: 'Steam.removeFromWishlist',
  5737. id: gameId
  5738. });
  5739. return true;
  5740. }
  5741. const logStatus = scripts_echoLog({
  5742. type: 'removingFromWishlist',
  5743. text: gameId
  5744. });
  5745. const {
  5746. result,
  5747. data
  5748. } = await tools_httpRequest({
  5749. url: 'https://store.steampowered.com/api/removefromwishlist',
  5750. method: 'POST',
  5751. headers: {
  5752. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5753. },
  5754. data: $.param({
  5755. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5756. appid: gameId
  5757. }),
  5758. dataType: 'json'
  5759. });
  5760. 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) {
  5761. logStatus.success();
  5762. return true;
  5763. }
  5764. const {
  5765. result: resultR,
  5766. statusText: statusTextR,
  5767. status: statusR,
  5768. data: dataR
  5769. } = await tools_httpRequest({
  5770. url: `https://store.steampowered.com/app/${gameId}`,
  5771. method: 'GET'
  5772. });
  5773. if (resultR === 'Success') {
  5774. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5775. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5776. logStatus.warning(i18n('changeAreaNotice'));
  5777. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5778. if (!result || result === 'CN' || result === 'skip') {
  5779. return false;
  5780. }
  5781. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5782. }
  5783. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5784. logStatus.success();
  5785. return true;
  5786. }
  5787. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5788. return false;
  5789. }
  5790. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5791. return false;
  5792. }
  5793. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5794. return false;
  5795. } catch (error) {
  5796. throwError(error, 'Steam.removeFromWishlist');
  5797. return false;
  5798. }
  5799. }
  5800. async function _toggleFollowGame2(gameId, doTask) {
  5801. try {
  5802. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5803. scripts_echoLog({
  5804. type: 'whiteList',
  5805. text: 'Steam.unfollowGame',
  5806. id: gameId
  5807. });
  5808. return true;
  5809. }
  5810. const logStatus = scripts_echoLog({
  5811. type: `${doTask ? '' : 'un'}followingGame`,
  5812. text: gameId
  5813. });
  5814. const requestData = {
  5815. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5816. appid: gameId
  5817. };
  5818. if (!doTask) {
  5819. requestData.unfollow = '1';
  5820. }
  5821. const {
  5822. result,
  5823. data
  5824. } = await tools_httpRequest({
  5825. url: 'https://store.steampowered.com/explore/followgame/',
  5826. method: 'POST',
  5827. headers: {
  5828. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5829. },
  5830. data: $.param(requestData)
  5831. });
  5832. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5833. logStatus.success();
  5834. return true;
  5835. }
  5836. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5837. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5838. logStatus.warning(i18n('changeAreaNotice'));
  5839. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5840. return false;
  5841. }
  5842. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5843. }
  5844. if (doTask === followed) {
  5845. logStatus.success();
  5846. if (doTask) {
  5847. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5848. }
  5849. return true;
  5850. }
  5851. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5852. return false;
  5853. } catch (error) {
  5854. throwError(error, 'Steam.toggleFollowGame');
  5855. return false;
  5856. }
  5857. }
  5858. async function _isFollowedGame2(gameId) {
  5859. try {
  5860. const {
  5861. result,
  5862. data
  5863. } = await tools_httpRequest({
  5864. url: `https://store.steampowered.com/app/${gameId}`,
  5865. method: 'GET'
  5866. });
  5867. if (result === 'Success') {
  5868. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5869. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5870. return 'areaLocked';
  5871. }
  5872. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5873. return true;
  5874. }
  5875. return false;
  5876. }
  5877. return false;
  5878. }
  5879. return false;
  5880. } catch (error) {
  5881. throwError(error, 'Steam.isFollowedGame');
  5882. return false;
  5883. }
  5884. }
  5885. async function _toggleForum2(gameId) {
  5886. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5887. try {
  5888. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5889. scripts_echoLog({
  5890. type: 'whiteList',
  5891. text: 'Steam.unsubscribeForum',
  5892. id: gameId
  5893. });
  5894. return true;
  5895. }
  5896. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5897. if (!forumId) {
  5898. return false;
  5899. }
  5900. const logStatus = scripts_echoLog({
  5901. type: `${doTask ? '' : 'un'}subscribingForum`,
  5902. text: gameId
  5903. });
  5904. const [ id, feature ] = forumId.split('_');
  5905. const {
  5906. result,
  5907. statusText,
  5908. status,
  5909. data
  5910. } = await tools_httpRequest({
  5911. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5912. method: 'POST',
  5913. responseType: 'json',
  5914. headers: {
  5915. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5916. },
  5917. data: $.param({
  5918. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5919. })
  5920. });
  5921. if (result === 'Success') {
  5922. var _data$response3, _data$response4;
  5923. 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)) {
  5924. if (doTask) {
  5925. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5926. }
  5927. logStatus.success();
  5928. return true;
  5929. }
  5930. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5931. return true;
  5932. }
  5933. logStatus.error(`${result}:${statusText}(${status})`);
  5934. return true;
  5935. } catch (error) {
  5936. throwError(error, 'Steam.toggleForum');
  5937. return true;
  5938. }
  5939. }
  5940. async function _getForumId2(gameId) {
  5941. try {
  5942. const logStatus = scripts_echoLog({
  5943. type: 'gettingForumId',
  5944. text: gameId
  5945. });
  5946. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5947. if (forumId) {
  5948. logStatus.success();
  5949. return forumId;
  5950. }
  5951. const {
  5952. result,
  5953. statusText,
  5954. status,
  5955. data
  5956. } = await tools_httpRequest({
  5957. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5958. method: 'GET'
  5959. });
  5960. if (result === 'Success') {
  5961. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5962. var _data$responseText, _data$responseText$ma10;
  5963. 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];
  5964. if (forumId) {
  5965. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5966. logStatus.success();
  5967. return forumId;
  5968. }
  5969. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5970. return false;
  5971. }
  5972. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5973. return false;
  5974. }
  5975. logStatus.error(`${result}:${statusText}(${status})`);
  5976. return false;
  5977. } catch (error) {
  5978. throwError(error, 'Steam.getForumId');
  5979. return false;
  5980. }
  5981. }
  5982. async function _toggleFavoriteWorkshop2(id) {
  5983. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5984. try {
  5985. if (!doTask && this.whiteList.workshops.includes(id)) {
  5986. scripts_echoLog({
  5987. type: 'whiteList',
  5988. text: 'Steam.unfavoriteWorkshop',
  5989. id: id
  5990. });
  5991. return true;
  5992. }
  5993. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5994. if (!appid) {
  5995. return false;
  5996. }
  5997. const logStatus = scripts_echoLog({
  5998. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5999. text: id
  6000. });
  6001. const {
  6002. result,
  6003. statusText,
  6004. status,
  6005. data
  6006. } = await tools_httpRequest({
  6007. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  6008. method: 'POST',
  6009. headers: {
  6010. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6011. },
  6012. data: $.param({
  6013. id: id,
  6014. appid: appid,
  6015. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6016. })
  6017. });
  6018. if (result === 'Success') {
  6019. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  6020. if (doTask) {
  6021. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  6022. }
  6023. logStatus.success();
  6024. return true;
  6025. }
  6026. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6027. return false;
  6028. }
  6029. logStatus.error(`${result}:${statusText}(${status})`);
  6030. return false;
  6031. } catch (error) {
  6032. throwError(error, 'Steam.toggleFavoriteWorkshop');
  6033. return false;
  6034. }
  6035. }
  6036. async function _getWorkshopAppId2(id) {
  6037. try {
  6038. const logStatus = scripts_echoLog({
  6039. type: 'gettingWorkshopAppId',
  6040. text: id
  6041. });
  6042. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  6043. if (appId) {
  6044. logStatus.success();
  6045. return appId;
  6046. }
  6047. const {
  6048. result,
  6049. statusText,
  6050. status,
  6051. data
  6052. } = await tools_httpRequest({
  6053. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6054. method: 'GET'
  6055. });
  6056. if (result === 'Success') {
  6057. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6058. var _data$responseText$ma11;
  6059. 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];
  6060. if (appId) {
  6061. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6062. logStatus.success();
  6063. return appId;
  6064. }
  6065. logStatus.error('Error: getWorkshopAppId failed');
  6066. return false;
  6067. }
  6068. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6069. return false;
  6070. }
  6071. logStatus.error(`${result}:${statusText}(${status})`);
  6072. return false;
  6073. } catch (error) {
  6074. throwError(error, 'Steam.getWorkshopAppId');
  6075. return false;
  6076. }
  6077. }
  6078. async function _voteUpWorkshop2(id) {
  6079. try {
  6080. const logStatus = scripts_echoLog({
  6081. type: 'votingUpWorkshop',
  6082. text: id
  6083. });
  6084. const {
  6085. result,
  6086. statusText,
  6087. status,
  6088. data
  6089. } = await tools_httpRequest({
  6090. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6091. method: 'POST',
  6092. responseType: 'json',
  6093. headers: {
  6094. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6095. },
  6096. data: $.param({
  6097. id: id,
  6098. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6099. })
  6100. });
  6101. if (result === 'Success') {
  6102. var _data$response5;
  6103. 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) {
  6104. logStatus.success();
  6105. return true;
  6106. }
  6107. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6108. return true;
  6109. }
  6110. logStatus.error(`${result}:${statusText}(${status})`);
  6111. return true;
  6112. } catch (error) {
  6113. throwError(error, 'Steam.voteupWorkshop');
  6114. return true;
  6115. }
  6116. }
  6117. async function _toggleCurator2(curatorId) {
  6118. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6119. try {
  6120. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6121. scripts_echoLog({
  6122. type: 'whiteList',
  6123. text: 'Steam.unfollowCurator',
  6124. id: curatorId
  6125. });
  6126. return true;
  6127. }
  6128. const logStatus = scripts_echoLog({
  6129. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6130. text: curatorId
  6131. });
  6132. const {
  6133. result,
  6134. statusText,
  6135. status,
  6136. data
  6137. } = await tools_httpRequest({
  6138. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6139. method: 'POST',
  6140. headers: {
  6141. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6142. },
  6143. data: $.param({
  6144. clanid: curatorId,
  6145. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6146. follow: doTask
  6147. }),
  6148. dataType: 'json'
  6149. });
  6150. if (result === 'Success') {
  6151. var _data$response6, _data$response6$succe, _data$response7;
  6152. 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) {
  6153. logStatus.success();
  6154. return true;
  6155. }
  6156. 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})`);
  6157. return false;
  6158. }
  6159. logStatus.error(`${result}:${statusText}(${status})`);
  6160. return false;
  6161. } catch (error) {
  6162. throwError(error, 'Steam.toggleCurator');
  6163. return false;
  6164. }
  6165. }
  6166. async function _toggleCuratorLike2(link) {
  6167. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6168. try {
  6169. const [ path, name ] = link.split('/');
  6170. if (!(path && name)) {
  6171. scripts_echoLog({
  6172. text: i18n('errorLink', link)
  6173. });
  6174. return false;
  6175. }
  6176. const curatorId = await this.getCuratorId(path, name);
  6177. if (curatorId) {
  6178. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6179. }
  6180. return false;
  6181. } catch (error) {
  6182. throwError(error, 'Steam.toggleCuratorLike');
  6183. return false;
  6184. }
  6185. }
  6186. async function _getAnnouncementParams2(appId, viewId) {
  6187. try {
  6188. const logStatus = scripts_echoLog({
  6189. type: 'gettingAnnouncementParams',
  6190. text: appId,
  6191. id: viewId
  6192. });
  6193. const {
  6194. result,
  6195. statusText,
  6196. status,
  6197. data
  6198. } = await tools_httpRequest({
  6199. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6200. method: 'GET',
  6201. headers: {
  6202. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6203. }
  6204. });
  6205. if (result === 'Success') {
  6206. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6207. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6208. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6209. logStatus.warning(i18n('changeAreaNotice'));
  6210. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6211. return {};
  6212. }
  6213. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6214. }
  6215. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6216. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6217. 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];
  6218. if (authWgToken && clanId) {
  6219. logStatus.success();
  6220. return {
  6221. authWgToken: authWgToken,
  6222. clanId: clanId,
  6223. gid: gid
  6224. };
  6225. }
  6226. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6227. return {};
  6228. }
  6229. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6230. return {};
  6231. }
  6232. logStatus.error(`${result}:${statusText}(${status})`);
  6233. return {};
  6234. } catch (error) {
  6235. throwError(error, 'Steam.likeAnnouncement');
  6236. return {};
  6237. }
  6238. }
  6239. async function _likeAnnouncement2(id) {
  6240. try {
  6241. const [ appId, viewId ] = id.split('/');
  6242. if (!(appId && viewId)) {
  6243. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6244. return false;
  6245. }
  6246. const {
  6247. authWgToken,
  6248. clanId,
  6249. gid
  6250. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6251. if (!(authWgToken && clanId)) {
  6252. return false;
  6253. }
  6254. const logStatus = scripts_echoLog({
  6255. type: 'likingAnnouncement',
  6256. text: appId,
  6257. id: viewId
  6258. });
  6259. const {
  6260. result,
  6261. statusText,
  6262. status,
  6263. data
  6264. } = await tools_httpRequest({
  6265. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6266. method: 'POST',
  6267. headers: {
  6268. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6269. Host: 'store.steampowered.com',
  6270. Origin: 'https://store.steampowered.com',
  6271. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6272. },
  6273. data: $.param({
  6274. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6275. wgauthtoken: authWgToken,
  6276. voteup: 1,
  6277. clanid: clanId,
  6278. ajax: 1
  6279. }),
  6280. dataType: 'json'
  6281. });
  6282. if (result === 'Success') {
  6283. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6284. logStatus.success();
  6285. return true;
  6286. }
  6287. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6288. return false;
  6289. }
  6290. logStatus.error(`${result}:${statusText}(${status})`);
  6291. return false;
  6292. } catch (error) {
  6293. throwError(error, 'Steam.likeAnnouncement');
  6294. return false;
  6295. }
  6296. }
  6297. async function _appid2subid2(id) {
  6298. try {
  6299. const logStatus = scripts_echoLog({
  6300. type: 'gettingSubid',
  6301. text: id
  6302. });
  6303. const {
  6304. result,
  6305. statusText,
  6306. status,
  6307. data
  6308. } = await tools_httpRequest({
  6309. url: `https://store.steampowered.com/app/${id}`,
  6310. method: 'GET',
  6311. headers: {
  6312. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6313. }
  6314. });
  6315. if (result === 'Success') {
  6316. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6317. var _data$responseText$ma15;
  6318. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6319. logStatus.warning(i18n('changeAreaNotice'));
  6320. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6321. if (!result || result === 'CN' || result === 'skip') {
  6322. return false;
  6323. }
  6324. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6325. }
  6326. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6327. if (subid) {
  6328. logStatus.success();
  6329. return subid;
  6330. }
  6331. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6332. return false;
  6333. }
  6334. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6335. return false;
  6336. }
  6337. logStatus.error(`${result}:${statusText}(${status})`);
  6338. return false;
  6339. } catch (error) {
  6340. throwError(error, 'Steam.appid2subid');
  6341. return false;
  6342. }
  6343. }
  6344. async function _getLicenses2() {
  6345. try {
  6346. const logStatus = scripts_echoLog({
  6347. text: i18n('gettingLicenses')
  6348. });
  6349. const {
  6350. result,
  6351. statusText,
  6352. status,
  6353. data
  6354. } = await tools_httpRequest({
  6355. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  6356. method: 'GET',
  6357. responseType: 'json'
  6358. });
  6359. if (result === 'Success') {
  6360. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6361. var _data$response8;
  6362. logStatus.success();
  6363. return (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.rgOwnedPackages;
  6364. }
  6365. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6366. return false;
  6367. }
  6368. logStatus.error(`${result}:${statusText}(${status})`);
  6369. return false;
  6370. } catch (error) {
  6371. throwError(error, 'Steam.getLicenses');
  6372. return false;
  6373. }
  6374. }
  6375. async function _addLicense2(id) {
  6376. try {
  6377. const [ type, ids ] = id.split('-');
  6378. if (type === 'appid') {
  6379. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6380. if (!subid) {
  6381. return false;
  6382. }
  6383. const logStatus = scripts_echoLog({
  6384. type: 'addingFreeLicense',
  6385. text: ids
  6386. });
  6387. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6388. return false;
  6389. }
  6390. const {
  6391. result,
  6392. statusText,
  6393. status,
  6394. data
  6395. } = await tools_httpRequest({
  6396. url: `https://store.steampowered.com/app/${ids}`,
  6397. method: 'GET'
  6398. });
  6399. if (result === 'Success') {
  6400. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6401. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6402. logStatus.success();
  6403. return true;
  6404. }
  6405. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6406. return false;
  6407. }
  6408. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6409. return false;
  6410. }
  6411. logStatus.error(`${result}:${statusText}(${status})`);
  6412. return false;
  6413. } else if (type === 'subid') {
  6414. if (Steam_classPrivateFieldGet(this, _area) === 'CN') {
  6415. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  6416. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6417. }
  6418. const logStatusArr = {};
  6419. const idsArr = ids.split(',');
  6420. for (const subid of idsArr) {
  6421. const logStatus = scripts_echoLog({
  6422. type: 'addingFreeLicenseSubid',
  6423. text: subid
  6424. });
  6425. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6426. return false;
  6427. }
  6428. logStatusArr[subid] = logStatus;
  6429. }
  6430. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6431. if (!licenses) {
  6432. return false;
  6433. }
  6434. for (const subid of idsArr) {
  6435. if (licenses.includes(parseInt(subid, 10))) {
  6436. logStatusArr[subid].success();
  6437. } else {
  6438. logStatusArr[subid].error();
  6439. }
  6440. }
  6441. return true;
  6442. }
  6443. return false;
  6444. } catch (error) {
  6445. throwError(error, 'Steam.addLicense');
  6446. return false;
  6447. }
  6448. }
  6449. async function _addFreeLicense2(id, logStatusPre) {
  6450. try {
  6451. const logStatus = logStatusPre || scripts_echoLog({
  6452. type: 'addingFreeLicenseSubid',
  6453. text: id
  6454. });
  6455. const {
  6456. result,
  6457. statusText,
  6458. status,
  6459. data
  6460. } = await tools_httpRequest({
  6461. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6462. method: 'POST',
  6463. headers: {
  6464. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6465. Host: 'store.steampowered.com',
  6466. Origin: 'https://store.steampowered.com',
  6467. Referer: 'https://store.steampowered.com/account/licenses/'
  6468. },
  6469. data: $.param({
  6470. action: 'add_to_cart',
  6471. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6472. subid: id
  6473. }),
  6474. dataType: 'json'
  6475. });
  6476. if (result === 'Success') {
  6477. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6478. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6479. logStatus.warning(i18n('changeAreaNotice'));
  6480. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6481. if (!result || result === 'CN') {
  6482. return false;
  6483. }
  6484. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6485. }
  6486. logStatus.success();
  6487. return true;
  6488. }
  6489. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6490. return false;
  6491. }
  6492. logStatus.error(`${result}:${statusText}(${status})`);
  6493. return false;
  6494. } catch (error) {
  6495. throwError(error, 'Steam.addFreeLicense');
  6496. return false;
  6497. }
  6498. }
  6499. async function _requestPlayTestAccess2(id) {
  6500. try {
  6501. const logStatus = scripts_echoLog({
  6502. type: 'requestingPlayTestAccess',
  6503. text: id
  6504. });
  6505. const {
  6506. result,
  6507. statusText,
  6508. status,
  6509. data
  6510. } = await tools_httpRequest({
  6511. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6512. method: 'POST',
  6513. headers: {
  6514. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6515. Host: 'store.steampowered.com',
  6516. Origin: 'https://store.steampowered.com',
  6517. Referer: `https://store.steampowered.com/app/${id}`
  6518. },
  6519. data: $.param({
  6520. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6521. }),
  6522. dataType: 'json'
  6523. });
  6524. if (result === 'Success') {
  6525. var _data$response9;
  6526. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response9 = data.response) === null || _data$response9 === void 0 ? void 0 : _data$response9.success) === 1) {
  6527. logStatus.success();
  6528. return true;
  6529. }
  6530. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6531. return false;
  6532. }
  6533. logStatus.error(`${result}:${statusText}(${status})`);
  6534. return false;
  6535. } catch (error) {
  6536. throwError(error, 'Steam.requestPlayTestAccess');
  6537. return false;
  6538. }
  6539. }
  6540. function Steam_setCache2(type, name, id) {
  6541. try {
  6542. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6543. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6544. } catch (error) {
  6545. throwError(error, 'Steam.setCache');
  6546. }
  6547. }
  6548. const social_Steam = Steam;
  6549. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6550. Website_checkPrivateRedeclaration(obj, privateSet);
  6551. privateSet.add(obj);
  6552. }
  6553. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6554. if (privateCollection.has(obj)) {
  6555. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6556. }
  6557. }
  6558. function Website_defineProperty(obj, key, value) {
  6559. if (key in obj) {
  6560. Object.defineProperty(obj, key, {
  6561. value: value,
  6562. enumerable: true,
  6563. configurable: true,
  6564. writable: true
  6565. });
  6566. } else {
  6567. obj[key] = value;
  6568. }
  6569. return obj;
  6570. }
  6571. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6572. if (!privateSet.has(receiver)) {
  6573. throw new TypeError('attempted to get private field on non-instance');
  6574. }
  6575. return fn;
  6576. }
  6577. var _bind = new WeakSet();
  6578. class Website {
  6579. constructor() {
  6580. Website_classPrivateMethodInitSpec(this, _bind);
  6581. Website_defineProperty(this, 'undoneTasks', void 0);
  6582. Website_defineProperty(this, 'socialTasks', void 0);
  6583. Website_defineProperty(this, 'giveawayId', void 0);
  6584. Website_defineProperty(this, 'socialInitialized', {
  6585. discord: false,
  6586. instagram: false,
  6587. reddit: false,
  6588. twitch: false,
  6589. twitter: false,
  6590. vk: false,
  6591. youtube: false,
  6592. steamStore: false,
  6593. steamCommunity: false
  6594. });
  6595. Website_defineProperty(this, 'initialized', false);
  6596. Website_defineProperty(this, 'social', {});
  6597. }
  6598. async initSocial(action) {
  6599. try {
  6600. const pro = [];
  6601. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6602. if (tasks.discord) {
  6603. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6604. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6605. this.social.discord = new social_Discord();
  6606. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6607. }
  6608. }
  6609. if (tasks.instagram) {
  6610. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6611. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6612. this.social.instagram = new social_Instagram();
  6613. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6614. }
  6615. }
  6616. if (tasks.reddit) {
  6617. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6618. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6619. this.social.reddit = new social_Reddit();
  6620. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6621. }
  6622. }
  6623. if (tasks.twitch) {
  6624. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6625. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6626. this.social.twitch = new social_Twitch();
  6627. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6628. }
  6629. }
  6630. if (tasks.twitter) {
  6631. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6632. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6633. this.social.twitter = new social_Twitter();
  6634. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6635. }
  6636. }
  6637. if (tasks.vk) {
  6638. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6639. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6640. this.social.vk = new social_Vk();
  6641. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6642. }
  6643. }
  6644. if (tasks.youtube) {
  6645. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6646. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6647. this.social.youtube = new Youtube();
  6648. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6649. }
  6650. }
  6651. if (tasks.steam) {
  6652. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6653. if (steamLength > 0) {
  6654. if (!this.social.steam) {
  6655. this.social.steam = new social_Steam();
  6656. }
  6657. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6658. var _tasks$steam, _tasks$steam$type;
  6659. 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;
  6660. }).reduce((total, number) => total + number, 0);
  6661. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6662. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6663. }
  6664. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6665. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6666. }
  6667. }
  6668. }
  6669. if (tasks.links && tasks.links.length > 0) {
  6670. this.social.visitLink = visitLink;
  6671. }
  6672. return await Promise.all(pro).then(result => {
  6673. let checked = true;
  6674. for (const data of result) {
  6675. if (data.result) {
  6676. this.socialInitialized[data.name] = data.result;
  6677. } else {
  6678. checked = false;
  6679. }
  6680. }
  6681. return checked;
  6682. });
  6683. } catch (error) {
  6684. throwError(error, 'Website.initSocial');
  6685. return false;
  6686. }
  6687. }
  6688. uniqueTasks(allTasks) {
  6689. const result = {};
  6690. for (const [ social, types ] of Object.entries(allTasks)) {
  6691. result[social] = {};
  6692. for (const [ type, tasks ] of Object.entries(types)) {
  6693. result[social][type] = unique(tasks);
  6694. }
  6695. }
  6696. return result;
  6697. }
  6698. async toggleTask(action) {
  6699. try {
  6700. if (!this.initialized && !this.init()) {
  6701. return false;
  6702. }
  6703. if (!await this.classifyTask(action)) {
  6704. return false;
  6705. }
  6706. if (!await this.initSocial(action)) {
  6707. return false;
  6708. }
  6709. const pro = [];
  6710. const doTask = action === 'do';
  6711. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6712. if (this.social.discord) {
  6713. pro.push(this.social.discord.toggle({
  6714. doTask: doTask,
  6715. ...tasks.discord
  6716. }));
  6717. }
  6718. if (this.social.instagram) {
  6719. pro.push(this.social.instagram.toggle({
  6720. doTask: doTask,
  6721. ...tasks.instagram
  6722. }));
  6723. }
  6724. if (this.social.reddit) {
  6725. pro.push(this.social.reddit.toggle({
  6726. doTask: doTask,
  6727. ...tasks.reddit
  6728. }));
  6729. }
  6730. if (this.social.twitch) {
  6731. pro.push(this.social.twitch.toggle({
  6732. doTask: doTask,
  6733. ...tasks.twitch
  6734. }));
  6735. }
  6736. if (this.social.twitter) {
  6737. pro.push(this.social.twitter.toggle({
  6738. doTask: doTask,
  6739. ...tasks.twitter
  6740. }));
  6741. }
  6742. if (this.social.vk) {
  6743. pro.push(this.social.vk.toggle({
  6744. doTask: doTask,
  6745. ...tasks.vk
  6746. }));
  6747. }
  6748. if (this.social.youtube) {
  6749. pro.push(this.social.youtube.toggle({
  6750. doTask: doTask,
  6751. ...tasks.youtube
  6752. }));
  6753. }
  6754. if (this.social.steam) {
  6755. pro.push(this.social.steam.toggle({
  6756. doTask: doTask,
  6757. ...tasks.steam
  6758. }));
  6759. }
  6760. if (this.social.visitLink && tasks.links && doTask) {
  6761. for (const link of tasks.links) {
  6762. pro.push(this.social.visitLink(link));
  6763. }
  6764. }
  6765. if (doTask && tasks.extra && this.extraDoTask) {
  6766. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6767. if (hasExtra) {
  6768. pro.push(this.extraDoTask(tasks.extra));
  6769. }
  6770. }
  6771. await Promise.all(pro);
  6772. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6773. return true;
  6774. } catch (error) {
  6775. throwError(error, 'Website.toggleTask');
  6776. return false;
  6777. }
  6778. }
  6779. async doTask() {
  6780. try {
  6781. return await this.toggleTask('do');
  6782. } catch (error) {
  6783. throwError(error, 'Website.doTask');
  6784. return false;
  6785. }
  6786. }
  6787. async undoTask() {
  6788. try {
  6789. return await this.toggleTask('undo');
  6790. } catch (error) {
  6791. throwError(error, 'Website.undoTask');
  6792. return false;
  6793. }
  6794. }
  6795. }
  6796. async function _bind2(name, init) {
  6797. try {
  6798. return {
  6799. name: name,
  6800. result: await init
  6801. };
  6802. } catch (error) {
  6803. throwError(error, 'Website.bind');
  6804. return {
  6805. name: name,
  6806. result: false
  6807. };
  6808. }
  6809. }
  6810. const website_Website = Website;
  6811. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6812. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6813. privateSet.add(obj);
  6814. }
  6815. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6816. if (privateCollection.has(obj)) {
  6817. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6818. }
  6819. }
  6820. function FreeAnyWhere_defineProperty(obj, key, value) {
  6821. if (key in obj) {
  6822. Object.defineProperty(obj, key, {
  6823. value: value,
  6824. enumerable: true,
  6825. configurable: true,
  6826. writable: true
  6827. });
  6828. } else {
  6829. obj[key] = value;
  6830. }
  6831. return obj;
  6832. }
  6833. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6834. if (!privateSet.has(receiver)) {
  6835. throw new TypeError('attempted to get private field on non-instance');
  6836. }
  6837. return fn;
  6838. }
  6839. const FreeAnyWhere_defaultTasksTemplate = {
  6840. steam: {
  6841. groupLinks: [],
  6842. wishlistLinks: [],
  6843. curatorLinks: [],
  6844. followLinks: []
  6845. },
  6846. vk: {
  6847. nameLinks: []
  6848. }
  6849. };
  6850. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6851. var _getGiveawayId = new WeakSet();
  6852. var _verify = new WeakSet();
  6853. class FreeAnyWhere extends website_Website {
  6854. constructor() {
  6855. super(...arguments);
  6856. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6857. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6858. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6859. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6860. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6861. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6862. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6863. }
  6864. static test() {
  6865. return window.location.host === 'freeanywhere.net';
  6866. }
  6867. init() {
  6868. try {
  6869. const logStatus = scripts_echoLog({
  6870. text: i18n('initing')
  6871. });
  6872. if ($('a[href="#/login"]').length > 0) {
  6873. window.open('/#/login', '_self');
  6874. logStatus.warning(i18n('needLogin'));
  6875. return false;
  6876. }
  6877. if (window.location.href.includes('/login')) {
  6878. logStatus.warning(i18n('needLogin'));
  6879. return false;
  6880. }
  6881. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6882. var _window$location$href;
  6883. 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];
  6884. if (!id) {
  6885. logStatus.error(i18n('getFailed', 'Id'));
  6886. return false;
  6887. }
  6888. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6889. }
  6890. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6891. return false;
  6892. }
  6893. this.initialized = true;
  6894. logStatus.success();
  6895. return true;
  6896. } catch (error) {
  6897. throwError(error, 'Freeanywhere.init');
  6898. return false;
  6899. }
  6900. }
  6901. async classifyTask(action) {
  6902. try {
  6903. const logStatus = scripts_echoLog({
  6904. text: i18n('getTasksInfo')
  6905. });
  6906. if (action === 'undo') {
  6907. var _GM_getValue;
  6908. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6909. }
  6910. const {
  6911. result,
  6912. statusText,
  6913. status,
  6914. data
  6915. } = await tools_httpRequest({
  6916. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6917. method: 'GET',
  6918. headers: {
  6919. authorization: `Token ${window.localStorage.getItem('token')}`,
  6920. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6921. },
  6922. responseType: 'json'
  6923. });
  6924. if (result === 'Success') {
  6925. var _data$response;
  6926. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6927. if (tasks) {
  6928. if (action === 'verify') {
  6929. this.tasks = [];
  6930. }
  6931. for (const task of tasks) {
  6932. const type = task.challenge;
  6933. const social = task.challenge_provider;
  6934. const taskInfo = {
  6935. id: task.id,
  6936. title: task.title
  6937. };
  6938. if (action === 'verify' && !task.is_success) {
  6939. this.tasks.push(taskInfo);
  6940. continue;
  6941. }
  6942. switch (social) {
  6943. case 'steam':
  6944. taskInfo.social = 'steam';
  6945. switch (type) {
  6946. case 'WL':
  6947. if (action === 'undo') {
  6948. this.socialTasks.steam.wishlistLinks.push(task.link);
  6949. }
  6950. if (action === 'do' && !task.is_success) {
  6951. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6952. }
  6953. break;
  6954.  
  6955. case 'JTG':
  6956. if (action === 'undo') {
  6957. this.socialTasks.steam.groupLinks.push(task.link);
  6958. }
  6959. if (action === 'do' && !task.is_success) {
  6960. this.undoneTasks.steam.groupLinks.push(task.link);
  6961. }
  6962. break;
  6963.  
  6964. case 'STC':
  6965. if (action === 'undo') {
  6966. this.socialTasks.steam.curatorLinks.push(task.link);
  6967. }
  6968. if (action === 'do' && !task.is_success) {
  6969. this.undoneTasks.steam.curatorLinks.push(task.link);
  6970. }
  6971. break;
  6972.  
  6973. case 'GF':
  6974. if (action === 'undo') {
  6975. this.socialTasks.steam.followLinks.push(task.link);
  6976. }
  6977. if (action === 'do' && !task.is_success) {
  6978. this.undoneTasks.steam.followLinks.push(task.link);
  6979. }
  6980. break;
  6981. }
  6982. break;
  6983.  
  6984. case 'vk-oauth2':
  6985. if (action === 'undo') {
  6986. this.socialTasks.vk.nameLinks.push(task.link);
  6987. }
  6988. if (action === 'do' && !task.is_success) {
  6989. this.undoneTasks.vk.nameLinks.push(task.link);
  6990. }
  6991. break;
  6992.  
  6993. case 'website':
  6994. break;
  6995.  
  6996. default:
  6997. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6998. break;
  6999. }
  7000. }
  7001. logStatus.success();
  7002. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7003. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7004. if (window.DEBUG) {
  7005. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7006. }
  7007. GM_setValue(`fawTasks-${this.giveawayId}`, {
  7008. tasks: this.socialTasks,
  7009. time: new Date().getTime()
  7010. });
  7011. return true;
  7012. }
  7013. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7014. return false;
  7015. }
  7016. logStatus.error(`${result}:${statusText}(${status})`);
  7017. return false;
  7018. } catch (error) {
  7019. throwError(error, 'Freeanywhere.classifyTask');
  7020. return false;
  7021. }
  7022. }
  7023. async verifyTask() {
  7024. try {
  7025. if (!this.initialized && !this.init()) {
  7026. return false;
  7027. }
  7028. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7029. return false;
  7030. }
  7031. const pro = [];
  7032. for (const task of this.tasks) {
  7033. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  7034. await delay(1e3);
  7035. }
  7036. await Promise.all(pro);
  7037. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7038. return !!await this.getKey(true);
  7039. } catch (error) {
  7040. throwError(error, 'Freeanywhere.verifyTask');
  7041. return false;
  7042. }
  7043. }
  7044. async getKey(initialized) {
  7045. try {
  7046. if (!initialized && !this.initialized && !this.init()) {
  7047. return false;
  7048. }
  7049. const logStatus = scripts_echoLog({
  7050. text: i18n('gettingKey')
  7051. });
  7052. const {
  7053. result,
  7054. statusText,
  7055. status,
  7056. data
  7057. } = await tools_httpRequest({
  7058. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7059. method: 'GET',
  7060. dataType: 'json',
  7061. headers: {
  7062. authorization: `Token ${window.localStorage.getItem('token')}`
  7063. }
  7064. });
  7065. if (result === 'Success') {
  7066. var _data$response2;
  7067. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7068. logStatus.success();
  7069. scripts_echoLog({}).success(data.response.reward);
  7070. return data.response.reward;
  7071. }
  7072. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7073. return false;
  7074. }
  7075. logStatus.error(`${result}:${statusText}(${status})`);
  7076. return false;
  7077. } catch (error) {
  7078. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7079. return false;
  7080. }
  7081. }
  7082. }
  7083. function _getGiveawayId2() {
  7084. try {
  7085. var _window$location$href2;
  7086. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7087. if (giveawayId) {
  7088. this.giveawayId = giveawayId;
  7089. return true;
  7090. }
  7091. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7092. return false;
  7093. } catch (error) {
  7094. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7095. }
  7096. }
  7097. async function _verify2(task) {
  7098. try {
  7099. const logStatus = scripts_echoLog({
  7100. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7101. });
  7102. const {
  7103. result,
  7104. statusText,
  7105. status,
  7106. data
  7107. } = await tools_httpRequest({
  7108. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7109. method: 'GET',
  7110. dataType: 'json',
  7111. headers: {
  7112. authorization: `Token ${window.localStorage.getItem('token')}`,
  7113. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7114. }
  7115. });
  7116. if (result === 'Success') {
  7117. var _data$response3;
  7118. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7119. logStatus.success();
  7120. return true;
  7121. }
  7122. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7123. return false;
  7124. }
  7125. logStatus.error(`${result}:${statusText}(${status})`);
  7126. return false;
  7127. } catch (error) {
  7128. throwError(error, 'Freeanywhere.verify');
  7129. return false;
  7130. }
  7131. }
  7132. const website_FreeAnyWhere = FreeAnyWhere;
  7133. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7134. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7135. privateSet.add(obj);
  7136. }
  7137. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7138. if (privateCollection.has(obj)) {
  7139. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7140. }
  7141. }
  7142. function GiveawaySu_defineProperty(obj, key, value) {
  7143. if (key in obj) {
  7144. Object.defineProperty(obj, key, {
  7145. value: value,
  7146. enumerable: true,
  7147. configurable: true,
  7148. writable: true
  7149. });
  7150. } else {
  7151. obj[key] = value;
  7152. }
  7153. return obj;
  7154. }
  7155. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7156. if (!privateSet.has(receiver)) {
  7157. throw new TypeError('attempted to get private field on non-instance');
  7158. }
  7159. return fn;
  7160. }
  7161. const GiveawaySu_defaultTasks = {
  7162. steam: {
  7163. groupLinks: [],
  7164. wishlistLinks: [],
  7165. curatorLinks: [],
  7166. curatorLikeLinks: [],
  7167. followLinks: [],
  7168. forumLinks: [],
  7169. announcementLinks: [],
  7170. workshopVoteLinks: [],
  7171. playtestLinks: []
  7172. },
  7173. discord: {
  7174. serverLinks: []
  7175. },
  7176. instagram: {
  7177. userLinks: []
  7178. },
  7179. vk: {
  7180. nameLinks: []
  7181. },
  7182. twitch: {
  7183. channelLinks: []
  7184. },
  7185. reddit: {
  7186. redditLinks: []
  7187. },
  7188. youtube: {
  7189. channelLinks: [],
  7190. likeLinks: []
  7191. }
  7192. };
  7193. var _checkLogin = new WeakSet();
  7194. var _checkLeftKey = new WeakSet();
  7195. var GiveawaySu_getGiveawayId = new WeakSet();
  7196. class GiveawaySu extends website_Website {
  7197. constructor() {
  7198. super(...arguments);
  7199. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7200. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  7201. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7202. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7203. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7204. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7205. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7206. }
  7207. static test() {
  7208. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7209. }
  7210. async after() {
  7211. try {
  7212. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7213. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7214. }
  7215. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7216. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7217. }
  7218. scripts_echoLog({}).warning(i18n('gsNotice'));
  7219. } catch (error) {
  7220. throwError(error, 'Giveawaysu.after');
  7221. }
  7222. }
  7223. init() {
  7224. try {
  7225. const logStatus = scripts_echoLog({
  7226. text: i18n('initing')
  7227. });
  7228. if ($('a.steam-login').length > 0) {
  7229. window.open('/steam/redirect', '_self');
  7230. logStatus.warning(i18n('needLogin'));
  7231. return false;
  7232. }
  7233. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7234. return false;
  7235. }
  7236. this.initialized = true;
  7237. logStatus.success();
  7238. return true;
  7239. } catch (error) {
  7240. throwError(error, 'Giveawaysu.init');
  7241. return false;
  7242. }
  7243. }
  7244. async classifyTask(action) {
  7245. try {
  7246. const logStatus = scripts_echoLog({
  7247. text: i18n('getTasksInfo')
  7248. });
  7249. if (action === 'undo') {
  7250. var _GM_getValue;
  7251. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7252. return true;
  7253. }
  7254. const pro = [];
  7255. const tasks = $('#actions tr');
  7256. if ($('div.bind-discord').is(':visible')) {
  7257. $('div.bind-discord a')[0].click();
  7258. }
  7259. if ($('div.bind-twitch').is(':visible')) {
  7260. $('div.bind-twitch a')[0].click();
  7261. }
  7262. for (const task of tasks) {
  7263. pro.push(new Promise(resolve => {
  7264. const td = $(task).find('td:not(".hidden")');
  7265. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7266. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7267. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7268. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7269. const taskName = taskDes.text().trim();
  7270. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7271. return resolve(true);
  7272. }
  7273. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7274. if (!taskLink) {
  7275. return resolve(false);
  7276. }
  7277. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7278. this.undoneTasks.steam.groupLinks.push(taskLink);
  7279. } else if (/like.*announcement/gi.test(taskName)) {
  7280. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7281. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7282. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7283. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7284. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7285. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7286. this.undoneTasks.steam.forumLinks.push(taskLink);
  7287. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7288. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7289. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7290. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7291. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7292. this.undoneTasks.discord.serverLinks.push(taskLink);
  7293. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7294. this.undoneTasks.instagram.userLinks.push(taskLink);
  7295. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7296. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7297. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7298. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7299. } else if (/watch.*art/gim.test(taskName)) {
  7300. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7301. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7302. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7303. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7304. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7305. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7306. this.undoneTasks.vk.nameLinks.push(taskLink);
  7307. } else {
  7308. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7309. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7310. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7311. }
  7312. if (/follow.*button/gim.test(taskName)) {
  7313. this.undoneTasks.steam.followLinks.push(taskLink);
  7314. }
  7315. }
  7316. }
  7317. resolve(true);
  7318. }).catch(error => {
  7319. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7320. return false;
  7321. });
  7322. }));
  7323. }
  7324. await Promise.all(pro);
  7325. logStatus.success();
  7326. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7327. this.socialTasks = this.undoneTasks;
  7328. if (window.DEBUG) {
  7329. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7330. }
  7331. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7332. tasks: this.socialTasks,
  7333. time: new Date().getTime()
  7334. });
  7335. return true;
  7336. } catch (error) {
  7337. throwError(error, 'Giveawaysu.classifyTask');
  7338. return false;
  7339. }
  7340. }
  7341. }
  7342. function _checkLogin2() {
  7343. try {
  7344. if (!globalOptions.other.checkLogin) {
  7345. return true;
  7346. }
  7347. if ($('a.steam-login').length > 0) {
  7348. window.open('/steam/redirect', '_self');
  7349. }
  7350. return true;
  7351. } catch (error) {
  7352. throwError(error, 'Giveawaysu.checkLogin');
  7353. return false;
  7354. }
  7355. }
  7356. async function _checkLeftKey2() {
  7357. try {
  7358. if (!globalOptions.other.checkLeftKey) {
  7359. return true;
  7360. }
  7361. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7362. await external_Swal_default().fire({
  7363. icon: 'warning',
  7364. title: i18n('notice'),
  7365. text: i18n('noKeysLeft'),
  7366. confirmButtonText: i18n('confirm'),
  7367. cancelButtonText: i18n('cancel'),
  7368. showCancelButton: true
  7369. }).then(_ref => {
  7370. let {
  7371. value
  7372. } = _ref;
  7373. if (value) {
  7374. window.close();
  7375. }
  7376. });
  7377. }
  7378. return true;
  7379. } catch (error) {
  7380. throwError(error, 'Giveawaysu.checkLeftKey');
  7381. return false;
  7382. }
  7383. }
  7384. function GiveawaySu_getGiveawayId2() {
  7385. var _window$location$href;
  7386. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7387. if (giveawayId) {
  7388. this.giveawayId = giveawayId;
  7389. return true;
  7390. }
  7391. scripts_echoLog({
  7392. text: i18n('getFailed', 'GiveawayId')
  7393. });
  7394. return false;
  7395. }
  7396. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7397. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7398. privateSet.add(obj);
  7399. }
  7400. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7401. if (privateCollection.has(obj)) {
  7402. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7403. }
  7404. }
  7405. function Indiedb_defineProperty(obj, key, value) {
  7406. if (key in obj) {
  7407. Object.defineProperty(obj, key, {
  7408. value: value,
  7409. enumerable: true,
  7410. configurable: true,
  7411. writable: true
  7412. });
  7413. } else {
  7414. obj[key] = value;
  7415. }
  7416. return obj;
  7417. }
  7418. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7419. if (!privateSet.has(receiver)) {
  7420. throw new TypeError('attempted to get private field on non-instance');
  7421. }
  7422. return fn;
  7423. }
  7424. var _join = new WeakSet();
  7425. var _do = new WeakSet();
  7426. var Indiedb_checkLogin = new WeakSet();
  7427. var Indiedb_checkLeftKey = new WeakSet();
  7428. class Indiedb {
  7429. constructor() {
  7430. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7431. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7432. Indiedb_classPrivateMethodInitSpec(this, _do);
  7433. Indiedb_classPrivateMethodInitSpec(this, _join);
  7434. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7435. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7436. }
  7437. static test() {
  7438. return window.location.host === 'www.indiedb.com';
  7439. }
  7440. async after() {
  7441. try {
  7442. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7443. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7444. }
  7445. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7446. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7447. }
  7448. } catch (error) {
  7449. throwError(error, 'Indiedb.after');
  7450. }
  7451. }
  7452. async doTask() {
  7453. try {
  7454. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7455. return false;
  7456. }
  7457. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7458. } catch (error) {
  7459. throwError(error, 'Indiedb.doTask');
  7460. return false;
  7461. }
  7462. }
  7463. }
  7464. async function _join2() {
  7465. try {
  7466. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7467. scripts_echoLog({}).error(i18n('needLogin'));
  7468. return false;
  7469. }
  7470. const currentoption = $('a.buttonenter.buttongiveaway');
  7471. if (/join giveaway/gim.test(currentoption.text())) {
  7472. const logStatus = scripts_echoLog({
  7473. text: `${i18n('joiningGiveaway')}...`
  7474. });
  7475. const {
  7476. result,
  7477. statusText,
  7478. status,
  7479. data
  7480. } = await tools_httpRequest({
  7481. url: currentoption.attr('href'),
  7482. method: 'POST',
  7483. data: 'ajax=t',
  7484. dataType: 'json',
  7485. headers: {
  7486. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7487. accept: 'application/json, text/javascript, */*; q=0.01',
  7488. origin: window.location.origin
  7489. }
  7490. });
  7491. if (result === 'Success') {
  7492. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7493. var _data$response, _data$response4, _data$response5;
  7494. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7495. var _data$response2, _data$response3;
  7496. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7497. $('#giveawaysjoined').slideDown();
  7498. $('#giveawaysrecommend').slideDown();
  7499. 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}` : ''}`);
  7500. return true;
  7501. }
  7502. 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}` : ''}`);
  7503. return false;
  7504. }
  7505. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7506. return false;
  7507. }
  7508. logStatus.error(`${result}:${statusText}(${status})`);
  7509. return false;
  7510. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7511. return true;
  7512. }
  7513. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7514. return false;
  7515. } catch (error) {
  7516. throwError(error, 'Indiedb.init');
  7517. return false;
  7518. }
  7519. }
  7520. async function _do2() {
  7521. try {
  7522. const id = $('script').map((index, script) => {
  7523. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7524. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7525. 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] ];
  7526. }
  7527. return null;
  7528. });
  7529. if (id.length === 2) {
  7530. const pro = [];
  7531. const tasks = $('#giveawaysjoined a[class*=promo]');
  7532. for (const task of tasks) {
  7533. const promo = $(task);
  7534. if (!promo.hasClass('buttonentered')) {
  7535. const status = scripts_echoLog({
  7536. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7537. });
  7538. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7539. let text = '';
  7540. if (promo.hasClass('facebookpromo')) {
  7541. text = 'facebookpromo';
  7542. } else if (promo.hasClass('twitterpromo')) {
  7543. text = 'twitterpromo';
  7544. } else {
  7545. text = 'visitpromo';
  7546. }
  7547. pro.push(new Promise(resolve => {
  7548. $.ajax({
  7549. type: 'POST',
  7550. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7551. timeout: 6e4,
  7552. dataType: 'json',
  7553. data: {
  7554. ajax: 't'
  7555. },
  7556. error(response, error, exception) {
  7557. if (window.DEBUG) {
  7558. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7559. response: response,
  7560. error: error,
  7561. exception: exception
  7562. });
  7563. }
  7564. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7565. resolve(true);
  7566. },
  7567. success(response) {
  7568. if (response.success) {
  7569. status.success(`Success:${response.text}`);
  7570. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7571. resolve(true);
  7572. } else {
  7573. status.error(`Error:${response.text}`);
  7574. resolve(true);
  7575. }
  7576. }
  7577. });
  7578. }));
  7579. } else if (promo.hasClass('emailoptinpromo')) {
  7580. pro.push(new Promise(resolve => {
  7581. $.ajax({
  7582. type: 'POST',
  7583. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7584. timeout: 6e4,
  7585. dataType: 'json',
  7586. data: {
  7587. ajax: 't',
  7588. emailsystoggle: 4
  7589. },
  7590. error(response, error, exception) {
  7591. if (window.DEBUG) {
  7592. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7593. response: response,
  7594. error: error,
  7595. exception: exception
  7596. });
  7597. }
  7598. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7599. resolve(true);
  7600. },
  7601. success(response) {
  7602. if (response.success) {
  7603. status.success(`Success:${response.text}`);
  7604. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7605. resolve(true);
  7606. } else {
  7607. status.error(`Error:${response.text}`);
  7608. resolve(true);
  7609. }
  7610. }
  7611. });
  7612. }));
  7613. } else if (promo.hasClass('watchingpromo')) {
  7614. pro.push(new Promise(resolve => {
  7615. var _promo$attr;
  7616. const data = getUrlQuery(promo.attr('href'));
  7617. data.ajax = 't';
  7618. $.ajax({
  7619. type: 'POST',
  7620. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7621. timeout: 6e4,
  7622. dataType: 'json',
  7623. data: data,
  7624. error(response, error, exception) {
  7625. if (window.DEBUG) {
  7626. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7627. response: response,
  7628. error: error,
  7629. exception: exception
  7630. });
  7631. }
  7632. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7633. resolve(true);
  7634. },
  7635. success(response) {
  7636. if (response.success) {
  7637. status.success(`Success:${response.text}`);
  7638. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7639. resolve(true);
  7640. } else {
  7641. status.error(`Error:${response.text}`);
  7642. resolve(true);
  7643. }
  7644. }
  7645. });
  7646. }));
  7647. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7648. pro.push(new Promise(resolve => {
  7649. $.ajax({
  7650. type: 'POST',
  7651. url: urlPath(promo.attr('href')),
  7652. timeout: 6e4,
  7653. dataType: 'json',
  7654. data: {
  7655. ajax: 't'
  7656. },
  7657. error(response, error, exception) {
  7658. if (window.DEBUG) {
  7659. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7660. response: response,
  7661. error: error,
  7662. exception: exception
  7663. });
  7664. }
  7665. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7666. resolve(true);
  7667. },
  7668. success(response) {
  7669. if (response.success) {
  7670. status.success(`Success:${response.text}`);
  7671. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7672. resolve(true);
  7673. } else {
  7674. status.error(`Error:${response.text}`);
  7675. resolve(true);
  7676. }
  7677. }
  7678. });
  7679. }));
  7680. } else {
  7681. status.error(`Error:${i18n('unKnownTaskType')}`);
  7682. }
  7683. }
  7684. }
  7685. await Promise.all(pro);
  7686. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7687. return true;
  7688. }
  7689. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7690. return false;
  7691. } catch (error) {
  7692. throwError(error, 'Indiedb.classifyTask');
  7693. return false;
  7694. }
  7695. }
  7696. function Indiedb_checkLogin2() {
  7697. try {
  7698. if (!globalOptions.other.checkLogin) {
  7699. return true;
  7700. }
  7701. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7702. window.open('/members/login', '_self');
  7703. }
  7704. return true;
  7705. } catch (error) {
  7706. throwError(error, 'Indiedb.checkLogin');
  7707. return false;
  7708. }
  7709. }
  7710. async function Indiedb_checkLeftKey2() {
  7711. try {
  7712. if (!globalOptions.other.checkLeftKey) {
  7713. return true;
  7714. }
  7715. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7716. await external_Swal_default().fire({
  7717. icon: 'warning',
  7718. title: i18n('notice'),
  7719. text: i18n('giveawayEnded'),
  7720. confirmButtonText: i18n('confirm'),
  7721. cancelButtonText: i18n('cancel'),
  7722. showCancelButton: true
  7723. }).then(_ref => {
  7724. let {
  7725. value
  7726. } = _ref;
  7727. if (value) {
  7728. window.close();
  7729. }
  7730. });
  7731. }
  7732. return true;
  7733. } catch (error) {
  7734. throwError(error, 'Indiedb.checkLeftKey');
  7735. return false;
  7736. }
  7737. }
  7738. const website_Indiedb = Indiedb;
  7739. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7740. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7741. privateSet.add(obj);
  7742. }
  7743. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7744. if (privateCollection.has(obj)) {
  7745. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7746. }
  7747. }
  7748. function Keyhub_defineProperty(obj, key, value) {
  7749. if (key in obj) {
  7750. Object.defineProperty(obj, key, {
  7751. value: value,
  7752. enumerable: true,
  7753. configurable: true,
  7754. writable: true
  7755. });
  7756. } else {
  7757. obj[key] = value;
  7758. }
  7759. return obj;
  7760. }
  7761. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7762. if (!privateSet.has(receiver)) {
  7763. throw new TypeError('attempted to get private field on non-instance');
  7764. }
  7765. return fn;
  7766. }
  7767. const Keyhub_defaultTasksTemplate = {
  7768. steam: {
  7769. groupLinks: [],
  7770. officialGroupLinks: [],
  7771. wishlistLinks: [],
  7772. curatorLinks: []
  7773. },
  7774. discord: {
  7775. serverLinks: []
  7776. },
  7777. links: []
  7778. };
  7779. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7780. var Keyhub_getGiveawayId = new WeakSet();
  7781. var Keyhub_checkLeftKey = new WeakSet();
  7782. var Keyhub_checkLogin = new WeakSet();
  7783. class Keyhub extends website_Website {
  7784. constructor() {
  7785. super(...arguments);
  7786. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7787. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7788. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7789. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7790. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7791. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7792. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7793. }
  7794. static test() {
  7795. return window.location.host === 'key-hub.eu';
  7796. }
  7797. async after() {
  7798. try {
  7799. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7800. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7801. }
  7802. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7803. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7804. }
  7805. $('.NSFW').hide();
  7806. } catch (error) {
  7807. throwError(error, 'Keyhub.after');
  7808. }
  7809. }
  7810. init() {
  7811. try {
  7812. const logStatus = scripts_echoLog({
  7813. text: i18n('initing')
  7814. });
  7815. if ($('a[href*="/connect/steam"]').length > 0) {
  7816. window.open('/connect/steam', '_self');
  7817. logStatus.warning(i18n('needLogin'));
  7818. return false;
  7819. }
  7820. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7821. return false;
  7822. }
  7823. $('#VPNoverlay').hide();
  7824. $('#mainArticleSection').show();
  7825. this.initialized = true;
  7826. logStatus.success();
  7827. return true;
  7828. } catch (error) {
  7829. throwError(error, 'Keyhub.init');
  7830. return false;
  7831. }
  7832. }
  7833. async classifyTask(action) {
  7834. try {
  7835. const logStatus = scripts_echoLog({
  7836. text: i18n('getTasksInfo')
  7837. });
  7838. if (action === 'undo') {
  7839. var _GM_getValue;
  7840. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7841. }
  7842. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7843. for (const task of tasks) {
  7844. let link = $(task).attr('href');
  7845. const taskDes = $(task).text().trim();
  7846. if (!link) {
  7847. continue;
  7848. }
  7849. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7850. link = await getRedirectLink(link) || link;
  7851. }
  7852. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7853. window.open(link, '_blank');
  7854. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7855. if (action === 'undo') {
  7856. this.socialTasks.steam.groupLinks.push(link);
  7857. }
  7858. if (action === 'do') {
  7859. this.undoneTasks.steam.groupLinks.push(link);
  7860. }
  7861. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7862. if (action === 'undo') {
  7863. this.socialTasks.steam.officialGroupLinks.push(link);
  7864. }
  7865. if (action === 'do') {
  7866. this.undoneTasks.steam.officialGroupLinks.push(link);
  7867. }
  7868. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7869. if (action === 'undo') {
  7870. this.socialTasks.steam.wishlistLinks.push(link);
  7871. }
  7872. if (action === 'do') {
  7873. this.undoneTasks.steam.wishlistLinks.push(link);
  7874. }
  7875. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7876. if (action === 'undo') {
  7877. this.socialTasks.steam.curatorLinks.push(link);
  7878. }
  7879. if (action === 'do') {
  7880. this.undoneTasks.steam.curatorLinks.push(link);
  7881. }
  7882. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7883. if (action === 'undo') {
  7884. this.socialTasks.discord.serverLinks.push(link);
  7885. }
  7886. if (action === 'do') {
  7887. this.undoneTasks.discord.serverLinks.push(link);
  7888. }
  7889. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link) || /^https?:\/\/www\.facebook\.com\/.*/.test(link)) {} else {
  7890. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7891. }
  7892. }
  7893. logStatus.success();
  7894. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7895. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7896. if (window.DEBUG) {
  7897. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7898. }
  7899. GM_setValue(`khTasks-${this.giveawayId}`, {
  7900. tasks: this.socialTasks,
  7901. time: new Date().getTime()
  7902. });
  7903. return true;
  7904. } catch (error) {
  7905. throwError(error, 'Keyhub.classifyTask');
  7906. return false;
  7907. }
  7908. }
  7909. verifyTask() {
  7910. try {
  7911. scripts_echoLog({
  7912. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7913. });
  7914. $.get(window.location.href, res => {
  7915. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7916. });
  7917. } catch (error) {
  7918. throwError(error, 'keyhub.verifyTask');
  7919. }
  7920. }
  7921. }
  7922. function Keyhub_getGiveawayId2() {
  7923. try {
  7924. var _window$location$href;
  7925. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7926. if (giveawayId) {
  7927. this.giveawayId = giveawayId;
  7928. return true;
  7929. }
  7930. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7931. return false;
  7932. } catch (error) {
  7933. throwError(error, 'Keyhub.getGiveawayId');
  7934. return false;
  7935. }
  7936. }
  7937. async function Keyhub_checkLeftKey2() {
  7938. try {
  7939. if (!globalOptions.other.checkLeftKey) {
  7940. return true;
  7941. }
  7942. const leftKey = $('#keysleft').text().trim();
  7943. if (leftKey === '0') {
  7944. await external_Swal_default().fire({
  7945. icon: 'warning',
  7946. title: i18n('notice'),
  7947. text: i18n('noKeysLeft'),
  7948. confirmButtonText: i18n('confirm'),
  7949. cancelButtonText: i18n('cancel'),
  7950. showCancelButton: true
  7951. }).then(_ref => {
  7952. let {
  7953. value
  7954. } = _ref;
  7955. if (value) {
  7956. window.close();
  7957. }
  7958. });
  7959. }
  7960. return true;
  7961. } catch (error) {
  7962. throwError(error, 'Keyhub.checkLeftKey');
  7963. return false;
  7964. }
  7965. }
  7966. function Keyhub_checkLogin2() {
  7967. try {
  7968. if (!globalOptions.other.checkLogin) {
  7969. return true;
  7970. }
  7971. if ($('a[href*="/connect/steam"]').length > 0) {
  7972. window.open('/connect/steam', '_self');
  7973. }
  7974. return true;
  7975. } catch (error) {
  7976. throwError(error, 'Keyhub.checkLogin');
  7977. return false;
  7978. }
  7979. }
  7980. const website_Keyhub = Keyhub;
  7981. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7982. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7983. privateSet.add(obj);
  7984. }
  7985. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7986. if (privateCollection.has(obj)) {
  7987. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7988. }
  7989. }
  7990. function Givekey_defineProperty(obj, key, value) {
  7991. if (key in obj) {
  7992. Object.defineProperty(obj, key, {
  7993. value: value,
  7994. enumerable: true,
  7995. configurable: true,
  7996. writable: true
  7997. });
  7998. } else {
  7999. obj[key] = value;
  8000. }
  8001. return obj;
  8002. }
  8003. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  8004. if (!privateSet.has(receiver)) {
  8005. throw new TypeError('attempted to get private field on non-instance');
  8006. }
  8007. return fn;
  8008. }
  8009. const Givekey_defaultTasksTemplate = {
  8010. steam: {
  8011. groupLinks: [],
  8012. wishlistLinks: [],
  8013. curatorLinks: [],
  8014. curatorLikeLinks: []
  8015. },
  8016. twitter: {
  8017. userLinks: []
  8018. },
  8019. vk: {
  8020. nameLinks: []
  8021. },
  8022. discord: {
  8023. serverLinks: []
  8024. }
  8025. };
  8026. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  8027. var Givekey_verify = new WeakSet();
  8028. var Givekey_getGiveawayId = new WeakSet();
  8029. var Givekey_checkLeftKey = new WeakSet();
  8030. class Givekey extends website_Website {
  8031. constructor() {
  8032. super(...arguments);
  8033. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  8034. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  8035. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  8036. Givekey_defineProperty(this, 'name', 'Givekey');
  8037. Givekey_defineProperty(this, 'tasks', []);
  8038. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  8039. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  8040. Givekey_defineProperty(this, 'userId', void 0);
  8041. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8042. }
  8043. static test() {
  8044. return window.location.host === 'givekey.ru';
  8045. }
  8046. async after() {
  8047. try {
  8048. await new Promise(resolve => {
  8049. const checker = setInterval(() => {
  8050. if ($('#navbarDropdown').length > 0) {
  8051. clearInterval(checker);
  8052. resolve(true);
  8053. }
  8054. });
  8055. });
  8056. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8057. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8058. }
  8059. } catch (error) {
  8060. throwError(error, 'Givekey.after');
  8061. return false;
  8062. }
  8063. }
  8064. init() {
  8065. try {
  8066. const logStatus = scripts_echoLog({
  8067. text: i18n('initing')
  8068. });
  8069. if ($('a[href*="/auth/steam"]').length > 0) {
  8070. window.open('/auth/steam', '_self');
  8071. logStatus.warning(i18n('needLogin'));
  8072. return false;
  8073. }
  8074. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8075. return false;
  8076. }
  8077. const userId = $('meta[name="user-id"]').attr('content');
  8078. if (!userId) {
  8079. logStatus.error(i18n('getFailed', i18n('userId')));
  8080. return false;
  8081. }
  8082. this.userId = userId;
  8083. this.initialized = true;
  8084. logStatus.success();
  8085. return true;
  8086. } catch (error) {
  8087. throwError(error, 'Givekey.init');
  8088. return false;
  8089. }
  8090. }
  8091. async classifyTask(action) {
  8092. try {
  8093. const logStatus = scripts_echoLog({
  8094. text: i18n('getTasksInfo')
  8095. });
  8096. if (action === 'undo') {
  8097. var _GM_getValue;
  8098. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8099. }
  8100. const tasks = $('.card-body:has("button") .row');
  8101. for (const task of tasks) {
  8102. const taskEle = $(task);
  8103. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8104. if (isSuccess && action !== 'undo') {
  8105. continue;
  8106. }
  8107. const checkButton = taskEle.find('#task_check');
  8108. const taskId = checkButton.attr('data-id');
  8109. if (taskId) {
  8110. this.tasks.push(taskId);
  8111. }
  8112. if (action === 'verify') {
  8113. continue;
  8114. }
  8115. let href = taskEle.find('a').attr('href') || null;
  8116. const text = taskEle.find('a').text().trim();
  8117. const icon = taskEle.find('i');
  8118. if (!href || !text) {
  8119. continue;
  8120. }
  8121. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8122. href = await getRedirectLink(href);
  8123. }
  8124. if (!href) {
  8125. continue;
  8126. }
  8127. if (/^https?:\/\/vk\.com\//.test(href)) {
  8128. this.socialTasks.vk.nameLinks.push(href);
  8129. if (action === 'do' && !isSuccess) {
  8130. this.undoneTasks.vk.nameLinks.push(href);
  8131. }
  8132. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8133. this.socialTasks.steam.groupLinks.push(href);
  8134. if (action === 'do' && !isSuccess) {
  8135. this.undoneTasks.steam.groupLinks.push(href);
  8136. }
  8137. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8138. this.socialTasks.steam.wishlistLinks.push(href);
  8139. if (action === 'do' && !isSuccess) {
  8140. this.undoneTasks.steam.wishlistLinks.push(href);
  8141. }
  8142. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8143. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8144. this.socialTasks.steam.curatorLinks.push(href);
  8145. if (action === 'do' && !isSuccess) {
  8146. this.undoneTasks.steam.curatorLinks.push(href);
  8147. }
  8148. } else {
  8149. this.socialTasks.steam.curatorLikeLinks.push(href);
  8150. if (action === 'do' && !isSuccess) {
  8151. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8152. }
  8153. }
  8154. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8155. this.socialTasks.twitter.userLinks.push(href);
  8156. if (action === 'do' && !isSuccess) {
  8157. this.undoneTasks.twitter.userLinks.push(href);
  8158. }
  8159. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8160. this.socialTasks.discord.serverLinks.push(href);
  8161. if (action === 'do' && !isSuccess) {
  8162. this.undoneTasks.discord.serverLinks.push(href);
  8163. }
  8164. } else {
  8165. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8166. }
  8167. }
  8168. logStatus.success();
  8169. this.tasks = unique(this.tasks);
  8170. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8171. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8172. if (window.DEBUG) {
  8173. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8174. }
  8175. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8176. tasks: this.socialTasks,
  8177. time: new Date().getTime()
  8178. });
  8179. return true;
  8180. } catch (error) {
  8181. throwError(error, 'Givekey.classifyTask');
  8182. return false;
  8183. }
  8184. }
  8185. async verifyTask() {
  8186. try {
  8187. if (!this.initialized && !this.init()) {
  8188. return false;
  8189. }
  8190. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8191. return false;
  8192. }
  8193. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8194. const taskLength = this.tasks.length;
  8195. for (let i = 0; i < taskLength; i++) {
  8196. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8197. if (i < taskLength - 1) {
  8198. await delay(15e3);
  8199. }
  8200. }
  8201. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8202. scripts_echoLog({
  8203. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8204. });
  8205. return true;
  8206. } catch (error) {
  8207. throwError(error, 'Givekey.verifyTask');
  8208. return false;
  8209. }
  8210. }
  8211. }
  8212. async function Givekey_verify2(task) {
  8213. try {
  8214. const logStatus = scripts_echoLog({
  8215. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8216. });
  8217. return await new Promise(resolve => {
  8218. $.ajax({
  8219. url: 'https://givekey.ru/giveaway/task',
  8220. method: 'POST',
  8221. data: `id=${task}&user_id=${this.userId}`,
  8222. dataType: 'json',
  8223. headers: {
  8224. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8225. },
  8226. success: data => {
  8227. if (data.btn) {
  8228. $(`button[data-id=${this.userId}]`).html(data.btn);
  8229. }
  8230. if (data.status === 'ok') {
  8231. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8232. logStatus.success();
  8233. resolve(true);
  8234. } else if (data.status === 'end') {
  8235. logStatus.success();
  8236. scripts_echoLog({}).success(data.key);
  8237. resolve(true);
  8238. } else {
  8239. logStatus.error(`Error:${data.msg}`);
  8240. resolve(false);
  8241. }
  8242. },
  8243. error: xhr => {
  8244. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8245. resolve(false);
  8246. }
  8247. });
  8248. });
  8249. } catch (error) {
  8250. throwError(error, 'Givekey.verify');
  8251. return false;
  8252. }
  8253. }
  8254. function Givekey_getGiveawayId2() {
  8255. try {
  8256. var _window$location$href;
  8257. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8258. if (giveawayId) {
  8259. this.giveawayId = giveawayId;
  8260. return true;
  8261. }
  8262. scripts_echoLog({
  8263. text: i18n('getFailed', 'GiveawayId')
  8264. });
  8265. return false;
  8266. } catch (error) {
  8267. throwError(error, 'Givekey.getGiveawayId');
  8268. return false;
  8269. }
  8270. }
  8271. async function Givekey_checkLeftKey2() {
  8272. try {
  8273. if (!globalOptions.other.checkLeftKey) {
  8274. return true;
  8275. }
  8276. if (!$('#keys_count').text()) {
  8277. await external_Swal_default().fire({
  8278. icon: 'warning',
  8279. title: i18n('notice'),
  8280. text: i18n('noKeysLeft'),
  8281. confirmButtonText: i18n('confirm'),
  8282. cancelButtonText: i18n('cancel'),
  8283. showCancelButton: true
  8284. }).then(_ref => {
  8285. let {
  8286. value
  8287. } = _ref;
  8288. if (value) {
  8289. window.close();
  8290. }
  8291. });
  8292. }
  8293. return true;
  8294. } catch (error) {
  8295. throwError(error, 'Givekey.checkLeftKey');
  8296. return false;
  8297. }
  8298. }
  8299. const website_Givekey = Givekey;
  8300. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8301. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8302. privateSet.add(obj);
  8303. }
  8304. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8305. if (privateCollection.has(obj)) {
  8306. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8307. }
  8308. }
  8309. function GiveeClub_defineProperty(obj, key, value) {
  8310. if (key in obj) {
  8311. Object.defineProperty(obj, key, {
  8312. value: value,
  8313. enumerable: true,
  8314. configurable: true,
  8315. writable: true
  8316. });
  8317. } else {
  8318. obj[key] = value;
  8319. }
  8320. return obj;
  8321. }
  8322. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8323. if (!privateSet.has(receiver)) {
  8324. throw new TypeError('attempted to get private field on non-instance');
  8325. }
  8326. return fn;
  8327. }
  8328. var GiveeClub_checkLogin = new WeakSet();
  8329. var GiveeClub_getGiveawayId = new WeakSet();
  8330. var GiveeClub_checkLeftKey = new WeakSet();
  8331. class GiveeClub extends GiveawaySu {
  8332. constructor() {
  8333. super(...arguments);
  8334. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8335. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8336. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8337. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8338. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  8339. }
  8340. static test() {
  8341. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8342. }
  8343. async after() {
  8344. try {
  8345. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8346. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8347. }
  8348. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8349. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8350. }
  8351. } catch (error) {
  8352. throwError(error, 'GiveeClub.after');
  8353. }
  8354. }
  8355. init() {
  8356. try {
  8357. const logStatus = scripts_echoLog({
  8358. text: i18n('initing')
  8359. });
  8360. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8361. logStatus.warning(i18n('needLogin'));
  8362. return false;
  8363. }
  8364. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8365. return false;
  8366. }
  8367. this.initialized = true;
  8368. logStatus.success();
  8369. return true;
  8370. } catch (error) {
  8371. throwError(error, 'GiveeClub.init');
  8372. return false;
  8373. }
  8374. }
  8375. async classifyTask(action) {
  8376. try {
  8377. const logStatus = scripts_echoLog({
  8378. text: i18n('getTasksInfo')
  8379. });
  8380. if (action === 'undo') {
  8381. var _GM_getValue;
  8382. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8383. return true;
  8384. }
  8385. const pro = [];
  8386. const tasks = $('.event-actions tr');
  8387. for (const task of tasks) {
  8388. pro.push(new Promise(resolve => {
  8389. const taskDes = $(task).find('.event-action-label a');
  8390. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8391. const taskName = taskDes.text().trim();
  8392. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8393. return resolve(true);
  8394. }
  8395. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8396. if (!taskLink) {
  8397. return resolve(false);
  8398. }
  8399. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8400. this.undoneTasks.steam.groupLinks.push(taskLink);
  8401. } else if (/like.*announcement/gi.test(taskName)) {
  8402. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8403. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8404. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8405. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  8406. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8407. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8408. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8409. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8410. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8411. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8412. this.undoneTasks.steam.forumLinks.push(taskLink);
  8413. } else if (taskIcon.includes('discord')) {
  8414. this.undoneTasks.discord.serverLinks.push(taskLink);
  8415. } else if (taskIcon.includes('instagram')) {
  8416. this.undoneTasks.instagram.userLinks.push(taskLink);
  8417. } else if (taskIcon.includes('twitch')) {
  8418. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8419. } else if (taskIcon.includes('reddit')) {
  8420. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8421. } else if (/watch.*art/gim.test(taskName)) {
  8422. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8423. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8424. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8425. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8426. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8427. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8428. this.undoneTasks.vk.nameLinks.push(taskLink);
  8429. } else {
  8430. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8431. if (/follow.*button/gim.test(taskName)) {
  8432. this.undoneTasks.steam.followLinks.push(taskLink);
  8433. }
  8434. }
  8435. }
  8436. resolve(true);
  8437. }).catch(error => {
  8438. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8439. return false;
  8440. });
  8441. }));
  8442. }
  8443. await Promise.all(pro);
  8444. logStatus.success();
  8445. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8446. this.socialTasks = this.undoneTasks;
  8447. if (window.DEBUG) {
  8448. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8449. }
  8450. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8451. tasks: this.socialTasks,
  8452. time: new Date().getTime()
  8453. });
  8454. return true;
  8455. } catch (error) {
  8456. throwError(error, 'GiveeClub.classifyTask');
  8457. return false;
  8458. }
  8459. }
  8460. }
  8461. function GiveeClub_checkLogin2() {
  8462. try {
  8463. if (!globalOptions.other.checkLogin) {
  8464. return true;
  8465. }
  8466. if ($('a[href*="/account/auth"]').length > 0) {
  8467. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8468. }
  8469. return true;
  8470. } catch (error) {
  8471. throwError(error, 'GiveeClub.checkLogin');
  8472. return false;
  8473. }
  8474. }
  8475. function GiveeClub_getGiveawayId2() {
  8476. var _window$location$href;
  8477. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8478. if (giveawayId) {
  8479. this.giveawayId = giveawayId;
  8480. return true;
  8481. }
  8482. scripts_echoLog({
  8483. text: i18n('getFailed', 'GiveawayId')
  8484. });
  8485. return false;
  8486. }
  8487. async function GiveeClub_checkLeftKey2() {
  8488. try {
  8489. if (!globalOptions.other.checkLeftKey) {
  8490. return true;
  8491. }
  8492. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8493. await external_Swal_default().fire({
  8494. icon: 'warning',
  8495. title: i18n('notice'),
  8496. text: i18n('giveawayEnded'),
  8497. confirmButtonText: i18n('confirm'),
  8498. cancelButtonText: i18n('cancel'),
  8499. showCancelButton: true
  8500. }).then(_ref => {
  8501. let {
  8502. value
  8503. } = _ref;
  8504. if (value) {
  8505. window.close();
  8506. }
  8507. });
  8508. }
  8509. return true;
  8510. } catch (error) {
  8511. throwError(error, 'Giveawaysu.checkLeftKey');
  8512. return false;
  8513. }
  8514. }
  8515. const website_GiveeClub = GiveeClub;
  8516. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8517. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8518. privateSet.add(obj);
  8519. }
  8520. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8521. if (privateCollection.has(obj)) {
  8522. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8523. }
  8524. }
  8525. function OpiumPulses_defineProperty(obj, key, value) {
  8526. if (key in obj) {
  8527. Object.defineProperty(obj, key, {
  8528. value: value,
  8529. enumerable: true,
  8530. configurable: true,
  8531. writable: true
  8532. });
  8533. } else {
  8534. obj[key] = value;
  8535. }
  8536. return obj;
  8537. }
  8538. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8539. if (!privateSet.has(receiver)) {
  8540. throw new TypeError('attempted to get private field on non-instance');
  8541. }
  8542. return fn;
  8543. }
  8544. const defaultOptions = {
  8545. maxPoint: '99999999'
  8546. };
  8547. var _toggleTask = new WeakSet();
  8548. var OpiumPulses_checkLogin = new WeakSet();
  8549. class OpiumPulses {
  8550. constructor() {
  8551. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8552. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8553. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8554. OpiumPulses_defineProperty(this, 'options', {
  8555. ...defaultOptions,
  8556. ...GM_getValue('OpiumPulsesOptions')
  8557. });
  8558. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8559. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8560. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8561. }
  8562. static test() {
  8563. return window.location.host === 'www.opiumpulses.com';
  8564. }
  8565. async after() {
  8566. try {
  8567. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8568. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8569. }
  8570. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8571. } catch (error) {
  8572. throwError(error, 'OpiumPulses.after');
  8573. }
  8574. }
  8575. async doFreeTask() {
  8576. try {
  8577. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8578. } catch (error) {
  8579. throwError(error, 'OpiumPulses.doFreeTask');
  8580. }
  8581. }
  8582. async doPointTask() {
  8583. try {
  8584. var _$$text$match;
  8585. 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);
  8586. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8587. } catch (error) {
  8588. throwError(error, 'OpiumPulses.doPointTask');
  8589. }
  8590. }
  8591. init() {
  8592. return true;
  8593. }
  8594. classifyTask() {
  8595. return true;
  8596. }
  8597. }
  8598. async function _toggleTask2(type) {
  8599. try {
  8600. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8601. for (const item of items) {
  8602. var _$$find$text$match;
  8603. 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);
  8604. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8605. if (type === 'points' && needPoints > this.myPoints) {
  8606. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8607. } else if (type === 'points' && !needPoints) {
  8608. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8609. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8610. var _aElement$attr;
  8611. const logStatus = scripts_echoLog({
  8612. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8613. });
  8614. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8615. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8616. var _aElement$attr2, _aElement$attr2$match;
  8617. 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];
  8618. if (giveawayId) {
  8619. checkUser(giveawayId);
  8620. }
  8621. }
  8622. if (!aElement.attr('href')) {
  8623. logStatus.error('Error: No "href".');
  8624. continue;
  8625. }
  8626. const {
  8627. result,
  8628. statusText,
  8629. status,
  8630. data
  8631. } = await tools_httpRequest({
  8632. url: aElement.attr('href'),
  8633. method: 'GET'
  8634. });
  8635. if (result === 'Success') {
  8636. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8637. var _data$responseText$ma;
  8638. logStatus.success();
  8639. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8640. if (type === 'points' && points) {
  8641. this.myPoints = parseInt(points, 10);
  8642. }
  8643. } else {
  8644. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8645. }
  8646. } else {
  8647. logStatus.error(`${result}:${statusText}(${status})`);
  8648. }
  8649. }
  8650. }
  8651. scripts_echoLog({
  8652. text: '-----END-----'
  8653. });
  8654. } catch (error) {
  8655. throwError(error, 'OpiumPulses.toggleTask');
  8656. }
  8657. }
  8658. function OpiumPulses_checkLogin2() {
  8659. try {
  8660. if (!globalOptions.other.checkLogin) {
  8661. return true;
  8662. }
  8663. if ($('a[href*="/site/login"]').length > 1) {
  8664. window.open('/site/login', '_self');
  8665. }
  8666. return true;
  8667. } catch (error) {
  8668. throwError(error, 'OpiumPulses.checkLogin');
  8669. return false;
  8670. }
  8671. }
  8672. const website_OpiumPulses = OpiumPulses;
  8673. const external_dayjs_namespaceObject = dayjs;
  8674. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8675. const leftKeyChecker = {
  8676. async classify(link) {
  8677. try {
  8678. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8679. return await this.giveawaySu(link);
  8680. }
  8681. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8682. return await this.giveeClub(link);
  8683. }
  8684. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8685. return await this.gleam(link);
  8686. }
  8687. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8688. return await this.indieDb(link);
  8689. }
  8690. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8691. return await this.keyhub(link);
  8692. }
  8693. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8694. return await this.opquests(link);
  8695. }
  8696. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8697. return await this.itch(link);
  8698. }
  8699. return false;
  8700. } catch (error) {
  8701. throwError(error, 'leftKeyChecker.classify');
  8702. return false;
  8703. }
  8704. },
  8705. async giveawaySu(link) {
  8706. try {
  8707. const {
  8708. result,
  8709. data
  8710. } = await tools_httpRequest({
  8711. url: link,
  8712. method: 'GET'
  8713. });
  8714. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8715. if (data.responseText.includes('class="steam-login"')) {
  8716. return false;
  8717. }
  8718. if (data.responseText.includes('class="giveaway-ended"')) {
  8719. return 'Ended';
  8720. }
  8721. return 'Active';
  8722. }
  8723. return false;
  8724. } catch (error) {
  8725. throwError(error, 'leftKeyChecker.giveawaySu');
  8726. return false;
  8727. }
  8728. },
  8729. async giveeClub(link) {
  8730. try {
  8731. const {
  8732. result,
  8733. data
  8734. } = await tools_httpRequest({
  8735. url: link,
  8736. method: 'GET'
  8737. });
  8738. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8739. if (data.responseText.includes('class="event-winner"')) {
  8740. return 'Won';
  8741. }
  8742. if (data.responseText.includes('class="event-ended"')) {
  8743. return 'Ended';
  8744. }
  8745. return 'Active';
  8746. }
  8747. return false;
  8748. } catch (error) {
  8749. throwError(error, 'leftKeyChecker.giveeClub');
  8750. return false;
  8751. }
  8752. },
  8753. async gleam(link) {
  8754. try {
  8755. const {
  8756. result,
  8757. data
  8758. } = await tools_httpRequest({
  8759. url: link,
  8760. method: 'GET'
  8761. });
  8762. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8763. var _data$responseText$ma, _$$attr, _$$attr$match;
  8764. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8765. return 'Won';
  8766. }
  8767. 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];
  8768. if (!campaignDiv) {
  8769. return false;
  8770. }
  8771. 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];
  8772. if (!campaignString) {
  8773. return false;
  8774. }
  8775. const {
  8776. campaign
  8777. } = JSON.parse(campaignString);
  8778. if (campaign.banned) {
  8779. return 'Banned';
  8780. }
  8781. if (campaign.finished) {
  8782. return 'Ended';
  8783. }
  8784. if (campaign.paused) {
  8785. return 'Paused';
  8786. }
  8787. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8788. return 'NotStart';
  8789. }
  8790. return 'Active';
  8791. }
  8792. return false;
  8793. } catch (error) {
  8794. throwError(error, 'leftKeyChecker.gleam');
  8795. return false;
  8796. }
  8797. },
  8798. async indieDb(link) {
  8799. try {
  8800. const {
  8801. result,
  8802. data
  8803. } = await tools_httpRequest({
  8804. url: link,
  8805. method: 'GET'
  8806. });
  8807. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8808. if (data.responseText.includes('Congrats you WON')) {
  8809. return 'Won';
  8810. }
  8811. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8812. return 'Ended';
  8813. }
  8814. return 'Active';
  8815. }
  8816. return false;
  8817. } catch (error) {
  8818. throwError(error, 'leftKeyChecker.indieDb');
  8819. return false;
  8820. }
  8821. },
  8822. async keyhub(link) {
  8823. try {
  8824. const {
  8825. result,
  8826. data
  8827. } = await tools_httpRequest({
  8828. url: link,
  8829. method: 'GET'
  8830. });
  8831. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8832. var _data$responseText$ma2;
  8833. 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];
  8834. if (!keysleft) {
  8835. return false;
  8836. }
  8837. if (keysleft === '0') {
  8838. return 'Ended';
  8839. }
  8840. return `Active(${keysleft})`;
  8841. }
  8842. return false;
  8843. } catch (error) {
  8844. throwError(error, 'leftKeyChecker.keyhub');
  8845. return false;
  8846. }
  8847. },
  8848. async opquests(link) {
  8849. try {
  8850. const {
  8851. result,
  8852. data
  8853. } = await tools_httpRequest({
  8854. url: link,
  8855. method: 'GET'
  8856. });
  8857. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8858. var _data$responseText$ma3;
  8859. 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];
  8860. if (!keysleft) {
  8861. return false;
  8862. }
  8863. if (keysleft === '0') {
  8864. return 'Ended';
  8865. }
  8866. return `Active(${keysleft})`;
  8867. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8868. return 'Ended';
  8869. }
  8870. return false;
  8871. } catch (error) {
  8872. throwError(error, 'leftKeyChecker.opquests');
  8873. return false;
  8874. }
  8875. },
  8876. async itch(link) {
  8877. try {
  8878. const {
  8879. result,
  8880. data
  8881. } = await tools_httpRequest({
  8882. url: link,
  8883. method: 'GET'
  8884. });
  8885. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8886. var _data$responseText$ma4;
  8887. 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];
  8888. if (!endDate) {
  8889. return false;
  8890. }
  8891. if (new Date().getTime() > new Date(endDate).getTime()) {
  8892. return 'Ended';
  8893. }
  8894. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8895. }
  8896. return false;
  8897. } catch (error) {
  8898. throwError(error, 'leftKeyChecker.opquests');
  8899. return false;
  8900. }
  8901. }
  8902. };
  8903. const website_leftKeyChecker = leftKeyChecker;
  8904. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8905. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8906. privateSet.add(obj);
  8907. }
  8908. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8909. if (privateCollection.has(obj)) {
  8910. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8911. }
  8912. }
  8913. function Keylol_defineProperty(obj, key, value) {
  8914. if (key in obj) {
  8915. Object.defineProperty(obj, key, {
  8916. value: value,
  8917. enumerable: true,
  8918. configurable: true,
  8919. writable: true
  8920. });
  8921. } else {
  8922. obj[key] = value;
  8923. }
  8924. return obj;
  8925. }
  8926. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8927. if (!privateSet.has(receiver)) {
  8928. throw new TypeError('attempted to get private field on non-instance');
  8929. }
  8930. return fn;
  8931. }
  8932. const Keylol_defaultTasksTemplate = {
  8933. steam: {
  8934. groupLinks: [],
  8935. wishlistLinks: [],
  8936. curatorLinks: [],
  8937. curatorLikeLinks: [],
  8938. followLinks: [],
  8939. forumLinks: [],
  8940. announcementLinks: [],
  8941. workshopVoteLinks: [],
  8942. licenseLinks: []
  8943. },
  8944. discord: {
  8945. serverLinks: []
  8946. },
  8947. instagram: {
  8948. userLinks: []
  8949. },
  8950. vk: {
  8951. nameLinks: []
  8952. },
  8953. twitch: {
  8954. channelLinks: []
  8955. },
  8956. reddit: {
  8957. redditLinks: []
  8958. },
  8959. twitter: {
  8960. userLinks: [],
  8961. retweetLinks: []
  8962. },
  8963. youtube: {
  8964. channelLinks: [],
  8965. likeLinks: []
  8966. }
  8967. };
  8968. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  8969. var _addBtn = new WeakSet();
  8970. class Keylol extends website_Website {
  8971. constructor() {
  8972. super(...arguments);
  8973. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8974. Keylol_defineProperty(this, 'name', 'Keylol');
  8975. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  8976. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  8977. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8978. }
  8979. static test() {
  8980. var _$$eq$attr, _$$eq$attr2;
  8981. 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')));
  8982. }
  8983. init() {
  8984. return true;
  8985. }
  8986. after() {
  8987. try {
  8988. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8989. const mainPost = $(selector);
  8990. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  8991. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  8992. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  8993. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  8994. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  8995. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  8996. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  8997. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  8998. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  8999. if (discordLinks.length > 0) {
  9000. for (const discordLink of discordLinks) {
  9001. const link = $(discordLink).attr('href');
  9002. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  9003. continue;
  9004. }
  9005. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  9006. }
  9007. }
  9008. if (redditLinks.length > 0) {
  9009. for (const redditLink of redditLinks) {
  9010. const link = $(redditLink).attr('href');
  9011. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  9012. continue;
  9013. }
  9014. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  9015. }
  9016. }
  9017. if (insLinks.length > 0) {
  9018. for (const insLink of insLinks) {
  9019. const link = $(insLink).attr('href');
  9020. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  9021. continue;
  9022. }
  9023. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  9024. }
  9025. }
  9026. if (twitterLinks.length > 0) {
  9027. for (const twitterLink of twitterLinks) {
  9028. const link = $(twitterLink).attr('href');
  9029. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  9030. continue;
  9031. }
  9032. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  9033. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  9034. } else {
  9035. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  9036. }
  9037. }
  9038. }
  9039. if (twitchLinks.length > 0) {
  9040. for (const twitchLink of twitchLinks) {
  9041. const link = $(twitchLink).attr('href');
  9042. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  9043. continue;
  9044. }
  9045. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9046. }
  9047. }
  9048. if (vkLinks.length > 0) {
  9049. for (const vkLink of vkLinks) {
  9050. const link = $(vkLink).attr('href');
  9051. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9052. continue;
  9053. }
  9054. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9055. }
  9056. }
  9057. if (steamStoreLinks.length > 0) {
  9058. for (const steamStoreLink of steamStoreLinks) {
  9059. const link = $(steamStoreLink).attr('href');
  9060. if (!link) {
  9061. continue;
  9062. }
  9063. if (/curator\/[\d]+/.test(link)) {
  9064. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9065. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9066. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9067. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9068. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9069. } else if (/app\/[\d]+/.test(link)) {
  9070. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9071. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9072. }
  9073. }
  9074. }
  9075. if (steamCommunityLinks.length > 0) {
  9076. for (const steamCommunityLink of steamCommunityLinks) {
  9077. const link = $(steamCommunityLink).attr('href');
  9078. if (!link) {
  9079. continue;
  9080. }
  9081. if (/groups\/.+/.test(link)) {
  9082. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9083. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9084. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9085. }
  9086. }
  9087. }
  9088. if (ytbLinks.length > 0) {
  9089. for (const ytbLink of ytbLinks) {
  9090. const link = $(ytbLink).attr('href');
  9091. if (!link) {
  9092. continue;
  9093. }
  9094. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9095. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9096. }
  9097. }
  9098. const giveawayLinks = mainPost.find('a[href*="giveaway.su/giveaway/view/"]:visible,a[href*="givee.club/"]:visible,a[href*="gleam.io/"]:visible,a[href*="www.indiedb.com/giveaways/"]:visible,a[href*="key-hub.eu/giveaway/"]:visible,a[href*="opquests.com/quests/"]:visible,a[href*="itch.io/s/"]:visible');
  9099. if (giveawayLinks.length > 0) {
  9100. for (const giveawayLink of giveawayLinks) {
  9101. const link = $(giveawayLink).attr('href');
  9102. if (!link) {
  9103. continue;
  9104. }
  9105. website_leftKeyChecker.classify(link).then(status => {
  9106. if (!status) {
  9107. return;
  9108. }
  9109. if (/^Active/.test(status)) {
  9110. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9111. return;
  9112. }
  9113. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9114. }).catch(error => {
  9115. throwError(error, 'keylol.after -> leftKeyChecker');
  9116. });
  9117. }
  9118. }
  9119. if (this.name === 'Keylol') {
  9120. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9121. if (asfLinks.length > 0) {
  9122. for (const asfLink of asfLinks) {
  9123. const link = $(asfLink).attr('href');
  9124. if (!link) {
  9125. continue;
  9126. }
  9127. 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', '')}`);
  9128. }
  9129. }
  9130. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9131. if (subLinks.length > 0) {
  9132. for (const subLink of subLinks) {
  9133. var _link$match;
  9134. const link = $(subLink).attr('href');
  9135. if (!link) {
  9136. continue;
  9137. }
  9138. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9139. if (!subid) {
  9140. continue;
  9141. }
  9142. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9143. }
  9144. }
  9145. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9146. if (asfLinks2.length > 0) {
  9147. for (const asfLink of asfLinks2) {
  9148. const subid = asfLink.innerText.match(/[\d]+/g);
  9149. if (!subid || subid.length === 0) {
  9150. continue;
  9151. }
  9152. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9153. }
  9154. }
  9155. }
  9156. } catch (error) {
  9157. throwError(error, 'keylol.after');
  9158. }
  9159. }
  9160. classifyTask(action) {
  9161. try {
  9162. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9163. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9164. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9165. for (const btn of selectedBtns) {
  9166. const button = $(btn);
  9167. const social = button.attr('data-social');
  9168. const type = button.attr('data-type');
  9169. const link = button.attr('data-link');
  9170. if (!(social && type && link)) {
  9171. continue;
  9172. }
  9173. if (action === 'do') {
  9174. this.undoneTasks[social][type].push(link);
  9175. }
  9176. if (action === 'undo') {
  9177. this.socialTasks[social][type].push(link);
  9178. }
  9179. }
  9180. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9181. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9182. if (window.DEBUG) {
  9183. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9184. }
  9185. return true;
  9186. } catch (error) {
  9187. throwError(error, 'Keylol.classifyTask');
  9188. return false;
  9189. }
  9190. }
  9191. selectAll() {
  9192. try {
  9193. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9194. } catch (error) {
  9195. throwError(error, 'Keylol.selectAll');
  9196. }
  9197. }
  9198. selectNone() {
  9199. try {
  9200. $('.auto-task-keylol:visible').removeAttr('selected');
  9201. } catch (error) {
  9202. throwError(error, 'Keylol.selectNone');
  9203. }
  9204. }
  9205. invertSelect() {
  9206. try {
  9207. $('.auto-task-keylol:visible').each((index, element) => {
  9208. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9209. });
  9210. } catch (error) {
  9211. throwError(error, 'Keylol.invertSelect');
  9212. }
  9213. }
  9214. }
  9215. function _addBtn2(before, social, linkType, link) {
  9216. try {
  9217. $(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>`);
  9218. } catch (error) {
  9219. throwError(error, 'keylol.addBtn');
  9220. }
  9221. }
  9222. const website_Keylol = Keylol;
  9223. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9224. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9225. privateSet.add(obj);
  9226. }
  9227. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9228. if (privateCollection.has(obj)) {
  9229. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9230. }
  9231. }
  9232. function Opquests_defineProperty(obj, key, value) {
  9233. if (key in obj) {
  9234. Object.defineProperty(obj, key, {
  9235. value: value,
  9236. enumerable: true,
  9237. configurable: true,
  9238. writable: true
  9239. });
  9240. } else {
  9241. obj[key] = value;
  9242. }
  9243. return obj;
  9244. }
  9245. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9246. if (!privateSet.has(receiver)) {
  9247. throw new TypeError('attempted to get private field on non-instance');
  9248. }
  9249. return fn;
  9250. }
  9251. const Opquests_defaultTasks = {
  9252. steam: {
  9253. groupLinks: [],
  9254. wishlistLinks: [],
  9255. followLinks: [],
  9256. curatorLikeLinks: []
  9257. }
  9258. };
  9259. var Opquests_getGiveawayId = new WeakSet();
  9260. var Opquests_checkLogin = new WeakSet();
  9261. class Opquests extends website_Website {
  9262. constructor() {
  9263. super(...arguments);
  9264. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9265. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9266. Opquests_defineProperty(this, 'name', 'Opquests');
  9267. Opquests_defineProperty(this, 'undoneTasks', {
  9268. ...Opquests_defaultTasks
  9269. });
  9270. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9271. }
  9272. static test() {
  9273. return window.location.host === 'opquests.com';
  9274. }
  9275. async after() {
  9276. try {
  9277. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9278. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9279. }
  9280. } catch (error) {
  9281. throwError(error, 'Opquests.after');
  9282. }
  9283. }
  9284. init() {
  9285. try {
  9286. const logStatus = scripts_echoLog({
  9287. text: i18n('initing')
  9288. });
  9289. if ($('a[href*="/auth/redirect"]').length > 0) {
  9290. window.open('/auth/redirect', '_self');
  9291. logStatus.warning(i18n('needLogin'));
  9292. return false;
  9293. }
  9294. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9295. return false;
  9296. }
  9297. this.initialized = true;
  9298. logStatus.success();
  9299. return true;
  9300. } catch (error) {
  9301. throwError(error, 'Opquests.init');
  9302. return false;
  9303. }
  9304. }
  9305. async classifyTask(action) {
  9306. try {
  9307. if (action === 'undo') {
  9308. scripts_echoLog({
  9309. text: i18n('cannotUndo')
  9310. });
  9311. return false;
  9312. }
  9313. const logStatus = scripts_echoLog({
  9314. text: i18n('getTasksInfo')
  9315. });
  9316. const tasks = $('.w-full:contains("Validate") .items-center');
  9317. for (const task of tasks) {
  9318. const link = $(task).find('a:contains("Open")').attr('href');
  9319. const taskDes = $(task).find('div').eq(1).text().trim();
  9320. if (!link) {
  9321. continue;
  9322. }
  9323. if (/steamcommunity\.com\/groups\//.test(link)) {
  9324. this.undoneTasks.steam.groupLinks.push(link);
  9325. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9326. if (/wishlist/gim.test(taskDes)) {
  9327. this.undoneTasks.steam.wishlistLinks.push(link);
  9328. } else if (/follow/gim.test(taskDes)) {
  9329. this.undoneTasks.steam.followLinks.push(link);
  9330. }
  9331. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9332. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9333. } else {
  9334. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9335. }
  9336. }
  9337. logStatus.success();
  9338. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9339. if (window.DEBUG) {
  9340. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9341. }
  9342. return true;
  9343. } catch (error) {
  9344. throwError(error, 'Opquests.classifyTask');
  9345. return false;
  9346. }
  9347. }
  9348. }
  9349. function Opquests_getGiveawayId2() {
  9350. try {
  9351. var _window$location$href;
  9352. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9353. if (giveawayId) {
  9354. this.giveawayId = giveawayId;
  9355. return true;
  9356. }
  9357. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9358. return false;
  9359. } catch (error) {
  9360. throwError(error, 'Opquests.getGiveawayId');
  9361. return false;
  9362. }
  9363. }
  9364. function Opquests_checkLogin2() {
  9365. try {
  9366. if (!globalOptions.other.checkLogin) {
  9367. return true;
  9368. }
  9369. if ($('a[href*="/auth/redirect"]').length > 0) {
  9370. window.open('/auth/redirect', '_self');
  9371. }
  9372. return true;
  9373. } catch (error) {
  9374. throwError(error, 'Opquests.checkLogin');
  9375. return false;
  9376. }
  9377. }
  9378. const website_Opquests = Opquests;
  9379. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9380. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9381. privateSet.add(obj);
  9382. }
  9383. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9384. if (privateCollection.has(obj)) {
  9385. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9386. }
  9387. }
  9388. function Gleam_defineProperty(obj, key, value) {
  9389. if (key in obj) {
  9390. Object.defineProperty(obj, key, {
  9391. value: value,
  9392. enumerable: true,
  9393. configurable: true,
  9394. writable: true
  9395. });
  9396. } else {
  9397. obj[key] = value;
  9398. }
  9399. return obj;
  9400. }
  9401. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9402. if (!privateSet.has(receiver)) {
  9403. throw new TypeError('attempted to get private field on non-instance');
  9404. }
  9405. return fn;
  9406. }
  9407. const Gleam_defaultTasksTemplate = {
  9408. steam: {
  9409. groupLinks: [],
  9410. wishlistLinks: [],
  9411. followLinks: [],
  9412. curatorLinks: [],
  9413. curatorLikeLinks: []
  9414. },
  9415. twitter: {
  9416. userLinks: [],
  9417. retweetLinks: []
  9418. },
  9419. twitch: {
  9420. channelLinks: []
  9421. },
  9422. discord: {
  9423. serverLinks: []
  9424. },
  9425. youtube: {
  9426. channelLinks: []
  9427. },
  9428. extra: {
  9429. gleam: []
  9430. }
  9431. };
  9432. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9433. const Gleam_defaultOptions = {
  9434. vlootUsername: '',
  9435. gameroundUsername: ''
  9436. };
  9437. var _checkSync = new WeakSet();
  9438. var _doGleamTask = new WeakSet();
  9439. var Gleam_getGiveawayId = new WeakSet();
  9440. var _getGleamLink = new WeakSet();
  9441. var Gleam_checkLeftKey = new WeakSet();
  9442. class Gleam extends website_Website {
  9443. constructor() {
  9444. super(...arguments);
  9445. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9446. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9447. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9448. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9449. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9450. Gleam_defineProperty(this, 'name', 'Gleam');
  9451. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9452. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9453. Gleam_defineProperty(this, 'options', {
  9454. ...Gleam_defaultOptions,
  9455. ...GM_getValue('GleamOptions')
  9456. });
  9457. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9458. }
  9459. static test() {
  9460. return window.location.host === 'gleam.io';
  9461. }
  9462. async after() {
  9463. try {
  9464. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9465. const checkComplete = setInterval(() => {
  9466. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9467. clearInterval(checkComplete);
  9468. window.close();
  9469. }
  9470. });
  9471. for (const task of $('.entry-content .entry-method')) {
  9472. const taskInfo = $(task).find('.user-links');
  9473. const expandInfo = $(task).find('.expandable');
  9474. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9475. if (aElements.length > 0) {
  9476. for (const element of aElements) {
  9477. const $element = $(element);
  9478. const href = $element.attr('href');
  9479. $element.removeAttr('href')[0].click();
  9480. $element.attr('href', href);
  9481. await delay(1e3);
  9482. }
  9483. }
  9484. taskInfo[0].click();
  9485. await delay(1e3);
  9486. }
  9487. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9488. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9489. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9490. }
  9491. } catch (error) {
  9492. throwError(error, 'Gleam.after');
  9493. return false;
  9494. }
  9495. }
  9496. init() {
  9497. try {
  9498. const logStatus = scripts_echoLog({
  9499. text: i18n('initing')
  9500. });
  9501. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9502. return false;
  9503. }
  9504. this.initialized = true;
  9505. logStatus.success();
  9506. return true;
  9507. } catch (error) {
  9508. throwError(error, 'Gleam.init');
  9509. return false;
  9510. }
  9511. }
  9512. async classifyTask(action) {
  9513. try {
  9514. const logStatus = scripts_echoLog({
  9515. text: i18n('getTasksInfo')
  9516. });
  9517. if (action === 'undo') {
  9518. var _GM_getValue;
  9519. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9520. }
  9521. const tasks = $('.entry-content .entry-method');
  9522. for (const task of tasks) {
  9523. var _socialIcon$attr;
  9524. const $task = $(task);
  9525. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9526. continue;
  9527. }
  9528. const socialIcon = $task.find('.icon-wrapper i');
  9529. const taskInfo = $task.find('.user-links');
  9530. const taskText = taskInfo.text().trim();
  9531. const expandInfo = $task.find('.expandable');
  9532. const aElements = expandInfo.find('a.btn');
  9533. if (aElements.length > 0) {
  9534. for (const element of aElements) {
  9535. const $element = $(element);
  9536. const href = $element.attr('href');
  9537. $element.removeAttr('href')[0].click();
  9538. $element.attr('href', href);
  9539. }
  9540. }
  9541. if (socialIcon.hasClass('fa-twitter')) {
  9542. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9543. if (!link) {
  9544. continue;
  9545. }
  9546. if (/follow/gi.test(taskText)) {
  9547. if (action === 'undo') {
  9548. this.socialTasks.twitter.userLinks.push(link);
  9549. }
  9550. if (action === 'do') {
  9551. this.undoneTasks.twitter.userLinks.push(link);
  9552. }
  9553. } else if (/retweet/gim.test(taskText)) {
  9554. if (action === 'undo') {
  9555. this.socialTasks.twitter.retweetLinks.push(link);
  9556. }
  9557. if (action === 'do') {
  9558. this.undoneTasks.twitter.retweetLinks.push(link);
  9559. }
  9560. }
  9561. } else if (socialIcon.hasClass('fa-twitch')) {
  9562. if (/follow/gim.test(taskText)) {
  9563. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9564. if (!link) {
  9565. continue;
  9566. }
  9567. if (action === 'undo') {
  9568. this.socialTasks.twitch.channelLinks.push(link);
  9569. }
  9570. if (action === 'do') {
  9571. this.undoneTasks.twitch.channelLinks.push(link);
  9572. }
  9573. }
  9574. } else if (socialIcon.hasClass('fa-discord')) {
  9575. if (/join/gim.test(taskText)) {
  9576. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9577. if (!link) {
  9578. var _$task$find$attr, _$task$find$attr$matc;
  9579. 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];
  9580. if (!ggLink) {
  9581. continue;
  9582. }
  9583. link = `https://discord.com/invite/${ggLink}`;
  9584. }
  9585. if (action === 'undo') {
  9586. this.socialTasks.discord.serverLinks.push(link);
  9587. }
  9588. if (action === 'do') {
  9589. this.undoneTasks.discord.serverLinks.push(link);
  9590. }
  9591. }
  9592. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9593. continue;
  9594. } else if (socialIcon.hasClass('fa-youtube')) {
  9595. if (/subscribe/gim.test(taskText)) {
  9596. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9597. if (!link) {
  9598. continue;
  9599. }
  9600. if (action === 'undo') {
  9601. this.socialTasks.youtube.channelLinks.push(link);
  9602. }
  9603. if (action === 'do') {
  9604. this.undoneTasks.youtube.channelLinks.push(link);
  9605. }
  9606. }
  9607. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9608. if (/join.*group/gi.test(taskText)) {
  9609. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9610. if (!link) {
  9611. continue;
  9612. }
  9613. if (action === 'undo') {
  9614. this.socialTasks.steam.groupLinks.push(link);
  9615. }
  9616. if (action === 'do') {
  9617. this.undoneTasks.steam.groupLinks.push(link);
  9618. }
  9619. } else if (/follow.*curator/gi.test(taskText)) {
  9620. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9621. if (!link) {
  9622. continue;
  9623. }
  9624. if (action === 'undo') {
  9625. this.socialTasks.steam.curatorLinks.push(link);
  9626. }
  9627. if (action === 'do') {
  9628. this.undoneTasks.steam.curatorLinks.push(link);
  9629. }
  9630. }
  9631. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9632. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9633. for (const button of continueBtn) {
  9634. button.click();
  9635. await delay(500);
  9636. expandInfo.find('input').val(this.options.vlootUsername);
  9637. }
  9638. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9639. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9640. for (const button of continueBtn) {
  9641. button.click();
  9642. await delay(500);
  9643. expandInfo.find('input').val(this.options.gameroundUsername);
  9644. }
  9645. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9646. if (action !== 'do') {
  9647. continue;
  9648. }
  9649. const link = aElements.attr('href');
  9650. if (!link) {
  9651. continue;
  9652. }
  9653. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9654. if (!gleamLink) {
  9655. continue;
  9656. }
  9657. this.undoneTasks.extra.gleam.push(gleamLink);
  9658. } 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 {
  9659. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9660. }
  9661. }
  9662. logStatus.success();
  9663. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9664. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9665. if (window.DEBUG) {
  9666. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9667. }
  9668. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9669. tasks: this.socialTasks,
  9670. time: new Date().getTime()
  9671. });
  9672. return true;
  9673. } catch (error) {
  9674. throwError(error, 'Gleam.classifyTask');
  9675. return false;
  9676. }
  9677. }
  9678. async extraDoTask(_ref) {
  9679. let {
  9680. gleam
  9681. } = _ref;
  9682. try {
  9683. const pro = [];
  9684. for (const link of gleam) {
  9685. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9686. }
  9687. return Promise.all(pro).then(() => true);
  9688. } catch (error) {
  9689. throwError(error, 'Gleam.extraDoTask');
  9690. return false;
  9691. }
  9692. }
  9693. async verifyTask() {
  9694. try {
  9695. scripts_echoLog({
  9696. text: `${i18n('verifyingTask')}...`
  9697. });
  9698. const tasks = $('.entry-content .entry-method');
  9699. for (const task of tasks) {
  9700. const $task = $(task);
  9701. if ($task.find('i.fa-question').length === 0) {
  9702. continue;
  9703. }
  9704. const taskInfo = $task.find('.user-links');
  9705. taskInfo[0].click();
  9706. await delay(500);
  9707. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9708. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9709. for (const button of continueBtn) {
  9710. button.click();
  9711. await delay(500);
  9712. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9713. }
  9714. }
  9715. scripts_echoLog({
  9716. text: i18n('verifiedGleamTasks')
  9717. });
  9718. } catch (error) {
  9719. throwError(error, 'Gleam.verifyTask');
  9720. return false;
  9721. }
  9722. }
  9723. }
  9724. async function _checkSync2() {
  9725. try {
  9726. return await new Promise(resolve => {
  9727. const checker = setInterval(() => {
  9728. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9729. clearInterval(checker);
  9730. resolve(true);
  9731. }
  9732. }, 500);
  9733. });
  9734. } catch (error) {
  9735. throwError(error, 'Gleam.checkSync');
  9736. return false;
  9737. }
  9738. }
  9739. async function _doGleamTask2(link) {
  9740. try {
  9741. const logStatus = scripts_echoLog({
  9742. text: i18n('doingGleamTask')
  9743. });
  9744. return await new Promise(resolve => {
  9745. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9746. active: true,
  9747. insert: true,
  9748. setParent: true
  9749. }).onclose = () => {
  9750. logStatus.success();
  9751. resolve(true);
  9752. };
  9753. });
  9754. } catch (error) {
  9755. throwError(error, 'Gleam.doGleamTask');
  9756. return false;
  9757. }
  9758. }
  9759. function Gleam_getGiveawayId2() {
  9760. try {
  9761. const giveawayId = window.location.pathname;
  9762. if (giveawayId) {
  9763. this.giveawayId = giveawayId;
  9764. return true;
  9765. }
  9766. scripts_echoLog({
  9767. text: i18n('getFailed', 'GiveawayId')
  9768. });
  9769. return false;
  9770. } catch (error) {
  9771. throwError(error, 'Gleam.getGiveawayId');
  9772. return false;
  9773. }
  9774. }
  9775. async function _getGleamLink2(link) {
  9776. try {
  9777. const logStatus = scripts_echoLog({
  9778. text: i18n('gettingGleamLink')
  9779. });
  9780. const {
  9781. result,
  9782. statusText,
  9783. status,
  9784. data
  9785. } = await tools_httpRequest({
  9786. url: link,
  9787. method: 'GET'
  9788. });
  9789. if (result === 'Success') {
  9790. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9791. var _data$responseText$ma;
  9792. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9793. if (gleamLink) {
  9794. logStatus.success();
  9795. return gleamLink;
  9796. }
  9797. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9798. return false;
  9799. }
  9800. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9801. return false;
  9802. }
  9803. logStatus.error(`${result}:${statusText}(${status})`);
  9804. return false;
  9805. } catch (error) {
  9806. throwError(error, 'Gleam.getGleamLink');
  9807. return false;
  9808. }
  9809. }
  9810. async function Gleam_checkLeftKey2() {
  9811. try {
  9812. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9813. if (!globalOptions.other.checkLeftKey) {
  9814. return true;
  9815. }
  9816. 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];
  9817. if (!campaignString) {
  9818. return false;
  9819. }
  9820. const {
  9821. campaign,
  9822. incentive
  9823. } = JSON.parse(campaignString);
  9824. 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];
  9825. let ownedKey = false;
  9826. if (controllerString) {
  9827. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9828. 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) {
  9829. ownedKey = true;
  9830. }
  9831. }
  9832. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9833. await external_Swal_default().fire({
  9834. icon: 'warning',
  9835. title: i18n('notice'),
  9836. text: i18n('giveawayNotWork'),
  9837. confirmButtonText: i18n('confirm'),
  9838. cancelButtonText: i18n('cancel'),
  9839. showCancelButton: true
  9840. }).then(_ref2 => {
  9841. let {
  9842. value
  9843. } = _ref2;
  9844. if (value) {
  9845. window.close();
  9846. }
  9847. });
  9848. }
  9849. return true;
  9850. } catch (error) {
  9851. throwError(error, 'Gleam.checkLeftKey');
  9852. return false;
  9853. }
  9854. }
  9855. const website_Gleam = Gleam;
  9856. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9857. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9858. privateSet.add(obj);
  9859. }
  9860. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9861. if (privateCollection.has(obj)) {
  9862. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9863. }
  9864. }
  9865. function SweepWidget_defineProperty(obj, key, value) {
  9866. if (key in obj) {
  9867. Object.defineProperty(obj, key, {
  9868. value: value,
  9869. enumerable: true,
  9870. configurable: true,
  9871. writable: true
  9872. });
  9873. } else {
  9874. obj[key] = value;
  9875. }
  9876. return obj;
  9877. }
  9878. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9879. if (!privateSet.has(receiver)) {
  9880. throw new TypeError('attempted to get private field on non-instance');
  9881. }
  9882. return fn;
  9883. }
  9884. const SweepWidget_defaultOptions = {
  9885. username: '',
  9886. email: ''
  9887. };
  9888. var SweepWidget_checkLogin = new WeakSet();
  9889. var SweepWidget_getGiveawayId = new WeakSet();
  9890. var _checkEnter = new WeakSet();
  9891. var _checkFinish = new WeakSet();
  9892. class SweepWidget extends website_Website {
  9893. constructor() {
  9894. super(...arguments);
  9895. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9896. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9897. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9898. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9899. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9900. SweepWidget_defineProperty(this, 'options', {
  9901. ...SweepWidget_defaultOptions,
  9902. ...GM_getValue('SweepWidgetOptions')
  9903. });
  9904. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9905. }
  9906. static test() {
  9907. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9908. }
  9909. async after() {
  9910. try {
  9911. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9912. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9913. }
  9914. } catch (error) {
  9915. throwError(error, 'SweepWidget.after');
  9916. }
  9917. }
  9918. init() {
  9919. try {
  9920. const logStatus = scripts_echoLog({
  9921. text: i18n('initing')
  9922. });
  9923. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9924. logStatus.warning(i18n('needLogin'));
  9925. return false;
  9926. }
  9927. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9928. return false;
  9929. }
  9930. this.initialized = true;
  9931. logStatus.success();
  9932. return true;
  9933. } catch (error) {
  9934. throwError(error, 'SweepWidget.init');
  9935. return false;
  9936. }
  9937. }
  9938. classifyTask() {
  9939. return true;
  9940. }
  9941. async doTask() {
  9942. try {
  9943. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9944. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9945. $('input[name="sw__login_name"]').val(this.options.username);
  9946. }
  9947. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9948. $('input[name="sw__login_email"]').val(this.options.email);
  9949. }
  9950. if ($('#sw_login_button:visible').length > 0) {
  9951. $('#sw_login_button')[0].click();
  9952. }
  9953. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9954. return false;
  9955. }
  9956. }
  9957. const logStatus = scripts_echoLog({
  9958. text: i18n('SweepWidgetNotice')
  9959. });
  9960. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9961. for (const task of tasks) {
  9962. var _aElement$, _$task$find$removeAtt;
  9963. const $task = $(task);
  9964. if ($task.find('i.fa-check:visible').length > 0) {
  9965. continue;
  9966. }
  9967. const title = $task.find('.sw_text_inner');
  9968. title[0].click();
  9969. const aElement = $task.find('a.sw_link');
  9970. const link = aElement.attr('href');
  9971. aElement.attr('href', '#a').attr('target', '_self');
  9972. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9973. await delay(300);
  9974. aElement.attr('href', link).attr('target', '_blank');
  9975. $task.find('input[type="text"]').val('test');
  9976. const verifyBtn = $task.find('input.sw_verify');
  9977. if (verifyBtn.prop('disabled') === true) {
  9978. title[0].click();
  9979. await delay(300);
  9980. title[0].click();
  9981. await delay(300);
  9982. }
  9983. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9984. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9985. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9986. }
  9987. logStatus.success();
  9988. return true;
  9989. } catch (error) {
  9990. throwError(error, 'SweepWidget.doTask');
  9991. return false;
  9992. }
  9993. }
  9994. }
  9995. function SweepWidget_checkLogin2() {
  9996. try {
  9997. if ($('#twitter_login_button').length > 0) {
  9998. $('#twitter_login_button')[0].click();
  9999. }
  10000. return true;
  10001. } catch (error) {
  10002. throwError(error, 'SweepWidget.checkLogin');
  10003. return false;
  10004. }
  10005. }
  10006. function SweepWidget_getGiveawayId2() {
  10007. try {
  10008. var _window$location$href;
  10009. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  10010. if (giveawayId) {
  10011. this.giveawayId = giveawayId;
  10012. return true;
  10013. }
  10014. scripts_echoLog({
  10015. text: i18n('getFailed', 'GiveawayId')
  10016. });
  10017. return false;
  10018. } catch (error) {
  10019. throwError(error, 'SweepWidget.getGiveawayId');
  10020. return false;
  10021. }
  10022. }
  10023. async function _checkEnter2() {
  10024. try {
  10025. return new Promise(resolve => {
  10026. const checker = setInterval(() => {
  10027. if ($('#unlock_rewards_main_wrapper').length > 0) {
  10028. clearInterval(checker);
  10029. resolve(true);
  10030. }
  10031. });
  10032. });
  10033. } catch (error) {
  10034. throwError(error, 'SweepWidget.checkEnter');
  10035. return false;
  10036. }
  10037. }
  10038. async function _checkFinish2($task) {
  10039. try {
  10040. return new Promise(resolve => {
  10041. const checker = setInterval(() => {
  10042. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  10043. clearInterval(checker);
  10044. resolve(true);
  10045. }
  10046. });
  10047. });
  10048. } catch (error) {
  10049. throwError(error, 'SweepWidget.checkFinish');
  10050. return false;
  10051. }
  10052. }
  10053. const website_SweepWidget = SweepWidget;
  10054. const defaultWhiteList = {
  10055. discord: {
  10056. servers: []
  10057. },
  10058. instagram: {
  10059. users: []
  10060. },
  10061. twitch: {
  10062. channels: []
  10063. },
  10064. twitter: {
  10065. users: [],
  10066. retweets: [],
  10067. likes: []
  10068. },
  10069. vk: {
  10070. names: []
  10071. },
  10072. youtube: {
  10073. channels: [],
  10074. likes: []
  10075. },
  10076. reddit: {
  10077. reddits: []
  10078. },
  10079. steam: {
  10080. groups: [],
  10081. officialGroups: [],
  10082. wishlists: [],
  10083. follows: [],
  10084. forums: [],
  10085. workshops: [],
  10086. curators: [],
  10087. workshopVotes: [],
  10088. curatorLikes: [],
  10089. announcements: [],
  10090. licenses: [],
  10091. playtests: []
  10092. }
  10093. };
  10094. const link2id = async function(type) {
  10095. 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;
  10096. try {
  10097. const link = $('#socialLink').val();
  10098. let id = '';
  10099. switch (type) {
  10100. case 'discord.servers':
  10101. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10102. break;
  10103.  
  10104. case 'instagram.users':
  10105. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10106. break;
  10107.  
  10108. case 'twitch.channels':
  10109. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10110. break;
  10111.  
  10112. case 'twitter.users':
  10113. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10114. break;
  10115.  
  10116. case 'twitter.retweets':
  10117. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10118. break;
  10119.  
  10120. case 'vk.names':
  10121. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10122. break;
  10123.  
  10124. case 'youtube.channels':
  10125. 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) || '';
  10126. break;
  10127.  
  10128. case 'youtube.likes':
  10129. 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) || '';
  10130. break;
  10131.  
  10132. case 'reddit.reddits':
  10133. 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]) || '';
  10134. break;
  10135.  
  10136. case 'steam.groups':
  10137. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10138. break;
  10139.  
  10140. case 'steam.wishlists':
  10141. case 'steam.follows':
  10142. case 'steam.forums':
  10143. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10144. break;
  10145.  
  10146. case 'steam.workshops':
  10147. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10148. break;
  10149.  
  10150. case 'steam.curators':
  10151. {
  10152. if (link.includes('curator')) {
  10153. var _link$match12;
  10154. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10155. } else {
  10156. var _link$match13;
  10157. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10158. if (!param || param.length !== 2) {
  10159. break;
  10160. }
  10161. const steam = new social_Steam();
  10162. if (await steam.init()) {
  10163. id = await steam.getCuratorId(param[0], param[1]) || '';
  10164. }
  10165. }
  10166. }
  10167. break;
  10168. }
  10169. return id;
  10170. } catch (error) {
  10171. throwError(error, 'link2id');
  10172. return i18n('getFailed', 'id');
  10173. }
  10174. };
  10175. const disabledType = {
  10176. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10177. twitter: [ 'likes' ]
  10178. };
  10179. const assignWhiteList = whiteList => {
  10180. try {
  10181. const newWhiteList = {};
  10182. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10183. newWhiteList[key] = {
  10184. ...value,
  10185. ...whiteList[key]
  10186. };
  10187. }
  10188. return newWhiteList;
  10189. } catch (error) {
  10190. throwError(error, 'assignWhiteList');
  10191. return defaultWhiteList;
  10192. }
  10193. };
  10194. const whiteListOptions = function(showType) {
  10195. try {
  10196. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10197. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10198. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10199. for (const [ social, types ] of Object.entries(whiteList)) {
  10200. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10201. var _disabledType$social;
  10202. 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>`;
  10203. }).join('');
  10204. }
  10205. whiteListOptionsForm += '</tbody></table></form>';
  10206. if (showType === 'swal') {
  10207. external_Swal_default().fire({
  10208. title: i18n('whiteListOptions'),
  10209. html: whiteListOptionsForm,
  10210. showConfirmButton: false,
  10211. showCloseButton: true
  10212. });
  10213. } else {
  10214. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10215. }
  10216. $('.editWhiteList').on('click', function() {
  10217. var _whiteList$social;
  10218. const value = $(this).attr('data-value');
  10219. if (!value) {
  10220. return;
  10221. }
  10222. const [ social, type ] = value.split('.');
  10223. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10224. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10225. return;
  10226. }
  10227. external_Swal_default().fire({
  10228. title: i18n('changeWhiteListOption', value),
  10229. input: 'textarea',
  10230. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10231. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10232. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10233. inputValue: whiteList[social][type].join('\n'),
  10234. showConfirmButton: true,
  10235. confirmButtonText: i18n('save'),
  10236. showCancelButton: true,
  10237. cancelButtonText: i18n('close'),
  10238. showDenyButton: true,
  10239. denyButtonText: i18n('return')
  10240. }).then(_ref => {
  10241. let {
  10242. isDenied,
  10243. isConfirmed,
  10244. value
  10245. } = _ref;
  10246. if (isDenied) {
  10247. if (showType === 'swal') {
  10248. whiteListOptions(showType);
  10249. }
  10250. return;
  10251. } else if (isConfirmed) {
  10252. whiteList[social][type] = value.split('\n');
  10253. GM_setValue('whiteList', whiteList);
  10254. external_Swal_default().fire({
  10255. title: i18n('changeWhiteListSuccess'),
  10256. icon: 'success'
  10257. });
  10258. }
  10259. });
  10260. $('#link2id').on('click', async function() {
  10261. const type = $(this).attr('data-type');
  10262. $('#socialLink').val(await link2id(type));
  10263. });
  10264. });
  10265. } catch (error) {
  10266. throwError(error, 'whiteListOptions');
  10267. }
  10268. };
  10269. const whiteList = whiteListOptions;
  10270. const setGistData = async (token, gistId, fileName, content) => {
  10271. try {
  10272. const logStatus = scripts_echoLog({
  10273. text: i18n('settingData')
  10274. });
  10275. const contentData = JSON.stringify({
  10276. files: {
  10277. [fileName]: {
  10278. content: JSON.stringify(content)
  10279. }
  10280. }
  10281. });
  10282. const {
  10283. result,
  10284. statusText,
  10285. status,
  10286. data
  10287. } = await tools_httpRequest({
  10288. url: `https://api.github.com/gists/${gistId}`,
  10289. headers: {
  10290. Accept: 'application/vnd.github.v3+json',
  10291. Authorization: `token ${token}`
  10292. },
  10293. data: contentData,
  10294. responseType: 'json',
  10295. method: 'POST',
  10296. timeout: 3e4
  10297. });
  10298. if (result === 'Success') {
  10299. var _data$response$files, _data$response$files$;
  10300. 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)) {
  10301. logStatus.success();
  10302. return true;
  10303. }
  10304. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10305. return false;
  10306. }
  10307. logStatus.error(`${result}:${statusText}(${status})`);
  10308. return false;
  10309. } catch (error) {
  10310. throwError(error, 'setGistData');
  10311. return false;
  10312. }
  10313. };
  10314. const getGistData = async function(token, gistId, fileName) {
  10315. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10316. try {
  10317. const logStatus = scripts_echoLog({
  10318. text: i18n('gettingData')
  10319. });
  10320. const {
  10321. result,
  10322. statusText,
  10323. status,
  10324. data
  10325. } = await tools_httpRequest({
  10326. url: `https://api.github.com/gists/${gistId}`,
  10327. headers: {
  10328. Accept: 'application/vnd.github.v3+json',
  10329. Authorization: `token ${token}`
  10330. },
  10331. responseType: 'json',
  10332. method: 'GET',
  10333. timeout: 3e4
  10334. });
  10335. if (result === 'Success') {
  10336. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10337. var _data$response, _data$response$files2, _data$response$files3;
  10338. 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;
  10339. let formatedContent;
  10340. if (!content) {
  10341. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10342. return false;
  10343. }
  10344. if (test) {
  10345. logStatus.success();
  10346. return true;
  10347. }
  10348. try {
  10349. formatedContent = JSON.parse(content);
  10350. } catch (error) {
  10351. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10352. return false;
  10353. }
  10354. logStatus.success();
  10355. return formatedContent;
  10356. }
  10357. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10358. return false;
  10359. }
  10360. logStatus.error(`${result}:${statusText}(${status})`);
  10361. return false;
  10362. } catch (error) {
  10363. throwError(error, 'getGistData');
  10364. return false;
  10365. }
  10366. };
  10367. const syncOptions = () => {
  10368. try {
  10369. const {
  10370. TOKEN,
  10371. GIST_ID,
  10372. FILE_NAME,
  10373. SYNC_HISTORY
  10374. } = GM_getValue('gistOptions') || {
  10375. TOKEN: '',
  10376. GIST_ID: '',
  10377. FILE_NAME: '',
  10378. SYNC_HISTORY: true
  10379. };
  10380. external_Swal_default().fire({
  10381. title: i18n('gistOptions'),
  10382. 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;">
  10383. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10384. ${i18n('downloadFromGist')}</button></p>`,
  10385. focusConfirm: false,
  10386. showLoaderOnConfirm: true,
  10387. 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>`,
  10388. preConfirm: async () => {
  10389. const token = $('#github-token').val();
  10390. const gistId = $('#gist-id').val();
  10391. const fileName = $('#file-name').val();
  10392. const syncHistory = $('#sync-history').prop('checked');
  10393. GM_setValue('gistOptions', {
  10394. TOKEN: token,
  10395. GIST_ID: gistId,
  10396. FILE_NAME: fileName,
  10397. SYNC_HISTORY: syncHistory
  10398. });
  10399. return await getGistData(token, gistId, fileName, true);
  10400. },
  10401. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10402. confirmButtonText: i18n('saveAndTest'),
  10403. showCancelButton: true,
  10404. cancelButtonText: i18n('close')
  10405. }).then(_ref => {
  10406. let {
  10407. value
  10408. } = _ref;
  10409. if (value) {
  10410. external_Swal_default().fire({
  10411. icon: 'success',
  10412. title: i18n('testSuccess')
  10413. }).then(syncOptions);
  10414. } else if (value !== undefined) {
  10415. external_Swal_default().fire({
  10416. icon: 'error',
  10417. title: i18n('testFailed')
  10418. }).then(syncOptions);
  10419. }
  10420. });
  10421. $('#upload-data').on('click', async () => {
  10422. const {
  10423. TOKEN,
  10424. GIST_ID,
  10425. FILE_NAME
  10426. } = GM_getValue('gistOptions') || {};
  10427. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10428. return external_Swal_default().fire({
  10429. icon: 'error',
  10430. title: i18n('saveAndTestNotice')
  10431. }).then(syncOptions);
  10432. }
  10433. external_Swal_default().fire({
  10434. icon: 'info',
  10435. title: i18n('processingData')
  10436. });
  10437. const data = {};
  10438. const names = GM_listValues();
  10439. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10440. for (const name of names) {
  10441. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10442. continue;
  10443. }
  10444. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10445. continue;
  10446. }
  10447. data[name] = GM_getValue(name);
  10448. }
  10449. external_Swal_default().update({
  10450. icon: 'info',
  10451. title: i18n('updatingData')
  10452. });
  10453. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10454. external_Swal_default().fire({
  10455. icon: 'success',
  10456. title: i18n('syncDataSuccess')
  10457. });
  10458. } else {
  10459. external_Swal_default().fire({
  10460. icon: 'error',
  10461. title: i18n('syncDataFailed')
  10462. });
  10463. }
  10464. });
  10465. $('#download-data').on('click', async () => {
  10466. const {
  10467. TOKEN,
  10468. GIST_ID,
  10469. FILE_NAME
  10470. } = GM_getValue('gistOptions') || {};
  10471. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10472. return external_Swal_default().fire({
  10473. icon: 'error',
  10474. title: i18n('saveAndTestNotice')
  10475. }).then(syncOptions);
  10476. }
  10477. external_Swal_default().fire({
  10478. icon: 'info',
  10479. title: i18n('downloadingData')
  10480. });
  10481. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10482. if (!data) {
  10483. return external_Swal_default().fire({
  10484. icon: 'error',
  10485. title: i18n('checkedNoData')
  10486. }).then(syncOptions);
  10487. }
  10488. external_Swal_default().update({
  10489. icon: 'info',
  10490. title: i18n('savingData')
  10491. });
  10492. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10493. for (const [ name, value ] of Object.entries(data)) {
  10494. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10495. continue;
  10496. }
  10497. GM_setValue(name, value);
  10498. }
  10499. external_Swal_default().fire({
  10500. icon: 'success',
  10501. title: i18n('syncDataSuccess')
  10502. });
  10503. });
  10504. } catch (error) {
  10505. throwError(error, 'syncOptions');
  10506. }
  10507. };
  10508. const dataSync = syncOptions;
  10509. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10510. Setting_checkPrivateRedeclaration(obj, privateSet);
  10511. privateSet.add(obj);
  10512. }
  10513. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10514. if (privateCollection.has(obj)) {
  10515. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10516. }
  10517. }
  10518. function Setting_defineProperty(obj, key, value) {
  10519. if (key in obj) {
  10520. Object.defineProperty(obj, key, {
  10521. value: value,
  10522. enumerable: true,
  10523. configurable: true,
  10524. writable: true
  10525. });
  10526. } else {
  10527. obj[key] = value;
  10528. }
  10529. return obj;
  10530. }
  10531. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10532. if (!privateSet.has(receiver)) {
  10533. throw new TypeError('attempted to get private field on non-instance');
  10534. }
  10535. return fn;
  10536. }
  10537. var Setting_getId = new WeakSet();
  10538. var _environment = new WeakSet();
  10539. class Setting {
  10540. constructor() {
  10541. Setting_classPrivateMethodInitSpec(this, _environment);
  10542. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10543. Setting_defineProperty(this, 'name', 'Setting');
  10544. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10545. Setting_defineProperty(this, 'syncData', dataSync);
  10546. }
  10547. tasksHistory() {
  10548. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10549. }
  10550. static test() {
  10551. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10552. }
  10553. before() {
  10554. $('body').html('').addClass('auto-task-options');
  10555. }
  10556. after() {
  10557. try {
  10558. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10559. changeGlobalOptions('page');
  10560. whiteList('page');
  10561. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10562. $('#getTwitterUserId').on('click', () => {
  10563. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10564. });
  10565. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10566. $('#getYoutubeChannelId').on('click', () => {
  10567. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10568. });
  10569. $('input[name^="position"]').on('input', function() {
  10570. const type = $(this).attr('name').replace('position.', '');
  10571. const xLabel = 'rightleft';
  10572. const yLabel = 'topbottpm';
  10573. switch (type) {
  10574. case 'buttonSideX':
  10575. case 'buttonSideY':
  10576. case 'buttonDistance':
  10577. {
  10578. const distance = $('input[name="position.buttonDistance"]').val();
  10579. const sideX = $('input[name="position.buttonSideX"]').val();
  10580. const sideY = $('input[name="position.buttonSideY"]').val();
  10581. if (![ 'right', 'left' ].includes(sideX)) {
  10582. break;
  10583. }
  10584. if (![ 'top', 'bottom' ].includes(sideY)) {
  10585. break;
  10586. }
  10587. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10588. break;
  10589. }
  10590. const distanceArr = distance.split(',');
  10591. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10592. break;
  10593. }
  10594.  
  10595. case 'showButtonSideX':
  10596. case 'showButtonSideY':
  10597. case 'showButtonDistance':
  10598. {
  10599. const distance = $('input[name="position.showButtonDistance"]').val();
  10600. const sideX = $('input[name="position.showButtonSideX"]').val();
  10601. const sideY = $('input[name="position.showButtonSideY"]').val();
  10602. if (![ 'right', 'left' ].includes(sideX)) {
  10603. break;
  10604. }
  10605. if (![ 'top', 'bottom' ].includes(sideY)) {
  10606. break;
  10607. }
  10608. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10609. break;
  10610. }
  10611. const distanceArr = distance.split(',');
  10612. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10613. break;
  10614. }
  10615.  
  10616. case 'logSideX':
  10617. case 'logSideY':
  10618. case 'logDistance':
  10619. {
  10620. const distance = $('input[name="position.logDistance"]').val();
  10621. const sideX = $('input[name="position.logSideX"]').val();
  10622. const sideY = $('input[name="position.logSideY"]').val();
  10623. if (![ 'right', 'left' ].includes(sideX)) {
  10624. break;
  10625. }
  10626. if (![ 'top', 'bottom' ].includes(sideY)) {
  10627. break;
  10628. }
  10629. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10630. break;
  10631. }
  10632. const distanceArr = distance.split(',');
  10633. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10634. break;
  10635. }
  10636.  
  10637. default:
  10638. break;
  10639. }
  10640. });
  10641. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10642. let functionKey = '';
  10643. if (event.altKey) {
  10644. functionKey += 'alt + ';
  10645. } else if (event.ctrlKey) {
  10646. functionKey += 'ctrl + ';
  10647. } else if (event.shiftKey) {
  10648. functionKey += 'shift + ';
  10649. }
  10650. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10651. });
  10652. } catch (error) {
  10653. throwError(error, 'Setting.after');
  10654. }
  10655. }
  10656. saveGlobalOptions() {
  10657. saveData();
  10658. }
  10659. }
  10660. function Setting_getId2(social) {
  10661. try {
  10662. external_Swal_default().fire({
  10663. title: i18n('getId', i18n(social)),
  10664. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10665. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10666. showCancelButton: true,
  10667. cancelButtonText: i18n('close'),
  10668. showConfirmButton: false
  10669. });
  10670. $('#link2id').on('click', async function() {
  10671. const link = $('#socialLink').val();
  10672. if (!link) {
  10673. return;
  10674. }
  10675. const type = $(this).attr('data-type');
  10676. if (type === 'twitterUser') {
  10677. var _link$match;
  10678. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10679. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10680. } else if (type === 'youtubeChannel') {
  10681. var _link$match2, _await$getInfo, _await$getInfo$params;
  10682. 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;
  10683. $('#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) || '');
  10684. }
  10685. });
  10686. } catch (error) {
  10687. throwError(error, 'Setting.getId');
  10688. }
  10689. }
  10690. function _environment2() {
  10691. try {
  10692. const userAgent = (0, javascript_utils_umd_min.ua)();
  10693. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10694. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10695. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10696. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10697. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10698. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10699. </tbody></table></form>`;
  10700. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10701. } catch (error) {
  10702. throwError(error, 'Setting.environment');
  10703. }
  10704. }
  10705. const website_Setting = Setting;
  10706. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10707. History_checkPrivateRedeclaration(obj, privateSet);
  10708. privateSet.add(obj);
  10709. }
  10710. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10711. if (privateCollection.has(obj)) {
  10712. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10713. }
  10714. }
  10715. function History_defineProperty(obj, key, value) {
  10716. if (key in obj) {
  10717. Object.defineProperty(obj, key, {
  10718. value: value,
  10719. enumerable: true,
  10720. configurable: true,
  10721. writable: true
  10722. });
  10723. } else {
  10724. obj[key] = value;
  10725. }
  10726. return obj;
  10727. }
  10728. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10729. if (!privateSet.has(receiver)) {
  10730. throw new TypeError('attempted to get private field on non-instance');
  10731. }
  10732. return fn;
  10733. }
  10734. var _addItem = new WeakSet();
  10735. class History extends website_Keylol {
  10736. constructor() {
  10737. super(...arguments);
  10738. History_classPrivateMethodInitSpec(this, _addItem);
  10739. History_defineProperty(this, 'name', 'History');
  10740. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10741. }
  10742. static test() {
  10743. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10744. }
  10745. before() {
  10746. try {
  10747. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10748. const data = GM_listValues() || [];
  10749. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10750. for (const item of tasksHistory) {
  10751. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10752. }
  10753. } catch (error) {
  10754. throwError(error, 'History.before');
  10755. }
  10756. }
  10757. clearHistory() {
  10758. try {
  10759. const data = GM_listValues() || [];
  10760. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10761. for (const item of tasksHistory) {
  10762. GM_deleteValue(item);
  10763. }
  10764. external_Swal_default().fire({
  10765. title: i18n('clearHistoryFinished'),
  10766. icon: 'success'
  10767. });
  10768. } catch (error) {
  10769. throwError(error, 'History.after');
  10770. }
  10771. }
  10772. }
  10773. function _addItem2(item) {
  10774. try {
  10775. const tasksData = GM_getValue(item);
  10776. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10777. return;
  10778. }
  10779. let html = '';
  10780. let title = '';
  10781. let link = '';
  10782. const [ website, id ] = item.split('-');
  10783. switch (website) {
  10784. case 'fawTasks':
  10785. title = `Freeanywhere[${id}]`;
  10786. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10787. break;
  10788.  
  10789. case 'gasTasks':
  10790. title = `Giveawaysu[${id}]`;
  10791. link = `https://giveaway.su/giveaway/view/${id}`;
  10792. break;
  10793.  
  10794. case 'gcTasks':
  10795. title = `GiveeClub[${id}]`;
  10796. link = `https://givee.club/event/${id}`;
  10797. break;
  10798.  
  10799. case 'gkTasks':
  10800. title = `Givekey[${id}]`;
  10801. link = `https://givekey.ru/giveaway/${id}`;
  10802. break;
  10803.  
  10804. case 'gleamTasks':
  10805. title = `Gleam[${id}]`;
  10806. link = `https://gleam.io${id}`;
  10807. break;
  10808.  
  10809. case 'khTasks':
  10810. title = `keyhub[${id}]`;
  10811. link = `https://key-hub.eu/giveaway/${id}`;
  10812. break;
  10813.  
  10814. case 'prysTasks':
  10815. title = `Prys[${id}]`;
  10816. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10817. break;
  10818.  
  10819. default:
  10820. return;
  10821. }
  10822. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10823. for (const [ type, tasks ] of Object.entries(types)) {
  10824. for (const task of tasks) {
  10825. 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>`;
  10826. }
  10827. }
  10828. }
  10829. $('.container').append(`<div class="card" data-name="${item}"><div class="title"><a href="${link}" target="_blank">${title}</a><span class="delete-task" data-name="${item}" title="${i18n('deleteTask')}"><svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2734" width="32" height="32"><path d="M607.897867 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L575.903242 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 351.94087C639.892491 753.593818 625.61532 768.043004 607.897867 768.043004z" p-id="2735" fill="#d81e06"></path><path d="M415.930119 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L383.935495 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625 17.717453 0 31.994625 14.277171 31.994625 31.994625l0 351.94087C447.924744 753.593818 433.647573 768.043004 415.930119 768.043004z" p-id="2736" fill="#d81e06"></path><path d="M928.016126 223.962372l-159.973123 0L768.043004 159.973123c0-52.980346-42.659499-95.983874-95.295817-95.983874L351.94087 63.989249c-52.980346 0-95.983874 43.003528-95.983874 95.983874l0 63.989249-159.973123 0c-17.717453 0-31.994625 14.277171-31.994625 31.994625s14.277171 31.994625 31.994625 31.994625l832.032253 0c17.717453 0 31.994625-14.277171 31.994625-31.994625S945.73358 223.962372 928.016126 223.962372zM319.946246 159.973123c0-17.545439 14.449185-31.994625 31.994625-31.994625l320.806316 0c17.545439 0 31.306568 14.105157 31.306568 31.994625l0 63.989249L319.946246 223.962372 319.946246 159.973123 319.946246 159.973123z" p-id="2737" fill="#d81e06"></path><path d="M736.048379 960.010751 288.123635 960.010751c-52.980346 0-95.983874-43.003528-95.983874-95.983874L192.139761 383.591466c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 480.435411c0 17.717453 14.449185 31.994625 31.994625 31.994625l448.096758 0c17.717453 0 31.994625-14.277171 31.994625-31.994625L768.215018 384.795565c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 479.231312C832.032253 916.835209 789.028725 960.010751 736.048379 960.010751z" p-id="2738" fill="#d81e06"></path></svg></span></div><ul>${html}</ul><span class="time">${i18n('lastChangeTime')}: ${external_dayjs_namespaceObject(tasksData.time).format('YYYY-MM-DD HH:mm:ss')}</span></div>`);
  10830. $('span.delete-task').on('click', function() {
  10831. const itemName = $(this).attr('data-name');
  10832. if (itemName) {
  10833. GM_deleteValue(itemName);
  10834. $(`div.card[data-name="${itemName}"]`).remove();
  10835. external_Swal_default().fire({
  10836. title: i18n('clearTaskFinished'),
  10837. text: itemName,
  10838. icon: 'success'
  10839. });
  10840. } else {
  10841. external_Swal_default().fire({
  10842. title: i18n('clearTaskFailed'),
  10843. icon: 'error'
  10844. });
  10845. }
  10846. });
  10847. } catch (error) {
  10848. throwError(error, 'History.addItem');
  10849. }
  10850. }
  10851. const website_History = History;
  10852. 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 ];
  10853. const websiteOptions = function(website, options) {
  10854. try {
  10855. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10856. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10857. for (const [ option, value ] of Object.entries(options)) {
  10858. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10859. }
  10860. websiteOptionsForm += '</tbody></table></form>';
  10861. external_Swal_default().fire({
  10862. title: i18n('websiteOptions'),
  10863. html: websiteOptionsForm,
  10864. showConfirmButton: true,
  10865. confirmButtonText: i18n('save'),
  10866. showCancelButton: true,
  10867. cancelButtonText: i18n('close')
  10868. }).then(_ref => {
  10869. let {
  10870. isConfirmed
  10871. } = _ref;
  10872. if (isConfirmed) {
  10873. $('#websiteOptionsForm').serializeArray().map(value => {
  10874. options[value.name] = value.value;
  10875. return value;
  10876. });
  10877. GM_setValue(`${website}Options`, options);
  10878. external_Swal_default().fire({
  10879. title: i18n('changeWebsiteOptionsSuccess'),
  10880. icon: 'success'
  10881. });
  10882. }
  10883. });
  10884. } catch (error) {
  10885. throwError(error, 'websiteOptions');
  10886. }
  10887. };
  10888. const options = websiteOptions;
  10889. const external_keyboardJS_namespaceObject = keyboardJS;
  10890. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10891. const checkUpdate = async (updateLink, auto) => {
  10892. try {
  10893. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10894. const {
  10895. result,
  10896. statusText,
  10897. status,
  10898. data
  10899. } = await tools_httpRequest({
  10900. url: checkUrl,
  10901. responseType: 'json',
  10902. method: 'GET',
  10903. timeout: 3e4
  10904. });
  10905. if (result === 'Success') {
  10906. var _data$response;
  10907. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10908. return data.response;
  10909. }
  10910. if (!auto) {
  10911. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10912. }
  10913. return false;
  10914. }
  10915. if (!auto) {
  10916. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10917. }
  10918. return false;
  10919. } catch (error) {
  10920. throwError(error, 'checkUpdate');
  10921. return false;
  10922. }
  10923. };
  10924. const hasNewVersion = (currentVersion, remoteVersion) => {
  10925. try {
  10926. const [ currentRealVersion ] = currentVersion.split('-');
  10927. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  10928. if (isPreview && !globalOptions.other.receivePreview) {
  10929. return false;
  10930. }
  10931. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10932. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10933. if (remoteVersion1 > currentVersion1) {
  10934. return true;
  10935. }
  10936. if (remoteVersion1 < currentVersion1) {
  10937. return false;
  10938. }
  10939. if (remoteVersion2 > currentVersion2) {
  10940. return true;
  10941. }
  10942. if (remoteVersion2 < currentVersion2) {
  10943. return false;
  10944. }
  10945. if (remoteVersion3 > currentVersion3) {
  10946. return true;
  10947. }
  10948. return false;
  10949. } catch (error) {
  10950. throwError(error, 'compareVersion');
  10951. return false;
  10952. }
  10953. };
  10954. const updateChecker = async () => {
  10955. try {
  10956. const currentVersion = GM_info.script.version;
  10957. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10958. const updateLinks = {
  10959. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10960. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10961. standby: 'https://auto-task-v4.hclonely.com/'
  10962. };
  10963. let version;
  10964. let updateLink = '';
  10965. let packageData;
  10966. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10967. updateLink = updateLinks[updateSource];
  10968. packageData = await checkUpdate(updateLink, false);
  10969. } else {
  10970. updateLink = updateLinks.github;
  10971. packageData = await checkUpdate(updateLink, true);
  10972. if (!packageData) {
  10973. updateLink = updateLinks.jsdelivr;
  10974. packageData = await checkUpdate(updateLink, true);
  10975. if (!packageData) {
  10976. updateLink = updateLinks.standby;
  10977. packageData = await checkUpdate(updateLink, true);
  10978. }
  10979. }
  10980. }
  10981. if (packageData) {
  10982. version = packageData.version || currentVersion;
  10983. } else {
  10984. version = currentVersion;
  10985. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10986. }
  10987. if (packageData && hasNewVersion(currentVersion, version)) {
  10988. var _packageData$change;
  10989. scripts_echoLog({
  10990. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10991. });
  10992. scripts_echoLog({
  10993. html: `<li>${i18n('updateText', version)}</li><ol class="update-text">${(_packageData$change = packageData.change) === null || _packageData$change === void 0 ? void 0 : _packageData$change.map(change => `<li>${change}</li>`).join('')}<li>${i18n('updateHistory')}</li></ol>`
  10994. });
  10995. }
  10996. } catch (error) {
  10997. throwError(error, 'updateChecker');
  10998. }
  10999. };
  11000. const scripts_updateChecker = updateChecker;
  11001. var _globalOptions$other, _globalOptions$other2;
  11002. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  11003. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  11004. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  11005. const loadScript = async () => {
  11006. var _website, _website2, _website3, _website4, _website5, _website6;
  11007. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  11008. const authToken = external_Cookies_namespaceObject.get('auth-token');
  11009. const isLogin = !!external_Cookies_namespaceObject.get('login');
  11010. if (isLogin) {
  11011. var _commonOptions, _commonOptions$header;
  11012. GM_setValue('twitchAuth', {
  11013. authToken: authToken,
  11014. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  11015. });
  11016. window.close();
  11017. external_Swal_default().fire('', i18n('closePageNotice'));
  11018. } else {
  11019. external_Swal_default().fire('', i18n('needLogin'));
  11020. }
  11021. return;
  11022. }
  11023. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  11024. const ct0 = external_Cookies_namespaceObject.get('ct0');
  11025. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  11026. if (isLogin && ct0) {
  11027. GM_setValue('twitterAuth', {
  11028. ct0: ct0
  11029. });
  11030. window.close();
  11031. external_Swal_default().fire('', i18n('closePageNotice'));
  11032. } else {
  11033. external_Swal_default().fire('', i18n('needLogin'));
  11034. }
  11035. return;
  11036. }
  11037. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  11038. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  11039. if (PAPISID) {
  11040. GM_setValue('youtubeAuth', {
  11041. PAPISID: PAPISID
  11042. });
  11043. window.close();
  11044. external_Swal_default().fire('', i18n('closePageNotice'));
  11045. } else {
  11046. external_Swal_default().fire('', i18n('needLogin'));
  11047. }
  11048. return;
  11049. }
  11050. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11051. const betaButton = $('#redesign-beta-optin-btn');
  11052. if (betaButton.length > 0) {
  11053. GM_setValue('redditAuth', '#auth');
  11054. return betaButton[0].click();
  11055. }
  11056. GM_setValue('redditAuth', null);
  11057. window.close();
  11058. external_Swal_default().fire('', i18n('closePageNotice'));
  11059. return;
  11060. }
  11061. let website;
  11062. for (const Website of Websites) {
  11063. if (Website.test()) {
  11064. website = new Website();
  11065. break;
  11066. }
  11067. }
  11068. if (!website) {
  11069. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11070. return;
  11071. }
  11072. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11073. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11074. }
  11075. $('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>`);
  11076. $('div.show-button-div').on('click', () => {
  11077. $('#auto-task-buttons').show();
  11078. $('div.show-button-div').hide();
  11079. });
  11080. const toggleLog = () => {
  11081. const $this = $('#toggle-log');
  11082. const status = $this.attr('data-status');
  11083. if (status === 'show') {
  11084. $('#auto-task-info').hide();
  11085. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11086. } else {
  11087. $('#auto-task-info').show();
  11088. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11089. }
  11090. };
  11091. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11092. if (website.doTask) {
  11093. website.doTask();
  11094. }
  11095. });
  11096. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11097. if (website.undoTask) {
  11098. website.doTask();
  11099. }
  11100. });
  11101. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11102. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11103. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11104. }
  11105. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11106. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11107. for (const button of website.buttons) {
  11108. if (website[button]) {
  11109. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11110. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11111. website[button]();
  11112. });
  11113. $('#auto-task-buttons').append(btnElement);
  11114. }
  11115. }
  11116. }
  11117. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11118. ${i18n('hideButton')}</a></p>`);
  11119. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11120. $('#auto-task-buttons').hide();
  11121. $('div.show-button-div').show();
  11122. });
  11123. 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'}">
  11124. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11125. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11126. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11127. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11128. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11129. options(website.name, website.options);
  11130. });
  11131. }
  11132. if (website.name !== 'Setting') {
  11133. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11134. changeGlobalOptions('swal');
  11135. });
  11136. GM_registerMenuCommand(i18n('settingPage'), () => {
  11137. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11138. });
  11139. }
  11140. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11141. if (!GM_getValue('notice')) {
  11142. var _echoLog$font;
  11143. external_Swal_default().fire({
  11144. title: i18n('swalNotice'),
  11145. icon: 'warning'
  11146. }).then(() => {
  11147. window.open(i18n('noticeLink'), '_blank');
  11148. GM_setValue('notice', new Date().getTime());
  11149. });
  11150. (_echoLog$font = scripts_echoLog({
  11151. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11152. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11153. GM_setValue('notice', new Date().getTime());
  11154. });
  11155. }
  11156. scripts_updateChecker();
  11157. };
  11158. if (window.location.hostname === 'discord.com') {
  11159. const LocalStorage = window.localStorage;
  11160. if (window.location.hash === '#auth') {
  11161. var _LocalStorage$getItem;
  11162. window.localStorage.removeItem = () => true;
  11163. 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, '');
  11164. if (discordAuth && discordAuth.length > 0) {
  11165. GM_setValue('discordAuth', {
  11166. auth: discordAuth
  11167. });
  11168. window.close();
  11169. external_Swal_default().fire('', i18n('closePageNotice'));
  11170. } else {
  11171. external_Swal_default().fire({
  11172. text: i18n('getDiscordAuthFailed'),
  11173. icon: 'error'
  11174. });
  11175. }
  11176. } else {
  11177. var _LocalStorage$getItem2;
  11178. 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, '');
  11179. if (discordAuth && discordAuth.length > 0) {
  11180. GM_setValue('discordAuth', {
  11181. auth: discordAuth
  11182. });
  11183. }
  11184. }
  11185. } else if (window.location.hostname === 'opquests.com') {
  11186. loadScript();
  11187. } else {
  11188. $(loadScript);
  11189. }
  11190. }();
  11191. })();