auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.11
  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. discordImportantNotice: '重要提醒!!!',
  1362. discordImportantNoticeText: '由于Discord网站后台更新,目前使用此脚本加组后可能会导致Discord帐号被强制退出,且需要两步验证才能正常登录,请谨慎使用!!!',
  1363. continue: '继续',
  1364. skipDiscordTask: '跳过Discord任务',
  1365. continueAndDontRemindAgain: '继续且不再提醒',
  1366. users: '用户',
  1367. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1368. insBanned: '您的Instagram账户已被封禁',
  1369. verifyingInsAuth: '正在验证Instagram凭证...',
  1370. gettingInsUserId: '正在获取Instagram用户Id',
  1371. followingIns: '正在关注Instagram用户',
  1372. unfollowingIns: '正在取关Instagram用户',
  1373. reddits: '社区/用户',
  1374. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1375. changingRedditVersion: '正在切换Reddit为新版页面...',
  1376. joiningReddit: '正在加入Reddit社区',
  1377. leavingReddit: '正在退出Reddit社区',
  1378. followingRedditUser: '正在关注Reddit用户',
  1379. unfollowingRedditUser: '正在取关Reddit用户',
  1380. channels: '频道',
  1381. followingTwitchChannel: '正在关注Twitch频道',
  1382. unfollowingTwitchChannel: '正在取关Twitch频道',
  1383. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1384. twitterUser: '推特用户',
  1385. retweets: '转推',
  1386. gettingTwitterUserId: '正在获取推特用户Id',
  1387. followingTwitterUser: '正在关注推特用户',
  1388. unfollowingTwitterUser: '正在取关推特用户',
  1389. retweetting: '正在转推',
  1390. unretweetting: '正在撤销转推',
  1391. names: '组/社区/动态',
  1392. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1393. gettingVkId: '正在获取Vk任务Id',
  1394. joiningVkGroup: '正在加入Vk组',
  1395. leavingVkGroup: '正在退出Vk组',
  1396. joiningVkPublic: '正在加入Vk社区',
  1397. leavingVkPublic: '正在退出Vk社区',
  1398. sendingVkWall: '正在转发Vk动态',
  1399. deletingVkWall: '正在撤销转发Vk动态',
  1400. youtubeChannel: 'YouTube频道',
  1401. likes: '点赞',
  1402. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1403. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1404. gettingYtbToken: '正在获取YouTube Token...',
  1405. followingYtbChannel: '正在订阅YouTube频道',
  1406. unfollowingYtbChannel: '正在退订YouTube频道',
  1407. likingYtbVideo: '正在点赞YouTube视频',
  1408. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1409. giveKeyNoticeBefore: '每次验证间隔15s',
  1410. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1411. noPoints: '点数不够,跳过抽奖',
  1412. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1413. joiningLottery: '正在加入抽奖',
  1414. doingGleamTask: '正在做Gleam任务...',
  1415. gettingGleamLink: '正在获取Gleam任务链接...',
  1416. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1417. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1418. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1419. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1420. };
  1421. const zh_CN = data;
  1422. const en_US_data = {
  1423. website: 'Website',
  1424. type: 'Type',
  1425. edit: 'Edit',
  1426. whiteList: 'Whitelist',
  1427. skipTask: 'Skip undo task',
  1428. whiteListOptions: 'Whitelist options',
  1429. changeWhiteListOption: 'Whitelist option(%0)',
  1430. whiteListNotFound: 'Cannot find this whitelist: %0',
  1431. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1432. changeWebsiteOptions: 'Website options',
  1433. changeGlobalOptions: 'Global options',
  1434. ok: 'OK',
  1435. save: 'Save',
  1436. close: 'Close',
  1437. return: 'Return',
  1438. option: 'Option',
  1439. value: 'Value',
  1440. websiteOptions: 'Current website settings',
  1441. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1442. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1443. needLogin: 'Please log in first!',
  1444. getTasksInfo: 'Obtaining and processing task information...',
  1445. gettingKey: 'Getting Key...',
  1446. verifyingTask: 'Verifying task',
  1447. notice: 'Automatic task script notice',
  1448. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1449. giveawayEnded: 'This event has ended, do you want to close it?',
  1450. 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?',
  1451. confirm: 'Confirm',
  1452. cancel: 'Cancel',
  1453. unKnown: 'Unknown',
  1454. unKnownTaskType: 'Unrecognized task',
  1455. doing: 'Doing a task',
  1456. allTasksComplete: 'All tasks have been completed!',
  1457. getTaskIdFailed: 'Failed to obtain task Id!',
  1458. initSuccess: '%0 was initialized successfully!',
  1459. initFailed: '%0 initialization failed!',
  1460. errorLink: 'Link error: %0',
  1461. needInit: 'Please initialize first',
  1462. verifyingAuth: 'Verifying %0 token...',
  1463. updatingAuth: 'Update %0 token...',
  1464. initing: 'Initializing...',
  1465. getFailed: 'Failed to get %0!',
  1466. checkLoginFailed: 'Failed to detect login status!',
  1467. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1468. userId: 'User Id',
  1469. joiningGiveaway: 'Joining giveaway',
  1470. needJoinGiveaway: 'Need to join the giveaway first',
  1471. cannotUndo: 'This website does not support canceling tasks',
  1472. verifyAuth: 'Verifying %0 token...',
  1473. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1474. errorReport: 'A script error is detected, do you want to report the BUG?',
  1475. visitingLink: 'Visiting link: ',
  1476. doTask: 'DoTask',
  1477. undoTask: 'UndoTask',
  1478. verifyTask: 'Verify',
  1479. getKey: 'GetKey',
  1480. selectAll: 'SelectAll',
  1481. selectNone: 'SelectNone',
  1482. invertSelect: 'InvertSelect',
  1483. doFreeTask: 'FreeTask',
  1484. doPointTask: 'PointTask',
  1485. skipTaskOption: 'Skip task has been configured in the settings',
  1486. other: 'Other',
  1487. globalOptions: 'Global Options',
  1488. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1489. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1490. 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.',
  1491. 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.',
  1492. 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.',
  1493. saveGlobalOptions: 'SaveSettings',
  1494. settingPage: 'Setting Page',
  1495. name: 'Name',
  1496. version: 'Version',
  1497. scriptManager: 'Script Manager',
  1498. script: 'Script',
  1499. environment: 'Environment',
  1500. os: 'OS',
  1501. browser: 'Browser',
  1502. getId: 'Get %0 id',
  1503. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1504. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1505. showButton: 'ShowButton',
  1506. hideButton: 'HideButton',
  1507. showLog: 'ShowLog',
  1508. hideLog: 'HideLog',
  1509. defaultShowButton: 'Default display button',
  1510. defaultShowLog: 'Display log by default',
  1511. debug: 'Output debug log, do not enable this option!',
  1512. receivePreview: 'Receive preview updates',
  1513. position: 'Component position',
  1514. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1515. 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',
  1516. 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',
  1517. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1518. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1519. 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',
  1520. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1521. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1522. 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',
  1523. hotKey: 'Shortcut key',
  1524. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1525. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1526. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1527. tasksHistory: 'TasksHistory',
  1528. clearHistory: 'Clear history',
  1529. clearHistoryFinished: 'The mission history has been cleared!',
  1530. deleteTask: 'Delete task',
  1531. lastChangeTime: 'Last Change Time',
  1532. clearTaskFinished: 'Delete the following tasks completed!',
  1533. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1534. syncData: 'DataSync',
  1535. settingData: 'Uploading data...',
  1536. gettingData: 'Getting data...',
  1537. help: 'Help',
  1538. fileName: 'Filename',
  1539. upload2gist: 'Sync to Gist',
  1540. downloadFromGist: 'Sync from Gist',
  1541. saveAndTest: 'Save configuration and test',
  1542. testSuccess: 'Test success!',
  1543. testFailed: 'Test failed!',
  1544. saveAndTestNotice: 'Please save the configuration and test first!',
  1545. processingData: 'Processing data...',
  1546. updatingData: 'Uploading data...',
  1547. syncDataSuccess: 'Synchronized data successfully!',
  1548. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1549. downloadingData: 'Downloading data...',
  1550. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1551. savingData: 'Saving data...',
  1552. syncHistory: 'Synchronize tasks history',
  1553. checkUpdateFailed: 'Check update failed',
  1554. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1555. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1556. gistOptions: 'Gist Settings',
  1557. 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!',
  1558. 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!',
  1559. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1560. toGithub: 'Feedback(Github)',
  1561. toKeylol: 'Feedback(Keylol)',
  1562. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1563. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1564. updateText: 'Updates in version %0:',
  1565. Active: 'Active',
  1566. Ended: 'Ended',
  1567. Banned: 'Banned',
  1568. Paused: 'Paused',
  1569. notStart: 'notStart',
  1570. noRemoteData: 'No data remotely',
  1571. errorRemoteDataFormat: 'Remote data has wrong format',
  1572. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1573. groups: 'Group',
  1574. officialGroups: 'Official Group',
  1575. wishlists: 'Wishlist',
  1576. follows: 'Follow Game',
  1577. forums: 'Forum',
  1578. workshops: 'Favorite Workshop',
  1579. curators: 'Curator',
  1580. workshopVotes: 'Voteup Workshop',
  1581. announcements: 'Announcement',
  1582. steamCommunity: 'Steam Community',
  1583. steamStore: 'Steam Store',
  1584. licenses: 'Add License',
  1585. playtests: 'Playtest Access',
  1586. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1587. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1588. joiningSteamGroup: 'Joining Steam Group',
  1589. leavingSteamGroup: 'Leaving Steam Group',
  1590. gettingSteamGroupId: 'Getting Steam Group Id',
  1591. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1592. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1593. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1594. subscribingForum: 'Subscribing the Steam Forum',
  1595. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1596. gettingForumId: 'Getting Steam Forum Id',
  1597. followingCurator: 'Following Steam Curator',
  1598. unfollowingCurator: 'Unfollowing Steam Curator',
  1599. gettingCuratorId: 'Getting Steam Curator Id',
  1600. addingToWishlist: 'Adding the game to the Steam wishlist',
  1601. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1602. followingGame: 'Following Steam games',
  1603. unfollowingGame: 'Unfollowing Steam games',
  1604. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1605. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1606. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1607. votingUpWorkshop: 'Liking Steam workshop items',
  1608. gettingAnnouncementParams: 'Getting Steam announcement information',
  1609. likingAnnouncement: 'Liking Steam announcement',
  1610. changingArea: 'Changing Steam area: %0...',
  1611. notNeededChangeArea: 'The current area does not need to be changed',
  1612. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1613. gettingAreaInfo: 'Getting Steam area information...',
  1614. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1615. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1616. gettingSubid: 'Getting subid',
  1617. addingFreeLicense: 'Adding free license',
  1618. missParams: 'Missing parameters',
  1619. gettingLicenses: 'Getting licenses...',
  1620. requestingPlayTestAccess: 'Requesting play test access',
  1621. 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.',
  1622. servers: 'Server',
  1623. joiningDiscordServer: 'Joining Discord Server',
  1624. leavingDiscordServer: 'Leaving Discord Server',
  1625. gettingDiscordGuild: 'Getting Discord server Id',
  1626. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1627. discordImportantNotice: 'Important Reminder! ! !',
  1628. discordImportantNoticeText: 'Due to the background update of the Discord website, currently using this script to join a group may cause the Discord account to be forcibly logged out, and two-step verification is required to log in normally, please use it with caution! ! !',
  1629. continue: 'Continue',
  1630. skipDiscordTask: 'Skip',
  1631. continueAndDontRemindAgain: 'Continue without Reminders',
  1632. users: 'User',
  1633. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1634. insBanned: 'Your Instagram account has been banned',
  1635. verifyingInsAuth: 'Verifying Instagram token...',
  1636. gettingInsUserId: 'Getting Instagram user Id',
  1637. followingIns: 'Following Instagram user',
  1638. unfollowingIns: 'Unfollowing Instagram user',
  1639. reddits: 'Reddit/User',
  1640. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1641. changingRedditVersion: 'Switching Reddit to a new version page...',
  1642. joiningReddit: 'Joining the Reddit',
  1643. leavingReddit: 'Leaving the Reddit',
  1644. followingRedditUser: 'Following Reddit User',
  1645. unfollowingRedditUser: 'Unfollowing Reddit User',
  1646. channels: 'Channel',
  1647. followingTwitchChannel: 'Following Twitch Channel',
  1648. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1649. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1650. twitterUser: 'Twitter User',
  1651. retweets: 'Retweet',
  1652. gettingTwitterUserId: 'Getting Twitter User Id',
  1653. followingTwitterUser: 'Following Twitter User',
  1654. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1655. retweetting: 'Retweetting',
  1656. unretweetting: 'Unretweetting',
  1657. names: 'Group/Public/Wall',
  1658. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1659. gettingVkId: 'Getting Vk task Id',
  1660. joiningVkGroup: 'Joining Vk Group',
  1661. leavingVkGroup: 'Leaving Vk Group',
  1662. joiningVkPublic: 'Joining Vk Public',
  1663. leavingVkPublic: 'Leaving Vk Public',
  1664. sendingVkWall: 'Sending Vk Wall',
  1665. deletingVkWall: 'Deleting Vk Wall',
  1666. youtubeChannel: 'YouTube Channel',
  1667. likes: 'Like',
  1668. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1669. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1670. gettingYtbToken: 'Getting YouTube Token...',
  1671. followingYtbChannel: 'Subscribing to YouTube channel',
  1672. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1673. likingYtbVideo: 'Liking YouTube video',
  1674. unlikingYtbVideo: 'Unliking YouTube video',
  1675. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1676. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1677. noPoints: 'Not enough points, skip the lottery',
  1678. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1679. joiningLottery: 'Joining the lottery',
  1680. doingGleamTask: 'Doing Gleam Task...',
  1681. gettingGleamLink: 'Getting Gleam task link...',
  1682. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1683. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1684. 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!',
  1685. 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...'
  1686. };
  1687. const en_US = en_US_data;
  1688. const languages = {
  1689. zh: zh_CN,
  1690. en: en_US
  1691. };
  1692. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1693. const I18n = function(key) {
  1694. var _languages$language;
  1695. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1696. argvs[_key - 1] = arguments[_key];
  1697. }
  1698. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1699. return key;
  1700. }
  1701. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1702. };
  1703. const i18n = I18n;
  1704. function throwError(error, name) {
  1705. if (window.TRACE) {
  1706. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1707. }
  1708. external_Swal_default().fire({
  1709. title: i18n('errorReport'),
  1710. icon: 'error',
  1711. showCancelButton: true,
  1712. confirmButtonText: i18n('toGithub'),
  1713. showDenyButton: true,
  1714. denyButtonText: i18n('toKeylol'),
  1715. cancelButtonText: i18n('close')
  1716. }).then(_ref => {
  1717. let {
  1718. isDenied,
  1719. isConfirmed
  1720. } = _ref;
  1721. if (isConfirmed) {
  1722. 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,
  1723. 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');
  1724. } else if (isDenied) {
  1725. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1726.  
  1727. 环境:
  1728.  
  1729. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1730.  
  1731. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1732. 脚本版本: ${GM_info.script.version}
  1733.  
  1734. 报错信息:
  1735. [code]${error.stack}[/code]
  1736.  
  1737. 执行日志:
  1738. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1739. GM_setClipboard(text);
  1740. external_Swal_default().fire({
  1741. title: i18n('copySuccess'),
  1742. icon: 'success',
  1743. confirmButtonText: i18n('ok')
  1744. }).then(() => {
  1745. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1746. });
  1747. }
  1748. });
  1749. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1750. }
  1751. function _defineProperty(obj, key, value) {
  1752. if (key in obj) {
  1753. Object.defineProperty(obj, key, {
  1754. value: value,
  1755. enumerable: true,
  1756. configurable: true,
  1757. writable: true
  1758. });
  1759. } else {
  1760. obj[key] = value;
  1761. }
  1762. return obj;
  1763. }
  1764. class Social {
  1765. constructor() {
  1766. _defineProperty(this, 'tasks', void 0);
  1767. }
  1768. getRealParams(name, links, doTask, link2param) {
  1769. try {
  1770. let realParams = [];
  1771. if (links.length > 0) {
  1772. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1773. }
  1774. if (!doTask && this.tasks[name].length > 0) {
  1775. realParams = [ ...realParams, ...this.tasks[name] ];
  1776. }
  1777. return unique(realParams);
  1778. } catch (error) {
  1779. throwError(error, 'Social.getRealParams');
  1780. return [];
  1781. }
  1782. }
  1783. }
  1784. const social_Social = Social;
  1785. function _classPrivateMethodInitSpec(obj, privateSet) {
  1786. _checkPrivateRedeclaration(obj, privateSet);
  1787. privateSet.add(obj);
  1788. }
  1789. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1790. _checkPrivateRedeclaration(obj, privateMap);
  1791. privateMap.set(obj, value);
  1792. }
  1793. function _checkPrivateRedeclaration(obj, privateCollection) {
  1794. if (privateCollection.has(obj)) {
  1795. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1796. }
  1797. }
  1798. function Discord_defineProperty(obj, key, value) {
  1799. if (key in obj) {
  1800. Object.defineProperty(obj, key, {
  1801. value: value,
  1802. enumerable: true,
  1803. configurable: true,
  1804. writable: true
  1805. });
  1806. } else {
  1807. obj[key] = value;
  1808. }
  1809. return obj;
  1810. }
  1811. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1812. if (!privateSet.has(receiver)) {
  1813. throw new TypeError('attempted to get private field on non-instance');
  1814. }
  1815. return fn;
  1816. }
  1817. function _classPrivateFieldGet(receiver, privateMap) {
  1818. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1819. return _classApplyDescriptorGet(receiver, descriptor);
  1820. }
  1821. function _classApplyDescriptorGet(receiver, descriptor) {
  1822. if (descriptor.get) {
  1823. return descriptor.get.call(receiver);
  1824. }
  1825. return descriptor.value;
  1826. }
  1827. function _classPrivateFieldSet(receiver, privateMap, value) {
  1828. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1829. _classApplyDescriptorSet(receiver, descriptor, value);
  1830. return value;
  1831. }
  1832. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1833. if (!privateMap.has(receiver)) {
  1834. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1835. }
  1836. return privateMap.get(receiver);
  1837. }
  1838. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1839. if (descriptor.set) {
  1840. descriptor.set.call(receiver, value);
  1841. } else {
  1842. if (!descriptor.writable) {
  1843. throw new TypeError('attempted to set read only private field');
  1844. }
  1845. descriptor.value = value;
  1846. }
  1847. }
  1848. const defaultTasksTemplate = {
  1849. servers: []
  1850. };
  1851. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1852. var _auth = new WeakMap();
  1853. var _cache = new WeakMap();
  1854. var _initialized = new WeakMap();
  1855. var _verifyAuth = new WeakSet();
  1856. var _updateAuth = new WeakSet();
  1857. var _joinServer = new WeakSet();
  1858. var _leaveServer = new WeakSet();
  1859. var _getGuild = new WeakSet();
  1860. var _setCache = new WeakSet();
  1861. class Discord extends social_Social {
  1862. constructor() {
  1863. var _GM_getValue;
  1864. super(...arguments);
  1865. _classPrivateMethodInitSpec(this, _setCache);
  1866. _classPrivateMethodInitSpec(this, _getGuild);
  1867. _classPrivateMethodInitSpec(this, _leaveServer);
  1868. _classPrivateMethodInitSpec(this, _joinServer);
  1869. _classPrivateMethodInitSpec(this, _updateAuth);
  1870. _classPrivateMethodInitSpec(this, _verifyAuth);
  1871. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1872. Discord_defineProperty(this, 'whiteList', {
  1873. ...JSON.parse(defaultTasks),
  1874. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1875. });
  1876. _classPrivateFieldInitSpec(this, _auth, {
  1877. writable: true,
  1878. value: GM_getValue('discordAuth') || {}
  1879. });
  1880. _classPrivateFieldInitSpec(this, _cache, {
  1881. writable: true,
  1882. value: GM_getValue('discordCache') || {}
  1883. });
  1884. _classPrivateFieldInitSpec(this, _initialized, {
  1885. writable: true,
  1886. value: false
  1887. });
  1888. }
  1889. async init() {
  1890. try {
  1891. if (!GM_getValue('dontRemindDiscordAgain')) {
  1892. const result = await external_Swal_default().fire({
  1893. title: i18n('discordImportantNotice'),
  1894. text: i18n('discordImportantNoticeText'),
  1895. showCancelButton: true,
  1896. showDenyButton: true,
  1897. confirmButtonText: i18n('continue'),
  1898. cancelButtonText: i18n('skipDiscordTask'),
  1899. denyButtonText: i18n('continueAndDontRemindAgain')
  1900. }).then(_ref => {
  1901. let {
  1902. isConfirmed,
  1903. isDenied
  1904. } = _ref;
  1905. if (isConfirmed) {
  1906. return true;
  1907. }
  1908. if (isDenied) {
  1909. GM_setValue('dontRemindDiscordAgain', true);
  1910. return true;
  1911. }
  1912. return false;
  1913. });
  1914. if (!result) {
  1915. _classPrivateFieldSet(this, _initialized, false);
  1916. return 'skip';
  1917. }
  1918. }
  1919. if (_classPrivateFieldGet(this, _initialized)) {
  1920. return true;
  1921. }
  1922. if (!_classPrivateFieldGet(this, _auth).auth) {
  1923. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1924. _classPrivateFieldSet(this, _initialized, true);
  1925. return true;
  1926. }
  1927. return false;
  1928. }
  1929. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1930. if (isVerified) {
  1931. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1932. _classPrivateFieldSet(this, _initialized, true);
  1933. return true;
  1934. }
  1935. GM_setValue('discordAuth', {
  1936. auth: null
  1937. });
  1938. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1939. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1940. _classPrivateFieldSet(this, _initialized, true);
  1941. return true;
  1942. }
  1943. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1944. return false;
  1945. } catch (error) {
  1946. throwError(error, 'Discord.init');
  1947. return false;
  1948. }
  1949. }
  1950. async toggle(_ref2) {
  1951. let {
  1952. doTask = true,
  1953. serverLinks = []
  1954. } = _ref2;
  1955. try {
  1956. if (!_classPrivateFieldGet(this, _initialized)) {
  1957. scripts_echoLog({
  1958. text: i18n('needInit')
  1959. });
  1960. return false;
  1961. }
  1962. const prom = [];
  1963. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1964. scripts_echoLog({
  1965. type: 'globalOptionsSkip',
  1966. text: 'discord.servers'
  1967. });
  1968. } else {
  1969. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1970. var _link$match;
  1971. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1972. });
  1973. if (realServers.length > 0) {
  1974. for (const server of realServers) {
  1975. if (doTask) {
  1976. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1977. } else {
  1978. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1979. }
  1980. await delay(1e3);
  1981. }
  1982. }
  1983. }
  1984. return await Promise.all(prom).then(() => true);
  1985. } catch (error) {
  1986. throwError(error, 'Discord.toggleServers');
  1987. return false;
  1988. }
  1989. }
  1990. }
  1991. async function _verifyAuth2() {
  1992. try {
  1993. const logStatus = scripts_echoLog({
  1994. text: i18n('verifyingAuth', 'Discord')
  1995. });
  1996. const {
  1997. result,
  1998. statusText,
  1999. status,
  2000. data
  2001. } = await tools_httpRequest({
  2002. url: 'https://discord.com/api/v6/users/@me',
  2003. method: 'HEAD',
  2004. headers: {
  2005. authorization: _classPrivateFieldGet(this, _auth).auth
  2006. }
  2007. });
  2008. if (result === 'Success') {
  2009. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2010. logStatus.success();
  2011. return true;
  2012. }
  2013. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2014. return false;
  2015. }
  2016. logStatus.error(`${result}:${statusText}(${status})`);
  2017. return false;
  2018. } catch (error) {
  2019. throwError(error, 'Discord.verifyAuth');
  2020. return false;
  2021. }
  2022. }
  2023. async function _updateAuth2() {
  2024. try {
  2025. const logStatus = scripts_echoLog({
  2026. text: i18n('updatingAuth', 'Discord')
  2027. });
  2028. return await new Promise(resolve => {
  2029. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  2030. active: true,
  2031. insert: true,
  2032. setParent: true
  2033. });
  2034. newTab.onclose = async () => {
  2035. var _GM_getValue2;
  2036. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  2037. if (auth) {
  2038. _classPrivateFieldSet(this, _auth, {
  2039. auth: auth
  2040. });
  2041. logStatus.success();
  2042. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  2043. } else {
  2044. logStatus.error('Error: Update discord auth failed!');
  2045. resolve(false);
  2046. }
  2047. };
  2048. });
  2049. } catch (error) {
  2050. throwError(error, 'Discord.updateAuth');
  2051. return false;
  2052. }
  2053. }
  2054. async function _joinServer2(inviteId) {
  2055. try {
  2056. const logStatus = scripts_echoLog({
  2057. type: 'joiningDiscordServer',
  2058. text: inviteId
  2059. });
  2060. const {
  2061. result,
  2062. statusText,
  2063. status,
  2064. data
  2065. } = await tools_httpRequest({
  2066. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2067. method: 'POST',
  2068. dataType: 'json',
  2069. headers: {
  2070. authorization: _classPrivateFieldGet(this, _auth).auth,
  2071. origin: 'https://discord.com',
  2072. referer: `https://discord.com/invite/${inviteId}`
  2073. }
  2074. });
  2075. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2076. var _data$response, _data$response$guild;
  2077. logStatus.success();
  2078. 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);
  2079. if (guild) {
  2080. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2081. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2082. }
  2083. return true;
  2084. }
  2085. logStatus.error(`${result}:${statusText}(${status})`);
  2086. return false;
  2087. } catch (error) {
  2088. throwError(error, 'Discord.joinServer');
  2089. return false;
  2090. }
  2091. }
  2092. async function _leaveServer2(inviteId) {
  2093. try {
  2094. if (this.whiteList.servers.includes(inviteId)) {
  2095. scripts_echoLog({
  2096. type: 'whiteList',
  2097. text: 'Discord.leaveServer',
  2098. id: inviteId
  2099. });
  2100. return true;
  2101. }
  2102. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2103. if (!guild) {
  2104. return false;
  2105. }
  2106. const logStatus = scripts_echoLog({
  2107. type: 'leavingDiscordServer',
  2108. text: guild
  2109. });
  2110. const {
  2111. result,
  2112. statusText,
  2113. status,
  2114. data
  2115. } = await tools_httpRequest({
  2116. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2117. method: 'DELETE',
  2118. headers: {
  2119. authorization: _classPrivateFieldGet(this, _auth).auth
  2120. }
  2121. });
  2122. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2123. logStatus.success();
  2124. return true;
  2125. }
  2126. logStatus.error(`${result}:${statusText}(${status})`);
  2127. return false;
  2128. } catch (error) {
  2129. throwError(error, 'Discord.leaveServer');
  2130. return false;
  2131. }
  2132. }
  2133. async function _getGuild2(inviteId) {
  2134. try {
  2135. const logStatus = scripts_echoLog({
  2136. type: 'gettingDiscordGuild',
  2137. text: inviteId
  2138. });
  2139. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2140. if (guild) {
  2141. logStatus.success();
  2142. return guild;
  2143. }
  2144. const {
  2145. result,
  2146. statusText,
  2147. status,
  2148. data
  2149. } = await tools_httpRequest({
  2150. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2151. responseType: 'json',
  2152. method: 'GET'
  2153. });
  2154. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2155. var _data$response2, _data$response2$guild;
  2156. 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;
  2157. if (guild) {
  2158. logStatus.success();
  2159. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2160. return guild;
  2161. }
  2162. logStatus.error(`${result}:${statusText}(${status})`);
  2163. return false;
  2164. }
  2165. logStatus.error(`${result}:${statusText}(${status})`);
  2166. return false;
  2167. } catch (error) {
  2168. throwError(error, 'Discord.getGuild');
  2169. return false;
  2170. }
  2171. }
  2172. function _setCache2(inviteId, guild) {
  2173. try {
  2174. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2175. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2176. } catch (error) {
  2177. throwError(error, 'Discord.setCache');
  2178. }
  2179. }
  2180. const social_Discord = Discord;
  2181. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2182. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2183. privateSet.add(obj);
  2184. }
  2185. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2186. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2187. privateMap.set(obj, value);
  2188. }
  2189. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2190. if (privateCollection.has(obj)) {
  2191. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2192. }
  2193. }
  2194. function Instagram_defineProperty(obj, key, value) {
  2195. if (key in obj) {
  2196. Object.defineProperty(obj, key, {
  2197. value: value,
  2198. enumerable: true,
  2199. configurable: true,
  2200. writable: true
  2201. });
  2202. } else {
  2203. obj[key] = value;
  2204. }
  2205. return obj;
  2206. }
  2207. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2208. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2209. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2210. return value;
  2211. }
  2212. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2213. if (descriptor.set) {
  2214. descriptor.set.call(receiver, value);
  2215. } else {
  2216. if (!descriptor.writable) {
  2217. throw new TypeError('attempted to set read only private field');
  2218. }
  2219. descriptor.value = value;
  2220. }
  2221. }
  2222. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2223. if (!privateSet.has(receiver)) {
  2224. throw new TypeError('attempted to get private field on non-instance');
  2225. }
  2226. return fn;
  2227. }
  2228. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2229. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2230. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2231. }
  2232. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2233. if (!privateMap.has(receiver)) {
  2234. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2235. }
  2236. return privateMap.get(receiver);
  2237. }
  2238. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2239. if (descriptor.get) {
  2240. return descriptor.get.call(receiver);
  2241. }
  2242. return descriptor.value;
  2243. }
  2244. const Instagram_defaultTasksTemplate = {
  2245. users: []
  2246. };
  2247. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2248. var Instagram_cache = new WeakMap();
  2249. var Instagram_auth = new WeakMap();
  2250. var Instagram_initialized = new WeakMap();
  2251. var _getUserInfo = new WeakSet();
  2252. var _followUser = new WeakSet();
  2253. var _unfollowUser = new WeakSet();
  2254. var Instagram_setCache = new WeakSet();
  2255. class Instagram extends social_Social {
  2256. constructor() {
  2257. var _GM_getValue;
  2258. super(...arguments);
  2259. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2260. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2261. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2262. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2263. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2264. Instagram_defineProperty(this, 'whiteList', {
  2265. ...JSON.parse(Instagram_defaultTasks),
  2266. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2267. });
  2268. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2269. writable: true,
  2270. value: GM_getValue('instagramCache') || {}
  2271. });
  2272. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2273. writable: true,
  2274. value: {}
  2275. });
  2276. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2277. writable: true,
  2278. value: false
  2279. });
  2280. }
  2281. async init() {
  2282. try {
  2283. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2284. return true;
  2285. }
  2286. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2287. if (isVerified) {
  2288. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2289. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2290. return true;
  2291. }
  2292. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2293. return false;
  2294. } catch (error) {
  2295. throwError(error, 'Instagram.init');
  2296. return false;
  2297. }
  2298. }
  2299. async toggle(_ref) {
  2300. let {
  2301. doTask = true,
  2302. userLinks = []
  2303. } = _ref;
  2304. try {
  2305. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2306. scripts_echoLog({
  2307. text: i18n('needInit')
  2308. });
  2309. return false;
  2310. }
  2311. const prom = [];
  2312. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2313. scripts_echoLog({
  2314. type: 'globalOptionsSkip',
  2315. text: 'instagram.users'
  2316. });
  2317. } else {
  2318. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2319. var _link$match;
  2320. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2321. });
  2322. if (realUsers.length > 0) {
  2323. for (const username of realUsers) {
  2324. if (doTask) {
  2325. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2326. } else {
  2327. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2328. }
  2329. await delay(1e3);
  2330. }
  2331. }
  2332. }
  2333. return await Promise.all(prom).then(() => true);
  2334. } catch (error) {
  2335. throwError(error, 'Instagram.toggleUsers');
  2336. return false;
  2337. }
  2338. }
  2339. }
  2340. async function _getUserInfo2() {
  2341. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2342. try {
  2343. const logStatus = scripts_echoLog({
  2344. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2345. text: name
  2346. });
  2347. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2348. if (userId && name !== 'instagram') {
  2349. logStatus.success();
  2350. return userId;
  2351. }
  2352. const {
  2353. result,
  2354. statusText,
  2355. status,
  2356. data
  2357. } = await tools_httpRequest({
  2358. url: `https://www.instagram.com/${name}/`,
  2359. method: 'GET'
  2360. });
  2361. if (result === 'Success') {
  2362. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2363. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2364. return false;
  2365. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2366. logStatus.error(`Error:${i18n('insBanned')}`);
  2367. return false;
  2368. }
  2369. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2370. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2371. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2372. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2373. if (name === 'instagram') {
  2374. if (csrftoken && hash) {
  2375. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2376. csrftoken: csrftoken,
  2377. hash: hash
  2378. });
  2379. return true;
  2380. }
  2381. return false;
  2382. }
  2383. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2384. if (id) {
  2385. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2386. logStatus.success();
  2387. return id;
  2388. }
  2389. logStatus.error('Error: Get ins data error!');
  2390. return false;
  2391. }
  2392. logStatus.error(`${result}:${statusText}(${status})`);
  2393. return false;
  2394. }
  2395. return false;
  2396. } catch (error) {
  2397. throwError(error, 'Instagram.getUserInfo');
  2398. return false;
  2399. }
  2400. }
  2401. async function _followUser2(name) {
  2402. try {
  2403. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2404. if (!id) {
  2405. return false;
  2406. }
  2407. const logStatus = scripts_echoLog({
  2408. type: 'followingIns',
  2409. text: name
  2410. });
  2411. const {
  2412. result,
  2413. statusText,
  2414. status,
  2415. data
  2416. } = await tools_httpRequest({
  2417. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2418. method: 'POST',
  2419. dataType: 'json',
  2420. headers: {
  2421. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2422. origin: 'https://www.instagram.com',
  2423. referer: `https://www.instagram.com/${name}/`,
  2424. 'content-type': 'application/x-www-form-urlencoded',
  2425. 'sec-fetch-site': 'same-origin',
  2426. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2427. }
  2428. });
  2429. if (result === 'Success') {
  2430. var _data$response, _data$response2;
  2431. 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') {
  2432. logStatus.success();
  2433. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2434. return true;
  2435. }
  2436. 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})`}`);
  2437. return false;
  2438. }
  2439. logStatus.error(`${result}:${statusText}(${status})`);
  2440. return false;
  2441. } catch (error) {
  2442. throwError(error, 'Instagram.followUser');
  2443. return false;
  2444. }
  2445. }
  2446. async function _unfollowUser2(name) {
  2447. try {
  2448. if (this.whiteList.users.includes(name)) {
  2449. scripts_echoLog({
  2450. type: 'whiteList',
  2451. text: 'Instagram.unfollowUser',
  2452. id: name
  2453. });
  2454. return true;
  2455. }
  2456. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2457. if (!id) {
  2458. return false;
  2459. }
  2460. const logStatus = scripts_echoLog({
  2461. type: 'unfollowingIns',
  2462. text: name
  2463. });
  2464. const {
  2465. result,
  2466. statusText,
  2467. status,
  2468. data
  2469. } = await tools_httpRequest({
  2470. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2471. method: 'POST',
  2472. dataType: 'json',
  2473. headers: {
  2474. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2475. origin: 'https://www.instagram.com',
  2476. referer: `https://www.instagram.com/${name}/`,
  2477. 'content-type': 'application/x-www-form-urlencoded',
  2478. 'sec-fetch-site': 'same-origin',
  2479. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2480. }
  2481. });
  2482. if (result === 'Success') {
  2483. var _data$response3;
  2484. 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') {
  2485. logStatus.success();
  2486. return true;
  2487. }
  2488. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2489. return false;
  2490. }
  2491. logStatus.error(`${result}:${statusText}(${status})`);
  2492. return false;
  2493. } catch (error) {
  2494. throwError(error, 'Instagram.unfollowUser');
  2495. return false;
  2496. }
  2497. }
  2498. function Instagram_setCache2(name, id) {
  2499. try {
  2500. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2501. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2502. } catch (error) {
  2503. throwError(error, 'Instagram.setCache');
  2504. }
  2505. }
  2506. const social_Instagram = Instagram;
  2507. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2508. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2509. privateSet.add(obj);
  2510. }
  2511. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2512. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2513. privateMap.set(obj, value);
  2514. }
  2515. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2516. if (privateCollection.has(obj)) {
  2517. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2518. }
  2519. }
  2520. function Reddit_defineProperty(obj, key, value) {
  2521. if (key in obj) {
  2522. Object.defineProperty(obj, key, {
  2523. value: value,
  2524. enumerable: true,
  2525. configurable: true,
  2526. writable: true
  2527. });
  2528. } else {
  2529. obj[key] = value;
  2530. }
  2531. return obj;
  2532. }
  2533. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2534. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2535. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2536. return value;
  2537. }
  2538. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2539. if (descriptor.set) {
  2540. descriptor.set.call(receiver, value);
  2541. } else {
  2542. if (!descriptor.writable) {
  2543. throw new TypeError('attempted to set read only private field');
  2544. }
  2545. descriptor.value = value;
  2546. }
  2547. }
  2548. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2549. if (!privateSet.has(receiver)) {
  2550. throw new TypeError('attempted to get private field on non-instance');
  2551. }
  2552. return fn;
  2553. }
  2554. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2555. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2556. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2557. }
  2558. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2559. if (!privateMap.has(receiver)) {
  2560. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2561. }
  2562. return privateMap.get(receiver);
  2563. }
  2564. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2565. if (descriptor.get) {
  2566. return descriptor.get.call(receiver);
  2567. }
  2568. return descriptor.value;
  2569. }
  2570. const Reddit_defaultTasksTemplate = {
  2571. reddits: []
  2572. };
  2573. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2574. var Reddit_auth = new WeakMap();
  2575. var Reddit_initialized = new WeakMap();
  2576. var _useBeta = new WeakSet();
  2577. var Reddit_updateAuth = new WeakSet();
  2578. class Reddit extends social_Social {
  2579. constructor() {
  2580. var _GM_getValue;
  2581. super(...arguments);
  2582. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2583. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2584. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2585. Reddit_defineProperty(this, 'whiteList', {
  2586. ...JSON.parse(Reddit_defaultTasks),
  2587. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2588. });
  2589. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2590. writable: true,
  2591. value: void 0
  2592. });
  2593. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2594. writable: true,
  2595. value: false
  2596. });
  2597. }
  2598. async init() {
  2599. try {
  2600. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2601. return true;
  2602. }
  2603. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2604. if (isVerified) {
  2605. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2606. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2607. return true;
  2608. }
  2609. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2610. return false;
  2611. } catch (error) {
  2612. throwError(error, 'Reddit.init');
  2613. return false;
  2614. }
  2615. }
  2616. async toggleTask(_ref) {
  2617. let {
  2618. name,
  2619. doTask = true
  2620. } = _ref;
  2621. try {
  2622. if (!doTask && this.whiteList.reddits.includes(name)) {
  2623. scripts_echoLog({
  2624. type: 'whiteList',
  2625. text: 'Reddit.undoTask',
  2626. id: name
  2627. });
  2628. return true;
  2629. }
  2630. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2631. if (/^u_/.test(name)) {
  2632. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2633. }
  2634. const logStatus = scripts_echoLog({
  2635. type: type,
  2636. text: name
  2637. });
  2638. const {
  2639. result,
  2640. statusText,
  2641. status,
  2642. data
  2643. } = await tools_httpRequest({
  2644. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2645. method: 'POST',
  2646. headers: {
  2647. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2648. 'content-type': 'application/x-www-form-urlencoded'
  2649. },
  2650. data: $.param({
  2651. action: doTask ? 'sub' : 'unsub',
  2652. sr_name: name,
  2653. api_type: 'json'
  2654. })
  2655. });
  2656. if (result === 'Success') {
  2657. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2658. logStatus.success();
  2659. if (doTask) {
  2660. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2661. }
  2662. return true;
  2663. }
  2664. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2665. return false;
  2666. }
  2667. logStatus.error(`${result}:${statusText}(${status})`);
  2668. return false;
  2669. } catch (error) {
  2670. throwError(error, 'Reddit.toggleTask');
  2671. return false;
  2672. }
  2673. }
  2674. async toggle(_ref2) {
  2675. let {
  2676. doTask = true,
  2677. redditLinks = []
  2678. } = _ref2;
  2679. try {
  2680. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2681. scripts_echoLog({
  2682. text: i18n('needInit')
  2683. });
  2684. return false;
  2685. }
  2686. const prom = [];
  2687. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2688. scripts_echoLog({
  2689. type: 'globalOptionsSkip',
  2690. text: 'reddit.reddits'
  2691. });
  2692. } else {
  2693. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2694. var _link$match, _link$match2;
  2695. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2696. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2697. if (userName) {
  2698. return name || userName;
  2699. }
  2700. return name;
  2701. });
  2702. if (realReddits.length > 0) {
  2703. for (const name of realReddits) {
  2704. prom.push(this.toggleTask({
  2705. name: name,
  2706. doTask: doTask
  2707. }));
  2708. await delay(1e3);
  2709. }
  2710. }
  2711. }
  2712. return await Promise.all(prom).then(() => true);
  2713. } catch (error) {
  2714. throwError(error, 'Reddit.toggle');
  2715. return false;
  2716. }
  2717. }
  2718. }
  2719. async function _useBeta2() {
  2720. try {
  2721. const logStatus = scripts_echoLog({
  2722. text: i18n('changingRedditVersion')
  2723. });
  2724. GM_setValue('redditAuth', null);
  2725. return await new Promise(resolve => {
  2726. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2727. active: true,
  2728. insert: true,
  2729. setParent: true
  2730. });
  2731. newTab.onclose = async () => {
  2732. logStatus.success();
  2733. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2734. };
  2735. });
  2736. } catch (error) {
  2737. throwError(error, 'Reddit.useBeta');
  2738. return false;
  2739. }
  2740. }
  2741. async function Reddit_updateAuth2() {
  2742. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2743. try {
  2744. const logStatus = scripts_echoLog({
  2745. text: i18n('updatingAuth', 'Reddit')
  2746. });
  2747. const {
  2748. result,
  2749. statusText,
  2750. status,
  2751. data
  2752. } = await tools_httpRequest({
  2753. url: 'https://www.reddit.com/',
  2754. method: 'GET',
  2755. nochche: true,
  2756. headers: {
  2757. 'Cache-Control': 'no-cache'
  2758. }
  2759. });
  2760. if (result === 'Success') {
  2761. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2762. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2763. return false;
  2764. }
  2765. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2766. var _data$responseText$ma;
  2767. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2768. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2769. }
  2770. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2771. if (accessToken) {
  2772. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2773. token: accessToken
  2774. });
  2775. logStatus.success();
  2776. return true;
  2777. }
  2778. logStatus.error('Error: Parameter "accessToken" not found!');
  2779. return false;
  2780. }
  2781. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2782. return false;
  2783. }
  2784. logStatus.error(`${result}:${statusText}(${status})`);
  2785. return false;
  2786. } catch (error) {
  2787. throwError(error, 'Reddit.updateAuth');
  2788. return false;
  2789. }
  2790. }
  2791. const social_Reddit = Reddit;
  2792. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2793. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2794. privateSet.add(obj);
  2795. }
  2796. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2797. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2798. privateMap.set(obj, value);
  2799. }
  2800. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2801. if (privateCollection.has(obj)) {
  2802. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2803. }
  2804. }
  2805. function Twitch_defineProperty(obj, key, value) {
  2806. if (key in obj) {
  2807. Object.defineProperty(obj, key, {
  2808. value: value,
  2809. enumerable: true,
  2810. configurable: true,
  2811. writable: true
  2812. });
  2813. } else {
  2814. obj[key] = value;
  2815. }
  2816. return obj;
  2817. }
  2818. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2819. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2820. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2821. return value;
  2822. }
  2823. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2824. if (descriptor.set) {
  2825. descriptor.set.call(receiver, value);
  2826. } else {
  2827. if (!descriptor.writable) {
  2828. throw new TypeError('attempted to set read only private field');
  2829. }
  2830. descriptor.value = value;
  2831. }
  2832. }
  2833. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2834. if (!privateSet.has(receiver)) {
  2835. throw new TypeError('attempted to get private field on non-instance');
  2836. }
  2837. return fn;
  2838. }
  2839. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2840. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2841. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2842. }
  2843. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2844. if (!privateMap.has(receiver)) {
  2845. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2846. }
  2847. return privateMap.get(receiver);
  2848. }
  2849. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2850. if (descriptor.get) {
  2851. return descriptor.get.call(receiver);
  2852. }
  2853. return descriptor.value;
  2854. }
  2855. const Twitch_defaultTasksTemplate = {
  2856. channels: []
  2857. };
  2858. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2859. var Twitch_auth = new WeakMap();
  2860. var Twitch_cache = new WeakMap();
  2861. var Twitch_initialized = new WeakMap();
  2862. var Twitch_verifyAuth = new WeakSet();
  2863. var Twitch_updateAuth = new WeakSet();
  2864. var _toggleChannel = new WeakSet();
  2865. var _getChannelId = new WeakSet();
  2866. var Twitch_setCache = new WeakSet();
  2867. class Twitch extends social_Social {
  2868. constructor() {
  2869. var _GM_getValue;
  2870. super(...arguments);
  2871. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2872. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2873. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2874. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2875. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2876. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2877. Twitch_defineProperty(this, 'whiteList', {
  2878. ...JSON.parse(Twitch_defaultTasks),
  2879. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2880. });
  2881. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2882. writable: true,
  2883. value: GM_getValue('twitchAuth') || {}
  2884. });
  2885. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2886. writable: true,
  2887. value: GM_getValue('twitchCache') || {}
  2888. });
  2889. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2890. writable: true,
  2891. value: false
  2892. });
  2893. }
  2894. async init() {
  2895. try {
  2896. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2897. return true;
  2898. }
  2899. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2900. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2901. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2902. return true;
  2903. }
  2904. return false;
  2905. }
  2906. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2907. if (isVerified) {
  2908. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2909. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2910. return true;
  2911. }
  2912. GM_setValue('twitchAuth', null);
  2913. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2914. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2915. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2916. return true;
  2917. }
  2918. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2919. return false;
  2920. } catch (error) {
  2921. throwError(error, 'Twitch.init');
  2922. return false;
  2923. }
  2924. }
  2925. async toggle(_ref) {
  2926. let {
  2927. doTask = true,
  2928. channelLinks = []
  2929. } = _ref;
  2930. try {
  2931. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2932. scripts_echoLog({
  2933. text: i18n('needInit')
  2934. });
  2935. return false;
  2936. }
  2937. const prom = [];
  2938. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2939. scripts_echoLog({
  2940. type: 'globalOptionsSkip',
  2941. text: 'twitch.channels'
  2942. });
  2943. } else {
  2944. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2945. var _link$match;
  2946. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2947. });
  2948. if (realChannels.length > 0) {
  2949. for (const channel of realChannels) {
  2950. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2951. name: channel,
  2952. doTask: doTask
  2953. }));
  2954. await delay(1e3);
  2955. }
  2956. }
  2957. }
  2958. return Promise.all(prom).then(() => true);
  2959. } catch (error) {
  2960. throwError(error, 'Twitch.toggle');
  2961. return false;
  2962. }
  2963. }
  2964. }
  2965. async function Twitch_verifyAuth2() {
  2966. try {
  2967. const logStatus = scripts_echoLog({
  2968. text: i18n('verifyingAuth', 'Twitch')
  2969. });
  2970. const {
  2971. result,
  2972. statusText,
  2973. status,
  2974. data
  2975. } = await tools_httpRequest({
  2976. url: 'https://gql.twitch.tv/gql',
  2977. method: 'POST',
  2978. dataType: 'json',
  2979. headers: {
  2980. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2981. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2982. },
  2983. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2984. });
  2985. if (result === 'Success') {
  2986. var _data$response, _data$response$, _data$response$$data;
  2987. 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) {
  2988. logStatus.success();
  2989. return true;
  2990. }
  2991. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2992. return false;
  2993. }
  2994. logStatus.error(`${result}:${statusText}(${status})`);
  2995. return false;
  2996. } catch (error) {
  2997. throwError(error, 'Twitch.verifyAuth');
  2998. return false;
  2999. }
  3000. }
  3001. async function Twitch_updateAuth2() {
  3002. try {
  3003. const logStatus = scripts_echoLog({
  3004. text: i18n('updatingAuth', 'Twitch')
  3005. });
  3006. return await new Promise(resolve => {
  3007. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  3008. active: true,
  3009. insert: true,
  3010. setParent: true
  3011. });
  3012. newTab.onclose = async () => {
  3013. const auth = GM_getValue('twitchAuth');
  3014. if (auth) {
  3015. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  3016. logStatus.success();
  3017. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  3018. } else {
  3019. logStatus.error('Error: Update twitch auth failed!');
  3020. resolve(false);
  3021. }
  3022. };
  3023. });
  3024. } catch (error) {
  3025. throwError(error, 'Twitch.updateAuth');
  3026. return false;
  3027. }
  3028. }
  3029. async function _toggleChannel2(_ref2) {
  3030. let {
  3031. name,
  3032. doTask = true
  3033. } = _ref2;
  3034. try {
  3035. if (!doTask && this.whiteList.channels.includes(name)) {
  3036. scripts_echoLog({
  3037. type: 'whiteList',
  3038. text: 'Twitch.unfollowChannel',
  3039. id: name
  3040. });
  3041. return true;
  3042. }
  3043. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  3044. if (!channelId) {
  3045. return false;
  3046. }
  3047. const logStatus = scripts_echoLog({
  3048. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  3049. text: name
  3050. });
  3051. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  3052. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  3053. const {
  3054. result,
  3055. statusText,
  3056. status,
  3057. data
  3058. } = await tools_httpRequest({
  3059. url: 'https://gql.twitch.tv/gql',
  3060. method: 'POST',
  3061. dataType: 'json',
  3062. headers: {
  3063. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  3064. },
  3065. data: doTask ? followData : unfollowData
  3066. });
  3067. if (result === 'Success') {
  3068. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3069. logStatus.success();
  3070. if (doTask) {
  3071. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3072. }
  3073. return true;
  3074. }
  3075. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3076. return false;
  3077. }
  3078. logStatus.error(`${result}:${statusText}(${status})`);
  3079. return false;
  3080. } catch (error) {
  3081. throwError(error, 'Twitch.toggleChannel');
  3082. return false;
  3083. }
  3084. }
  3085. async function _getChannelId2(name) {
  3086. try {
  3087. const logStatus = scripts_echoLog({
  3088. type: 'gettingTwitchChannelId',
  3089. text: name
  3090. });
  3091. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3092. if (channelId) {
  3093. logStatus.success();
  3094. return channelId;
  3095. }
  3096. const {
  3097. result,
  3098. statusText,
  3099. status,
  3100. data
  3101. } = await tools_httpRequest({
  3102. url: 'https://gql.twitch.tv/gql',
  3103. method: 'POST',
  3104. headers: {
  3105. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3106. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3107. },
  3108. responseType: 'json',
  3109. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3110. });
  3111. if (result === 'Success') {
  3112. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3113. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3114. 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);
  3115. if (channelId) {
  3116. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3117. logStatus.success();
  3118. return channelId;
  3119. }
  3120. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3121. return false;
  3122. }
  3123. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3124. return false;
  3125. }
  3126. logStatus.error(`${result}:${statusText}(${status})`);
  3127. return false;
  3128. } catch (error) {
  3129. throwError(error, 'Twitch.getChannelId');
  3130. return false;
  3131. }
  3132. }
  3133. function Twitch_setCache2(name, id) {
  3134. try {
  3135. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3136. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3137. } catch (error) {
  3138. throwError(error, 'Twitch.setCache');
  3139. }
  3140. }
  3141. const social_Twitch = Twitch;
  3142. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3143. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3144. privateSet.add(obj);
  3145. }
  3146. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3147. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3148. privateMap.set(obj, value);
  3149. }
  3150. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3151. if (privateCollection.has(obj)) {
  3152. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3153. }
  3154. }
  3155. function Twitter_defineProperty(obj, key, value) {
  3156. if (key in obj) {
  3157. Object.defineProperty(obj, key, {
  3158. value: value,
  3159. enumerable: true,
  3160. configurable: true,
  3161. writable: true
  3162. });
  3163. } else {
  3164. obj[key] = value;
  3165. }
  3166. return obj;
  3167. }
  3168. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3169. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3170. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3171. return value;
  3172. }
  3173. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3174. if (descriptor.set) {
  3175. descriptor.set.call(receiver, value);
  3176. } else {
  3177. if (!descriptor.writable) {
  3178. throw new TypeError('attempted to set read only private field');
  3179. }
  3180. descriptor.value = value;
  3181. }
  3182. }
  3183. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3184. if (!privateSet.has(receiver)) {
  3185. throw new TypeError('attempted to get private field on non-instance');
  3186. }
  3187. return fn;
  3188. }
  3189. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3190. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3191. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3192. }
  3193. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3194. if (!privateMap.has(receiver)) {
  3195. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3196. }
  3197. return privateMap.get(receiver);
  3198. }
  3199. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3200. if (descriptor.get) {
  3201. return descriptor.get.call(receiver);
  3202. }
  3203. return descriptor.value;
  3204. }
  3205. const Twitter_defaultTasksTemplate = {
  3206. users: [],
  3207. retweets: [],
  3208. likes: []
  3209. };
  3210. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3211. var _verifyId = new WeakMap();
  3212. var Twitter_auth = new WeakMap();
  3213. var Twitter_cache = new WeakMap();
  3214. var Twitter_initialized = new WeakMap();
  3215. var Twitter_verifyAuth = new WeakSet();
  3216. var Twitter_updateAuth = new WeakSet();
  3217. var _toggleUser = new WeakSet();
  3218. var _toggleRetweet = new WeakSet();
  3219. var Twitter_setCache = new WeakSet();
  3220. class Twitter extends social_Social {
  3221. constructor() {
  3222. var _GM_getValue;
  3223. super(...arguments);
  3224. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3225. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3226. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3227. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3228. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3229. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3230. Twitter_defineProperty(this, 'whiteList', {
  3231. ...JSON.parse(Twitter_defaultTasks),
  3232. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3233. });
  3234. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3235. writable: true,
  3236. value: globalOptions.other.twitterVerifyId
  3237. });
  3238. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3239. writable: true,
  3240. value: GM_getValue('twitterAuth') || {}
  3241. });
  3242. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3243. writable: true,
  3244. value: GM_getValue('twitterCache') || {}
  3245. });
  3246. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3247. writable: true,
  3248. value: false
  3249. });
  3250. }
  3251. async init() {
  3252. try {
  3253. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3254. return true;
  3255. }
  3256. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3257. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3258. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3259. return true;
  3260. }
  3261. return false;
  3262. }
  3263. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3264. if (isVerified) {
  3265. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3266. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3267. return true;
  3268. }
  3269. GM_setValue('twitterAuth', null);
  3270. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3271. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3272. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3273. return true;
  3274. }
  3275. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3276. return false;
  3277. } catch (error) {
  3278. throwError(error, 'Twitter.init');
  3279. return false;
  3280. }
  3281. }
  3282. async userName2id(name) {
  3283. try {
  3284. const logStatus = scripts_echoLog({
  3285. type: 'gettingTwitterUserId',
  3286. text: name
  3287. });
  3288. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3289. if (userId) {
  3290. logStatus.success();
  3291. return userId;
  3292. }
  3293. const {
  3294. result,
  3295. statusText,
  3296. status,
  3297. data
  3298. } = await tools_httpRequest({
  3299. url: 'https://api.twitter.com/graphql/mCbpQvZAw6zu_4PvuAUVVQ/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D`,
  3300. method: 'GET',
  3301. headers: {
  3302. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3303. 'content-type': 'application/json',
  3304. referer: `https://twitter.com/${name}`,
  3305. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3306. },
  3307. responseType: 'json'
  3308. });
  3309. if (result === 'Success') {
  3310. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3311. var _response, _response$data, _response$data$user, _response$data$user$r;
  3312. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3313. if (!response) {
  3314. try {
  3315. response = JSON.parse(data.responseText);
  3316. } catch (error) {
  3317. response = null;
  3318. }
  3319. }
  3320. const userId = String((_response = response) === null || _response === void 0 ? void 0 : (_response$data = _response.data) === null || _response$data === void 0 ? void 0 : (_response$data$user = _response$data.user) === null || _response$data$user === void 0 ? void 0 : (_response$data$user$r = _response$data$user.result) === null || _response$data$user$r === void 0 ? void 0 : _response$data$user$r.rest_id);
  3321. if (userId) {
  3322. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3323. logStatus.success();
  3324. return userId;
  3325. }
  3326. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3327. return false;
  3328. }
  3329. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3330. return false;
  3331. }
  3332. logStatus.error(`${result}:${statusText}(${status})`);
  3333. return false;
  3334. } catch (error) {
  3335. throwError(error, 'Twitter.getUserId');
  3336. return false;
  3337. }
  3338. }
  3339. async toggle(_ref) {
  3340. let {
  3341. doTask = true,
  3342. userLinks = [],
  3343. retweetLinks = []
  3344. } = _ref;
  3345. try {
  3346. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3347. scripts_echoLog({
  3348. text: i18n('needInit')
  3349. });
  3350. return false;
  3351. }
  3352. const prom = [];
  3353. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3354. scripts_echoLog({
  3355. type: 'globalOptionsSkip',
  3356. text: 'twitter.users'
  3357. });
  3358. } else {
  3359. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3360. var _link$match;
  3361. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3362. });
  3363. if (realUsers.length > 0) {
  3364. for (const user of realUsers) {
  3365. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3366. name: user,
  3367. doTask: doTask
  3368. }));
  3369. await delay(1e3);
  3370. }
  3371. }
  3372. }
  3373. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3374. scripts_echoLog({
  3375. type: 'globalOptionsSkip',
  3376. text: 'twitter.retweets'
  3377. });
  3378. } else {
  3379. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3380. var _link$match2;
  3381. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3382. });
  3383. if (realRetweets.length > 0) {
  3384. for (const retweet of realRetweets) {
  3385. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3386. retweetId: retweet,
  3387. doTask: doTask
  3388. }));
  3389. await delay(1e3);
  3390. }
  3391. }
  3392. }
  3393. return Promise.all(prom).then(() => true);
  3394. } catch (error) {
  3395. throwError(error, 'Twitter.toggle');
  3396. return false;
  3397. }
  3398. }
  3399. }
  3400. async function Twitter_verifyAuth2() {
  3401. try {
  3402. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3403. name: 'verify',
  3404. doTask: true,
  3405. verify: true
  3406. });
  3407. } catch (error) {
  3408. throwError(error, 'Twitter.verifyAuth');
  3409. return false;
  3410. }
  3411. }
  3412. async function Twitter_updateAuth2() {
  3413. try {
  3414. const logStatus = scripts_echoLog({
  3415. text: i18n('updatingAuth', 'Twitter')
  3416. });
  3417. return await new Promise(resolve => {
  3418. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3419. active: true,
  3420. insert: true,
  3421. setParent: true
  3422. });
  3423. newTab.onclose = async () => {
  3424. const auth = GM_getValue('twitterAuth');
  3425. if (auth) {
  3426. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3427. logStatus.success();
  3428. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3429. } else {
  3430. logStatus.error('Error: Update twitter auth failed!');
  3431. resolve(false);
  3432. }
  3433. };
  3434. });
  3435. } catch (error) {
  3436. throwError(error, 'Twitter.updateToken');
  3437. return false;
  3438. }
  3439. }
  3440. async function _toggleUser2(_ref2) {
  3441. let {
  3442. name,
  3443. doTask = true,
  3444. verify = false
  3445. } = _ref2;
  3446. try {
  3447. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3448. scripts_echoLog({
  3449. type: 'whiteList',
  3450. text: 'Twitter.unfollowUser',
  3451. id: name
  3452. });
  3453. return true;
  3454. }
  3455. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3456. if (!userId) {
  3457. return false;
  3458. }
  3459. const logStatus = verify ? scripts_echoLog({
  3460. text: i18n('verifyingAuth', 'Twitter')
  3461. }) : scripts_echoLog({
  3462. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3463. text: name
  3464. });
  3465. const {
  3466. result,
  3467. statusText,
  3468. status,
  3469. data
  3470. } = await tools_httpRequest({
  3471. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3472. method: 'POST',
  3473. headers: {
  3474. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3475. 'Content-Type': 'application/x-www-form-urlencoded',
  3476. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3477. },
  3478. responseType: 'json',
  3479. data: $.param({
  3480. include_profile_interstitial_type: 1,
  3481. include_blocking: 1,
  3482. include_blocked_by: 1,
  3483. include_followed_by: 1,
  3484. include_want_retweets: 1,
  3485. include_mute_edge: 1,
  3486. include_can_dm: 1,
  3487. include_can_media_tag: 1,
  3488. skip_status: 1,
  3489. id: userId
  3490. })
  3491. });
  3492. if (result === 'Success') {
  3493. var _data$response, _data$response$errors, _data$response$errors2;
  3494. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3495. logStatus.success();
  3496. if (doTask && !verify) {
  3497. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3498. }
  3499. return true;
  3500. }
  3501. 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) {
  3502. logStatus.success();
  3503. return true;
  3504. }
  3505. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3506. return false;
  3507. }
  3508. logStatus.error(`${result}:${statusText}(${status})`);
  3509. return false;
  3510. } catch (error) {
  3511. throwError(error, 'Twitter.toggleUser');
  3512. return false;
  3513. }
  3514. }
  3515. async function _toggleRetweet2(_ref3) {
  3516. let {
  3517. retweetId,
  3518. doTask = true
  3519. } = _ref3;
  3520. try {
  3521. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3522. scripts_echoLog({
  3523. type: 'whiteList',
  3524. text: 'Twitter.unretweet',
  3525. id: retweetId
  3526. });
  3527. return true;
  3528. }
  3529. const logStatus = scripts_echoLog({
  3530. type: `${doTask ? '' : 'un'}retweetting`,
  3531. text: retweetId
  3532. });
  3533. const {
  3534. result,
  3535. statusText,
  3536. status,
  3537. data
  3538. } = await tools_httpRequest({
  3539. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3540. method: 'POST',
  3541. headers: {
  3542. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3543. 'Content-Type': 'application/x-www-form-urlencoded',
  3544. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3545. },
  3546. data: $.param({
  3547. tweet_mode: 'extended',
  3548. id: retweetId
  3549. }),
  3550. responseType: 'json'
  3551. });
  3552. if (result === 'Success') {
  3553. var _data$response2, _data$response2$error, _data$response2$error2;
  3554. 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) {
  3555. logStatus.success();
  3556. if (doTask) {
  3557. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3558. }
  3559. return true;
  3560. }
  3561. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3562. return false;
  3563. }
  3564. logStatus.error(`${result}:${statusText}(${status})`);
  3565. return false;
  3566. } catch (error) {
  3567. throwError(error, 'Twitter.toggleRetweet');
  3568. return false;
  3569. }
  3570. }
  3571. function Twitter_setCache2(name, id) {
  3572. try {
  3573. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3574. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3575. } catch (error) {
  3576. throwError(error, 'Twitter.setCache');
  3577. }
  3578. }
  3579. const social_Twitter = Twitter;
  3580. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3581. Vk_checkPrivateRedeclaration(obj, privateSet);
  3582. privateSet.add(obj);
  3583. }
  3584. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3585. Vk_checkPrivateRedeclaration(obj, privateMap);
  3586. privateMap.set(obj, value);
  3587. }
  3588. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3589. if (privateCollection.has(obj)) {
  3590. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3591. }
  3592. }
  3593. function Vk_defineProperty(obj, key, value) {
  3594. if (key in obj) {
  3595. Object.defineProperty(obj, key, {
  3596. value: value,
  3597. enumerable: true,
  3598. configurable: true,
  3599. writable: true
  3600. });
  3601. } else {
  3602. obj[key] = value;
  3603. }
  3604. return obj;
  3605. }
  3606. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3607. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3608. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3609. return value;
  3610. }
  3611. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3612. if (descriptor.set) {
  3613. descriptor.set.call(receiver, value);
  3614. } else {
  3615. if (!descriptor.writable) {
  3616. throw new TypeError('attempted to set read only private field');
  3617. }
  3618. descriptor.value = value;
  3619. }
  3620. }
  3621. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3622. if (!privateSet.has(receiver)) {
  3623. throw new TypeError('attempted to get private field on non-instance');
  3624. }
  3625. return fn;
  3626. }
  3627. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3628. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3629. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3630. }
  3631. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3632. if (!privateMap.has(receiver)) {
  3633. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3634. }
  3635. return privateMap.get(receiver);
  3636. }
  3637. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3638. if (descriptor.get) {
  3639. return descriptor.get.call(receiver);
  3640. }
  3641. return descriptor.value;
  3642. }
  3643. const Vk_defaultTasksTemplate = {
  3644. names: []
  3645. };
  3646. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3647. var _username = new WeakMap();
  3648. var Vk_cache = new WeakMap();
  3649. var Vk_initialized = new WeakMap();
  3650. var Vk_verifyAuth = new WeakSet();
  3651. var _toggleGroup = new WeakSet();
  3652. var _togglePublic = new WeakSet();
  3653. var _sendWall = new WeakSet();
  3654. var _deleteWall = new WeakSet();
  3655. var _getId = new WeakSet();
  3656. var _toggleVk = new WeakSet();
  3657. var Vk_setCache = new WeakSet();
  3658. class Vk extends social_Social {
  3659. constructor() {
  3660. var _GM_getValue;
  3661. super(...arguments);
  3662. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3663. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3664. Vk_classPrivateMethodInitSpec(this, _getId);
  3665. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3666. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3667. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3668. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3669. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3670. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3671. Vk_defineProperty(this, 'whiteList', {
  3672. ...JSON.parse(Vk_defaultTasks),
  3673. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3674. });
  3675. Vk_classPrivateFieldInitSpec(this, _username, {
  3676. writable: true,
  3677. value: ''
  3678. });
  3679. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3680. writable: true,
  3681. value: GM_getValue('vkCache') || {}
  3682. });
  3683. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3684. writable: true,
  3685. value: false
  3686. });
  3687. }
  3688. async init() {
  3689. try {
  3690. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3691. return true;
  3692. }
  3693. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3694. if (isVerified) {
  3695. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3696. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3697. return true;
  3698. }
  3699. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3700. return false;
  3701. } catch (error) {
  3702. throwError(error, 'Vk.init');
  3703. return false;
  3704. }
  3705. }
  3706. async toggle(_ref) {
  3707. let {
  3708. doTask = true,
  3709. nameLinks = []
  3710. } = _ref;
  3711. try {
  3712. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3713. scripts_echoLog({
  3714. text: i18n('needInit')
  3715. });
  3716. return false;
  3717. }
  3718. const prom = [];
  3719. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3720. scripts_echoLog({
  3721. type: 'globalOptionsSkip',
  3722. text: 'vk.names'
  3723. });
  3724. } else {
  3725. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3726. var _link$match;
  3727. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3728. });
  3729. if (realNames.length > 0) {
  3730. for (const name of realNames) {
  3731. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3732. name: name,
  3733. doTask: doTask
  3734. }));
  3735. await delay(1e3);
  3736. }
  3737. }
  3738. }
  3739. return Promise.all(prom).then(() => true);
  3740. } catch (error) {
  3741. throwError(error, 'Vk.toggle');
  3742. return false;
  3743. }
  3744. }
  3745. }
  3746. async function Vk_verifyAuth2() {
  3747. try {
  3748. const logStatus = scripts_echoLog({
  3749. text: i18n('verifyAuth', 'Vk')
  3750. });
  3751. const {
  3752. result,
  3753. statusText,
  3754. status,
  3755. data
  3756. } = await tools_httpRequest({
  3757. url: 'https://vk.com/im',
  3758. method: 'GET'
  3759. });
  3760. if (result === 'Success') {
  3761. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3762. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3763. return false;
  3764. }
  3765. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3766. var _data$responseText$ma;
  3767. 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]) || '');
  3768. logStatus.success();
  3769. return true;
  3770. }
  3771. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3772. return false;
  3773. }
  3774. logStatus.error(`${result}:${statusText}(${status})`);
  3775. return false;
  3776. } catch (error) {
  3777. throwError(error, 'Vk.verifyAuth');
  3778. return false;
  3779. }
  3780. }
  3781. async function _toggleGroup2(name, dataParam) {
  3782. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3783. try {
  3784. const logStatus = scripts_echoLog({
  3785. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3786. text: name
  3787. });
  3788. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3789. logStatus.success();
  3790. return true;
  3791. }
  3792. const reqData = {
  3793. act: doTask ? 'enter' : 'leave',
  3794. al: 1,
  3795. gid: dataParam.groupId,
  3796. hash: dataParam.groupHash
  3797. };
  3798. if (doTask) {
  3799. reqData.context = '_';
  3800. }
  3801. const {
  3802. result,
  3803. statusText,
  3804. status,
  3805. data
  3806. } = await tools_httpRequest({
  3807. url: 'https://vk.com/al_groups.php',
  3808. method: 'POST',
  3809. headers: {
  3810. origin: 'https://vk.com',
  3811. referer: `https://vk.com/${name}`,
  3812. 'content-type': 'application/x-www-form-urlencoded'
  3813. },
  3814. data: $.param(reqData)
  3815. });
  3816. if (result === 'Success') {
  3817. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3818. logStatus.success();
  3819. if (doTask) {
  3820. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3821. }
  3822. return true;
  3823. }
  3824. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3825. return false;
  3826. }
  3827. logStatus.error(`${result}:${statusText}(${status})`);
  3828. return false;
  3829. } catch (error) {
  3830. throwError(error, 'Vk.toggleGroup');
  3831. return false;
  3832. }
  3833. }
  3834. async function _togglePublic2(name, dataParam) {
  3835. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3836. try {
  3837. const logStatus = scripts_echoLog({
  3838. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3839. text: name
  3840. });
  3841. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3842. logStatus.success();
  3843. return true;
  3844. }
  3845. const {
  3846. result,
  3847. statusText,
  3848. status,
  3849. data
  3850. } = await tools_httpRequest({
  3851. url: 'https://vk.com/al_public.php',
  3852. method: 'POST',
  3853. headers: {
  3854. origin: 'https://vk.com',
  3855. referer: `https://vk.com/${name}`,
  3856. 'content-type': 'application/x-www-form-urlencoded'
  3857. },
  3858. data: $.param({
  3859. act: doTask ? 'a_enter' : 'a_leave',
  3860. al: 1,
  3861. pid: dataParam.publicPid,
  3862. hash: dataParam.publicHash
  3863. })
  3864. });
  3865. if (result === 'Success') {
  3866. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3867. logStatus.success();
  3868. if (doTask) {
  3869. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3870. }
  3871. return true;
  3872. }
  3873. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3874. return false;
  3875. }
  3876. logStatus.error(`${result}:${statusText}(${status})`);
  3877. return false;
  3878. } catch (error) {
  3879. throwError(error, 'Vk.togglePublic');
  3880. return false;
  3881. }
  3882. }
  3883. async function _sendWall2(name) {
  3884. try {
  3885. const logStatus = scripts_echoLog({
  3886. type: 'sendingVkWall',
  3887. text: name
  3888. });
  3889. const {
  3890. result,
  3891. statusText,
  3892. status,
  3893. data
  3894. } = await tools_httpRequest({
  3895. url: 'https://vk.com/like.php',
  3896. method: 'POST',
  3897. headers: {
  3898. origin: 'https://vk.com',
  3899. referer: `https://vk.com/${name}`,
  3900. 'content-type': 'application/x-www-form-urlencoded'
  3901. },
  3902. data: $.param({
  3903. act: 'publish_box',
  3904. al: 1,
  3905. object: name
  3906. })
  3907. });
  3908. if (result === 'Success') {
  3909. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3910. var _data$responseText$ma2;
  3911. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3912. if (hash) {
  3913. const {
  3914. result: resultR,
  3915. statusText: statusTextR,
  3916. status: statusR,
  3917. data: dataR
  3918. } = await tools_httpRequest({
  3919. url: 'https://vk.com/like.php',
  3920. method: 'POST',
  3921. headers: {
  3922. origin: 'https://vk.com',
  3923. referer: `https://vk.com/${name}`,
  3924. 'content-type': 'application/x-www-form-urlencoded'
  3925. },
  3926. data: $.param({
  3927. Message: '',
  3928. act: 'a_do_publish',
  3929. al: 1,
  3930. close_comments: 0,
  3931. friends_only: 0,
  3932. from: 'box',
  3933. hash: hash,
  3934. list: '',
  3935. mark_as_ads: 0,
  3936. mute_notifications: 0,
  3937. object: name,
  3938. ret_data: 1,
  3939. to: 0
  3940. })
  3941. });
  3942. if (resultR === 'Success') {
  3943. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3944. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3945. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3946. 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) {
  3947. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3948. logStatus.success();
  3949. 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);
  3950. 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);
  3951. if (postId && ownerId) {
  3952. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3953. }
  3954. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3955. return true;
  3956. }
  3957. }
  3958. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3959. return false;
  3960. }
  3961. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3962. return false;
  3963. }
  3964. logStatus.error('Error: Get "hash" failed');
  3965. return false;
  3966. }
  3967. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3968. return false;
  3969. }
  3970. logStatus.error(`${result}:${statusText}(${status})`);
  3971. return false;
  3972. } catch (error) {
  3973. throwError(error, 'Vk.sendWall');
  3974. return false;
  3975. }
  3976. }
  3977. async function _deleteWall2(name, dataParams) {
  3978. try {
  3979. const logStatus = scripts_echoLog({
  3980. type: 'deletingVkWall',
  3981. text: name
  3982. });
  3983. const {
  3984. result,
  3985. statusText,
  3986. status,
  3987. data
  3988. } = await tools_httpRequest({
  3989. url: 'https://vk.com/al_wall.php?act=delete',
  3990. method: 'POST',
  3991. headers: {
  3992. origin: 'https://vk.com',
  3993. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3994. 'content-type': 'application/x-www-form-urlencoded'
  3995. },
  3996. data: $.param({
  3997. act: 'delete',
  3998. al: 1,
  3999. confirm: 0,
  4000. from: 'wkview',
  4001. hash: dataParams.wallHash,
  4002. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  4003. })
  4004. });
  4005. if (result === 'Success') {
  4006. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4007. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  4008. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  4009. 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]) {
  4010. logStatus.success();
  4011. return true;
  4012. }
  4013. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4014. return false;
  4015. }
  4016. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4017. return false;
  4018. }
  4019. logStatus.error(`${result}:${statusText}(${status})`);
  4020. return false;
  4021. } catch (error) {
  4022. throwError(error, 'Vk.deleteWall');
  4023. return false;
  4024. }
  4025. }
  4026. async function _getId2(name, doTask) {
  4027. try {
  4028. let url = `https://vk.com/${name}`;
  4029. if (/^wall-/.test(name)) {
  4030. if (doTask) {
  4031. return {
  4032. type: 'sendWall'
  4033. };
  4034. }
  4035. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  4036. return {
  4037. type: 'unSupport'
  4038. };
  4039. }
  4040. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  4041. }
  4042. const logStatus = scripts_echoLog({
  4043. type: 'gettingVkId',
  4044. text: name
  4045. });
  4046. const {
  4047. result,
  4048. statusText,
  4049. status,
  4050. data
  4051. } = await tools_httpRequest({
  4052. url: url,
  4053. method: 'GET'
  4054. });
  4055. if (result === 'Success') {
  4056. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4057. var _data$responseText$ma3, _data$responseText$ma4;
  4058. const [ , groupAct, groupId, , groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), (&#39;|')(.*?)(&#39;|')/) || [];
  4059. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4060. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4061. const publicJoined = !data.responseText.includes('Public.subscribe');
  4062. if (groupAct && groupId && groupHash) {
  4063. logStatus.success();
  4064. return {
  4065. groupAct: groupAct,
  4066. groupId: groupId,
  4067. groupHash: groupHash,
  4068. type: 'group'
  4069. };
  4070. } else if (publicHash && publicPid) {
  4071. logStatus.success();
  4072. return {
  4073. publicHash: publicHash,
  4074. publicPid: publicPid,
  4075. publicJoined: publicJoined,
  4076. type: 'public'
  4077. };
  4078. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4079. var _data$responseText$ma5;
  4080. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4081. if (wallHash) {
  4082. logStatus.success();
  4083. return {
  4084. type: 'deleteWall',
  4085. wallHash: wallHash
  4086. };
  4087. }
  4088. } else if (name.includes('wall') && doTask) {
  4089. logStatus.success();
  4090. return {
  4091. type: 'sendWall'
  4092. };
  4093. }
  4094. logStatus.error('Error: Parameters not found!');
  4095. return false;
  4096. }
  4097. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4098. return false;
  4099. }
  4100. logStatus.error(`${result}:${statusText}(${status})`);
  4101. return false;
  4102. } catch (error) {
  4103. throwError(error, 'Vk.getId');
  4104. return false;
  4105. }
  4106. }
  4107. async function _toggleVk2(_ref2) {
  4108. let {
  4109. name,
  4110. doTask = true
  4111. } = _ref2;
  4112. try {
  4113. if (!doTask && this.whiteList.names.includes(name)) {
  4114. scripts_echoLog({
  4115. type: 'whiteList',
  4116. text: 'Vk.undoTask',
  4117. id: name
  4118. });
  4119. return true;
  4120. }
  4121. const formatName = name.replace(/\/$/, '');
  4122. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4123. if (!data) {
  4124. return false;
  4125. }
  4126. switch (data.type) {
  4127. case 'group':
  4128. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4129.  
  4130. case 'public':
  4131. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4132.  
  4133. case 'sendWall':
  4134. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4135.  
  4136. case 'deleteWall':
  4137. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4138.  
  4139. default:
  4140. return false;
  4141. }
  4142. } catch (error) {
  4143. throwError(error, 'Vk.toggleVk');
  4144. return false;
  4145. }
  4146. }
  4147. function Vk_setCache2(name, postId) {
  4148. try {
  4149. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4150. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4151. } catch (error) {
  4152. throwError(error, 'Vk.setCache');
  4153. }
  4154. }
  4155. const social_Vk = Vk;
  4156. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4157. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4158. privateSet.add(obj);
  4159. }
  4160. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4161. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4162. privateMap.set(obj, value);
  4163. }
  4164. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4165. if (privateCollection.has(obj)) {
  4166. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4167. }
  4168. }
  4169. function Youtube_defineProperty(obj, key, value) {
  4170. if (key in obj) {
  4171. Object.defineProperty(obj, key, {
  4172. value: value,
  4173. enumerable: true,
  4174. configurable: true,
  4175. writable: true
  4176. });
  4177. } else {
  4178. obj[key] = value;
  4179. }
  4180. return obj;
  4181. }
  4182. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4183. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4184. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4185. return value;
  4186. }
  4187. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4188. if (descriptor.set) {
  4189. descriptor.set.call(receiver, value);
  4190. } else {
  4191. if (!descriptor.writable) {
  4192. throw new TypeError('attempted to set read only private field');
  4193. }
  4194. descriptor.value = value;
  4195. }
  4196. }
  4197. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4198. if (!privateSet.has(receiver)) {
  4199. throw new TypeError('attempted to get private field on non-instance');
  4200. }
  4201. return fn;
  4202. }
  4203. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4204. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4205. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4206. }
  4207. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4208. if (!privateMap.has(receiver)) {
  4209. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4210. }
  4211. return privateMap.get(receiver);
  4212. }
  4213. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4214. if (descriptor.get) {
  4215. return descriptor.get.call(receiver);
  4216. }
  4217. return descriptor.value;
  4218. }
  4219. const Youtube_defaultTasksTemplate = {
  4220. channels: [],
  4221. likes: []
  4222. };
  4223. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4224. const getInfo = async function(link, type) {
  4225. try {
  4226. const logStatus = scripts_echoLog({
  4227. text: i18n('gettingYtbToken')
  4228. });
  4229. const {
  4230. result,
  4231. statusText,
  4232. status,
  4233. data
  4234. } = await tools_httpRequest({
  4235. url: link,
  4236. method: 'GET'
  4237. });
  4238. if (result === 'Success') {
  4239. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4240. var _data$responseText$ma, _ref;
  4241. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4242. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4243. return {
  4244. needLogin: true
  4245. };
  4246. }
  4247. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4248. 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]) || '{}';
  4249. const {
  4250. client,
  4251. request
  4252. } = JSON.parse(context);
  4253. if (apiKey && client && request) {
  4254. client.hl = 'en';
  4255. if (type === 'channel') {
  4256. var _data$responseText$ma2;
  4257. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4258. if (channelId) {
  4259. logStatus.success();
  4260. return {
  4261. params: {
  4262. apiKey: apiKey,
  4263. client: client,
  4264. request: request,
  4265. channelId: channelId
  4266. }
  4267. };
  4268. }
  4269. logStatus.error('Error: Get "channelId" failed!');
  4270. return {};
  4271. } else if (type === 'likeVideo') {
  4272. var _data$responseText$ma3, _data$responseText$ma4;
  4273. 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];
  4274. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4275. if (videoId) {
  4276. logStatus.success();
  4277. return {
  4278. params: {
  4279. apiKey: apiKey,
  4280. client: client,
  4281. request: request,
  4282. videoId: videoId,
  4283. likeParams: likeParams
  4284. }
  4285. };
  4286. }
  4287. logStatus.error('Error: Get "videoId" failed!');
  4288. return {};
  4289. }
  4290. logStatus.error('Error: Unknown type');
  4291. return {};
  4292. }
  4293. logStatus.error('Error: Parameter "apiKey" not found!');
  4294. return {};
  4295. }
  4296. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4297. return {};
  4298. }
  4299. logStatus.error(`${result}:${statusText}(${status})`);
  4300. return {};
  4301. } catch (error) {
  4302. throwError(error, 'Youtube.getInfo');
  4303. return {};
  4304. }
  4305. };
  4306. var Youtube_auth = new WeakMap();
  4307. var Youtube_initialized = new WeakMap();
  4308. var _verifyChannel = new WeakMap();
  4309. var Youtube_verifyAuth = new WeakSet();
  4310. var Youtube_updateAuth = new WeakSet();
  4311. var _getInfo = new WeakSet();
  4312. var Youtube_toggleChannel = new WeakSet();
  4313. var _toggleLikeVideo = new WeakSet();
  4314. class Youtube extends social_Social {
  4315. constructor() {
  4316. var _GM_getValue;
  4317. super(...arguments);
  4318. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4319. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4320. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4321. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4322. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4323. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4324. Youtube_defineProperty(this, 'whiteList', {
  4325. ...JSON.parse(Youtube_defaultTasks),
  4326. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4327. });
  4328. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4329. writable: true,
  4330. value: GM_getValue('youtubeAuth') || {}
  4331. });
  4332. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4333. writable: true,
  4334. value: false
  4335. });
  4336. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4337. writable: true,
  4338. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4339. });
  4340. }
  4341. async init() {
  4342. try {
  4343. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4344. return true;
  4345. }
  4346. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4347. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4348. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4349. return true;
  4350. }
  4351. return false;
  4352. }
  4353. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4354. if (isVerified) {
  4355. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4356. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4357. return true;
  4358. }
  4359. GM_setValue('youtubeAuth', null);
  4360. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4361. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4362. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4363. return true;
  4364. }
  4365. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4366. return false;
  4367. } catch (error) {
  4368. throwError(error, 'Youtube.init');
  4369. return false;
  4370. }
  4371. }
  4372. async toggle(_ref2) {
  4373. let {
  4374. doTask = true,
  4375. channelLinks = [],
  4376. videoLinks = []
  4377. } = _ref2;
  4378. try {
  4379. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4380. scripts_echoLog({
  4381. text: i18n('needInit')
  4382. });
  4383. return false;
  4384. }
  4385. const prom = [];
  4386. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4387. scripts_echoLog({
  4388. type: 'globalOptionsSkip',
  4389. text: 'youtube.channels'
  4390. });
  4391. } else {
  4392. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4393. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4394. var _link$match;
  4395. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4396. }
  4397. return link;
  4398. });
  4399. if (realChannels.length > 0) {
  4400. for (const channel of realChannels) {
  4401. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4402. link: channel,
  4403. doTask: doTask
  4404. }));
  4405. await delay(1e3);
  4406. }
  4407. }
  4408. }
  4409. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4410. scripts_echoLog({
  4411. type: 'globalOptionsSkip',
  4412. text: 'youtube.likes'
  4413. });
  4414. } else {
  4415. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4416. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4417. var _link$match2;
  4418. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4419. }
  4420. return link;
  4421. });
  4422. if (realLikes.length > 0) {
  4423. for (const video of realLikes) {
  4424. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4425. link: video,
  4426. doTask: doTask
  4427. }));
  4428. await delay(1e3);
  4429. }
  4430. }
  4431. }
  4432. return Promise.all(prom).then(() => true);
  4433. } catch (error) {
  4434. throwError(error, 'Youtube.toggle');
  4435. return false;
  4436. }
  4437. }
  4438. }
  4439. async function Youtube_verifyAuth2() {
  4440. try {
  4441. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4442. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4443. doTask: true,
  4444. verify: true
  4445. });
  4446. } catch (error) {
  4447. throwError(error, 'Youtube.verifyAuth');
  4448. return false;
  4449. }
  4450. }
  4451. async function Youtube_updateAuth2() {
  4452. try {
  4453. const logStatus = scripts_echoLog({
  4454. text: i18n('updatingAuth', 'Youtube')
  4455. });
  4456. return await new Promise(resolve => {
  4457. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4458. active: true,
  4459. insert: true,
  4460. setParent: true
  4461. });
  4462. newTab.onclose = async () => {
  4463. const auth = GM_getValue('youtubeAuth');
  4464. if (auth) {
  4465. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4466. logStatus.success();
  4467. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4468. resolve(result);
  4469. });
  4470. } else {
  4471. logStatus.error('Error: Update youtube auth failed!');
  4472. resolve(false);
  4473. }
  4474. };
  4475. });
  4476. } catch (error) {
  4477. throwError(error, 'Discord.updateAuth');
  4478. return false;
  4479. }
  4480. }
  4481. function _getInfo2(link, type) {
  4482. return getInfo(link, type);
  4483. }
  4484. async function Youtube_toggleChannel2(_ref3) {
  4485. let {
  4486. link,
  4487. doTask = true,
  4488. verify = false
  4489. } = _ref3;
  4490. try {
  4491. const {
  4492. params,
  4493. needLogin
  4494. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4495. const {
  4496. apiKey,
  4497. client,
  4498. request,
  4499. channelId
  4500. } = params || {};
  4501. if (needLogin) {
  4502. scripts_echoLog({
  4503. html: i18n('loginYtb')
  4504. });
  4505. return false;
  4506. }
  4507. if (!(apiKey && client && request && channelId)) {
  4508. scripts_echoLog({
  4509. text: '"getYtbToken" failed'
  4510. });
  4511. return false;
  4512. }
  4513. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4514. scripts_echoLog({
  4515. type: 'whiteList',
  4516. text: 'Youtube.unfollowChannel',
  4517. id: channelId
  4518. });
  4519. return true;
  4520. }
  4521. const logStatus = verify ? scripts_echoLog({
  4522. text: i18n('verifyingAuth', 'Youtube')
  4523. }) : scripts_echoLog({
  4524. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4525. text: channelId
  4526. });
  4527. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4528. const {
  4529. result,
  4530. statusText,
  4531. status,
  4532. data
  4533. } = await tools_httpRequest({
  4534. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4535. method: 'POST',
  4536. headers: {
  4537. origin: 'https://www.youtube.com',
  4538. referer: `https://www.youtube.com/channel/${channelId}`,
  4539. 'content-type': 'application/json',
  4540. 'x-goog-authuser': '0',
  4541. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4542. 'x-origin': 'https://www.youtube.com',
  4543. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4544. },
  4545. data: JSON.stringify({
  4546. context: {
  4547. client: client,
  4548. request: {
  4549. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4550. internalExperimentFlags: [],
  4551. consistencyTokenJars: []
  4552. },
  4553. user: {}
  4554. },
  4555. channelIds: [ channelId ],
  4556. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4557. })
  4558. });
  4559. if (result === 'Success') {
  4560. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4561. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4562. logStatus.success();
  4563. if (doTask && !verify) {
  4564. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4565. }
  4566. return true;
  4567. }
  4568. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4569. logStatus.success();
  4570. return true;
  4571. }
  4572. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4573. return false;
  4574. }
  4575. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4576. return false;
  4577. }
  4578. logStatus.error(`${result}:${statusText}(${status})`);
  4579. return false;
  4580. } catch (error) {
  4581. throwError(error, 'Youtube.toggleChannel');
  4582. return false;
  4583. }
  4584. }
  4585. async function _toggleLikeVideo2(_ref4) {
  4586. let {
  4587. link,
  4588. doTask = true
  4589. } = _ref4;
  4590. try {
  4591. const {
  4592. params,
  4593. needLogin
  4594. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4595. const {
  4596. apiKey,
  4597. client,
  4598. request,
  4599. videoId,
  4600. likeParams
  4601. } = params || {};
  4602. if (needLogin) {
  4603. scripts_echoLog({
  4604. html: `${i18n('loginYtb')}`
  4605. });
  4606. return false;
  4607. }
  4608. if (!(apiKey && client && request && videoId && likeParams)) {
  4609. scripts_echoLog({
  4610. text: '"getYtbToken" failed'
  4611. });
  4612. return false;
  4613. }
  4614. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4615. scripts_echoLog({
  4616. type: 'whiteList',
  4617. text: 'Youtube.unlikeVideo',
  4618. id: videoId
  4619. });
  4620. return true;
  4621. }
  4622. const logStatus = scripts_echoLog({
  4623. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4624. text: videoId
  4625. });
  4626. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4627. const likeVideoData = {
  4628. context: {
  4629. client: client,
  4630. request: {
  4631. sessionId: request.sessionId,
  4632. internalExperimentFlags: [],
  4633. consistencyTokenJars: []
  4634. },
  4635. user: {}
  4636. },
  4637. target: {
  4638. videoId: videoId
  4639. }
  4640. };
  4641. if (doTask) {
  4642. if (likeParams) {
  4643. likeVideoData.params = likeParams;
  4644. } else {
  4645. logStatus.error('Empty likeParams');
  4646. return false;
  4647. }
  4648. }
  4649. const {
  4650. result,
  4651. statusText,
  4652. status,
  4653. data
  4654. } = await tools_httpRequest({
  4655. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4656. method: 'POST',
  4657. headers: {
  4658. origin: 'https://www.youtube.com',
  4659. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4660. 'content-type': 'application/json',
  4661. 'x-goog-authuser': '0',
  4662. 'x-goog-visitor-id': client.visitorData,
  4663. 'x-origin': 'https://www.youtube.com',
  4664. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4665. },
  4666. data: JSON.stringify(likeVideoData)
  4667. });
  4668. if (result === 'Success') {
  4669. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4670. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4671. logStatus.success();
  4672. if (doTask) {
  4673. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4674. }
  4675. return true;
  4676. }
  4677. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4678. return false;
  4679. }
  4680. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4681. return false;
  4682. }
  4683. logStatus.error(`${result}:${statusText}(${status})`);
  4684. return false;
  4685. } catch (error) {
  4686. throwError(error, 'Youtube.toggleLikeVideo');
  4687. return false;
  4688. }
  4689. }
  4690. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4691. Steam_checkPrivateRedeclaration(obj, privateSet);
  4692. privateSet.add(obj);
  4693. }
  4694. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4695. Steam_checkPrivateRedeclaration(obj, privateMap);
  4696. privateMap.set(obj, value);
  4697. }
  4698. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4699. if (privateCollection.has(obj)) {
  4700. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4701. }
  4702. }
  4703. function Steam_defineProperty(obj, key, value) {
  4704. if (key in obj) {
  4705. Object.defineProperty(obj, key, {
  4706. value: value,
  4707. enumerable: true,
  4708. configurable: true,
  4709. writable: true
  4710. });
  4711. } else {
  4712. obj[key] = value;
  4713. }
  4714. return obj;
  4715. }
  4716. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4717. if (!privateSet.has(receiver)) {
  4718. throw new TypeError('attempted to get private field on non-instance');
  4719. }
  4720. return fn;
  4721. }
  4722. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4723. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4724. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4725. return value;
  4726. }
  4727. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4728. if (descriptor.set) {
  4729. descriptor.set.call(receiver, value);
  4730. } else {
  4731. if (!descriptor.writable) {
  4732. throw new TypeError('attempted to set read only private field');
  4733. }
  4734. descriptor.value = value;
  4735. }
  4736. }
  4737. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4738. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4739. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4740. }
  4741. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4742. if (!privateMap.has(receiver)) {
  4743. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4744. }
  4745. return privateMap.get(receiver);
  4746. }
  4747. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4748. if (descriptor.get) {
  4749. return descriptor.get.call(receiver);
  4750. }
  4751. return descriptor.value;
  4752. }
  4753. const Steam_defaultTasksTemplate = {
  4754. groups: [],
  4755. officialGroups: [],
  4756. wishlists: [],
  4757. follows: [],
  4758. forums: [],
  4759. workshops: [],
  4760. workshopVotes: [],
  4761. curators: [],
  4762. curatorLikes: [],
  4763. announcements: [],
  4764. licenses: [],
  4765. playtests: []
  4766. };
  4767. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4768. var Steam_cache = new WeakMap();
  4769. var Steam_auth = new WeakMap();
  4770. var _storeInitialized = new WeakMap();
  4771. var _communityInitialized = new WeakMap();
  4772. var _area = new WeakMap();
  4773. var _areaStatus = new WeakMap();
  4774. var _updateStoreAuth = new WeakSet();
  4775. var _updateCommunityAuth = new WeakSet();
  4776. var _getAreaInfo = new WeakSet();
  4777. var _changeArea = new WeakSet();
  4778. var _joinGroup = new WeakSet();
  4779. var _leaveGroup = new WeakSet();
  4780. var _getGroupId = new WeakSet();
  4781. var _joinOfficialGroup = new WeakSet();
  4782. var _leaveOfficialGroup = new WeakSet();
  4783. var _getOfficialGroupId = new WeakSet();
  4784. var _addToWishlist = new WeakSet();
  4785. var _removeFromWishlist = new WeakSet();
  4786. var _toggleFollowGame = new WeakSet();
  4787. var _isFollowedGame = new WeakSet();
  4788. var _toggleForum = new WeakSet();
  4789. var _getForumId = new WeakSet();
  4790. var _toggleFavoriteWorkshop = new WeakSet();
  4791. var _getWorkshopAppId = new WeakSet();
  4792. var _voteUpWorkshop = new WeakSet();
  4793. var _toggleCurator = new WeakSet();
  4794. var _toggleCuratorLike = new WeakSet();
  4795. var _getAnnouncementParams = new WeakSet();
  4796. var _likeAnnouncement = new WeakSet();
  4797. var _appid2subid = new WeakSet();
  4798. var _getLicenses = new WeakSet();
  4799. var _addLicense = new WeakSet();
  4800. var _addFreeLicense = new WeakSet();
  4801. var _requestPlayTestAccess = new WeakSet();
  4802. var Steam_setCache = new WeakSet();
  4803. class Steam extends social_Social {
  4804. constructor() {
  4805. var _GM_getValue;
  4806. super(...arguments);
  4807. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4808. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4809. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4810. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4811. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4812. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4813. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4814. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4815. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4816. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4817. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4818. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4819. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4820. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4821. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4822. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4823. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4824. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4825. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4826. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4827. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4828. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4829. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4830. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4831. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4832. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4833. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4834. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4835. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4836. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4837. Steam_defineProperty(this, 'whiteList', {
  4838. ...JSON.parse(Steam_defaultTasks),
  4839. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4840. });
  4841. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4842. writable: true,
  4843. value: {
  4844. ...{
  4845. group: {},
  4846. officialGroup: {},
  4847. forum: {},
  4848. workshop: {},
  4849. curator: {}
  4850. },
  4851. ...GM_getValue('steamCache')
  4852. }
  4853. });
  4854. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4855. writable: true,
  4856. value: {}
  4857. });
  4858. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4859. writable: true,
  4860. value: false
  4861. });
  4862. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4863. writable: true,
  4864. value: false
  4865. });
  4866. Steam_classPrivateFieldInitSpec(this, _area, {
  4867. writable: true,
  4868. value: 'CN'
  4869. });
  4870. Steam_classPrivateFieldInitSpec(this, _areaStatus, {
  4871. writable: true,
  4872. value: 'end'
  4873. });
  4874. }
  4875. async init() {
  4876. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4877. try {
  4878. if (type === 'store') {
  4879. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4880. return true;
  4881. }
  4882. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4883. if (!Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4884. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4885. return false;
  4886. }
  4887. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4888. return true;
  4889. }
  4890. if (type === 'community') {
  4891. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4892. return true;
  4893. }
  4894. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4895. if (!Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4896. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4897. return false;
  4898. }
  4899. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4900. return true;
  4901. }
  4902. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4903. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4904. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4905. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4906. return true;
  4907. }
  4908. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4909. return false;
  4910. } catch (error) {
  4911. throwError(error, 'Steam.init');
  4912. return false;
  4913. }
  4914. }
  4915. async getCuratorId(path, name) {
  4916. try {
  4917. const logStatus = scripts_echoLog({
  4918. type: 'gettingCuratorId',
  4919. text: `${path}/${name}`
  4920. });
  4921. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4922. if (curatorId) {
  4923. logStatus.success();
  4924. return curatorId;
  4925. }
  4926. const {
  4927. result,
  4928. statusText,
  4929. status,
  4930. data
  4931. } = await tools_httpRequest({
  4932. url: `https://store.steampowered.com/${path}/${name}`,
  4933. method: 'GET',
  4934. headers: {
  4935. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4936. }
  4937. });
  4938. if (result === 'Success') {
  4939. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4940. var _data$responseText$ma;
  4941. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4942. if (curatorId) {
  4943. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4944. logStatus.success();
  4945. return curatorId;
  4946. }
  4947. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4948. return false;
  4949. }
  4950. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4951. return false;
  4952. }
  4953. logStatus.error(`${result}:${statusText}(${status})`);
  4954. return false;
  4955. } catch (error) {
  4956. throwError(error, 'Steam.getCuratorID');
  4957. return false;
  4958. }
  4959. }
  4960. async toggle(_ref) {
  4961. let {
  4962. doTask = true,
  4963. groupLinks = [],
  4964. officialGroupLinks = [],
  4965. wishlistLinks = [],
  4966. followLinks = [],
  4967. forumLinks = [],
  4968. workshopLinks = [],
  4969. workshopVoteLinks = [],
  4970. curatorLinks = [],
  4971. curatorLikeLinks = [],
  4972. announcementLinks = [],
  4973. licenseLinks = [],
  4974. playtestLinks = []
  4975. } = _ref;
  4976. try {
  4977. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4978. scripts_echoLog({
  4979. text: i18n('needInit')
  4980. });
  4981. return false;
  4982. }
  4983. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4984. scripts_echoLog({
  4985. text: i18n('needInit')
  4986. });
  4987. return false;
  4988. }
  4989. const prom = [];
  4990. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4991. scripts_echoLog({
  4992. type: 'globalOptionsSkip',
  4993. text: 'steam.groups'
  4994. });
  4995. } else {
  4996. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4997. var _link$match;
  4998. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4999. });
  5000. if (realGroups.length > 0) {
  5001. for (const group of realGroups) {
  5002. if (doTask) {
  5003. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  5004. } else {
  5005. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  5006. }
  5007. await delay(1e3);
  5008. }
  5009. }
  5010. }
  5011. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  5012. scripts_echoLog({
  5013. type: 'globalOptionsSkip',
  5014. text: 'steam.officialGroups'
  5015. });
  5016. } else {
  5017. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  5018. var _link$match2;
  5019. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  5020. });
  5021. if (realOfficialGroups.length > 0) {
  5022. for (const officialGroup of realOfficialGroups) {
  5023. if (doTask) {
  5024. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  5025. } else {
  5026. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  5027. }
  5028. await delay(1e3);
  5029. }
  5030. }
  5031. }
  5032. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  5033. scripts_echoLog({
  5034. type: 'globalOptionsSkip',
  5035. text: 'steam.wishlists'
  5036. });
  5037. } else {
  5038. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  5039. var _link$match3;
  5040. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5041. });
  5042. if (realWishlists.length > 0) {
  5043. for (const game of realWishlists) {
  5044. if (doTask) {
  5045. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  5046. } else {
  5047. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  5048. }
  5049. await delay(1e3);
  5050. }
  5051. }
  5052. }
  5053. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5054. scripts_echoLog({
  5055. type: 'globalOptionsSkip',
  5056. text: 'steam.follows'
  5057. });
  5058. } else {
  5059. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5060. var _link$match4;
  5061. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5062. });
  5063. if (realFollows.length > 0) {
  5064. for (const game of realFollows) {
  5065. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  5066. await delay(1e3);
  5067. }
  5068. }
  5069. }
  5070. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5071. scripts_echoLog({
  5072. type: 'globalOptionsSkip',
  5073. text: 'steam.forums'
  5074. });
  5075. } else {
  5076. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5077. var _link$match5;
  5078. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5079. });
  5080. if (realForums.length > 0) {
  5081. for (const forum of realForums) {
  5082. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5083. await delay(1e3);
  5084. }
  5085. }
  5086. }
  5087. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5088. scripts_echoLog({
  5089. type: 'globalOptionsSkip',
  5090. text: 'steam.workshops'
  5091. });
  5092. } else {
  5093. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5094. var _link$match6;
  5095. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5096. });
  5097. if (realWorkshops.length > 0) {
  5098. for (const workshop of realWorkshops) {
  5099. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5100. await delay(1e3);
  5101. }
  5102. }
  5103. }
  5104. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5105. scripts_echoLog({
  5106. type: 'globalOptionsSkip',
  5107. text: 'steam.workshopVotes'
  5108. });
  5109. } else {
  5110. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5111. var _link$match7;
  5112. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5113. });
  5114. if (doTask && realworkshopVotes.length > 0) {
  5115. for (const workshop of realworkshopVotes) {
  5116. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5117. await delay(1e3);
  5118. }
  5119. }
  5120. }
  5121. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5122. scripts_echoLog({
  5123. type: 'globalOptionsSkip',
  5124. text: 'steam.curators'
  5125. });
  5126. } else {
  5127. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5128. var _link$match8;
  5129. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5130. });
  5131. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5132. var _link$match9;
  5133. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5134. });
  5135. if (realCurators.length > 0) {
  5136. for (const curator of realCurators) {
  5137. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5138. await delay(1e3);
  5139. }
  5140. }
  5141. if (realCuratorLikes.length > 0) {
  5142. for (const curatorLike of realCuratorLikes) {
  5143. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5144. await delay(1e3);
  5145. }
  5146. }
  5147. }
  5148. if (doTask && !globalOptions.doTask.steam.announcements) {
  5149. scripts_echoLog({
  5150. type: 'globalOptionsSkip',
  5151. text: 'steam.announcements'
  5152. });
  5153. } else {
  5154. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5155. var _link$match11;
  5156. if (link.includes('store.steampowered.com')) {
  5157. var _link$match10;
  5158. 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('/');
  5159. }
  5160. 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('/');
  5161. });
  5162. if (doTask && realAnnouncements.length > 0) {
  5163. for (const id of realAnnouncements) {
  5164. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5165. await delay(1e3);
  5166. }
  5167. }
  5168. }
  5169. if (doTask && !globalOptions.doTask.steam.licenses) {
  5170. scripts_echoLog({
  5171. type: 'globalOptionsSkip',
  5172. text: 'steam.licenses'
  5173. });
  5174. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5175. for (const id of licenseLinks) {
  5176. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5177. await delay(1e3);
  5178. }
  5179. }
  5180. if (doTask && !globalOptions.doTask.steam.playtests) {
  5181. scripts_echoLog({
  5182. type: 'globalOptionsSkip',
  5183. text: 'steam.playtests'
  5184. });
  5185. } else {
  5186. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5187. var _link$match12;
  5188. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5189. });
  5190. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5191. for (const id of realPlaytests) {
  5192. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5193. await delay(1e3);
  5194. }
  5195. }
  5196. }
  5197. return Promise.all(prom).then(async () => {
  5198. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5199. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5200. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5201. }
  5202. return true;
  5203. });
  5204. } catch (error) {
  5205. throwError(error, 'Steam.toggle');
  5206. return false;
  5207. }
  5208. }
  5209. }
  5210. async function _updateStoreAuth2() {
  5211. try {
  5212. const logStatus = scripts_echoLog({
  5213. text: i18n('updatingAuth', i18n('steamStore'))
  5214. });
  5215. const {
  5216. result,
  5217. statusText,
  5218. status,
  5219. data
  5220. } = await tools_httpRequest({
  5221. url: 'https://store.steampowered.com/stats/',
  5222. method: 'GET'
  5223. });
  5224. if (result === 'Success') {
  5225. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5226. var _data$responseText$ma2;
  5227. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5228. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5229. return false;
  5230. }
  5231. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5232. if (storeSessionID) {
  5233. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5234. logStatus.success();
  5235. return true;
  5236. }
  5237. logStatus.error('Error: Get "sessionID" failed');
  5238. return false;
  5239. }
  5240. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5241. return false;
  5242. }
  5243. logStatus.error(`${result}:${statusText}(${status})`);
  5244. return false;
  5245. } catch (error) {
  5246. throwError(error, 'Steam.updateStoreAuth');
  5247. return false;
  5248. }
  5249. }
  5250. async function _updateCommunityAuth2() {
  5251. try {
  5252. const logStatus = scripts_echoLog({
  5253. text: i18n('updatingAuth', i18n('steamCommunity'))
  5254. });
  5255. const {
  5256. result,
  5257. statusText,
  5258. status,
  5259. data
  5260. } = await tools_httpRequest({
  5261. url: 'https://steamcommunity.com/my',
  5262. method: 'GET'
  5263. });
  5264. if (result === 'Success') {
  5265. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5266. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5267. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5268. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5269. return false;
  5270. }
  5271. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5272. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5273. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5274. if (steam64Id) {
  5275. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5276. }
  5277. if (userName) {
  5278. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5279. }
  5280. if (communitySessionID) {
  5281. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5282. logStatus.success();
  5283. return true;
  5284. }
  5285. logStatus.error('Error: Get "sessionID" failed');
  5286. return false;
  5287. }
  5288. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5289. return false;
  5290. }
  5291. logStatus.error(`${result}:${statusText}(${status})`);
  5292. return false;
  5293. } catch (error) {
  5294. throwError(error, 'Steam.updateCommunityAuth');
  5295. return false;
  5296. }
  5297. }
  5298. async function _getAreaInfo2() {
  5299. try {
  5300. const logStatus = scripts_echoLog({
  5301. text: i18n('gettingAreaInfo')
  5302. });
  5303. const {
  5304. result,
  5305. statusText,
  5306. status,
  5307. data
  5308. } = await tools_httpRequest({
  5309. url: 'https://store.steampowered.com/cart/',
  5310. method: 'GET'
  5311. });
  5312. if (result === 'Success') {
  5313. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5314. var _data$responseText$ma6;
  5315. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5316. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5317. if (currentArea && areas.length > 0) {
  5318. Steam_classPrivateFieldSet(this, _area, currentArea);
  5319. logStatus.success();
  5320. return {
  5321. currentArea: currentArea,
  5322. areas: areas
  5323. };
  5324. }
  5325. logStatus.error('Error: get country info filed');
  5326. return {};
  5327. }
  5328. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5329. return {};
  5330. }
  5331. logStatus.error(`${result}:${statusText}(${status})`);
  5332. return {};
  5333. } catch (error) {
  5334. throwError(error, 'Steam.getAreaInfo');
  5335. return {};
  5336. }
  5337. }
  5338. async function _changeArea2(area) {
  5339. try {
  5340. if (Steam_classPrivateFieldGet(this, _areaStatus) === 'waiting') {
  5341. await new Promise(resolve => {
  5342. const checker = setInterval(() => {
  5343. if (Steam_classPrivateFieldGet(this, _areaStatus) !== 'waiting') {
  5344. clearInterval(checker);
  5345. resolve(true);
  5346. }
  5347. });
  5348. });
  5349. }
  5350. if (Steam_classPrivateFieldGet(this, _area) === area || !area && Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5351. return true;
  5352. }
  5353. Steam_classPrivateFieldSet(this, _areaStatus, 'waiting');
  5354. let aimedArea = area;
  5355. if (!aimedArea) {
  5356. const {
  5357. currentArea,
  5358. areas
  5359. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5360. if (!currentArea || !areas) {
  5361. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5362. return false;
  5363. }
  5364. if (currentArea !== 'CN') {
  5365. Steam_classPrivateFieldSet(this, _areaStatus, 'skip');
  5366. scripts_echoLog({
  5367. text: 'notNeededChangeArea'
  5368. });
  5369. return 'skip';
  5370. }
  5371. const anotherArea = areas.filter(area => area && area !== 'CN');
  5372. if (!anotherArea || anotherArea.length === 0) {
  5373. Steam_classPrivateFieldSet(this, _areaStatus, 'noAnotherArea');
  5374. scripts_echoLog({
  5375. text: 'noAnotherArea'
  5376. });
  5377. return false;
  5378. }
  5379. [ aimedArea ] = anotherArea;
  5380. }
  5381. const logStatus = scripts_echoLog({
  5382. text: i18n('changingArea', aimedArea)
  5383. });
  5384. const {
  5385. result,
  5386. statusText,
  5387. status,
  5388. data
  5389. } = await tools_httpRequest({
  5390. url: 'https://store.steampowered.com/account/setcountry',
  5391. method: 'POST',
  5392. headers: {
  5393. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5394. },
  5395. data: $.param({
  5396. cc: aimedArea,
  5397. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5398. })
  5399. });
  5400. if (result === 'Success') {
  5401. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5402. const {
  5403. currentArea
  5404. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5405. if (currentArea === aimedArea) {
  5406. Steam_classPrivateFieldSet(this, _areaStatus, 'success');
  5407. logStatus.success();
  5408. return currentArea;
  5409. }
  5410. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5411. logStatus.error('Error: change country filed');
  5412. return 'CN';
  5413. }
  5414. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5415. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5416. return 'CN';
  5417. }
  5418. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5419. logStatus.error(`${result}:${statusText}(${status})`);
  5420. return 'CN';
  5421. } catch (error) {
  5422. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5423. throwError(error, 'Steam.changeArea');
  5424. return false;
  5425. }
  5426. }
  5427. async function _joinGroup2(groupName) {
  5428. try {
  5429. const logStatus = scripts_echoLog({
  5430. type: 'joiningSteamGroup',
  5431. text: groupName
  5432. });
  5433. const {
  5434. result,
  5435. statusText,
  5436. status,
  5437. data
  5438. } = await tools_httpRequest({
  5439. url: `https://steamcommunity.com/groups/${groupName}`,
  5440. method: 'POST',
  5441. headers: {
  5442. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5443. },
  5444. data: $.param({
  5445. action: 'join',
  5446. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5447. })
  5448. });
  5449. if (result === 'Success') {
  5450. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5451. logStatus.success();
  5452. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5453. return true;
  5454. }
  5455. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5456. return false;
  5457. }
  5458. logStatus.error(`${result}:${statusText}(${status})`);
  5459. return false;
  5460. } catch (error) {
  5461. throwError(error, 'Steam.joinGroup');
  5462. return false;
  5463. }
  5464. }
  5465. async function _leaveGroup2(groupName) {
  5466. try {
  5467. if (this.whiteList.groups.includes(groupName)) {
  5468. scripts_echoLog({
  5469. type: 'whiteList',
  5470. text: 'Steam.leaveGroup',
  5471. id: groupName
  5472. });
  5473. return true;
  5474. }
  5475. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5476. if (!groupId) {
  5477. return false;
  5478. }
  5479. const logStatus = scripts_echoLog({
  5480. type: 'leavingSteamGroup',
  5481. text: groupName
  5482. });
  5483. const {
  5484. result,
  5485. statusText,
  5486. status,
  5487. data
  5488. } = await tools_httpRequest({
  5489. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5490. method: 'POST',
  5491. headers: {
  5492. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5493. },
  5494. data: $.param({
  5495. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5496. action: 'leaveGroup',
  5497. groupId: groupId
  5498. })
  5499. });
  5500. if (result === 'Success') {
  5501. 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) {
  5502. logStatus.success();
  5503. return true;
  5504. }
  5505. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5506. return false;
  5507. }
  5508. logStatus.error(`${result}:${statusText}(${status})`);
  5509. return false;
  5510. } catch (error) {
  5511. throwError(error, 'Steam.leaveGroup');
  5512. return false;
  5513. }
  5514. }
  5515. async function _getGroupId2(groupName) {
  5516. try {
  5517. const logStatus = scripts_echoLog({
  5518. type: 'gettingSteamGroupId',
  5519. text: groupName
  5520. });
  5521. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5522. if (groupId) {
  5523. logStatus.success();
  5524. return groupId;
  5525. }
  5526. const {
  5527. result,
  5528. statusText,
  5529. status,
  5530. data
  5531. } = await tools_httpRequest({
  5532. url: `https://steamcommunity.com/groups/${groupName}`,
  5533. method: 'GET',
  5534. headers: {
  5535. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5536. }
  5537. });
  5538. if (result === 'Success') {
  5539. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5540. var _data$responseText$ma7;
  5541. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5542. if (groupId) {
  5543. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5544. logStatus.success();
  5545. return groupId;
  5546. }
  5547. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5548. return false;
  5549. }
  5550. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5551. return false;
  5552. }
  5553. logStatus.error(`${result}:${statusText}(${status})`);
  5554. return false;
  5555. } catch (error) {
  5556. throwError(error, 'Steam.getGroupID');
  5557. return false;
  5558. }
  5559. }
  5560. async function _joinOfficialGroup2(gameId) {
  5561. try {
  5562. const logStatus = scripts_echoLog({
  5563. type: 'joiningSteamOfficialGroup',
  5564. text: gameId
  5565. });
  5566. const {
  5567. result,
  5568. statusText,
  5569. status,
  5570. data
  5571. } = await tools_httpRequest({
  5572. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5573. method: 'GET',
  5574. headers: {
  5575. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5576. }
  5577. });
  5578. if (result === 'Success') {
  5579. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5580. var _data$responseText$ma8;
  5581. logStatus.success();
  5582. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5583. 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];
  5584. if (groupId) {
  5585. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5586. }
  5587. return true;
  5588. }
  5589. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5590. return false;
  5591. }
  5592. logStatus.error(`${result}:${statusText}(${status})`);
  5593. return false;
  5594. } catch (error) {
  5595. throwError(error, 'Steam.joinOfficialGroup');
  5596. return false;
  5597. }
  5598. }
  5599. async function _leaveOfficialGroup2(gameId) {
  5600. try {
  5601. if (this.whiteList.officialGroups.includes(gameId)) {
  5602. scripts_echoLog({
  5603. type: 'whiteList',
  5604. text: 'Steam.leaveOfficialGroup',
  5605. id: gameId
  5606. });
  5607. return true;
  5608. }
  5609. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5610. if (!groupId) {
  5611. return false;
  5612. }
  5613. const logStatus = scripts_echoLog({
  5614. type: 'leavingSteamOfficialGroup',
  5615. text: gameId
  5616. });
  5617. const {
  5618. result,
  5619. statusText,
  5620. status,
  5621. data
  5622. } = await tools_httpRequest({
  5623. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5624. method: 'POST',
  5625. headers: {
  5626. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5627. },
  5628. data: $.param({
  5629. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5630. action: 'leaveGroup',
  5631. groupId: groupId
  5632. })
  5633. });
  5634. if (result === 'Success') {
  5635. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5636. const {
  5637. result: resultR,
  5638. statusText: statusTextR,
  5639. status: statusR,
  5640. data: dataR
  5641. } = await tools_httpRequest({
  5642. url: `https://steamcommunity.com/games/${gameId}`,
  5643. method: 'GET',
  5644. headers: {
  5645. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5646. }
  5647. });
  5648. if (resultR === 'Success') {
  5649. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5650. logStatus.success();
  5651. return true;
  5652. }
  5653. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5654. return false;
  5655. }
  5656. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5657. return false;
  5658. }
  5659. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5660. return false;
  5661. }
  5662. logStatus.error(`${result}:${statusText}(${status})`);
  5663. return false;
  5664. } catch (error) {
  5665. throwError(error, 'Steam.leaveOfficialGroup');
  5666. return false;
  5667. }
  5668. }
  5669. async function _getOfficialGroupId2(gameId) {
  5670. try {
  5671. const logStatus = scripts_echoLog({
  5672. type: 'gettingSteamOfficialGroupId',
  5673. text: gameId
  5674. });
  5675. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5676. if (groupId) {
  5677. logStatus.success();
  5678. return groupId;
  5679. }
  5680. const {
  5681. result,
  5682. statusText,
  5683. status,
  5684. data
  5685. } = await tools_httpRequest({
  5686. url: `https://steamcommunity.com/games/${gameId}`,
  5687. method: 'GET',
  5688. headers: {
  5689. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5690. }
  5691. });
  5692. if (result === 'Success') {
  5693. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5694. var _data$responseText$ma9;
  5695. 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];
  5696. if (groupId) {
  5697. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5698. logStatus.success();
  5699. return groupId;
  5700. }
  5701. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5702. return false;
  5703. }
  5704. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5705. return false;
  5706. }
  5707. logStatus.error(`${result}:${statusText}(${status})`);
  5708. return false;
  5709. } catch (error) {
  5710. throwError(error, 'Steam.getGroupID');
  5711. return false;
  5712. }
  5713. }
  5714. async function _addToWishlist2(gameId) {
  5715. try {
  5716. var _data$response;
  5717. const logStatus = scripts_echoLog({
  5718. type: 'addingToWishlist',
  5719. text: gameId
  5720. });
  5721. const {
  5722. result,
  5723. data
  5724. } = await tools_httpRequest({
  5725. url: 'https://store.steampowered.com/api/addtowishlist',
  5726. method: 'POST',
  5727. headers: {
  5728. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5729. },
  5730. data: $.param({
  5731. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5732. appid: gameId
  5733. }),
  5734. dataType: 'json'
  5735. });
  5736. 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) {
  5737. logStatus.success();
  5738. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5739. return true;
  5740. }
  5741. const {
  5742. result: resultR,
  5743. statusText: statusTextR,
  5744. status: statusR,
  5745. data: dataR
  5746. } = await tools_httpRequest({
  5747. url: `https://store.steampowered.com/app/${gameId}`,
  5748. method: 'GET'
  5749. });
  5750. if (resultR === 'Success') {
  5751. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5752. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5753. logStatus.warning(i18n('changeAreaNotice'));
  5754. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5755. return false;
  5756. }
  5757. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5758. }
  5759. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5760. logStatus.success();
  5761. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5762. return true;
  5763. } 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"')) {
  5764. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5765. return false;
  5766. }
  5767. logStatus.success();
  5768. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5769. return true;
  5770. }
  5771. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5772. return false;
  5773. }
  5774. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5775. return false;
  5776. } catch (error) {
  5777. throwError(error, 'Steam.addToWishlist');
  5778. return false;
  5779. }
  5780. }
  5781. async function _removeFromWishlist2(gameId) {
  5782. try {
  5783. var _data$response2;
  5784. if (this.whiteList.wishlists.includes(gameId)) {
  5785. scripts_echoLog({
  5786. type: 'whiteList',
  5787. text: 'Steam.removeFromWishlist',
  5788. id: gameId
  5789. });
  5790. return true;
  5791. }
  5792. const logStatus = scripts_echoLog({
  5793. type: 'removingFromWishlist',
  5794. text: gameId
  5795. });
  5796. const {
  5797. result,
  5798. data
  5799. } = await tools_httpRequest({
  5800. url: 'https://store.steampowered.com/api/removefromwishlist',
  5801. method: 'POST',
  5802. headers: {
  5803. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5804. },
  5805. data: $.param({
  5806. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5807. appid: gameId
  5808. }),
  5809. dataType: 'json'
  5810. });
  5811. 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) {
  5812. logStatus.success();
  5813. return true;
  5814. }
  5815. const {
  5816. result: resultR,
  5817. statusText: statusTextR,
  5818. status: statusR,
  5819. data: dataR
  5820. } = await tools_httpRequest({
  5821. url: `https://store.steampowered.com/app/${gameId}`,
  5822. method: 'GET'
  5823. });
  5824. if (resultR === 'Success') {
  5825. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5826. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5827. logStatus.warning(i18n('changeAreaNotice'));
  5828. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5829. if (!result || result === 'CN' || result === 'skip') {
  5830. return false;
  5831. }
  5832. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5833. }
  5834. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5835. logStatus.success();
  5836. return true;
  5837. }
  5838. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5839. return false;
  5840. }
  5841. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5842. return false;
  5843. }
  5844. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5845. return false;
  5846. } catch (error) {
  5847. throwError(error, 'Steam.removeFromWishlist');
  5848. return false;
  5849. }
  5850. }
  5851. async function _toggleFollowGame2(gameId, doTask) {
  5852. try {
  5853. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5854. scripts_echoLog({
  5855. type: 'whiteList',
  5856. text: 'Steam.unfollowGame',
  5857. id: gameId
  5858. });
  5859. return true;
  5860. }
  5861. const logStatus = scripts_echoLog({
  5862. type: `${doTask ? '' : 'un'}followingGame`,
  5863. text: gameId
  5864. });
  5865. const requestData = {
  5866. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5867. appid: gameId
  5868. };
  5869. if (!doTask) {
  5870. requestData.unfollow = '1';
  5871. }
  5872. const {
  5873. result,
  5874. data
  5875. } = await tools_httpRequest({
  5876. url: 'https://store.steampowered.com/explore/followgame/',
  5877. method: 'POST',
  5878. headers: {
  5879. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5880. },
  5881. data: $.param(requestData)
  5882. });
  5883. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5884. logStatus.success();
  5885. return true;
  5886. }
  5887. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5888. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5889. logStatus.warning(i18n('changeAreaNotice'));
  5890. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5891. return false;
  5892. }
  5893. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5894. }
  5895. if (doTask === followed) {
  5896. logStatus.success();
  5897. if (doTask) {
  5898. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5899. }
  5900. return true;
  5901. }
  5902. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5903. return false;
  5904. } catch (error) {
  5905. throwError(error, 'Steam.toggleFollowGame');
  5906. return false;
  5907. }
  5908. }
  5909. async function _isFollowedGame2(gameId) {
  5910. try {
  5911. const {
  5912. result,
  5913. data
  5914. } = await tools_httpRequest({
  5915. url: `https://store.steampowered.com/app/${gameId}`,
  5916. method: 'GET'
  5917. });
  5918. if (result === 'Success') {
  5919. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5920. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5921. return 'areaLocked';
  5922. }
  5923. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5924. return true;
  5925. }
  5926. return false;
  5927. }
  5928. return false;
  5929. }
  5930. return false;
  5931. } catch (error) {
  5932. throwError(error, 'Steam.isFollowedGame');
  5933. return false;
  5934. }
  5935. }
  5936. async function _toggleForum2(gameId) {
  5937. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5938. try {
  5939. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5940. scripts_echoLog({
  5941. type: 'whiteList',
  5942. text: 'Steam.unsubscribeForum',
  5943. id: gameId
  5944. });
  5945. return true;
  5946. }
  5947. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5948. if (!forumId) {
  5949. return false;
  5950. }
  5951. const logStatus = scripts_echoLog({
  5952. type: `${doTask ? '' : 'un'}subscribingForum`,
  5953. text: gameId
  5954. });
  5955. const [ id, feature ] = forumId.split('_');
  5956. const {
  5957. result,
  5958. statusText,
  5959. status,
  5960. data
  5961. } = await tools_httpRequest({
  5962. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5963. method: 'POST',
  5964. responseType: 'json',
  5965. headers: {
  5966. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5967. },
  5968. data: $.param({
  5969. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5970. })
  5971. });
  5972. if (result === 'Success') {
  5973. var _data$response3, _data$response4;
  5974. 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)) {
  5975. if (doTask) {
  5976. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5977. }
  5978. logStatus.success();
  5979. return true;
  5980. }
  5981. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5982. return true;
  5983. }
  5984. logStatus.error(`${result}:${statusText}(${status})`);
  5985. return true;
  5986. } catch (error) {
  5987. throwError(error, 'Steam.toggleForum');
  5988. return true;
  5989. }
  5990. }
  5991. async function _getForumId2(gameId) {
  5992. try {
  5993. const logStatus = scripts_echoLog({
  5994. type: 'gettingForumId',
  5995. text: gameId
  5996. });
  5997. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5998. if (forumId) {
  5999. logStatus.success();
  6000. return forumId;
  6001. }
  6002. const {
  6003. result,
  6004. statusText,
  6005. status,
  6006. data
  6007. } = await tools_httpRequest({
  6008. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  6009. method: 'GET'
  6010. });
  6011. if (result === 'Success') {
  6012. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6013. var _data$responseText, _data$responseText$ma10;
  6014. 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];
  6015. if (forumId) {
  6016. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  6017. logStatus.success();
  6018. return forumId;
  6019. }
  6020. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6021. return false;
  6022. }
  6023. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6024. return false;
  6025. }
  6026. logStatus.error(`${result}:${statusText}(${status})`);
  6027. return false;
  6028. } catch (error) {
  6029. throwError(error, 'Steam.getForumId');
  6030. return false;
  6031. }
  6032. }
  6033. async function _toggleFavoriteWorkshop2(id) {
  6034. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6035. try {
  6036. if (!doTask && this.whiteList.workshops.includes(id)) {
  6037. scripts_echoLog({
  6038. type: 'whiteList',
  6039. text: 'Steam.unfavoriteWorkshop',
  6040. id: id
  6041. });
  6042. return true;
  6043. }
  6044. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  6045. if (!appid) {
  6046. return false;
  6047. }
  6048. const logStatus = scripts_echoLog({
  6049. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  6050. text: id
  6051. });
  6052. const {
  6053. result,
  6054. statusText,
  6055. status,
  6056. data
  6057. } = await tools_httpRequest({
  6058. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  6059. method: 'POST',
  6060. headers: {
  6061. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6062. },
  6063. data: $.param({
  6064. id: id,
  6065. appid: appid,
  6066. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6067. })
  6068. });
  6069. if (result === 'Success') {
  6070. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  6071. if (doTask) {
  6072. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  6073. }
  6074. logStatus.success();
  6075. return true;
  6076. }
  6077. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6078. return false;
  6079. }
  6080. logStatus.error(`${result}:${statusText}(${status})`);
  6081. return false;
  6082. } catch (error) {
  6083. throwError(error, 'Steam.toggleFavoriteWorkshop');
  6084. return false;
  6085. }
  6086. }
  6087. async function _getWorkshopAppId2(id) {
  6088. try {
  6089. const logStatus = scripts_echoLog({
  6090. type: 'gettingWorkshopAppId',
  6091. text: id
  6092. });
  6093. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  6094. if (appId) {
  6095. logStatus.success();
  6096. return appId;
  6097. }
  6098. const {
  6099. result,
  6100. statusText,
  6101. status,
  6102. data
  6103. } = await tools_httpRequest({
  6104. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6105. method: 'GET'
  6106. });
  6107. if (result === 'Success') {
  6108. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6109. var _data$responseText$ma11;
  6110. 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];
  6111. if (appId) {
  6112. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6113. logStatus.success();
  6114. return appId;
  6115. }
  6116. logStatus.error('Error: getWorkshopAppId failed');
  6117. return false;
  6118. }
  6119. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6120. return false;
  6121. }
  6122. logStatus.error(`${result}:${statusText}(${status})`);
  6123. return false;
  6124. } catch (error) {
  6125. throwError(error, 'Steam.getWorkshopAppId');
  6126. return false;
  6127. }
  6128. }
  6129. async function _voteUpWorkshop2(id) {
  6130. try {
  6131. const logStatus = scripts_echoLog({
  6132. type: 'votingUpWorkshop',
  6133. text: id
  6134. });
  6135. const {
  6136. result,
  6137. statusText,
  6138. status,
  6139. data
  6140. } = await tools_httpRequest({
  6141. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6142. method: 'POST',
  6143. responseType: 'json',
  6144. headers: {
  6145. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6146. },
  6147. data: $.param({
  6148. id: id,
  6149. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6150. })
  6151. });
  6152. if (result === 'Success') {
  6153. var _data$response5;
  6154. 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) {
  6155. logStatus.success();
  6156. return true;
  6157. }
  6158. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6159. return true;
  6160. }
  6161. logStatus.error(`${result}:${statusText}(${status})`);
  6162. return true;
  6163. } catch (error) {
  6164. throwError(error, 'Steam.voteupWorkshop');
  6165. return true;
  6166. }
  6167. }
  6168. async function _toggleCurator2(curatorId) {
  6169. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6170. try {
  6171. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6172. scripts_echoLog({
  6173. type: 'whiteList',
  6174. text: 'Steam.unfollowCurator',
  6175. id: curatorId
  6176. });
  6177. return true;
  6178. }
  6179. const logStatus = scripts_echoLog({
  6180. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6181. text: curatorId
  6182. });
  6183. const {
  6184. result,
  6185. statusText,
  6186. status,
  6187. data
  6188. } = await tools_httpRequest({
  6189. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6190. method: 'POST',
  6191. headers: {
  6192. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6193. },
  6194. data: $.param({
  6195. clanid: curatorId,
  6196. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6197. follow: doTask
  6198. }),
  6199. dataType: 'json'
  6200. });
  6201. if (result === 'Success') {
  6202. var _data$response6, _data$response6$succe, _data$response7;
  6203. 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) {
  6204. logStatus.success();
  6205. return true;
  6206. }
  6207. 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})`);
  6208. return false;
  6209. }
  6210. logStatus.error(`${result}:${statusText}(${status})`);
  6211. return false;
  6212. } catch (error) {
  6213. throwError(error, 'Steam.toggleCurator');
  6214. return false;
  6215. }
  6216. }
  6217. async function _toggleCuratorLike2(link) {
  6218. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6219. try {
  6220. const [ path, name ] = link.split('/');
  6221. if (!(path && name)) {
  6222. scripts_echoLog({
  6223. text: i18n('errorLink', link)
  6224. });
  6225. return false;
  6226. }
  6227. const curatorId = await this.getCuratorId(path, name);
  6228. if (curatorId) {
  6229. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6230. }
  6231. return false;
  6232. } catch (error) {
  6233. throwError(error, 'Steam.toggleCuratorLike');
  6234. return false;
  6235. }
  6236. }
  6237. async function _getAnnouncementParams2(appId, viewId) {
  6238. try {
  6239. const logStatus = scripts_echoLog({
  6240. type: 'gettingAnnouncementParams',
  6241. text: appId,
  6242. id: viewId
  6243. });
  6244. const {
  6245. result,
  6246. statusText,
  6247. status,
  6248. data
  6249. } = await tools_httpRequest({
  6250. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6251. method: 'GET',
  6252. headers: {
  6253. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6254. }
  6255. });
  6256. if (result === 'Success') {
  6257. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6258. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6259. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6260. logStatus.warning(i18n('changeAreaNotice'));
  6261. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6262. return {};
  6263. }
  6264. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6265. }
  6266. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6267. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6268. 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];
  6269. if (authWgToken && clanId) {
  6270. logStatus.success();
  6271. return {
  6272. authWgToken: authWgToken,
  6273. clanId: clanId,
  6274. gid: gid
  6275. };
  6276. }
  6277. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6278. return {};
  6279. }
  6280. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6281. return {};
  6282. }
  6283. logStatus.error(`${result}:${statusText}(${status})`);
  6284. return {};
  6285. } catch (error) {
  6286. throwError(error, 'Steam.likeAnnouncement');
  6287. return {};
  6288. }
  6289. }
  6290. async function _likeAnnouncement2(id) {
  6291. try {
  6292. const [ appId, viewId ] = id.split('/');
  6293. if (!(appId && viewId)) {
  6294. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6295. return false;
  6296. }
  6297. const {
  6298. authWgToken,
  6299. clanId,
  6300. gid
  6301. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6302. if (!(authWgToken && clanId)) {
  6303. return false;
  6304. }
  6305. const logStatus = scripts_echoLog({
  6306. type: 'likingAnnouncement',
  6307. text: appId,
  6308. id: viewId
  6309. });
  6310. const {
  6311. result,
  6312. statusText,
  6313. status,
  6314. data
  6315. } = await tools_httpRequest({
  6316. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6317. method: 'POST',
  6318. headers: {
  6319. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6320. Host: 'store.steampowered.com',
  6321. Origin: 'https://store.steampowered.com',
  6322. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6323. },
  6324. data: $.param({
  6325. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6326. wgauthtoken: authWgToken,
  6327. voteup: 1,
  6328. clanid: clanId,
  6329. ajax: 1
  6330. }),
  6331. dataType: 'json'
  6332. });
  6333. if (result === 'Success') {
  6334. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6335. logStatus.success();
  6336. return true;
  6337. }
  6338. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6339. return false;
  6340. }
  6341. logStatus.error(`${result}:${statusText}(${status})`);
  6342. return false;
  6343. } catch (error) {
  6344. throwError(error, 'Steam.likeAnnouncement');
  6345. return false;
  6346. }
  6347. }
  6348. async function _appid2subid2(id) {
  6349. try {
  6350. const logStatus = scripts_echoLog({
  6351. type: 'gettingSubid',
  6352. text: id
  6353. });
  6354. const {
  6355. result,
  6356. statusText,
  6357. status,
  6358. data
  6359. } = await tools_httpRequest({
  6360. url: `https://store.steampowered.com/app/${id}`,
  6361. method: 'GET',
  6362. headers: {
  6363. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6364. }
  6365. });
  6366. if (result === 'Success') {
  6367. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6368. var _data$responseText$ma15;
  6369. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6370. logStatus.warning(i18n('changeAreaNotice'));
  6371. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6372. if (!result || result === 'CN' || result === 'skip') {
  6373. return false;
  6374. }
  6375. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6376. }
  6377. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6378. if (subid) {
  6379. logStatus.success();
  6380. return subid;
  6381. }
  6382. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6383. return false;
  6384. }
  6385. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6386. return false;
  6387. }
  6388. logStatus.error(`${result}:${statusText}(${status})`);
  6389. return false;
  6390. } catch (error) {
  6391. throwError(error, 'Steam.appid2subid');
  6392. return false;
  6393. }
  6394. }
  6395. async function _getLicenses2() {
  6396. try {
  6397. const logStatus = scripts_echoLog({
  6398. text: i18n('gettingLicenses')
  6399. });
  6400. const {
  6401. result,
  6402. statusText,
  6403. status,
  6404. data
  6405. } = await tools_httpRequest({
  6406. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  6407. method: 'GET',
  6408. responseType: 'json'
  6409. });
  6410. if (result === 'Success') {
  6411. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6412. var _data$response8;
  6413. logStatus.success();
  6414. return (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.rgOwnedPackages;
  6415. }
  6416. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6417. return false;
  6418. }
  6419. logStatus.error(`${result}:${statusText}(${status})`);
  6420. return false;
  6421. } catch (error) {
  6422. throwError(error, 'Steam.getLicenses');
  6423. return false;
  6424. }
  6425. }
  6426. async function _addLicense2(id) {
  6427. try {
  6428. const [ type, ids ] = id.split('-');
  6429. if (type === 'appid') {
  6430. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6431. if (!subid) {
  6432. return false;
  6433. }
  6434. const logStatus = scripts_echoLog({
  6435. type: 'addingFreeLicense',
  6436. text: ids
  6437. });
  6438. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6439. return false;
  6440. }
  6441. const {
  6442. result,
  6443. statusText,
  6444. status,
  6445. data
  6446. } = await tools_httpRequest({
  6447. url: `https://store.steampowered.com/app/${ids}`,
  6448. method: 'GET'
  6449. });
  6450. if (result === 'Success') {
  6451. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6452. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6453. logStatus.success();
  6454. return true;
  6455. }
  6456. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6457. return false;
  6458. }
  6459. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6460. return false;
  6461. }
  6462. logStatus.error(`${result}:${statusText}(${status})`);
  6463. return false;
  6464. } else if (type === 'subid') {
  6465. if (Steam_classPrivateFieldGet(this, _area) === 'CN') {
  6466. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  6467. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6468. }
  6469. const logStatusArr = {};
  6470. const idsArr = ids.split(',');
  6471. for (const subid of idsArr) {
  6472. const logStatus = scripts_echoLog({
  6473. type: 'addingFreeLicenseSubid',
  6474. text: subid
  6475. });
  6476. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6477. return false;
  6478. }
  6479. logStatusArr[subid] = logStatus;
  6480. }
  6481. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6482. if (!licenses) {
  6483. return false;
  6484. }
  6485. for (const subid of idsArr) {
  6486. if (licenses.includes(parseInt(subid, 10))) {
  6487. logStatusArr[subid].success();
  6488. } else {
  6489. logStatusArr[subid].error();
  6490. }
  6491. }
  6492. return true;
  6493. }
  6494. return false;
  6495. } catch (error) {
  6496. throwError(error, 'Steam.addLicense');
  6497. return false;
  6498. }
  6499. }
  6500. async function _addFreeLicense2(id, logStatusPre) {
  6501. try {
  6502. const logStatus = logStatusPre || scripts_echoLog({
  6503. type: 'addingFreeLicenseSubid',
  6504. text: id
  6505. });
  6506. const {
  6507. result,
  6508. statusText,
  6509. status,
  6510. data
  6511. } = await tools_httpRequest({
  6512. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6513. method: 'POST',
  6514. headers: {
  6515. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6516. Host: 'store.steampowered.com',
  6517. Origin: 'https://store.steampowered.com',
  6518. Referer: 'https://store.steampowered.com/account/licenses/'
  6519. },
  6520. data: $.param({
  6521. action: 'add_to_cart',
  6522. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6523. subid: id
  6524. }),
  6525. dataType: 'json'
  6526. });
  6527. if (result === 'Success') {
  6528. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6529. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6530. logStatus.warning(i18n('changeAreaNotice'));
  6531. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6532. if (!result || result === 'CN') {
  6533. return false;
  6534. }
  6535. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6536. }
  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.addFreeLicense');
  6547. return false;
  6548. }
  6549. }
  6550. async function _requestPlayTestAccess2(id) {
  6551. try {
  6552. const logStatus = scripts_echoLog({
  6553. type: 'requestingPlayTestAccess',
  6554. text: id
  6555. });
  6556. const {
  6557. result,
  6558. statusText,
  6559. status,
  6560. data
  6561. } = await tools_httpRequest({
  6562. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6563. method: 'POST',
  6564. headers: {
  6565. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6566. Host: 'store.steampowered.com',
  6567. Origin: 'https://store.steampowered.com',
  6568. Referer: `https://store.steampowered.com/app/${id}`
  6569. },
  6570. data: $.param({
  6571. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6572. }),
  6573. dataType: 'json'
  6574. });
  6575. if (result === 'Success') {
  6576. var _data$response9;
  6577. 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) {
  6578. logStatus.success();
  6579. return true;
  6580. }
  6581. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6582. return false;
  6583. }
  6584. logStatus.error(`${result}:${statusText}(${status})`);
  6585. return false;
  6586. } catch (error) {
  6587. throwError(error, 'Steam.requestPlayTestAccess');
  6588. return false;
  6589. }
  6590. }
  6591. function Steam_setCache2(type, name, id) {
  6592. try {
  6593. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6594. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6595. } catch (error) {
  6596. throwError(error, 'Steam.setCache');
  6597. }
  6598. }
  6599. const social_Steam = Steam;
  6600. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6601. Website_checkPrivateRedeclaration(obj, privateSet);
  6602. privateSet.add(obj);
  6603. }
  6604. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6605. if (privateCollection.has(obj)) {
  6606. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6607. }
  6608. }
  6609. function Website_defineProperty(obj, key, value) {
  6610. if (key in obj) {
  6611. Object.defineProperty(obj, key, {
  6612. value: value,
  6613. enumerable: true,
  6614. configurable: true,
  6615. writable: true
  6616. });
  6617. } else {
  6618. obj[key] = value;
  6619. }
  6620. return obj;
  6621. }
  6622. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6623. if (!privateSet.has(receiver)) {
  6624. throw new TypeError('attempted to get private field on non-instance');
  6625. }
  6626. return fn;
  6627. }
  6628. var _bind = new WeakSet();
  6629. class Website {
  6630. constructor() {
  6631. Website_classPrivateMethodInitSpec(this, _bind);
  6632. Website_defineProperty(this, 'undoneTasks', void 0);
  6633. Website_defineProperty(this, 'socialTasks', void 0);
  6634. Website_defineProperty(this, 'giveawayId', void 0);
  6635. Website_defineProperty(this, 'socialInitialized', {
  6636. discord: false,
  6637. instagram: false,
  6638. reddit: false,
  6639. twitch: false,
  6640. twitter: false,
  6641. vk: false,
  6642. youtube: false,
  6643. steamStore: false,
  6644. steamCommunity: false
  6645. });
  6646. Website_defineProperty(this, 'initialized', false);
  6647. Website_defineProperty(this, 'social', {});
  6648. }
  6649. async initSocial(action) {
  6650. try {
  6651. const pro = [];
  6652. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6653. if (tasks.discord) {
  6654. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6655. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6656. this.social.discord = new social_Discord();
  6657. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6658. }
  6659. }
  6660. if (tasks.instagram) {
  6661. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6662. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6663. this.social.instagram = new social_Instagram();
  6664. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6665. }
  6666. }
  6667. if (tasks.reddit) {
  6668. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6669. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6670. this.social.reddit = new social_Reddit();
  6671. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6672. }
  6673. }
  6674. if (tasks.twitch) {
  6675. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6676. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6677. this.social.twitch = new social_Twitch();
  6678. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6679. }
  6680. }
  6681. if (tasks.twitter) {
  6682. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6683. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6684. this.social.twitter = new social_Twitter();
  6685. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6686. }
  6687. }
  6688. if (tasks.vk) {
  6689. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6690. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6691. this.social.vk = new social_Vk();
  6692. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6693. }
  6694. }
  6695. if (tasks.youtube) {
  6696. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6697. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6698. this.social.youtube = new Youtube();
  6699. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6700. }
  6701. }
  6702. if (tasks.steam) {
  6703. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6704. if (steamLength > 0) {
  6705. if (!this.social.steam) {
  6706. this.social.steam = new social_Steam();
  6707. }
  6708. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6709. var _tasks$steam, _tasks$steam$type;
  6710. 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;
  6711. }).reduce((total, number) => total + number, 0);
  6712. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6713. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6714. }
  6715. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6716. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6717. }
  6718. }
  6719. }
  6720. if (tasks.links && tasks.links.length > 0) {
  6721. this.social.visitLink = visitLink;
  6722. }
  6723. return await Promise.all(pro).then(result => {
  6724. let checked = true;
  6725. for (const data of result) {
  6726. if (data.result) {
  6727. this.socialInitialized[data.name] = data.result;
  6728. } else {
  6729. checked = false;
  6730. }
  6731. }
  6732. return checked;
  6733. });
  6734. } catch (error) {
  6735. throwError(error, 'Website.initSocial');
  6736. return false;
  6737. }
  6738. }
  6739. uniqueTasks(allTasks) {
  6740. const result = {};
  6741. for (const [ social, types ] of Object.entries(allTasks)) {
  6742. result[social] = {};
  6743. for (const [ type, tasks ] of Object.entries(types)) {
  6744. result[social][type] = unique(tasks);
  6745. }
  6746. }
  6747. return result;
  6748. }
  6749. async toggleTask(action) {
  6750. try {
  6751. if (!this.initialized && !this.init()) {
  6752. return false;
  6753. }
  6754. if (!await this.classifyTask(action)) {
  6755. return false;
  6756. }
  6757. if (!await this.initSocial(action)) {
  6758. return false;
  6759. }
  6760. const pro = [];
  6761. const doTask = action === 'do';
  6762. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6763. if (this.socialInitialized.discord !== 'skip' && this.social.discord) {
  6764. pro.push(this.social.discord.toggle({
  6765. doTask: doTask,
  6766. ...tasks.discord
  6767. }));
  6768. }
  6769. if (this.social.instagram) {
  6770. pro.push(this.social.instagram.toggle({
  6771. doTask: doTask,
  6772. ...tasks.instagram
  6773. }));
  6774. }
  6775. if (this.social.reddit) {
  6776. pro.push(this.social.reddit.toggle({
  6777. doTask: doTask,
  6778. ...tasks.reddit
  6779. }));
  6780. }
  6781. if (this.social.twitch) {
  6782. pro.push(this.social.twitch.toggle({
  6783. doTask: doTask,
  6784. ...tasks.twitch
  6785. }));
  6786. }
  6787. if (this.social.twitter) {
  6788. pro.push(this.social.twitter.toggle({
  6789. doTask: doTask,
  6790. ...tasks.twitter
  6791. }));
  6792. }
  6793. if (this.social.vk) {
  6794. pro.push(this.social.vk.toggle({
  6795. doTask: doTask,
  6796. ...tasks.vk
  6797. }));
  6798. }
  6799. if (this.social.youtube) {
  6800. pro.push(this.social.youtube.toggle({
  6801. doTask: doTask,
  6802. ...tasks.youtube
  6803. }));
  6804. }
  6805. if (this.social.steam) {
  6806. pro.push(this.social.steam.toggle({
  6807. doTask: doTask,
  6808. ...tasks.steam
  6809. }));
  6810. }
  6811. if (this.social.visitLink && tasks.links && doTask) {
  6812. for (const link of tasks.links) {
  6813. pro.push(this.social.visitLink(link));
  6814. }
  6815. }
  6816. if (doTask && tasks.extra && this.extraDoTask) {
  6817. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6818. if (hasExtra) {
  6819. pro.push(this.extraDoTask(tasks.extra));
  6820. }
  6821. }
  6822. await Promise.all(pro);
  6823. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6824. return true;
  6825. } catch (error) {
  6826. throwError(error, 'Website.toggleTask');
  6827. return false;
  6828. }
  6829. }
  6830. async doTask() {
  6831. try {
  6832. return await this.toggleTask('do');
  6833. } catch (error) {
  6834. throwError(error, 'Website.doTask');
  6835. return false;
  6836. }
  6837. }
  6838. async undoTask() {
  6839. try {
  6840. return await this.toggleTask('undo');
  6841. } catch (error) {
  6842. throwError(error, 'Website.undoTask');
  6843. return false;
  6844. }
  6845. }
  6846. }
  6847. async function _bind2(name, init) {
  6848. try {
  6849. return {
  6850. name: name,
  6851. result: await init
  6852. };
  6853. } catch (error) {
  6854. throwError(error, 'Website.bind');
  6855. return {
  6856. name: name,
  6857. result: false
  6858. };
  6859. }
  6860. }
  6861. const website_Website = Website;
  6862. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6863. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6864. privateSet.add(obj);
  6865. }
  6866. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6867. if (privateCollection.has(obj)) {
  6868. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6869. }
  6870. }
  6871. function FreeAnyWhere_defineProperty(obj, key, value) {
  6872. if (key in obj) {
  6873. Object.defineProperty(obj, key, {
  6874. value: value,
  6875. enumerable: true,
  6876. configurable: true,
  6877. writable: true
  6878. });
  6879. } else {
  6880. obj[key] = value;
  6881. }
  6882. return obj;
  6883. }
  6884. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6885. if (!privateSet.has(receiver)) {
  6886. throw new TypeError('attempted to get private field on non-instance');
  6887. }
  6888. return fn;
  6889. }
  6890. const FreeAnyWhere_defaultTasksTemplate = {
  6891. steam: {
  6892. groupLinks: [],
  6893. wishlistLinks: [],
  6894. curatorLinks: [],
  6895. followLinks: []
  6896. },
  6897. vk: {
  6898. nameLinks: []
  6899. }
  6900. };
  6901. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6902. var _getGiveawayId = new WeakSet();
  6903. var _verify = new WeakSet();
  6904. class FreeAnyWhere extends website_Website {
  6905. constructor() {
  6906. super(...arguments);
  6907. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6908. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6909. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6910. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6911. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6912. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6913. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6914. }
  6915. static test() {
  6916. return window.location.host === 'freeanywhere.net';
  6917. }
  6918. init() {
  6919. try {
  6920. const logStatus = scripts_echoLog({
  6921. text: i18n('initing')
  6922. });
  6923. if ($('a[href="#/login"]').length > 0) {
  6924. window.open('/#/login', '_self');
  6925. logStatus.warning(i18n('needLogin'));
  6926. return false;
  6927. }
  6928. if (window.location.href.includes('/login')) {
  6929. logStatus.warning(i18n('needLogin'));
  6930. return false;
  6931. }
  6932. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6933. var _window$location$href;
  6934. 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];
  6935. if (!id) {
  6936. logStatus.error(i18n('getFailed', 'Id'));
  6937. return false;
  6938. }
  6939. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6940. }
  6941. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6942. return false;
  6943. }
  6944. this.initialized = true;
  6945. logStatus.success();
  6946. return true;
  6947. } catch (error) {
  6948. throwError(error, 'Freeanywhere.init');
  6949. return false;
  6950. }
  6951. }
  6952. async classifyTask(action) {
  6953. try {
  6954. const logStatus = scripts_echoLog({
  6955. text: i18n('getTasksInfo')
  6956. });
  6957. if (action === 'undo') {
  6958. var _GM_getValue;
  6959. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6960. }
  6961. const {
  6962. result,
  6963. statusText,
  6964. status,
  6965. data
  6966. } = await tools_httpRequest({
  6967. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6968. method: 'GET',
  6969. headers: {
  6970. authorization: `Token ${window.localStorage.getItem('token')}`,
  6971. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6972. },
  6973. responseType: 'json'
  6974. });
  6975. if (result === 'Success') {
  6976. var _data$response;
  6977. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6978. if (tasks) {
  6979. if (action === 'verify') {
  6980. this.tasks = [];
  6981. }
  6982. for (const task of tasks) {
  6983. const type = task.challenge;
  6984. const social = task.challenge_provider;
  6985. const taskInfo = {
  6986. id: task.id,
  6987. title: task.title
  6988. };
  6989. if (action === 'verify' && !task.is_success) {
  6990. this.tasks.push(taskInfo);
  6991. continue;
  6992. }
  6993. switch (social) {
  6994. case 'steam':
  6995. taskInfo.social = 'steam';
  6996. switch (type) {
  6997. case 'WL':
  6998. if (action === 'undo') {
  6999. this.socialTasks.steam.wishlistLinks.push(task.link);
  7000. }
  7001. if (action === 'do' && !task.is_success) {
  7002. this.undoneTasks.steam.wishlistLinks.push(task.link);
  7003. }
  7004. break;
  7005.  
  7006. case 'JTG':
  7007. if (action === 'undo') {
  7008. this.socialTasks.steam.groupLinks.push(task.link);
  7009. }
  7010. if (action === 'do' && !task.is_success) {
  7011. this.undoneTasks.steam.groupLinks.push(task.link);
  7012. }
  7013. break;
  7014.  
  7015. case 'STC':
  7016. if (action === 'undo') {
  7017. this.socialTasks.steam.curatorLinks.push(task.link);
  7018. }
  7019. if (action === 'do' && !task.is_success) {
  7020. this.undoneTasks.steam.curatorLinks.push(task.link);
  7021. }
  7022. break;
  7023.  
  7024. case 'GF':
  7025. if (action === 'undo') {
  7026. this.socialTasks.steam.followLinks.push(task.link);
  7027. }
  7028. if (action === 'do' && !task.is_success) {
  7029. this.undoneTasks.steam.followLinks.push(task.link);
  7030. }
  7031. break;
  7032. }
  7033. break;
  7034.  
  7035. case 'vk-oauth2':
  7036. if (action === 'undo') {
  7037. this.socialTasks.vk.nameLinks.push(task.link);
  7038. }
  7039. if (action === 'do' && !task.is_success) {
  7040. this.undoneTasks.vk.nameLinks.push(task.link);
  7041. }
  7042. break;
  7043.  
  7044. case 'website':
  7045. break;
  7046.  
  7047. default:
  7048. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  7049. break;
  7050. }
  7051. }
  7052. logStatus.success();
  7053. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7054. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7055. if (window.DEBUG) {
  7056. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7057. }
  7058. GM_setValue(`fawTasks-${this.giveawayId}`, {
  7059. tasks: this.socialTasks,
  7060. time: new Date().getTime()
  7061. });
  7062. return true;
  7063. }
  7064. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7065. return false;
  7066. }
  7067. logStatus.error(`${result}:${statusText}(${status})`);
  7068. return false;
  7069. } catch (error) {
  7070. throwError(error, 'Freeanywhere.classifyTask');
  7071. return false;
  7072. }
  7073. }
  7074. async verifyTask() {
  7075. try {
  7076. if (!this.initialized && !this.init()) {
  7077. return false;
  7078. }
  7079. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7080. return false;
  7081. }
  7082. const pro = [];
  7083. for (const task of this.tasks) {
  7084. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  7085. await delay(1e3);
  7086. }
  7087. await Promise.all(pro);
  7088. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7089. return !!await this.getKey(true);
  7090. } catch (error) {
  7091. throwError(error, 'Freeanywhere.verifyTask');
  7092. return false;
  7093. }
  7094. }
  7095. async getKey(initialized) {
  7096. try {
  7097. if (!initialized && !this.initialized && !this.init()) {
  7098. return false;
  7099. }
  7100. const logStatus = scripts_echoLog({
  7101. text: i18n('gettingKey')
  7102. });
  7103. const {
  7104. result,
  7105. statusText,
  7106. status,
  7107. data
  7108. } = await tools_httpRequest({
  7109. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7110. method: 'GET',
  7111. dataType: 'json',
  7112. headers: {
  7113. authorization: `Token ${window.localStorage.getItem('token')}`
  7114. }
  7115. });
  7116. if (result === 'Success') {
  7117. var _data$response2;
  7118. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7119. logStatus.success();
  7120. scripts_echoLog({}).success(data.response.reward);
  7121. return data.response.reward;
  7122. }
  7123. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7124. return false;
  7125. }
  7126. logStatus.error(`${result}:${statusText}(${status})`);
  7127. return false;
  7128. } catch (error) {
  7129. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7130. return false;
  7131. }
  7132. }
  7133. }
  7134. function _getGiveawayId2() {
  7135. try {
  7136. var _window$location$href2;
  7137. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7138. if (giveawayId) {
  7139. this.giveawayId = giveawayId;
  7140. return true;
  7141. }
  7142. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7143. return false;
  7144. } catch (error) {
  7145. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7146. }
  7147. }
  7148. async function _verify2(task) {
  7149. try {
  7150. const logStatus = scripts_echoLog({
  7151. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7152. });
  7153. const {
  7154. result,
  7155. statusText,
  7156. status,
  7157. data
  7158. } = await tools_httpRequest({
  7159. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7160. method: 'GET',
  7161. dataType: 'json',
  7162. headers: {
  7163. authorization: `Token ${window.localStorage.getItem('token')}`,
  7164. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7165. }
  7166. });
  7167. if (result === 'Success') {
  7168. var _data$response3;
  7169. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7170. logStatus.success();
  7171. return true;
  7172. }
  7173. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7174. return false;
  7175. }
  7176. logStatus.error(`${result}:${statusText}(${status})`);
  7177. return false;
  7178. } catch (error) {
  7179. throwError(error, 'Freeanywhere.verify');
  7180. return false;
  7181. }
  7182. }
  7183. const website_FreeAnyWhere = FreeAnyWhere;
  7184. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7185. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7186. privateSet.add(obj);
  7187. }
  7188. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7189. if (privateCollection.has(obj)) {
  7190. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7191. }
  7192. }
  7193. function GiveawaySu_defineProperty(obj, key, value) {
  7194. if (key in obj) {
  7195. Object.defineProperty(obj, key, {
  7196. value: value,
  7197. enumerable: true,
  7198. configurable: true,
  7199. writable: true
  7200. });
  7201. } else {
  7202. obj[key] = value;
  7203. }
  7204. return obj;
  7205. }
  7206. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7207. if (!privateSet.has(receiver)) {
  7208. throw new TypeError('attempted to get private field on non-instance');
  7209. }
  7210. return fn;
  7211. }
  7212. const GiveawaySu_defaultTasks = {
  7213. steam: {
  7214. groupLinks: [],
  7215. wishlistLinks: [],
  7216. curatorLinks: [],
  7217. curatorLikeLinks: [],
  7218. followLinks: [],
  7219. forumLinks: [],
  7220. announcementLinks: [],
  7221. workshopVoteLinks: [],
  7222. playtestLinks: []
  7223. },
  7224. discord: {
  7225. serverLinks: []
  7226. },
  7227. instagram: {
  7228. userLinks: []
  7229. },
  7230. vk: {
  7231. nameLinks: []
  7232. },
  7233. twitch: {
  7234. channelLinks: []
  7235. },
  7236. reddit: {
  7237. redditLinks: []
  7238. },
  7239. youtube: {
  7240. channelLinks: [],
  7241. likeLinks: []
  7242. }
  7243. };
  7244. var _checkLogin = new WeakSet();
  7245. var _checkLeftKey = new WeakSet();
  7246. var GiveawaySu_getGiveawayId = new WeakSet();
  7247. class GiveawaySu extends website_Website {
  7248. constructor() {
  7249. super(...arguments);
  7250. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7251. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  7252. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7253. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7254. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7255. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7256. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7257. }
  7258. static test() {
  7259. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7260. }
  7261. async after() {
  7262. try {
  7263. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7264. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7265. }
  7266. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7267. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7268. }
  7269. scripts_echoLog({}).warning(i18n('gsNotice'));
  7270. } catch (error) {
  7271. throwError(error, 'Giveawaysu.after');
  7272. }
  7273. }
  7274. init() {
  7275. try {
  7276. const logStatus = scripts_echoLog({
  7277. text: i18n('initing')
  7278. });
  7279. if ($('a.steam-login').length > 0) {
  7280. window.open('/steam/redirect', '_self');
  7281. logStatus.warning(i18n('needLogin'));
  7282. return false;
  7283. }
  7284. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7285. return false;
  7286. }
  7287. this.initialized = true;
  7288. logStatus.success();
  7289. return true;
  7290. } catch (error) {
  7291. throwError(error, 'Giveawaysu.init');
  7292. return false;
  7293. }
  7294. }
  7295. async classifyTask(action) {
  7296. try {
  7297. const logStatus = scripts_echoLog({
  7298. text: i18n('getTasksInfo')
  7299. });
  7300. if (action === 'undo') {
  7301. var _GM_getValue;
  7302. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7303. return true;
  7304. }
  7305. const pro = [];
  7306. const tasks = $('#actions tr');
  7307. if ($('div.bind-discord').is(':visible')) {
  7308. $('div.bind-discord a')[0].click();
  7309. }
  7310. if ($('div.bind-twitch').is(':visible')) {
  7311. $('div.bind-twitch a')[0].click();
  7312. }
  7313. for (const task of tasks) {
  7314. pro.push(new Promise(resolve => {
  7315. const td = $(task).find('td:not(".hidden")');
  7316. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7317. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7318. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7319. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7320. const taskName = taskDes.text().trim();
  7321. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7322. return resolve(true);
  7323. }
  7324. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7325. if (!taskLink) {
  7326. return resolve(false);
  7327. }
  7328. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7329. this.undoneTasks.steam.groupLinks.push(taskLink);
  7330. } else if (/like.*announcement/gi.test(taskName)) {
  7331. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7332. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7333. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7334. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7335. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7336. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7337. this.undoneTasks.steam.forumLinks.push(taskLink);
  7338. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7339. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7340. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7341. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7342. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7343. this.undoneTasks.discord.serverLinks.push(taskLink);
  7344. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7345. this.undoneTasks.instagram.userLinks.push(taskLink);
  7346. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7347. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7348. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7349. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7350. } else if (/watch.*art/gim.test(taskName)) {
  7351. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7352. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7353. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7354. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7355. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7356. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7357. this.undoneTasks.vk.nameLinks.push(taskLink);
  7358. } else {
  7359. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7360. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7361. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7362. }
  7363. if (/follow.*button/gim.test(taskName)) {
  7364. this.undoneTasks.steam.followLinks.push(taskLink);
  7365. }
  7366. }
  7367. }
  7368. resolve(true);
  7369. }).catch(error => {
  7370. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7371. return false;
  7372. });
  7373. }));
  7374. }
  7375. await Promise.all(pro);
  7376. logStatus.success();
  7377. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7378. this.socialTasks = this.undoneTasks;
  7379. if (window.DEBUG) {
  7380. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7381. }
  7382. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7383. tasks: this.socialTasks,
  7384. time: new Date().getTime()
  7385. });
  7386. return true;
  7387. } catch (error) {
  7388. throwError(error, 'Giveawaysu.classifyTask');
  7389. return false;
  7390. }
  7391. }
  7392. }
  7393. function _checkLogin2() {
  7394. try {
  7395. if (!globalOptions.other.checkLogin) {
  7396. return true;
  7397. }
  7398. if ($('a.steam-login').length > 0) {
  7399. window.open('/steam/redirect', '_self');
  7400. }
  7401. return true;
  7402. } catch (error) {
  7403. throwError(error, 'Giveawaysu.checkLogin');
  7404. return false;
  7405. }
  7406. }
  7407. async function _checkLeftKey2() {
  7408. try {
  7409. if (!globalOptions.other.checkLeftKey) {
  7410. return true;
  7411. }
  7412. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7413. await external_Swal_default().fire({
  7414. icon: 'warning',
  7415. title: i18n('notice'),
  7416. text: i18n('noKeysLeft'),
  7417. confirmButtonText: i18n('confirm'),
  7418. cancelButtonText: i18n('cancel'),
  7419. showCancelButton: true
  7420. }).then(_ref => {
  7421. let {
  7422. value
  7423. } = _ref;
  7424. if (value) {
  7425. window.close();
  7426. }
  7427. });
  7428. }
  7429. return true;
  7430. } catch (error) {
  7431. throwError(error, 'Giveawaysu.checkLeftKey');
  7432. return false;
  7433. }
  7434. }
  7435. function GiveawaySu_getGiveawayId2() {
  7436. var _window$location$href;
  7437. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7438. if (giveawayId) {
  7439. this.giveawayId = giveawayId;
  7440. return true;
  7441. }
  7442. scripts_echoLog({
  7443. text: i18n('getFailed', 'GiveawayId')
  7444. });
  7445. return false;
  7446. }
  7447. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7448. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7449. privateSet.add(obj);
  7450. }
  7451. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7452. if (privateCollection.has(obj)) {
  7453. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7454. }
  7455. }
  7456. function Indiedb_defineProperty(obj, key, value) {
  7457. if (key in obj) {
  7458. Object.defineProperty(obj, key, {
  7459. value: value,
  7460. enumerable: true,
  7461. configurable: true,
  7462. writable: true
  7463. });
  7464. } else {
  7465. obj[key] = value;
  7466. }
  7467. return obj;
  7468. }
  7469. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7470. if (!privateSet.has(receiver)) {
  7471. throw new TypeError('attempted to get private field on non-instance');
  7472. }
  7473. return fn;
  7474. }
  7475. var _join = new WeakSet();
  7476. var _do = new WeakSet();
  7477. var Indiedb_checkLogin = new WeakSet();
  7478. var Indiedb_checkLeftKey = new WeakSet();
  7479. class Indiedb {
  7480. constructor() {
  7481. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7482. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7483. Indiedb_classPrivateMethodInitSpec(this, _do);
  7484. Indiedb_classPrivateMethodInitSpec(this, _join);
  7485. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7486. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7487. }
  7488. static test() {
  7489. return window.location.host === 'www.indiedb.com';
  7490. }
  7491. async after() {
  7492. try {
  7493. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7494. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7495. }
  7496. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7497. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7498. }
  7499. } catch (error) {
  7500. throwError(error, 'Indiedb.after');
  7501. }
  7502. }
  7503. async doTask() {
  7504. try {
  7505. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7506. return false;
  7507. }
  7508. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7509. } catch (error) {
  7510. throwError(error, 'Indiedb.doTask');
  7511. return false;
  7512. }
  7513. }
  7514. }
  7515. async function _join2() {
  7516. try {
  7517. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7518. scripts_echoLog({}).error(i18n('needLogin'));
  7519. return false;
  7520. }
  7521. const currentoption = $('a.buttonenter.buttongiveaway');
  7522. if (/join giveaway/gim.test(currentoption.text())) {
  7523. const logStatus = scripts_echoLog({
  7524. text: `${i18n('joiningGiveaway')}...`
  7525. });
  7526. const {
  7527. result,
  7528. statusText,
  7529. status,
  7530. data
  7531. } = await tools_httpRequest({
  7532. url: currentoption.attr('href'),
  7533. method: 'POST',
  7534. data: 'ajax=t',
  7535. dataType: 'json',
  7536. headers: {
  7537. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7538. accept: 'application/json, text/javascript, */*; q=0.01',
  7539. origin: window.location.origin
  7540. }
  7541. });
  7542. if (result === 'Success') {
  7543. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7544. var _data$response, _data$response4, _data$response5;
  7545. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7546. var _data$response2, _data$response3;
  7547. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7548. $('#giveawaysjoined').slideDown();
  7549. $('#giveawaysrecommend').slideDown();
  7550. 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}` : ''}`);
  7551. return true;
  7552. }
  7553. 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}` : ''}`);
  7554. return false;
  7555. }
  7556. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7557. return false;
  7558. }
  7559. logStatus.error(`${result}:${statusText}(${status})`);
  7560. return false;
  7561. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7562. return true;
  7563. }
  7564. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7565. return false;
  7566. } catch (error) {
  7567. throwError(error, 'Indiedb.init');
  7568. return false;
  7569. }
  7570. }
  7571. async function _do2() {
  7572. try {
  7573. const id = $('script').map((index, script) => {
  7574. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7575. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7576. 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] ];
  7577. }
  7578. return null;
  7579. });
  7580. if (id.length === 2) {
  7581. const pro = [];
  7582. const tasks = $('#giveawaysjoined a[class*=promo]');
  7583. for (const task of tasks) {
  7584. const promo = $(task);
  7585. if (!promo.hasClass('buttonentered')) {
  7586. const status = scripts_echoLog({
  7587. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7588. });
  7589. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7590. let text = '';
  7591. if (promo.hasClass('facebookpromo')) {
  7592. text = 'facebookpromo';
  7593. } else if (promo.hasClass('twitterpromo')) {
  7594. text = 'twitterpromo';
  7595. } else {
  7596. text = 'visitpromo';
  7597. }
  7598. pro.push(new Promise(resolve => {
  7599. $.ajax({
  7600. type: 'POST',
  7601. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7602. timeout: 6e4,
  7603. dataType: 'json',
  7604. data: {
  7605. ajax: 't'
  7606. },
  7607. error(response, error, exception) {
  7608. if (window.DEBUG) {
  7609. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7610. response: response,
  7611. error: error,
  7612. exception: exception
  7613. });
  7614. }
  7615. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7616. resolve(true);
  7617. },
  7618. success(response) {
  7619. if (response.success) {
  7620. status.success(`Success:${response.text}`);
  7621. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7622. resolve(true);
  7623. } else {
  7624. status.error(`Error:${response.text}`);
  7625. resolve(true);
  7626. }
  7627. }
  7628. });
  7629. }));
  7630. } else if (promo.hasClass('emailoptinpromo')) {
  7631. pro.push(new Promise(resolve => {
  7632. $.ajax({
  7633. type: 'POST',
  7634. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7635. timeout: 6e4,
  7636. dataType: 'json',
  7637. data: {
  7638. ajax: 't',
  7639. emailsystoggle: 4
  7640. },
  7641. error(response, error, exception) {
  7642. if (window.DEBUG) {
  7643. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7644. response: response,
  7645. error: error,
  7646. exception: exception
  7647. });
  7648. }
  7649. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7650. resolve(true);
  7651. },
  7652. success(response) {
  7653. if (response.success) {
  7654. status.success(`Success:${response.text}`);
  7655. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7656. resolve(true);
  7657. } else {
  7658. status.error(`Error:${response.text}`);
  7659. resolve(true);
  7660. }
  7661. }
  7662. });
  7663. }));
  7664. } else if (promo.hasClass('watchingpromo')) {
  7665. pro.push(new Promise(resolve => {
  7666. var _promo$attr;
  7667. const data = getUrlQuery(promo.attr('href'));
  7668. data.ajax = 't';
  7669. $.ajax({
  7670. type: 'POST',
  7671. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7672. timeout: 6e4,
  7673. dataType: 'json',
  7674. data: data,
  7675. error(response, error, exception) {
  7676. if (window.DEBUG) {
  7677. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7678. response: response,
  7679. error: error,
  7680. exception: exception
  7681. });
  7682. }
  7683. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7684. resolve(true);
  7685. },
  7686. success(response) {
  7687. if (response.success) {
  7688. status.success(`Success:${response.text}`);
  7689. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7690. resolve(true);
  7691. } else {
  7692. status.error(`Error:${response.text}`);
  7693. resolve(true);
  7694. }
  7695. }
  7696. });
  7697. }));
  7698. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7699. pro.push(new Promise(resolve => {
  7700. $.ajax({
  7701. type: 'POST',
  7702. url: urlPath(promo.attr('href')),
  7703. timeout: 6e4,
  7704. dataType: 'json',
  7705. data: {
  7706. ajax: 't'
  7707. },
  7708. error(response, error, exception) {
  7709. if (window.DEBUG) {
  7710. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7711. response: response,
  7712. error: error,
  7713. exception: exception
  7714. });
  7715. }
  7716. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7717. resolve(true);
  7718. },
  7719. success(response) {
  7720. if (response.success) {
  7721. status.success(`Success:${response.text}`);
  7722. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7723. resolve(true);
  7724. } else {
  7725. status.error(`Error:${response.text}`);
  7726. resolve(true);
  7727. }
  7728. }
  7729. });
  7730. }));
  7731. } else {
  7732. status.error(`Error:${i18n('unKnownTaskType')}`);
  7733. }
  7734. }
  7735. }
  7736. await Promise.all(pro);
  7737. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7738. return true;
  7739. }
  7740. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7741. return false;
  7742. } catch (error) {
  7743. throwError(error, 'Indiedb.classifyTask');
  7744. return false;
  7745. }
  7746. }
  7747. function Indiedb_checkLogin2() {
  7748. try {
  7749. if (!globalOptions.other.checkLogin) {
  7750. return true;
  7751. }
  7752. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7753. window.open('/members/login', '_self');
  7754. }
  7755. return true;
  7756. } catch (error) {
  7757. throwError(error, 'Indiedb.checkLogin');
  7758. return false;
  7759. }
  7760. }
  7761. async function Indiedb_checkLeftKey2() {
  7762. try {
  7763. if (!globalOptions.other.checkLeftKey) {
  7764. return true;
  7765. }
  7766. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7767. await external_Swal_default().fire({
  7768. icon: 'warning',
  7769. title: i18n('notice'),
  7770. text: i18n('giveawayEnded'),
  7771. confirmButtonText: i18n('confirm'),
  7772. cancelButtonText: i18n('cancel'),
  7773. showCancelButton: true
  7774. }).then(_ref => {
  7775. let {
  7776. value
  7777. } = _ref;
  7778. if (value) {
  7779. window.close();
  7780. }
  7781. });
  7782. }
  7783. return true;
  7784. } catch (error) {
  7785. throwError(error, 'Indiedb.checkLeftKey');
  7786. return false;
  7787. }
  7788. }
  7789. const website_Indiedb = Indiedb;
  7790. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7791. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7792. privateSet.add(obj);
  7793. }
  7794. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7795. if (privateCollection.has(obj)) {
  7796. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7797. }
  7798. }
  7799. function Keyhub_defineProperty(obj, key, value) {
  7800. if (key in obj) {
  7801. Object.defineProperty(obj, key, {
  7802. value: value,
  7803. enumerable: true,
  7804. configurable: true,
  7805. writable: true
  7806. });
  7807. } else {
  7808. obj[key] = value;
  7809. }
  7810. return obj;
  7811. }
  7812. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7813. if (!privateSet.has(receiver)) {
  7814. throw new TypeError('attempted to get private field on non-instance');
  7815. }
  7816. return fn;
  7817. }
  7818. const Keyhub_defaultTasksTemplate = {
  7819. steam: {
  7820. groupLinks: [],
  7821. officialGroupLinks: [],
  7822. wishlistLinks: [],
  7823. curatorLinks: []
  7824. },
  7825. discord: {
  7826. serverLinks: []
  7827. },
  7828. links: []
  7829. };
  7830. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7831. var Keyhub_getGiveawayId = new WeakSet();
  7832. var Keyhub_checkLeftKey = new WeakSet();
  7833. var Keyhub_checkLogin = new WeakSet();
  7834. class Keyhub extends website_Website {
  7835. constructor() {
  7836. super(...arguments);
  7837. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7838. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7839. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7840. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7841. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7842. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7843. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7844. }
  7845. static test() {
  7846. return window.location.host === 'key-hub.eu';
  7847. }
  7848. async after() {
  7849. try {
  7850. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7851. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7852. }
  7853. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7854. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7855. }
  7856. $('.NSFW').hide();
  7857. } catch (error) {
  7858. throwError(error, 'Keyhub.after');
  7859. }
  7860. }
  7861. init() {
  7862. try {
  7863. const logStatus = scripts_echoLog({
  7864. text: i18n('initing')
  7865. });
  7866. if ($('a[href*="/connect/steam"]').length > 0) {
  7867. window.open('/connect/steam', '_self');
  7868. logStatus.warning(i18n('needLogin'));
  7869. return false;
  7870. }
  7871. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7872. return false;
  7873. }
  7874. $('#VPNoverlay').hide();
  7875. $('#mainArticleSection').show();
  7876. this.initialized = true;
  7877. logStatus.success();
  7878. return true;
  7879. } catch (error) {
  7880. throwError(error, 'Keyhub.init');
  7881. return false;
  7882. }
  7883. }
  7884. async classifyTask(action) {
  7885. try {
  7886. const logStatus = scripts_echoLog({
  7887. text: i18n('getTasksInfo')
  7888. });
  7889. if (action === 'undo') {
  7890. var _GM_getValue;
  7891. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7892. }
  7893. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7894. for (const task of tasks) {
  7895. let link = $(task).attr('href');
  7896. const taskDes = $(task).text().trim();
  7897. if (!link) {
  7898. continue;
  7899. }
  7900. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7901. link = await getRedirectLink(link) || link;
  7902. }
  7903. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7904. window.open(link, '_blank');
  7905. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7906. if (action === 'undo') {
  7907. this.socialTasks.steam.groupLinks.push(link);
  7908. }
  7909. if (action === 'do') {
  7910. this.undoneTasks.steam.groupLinks.push(link);
  7911. }
  7912. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7913. if (action === 'undo') {
  7914. this.socialTasks.steam.officialGroupLinks.push(link);
  7915. }
  7916. if (action === 'do') {
  7917. this.undoneTasks.steam.officialGroupLinks.push(link);
  7918. }
  7919. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7920. if (action === 'undo') {
  7921. this.socialTasks.steam.wishlistLinks.push(link);
  7922. }
  7923. if (action === 'do') {
  7924. this.undoneTasks.steam.wishlistLinks.push(link);
  7925. }
  7926. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7927. if (action === 'undo') {
  7928. this.socialTasks.steam.curatorLinks.push(link);
  7929. }
  7930. if (action === 'do') {
  7931. this.undoneTasks.steam.curatorLinks.push(link);
  7932. }
  7933. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7934. if (action === 'undo') {
  7935. this.socialTasks.discord.serverLinks.push(link);
  7936. }
  7937. if (action === 'do') {
  7938. this.undoneTasks.discord.serverLinks.push(link);
  7939. }
  7940. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link) || /^https?:\/\/www\.facebook\.com\/.*/.test(link)) {} else {
  7941. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7942. }
  7943. }
  7944. logStatus.success();
  7945. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7946. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7947. if (window.DEBUG) {
  7948. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7949. }
  7950. GM_setValue(`khTasks-${this.giveawayId}`, {
  7951. tasks: this.socialTasks,
  7952. time: new Date().getTime()
  7953. });
  7954. return true;
  7955. } catch (error) {
  7956. throwError(error, 'Keyhub.classifyTask');
  7957. return false;
  7958. }
  7959. }
  7960. verifyTask() {
  7961. try {
  7962. scripts_echoLog({
  7963. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7964. });
  7965. $.get(window.location.href, res => {
  7966. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7967. });
  7968. } catch (error) {
  7969. throwError(error, 'keyhub.verifyTask');
  7970. }
  7971. }
  7972. }
  7973. function Keyhub_getGiveawayId2() {
  7974. try {
  7975. var _window$location$href;
  7976. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7977. if (giveawayId) {
  7978. this.giveawayId = giveawayId;
  7979. return true;
  7980. }
  7981. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7982. return false;
  7983. } catch (error) {
  7984. throwError(error, 'Keyhub.getGiveawayId');
  7985. return false;
  7986. }
  7987. }
  7988. async function Keyhub_checkLeftKey2() {
  7989. try {
  7990. if (!globalOptions.other.checkLeftKey) {
  7991. return true;
  7992. }
  7993. const leftKey = $('#keysleft').text().trim();
  7994. if (leftKey === '0') {
  7995. await external_Swal_default().fire({
  7996. icon: 'warning',
  7997. title: i18n('notice'),
  7998. text: i18n('noKeysLeft'),
  7999. confirmButtonText: i18n('confirm'),
  8000. cancelButtonText: i18n('cancel'),
  8001. showCancelButton: true
  8002. }).then(_ref => {
  8003. let {
  8004. value
  8005. } = _ref;
  8006. if (value) {
  8007. window.close();
  8008. }
  8009. });
  8010. }
  8011. return true;
  8012. } catch (error) {
  8013. throwError(error, 'Keyhub.checkLeftKey');
  8014. return false;
  8015. }
  8016. }
  8017. function Keyhub_checkLogin2() {
  8018. try {
  8019. if (!globalOptions.other.checkLogin) {
  8020. return true;
  8021. }
  8022. if ($('a[href*="/connect/steam"]').length > 0) {
  8023. window.open('/connect/steam', '_self');
  8024. }
  8025. return true;
  8026. } catch (error) {
  8027. throwError(error, 'Keyhub.checkLogin');
  8028. return false;
  8029. }
  8030. }
  8031. const website_Keyhub = Keyhub;
  8032. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  8033. Givekey_checkPrivateRedeclaration(obj, privateSet);
  8034. privateSet.add(obj);
  8035. }
  8036. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  8037. if (privateCollection.has(obj)) {
  8038. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8039. }
  8040. }
  8041. function Givekey_defineProperty(obj, key, value) {
  8042. if (key in obj) {
  8043. Object.defineProperty(obj, key, {
  8044. value: value,
  8045. enumerable: true,
  8046. configurable: true,
  8047. writable: true
  8048. });
  8049. } else {
  8050. obj[key] = value;
  8051. }
  8052. return obj;
  8053. }
  8054. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  8055. if (!privateSet.has(receiver)) {
  8056. throw new TypeError('attempted to get private field on non-instance');
  8057. }
  8058. return fn;
  8059. }
  8060. const Givekey_defaultTasksTemplate = {
  8061. steam: {
  8062. groupLinks: [],
  8063. wishlistLinks: [],
  8064. curatorLinks: [],
  8065. curatorLikeLinks: []
  8066. },
  8067. twitter: {
  8068. userLinks: []
  8069. },
  8070. vk: {
  8071. nameLinks: []
  8072. },
  8073. discord: {
  8074. serverLinks: []
  8075. }
  8076. };
  8077. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  8078. var Givekey_verify = new WeakSet();
  8079. var Givekey_getGiveawayId = new WeakSet();
  8080. var Givekey_checkLeftKey = new WeakSet();
  8081. class Givekey extends website_Website {
  8082. constructor() {
  8083. super(...arguments);
  8084. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  8085. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  8086. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  8087. Givekey_defineProperty(this, 'name', 'Givekey');
  8088. Givekey_defineProperty(this, 'tasks', []);
  8089. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  8090. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  8091. Givekey_defineProperty(this, 'userId', void 0);
  8092. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8093. }
  8094. static test() {
  8095. return window.location.host === 'givekey.ru';
  8096. }
  8097. async after() {
  8098. try {
  8099. await new Promise(resolve => {
  8100. const checker = setInterval(() => {
  8101. if ($('#navbarDropdown').length > 0) {
  8102. clearInterval(checker);
  8103. resolve(true);
  8104. }
  8105. });
  8106. });
  8107. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8108. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8109. }
  8110. } catch (error) {
  8111. throwError(error, 'Givekey.after');
  8112. return false;
  8113. }
  8114. }
  8115. init() {
  8116. try {
  8117. const logStatus = scripts_echoLog({
  8118. text: i18n('initing')
  8119. });
  8120. if ($('a[href*="/auth/steam"]').length > 0) {
  8121. window.open('/auth/steam', '_self');
  8122. logStatus.warning(i18n('needLogin'));
  8123. return false;
  8124. }
  8125. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8126. return false;
  8127. }
  8128. const userId = $('meta[name="user-id"]').attr('content');
  8129. if (!userId) {
  8130. logStatus.error(i18n('getFailed', i18n('userId')));
  8131. return false;
  8132. }
  8133. this.userId = userId;
  8134. this.initialized = true;
  8135. logStatus.success();
  8136. return true;
  8137. } catch (error) {
  8138. throwError(error, 'Givekey.init');
  8139. return false;
  8140. }
  8141. }
  8142. async classifyTask(action) {
  8143. try {
  8144. const logStatus = scripts_echoLog({
  8145. text: i18n('getTasksInfo')
  8146. });
  8147. if (action === 'undo') {
  8148. var _GM_getValue;
  8149. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8150. }
  8151. const tasks = $('.card-body:has("button") .row');
  8152. for (const task of tasks) {
  8153. const taskEle = $(task);
  8154. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8155. if (isSuccess && action !== 'undo') {
  8156. continue;
  8157. }
  8158. const checkButton = taskEle.find('#task_check');
  8159. const taskId = checkButton.attr('data-id');
  8160. if (taskId) {
  8161. this.tasks.push(taskId);
  8162. }
  8163. if (action === 'verify') {
  8164. continue;
  8165. }
  8166. let href = taskEle.find('a').attr('href') || null;
  8167. const text = taskEle.find('a').text().trim();
  8168. const icon = taskEle.find('i');
  8169. if (!href || !text) {
  8170. continue;
  8171. }
  8172. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8173. href = await getRedirectLink(href);
  8174. }
  8175. if (!href) {
  8176. continue;
  8177. }
  8178. if (/^https?:\/\/vk\.com\//.test(href)) {
  8179. this.socialTasks.vk.nameLinks.push(href);
  8180. if (action === 'do' && !isSuccess) {
  8181. this.undoneTasks.vk.nameLinks.push(href);
  8182. }
  8183. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8184. this.socialTasks.steam.groupLinks.push(href);
  8185. if (action === 'do' && !isSuccess) {
  8186. this.undoneTasks.steam.groupLinks.push(href);
  8187. }
  8188. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8189. this.socialTasks.steam.wishlistLinks.push(href);
  8190. if (action === 'do' && !isSuccess) {
  8191. this.undoneTasks.steam.wishlistLinks.push(href);
  8192. }
  8193. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8194. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8195. this.socialTasks.steam.curatorLinks.push(href);
  8196. if (action === 'do' && !isSuccess) {
  8197. this.undoneTasks.steam.curatorLinks.push(href);
  8198. }
  8199. } else {
  8200. this.socialTasks.steam.curatorLikeLinks.push(href);
  8201. if (action === 'do' && !isSuccess) {
  8202. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8203. }
  8204. }
  8205. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8206. this.socialTasks.twitter.userLinks.push(href);
  8207. if (action === 'do' && !isSuccess) {
  8208. this.undoneTasks.twitter.userLinks.push(href);
  8209. }
  8210. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8211. this.socialTasks.discord.serverLinks.push(href);
  8212. if (action === 'do' && !isSuccess) {
  8213. this.undoneTasks.discord.serverLinks.push(href);
  8214. }
  8215. } else {
  8216. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8217. }
  8218. }
  8219. logStatus.success();
  8220. this.tasks = unique(this.tasks);
  8221. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8222. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8223. if (window.DEBUG) {
  8224. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8225. }
  8226. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8227. tasks: this.socialTasks,
  8228. time: new Date().getTime()
  8229. });
  8230. return true;
  8231. } catch (error) {
  8232. throwError(error, 'Givekey.classifyTask');
  8233. return false;
  8234. }
  8235. }
  8236. async verifyTask() {
  8237. try {
  8238. if (!this.initialized && !this.init()) {
  8239. return false;
  8240. }
  8241. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8242. return false;
  8243. }
  8244. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8245. const taskLength = this.tasks.length;
  8246. for (let i = 0; i < taskLength; i++) {
  8247. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8248. if (i < taskLength - 1) {
  8249. await delay(15e3);
  8250. }
  8251. }
  8252. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8253. scripts_echoLog({
  8254. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8255. });
  8256. return true;
  8257. } catch (error) {
  8258. throwError(error, 'Givekey.verifyTask');
  8259. return false;
  8260. }
  8261. }
  8262. }
  8263. async function Givekey_verify2(task) {
  8264. try {
  8265. const logStatus = scripts_echoLog({
  8266. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8267. });
  8268. return await new Promise(resolve => {
  8269. $.ajax({
  8270. url: 'https://givekey.ru/giveaway/task',
  8271. method: 'POST',
  8272. data: `id=${task}&user_id=${this.userId}`,
  8273. dataType: 'json',
  8274. headers: {
  8275. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8276. },
  8277. success: data => {
  8278. if (data.btn) {
  8279. $(`button[data-id=${this.userId}]`).html(data.btn);
  8280. }
  8281. if (data.status === 'ok') {
  8282. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8283. logStatus.success();
  8284. resolve(true);
  8285. } else if (data.status === 'end') {
  8286. logStatus.success();
  8287. scripts_echoLog({}).success(data.key);
  8288. resolve(true);
  8289. } else {
  8290. logStatus.error(`Error:${data.msg}`);
  8291. resolve(false);
  8292. }
  8293. },
  8294. error: xhr => {
  8295. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8296. resolve(false);
  8297. }
  8298. });
  8299. });
  8300. } catch (error) {
  8301. throwError(error, 'Givekey.verify');
  8302. return false;
  8303. }
  8304. }
  8305. function Givekey_getGiveawayId2() {
  8306. try {
  8307. var _window$location$href;
  8308. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8309. if (giveawayId) {
  8310. this.giveawayId = giveawayId;
  8311. return true;
  8312. }
  8313. scripts_echoLog({
  8314. text: i18n('getFailed', 'GiveawayId')
  8315. });
  8316. return false;
  8317. } catch (error) {
  8318. throwError(error, 'Givekey.getGiveawayId');
  8319. return false;
  8320. }
  8321. }
  8322. async function Givekey_checkLeftKey2() {
  8323. try {
  8324. if (!globalOptions.other.checkLeftKey) {
  8325. return true;
  8326. }
  8327. if (!$('#keys_count').text()) {
  8328. await external_Swal_default().fire({
  8329. icon: 'warning',
  8330. title: i18n('notice'),
  8331. text: i18n('noKeysLeft'),
  8332. confirmButtonText: i18n('confirm'),
  8333. cancelButtonText: i18n('cancel'),
  8334. showCancelButton: true
  8335. }).then(_ref => {
  8336. let {
  8337. value
  8338. } = _ref;
  8339. if (value) {
  8340. window.close();
  8341. }
  8342. });
  8343. }
  8344. return true;
  8345. } catch (error) {
  8346. throwError(error, 'Givekey.checkLeftKey');
  8347. return false;
  8348. }
  8349. }
  8350. const website_Givekey = Givekey;
  8351. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8352. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8353. privateSet.add(obj);
  8354. }
  8355. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8356. if (privateCollection.has(obj)) {
  8357. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8358. }
  8359. }
  8360. function GiveeClub_defineProperty(obj, key, value) {
  8361. if (key in obj) {
  8362. Object.defineProperty(obj, key, {
  8363. value: value,
  8364. enumerable: true,
  8365. configurable: true,
  8366. writable: true
  8367. });
  8368. } else {
  8369. obj[key] = value;
  8370. }
  8371. return obj;
  8372. }
  8373. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8374. if (!privateSet.has(receiver)) {
  8375. throw new TypeError('attempted to get private field on non-instance');
  8376. }
  8377. return fn;
  8378. }
  8379. var GiveeClub_checkLogin = new WeakSet();
  8380. var GiveeClub_getGiveawayId = new WeakSet();
  8381. var GiveeClub_checkLeftKey = new WeakSet();
  8382. class GiveeClub extends GiveawaySu {
  8383. constructor() {
  8384. super(...arguments);
  8385. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8386. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8387. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8388. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8389. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  8390. }
  8391. static test() {
  8392. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8393. }
  8394. async after() {
  8395. try {
  8396. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8397. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8398. }
  8399. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8400. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8401. }
  8402. } catch (error) {
  8403. throwError(error, 'GiveeClub.after');
  8404. }
  8405. }
  8406. init() {
  8407. try {
  8408. const logStatus = scripts_echoLog({
  8409. text: i18n('initing')
  8410. });
  8411. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8412. logStatus.warning(i18n('needLogin'));
  8413. return false;
  8414. }
  8415. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8416. return false;
  8417. }
  8418. this.initialized = true;
  8419. logStatus.success();
  8420. return true;
  8421. } catch (error) {
  8422. throwError(error, 'GiveeClub.init');
  8423. return false;
  8424. }
  8425. }
  8426. async classifyTask(action) {
  8427. try {
  8428. const logStatus = scripts_echoLog({
  8429. text: i18n('getTasksInfo')
  8430. });
  8431. if (action === 'undo') {
  8432. var _GM_getValue;
  8433. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8434. return true;
  8435. }
  8436. const pro = [];
  8437. const tasks = $('.event-actions tr');
  8438. for (const task of tasks) {
  8439. pro.push(new Promise(resolve => {
  8440. const taskDes = $(task).find('.event-action-label a');
  8441. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8442. const taskName = taskDes.text().trim();
  8443. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8444. return resolve(true);
  8445. }
  8446. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8447. if (!taskLink) {
  8448. return resolve(false);
  8449. }
  8450. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8451. this.undoneTasks.steam.groupLinks.push(taskLink);
  8452. } else if (/like.*announcement/gi.test(taskName)) {
  8453. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8454. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8455. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8456. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  8457. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8458. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8459. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8460. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8461. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8462. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8463. this.undoneTasks.steam.forumLinks.push(taskLink);
  8464. } else if (taskIcon.includes('discord')) {
  8465. this.undoneTasks.discord.serverLinks.push(taskLink);
  8466. } else if (taskIcon.includes('instagram')) {
  8467. this.undoneTasks.instagram.userLinks.push(taskLink);
  8468. } else if (taskIcon.includes('twitch')) {
  8469. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8470. } else if (taskIcon.includes('reddit')) {
  8471. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8472. } else if (/watch.*art/gim.test(taskName)) {
  8473. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8474. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8475. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8476. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8477. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8478. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8479. this.undoneTasks.vk.nameLinks.push(taskLink);
  8480. } else {
  8481. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8482. if (/follow.*button/gim.test(taskName)) {
  8483. this.undoneTasks.steam.followLinks.push(taskLink);
  8484. }
  8485. }
  8486. }
  8487. resolve(true);
  8488. }).catch(error => {
  8489. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8490. return false;
  8491. });
  8492. }));
  8493. }
  8494. await Promise.all(pro);
  8495. logStatus.success();
  8496. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8497. this.socialTasks = this.undoneTasks;
  8498. if (window.DEBUG) {
  8499. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8500. }
  8501. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8502. tasks: this.socialTasks,
  8503. time: new Date().getTime()
  8504. });
  8505. return true;
  8506. } catch (error) {
  8507. throwError(error, 'GiveeClub.classifyTask');
  8508. return false;
  8509. }
  8510. }
  8511. }
  8512. function GiveeClub_checkLogin2() {
  8513. try {
  8514. if (!globalOptions.other.checkLogin) {
  8515. return true;
  8516. }
  8517. if ($('a[href*="/account/auth"]').length > 0) {
  8518. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8519. }
  8520. return true;
  8521. } catch (error) {
  8522. throwError(error, 'GiveeClub.checkLogin');
  8523. return false;
  8524. }
  8525. }
  8526. function GiveeClub_getGiveawayId2() {
  8527. var _window$location$href;
  8528. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8529. if (giveawayId) {
  8530. this.giveawayId = giveawayId;
  8531. return true;
  8532. }
  8533. scripts_echoLog({
  8534. text: i18n('getFailed', 'GiveawayId')
  8535. });
  8536. return false;
  8537. }
  8538. async function GiveeClub_checkLeftKey2() {
  8539. try {
  8540. if (!globalOptions.other.checkLeftKey) {
  8541. return true;
  8542. }
  8543. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8544. await external_Swal_default().fire({
  8545. icon: 'warning',
  8546. title: i18n('notice'),
  8547. text: i18n('giveawayEnded'),
  8548. confirmButtonText: i18n('confirm'),
  8549. cancelButtonText: i18n('cancel'),
  8550. showCancelButton: true
  8551. }).then(_ref => {
  8552. let {
  8553. value
  8554. } = _ref;
  8555. if (value) {
  8556. window.close();
  8557. }
  8558. });
  8559. }
  8560. return true;
  8561. } catch (error) {
  8562. throwError(error, 'Giveawaysu.checkLeftKey');
  8563. return false;
  8564. }
  8565. }
  8566. const website_GiveeClub = GiveeClub;
  8567. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8568. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8569. privateSet.add(obj);
  8570. }
  8571. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8572. if (privateCollection.has(obj)) {
  8573. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8574. }
  8575. }
  8576. function OpiumPulses_defineProperty(obj, key, value) {
  8577. if (key in obj) {
  8578. Object.defineProperty(obj, key, {
  8579. value: value,
  8580. enumerable: true,
  8581. configurable: true,
  8582. writable: true
  8583. });
  8584. } else {
  8585. obj[key] = value;
  8586. }
  8587. return obj;
  8588. }
  8589. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8590. if (!privateSet.has(receiver)) {
  8591. throw new TypeError('attempted to get private field on non-instance');
  8592. }
  8593. return fn;
  8594. }
  8595. const defaultOptions = {
  8596. maxPoint: '99999999'
  8597. };
  8598. var _toggleTask = new WeakSet();
  8599. var OpiumPulses_checkLogin = new WeakSet();
  8600. class OpiumPulses {
  8601. constructor() {
  8602. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8603. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8604. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8605. OpiumPulses_defineProperty(this, 'options', {
  8606. ...defaultOptions,
  8607. ...GM_getValue('OpiumPulsesOptions')
  8608. });
  8609. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8610. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8611. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8612. }
  8613. static test() {
  8614. return window.location.host === 'www.opiumpulses.com';
  8615. }
  8616. async after() {
  8617. try {
  8618. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8619. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8620. }
  8621. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8622. } catch (error) {
  8623. throwError(error, 'OpiumPulses.after');
  8624. }
  8625. }
  8626. async doFreeTask() {
  8627. try {
  8628. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8629. } catch (error) {
  8630. throwError(error, 'OpiumPulses.doFreeTask');
  8631. }
  8632. }
  8633. async doPointTask() {
  8634. try {
  8635. var _$$text$match;
  8636. 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);
  8637. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8638. } catch (error) {
  8639. throwError(error, 'OpiumPulses.doPointTask');
  8640. }
  8641. }
  8642. init() {
  8643. return true;
  8644. }
  8645. classifyTask() {
  8646. return true;
  8647. }
  8648. }
  8649. async function _toggleTask2(type) {
  8650. try {
  8651. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8652. for (const item of items) {
  8653. var _$$find$text$match;
  8654. 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);
  8655. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8656. if (type === 'points' && needPoints > this.myPoints) {
  8657. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8658. } else if (type === 'points' && !needPoints) {
  8659. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8660. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8661. var _aElement$attr;
  8662. const logStatus = scripts_echoLog({
  8663. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8664. });
  8665. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8666. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8667. var _aElement$attr2, _aElement$attr2$match;
  8668. 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];
  8669. if (giveawayId) {
  8670. checkUser(giveawayId);
  8671. }
  8672. }
  8673. if (!aElement.attr('href')) {
  8674. logStatus.error('Error: No "href".');
  8675. continue;
  8676. }
  8677. const {
  8678. result,
  8679. statusText,
  8680. status,
  8681. data
  8682. } = await tools_httpRequest({
  8683. url: aElement.attr('href'),
  8684. method: 'GET'
  8685. });
  8686. if (result === 'Success') {
  8687. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8688. var _data$responseText$ma;
  8689. logStatus.success();
  8690. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8691. if (type === 'points' && points) {
  8692. this.myPoints = parseInt(points, 10);
  8693. }
  8694. } else {
  8695. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8696. }
  8697. } else {
  8698. logStatus.error(`${result}:${statusText}(${status})`);
  8699. }
  8700. }
  8701. }
  8702. scripts_echoLog({
  8703. text: '-----END-----'
  8704. });
  8705. } catch (error) {
  8706. throwError(error, 'OpiumPulses.toggleTask');
  8707. }
  8708. }
  8709. function OpiumPulses_checkLogin2() {
  8710. try {
  8711. if (!globalOptions.other.checkLogin) {
  8712. return true;
  8713. }
  8714. if ($('a[href*="/site/login"]').length > 1) {
  8715. window.open('/site/login', '_self');
  8716. }
  8717. return true;
  8718. } catch (error) {
  8719. throwError(error, 'OpiumPulses.checkLogin');
  8720. return false;
  8721. }
  8722. }
  8723. const website_OpiumPulses = OpiumPulses;
  8724. const external_dayjs_namespaceObject = dayjs;
  8725. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8726. const leftKeyChecker = {
  8727. async classify(link) {
  8728. try {
  8729. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8730. return await this.giveawaySu(link);
  8731. }
  8732. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8733. return await this.giveeClub(link);
  8734. }
  8735. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8736. return await this.gleam(link);
  8737. }
  8738. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8739. return await this.indieDb(link);
  8740. }
  8741. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8742. return await this.keyhub(link);
  8743. }
  8744. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8745. return await this.opquests(link);
  8746. }
  8747. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8748. return await this.itch(link);
  8749. }
  8750. return false;
  8751. } catch (error) {
  8752. throwError(error, 'leftKeyChecker.classify');
  8753. return false;
  8754. }
  8755. },
  8756. async giveawaySu(link) {
  8757. try {
  8758. const {
  8759. result,
  8760. data
  8761. } = await tools_httpRequest({
  8762. url: link,
  8763. method: 'GET'
  8764. });
  8765. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8766. if (data.responseText.includes('class="steam-login"')) {
  8767. return false;
  8768. }
  8769. if (data.responseText.includes('class="giveaway-ended"')) {
  8770. return 'Ended';
  8771. }
  8772. return 'Active';
  8773. }
  8774. return false;
  8775. } catch (error) {
  8776. throwError(error, 'leftKeyChecker.giveawaySu');
  8777. return false;
  8778. }
  8779. },
  8780. async giveeClub(link) {
  8781. try {
  8782. const {
  8783. result,
  8784. data
  8785. } = await tools_httpRequest({
  8786. url: link,
  8787. method: 'GET'
  8788. });
  8789. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8790. if (data.responseText.includes('class="event-winner"')) {
  8791. return 'Won';
  8792. }
  8793. if (data.responseText.includes('class="event-ended"')) {
  8794. return 'Ended';
  8795. }
  8796. return 'Active';
  8797. }
  8798. return false;
  8799. } catch (error) {
  8800. throwError(error, 'leftKeyChecker.giveeClub');
  8801. return false;
  8802. }
  8803. },
  8804. async gleam(link) {
  8805. try {
  8806. const {
  8807. result,
  8808. data
  8809. } = await tools_httpRequest({
  8810. url: link,
  8811. method: 'GET'
  8812. });
  8813. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8814. var _data$responseText$ma, _$$attr, _$$attr$match;
  8815. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8816. return 'Won';
  8817. }
  8818. 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];
  8819. if (!campaignDiv) {
  8820. return false;
  8821. }
  8822. 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];
  8823. if (!campaignString) {
  8824. return false;
  8825. }
  8826. const {
  8827. campaign
  8828. } = JSON.parse(campaignString);
  8829. if (campaign.banned) {
  8830. return 'Banned';
  8831. }
  8832. if (campaign.finished) {
  8833. return 'Ended';
  8834. }
  8835. if (campaign.paused) {
  8836. return 'Paused';
  8837. }
  8838. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8839. return 'NotStart';
  8840. }
  8841. return 'Active';
  8842. }
  8843. return false;
  8844. } catch (error) {
  8845. throwError(error, 'leftKeyChecker.gleam');
  8846. return false;
  8847. }
  8848. },
  8849. async indieDb(link) {
  8850. try {
  8851. const {
  8852. result,
  8853. data
  8854. } = await tools_httpRequest({
  8855. url: link,
  8856. method: 'GET'
  8857. });
  8858. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8859. if (data.responseText.includes('Congrats you WON')) {
  8860. return 'Won';
  8861. }
  8862. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8863. return 'Ended';
  8864. }
  8865. return 'Active';
  8866. }
  8867. return false;
  8868. } catch (error) {
  8869. throwError(error, 'leftKeyChecker.indieDb');
  8870. return false;
  8871. }
  8872. },
  8873. async keyhub(link) {
  8874. try {
  8875. const {
  8876. result,
  8877. data
  8878. } = await tools_httpRequest({
  8879. url: link,
  8880. method: 'GET'
  8881. });
  8882. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8883. var _data$responseText$ma2;
  8884. 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];
  8885. if (!keysleft) {
  8886. return false;
  8887. }
  8888. if (keysleft === '0') {
  8889. return 'Ended';
  8890. }
  8891. return `Active(${keysleft})`;
  8892. }
  8893. return false;
  8894. } catch (error) {
  8895. throwError(error, 'leftKeyChecker.keyhub');
  8896. return false;
  8897. }
  8898. },
  8899. async opquests(link) {
  8900. try {
  8901. const {
  8902. result,
  8903. data
  8904. } = await tools_httpRequest({
  8905. url: link,
  8906. method: 'GET'
  8907. });
  8908. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8909. var _data$responseText$ma3;
  8910. 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];
  8911. if (!keysleft) {
  8912. return false;
  8913. }
  8914. if (keysleft === '0') {
  8915. return 'Ended';
  8916. }
  8917. return `Active(${keysleft})`;
  8918. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8919. return 'Ended';
  8920. }
  8921. return false;
  8922. } catch (error) {
  8923. throwError(error, 'leftKeyChecker.opquests');
  8924. return false;
  8925. }
  8926. },
  8927. async itch(link) {
  8928. try {
  8929. const {
  8930. result,
  8931. data
  8932. } = await tools_httpRequest({
  8933. url: link,
  8934. method: 'GET'
  8935. });
  8936. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8937. var _data$responseText$ma4;
  8938. 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];
  8939. if (!endDate) {
  8940. return false;
  8941. }
  8942. if (new Date().getTime() > new Date(endDate).getTime()) {
  8943. return 'Ended';
  8944. }
  8945. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8946. }
  8947. return false;
  8948. } catch (error) {
  8949. throwError(error, 'leftKeyChecker.opquests');
  8950. return false;
  8951. }
  8952. }
  8953. };
  8954. const website_leftKeyChecker = leftKeyChecker;
  8955. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8956. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8957. privateSet.add(obj);
  8958. }
  8959. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8960. if (privateCollection.has(obj)) {
  8961. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8962. }
  8963. }
  8964. function Keylol_defineProperty(obj, key, value) {
  8965. if (key in obj) {
  8966. Object.defineProperty(obj, key, {
  8967. value: value,
  8968. enumerable: true,
  8969. configurable: true,
  8970. writable: true
  8971. });
  8972. } else {
  8973. obj[key] = value;
  8974. }
  8975. return obj;
  8976. }
  8977. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8978. if (!privateSet.has(receiver)) {
  8979. throw new TypeError('attempted to get private field on non-instance');
  8980. }
  8981. return fn;
  8982. }
  8983. const Keylol_defaultTasksTemplate = {
  8984. steam: {
  8985. groupLinks: [],
  8986. wishlistLinks: [],
  8987. curatorLinks: [],
  8988. curatorLikeLinks: [],
  8989. followLinks: [],
  8990. forumLinks: [],
  8991. announcementLinks: [],
  8992. workshopVoteLinks: [],
  8993. licenseLinks: []
  8994. },
  8995. discord: {
  8996. serverLinks: []
  8997. },
  8998. instagram: {
  8999. userLinks: []
  9000. },
  9001. vk: {
  9002. nameLinks: []
  9003. },
  9004. twitch: {
  9005. channelLinks: []
  9006. },
  9007. reddit: {
  9008. redditLinks: []
  9009. },
  9010. twitter: {
  9011. userLinks: [],
  9012. retweetLinks: []
  9013. },
  9014. youtube: {
  9015. channelLinks: [],
  9016. likeLinks: []
  9017. }
  9018. };
  9019. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  9020. var _addBtn = new WeakSet();
  9021. class Keylol extends website_Website {
  9022. constructor() {
  9023. super(...arguments);
  9024. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  9025. Keylol_defineProperty(this, 'name', 'Keylol');
  9026. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  9027. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  9028. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  9029. }
  9030. static test() {
  9031. var _$$eq$attr, _$$eq$attr2;
  9032. 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')));
  9033. }
  9034. init() {
  9035. return true;
  9036. }
  9037. after() {
  9038. try {
  9039. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  9040. const mainPost = $(selector);
  9041. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  9042. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  9043. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  9044. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  9045. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  9046. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  9047. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  9048. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  9049. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  9050. if (discordLinks.length > 0) {
  9051. for (const discordLink of discordLinks) {
  9052. const link = $(discordLink).attr('href');
  9053. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  9054. continue;
  9055. }
  9056. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  9057. }
  9058. }
  9059. if (redditLinks.length > 0) {
  9060. for (const redditLink of redditLinks) {
  9061. const link = $(redditLink).attr('href');
  9062. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  9063. continue;
  9064. }
  9065. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  9066. }
  9067. }
  9068. if (insLinks.length > 0) {
  9069. for (const insLink of insLinks) {
  9070. const link = $(insLink).attr('href');
  9071. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  9072. continue;
  9073. }
  9074. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  9075. }
  9076. }
  9077. if (twitterLinks.length > 0) {
  9078. for (const twitterLink of twitterLinks) {
  9079. const link = $(twitterLink).attr('href');
  9080. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  9081. continue;
  9082. }
  9083. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  9084. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  9085. } else {
  9086. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  9087. }
  9088. }
  9089. }
  9090. if (twitchLinks.length > 0) {
  9091. for (const twitchLink of twitchLinks) {
  9092. const link = $(twitchLink).attr('href');
  9093. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  9094. continue;
  9095. }
  9096. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9097. }
  9098. }
  9099. if (vkLinks.length > 0) {
  9100. for (const vkLink of vkLinks) {
  9101. const link = $(vkLink).attr('href');
  9102. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9103. continue;
  9104. }
  9105. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9106. }
  9107. }
  9108. if (steamStoreLinks.length > 0) {
  9109. for (const steamStoreLink of steamStoreLinks) {
  9110. const link = $(steamStoreLink).attr('href');
  9111. if (!link) {
  9112. continue;
  9113. }
  9114. if (/curator\/[\d]+/.test(link)) {
  9115. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9116. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9117. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9118. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9119. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9120. } else if (/app\/[\d]+/.test(link)) {
  9121. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9122. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9123. }
  9124. }
  9125. }
  9126. if (steamCommunityLinks.length > 0) {
  9127. for (const steamCommunityLink of steamCommunityLinks) {
  9128. const link = $(steamCommunityLink).attr('href');
  9129. if (!link) {
  9130. continue;
  9131. }
  9132. if (/groups\/.+/.test(link)) {
  9133. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9134. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9135. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9136. }
  9137. }
  9138. }
  9139. if (ytbLinks.length > 0) {
  9140. for (const ytbLink of ytbLinks) {
  9141. const link = $(ytbLink).attr('href');
  9142. if (!link) {
  9143. continue;
  9144. }
  9145. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9146. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9147. }
  9148. }
  9149. 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');
  9150. if (giveawayLinks.length > 0) {
  9151. for (const giveawayLink of giveawayLinks) {
  9152. const link = $(giveawayLink).attr('href');
  9153. if (!link) {
  9154. continue;
  9155. }
  9156. website_leftKeyChecker.classify(link).then(status => {
  9157. if (!status) {
  9158. return;
  9159. }
  9160. if (/^Active/.test(status)) {
  9161. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9162. return;
  9163. }
  9164. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9165. }).catch(error => {
  9166. throwError(error, 'keylol.after -> leftKeyChecker');
  9167. });
  9168. }
  9169. }
  9170. if (this.name === 'Keylol') {
  9171. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9172. if (asfLinks.length > 0) {
  9173. for (const asfLink of asfLinks) {
  9174. const link = $(asfLink).attr('href');
  9175. if (!link) {
  9176. continue;
  9177. }
  9178. 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', '')}`);
  9179. }
  9180. }
  9181. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9182. if (subLinks.length > 0) {
  9183. for (const subLink of subLinks) {
  9184. var _link$match;
  9185. const link = $(subLink).attr('href');
  9186. if (!link) {
  9187. continue;
  9188. }
  9189. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9190. if (!subid) {
  9191. continue;
  9192. }
  9193. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9194. }
  9195. }
  9196. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9197. if (asfLinks2.length > 0) {
  9198. for (const asfLink of asfLinks2) {
  9199. const subid = asfLink.innerText.match(/[\d]+/g);
  9200. if (!subid || subid.length === 0) {
  9201. continue;
  9202. }
  9203. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9204. }
  9205. }
  9206. }
  9207. } catch (error) {
  9208. throwError(error, 'keylol.after');
  9209. }
  9210. }
  9211. classifyTask(action) {
  9212. try {
  9213. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9214. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9215. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9216. for (const btn of selectedBtns) {
  9217. const button = $(btn);
  9218. const social = button.attr('data-social');
  9219. const type = button.attr('data-type');
  9220. const link = button.attr('data-link');
  9221. if (!(social && type && link)) {
  9222. continue;
  9223. }
  9224. if (action === 'do') {
  9225. this.undoneTasks[social][type].push(link);
  9226. }
  9227. if (action === 'undo') {
  9228. this.socialTasks[social][type].push(link);
  9229. }
  9230. }
  9231. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9232. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9233. if (window.DEBUG) {
  9234. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9235. }
  9236. return true;
  9237. } catch (error) {
  9238. throwError(error, 'Keylol.classifyTask');
  9239. return false;
  9240. }
  9241. }
  9242. selectAll() {
  9243. try {
  9244. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9245. } catch (error) {
  9246. throwError(error, 'Keylol.selectAll');
  9247. }
  9248. }
  9249. selectNone() {
  9250. try {
  9251. $('.auto-task-keylol:visible').removeAttr('selected');
  9252. } catch (error) {
  9253. throwError(error, 'Keylol.selectNone');
  9254. }
  9255. }
  9256. invertSelect() {
  9257. try {
  9258. $('.auto-task-keylol:visible').each((index, element) => {
  9259. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9260. });
  9261. } catch (error) {
  9262. throwError(error, 'Keylol.invertSelect');
  9263. }
  9264. }
  9265. }
  9266. function _addBtn2(before, social, linkType, link) {
  9267. try {
  9268. $(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>`);
  9269. } catch (error) {
  9270. throwError(error, 'keylol.addBtn');
  9271. }
  9272. }
  9273. const website_Keylol = Keylol;
  9274. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9275. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9276. privateSet.add(obj);
  9277. }
  9278. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9279. if (privateCollection.has(obj)) {
  9280. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9281. }
  9282. }
  9283. function Opquests_defineProperty(obj, key, value) {
  9284. if (key in obj) {
  9285. Object.defineProperty(obj, key, {
  9286. value: value,
  9287. enumerable: true,
  9288. configurable: true,
  9289. writable: true
  9290. });
  9291. } else {
  9292. obj[key] = value;
  9293. }
  9294. return obj;
  9295. }
  9296. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9297. if (!privateSet.has(receiver)) {
  9298. throw new TypeError('attempted to get private field on non-instance');
  9299. }
  9300. return fn;
  9301. }
  9302. const Opquests_defaultTasks = {
  9303. steam: {
  9304. groupLinks: [],
  9305. wishlistLinks: [],
  9306. followLinks: [],
  9307. curatorLikeLinks: []
  9308. }
  9309. };
  9310. var Opquests_getGiveawayId = new WeakSet();
  9311. var Opquests_checkLogin = new WeakSet();
  9312. class Opquests extends website_Website {
  9313. constructor() {
  9314. super(...arguments);
  9315. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9316. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9317. Opquests_defineProperty(this, 'name', 'Opquests');
  9318. Opquests_defineProperty(this, 'undoneTasks', {
  9319. ...Opquests_defaultTasks
  9320. });
  9321. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9322. }
  9323. static test() {
  9324. return window.location.host === 'opquests.com';
  9325. }
  9326. async after() {
  9327. try {
  9328. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9329. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9330. }
  9331. } catch (error) {
  9332. throwError(error, 'Opquests.after');
  9333. }
  9334. }
  9335. init() {
  9336. try {
  9337. const logStatus = scripts_echoLog({
  9338. text: i18n('initing')
  9339. });
  9340. if ($('a[href*="/auth/redirect"]').length > 0) {
  9341. window.open('/auth/redirect', '_self');
  9342. logStatus.warning(i18n('needLogin'));
  9343. return false;
  9344. }
  9345. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9346. return false;
  9347. }
  9348. this.initialized = true;
  9349. logStatus.success();
  9350. return true;
  9351. } catch (error) {
  9352. throwError(error, 'Opquests.init');
  9353. return false;
  9354. }
  9355. }
  9356. async classifyTask(action) {
  9357. try {
  9358. if (action === 'undo') {
  9359. scripts_echoLog({
  9360. text: i18n('cannotUndo')
  9361. });
  9362. return false;
  9363. }
  9364. const logStatus = scripts_echoLog({
  9365. text: i18n('getTasksInfo')
  9366. });
  9367. const tasks = $('.w-full:contains("Validate") .items-center');
  9368. for (const task of tasks) {
  9369. const link = $(task).find('a:contains("Open")').attr('href');
  9370. const taskDes = $(task).find('div').eq(1).text().trim();
  9371. if (!link) {
  9372. continue;
  9373. }
  9374. if (/steamcommunity\.com\/groups\//.test(link)) {
  9375. this.undoneTasks.steam.groupLinks.push(link);
  9376. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9377. if (/wishlist/gim.test(taskDes)) {
  9378. this.undoneTasks.steam.wishlistLinks.push(link);
  9379. } else if (/follow/gim.test(taskDes)) {
  9380. this.undoneTasks.steam.followLinks.push(link);
  9381. }
  9382. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9383. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9384. } else {
  9385. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9386. }
  9387. }
  9388. logStatus.success();
  9389. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9390. if (window.DEBUG) {
  9391. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9392. }
  9393. return true;
  9394. } catch (error) {
  9395. throwError(error, 'Opquests.classifyTask');
  9396. return false;
  9397. }
  9398. }
  9399. }
  9400. function Opquests_getGiveawayId2() {
  9401. try {
  9402. var _window$location$href;
  9403. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9404. if (giveawayId) {
  9405. this.giveawayId = giveawayId;
  9406. return true;
  9407. }
  9408. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9409. return false;
  9410. } catch (error) {
  9411. throwError(error, 'Opquests.getGiveawayId');
  9412. return false;
  9413. }
  9414. }
  9415. function Opquests_checkLogin2() {
  9416. try {
  9417. if (!globalOptions.other.checkLogin) {
  9418. return true;
  9419. }
  9420. if ($('a[href*="/auth/redirect"]').length > 0) {
  9421. window.open('/auth/redirect', '_self');
  9422. }
  9423. return true;
  9424. } catch (error) {
  9425. throwError(error, 'Opquests.checkLogin');
  9426. return false;
  9427. }
  9428. }
  9429. const website_Opquests = Opquests;
  9430. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9431. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9432. privateSet.add(obj);
  9433. }
  9434. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9435. if (privateCollection.has(obj)) {
  9436. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9437. }
  9438. }
  9439. function Gleam_defineProperty(obj, key, value) {
  9440. if (key in obj) {
  9441. Object.defineProperty(obj, key, {
  9442. value: value,
  9443. enumerable: true,
  9444. configurable: true,
  9445. writable: true
  9446. });
  9447. } else {
  9448. obj[key] = value;
  9449. }
  9450. return obj;
  9451. }
  9452. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9453. if (!privateSet.has(receiver)) {
  9454. throw new TypeError('attempted to get private field on non-instance');
  9455. }
  9456. return fn;
  9457. }
  9458. const Gleam_defaultTasksTemplate = {
  9459. steam: {
  9460. groupLinks: [],
  9461. wishlistLinks: [],
  9462. followLinks: [],
  9463. curatorLinks: [],
  9464. curatorLikeLinks: []
  9465. },
  9466. twitter: {
  9467. userLinks: [],
  9468. retweetLinks: []
  9469. },
  9470. twitch: {
  9471. channelLinks: []
  9472. },
  9473. discord: {
  9474. serverLinks: []
  9475. },
  9476. youtube: {
  9477. channelLinks: []
  9478. },
  9479. extra: {
  9480. gleam: []
  9481. }
  9482. };
  9483. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9484. const Gleam_defaultOptions = {
  9485. vlootUsername: '',
  9486. gameroundUsername: ''
  9487. };
  9488. var _checkSync = new WeakSet();
  9489. var _doGleamTask = new WeakSet();
  9490. var Gleam_getGiveawayId = new WeakSet();
  9491. var _getGleamLink = new WeakSet();
  9492. var Gleam_checkLeftKey = new WeakSet();
  9493. class Gleam extends website_Website {
  9494. constructor() {
  9495. super(...arguments);
  9496. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9497. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9498. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9499. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9500. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9501. Gleam_defineProperty(this, 'name', 'Gleam');
  9502. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9503. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9504. Gleam_defineProperty(this, 'options', {
  9505. ...Gleam_defaultOptions,
  9506. ...GM_getValue('GleamOptions')
  9507. });
  9508. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9509. }
  9510. static test() {
  9511. return window.location.host === 'gleam.io';
  9512. }
  9513. async after() {
  9514. try {
  9515. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9516. const checkComplete = setInterval(() => {
  9517. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9518. clearInterval(checkComplete);
  9519. window.close();
  9520. }
  9521. });
  9522. for (const task of $('.entry-content .entry-method')) {
  9523. const taskInfo = $(task).find('.user-links');
  9524. const expandInfo = $(task).find('.expandable');
  9525. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9526. if (aElements.length > 0) {
  9527. for (const element of aElements) {
  9528. const $element = $(element);
  9529. const href = $element.attr('href');
  9530. $element.removeAttr('href')[0].click();
  9531. $element.attr('href', href);
  9532. await delay(1e3);
  9533. }
  9534. }
  9535. taskInfo[0].click();
  9536. await delay(1e3);
  9537. }
  9538. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9539. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9540. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9541. }
  9542. } catch (error) {
  9543. throwError(error, 'Gleam.after');
  9544. return false;
  9545. }
  9546. }
  9547. init() {
  9548. try {
  9549. const logStatus = scripts_echoLog({
  9550. text: i18n('initing')
  9551. });
  9552. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9553. return false;
  9554. }
  9555. this.initialized = true;
  9556. logStatus.success();
  9557. return true;
  9558. } catch (error) {
  9559. throwError(error, 'Gleam.init');
  9560. return false;
  9561. }
  9562. }
  9563. async classifyTask(action) {
  9564. try {
  9565. const logStatus = scripts_echoLog({
  9566. text: i18n('getTasksInfo')
  9567. });
  9568. if (action === 'undo') {
  9569. var _GM_getValue;
  9570. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9571. }
  9572. const tasks = $('.entry-content .entry-method');
  9573. for (const task of tasks) {
  9574. var _socialIcon$attr;
  9575. const $task = $(task);
  9576. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9577. continue;
  9578. }
  9579. const socialIcon = $task.find('.icon-wrapper i');
  9580. const taskInfo = $task.find('.user-links');
  9581. const taskText = taskInfo.text().trim();
  9582. const expandInfo = $task.find('.expandable');
  9583. const aElements = expandInfo.find('a.btn');
  9584. if (aElements.length > 0) {
  9585. for (const element of aElements) {
  9586. const $element = $(element);
  9587. const href = $element.attr('href');
  9588. $element.removeAttr('href')[0].click();
  9589. $element.attr('href', href);
  9590. }
  9591. }
  9592. if (socialIcon.hasClass('fa-twitter')) {
  9593. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9594. if (!link) {
  9595. continue;
  9596. }
  9597. if (/follow/gi.test(taskText)) {
  9598. if (action === 'undo') {
  9599. this.socialTasks.twitter.userLinks.push(link);
  9600. }
  9601. if (action === 'do') {
  9602. this.undoneTasks.twitter.userLinks.push(link);
  9603. }
  9604. } else if (/retweet/gim.test(taskText)) {
  9605. if (action === 'undo') {
  9606. this.socialTasks.twitter.retweetLinks.push(link);
  9607. }
  9608. if (action === 'do') {
  9609. this.undoneTasks.twitter.retweetLinks.push(link);
  9610. }
  9611. }
  9612. } else if (socialIcon.hasClass('fa-twitch')) {
  9613. if (/follow/gim.test(taskText)) {
  9614. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9615. if (!link) {
  9616. continue;
  9617. }
  9618. if (action === 'undo') {
  9619. this.socialTasks.twitch.channelLinks.push(link);
  9620. }
  9621. if (action === 'do') {
  9622. this.undoneTasks.twitch.channelLinks.push(link);
  9623. }
  9624. }
  9625. } else if (socialIcon.hasClass('fa-discord')) {
  9626. if (/join/gim.test(taskText)) {
  9627. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9628. if (!link) {
  9629. var _$task$find$attr, _$task$find$attr$matc;
  9630. 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];
  9631. if (!ggLink) {
  9632. continue;
  9633. }
  9634. link = `https://discord.com/invite/${ggLink}`;
  9635. }
  9636. if (action === 'undo') {
  9637. this.socialTasks.discord.serverLinks.push(link);
  9638. }
  9639. if (action === 'do') {
  9640. this.undoneTasks.discord.serverLinks.push(link);
  9641. }
  9642. }
  9643. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9644. continue;
  9645. } else if (socialIcon.hasClass('fa-youtube')) {
  9646. if (/subscribe/gim.test(taskText)) {
  9647. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9648. if (!link) {
  9649. continue;
  9650. }
  9651. if (action === 'undo') {
  9652. this.socialTasks.youtube.channelLinks.push(link);
  9653. }
  9654. if (action === 'do') {
  9655. this.undoneTasks.youtube.channelLinks.push(link);
  9656. }
  9657. }
  9658. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9659. if (/join.*group/gi.test(taskText)) {
  9660. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9661. if (!link) {
  9662. continue;
  9663. }
  9664. if (action === 'undo') {
  9665. this.socialTasks.steam.groupLinks.push(link);
  9666. }
  9667. if (action === 'do') {
  9668. this.undoneTasks.steam.groupLinks.push(link);
  9669. }
  9670. } else if (/follow.*curator/gi.test(taskText)) {
  9671. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9672. if (!link) {
  9673. continue;
  9674. }
  9675. if (action === 'undo') {
  9676. this.socialTasks.steam.curatorLinks.push(link);
  9677. }
  9678. if (action === 'do') {
  9679. this.undoneTasks.steam.curatorLinks.push(link);
  9680. }
  9681. }
  9682. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9683. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9684. for (const button of continueBtn) {
  9685. button.click();
  9686. await delay(500);
  9687. expandInfo.find('input').val(this.options.vlootUsername);
  9688. }
  9689. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9690. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9691. for (const button of continueBtn) {
  9692. button.click();
  9693. await delay(500);
  9694. expandInfo.find('input').val(this.options.gameroundUsername);
  9695. }
  9696. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9697. if (action !== 'do') {
  9698. continue;
  9699. }
  9700. const link = aElements.attr('href');
  9701. if (!link) {
  9702. continue;
  9703. }
  9704. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9705. if (!gleamLink) {
  9706. continue;
  9707. }
  9708. this.undoneTasks.extra.gleam.push(gleamLink);
  9709. } 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 {
  9710. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9711. }
  9712. }
  9713. logStatus.success();
  9714. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9715. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9716. if (window.DEBUG) {
  9717. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9718. }
  9719. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9720. tasks: this.socialTasks,
  9721. time: new Date().getTime()
  9722. });
  9723. return true;
  9724. } catch (error) {
  9725. throwError(error, 'Gleam.classifyTask');
  9726. return false;
  9727. }
  9728. }
  9729. async extraDoTask(_ref) {
  9730. let {
  9731. gleam
  9732. } = _ref;
  9733. try {
  9734. const pro = [];
  9735. for (const link of gleam) {
  9736. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9737. }
  9738. return Promise.all(pro).then(() => true);
  9739. } catch (error) {
  9740. throwError(error, 'Gleam.extraDoTask');
  9741. return false;
  9742. }
  9743. }
  9744. async verifyTask() {
  9745. try {
  9746. scripts_echoLog({
  9747. text: `${i18n('verifyingTask')}...`
  9748. });
  9749. const tasks = $('.entry-content .entry-method');
  9750. for (const task of tasks) {
  9751. const $task = $(task);
  9752. if ($task.find('i.fa-question').length === 0) {
  9753. continue;
  9754. }
  9755. const taskInfo = $task.find('.user-links');
  9756. taskInfo[0].click();
  9757. await delay(500);
  9758. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9759. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9760. for (const button of continueBtn) {
  9761. button.click();
  9762. await delay(500);
  9763. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9764. }
  9765. }
  9766. scripts_echoLog({
  9767. text: i18n('verifiedGleamTasks')
  9768. });
  9769. } catch (error) {
  9770. throwError(error, 'Gleam.verifyTask');
  9771. return false;
  9772. }
  9773. }
  9774. }
  9775. async function _checkSync2() {
  9776. try {
  9777. return await new Promise(resolve => {
  9778. const checker = setInterval(() => {
  9779. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9780. clearInterval(checker);
  9781. resolve(true);
  9782. }
  9783. }, 500);
  9784. });
  9785. } catch (error) {
  9786. throwError(error, 'Gleam.checkSync');
  9787. return false;
  9788. }
  9789. }
  9790. async function _doGleamTask2(link) {
  9791. try {
  9792. const logStatus = scripts_echoLog({
  9793. text: i18n('doingGleamTask')
  9794. });
  9795. return await new Promise(resolve => {
  9796. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9797. active: true,
  9798. insert: true,
  9799. setParent: true
  9800. }).onclose = () => {
  9801. logStatus.success();
  9802. resolve(true);
  9803. };
  9804. });
  9805. } catch (error) {
  9806. throwError(error, 'Gleam.doGleamTask');
  9807. return false;
  9808. }
  9809. }
  9810. function Gleam_getGiveawayId2() {
  9811. try {
  9812. const giveawayId = window.location.pathname;
  9813. if (giveawayId) {
  9814. this.giveawayId = giveawayId;
  9815. return true;
  9816. }
  9817. scripts_echoLog({
  9818. text: i18n('getFailed', 'GiveawayId')
  9819. });
  9820. return false;
  9821. } catch (error) {
  9822. throwError(error, 'Gleam.getGiveawayId');
  9823. return false;
  9824. }
  9825. }
  9826. async function _getGleamLink2(link) {
  9827. try {
  9828. const logStatus = scripts_echoLog({
  9829. text: i18n('gettingGleamLink')
  9830. });
  9831. const {
  9832. result,
  9833. statusText,
  9834. status,
  9835. data
  9836. } = await tools_httpRequest({
  9837. url: link,
  9838. method: 'GET'
  9839. });
  9840. if (result === 'Success') {
  9841. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9842. var _data$responseText$ma;
  9843. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9844. if (gleamLink) {
  9845. logStatus.success();
  9846. return gleamLink;
  9847. }
  9848. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9849. return false;
  9850. }
  9851. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9852. return false;
  9853. }
  9854. logStatus.error(`${result}:${statusText}(${status})`);
  9855. return false;
  9856. } catch (error) {
  9857. throwError(error, 'Gleam.getGleamLink');
  9858. return false;
  9859. }
  9860. }
  9861. async function Gleam_checkLeftKey2() {
  9862. try {
  9863. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9864. if (!globalOptions.other.checkLeftKey) {
  9865. return true;
  9866. }
  9867. 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];
  9868. if (!campaignString) {
  9869. return false;
  9870. }
  9871. const {
  9872. campaign,
  9873. incentive
  9874. } = JSON.parse(campaignString);
  9875. 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];
  9876. let ownedKey = false;
  9877. if (controllerString) {
  9878. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9879. 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) {
  9880. ownedKey = true;
  9881. }
  9882. }
  9883. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9884. await external_Swal_default().fire({
  9885. icon: 'warning',
  9886. title: i18n('notice'),
  9887. text: i18n('giveawayNotWork'),
  9888. confirmButtonText: i18n('confirm'),
  9889. cancelButtonText: i18n('cancel'),
  9890. showCancelButton: true
  9891. }).then(_ref2 => {
  9892. let {
  9893. value
  9894. } = _ref2;
  9895. if (value) {
  9896. window.close();
  9897. }
  9898. });
  9899. }
  9900. return true;
  9901. } catch (error) {
  9902. throwError(error, 'Gleam.checkLeftKey');
  9903. return false;
  9904. }
  9905. }
  9906. const website_Gleam = Gleam;
  9907. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9908. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9909. privateSet.add(obj);
  9910. }
  9911. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9912. if (privateCollection.has(obj)) {
  9913. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9914. }
  9915. }
  9916. function SweepWidget_defineProperty(obj, key, value) {
  9917. if (key in obj) {
  9918. Object.defineProperty(obj, key, {
  9919. value: value,
  9920. enumerable: true,
  9921. configurable: true,
  9922. writable: true
  9923. });
  9924. } else {
  9925. obj[key] = value;
  9926. }
  9927. return obj;
  9928. }
  9929. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9930. if (!privateSet.has(receiver)) {
  9931. throw new TypeError('attempted to get private field on non-instance');
  9932. }
  9933. return fn;
  9934. }
  9935. const SweepWidget_defaultOptions = {
  9936. username: '',
  9937. email: ''
  9938. };
  9939. var SweepWidget_checkLogin = new WeakSet();
  9940. var SweepWidget_getGiveawayId = new WeakSet();
  9941. var _checkEnter = new WeakSet();
  9942. var _checkFinish = new WeakSet();
  9943. class SweepWidget extends website_Website {
  9944. constructor() {
  9945. super(...arguments);
  9946. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9947. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9948. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9949. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9950. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9951. SweepWidget_defineProperty(this, 'options', {
  9952. ...SweepWidget_defaultOptions,
  9953. ...GM_getValue('SweepWidgetOptions')
  9954. });
  9955. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9956. }
  9957. static test() {
  9958. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9959. }
  9960. async after() {
  9961. try {
  9962. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9963. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9964. }
  9965. } catch (error) {
  9966. throwError(error, 'SweepWidget.after');
  9967. }
  9968. }
  9969. init() {
  9970. try {
  9971. const logStatus = scripts_echoLog({
  9972. text: i18n('initing')
  9973. });
  9974. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9975. logStatus.warning(i18n('needLogin'));
  9976. return false;
  9977. }
  9978. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9979. return false;
  9980. }
  9981. this.initialized = true;
  9982. logStatus.success();
  9983. return true;
  9984. } catch (error) {
  9985. throwError(error, 'SweepWidget.init');
  9986. return false;
  9987. }
  9988. }
  9989. classifyTask() {
  9990. return true;
  9991. }
  9992. async doTask() {
  9993. try {
  9994. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9995. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9996. $('input[name="sw__login_name"]').val(this.options.username);
  9997. }
  9998. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9999. $('input[name="sw__login_email"]').val(this.options.email);
  10000. }
  10001. if ($('#sw_login_button:visible').length > 0) {
  10002. $('#sw_login_button')[0].click();
  10003. }
  10004. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  10005. return false;
  10006. }
  10007. }
  10008. const logStatus = scripts_echoLog({
  10009. text: i18n('SweepWidgetNotice')
  10010. });
  10011. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  10012. for (const task of tasks) {
  10013. var _aElement$, _$task$find$removeAtt;
  10014. const $task = $(task);
  10015. if ($task.find('i.fa-check:visible').length > 0) {
  10016. continue;
  10017. }
  10018. const title = $task.find('.sw_text_inner');
  10019. title[0].click();
  10020. const aElement = $task.find('a.sw_link');
  10021. const link = aElement.attr('href');
  10022. aElement.attr('href', '#a').attr('target', '_self');
  10023. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  10024. await delay(300);
  10025. aElement.attr('href', link).attr('target', '_blank');
  10026. $task.find('input[type="text"]').val('test');
  10027. const verifyBtn = $task.find('input.sw_verify');
  10028. if (verifyBtn.prop('disabled') === true) {
  10029. title[0].click();
  10030. await delay(300);
  10031. title[0].click();
  10032. await delay(300);
  10033. }
  10034. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  10035. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  10036. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  10037. }
  10038. logStatus.success();
  10039. return true;
  10040. } catch (error) {
  10041. throwError(error, 'SweepWidget.doTask');
  10042. return false;
  10043. }
  10044. }
  10045. }
  10046. function SweepWidget_checkLogin2() {
  10047. try {
  10048. if ($('#twitter_login_button').length > 0) {
  10049. $('#twitter_login_button')[0].click();
  10050. }
  10051. return true;
  10052. } catch (error) {
  10053. throwError(error, 'SweepWidget.checkLogin');
  10054. return false;
  10055. }
  10056. }
  10057. function SweepWidget_getGiveawayId2() {
  10058. try {
  10059. var _window$location$href;
  10060. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  10061. if (giveawayId) {
  10062. this.giveawayId = giveawayId;
  10063. return true;
  10064. }
  10065. scripts_echoLog({
  10066. text: i18n('getFailed', 'GiveawayId')
  10067. });
  10068. return false;
  10069. } catch (error) {
  10070. throwError(error, 'SweepWidget.getGiveawayId');
  10071. return false;
  10072. }
  10073. }
  10074. async function _checkEnter2() {
  10075. try {
  10076. return new Promise(resolve => {
  10077. const checker = setInterval(() => {
  10078. if ($('#unlock_rewards_main_wrapper').length > 0) {
  10079. clearInterval(checker);
  10080. resolve(true);
  10081. }
  10082. });
  10083. });
  10084. } catch (error) {
  10085. throwError(error, 'SweepWidget.checkEnter');
  10086. return false;
  10087. }
  10088. }
  10089. async function _checkFinish2($task) {
  10090. try {
  10091. return new Promise(resolve => {
  10092. const checker = setInterval(() => {
  10093. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  10094. clearInterval(checker);
  10095. resolve(true);
  10096. }
  10097. });
  10098. });
  10099. } catch (error) {
  10100. throwError(error, 'SweepWidget.checkFinish');
  10101. return false;
  10102. }
  10103. }
  10104. const website_SweepWidget = SweepWidget;
  10105. const defaultWhiteList = {
  10106. discord: {
  10107. servers: []
  10108. },
  10109. instagram: {
  10110. users: []
  10111. },
  10112. twitch: {
  10113. channels: []
  10114. },
  10115. twitter: {
  10116. users: [],
  10117. retweets: [],
  10118. likes: []
  10119. },
  10120. vk: {
  10121. names: []
  10122. },
  10123. youtube: {
  10124. channels: [],
  10125. likes: []
  10126. },
  10127. reddit: {
  10128. reddits: []
  10129. },
  10130. steam: {
  10131. groups: [],
  10132. officialGroups: [],
  10133. wishlists: [],
  10134. follows: [],
  10135. forums: [],
  10136. workshops: [],
  10137. curators: [],
  10138. workshopVotes: [],
  10139. curatorLikes: [],
  10140. announcements: [],
  10141. licenses: [],
  10142. playtests: []
  10143. }
  10144. };
  10145. const link2id = async function(type) {
  10146. 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;
  10147. try {
  10148. const link = $('#socialLink').val();
  10149. let id = '';
  10150. switch (type) {
  10151. case 'discord.servers':
  10152. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10153. break;
  10154.  
  10155. case 'instagram.users':
  10156. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10157. break;
  10158.  
  10159. case 'twitch.channels':
  10160. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10161. break;
  10162.  
  10163. case 'twitter.users':
  10164. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10165. break;
  10166.  
  10167. case 'twitter.retweets':
  10168. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10169. break;
  10170.  
  10171. case 'vk.names':
  10172. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10173. break;
  10174.  
  10175. case 'youtube.channels':
  10176. 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) || '';
  10177. break;
  10178.  
  10179. case 'youtube.likes':
  10180. 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) || '';
  10181. break;
  10182.  
  10183. case 'reddit.reddits':
  10184. 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]) || '';
  10185. break;
  10186.  
  10187. case 'steam.groups':
  10188. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10189. break;
  10190.  
  10191. case 'steam.wishlists':
  10192. case 'steam.follows':
  10193. case 'steam.forums':
  10194. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10195. break;
  10196.  
  10197. case 'steam.workshops':
  10198. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10199. break;
  10200.  
  10201. case 'steam.curators':
  10202. {
  10203. if (link.includes('curator')) {
  10204. var _link$match12;
  10205. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10206. } else {
  10207. var _link$match13;
  10208. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10209. if (!param || param.length !== 2) {
  10210. break;
  10211. }
  10212. const steam = new social_Steam();
  10213. if (await steam.init()) {
  10214. id = await steam.getCuratorId(param[0], param[1]) || '';
  10215. }
  10216. }
  10217. }
  10218. break;
  10219. }
  10220. return id;
  10221. } catch (error) {
  10222. throwError(error, 'link2id');
  10223. return i18n('getFailed', 'id');
  10224. }
  10225. };
  10226. const disabledType = {
  10227. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10228. twitter: [ 'likes' ]
  10229. };
  10230. const assignWhiteList = whiteList => {
  10231. try {
  10232. const newWhiteList = {};
  10233. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10234. newWhiteList[key] = {
  10235. ...value,
  10236. ...whiteList[key]
  10237. };
  10238. }
  10239. return newWhiteList;
  10240. } catch (error) {
  10241. throwError(error, 'assignWhiteList');
  10242. return defaultWhiteList;
  10243. }
  10244. };
  10245. const whiteListOptions = function(showType) {
  10246. try {
  10247. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10248. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10249. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10250. for (const [ social, types ] of Object.entries(whiteList)) {
  10251. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10252. var _disabledType$social;
  10253. 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>`;
  10254. }).join('');
  10255. }
  10256. whiteListOptionsForm += '</tbody></table></form>';
  10257. if (showType === 'swal') {
  10258. external_Swal_default().fire({
  10259. title: i18n('whiteListOptions'),
  10260. html: whiteListOptionsForm,
  10261. showConfirmButton: false,
  10262. showCloseButton: true
  10263. });
  10264. } else {
  10265. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10266. }
  10267. $('.editWhiteList').on('click', function() {
  10268. var _whiteList$social;
  10269. const value = $(this).attr('data-value');
  10270. if (!value) {
  10271. return;
  10272. }
  10273. const [ social, type ] = value.split('.');
  10274. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10275. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10276. return;
  10277. }
  10278. external_Swal_default().fire({
  10279. title: i18n('changeWhiteListOption', value),
  10280. input: 'textarea',
  10281. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10282. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10283. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10284. inputValue: whiteList[social][type].join('\n'),
  10285. showConfirmButton: true,
  10286. confirmButtonText: i18n('save'),
  10287. showCancelButton: true,
  10288. cancelButtonText: i18n('close'),
  10289. showDenyButton: true,
  10290. denyButtonText: i18n('return')
  10291. }).then(_ref => {
  10292. let {
  10293. isDenied,
  10294. isConfirmed,
  10295. value
  10296. } = _ref;
  10297. if (isDenied) {
  10298. if (showType === 'swal') {
  10299. whiteListOptions(showType);
  10300. }
  10301. return;
  10302. } else if (isConfirmed) {
  10303. whiteList[social][type] = value.split('\n');
  10304. GM_setValue('whiteList', whiteList);
  10305. external_Swal_default().fire({
  10306. title: i18n('changeWhiteListSuccess'),
  10307. icon: 'success'
  10308. });
  10309. }
  10310. });
  10311. $('#link2id').on('click', async function() {
  10312. const type = $(this).attr('data-type');
  10313. $('#socialLink').val(await link2id(type));
  10314. });
  10315. });
  10316. } catch (error) {
  10317. throwError(error, 'whiteListOptions');
  10318. }
  10319. };
  10320. const whiteList = whiteListOptions;
  10321. const setGistData = async (token, gistId, fileName, content) => {
  10322. try {
  10323. const logStatus = scripts_echoLog({
  10324. text: i18n('settingData')
  10325. });
  10326. const contentData = JSON.stringify({
  10327. files: {
  10328. [fileName]: {
  10329. content: JSON.stringify(content)
  10330. }
  10331. }
  10332. });
  10333. const {
  10334. result,
  10335. statusText,
  10336. status,
  10337. data
  10338. } = await tools_httpRequest({
  10339. url: `https://api.github.com/gists/${gistId}`,
  10340. headers: {
  10341. Accept: 'application/vnd.github.v3+json',
  10342. Authorization: `token ${token}`
  10343. },
  10344. data: contentData,
  10345. responseType: 'json',
  10346. method: 'POST',
  10347. timeout: 3e4
  10348. });
  10349. if (result === 'Success') {
  10350. var _data$response$files, _data$response$files$;
  10351. 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)) {
  10352. logStatus.success();
  10353. return true;
  10354. }
  10355. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10356. return false;
  10357. }
  10358. logStatus.error(`${result}:${statusText}(${status})`);
  10359. return false;
  10360. } catch (error) {
  10361. throwError(error, 'setGistData');
  10362. return false;
  10363. }
  10364. };
  10365. const getGistData = async function(token, gistId, fileName) {
  10366. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10367. try {
  10368. const logStatus = scripts_echoLog({
  10369. text: i18n('gettingData')
  10370. });
  10371. const {
  10372. result,
  10373. statusText,
  10374. status,
  10375. data
  10376. } = await tools_httpRequest({
  10377. url: `https://api.github.com/gists/${gistId}`,
  10378. headers: {
  10379. Accept: 'application/vnd.github.v3+json',
  10380. Authorization: `token ${token}`
  10381. },
  10382. responseType: 'json',
  10383. method: 'GET',
  10384. timeout: 3e4
  10385. });
  10386. if (result === 'Success') {
  10387. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10388. var _data$response, _data$response$files2, _data$response$files3;
  10389. 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;
  10390. let formatedContent;
  10391. if (!content) {
  10392. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10393. return false;
  10394. }
  10395. if (test) {
  10396. logStatus.success();
  10397. return true;
  10398. }
  10399. try {
  10400. formatedContent = JSON.parse(content);
  10401. } catch (error) {
  10402. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10403. return false;
  10404. }
  10405. logStatus.success();
  10406. return formatedContent;
  10407. }
  10408. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10409. return false;
  10410. }
  10411. logStatus.error(`${result}:${statusText}(${status})`);
  10412. return false;
  10413. } catch (error) {
  10414. throwError(error, 'getGistData');
  10415. return false;
  10416. }
  10417. };
  10418. const syncOptions = () => {
  10419. try {
  10420. const {
  10421. TOKEN,
  10422. GIST_ID,
  10423. FILE_NAME,
  10424. SYNC_HISTORY
  10425. } = GM_getValue('gistOptions') || {
  10426. TOKEN: '',
  10427. GIST_ID: '',
  10428. FILE_NAME: '',
  10429. SYNC_HISTORY: true
  10430. };
  10431. external_Swal_default().fire({
  10432. title: i18n('gistOptions'),
  10433. 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;">
  10434. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10435. ${i18n('downloadFromGist')}</button></p>`,
  10436. focusConfirm: false,
  10437. showLoaderOnConfirm: true,
  10438. 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>`,
  10439. preConfirm: async () => {
  10440. const token = $('#github-token').val();
  10441. const gistId = $('#gist-id').val();
  10442. const fileName = $('#file-name').val();
  10443. const syncHistory = $('#sync-history').prop('checked');
  10444. GM_setValue('gistOptions', {
  10445. TOKEN: token,
  10446. GIST_ID: gistId,
  10447. FILE_NAME: fileName,
  10448. SYNC_HISTORY: syncHistory
  10449. });
  10450. return await getGistData(token, gistId, fileName, true);
  10451. },
  10452. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10453. confirmButtonText: i18n('saveAndTest'),
  10454. showCancelButton: true,
  10455. cancelButtonText: i18n('close')
  10456. }).then(_ref => {
  10457. let {
  10458. value
  10459. } = _ref;
  10460. if (value) {
  10461. external_Swal_default().fire({
  10462. icon: 'success',
  10463. title: i18n('testSuccess')
  10464. }).then(syncOptions);
  10465. } else if (value !== undefined) {
  10466. external_Swal_default().fire({
  10467. icon: 'error',
  10468. title: i18n('testFailed')
  10469. }).then(syncOptions);
  10470. }
  10471. });
  10472. $('#upload-data').on('click', async () => {
  10473. const {
  10474. TOKEN,
  10475. GIST_ID,
  10476. FILE_NAME
  10477. } = GM_getValue('gistOptions') || {};
  10478. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10479. return external_Swal_default().fire({
  10480. icon: 'error',
  10481. title: i18n('saveAndTestNotice')
  10482. }).then(syncOptions);
  10483. }
  10484. external_Swal_default().fire({
  10485. icon: 'info',
  10486. title: i18n('processingData')
  10487. });
  10488. const data = {};
  10489. const names = GM_listValues();
  10490. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10491. for (const name of names) {
  10492. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10493. continue;
  10494. }
  10495. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10496. continue;
  10497. }
  10498. data[name] = GM_getValue(name);
  10499. }
  10500. external_Swal_default().update({
  10501. icon: 'info',
  10502. title: i18n('updatingData')
  10503. });
  10504. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10505. external_Swal_default().fire({
  10506. icon: 'success',
  10507. title: i18n('syncDataSuccess')
  10508. });
  10509. } else {
  10510. external_Swal_default().fire({
  10511. icon: 'error',
  10512. title: i18n('syncDataFailed')
  10513. });
  10514. }
  10515. });
  10516. $('#download-data').on('click', async () => {
  10517. const {
  10518. TOKEN,
  10519. GIST_ID,
  10520. FILE_NAME
  10521. } = GM_getValue('gistOptions') || {};
  10522. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10523. return external_Swal_default().fire({
  10524. icon: 'error',
  10525. title: i18n('saveAndTestNotice')
  10526. }).then(syncOptions);
  10527. }
  10528. external_Swal_default().fire({
  10529. icon: 'info',
  10530. title: i18n('downloadingData')
  10531. });
  10532. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10533. if (!data) {
  10534. return external_Swal_default().fire({
  10535. icon: 'error',
  10536. title: i18n('checkedNoData')
  10537. }).then(syncOptions);
  10538. }
  10539. external_Swal_default().update({
  10540. icon: 'info',
  10541. title: i18n('savingData')
  10542. });
  10543. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10544. for (const [ name, value ] of Object.entries(data)) {
  10545. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10546. continue;
  10547. }
  10548. GM_setValue(name, value);
  10549. }
  10550. external_Swal_default().fire({
  10551. icon: 'success',
  10552. title: i18n('syncDataSuccess')
  10553. });
  10554. });
  10555. } catch (error) {
  10556. throwError(error, 'syncOptions');
  10557. }
  10558. };
  10559. const dataSync = syncOptions;
  10560. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10561. Setting_checkPrivateRedeclaration(obj, privateSet);
  10562. privateSet.add(obj);
  10563. }
  10564. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10565. if (privateCollection.has(obj)) {
  10566. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10567. }
  10568. }
  10569. function Setting_defineProperty(obj, key, value) {
  10570. if (key in obj) {
  10571. Object.defineProperty(obj, key, {
  10572. value: value,
  10573. enumerable: true,
  10574. configurable: true,
  10575. writable: true
  10576. });
  10577. } else {
  10578. obj[key] = value;
  10579. }
  10580. return obj;
  10581. }
  10582. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10583. if (!privateSet.has(receiver)) {
  10584. throw new TypeError('attempted to get private field on non-instance');
  10585. }
  10586. return fn;
  10587. }
  10588. var Setting_getId = new WeakSet();
  10589. var _environment = new WeakSet();
  10590. class Setting {
  10591. constructor() {
  10592. Setting_classPrivateMethodInitSpec(this, _environment);
  10593. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10594. Setting_defineProperty(this, 'name', 'Setting');
  10595. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10596. Setting_defineProperty(this, 'syncData', dataSync);
  10597. }
  10598. tasksHistory() {
  10599. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10600. }
  10601. static test() {
  10602. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10603. }
  10604. before() {
  10605. $('body').html('').addClass('auto-task-options');
  10606. }
  10607. after() {
  10608. try {
  10609. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10610. changeGlobalOptions('page');
  10611. whiteList('page');
  10612. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10613. $('#getTwitterUserId').on('click', () => {
  10614. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10615. });
  10616. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10617. $('#getYoutubeChannelId').on('click', () => {
  10618. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10619. });
  10620. $('input[name^="position"]').on('input', function() {
  10621. const type = $(this).attr('name').replace('position.', '');
  10622. const xLabel = 'rightleft';
  10623. const yLabel = 'topbottpm';
  10624. switch (type) {
  10625. case 'buttonSideX':
  10626. case 'buttonSideY':
  10627. case 'buttonDistance':
  10628. {
  10629. const distance = $('input[name="position.buttonDistance"]').val();
  10630. const sideX = $('input[name="position.buttonSideX"]').val();
  10631. const sideY = $('input[name="position.buttonSideY"]').val();
  10632. if (![ 'right', 'left' ].includes(sideX)) {
  10633. break;
  10634. }
  10635. if (![ 'top', 'bottom' ].includes(sideY)) {
  10636. break;
  10637. }
  10638. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10639. break;
  10640. }
  10641. const distanceArr = distance.split(',');
  10642. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10643. break;
  10644. }
  10645.  
  10646. case 'showButtonSideX':
  10647. case 'showButtonSideY':
  10648. case 'showButtonDistance':
  10649. {
  10650. const distance = $('input[name="position.showButtonDistance"]').val();
  10651. const sideX = $('input[name="position.showButtonSideX"]').val();
  10652. const sideY = $('input[name="position.showButtonSideY"]').val();
  10653. if (![ 'right', 'left' ].includes(sideX)) {
  10654. break;
  10655. }
  10656. if (![ 'top', 'bottom' ].includes(sideY)) {
  10657. break;
  10658. }
  10659. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10660. break;
  10661. }
  10662. const distanceArr = distance.split(',');
  10663. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10664. break;
  10665. }
  10666.  
  10667. case 'logSideX':
  10668. case 'logSideY':
  10669. case 'logDistance':
  10670. {
  10671. const distance = $('input[name="position.logDistance"]').val();
  10672. const sideX = $('input[name="position.logSideX"]').val();
  10673. const sideY = $('input[name="position.logSideY"]').val();
  10674. if (![ 'right', 'left' ].includes(sideX)) {
  10675. break;
  10676. }
  10677. if (![ 'top', 'bottom' ].includes(sideY)) {
  10678. break;
  10679. }
  10680. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10681. break;
  10682. }
  10683. const distanceArr = distance.split(',');
  10684. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10685. break;
  10686. }
  10687.  
  10688. default:
  10689. break;
  10690. }
  10691. });
  10692. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10693. let functionKey = '';
  10694. if (event.altKey) {
  10695. functionKey += 'alt + ';
  10696. } else if (event.ctrlKey) {
  10697. functionKey += 'ctrl + ';
  10698. } else if (event.shiftKey) {
  10699. functionKey += 'shift + ';
  10700. }
  10701. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10702. });
  10703. } catch (error) {
  10704. throwError(error, 'Setting.after');
  10705. }
  10706. }
  10707. saveGlobalOptions() {
  10708. saveData();
  10709. }
  10710. }
  10711. function Setting_getId2(social) {
  10712. try {
  10713. external_Swal_default().fire({
  10714. title: i18n('getId', i18n(social)),
  10715. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10716. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10717. showCancelButton: true,
  10718. cancelButtonText: i18n('close'),
  10719. showConfirmButton: false
  10720. });
  10721. $('#link2id').on('click', async function() {
  10722. const link = $('#socialLink').val();
  10723. if (!link) {
  10724. return;
  10725. }
  10726. const type = $(this).attr('data-type');
  10727. if (type === 'twitterUser') {
  10728. var _link$match;
  10729. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10730. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10731. } else if (type === 'youtubeChannel') {
  10732. var _link$match2, _await$getInfo, _await$getInfo$params;
  10733. 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;
  10734. $('#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) || '');
  10735. }
  10736. });
  10737. } catch (error) {
  10738. throwError(error, 'Setting.getId');
  10739. }
  10740. }
  10741. function _environment2() {
  10742. try {
  10743. const userAgent = (0, javascript_utils_umd_min.ua)();
  10744. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10745. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10746. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10747. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10748. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10749. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10750. </tbody></table></form>`;
  10751. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10752. } catch (error) {
  10753. throwError(error, 'Setting.environment');
  10754. }
  10755. }
  10756. const website_Setting = Setting;
  10757. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10758. History_checkPrivateRedeclaration(obj, privateSet);
  10759. privateSet.add(obj);
  10760. }
  10761. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10762. if (privateCollection.has(obj)) {
  10763. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10764. }
  10765. }
  10766. function History_defineProperty(obj, key, value) {
  10767. if (key in obj) {
  10768. Object.defineProperty(obj, key, {
  10769. value: value,
  10770. enumerable: true,
  10771. configurable: true,
  10772. writable: true
  10773. });
  10774. } else {
  10775. obj[key] = value;
  10776. }
  10777. return obj;
  10778. }
  10779. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10780. if (!privateSet.has(receiver)) {
  10781. throw new TypeError('attempted to get private field on non-instance');
  10782. }
  10783. return fn;
  10784. }
  10785. var _addItem = new WeakSet();
  10786. class History extends website_Keylol {
  10787. constructor() {
  10788. super(...arguments);
  10789. History_classPrivateMethodInitSpec(this, _addItem);
  10790. History_defineProperty(this, 'name', 'History');
  10791. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10792. }
  10793. static test() {
  10794. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10795. }
  10796. before() {
  10797. try {
  10798. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10799. const data = GM_listValues() || [];
  10800. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10801. for (const item of tasksHistory) {
  10802. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10803. }
  10804. } catch (error) {
  10805. throwError(error, 'History.before');
  10806. }
  10807. }
  10808. clearHistory() {
  10809. try {
  10810. const data = GM_listValues() || [];
  10811. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10812. for (const item of tasksHistory) {
  10813. GM_deleteValue(item);
  10814. }
  10815. external_Swal_default().fire({
  10816. title: i18n('clearHistoryFinished'),
  10817. icon: 'success'
  10818. });
  10819. } catch (error) {
  10820. throwError(error, 'History.after');
  10821. }
  10822. }
  10823. }
  10824. function _addItem2(item) {
  10825. try {
  10826. const tasksData = GM_getValue(item);
  10827. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10828. return;
  10829. }
  10830. let html = '';
  10831. let title = '';
  10832. let link = '';
  10833. const [ website, id ] = item.split('-');
  10834. switch (website) {
  10835. case 'fawTasks':
  10836. title = `Freeanywhere[${id}]`;
  10837. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10838. break;
  10839.  
  10840. case 'gasTasks':
  10841. title = `Giveawaysu[${id}]`;
  10842. link = `https://giveaway.su/giveaway/view/${id}`;
  10843. break;
  10844.  
  10845. case 'gcTasks':
  10846. title = `GiveeClub[${id}]`;
  10847. link = `https://givee.club/event/${id}`;
  10848. break;
  10849.  
  10850. case 'gkTasks':
  10851. title = `Givekey[${id}]`;
  10852. link = `https://givekey.ru/giveaway/${id}`;
  10853. break;
  10854.  
  10855. case 'gleamTasks':
  10856. title = `Gleam[${id}]`;
  10857. link = `https://gleam.io${id}`;
  10858. break;
  10859.  
  10860. case 'khTasks':
  10861. title = `keyhub[${id}]`;
  10862. link = `https://key-hub.eu/giveaway/${id}`;
  10863. break;
  10864.  
  10865. case 'prysTasks':
  10866. title = `Prys[${id}]`;
  10867. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10868. break;
  10869.  
  10870. default:
  10871. return;
  10872. }
  10873. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10874. for (const [ type, tasks ] of Object.entries(types)) {
  10875. for (const task of tasks) {
  10876. 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>`;
  10877. }
  10878. }
  10879. }
  10880. $('.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>`);
  10881. $('span.delete-task').on('click', function() {
  10882. const itemName = $(this).attr('data-name');
  10883. if (itemName) {
  10884. GM_deleteValue(itemName);
  10885. $(`div.card[data-name="${itemName}"]`).remove();
  10886. external_Swal_default().fire({
  10887. title: i18n('clearTaskFinished'),
  10888. text: itemName,
  10889. icon: 'success'
  10890. });
  10891. } else {
  10892. external_Swal_default().fire({
  10893. title: i18n('clearTaskFailed'),
  10894. icon: 'error'
  10895. });
  10896. }
  10897. });
  10898. } catch (error) {
  10899. throwError(error, 'History.addItem');
  10900. }
  10901. }
  10902. const website_History = History;
  10903. 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 ];
  10904. const websiteOptions = function(website, options) {
  10905. try {
  10906. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10907. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10908. for (const [ option, value ] of Object.entries(options)) {
  10909. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10910. }
  10911. websiteOptionsForm += '</tbody></table></form>';
  10912. external_Swal_default().fire({
  10913. title: i18n('websiteOptions'),
  10914. html: websiteOptionsForm,
  10915. showConfirmButton: true,
  10916. confirmButtonText: i18n('save'),
  10917. showCancelButton: true,
  10918. cancelButtonText: i18n('close')
  10919. }).then(_ref => {
  10920. let {
  10921. isConfirmed
  10922. } = _ref;
  10923. if (isConfirmed) {
  10924. $('#websiteOptionsForm').serializeArray().map(value => {
  10925. options[value.name] = value.value;
  10926. return value;
  10927. });
  10928. GM_setValue(`${website}Options`, options);
  10929. external_Swal_default().fire({
  10930. title: i18n('changeWebsiteOptionsSuccess'),
  10931. icon: 'success'
  10932. });
  10933. }
  10934. });
  10935. } catch (error) {
  10936. throwError(error, 'websiteOptions');
  10937. }
  10938. };
  10939. const options = websiteOptions;
  10940. const external_keyboardJS_namespaceObject = keyboardJS;
  10941. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10942. const checkUpdate = async (updateLink, auto) => {
  10943. try {
  10944. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10945. const {
  10946. result,
  10947. statusText,
  10948. status,
  10949. data
  10950. } = await tools_httpRequest({
  10951. url: checkUrl,
  10952. responseType: 'json',
  10953. method: 'GET',
  10954. timeout: 3e4
  10955. });
  10956. if (result === 'Success') {
  10957. var _data$response;
  10958. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10959. return data.response;
  10960. }
  10961. if (!auto) {
  10962. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10963. }
  10964. return false;
  10965. }
  10966. if (!auto) {
  10967. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10968. }
  10969. return false;
  10970. } catch (error) {
  10971. throwError(error, 'checkUpdate');
  10972. return false;
  10973. }
  10974. };
  10975. const hasNewVersion = (currentVersion, remoteVersion) => {
  10976. try {
  10977. const [ currentRealVersion ] = currentVersion.split('-');
  10978. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  10979. if (isPreview && !globalOptions.other.receivePreview) {
  10980. return false;
  10981. }
  10982. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10983. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10984. if (remoteVersion1 > currentVersion1) {
  10985. return true;
  10986. }
  10987. if (remoteVersion1 < currentVersion1) {
  10988. return false;
  10989. }
  10990. if (remoteVersion2 > currentVersion2) {
  10991. return true;
  10992. }
  10993. if (remoteVersion2 < currentVersion2) {
  10994. return false;
  10995. }
  10996. if (remoteVersion3 > currentVersion3) {
  10997. return true;
  10998. }
  10999. return false;
  11000. } catch (error) {
  11001. throwError(error, 'compareVersion');
  11002. return false;
  11003. }
  11004. };
  11005. const updateChecker = async () => {
  11006. try {
  11007. const currentVersion = GM_info.script.version;
  11008. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  11009. const updateLinks = {
  11010. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  11011. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  11012. standby: 'https://auto-task-v4.hclonely.com/'
  11013. };
  11014. let version;
  11015. let updateLink = '';
  11016. let packageData;
  11017. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  11018. updateLink = updateLinks[updateSource];
  11019. packageData = await checkUpdate(updateLink, false);
  11020. } else {
  11021. updateLink = updateLinks.github;
  11022. packageData = await checkUpdate(updateLink, true);
  11023. if (!packageData) {
  11024. updateLink = updateLinks.jsdelivr;
  11025. packageData = await checkUpdate(updateLink, true);
  11026. if (!packageData) {
  11027. updateLink = updateLinks.standby;
  11028. packageData = await checkUpdate(updateLink, true);
  11029. }
  11030. }
  11031. }
  11032. if (packageData) {
  11033. version = packageData.version || currentVersion;
  11034. } else {
  11035. version = currentVersion;
  11036. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  11037. }
  11038. if (packageData && hasNewVersion(currentVersion, version)) {
  11039. var _packageData$change;
  11040. scripts_echoLog({
  11041. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  11042. });
  11043. scripts_echoLog({
  11044. 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>`
  11045. });
  11046. }
  11047. } catch (error) {
  11048. throwError(error, 'updateChecker');
  11049. }
  11050. };
  11051. const scripts_updateChecker = updateChecker;
  11052. var _globalOptions$other, _globalOptions$other2;
  11053. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  11054. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  11055. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  11056. const loadScript = async () => {
  11057. var _website, _website2, _website3, _website4, _website5, _website6;
  11058. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  11059. const authToken = external_Cookies_namespaceObject.get('auth-token');
  11060. const isLogin = !!external_Cookies_namespaceObject.get('login');
  11061. if (isLogin) {
  11062. var _commonOptions, _commonOptions$header;
  11063. GM_setValue('twitchAuth', {
  11064. authToken: authToken,
  11065. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  11066. });
  11067. window.close();
  11068. external_Swal_default().fire('', i18n('closePageNotice'));
  11069. } else {
  11070. external_Swal_default().fire('', i18n('needLogin'));
  11071. }
  11072. return;
  11073. }
  11074. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  11075. const ct0 = external_Cookies_namespaceObject.get('ct0');
  11076. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  11077. if (isLogin && ct0) {
  11078. GM_setValue('twitterAuth', {
  11079. ct0: ct0
  11080. });
  11081. window.close();
  11082. external_Swal_default().fire('', i18n('closePageNotice'));
  11083. } else {
  11084. external_Swal_default().fire('', i18n('needLogin'));
  11085. }
  11086. return;
  11087. }
  11088. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  11089. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  11090. if (PAPISID) {
  11091. GM_setValue('youtubeAuth', {
  11092. PAPISID: PAPISID
  11093. });
  11094. window.close();
  11095. external_Swal_default().fire('', i18n('closePageNotice'));
  11096. } else {
  11097. external_Swal_default().fire('', i18n('needLogin'));
  11098. }
  11099. return;
  11100. }
  11101. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11102. const betaButton = $('#redesign-beta-optin-btn');
  11103. if (betaButton.length > 0) {
  11104. GM_setValue('redditAuth', '#auth');
  11105. return betaButton[0].click();
  11106. }
  11107. GM_setValue('redditAuth', null);
  11108. window.close();
  11109. external_Swal_default().fire('', i18n('closePageNotice'));
  11110. return;
  11111. }
  11112. let website;
  11113. for (const Website of Websites) {
  11114. if (Website.test()) {
  11115. website = new Website();
  11116. break;
  11117. }
  11118. }
  11119. if (!website) {
  11120. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11121. return;
  11122. }
  11123. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11124. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11125. }
  11126. $('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>`);
  11127. $('div.show-button-div').on('click', () => {
  11128. $('#auto-task-buttons').show();
  11129. $('div.show-button-div').hide();
  11130. });
  11131. const toggleLog = () => {
  11132. const $this = $('#toggle-log');
  11133. const status = $this.attr('data-status');
  11134. if (status === 'show') {
  11135. $('#auto-task-info').hide();
  11136. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11137. } else {
  11138. $('#auto-task-info').show();
  11139. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11140. }
  11141. };
  11142. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11143. if (website.doTask) {
  11144. website.doTask();
  11145. }
  11146. });
  11147. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11148. if (website.undoTask) {
  11149. website.doTask();
  11150. }
  11151. });
  11152. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11153. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11154. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11155. }
  11156. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11157. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11158. for (const button of website.buttons) {
  11159. if (website[button]) {
  11160. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11161. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11162. website[button]();
  11163. });
  11164. $('#auto-task-buttons').append(btnElement);
  11165. }
  11166. }
  11167. }
  11168. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11169. ${i18n('hideButton')}</a></p>`);
  11170. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11171. $('#auto-task-buttons').hide();
  11172. $('div.show-button-div').show();
  11173. });
  11174. 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'}">
  11175. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11176. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11177. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11178. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11179. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11180. options(website.name, website.options);
  11181. });
  11182. }
  11183. if (website.name !== 'Setting') {
  11184. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11185. changeGlobalOptions('swal');
  11186. });
  11187. GM_registerMenuCommand(i18n('settingPage'), () => {
  11188. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11189. });
  11190. }
  11191. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11192. if (!GM_getValue('notice')) {
  11193. var _echoLog$font;
  11194. external_Swal_default().fire({
  11195. title: i18n('swalNotice'),
  11196. icon: 'warning'
  11197. }).then(() => {
  11198. window.open(i18n('noticeLink'), '_blank');
  11199. GM_setValue('notice', new Date().getTime());
  11200. });
  11201. (_echoLog$font = scripts_echoLog({
  11202. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11203. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11204. GM_setValue('notice', new Date().getTime());
  11205. });
  11206. }
  11207. scripts_updateChecker();
  11208. };
  11209. if (window.location.hostname === 'discord.com') {
  11210. const LocalStorage = window.localStorage;
  11211. if (window.location.hash === '#auth') {
  11212. var _LocalStorage$getItem;
  11213. window.localStorage.removeItem = () => true;
  11214. 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, '');
  11215. if (discordAuth && discordAuth.length > 0) {
  11216. GM_setValue('discordAuth', {
  11217. auth: discordAuth
  11218. });
  11219. window.close();
  11220. external_Swal_default().fire('', i18n('closePageNotice'));
  11221. } else {
  11222. external_Swal_default().fire({
  11223. text: i18n('getDiscordAuthFailed'),
  11224. icon: 'error'
  11225. });
  11226. }
  11227. } else {
  11228. var _LocalStorage$getItem2;
  11229. 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, '');
  11230. if (discordAuth && discordAuth.length > 0) {
  11231. GM_setValue('discordAuth', {
  11232. auth: discordAuth
  11233. });
  11234. }
  11235. }
  11236. } else if (window.location.hostname === 'opquests.com') {
  11237. loadScript();
  11238. } else {
  11239. $(loadScript);
  11240. }
  11241. }();
  11242. })();