auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.6
  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. gettingTwitterUserId: '正在获取推特用户Id',
  1382. followingTwitterUser: '正在关注推特用户',
  1383. unfollowingTwitterUser: '正在取关推特用户',
  1384. retweetting: '正在转推',
  1385. unretweetting: '正在撤销转推',
  1386. names: '组/社区/动态',
  1387. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1388. gettingVkId: '正在获取Vk任务Id',
  1389. joiningVkGroup: '正在加入Vk组',
  1390. leavingVkGroup: '正在退出Vk组',
  1391. joiningVkPublic: '正在加入Vk社区',
  1392. leavingVkPublic: '正在退出Vk社区',
  1393. sendingVkWall: '正在转发Vk动态',
  1394. deletingVkWall: '正在撤销转发Vk动态',
  1395. youtubeChannel: 'YouTube频道',
  1396. likes: '点赞',
  1397. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1398. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1399. gettingYtbToken: '正在获取YouTube Token...',
  1400. followingYtbChannel: '正在订阅YouTube频道',
  1401. unfollowingYtbChannel: '正在退订YouTube频道',
  1402. likingYtbVideo: '正在点赞YouTube视频',
  1403. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1404. giveKeyNoticeBefore: '每次验证间隔15s',
  1405. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1406. noPoints: '点数不够,跳过抽奖',
  1407. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1408. joiningLottery: '正在加入抽奖',
  1409. doingGleamTask: '正在做Gleam任务...',
  1410. gettingGleamLink: '正在获取Gleam任务链接...',
  1411. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1412. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1413. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1414. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1415. };
  1416. const zh_CN = data;
  1417. const en_US_data = {
  1418. website: 'Website',
  1419. type: 'Type',
  1420. edit: 'Edit',
  1421. whiteList: 'Whitelist',
  1422. skipTask: 'Skip undo task',
  1423. whiteListOptions: 'Whitelist options',
  1424. changeWhiteListOption: 'Whitelist option(%0)',
  1425. whiteListNotFound: 'Cannot find this whitelist: %0',
  1426. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1427. changeWebsiteOptions: 'Website options',
  1428. changeGlobalOptions: 'Global options',
  1429. ok: 'OK',
  1430. save: 'Save',
  1431. close: 'Close',
  1432. return: 'Return',
  1433. option: 'Option',
  1434. value: 'Value',
  1435. websiteOptions: 'Current website settings',
  1436. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1437. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1438. needLogin: 'Please log in first!',
  1439. getTasksInfo: 'Obtaining and processing task information...',
  1440. gettingKey: 'Getting Key...',
  1441. verifyingTask: 'Verifying task',
  1442. notice: 'Automatic task script notice',
  1443. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1444. giveawayEnded: 'This event has ended, do you want to close it?',
  1445. 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?',
  1446. confirm: 'Confirm',
  1447. cancel: 'Cancel',
  1448. unKnown: 'Unknown',
  1449. unKnownTaskType: 'Unrecognized task',
  1450. doing: 'Doing a task',
  1451. allTasksComplete: 'All tasks have been completed!',
  1452. getTaskIdFailed: 'Failed to obtain task Id!',
  1453. initSuccess: '%0 was initialized successfully!',
  1454. initFailed: '%0 initialization failed!',
  1455. errorLink: 'Link error: %0',
  1456. needInit: 'Please initialize first',
  1457. verifyingAuth: 'Verifying %0 token...',
  1458. updatingAuth: 'Update %0 token...',
  1459. initing: 'Initializing...',
  1460. getFailed: 'Failed to get %0!',
  1461. checkLoginFailed: 'Failed to detect login status!',
  1462. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1463. userId: 'User Id',
  1464. joiningGiveaway: 'Joining giveaway',
  1465. needJoinGiveaway: 'Need to join the giveaway first',
  1466. cannotUndo: 'This website does not support canceling tasks',
  1467. verifyAuth: 'Verifying %0 token...',
  1468. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1469. errorReport: 'A script error is detected, do you want to report the BUG?',
  1470. visitingLink: 'Visiting link: ',
  1471. doTask: 'DoTask',
  1472. undoTask: 'UndoTask',
  1473. verifyTask: 'Verify',
  1474. getKey: 'GetKey',
  1475. selectAll: 'SelectAll',
  1476. selectNone: 'SelectNone',
  1477. invertSelect: 'InvertSelect',
  1478. doFreeTask: 'FreeTask',
  1479. doPointTask: 'PointTask',
  1480. skipTaskOption: 'Skip task has been configured in the settings',
  1481. other: 'Other',
  1482. globalOptions: 'Global Options',
  1483. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1484. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1485. 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.',
  1486. 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.',
  1487. 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.',
  1488. saveGlobalOptions: 'SaveSettings',
  1489. settingPage: 'Setting Page',
  1490. name: 'Name',
  1491. version: 'Version',
  1492. scriptManager: 'Script Manager',
  1493. script: 'Script',
  1494. environment: 'Environment',
  1495. os: 'OS',
  1496. browser: 'Browser',
  1497. getId: 'Get %0 id',
  1498. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1499. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1500. showButton: 'ShowButton',
  1501. hideButton: 'HideButton',
  1502. showLog: 'ShowLog',
  1503. hideLog: 'HideLog',
  1504. defaultShowButton: 'Default display button',
  1505. defaultShowLog: 'Display log by default',
  1506. debug: 'Output debug log, do not enable this option!',
  1507. receivePreview: 'Receive preview updates',
  1508. position: 'Component position',
  1509. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1510. 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',
  1511. 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',
  1512. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1513. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1514. 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',
  1515. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1516. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1517. 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',
  1518. hotKey: 'Shortcut key',
  1519. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1520. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1521. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1522. tasksHistory: 'TasksHistory',
  1523. clearHistory: 'Clear history',
  1524. clearHistoryFinished: 'The mission history has been cleared!',
  1525. deleteTask: 'Delete task',
  1526. lastChangeTime: 'Last Change Time',
  1527. clearTaskFinished: 'Delete the following tasks completed!',
  1528. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1529. syncData: 'DataSync',
  1530. settingData: 'Uploading data...',
  1531. gettingData: 'Getting data...',
  1532. help: 'Help',
  1533. fileName: 'Filename',
  1534. upload2gist: 'Sync to Gist',
  1535. downloadFromGist: 'Sync from Gist',
  1536. saveAndTest: 'Save configuration and test',
  1537. testSuccess: 'Test success!',
  1538. testFailed: 'Test failed!',
  1539. saveAndTestNotice: 'Please save the configuration and test first!',
  1540. processingData: 'Processing data...',
  1541. updatingData: 'Uploading data...',
  1542. syncDataSuccess: 'Synchronized data successfully!',
  1543. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1544. downloadingData: 'Downloading data...',
  1545. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1546. savingData: 'Saving data...',
  1547. syncHistory: 'Synchronize tasks history',
  1548. checkUpdateFailed: 'Check update failed',
  1549. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1550. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1551. gistOptions: 'Gist Settings',
  1552. 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!',
  1553. 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!',
  1554. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1555. toGithub: 'Feedback(Github)',
  1556. toKeylol: 'Feedback(Keylol)',
  1557. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1558. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1559. updateText: 'Updates in version %0:',
  1560. Active: 'Active',
  1561. Ended: 'Ended',
  1562. Banned: 'Banned',
  1563. Paused: 'Paused',
  1564. notStart: 'notStart',
  1565. noRemoteData: 'No data remotely',
  1566. errorRemoteDataFormat: 'Remote data has wrong format',
  1567. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1568. groups: 'Group',
  1569. officialGroups: 'Official Group',
  1570. wishlists: 'Wishlist',
  1571. follows: 'Follow Game',
  1572. forums: 'Forum',
  1573. workshops: 'Favorite Workshop',
  1574. curators: 'Curator',
  1575. workshopVotes: 'Voteup Workshop',
  1576. announcements: 'Announcement',
  1577. steamCommunity: 'Steam Community',
  1578. steamStore: 'Steam Store',
  1579. licenses: 'Add License',
  1580. playtests: 'Playtest Access',
  1581. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1582. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1583. joiningSteamGroup: 'Joining Steam Group',
  1584. leavingSteamGroup: 'Leaving Steam Group',
  1585. gettingSteamGroupId: 'Getting Steam Group Id',
  1586. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1587. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1588. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1589. subscribingForum: 'Subscribing the Steam Forum',
  1590. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1591. gettingForumId: 'Getting Steam Forum Id',
  1592. followingCurator: 'Following Steam Curator',
  1593. unfollowingCurator: 'Unfollowing Steam Curator',
  1594. gettingCuratorId: 'Getting Steam Curator Id',
  1595. addingToWishlist: 'Adding the game to the Steam wishlist',
  1596. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1597. followingGame: 'Following Steam games',
  1598. unfollowingGame: 'Unfollowing Steam games',
  1599. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1600. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1601. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1602. votingUpWorkshop: 'Liking Steam workshop items',
  1603. gettingAnnouncementParams: 'Getting Steam announcement information',
  1604. likingAnnouncement: 'Liking Steam announcement',
  1605. changingArea: 'Changing Steam area: %0...',
  1606. notNeededChangeArea: 'The current area does not need to be changed',
  1607. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1608. gettingAreaInfo: 'Getting Steam area information...',
  1609. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1610. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1611. gettingSubid: 'Getting subid',
  1612. addingFreeLicense: 'Adding free license',
  1613. missParams: 'Missing parameters',
  1614. gettingLicenses: 'Getting licenses...',
  1615. requestingPlayTestAccess: 'Requesting play test access',
  1616. 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.',
  1617. servers: 'Server',
  1618. joiningDiscordServer: 'Joining Discord Server',
  1619. leavingDiscordServer: 'Leaving Discord Server',
  1620. gettingDiscordGuild: 'Getting Discord server Id',
  1621. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1622. users: 'User',
  1623. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1624. insBanned: 'Your Instagram account has been banned',
  1625. verifyingInsAuth: 'Verifying Instagram token...',
  1626. gettingInsUserId: 'Getting Instagram user Id',
  1627. followingIns: 'Following Instagram user',
  1628. unfollowingIns: 'Unfollowing Instagram user',
  1629. reddits: 'Reddit/User',
  1630. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1631. changingRedditVersion: 'Switching Reddit to a new version page...',
  1632. joiningReddit: 'Joining the Reddit',
  1633. leavingReddit: 'Leaving the Reddit',
  1634. followingRedditUser: 'Following Reddit User',
  1635. unfollowingRedditUser: 'Unfollowing Reddit User',
  1636. channels: 'Channel',
  1637. followingTwitchChannel: 'Following Twitch Channel',
  1638. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1639. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1640. twitterUser: 'Twitter User',
  1641. retweets: 'Retweet',
  1642. gettingTwitterUserId: 'Getting Twitter User Id',
  1643. followingTwitterUser: 'Following Twitter User',
  1644. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1645. retweetting: 'Retweetting',
  1646. unretweetting: 'Unretweetting',
  1647. names: 'Group/Public/Wall',
  1648. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1649. gettingVkId: 'Getting Vk task Id',
  1650. joiningVkGroup: 'Joining Vk Group',
  1651. leavingVkGroup: 'Leaving Vk Group',
  1652. joiningVkPublic: 'Joining Vk Public',
  1653. leavingVkPublic: 'Leaving Vk Public',
  1654. sendingVkWall: 'Sending Vk Wall',
  1655. deletingVkWall: 'Deleting Vk Wall',
  1656. youtubeChannel: 'YouTube Channel',
  1657. likes: 'Like',
  1658. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1659. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1660. gettingYtbToken: 'Getting YouTube Token...',
  1661. followingYtbChannel: 'Subscribing to YouTube channel',
  1662. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1663. likingYtbVideo: 'Liking YouTube video',
  1664. unlikingYtbVideo: 'Unliking YouTube video',
  1665. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1666. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1667. noPoints: 'Not enough points, skip the lottery',
  1668. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1669. joiningLottery: 'Joining the lottery',
  1670. doingGleamTask: 'Doing Gleam Task...',
  1671. gettingGleamLink: 'Getting Gleam task link...',
  1672. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1673. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1674. 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!',
  1675. 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...'
  1676. };
  1677. const en_US = en_US_data;
  1678. const languages = {
  1679. zh: zh_CN,
  1680. en: en_US
  1681. };
  1682. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1683. const I18n = function(key) {
  1684. var _languages$language;
  1685. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1686. argvs[_key - 1] = arguments[_key];
  1687. }
  1688. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1689. return key;
  1690. }
  1691. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1692. };
  1693. const i18n = I18n;
  1694. function throwError(error, name) {
  1695. if (window.TRACE) {
  1696. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1697. }
  1698. external_Swal_default().fire({
  1699. title: i18n('errorReport'),
  1700. icon: 'error',
  1701. showCancelButton: true,
  1702. confirmButtonText: i18n('toGithub'),
  1703. showDenyButton: true,
  1704. denyButtonText: i18n('toKeylol'),
  1705. cancelButtonText: i18n('close')
  1706. }).then(_ref => {
  1707. let {
  1708. isDenied,
  1709. isConfirmed
  1710. } = _ref;
  1711. if (isConfirmed) {
  1712. 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,
  1713. 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');
  1714. } else if (isDenied) {
  1715. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1716.  
  1717. 环境:
  1718.  
  1719. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1720.  
  1721. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1722. 脚本版本: ${GM_info.script.version}
  1723.  
  1724. 报错信息:
  1725. [code]${error.stack}[/code]
  1726.  
  1727. 执行日志:
  1728. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1729. GM_setClipboard(text);
  1730. external_Swal_default().fire({
  1731. title: i18n('copySuccess'),
  1732. icon: 'success',
  1733. confirmButtonText: i18n('ok')
  1734. }).then(() => {
  1735. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1736. });
  1737. }
  1738. });
  1739. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1740. }
  1741. function _defineProperty(obj, key, value) {
  1742. if (key in obj) {
  1743. Object.defineProperty(obj, key, {
  1744. value: value,
  1745. enumerable: true,
  1746. configurable: true,
  1747. writable: true
  1748. });
  1749. } else {
  1750. obj[key] = value;
  1751. }
  1752. return obj;
  1753. }
  1754. class Social {
  1755. constructor() {
  1756. _defineProperty(this, 'tasks', void 0);
  1757. }
  1758. getRealParams(name, links, doTask, link2param) {
  1759. try {
  1760. let realParams = [];
  1761. if (links.length > 0) {
  1762. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1763. }
  1764. if (!doTask && this.tasks[name].length > 0) {
  1765. realParams = [ ...realParams, ...this.tasks[name] ];
  1766. }
  1767. return unique(realParams);
  1768. } catch (error) {
  1769. throwError(error, 'Social.getRealParams');
  1770. return [];
  1771. }
  1772. }
  1773. }
  1774. const social_Social = Social;
  1775. function _classPrivateMethodInitSpec(obj, privateSet) {
  1776. _checkPrivateRedeclaration(obj, privateSet);
  1777. privateSet.add(obj);
  1778. }
  1779. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1780. _checkPrivateRedeclaration(obj, privateMap);
  1781. privateMap.set(obj, value);
  1782. }
  1783. function _checkPrivateRedeclaration(obj, privateCollection) {
  1784. if (privateCollection.has(obj)) {
  1785. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1786. }
  1787. }
  1788. function Discord_defineProperty(obj, key, value) {
  1789. if (key in obj) {
  1790. Object.defineProperty(obj, key, {
  1791. value: value,
  1792. enumerable: true,
  1793. configurable: true,
  1794. writable: true
  1795. });
  1796. } else {
  1797. obj[key] = value;
  1798. }
  1799. return obj;
  1800. }
  1801. function _classPrivateFieldSet(receiver, privateMap, value) {
  1802. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1803. _classApplyDescriptorSet(receiver, descriptor, value);
  1804. return value;
  1805. }
  1806. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1807. if (descriptor.set) {
  1808. descriptor.set.call(receiver, value);
  1809. } else {
  1810. if (!descriptor.writable) {
  1811. throw new TypeError('attempted to set read only private field');
  1812. }
  1813. descriptor.value = value;
  1814. }
  1815. }
  1816. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1817. if (!privateSet.has(receiver)) {
  1818. throw new TypeError('attempted to get private field on non-instance');
  1819. }
  1820. return fn;
  1821. }
  1822. function _classPrivateFieldGet(receiver, privateMap) {
  1823. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1824. return _classApplyDescriptorGet(receiver, descriptor);
  1825. }
  1826. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1827. if (!privateMap.has(receiver)) {
  1828. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1829. }
  1830. return privateMap.get(receiver);
  1831. }
  1832. function _classApplyDescriptorGet(receiver, descriptor) {
  1833. if (descriptor.get) {
  1834. return descriptor.get.call(receiver);
  1835. }
  1836. return descriptor.value;
  1837. }
  1838. const defaultTasksTemplate = {
  1839. servers: []
  1840. };
  1841. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1842. var _auth = new WeakMap();
  1843. var _cache = new WeakMap();
  1844. var _initialized = new WeakMap();
  1845. var _verifyAuth = new WeakSet();
  1846. var _updateAuth = new WeakSet();
  1847. var _joinServer = new WeakSet();
  1848. var _leaveServer = new WeakSet();
  1849. var _getGuild = new WeakSet();
  1850. var _setCache = new WeakSet();
  1851. class Discord extends social_Social {
  1852. constructor() {
  1853. var _GM_getValue;
  1854. super(...arguments);
  1855. _classPrivateMethodInitSpec(this, _setCache);
  1856. _classPrivateMethodInitSpec(this, _getGuild);
  1857. _classPrivateMethodInitSpec(this, _leaveServer);
  1858. _classPrivateMethodInitSpec(this, _joinServer);
  1859. _classPrivateMethodInitSpec(this, _updateAuth);
  1860. _classPrivateMethodInitSpec(this, _verifyAuth);
  1861. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1862. Discord_defineProperty(this, 'whiteList', {
  1863. ...JSON.parse(defaultTasks),
  1864. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1865. });
  1866. _classPrivateFieldInitSpec(this, _auth, {
  1867. writable: true,
  1868. value: GM_getValue('discordAuth') || {}
  1869. });
  1870. _classPrivateFieldInitSpec(this, _cache, {
  1871. writable: true,
  1872. value: GM_getValue('discordCache') || {}
  1873. });
  1874. _classPrivateFieldInitSpec(this, _initialized, {
  1875. writable: true,
  1876. value: false
  1877. });
  1878. }
  1879. async init() {
  1880. try {
  1881. if (_classPrivateFieldGet(this, _initialized)) {
  1882. return true;
  1883. }
  1884. if (!_classPrivateFieldGet(this, _auth).auth) {
  1885. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1886. _classPrivateFieldSet(this, _initialized, true);
  1887. return true;
  1888. }
  1889. return false;
  1890. }
  1891. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1892. if (isVerified) {
  1893. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1894. _classPrivateFieldSet(this, _initialized, true);
  1895. return true;
  1896. }
  1897. GM_setValue('discordAuth', {
  1898. auth: null
  1899. });
  1900. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1901. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1902. _classPrivateFieldSet(this, _initialized, true);
  1903. return true;
  1904. }
  1905. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1906. return false;
  1907. } catch (error) {
  1908. throwError(error, 'Discord.init');
  1909. return false;
  1910. }
  1911. }
  1912. async toggle(_ref) {
  1913. let {
  1914. doTask = true,
  1915. serverLinks = []
  1916. } = _ref;
  1917. try {
  1918. if (!_classPrivateFieldGet(this, _initialized)) {
  1919. scripts_echoLog({
  1920. text: i18n('needInit')
  1921. });
  1922. return false;
  1923. }
  1924. const prom = [];
  1925. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1926. scripts_echoLog({
  1927. type: 'globalOptionsSkip',
  1928. text: 'discord.servers'
  1929. });
  1930. } else {
  1931. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1932. var _link$match;
  1933. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1934. });
  1935. if (realServers.length > 0) {
  1936. for (const server of realServers) {
  1937. if (doTask) {
  1938. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1939. } else {
  1940. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1941. }
  1942. await delay(1e3);
  1943. }
  1944. }
  1945. }
  1946. return await Promise.all(prom).then(() => true);
  1947. } catch (error) {
  1948. throwError(error, 'Discord.toggleServers');
  1949. return false;
  1950. }
  1951. }
  1952. }
  1953. async function _verifyAuth2() {
  1954. try {
  1955. const logStatus = scripts_echoLog({
  1956. text: i18n('verifyingAuth', 'Discord')
  1957. });
  1958. const {
  1959. result,
  1960. statusText,
  1961. status,
  1962. data
  1963. } = await tools_httpRequest({
  1964. url: 'https://discord.com/api/v6/users/@me',
  1965. method: 'HEAD',
  1966. headers: {
  1967. authorization: _classPrivateFieldGet(this, _auth).auth
  1968. }
  1969. });
  1970. if (result === 'Success') {
  1971. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1972. logStatus.success();
  1973. return true;
  1974. }
  1975. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1976. return false;
  1977. }
  1978. logStatus.error(`${result}:${statusText}(${status})`);
  1979. return false;
  1980. } catch (error) {
  1981. throwError(error, 'Discord.verifyAuth');
  1982. return false;
  1983. }
  1984. }
  1985. async function _updateAuth2() {
  1986. try {
  1987. const logStatus = scripts_echoLog({
  1988. text: i18n('updatingAuth', 'Discord')
  1989. });
  1990. return await new Promise(resolve => {
  1991. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1992. active: true,
  1993. insert: true,
  1994. setParent: true
  1995. });
  1996. newTab.onclose = async () => {
  1997. var _GM_getValue2;
  1998. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1999. if (auth) {
  2000. _classPrivateFieldSet(this, _auth, {
  2001. auth: auth
  2002. });
  2003. logStatus.success();
  2004. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  2005. } else {
  2006. logStatus.error('Error: Update discord auth failed!');
  2007. resolve(false);
  2008. }
  2009. };
  2010. });
  2011. } catch (error) {
  2012. throwError(error, 'Discord.updateAuth');
  2013. return false;
  2014. }
  2015. }
  2016. async function _joinServer2(inviteId) {
  2017. try {
  2018. const logStatus = scripts_echoLog({
  2019. type: 'joiningDiscordServer',
  2020. text: inviteId
  2021. });
  2022. const {
  2023. result,
  2024. statusText,
  2025. status,
  2026. data
  2027. } = await tools_httpRequest({
  2028. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2029. method: 'POST',
  2030. dataType: 'json',
  2031. headers: {
  2032. authorization: _classPrivateFieldGet(this, _auth).auth
  2033. }
  2034. });
  2035. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2036. var _data$response, _data$response$guild;
  2037. logStatus.success();
  2038. 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);
  2039. if (guild) {
  2040. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2041. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2042. }
  2043. return true;
  2044. }
  2045. logStatus.error(`${result}:${statusText}(${status})`);
  2046. return false;
  2047. } catch (error) {
  2048. throwError(error, 'Discord.joinServer');
  2049. return false;
  2050. }
  2051. }
  2052. async function _leaveServer2(inviteId) {
  2053. try {
  2054. if (this.whiteList.servers.includes(inviteId)) {
  2055. scripts_echoLog({
  2056. type: 'whiteList',
  2057. text: 'Discord.leaveServer',
  2058. id: inviteId
  2059. });
  2060. return true;
  2061. }
  2062. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2063. if (!guild) {
  2064. return false;
  2065. }
  2066. const logStatus = scripts_echoLog({
  2067. type: 'leavingDiscordServer',
  2068. text: guild
  2069. });
  2070. const {
  2071. result,
  2072. statusText,
  2073. status,
  2074. data
  2075. } = await tools_httpRequest({
  2076. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2077. method: 'DELETE',
  2078. headers: {
  2079. authorization: _classPrivateFieldGet(this, _auth).auth
  2080. }
  2081. });
  2082. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2083. logStatus.success();
  2084. return true;
  2085. }
  2086. logStatus.error(`${result}:${statusText}(${status})`);
  2087. return false;
  2088. } catch (error) {
  2089. throwError(error, 'Discord.leaveServer');
  2090. return false;
  2091. }
  2092. }
  2093. async function _getGuild2(inviteId) {
  2094. try {
  2095. const logStatus = scripts_echoLog({
  2096. type: 'gettingDiscordGuild',
  2097. text: inviteId
  2098. });
  2099. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2100. if (guild) {
  2101. logStatus.success();
  2102. return guild;
  2103. }
  2104. const {
  2105. result,
  2106. statusText,
  2107. status,
  2108. data
  2109. } = await tools_httpRequest({
  2110. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2111. responseType: 'json',
  2112. method: 'GET'
  2113. });
  2114. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2115. var _data$response2, _data$response2$guild;
  2116. 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;
  2117. if (guild) {
  2118. logStatus.success();
  2119. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2120. return guild;
  2121. }
  2122. logStatus.error(`${result}:${statusText}(${status})`);
  2123. return false;
  2124. }
  2125. logStatus.error(`${result}:${statusText}(${status})`);
  2126. return false;
  2127. } catch (error) {
  2128. throwError(error, 'Discord.getGuild');
  2129. return false;
  2130. }
  2131. }
  2132. function _setCache2(inviteId, guild) {
  2133. try {
  2134. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2135. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2136. } catch (error) {
  2137. throwError(error, 'Discord.setCache');
  2138. }
  2139. }
  2140. const social_Discord = Discord;
  2141. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2142. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2143. privateSet.add(obj);
  2144. }
  2145. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2146. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2147. privateMap.set(obj, value);
  2148. }
  2149. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2150. if (privateCollection.has(obj)) {
  2151. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2152. }
  2153. }
  2154. function Instagram_defineProperty(obj, key, value) {
  2155. if (key in obj) {
  2156. Object.defineProperty(obj, key, {
  2157. value: value,
  2158. enumerable: true,
  2159. configurable: true,
  2160. writable: true
  2161. });
  2162. } else {
  2163. obj[key] = value;
  2164. }
  2165. return obj;
  2166. }
  2167. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2168. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2169. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2170. return value;
  2171. }
  2172. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2173. if (descriptor.set) {
  2174. descriptor.set.call(receiver, value);
  2175. } else {
  2176. if (!descriptor.writable) {
  2177. throw new TypeError('attempted to set read only private field');
  2178. }
  2179. descriptor.value = value;
  2180. }
  2181. }
  2182. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2183. if (!privateSet.has(receiver)) {
  2184. throw new TypeError('attempted to get private field on non-instance');
  2185. }
  2186. return fn;
  2187. }
  2188. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2189. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2190. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2191. }
  2192. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2193. if (!privateMap.has(receiver)) {
  2194. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2195. }
  2196. return privateMap.get(receiver);
  2197. }
  2198. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2199. if (descriptor.get) {
  2200. return descriptor.get.call(receiver);
  2201. }
  2202. return descriptor.value;
  2203. }
  2204. const Instagram_defaultTasksTemplate = {
  2205. users: []
  2206. };
  2207. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2208. var Instagram_cache = new WeakMap();
  2209. var Instagram_auth = new WeakMap();
  2210. var Instagram_initialized = new WeakMap();
  2211. var _getUserInfo = new WeakSet();
  2212. var _followUser = new WeakSet();
  2213. var _unfollowUser = new WeakSet();
  2214. var Instagram_setCache = new WeakSet();
  2215. class Instagram extends social_Social {
  2216. constructor() {
  2217. var _GM_getValue;
  2218. super(...arguments);
  2219. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2220. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2221. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2222. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2223. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2224. Instagram_defineProperty(this, 'whiteList', {
  2225. ...JSON.parse(Instagram_defaultTasks),
  2226. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2227. });
  2228. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2229. writable: true,
  2230. value: GM_getValue('instagramCache') || {}
  2231. });
  2232. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2233. writable: true,
  2234. value: {}
  2235. });
  2236. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2237. writable: true,
  2238. value: false
  2239. });
  2240. }
  2241. async init() {
  2242. try {
  2243. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2244. return true;
  2245. }
  2246. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2247. if (isVerified) {
  2248. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2249. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2250. return true;
  2251. }
  2252. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2253. return false;
  2254. } catch (error) {
  2255. throwError(error, 'Instagram.init');
  2256. return false;
  2257. }
  2258. }
  2259. async toggle(_ref) {
  2260. let {
  2261. doTask = true,
  2262. userLinks = []
  2263. } = _ref;
  2264. try {
  2265. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2266. scripts_echoLog({
  2267. text: i18n('needInit')
  2268. });
  2269. return false;
  2270. }
  2271. const prom = [];
  2272. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2273. scripts_echoLog({
  2274. type: 'globalOptionsSkip',
  2275. text: 'instagram.users'
  2276. });
  2277. } else {
  2278. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2279. var _link$match;
  2280. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2281. });
  2282. if (realUsers.length > 0) {
  2283. for (const username of realUsers) {
  2284. if (doTask) {
  2285. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2286. } else {
  2287. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2288. }
  2289. await delay(1e3);
  2290. }
  2291. }
  2292. }
  2293. return await Promise.all(prom).then(() => true);
  2294. } catch (error) {
  2295. throwError(error, 'Instagram.toggleUsers');
  2296. return false;
  2297. }
  2298. }
  2299. }
  2300. async function _getUserInfo2() {
  2301. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2302. try {
  2303. const logStatus = scripts_echoLog({
  2304. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2305. text: name
  2306. });
  2307. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2308. if (userId && name !== 'instagram') {
  2309. logStatus.success();
  2310. return userId;
  2311. }
  2312. const {
  2313. result,
  2314. statusText,
  2315. status,
  2316. data
  2317. } = await tools_httpRequest({
  2318. url: `https://www.instagram.com/${name}/`,
  2319. method: 'GET'
  2320. });
  2321. if (result === 'Success') {
  2322. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2323. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2324. return false;
  2325. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2326. logStatus.error(`Error:${i18n('insBanned')}`);
  2327. return false;
  2328. }
  2329. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2330. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2331. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2332. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2333. if (name === 'instagram') {
  2334. if (csrftoken && hash) {
  2335. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2336. csrftoken: csrftoken,
  2337. hash: hash
  2338. });
  2339. return true;
  2340. }
  2341. return false;
  2342. }
  2343. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2344. if (id) {
  2345. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2346. logStatus.success();
  2347. return id;
  2348. }
  2349. logStatus.error('Error: Get ins data error!');
  2350. return false;
  2351. }
  2352. logStatus.error(`${result}:${statusText}(${status})`);
  2353. return false;
  2354. }
  2355. return false;
  2356. } catch (error) {
  2357. throwError(error, 'Instagram.getUserInfo');
  2358. return false;
  2359. }
  2360. }
  2361. async function _followUser2(name) {
  2362. try {
  2363. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2364. if (!id) {
  2365. return false;
  2366. }
  2367. const logStatus = scripts_echoLog({
  2368. type: 'followingIns',
  2369. text: name
  2370. });
  2371. const {
  2372. result,
  2373. statusText,
  2374. status,
  2375. data
  2376. } = await tools_httpRequest({
  2377. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2378. method: 'POST',
  2379. dataType: 'json',
  2380. headers: {
  2381. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2382. origin: 'https://www.instagram.com',
  2383. referer: `https://www.instagram.com/${name}/`,
  2384. 'content-type': 'application/x-www-form-urlencoded',
  2385. 'sec-fetch-site': 'same-origin',
  2386. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2387. }
  2388. });
  2389. if (result === 'Success') {
  2390. var _data$response, _data$response2;
  2391. 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') {
  2392. logStatus.success();
  2393. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2394. return true;
  2395. }
  2396. 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})`}`);
  2397. return false;
  2398. }
  2399. logStatus.error(`${result}:${statusText}(${status})`);
  2400. return false;
  2401. } catch (error) {
  2402. throwError(error, 'Instagram.followUser');
  2403. return false;
  2404. }
  2405. }
  2406. async function _unfollowUser2(name) {
  2407. try {
  2408. if (this.whiteList.users.includes(name)) {
  2409. scripts_echoLog({
  2410. type: 'whiteList',
  2411. text: 'Instagram.unfollowUser',
  2412. id: name
  2413. });
  2414. return true;
  2415. }
  2416. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2417. if (!id) {
  2418. return false;
  2419. }
  2420. const logStatus = scripts_echoLog({
  2421. type: 'unfollowingIns',
  2422. text: name
  2423. });
  2424. const {
  2425. result,
  2426. statusText,
  2427. status,
  2428. data
  2429. } = await tools_httpRequest({
  2430. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2431. method: 'POST',
  2432. dataType: 'json',
  2433. headers: {
  2434. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2435. origin: 'https://www.instagram.com',
  2436. referer: `https://www.instagram.com/${name}/`,
  2437. 'content-type': 'application/x-www-form-urlencoded',
  2438. 'sec-fetch-site': 'same-origin',
  2439. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2440. }
  2441. });
  2442. if (result === 'Success') {
  2443. var _data$response3;
  2444. 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') {
  2445. logStatus.success();
  2446. return true;
  2447. }
  2448. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2449. return false;
  2450. }
  2451. logStatus.error(`${result}:${statusText}(${status})`);
  2452. return false;
  2453. } catch (error) {
  2454. throwError(error, 'Instagram.unfollowUser');
  2455. return false;
  2456. }
  2457. }
  2458. function Instagram_setCache2(name, id) {
  2459. try {
  2460. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2461. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2462. } catch (error) {
  2463. throwError(error, 'Instagram.setCache');
  2464. }
  2465. }
  2466. const social_Instagram = Instagram;
  2467. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2468. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2469. privateSet.add(obj);
  2470. }
  2471. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2472. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2473. privateMap.set(obj, value);
  2474. }
  2475. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2476. if (privateCollection.has(obj)) {
  2477. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2478. }
  2479. }
  2480. function Reddit_defineProperty(obj, key, value) {
  2481. if (key in obj) {
  2482. Object.defineProperty(obj, key, {
  2483. value: value,
  2484. enumerable: true,
  2485. configurable: true,
  2486. writable: true
  2487. });
  2488. } else {
  2489. obj[key] = value;
  2490. }
  2491. return obj;
  2492. }
  2493. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2494. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2495. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2496. return value;
  2497. }
  2498. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2499. if (descriptor.set) {
  2500. descriptor.set.call(receiver, value);
  2501. } else {
  2502. if (!descriptor.writable) {
  2503. throw new TypeError('attempted to set read only private field');
  2504. }
  2505. descriptor.value = value;
  2506. }
  2507. }
  2508. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2509. if (!privateSet.has(receiver)) {
  2510. throw new TypeError('attempted to get private field on non-instance');
  2511. }
  2512. return fn;
  2513. }
  2514. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2515. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2516. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2517. }
  2518. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2519. if (!privateMap.has(receiver)) {
  2520. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2521. }
  2522. return privateMap.get(receiver);
  2523. }
  2524. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2525. if (descriptor.get) {
  2526. return descriptor.get.call(receiver);
  2527. }
  2528. return descriptor.value;
  2529. }
  2530. const Reddit_defaultTasksTemplate = {
  2531. reddits: []
  2532. };
  2533. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2534. var Reddit_auth = new WeakMap();
  2535. var Reddit_initialized = new WeakMap();
  2536. var _useBeta = new WeakSet();
  2537. var Reddit_updateAuth = new WeakSet();
  2538. class Reddit extends social_Social {
  2539. constructor() {
  2540. var _GM_getValue;
  2541. super(...arguments);
  2542. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2543. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2544. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2545. Reddit_defineProperty(this, 'whiteList', {
  2546. ...JSON.parse(Reddit_defaultTasks),
  2547. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2548. });
  2549. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2550. writable: true,
  2551. value: void 0
  2552. });
  2553. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2554. writable: true,
  2555. value: false
  2556. });
  2557. }
  2558. async init() {
  2559. try {
  2560. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2561. return true;
  2562. }
  2563. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2564. if (isVerified) {
  2565. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2566. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2567. return true;
  2568. }
  2569. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2570. return false;
  2571. } catch (error) {
  2572. throwError(error, 'Reddit.init');
  2573. return false;
  2574. }
  2575. }
  2576. async toggleTask(_ref) {
  2577. let {
  2578. name,
  2579. doTask = true
  2580. } = _ref;
  2581. try {
  2582. if (!doTask && this.whiteList.reddits.includes(name)) {
  2583. scripts_echoLog({
  2584. type: 'whiteList',
  2585. text: 'Reddit.undoTask',
  2586. id: name
  2587. });
  2588. return true;
  2589. }
  2590. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2591. if (/^u_/.test(name)) {
  2592. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2593. }
  2594. const logStatus = scripts_echoLog({
  2595. type: type,
  2596. text: name
  2597. });
  2598. const {
  2599. result,
  2600. statusText,
  2601. status,
  2602. data
  2603. } = await tools_httpRequest({
  2604. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2605. method: 'POST',
  2606. headers: {
  2607. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2608. 'content-type': 'application/x-www-form-urlencoded'
  2609. },
  2610. data: $.param({
  2611. action: doTask ? 'sub' : 'unsub',
  2612. sr_name: name,
  2613. api_type: 'json'
  2614. })
  2615. });
  2616. if (result === 'Success') {
  2617. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2618. logStatus.success();
  2619. if (doTask) {
  2620. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2621. }
  2622. return true;
  2623. }
  2624. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2625. return false;
  2626. }
  2627. logStatus.error(`${result}:${statusText}(${status})`);
  2628. return false;
  2629. } catch (error) {
  2630. throwError(error, 'Reddit.toggleTask');
  2631. return false;
  2632. }
  2633. }
  2634. async toggle(_ref2) {
  2635. let {
  2636. doTask = true,
  2637. redditLinks = []
  2638. } = _ref2;
  2639. try {
  2640. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2641. scripts_echoLog({
  2642. text: i18n('needInit')
  2643. });
  2644. return false;
  2645. }
  2646. const prom = [];
  2647. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2648. scripts_echoLog({
  2649. type: 'globalOptionsSkip',
  2650. text: 'reddit.reddits'
  2651. });
  2652. } else {
  2653. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2654. var _link$match, _link$match2;
  2655. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2656. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2657. if (userName) {
  2658. return name || userName;
  2659. }
  2660. return name;
  2661. });
  2662. if (realReddits.length > 0) {
  2663. for (const name of realReddits) {
  2664. prom.push(this.toggleTask({
  2665. name: name,
  2666. doTask: doTask
  2667. }));
  2668. await delay(1e3);
  2669. }
  2670. }
  2671. }
  2672. return await Promise.all(prom).then(() => true);
  2673. } catch (error) {
  2674. throwError(error, 'Reddit.toggle');
  2675. return false;
  2676. }
  2677. }
  2678. }
  2679. async function _useBeta2() {
  2680. try {
  2681. const logStatus = scripts_echoLog({
  2682. text: i18n('changingRedditVersion')
  2683. });
  2684. GM_setValue('redditAuth', null);
  2685. return await new Promise(resolve => {
  2686. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2687. active: true,
  2688. insert: true,
  2689. setParent: true
  2690. });
  2691. newTab.onclose = async () => {
  2692. logStatus.success();
  2693. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2694. };
  2695. });
  2696. } catch (error) {
  2697. throwError(error, 'Reddit.useBeta');
  2698. return false;
  2699. }
  2700. }
  2701. async function Reddit_updateAuth2() {
  2702. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2703. try {
  2704. const logStatus = scripts_echoLog({
  2705. text: i18n('updatingAuth', 'Reddit')
  2706. });
  2707. const {
  2708. result,
  2709. statusText,
  2710. status,
  2711. data
  2712. } = await tools_httpRequest({
  2713. url: 'https://www.reddit.com/',
  2714. method: 'GET',
  2715. nochche: true,
  2716. headers: {
  2717. 'Cache-Control': 'no-cache'
  2718. }
  2719. });
  2720. if (result === 'Success') {
  2721. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2722. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2723. return false;
  2724. }
  2725. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2726. var _data$responseText$ma;
  2727. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2728. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2729. }
  2730. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2731. if (accessToken) {
  2732. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2733. token: accessToken
  2734. });
  2735. logStatus.success();
  2736. return true;
  2737. }
  2738. logStatus.error('Error: Parameter "accessToken" not found!');
  2739. return false;
  2740. }
  2741. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2742. return false;
  2743. }
  2744. logStatus.error(`${result}:${statusText}(${status})`);
  2745. return false;
  2746. } catch (error) {
  2747. throwError(error, 'Reddit.updateAuth');
  2748. return false;
  2749. }
  2750. }
  2751. const social_Reddit = Reddit;
  2752. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2753. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2754. privateSet.add(obj);
  2755. }
  2756. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2757. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2758. privateMap.set(obj, value);
  2759. }
  2760. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2761. if (privateCollection.has(obj)) {
  2762. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2763. }
  2764. }
  2765. function Twitch_defineProperty(obj, key, value) {
  2766. if (key in obj) {
  2767. Object.defineProperty(obj, key, {
  2768. value: value,
  2769. enumerable: true,
  2770. configurable: true,
  2771. writable: true
  2772. });
  2773. } else {
  2774. obj[key] = value;
  2775. }
  2776. return obj;
  2777. }
  2778. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2779. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2780. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2781. return value;
  2782. }
  2783. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2784. if (descriptor.set) {
  2785. descriptor.set.call(receiver, value);
  2786. } else {
  2787. if (!descriptor.writable) {
  2788. throw new TypeError('attempted to set read only private field');
  2789. }
  2790. descriptor.value = value;
  2791. }
  2792. }
  2793. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2794. if (!privateSet.has(receiver)) {
  2795. throw new TypeError('attempted to get private field on non-instance');
  2796. }
  2797. return fn;
  2798. }
  2799. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2800. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2801. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2802. }
  2803. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2804. if (!privateMap.has(receiver)) {
  2805. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2806. }
  2807. return privateMap.get(receiver);
  2808. }
  2809. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2810. if (descriptor.get) {
  2811. return descriptor.get.call(receiver);
  2812. }
  2813. return descriptor.value;
  2814. }
  2815. const Twitch_defaultTasksTemplate = {
  2816. channels: []
  2817. };
  2818. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2819. var Twitch_auth = new WeakMap();
  2820. var Twitch_cache = new WeakMap();
  2821. var Twitch_initialized = new WeakMap();
  2822. var Twitch_verifyAuth = new WeakSet();
  2823. var Twitch_updateAuth = new WeakSet();
  2824. var _toggleChannel = new WeakSet();
  2825. var _getChannelId = new WeakSet();
  2826. var Twitch_setCache = new WeakSet();
  2827. class Twitch extends social_Social {
  2828. constructor() {
  2829. var _GM_getValue;
  2830. super(...arguments);
  2831. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2832. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2833. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2834. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2835. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2836. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2837. Twitch_defineProperty(this, 'whiteList', {
  2838. ...JSON.parse(Twitch_defaultTasks),
  2839. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2840. });
  2841. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2842. writable: true,
  2843. value: GM_getValue('twitchAuth') || {}
  2844. });
  2845. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2846. writable: true,
  2847. value: GM_getValue('twitchCache') || {}
  2848. });
  2849. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2850. writable: true,
  2851. value: false
  2852. });
  2853. }
  2854. async init() {
  2855. try {
  2856. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2857. return true;
  2858. }
  2859. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2860. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2861. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2862. return true;
  2863. }
  2864. return false;
  2865. }
  2866. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2867. if (isVerified) {
  2868. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2869. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2870. return true;
  2871. }
  2872. GM_setValue('twitchAuth', null);
  2873. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2874. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2875. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2876. return true;
  2877. }
  2878. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2879. return false;
  2880. } catch (error) {
  2881. throwError(error, 'Twitch.init');
  2882. return false;
  2883. }
  2884. }
  2885. async toggle(_ref) {
  2886. let {
  2887. doTask = true,
  2888. channelLinks = []
  2889. } = _ref;
  2890. try {
  2891. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2892. scripts_echoLog({
  2893. text: i18n('needInit')
  2894. });
  2895. return false;
  2896. }
  2897. const prom = [];
  2898. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2899. scripts_echoLog({
  2900. type: 'globalOptionsSkip',
  2901. text: 'twitch.channels'
  2902. });
  2903. } else {
  2904. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2905. var _link$match;
  2906. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2907. });
  2908. if (realChannels.length > 0) {
  2909. for (const channel of realChannels) {
  2910. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2911. name: channel,
  2912. doTask: doTask
  2913. }));
  2914. await delay(1e3);
  2915. }
  2916. }
  2917. }
  2918. return Promise.all(prom).then(() => true);
  2919. } catch (error) {
  2920. throwError(error, 'Twitch.toggle');
  2921. return false;
  2922. }
  2923. }
  2924. }
  2925. async function Twitch_verifyAuth2() {
  2926. try {
  2927. const logStatus = scripts_echoLog({
  2928. text: i18n('verifyingAuth', 'Twitch')
  2929. });
  2930. const {
  2931. result,
  2932. statusText,
  2933. status,
  2934. data
  2935. } = await tools_httpRequest({
  2936. url: 'https://gql.twitch.tv/gql',
  2937. method: 'POST',
  2938. dataType: 'json',
  2939. headers: {
  2940. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2941. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2942. },
  2943. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2944. });
  2945. if (result === 'Success') {
  2946. var _data$response, _data$response$, _data$response$$data;
  2947. 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) {
  2948. logStatus.success();
  2949. return true;
  2950. }
  2951. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2952. return false;
  2953. }
  2954. logStatus.error(`${result}:${statusText}(${status})`);
  2955. return false;
  2956. } catch (error) {
  2957. throwError(error, 'Twitch.verifyAuth');
  2958. return false;
  2959. }
  2960. }
  2961. async function Twitch_updateAuth2() {
  2962. try {
  2963. const logStatus = scripts_echoLog({
  2964. text: i18n('updatingAuth', 'Twitch')
  2965. });
  2966. return await new Promise(resolve => {
  2967. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2968. active: true,
  2969. insert: true,
  2970. setParent: true
  2971. });
  2972. newTab.onclose = async () => {
  2973. const auth = GM_getValue('twitchAuth');
  2974. if (auth) {
  2975. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2976. logStatus.success();
  2977. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2978. } else {
  2979. logStatus.error('Error: Update twitch auth failed!');
  2980. resolve(false);
  2981. }
  2982. };
  2983. });
  2984. } catch (error) {
  2985. throwError(error, 'Twitch.updateAuth');
  2986. return false;
  2987. }
  2988. }
  2989. async function _toggleChannel2(_ref2) {
  2990. let {
  2991. name,
  2992. doTask = true
  2993. } = _ref2;
  2994. try {
  2995. if (!doTask && this.whiteList.channels.includes(name)) {
  2996. scripts_echoLog({
  2997. type: 'whiteList',
  2998. text: 'Twitch.unfollowChannel',
  2999. id: name
  3000. });
  3001. return true;
  3002. }
  3003. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  3004. if (!channelId) {
  3005. return false;
  3006. }
  3007. const logStatus = scripts_echoLog({
  3008. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  3009. text: name
  3010. });
  3011. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  3012. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  3013. const {
  3014. result,
  3015. statusText,
  3016. status,
  3017. data
  3018. } = await tools_httpRequest({
  3019. url: 'https://gql.twitch.tv/gql',
  3020. method: 'POST',
  3021. dataType: 'json',
  3022. headers: {
  3023. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  3024. },
  3025. data: doTask ? followData : unfollowData
  3026. });
  3027. if (result === 'Success') {
  3028. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3029. logStatus.success();
  3030. if (doTask) {
  3031. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3032. }
  3033. return true;
  3034. }
  3035. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3036. return false;
  3037. }
  3038. logStatus.error(`${result}:${statusText}(${status})`);
  3039. return false;
  3040. } catch (error) {
  3041. throwError(error, 'Twitch.toggleChannel');
  3042. return false;
  3043. }
  3044. }
  3045. async function _getChannelId2(name) {
  3046. try {
  3047. const logStatus = scripts_echoLog({
  3048. type: 'gettingTwitchChannelId',
  3049. text: name
  3050. });
  3051. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3052. if (channelId) {
  3053. logStatus.success();
  3054. return channelId;
  3055. }
  3056. const {
  3057. result,
  3058. statusText,
  3059. status,
  3060. data
  3061. } = await tools_httpRequest({
  3062. url: 'https://gql.twitch.tv/gql',
  3063. method: 'POST',
  3064. headers: {
  3065. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3066. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3067. },
  3068. responseType: 'json',
  3069. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3070. });
  3071. if (result === 'Success') {
  3072. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3073. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3074. 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);
  3075. if (channelId) {
  3076. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3077. logStatus.success();
  3078. return channelId;
  3079. }
  3080. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3081. return false;
  3082. }
  3083. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3084. return false;
  3085. }
  3086. logStatus.error(`${result}:${statusText}(${status})`);
  3087. return false;
  3088. } catch (error) {
  3089. throwError(error, 'Twitch.getChannelId');
  3090. return false;
  3091. }
  3092. }
  3093. function Twitch_setCache2(name, id) {
  3094. try {
  3095. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3096. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3097. } catch (error) {
  3098. throwError(error, 'Twitch.setCache');
  3099. }
  3100. }
  3101. const social_Twitch = Twitch;
  3102. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3103. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3104. privateSet.add(obj);
  3105. }
  3106. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3107. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3108. privateMap.set(obj, value);
  3109. }
  3110. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3111. if (privateCollection.has(obj)) {
  3112. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3113. }
  3114. }
  3115. function Twitter_defineProperty(obj, key, value) {
  3116. if (key in obj) {
  3117. Object.defineProperty(obj, key, {
  3118. value: value,
  3119. enumerable: true,
  3120. configurable: true,
  3121. writable: true
  3122. });
  3123. } else {
  3124. obj[key] = value;
  3125. }
  3126. return obj;
  3127. }
  3128. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3129. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3130. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3131. return value;
  3132. }
  3133. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3134. if (descriptor.set) {
  3135. descriptor.set.call(receiver, value);
  3136. } else {
  3137. if (!descriptor.writable) {
  3138. throw new TypeError('attempted to set read only private field');
  3139. }
  3140. descriptor.value = value;
  3141. }
  3142. }
  3143. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3144. if (!privateSet.has(receiver)) {
  3145. throw new TypeError('attempted to get private field on non-instance');
  3146. }
  3147. return fn;
  3148. }
  3149. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3150. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3151. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3152. }
  3153. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3154. if (!privateMap.has(receiver)) {
  3155. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3156. }
  3157. return privateMap.get(receiver);
  3158. }
  3159. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3160. if (descriptor.get) {
  3161. return descriptor.get.call(receiver);
  3162. }
  3163. return descriptor.value;
  3164. }
  3165. const Twitter_defaultTasksTemplate = {
  3166. users: [],
  3167. retweets: [],
  3168. likes: []
  3169. };
  3170. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3171. var _verifyId = new WeakMap();
  3172. var Twitter_auth = new WeakMap();
  3173. var Twitter_cache = new WeakMap();
  3174. var Twitter_initialized = new WeakMap();
  3175. var Twitter_verifyAuth = new WeakSet();
  3176. var Twitter_updateAuth = new WeakSet();
  3177. var _toggleUser = new WeakSet();
  3178. var _toggleRetweet = new WeakSet();
  3179. var Twitter_setCache = new WeakSet();
  3180. class Twitter extends social_Social {
  3181. constructor() {
  3182. var _GM_getValue;
  3183. super(...arguments);
  3184. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3185. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3186. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3187. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3188. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3189. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3190. Twitter_defineProperty(this, 'whiteList', {
  3191. ...JSON.parse(Twitter_defaultTasks),
  3192. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3193. });
  3194. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3195. writable: true,
  3196. value: globalOptions.other.twitterVerifyId
  3197. });
  3198. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3199. writable: true,
  3200. value: GM_getValue('twitterAuth') || {}
  3201. });
  3202. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3203. writable: true,
  3204. value: GM_getValue('twitterCache') || {}
  3205. });
  3206. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3207. writable: true,
  3208. value: false
  3209. });
  3210. }
  3211. async init() {
  3212. try {
  3213. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3214. return true;
  3215. }
  3216. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3217. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3218. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3219. return true;
  3220. }
  3221. return false;
  3222. }
  3223. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3224. if (isVerified) {
  3225. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3226. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3227. return true;
  3228. }
  3229. GM_setValue('twitterAuth', null);
  3230. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3231. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3232. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3233. return true;
  3234. }
  3235. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3236. return false;
  3237. } catch (error) {
  3238. throwError(error, 'Twitter.init');
  3239. return false;
  3240. }
  3241. }
  3242. async userName2id(name) {
  3243. try {
  3244. const logStatus = scripts_echoLog({
  3245. type: 'gettingTwitterUserId',
  3246. text: name
  3247. });
  3248. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3249. if (userId) {
  3250. logStatus.success();
  3251. return userId;
  3252. }
  3253. const {
  3254. result,
  3255. statusText,
  3256. status,
  3257. data
  3258. } = await tools_httpRequest({
  3259. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3260. method: 'GET',
  3261. headers: {
  3262. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3263. 'content-type': 'application/json'
  3264. },
  3265. responseType: 'json',
  3266. anonymous: true
  3267. });
  3268. if (result === 'Success') {
  3269. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3270. var _response, _response$data, _response$data$user;
  3271. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3272. if (!response) {
  3273. try {
  3274. response = JSON.parse(data.responseText);
  3275. } catch (error) {
  3276. response = null;
  3277. }
  3278. }
  3279. 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);
  3280. if (userId) {
  3281. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3282. logStatus.success();
  3283. return userId;
  3284. }
  3285. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3286. return false;
  3287. }
  3288. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3289. return false;
  3290. }
  3291. logStatus.error(`${result}:${statusText}(${status})`);
  3292. return false;
  3293. } catch (error) {
  3294. throwError(error, 'Twitter.getUserId');
  3295. return false;
  3296. }
  3297. }
  3298. async toggle(_ref) {
  3299. let {
  3300. doTask = true,
  3301. userLinks = [],
  3302. retweetLinks = []
  3303. } = _ref;
  3304. try {
  3305. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3306. scripts_echoLog({
  3307. text: i18n('needInit')
  3308. });
  3309. return false;
  3310. }
  3311. const prom = [];
  3312. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3313. scripts_echoLog({
  3314. type: 'globalOptionsSkip',
  3315. text: 'twitter.users'
  3316. });
  3317. } else {
  3318. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3319. var _link$match;
  3320. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3321. });
  3322. if (realUsers.length > 0) {
  3323. for (const user of realUsers) {
  3324. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3325. name: user,
  3326. doTask: doTask
  3327. }));
  3328. await delay(1e3);
  3329. }
  3330. }
  3331. }
  3332. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3333. scripts_echoLog({
  3334. type: 'globalOptionsSkip',
  3335. text: 'twitter.retweets'
  3336. });
  3337. } else {
  3338. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3339. var _link$match2;
  3340. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3341. });
  3342. if (realRetweets.length > 0) {
  3343. for (const retweet of realRetweets) {
  3344. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3345. retweetId: retweet,
  3346. doTask: doTask
  3347. }));
  3348. await delay(1e3);
  3349. }
  3350. }
  3351. }
  3352. return Promise.all(prom).then(() => true);
  3353. } catch (error) {
  3354. throwError(error, 'Twitter.toggle');
  3355. return false;
  3356. }
  3357. }
  3358. }
  3359. async function Twitter_verifyAuth2() {
  3360. try {
  3361. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3362. name: 'verify',
  3363. doTask: true,
  3364. verify: true
  3365. });
  3366. } catch (error) {
  3367. throwError(error, 'Twitter.verifyAuth');
  3368. return false;
  3369. }
  3370. }
  3371. async function Twitter_updateAuth2() {
  3372. try {
  3373. const logStatus = scripts_echoLog({
  3374. text: i18n('updatingAuth', 'Twitter')
  3375. });
  3376. return await new Promise(resolve => {
  3377. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3378. active: true,
  3379. insert: true,
  3380. setParent: true
  3381. });
  3382. newTab.onclose = async () => {
  3383. const auth = GM_getValue('twitterAuth');
  3384. if (auth) {
  3385. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3386. logStatus.success();
  3387. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3388. } else {
  3389. logStatus.error('Error: Update twitter auth failed!');
  3390. resolve(false);
  3391. }
  3392. };
  3393. });
  3394. } catch (error) {
  3395. throwError(error, 'Twitter.updateToken');
  3396. return false;
  3397. }
  3398. }
  3399. async function _toggleUser2(_ref2) {
  3400. let {
  3401. name,
  3402. doTask = true,
  3403. verify = false
  3404. } = _ref2;
  3405. try {
  3406. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3407. scripts_echoLog({
  3408. type: 'whiteList',
  3409. text: 'Twitter.unfollowUser',
  3410. id: name
  3411. });
  3412. return true;
  3413. }
  3414. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3415. if (!userId) {
  3416. return false;
  3417. }
  3418. const logStatus = verify ? scripts_echoLog({
  3419. text: i18n('verifyingAuth', 'Twitter')
  3420. }) : scripts_echoLog({
  3421. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3422. text: name
  3423. });
  3424. const {
  3425. result,
  3426. statusText,
  3427. status,
  3428. data
  3429. } = await tools_httpRequest({
  3430. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3431. method: 'POST',
  3432. headers: {
  3433. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3434. 'Content-Type': 'application/x-www-form-urlencoded',
  3435. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3436. },
  3437. responseType: 'json',
  3438. data: $.param({
  3439. include_profile_interstitial_type: 1,
  3440. include_blocking: 1,
  3441. include_blocked_by: 1,
  3442. include_followed_by: 1,
  3443. include_want_retweets: 1,
  3444. include_mute_edge: 1,
  3445. include_can_dm: 1,
  3446. include_can_media_tag: 1,
  3447. skip_status: 1,
  3448. id: userId
  3449. })
  3450. });
  3451. if (result === 'Success') {
  3452. var _data$response, _data$response$errors, _data$response$errors2;
  3453. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3454. logStatus.success();
  3455. if (doTask && !verify) {
  3456. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3457. }
  3458. return true;
  3459. }
  3460. 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) {
  3461. logStatus.success();
  3462. return true;
  3463. }
  3464. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3465. return false;
  3466. }
  3467. logStatus.error(`${result}:${statusText}(${status})`);
  3468. return false;
  3469. } catch (error) {
  3470. throwError(error, 'Twitter.toggleUser');
  3471. return false;
  3472. }
  3473. }
  3474. async function _toggleRetweet2(_ref3) {
  3475. let {
  3476. retweetId,
  3477. doTask = true
  3478. } = _ref3;
  3479. try {
  3480. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3481. scripts_echoLog({
  3482. type: 'whiteList',
  3483. text: 'Twitter.unretweet',
  3484. id: retweetId
  3485. });
  3486. return true;
  3487. }
  3488. const logStatus = scripts_echoLog({
  3489. type: `${doTask ? '' : 'un'}retweetting`,
  3490. text: retweetId
  3491. });
  3492. const {
  3493. result,
  3494. statusText,
  3495. status,
  3496. data
  3497. } = await tools_httpRequest({
  3498. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3499. method: 'POST',
  3500. headers: {
  3501. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3502. 'Content-Type': 'application/x-www-form-urlencoded',
  3503. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3504. },
  3505. data: $.param({
  3506. tweet_mode: 'extended',
  3507. id: retweetId
  3508. }),
  3509. responseType: 'json'
  3510. });
  3511. if (result === 'Success') {
  3512. var _data$response2, _data$response2$error, _data$response2$error2;
  3513. 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) {
  3514. logStatus.success();
  3515. if (doTask) {
  3516. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3517. }
  3518. return true;
  3519. }
  3520. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3521. return false;
  3522. }
  3523. logStatus.error(`${result}:${statusText}(${status})`);
  3524. return false;
  3525. } catch (error) {
  3526. throwError(error, 'Twitter.toggleRetweet');
  3527. return false;
  3528. }
  3529. }
  3530. function Twitter_setCache2(name, id) {
  3531. try {
  3532. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3533. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3534. } catch (error) {
  3535. throwError(error, 'Twitter.setCache');
  3536. }
  3537. }
  3538. const social_Twitter = Twitter;
  3539. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3540. Vk_checkPrivateRedeclaration(obj, privateSet);
  3541. privateSet.add(obj);
  3542. }
  3543. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3544. Vk_checkPrivateRedeclaration(obj, privateMap);
  3545. privateMap.set(obj, value);
  3546. }
  3547. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3548. if (privateCollection.has(obj)) {
  3549. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3550. }
  3551. }
  3552. function Vk_defineProperty(obj, key, value) {
  3553. if (key in obj) {
  3554. Object.defineProperty(obj, key, {
  3555. value: value,
  3556. enumerable: true,
  3557. configurable: true,
  3558. writable: true
  3559. });
  3560. } else {
  3561. obj[key] = value;
  3562. }
  3563. return obj;
  3564. }
  3565. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3566. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3567. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3568. return value;
  3569. }
  3570. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3571. if (descriptor.set) {
  3572. descriptor.set.call(receiver, value);
  3573. } else {
  3574. if (!descriptor.writable) {
  3575. throw new TypeError('attempted to set read only private field');
  3576. }
  3577. descriptor.value = value;
  3578. }
  3579. }
  3580. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3581. if (!privateSet.has(receiver)) {
  3582. throw new TypeError('attempted to get private field on non-instance');
  3583. }
  3584. return fn;
  3585. }
  3586. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3587. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3588. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3589. }
  3590. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3591. if (!privateMap.has(receiver)) {
  3592. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3593. }
  3594. return privateMap.get(receiver);
  3595. }
  3596. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3597. if (descriptor.get) {
  3598. return descriptor.get.call(receiver);
  3599. }
  3600. return descriptor.value;
  3601. }
  3602. const Vk_defaultTasksTemplate = {
  3603. names: []
  3604. };
  3605. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3606. var _username = new WeakMap();
  3607. var Vk_cache = new WeakMap();
  3608. var Vk_initialized = new WeakMap();
  3609. var Vk_verifyAuth = new WeakSet();
  3610. var _toggleGroup = new WeakSet();
  3611. var _togglePublic = new WeakSet();
  3612. var _sendWall = new WeakSet();
  3613. var _deleteWall = new WeakSet();
  3614. var _getId = new WeakSet();
  3615. var _toggleVk = new WeakSet();
  3616. var Vk_setCache = new WeakSet();
  3617. class Vk extends social_Social {
  3618. constructor() {
  3619. var _GM_getValue;
  3620. super(...arguments);
  3621. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3622. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3623. Vk_classPrivateMethodInitSpec(this, _getId);
  3624. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3625. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3626. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3627. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3628. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3629. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3630. Vk_defineProperty(this, 'whiteList', {
  3631. ...JSON.parse(Vk_defaultTasks),
  3632. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3633. });
  3634. Vk_classPrivateFieldInitSpec(this, _username, {
  3635. writable: true,
  3636. value: ''
  3637. });
  3638. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3639. writable: true,
  3640. value: GM_getValue('vkCache') || {}
  3641. });
  3642. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3643. writable: true,
  3644. value: false
  3645. });
  3646. }
  3647. async init() {
  3648. try {
  3649. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3650. return true;
  3651. }
  3652. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3653. if (isVerified) {
  3654. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3655. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3656. return true;
  3657. }
  3658. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3659. return false;
  3660. } catch (error) {
  3661. throwError(error, 'Vk.init');
  3662. return false;
  3663. }
  3664. }
  3665. async toggle(_ref) {
  3666. let {
  3667. doTask = true,
  3668. nameLinks = []
  3669. } = _ref;
  3670. try {
  3671. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3672. scripts_echoLog({
  3673. text: i18n('needInit')
  3674. });
  3675. return false;
  3676. }
  3677. const prom = [];
  3678. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3679. scripts_echoLog({
  3680. type: 'globalOptionsSkip',
  3681. text: 'vk.names'
  3682. });
  3683. } else {
  3684. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3685. var _link$match;
  3686. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3687. });
  3688. if (realNames.length > 0) {
  3689. for (const name of realNames) {
  3690. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3691. name: name,
  3692. doTask: doTask
  3693. }));
  3694. await delay(1e3);
  3695. }
  3696. }
  3697. }
  3698. return Promise.all(prom).then(() => true);
  3699. } catch (error) {
  3700. throwError(error, 'Vk.toggle');
  3701. return false;
  3702. }
  3703. }
  3704. }
  3705. async function Vk_verifyAuth2() {
  3706. try {
  3707. const logStatus = scripts_echoLog({
  3708. text: i18n('verifyAuth', 'Vk')
  3709. });
  3710. const {
  3711. result,
  3712. statusText,
  3713. status,
  3714. data
  3715. } = await tools_httpRequest({
  3716. url: 'https://vk.com/im',
  3717. method: 'GET'
  3718. });
  3719. if (result === 'Success') {
  3720. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3721. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3722. return false;
  3723. }
  3724. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3725. var _data$responseText$ma;
  3726. 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]) || '');
  3727. logStatus.success();
  3728. return true;
  3729. }
  3730. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3731. return false;
  3732. }
  3733. logStatus.error(`${result}:${statusText}(${status})`);
  3734. return false;
  3735. } catch (error) {
  3736. throwError(error, 'Vk.verifyAuth');
  3737. return false;
  3738. }
  3739. }
  3740. async function _toggleGroup2(name, dataParam) {
  3741. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3742. try {
  3743. const logStatus = scripts_echoLog({
  3744. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3745. text: name
  3746. });
  3747. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3748. logStatus.success();
  3749. return true;
  3750. }
  3751. const reqData = {
  3752. act: doTask ? 'enter' : 'leave',
  3753. al: 1,
  3754. gid: dataParam.groupId,
  3755. hash: dataParam.groupHash
  3756. };
  3757. if (doTask) {
  3758. reqData.context = '_';
  3759. }
  3760. const {
  3761. result,
  3762. statusText,
  3763. status,
  3764. data
  3765. } = await tools_httpRequest({
  3766. url: 'https://vk.com/al_groups.php',
  3767. method: 'POST',
  3768. headers: {
  3769. origin: 'https://vk.com',
  3770. referer: `https://vk.com/${name}`,
  3771. 'content-type': 'application/x-www-form-urlencoded'
  3772. },
  3773. data: $.param(reqData)
  3774. });
  3775. if (result === 'Success') {
  3776. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3777. logStatus.success();
  3778. if (doTask) {
  3779. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3780. }
  3781. return true;
  3782. }
  3783. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3784. return false;
  3785. }
  3786. logStatus.error(`${result}:${statusText}(${status})`);
  3787. return false;
  3788. } catch (error) {
  3789. throwError(error, 'Vk.toggleGroup');
  3790. return false;
  3791. }
  3792. }
  3793. async function _togglePublic2(name, dataParam) {
  3794. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3795. try {
  3796. const logStatus = scripts_echoLog({
  3797. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3798. text: name
  3799. });
  3800. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3801. logStatus.success();
  3802. return true;
  3803. }
  3804. const {
  3805. result,
  3806. statusText,
  3807. status,
  3808. data
  3809. } = await tools_httpRequest({
  3810. url: 'https://vk.com/al_public.php',
  3811. method: 'POST',
  3812. headers: {
  3813. origin: 'https://vk.com',
  3814. referer: `https://vk.com/${name}`,
  3815. 'content-type': 'application/x-www-form-urlencoded'
  3816. },
  3817. data: $.param({
  3818. act: doTask ? 'a_enter' : 'a_leave',
  3819. al: 1,
  3820. pid: dataParam.publicPid,
  3821. hash: dataParam.publicHash
  3822. })
  3823. });
  3824. if (result === 'Success') {
  3825. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3826. logStatus.success();
  3827. if (doTask) {
  3828. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3829. }
  3830. return true;
  3831. }
  3832. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3833. return false;
  3834. }
  3835. logStatus.error(`${result}:${statusText}(${status})`);
  3836. return false;
  3837. } catch (error) {
  3838. throwError(error, 'Vk.togglePublic');
  3839. return false;
  3840. }
  3841. }
  3842. async function _sendWall2(name) {
  3843. try {
  3844. const logStatus = scripts_echoLog({
  3845. type: 'sendingVkWall',
  3846. text: name
  3847. });
  3848. const {
  3849. result,
  3850. statusText,
  3851. status,
  3852. data
  3853. } = await tools_httpRequest({
  3854. url: 'https://vk.com/like.php',
  3855. method: 'POST',
  3856. headers: {
  3857. origin: 'https://vk.com',
  3858. referer: `https://vk.com/${name}`,
  3859. 'content-type': 'application/x-www-form-urlencoded'
  3860. },
  3861. data: $.param({
  3862. act: 'publish_box',
  3863. al: 1,
  3864. object: name
  3865. })
  3866. });
  3867. if (result === 'Success') {
  3868. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3869. var _data$responseText$ma2;
  3870. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3871. if (hash) {
  3872. const {
  3873. result: resultR,
  3874. statusText: statusTextR,
  3875. status: statusR,
  3876. data: dataR
  3877. } = await tools_httpRequest({
  3878. url: 'https://vk.com/like.php',
  3879. method: 'POST',
  3880. headers: {
  3881. origin: 'https://vk.com',
  3882. referer: `https://vk.com/${name}`,
  3883. 'content-type': 'application/x-www-form-urlencoded'
  3884. },
  3885. data: $.param({
  3886. Message: '',
  3887. act: 'a_do_publish',
  3888. al: 1,
  3889. close_comments: 0,
  3890. friends_only: 0,
  3891. from: 'box',
  3892. hash: hash,
  3893. list: '',
  3894. mark_as_ads: 0,
  3895. mute_notifications: 0,
  3896. object: name,
  3897. ret_data: 1,
  3898. to: 0
  3899. })
  3900. });
  3901. if (resultR === 'Success') {
  3902. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3903. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3904. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3905. 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) {
  3906. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3907. logStatus.success();
  3908. 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);
  3909. 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);
  3910. if (postId && ownerId) {
  3911. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3912. }
  3913. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3914. return true;
  3915. }
  3916. }
  3917. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3918. return false;
  3919. }
  3920. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3921. return false;
  3922. }
  3923. logStatus.error('Error: Get "hash" failed');
  3924. return false;
  3925. }
  3926. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3927. return false;
  3928. }
  3929. logStatus.error(`${result}:${statusText}(${status})`);
  3930. return false;
  3931. } catch (error) {
  3932. throwError(error, 'Vk.sendWall');
  3933. return false;
  3934. }
  3935. }
  3936. async function _deleteWall2(name, dataParams) {
  3937. try {
  3938. const logStatus = scripts_echoLog({
  3939. type: 'deletingVkWall',
  3940. text: name
  3941. });
  3942. const {
  3943. result,
  3944. statusText,
  3945. status,
  3946. data
  3947. } = await tools_httpRequest({
  3948. url: 'https://vk.com/al_wall.php?act=delete',
  3949. method: 'POST',
  3950. headers: {
  3951. origin: 'https://vk.com',
  3952. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3953. 'content-type': 'application/x-www-form-urlencoded'
  3954. },
  3955. data: $.param({
  3956. act: 'delete',
  3957. al: 1,
  3958. confirm: 0,
  3959. from: 'wkview',
  3960. hash: dataParams.wallHash,
  3961. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3962. })
  3963. });
  3964. if (result === 'Success') {
  3965. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3966. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3967. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3968. 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]) {
  3969. logStatus.success();
  3970. return true;
  3971. }
  3972. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3973. return false;
  3974. }
  3975. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3976. return false;
  3977. }
  3978. logStatus.error(`${result}:${statusText}(${status})`);
  3979. return false;
  3980. } catch (error) {
  3981. throwError(error, 'Vk.deleteWall');
  3982. return false;
  3983. }
  3984. }
  3985. async function _getId2(name, doTask) {
  3986. try {
  3987. let url = `https://vk.com/${name}`;
  3988. if (/^wall-/.test(name)) {
  3989. if (doTask) {
  3990. return {
  3991. type: 'sendWall'
  3992. };
  3993. }
  3994. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3995. return {
  3996. type: 'unSupport'
  3997. };
  3998. }
  3999. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  4000. }
  4001. const logStatus = scripts_echoLog({
  4002. type: 'gettingVkId',
  4003. text: name
  4004. });
  4005. const {
  4006. result,
  4007. statusText,
  4008. status,
  4009. data
  4010. } = await tools_httpRequest({
  4011. url: url,
  4012. method: 'GET'
  4013. });
  4014. if (result === 'Success') {
  4015. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4016. var _data$responseText$ma3, _data$responseText$ma4;
  4017. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  4018. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4019. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4020. const publicJoined = !data.responseText.includes('Public.subscribe');
  4021. if (groupAct && groupId && groupHash) {
  4022. logStatus.success();
  4023. return {
  4024. groupAct: groupAct,
  4025. groupId: groupId,
  4026. groupHash: groupHash,
  4027. type: 'group'
  4028. };
  4029. } else if (publicHash && publicPid) {
  4030. logStatus.success();
  4031. return {
  4032. publicHash: publicHash,
  4033. publicPid: publicPid,
  4034. publicJoined: publicJoined,
  4035. type: 'public'
  4036. };
  4037. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4038. var _data$responseText$ma5;
  4039. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4040. if (wallHash) {
  4041. logStatus.success();
  4042. return {
  4043. type: 'deleteWall',
  4044. wallHash: wallHash
  4045. };
  4046. }
  4047. } else if (name.includes('wall') && doTask) {
  4048. logStatus.success();
  4049. return {
  4050. type: 'sendWall'
  4051. };
  4052. }
  4053. logStatus.error('Error: Parameters not found!');
  4054. return false;
  4055. }
  4056. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4057. return false;
  4058. }
  4059. logStatus.error(`${result}:${statusText}(${status})`);
  4060. return false;
  4061. } catch (error) {
  4062. throwError(error, 'Vk.getId');
  4063. return false;
  4064. }
  4065. }
  4066. async function _toggleVk2(_ref2) {
  4067. let {
  4068. name,
  4069. doTask = true
  4070. } = _ref2;
  4071. try {
  4072. if (!doTask && this.whiteList.names.includes(name)) {
  4073. scripts_echoLog({
  4074. type: 'whiteList',
  4075. text: 'Vk.undoTask',
  4076. id: name
  4077. });
  4078. return true;
  4079. }
  4080. const formatName = name.replace(/\/$/, '');
  4081. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4082. if (!data) {
  4083. return false;
  4084. }
  4085. switch (data.type) {
  4086. case 'group':
  4087. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4088.  
  4089. case 'public':
  4090. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4091.  
  4092. case 'sendWall':
  4093. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4094.  
  4095. case 'deleteWall':
  4096. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4097.  
  4098. default:
  4099. return false;
  4100. }
  4101. } catch (error) {
  4102. throwError(error, 'Vk.toggleVk');
  4103. return false;
  4104. }
  4105. }
  4106. function Vk_setCache2(name, postId) {
  4107. try {
  4108. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4109. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4110. } catch (error) {
  4111. throwError(error, 'Vk.setCache');
  4112. }
  4113. }
  4114. const social_Vk = Vk;
  4115. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4116. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4117. privateSet.add(obj);
  4118. }
  4119. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4120. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4121. privateMap.set(obj, value);
  4122. }
  4123. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4124. if (privateCollection.has(obj)) {
  4125. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4126. }
  4127. }
  4128. function Youtube_defineProperty(obj, key, value) {
  4129. if (key in obj) {
  4130. Object.defineProperty(obj, key, {
  4131. value: value,
  4132. enumerable: true,
  4133. configurable: true,
  4134. writable: true
  4135. });
  4136. } else {
  4137. obj[key] = value;
  4138. }
  4139. return obj;
  4140. }
  4141. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4142. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4143. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4144. return value;
  4145. }
  4146. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4147. if (descriptor.set) {
  4148. descriptor.set.call(receiver, value);
  4149. } else {
  4150. if (!descriptor.writable) {
  4151. throw new TypeError('attempted to set read only private field');
  4152. }
  4153. descriptor.value = value;
  4154. }
  4155. }
  4156. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4157. if (!privateSet.has(receiver)) {
  4158. throw new TypeError('attempted to get private field on non-instance');
  4159. }
  4160. return fn;
  4161. }
  4162. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4163. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4164. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4165. }
  4166. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4167. if (!privateMap.has(receiver)) {
  4168. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4169. }
  4170. return privateMap.get(receiver);
  4171. }
  4172. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4173. if (descriptor.get) {
  4174. return descriptor.get.call(receiver);
  4175. }
  4176. return descriptor.value;
  4177. }
  4178. const Youtube_defaultTasksTemplate = {
  4179. channels: [],
  4180. likes: []
  4181. };
  4182. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4183. const getInfo = async function(link, type) {
  4184. try {
  4185. const logStatus = scripts_echoLog({
  4186. text: i18n('gettingYtbToken')
  4187. });
  4188. const {
  4189. result,
  4190. statusText,
  4191. status,
  4192. data
  4193. } = await tools_httpRequest({
  4194. url: link,
  4195. method: 'GET'
  4196. });
  4197. if (result === 'Success') {
  4198. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4199. var _data$responseText$ma, _ref;
  4200. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4201. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4202. return {
  4203. needLogin: true
  4204. };
  4205. }
  4206. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4207. 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]) || '{}';
  4208. const {
  4209. client,
  4210. request
  4211. } = JSON.parse(context);
  4212. if (apiKey && client && request) {
  4213. client.hl = 'en';
  4214. if (type === 'channel') {
  4215. var _data$responseText$ma2;
  4216. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4217. if (channelId) {
  4218. logStatus.success();
  4219. return {
  4220. params: {
  4221. apiKey: apiKey,
  4222. client: client,
  4223. request: request,
  4224. channelId: channelId
  4225. }
  4226. };
  4227. }
  4228. logStatus.error('Error: Get "channelId" failed!');
  4229. return {};
  4230. } else if (type === 'likeVideo') {
  4231. var _data$responseText$ma3, _data$responseText$ma4;
  4232. 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];
  4233. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4234. if (videoId) {
  4235. logStatus.success();
  4236. return {
  4237. params: {
  4238. apiKey: apiKey,
  4239. client: client,
  4240. request: request,
  4241. videoId: videoId,
  4242. likeParams: likeParams
  4243. }
  4244. };
  4245. }
  4246. logStatus.error('Error: Get "videoId" failed!');
  4247. return {};
  4248. }
  4249. logStatus.error('Error: Unknown type');
  4250. return {};
  4251. }
  4252. logStatus.error('Error: Parameter "apiKey" not found!');
  4253. return {};
  4254. }
  4255. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4256. return {};
  4257. }
  4258. logStatus.error(`${result}:${statusText}(${status})`);
  4259. return {};
  4260. } catch (error) {
  4261. throwError(error, 'Youtube.getInfo');
  4262. return {};
  4263. }
  4264. };
  4265. var Youtube_auth = new WeakMap();
  4266. var Youtube_initialized = new WeakMap();
  4267. var _verifyChannel = new WeakMap();
  4268. var Youtube_verifyAuth = new WeakSet();
  4269. var Youtube_updateAuth = new WeakSet();
  4270. var _getInfo = new WeakSet();
  4271. var Youtube_toggleChannel = new WeakSet();
  4272. var _toggleLikeVideo = new WeakSet();
  4273. class Youtube extends social_Social {
  4274. constructor() {
  4275. var _GM_getValue;
  4276. super(...arguments);
  4277. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4278. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4279. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4280. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4281. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4282. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4283. Youtube_defineProperty(this, 'whiteList', {
  4284. ...JSON.parse(Youtube_defaultTasks),
  4285. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4286. });
  4287. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4288. writable: true,
  4289. value: GM_getValue('youtubeAuth') || {}
  4290. });
  4291. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4292. writable: true,
  4293. value: false
  4294. });
  4295. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4296. writable: true,
  4297. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4298. });
  4299. }
  4300. async init() {
  4301. try {
  4302. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4303. return true;
  4304. }
  4305. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4306. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4307. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4308. return true;
  4309. }
  4310. return false;
  4311. }
  4312. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4313. if (isVerified) {
  4314. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4315. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4316. return true;
  4317. }
  4318. GM_setValue('youtubeAuth', null);
  4319. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4320. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4321. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4322. return true;
  4323. }
  4324. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4325. return false;
  4326. } catch (error) {
  4327. throwError(error, 'Youtube.init');
  4328. return false;
  4329. }
  4330. }
  4331. async toggle(_ref2) {
  4332. let {
  4333. doTask = true,
  4334. channelLinks = [],
  4335. videoLinks = []
  4336. } = _ref2;
  4337. try {
  4338. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4339. scripts_echoLog({
  4340. text: i18n('needInit')
  4341. });
  4342. return false;
  4343. }
  4344. const prom = [];
  4345. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4346. scripts_echoLog({
  4347. type: 'globalOptionsSkip',
  4348. text: 'youtube.channels'
  4349. });
  4350. } else {
  4351. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4352. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4353. var _link$match;
  4354. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4355. }
  4356. return link;
  4357. });
  4358. if (realChannels.length > 0) {
  4359. for (const channel of realChannels) {
  4360. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4361. link: channel,
  4362. doTask: doTask
  4363. }));
  4364. await delay(1e3);
  4365. }
  4366. }
  4367. }
  4368. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4369. scripts_echoLog({
  4370. type: 'globalOptionsSkip',
  4371. text: 'youtube.likes'
  4372. });
  4373. } else {
  4374. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4375. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4376. var _link$match2;
  4377. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4378. }
  4379. return link;
  4380. });
  4381. if (realLikes.length > 0) {
  4382. for (const video of realLikes) {
  4383. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4384. link: video,
  4385. doTask: doTask
  4386. }));
  4387. await delay(1e3);
  4388. }
  4389. }
  4390. }
  4391. return Promise.all(prom).then(() => true);
  4392. } catch (error) {
  4393. throwError(error, 'Youtube.toggle');
  4394. return false;
  4395. }
  4396. }
  4397. }
  4398. async function Youtube_verifyAuth2() {
  4399. try {
  4400. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4401. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4402. doTask: true,
  4403. verify: true
  4404. });
  4405. } catch (error) {
  4406. throwError(error, 'Youtube.verifyAuth');
  4407. return false;
  4408. }
  4409. }
  4410. async function Youtube_updateAuth2() {
  4411. try {
  4412. const logStatus = scripts_echoLog({
  4413. text: i18n('updatingAuth', 'Youtube')
  4414. });
  4415. return await new Promise(resolve => {
  4416. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4417. active: true,
  4418. insert: true,
  4419. setParent: true
  4420. });
  4421. newTab.onclose = async () => {
  4422. const auth = GM_getValue('youtubeAuth');
  4423. if (auth) {
  4424. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4425. logStatus.success();
  4426. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4427. resolve(result);
  4428. });
  4429. } else {
  4430. logStatus.error('Error: Update youtube auth failed!');
  4431. resolve(false);
  4432. }
  4433. };
  4434. });
  4435. } catch (error) {
  4436. throwError(error, 'Discord.updateAuth');
  4437. return false;
  4438. }
  4439. }
  4440. function _getInfo2(link, type) {
  4441. return getInfo(link, type);
  4442. }
  4443. async function Youtube_toggleChannel2(_ref3) {
  4444. let {
  4445. link,
  4446. doTask = true,
  4447. verify = false
  4448. } = _ref3;
  4449. try {
  4450. const {
  4451. params,
  4452. needLogin
  4453. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4454. const {
  4455. apiKey,
  4456. client,
  4457. request,
  4458. channelId
  4459. } = params || {};
  4460. if (needLogin) {
  4461. scripts_echoLog({
  4462. html: i18n('loginYtb')
  4463. });
  4464. return false;
  4465. }
  4466. if (!(apiKey && client && request && channelId)) {
  4467. scripts_echoLog({
  4468. text: '"getYtbToken" failed'
  4469. });
  4470. return false;
  4471. }
  4472. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4473. scripts_echoLog({
  4474. type: 'whiteList',
  4475. text: 'Youtube.unfollowChannel',
  4476. id: channelId
  4477. });
  4478. return true;
  4479. }
  4480. const logStatus = verify ? scripts_echoLog({
  4481. text: i18n('verifyingAuth', 'Youtube')
  4482. }) : scripts_echoLog({
  4483. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4484. text: channelId
  4485. });
  4486. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4487. const {
  4488. result,
  4489. statusText,
  4490. status,
  4491. data
  4492. } = await tools_httpRequest({
  4493. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4494. method: 'POST',
  4495. headers: {
  4496. origin: 'https://www.youtube.com',
  4497. referer: `https://www.youtube.com/channel/${channelId}`,
  4498. 'content-type': 'application/json',
  4499. 'x-goog-authuser': '0',
  4500. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4501. 'x-origin': 'https://www.youtube.com',
  4502. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4503. },
  4504. data: JSON.stringify({
  4505. context: {
  4506. client: client,
  4507. request: {
  4508. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4509. internalExperimentFlags: [],
  4510. consistencyTokenJars: []
  4511. },
  4512. user: {}
  4513. },
  4514. channelIds: [ channelId ],
  4515. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4516. })
  4517. });
  4518. if (result === 'Success') {
  4519. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4520. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4521. logStatus.success();
  4522. if (doTask && !verify) {
  4523. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4524. }
  4525. return true;
  4526. }
  4527. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4528. logStatus.success();
  4529. return true;
  4530. }
  4531. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4532. return false;
  4533. }
  4534. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4535. return false;
  4536. }
  4537. logStatus.error(`${result}:${statusText}(${status})`);
  4538. return false;
  4539. } catch (error) {
  4540. throwError(error, 'Youtube.toggleChannel');
  4541. return false;
  4542. }
  4543. }
  4544. async function _toggleLikeVideo2(_ref4) {
  4545. let {
  4546. link,
  4547. doTask = true
  4548. } = _ref4;
  4549. try {
  4550. const {
  4551. params,
  4552. needLogin
  4553. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4554. const {
  4555. apiKey,
  4556. client,
  4557. request,
  4558. videoId,
  4559. likeParams
  4560. } = params || {};
  4561. if (needLogin) {
  4562. scripts_echoLog({
  4563. html: `${i18n('loginYtb')}`
  4564. });
  4565. return false;
  4566. }
  4567. if (!(apiKey && client && request && videoId && likeParams)) {
  4568. scripts_echoLog({
  4569. text: '"getYtbToken" failed'
  4570. });
  4571. return false;
  4572. }
  4573. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4574. scripts_echoLog({
  4575. type: 'whiteList',
  4576. text: 'Youtube.unlikeVideo',
  4577. id: videoId
  4578. });
  4579. return true;
  4580. }
  4581. const logStatus = scripts_echoLog({
  4582. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4583. text: videoId
  4584. });
  4585. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4586. const likeVideoData = {
  4587. context: {
  4588. client: client,
  4589. request: {
  4590. sessionId: request.sessionId,
  4591. internalExperimentFlags: [],
  4592. consistencyTokenJars: []
  4593. },
  4594. user: {}
  4595. },
  4596. target: {
  4597. videoId: videoId
  4598. }
  4599. };
  4600. if (doTask) {
  4601. if (likeParams) {
  4602. likeVideoData.params = likeParams;
  4603. } else {
  4604. logStatus.error('Empty likeParams');
  4605. return false;
  4606. }
  4607. }
  4608. const {
  4609. result,
  4610. statusText,
  4611. status,
  4612. data
  4613. } = await tools_httpRequest({
  4614. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4615. method: 'POST',
  4616. headers: {
  4617. origin: 'https://www.youtube.com',
  4618. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4619. 'content-type': 'application/json',
  4620. 'x-goog-authuser': '0',
  4621. 'x-goog-visitor-id': client.visitorData,
  4622. 'x-origin': 'https://www.youtube.com',
  4623. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4624. },
  4625. data: JSON.stringify(likeVideoData)
  4626. });
  4627. if (result === 'Success') {
  4628. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4629. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4630. logStatus.success();
  4631. if (doTask) {
  4632. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4633. }
  4634. return true;
  4635. }
  4636. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4637. return false;
  4638. }
  4639. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4640. return false;
  4641. }
  4642. logStatus.error(`${result}:${statusText}(${status})`);
  4643. return false;
  4644. } catch (error) {
  4645. throwError(error, 'Youtube.toggleLikeVideo');
  4646. return false;
  4647. }
  4648. }
  4649. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4650. Steam_checkPrivateRedeclaration(obj, privateSet);
  4651. privateSet.add(obj);
  4652. }
  4653. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4654. Steam_checkPrivateRedeclaration(obj, privateMap);
  4655. privateMap.set(obj, value);
  4656. }
  4657. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4658. if (privateCollection.has(obj)) {
  4659. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4660. }
  4661. }
  4662. function Steam_defineProperty(obj, key, value) {
  4663. if (key in obj) {
  4664. Object.defineProperty(obj, key, {
  4665. value: value,
  4666. enumerable: true,
  4667. configurable: true,
  4668. writable: true
  4669. });
  4670. } else {
  4671. obj[key] = value;
  4672. }
  4673. return obj;
  4674. }
  4675. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4676. if (!privateSet.has(receiver)) {
  4677. throw new TypeError('attempted to get private field on non-instance');
  4678. }
  4679. return fn;
  4680. }
  4681. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4682. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4683. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4684. return value;
  4685. }
  4686. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4687. if (descriptor.set) {
  4688. descriptor.set.call(receiver, value);
  4689. } else {
  4690. if (!descriptor.writable) {
  4691. throw new TypeError('attempted to set read only private field');
  4692. }
  4693. descriptor.value = value;
  4694. }
  4695. }
  4696. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4697. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4698. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4699. }
  4700. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4701. if (!privateMap.has(receiver)) {
  4702. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4703. }
  4704. return privateMap.get(receiver);
  4705. }
  4706. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4707. if (descriptor.get) {
  4708. return descriptor.get.call(receiver);
  4709. }
  4710. return descriptor.value;
  4711. }
  4712. const Steam_defaultTasksTemplate = {
  4713. groups: [],
  4714. officialGroups: [],
  4715. wishlists: [],
  4716. follows: [],
  4717. forums: [],
  4718. workshops: [],
  4719. workshopVotes: [],
  4720. curators: [],
  4721. curatorLikes: [],
  4722. announcements: [],
  4723. licenses: [],
  4724. playtests: []
  4725. };
  4726. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4727. var Steam_cache = new WeakMap();
  4728. var Steam_auth = new WeakMap();
  4729. var _storeInitialized = new WeakMap();
  4730. var _communityInitialized = new WeakMap();
  4731. var _area = new WeakMap();
  4732. var _areaStatus = new WeakMap();
  4733. var _updateStoreAuth = new WeakSet();
  4734. var _updateCommunityAuth = new WeakSet();
  4735. var _getAreaInfo = new WeakSet();
  4736. var _changeArea = new WeakSet();
  4737. var _joinGroup = new WeakSet();
  4738. var _leaveGroup = new WeakSet();
  4739. var _getGroupId = new WeakSet();
  4740. var _joinOfficialGroup = new WeakSet();
  4741. var _leaveOfficialGroup = new WeakSet();
  4742. var _getOfficialGroupId = new WeakSet();
  4743. var _addToWishlist = new WeakSet();
  4744. var _removeFromWishlist = new WeakSet();
  4745. var _toggleFollowGame = new WeakSet();
  4746. var _isFollowedGame = new WeakSet();
  4747. var _toggleForum = new WeakSet();
  4748. var _getForumId = new WeakSet();
  4749. var _toggleFavoriteWorkshop = new WeakSet();
  4750. var _getWorkshopAppId = new WeakSet();
  4751. var _voteUpWorkshop = new WeakSet();
  4752. var _toggleCurator = new WeakSet();
  4753. var _toggleCuratorLike = new WeakSet();
  4754. var _getAnnouncementParams = new WeakSet();
  4755. var _likeAnnouncement = new WeakSet();
  4756. var _appid2subid = new WeakSet();
  4757. var _getLicenses = new WeakSet();
  4758. var _addLicense = new WeakSet();
  4759. var _addFreeLicense = new WeakSet();
  4760. var _requestPlayTestAccess = new WeakSet();
  4761. var Steam_setCache = new WeakSet();
  4762. class Steam extends social_Social {
  4763. constructor() {
  4764. var _GM_getValue;
  4765. super(...arguments);
  4766. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4767. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4768. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4769. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4770. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4771. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4772. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4773. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4774. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4775. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4776. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4777. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4778. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4779. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4780. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4781. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4782. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4783. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4784. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4785. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4786. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4787. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4788. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4789. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4790. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4791. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4792. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4793. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4794. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4795. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4796. Steam_defineProperty(this, 'whiteList', {
  4797. ...JSON.parse(Steam_defaultTasks),
  4798. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4799. });
  4800. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4801. writable: true,
  4802. value: {
  4803. ...{
  4804. group: {},
  4805. officialGroup: {},
  4806. forum: {},
  4807. workshop: {},
  4808. curator: {}
  4809. },
  4810. ...GM_getValue('steamCache')
  4811. }
  4812. });
  4813. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4814. writable: true,
  4815. value: {}
  4816. });
  4817. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4818. writable: true,
  4819. value: false
  4820. });
  4821. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4822. writable: true,
  4823. value: false
  4824. });
  4825. Steam_classPrivateFieldInitSpec(this, _area, {
  4826. writable: true,
  4827. value: 'CN'
  4828. });
  4829. Steam_classPrivateFieldInitSpec(this, _areaStatus, {
  4830. writable: true,
  4831. value: 'end'
  4832. });
  4833. }
  4834. async init() {
  4835. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4836. try {
  4837. if (type === 'store') {
  4838. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4839. return true;
  4840. }
  4841. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4842. if (!Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4843. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4844. return false;
  4845. }
  4846. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4847. return true;
  4848. }
  4849. if (type === 'community') {
  4850. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4851. return true;
  4852. }
  4853. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4854. if (!Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4855. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4856. return false;
  4857. }
  4858. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4859. return true;
  4860. }
  4861. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4862. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4863. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4864. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4865. return true;
  4866. }
  4867. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4868. return false;
  4869. } catch (error) {
  4870. throwError(error, 'Steam.init');
  4871. return false;
  4872. }
  4873. }
  4874. async getCuratorId(path, name) {
  4875. try {
  4876. const logStatus = scripts_echoLog({
  4877. type: 'gettingCuratorId',
  4878. text: `${path}/${name}`
  4879. });
  4880. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4881. if (curatorId) {
  4882. logStatus.success();
  4883. return curatorId;
  4884. }
  4885. const {
  4886. result,
  4887. statusText,
  4888. status,
  4889. data
  4890. } = await tools_httpRequest({
  4891. url: `https://store.steampowered.com/${path}/${name}`,
  4892. method: 'GET',
  4893. headers: {
  4894. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4895. }
  4896. });
  4897. if (result === 'Success') {
  4898. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4899. var _data$responseText$ma;
  4900. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4901. if (curatorId) {
  4902. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4903. logStatus.success();
  4904. return curatorId;
  4905. }
  4906. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4907. return false;
  4908. }
  4909. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4910. return false;
  4911. }
  4912. logStatus.error(`${result}:${statusText}(${status})`);
  4913. return false;
  4914. } catch (error) {
  4915. throwError(error, 'Steam.getCuratorID');
  4916. return false;
  4917. }
  4918. }
  4919. async toggle(_ref) {
  4920. let {
  4921. doTask = true,
  4922. groupLinks = [],
  4923. officialGroupLinks = [],
  4924. wishlistLinks = [],
  4925. followLinks = [],
  4926. forumLinks = [],
  4927. workshopLinks = [],
  4928. workshopVoteLinks = [],
  4929. curatorLinks = [],
  4930. curatorLikeLinks = [],
  4931. announcementLinks = [],
  4932. licenseLinks = [],
  4933. playtestLinks = []
  4934. } = _ref;
  4935. try {
  4936. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4937. scripts_echoLog({
  4938. text: i18n('needInit')
  4939. });
  4940. return false;
  4941. }
  4942. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4943. scripts_echoLog({
  4944. text: i18n('needInit')
  4945. });
  4946. return false;
  4947. }
  4948. const prom = [];
  4949. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4950. scripts_echoLog({
  4951. type: 'globalOptionsSkip',
  4952. text: 'steam.groups'
  4953. });
  4954. } else {
  4955. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4956. var _link$match;
  4957. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4958. });
  4959. if (realGroups.length > 0) {
  4960. for (const group of realGroups) {
  4961. if (doTask) {
  4962. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4963. } else {
  4964. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4965. }
  4966. await delay(1e3);
  4967. }
  4968. }
  4969. }
  4970. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  4971. scripts_echoLog({
  4972. type: 'globalOptionsSkip',
  4973. text: 'steam.officialGroups'
  4974. });
  4975. } else {
  4976. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  4977. var _link$match2;
  4978. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4979. });
  4980. if (realOfficialGroups.length > 0) {
  4981. for (const officialGroup of realOfficialGroups) {
  4982. if (doTask) {
  4983. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  4984. } else {
  4985. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  4986. }
  4987. await delay(1e3);
  4988. }
  4989. }
  4990. }
  4991. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4992. scripts_echoLog({
  4993. type: 'globalOptionsSkip',
  4994. text: 'steam.wishlists'
  4995. });
  4996. } else {
  4997. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4998. var _link$match3;
  4999. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5000. });
  5001. if (realWishlists.length > 0) {
  5002. for (const game of realWishlists) {
  5003. if (doTask) {
  5004. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  5005. } else {
  5006. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  5007. }
  5008. await delay(1e3);
  5009. }
  5010. }
  5011. }
  5012. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5013. scripts_echoLog({
  5014. type: 'globalOptionsSkip',
  5015. text: 'steam.follows'
  5016. });
  5017. } else {
  5018. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5019. var _link$match4;
  5020. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5021. });
  5022. if (realFollows.length > 0) {
  5023. for (const game of realFollows) {
  5024. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  5025. await delay(1e3);
  5026. }
  5027. }
  5028. }
  5029. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5030. scripts_echoLog({
  5031. type: 'globalOptionsSkip',
  5032. text: 'steam.forums'
  5033. });
  5034. } else {
  5035. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5036. var _link$match5;
  5037. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5038. });
  5039. if (realForums.length > 0) {
  5040. for (const forum of realForums) {
  5041. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5042. await delay(1e3);
  5043. }
  5044. }
  5045. }
  5046. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5047. scripts_echoLog({
  5048. type: 'globalOptionsSkip',
  5049. text: 'steam.workshops'
  5050. });
  5051. } else {
  5052. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5053. var _link$match6;
  5054. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5055. });
  5056. if (realWorkshops.length > 0) {
  5057. for (const workshop of realWorkshops) {
  5058. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5059. await delay(1e3);
  5060. }
  5061. }
  5062. }
  5063. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5064. scripts_echoLog({
  5065. type: 'globalOptionsSkip',
  5066. text: 'steam.workshopVotes'
  5067. });
  5068. } else {
  5069. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5070. var _link$match7;
  5071. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5072. });
  5073. if (doTask && realworkshopVotes.length > 0) {
  5074. for (const workshop of realworkshopVotes) {
  5075. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5076. await delay(1e3);
  5077. }
  5078. }
  5079. }
  5080. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5081. scripts_echoLog({
  5082. type: 'globalOptionsSkip',
  5083. text: 'steam.curators'
  5084. });
  5085. } else {
  5086. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5087. var _link$match8;
  5088. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5089. });
  5090. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5091. var _link$match9;
  5092. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5093. });
  5094. if (realCurators.length > 0) {
  5095. for (const curator of realCurators) {
  5096. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5097. await delay(1e3);
  5098. }
  5099. }
  5100. if (realCuratorLikes.length > 0) {
  5101. for (const curatorLike of realCuratorLikes) {
  5102. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5103. await delay(1e3);
  5104. }
  5105. }
  5106. }
  5107. if (doTask && !globalOptions.doTask.steam.announcements) {
  5108. scripts_echoLog({
  5109. type: 'globalOptionsSkip',
  5110. text: 'steam.announcements'
  5111. });
  5112. } else {
  5113. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5114. var _link$match11;
  5115. if (link.includes('store.steampowered.com')) {
  5116. var _link$match10;
  5117. 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('/');
  5118. }
  5119. 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('/');
  5120. });
  5121. if (doTask && realAnnouncements.length > 0) {
  5122. for (const id of realAnnouncements) {
  5123. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5124. await delay(1e3);
  5125. }
  5126. }
  5127. }
  5128. if (doTask && !globalOptions.doTask.steam.licenses) {
  5129. scripts_echoLog({
  5130. type: 'globalOptionsSkip',
  5131. text: 'steam.licenses'
  5132. });
  5133. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5134. for (const id of licenseLinks) {
  5135. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5136. await delay(1e3);
  5137. }
  5138. }
  5139. if (doTask && !globalOptions.doTask.steam.playtests) {
  5140. scripts_echoLog({
  5141. type: 'globalOptionsSkip',
  5142. text: 'steam.playtests'
  5143. });
  5144. } else {
  5145. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5146. var _link$match12;
  5147. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5148. });
  5149. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5150. for (const id of realPlaytests) {
  5151. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5152. await delay(1e3);
  5153. }
  5154. }
  5155. }
  5156. return Promise.all(prom).then(async () => {
  5157. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5158. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5159. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5160. }
  5161. return true;
  5162. });
  5163. } catch (error) {
  5164. throwError(error, 'Steam.toggle');
  5165. return false;
  5166. }
  5167. }
  5168. }
  5169. async function _updateStoreAuth2() {
  5170. try {
  5171. const logStatus = scripts_echoLog({
  5172. text: i18n('updatingAuth', i18n('steamStore'))
  5173. });
  5174. const {
  5175. result,
  5176. statusText,
  5177. status,
  5178. data
  5179. } = await tools_httpRequest({
  5180. url: 'https://store.steampowered.com/stats/',
  5181. method: 'GET'
  5182. });
  5183. if (result === 'Success') {
  5184. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5185. var _data$responseText$ma2;
  5186. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5187. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5188. return false;
  5189. }
  5190. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5191. if (storeSessionID) {
  5192. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5193. logStatus.success();
  5194. return true;
  5195. }
  5196. logStatus.error('Error: Get "sessionID" failed');
  5197. return false;
  5198. }
  5199. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5200. return false;
  5201. }
  5202. logStatus.error(`${result}:${statusText}(${status})`);
  5203. return false;
  5204. } catch (error) {
  5205. throwError(error, 'Steam.updateStoreAuth');
  5206. return false;
  5207. }
  5208. }
  5209. async function _updateCommunityAuth2() {
  5210. try {
  5211. const logStatus = scripts_echoLog({
  5212. text: i18n('updatingAuth', i18n('steamCommunity'))
  5213. });
  5214. const {
  5215. result,
  5216. statusText,
  5217. status,
  5218. data
  5219. } = await tools_httpRequest({
  5220. url: 'https://steamcommunity.com/my',
  5221. method: 'GET'
  5222. });
  5223. if (result === 'Success') {
  5224. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5225. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5226. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5227. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5228. return false;
  5229. }
  5230. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5231. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5232. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5233. if (steam64Id) {
  5234. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5235. }
  5236. if (userName) {
  5237. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5238. }
  5239. if (communitySessionID) {
  5240. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5241. logStatus.success();
  5242. return true;
  5243. }
  5244. logStatus.error('Error: Get "sessionID" failed');
  5245. return false;
  5246. }
  5247. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5248. return false;
  5249. }
  5250. logStatus.error(`${result}:${statusText}(${status})`);
  5251. return false;
  5252. } catch (error) {
  5253. throwError(error, 'Steam.updateCommunityAuth');
  5254. return false;
  5255. }
  5256. }
  5257. async function _getAreaInfo2() {
  5258. try {
  5259. const logStatus = scripts_echoLog({
  5260. text: i18n('gettingAreaInfo')
  5261. });
  5262. const {
  5263. result,
  5264. statusText,
  5265. status,
  5266. data
  5267. } = await tools_httpRequest({
  5268. url: 'https://store.steampowered.com/cart/',
  5269. method: 'GET'
  5270. });
  5271. if (result === 'Success') {
  5272. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5273. var _data$responseText$ma6;
  5274. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5275. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5276. if (currentArea && areas.length > 0) {
  5277. Steam_classPrivateFieldSet(this, _area, currentArea);
  5278. logStatus.success();
  5279. return {
  5280. currentArea: currentArea,
  5281. areas: areas
  5282. };
  5283. }
  5284. logStatus.error('Error: get country info filed');
  5285. return {};
  5286. }
  5287. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5288. return {};
  5289. }
  5290. logStatus.error(`${result}:${statusText}(${status})`);
  5291. return {};
  5292. } catch (error) {
  5293. throwError(error, 'Steam.getAreaInfo');
  5294. return {};
  5295. }
  5296. }
  5297. async function _changeArea2(area) {
  5298. try {
  5299. if (Steam_classPrivateFieldGet(this, _areaStatus) === 'waiting') {
  5300. await new Promise(resolve => {
  5301. const checker = setInterval(() => {
  5302. if (Steam_classPrivateFieldGet(this, _areaStatus) !== 'waiting') {
  5303. clearInterval(checker);
  5304. resolve(true);
  5305. }
  5306. });
  5307. });
  5308. }
  5309. if (Steam_classPrivateFieldGet(this, _area) === area || !area && Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5310. return true;
  5311. }
  5312. Steam_classPrivateFieldSet(this, _areaStatus, 'waiting');
  5313. let aimedArea = area;
  5314. if (!aimedArea) {
  5315. const {
  5316. currentArea,
  5317. areas
  5318. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5319. if (!currentArea || !areas) {
  5320. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5321. return false;
  5322. }
  5323. if (currentArea !== 'CN') {
  5324. Steam_classPrivateFieldSet(this, _areaStatus, 'skip');
  5325. scripts_echoLog({
  5326. text: 'notNeededChangeArea'
  5327. });
  5328. return 'skip';
  5329. }
  5330. const anotherArea = areas.filter(area => area && area !== 'CN');
  5331. if (!anotherArea || anotherArea.length === 0) {
  5332. Steam_classPrivateFieldSet(this, _areaStatus, 'noAnotherArea');
  5333. scripts_echoLog({
  5334. text: 'noAnotherArea'
  5335. });
  5336. return false;
  5337. }
  5338. [ aimedArea ] = anotherArea;
  5339. }
  5340. const logStatus = scripts_echoLog({
  5341. text: i18n('changingArea', aimedArea)
  5342. });
  5343. const {
  5344. result,
  5345. statusText,
  5346. status,
  5347. data
  5348. } = await tools_httpRequest({
  5349. url: 'https://store.steampowered.com/account/setcountry',
  5350. method: 'POST',
  5351. headers: {
  5352. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5353. },
  5354. data: $.param({
  5355. cc: aimedArea,
  5356. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5357. })
  5358. });
  5359. if (result === 'Success') {
  5360. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5361. const {
  5362. currentArea
  5363. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5364. if (currentArea === aimedArea) {
  5365. Steam_classPrivateFieldSet(this, _areaStatus, 'success');
  5366. logStatus.success();
  5367. return currentArea;
  5368. }
  5369. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5370. logStatus.error('Error: change country filed');
  5371. return 'CN';
  5372. }
  5373. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5374. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5375. return 'CN';
  5376. }
  5377. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5378. logStatus.error(`${result}:${statusText}(${status})`);
  5379. return 'CN';
  5380. } catch (error) {
  5381. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5382. throwError(error, 'Steam.changeArea');
  5383. return false;
  5384. }
  5385. }
  5386. async function _joinGroup2(groupName) {
  5387. try {
  5388. const logStatus = scripts_echoLog({
  5389. type: 'joiningSteamGroup',
  5390. text: groupName
  5391. });
  5392. const {
  5393. result,
  5394. statusText,
  5395. status,
  5396. data
  5397. } = await tools_httpRequest({
  5398. url: `https://steamcommunity.com/groups/${groupName}`,
  5399. method: 'POST',
  5400. headers: {
  5401. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5402. },
  5403. data: $.param({
  5404. action: 'join',
  5405. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5406. })
  5407. });
  5408. if (result === 'Success') {
  5409. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5410. logStatus.success();
  5411. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5412. return true;
  5413. }
  5414. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5415. return false;
  5416. }
  5417. logStatus.error(`${result}:${statusText}(${status})`);
  5418. return false;
  5419. } catch (error) {
  5420. throwError(error, 'Steam.joinGroup');
  5421. return false;
  5422. }
  5423. }
  5424. async function _leaveGroup2(groupName) {
  5425. try {
  5426. if (this.whiteList.groups.includes(groupName)) {
  5427. scripts_echoLog({
  5428. type: 'whiteList',
  5429. text: 'Steam.leaveGroup',
  5430. id: groupName
  5431. });
  5432. return true;
  5433. }
  5434. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5435. if (!groupId) {
  5436. return false;
  5437. }
  5438. const logStatus = scripts_echoLog({
  5439. type: 'leavingSteamGroup',
  5440. text: groupName
  5441. });
  5442. const {
  5443. result,
  5444. statusText,
  5445. status,
  5446. data
  5447. } = await tools_httpRequest({
  5448. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5449. method: 'POST',
  5450. headers: {
  5451. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5452. },
  5453. data: $.param({
  5454. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5455. action: 'leaveGroup',
  5456. groupId: groupId
  5457. })
  5458. });
  5459. if (result === 'Success') {
  5460. 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) {
  5461. logStatus.success();
  5462. return true;
  5463. }
  5464. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5465. return false;
  5466. }
  5467. logStatus.error(`${result}:${statusText}(${status})`);
  5468. return false;
  5469. } catch (error) {
  5470. throwError(error, 'Steam.leaveGroup');
  5471. return false;
  5472. }
  5473. }
  5474. async function _getGroupId2(groupName) {
  5475. try {
  5476. const logStatus = scripts_echoLog({
  5477. type: 'gettingSteamGroupId',
  5478. text: groupName
  5479. });
  5480. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5481. if (groupId) {
  5482. logStatus.success();
  5483. return groupId;
  5484. }
  5485. const {
  5486. result,
  5487. statusText,
  5488. status,
  5489. data
  5490. } = await tools_httpRequest({
  5491. url: `https://steamcommunity.com/groups/${groupName}`,
  5492. method: 'GET',
  5493. headers: {
  5494. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5495. }
  5496. });
  5497. if (result === 'Success') {
  5498. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5499. var _data$responseText$ma7;
  5500. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5501. if (groupId) {
  5502. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5503. logStatus.success();
  5504. return groupId;
  5505. }
  5506. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5507. return false;
  5508. }
  5509. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5510. return false;
  5511. }
  5512. logStatus.error(`${result}:${statusText}(${status})`);
  5513. return false;
  5514. } catch (error) {
  5515. throwError(error, 'Steam.getGroupID');
  5516. return false;
  5517. }
  5518. }
  5519. async function _joinOfficialGroup2(gameId) {
  5520. try {
  5521. const logStatus = scripts_echoLog({
  5522. type: 'joiningSteamOfficialGroup',
  5523. text: gameId
  5524. });
  5525. const {
  5526. result,
  5527. statusText,
  5528. status,
  5529. data
  5530. } = await tools_httpRequest({
  5531. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5532. method: 'GET',
  5533. headers: {
  5534. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5535. }
  5536. });
  5537. if (result === 'Success') {
  5538. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5539. var _data$responseText$ma8;
  5540. logStatus.success();
  5541. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5542. 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];
  5543. if (groupId) {
  5544. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5545. }
  5546. return true;
  5547. }
  5548. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5549. return false;
  5550. }
  5551. logStatus.error(`${result}:${statusText}(${status})`);
  5552. return false;
  5553. } catch (error) {
  5554. throwError(error, 'Steam.joinOfficialGroup');
  5555. return false;
  5556. }
  5557. }
  5558. async function _leaveOfficialGroup2(gameId) {
  5559. try {
  5560. if (this.whiteList.officialGroups.includes(gameId)) {
  5561. scripts_echoLog({
  5562. type: 'whiteList',
  5563. text: 'Steam.leaveOfficialGroup',
  5564. id: gameId
  5565. });
  5566. return true;
  5567. }
  5568. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5569. if (!groupId) {
  5570. return false;
  5571. }
  5572. const logStatus = scripts_echoLog({
  5573. type: 'leavingSteamOfficialGroup',
  5574. text: gameId
  5575. });
  5576. const {
  5577. result,
  5578. statusText,
  5579. status,
  5580. data
  5581. } = await tools_httpRequest({
  5582. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5583. method: 'POST',
  5584. headers: {
  5585. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5586. },
  5587. data: $.param({
  5588. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5589. action: 'leaveGroup',
  5590. groupId: groupId
  5591. })
  5592. });
  5593. if (result === 'Success') {
  5594. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5595. const {
  5596. result: resultR,
  5597. statusText: statusTextR,
  5598. status: statusR,
  5599. data: dataR
  5600. } = await tools_httpRequest({
  5601. url: `https://steamcommunity.com/games/${gameId}`,
  5602. method: 'GET',
  5603. headers: {
  5604. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5605. }
  5606. });
  5607. if (resultR === 'Success') {
  5608. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5609. logStatus.success();
  5610. return true;
  5611. }
  5612. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5613. return false;
  5614. }
  5615. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5616. return false;
  5617. }
  5618. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5619. return false;
  5620. }
  5621. logStatus.error(`${result}:${statusText}(${status})`);
  5622. return false;
  5623. } catch (error) {
  5624. throwError(error, 'Steam.leaveOfficialGroup');
  5625. return false;
  5626. }
  5627. }
  5628. async function _getOfficialGroupId2(gameId) {
  5629. try {
  5630. const logStatus = scripts_echoLog({
  5631. type: 'gettingSteamOfficialGroupId',
  5632. text: gameId
  5633. });
  5634. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5635. if (groupId) {
  5636. logStatus.success();
  5637. return groupId;
  5638. }
  5639. const {
  5640. result,
  5641. statusText,
  5642. status,
  5643. data
  5644. } = await tools_httpRequest({
  5645. url: `https://steamcommunity.com/games/${gameId}`,
  5646. method: 'GET',
  5647. headers: {
  5648. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5649. }
  5650. });
  5651. if (result === 'Success') {
  5652. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5653. var _data$responseText$ma9;
  5654. 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];
  5655. if (groupId) {
  5656. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5657. logStatus.success();
  5658. return groupId;
  5659. }
  5660. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5661. return false;
  5662. }
  5663. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5664. return false;
  5665. }
  5666. logStatus.error(`${result}:${statusText}(${status})`);
  5667. return false;
  5668. } catch (error) {
  5669. throwError(error, 'Steam.getGroupID');
  5670. return false;
  5671. }
  5672. }
  5673. async function _addToWishlist2(gameId) {
  5674. try {
  5675. var _data$response;
  5676. const logStatus = scripts_echoLog({
  5677. type: 'addingToWishlist',
  5678. text: gameId
  5679. });
  5680. const {
  5681. result,
  5682. data
  5683. } = await tools_httpRequest({
  5684. url: 'https://store.steampowered.com/api/addtowishlist',
  5685. method: 'POST',
  5686. headers: {
  5687. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5688. },
  5689. data: $.param({
  5690. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5691. appid: gameId
  5692. }),
  5693. dataType: 'json'
  5694. });
  5695. 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) {
  5696. logStatus.success();
  5697. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5698. return true;
  5699. }
  5700. const {
  5701. result: resultR,
  5702. statusText: statusTextR,
  5703. status: statusR,
  5704. data: dataR
  5705. } = await tools_httpRequest({
  5706. url: `https://store.steampowered.com/app/${gameId}`,
  5707. method: 'GET'
  5708. });
  5709. if (resultR === 'Success') {
  5710. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5711. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5712. logStatus.warning(i18n('changeAreaNotice'));
  5713. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5714. return false;
  5715. }
  5716. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5717. }
  5718. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5719. logStatus.success();
  5720. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5721. return true;
  5722. } 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"')) {
  5723. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5724. return false;
  5725. }
  5726. logStatus.success();
  5727. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5728. return true;
  5729. }
  5730. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5731. return false;
  5732. }
  5733. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5734. return false;
  5735. } catch (error) {
  5736. throwError(error, 'Steam.addToWishlist');
  5737. return false;
  5738. }
  5739. }
  5740. async function _removeFromWishlist2(gameId) {
  5741. try {
  5742. var _data$response2;
  5743. if (this.whiteList.wishlists.includes(gameId)) {
  5744. scripts_echoLog({
  5745. type: 'whiteList',
  5746. text: 'Steam.removeFromWishlist',
  5747. id: gameId
  5748. });
  5749. return true;
  5750. }
  5751. const logStatus = scripts_echoLog({
  5752. type: 'removingFromWishlist',
  5753. text: gameId
  5754. });
  5755. const {
  5756. result,
  5757. data
  5758. } = await tools_httpRequest({
  5759. url: 'https://store.steampowered.com/api/removefromwishlist',
  5760. method: 'POST',
  5761. headers: {
  5762. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5763. },
  5764. data: $.param({
  5765. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5766. appid: gameId
  5767. }),
  5768. dataType: 'json'
  5769. });
  5770. 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) {
  5771. logStatus.success();
  5772. return true;
  5773. }
  5774. const {
  5775. result: resultR,
  5776. statusText: statusTextR,
  5777. status: statusR,
  5778. data: dataR
  5779. } = await tools_httpRequest({
  5780. url: `https://store.steampowered.com/app/${gameId}`,
  5781. method: 'GET'
  5782. });
  5783. if (resultR === 'Success') {
  5784. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5785. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5786. logStatus.warning(i18n('changeAreaNotice'));
  5787. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5788. if (!result || result === 'CN' || result === 'skip') {
  5789. return false;
  5790. }
  5791. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5792. }
  5793. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5794. logStatus.success();
  5795. return true;
  5796. }
  5797. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5798. return false;
  5799. }
  5800. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5801. return false;
  5802. }
  5803. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5804. return false;
  5805. } catch (error) {
  5806. throwError(error, 'Steam.removeFromWishlist');
  5807. return false;
  5808. }
  5809. }
  5810. async function _toggleFollowGame2(gameId, doTask) {
  5811. try {
  5812. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5813. scripts_echoLog({
  5814. type: 'whiteList',
  5815. text: 'Steam.unfollowGame',
  5816. id: gameId
  5817. });
  5818. return true;
  5819. }
  5820. const logStatus = scripts_echoLog({
  5821. type: `${doTask ? '' : 'un'}followingGame`,
  5822. text: gameId
  5823. });
  5824. const requestData = {
  5825. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5826. appid: gameId
  5827. };
  5828. if (!doTask) {
  5829. requestData.unfollow = '1';
  5830. }
  5831. const {
  5832. result,
  5833. data
  5834. } = await tools_httpRequest({
  5835. url: 'https://store.steampowered.com/explore/followgame/',
  5836. method: 'POST',
  5837. headers: {
  5838. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5839. },
  5840. data: $.param(requestData)
  5841. });
  5842. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5843. logStatus.success();
  5844. return true;
  5845. }
  5846. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5847. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5848. logStatus.warning(i18n('changeAreaNotice'));
  5849. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5850. return false;
  5851. }
  5852. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5853. }
  5854. if (doTask === followed) {
  5855. logStatus.success();
  5856. if (doTask) {
  5857. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5858. }
  5859. return true;
  5860. }
  5861. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5862. return false;
  5863. } catch (error) {
  5864. throwError(error, 'Steam.toggleFollowGame');
  5865. return false;
  5866. }
  5867. }
  5868. async function _isFollowedGame2(gameId) {
  5869. try {
  5870. const {
  5871. result,
  5872. data
  5873. } = await tools_httpRequest({
  5874. url: `https://store.steampowered.com/app/${gameId}`,
  5875. method: 'GET'
  5876. });
  5877. if (result === 'Success') {
  5878. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5879. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5880. return 'areaLocked';
  5881. }
  5882. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5883. return true;
  5884. }
  5885. return false;
  5886. }
  5887. return false;
  5888. }
  5889. return false;
  5890. } catch (error) {
  5891. throwError(error, 'Steam.isFollowedGame');
  5892. return false;
  5893. }
  5894. }
  5895. async function _toggleForum2(gameId) {
  5896. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5897. try {
  5898. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5899. scripts_echoLog({
  5900. type: 'whiteList',
  5901. text: 'Steam.unsubscribeForum',
  5902. id: gameId
  5903. });
  5904. return true;
  5905. }
  5906. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5907. if (!forumId) {
  5908. return false;
  5909. }
  5910. const logStatus = scripts_echoLog({
  5911. type: `${doTask ? '' : 'un'}subscribingForum`,
  5912. text: gameId
  5913. });
  5914. const [ id, feature ] = forumId.split('_');
  5915. const {
  5916. result,
  5917. statusText,
  5918. status,
  5919. data
  5920. } = await tools_httpRequest({
  5921. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5922. method: 'POST',
  5923. responseType: 'json',
  5924. headers: {
  5925. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5926. },
  5927. data: $.param({
  5928. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5929. })
  5930. });
  5931. if (result === 'Success') {
  5932. var _data$response3, _data$response4;
  5933. 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)) {
  5934. if (doTask) {
  5935. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5936. }
  5937. logStatus.success();
  5938. return true;
  5939. }
  5940. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5941. return true;
  5942. }
  5943. logStatus.error(`${result}:${statusText}(${status})`);
  5944. return true;
  5945. } catch (error) {
  5946. throwError(error, 'Steam.toggleForum');
  5947. return true;
  5948. }
  5949. }
  5950. async function _getForumId2(gameId) {
  5951. try {
  5952. const logStatus = scripts_echoLog({
  5953. type: 'gettingForumId',
  5954. text: gameId
  5955. });
  5956. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5957. if (forumId) {
  5958. logStatus.success();
  5959. return forumId;
  5960. }
  5961. const {
  5962. result,
  5963. statusText,
  5964. status,
  5965. data
  5966. } = await tools_httpRequest({
  5967. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5968. method: 'GET'
  5969. });
  5970. if (result === 'Success') {
  5971. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5972. var _data$responseText, _data$responseText$ma10;
  5973. 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];
  5974. if (forumId) {
  5975. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5976. logStatus.success();
  5977. return forumId;
  5978. }
  5979. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5980. return false;
  5981. }
  5982. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5983. return false;
  5984. }
  5985. logStatus.error(`${result}:${statusText}(${status})`);
  5986. return false;
  5987. } catch (error) {
  5988. throwError(error, 'Steam.getForumId');
  5989. return false;
  5990. }
  5991. }
  5992. async function _toggleFavoriteWorkshop2(id) {
  5993. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5994. try {
  5995. if (!doTask && this.whiteList.workshops.includes(id)) {
  5996. scripts_echoLog({
  5997. type: 'whiteList',
  5998. text: 'Steam.unfavoriteWorkshop',
  5999. id: id
  6000. });
  6001. return true;
  6002. }
  6003. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  6004. if (!appid) {
  6005. return false;
  6006. }
  6007. const logStatus = scripts_echoLog({
  6008. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  6009. text: id
  6010. });
  6011. const {
  6012. result,
  6013. statusText,
  6014. status,
  6015. data
  6016. } = await tools_httpRequest({
  6017. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  6018. method: 'POST',
  6019. headers: {
  6020. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6021. },
  6022. data: $.param({
  6023. id: id,
  6024. appid: appid,
  6025. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6026. })
  6027. });
  6028. if (result === 'Success') {
  6029. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  6030. if (doTask) {
  6031. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  6032. }
  6033. logStatus.success();
  6034. return true;
  6035. }
  6036. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6037. return false;
  6038. }
  6039. logStatus.error(`${result}:${statusText}(${status})`);
  6040. return false;
  6041. } catch (error) {
  6042. throwError(error, 'Steam.toggleFavoriteWorkshop');
  6043. return false;
  6044. }
  6045. }
  6046. async function _getWorkshopAppId2(id) {
  6047. try {
  6048. const logStatus = scripts_echoLog({
  6049. type: 'gettingWorkshopAppId',
  6050. text: id
  6051. });
  6052. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  6053. if (appId) {
  6054. logStatus.success();
  6055. return appId;
  6056. }
  6057. const {
  6058. result,
  6059. statusText,
  6060. status,
  6061. data
  6062. } = await tools_httpRequest({
  6063. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6064. method: 'GET'
  6065. });
  6066. if (result === 'Success') {
  6067. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6068. var _data$responseText$ma11;
  6069. 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];
  6070. if (appId) {
  6071. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6072. logStatus.success();
  6073. return appId;
  6074. }
  6075. logStatus.error('Error: getWorkshopAppId failed');
  6076. return false;
  6077. }
  6078. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6079. return false;
  6080. }
  6081. logStatus.error(`${result}:${statusText}(${status})`);
  6082. return false;
  6083. } catch (error) {
  6084. throwError(error, 'Steam.getWorkshopAppId');
  6085. return false;
  6086. }
  6087. }
  6088. async function _voteUpWorkshop2(id) {
  6089. try {
  6090. const logStatus = scripts_echoLog({
  6091. type: 'votingUpWorkshop',
  6092. text: id
  6093. });
  6094. const {
  6095. result,
  6096. statusText,
  6097. status,
  6098. data
  6099. } = await tools_httpRequest({
  6100. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6101. method: 'POST',
  6102. responseType: 'json',
  6103. headers: {
  6104. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6105. },
  6106. data: $.param({
  6107. id: id,
  6108. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6109. })
  6110. });
  6111. if (result === 'Success') {
  6112. var _data$response5;
  6113. 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) {
  6114. logStatus.success();
  6115. return true;
  6116. }
  6117. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6118. return true;
  6119. }
  6120. logStatus.error(`${result}:${statusText}(${status})`);
  6121. return true;
  6122. } catch (error) {
  6123. throwError(error, 'Steam.voteupWorkshop');
  6124. return true;
  6125. }
  6126. }
  6127. async function _toggleCurator2(curatorId) {
  6128. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6129. try {
  6130. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6131. scripts_echoLog({
  6132. type: 'whiteList',
  6133. text: 'Steam.unfollowCurator',
  6134. id: curatorId
  6135. });
  6136. return true;
  6137. }
  6138. const logStatus = scripts_echoLog({
  6139. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6140. text: curatorId
  6141. });
  6142. const {
  6143. result,
  6144. statusText,
  6145. status,
  6146. data
  6147. } = await tools_httpRequest({
  6148. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6149. method: 'POST',
  6150. headers: {
  6151. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6152. },
  6153. data: $.param({
  6154. clanid: curatorId,
  6155. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6156. follow: doTask
  6157. }),
  6158. dataType: 'json'
  6159. });
  6160. if (result === 'Success') {
  6161. var _data$response6, _data$response6$succe, _data$response7;
  6162. 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) {
  6163. logStatus.success();
  6164. return true;
  6165. }
  6166. 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})`);
  6167. return false;
  6168. }
  6169. logStatus.error(`${result}:${statusText}(${status})`);
  6170. return false;
  6171. } catch (error) {
  6172. throwError(error, 'Steam.toggleCurator');
  6173. return false;
  6174. }
  6175. }
  6176. async function _toggleCuratorLike2(link) {
  6177. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6178. try {
  6179. const [ path, name ] = link.split('/');
  6180. if (!(path && name)) {
  6181. scripts_echoLog({
  6182. text: i18n('errorLink', link)
  6183. });
  6184. return false;
  6185. }
  6186. const curatorId = await this.getCuratorId(path, name);
  6187. if (curatorId) {
  6188. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6189. }
  6190. return false;
  6191. } catch (error) {
  6192. throwError(error, 'Steam.toggleCuratorLike');
  6193. return false;
  6194. }
  6195. }
  6196. async function _getAnnouncementParams2(appId, viewId) {
  6197. try {
  6198. const logStatus = scripts_echoLog({
  6199. type: 'gettingAnnouncementParams',
  6200. text: appId,
  6201. id: viewId
  6202. });
  6203. const {
  6204. result,
  6205. statusText,
  6206. status,
  6207. data
  6208. } = await tools_httpRequest({
  6209. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6210. method: 'GET',
  6211. headers: {
  6212. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6213. }
  6214. });
  6215. if (result === 'Success') {
  6216. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6217. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6218. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6219. logStatus.warning(i18n('changeAreaNotice'));
  6220. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6221. return {};
  6222. }
  6223. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6224. }
  6225. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6226. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6227. 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];
  6228. if (authWgToken && clanId) {
  6229. logStatus.success();
  6230. return {
  6231. authWgToken: authWgToken,
  6232. clanId: clanId,
  6233. gid: gid
  6234. };
  6235. }
  6236. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6237. return {};
  6238. }
  6239. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6240. return {};
  6241. }
  6242. logStatus.error(`${result}:${statusText}(${status})`);
  6243. return {};
  6244. } catch (error) {
  6245. throwError(error, 'Steam.likeAnnouncement');
  6246. return {};
  6247. }
  6248. }
  6249. async function _likeAnnouncement2(id) {
  6250. try {
  6251. const [ appId, viewId ] = id.split('/');
  6252. if (!(appId && viewId)) {
  6253. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6254. return false;
  6255. }
  6256. const {
  6257. authWgToken,
  6258. clanId,
  6259. gid
  6260. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6261. if (!(authWgToken && clanId)) {
  6262. return false;
  6263. }
  6264. const logStatus = scripts_echoLog({
  6265. type: 'likingAnnouncement',
  6266. text: appId,
  6267. id: viewId
  6268. });
  6269. const {
  6270. result,
  6271. statusText,
  6272. status,
  6273. data
  6274. } = await tools_httpRequest({
  6275. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6276. method: 'POST',
  6277. headers: {
  6278. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6279. Host: 'store.steampowered.com',
  6280. Origin: 'https://store.steampowered.com',
  6281. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6282. },
  6283. data: $.param({
  6284. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6285. wgauthtoken: authWgToken,
  6286. voteup: 1,
  6287. clanid: clanId,
  6288. ajax: 1
  6289. }),
  6290. dataType: 'json'
  6291. });
  6292. if (result === 'Success') {
  6293. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6294. logStatus.success();
  6295. return true;
  6296. }
  6297. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6298. return false;
  6299. }
  6300. logStatus.error(`${result}:${statusText}(${status})`);
  6301. return false;
  6302. } catch (error) {
  6303. throwError(error, 'Steam.likeAnnouncement');
  6304. return false;
  6305. }
  6306. }
  6307. async function _appid2subid2(id) {
  6308. try {
  6309. const logStatus = scripts_echoLog({
  6310. type: 'gettingSubid',
  6311. text: id
  6312. });
  6313. const {
  6314. result,
  6315. statusText,
  6316. status,
  6317. data
  6318. } = await tools_httpRequest({
  6319. url: `https://store.steampowered.com/app/${id}`,
  6320. method: 'GET',
  6321. headers: {
  6322. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6323. }
  6324. });
  6325. if (result === 'Success') {
  6326. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6327. var _data$responseText$ma15;
  6328. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6329. logStatus.warning(i18n('changeAreaNotice'));
  6330. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6331. if (!result || result === 'CN' || result === 'skip') {
  6332. return false;
  6333. }
  6334. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6335. }
  6336. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6337. if (subid) {
  6338. logStatus.success();
  6339. return subid;
  6340. }
  6341. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6342. return false;
  6343. }
  6344. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6345. return false;
  6346. }
  6347. logStatus.error(`${result}:${statusText}(${status})`);
  6348. return false;
  6349. } catch (error) {
  6350. throwError(error, 'Steam.appid2subid');
  6351. return false;
  6352. }
  6353. }
  6354. async function _getLicenses2() {
  6355. try {
  6356. const logStatus = scripts_echoLog({
  6357. text: i18n('gettingLicenses')
  6358. });
  6359. const {
  6360. result,
  6361. statusText,
  6362. status,
  6363. data
  6364. } = await tools_httpRequest({
  6365. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  6366. method: 'GET',
  6367. responseType: 'json'
  6368. });
  6369. if (result === 'Success') {
  6370. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6371. var _data$response8;
  6372. logStatus.success();
  6373. return (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.rgOwnedPackages;
  6374. }
  6375. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6376. return false;
  6377. }
  6378. logStatus.error(`${result}:${statusText}(${status})`);
  6379. return false;
  6380. } catch (error) {
  6381. throwError(error, 'Steam.getLicenses');
  6382. return false;
  6383. }
  6384. }
  6385. async function _addLicense2(id) {
  6386. try {
  6387. const [ type, ids ] = id.split('-');
  6388. if (type === 'appid') {
  6389. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6390. if (!subid) {
  6391. return false;
  6392. }
  6393. const logStatus = scripts_echoLog({
  6394. type: 'addingFreeLicense',
  6395. text: ids
  6396. });
  6397. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6398. return false;
  6399. }
  6400. const {
  6401. result,
  6402. statusText,
  6403. status,
  6404. data
  6405. } = await tools_httpRequest({
  6406. url: `https://store.steampowered.com/app/${ids}`,
  6407. method: 'GET'
  6408. });
  6409. if (result === 'Success') {
  6410. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6411. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6412. logStatus.success();
  6413. return true;
  6414. }
  6415. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6416. return false;
  6417. }
  6418. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6419. return false;
  6420. }
  6421. logStatus.error(`${result}:${statusText}(${status})`);
  6422. return false;
  6423. } else if (type === 'subid') {
  6424. if (Steam_classPrivateFieldGet(this, _area) === 'CN') {
  6425. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  6426. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6427. }
  6428. const logStatusArr = {};
  6429. const idsArr = ids.split(',');
  6430. for (const subid of idsArr) {
  6431. const logStatus = scripts_echoLog({
  6432. type: 'addingFreeLicenseSubid',
  6433. text: subid
  6434. });
  6435. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6436. return false;
  6437. }
  6438. logStatusArr[subid] = logStatus;
  6439. }
  6440. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6441. if (!licenses) {
  6442. return false;
  6443. }
  6444. for (const subid of idsArr) {
  6445. if (licenses.includes(parseInt(subid, 10))) {
  6446. logStatusArr[subid].success();
  6447. } else {
  6448. logStatusArr[subid].error();
  6449. }
  6450. }
  6451. return true;
  6452. }
  6453. return false;
  6454. } catch (error) {
  6455. throwError(error, 'Steam.addLicense');
  6456. return false;
  6457. }
  6458. }
  6459. async function _addFreeLicense2(id, logStatusPre) {
  6460. try {
  6461. const logStatus = logStatusPre || scripts_echoLog({
  6462. type: 'addingFreeLicenseSubid',
  6463. text: id
  6464. });
  6465. const {
  6466. result,
  6467. statusText,
  6468. status,
  6469. data
  6470. } = await tools_httpRequest({
  6471. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6472. method: 'POST',
  6473. headers: {
  6474. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6475. Host: 'store.steampowered.com',
  6476. Origin: 'https://store.steampowered.com',
  6477. Referer: 'https://store.steampowered.com/account/licenses/'
  6478. },
  6479. data: $.param({
  6480. action: 'add_to_cart',
  6481. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6482. subid: id
  6483. }),
  6484. dataType: 'json'
  6485. });
  6486. if (result === 'Success') {
  6487. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6488. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6489. logStatus.warning(i18n('changeAreaNotice'));
  6490. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6491. if (!result || result === 'CN') {
  6492. return false;
  6493. }
  6494. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6495. }
  6496. logStatus.success();
  6497. return true;
  6498. }
  6499. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6500. return false;
  6501. }
  6502. logStatus.error(`${result}:${statusText}(${status})`);
  6503. return false;
  6504. } catch (error) {
  6505. throwError(error, 'Steam.addFreeLicense');
  6506. return false;
  6507. }
  6508. }
  6509. async function _requestPlayTestAccess2(id) {
  6510. try {
  6511. const logStatus = scripts_echoLog({
  6512. type: 'requestingPlayTestAccess',
  6513. text: id
  6514. });
  6515. const {
  6516. result,
  6517. statusText,
  6518. status,
  6519. data
  6520. } = await tools_httpRequest({
  6521. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6522. method: 'POST',
  6523. headers: {
  6524. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6525. Host: 'store.steampowered.com',
  6526. Origin: 'https://store.steampowered.com',
  6527. Referer: `https://store.steampowered.com/app/${id}`
  6528. },
  6529. data: $.param({
  6530. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6531. }),
  6532. dataType: 'json'
  6533. });
  6534. if (result === 'Success') {
  6535. var _data$response9;
  6536. 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) {
  6537. logStatus.success();
  6538. return true;
  6539. }
  6540. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6541. return false;
  6542. }
  6543. logStatus.error(`${result}:${statusText}(${status})`);
  6544. return false;
  6545. } catch (error) {
  6546. throwError(error, 'Steam.requestPlayTestAccess');
  6547. return false;
  6548. }
  6549. }
  6550. function Steam_setCache2(type, name, id) {
  6551. try {
  6552. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6553. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6554. } catch (error) {
  6555. throwError(error, 'Steam.setCache');
  6556. }
  6557. }
  6558. const social_Steam = Steam;
  6559. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6560. Website_checkPrivateRedeclaration(obj, privateSet);
  6561. privateSet.add(obj);
  6562. }
  6563. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6564. if (privateCollection.has(obj)) {
  6565. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6566. }
  6567. }
  6568. function Website_defineProperty(obj, key, value) {
  6569. if (key in obj) {
  6570. Object.defineProperty(obj, key, {
  6571. value: value,
  6572. enumerable: true,
  6573. configurable: true,
  6574. writable: true
  6575. });
  6576. } else {
  6577. obj[key] = value;
  6578. }
  6579. return obj;
  6580. }
  6581. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6582. if (!privateSet.has(receiver)) {
  6583. throw new TypeError('attempted to get private field on non-instance');
  6584. }
  6585. return fn;
  6586. }
  6587. var _bind = new WeakSet();
  6588. class Website {
  6589. constructor() {
  6590. Website_classPrivateMethodInitSpec(this, _bind);
  6591. Website_defineProperty(this, 'undoneTasks', void 0);
  6592. Website_defineProperty(this, 'socialTasks', void 0);
  6593. Website_defineProperty(this, 'giveawayId', void 0);
  6594. Website_defineProperty(this, 'socialInitialized', {
  6595. discord: false,
  6596. instagram: false,
  6597. reddit: false,
  6598. twitch: false,
  6599. twitter: false,
  6600. vk: false,
  6601. youtube: false,
  6602. steamStore: false,
  6603. steamCommunity: false
  6604. });
  6605. Website_defineProperty(this, 'initialized', false);
  6606. Website_defineProperty(this, 'social', {});
  6607. }
  6608. async initSocial(action) {
  6609. try {
  6610. const pro = [];
  6611. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6612. if (tasks.discord) {
  6613. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6614. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6615. this.social.discord = new social_Discord();
  6616. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6617. }
  6618. }
  6619. if (tasks.instagram) {
  6620. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6621. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6622. this.social.instagram = new social_Instagram();
  6623. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6624. }
  6625. }
  6626. if (tasks.reddit) {
  6627. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6628. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6629. this.social.reddit = new social_Reddit();
  6630. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6631. }
  6632. }
  6633. if (tasks.twitch) {
  6634. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6635. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6636. this.social.twitch = new social_Twitch();
  6637. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6638. }
  6639. }
  6640. if (tasks.twitter) {
  6641. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6642. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6643. this.social.twitter = new social_Twitter();
  6644. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6645. }
  6646. }
  6647. if (tasks.vk) {
  6648. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6649. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6650. this.social.vk = new social_Vk();
  6651. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6652. }
  6653. }
  6654. if (tasks.youtube) {
  6655. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6656. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6657. this.social.youtube = new Youtube();
  6658. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6659. }
  6660. }
  6661. if (tasks.steam) {
  6662. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6663. if (steamLength > 0) {
  6664. if (!this.social.steam) {
  6665. this.social.steam = new social_Steam();
  6666. }
  6667. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6668. var _tasks$steam, _tasks$steam$type;
  6669. 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;
  6670. }).reduce((total, number) => total + number, 0);
  6671. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6672. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6673. }
  6674. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6675. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6676. }
  6677. }
  6678. }
  6679. if (tasks.links && tasks.links.length > 0) {
  6680. this.social.visitLink = visitLink;
  6681. }
  6682. return await Promise.all(pro).then(result => {
  6683. let checked = true;
  6684. for (const data of result) {
  6685. if (data.result) {
  6686. this.socialInitialized[data.name] = data.result;
  6687. } else {
  6688. checked = false;
  6689. }
  6690. }
  6691. return checked;
  6692. });
  6693. } catch (error) {
  6694. throwError(error, 'Website.initSocial');
  6695. return false;
  6696. }
  6697. }
  6698. uniqueTasks(allTasks) {
  6699. const result = {};
  6700. for (const [ social, types ] of Object.entries(allTasks)) {
  6701. result[social] = {};
  6702. for (const [ type, tasks ] of Object.entries(types)) {
  6703. result[social][type] = unique(tasks);
  6704. }
  6705. }
  6706. return result;
  6707. }
  6708. async toggleTask(action) {
  6709. try {
  6710. if (!this.initialized && !this.init()) {
  6711. return false;
  6712. }
  6713. if (!await this.classifyTask(action)) {
  6714. return false;
  6715. }
  6716. if (!await this.initSocial(action)) {
  6717. return false;
  6718. }
  6719. const pro = [];
  6720. const doTask = action === 'do';
  6721. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6722. if (this.social.discord) {
  6723. pro.push(this.social.discord.toggle({
  6724. doTask: doTask,
  6725. ...tasks.discord
  6726. }));
  6727. }
  6728. if (this.social.instagram) {
  6729. pro.push(this.social.instagram.toggle({
  6730. doTask: doTask,
  6731. ...tasks.instagram
  6732. }));
  6733. }
  6734. if (this.social.reddit) {
  6735. pro.push(this.social.reddit.toggle({
  6736. doTask: doTask,
  6737. ...tasks.reddit
  6738. }));
  6739. }
  6740. if (this.social.twitch) {
  6741. pro.push(this.social.twitch.toggle({
  6742. doTask: doTask,
  6743. ...tasks.twitch
  6744. }));
  6745. }
  6746. if (this.social.twitter) {
  6747. pro.push(this.social.twitter.toggle({
  6748. doTask: doTask,
  6749. ...tasks.twitter
  6750. }));
  6751. }
  6752. if (this.social.vk) {
  6753. pro.push(this.social.vk.toggle({
  6754. doTask: doTask,
  6755. ...tasks.vk
  6756. }));
  6757. }
  6758. if (this.social.youtube) {
  6759. pro.push(this.social.youtube.toggle({
  6760. doTask: doTask,
  6761. ...tasks.youtube
  6762. }));
  6763. }
  6764. if (this.social.steam) {
  6765. pro.push(this.social.steam.toggle({
  6766. doTask: doTask,
  6767. ...tasks.steam
  6768. }));
  6769. }
  6770. if (this.social.visitLink && tasks.links && doTask) {
  6771. for (const link of tasks.links) {
  6772. pro.push(this.social.visitLink(link));
  6773. }
  6774. }
  6775. if (doTask && tasks.extra && this.extraDoTask) {
  6776. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6777. if (hasExtra) {
  6778. pro.push(this.extraDoTask(tasks.extra));
  6779. }
  6780. }
  6781. await Promise.all(pro);
  6782. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6783. return true;
  6784. } catch (error) {
  6785. throwError(error, 'Website.toggleTask');
  6786. return false;
  6787. }
  6788. }
  6789. async doTask() {
  6790. try {
  6791. return await this.toggleTask('do');
  6792. } catch (error) {
  6793. throwError(error, 'Website.doTask');
  6794. return false;
  6795. }
  6796. }
  6797. async undoTask() {
  6798. try {
  6799. return await this.toggleTask('undo');
  6800. } catch (error) {
  6801. throwError(error, 'Website.undoTask');
  6802. return false;
  6803. }
  6804. }
  6805. }
  6806. async function _bind2(name, init) {
  6807. try {
  6808. return {
  6809. name: name,
  6810. result: await init
  6811. };
  6812. } catch (error) {
  6813. throwError(error, 'Website.bind');
  6814. return {
  6815. name: name,
  6816. result: false
  6817. };
  6818. }
  6819. }
  6820. const website_Website = Website;
  6821. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6822. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6823. privateSet.add(obj);
  6824. }
  6825. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6826. if (privateCollection.has(obj)) {
  6827. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6828. }
  6829. }
  6830. function FreeAnyWhere_defineProperty(obj, key, value) {
  6831. if (key in obj) {
  6832. Object.defineProperty(obj, key, {
  6833. value: value,
  6834. enumerable: true,
  6835. configurable: true,
  6836. writable: true
  6837. });
  6838. } else {
  6839. obj[key] = value;
  6840. }
  6841. return obj;
  6842. }
  6843. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6844. if (!privateSet.has(receiver)) {
  6845. throw new TypeError('attempted to get private field on non-instance');
  6846. }
  6847. return fn;
  6848. }
  6849. const FreeAnyWhere_defaultTasksTemplate = {
  6850. steam: {
  6851. groupLinks: [],
  6852. wishlistLinks: [],
  6853. curatorLinks: [],
  6854. followLinks: []
  6855. },
  6856. vk: {
  6857. nameLinks: []
  6858. }
  6859. };
  6860. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6861. var _getGiveawayId = new WeakSet();
  6862. var _verify = new WeakSet();
  6863. class FreeAnyWhere extends website_Website {
  6864. constructor() {
  6865. super(...arguments);
  6866. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6867. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6868. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6869. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6870. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6871. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6872. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6873. }
  6874. static test() {
  6875. return window.location.host === 'freeanywhere.net';
  6876. }
  6877. init() {
  6878. try {
  6879. const logStatus = scripts_echoLog({
  6880. text: i18n('initing')
  6881. });
  6882. if ($('a[href="#/login"]').length > 0) {
  6883. window.open('/#/login', '_self');
  6884. logStatus.warning(i18n('needLogin'));
  6885. return false;
  6886. }
  6887. if (window.location.href.includes('/login')) {
  6888. logStatus.warning(i18n('needLogin'));
  6889. return false;
  6890. }
  6891. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6892. var _window$location$href;
  6893. 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];
  6894. if (!id) {
  6895. logStatus.error(i18n('getFailed', 'Id'));
  6896. return false;
  6897. }
  6898. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6899. }
  6900. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6901. return false;
  6902. }
  6903. this.initialized = true;
  6904. logStatus.success();
  6905. return true;
  6906. } catch (error) {
  6907. throwError(error, 'Freeanywhere.init');
  6908. return false;
  6909. }
  6910. }
  6911. async classifyTask(action) {
  6912. try {
  6913. const logStatus = scripts_echoLog({
  6914. text: i18n('getTasksInfo')
  6915. });
  6916. if (action === 'undo') {
  6917. var _GM_getValue;
  6918. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6919. }
  6920. const {
  6921. result,
  6922. statusText,
  6923. status,
  6924. data
  6925. } = await tools_httpRequest({
  6926. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6927. method: 'GET',
  6928. headers: {
  6929. authorization: `Token ${window.localStorage.getItem('token')}`,
  6930. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6931. },
  6932. responseType: 'json'
  6933. });
  6934. if (result === 'Success') {
  6935. var _data$response;
  6936. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6937. if (tasks) {
  6938. if (action === 'verify') {
  6939. this.tasks = [];
  6940. }
  6941. for (const task of tasks) {
  6942. const type = task.challenge;
  6943. const social = task.challenge_provider;
  6944. const taskInfo = {
  6945. id: task.id,
  6946. title: task.title
  6947. };
  6948. if (action === 'verify' && !task.is_success) {
  6949. this.tasks.push(taskInfo);
  6950. continue;
  6951. }
  6952. switch (social) {
  6953. case 'steam':
  6954. taskInfo.social = 'steam';
  6955. switch (type) {
  6956. case 'WL':
  6957. if (action === 'undo') {
  6958. this.socialTasks.steam.wishlistLinks.push(task.link);
  6959. }
  6960. if (action === 'do' && !task.is_success) {
  6961. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6962. }
  6963. break;
  6964.  
  6965. case 'JTG':
  6966. if (action === 'undo') {
  6967. this.socialTasks.steam.groupLinks.push(task.link);
  6968. }
  6969. if (action === 'do' && !task.is_success) {
  6970. this.undoneTasks.steam.groupLinks.push(task.link);
  6971. }
  6972. break;
  6973.  
  6974. case 'STC':
  6975. if (action === 'undo') {
  6976. this.socialTasks.steam.curatorLinks.push(task.link);
  6977. }
  6978. if (action === 'do' && !task.is_success) {
  6979. this.undoneTasks.steam.curatorLinks.push(task.link);
  6980. }
  6981. break;
  6982.  
  6983. case 'GF':
  6984. if (action === 'undo') {
  6985. this.socialTasks.steam.followLinks.push(task.link);
  6986. }
  6987. if (action === 'do' && !task.is_success) {
  6988. this.undoneTasks.steam.followLinks.push(task.link);
  6989. }
  6990. break;
  6991. }
  6992. break;
  6993.  
  6994. case 'vk-oauth2':
  6995. if (action === 'undo') {
  6996. this.socialTasks.vk.nameLinks.push(task.link);
  6997. }
  6998. if (action === 'do' && !task.is_success) {
  6999. this.undoneTasks.vk.nameLinks.push(task.link);
  7000. }
  7001. break;
  7002.  
  7003. case 'website':
  7004. break;
  7005.  
  7006. default:
  7007. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  7008. break;
  7009. }
  7010. }
  7011. logStatus.success();
  7012. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7013. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7014. if (window.DEBUG) {
  7015. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7016. }
  7017. GM_setValue(`fawTasks-${this.giveawayId}`, {
  7018. tasks: this.socialTasks,
  7019. time: new Date().getTime()
  7020. });
  7021. return true;
  7022. }
  7023. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7024. return false;
  7025. }
  7026. logStatus.error(`${result}:${statusText}(${status})`);
  7027. return false;
  7028. } catch (error) {
  7029. throwError(error, 'Freeanywhere.classifyTask');
  7030. return false;
  7031. }
  7032. }
  7033. async verifyTask() {
  7034. try {
  7035. if (!this.initialized && !this.init()) {
  7036. return false;
  7037. }
  7038. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7039. return false;
  7040. }
  7041. const pro = [];
  7042. for (const task of this.tasks) {
  7043. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  7044. await delay(1e3);
  7045. }
  7046. await Promise.all(pro);
  7047. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7048. return !!await this.getKey(true);
  7049. } catch (error) {
  7050. throwError(error, 'Freeanywhere.verifyTask');
  7051. return false;
  7052. }
  7053. }
  7054. async getKey(initialized) {
  7055. try {
  7056. if (!initialized && !this.initialized && !this.init()) {
  7057. return false;
  7058. }
  7059. const logStatus = scripts_echoLog({
  7060. text: i18n('gettingKey')
  7061. });
  7062. const {
  7063. result,
  7064. statusText,
  7065. status,
  7066. data
  7067. } = await tools_httpRequest({
  7068. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7069. method: 'GET',
  7070. dataType: 'json',
  7071. headers: {
  7072. authorization: `Token ${window.localStorage.getItem('token')}`
  7073. }
  7074. });
  7075. if (result === 'Success') {
  7076. var _data$response2;
  7077. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7078. logStatus.success();
  7079. scripts_echoLog({}).success(data.response.reward);
  7080. return data.response.reward;
  7081. }
  7082. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7083. return false;
  7084. }
  7085. logStatus.error(`${result}:${statusText}(${status})`);
  7086. return false;
  7087. } catch (error) {
  7088. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7089. return false;
  7090. }
  7091. }
  7092. }
  7093. function _getGiveawayId2() {
  7094. try {
  7095. var _window$location$href2;
  7096. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7097. if (giveawayId) {
  7098. this.giveawayId = giveawayId;
  7099. return true;
  7100. }
  7101. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7102. return false;
  7103. } catch (error) {
  7104. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7105. }
  7106. }
  7107. async function _verify2(task) {
  7108. try {
  7109. const logStatus = scripts_echoLog({
  7110. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7111. });
  7112. const {
  7113. result,
  7114. statusText,
  7115. status,
  7116. data
  7117. } = await tools_httpRequest({
  7118. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7119. method: 'GET',
  7120. dataType: 'json',
  7121. headers: {
  7122. authorization: `Token ${window.localStorage.getItem('token')}`,
  7123. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7124. }
  7125. });
  7126. if (result === 'Success') {
  7127. var _data$response3;
  7128. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7129. logStatus.success();
  7130. return true;
  7131. }
  7132. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7133. return false;
  7134. }
  7135. logStatus.error(`${result}:${statusText}(${status})`);
  7136. return false;
  7137. } catch (error) {
  7138. throwError(error, 'Freeanywhere.verify');
  7139. return false;
  7140. }
  7141. }
  7142. const website_FreeAnyWhere = FreeAnyWhere;
  7143. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7144. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7145. privateSet.add(obj);
  7146. }
  7147. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7148. if (privateCollection.has(obj)) {
  7149. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7150. }
  7151. }
  7152. function GiveawaySu_defineProperty(obj, key, value) {
  7153. if (key in obj) {
  7154. Object.defineProperty(obj, key, {
  7155. value: value,
  7156. enumerable: true,
  7157. configurable: true,
  7158. writable: true
  7159. });
  7160. } else {
  7161. obj[key] = value;
  7162. }
  7163. return obj;
  7164. }
  7165. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7166. if (!privateSet.has(receiver)) {
  7167. throw new TypeError('attempted to get private field on non-instance');
  7168. }
  7169. return fn;
  7170. }
  7171. const GiveawaySu_defaultTasks = {
  7172. steam: {
  7173. groupLinks: [],
  7174. wishlistLinks: [],
  7175. curatorLinks: [],
  7176. curatorLikeLinks: [],
  7177. followLinks: [],
  7178. forumLinks: [],
  7179. announcementLinks: [],
  7180. workshopVoteLinks: [],
  7181. playtestLinks: []
  7182. },
  7183. discord: {
  7184. serverLinks: []
  7185. },
  7186. instagram: {
  7187. userLinks: []
  7188. },
  7189. vk: {
  7190. nameLinks: []
  7191. },
  7192. twitch: {
  7193. channelLinks: []
  7194. },
  7195. reddit: {
  7196. redditLinks: []
  7197. },
  7198. youtube: {
  7199. channelLinks: [],
  7200. likeLinks: []
  7201. }
  7202. };
  7203. var _checkLogin = new WeakSet();
  7204. var _checkLeftKey = new WeakSet();
  7205. var GiveawaySu_getGiveawayId = new WeakSet();
  7206. class GiveawaySu extends website_Website {
  7207. constructor() {
  7208. super(...arguments);
  7209. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7210. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  7211. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7212. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7213. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7214. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7215. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7216. }
  7217. static test() {
  7218. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7219. }
  7220. async after() {
  7221. try {
  7222. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7223. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7224. }
  7225. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7226. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7227. }
  7228. scripts_echoLog({}).warning(i18n('gsNotice'));
  7229. } catch (error) {
  7230. throwError(error, 'Giveawaysu.after');
  7231. }
  7232. }
  7233. init() {
  7234. try {
  7235. const logStatus = scripts_echoLog({
  7236. text: i18n('initing')
  7237. });
  7238. if ($('a.steam-login').length > 0) {
  7239. window.open('/steam/redirect', '_self');
  7240. logStatus.warning(i18n('needLogin'));
  7241. return false;
  7242. }
  7243. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7244. return false;
  7245. }
  7246. this.initialized = true;
  7247. logStatus.success();
  7248. return true;
  7249. } catch (error) {
  7250. throwError(error, 'Giveawaysu.init');
  7251. return false;
  7252. }
  7253. }
  7254. async classifyTask(action) {
  7255. try {
  7256. const logStatus = scripts_echoLog({
  7257. text: i18n('getTasksInfo')
  7258. });
  7259. if (action === 'undo') {
  7260. var _GM_getValue;
  7261. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7262. return true;
  7263. }
  7264. const pro = [];
  7265. const tasks = $('#actions tr');
  7266. if ($('div.bind-discord').is(':visible')) {
  7267. $('div.bind-discord a')[0].click();
  7268. }
  7269. if ($('div.bind-twitch').is(':visible')) {
  7270. $('div.bind-twitch a')[0].click();
  7271. }
  7272. for (const task of tasks) {
  7273. pro.push(new Promise(resolve => {
  7274. const td = $(task).find('td:not(".hidden")');
  7275. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7276. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7277. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7278. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7279. const taskName = taskDes.text().trim();
  7280. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7281. return resolve(true);
  7282. }
  7283. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7284. if (!taskLink) {
  7285. return resolve(false);
  7286. }
  7287. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7288. this.undoneTasks.steam.groupLinks.push(taskLink);
  7289. } else if (/like.*announcement/gi.test(taskName)) {
  7290. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7291. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7292. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7293. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7294. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7295. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7296. this.undoneTasks.steam.forumLinks.push(taskLink);
  7297. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7298. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7299. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7300. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7301. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7302. this.undoneTasks.discord.serverLinks.push(taskLink);
  7303. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7304. this.undoneTasks.instagram.userLinks.push(taskLink);
  7305. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7306. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7307. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7308. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7309. } else if (/watch.*art/gim.test(taskName)) {
  7310. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7311. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7312. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7313. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7314. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7315. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7316. this.undoneTasks.vk.nameLinks.push(taskLink);
  7317. } else {
  7318. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7319. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7320. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7321. }
  7322. if (/follow.*button/gim.test(taskName)) {
  7323. this.undoneTasks.steam.followLinks.push(taskLink);
  7324. }
  7325. }
  7326. }
  7327. resolve(true);
  7328. }).catch(error => {
  7329. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7330. return false;
  7331. });
  7332. }));
  7333. }
  7334. await Promise.all(pro);
  7335. logStatus.success();
  7336. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7337. this.socialTasks = this.undoneTasks;
  7338. if (window.DEBUG) {
  7339. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7340. }
  7341. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7342. tasks: this.socialTasks,
  7343. time: new Date().getTime()
  7344. });
  7345. return true;
  7346. } catch (error) {
  7347. throwError(error, 'Giveawaysu.classifyTask');
  7348. return false;
  7349. }
  7350. }
  7351. }
  7352. function _checkLogin2() {
  7353. try {
  7354. if (!globalOptions.other.checkLogin) {
  7355. return true;
  7356. }
  7357. if ($('a.steam-login').length > 0) {
  7358. window.open('/steam/redirect', '_self');
  7359. }
  7360. return true;
  7361. } catch (error) {
  7362. throwError(error, 'Giveawaysu.checkLogin');
  7363. return false;
  7364. }
  7365. }
  7366. async function _checkLeftKey2() {
  7367. try {
  7368. if (!globalOptions.other.checkLeftKey) {
  7369. return true;
  7370. }
  7371. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7372. await external_Swal_default().fire({
  7373. icon: 'warning',
  7374. title: i18n('notice'),
  7375. text: i18n('noKeysLeft'),
  7376. confirmButtonText: i18n('confirm'),
  7377. cancelButtonText: i18n('cancel'),
  7378. showCancelButton: true
  7379. }).then(_ref => {
  7380. let {
  7381. value
  7382. } = _ref;
  7383. if (value) {
  7384. window.close();
  7385. }
  7386. });
  7387. }
  7388. return true;
  7389. } catch (error) {
  7390. throwError(error, 'Giveawaysu.checkLeftKey');
  7391. return false;
  7392. }
  7393. }
  7394. function GiveawaySu_getGiveawayId2() {
  7395. var _window$location$href;
  7396. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7397. if (giveawayId) {
  7398. this.giveawayId = giveawayId;
  7399. return true;
  7400. }
  7401. scripts_echoLog({
  7402. text: i18n('getFailed', 'GiveawayId')
  7403. });
  7404. return false;
  7405. }
  7406. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7407. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7408. privateSet.add(obj);
  7409. }
  7410. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7411. if (privateCollection.has(obj)) {
  7412. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7413. }
  7414. }
  7415. function Indiedb_defineProperty(obj, key, value) {
  7416. if (key in obj) {
  7417. Object.defineProperty(obj, key, {
  7418. value: value,
  7419. enumerable: true,
  7420. configurable: true,
  7421. writable: true
  7422. });
  7423. } else {
  7424. obj[key] = value;
  7425. }
  7426. return obj;
  7427. }
  7428. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7429. if (!privateSet.has(receiver)) {
  7430. throw new TypeError('attempted to get private field on non-instance');
  7431. }
  7432. return fn;
  7433. }
  7434. var _join = new WeakSet();
  7435. var _do = new WeakSet();
  7436. var Indiedb_checkLogin = new WeakSet();
  7437. var Indiedb_checkLeftKey = new WeakSet();
  7438. class Indiedb {
  7439. constructor() {
  7440. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7441. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7442. Indiedb_classPrivateMethodInitSpec(this, _do);
  7443. Indiedb_classPrivateMethodInitSpec(this, _join);
  7444. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7445. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7446. }
  7447. static test() {
  7448. return window.location.host === 'www.indiedb.com';
  7449. }
  7450. async after() {
  7451. try {
  7452. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7453. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7454. }
  7455. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7456. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7457. }
  7458. } catch (error) {
  7459. throwError(error, 'Indiedb.after');
  7460. }
  7461. }
  7462. async doTask() {
  7463. try {
  7464. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7465. return false;
  7466. }
  7467. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7468. } catch (error) {
  7469. throwError(error, 'Indiedb.doTask');
  7470. return false;
  7471. }
  7472. }
  7473. }
  7474. async function _join2() {
  7475. try {
  7476. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7477. scripts_echoLog({}).error(i18n('needLogin'));
  7478. return false;
  7479. }
  7480. const currentoption = $('a.buttonenter.buttongiveaway');
  7481. if (/join giveaway/gim.test(currentoption.text())) {
  7482. const logStatus = scripts_echoLog({
  7483. text: `${i18n('joiningGiveaway')}...`
  7484. });
  7485. const {
  7486. result,
  7487. statusText,
  7488. status,
  7489. data
  7490. } = await tools_httpRequest({
  7491. url: currentoption.attr('href'),
  7492. method: 'POST',
  7493. data: 'ajax=t',
  7494. dataType: 'json',
  7495. headers: {
  7496. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7497. accept: 'application/json, text/javascript, */*; q=0.01',
  7498. origin: window.location.origin
  7499. }
  7500. });
  7501. if (result === 'Success') {
  7502. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7503. var _data$response, _data$response4, _data$response5;
  7504. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7505. var _data$response2, _data$response3;
  7506. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7507. $('#giveawaysjoined').slideDown();
  7508. $('#giveawaysrecommend').slideDown();
  7509. 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}` : ''}`);
  7510. return true;
  7511. }
  7512. 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}` : ''}`);
  7513. return false;
  7514. }
  7515. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7516. return false;
  7517. }
  7518. logStatus.error(`${result}:${statusText}(${status})`);
  7519. return false;
  7520. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7521. return true;
  7522. }
  7523. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7524. return false;
  7525. } catch (error) {
  7526. throwError(error, 'Indiedb.init');
  7527. return false;
  7528. }
  7529. }
  7530. async function _do2() {
  7531. try {
  7532. const id = $('script').map((index, script) => {
  7533. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7534. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7535. 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] ];
  7536. }
  7537. return null;
  7538. });
  7539. if (id.length === 2) {
  7540. const pro = [];
  7541. const tasks = $('#giveawaysjoined a[class*=promo]');
  7542. for (const task of tasks) {
  7543. const promo = $(task);
  7544. if (!promo.hasClass('buttonentered')) {
  7545. const status = scripts_echoLog({
  7546. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7547. });
  7548. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7549. let text = '';
  7550. if (promo.hasClass('facebookpromo')) {
  7551. text = 'facebookpromo';
  7552. } else if (promo.hasClass('twitterpromo')) {
  7553. text = 'twitterpromo';
  7554. } else {
  7555. text = 'visitpromo';
  7556. }
  7557. pro.push(new Promise(resolve => {
  7558. $.ajax({
  7559. type: 'POST',
  7560. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7561. timeout: 6e4,
  7562. dataType: 'json',
  7563. data: {
  7564. ajax: 't'
  7565. },
  7566. error(response, error, exception) {
  7567. if (window.DEBUG) {
  7568. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7569. response: response,
  7570. error: error,
  7571. exception: exception
  7572. });
  7573. }
  7574. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7575. resolve(true);
  7576. },
  7577. success(response) {
  7578. if (response.success) {
  7579. status.success(`Success:${response.text}`);
  7580. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7581. resolve(true);
  7582. } else {
  7583. status.error(`Error:${response.text}`);
  7584. resolve(true);
  7585. }
  7586. }
  7587. });
  7588. }));
  7589. } else if (promo.hasClass('emailoptinpromo')) {
  7590. pro.push(new Promise(resolve => {
  7591. $.ajax({
  7592. type: 'POST',
  7593. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7594. timeout: 6e4,
  7595. dataType: 'json',
  7596. data: {
  7597. ajax: 't',
  7598. emailsystoggle: 4
  7599. },
  7600. error(response, error, exception) {
  7601. if (window.DEBUG) {
  7602. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7603. response: response,
  7604. error: error,
  7605. exception: exception
  7606. });
  7607. }
  7608. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7609. resolve(true);
  7610. },
  7611. success(response) {
  7612. if (response.success) {
  7613. status.success(`Success:${response.text}`);
  7614. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7615. resolve(true);
  7616. } else {
  7617. status.error(`Error:${response.text}`);
  7618. resolve(true);
  7619. }
  7620. }
  7621. });
  7622. }));
  7623. } else if (promo.hasClass('watchingpromo')) {
  7624. pro.push(new Promise(resolve => {
  7625. var _promo$attr;
  7626. const data = getUrlQuery(promo.attr('href'));
  7627. data.ajax = 't';
  7628. $.ajax({
  7629. type: 'POST',
  7630. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7631. timeout: 6e4,
  7632. dataType: 'json',
  7633. data: data,
  7634. error(response, error, exception) {
  7635. if (window.DEBUG) {
  7636. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7637. response: response,
  7638. error: error,
  7639. exception: exception
  7640. });
  7641. }
  7642. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7643. resolve(true);
  7644. },
  7645. success(response) {
  7646. if (response.success) {
  7647. status.success(`Success:${response.text}`);
  7648. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7649. resolve(true);
  7650. } else {
  7651. status.error(`Error:${response.text}`);
  7652. resolve(true);
  7653. }
  7654. }
  7655. });
  7656. }));
  7657. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7658. pro.push(new Promise(resolve => {
  7659. $.ajax({
  7660. type: 'POST',
  7661. url: urlPath(promo.attr('href')),
  7662. timeout: 6e4,
  7663. dataType: 'json',
  7664. data: {
  7665. ajax: 't'
  7666. },
  7667. error(response, error, exception) {
  7668. if (window.DEBUG) {
  7669. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7670. response: response,
  7671. error: error,
  7672. exception: exception
  7673. });
  7674. }
  7675. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7676. resolve(true);
  7677. },
  7678. success(response) {
  7679. if (response.success) {
  7680. status.success(`Success:${response.text}`);
  7681. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7682. resolve(true);
  7683. } else {
  7684. status.error(`Error:${response.text}`);
  7685. resolve(true);
  7686. }
  7687. }
  7688. });
  7689. }));
  7690. } else {
  7691. status.error(`Error:${i18n('unKnownTaskType')}`);
  7692. }
  7693. }
  7694. }
  7695. await Promise.all(pro);
  7696. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7697. return true;
  7698. }
  7699. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7700. return false;
  7701. } catch (error) {
  7702. throwError(error, 'Indiedb.classifyTask');
  7703. return false;
  7704. }
  7705. }
  7706. function Indiedb_checkLogin2() {
  7707. try {
  7708. if (!globalOptions.other.checkLogin) {
  7709. return true;
  7710. }
  7711. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7712. window.open('/members/login', '_self');
  7713. }
  7714. return true;
  7715. } catch (error) {
  7716. throwError(error, 'Indiedb.checkLogin');
  7717. return false;
  7718. }
  7719. }
  7720. async function Indiedb_checkLeftKey2() {
  7721. try {
  7722. if (!globalOptions.other.checkLeftKey) {
  7723. return true;
  7724. }
  7725. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7726. await external_Swal_default().fire({
  7727. icon: 'warning',
  7728. title: i18n('notice'),
  7729. text: i18n('giveawayEnded'),
  7730. confirmButtonText: i18n('confirm'),
  7731. cancelButtonText: i18n('cancel'),
  7732. showCancelButton: true
  7733. }).then(_ref => {
  7734. let {
  7735. value
  7736. } = _ref;
  7737. if (value) {
  7738. window.close();
  7739. }
  7740. });
  7741. }
  7742. return true;
  7743. } catch (error) {
  7744. throwError(error, 'Indiedb.checkLeftKey');
  7745. return false;
  7746. }
  7747. }
  7748. const website_Indiedb = Indiedb;
  7749. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7750. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7751. privateSet.add(obj);
  7752. }
  7753. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7754. if (privateCollection.has(obj)) {
  7755. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7756. }
  7757. }
  7758. function Keyhub_defineProperty(obj, key, value) {
  7759. if (key in obj) {
  7760. Object.defineProperty(obj, key, {
  7761. value: value,
  7762. enumerable: true,
  7763. configurable: true,
  7764. writable: true
  7765. });
  7766. } else {
  7767. obj[key] = value;
  7768. }
  7769. return obj;
  7770. }
  7771. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7772. if (!privateSet.has(receiver)) {
  7773. throw new TypeError('attempted to get private field on non-instance');
  7774. }
  7775. return fn;
  7776. }
  7777. const Keyhub_defaultTasksTemplate = {
  7778. steam: {
  7779. groupLinks: [],
  7780. officialGroupLinks: [],
  7781. wishlistLinks: [],
  7782. curatorLinks: []
  7783. },
  7784. discord: {
  7785. serverLinks: []
  7786. },
  7787. links: []
  7788. };
  7789. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7790. var Keyhub_getGiveawayId = new WeakSet();
  7791. var Keyhub_checkLeftKey = new WeakSet();
  7792. var Keyhub_checkLogin = new WeakSet();
  7793. class Keyhub extends website_Website {
  7794. constructor() {
  7795. super(...arguments);
  7796. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7797. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7798. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7799. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7800. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7801. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7802. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7803. }
  7804. static test() {
  7805. return window.location.host === 'key-hub.eu';
  7806. }
  7807. async after() {
  7808. try {
  7809. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7810. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7811. }
  7812. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7813. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7814. }
  7815. $('.NSFW').hide();
  7816. } catch (error) {
  7817. throwError(error, 'Keyhub.after');
  7818. }
  7819. }
  7820. init() {
  7821. try {
  7822. const logStatus = scripts_echoLog({
  7823. text: i18n('initing')
  7824. });
  7825. if ($('a[href*="/connect/steam"]').length > 0) {
  7826. window.open('/connect/steam', '_self');
  7827. logStatus.warning(i18n('needLogin'));
  7828. return false;
  7829. }
  7830. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7831. return false;
  7832. }
  7833. $('#VPNoverlay').hide();
  7834. $('#mainArticleSection').show();
  7835. this.initialized = true;
  7836. logStatus.success();
  7837. return true;
  7838. } catch (error) {
  7839. throwError(error, 'Keyhub.init');
  7840. return false;
  7841. }
  7842. }
  7843. async classifyTask(action) {
  7844. try {
  7845. const logStatus = scripts_echoLog({
  7846. text: i18n('getTasksInfo')
  7847. });
  7848. if (action === 'undo') {
  7849. var _GM_getValue;
  7850. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7851. }
  7852. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7853. for (const task of tasks) {
  7854. let link = $(task).attr('href');
  7855. const taskDes = $(task).text().trim();
  7856. if (!link) {
  7857. continue;
  7858. }
  7859. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7860. link = await getRedirectLink(link) || link;
  7861. }
  7862. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7863. window.open(link, '_blank');
  7864. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7865. if (action === 'undo') {
  7866. this.socialTasks.steam.groupLinks.push(link);
  7867. }
  7868. if (action === 'do') {
  7869. this.undoneTasks.steam.groupLinks.push(link);
  7870. }
  7871. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7872. if (action === 'undo') {
  7873. this.socialTasks.steam.officialGroupLinks.push(link);
  7874. }
  7875. if (action === 'do') {
  7876. this.undoneTasks.steam.officialGroupLinks.push(link);
  7877. }
  7878. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7879. if (action === 'undo') {
  7880. this.socialTasks.steam.wishlistLinks.push(link);
  7881. }
  7882. if (action === 'do') {
  7883. this.undoneTasks.steam.wishlistLinks.push(link);
  7884. }
  7885. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7886. if (action === 'undo') {
  7887. this.socialTasks.steam.curatorLinks.push(link);
  7888. }
  7889. if (action === 'do') {
  7890. this.undoneTasks.steam.curatorLinks.push(link);
  7891. }
  7892. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7893. if (action === 'undo') {
  7894. this.socialTasks.discord.serverLinks.push(link);
  7895. }
  7896. if (action === 'do') {
  7897. this.undoneTasks.discord.serverLinks.push(link);
  7898. }
  7899. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link) || /^https?:\/\/www\.facebook\.com\/.*/.test(link)) {} else {
  7900. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7901. }
  7902. }
  7903. logStatus.success();
  7904. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7905. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7906. if (window.DEBUG) {
  7907. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7908. }
  7909. GM_setValue(`khTasks-${this.giveawayId}`, {
  7910. tasks: this.socialTasks,
  7911. time: new Date().getTime()
  7912. });
  7913. return true;
  7914. } catch (error) {
  7915. throwError(error, 'Keyhub.classifyTask');
  7916. return false;
  7917. }
  7918. }
  7919. verifyTask() {
  7920. try {
  7921. scripts_echoLog({
  7922. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7923. });
  7924. $.get(window.location.href, res => {
  7925. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7926. });
  7927. } catch (error) {
  7928. throwError(error, 'keyhub.verifyTask');
  7929. }
  7930. }
  7931. }
  7932. function Keyhub_getGiveawayId2() {
  7933. try {
  7934. var _window$location$href;
  7935. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7936. if (giveawayId) {
  7937. this.giveawayId = giveawayId;
  7938. return true;
  7939. }
  7940. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7941. return false;
  7942. } catch (error) {
  7943. throwError(error, 'Keyhub.getGiveawayId');
  7944. return false;
  7945. }
  7946. }
  7947. async function Keyhub_checkLeftKey2() {
  7948. try {
  7949. if (!globalOptions.other.checkLeftKey) {
  7950. return true;
  7951. }
  7952. const leftKey = $('#keysleft').text().trim();
  7953. if (leftKey === '0') {
  7954. await external_Swal_default().fire({
  7955. icon: 'warning',
  7956. title: i18n('notice'),
  7957. text: i18n('noKeysLeft'),
  7958. confirmButtonText: i18n('confirm'),
  7959. cancelButtonText: i18n('cancel'),
  7960. showCancelButton: true
  7961. }).then(_ref => {
  7962. let {
  7963. value
  7964. } = _ref;
  7965. if (value) {
  7966. window.close();
  7967. }
  7968. });
  7969. }
  7970. return true;
  7971. } catch (error) {
  7972. throwError(error, 'Keyhub.checkLeftKey');
  7973. return false;
  7974. }
  7975. }
  7976. function Keyhub_checkLogin2() {
  7977. try {
  7978. if (!globalOptions.other.checkLogin) {
  7979. return true;
  7980. }
  7981. if ($('a[href*="/connect/steam"]').length > 0) {
  7982. window.open('/connect/steam', '_self');
  7983. }
  7984. return true;
  7985. } catch (error) {
  7986. throwError(error, 'Keyhub.checkLogin');
  7987. return false;
  7988. }
  7989. }
  7990. const website_Keyhub = Keyhub;
  7991. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7992. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7993. privateSet.add(obj);
  7994. }
  7995. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7996. if (privateCollection.has(obj)) {
  7997. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7998. }
  7999. }
  8000. function Givekey_defineProperty(obj, key, value) {
  8001. if (key in obj) {
  8002. Object.defineProperty(obj, key, {
  8003. value: value,
  8004. enumerable: true,
  8005. configurable: true,
  8006. writable: true
  8007. });
  8008. } else {
  8009. obj[key] = value;
  8010. }
  8011. return obj;
  8012. }
  8013. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  8014. if (!privateSet.has(receiver)) {
  8015. throw new TypeError('attempted to get private field on non-instance');
  8016. }
  8017. return fn;
  8018. }
  8019. const Givekey_defaultTasksTemplate = {
  8020. steam: {
  8021. groupLinks: [],
  8022. wishlistLinks: [],
  8023. curatorLinks: [],
  8024. curatorLikeLinks: []
  8025. },
  8026. twitter: {
  8027. userLinks: []
  8028. },
  8029. vk: {
  8030. nameLinks: []
  8031. },
  8032. discord: {
  8033. serverLinks: []
  8034. }
  8035. };
  8036. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  8037. var Givekey_verify = new WeakSet();
  8038. var Givekey_getGiveawayId = new WeakSet();
  8039. var Givekey_checkLeftKey = new WeakSet();
  8040. class Givekey extends website_Website {
  8041. constructor() {
  8042. super(...arguments);
  8043. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  8044. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  8045. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  8046. Givekey_defineProperty(this, 'name', 'Givekey');
  8047. Givekey_defineProperty(this, 'tasks', []);
  8048. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  8049. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  8050. Givekey_defineProperty(this, 'userId', void 0);
  8051. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8052. }
  8053. static test() {
  8054. return window.location.host === 'givekey.ru';
  8055. }
  8056. async after() {
  8057. try {
  8058. await new Promise(resolve => {
  8059. const checker = setInterval(() => {
  8060. if ($('#navbarDropdown').length > 0) {
  8061. clearInterval(checker);
  8062. resolve(true);
  8063. }
  8064. });
  8065. });
  8066. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8067. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8068. }
  8069. } catch (error) {
  8070. throwError(error, 'Givekey.after');
  8071. return false;
  8072. }
  8073. }
  8074. init() {
  8075. try {
  8076. const logStatus = scripts_echoLog({
  8077. text: i18n('initing')
  8078. });
  8079. if ($('a[href*="/auth/steam"]').length > 0) {
  8080. window.open('/auth/steam', '_self');
  8081. logStatus.warning(i18n('needLogin'));
  8082. return false;
  8083. }
  8084. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8085. return false;
  8086. }
  8087. const userId = $('meta[name="user-id"]').attr('content');
  8088. if (!userId) {
  8089. logStatus.error(i18n('getFailed', i18n('userId')));
  8090. return false;
  8091. }
  8092. this.userId = userId;
  8093. this.initialized = true;
  8094. logStatus.success();
  8095. return true;
  8096. } catch (error) {
  8097. throwError(error, 'Givekey.init');
  8098. return false;
  8099. }
  8100. }
  8101. async classifyTask(action) {
  8102. try {
  8103. const logStatus = scripts_echoLog({
  8104. text: i18n('getTasksInfo')
  8105. });
  8106. if (action === 'undo') {
  8107. var _GM_getValue;
  8108. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8109. }
  8110. const tasks = $('.card-body:has("button") .row');
  8111. for (const task of tasks) {
  8112. const taskEle = $(task);
  8113. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8114. if (isSuccess && action !== 'undo') {
  8115. continue;
  8116. }
  8117. const checkButton = taskEle.find('#task_check');
  8118. const taskId = checkButton.attr('data-id');
  8119. if (taskId) {
  8120. this.tasks.push(taskId);
  8121. }
  8122. if (action === 'verify') {
  8123. continue;
  8124. }
  8125. let href = taskEle.find('a').attr('href') || null;
  8126. const text = taskEle.find('a').text().trim();
  8127. const icon = taskEle.find('i');
  8128. if (!href || !text) {
  8129. continue;
  8130. }
  8131. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8132. href = await getRedirectLink(href);
  8133. }
  8134. if (!href) {
  8135. continue;
  8136. }
  8137. if (/^https?:\/\/vk\.com\//.test(href)) {
  8138. this.socialTasks.vk.nameLinks.push(href);
  8139. if (action === 'do' && !isSuccess) {
  8140. this.undoneTasks.vk.nameLinks.push(href);
  8141. }
  8142. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8143. this.socialTasks.steam.groupLinks.push(href);
  8144. if (action === 'do' && !isSuccess) {
  8145. this.undoneTasks.steam.groupLinks.push(href);
  8146. }
  8147. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8148. this.socialTasks.steam.wishlistLinks.push(href);
  8149. if (action === 'do' && !isSuccess) {
  8150. this.undoneTasks.steam.wishlistLinks.push(href);
  8151. }
  8152. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8153. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8154. this.socialTasks.steam.curatorLinks.push(href);
  8155. if (action === 'do' && !isSuccess) {
  8156. this.undoneTasks.steam.curatorLinks.push(href);
  8157. }
  8158. } else {
  8159. this.socialTasks.steam.curatorLikeLinks.push(href);
  8160. if (action === 'do' && !isSuccess) {
  8161. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8162. }
  8163. }
  8164. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8165. this.socialTasks.twitter.userLinks.push(href);
  8166. if (action === 'do' && !isSuccess) {
  8167. this.undoneTasks.twitter.userLinks.push(href);
  8168. }
  8169. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8170. this.socialTasks.discord.serverLinks.push(href);
  8171. if (action === 'do' && !isSuccess) {
  8172. this.undoneTasks.discord.serverLinks.push(href);
  8173. }
  8174. } else {
  8175. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8176. }
  8177. }
  8178. logStatus.success();
  8179. this.tasks = unique(this.tasks);
  8180. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8181. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8182. if (window.DEBUG) {
  8183. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8184. }
  8185. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8186. tasks: this.socialTasks,
  8187. time: new Date().getTime()
  8188. });
  8189. return true;
  8190. } catch (error) {
  8191. throwError(error, 'Givekey.classifyTask');
  8192. return false;
  8193. }
  8194. }
  8195. async verifyTask() {
  8196. try {
  8197. if (!this.initialized && !this.init()) {
  8198. return false;
  8199. }
  8200. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8201. return false;
  8202. }
  8203. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8204. const taskLength = this.tasks.length;
  8205. for (let i = 0; i < taskLength; i++) {
  8206. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8207. if (i < taskLength - 1) {
  8208. await delay(15e3);
  8209. }
  8210. }
  8211. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8212. scripts_echoLog({
  8213. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8214. });
  8215. return true;
  8216. } catch (error) {
  8217. throwError(error, 'Givekey.verifyTask');
  8218. return false;
  8219. }
  8220. }
  8221. }
  8222. async function Givekey_verify2(task) {
  8223. try {
  8224. const logStatus = scripts_echoLog({
  8225. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8226. });
  8227. return await new Promise(resolve => {
  8228. $.ajax({
  8229. url: 'https://givekey.ru/giveaway/task',
  8230. method: 'POST',
  8231. data: `id=${task}&user_id=${this.userId}`,
  8232. dataType: 'json',
  8233. headers: {
  8234. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8235. },
  8236. success: data => {
  8237. if (data.btn) {
  8238. $(`button[data-id=${this.userId}]`).html(data.btn);
  8239. }
  8240. if (data.status === 'ok') {
  8241. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8242. logStatus.success();
  8243. resolve(true);
  8244. } else if (data.status === 'end') {
  8245. logStatus.success();
  8246. scripts_echoLog({}).success(data.key);
  8247. resolve(true);
  8248. } else {
  8249. logStatus.error(`Error:${data.msg}`);
  8250. resolve(false);
  8251. }
  8252. },
  8253. error: xhr => {
  8254. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8255. resolve(false);
  8256. }
  8257. });
  8258. });
  8259. } catch (error) {
  8260. throwError(error, 'Givekey.verify');
  8261. return false;
  8262. }
  8263. }
  8264. function Givekey_getGiveawayId2() {
  8265. try {
  8266. var _window$location$href;
  8267. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8268. if (giveawayId) {
  8269. this.giveawayId = giveawayId;
  8270. return true;
  8271. }
  8272. scripts_echoLog({
  8273. text: i18n('getFailed', 'GiveawayId')
  8274. });
  8275. return false;
  8276. } catch (error) {
  8277. throwError(error, 'Givekey.getGiveawayId');
  8278. return false;
  8279. }
  8280. }
  8281. async function Givekey_checkLeftKey2() {
  8282. try {
  8283. if (!globalOptions.other.checkLeftKey) {
  8284. return true;
  8285. }
  8286. if (!$('#keys_count').text()) {
  8287. await external_Swal_default().fire({
  8288. icon: 'warning',
  8289. title: i18n('notice'),
  8290. text: i18n('noKeysLeft'),
  8291. confirmButtonText: i18n('confirm'),
  8292. cancelButtonText: i18n('cancel'),
  8293. showCancelButton: true
  8294. }).then(_ref => {
  8295. let {
  8296. value
  8297. } = _ref;
  8298. if (value) {
  8299. window.close();
  8300. }
  8301. });
  8302. }
  8303. return true;
  8304. } catch (error) {
  8305. throwError(error, 'Givekey.checkLeftKey');
  8306. return false;
  8307. }
  8308. }
  8309. const website_Givekey = Givekey;
  8310. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8311. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8312. privateSet.add(obj);
  8313. }
  8314. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8315. if (privateCollection.has(obj)) {
  8316. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8317. }
  8318. }
  8319. function GiveeClub_defineProperty(obj, key, value) {
  8320. if (key in obj) {
  8321. Object.defineProperty(obj, key, {
  8322. value: value,
  8323. enumerable: true,
  8324. configurable: true,
  8325. writable: true
  8326. });
  8327. } else {
  8328. obj[key] = value;
  8329. }
  8330. return obj;
  8331. }
  8332. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8333. if (!privateSet.has(receiver)) {
  8334. throw new TypeError('attempted to get private field on non-instance');
  8335. }
  8336. return fn;
  8337. }
  8338. var GiveeClub_checkLogin = new WeakSet();
  8339. var GiveeClub_getGiveawayId = new WeakSet();
  8340. var GiveeClub_checkLeftKey = new WeakSet();
  8341. class GiveeClub extends GiveawaySu {
  8342. constructor() {
  8343. super(...arguments);
  8344. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8345. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8346. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8347. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8348. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  8349. }
  8350. static test() {
  8351. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8352. }
  8353. async after() {
  8354. try {
  8355. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8356. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8357. }
  8358. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8359. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8360. }
  8361. } catch (error) {
  8362. throwError(error, 'GiveeClub.after');
  8363. }
  8364. }
  8365. init() {
  8366. try {
  8367. const logStatus = scripts_echoLog({
  8368. text: i18n('initing')
  8369. });
  8370. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8371. logStatus.warning(i18n('needLogin'));
  8372. return false;
  8373. }
  8374. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8375. return false;
  8376. }
  8377. this.initialized = true;
  8378. logStatus.success();
  8379. return true;
  8380. } catch (error) {
  8381. throwError(error, 'GiveeClub.init');
  8382. return false;
  8383. }
  8384. }
  8385. async classifyTask(action) {
  8386. try {
  8387. const logStatus = scripts_echoLog({
  8388. text: i18n('getTasksInfo')
  8389. });
  8390. if (action === 'undo') {
  8391. var _GM_getValue;
  8392. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8393. return true;
  8394. }
  8395. const pro = [];
  8396. const tasks = $('.event-actions tr');
  8397. for (const task of tasks) {
  8398. pro.push(new Promise(resolve => {
  8399. const taskDes = $(task).find('.event-action-label a');
  8400. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8401. const taskName = taskDes.text().trim();
  8402. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8403. return resolve(true);
  8404. }
  8405. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8406. if (!taskLink) {
  8407. return resolve(false);
  8408. }
  8409. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8410. this.undoneTasks.steam.groupLinks.push(taskLink);
  8411. } else if (/like.*announcement/gi.test(taskName)) {
  8412. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8413. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8414. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8415. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  8416. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8417. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8418. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8419. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8420. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8421. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8422. this.undoneTasks.steam.forumLinks.push(taskLink);
  8423. } else if (taskIcon.includes('discord')) {
  8424. this.undoneTasks.discord.serverLinks.push(taskLink);
  8425. } else if (taskIcon.includes('instagram')) {
  8426. this.undoneTasks.instagram.userLinks.push(taskLink);
  8427. } else if (taskIcon.includes('twitch')) {
  8428. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8429. } else if (taskIcon.includes('reddit')) {
  8430. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8431. } else if (/watch.*art/gim.test(taskName)) {
  8432. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8433. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8434. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8435. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8436. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8437. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8438. this.undoneTasks.vk.nameLinks.push(taskLink);
  8439. } else {
  8440. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8441. if (/follow.*button/gim.test(taskName)) {
  8442. this.undoneTasks.steam.followLinks.push(taskLink);
  8443. }
  8444. }
  8445. }
  8446. resolve(true);
  8447. }).catch(error => {
  8448. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8449. return false;
  8450. });
  8451. }));
  8452. }
  8453. await Promise.all(pro);
  8454. logStatus.success();
  8455. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8456. this.socialTasks = this.undoneTasks;
  8457. if (window.DEBUG) {
  8458. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8459. }
  8460. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8461. tasks: this.socialTasks,
  8462. time: new Date().getTime()
  8463. });
  8464. return true;
  8465. } catch (error) {
  8466. throwError(error, 'GiveeClub.classifyTask');
  8467. return false;
  8468. }
  8469. }
  8470. }
  8471. function GiveeClub_checkLogin2() {
  8472. try {
  8473. if (!globalOptions.other.checkLogin) {
  8474. return true;
  8475. }
  8476. if ($('a[href*="/account/auth"]').length > 0) {
  8477. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8478. }
  8479. return true;
  8480. } catch (error) {
  8481. throwError(error, 'GiveeClub.checkLogin');
  8482. return false;
  8483. }
  8484. }
  8485. function GiveeClub_getGiveawayId2() {
  8486. var _window$location$href;
  8487. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8488. if (giveawayId) {
  8489. this.giveawayId = giveawayId;
  8490. return true;
  8491. }
  8492. scripts_echoLog({
  8493. text: i18n('getFailed', 'GiveawayId')
  8494. });
  8495. return false;
  8496. }
  8497. async function GiveeClub_checkLeftKey2() {
  8498. try {
  8499. if (!globalOptions.other.checkLeftKey) {
  8500. return true;
  8501. }
  8502. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8503. await external_Swal_default().fire({
  8504. icon: 'warning',
  8505. title: i18n('notice'),
  8506. text: i18n('giveawayEnded'),
  8507. confirmButtonText: i18n('confirm'),
  8508. cancelButtonText: i18n('cancel'),
  8509. showCancelButton: true
  8510. }).then(_ref => {
  8511. let {
  8512. value
  8513. } = _ref;
  8514. if (value) {
  8515. window.close();
  8516. }
  8517. });
  8518. }
  8519. return true;
  8520. } catch (error) {
  8521. throwError(error, 'Giveawaysu.checkLeftKey');
  8522. return false;
  8523. }
  8524. }
  8525. const website_GiveeClub = GiveeClub;
  8526. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8527. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8528. privateSet.add(obj);
  8529. }
  8530. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8531. if (privateCollection.has(obj)) {
  8532. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8533. }
  8534. }
  8535. function OpiumPulses_defineProperty(obj, key, value) {
  8536. if (key in obj) {
  8537. Object.defineProperty(obj, key, {
  8538. value: value,
  8539. enumerable: true,
  8540. configurable: true,
  8541. writable: true
  8542. });
  8543. } else {
  8544. obj[key] = value;
  8545. }
  8546. return obj;
  8547. }
  8548. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8549. if (!privateSet.has(receiver)) {
  8550. throw new TypeError('attempted to get private field on non-instance');
  8551. }
  8552. return fn;
  8553. }
  8554. const defaultOptions = {
  8555. maxPoint: '99999999'
  8556. };
  8557. var _toggleTask = new WeakSet();
  8558. var OpiumPulses_checkLogin = new WeakSet();
  8559. class OpiumPulses {
  8560. constructor() {
  8561. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8562. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8563. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8564. OpiumPulses_defineProperty(this, 'options', {
  8565. ...defaultOptions,
  8566. ...GM_getValue('OpiumPulsesOptions')
  8567. });
  8568. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8569. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8570. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8571. }
  8572. static test() {
  8573. return window.location.host === 'www.opiumpulses.com';
  8574. }
  8575. async after() {
  8576. try {
  8577. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8578. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8579. }
  8580. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8581. } catch (error) {
  8582. throwError(error, 'OpiumPulses.after');
  8583. }
  8584. }
  8585. async doFreeTask() {
  8586. try {
  8587. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8588. } catch (error) {
  8589. throwError(error, 'OpiumPulses.doFreeTask');
  8590. }
  8591. }
  8592. async doPointTask() {
  8593. try {
  8594. var _$$text$match;
  8595. 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);
  8596. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8597. } catch (error) {
  8598. throwError(error, 'OpiumPulses.doPointTask');
  8599. }
  8600. }
  8601. init() {
  8602. return true;
  8603. }
  8604. classifyTask() {
  8605. return true;
  8606. }
  8607. }
  8608. async function _toggleTask2(type) {
  8609. try {
  8610. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8611. for (const item of items) {
  8612. var _$$find$text$match;
  8613. 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);
  8614. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8615. if (type === 'points' && needPoints > this.myPoints) {
  8616. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8617. } else if (type === 'points' && !needPoints) {
  8618. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8619. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8620. var _aElement$attr;
  8621. const logStatus = scripts_echoLog({
  8622. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8623. });
  8624. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8625. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8626. var _aElement$attr2, _aElement$attr2$match;
  8627. 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];
  8628. if (giveawayId) {
  8629. checkUser(giveawayId);
  8630. }
  8631. }
  8632. if (!aElement.attr('href')) {
  8633. logStatus.error('Error: No "href".');
  8634. continue;
  8635. }
  8636. const {
  8637. result,
  8638. statusText,
  8639. status,
  8640. data
  8641. } = await tools_httpRequest({
  8642. url: aElement.attr('href'),
  8643. method: 'GET'
  8644. });
  8645. if (result === 'Success') {
  8646. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8647. var _data$responseText$ma;
  8648. logStatus.success();
  8649. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8650. if (type === 'points' && points) {
  8651. this.myPoints = parseInt(points, 10);
  8652. }
  8653. } else {
  8654. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8655. }
  8656. } else {
  8657. logStatus.error(`${result}:${statusText}(${status})`);
  8658. }
  8659. }
  8660. }
  8661. scripts_echoLog({
  8662. text: '-----END-----'
  8663. });
  8664. } catch (error) {
  8665. throwError(error, 'OpiumPulses.toggleTask');
  8666. }
  8667. }
  8668. function OpiumPulses_checkLogin2() {
  8669. try {
  8670. if (!globalOptions.other.checkLogin) {
  8671. return true;
  8672. }
  8673. if ($('a[href*="/site/login"]').length > 1) {
  8674. window.open('/site/login', '_self');
  8675. }
  8676. return true;
  8677. } catch (error) {
  8678. throwError(error, 'OpiumPulses.checkLogin');
  8679. return false;
  8680. }
  8681. }
  8682. const website_OpiumPulses = OpiumPulses;
  8683. const external_dayjs_namespaceObject = dayjs;
  8684. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8685. const leftKeyChecker = {
  8686. async classify(link) {
  8687. try {
  8688. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8689. return await this.giveawaySu(link);
  8690. }
  8691. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8692. return await this.giveeClub(link);
  8693. }
  8694. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8695. return await this.gleam(link);
  8696. }
  8697. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8698. return await this.indieDb(link);
  8699. }
  8700. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8701. return await this.keyhub(link);
  8702. }
  8703. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8704. return await this.opquests(link);
  8705. }
  8706. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8707. return await this.itch(link);
  8708. }
  8709. return false;
  8710. } catch (error) {
  8711. throwError(error, 'leftKeyChecker.classify');
  8712. return false;
  8713. }
  8714. },
  8715. async giveawaySu(link) {
  8716. try {
  8717. const {
  8718. result,
  8719. data
  8720. } = await tools_httpRequest({
  8721. url: link,
  8722. method: 'GET'
  8723. });
  8724. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8725. if (data.responseText.includes('class="steam-login"')) {
  8726. return false;
  8727. }
  8728. if (data.responseText.includes('class="giveaway-ended"')) {
  8729. return 'Ended';
  8730. }
  8731. return 'Active';
  8732. }
  8733. return false;
  8734. } catch (error) {
  8735. throwError(error, 'leftKeyChecker.giveawaySu');
  8736. return false;
  8737. }
  8738. },
  8739. async giveeClub(link) {
  8740. try {
  8741. const {
  8742. result,
  8743. data
  8744. } = await tools_httpRequest({
  8745. url: link,
  8746. method: 'GET'
  8747. });
  8748. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8749. if (data.responseText.includes('class="event-winner"')) {
  8750. return 'Won';
  8751. }
  8752. if (data.responseText.includes('class="event-ended"')) {
  8753. return 'Ended';
  8754. }
  8755. return 'Active';
  8756. }
  8757. return false;
  8758. } catch (error) {
  8759. throwError(error, 'leftKeyChecker.giveeClub');
  8760. return false;
  8761. }
  8762. },
  8763. async gleam(link) {
  8764. try {
  8765. const {
  8766. result,
  8767. data
  8768. } = await tools_httpRequest({
  8769. url: link,
  8770. method: 'GET'
  8771. });
  8772. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8773. var _data$responseText$ma, _$$attr, _$$attr$match;
  8774. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8775. return 'Won';
  8776. }
  8777. 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];
  8778. if (!campaignDiv) {
  8779. return false;
  8780. }
  8781. 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];
  8782. if (!campaignString) {
  8783. return false;
  8784. }
  8785. const {
  8786. campaign
  8787. } = JSON.parse(campaignString);
  8788. if (campaign.banned) {
  8789. return 'Banned';
  8790. }
  8791. if (campaign.finished) {
  8792. return 'Ended';
  8793. }
  8794. if (campaign.paused) {
  8795. return 'Paused';
  8796. }
  8797. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8798. return 'NotStart';
  8799. }
  8800. return 'Active';
  8801. }
  8802. return false;
  8803. } catch (error) {
  8804. throwError(error, 'leftKeyChecker.gleam');
  8805. return false;
  8806. }
  8807. },
  8808. async indieDb(link) {
  8809. try {
  8810. const {
  8811. result,
  8812. data
  8813. } = await tools_httpRequest({
  8814. url: link,
  8815. method: 'GET'
  8816. });
  8817. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8818. if (data.responseText.includes('Congrats you WON')) {
  8819. return 'Won';
  8820. }
  8821. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8822. return 'Ended';
  8823. }
  8824. return 'Active';
  8825. }
  8826. return false;
  8827. } catch (error) {
  8828. throwError(error, 'leftKeyChecker.indieDb');
  8829. return false;
  8830. }
  8831. },
  8832. async keyhub(link) {
  8833. try {
  8834. const {
  8835. result,
  8836. data
  8837. } = await tools_httpRequest({
  8838. url: link,
  8839. method: 'GET'
  8840. });
  8841. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8842. var _data$responseText$ma2;
  8843. 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];
  8844. if (!keysleft) {
  8845. return false;
  8846. }
  8847. if (keysleft === '0') {
  8848. return 'Ended';
  8849. }
  8850. return `Active(${keysleft})`;
  8851. }
  8852. return false;
  8853. } catch (error) {
  8854. throwError(error, 'leftKeyChecker.keyhub');
  8855. return false;
  8856. }
  8857. },
  8858. async opquests(link) {
  8859. try {
  8860. const {
  8861. result,
  8862. data
  8863. } = await tools_httpRequest({
  8864. url: link,
  8865. method: 'GET'
  8866. });
  8867. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8868. var _data$responseText$ma3;
  8869. 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];
  8870. if (!keysleft) {
  8871. return false;
  8872. }
  8873. if (keysleft === '0') {
  8874. return 'Ended';
  8875. }
  8876. return `Active(${keysleft})`;
  8877. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8878. return 'Ended';
  8879. }
  8880. return false;
  8881. } catch (error) {
  8882. throwError(error, 'leftKeyChecker.opquests');
  8883. return false;
  8884. }
  8885. },
  8886. async itch(link) {
  8887. try {
  8888. const {
  8889. result,
  8890. data
  8891. } = await tools_httpRequest({
  8892. url: link,
  8893. method: 'GET'
  8894. });
  8895. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8896. var _data$responseText$ma4;
  8897. 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];
  8898. if (!endDate) {
  8899. return false;
  8900. }
  8901. if (new Date().getTime() > new Date(endDate).getTime()) {
  8902. return 'Ended';
  8903. }
  8904. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8905. }
  8906. return false;
  8907. } catch (error) {
  8908. throwError(error, 'leftKeyChecker.opquests');
  8909. return false;
  8910. }
  8911. }
  8912. };
  8913. const website_leftKeyChecker = leftKeyChecker;
  8914. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8915. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8916. privateSet.add(obj);
  8917. }
  8918. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8919. if (privateCollection.has(obj)) {
  8920. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8921. }
  8922. }
  8923. function Keylol_defineProperty(obj, key, value) {
  8924. if (key in obj) {
  8925. Object.defineProperty(obj, key, {
  8926. value: value,
  8927. enumerable: true,
  8928. configurable: true,
  8929. writable: true
  8930. });
  8931. } else {
  8932. obj[key] = value;
  8933. }
  8934. return obj;
  8935. }
  8936. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8937. if (!privateSet.has(receiver)) {
  8938. throw new TypeError('attempted to get private field on non-instance');
  8939. }
  8940. return fn;
  8941. }
  8942. const Keylol_defaultTasksTemplate = {
  8943. steam: {
  8944. groupLinks: [],
  8945. wishlistLinks: [],
  8946. curatorLinks: [],
  8947. curatorLikeLinks: [],
  8948. followLinks: [],
  8949. forumLinks: [],
  8950. announcementLinks: [],
  8951. workshopVoteLinks: [],
  8952. licenseLinks: []
  8953. },
  8954. discord: {
  8955. serverLinks: []
  8956. },
  8957. instagram: {
  8958. userLinks: []
  8959. },
  8960. vk: {
  8961. nameLinks: []
  8962. },
  8963. twitch: {
  8964. channelLinks: []
  8965. },
  8966. reddit: {
  8967. redditLinks: []
  8968. },
  8969. twitter: {
  8970. userLinks: [],
  8971. retweetLinks: []
  8972. },
  8973. youtube: {
  8974. channelLinks: [],
  8975. likeLinks: []
  8976. }
  8977. };
  8978. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  8979. var _addBtn = new WeakSet();
  8980. class Keylol extends website_Website {
  8981. constructor() {
  8982. super(...arguments);
  8983. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8984. Keylol_defineProperty(this, 'name', 'Keylol');
  8985. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  8986. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  8987. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8988. }
  8989. static test() {
  8990. var _$$eq$attr, _$$eq$attr2;
  8991. 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')));
  8992. }
  8993. init() {
  8994. return true;
  8995. }
  8996. after() {
  8997. try {
  8998. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8999. const mainPost = $(selector);
  9000. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  9001. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  9002. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  9003. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  9004. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  9005. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  9006. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  9007. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  9008. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  9009. if (discordLinks.length > 0) {
  9010. for (const discordLink of discordLinks) {
  9011. const link = $(discordLink).attr('href');
  9012. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  9013. continue;
  9014. }
  9015. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  9016. }
  9017. }
  9018. if (redditLinks.length > 0) {
  9019. for (const redditLink of redditLinks) {
  9020. const link = $(redditLink).attr('href');
  9021. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  9022. continue;
  9023. }
  9024. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  9025. }
  9026. }
  9027. if (insLinks.length > 0) {
  9028. for (const insLink of insLinks) {
  9029. const link = $(insLink).attr('href');
  9030. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  9031. continue;
  9032. }
  9033. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  9034. }
  9035. }
  9036. if (twitterLinks.length > 0) {
  9037. for (const twitterLink of twitterLinks) {
  9038. const link = $(twitterLink).attr('href');
  9039. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  9040. continue;
  9041. }
  9042. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  9043. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  9044. } else {
  9045. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  9046. }
  9047. }
  9048. }
  9049. if (twitchLinks.length > 0) {
  9050. for (const twitchLink of twitchLinks) {
  9051. const link = $(twitchLink).attr('href');
  9052. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  9053. continue;
  9054. }
  9055. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9056. }
  9057. }
  9058. if (vkLinks.length > 0) {
  9059. for (const vkLink of vkLinks) {
  9060. const link = $(vkLink).attr('href');
  9061. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9062. continue;
  9063. }
  9064. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9065. }
  9066. }
  9067. if (steamStoreLinks.length > 0) {
  9068. for (const steamStoreLink of steamStoreLinks) {
  9069. const link = $(steamStoreLink).attr('href');
  9070. if (!link) {
  9071. continue;
  9072. }
  9073. if (/curator\/[\d]+/.test(link)) {
  9074. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9075. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9076. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9077. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9078. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9079. } else if (/app\/[\d]+/.test(link)) {
  9080. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9081. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9082. }
  9083. }
  9084. }
  9085. if (steamCommunityLinks.length > 0) {
  9086. for (const steamCommunityLink of steamCommunityLinks) {
  9087. const link = $(steamCommunityLink).attr('href');
  9088. if (!link) {
  9089. continue;
  9090. }
  9091. if (/groups\/.+/.test(link)) {
  9092. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9093. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9094. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9095. }
  9096. }
  9097. }
  9098. if (ytbLinks.length > 0) {
  9099. for (const ytbLink of ytbLinks) {
  9100. const link = $(ytbLink).attr('href');
  9101. if (!link) {
  9102. continue;
  9103. }
  9104. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9105. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9106. }
  9107. }
  9108. 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');
  9109. if (giveawayLinks.length > 0) {
  9110. for (const giveawayLink of giveawayLinks) {
  9111. const link = $(giveawayLink).attr('href');
  9112. if (!link) {
  9113. continue;
  9114. }
  9115. website_leftKeyChecker.classify(link).then(status => {
  9116. if (!status) {
  9117. return;
  9118. }
  9119. if (/^Active/.test(status)) {
  9120. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9121. return;
  9122. }
  9123. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9124. }).catch(error => {
  9125. throwError(error, 'keylol.after -> leftKeyChecker');
  9126. });
  9127. }
  9128. }
  9129. if (this.name === 'Keylol') {
  9130. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9131. if (asfLinks.length > 0) {
  9132. for (const asfLink of asfLinks) {
  9133. const link = $(asfLink).attr('href');
  9134. if (!link) {
  9135. continue;
  9136. }
  9137. 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', '')}`);
  9138. }
  9139. }
  9140. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9141. if (subLinks.length > 0) {
  9142. for (const subLink of subLinks) {
  9143. var _link$match;
  9144. const link = $(subLink).attr('href');
  9145. if (!link) {
  9146. continue;
  9147. }
  9148. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9149. if (!subid) {
  9150. continue;
  9151. }
  9152. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9153. }
  9154. }
  9155. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9156. if (asfLinks2.length > 0) {
  9157. for (const asfLink of asfLinks2) {
  9158. const subid = asfLink.innerText.match(/[\d]+/g);
  9159. if (!subid || subid.length === 0) {
  9160. continue;
  9161. }
  9162. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9163. }
  9164. }
  9165. }
  9166. } catch (error) {
  9167. throwError(error, 'keylol.after');
  9168. }
  9169. }
  9170. classifyTask(action) {
  9171. try {
  9172. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9173. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9174. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9175. for (const btn of selectedBtns) {
  9176. const button = $(btn);
  9177. const social = button.attr('data-social');
  9178. const type = button.attr('data-type');
  9179. const link = button.attr('data-link');
  9180. if (!(social && type && link)) {
  9181. continue;
  9182. }
  9183. if (action === 'do') {
  9184. this.undoneTasks[social][type].push(link);
  9185. }
  9186. if (action === 'undo') {
  9187. this.socialTasks[social][type].push(link);
  9188. }
  9189. }
  9190. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9191. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9192. if (window.DEBUG) {
  9193. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9194. }
  9195. return true;
  9196. } catch (error) {
  9197. throwError(error, 'Keylol.classifyTask');
  9198. return false;
  9199. }
  9200. }
  9201. selectAll() {
  9202. try {
  9203. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9204. } catch (error) {
  9205. throwError(error, 'Keylol.selectAll');
  9206. }
  9207. }
  9208. selectNone() {
  9209. try {
  9210. $('.auto-task-keylol:visible').removeAttr('selected');
  9211. } catch (error) {
  9212. throwError(error, 'Keylol.selectNone');
  9213. }
  9214. }
  9215. invertSelect() {
  9216. try {
  9217. $('.auto-task-keylol:visible').each((index, element) => {
  9218. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9219. });
  9220. } catch (error) {
  9221. throwError(error, 'Keylol.invertSelect');
  9222. }
  9223. }
  9224. }
  9225. function _addBtn2(before, social, linkType, link) {
  9226. try {
  9227. $(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>`);
  9228. } catch (error) {
  9229. throwError(error, 'keylol.addBtn');
  9230. }
  9231. }
  9232. const website_Keylol = Keylol;
  9233. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9234. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9235. privateSet.add(obj);
  9236. }
  9237. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9238. if (privateCollection.has(obj)) {
  9239. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9240. }
  9241. }
  9242. function Opquests_defineProperty(obj, key, value) {
  9243. if (key in obj) {
  9244. Object.defineProperty(obj, key, {
  9245. value: value,
  9246. enumerable: true,
  9247. configurable: true,
  9248. writable: true
  9249. });
  9250. } else {
  9251. obj[key] = value;
  9252. }
  9253. return obj;
  9254. }
  9255. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9256. if (!privateSet.has(receiver)) {
  9257. throw new TypeError('attempted to get private field on non-instance');
  9258. }
  9259. return fn;
  9260. }
  9261. const Opquests_defaultTasks = {
  9262. steam: {
  9263. groupLinks: [],
  9264. wishlistLinks: [],
  9265. followLinks: [],
  9266. curatorLikeLinks: []
  9267. }
  9268. };
  9269. var Opquests_getGiveawayId = new WeakSet();
  9270. var Opquests_checkLogin = new WeakSet();
  9271. class Opquests extends website_Website {
  9272. constructor() {
  9273. super(...arguments);
  9274. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9275. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9276. Opquests_defineProperty(this, 'name', 'Opquests');
  9277. Opquests_defineProperty(this, 'undoneTasks', {
  9278. ...Opquests_defaultTasks
  9279. });
  9280. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9281. }
  9282. static test() {
  9283. return window.location.host === 'opquests.com';
  9284. }
  9285. async after() {
  9286. try {
  9287. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9288. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9289. }
  9290. } catch (error) {
  9291. throwError(error, 'Opquests.after');
  9292. }
  9293. }
  9294. init() {
  9295. try {
  9296. const logStatus = scripts_echoLog({
  9297. text: i18n('initing')
  9298. });
  9299. if ($('a[href*="/auth/redirect"]').length > 0) {
  9300. window.open('/auth/redirect', '_self');
  9301. logStatus.warning(i18n('needLogin'));
  9302. return false;
  9303. }
  9304. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9305. return false;
  9306. }
  9307. this.initialized = true;
  9308. logStatus.success();
  9309. return true;
  9310. } catch (error) {
  9311. throwError(error, 'Opquests.init');
  9312. return false;
  9313. }
  9314. }
  9315. async classifyTask(action) {
  9316. try {
  9317. if (action === 'undo') {
  9318. scripts_echoLog({
  9319. text: i18n('cannotUndo')
  9320. });
  9321. return false;
  9322. }
  9323. const logStatus = scripts_echoLog({
  9324. text: i18n('getTasksInfo')
  9325. });
  9326. const tasks = $('.w-full:contains("Validate") .items-center');
  9327. for (const task of tasks) {
  9328. const link = $(task).find('a:contains("Open")').attr('href');
  9329. const taskDes = $(task).find('div').eq(1).text().trim();
  9330. if (!link) {
  9331. continue;
  9332. }
  9333. if (/steamcommunity\.com\/groups\//.test(link)) {
  9334. this.undoneTasks.steam.groupLinks.push(link);
  9335. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9336. if (/wishlist/gim.test(taskDes)) {
  9337. this.undoneTasks.steam.wishlistLinks.push(link);
  9338. } else if (/follow/gim.test(taskDes)) {
  9339. this.undoneTasks.steam.followLinks.push(link);
  9340. }
  9341. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9342. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9343. } else {
  9344. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9345. }
  9346. }
  9347. logStatus.success();
  9348. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9349. if (window.DEBUG) {
  9350. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9351. }
  9352. return true;
  9353. } catch (error) {
  9354. throwError(error, 'Opquests.classifyTask');
  9355. return false;
  9356. }
  9357. }
  9358. }
  9359. function Opquests_getGiveawayId2() {
  9360. try {
  9361. var _window$location$href;
  9362. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9363. if (giveawayId) {
  9364. this.giveawayId = giveawayId;
  9365. return true;
  9366. }
  9367. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9368. return false;
  9369. } catch (error) {
  9370. throwError(error, 'Opquests.getGiveawayId');
  9371. return false;
  9372. }
  9373. }
  9374. function Opquests_checkLogin2() {
  9375. try {
  9376. if (!globalOptions.other.checkLogin) {
  9377. return true;
  9378. }
  9379. if ($('a[href*="/auth/redirect"]').length > 0) {
  9380. window.open('/auth/redirect', '_self');
  9381. }
  9382. return true;
  9383. } catch (error) {
  9384. throwError(error, 'Opquests.checkLogin');
  9385. return false;
  9386. }
  9387. }
  9388. const website_Opquests = Opquests;
  9389. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9390. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9391. privateSet.add(obj);
  9392. }
  9393. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9394. if (privateCollection.has(obj)) {
  9395. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9396. }
  9397. }
  9398. function Gleam_defineProperty(obj, key, value) {
  9399. if (key in obj) {
  9400. Object.defineProperty(obj, key, {
  9401. value: value,
  9402. enumerable: true,
  9403. configurable: true,
  9404. writable: true
  9405. });
  9406. } else {
  9407. obj[key] = value;
  9408. }
  9409. return obj;
  9410. }
  9411. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9412. if (!privateSet.has(receiver)) {
  9413. throw new TypeError('attempted to get private field on non-instance');
  9414. }
  9415. return fn;
  9416. }
  9417. const Gleam_defaultTasksTemplate = {
  9418. steam: {
  9419. groupLinks: [],
  9420. wishlistLinks: [],
  9421. followLinks: [],
  9422. curatorLinks: [],
  9423. curatorLikeLinks: []
  9424. },
  9425. twitter: {
  9426. userLinks: [],
  9427. retweetLinks: []
  9428. },
  9429. twitch: {
  9430. channelLinks: []
  9431. },
  9432. discord: {
  9433. serverLinks: []
  9434. },
  9435. youtube: {
  9436. channelLinks: []
  9437. },
  9438. extra: {
  9439. gleam: []
  9440. }
  9441. };
  9442. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9443. const Gleam_defaultOptions = {
  9444. vlootUsername: '',
  9445. gameroundUsername: ''
  9446. };
  9447. var _checkSync = new WeakSet();
  9448. var _doGleamTask = new WeakSet();
  9449. var Gleam_getGiveawayId = new WeakSet();
  9450. var _getGleamLink = new WeakSet();
  9451. var Gleam_checkLeftKey = new WeakSet();
  9452. class Gleam extends website_Website {
  9453. constructor() {
  9454. super(...arguments);
  9455. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9456. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9457. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9458. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9459. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9460. Gleam_defineProperty(this, 'name', 'Gleam');
  9461. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9462. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9463. Gleam_defineProperty(this, 'options', {
  9464. ...Gleam_defaultOptions,
  9465. ...GM_getValue('GleamOptions')
  9466. });
  9467. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9468. }
  9469. static test() {
  9470. return window.location.host === 'gleam.io';
  9471. }
  9472. async after() {
  9473. try {
  9474. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9475. const checkComplete = setInterval(() => {
  9476. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9477. clearInterval(checkComplete);
  9478. window.close();
  9479. }
  9480. });
  9481. for (const task of $('.entry-content .entry-method')) {
  9482. const taskInfo = $(task).find('.user-links');
  9483. const expandInfo = $(task).find('.expandable');
  9484. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9485. if (aElements.length > 0) {
  9486. for (const element of aElements) {
  9487. const $element = $(element);
  9488. const href = $element.attr('href');
  9489. $element.removeAttr('href')[0].click();
  9490. $element.attr('href', href);
  9491. await delay(1e3);
  9492. }
  9493. }
  9494. taskInfo[0].click();
  9495. await delay(1e3);
  9496. }
  9497. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9498. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9499. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9500. }
  9501. } catch (error) {
  9502. throwError(error, 'Gleam.after');
  9503. return false;
  9504. }
  9505. }
  9506. init() {
  9507. try {
  9508. const logStatus = scripts_echoLog({
  9509. text: i18n('initing')
  9510. });
  9511. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9512. return false;
  9513. }
  9514. this.initialized = true;
  9515. logStatus.success();
  9516. return true;
  9517. } catch (error) {
  9518. throwError(error, 'Gleam.init');
  9519. return false;
  9520. }
  9521. }
  9522. async classifyTask(action) {
  9523. try {
  9524. const logStatus = scripts_echoLog({
  9525. text: i18n('getTasksInfo')
  9526. });
  9527. if (action === 'undo') {
  9528. var _GM_getValue;
  9529. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9530. }
  9531. const tasks = $('.entry-content .entry-method');
  9532. for (const task of tasks) {
  9533. var _socialIcon$attr;
  9534. const $task = $(task);
  9535. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9536. continue;
  9537. }
  9538. const socialIcon = $task.find('.icon-wrapper i');
  9539. const taskInfo = $task.find('.user-links');
  9540. const taskText = taskInfo.text().trim();
  9541. const expandInfo = $task.find('.expandable');
  9542. const aElements = expandInfo.find('a.btn');
  9543. if (aElements.length > 0) {
  9544. for (const element of aElements) {
  9545. const $element = $(element);
  9546. const href = $element.attr('href');
  9547. $element.removeAttr('href')[0].click();
  9548. $element.attr('href', href);
  9549. }
  9550. }
  9551. if (socialIcon.hasClass('fa-twitter')) {
  9552. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9553. if (!link) {
  9554. continue;
  9555. }
  9556. if (/follow/gi.test(taskText)) {
  9557. if (action === 'undo') {
  9558. this.socialTasks.twitter.userLinks.push(link);
  9559. }
  9560. if (action === 'do') {
  9561. this.undoneTasks.twitter.userLinks.push(link);
  9562. }
  9563. } else if (/retweet/gim.test(taskText)) {
  9564. if (action === 'undo') {
  9565. this.socialTasks.twitter.retweetLinks.push(link);
  9566. }
  9567. if (action === 'do') {
  9568. this.undoneTasks.twitter.retweetLinks.push(link);
  9569. }
  9570. }
  9571. } else if (socialIcon.hasClass('fa-twitch')) {
  9572. if (/follow/gim.test(taskText)) {
  9573. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9574. if (!link) {
  9575. continue;
  9576. }
  9577. if (action === 'undo') {
  9578. this.socialTasks.twitch.channelLinks.push(link);
  9579. }
  9580. if (action === 'do') {
  9581. this.undoneTasks.twitch.channelLinks.push(link);
  9582. }
  9583. }
  9584. } else if (socialIcon.hasClass('fa-discord')) {
  9585. if (/join/gim.test(taskText)) {
  9586. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9587. if (!link) {
  9588. var _$task$find$attr, _$task$find$attr$matc;
  9589. 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];
  9590. if (!ggLink) {
  9591. continue;
  9592. }
  9593. link = `https://discord.com/invite/${ggLink}`;
  9594. }
  9595. if (action === 'undo') {
  9596. this.socialTasks.discord.serverLinks.push(link);
  9597. }
  9598. if (action === 'do') {
  9599. this.undoneTasks.discord.serverLinks.push(link);
  9600. }
  9601. }
  9602. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9603. continue;
  9604. } else if (socialIcon.hasClass('fa-youtube')) {
  9605. if (/subscribe/gim.test(taskText)) {
  9606. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9607. if (!link) {
  9608. continue;
  9609. }
  9610. if (action === 'undo') {
  9611. this.socialTasks.youtube.channelLinks.push(link);
  9612. }
  9613. if (action === 'do') {
  9614. this.undoneTasks.youtube.channelLinks.push(link);
  9615. }
  9616. }
  9617. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9618. if (/join.*group/gi.test(taskText)) {
  9619. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9620. if (!link) {
  9621. continue;
  9622. }
  9623. if (action === 'undo') {
  9624. this.socialTasks.steam.groupLinks.push(link);
  9625. }
  9626. if (action === 'do') {
  9627. this.undoneTasks.steam.groupLinks.push(link);
  9628. }
  9629. } else if (/follow.*curator/gi.test(taskText)) {
  9630. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9631. if (!link) {
  9632. continue;
  9633. }
  9634. if (action === 'undo') {
  9635. this.socialTasks.steam.curatorLinks.push(link);
  9636. }
  9637. if (action === 'do') {
  9638. this.undoneTasks.steam.curatorLinks.push(link);
  9639. }
  9640. }
  9641. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9642. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9643. for (const button of continueBtn) {
  9644. button.click();
  9645. await delay(500);
  9646. expandInfo.find('input').val(this.options.vlootUsername);
  9647. }
  9648. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9649. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9650. for (const button of continueBtn) {
  9651. button.click();
  9652. await delay(500);
  9653. expandInfo.find('input').val(this.options.gameroundUsername);
  9654. }
  9655. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9656. if (action !== 'do') {
  9657. continue;
  9658. }
  9659. const link = aElements.attr('href');
  9660. if (!link) {
  9661. continue;
  9662. }
  9663. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9664. if (!gleamLink) {
  9665. continue;
  9666. }
  9667. this.undoneTasks.extra.gleam.push(gleamLink);
  9668. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-instagram') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-telegram-plane') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  9669. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9670. }
  9671. }
  9672. logStatus.success();
  9673. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9674. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9675. if (window.DEBUG) {
  9676. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9677. }
  9678. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9679. tasks: this.socialTasks,
  9680. time: new Date().getTime()
  9681. });
  9682. return true;
  9683. } catch (error) {
  9684. throwError(error, 'Gleam.classifyTask');
  9685. return false;
  9686. }
  9687. }
  9688. async extraDoTask(_ref) {
  9689. let {
  9690. gleam
  9691. } = _ref;
  9692. try {
  9693. const pro = [];
  9694. for (const link of gleam) {
  9695. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9696. }
  9697. return Promise.all(pro).then(() => true);
  9698. } catch (error) {
  9699. throwError(error, 'Gleam.extraDoTask');
  9700. return false;
  9701. }
  9702. }
  9703. async verifyTask() {
  9704. try {
  9705. scripts_echoLog({
  9706. text: `${i18n('verifyingTask')}...`
  9707. });
  9708. const tasks = $('.entry-content .entry-method');
  9709. for (const task of tasks) {
  9710. const $task = $(task);
  9711. if ($task.find('i.fa-question').length === 0) {
  9712. continue;
  9713. }
  9714. const taskInfo = $task.find('.user-links');
  9715. taskInfo[0].click();
  9716. await delay(500);
  9717. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9718. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9719. for (const button of continueBtn) {
  9720. button.click();
  9721. await delay(500);
  9722. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9723. }
  9724. }
  9725. scripts_echoLog({
  9726. text: i18n('verifiedGleamTasks')
  9727. });
  9728. } catch (error) {
  9729. throwError(error, 'Gleam.verifyTask');
  9730. return false;
  9731. }
  9732. }
  9733. }
  9734. async function _checkSync2() {
  9735. try {
  9736. return await new Promise(resolve => {
  9737. const checker = setInterval(() => {
  9738. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9739. clearInterval(checker);
  9740. resolve(true);
  9741. }
  9742. }, 500);
  9743. });
  9744. } catch (error) {
  9745. throwError(error, 'Gleam.checkSync');
  9746. return false;
  9747. }
  9748. }
  9749. async function _doGleamTask2(link) {
  9750. try {
  9751. const logStatus = scripts_echoLog({
  9752. text: i18n('doingGleamTask')
  9753. });
  9754. return await new Promise(resolve => {
  9755. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9756. active: true,
  9757. insert: true,
  9758. setParent: true
  9759. }).onclose = () => {
  9760. logStatus.success();
  9761. resolve(true);
  9762. };
  9763. });
  9764. } catch (error) {
  9765. throwError(error, 'Gleam.doGleamTask');
  9766. return false;
  9767. }
  9768. }
  9769. function Gleam_getGiveawayId2() {
  9770. try {
  9771. const giveawayId = window.location.pathname;
  9772. if (giveawayId) {
  9773. this.giveawayId = giveawayId;
  9774. return true;
  9775. }
  9776. scripts_echoLog({
  9777. text: i18n('getFailed', 'GiveawayId')
  9778. });
  9779. return false;
  9780. } catch (error) {
  9781. throwError(error, 'Gleam.getGiveawayId');
  9782. return false;
  9783. }
  9784. }
  9785. async function _getGleamLink2(link) {
  9786. try {
  9787. const logStatus = scripts_echoLog({
  9788. text: i18n('gettingGleamLink')
  9789. });
  9790. const {
  9791. result,
  9792. statusText,
  9793. status,
  9794. data
  9795. } = await tools_httpRequest({
  9796. url: link,
  9797. method: 'GET'
  9798. });
  9799. if (result === 'Success') {
  9800. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9801. var _data$responseText$ma;
  9802. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9803. if (gleamLink) {
  9804. logStatus.success();
  9805. return gleamLink;
  9806. }
  9807. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9808. return false;
  9809. }
  9810. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9811. return false;
  9812. }
  9813. logStatus.error(`${result}:${statusText}(${status})`);
  9814. return false;
  9815. } catch (error) {
  9816. throwError(error, 'Gleam.getGleamLink');
  9817. return false;
  9818. }
  9819. }
  9820. async function Gleam_checkLeftKey2() {
  9821. try {
  9822. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9823. if (!globalOptions.other.checkLeftKey) {
  9824. return true;
  9825. }
  9826. 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];
  9827. if (!campaignString) {
  9828. return false;
  9829. }
  9830. const {
  9831. campaign,
  9832. incentive
  9833. } = JSON.parse(campaignString);
  9834. 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];
  9835. let ownedKey = false;
  9836. if (controllerString) {
  9837. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9838. 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) {
  9839. ownedKey = true;
  9840. }
  9841. }
  9842. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9843. await external_Swal_default().fire({
  9844. icon: 'warning',
  9845. title: i18n('notice'),
  9846. text: i18n('giveawayNotWork'),
  9847. confirmButtonText: i18n('confirm'),
  9848. cancelButtonText: i18n('cancel'),
  9849. showCancelButton: true
  9850. }).then(_ref2 => {
  9851. let {
  9852. value
  9853. } = _ref2;
  9854. if (value) {
  9855. window.close();
  9856. }
  9857. });
  9858. }
  9859. return true;
  9860. } catch (error) {
  9861. throwError(error, 'Gleam.checkLeftKey');
  9862. return false;
  9863. }
  9864. }
  9865. const website_Gleam = Gleam;
  9866. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9867. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9868. privateSet.add(obj);
  9869. }
  9870. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9871. if (privateCollection.has(obj)) {
  9872. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9873. }
  9874. }
  9875. function SweepWidget_defineProperty(obj, key, value) {
  9876. if (key in obj) {
  9877. Object.defineProperty(obj, key, {
  9878. value: value,
  9879. enumerable: true,
  9880. configurable: true,
  9881. writable: true
  9882. });
  9883. } else {
  9884. obj[key] = value;
  9885. }
  9886. return obj;
  9887. }
  9888. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9889. if (!privateSet.has(receiver)) {
  9890. throw new TypeError('attempted to get private field on non-instance');
  9891. }
  9892. return fn;
  9893. }
  9894. const SweepWidget_defaultOptions = {
  9895. username: '',
  9896. email: ''
  9897. };
  9898. var SweepWidget_checkLogin = new WeakSet();
  9899. var SweepWidget_getGiveawayId = new WeakSet();
  9900. var _checkEnter = new WeakSet();
  9901. var _checkFinish = new WeakSet();
  9902. class SweepWidget extends website_Website {
  9903. constructor() {
  9904. super(...arguments);
  9905. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9906. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9907. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9908. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9909. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9910. SweepWidget_defineProperty(this, 'options', {
  9911. ...SweepWidget_defaultOptions,
  9912. ...GM_getValue('SweepWidgetOptions')
  9913. });
  9914. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9915. }
  9916. static test() {
  9917. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9918. }
  9919. async after() {
  9920. try {
  9921. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9922. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9923. }
  9924. } catch (error) {
  9925. throwError(error, 'SweepWidget.after');
  9926. }
  9927. }
  9928. init() {
  9929. try {
  9930. const logStatus = scripts_echoLog({
  9931. text: i18n('initing')
  9932. });
  9933. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9934. logStatus.warning(i18n('needLogin'));
  9935. return false;
  9936. }
  9937. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9938. return false;
  9939. }
  9940. this.initialized = true;
  9941. logStatus.success();
  9942. return true;
  9943. } catch (error) {
  9944. throwError(error, 'SweepWidget.init');
  9945. return false;
  9946. }
  9947. }
  9948. classifyTask() {
  9949. return true;
  9950. }
  9951. async doTask() {
  9952. try {
  9953. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9954. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9955. $('input[name="sw__login_name"]').val(this.options.username);
  9956. }
  9957. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9958. $('input[name="sw__login_email"]').val(this.options.email);
  9959. }
  9960. if ($('#sw_login_button:visible').length > 0) {
  9961. $('#sw_login_button')[0].click();
  9962. }
  9963. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9964. return false;
  9965. }
  9966. }
  9967. const logStatus = scripts_echoLog({
  9968. text: i18n('SweepWidgetNotice')
  9969. });
  9970. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9971. for (const task of tasks) {
  9972. var _aElement$, _$task$find$removeAtt;
  9973. const $task = $(task);
  9974. if ($task.find('i.fa-check:visible').length > 0) {
  9975. continue;
  9976. }
  9977. const title = $task.find('.sw_text_inner');
  9978. title[0].click();
  9979. const aElement = $task.find('a.sw_link');
  9980. const link = aElement.attr('href');
  9981. aElement.attr('href', '#a').attr('target', '_self');
  9982. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9983. await delay(300);
  9984. aElement.attr('href', link).attr('target', '_blank');
  9985. $task.find('input[type="text"]').val('test');
  9986. const verifyBtn = $task.find('input.sw_verify');
  9987. if (verifyBtn.prop('disabled') === true) {
  9988. title[0].click();
  9989. await delay(300);
  9990. title[0].click();
  9991. await delay(300);
  9992. }
  9993. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9994. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9995. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9996. }
  9997. logStatus.success();
  9998. return true;
  9999. } catch (error) {
  10000. throwError(error, 'SweepWidget.doTask');
  10001. return false;
  10002. }
  10003. }
  10004. }
  10005. function SweepWidget_checkLogin2() {
  10006. try {
  10007. if ($('#twitter_login_button').length > 0) {
  10008. $('#twitter_login_button')[0].click();
  10009. }
  10010. return true;
  10011. } catch (error) {
  10012. throwError(error, 'SweepWidget.checkLogin');
  10013. return false;
  10014. }
  10015. }
  10016. function SweepWidget_getGiveawayId2() {
  10017. try {
  10018. var _window$location$href;
  10019. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  10020. if (giveawayId) {
  10021. this.giveawayId = giveawayId;
  10022. return true;
  10023. }
  10024. scripts_echoLog({
  10025. text: i18n('getFailed', 'GiveawayId')
  10026. });
  10027. return false;
  10028. } catch (error) {
  10029. throwError(error, 'SweepWidget.getGiveawayId');
  10030. return false;
  10031. }
  10032. }
  10033. async function _checkEnter2() {
  10034. try {
  10035. return new Promise(resolve => {
  10036. const checker = setInterval(() => {
  10037. if ($('#unlock_rewards_main_wrapper').length > 0) {
  10038. clearInterval(checker);
  10039. resolve(true);
  10040. }
  10041. });
  10042. });
  10043. } catch (error) {
  10044. throwError(error, 'SweepWidget.checkEnter');
  10045. return false;
  10046. }
  10047. }
  10048. async function _checkFinish2($task) {
  10049. try {
  10050. return new Promise(resolve => {
  10051. const checker = setInterval(() => {
  10052. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  10053. clearInterval(checker);
  10054. resolve(true);
  10055. }
  10056. });
  10057. });
  10058. } catch (error) {
  10059. throwError(error, 'SweepWidget.checkFinish');
  10060. return false;
  10061. }
  10062. }
  10063. const website_SweepWidget = SweepWidget;
  10064. const defaultWhiteList = {
  10065. discord: {
  10066. servers: []
  10067. },
  10068. instagram: {
  10069. users: []
  10070. },
  10071. twitch: {
  10072. channels: []
  10073. },
  10074. twitter: {
  10075. users: [],
  10076. retweets: [],
  10077. likes: []
  10078. },
  10079. vk: {
  10080. names: []
  10081. },
  10082. youtube: {
  10083. channels: [],
  10084. likes: []
  10085. },
  10086. reddit: {
  10087. reddits: []
  10088. },
  10089. steam: {
  10090. groups: [],
  10091. officialGroups: [],
  10092. wishlists: [],
  10093. follows: [],
  10094. forums: [],
  10095. workshops: [],
  10096. curators: [],
  10097. workshopVotes: [],
  10098. curatorLikes: [],
  10099. announcements: [],
  10100. licenses: [],
  10101. playtests: []
  10102. }
  10103. };
  10104. const link2id = async function(type) {
  10105. 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;
  10106. try {
  10107. const link = $('#socialLink').val();
  10108. let id = '';
  10109. switch (type) {
  10110. case 'discord.servers':
  10111. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10112. break;
  10113.  
  10114. case 'instagram.users':
  10115. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10116. break;
  10117.  
  10118. case 'twitch.channels':
  10119. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10120. break;
  10121.  
  10122. case 'twitter.users':
  10123. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10124. break;
  10125.  
  10126. case 'twitter.retweets':
  10127. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10128. break;
  10129.  
  10130. case 'vk.names':
  10131. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10132. break;
  10133.  
  10134. case 'youtube.channels':
  10135. 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) || '';
  10136. break;
  10137.  
  10138. case 'youtube.likes':
  10139. 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) || '';
  10140. break;
  10141.  
  10142. case 'reddit.reddits':
  10143. 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]) || '';
  10144. break;
  10145.  
  10146. case 'steam.groups':
  10147. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10148. break;
  10149.  
  10150. case 'steam.wishlists':
  10151. case 'steam.follows':
  10152. case 'steam.forums':
  10153. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10154. break;
  10155.  
  10156. case 'steam.workshops':
  10157. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10158. break;
  10159.  
  10160. case 'steam.curators':
  10161. {
  10162. if (link.includes('curator')) {
  10163. var _link$match12;
  10164. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10165. } else {
  10166. var _link$match13;
  10167. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10168. if (!param || param.length !== 2) {
  10169. break;
  10170. }
  10171. const steam = new social_Steam();
  10172. if (await steam.init()) {
  10173. id = await steam.getCuratorId(param[0], param[1]) || '';
  10174. }
  10175. }
  10176. }
  10177. break;
  10178. }
  10179. return id;
  10180. } catch (error) {
  10181. throwError(error, 'link2id');
  10182. return i18n('getFailed', 'id');
  10183. }
  10184. };
  10185. const disabledType = {
  10186. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10187. twitter: [ 'likes' ]
  10188. };
  10189. const assignWhiteList = whiteList => {
  10190. try {
  10191. const newWhiteList = {};
  10192. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10193. newWhiteList[key] = {
  10194. ...value,
  10195. ...whiteList[key]
  10196. };
  10197. }
  10198. return newWhiteList;
  10199. } catch (error) {
  10200. throwError(error, 'assignWhiteList');
  10201. return defaultWhiteList;
  10202. }
  10203. };
  10204. const whiteListOptions = function(showType) {
  10205. try {
  10206. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10207. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10208. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10209. for (const [ social, types ] of Object.entries(whiteList)) {
  10210. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10211. var _disabledType$social;
  10212. 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>`;
  10213. }).join('');
  10214. }
  10215. whiteListOptionsForm += '</tbody></table></form>';
  10216. if (showType === 'swal') {
  10217. external_Swal_default().fire({
  10218. title: i18n('whiteListOptions'),
  10219. html: whiteListOptionsForm,
  10220. showConfirmButton: false,
  10221. showCloseButton: true
  10222. });
  10223. } else {
  10224. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10225. }
  10226. $('.editWhiteList').on('click', function() {
  10227. var _whiteList$social;
  10228. const value = $(this).attr('data-value');
  10229. if (!value) {
  10230. return;
  10231. }
  10232. const [ social, type ] = value.split('.');
  10233. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10234. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10235. return;
  10236. }
  10237. external_Swal_default().fire({
  10238. title: i18n('changeWhiteListOption', value),
  10239. input: 'textarea',
  10240. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10241. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10242. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10243. inputValue: whiteList[social][type].join('\n'),
  10244. showConfirmButton: true,
  10245. confirmButtonText: i18n('save'),
  10246. showCancelButton: true,
  10247. cancelButtonText: i18n('close'),
  10248. showDenyButton: true,
  10249. denyButtonText: i18n('return')
  10250. }).then(_ref => {
  10251. let {
  10252. isDenied,
  10253. isConfirmed,
  10254. value
  10255. } = _ref;
  10256. if (isDenied) {
  10257. if (showType === 'swal') {
  10258. whiteListOptions(showType);
  10259. }
  10260. return;
  10261. } else if (isConfirmed) {
  10262. whiteList[social][type] = value.split('\n');
  10263. GM_setValue('whiteList', whiteList);
  10264. external_Swal_default().fire({
  10265. title: i18n('changeWhiteListSuccess'),
  10266. icon: 'success'
  10267. });
  10268. }
  10269. });
  10270. $('#link2id').on('click', async function() {
  10271. const type = $(this).attr('data-type');
  10272. $('#socialLink').val(await link2id(type));
  10273. });
  10274. });
  10275. } catch (error) {
  10276. throwError(error, 'whiteListOptions');
  10277. }
  10278. };
  10279. const whiteList = whiteListOptions;
  10280. const setGistData = async (token, gistId, fileName, content) => {
  10281. try {
  10282. const logStatus = scripts_echoLog({
  10283. text: i18n('settingData')
  10284. });
  10285. const contentData = JSON.stringify({
  10286. files: {
  10287. [fileName]: {
  10288. content: JSON.stringify(content)
  10289. }
  10290. }
  10291. });
  10292. const {
  10293. result,
  10294. statusText,
  10295. status,
  10296. data
  10297. } = await tools_httpRequest({
  10298. url: `https://api.github.com/gists/${gistId}`,
  10299. headers: {
  10300. Accept: 'application/vnd.github.v3+json',
  10301. Authorization: `token ${token}`
  10302. },
  10303. data: contentData,
  10304. responseType: 'json',
  10305. method: 'POST',
  10306. timeout: 3e4
  10307. });
  10308. if (result === 'Success') {
  10309. var _data$response$files, _data$response$files$;
  10310. 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)) {
  10311. logStatus.success();
  10312. return true;
  10313. }
  10314. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10315. return false;
  10316. }
  10317. logStatus.error(`${result}:${statusText}(${status})`);
  10318. return false;
  10319. } catch (error) {
  10320. throwError(error, 'setGistData');
  10321. return false;
  10322. }
  10323. };
  10324. const getGistData = async function(token, gistId, fileName) {
  10325. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10326. try {
  10327. const logStatus = scripts_echoLog({
  10328. text: i18n('gettingData')
  10329. });
  10330. const {
  10331. result,
  10332. statusText,
  10333. status,
  10334. data
  10335. } = await tools_httpRequest({
  10336. url: `https://api.github.com/gists/${gistId}`,
  10337. headers: {
  10338. Accept: 'application/vnd.github.v3+json',
  10339. Authorization: `token ${token}`
  10340. },
  10341. responseType: 'json',
  10342. method: 'GET',
  10343. timeout: 3e4
  10344. });
  10345. if (result === 'Success') {
  10346. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10347. var _data$response, _data$response$files2, _data$response$files3;
  10348. 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;
  10349. let formatedContent;
  10350. if (!content) {
  10351. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10352. return false;
  10353. }
  10354. if (test) {
  10355. logStatus.success();
  10356. return true;
  10357. }
  10358. try {
  10359. formatedContent = JSON.parse(content);
  10360. } catch (error) {
  10361. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10362. return false;
  10363. }
  10364. logStatus.success();
  10365. return formatedContent;
  10366. }
  10367. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10368. return false;
  10369. }
  10370. logStatus.error(`${result}:${statusText}(${status})`);
  10371. return false;
  10372. } catch (error) {
  10373. throwError(error, 'getGistData');
  10374. return false;
  10375. }
  10376. };
  10377. const syncOptions = () => {
  10378. try {
  10379. const {
  10380. TOKEN,
  10381. GIST_ID,
  10382. FILE_NAME,
  10383. SYNC_HISTORY
  10384. } = GM_getValue('gistOptions') || {
  10385. TOKEN: '',
  10386. GIST_ID: '',
  10387. FILE_NAME: '',
  10388. SYNC_HISTORY: true
  10389. };
  10390. external_Swal_default().fire({
  10391. title: i18n('gistOptions'),
  10392. 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;">
  10393. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10394. ${i18n('downloadFromGist')}</button></p>`,
  10395. focusConfirm: false,
  10396. showLoaderOnConfirm: true,
  10397. 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>`,
  10398. preConfirm: async () => {
  10399. const token = $('#github-token').val();
  10400. const gistId = $('#gist-id').val();
  10401. const fileName = $('#file-name').val();
  10402. const syncHistory = $('#sync-history').prop('checked');
  10403. GM_setValue('gistOptions', {
  10404. TOKEN: token,
  10405. GIST_ID: gistId,
  10406. FILE_NAME: fileName,
  10407. SYNC_HISTORY: syncHistory
  10408. });
  10409. return await getGistData(token, gistId, fileName, true);
  10410. },
  10411. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10412. confirmButtonText: i18n('saveAndTest'),
  10413. showCancelButton: true,
  10414. cancelButtonText: i18n('close')
  10415. }).then(_ref => {
  10416. let {
  10417. value
  10418. } = _ref;
  10419. if (value) {
  10420. external_Swal_default().fire({
  10421. icon: 'success',
  10422. title: i18n('testSuccess')
  10423. }).then(syncOptions);
  10424. } else if (value !== undefined) {
  10425. external_Swal_default().fire({
  10426. icon: 'error',
  10427. title: i18n('testFailed')
  10428. }).then(syncOptions);
  10429. }
  10430. });
  10431. $('#upload-data').on('click', async () => {
  10432. const {
  10433. TOKEN,
  10434. GIST_ID,
  10435. FILE_NAME
  10436. } = GM_getValue('gistOptions') || {};
  10437. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10438. return external_Swal_default().fire({
  10439. icon: 'error',
  10440. title: i18n('saveAndTestNotice')
  10441. }).then(syncOptions);
  10442. }
  10443. external_Swal_default().fire({
  10444. icon: 'info',
  10445. title: i18n('processingData')
  10446. });
  10447. const data = {};
  10448. const names = GM_listValues();
  10449. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10450. for (const name of names) {
  10451. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10452. continue;
  10453. }
  10454. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10455. continue;
  10456. }
  10457. data[name] = GM_getValue(name);
  10458. }
  10459. external_Swal_default().update({
  10460. icon: 'info',
  10461. title: i18n('updatingData')
  10462. });
  10463. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10464. external_Swal_default().fire({
  10465. icon: 'success',
  10466. title: i18n('syncDataSuccess')
  10467. });
  10468. } else {
  10469. external_Swal_default().fire({
  10470. icon: 'error',
  10471. title: i18n('syncDataFailed')
  10472. });
  10473. }
  10474. });
  10475. $('#download-data').on('click', async () => {
  10476. const {
  10477. TOKEN,
  10478. GIST_ID,
  10479. FILE_NAME
  10480. } = GM_getValue('gistOptions') || {};
  10481. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10482. return external_Swal_default().fire({
  10483. icon: 'error',
  10484. title: i18n('saveAndTestNotice')
  10485. }).then(syncOptions);
  10486. }
  10487. external_Swal_default().fire({
  10488. icon: 'info',
  10489. title: i18n('downloadingData')
  10490. });
  10491. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10492. if (!data) {
  10493. return external_Swal_default().fire({
  10494. icon: 'error',
  10495. title: i18n('checkedNoData')
  10496. }).then(syncOptions);
  10497. }
  10498. external_Swal_default().update({
  10499. icon: 'info',
  10500. title: i18n('savingData')
  10501. });
  10502. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10503. for (const [ name, value ] of Object.entries(data)) {
  10504. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10505. continue;
  10506. }
  10507. GM_setValue(name, value);
  10508. }
  10509. external_Swal_default().fire({
  10510. icon: 'success',
  10511. title: i18n('syncDataSuccess')
  10512. });
  10513. });
  10514. } catch (error) {
  10515. throwError(error, 'syncOptions');
  10516. }
  10517. };
  10518. const dataSync = syncOptions;
  10519. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10520. Setting_checkPrivateRedeclaration(obj, privateSet);
  10521. privateSet.add(obj);
  10522. }
  10523. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10524. if (privateCollection.has(obj)) {
  10525. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10526. }
  10527. }
  10528. function Setting_defineProperty(obj, key, value) {
  10529. if (key in obj) {
  10530. Object.defineProperty(obj, key, {
  10531. value: value,
  10532. enumerable: true,
  10533. configurable: true,
  10534. writable: true
  10535. });
  10536. } else {
  10537. obj[key] = value;
  10538. }
  10539. return obj;
  10540. }
  10541. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10542. if (!privateSet.has(receiver)) {
  10543. throw new TypeError('attempted to get private field on non-instance');
  10544. }
  10545. return fn;
  10546. }
  10547. var Setting_getId = new WeakSet();
  10548. var _environment = new WeakSet();
  10549. class Setting {
  10550. constructor() {
  10551. Setting_classPrivateMethodInitSpec(this, _environment);
  10552. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10553. Setting_defineProperty(this, 'name', 'Setting');
  10554. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10555. Setting_defineProperty(this, 'syncData', dataSync);
  10556. }
  10557. tasksHistory() {
  10558. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10559. }
  10560. static test() {
  10561. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10562. }
  10563. before() {
  10564. $('body').html('').addClass('auto-task-options');
  10565. }
  10566. after() {
  10567. try {
  10568. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10569. changeGlobalOptions('page');
  10570. whiteList('page');
  10571. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10572. $('#getTwitterUserId').on('click', () => {
  10573. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10574. });
  10575. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10576. $('#getYoutubeChannelId').on('click', () => {
  10577. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10578. });
  10579. $('input[name^="position"]').on('input', function() {
  10580. const type = $(this).attr('name').replace('position.', '');
  10581. const xLabel = 'rightleft';
  10582. const yLabel = 'topbottpm';
  10583. switch (type) {
  10584. case 'buttonSideX':
  10585. case 'buttonSideY':
  10586. case 'buttonDistance':
  10587. {
  10588. const distance = $('input[name="position.buttonDistance"]').val();
  10589. const sideX = $('input[name="position.buttonSideX"]').val();
  10590. const sideY = $('input[name="position.buttonSideY"]').val();
  10591. if (![ 'right', 'left' ].includes(sideX)) {
  10592. break;
  10593. }
  10594. if (![ 'top', 'bottom' ].includes(sideY)) {
  10595. break;
  10596. }
  10597. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10598. break;
  10599. }
  10600. const distanceArr = distance.split(',');
  10601. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10602. break;
  10603. }
  10604.  
  10605. case 'showButtonSideX':
  10606. case 'showButtonSideY':
  10607. case 'showButtonDistance':
  10608. {
  10609. const distance = $('input[name="position.showButtonDistance"]').val();
  10610. const sideX = $('input[name="position.showButtonSideX"]').val();
  10611. const sideY = $('input[name="position.showButtonSideY"]').val();
  10612. if (![ 'right', 'left' ].includes(sideX)) {
  10613. break;
  10614. }
  10615. if (![ 'top', 'bottom' ].includes(sideY)) {
  10616. break;
  10617. }
  10618. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10619. break;
  10620. }
  10621. const distanceArr = distance.split(',');
  10622. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10623. break;
  10624. }
  10625.  
  10626. case 'logSideX':
  10627. case 'logSideY':
  10628. case 'logDistance':
  10629. {
  10630. const distance = $('input[name="position.logDistance"]').val();
  10631. const sideX = $('input[name="position.logSideX"]').val();
  10632. const sideY = $('input[name="position.logSideY"]').val();
  10633. if (![ 'right', 'left' ].includes(sideX)) {
  10634. break;
  10635. }
  10636. if (![ 'top', 'bottom' ].includes(sideY)) {
  10637. break;
  10638. }
  10639. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10640. break;
  10641. }
  10642. const distanceArr = distance.split(',');
  10643. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10644. break;
  10645. }
  10646.  
  10647. default:
  10648. break;
  10649. }
  10650. });
  10651. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10652. let functionKey = '';
  10653. if (event.altKey) {
  10654. functionKey += 'alt + ';
  10655. } else if (event.ctrlKey) {
  10656. functionKey += 'ctrl + ';
  10657. } else if (event.shiftKey) {
  10658. functionKey += 'shift + ';
  10659. }
  10660. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10661. });
  10662. } catch (error) {
  10663. throwError(error, 'Setting.after');
  10664. }
  10665. }
  10666. saveGlobalOptions() {
  10667. saveData();
  10668. }
  10669. }
  10670. function Setting_getId2(social) {
  10671. try {
  10672. external_Swal_default().fire({
  10673. title: i18n('getId', i18n(social)),
  10674. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10675. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10676. showCancelButton: true,
  10677. cancelButtonText: i18n('close'),
  10678. showConfirmButton: false
  10679. });
  10680. $('#link2id').on('click', async function() {
  10681. const link = $('#socialLink').val();
  10682. if (!link) {
  10683. return;
  10684. }
  10685. const type = $(this).attr('data-type');
  10686. if (type === 'twitterUser') {
  10687. var _link$match;
  10688. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10689. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10690. } else if (type === 'youtubeChannel') {
  10691. var _link$match2, _await$getInfo, _await$getInfo$params;
  10692. 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;
  10693. $('#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) || '');
  10694. }
  10695. });
  10696. } catch (error) {
  10697. throwError(error, 'Setting.getId');
  10698. }
  10699. }
  10700. function _environment2() {
  10701. try {
  10702. const userAgent = (0, javascript_utils_umd_min.ua)();
  10703. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10704. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10705. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10706. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10707. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10708. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10709. </tbody></table></form>`;
  10710. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10711. } catch (error) {
  10712. throwError(error, 'Setting.environment');
  10713. }
  10714. }
  10715. const website_Setting = Setting;
  10716. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10717. History_checkPrivateRedeclaration(obj, privateSet);
  10718. privateSet.add(obj);
  10719. }
  10720. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10721. if (privateCollection.has(obj)) {
  10722. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10723. }
  10724. }
  10725. function History_defineProperty(obj, key, value) {
  10726. if (key in obj) {
  10727. Object.defineProperty(obj, key, {
  10728. value: value,
  10729. enumerable: true,
  10730. configurable: true,
  10731. writable: true
  10732. });
  10733. } else {
  10734. obj[key] = value;
  10735. }
  10736. return obj;
  10737. }
  10738. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10739. if (!privateSet.has(receiver)) {
  10740. throw new TypeError('attempted to get private field on non-instance');
  10741. }
  10742. return fn;
  10743. }
  10744. var _addItem = new WeakSet();
  10745. class History extends website_Keylol {
  10746. constructor() {
  10747. super(...arguments);
  10748. History_classPrivateMethodInitSpec(this, _addItem);
  10749. History_defineProperty(this, 'name', 'History');
  10750. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10751. }
  10752. static test() {
  10753. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10754. }
  10755. before() {
  10756. try {
  10757. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10758. const data = GM_listValues() || [];
  10759. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10760. for (const item of tasksHistory) {
  10761. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10762. }
  10763. } catch (error) {
  10764. throwError(error, 'History.before');
  10765. }
  10766. }
  10767. clearHistory() {
  10768. try {
  10769. const data = GM_listValues() || [];
  10770. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10771. for (const item of tasksHistory) {
  10772. GM_deleteValue(item);
  10773. }
  10774. external_Swal_default().fire({
  10775. title: i18n('clearHistoryFinished'),
  10776. icon: 'success'
  10777. });
  10778. } catch (error) {
  10779. throwError(error, 'History.after');
  10780. }
  10781. }
  10782. }
  10783. function _addItem2(item) {
  10784. try {
  10785. const tasksData = GM_getValue(item);
  10786. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10787. return;
  10788. }
  10789. let html = '';
  10790. let title = '';
  10791. let link = '';
  10792. const [ website, id ] = item.split('-');
  10793. switch (website) {
  10794. case 'fawTasks':
  10795. title = `Freeanywhere[${id}]`;
  10796. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10797. break;
  10798.  
  10799. case 'gasTasks':
  10800. title = `Giveawaysu[${id}]`;
  10801. link = `https://giveaway.su/giveaway/view/${id}`;
  10802. break;
  10803.  
  10804. case 'gcTasks':
  10805. title = `GiveeClub[${id}]`;
  10806. link = `https://givee.club/event/${id}`;
  10807. break;
  10808.  
  10809. case 'gkTasks':
  10810. title = `Givekey[${id}]`;
  10811. link = `https://givekey.ru/giveaway/${id}`;
  10812. break;
  10813.  
  10814. case 'gleamTasks':
  10815. title = `Gleam[${id}]`;
  10816. link = `https://gleam.io${id}`;
  10817. break;
  10818.  
  10819. case 'khTasks':
  10820. title = `keyhub[${id}]`;
  10821. link = `https://key-hub.eu/giveaway/${id}`;
  10822. break;
  10823.  
  10824. case 'prysTasks':
  10825. title = `Prys[${id}]`;
  10826. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10827. break;
  10828.  
  10829. default:
  10830. return;
  10831. }
  10832. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10833. for (const [ type, tasks ] of Object.entries(types)) {
  10834. for (const task of tasks) {
  10835. 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>`;
  10836. }
  10837. }
  10838. }
  10839. $('.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>`);
  10840. $('span.delete-task').on('click', function() {
  10841. const itemName = $(this).attr('data-name');
  10842. if (itemName) {
  10843. GM_deleteValue(itemName);
  10844. $(`div.card[data-name="${itemName}"]`).remove();
  10845. external_Swal_default().fire({
  10846. title: i18n('clearTaskFinished'),
  10847. text: itemName,
  10848. icon: 'success'
  10849. });
  10850. } else {
  10851. external_Swal_default().fire({
  10852. title: i18n('clearTaskFailed'),
  10853. icon: 'error'
  10854. });
  10855. }
  10856. });
  10857. } catch (error) {
  10858. throwError(error, 'History.addItem');
  10859. }
  10860. }
  10861. const website_History = History;
  10862. 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 ];
  10863. const websiteOptions = function(website, options) {
  10864. try {
  10865. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10866. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10867. for (const [ option, value ] of Object.entries(options)) {
  10868. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10869. }
  10870. websiteOptionsForm += '</tbody></table></form>';
  10871. external_Swal_default().fire({
  10872. title: i18n('websiteOptions'),
  10873. html: websiteOptionsForm,
  10874. showConfirmButton: true,
  10875. confirmButtonText: i18n('save'),
  10876. showCancelButton: true,
  10877. cancelButtonText: i18n('close')
  10878. }).then(_ref => {
  10879. let {
  10880. isConfirmed
  10881. } = _ref;
  10882. if (isConfirmed) {
  10883. $('#websiteOptionsForm').serializeArray().map(value => {
  10884. options[value.name] = value.value;
  10885. return value;
  10886. });
  10887. GM_setValue(`${website}Options`, options);
  10888. external_Swal_default().fire({
  10889. title: i18n('changeWebsiteOptionsSuccess'),
  10890. icon: 'success'
  10891. });
  10892. }
  10893. });
  10894. } catch (error) {
  10895. throwError(error, 'websiteOptions');
  10896. }
  10897. };
  10898. const options = websiteOptions;
  10899. const external_keyboardJS_namespaceObject = keyboardJS;
  10900. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10901. const checkUpdate = async (updateLink, auto) => {
  10902. try {
  10903. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10904. const {
  10905. result,
  10906. statusText,
  10907. status,
  10908. data
  10909. } = await tools_httpRequest({
  10910. url: checkUrl,
  10911. responseType: 'json',
  10912. method: 'GET',
  10913. timeout: 3e4
  10914. });
  10915. if (result === 'Success') {
  10916. var _data$response;
  10917. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10918. return data.response;
  10919. }
  10920. if (!auto) {
  10921. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10922. }
  10923. return false;
  10924. }
  10925. if (!auto) {
  10926. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10927. }
  10928. return false;
  10929. } catch (error) {
  10930. throwError(error, 'checkUpdate');
  10931. return false;
  10932. }
  10933. };
  10934. const hasNewVersion = (currentVersion, remoteVersion) => {
  10935. try {
  10936. const [ currentRealVersion ] = currentVersion.split('-');
  10937. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  10938. if (isPreview && !globalOptions.other.receivePreview) {
  10939. return false;
  10940. }
  10941. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10942. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10943. if (remoteVersion1 > currentVersion1) {
  10944. return true;
  10945. }
  10946. if (remoteVersion1 < currentVersion1) {
  10947. return false;
  10948. }
  10949. if (remoteVersion2 > currentVersion2) {
  10950. return true;
  10951. }
  10952. if (remoteVersion2 < currentVersion2) {
  10953. return false;
  10954. }
  10955. if (remoteVersion3 > currentVersion3) {
  10956. return true;
  10957. }
  10958. return false;
  10959. } catch (error) {
  10960. throwError(error, 'compareVersion');
  10961. return false;
  10962. }
  10963. };
  10964. const updateChecker = async () => {
  10965. try {
  10966. const currentVersion = GM_info.script.version;
  10967. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10968. const updateLinks = {
  10969. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10970. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10971. standby: 'https://auto-task-v4.hclonely.com/'
  10972. };
  10973. let version;
  10974. let updateLink = '';
  10975. let packageData;
  10976. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10977. updateLink = updateLinks[updateSource];
  10978. packageData = await checkUpdate(updateLink, false);
  10979. } else {
  10980. updateLink = updateLinks.github;
  10981. packageData = await checkUpdate(updateLink, true);
  10982. if (!packageData) {
  10983. updateLink = updateLinks.jsdelivr;
  10984. packageData = await checkUpdate(updateLink, true);
  10985. if (!packageData) {
  10986. updateLink = updateLinks.standby;
  10987. packageData = await checkUpdate(updateLink, true);
  10988. }
  10989. }
  10990. }
  10991. if (packageData) {
  10992. version = packageData.version || currentVersion;
  10993. } else {
  10994. version = currentVersion;
  10995. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10996. }
  10997. if (packageData && hasNewVersion(currentVersion, version)) {
  10998. var _packageData$change;
  10999. scripts_echoLog({
  11000. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  11001. });
  11002. scripts_echoLog({
  11003. 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>`
  11004. });
  11005. }
  11006. } catch (error) {
  11007. throwError(error, 'updateChecker');
  11008. }
  11009. };
  11010. const scripts_updateChecker = updateChecker;
  11011. var _globalOptions$other, _globalOptions$other2;
  11012. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  11013. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  11014. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  11015. const loadScript = async () => {
  11016. var _website, _website2, _website3, _website4, _website5, _website6;
  11017. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  11018. const authToken = external_Cookies_namespaceObject.get('auth-token');
  11019. const isLogin = !!external_Cookies_namespaceObject.get('login');
  11020. if (isLogin) {
  11021. var _commonOptions, _commonOptions$header;
  11022. GM_setValue('twitchAuth', {
  11023. authToken: authToken,
  11024. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  11025. });
  11026. window.close();
  11027. external_Swal_default().fire('', i18n('closePageNotice'));
  11028. } else {
  11029. external_Swal_default().fire('', i18n('needLogin'));
  11030. }
  11031. return;
  11032. }
  11033. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  11034. const ct0 = external_Cookies_namespaceObject.get('ct0');
  11035. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  11036. if (isLogin && ct0) {
  11037. GM_setValue('twitterAuth', {
  11038. ct0: ct0
  11039. });
  11040. window.close();
  11041. external_Swal_default().fire('', i18n('closePageNotice'));
  11042. } else {
  11043. external_Swal_default().fire('', i18n('needLogin'));
  11044. }
  11045. return;
  11046. }
  11047. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  11048. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  11049. if (PAPISID) {
  11050. GM_setValue('youtubeAuth', {
  11051. PAPISID: PAPISID
  11052. });
  11053. window.close();
  11054. external_Swal_default().fire('', i18n('closePageNotice'));
  11055. } else {
  11056. external_Swal_default().fire('', i18n('needLogin'));
  11057. }
  11058. return;
  11059. }
  11060. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11061. const betaButton = $('#redesign-beta-optin-btn');
  11062. if (betaButton.length > 0) {
  11063. GM_setValue('redditAuth', '#auth');
  11064. return betaButton[0].click();
  11065. }
  11066. GM_setValue('redditAuth', null);
  11067. window.close();
  11068. external_Swal_default().fire('', i18n('closePageNotice'));
  11069. return;
  11070. }
  11071. let website;
  11072. for (const Website of Websites) {
  11073. if (Website.test()) {
  11074. website = new Website();
  11075. break;
  11076. }
  11077. }
  11078. if (!website) {
  11079. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11080. return;
  11081. }
  11082. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11083. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11084. }
  11085. $('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>`);
  11086. $('div.show-button-div').on('click', () => {
  11087. $('#auto-task-buttons').show();
  11088. $('div.show-button-div').hide();
  11089. });
  11090. const toggleLog = () => {
  11091. const $this = $('#toggle-log');
  11092. const status = $this.attr('data-status');
  11093. if (status === 'show') {
  11094. $('#auto-task-info').hide();
  11095. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11096. } else {
  11097. $('#auto-task-info').show();
  11098. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11099. }
  11100. };
  11101. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11102. if (website.doTask) {
  11103. website.doTask();
  11104. }
  11105. });
  11106. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11107. if (website.undoTask) {
  11108. website.doTask();
  11109. }
  11110. });
  11111. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11112. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11113. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11114. }
  11115. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11116. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11117. for (const button of website.buttons) {
  11118. if (website[button]) {
  11119. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11120. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11121. website[button]();
  11122. });
  11123. $('#auto-task-buttons').append(btnElement);
  11124. }
  11125. }
  11126. }
  11127. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11128. ${i18n('hideButton')}</a></p>`);
  11129. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11130. $('#auto-task-buttons').hide();
  11131. $('div.show-button-div').show();
  11132. });
  11133. 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'}">
  11134. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11135. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11136. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11137. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11138. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11139. options(website.name, website.options);
  11140. });
  11141. }
  11142. if (website.name !== 'Setting') {
  11143. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11144. changeGlobalOptions('swal');
  11145. });
  11146. GM_registerMenuCommand(i18n('settingPage'), () => {
  11147. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11148. });
  11149. }
  11150. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11151. if (!GM_getValue('notice')) {
  11152. var _echoLog$font;
  11153. external_Swal_default().fire({
  11154. title: i18n('swalNotice'),
  11155. icon: 'warning'
  11156. }).then(() => {
  11157. window.open(i18n('noticeLink'), '_blank');
  11158. GM_setValue('notice', new Date().getTime());
  11159. });
  11160. (_echoLog$font = scripts_echoLog({
  11161. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11162. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11163. GM_setValue('notice', new Date().getTime());
  11164. });
  11165. }
  11166. scripts_updateChecker();
  11167. };
  11168. if (window.location.hostname === 'discord.com') {
  11169. const LocalStorage = window.localStorage;
  11170. if (window.location.hash === '#auth') {
  11171. var _LocalStorage$getItem;
  11172. window.localStorage.removeItem = () => true;
  11173. 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, '');
  11174. if (discordAuth && discordAuth.length > 0) {
  11175. GM_setValue('discordAuth', {
  11176. auth: discordAuth
  11177. });
  11178. window.close();
  11179. external_Swal_default().fire('', i18n('closePageNotice'));
  11180. } else {
  11181. external_Swal_default().fire({
  11182. text: i18n('getDiscordAuthFailed'),
  11183. icon: 'error'
  11184. });
  11185. }
  11186. } else {
  11187. var _LocalStorage$getItem2;
  11188. 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, '');
  11189. if (discordAuth && discordAuth.length > 0) {
  11190. GM_setValue('discordAuth', {
  11191. auth: discordAuth
  11192. });
  11193. }
  11194. }
  11195. } else if (window.location.hostname === 'opquests.com') {
  11196. loadScript();
  11197. } else {
  11198. $(loadScript);
  11199. }
  11200. }();
  11201. })();