auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.21-beta
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12. // @icon https://auto-task-v4.hclonely.com/favicon.ico
  13.  
  14. // @include *://freeanywhere.net/*
  15. // @include *://giveaway.su/giveaway/view/*
  16. // @include *://givee.club/*/event/*
  17. // @include *://givekey.ru/giveaway/*
  18. // @include *://www.indiedb.com/giveaways*
  19. // @include *://key-hub.eu/giveaway/*
  20. // @include *://keylol.com/*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://prys.revadike.com/giveaway/?id=*
  23. // @include *://opquests.com/quests/*
  24. // @include *://gleam.io/*
  25. // @include *://sweepwidget.com/view/*
  26. // @include *://discord.com/*
  27. // @include *://www.twitch.tv/*
  28. // @include *://www.youtube.com/*
  29. // @include *://*.reddit.com/*
  30. // @include *://twitter.com/settings/account?k*
  31. // @include https://auto-task-v4.hclonely.com/setting.html
  32. // @include https://auto-task-v4.hclonely.com/history.html
  33.  
  34. // @grant GM_setValue
  35. // @grant GM_getValue
  36. // @grant GM_listValues
  37. // @grant GM_deleteValue
  38. // @grant GM_addStyle
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_info
  42. // @grant GM_openInTab
  43. // @grant GM_setClipboard
  44. // @grant GM_getResourceText
  45. // @grant unsafeWindow
  46. // @grant window.close
  47. // @grant window.localStorage
  48.  
  49. // @connect cdn.jsdelivr.net
  50. // @connect store.steampowered.com
  51. // @connect steamcommunity.com
  52. // @connect twitter.com
  53. // @connect api.twitter.com
  54. // @connect youtube.com
  55. // @connect www.youtube.com
  56. // @connect facebook.com
  57. // @connect instagram.com
  58. // @connect vk.com
  59. // @connect twitch.tv
  60. // @connect www.twitch.tv
  61. // @connect gql.twitch.tv
  62. // @connect github.com
  63. // @connect discordapp.com
  64. // @connect discord.gg
  65. // @connect discord.com
  66. // @connect www.reddit.com
  67. // @connect oauth.reddit.com
  68. // @connect raw.githubusercontent.com
  69. // @connect t.me
  70. // @connect bit.ly
  71. // @connect giveaway.su
  72. // @connect google.com
  73. // @connect www.vloot.io
  74. // @connect givee.club
  75. // @connect gleam.io
  76. // @connect www.indiedb.com
  77. // @connect key-hub.eu
  78. // @connect opquests.com
  79. // @connect itch.io
  80. // @connect auto-task-v4.hclonely.com
  81. // @connect *
  82. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  83. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  84. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  85. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  86. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  87. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  88. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  89. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  90.  
  91. // @noframes
  92. // ==/UserScript==
  93.  
  94. console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
  95.  
  96. (function() {
  97. var __webpack_modules__ = {
  98. 514: function(__unused_webpack_module, exports) {
  99. !function(e, n) {
  100. true ? n(exports) : 0;
  101. }(this, function(e) {
  102. 'use strict';
  103. var t = function() {
  104. return (t = Object.assign || function(e) {
  105. for (var n, o = 1, t = arguments.length; o < t; o++) {
  106. for (var r in n = arguments[o]) {
  107. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  108. }
  109. }
  110. return e;
  111. }).apply(this, arguments);
  112. };
  113. function r(e, n, o) {
  114. if (o || 2 === arguments.length) {
  115. for (var t, r = 0, i = n.length; r < i; r++) {
  116. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  117. }
  118. }
  119. return e.concat(t || Array.prototype.slice.call(n));
  120. }
  121. function d(e) {
  122. return '[object Object]' === n(e);
  123. }
  124. function l(e, n) {
  125. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  126. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  127. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  128. });
  129. }
  130. var n = function(e) {
  131. return Object.prototype.toString.call(e);
  132. };
  133. var o = (i.prototype.init = function() {
  134. try {
  135. this.getSystemName(), this.getBrowserName();
  136. } catch (e) {
  137. console.warn('[UA formatter error] '.concat(e));
  138. }
  139. }, i.prototype.getEngine = function() {
  140. var e = this.agent;
  141. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  142. }, i.prototype.getSystemName = function() {
  143. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  144. try {
  145. var o = '';
  146. if (/Windows/i.test(n)) {
  147. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  148. switch (this.info.os = 'Windows', t) {
  149. case '6.3':
  150. o = '8.1';
  151. break;
  152.  
  153. case '6.2':
  154. o = '8';
  155. break;
  156.  
  157. case '6.1':
  158. o = '7';
  159. break;
  160.  
  161. case '5.2':
  162. case '5.1':
  163. o = 'XP';
  164. break;
  165.  
  166. default:
  167. o = t;
  168. }
  169. return this.info.device = 'PC', void (this.info.osVersion = o);
  170. }
  171. if (/^Macintosh/i.test(n)) {
  172. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  173. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  174. }
  175. if (/^iPad/i.test(n)) {
  176. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  177. void (this.info.osVersion = o.replace(/_/g, '.'));
  178. }
  179. if (/^iPhone/i.test(n)) {
  180. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  181. void (this.info.osVersion = o.replace(/_/g, '.'));
  182. }
  183. if (-1 !== n.indexOf('Android')) {
  184. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  185. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  186. }
  187. if (/Linux\s[a-z\d_]+/.test(n)) {
  188. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  189. }
  190. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  191. } catch (e) {
  192. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  193. }
  194. }, i.prototype.getBrowserName = function() {
  195. var e = Object.keys(this.browserNameMap).map(function(e) {
  196. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  197. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  198. return -1 !== e.findIndex(function(e) {
  199. return e.test(n);
  200. });
  201. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  202. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  203. }, i.prototype._formatBrowserVersion = function(e) {
  204. var n, o, t, r;
  205. try {
  206. for (var i = null !== (o = null === (n = e.match(/(?<name>[a-z\d]+)(\/|\s)(?<version>(\d+\.)+\d+)/i)) || void 0 === n ? void 0 : n.groups) && void 0 !== o ? o : {}, s = i.name, a = i.version, c = {}, f = 0, u = Object.entries(this.browserNameMap); f < u.length; f++) {
  207. var d = u[f], l = d[0], h = d[1];
  208. if (new RegExp(l).test(s)) {
  209. c = h;
  210. break;
  211. }
  212. }
  213. var p = {
  214. browserVersion: null != a ? a : 'Unknown',
  215. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  216. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  217. };
  218. return 'Trident' === s && (p.browserVersion = {
  219. '4.0': 8,
  220. '5.0': 9,
  221. '6.0': 10,
  222. '7.0': 11
  223. }[a]), p;
  224. } catch (e) {
  225. return console.warn('[UA formatter error] '.concat(e)), {
  226. browser: 'Unknown',
  227. browserVersion: 'Unknown'
  228. };
  229. }
  230. }, i);
  231. function i(e) {
  232. this.agent = '', this.info = {
  233. browser: '',
  234. browserZH: '',
  235. browserVersion: '',
  236. os: '',
  237. osVersion: '',
  238. device: 'Unknown',
  239. engine: 'WebKit'
  240. }, this.browserNameMap = {
  241. MicroMessenger: {
  242. en: 'MicroMessenger',
  243. zh: '微信'
  244. },
  245. MetaSr: {
  246. en: 'MetaSr',
  247. zh: '搜狗浏览器'
  248. },
  249. 'QQ(Browser)?': {
  250. en: 'QQBrowser',
  251. zh: 'QQ浏览器'
  252. },
  253. UCBrowser: {
  254. en: 'UCBrowser',
  255. zh: 'UC浏览器'
  256. },
  257. '2345Explorer': {
  258. en: '2345Explorer',
  259. zh: '2345极速浏览器'
  260. },
  261. Mb2345Browser: {
  262. en: 'Mb2345Browser',
  263. zh: '2345手机浏览器'
  264. },
  265. Trident: {
  266. en: 'Internet Explorer'
  267. },
  268. 'Edge?': {
  269. en: 'Edge'
  270. },
  271. OPR: {
  272. en: 'Opera'
  273. },
  274. Vivaldi: {
  275. en: 'Vivaldi'
  276. },
  277. Firefox: {
  278. en: 'Firefox'
  279. },
  280. Chrome: {
  281. en: 'Chrome'
  282. },
  283. Safari: {
  284. en: 'Safari'
  285. }
  286. }, this.agent = e, this.init();
  287. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  288. this.info = t(t({}, this.info), {
  289. engine: this.getEngine(),
  290. browserVersion: 'Safari' === o ? n : e
  291. });
  292. }
  293. function s() {
  294. this.cookies = {}, this.init();
  295. }
  296. var a = new (s.prototype.init = function() {
  297. var o = {};
  298. document.cookie.split(/;\s/).forEach(function(e) {
  299. var n = e.split(/=/), e = n[0], n = n[1];
  300. o[e] = n;
  301. }), this.cookies = o;
  302. }, s.prototype.getItem = function(e) {
  303. return this.cookies[e];
  304. }, s.prototype.getAllItems = function() {
  305. return this.cookies;
  306. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  307. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  308. }, s)();
  309. e.countDown = function e(n, o, t, r) {
  310. if (!window) {
  311. throw new Error('window is not defind.');
  312. }
  313. if (0 < n) {
  314. return r && r(), n--, window[o] = window.setTimeout(function() {
  315. e(n, o, t, r);
  316. }, 1e3), function() {
  317. return clearTimeout(window[o]);
  318. };
  319. }
  320. clearTimeout(window[o]), t && t();
  321. }, e.createRandomID = function(e) {
  322. void 0 === e && (e = 12);
  323. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  324. n.push(o[Math.round(Math.random() * t)]);
  325. }
  326. return n.join('');
  327. }, e.dCookie = a, e.debounce = function(o, t, r) {
  328. var i;
  329. void 0 === t && (t = 0);
  330. var s = r = void 0 === r ? !1 : r;
  331. return function() {
  332. var e = this, n = arguments;
  333. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  334. r ? s = !0 : o.apply(e, n);
  335. }, t);
  336. };
  337. }, e.deepCopy = function e(n) {
  338. if (d(n) || Array.isArray(n)) {
  339. var o, t = Array.isArray(n) ? [] : {};
  340. for (o in n) {
  341. t[o] = e(n[o]);
  342. }
  343. return t;
  344. }
  345. return n;
  346. }, e.formatQueryParams = function(e) {
  347. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  348. if (!e) {
  349. return {};
  350. }
  351. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  352. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  353. return t[n] = o, e;
  354. });
  355. }
  356. return t;
  357. }, e.formatThousandth = function(e) {
  358. var n = ''.concat(e).split('.'), e = n[0], n = n[1], n = void 0 === n ? '' : n, e = e.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
  359. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  360. }, e.generateTree = function e(n, o, t, r) {
  361. for (var i = [], s = 0; s < n.length; s++) {
  362. var a = n[s];
  363. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  364. }
  365. return i;
  366. }, e.isEmpty = function(e) {
  367. return Array.isArray(e) ? 0 === e.length : d(e) ? 0 === Object.keys(e).length : [ '[object Set]', '[object Map]' ].includes(n(e)) ? 0 === e.size : [ null, void 0, '' ].includes(e);
  368. }, e.isFunction = function(e) {
  369. return '[object Function]' === n(e);
  370. }, e.isImageUrl = function(e) {
  371. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  372. }, e.isObject = d, e.isRegexp = function(e) {
  373. return '[object RegExp]' === n(e);
  374. }, e.objectKeyToCamelCase = function e(n, o, t) {
  375. if (Array.isArray(n)) {
  376. for (var r = [], i = 0; i < n.length; i++) {
  377. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  378. }
  379. } else if (d(n)) {
  380. r = {};
  381. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  382. var f = (u = c[a])[0], u = u[1];
  383. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  384. }
  385. } else {
  386. r = n;
  387. }
  388. return r;
  389. }, e.realType = n, e.searchParams = function(e, n) {
  390. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  391. new URLSearchParams(e).get(n);
  392. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  393. return e.replace(/([A-Z])/g, function(e) {
  394. return '_'.concat(e.toLocaleLowerCase());
  395. });
  396. }, e.ua = function(e) {
  397. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  398. }, Object.defineProperty(e, '__esModule', {
  399. value: !0
  400. });
  401. });
  402. },
  403. 786: function(module, __webpack_exports__, __webpack_require__) {
  404. 'use strict';
  405. __webpack_require__.d(__webpack_exports__, {
  406. Z: function() {
  407. return __WEBPACK_DEFAULT_EXPORT__;
  408. }
  409. });
  410. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  411. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  412. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  413. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  414. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default());
  415. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(10px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px rgba(5,190,5,0.4)}body.auto-task-options .auto-task-form table label input:checked~span i{left:84px}body.auto-task-options .auto-task-form table label input:checked~span i::before{background:#05be05;box-shadow:35px 0 0 #05be05}body.auto-task-options .auto-task-form table label input:checked~span i::after{bottom:12px;height:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;background:#05be05}body.auto-task-options .auto-task-form table label span{position:absolute;top:0;left:0;width:100%;height:100%;background:#fe0000;border-radius:80px;transition:.5s;box-shadow:0 15px 25px rgba(254,0,0,0.4)}body.auto-task-options .auto-task-form table label span i{position:absolute;top:4px;left:4px;width:72px;height:72px;background:#fff;border-radius:50%}body.auto-task-options .auto-task-form table label span i::before{content:"";position:absolute;top:22px;left:12px;width:12px;height:12px;border-radius:50%;background:#fe0000;box-shadow:35px 0 0 #fe0000;transition:.5s}body.auto-task-options .auto-task-form table label span i::after{content:"";position:absolute;bottom:15px;left:calc(50% - 15px);width:30px;height:6px;border-radius:6px;background:#fe0000;transition:.5s}body.auto-task-history{font-size:15px;font-weight:400;line-height:1.5}body.auto-task-history .container a{color:#007bff;text-decoration:none;background-color:transparent}body.auto-task-history .container .card{width:80%;max-width:800px;border-radius:10px;background:rgba(118,118,118,0.10196);border-top:1px solid rgba(255,255,255,0.50196);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px rgba(0,0,0,0.10196);margin:20px auto;position:relative;display:flex;flex-direction:column;word-wrap:break-word;-webkit-background-clip:border-box;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}body.auto-task-history .container .card .title{text-align:center;font-size:30px;font-weight:bold;margin:5px 0}body.auto-task-history .container .card .title a:hover{text-decoration:none;background:#93e1ff;border-radius:10px;padding:3px}body.auto-task-history .container .card ul{margin-bottom:25px}body.auto-task-history .container .card ul li{margin-bottom:5px;line-height:20px}body.auto-task-history .container .card ul a:hover{text-decoration:underline}body.auto-task-history .container .card .delete-task{right:10px;width:38px;height:35px;position:absolute;font-size:24px;cursor:pointer;border-radius:10px}body.auto-task-history .container .card .delete-task:hover{background:#fff}body.auto-task-history .container .card .time{right:5px;position:absolute;bottom:0;color:#e83e8c;font-family:\'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace\';font-size:15px}#auto-task-buttons,.show-button-div{position:fixed;top:30px;right:15px;width:170px;z-index:999999999 !important;transform:scale(0.9)}#auto-task-buttons p,.show-button-div p{line-height:30px;height:40px;text-align:center;margin:5px !important}#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn{width:150px;height:40px;line-height:30px;font-size:20px}.show-button-div{width:20px}.auto-task-capitalize{text-transform:capitalize !important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{box-shadow:inset 0px 0px 4px 1px rgba(100,150,200,.5) !important}.swal2-checkbox-custom{align-items:center;justify-content:center;background:#fff;color:inherit;margin:1em auto}.swal2-checkbox-custom input{flex-shrink:0;margin:0 .4em}.giveaway-actions #getKey{display:none !important}.auto-task-giveaway-status{color:#fff;border-radius:10px;padding:0 5px;margin-left:5px}.auto-task-giveaway-status.active{background-color:#5cb85c}.auto-task-giveaway-status.not-active{background-color:#d9534f}.left-keys.lk-green,.left-keys.lk-yellow,.left-keys.lk-red,.left-keys.lk-black{display:none !important}', '' ]);
  416. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  417. },
  418. 400: function(module) {
  419. 'use strict';
  420. module.exports = function(cssWithMappingToString) {
  421. var list = [];
  422. list.toString = function toString() {
  423. return this.map(function(item) {
  424. var content = '';
  425. var needLayer = typeof item[5] !== 'undefined';
  426. if (item[4]) {
  427. content += '@supports ('.concat(item[4], ') {');
  428. }
  429. if (item[2]) {
  430. content += '@media '.concat(item[2], ' {');
  431. }
  432. if (needLayer) {
  433. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  434. }
  435. content += cssWithMappingToString(item);
  436. if (needLayer) {
  437. content += '}';
  438. }
  439. if (item[2]) {
  440. content += '}';
  441. }
  442. if (item[4]) {
  443. content += '}';
  444. }
  445. return content;
  446. }).join('');
  447. };
  448. list.i = function i(modules, media, dedupe, supports, layer) {
  449. if (typeof modules === 'string') {
  450. modules = [ [ null, modules, undefined ] ];
  451. }
  452. var alreadyImportedModules = {};
  453. if (dedupe) {
  454. for (var k = 0; k < this.length; k++) {
  455. var id = this[k][0];
  456. if (id != null) {
  457. alreadyImportedModules[id] = true;
  458. }
  459. }
  460. }
  461. for (var _k = 0; _k < modules.length; _k++) {
  462. var item = [].concat(modules[_k]);
  463. if (dedupe && alreadyImportedModules[item[0]]) {
  464. continue;
  465. }
  466. if (typeof layer !== 'undefined') {
  467. if (typeof item[5] === 'undefined') {
  468. item[5] = layer;
  469. } else {
  470. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  471. item[5] = layer;
  472. }
  473. }
  474. if (media) {
  475. if (!item[2]) {
  476. item[2] = media;
  477. } else {
  478. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  479. item[2] = media;
  480. }
  481. }
  482. if (supports) {
  483. if (!item[4]) {
  484. item[4] = ''.concat(supports);
  485. } else {
  486. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  487. item[4] = supports;
  488. }
  489. }
  490. list.push(item);
  491. }
  492. };
  493. return list;
  494. };
  495. },
  496. 220: function(module) {
  497. 'use strict';
  498. module.exports = function(i) {
  499. return i[1];
  500. };
  501. }
  502. };
  503. var __webpack_module_cache__ = {};
  504. function __webpack_require__(moduleId) {
  505. var cachedModule = __webpack_module_cache__[moduleId];
  506. if (cachedModule !== undefined) {
  507. return cachedModule.exports;
  508. }
  509. var module = __webpack_module_cache__[moduleId] = {
  510. id: moduleId,
  511. exports: {}
  512. };
  513. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  514. return module.exports;
  515. }
  516. !function() {
  517. __webpack_require__.n = function(module) {
  518. var getter = module && module.__esModule ? function() {
  519. return module['default'];
  520. } : function() {
  521. return module;
  522. };
  523. __webpack_require__.d(getter, {
  524. a: getter
  525. });
  526. return getter;
  527. };
  528. }();
  529. !function() {
  530. __webpack_require__.d = function(exports, definition) {
  531. for (var key in definition) {
  532. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  533. Object.defineProperty(exports, key, {
  534. enumerable: true,
  535. get: definition[key]
  536. });
  537. }
  538. }
  539. };
  540. }();
  541. !function() {
  542. __webpack_require__.o = function(obj, prop) {
  543. return Object.prototype.hasOwnProperty.call(obj, prop);
  544. };
  545. }();
  546. var __webpack_exports__ = {};
  547. !function() {
  548. 'use strict';
  549. const external_Swal_namespaceObject = Swal;
  550. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  551. const external_Cookies_namespaceObject = Cookies;
  552. var auto_task = __webpack_require__(786);
  553. var javascript_utils_umd_min = __webpack_require__(514);
  554. const httpRequest = async function(options) {
  555. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  556. try {
  557. const result = await new Promise(resolve => {
  558. if (options.dataType) {
  559. options.responseType = options.dataType;
  560. }
  561. const requestObj = {
  562. ...{
  563. timeout: 3e4,
  564. ontimeout(data) {
  565. resolve({
  566. result: 'Error',
  567. statusText: 'Timeout',
  568. status: 601,
  569. data: data,
  570. options: options
  571. });
  572. },
  573. onabort(data) {
  574. resolve({
  575. result: 'Error',
  576. statusText: 'Aborted',
  577. status: 602,
  578. data: data,
  579. options: options
  580. });
  581. },
  582. onerror(data) {
  583. resolve({
  584. result: 'Error',
  585. statusText: 'Error',
  586. status: 603,
  587. data: data,
  588. options: options
  589. });
  590. },
  591. onload(data) {
  592. resolve({
  593. result: 'Success',
  594. statusText: 'Load',
  595. status: 600,
  596. data: data,
  597. options: options
  598. });
  599. }
  600. },
  601. ...options
  602. };
  603. GM_xmlhttpRequest(requestObj);
  604. });
  605. console.log('发送请求:', result);
  606. if (result.status !== 600 && times < 2) {
  607. return await httpRequest(options, times + 1);
  608. }
  609. return result;
  610. } catch (error) {
  611. throwError(error, 'httpRequest');
  612. console.log('发送请求:', {
  613. errorMsg: error,
  614. options: options
  615. });
  616. return {
  617. result: 'JsError',
  618. statusText: 'Error',
  619. status: 604,
  620. error: error,
  621. options: options
  622. };
  623. }
  624. };
  625. const tools_httpRequest = httpRequest;
  626. const echoLog = _ref => {
  627. let {
  628. type,
  629. text,
  630. html,
  631. id
  632. } = _ref;
  633. const emptyStatus = {
  634. success: () => emptyStatus,
  635. error: () => emptyStatus,
  636. warning: () => emptyStatus,
  637. info: () => emptyStatus,
  638. view: () => emptyStatus
  639. };
  640. try {
  641. var _ele$;
  642. let ele;
  643. if (type) {
  644. switch (type) {
  645. case 'joiningSteamGroup':
  646. case 'leavingSteamGroup':
  647. case 'gettingSteamGroupId':
  648. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>...<font></font></li>`);
  649. break;
  650.  
  651. case 'subscribingForum':
  652. case 'unsubscribingForum':
  653. case 'gettingForumId':
  654. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>...<font></font></li>`);
  655. break;
  656.  
  657. case 'followingCurator':
  658. case 'unfollowingCurator':
  659. case 'getCuratorId':
  660. 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>`);
  661. break;
  662.  
  663. case 'addingToWishlist':
  664. case 'removingFromWishlist':
  665. case 'followingGame':
  666. case 'unfollowingGame':
  667. case 'gettingSubid':
  668. case 'addingFreeLicense':
  669. case 'requestingPlayTestAccess':
  670. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>...<font></font></li>`);
  671. break;
  672.  
  673. case 'addingFreeLicenseSubid':
  674. ele = $(`<li>${i18n('addingFreeLicense')}<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  675. break;
  676.  
  677. case 'favoritingWorkshop':
  678. case 'unfavoritingWorkshop':
  679. case 'gettingWorkshopAppId':
  680. case 'votingUpWorkshop':
  681. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  682. ${text}</a>...<font></font></li>`);
  683. break;
  684.  
  685. case 'gettingAnnouncementParams':
  686. case 'likingAnnouncement':
  687. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  688. ${id}</a>...<font></font></li>`);
  689. break;
  690.  
  691. case 'joiningDiscordServer':
  692. case 'gettingDiscordGuild':
  693. ele = $(`<li>${i18n(type)}<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>...<font></font></li>`);
  694. break;
  695.  
  696. case 'leavingDiscordServer':
  697. ele = $(`<li>${i18n(type)}<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>...<font></font></li>`);
  698. break;
  699.  
  700. case 'updateDiscordAuth':
  701. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  702. break;
  703.  
  704. case 'followingTwitchChannel':
  705. case 'unfollowingTwitchChannel':
  706. case 'gettingTwitchChannelId':
  707. ele = $(`<li>${i18n(type)}<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>...<font></font></li>`);
  708. break;
  709.  
  710. case 'gettingInsUserId':
  711. case 'followingIns':
  712. case 'unfollowingIns':
  713. ele = $(`<li>${i18n(type)}<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  714. break;
  715.  
  716. case 'gettingTwitterUserId':
  717. case 'followingTwitterUser':
  718. case 'unfollowingTwitterUser':
  719. ele = $(`<li>${i18n(type)}<a href="https://twitter.com/${text}" target="_blank">${text}</a>...<font></font></li>`);
  720. break;
  721.  
  722. case 'retweetting':
  723. case 'unretweetting':
  724. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  725. break;
  726.  
  727. case 'joiningReddit':
  728. case 'leavingReddit':
  729. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  730. break;
  731.  
  732. case 'followingRedditUser':
  733. case 'unfollowingRedditUser':
  734. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  735. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>...<font></font></li>`);
  736. break;
  737.  
  738. case 'followingYtbChannel':
  739. case 'unfollowingYtbChannel':
  740. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>...<font></font></li>`);
  741. break;
  742.  
  743. case 'likingYtbVideo':
  744. case 'unlikingYtbVideo':
  745. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>...<font></font></li>`);
  746. break;
  747.  
  748. case 'gettingVkId':
  749. case 'joiningVkGroup':
  750. case 'leavingVkGroup':
  751. case 'joiningVkPublic':
  752. case 'leavingVkPublic':
  753. case 'sendingVkWall':
  754. case 'deletingVkWall':
  755. ele = $(`<li>${i18n(type)}<a href="https://vk.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  756. break;
  757.  
  758. case 'visitingLink':
  759. ele = $(`<li>${i18n('visitingLink')}<a href="${text}" target="_blank">${text}</a>...<font></font></li>`);
  760. break;
  761.  
  762. case 'verifyingInsAuth':
  763. case 'text':
  764. ele = $(`<li>${i18n(text)}<font></font></li>`);
  765. break;
  766.  
  767. case 'html':
  768. ele = $(text || html);
  769. break;
  770.  
  771. case 'whiteList':
  772. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  773. break;
  774.  
  775. case 'globalOptionsSkip':
  776. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  777. break;
  778.  
  779. default:
  780. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  781. break;
  782. }
  783. } else if (text) {
  784. ele = $(`<li>${i18n(text)}<font></font></li>`);
  785. } else if (html) {
  786. ele = $(html);
  787. } else {
  788. ele = $('<li><font></font></li>');
  789. }
  790. ele.addClass('card-text');
  791. $('#auto-task-info').append(ele);
  792. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  793. const font = ele.find('font');
  794. const status = {
  795. font: font,
  796. success() {
  797. var _this$font, _this$font2, _this$font3;
  798. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  799. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  800. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  801. 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);
  802. return this;
  803. },
  804. error() {
  805. var _this$font4, _this$font5, _this$font6;
  806. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  807. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  808. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  809. 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);
  810. return this;
  811. },
  812. warning() {
  813. var _this$font7, _this$font8, _this$font9;
  814. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  815. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  816. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  817. 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);
  818. return this;
  819. },
  820. info() {
  821. var _this$font10, _this$font11, _this$font12;
  822. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  823. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  824. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  825. 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);
  826. return this;
  827. },
  828. view() {
  829. var _this$font13;
  830. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  831. return this;
  832. }
  833. };
  834. return status;
  835. } catch (error) {
  836. throwError(error, 'echoLog');
  837. return emptyStatus;
  838. }
  839. };
  840. const scripts_echoLog = echoLog;
  841. const unique = array => {
  842. try {
  843. return [ ...new Set(array) ];
  844. } catch (error) {
  845. throwError(error, 'unique');
  846. return [];
  847. }
  848. };
  849. const delay = function() {
  850. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  851. return new Promise(resolve => {
  852. setTimeout(() => {
  853. resolve(true);
  854. }, time);
  855. });
  856. };
  857. const getRedirectLink = async link => {
  858. try {
  859. if (!link) {
  860. return null;
  861. }
  862. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  863. if (redirectLinksCache[link]) {
  864. redirectLinksCache[link];
  865. }
  866. return await tools_httpRequest({
  867. url: link,
  868. method: 'GET'
  869. }).then(_ref => {
  870. let {
  871. data
  872. } = _ref;
  873. if (data !== null && data !== void 0 && data.finalUrl) {
  874. redirectLinksCache[link] = data.finalUrl;
  875. GM_setValue('redirectLinks', redirectLinksCache);
  876. return data.finalUrl;
  877. }
  878. return null;
  879. });
  880. } catch (error) {
  881. throwError(error, 'getRedirectLink');
  882. return null;
  883. }
  884. };
  885. const visitLink = async (link, options) => {
  886. try {
  887. const logStatus = scripts_echoLog({
  888. type: 'visitLink',
  889. text: link
  890. });
  891. return await tools_httpRequest({
  892. url: link,
  893. method: 'GET',
  894. ...options
  895. }).then(_ref2 => {
  896. let {
  897. result,
  898. statusText,
  899. status
  900. } = _ref2;
  901. if (result === 'Success') {
  902. logStatus.success();
  903. return true;
  904. }
  905. logStatus.error(`${result}:${statusText}(${status})`);
  906. return false;
  907. });
  908. } catch (error) {
  909. throwError(error, 'visitLink');
  910. return false;
  911. }
  912. };
  913. const getUrlQuery = url => {
  914. try {
  915. const query = {};
  916. if (url) {
  917. if (url.includes('?')) {
  918. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  919. query[key] = value;
  920. return str;
  921. });
  922. }
  923. } else {
  924. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  925. query[key] = value;
  926. return str;
  927. });
  928. }
  929. return query;
  930. } catch (error) {
  931. throwError(error, 'getUrlQuery');
  932. return {};
  933. }
  934. };
  935. const getUuid = () => {
  936. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  937. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  938. };
  939. const stringToColour = str => {
  940. try {
  941. let hash = 0;
  942. for (let i = 0; i < str.length; i++) {
  943. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  944. }
  945. let colour = '#';
  946. for (let i = 0; i < 3; i++) {
  947. const value = hash >> i * 8 & 255;
  948. colour += `00${value.toString(16)}`.slice(-2);
  949. }
  950. return colour;
  951. } catch (error) {
  952. throwError(error, 'stringToColour');
  953. return '#fff';
  954. }
  955. };
  956. const defaultGlobalOptions = {
  957. doTask: {
  958. discord: {
  959. servers: true
  960. },
  961. instagram: {
  962. users: true
  963. },
  964. twitch: {
  965. channels: true
  966. },
  967. twitter: {
  968. users: true,
  969. retweets: true
  970. },
  971. vk: {
  972. names: true
  973. },
  974. youtube: {
  975. channels: true,
  976. likes: true
  977. },
  978. reddit: {
  979. reddits: true
  980. },
  981. steam: {
  982. groups: true,
  983. wishlists: true,
  984. follows: true,
  985. forums: true,
  986. workshops: true,
  987. curators: true,
  988. workshopVotes: true,
  989. announcements: true,
  990. licenses: true,
  991. playtests: true
  992. }
  993. },
  994. undoTask: {
  995. discord: {
  996. servers: true
  997. },
  998. instagram: {
  999. users: true
  1000. },
  1001. twitch: {
  1002. channels: true
  1003. },
  1004. twitter: {
  1005. users: true,
  1006. retweets: true
  1007. },
  1008. vk: {
  1009. names: true
  1010. },
  1011. youtube: {
  1012. channels: true,
  1013. likes: true
  1014. },
  1015. reddit: {
  1016. reddits: true
  1017. },
  1018. steam: {
  1019. groups: true,
  1020. wishlists: true,
  1021. follows: true,
  1022. forums: true,
  1023. workshops: true,
  1024. curators: true
  1025. }
  1026. },
  1027. position: {
  1028. buttonSideX: 'right',
  1029. buttonSideY: 'top',
  1030. buttonDistance: '15,30',
  1031. showButtonSideX: 'right',
  1032. showButtonSideY: 'top',
  1033. showButtonDistance: '15,30',
  1034. logSideX: 'right',
  1035. logSideY: 'bottom',
  1036. logDistance: '10,10'
  1037. },
  1038. hotKey: {
  1039. doTaskKey: 'alt + d',
  1040. undoTaskKey: 'alt + u',
  1041. toggleLogKey: 'alt + l'
  1042. },
  1043. other: {
  1044. twitterVerifyId: '783214',
  1045. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1046. autoUpdateSource: 'jsdelivr',
  1047. language: 'zh',
  1048. checkLogin: true,
  1049. checkLeftKey: true,
  1050. defaultShowButton: true,
  1051. defaultShowLog: true
  1052. }
  1053. };
  1054. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1055. const assignObject = (obj1, obj2) => {
  1056. try {
  1057. const newObj = {};
  1058. for (const [ key, value ] of Object.entries(obj1)) {
  1059. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1060. newObj[key] = assignObject(value, obj2[key]);
  1061. } else {
  1062. newObj[key] = obj2[key] ?? value;
  1063. }
  1064. }
  1065. return newObj;
  1066. } catch (error) {
  1067. throwError(error, 'assignObject');
  1068. return defaultGlobalOptions;
  1069. }
  1070. };
  1071. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1072. const saveData = () => {
  1073. try {
  1074. const data = {};
  1075. $('#globalOptionsForm').serializeArray().map(value => {
  1076. data[value.name] = value.value;
  1077. return value;
  1078. });
  1079. $.makeArray($('#globalOptionsForm input')).map(element => {
  1080. const name = $(element).attr('name');
  1081. const keys = name.split('.');
  1082. if (keys.length === 3) {
  1083. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1084. } else if (keys.length === 2) {
  1085. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1086. }
  1087. return element;
  1088. });
  1089. GM_setValue('globalOptions', globalOptions);
  1090. external_Swal_default().fire({
  1091. title: i18n('changeGlobalOptionsSuccess'),
  1092. icon: 'success'
  1093. });
  1094. } catch (error) {
  1095. throwError(error, 'saveData');
  1096. }
  1097. };
  1098. const changeGlobalOptions = showType => {
  1099. try {
  1100. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1101. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1102. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1103. for (const [ option, data2 ] of Object.entries(data1)) {
  1104. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1105. if (typeof data2 === 'boolean') {
  1106. 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>`;
  1107. } else {
  1108. 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>`;
  1109. }
  1110. } else {
  1111. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1112. 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>`;
  1113. }
  1114. }
  1115. }
  1116. }
  1117. globalOptionsForm += '</tbody></table></form>';
  1118. if (showType === 'swal') {
  1119. external_Swal_default().fire({
  1120. title: i18n('globalOptions'),
  1121. html: globalOptionsForm,
  1122. showConfirmButton: true,
  1123. confirmButtonText: i18n('save'),
  1124. showCancelButton: true,
  1125. cancelButtonText: i18n('close')
  1126. }).then(_ref => {
  1127. let {
  1128. isConfirmed
  1129. } = _ref;
  1130. if (isConfirmed) {
  1131. saveData();
  1132. }
  1133. });
  1134. } else {
  1135. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1136. }
  1137. } catch (error) {
  1138. throwError(error, 'changeGlobalOptions');
  1139. }
  1140. };
  1141. const data = {
  1142. website: '网站',
  1143. type: '类型',
  1144. edit: '编辑',
  1145. whiteList: '白名单',
  1146. skipTask: '跳过撤销任务',
  1147. whiteListOptions: '白名单设置',
  1148. changeWhiteListOption: '设置白名单(%0)',
  1149. whiteListNotFound: '找不到此项白名单: %0',
  1150. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1151. changeWebsiteOptions: '网站设置',
  1152. changeGlobalOptions: '全局设置',
  1153. ok: '是',
  1154. save: '保存',
  1155. close: '关闭',
  1156. return: '返回',
  1157. option: '选项',
  1158. value: '值',
  1159. websiteOptions: '当前网站设置',
  1160. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1161. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1162. needLogin: '请先登录!',
  1163. getTasksInfo: '正在获取并处理任务信息...',
  1164. gettingKey: '正在获取Key...',
  1165. verifyingTask: '正在验证任务',
  1166. notice: '自动任务脚本提醒',
  1167. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1168. giveawayEnded: '此活动已结束,是否关闭?',
  1169. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1170. confirm: '确定',
  1171. cancel: '取消',
  1172. unKnown: '未知',
  1173. unKnownTaskType: '未识别的任务',
  1174. doing: '正在做任务',
  1175. allTasksComplete: '所有任务已完成!',
  1176. getTaskIdFailed: '获取任务Id失败!',
  1177. initSuccess: '%0 初始化成功!',
  1178. initFailed: '%0 初始化失败!',
  1179. errorLink: '链接错误: %0',
  1180. needInit: '请先初始化',
  1181. verifyingAuth: '正在验证%0凭证...',
  1182. updatingAuth: '正在更新%0凭证...',
  1183. initing: '正在初始化...',
  1184. getFailed: '获取%0失败!',
  1185. checkLoginFailed: '检测登录状态失败!',
  1186. checkLeftKeyFailed: '检测剩余Key失败!',
  1187. userId: '用户Id',
  1188. joiningGiveaway: '正在加入赠Key',
  1189. needJoinGiveaway: '需要先加入赠Key',
  1190. cannotUndo: '此网站不支持取消任务',
  1191. verifyAuth: '正在验证 %0 凭证...',
  1192. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1193. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1194. visitingLink: '正在访问链接: ',
  1195. doTask: '做任务',
  1196. undoTask: '撤销任务',
  1197. verifyTask: '验证任务',
  1198. getKey: '获取Key',
  1199. selectAll: '全选',
  1200. selectNone: '全不选',
  1201. invertSelect: '反选',
  1202. doFreeTask: '加入免费赠品',
  1203. doPointTask: '加入点数赠品',
  1204. skipTaskOption: '设置中已配置跳过任务',
  1205. other: '其他',
  1206. globalOptions: '全局设置',
  1207. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1208. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1209. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1210. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1211. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1212. saveGlobalOptions: '保存全局设置',
  1213. settingPage: '设置页面',
  1214. name: '名称',
  1215. version: '版本',
  1216. scriptManager: '脚本管理器',
  1217. script: '脚本',
  1218. environment: '环境',
  1219. os: '系统',
  1220. browser: '浏览器',
  1221. getId: '获取 %0 id',
  1222. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1223. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1224. showButton: '显示按钮',
  1225. hideButton: '隐藏按钮',
  1226. showLog: '显示日志',
  1227. hideLog: '隐藏日志',
  1228. defaultShowButton: '默认显示按钮',
  1229. defaultShowLog: '默认显示日志',
  1230. position: '组件位置',
  1231. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1232. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1233. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1234. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1235. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1236. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1237. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1238. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1239. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1240. hotKey: '快捷键',
  1241. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1242. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1243. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1244. tasksHistory: '任务历史',
  1245. clearHistory: '清空历史',
  1246. clearHistoryFinished: '已清空任务历史!',
  1247. deleteTask: '删除任务',
  1248. lastChangeTime: '最后一次修改时间',
  1249. clearTaskFinished: '删除以下任务完成!',
  1250. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1251. syncData: '数据同步',
  1252. settingData: '正在上传数据...',
  1253. gettingData: '正在获取数据...',
  1254. help: '帮助',
  1255. fileName: '文件名',
  1256. upload2gist: '同步到Gist',
  1257. downloadFromGist: '从Gist同步',
  1258. saveAndTest: '保存配置并测试',
  1259. testSuccess: '测试成功!',
  1260. testFailed: '测试失败!',
  1261. saveAndTestNotice: '请先保存配置并测试!',
  1262. processingData: '正在处理数据...',
  1263. updatingData: '正在上传数据...',
  1264. syncDataSuccess: '同步数据成功!',
  1265. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1266. downloadingData: '正在下载数据...',
  1267. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1268. savingData: '正在保存数据...',
  1269. syncHistory: '同步任务历史',
  1270. checkUpdateFailed: '检测更新失败',
  1271. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1272. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1273. gistOptions: 'Gist 设置',
  1274. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1275. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1276. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1277. toGithub: '前往Github反馈',
  1278. toKeylol: '前往其乐论坛反馈',
  1279. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1280. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1281. updateText: '%0 版本更新内容:',
  1282. Active: '进行中',
  1283. Ended: '已结束',
  1284. Banned: '已封禁',
  1285. Paused: '已暂停',
  1286. notStart: '未开始',
  1287. noRemoteData: '检测到远程无数据',
  1288. errorRemoteDataFormat: '远程数据格式错误',
  1289. groups: '组',
  1290. wishlists: '愿望单',
  1291. follows: '游戏关注',
  1292. forums: '论坛',
  1293. workshops: '创意工坊收藏',
  1294. curators: '鉴赏家',
  1295. workshopVotes: '创意工坊点赞',
  1296. announcements: '社区通知',
  1297. steamCommunity: 'Steam社区',
  1298. steamStore: 'Steam商店',
  1299. licenses: '入库免费游戏',
  1300. playtests: '请求访问权限',
  1301. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1302. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1303. joiningSteamGroup: '正在加入Steam组',
  1304. leavingSteamGroup: '正在退出Steam组',
  1305. gettingSteamGroupId: '正在获取Steam组Id',
  1306. subscribingForum: '正在订阅Steam论坛',
  1307. unsubscribingForum: '正在取消订阅Steam论坛',
  1308. gettingForumId: '正在获取Steam论坛Id',
  1309. followingCurator: '正在关注Steam鉴赏家',
  1310. unfollowingCurator: '正在取关Steam鉴赏家',
  1311. addingToWishlist: '正在添加游戏到Steam愿望单',
  1312. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1313. followingGame: '正在关注Steam游戏',
  1314. unfollowingGame: '正在取关Steam游戏',
  1315. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1316. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1317. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1318. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1319. gettingAnnouncementParams: '正在获取Steam通知信息',
  1320. likingAnnouncement: '正在点赞Steam通知',
  1321. changingArea: '正在更换Steam地区: %0...',
  1322. notNeededChangeArea: '当前地区不需要更换',
  1323. noAnotherArea: '请检测是否开启正确开启代理',
  1324. gettingAreaInfo: '正在获取Steam地区信息...',
  1325. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1326. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1327. gettingSubid: '正在获取游戏subid',
  1328. addingFreeLicense: '正在入库',
  1329. missParams: '缺少参数',
  1330. gettingLicenses: '正在获取Licenses...',
  1331. requestingPlayTestAccess: '正在请求访问权限',
  1332. servers: '服务器',
  1333. joiningDiscordServer: '正在加入Discord服务器',
  1334. leavingDiscordServer: '正在退出Discord服务器',
  1335. gettingDiscordGuild: '正在获取Discord服务器Id',
  1336. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1337. users: '用户',
  1338. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1339. insBanned: '您的Instagram账户已被封禁',
  1340. verifyingInsAuth: '正在验证Instagram凭证...',
  1341. gettingInsUserId: '正在获取Instagram用户Id',
  1342. followingIns: '正在关注Instagram用户',
  1343. unfollowingIns: '正在取关Instagram用户',
  1344. reddits: '社区/用户',
  1345. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1346. changingRedditVersion: '正在切换Reddit为新版页面...',
  1347. joiningReddit: '正在加入Reddit社区',
  1348. leavingReddit: '正在退出Reddit社区',
  1349. followingRedditUser: '正在关注Reddit用户',
  1350. unfollowingRedditUser: '正在取关Reddit用户',
  1351. channels: '频道',
  1352. followingTwitchChannel: '正在关注Twitch频道',
  1353. unfollowingTwitchChannel: '正在取关Twitch频道',
  1354. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1355. twitterUser: '推特用户',
  1356. retweets: '转推',
  1357. followingTwitterUser: '正在关注推特用户',
  1358. unfollowingTwitterUser: '正在取关推特用户',
  1359. retweetting: '正在转推',
  1360. unretweetting: '正在撤销转推',
  1361. names: '组/社区/动态',
  1362. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1363. gettingVkId: '正在获取Vk任务Id',
  1364. joiningVkGroup: '正在加入Vk组',
  1365. leavingVkGroup: '正在退出Vk组',
  1366. joiningVkPublic: '正在加入Vk社区',
  1367. leavingVkPublic: '正在退出Vk社区',
  1368. sendingVkWall: '正在转发Vk动态',
  1369. deletingVkWall: '正在撤销转发Vk动态',
  1370. youtubeChannel: 'YouTube频道',
  1371. likes: '点赞',
  1372. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1373. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1374. gettingYtbToken: '正在获取YouTube Token...',
  1375. followingYtbChannel: '正在订阅YouTube频道',
  1376. unfollowingYtbChannel: '正在退订YouTube频道',
  1377. likingYtbVideo: '正在点赞YouTube视频',
  1378. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1379. giveKeyNoticeBefore: '每次验证间隔15s',
  1380. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1381. noPoints: '点数不够,跳过抽奖',
  1382. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1383. joiningLottery: '正在加入抽奖',
  1384. doingGleamTask: '正在做Gleam任务...',
  1385. gettingGleamLink: '正在获取Gleam任务链接...',
  1386. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1387. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1388. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1389. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1390. };
  1391. const zh_CN = data;
  1392. const en_US_data = {
  1393. website: 'Website',
  1394. type: 'Type',
  1395. edit: 'Edit',
  1396. whiteList: 'Whitelist',
  1397. skipTask: 'Skip undo task',
  1398. whiteListOptions: 'Whitelist options',
  1399. changeWhiteListOption: 'Whitelist option(%0)',
  1400. whiteListNotFound: 'Cannot find this whitelist: %0',
  1401. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1402. changeWebsiteOptions: 'Website options',
  1403. changeGlobalOptions: 'Global options',
  1404. ok: 'OK',
  1405. save: 'Save',
  1406. close: 'Close',
  1407. return: 'Return',
  1408. option: 'Option',
  1409. value: 'Value',
  1410. websiteOptions: 'Current website settings',
  1411. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1412. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1413. needLogin: 'Please log in first!',
  1414. getTasksInfo: 'Obtaining and processing task information...',
  1415. gettingKey: 'Getting Key...',
  1416. verifyingTask: 'Verifying task',
  1417. notice: 'Automatic task script notice',
  1418. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1419. giveawayEnded: 'This event has ended, do you want to close it?',
  1420. 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?',
  1421. confirm: 'Confirm',
  1422. cancel: 'Cancel',
  1423. unKnown: 'Unknown',
  1424. unKnownTaskType: 'Unrecognized task',
  1425. doing: 'Doing a task',
  1426. allTasksComplete: 'All tasks have been completed!',
  1427. getTaskIdFailed: 'Failed to obtain task Id!',
  1428. initSuccess: '%0 was initialized successfully!',
  1429. initFailed: '%0 initialization failed!',
  1430. errorLink: 'Link error: %0',
  1431. needInit: 'Please initialize first',
  1432. verifyingAuth: 'Verifying %0 token...',
  1433. updatingAuth: 'Update %0 token...',
  1434. initing: 'Initializing...',
  1435. getFailed: 'Failed to get %0!',
  1436. checkLoginFailed: 'Failed to detect login status!',
  1437. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1438. userId: 'User Id',
  1439. joiningGiveaway: 'Joining giveaway',
  1440. needJoinGiveaway: 'Need to join the giveaway first',
  1441. cannotUndo: 'This website does not support canceling tasks',
  1442. verifyAuth: 'Verifying %0 token...',
  1443. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1444. errorReport: 'A script error is detected, do you want to report the BUG?',
  1445. visitingLink: 'Visiting link: ',
  1446. doTask: 'DoTask',
  1447. undoTask: 'UndoTask',
  1448. verifyTask: 'Verify',
  1449. getKey: 'GetKey',
  1450. selectAll: 'SelectAll',
  1451. selectNone: 'SelectNone',
  1452. invertSelect: 'InvertSelect',
  1453. doFreeTask: 'FreeTask',
  1454. doPointTask: 'PointTask',
  1455. skipTaskOption: 'Skip task has been configured in the settings',
  1456. other: 'Other',
  1457. globalOptions: 'Global Options',
  1458. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1459. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1460. 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.',
  1461. 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.',
  1462. 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.',
  1463. saveGlobalOptions: 'SaveSettings',
  1464. settingPage: 'Setting Page',
  1465. name: 'Name',
  1466. version: 'Version',
  1467. scriptManager: 'Script Manager',
  1468. script: 'Script',
  1469. environment: 'Environment',
  1470. os: 'OS',
  1471. browser: 'Browser',
  1472. getId: 'Get %0 id',
  1473. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1474. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1475. showButton: 'ShowButton',
  1476. hideButton: 'HideButton',
  1477. showLog: 'ShowLog',
  1478. hideLog: 'HideLog',
  1479. defaultShowButton: 'Default display button',
  1480. defaultShowLog: 'Display log by default',
  1481. position: 'Component position',
  1482. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1483. 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',
  1484. 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',
  1485. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1486. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1487. 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',
  1488. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1489. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1490. 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',
  1491. hotKey: 'Shortcut key',
  1492. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1493. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1494. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1495. tasksHistory: 'TasksHistory',
  1496. clearHistory: 'Clear history',
  1497. clearHistoryFinished: 'The mission history has been cleared!',
  1498. deleteTask: 'Delete task',
  1499. lastChangeTime: 'Last Change Time',
  1500. clearTaskFinished: 'Delete the following tasks completed!',
  1501. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1502. syncData: 'DataSync',
  1503. settingData: 'Uploading data...',
  1504. gettingData: 'Getting data...',
  1505. help: 'Help',
  1506. fileName: 'Filename',
  1507. upload2gist: 'Sync to Gist',
  1508. downloadFromGist: 'Sync from Gist',
  1509. saveAndTest: 'Save configuration and test',
  1510. testSuccess: 'Test success!',
  1511. testFailed: 'Test failed!',
  1512. saveAndTestNotice: 'Please save the configuration and test first!',
  1513. processingData: 'Processing data...',
  1514. updatingData: 'Uploading data...',
  1515. syncDataSuccess: 'Synchronized data successfully!',
  1516. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1517. downloadingData: 'Downloading data...',
  1518. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1519. savingData: 'Saving data...',
  1520. syncHistory: 'Synchronize tasks history',
  1521. checkUpdateFailed: 'Check update failed',
  1522. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1523. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1524. gistOptions: 'Gist Settings',
  1525. 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!',
  1526. 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!',
  1527. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1528. toGithub: 'Feedback(Github)',
  1529. toKeylol: 'Feedback(Keylol)',
  1530. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1531. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1532. updateText: 'Updates in version %0:',
  1533. Active: 'Active',
  1534. Ended: 'Ended',
  1535. Banned: 'Banned',
  1536. Paused: 'Paused',
  1537. notStart: 'notStart',
  1538. noRemoteData: 'No data remotely',
  1539. errorRemoteDataFormat: 'Remote data has wrong format',
  1540. groups: 'Group',
  1541. wishlists: 'Wishlist',
  1542. follows: 'Follow Game',
  1543. forums: 'Forum',
  1544. workshops: 'Favorite Workshop',
  1545. curators: 'Curator',
  1546. workshopVotes: 'Voteup Workshop',
  1547. announcements: 'Announcement',
  1548. steamCommunity: 'Steam Community',
  1549. steamStore: 'Steam Store',
  1550. licenses: 'Add License',
  1551. playtests: 'Playtest Access',
  1552. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1553. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1554. joiningSteamGroup: 'Joining Steam Group',
  1555. leavingSteamGroup: 'Leaving Steam Group',
  1556. gettingSteamGroupId: 'Getting Steam Group Id',
  1557. subscribingForum: 'Subscribing the Steam Forum',
  1558. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1559. gettingForumId: 'Getting Steam Forum Id',
  1560. followingCurator: 'Following Steam Curator',
  1561. unfollowingCurator: 'Unfollowing Steam Curator',
  1562. addingToWishlist: 'Adding the game to the Steam wishlist',
  1563. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1564. followingGame: 'Following Steam games',
  1565. unfollowingGame: 'Unfollowing Steam games',
  1566. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1567. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1568. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1569. votingUpWorkshop: 'Liking Steam workshop items',
  1570. gettingAnnouncementParams: 'Getting Steam announcement information',
  1571. likingAnnouncement: 'Liking Steam announcement',
  1572. changingArea: 'Changing Steam area: %0...',
  1573. notNeededChangeArea: 'The current area does not need to be changed',
  1574. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1575. gettingAreaInfo: 'Getting Steam area information...',
  1576. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1577. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1578. gettingSubid: 'Getting subid',
  1579. addingFreeLicense: 'Adding free license',
  1580. missParams: 'Missing parameters',
  1581. gettingLicenses: 'Getting licenses...',
  1582. requestingPlayTestAccess: 'Requesting play test access',
  1583. servers: 'Server',
  1584. joiningDiscordServer: 'Joining Discord Server',
  1585. leavingDiscordServer: 'Leaving Discord Server',
  1586. gettingDiscordGuild: 'Getting Discord server Id',
  1587. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1588. users: 'User',
  1589. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1590. insBanned: 'Your Instagram account has been banned',
  1591. verifyingInsAuth: 'Verifying Instagram token...',
  1592. gettingInsUserId: 'Getting Instagram user Id',
  1593. followingIns: 'Following Instagram user',
  1594. unfollowingIns: 'Unfollowing Instagram user',
  1595. reddits: 'Reddit/User',
  1596. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1597. changingRedditVersion: 'Switching Reddit to a new version page...',
  1598. joiningReddit: 'Joining the Reddit',
  1599. leavingReddit: 'Leaving the Reddit',
  1600. followingRedditUser: 'Following Reddit User',
  1601. unfollowingRedditUser: 'Unfollowing Reddit User',
  1602. channels: 'Channel',
  1603. followingTwitchChannel: 'Following Twitch Channel',
  1604. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1605. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1606. twitterUser: 'Twitter User',
  1607. retweets: 'Retweet',
  1608. followingTwitterUser: 'Following Twitter User',
  1609. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1610. retweetting: 'Retweetting',
  1611. unretweetting: 'Unretweetting',
  1612. names: 'Group/Public/Wall',
  1613. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1614. gettingVkId: 'Getting Vk task Id',
  1615. joiningVkGroup: 'Joining Vk Group',
  1616. leavingVkGroup: 'Leaving Vk Group',
  1617. joiningVkPublic: 'Joining Vk Public',
  1618. leavingVkPublic: 'Leaving Vk Public',
  1619. sendingVkWall: 'Sending Vk Wall',
  1620. deletingVkWall: 'Deleting Vk Wall',
  1621. youtubeChannel: 'YouTube Channel',
  1622. likes: 'Like',
  1623. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1624. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1625. gettingYtbToken: 'Getting YouTube Token...',
  1626. followingYtbChannel: 'Subscribing to YouTube channel',
  1627. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1628. likingYtbVideo: 'Liking YouTube video',
  1629. unlikingYtbVideo: 'Unliking YouTube video',
  1630. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1631. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1632. noPoints: 'Not enough points, skip the lottery',
  1633. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1634. joiningLottery: 'Joining the lottery',
  1635. doingGleamTask: 'Doing Gleam Task...',
  1636. gettingGleamLink: 'Getting Gleam task link...',
  1637. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1638. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1639. 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!',
  1640. 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...'
  1641. };
  1642. const en_US = en_US_data;
  1643. const languages = {
  1644. zh: zh_CN,
  1645. en: en_US
  1646. };
  1647. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1648. const I18n = function(key) {
  1649. var _languages$language;
  1650. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1651. argvs[_key - 1] = arguments[_key];
  1652. }
  1653. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1654. return key;
  1655. }
  1656. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1657. };
  1658. const i18n = I18n;
  1659. function throwError(error, name) {
  1660. external_Swal_default().fire({
  1661. title: i18n('errorReport'),
  1662. icon: 'error',
  1663. showCancelButton: true,
  1664. confirmButtonText: i18n('toGithub'),
  1665. showDenyButton: true,
  1666. denyButtonText: i18n('toKeylol'),
  1667. cancelButtonText: i18n('close')
  1668. }).then(_ref => {
  1669. let {
  1670. isDenied,
  1671. isConfirmed
  1672. } = _ref;
  1673. if (isConfirmed) {
  1674. 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,
  1675. 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');
  1676. } else if (isDenied) {
  1677. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1678.  
  1679. 环境:
  1680.  
  1681. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1682.  
  1683. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1684. 脚本版本: ${GM_info.script.version}
  1685.  
  1686. 报错信息:
  1687. [code]${error.stack}[/code]
  1688.  
  1689. 执行日志:
  1690. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1691. GM_setClipboard(text);
  1692. external_Swal_default().fire({
  1693. title: i18n('copySuccess'),
  1694. icon: 'success',
  1695. confirmButtonText: i18n('ok')
  1696. }).then(() => {
  1697. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1698. });
  1699. }
  1700. });
  1701. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1702. }
  1703. function _defineProperty(obj, key, value) {
  1704. if (key in obj) {
  1705. Object.defineProperty(obj, key, {
  1706. value: value,
  1707. enumerable: true,
  1708. configurable: true,
  1709. writable: true
  1710. });
  1711. } else {
  1712. obj[key] = value;
  1713. }
  1714. return obj;
  1715. }
  1716. class Social {
  1717. constructor() {
  1718. _defineProperty(this, 'tasks', void 0);
  1719. }
  1720. getRealParams(name, links, doTask, link2param) {
  1721. try {
  1722. let realParams = [];
  1723. if (links.length > 0) {
  1724. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1725. }
  1726. if (!doTask && this.tasks[name].length > 0) {
  1727. realParams = [ ...realParams, ...this.tasks[name] ];
  1728. }
  1729. return unique(realParams);
  1730. } catch (error) {
  1731. throwError(error, 'Social.getRealParams');
  1732. return [];
  1733. }
  1734. }
  1735. }
  1736. const social_Social = Social;
  1737. function _classPrivateMethodInitSpec(obj, privateSet) {
  1738. _checkPrivateRedeclaration(obj, privateSet);
  1739. privateSet.add(obj);
  1740. }
  1741. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1742. _checkPrivateRedeclaration(obj, privateMap);
  1743. privateMap.set(obj, value);
  1744. }
  1745. function _checkPrivateRedeclaration(obj, privateCollection) {
  1746. if (privateCollection.has(obj)) {
  1747. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1748. }
  1749. }
  1750. function Discord_defineProperty(obj, key, value) {
  1751. if (key in obj) {
  1752. Object.defineProperty(obj, key, {
  1753. value: value,
  1754. enumerable: true,
  1755. configurable: true,
  1756. writable: true
  1757. });
  1758. } else {
  1759. obj[key] = value;
  1760. }
  1761. return obj;
  1762. }
  1763. function _classPrivateFieldSet(receiver, privateMap, value) {
  1764. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1765. _classApplyDescriptorSet(receiver, descriptor, value);
  1766. return value;
  1767. }
  1768. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1769. if (descriptor.set) {
  1770. descriptor.set.call(receiver, value);
  1771. } else {
  1772. if (!descriptor.writable) {
  1773. throw new TypeError('attempted to set read only private field');
  1774. }
  1775. descriptor.value = value;
  1776. }
  1777. }
  1778. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1779. if (!privateSet.has(receiver)) {
  1780. throw new TypeError('attempted to get private field on non-instance');
  1781. }
  1782. return fn;
  1783. }
  1784. function _classPrivateFieldGet(receiver, privateMap) {
  1785. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1786. return _classApplyDescriptorGet(receiver, descriptor);
  1787. }
  1788. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1789. if (!privateMap.has(receiver)) {
  1790. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1791. }
  1792. return privateMap.get(receiver);
  1793. }
  1794. function _classApplyDescriptorGet(receiver, descriptor) {
  1795. if (descriptor.get) {
  1796. return descriptor.get.call(receiver);
  1797. }
  1798. return descriptor.value;
  1799. }
  1800. const defaultTasksTemplate = {
  1801. servers: []
  1802. };
  1803. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1804. var _auth = new WeakMap();
  1805. var _cache = new WeakMap();
  1806. var _initialized = new WeakMap();
  1807. var _verifyAuth = new WeakSet();
  1808. var _updateAuth = new WeakSet();
  1809. var _joinServer = new WeakSet();
  1810. var _leaveServer = new WeakSet();
  1811. var _getGuild = new WeakSet();
  1812. var _setCache = new WeakSet();
  1813. class Discord extends social_Social {
  1814. constructor() {
  1815. var _GM_getValue;
  1816. super(...arguments);
  1817. _classPrivateMethodInitSpec(this, _setCache);
  1818. _classPrivateMethodInitSpec(this, _getGuild);
  1819. _classPrivateMethodInitSpec(this, _leaveServer);
  1820. _classPrivateMethodInitSpec(this, _joinServer);
  1821. _classPrivateMethodInitSpec(this, _updateAuth);
  1822. _classPrivateMethodInitSpec(this, _verifyAuth);
  1823. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1824. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || JSON.parse(defaultTasks));
  1825. _classPrivateFieldInitSpec(this, _auth, {
  1826. writable: true,
  1827. value: GM_getValue('discordAuth') || {}
  1828. });
  1829. _classPrivateFieldInitSpec(this, _cache, {
  1830. writable: true,
  1831. value: GM_getValue('discordCache') || {}
  1832. });
  1833. _classPrivateFieldInitSpec(this, _initialized, {
  1834. writable: true,
  1835. value: false
  1836. });
  1837. }
  1838. async init() {
  1839. try {
  1840. if (_classPrivateFieldGet(this, _initialized)) {
  1841. return true;
  1842. }
  1843. if (!_classPrivateFieldGet(this, _auth).auth) {
  1844. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1845. _classPrivateFieldSet(this, _initialized, true);
  1846. return true;
  1847. }
  1848. return false;
  1849. }
  1850. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1851. if (isVerified) {
  1852. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1853. _classPrivateFieldSet(this, _initialized, true);
  1854. return true;
  1855. }
  1856. GM_setValue('discordAuth', {
  1857. auth: null
  1858. });
  1859. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1860. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1861. _classPrivateFieldSet(this, _initialized, true);
  1862. return true;
  1863. }
  1864. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1865. return false;
  1866. } catch (error) {
  1867. throwError(error, 'Discord.init');
  1868. return false;
  1869. }
  1870. }
  1871. async toggle(_ref) {
  1872. let {
  1873. doTask = true,
  1874. serverLinks = []
  1875. } = _ref;
  1876. try {
  1877. if (!_classPrivateFieldGet(this, _initialized)) {
  1878. scripts_echoLog({
  1879. text: i18n('needInit')
  1880. });
  1881. return false;
  1882. }
  1883. const prom = [];
  1884. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1885. scripts_echoLog({
  1886. type: 'globalOptionsSkip',
  1887. text: 'discord.servers'
  1888. });
  1889. } else {
  1890. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1891. var _link$match;
  1892. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1893. });
  1894. if (realServers.length > 0) {
  1895. for (const server of realServers) {
  1896. if (doTask) {
  1897. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1898. } else {
  1899. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1900. }
  1901. await delay(1e3);
  1902. }
  1903. }
  1904. }
  1905. return await Promise.all(prom).then(() => true);
  1906. } catch (error) {
  1907. throwError(error, 'Discord.toggleServers');
  1908. return false;
  1909. }
  1910. }
  1911. }
  1912. async function _verifyAuth2() {
  1913. try {
  1914. const logStatus = scripts_echoLog({
  1915. text: i18n('verifyingAuth', 'Discord')
  1916. });
  1917. const {
  1918. result,
  1919. statusText,
  1920. status,
  1921. data
  1922. } = await tools_httpRequest({
  1923. url: 'https://discord.com/api/v6/users/@me',
  1924. method: 'HEAD',
  1925. headers: {
  1926. authorization: _classPrivateFieldGet(this, _auth).auth
  1927. }
  1928. });
  1929. if (result === 'Success') {
  1930. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1931. logStatus.success();
  1932. return true;
  1933. }
  1934. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1935. return false;
  1936. }
  1937. logStatus.error(`${result}:${statusText}(${status})`);
  1938. return false;
  1939. } catch (error) {
  1940. throwError(error, 'Discord.verifyAuth');
  1941. return false;
  1942. }
  1943. }
  1944. async function _updateAuth2() {
  1945. try {
  1946. const logStatus = scripts_echoLog({
  1947. text: i18n('updatingAuth', 'Discord')
  1948. });
  1949. return await new Promise(resolve => {
  1950. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1951. active: true,
  1952. insert: true,
  1953. setParent: true
  1954. });
  1955. newTab.onclose = async () => {
  1956. var _GM_getValue2;
  1957. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1958. if (auth) {
  1959. _classPrivateFieldSet(this, _auth, {
  1960. auth: auth
  1961. });
  1962. logStatus.success();
  1963. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1964. } else {
  1965. logStatus.error('Error: Update discord auth failed!');
  1966. resolve(false);
  1967. }
  1968. };
  1969. });
  1970. } catch (error) {
  1971. throwError(error, 'Discord.updateAuth');
  1972. return false;
  1973. }
  1974. }
  1975. async function _joinServer2(inviteId) {
  1976. try {
  1977. const logStatus = scripts_echoLog({
  1978. type: 'joiningDiscordServer',
  1979. text: inviteId
  1980. });
  1981. const {
  1982. result,
  1983. statusText,
  1984. status,
  1985. data
  1986. } = await tools_httpRequest({
  1987. url: `https://discord.com/api/v9/invites/${inviteId}`,
  1988. method: 'POST',
  1989. dataType: 'json',
  1990. headers: {
  1991. authorization: _classPrivateFieldGet(this, _auth).auth
  1992. }
  1993. });
  1994. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1995. var _data$response, _data$response$guild;
  1996. logStatus.success();
  1997. 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);
  1998. if (guild) {
  1999. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2000. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2001. }
  2002. return true;
  2003. }
  2004. logStatus.error(`${result}:${statusText}(${status})`);
  2005. return false;
  2006. } catch (error) {
  2007. throwError(error, 'Discord.joinServer');
  2008. return false;
  2009. }
  2010. }
  2011. async function _leaveServer2(inviteId) {
  2012. try {
  2013. if (this.whiteList.servers.includes(inviteId)) {
  2014. scripts_echoLog({
  2015. type: 'whiteList',
  2016. text: 'Discord.leaveServer',
  2017. id: inviteId
  2018. });
  2019. return true;
  2020. }
  2021. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2022. if (!guild) {
  2023. return false;
  2024. }
  2025. const logStatus = scripts_echoLog({
  2026. type: 'leavingDiscordServer',
  2027. text: guild
  2028. });
  2029. const {
  2030. result,
  2031. statusText,
  2032. status,
  2033. data
  2034. } = await tools_httpRequest({
  2035. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2036. method: 'DELETE',
  2037. headers: {
  2038. authorization: _classPrivateFieldGet(this, _auth).auth
  2039. }
  2040. });
  2041. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2042. logStatus.success();
  2043. return true;
  2044. }
  2045. logStatus.error(`${result}:${statusText}(${status})`);
  2046. return false;
  2047. } catch (error) {
  2048. throwError(error, 'Discord.leaveServer');
  2049. return false;
  2050. }
  2051. }
  2052. async function _getGuild2(inviteId) {
  2053. try {
  2054. const logStatus = scripts_echoLog({
  2055. type: 'gettingDiscordGuild',
  2056. text: inviteId
  2057. });
  2058. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2059. if (guild) {
  2060. logStatus.success();
  2061. return guild;
  2062. }
  2063. const {
  2064. result,
  2065. statusText,
  2066. status,
  2067. data
  2068. } = await tools_httpRequest({
  2069. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2070. responseType: 'json',
  2071. method: 'GET'
  2072. });
  2073. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2074. var _data$response2, _data$response2$guild;
  2075. 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;
  2076. if (guild) {
  2077. logStatus.success();
  2078. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2079. return guild;
  2080. }
  2081. logStatus.error(`${result}:${statusText}(${status})`);
  2082. return false;
  2083. }
  2084. logStatus.error(`${result}:${statusText}(${status})`);
  2085. return false;
  2086. } catch (error) {
  2087. throwError(error, 'Discord.getGuild');
  2088. return false;
  2089. }
  2090. }
  2091. function _setCache2(inviteId, guild) {
  2092. try {
  2093. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2094. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2095. } catch (error) {
  2096. throwError(error, 'Discord.setCache');
  2097. }
  2098. }
  2099. unsafeWindow.Discord = Discord;
  2100. const social_Discord = Discord;
  2101. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2102. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2103. privateSet.add(obj);
  2104. }
  2105. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2106. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2107. privateMap.set(obj, value);
  2108. }
  2109. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2110. if (privateCollection.has(obj)) {
  2111. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2112. }
  2113. }
  2114. function Instagram_defineProperty(obj, key, value) {
  2115. if (key in obj) {
  2116. Object.defineProperty(obj, key, {
  2117. value: value,
  2118. enumerable: true,
  2119. configurable: true,
  2120. writable: true
  2121. });
  2122. } else {
  2123. obj[key] = value;
  2124. }
  2125. return obj;
  2126. }
  2127. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2128. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2129. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2130. return value;
  2131. }
  2132. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2133. if (descriptor.set) {
  2134. descriptor.set.call(receiver, value);
  2135. } else {
  2136. if (!descriptor.writable) {
  2137. throw new TypeError('attempted to set read only private field');
  2138. }
  2139. descriptor.value = value;
  2140. }
  2141. }
  2142. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2143. if (!privateSet.has(receiver)) {
  2144. throw new TypeError('attempted to get private field on non-instance');
  2145. }
  2146. return fn;
  2147. }
  2148. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2149. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2150. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2151. }
  2152. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2153. if (!privateMap.has(receiver)) {
  2154. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2155. }
  2156. return privateMap.get(receiver);
  2157. }
  2158. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2159. if (descriptor.get) {
  2160. return descriptor.get.call(receiver);
  2161. }
  2162. return descriptor.value;
  2163. }
  2164. const Instagram_defaultTasksTemplate = {
  2165. users: []
  2166. };
  2167. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2168. var Instagram_cache = new WeakMap();
  2169. var Instagram_auth = new WeakMap();
  2170. var Instagram_initialized = new WeakMap();
  2171. var _getUserInfo = new WeakSet();
  2172. var _followUser = new WeakSet();
  2173. var _unfollowUser = new WeakSet();
  2174. var Instagram_setCache = new WeakSet();
  2175. class Instagram extends social_Social {
  2176. constructor() {
  2177. var _GM_getValue;
  2178. super(...arguments);
  2179. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2180. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2181. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2182. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2183. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2184. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || JSON.parse(Instagram_defaultTasks));
  2185. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2186. writable: true,
  2187. value: GM_getValue('instagramCache') || {}
  2188. });
  2189. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2190. writable: true,
  2191. value: {}
  2192. });
  2193. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2194. writable: true,
  2195. value: false
  2196. });
  2197. }
  2198. async init() {
  2199. try {
  2200. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2201. return true;
  2202. }
  2203. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2204. if (isVerified) {
  2205. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2206. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2207. return true;
  2208. }
  2209. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2210. return false;
  2211. } catch (error) {
  2212. throwError(error, 'Instagram.init');
  2213. return false;
  2214. }
  2215. }
  2216. async toggle(_ref) {
  2217. let {
  2218. doTask = true,
  2219. userLinks = []
  2220. } = _ref;
  2221. try {
  2222. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2223. scripts_echoLog({
  2224. text: i18n('needInit')
  2225. });
  2226. return false;
  2227. }
  2228. const prom = [];
  2229. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2230. scripts_echoLog({
  2231. type: 'globalOptionsSkip',
  2232. text: 'instagram.users'
  2233. });
  2234. } else {
  2235. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2236. var _link$match;
  2237. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2238. });
  2239. if (realUsers.length > 0) {
  2240. for (const username of realUsers) {
  2241. if (doTask) {
  2242. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2243. } else {
  2244. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2245. }
  2246. await delay(1e3);
  2247. }
  2248. }
  2249. }
  2250. return await Promise.all(prom).then(() => true);
  2251. } catch (error) {
  2252. throwError(error, 'Instagram.toggleUsers');
  2253. return false;
  2254. }
  2255. }
  2256. }
  2257. async function _getUserInfo2() {
  2258. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2259. try {
  2260. const logStatus = scripts_echoLog({
  2261. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2262. text: name
  2263. });
  2264. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2265. if (userId && name !== 'instagram') {
  2266. logStatus.success();
  2267. return userId;
  2268. }
  2269. const {
  2270. result,
  2271. statusText,
  2272. status,
  2273. data
  2274. } = await tools_httpRequest({
  2275. url: `https://www.instagram.com/${name}/`,
  2276. method: 'GET'
  2277. });
  2278. if (result === 'Success') {
  2279. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2280. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2281. return false;
  2282. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2283. logStatus.error(`Error:${i18n('insBanned')}`);
  2284. return false;
  2285. }
  2286. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2287. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2288. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2289. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2290. if (name === 'instagram') {
  2291. if (csrftoken && hash) {
  2292. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2293. csrftoken: csrftoken,
  2294. hash: hash
  2295. });
  2296. return true;
  2297. }
  2298. return false;
  2299. }
  2300. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2301. if (id) {
  2302. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2303. logStatus.success();
  2304. return id;
  2305. }
  2306. logStatus.error('Error: Get ins data error!');
  2307. return false;
  2308. }
  2309. logStatus.error(`${result}:${statusText}(${status})`);
  2310. return false;
  2311. }
  2312. return false;
  2313. } catch (error) {
  2314. throwError(error, 'Instagram.getUserInfo');
  2315. return false;
  2316. }
  2317. }
  2318. async function _followUser2(name) {
  2319. try {
  2320. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2321. if (!id) {
  2322. return false;
  2323. }
  2324. const logStatus = scripts_echoLog({
  2325. type: 'followingIns',
  2326. text: name
  2327. });
  2328. const {
  2329. result,
  2330. statusText,
  2331. status,
  2332. data
  2333. } = await tools_httpRequest({
  2334. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2335. method: 'POST',
  2336. dataType: 'json',
  2337. headers: {
  2338. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2339. origin: 'https://www.instagram.com',
  2340. referer: `https://www.instagram.com/${name}/`,
  2341. 'content-type': 'application/x-www-form-urlencoded',
  2342. 'sec-fetch-site': 'same-origin',
  2343. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2344. }
  2345. });
  2346. if (result === 'Success') {
  2347. var _data$response, _data$response2;
  2348. 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') {
  2349. logStatus.success();
  2350. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2351. return true;
  2352. }
  2353. 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})`}`);
  2354. return false;
  2355. }
  2356. logStatus.error(`${result}:${statusText}(${status})`);
  2357. return false;
  2358. } catch (error) {
  2359. throwError(error, 'Instagram.followUser');
  2360. return false;
  2361. }
  2362. }
  2363. async function _unfollowUser2(name) {
  2364. try {
  2365. if (this.whiteList.users.includes(name)) {
  2366. scripts_echoLog({
  2367. type: 'whiteList',
  2368. text: 'Instagram.unfollowUser',
  2369. id: name
  2370. });
  2371. return true;
  2372. }
  2373. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2374. if (!id) {
  2375. return false;
  2376. }
  2377. const logStatus = scripts_echoLog({
  2378. type: 'unfollowingIns',
  2379. text: name
  2380. });
  2381. const {
  2382. result,
  2383. statusText,
  2384. status,
  2385. data
  2386. } = await tools_httpRequest({
  2387. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2388. method: 'POST',
  2389. dataType: 'json',
  2390. headers: {
  2391. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2392. origin: 'https://www.instagram.com',
  2393. referer: `https://www.instagram.com/${name}/`,
  2394. 'content-type': 'application/x-www-form-urlencoded',
  2395. 'sec-fetch-site': 'same-origin',
  2396. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2397. }
  2398. });
  2399. if (result === 'Success') {
  2400. var _data$response3;
  2401. 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') {
  2402. logStatus.success();
  2403. return true;
  2404. }
  2405. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2406. return false;
  2407. }
  2408. logStatus.error(`${result}:${statusText}(${status})`);
  2409. return false;
  2410. } catch (error) {
  2411. throwError(error, 'Instagram.unfollowUser');
  2412. return false;
  2413. }
  2414. }
  2415. function Instagram_setCache2(name, id) {
  2416. try {
  2417. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2418. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2419. } catch (error) {
  2420. throwError(error, 'Instagram.setCache');
  2421. }
  2422. }
  2423. const social_Instagram = Instagram;
  2424. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2425. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2426. privateSet.add(obj);
  2427. }
  2428. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2429. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2430. privateMap.set(obj, value);
  2431. }
  2432. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2433. if (privateCollection.has(obj)) {
  2434. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2435. }
  2436. }
  2437. function Reddit_defineProperty(obj, key, value) {
  2438. if (key in obj) {
  2439. Object.defineProperty(obj, key, {
  2440. value: value,
  2441. enumerable: true,
  2442. configurable: true,
  2443. writable: true
  2444. });
  2445. } else {
  2446. obj[key] = value;
  2447. }
  2448. return obj;
  2449. }
  2450. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2451. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2452. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2453. return value;
  2454. }
  2455. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2456. if (descriptor.set) {
  2457. descriptor.set.call(receiver, value);
  2458. } else {
  2459. if (!descriptor.writable) {
  2460. throw new TypeError('attempted to set read only private field');
  2461. }
  2462. descriptor.value = value;
  2463. }
  2464. }
  2465. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2466. if (!privateSet.has(receiver)) {
  2467. throw new TypeError('attempted to get private field on non-instance');
  2468. }
  2469. return fn;
  2470. }
  2471. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2472. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2473. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2474. }
  2475. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2476. if (!privateMap.has(receiver)) {
  2477. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2478. }
  2479. return privateMap.get(receiver);
  2480. }
  2481. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2482. if (descriptor.get) {
  2483. return descriptor.get.call(receiver);
  2484. }
  2485. return descriptor.value;
  2486. }
  2487. const Reddit_defaultTasksTemplate = {
  2488. reddits: []
  2489. };
  2490. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2491. var Reddit_auth = new WeakMap();
  2492. var Reddit_initialized = new WeakMap();
  2493. var _useBeta = new WeakSet();
  2494. var Reddit_updateAuth = new WeakSet();
  2495. class Reddit extends social_Social {
  2496. constructor() {
  2497. var _GM_getValue;
  2498. super(...arguments);
  2499. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2500. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2501. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2502. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || JSON.parse(Reddit_defaultTasks));
  2503. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2504. writable: true,
  2505. value: void 0
  2506. });
  2507. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2508. writable: true,
  2509. value: false
  2510. });
  2511. }
  2512. async init() {
  2513. try {
  2514. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2515. return true;
  2516. }
  2517. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2518. if (isVerified) {
  2519. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2520. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2521. return true;
  2522. }
  2523. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2524. return false;
  2525. } catch (error) {
  2526. throwError(error, 'Reddit.init');
  2527. return false;
  2528. }
  2529. }
  2530. async toggleTask(_ref) {
  2531. let {
  2532. name,
  2533. doTask = true
  2534. } = _ref;
  2535. try {
  2536. if (!doTask && this.whiteList.reddits.includes(name)) {
  2537. scripts_echoLog({
  2538. type: 'whiteList',
  2539. text: 'Reddit.undoTask',
  2540. id: name
  2541. });
  2542. return true;
  2543. }
  2544. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2545. if (/^u_/.test(name)) {
  2546. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2547. }
  2548. const logStatus = scripts_echoLog({
  2549. type: type,
  2550. text: name
  2551. });
  2552. const {
  2553. result,
  2554. statusText,
  2555. status,
  2556. data
  2557. } = await tools_httpRequest({
  2558. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2559. method: 'POST',
  2560. headers: {
  2561. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2562. 'content-type': 'application/x-www-form-urlencoded'
  2563. },
  2564. data: $.param({
  2565. action: doTask ? 'sub' : 'unsub',
  2566. sr_name: name,
  2567. api_type: 'json'
  2568. })
  2569. });
  2570. if (result === 'Success') {
  2571. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2572. logStatus.success();
  2573. if (doTask) {
  2574. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2575. }
  2576. return true;
  2577. }
  2578. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2579. return false;
  2580. }
  2581. logStatus.error(`${result}:${statusText}(${status})`);
  2582. return false;
  2583. } catch (error) {
  2584. throwError(error, 'Reddit.toggleTask');
  2585. return false;
  2586. }
  2587. }
  2588. async toggle(_ref2) {
  2589. let {
  2590. doTask = true,
  2591. redditLinks = []
  2592. } = _ref2;
  2593. try {
  2594. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2595. scripts_echoLog({
  2596. text: i18n('needInit')
  2597. });
  2598. return false;
  2599. }
  2600. const prom = [];
  2601. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2602. scripts_echoLog({
  2603. type: 'globalOptionsSkip',
  2604. text: 'reddit.reddits'
  2605. });
  2606. } else {
  2607. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2608. var _link$match, _link$match2;
  2609. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2610. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2611. if (userName) {
  2612. return name || userName;
  2613. }
  2614. return name;
  2615. });
  2616. if (realReddits.length > 0) {
  2617. for (const name of realReddits) {
  2618. prom.push(this.toggleTask({
  2619. name: name,
  2620. doTask: doTask
  2621. }));
  2622. await delay(1e3);
  2623. }
  2624. }
  2625. }
  2626. return await Promise.all(prom).then(() => true);
  2627. } catch (error) {
  2628. throwError(error, 'Reddit.toggle');
  2629. return false;
  2630. }
  2631. }
  2632. }
  2633. async function _useBeta2() {
  2634. try {
  2635. const logStatus = scripts_echoLog({
  2636. text: i18n('changingRedditVersion')
  2637. });
  2638. GM_setValue('redditAuth', null);
  2639. return await new Promise(resolve => {
  2640. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2641. active: true,
  2642. insert: true,
  2643. setParent: true
  2644. });
  2645. newTab.onclose = async () => {
  2646. logStatus.success();
  2647. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2648. };
  2649. });
  2650. } catch (error) {
  2651. throwError(error, 'Reddit.useBeta');
  2652. return false;
  2653. }
  2654. }
  2655. async function Reddit_updateAuth2() {
  2656. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2657. try {
  2658. const logStatus = scripts_echoLog({
  2659. text: i18n('updatingAuth', 'Reddit')
  2660. });
  2661. const {
  2662. result,
  2663. statusText,
  2664. status,
  2665. data
  2666. } = await tools_httpRequest({
  2667. url: 'https://www.reddit.com/',
  2668. method: 'GET',
  2669. nochche: true,
  2670. headers: {
  2671. 'Cache-Control': 'no-cache'
  2672. }
  2673. });
  2674. if (result === 'Success') {
  2675. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2676. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2677. return false;
  2678. }
  2679. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2680. var _data$responseText$ma;
  2681. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2682. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2683. }
  2684. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2685. if (accessToken) {
  2686. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2687. token: accessToken
  2688. });
  2689. logStatus.success();
  2690. return true;
  2691. }
  2692. logStatus.error('Error: Parameter "accessToken" not found!');
  2693. return false;
  2694. }
  2695. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2696. return false;
  2697. }
  2698. logStatus.error(`${result}:${statusText}(${status})`);
  2699. return false;
  2700. } catch (error) {
  2701. throwError(error, 'Reddit.updateAuth');
  2702. return false;
  2703. }
  2704. }
  2705. const social_Reddit = Reddit;
  2706. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2707. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2708. privateSet.add(obj);
  2709. }
  2710. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2711. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2712. privateMap.set(obj, value);
  2713. }
  2714. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2715. if (privateCollection.has(obj)) {
  2716. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2717. }
  2718. }
  2719. function Twitch_defineProperty(obj, key, value) {
  2720. if (key in obj) {
  2721. Object.defineProperty(obj, key, {
  2722. value: value,
  2723. enumerable: true,
  2724. configurable: true,
  2725. writable: true
  2726. });
  2727. } else {
  2728. obj[key] = value;
  2729. }
  2730. return obj;
  2731. }
  2732. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2733. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2734. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2735. return value;
  2736. }
  2737. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2738. if (descriptor.set) {
  2739. descriptor.set.call(receiver, value);
  2740. } else {
  2741. if (!descriptor.writable) {
  2742. throw new TypeError('attempted to set read only private field');
  2743. }
  2744. descriptor.value = value;
  2745. }
  2746. }
  2747. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2748. if (!privateSet.has(receiver)) {
  2749. throw new TypeError('attempted to get private field on non-instance');
  2750. }
  2751. return fn;
  2752. }
  2753. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2754. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2755. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2756. }
  2757. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2758. if (!privateMap.has(receiver)) {
  2759. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2760. }
  2761. return privateMap.get(receiver);
  2762. }
  2763. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2764. if (descriptor.get) {
  2765. return descriptor.get.call(receiver);
  2766. }
  2767. return descriptor.value;
  2768. }
  2769. const Twitch_defaultTasksTemplate = {
  2770. channels: []
  2771. };
  2772. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2773. var Twitch_auth = new WeakMap();
  2774. var Twitch_cache = new WeakMap();
  2775. var Twitch_initialized = new WeakMap();
  2776. var Twitch_verifyAuth = new WeakSet();
  2777. var Twitch_updateAuth = new WeakSet();
  2778. var _toggleChannel = new WeakSet();
  2779. var _getChannelId = new WeakSet();
  2780. var Twitch_setCache = new WeakSet();
  2781. class Twitch extends social_Social {
  2782. constructor() {
  2783. var _GM_getValue;
  2784. super(...arguments);
  2785. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2786. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2787. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2788. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2789. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2790. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2791. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || JSON.parse(Twitch_defaultTasks));
  2792. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2793. writable: true,
  2794. value: GM_getValue('twitchAuth') || {}
  2795. });
  2796. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2797. writable: true,
  2798. value: GM_getValue('twitchCache') || {}
  2799. });
  2800. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2801. writable: true,
  2802. value: false
  2803. });
  2804. }
  2805. async init() {
  2806. try {
  2807. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2808. return true;
  2809. }
  2810. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2811. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2812. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2813. return true;
  2814. }
  2815. return false;
  2816. }
  2817. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2818. if (isVerified) {
  2819. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2820. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2821. return true;
  2822. }
  2823. GM_setValue('twitchAuth', null);
  2824. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2825. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2826. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2827. return true;
  2828. }
  2829. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2830. return false;
  2831. } catch (error) {
  2832. throwError(error, 'Twitch.init');
  2833. return false;
  2834. }
  2835. }
  2836. async toggle(_ref) {
  2837. let {
  2838. doTask = true,
  2839. channelLinks = []
  2840. } = _ref;
  2841. try {
  2842. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2843. scripts_echoLog({
  2844. text: i18n('needInit')
  2845. });
  2846. return false;
  2847. }
  2848. const prom = [];
  2849. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2850. scripts_echoLog({
  2851. type: 'globalOptionsSkip',
  2852. text: 'twitch.channels'
  2853. });
  2854. } else {
  2855. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2856. var _link$match;
  2857. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2858. });
  2859. if (realChannels.length > 0) {
  2860. for (const channel of realChannels) {
  2861. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2862. name: channel,
  2863. doTask: doTask
  2864. }));
  2865. await delay(1e3);
  2866. }
  2867. }
  2868. }
  2869. return Promise.all(prom).then(() => true);
  2870. } catch (error) {
  2871. throwError(error, 'Twitch.toggle');
  2872. return false;
  2873. }
  2874. }
  2875. }
  2876. async function Twitch_verifyAuth2() {
  2877. try {
  2878. const logStatus = scripts_echoLog({
  2879. text: i18n('verifyingAuth', 'Twitch')
  2880. });
  2881. const {
  2882. result,
  2883. statusText,
  2884. status,
  2885. data
  2886. } = await tools_httpRequest({
  2887. url: 'https://gql.twitch.tv/gql',
  2888. method: 'POST',
  2889. dataType: 'json',
  2890. headers: {
  2891. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2892. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2893. },
  2894. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2895. });
  2896. if (result === 'Success') {
  2897. var _data$response, _data$response$, _data$response$$data;
  2898. 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) {
  2899. logStatus.success();
  2900. return true;
  2901. }
  2902. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2903. return false;
  2904. }
  2905. logStatus.error(`${result}:${statusText}(${status})`);
  2906. return false;
  2907. } catch (error) {
  2908. throwError(error, 'Twitch.verifyAuth');
  2909. return false;
  2910. }
  2911. }
  2912. async function Twitch_updateAuth2() {
  2913. try {
  2914. const logStatus = scripts_echoLog({
  2915. text: i18n('updatingAuth', 'Twitch')
  2916. });
  2917. return await new Promise(resolve => {
  2918. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2919. active: true,
  2920. insert: true,
  2921. setParent: true
  2922. });
  2923. newTab.onclose = async () => {
  2924. const auth = GM_getValue('twitchAuth');
  2925. if (auth) {
  2926. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2927. logStatus.success();
  2928. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2929. } else {
  2930. logStatus.error('Error: Update twitch auth failed!');
  2931. resolve(false);
  2932. }
  2933. };
  2934. });
  2935. } catch (error) {
  2936. throwError(error, 'Twitch.updateAuth');
  2937. return false;
  2938. }
  2939. }
  2940. async function _toggleChannel2(_ref2) {
  2941. let {
  2942. name,
  2943. doTask = true
  2944. } = _ref2;
  2945. try {
  2946. if (!doTask && this.whiteList.channels.includes(name)) {
  2947. scripts_echoLog({
  2948. type: 'whiteList',
  2949. text: 'Twitch.unfollowChannel',
  2950. id: name
  2951. });
  2952. return true;
  2953. }
  2954. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2955. if (!channelId) {
  2956. return false;
  2957. }
  2958. const logStatus = scripts_echoLog({
  2959. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2960. text: name
  2961. });
  2962. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2963. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2964. const {
  2965. result,
  2966. statusText,
  2967. status,
  2968. data
  2969. } = await tools_httpRequest({
  2970. url: 'https://gql.twitch.tv/gql',
  2971. method: 'POST',
  2972. dataType: 'json',
  2973. headers: {
  2974. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2975. },
  2976. data: doTask ? followData : unfollowData
  2977. });
  2978. if (result === 'Success') {
  2979. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2980. logStatus.success();
  2981. if (doTask) {
  2982. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2983. }
  2984. return true;
  2985. }
  2986. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2987. return false;
  2988. }
  2989. logStatus.error(`${result}:${statusText}(${status})`);
  2990. return false;
  2991. } catch (error) {
  2992. throwError(error, 'Twitch.toggleChannel');
  2993. return false;
  2994. }
  2995. }
  2996. async function _getChannelId2(name) {
  2997. try {
  2998. const logStatus = scripts_echoLog({
  2999. type: 'gettingTwitchChannelId',
  3000. text: name
  3001. });
  3002. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3003. if (channelId) {
  3004. logStatus.success();
  3005. return channelId;
  3006. }
  3007. const {
  3008. result,
  3009. statusText,
  3010. status,
  3011. data
  3012. } = await tools_httpRequest({
  3013. url: 'https://gql.twitch.tv/gql',
  3014. method: 'POST',
  3015. headers: {
  3016. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3017. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3018. },
  3019. responseType: 'json',
  3020. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3021. });
  3022. if (result === 'Success') {
  3023. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3024. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3025. 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);
  3026. if (channelId) {
  3027. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3028. logStatus.success();
  3029. return channelId;
  3030. }
  3031. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3032. return false;
  3033. }
  3034. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3035. return false;
  3036. }
  3037. logStatus.error(`${result}:${statusText}(${status})`);
  3038. return false;
  3039. } catch (error) {
  3040. throwError(error, 'Twitch.getChannelId');
  3041. return false;
  3042. }
  3043. }
  3044. function Twitch_setCache2(name, id) {
  3045. try {
  3046. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3047. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3048. } catch (error) {
  3049. throwError(error, 'Twitch.setCache');
  3050. }
  3051. }
  3052. const social_Twitch = Twitch;
  3053. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3054. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3055. privateSet.add(obj);
  3056. }
  3057. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3058. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3059. privateMap.set(obj, value);
  3060. }
  3061. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3062. if (privateCollection.has(obj)) {
  3063. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3064. }
  3065. }
  3066. function Twitter_defineProperty(obj, key, value) {
  3067. if (key in obj) {
  3068. Object.defineProperty(obj, key, {
  3069. value: value,
  3070. enumerable: true,
  3071. configurable: true,
  3072. writable: true
  3073. });
  3074. } else {
  3075. obj[key] = value;
  3076. }
  3077. return obj;
  3078. }
  3079. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3080. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3081. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3082. return value;
  3083. }
  3084. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3085. if (descriptor.set) {
  3086. descriptor.set.call(receiver, value);
  3087. } else {
  3088. if (!descriptor.writable) {
  3089. throw new TypeError('attempted to set read only private field');
  3090. }
  3091. descriptor.value = value;
  3092. }
  3093. }
  3094. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3095. if (!privateSet.has(receiver)) {
  3096. throw new TypeError('attempted to get private field on non-instance');
  3097. }
  3098. return fn;
  3099. }
  3100. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3101. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3102. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3103. }
  3104. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3105. if (!privateMap.has(receiver)) {
  3106. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3107. }
  3108. return privateMap.get(receiver);
  3109. }
  3110. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3111. if (descriptor.get) {
  3112. return descriptor.get.call(receiver);
  3113. }
  3114. return descriptor.value;
  3115. }
  3116. const Twitter_defaultTasksTemplate = {
  3117. users: [],
  3118. retweets: [],
  3119. likes: []
  3120. };
  3121. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3122. var _verifyId = new WeakMap();
  3123. var Twitter_auth = new WeakMap();
  3124. var Twitter_cache = new WeakMap();
  3125. var Twitter_initialized = new WeakMap();
  3126. var Twitter_verifyAuth = new WeakSet();
  3127. var Twitter_updateAuth = new WeakSet();
  3128. var _toggleUser = new WeakSet();
  3129. var _toggleRetweet = new WeakSet();
  3130. var Twitter_setCache = new WeakSet();
  3131. class Twitter extends social_Social {
  3132. constructor() {
  3133. var _GM_getValue;
  3134. super(...arguments);
  3135. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3136. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3137. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3138. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3139. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3140. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3141. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || JSON.parse(Twitter_defaultTasks));
  3142. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3143. writable: true,
  3144. value: globalOptions.other.twitterVerifyId
  3145. });
  3146. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3147. writable: true,
  3148. value: GM_getValue('twitterAuth') || {}
  3149. });
  3150. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3151. writable: true,
  3152. value: GM_getValue('twitterCache') || {}
  3153. });
  3154. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3155. writable: true,
  3156. value: false
  3157. });
  3158. }
  3159. async init() {
  3160. try {
  3161. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3162. return true;
  3163. }
  3164. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3165. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3166. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3167. return true;
  3168. }
  3169. return false;
  3170. }
  3171. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3172. if (isVerified) {
  3173. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3174. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3175. return true;
  3176. }
  3177. GM_setValue('twitterAuth', null);
  3178. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3179. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3180. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3181. return true;
  3182. }
  3183. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3184. return false;
  3185. } catch (error) {
  3186. throwError(error, 'Twitter.init');
  3187. return false;
  3188. }
  3189. }
  3190. async userName2id(name) {
  3191. try {
  3192. const logStatus = scripts_echoLog({
  3193. type: 'gettingTwitterUserId',
  3194. text: name
  3195. });
  3196. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3197. if (userId) {
  3198. logStatus.success();
  3199. return userId;
  3200. }
  3201. const {
  3202. result,
  3203. statusText,
  3204. status,
  3205. data
  3206. } = await tools_httpRequest({
  3207. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3208. method: 'GET',
  3209. headers: {
  3210. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3211. 'content-type': 'application/json'
  3212. },
  3213. responseType: 'json',
  3214. anonymous: true
  3215. });
  3216. if (result === 'Success') {
  3217. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3218. var _response, _response$data, _response$data$user;
  3219. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3220. if (!response) {
  3221. try {
  3222. response = JSON.parse(data.responseText);
  3223. } catch (error) {
  3224. response = null;
  3225. }
  3226. }
  3227. const userId = String((_response = response) === null || _response === void 0 ? void 0 : (_response$data = _response.data) === null || _response$data === void 0 ? void 0 : (_response$data$user = _response$data.user) === null || _response$data$user === void 0 ? void 0 : _response$data$user.rest_id);
  3228. if (userId) {
  3229. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3230. logStatus.success();
  3231. return userId;
  3232. }
  3233. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3234. return false;
  3235. }
  3236. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3237. return false;
  3238. }
  3239. logStatus.error(`${result}:${statusText}(${status})`);
  3240. return false;
  3241. } catch (error) {
  3242. throwError(error, 'Twitter.getUserId');
  3243. return false;
  3244. }
  3245. }
  3246. async toggle(_ref) {
  3247. let {
  3248. doTask = true,
  3249. userLinks = [],
  3250. retweetLinks = []
  3251. } = _ref;
  3252. try {
  3253. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3254. scripts_echoLog({
  3255. text: i18n('needInit')
  3256. });
  3257. return false;
  3258. }
  3259. const prom = [];
  3260. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3261. scripts_echoLog({
  3262. type: 'globalOptionsSkip',
  3263. text: 'twitter.users'
  3264. });
  3265. } else {
  3266. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3267. var _link$match;
  3268. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3269. });
  3270. if (realUsers.length > 0) {
  3271. for (const user of realUsers) {
  3272. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3273. name: user,
  3274. doTask: doTask
  3275. }));
  3276. await delay(1e3);
  3277. }
  3278. }
  3279. }
  3280. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3281. scripts_echoLog({
  3282. type: 'globalOptionsSkip',
  3283. text: 'twitter.retweets'
  3284. });
  3285. } else {
  3286. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3287. var _link$match2;
  3288. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3289. });
  3290. if (realRetweets.length > 0) {
  3291. for (const retweet of realRetweets) {
  3292. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3293. retweetId: retweet,
  3294. doTask: doTask
  3295. }));
  3296. await delay(1e3);
  3297. }
  3298. }
  3299. }
  3300. return Promise.all(prom).then(() => true);
  3301. } catch (error) {
  3302. throwError(error, 'Twitter.toggle');
  3303. return false;
  3304. }
  3305. }
  3306. }
  3307. async function Twitter_verifyAuth2() {
  3308. try {
  3309. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3310. name: 'verify',
  3311. doTask: true,
  3312. verify: true
  3313. });
  3314. } catch (error) {
  3315. throwError(error, 'Twitter.verifyAuth');
  3316. return false;
  3317. }
  3318. }
  3319. async function Twitter_updateAuth2() {
  3320. try {
  3321. const logStatus = scripts_echoLog({
  3322. text: i18n('updatingAuth', 'Twitter')
  3323. });
  3324. return await new Promise(resolve => {
  3325. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3326. active: true,
  3327. insert: true,
  3328. setParent: true
  3329. });
  3330. newTab.onclose = async () => {
  3331. const auth = GM_getValue('twitterAuth');
  3332. if (auth) {
  3333. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3334. logStatus.success();
  3335. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3336. } else {
  3337. logStatus.error('Error: Update twitter auth failed!');
  3338. resolve(false);
  3339. }
  3340. };
  3341. });
  3342. } catch (error) {
  3343. throwError(error, 'Twitter.updateToken');
  3344. return false;
  3345. }
  3346. }
  3347. async function _toggleUser2(_ref2) {
  3348. let {
  3349. name,
  3350. doTask = true,
  3351. verify = false
  3352. } = _ref2;
  3353. try {
  3354. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3355. scripts_echoLog({
  3356. type: 'whiteList',
  3357. text: 'Twitter.unfollowUser',
  3358. id: name
  3359. });
  3360. return true;
  3361. }
  3362. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3363. if (!userId) {
  3364. return false;
  3365. }
  3366. const logStatus = verify ? scripts_echoLog({
  3367. text: i18n('verifyingAuth', 'Twitter')
  3368. }) : scripts_echoLog({
  3369. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3370. text: name
  3371. });
  3372. const {
  3373. result,
  3374. statusText,
  3375. status,
  3376. data
  3377. } = await tools_httpRequest({
  3378. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3379. method: 'POST',
  3380. headers: {
  3381. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3382. 'Content-Type': 'application/x-www-form-urlencoded',
  3383. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3384. },
  3385. responseType: 'json',
  3386. data: $.param({
  3387. include_profile_interstitial_type: 1,
  3388. include_blocking: 1,
  3389. include_blocked_by: 1,
  3390. include_followed_by: 1,
  3391. include_want_retweets: 1,
  3392. include_mute_edge: 1,
  3393. include_can_dm: 1,
  3394. include_can_media_tag: 1,
  3395. skip_status: 1,
  3396. id: userId
  3397. })
  3398. });
  3399. if (result === 'Success') {
  3400. var _data$response, _data$response$errors, _data$response$errors2;
  3401. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3402. logStatus.success();
  3403. if (doTask && !verify) {
  3404. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3405. }
  3406. return true;
  3407. }
  3408. 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) {
  3409. logStatus.success();
  3410. return true;
  3411. }
  3412. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3413. return false;
  3414. }
  3415. logStatus.error(`${result}:${statusText}(${status})`);
  3416. return false;
  3417. } catch (error) {
  3418. throwError(error, 'Twitter.toggleUser');
  3419. return false;
  3420. }
  3421. }
  3422. async function _toggleRetweet2(_ref3) {
  3423. let {
  3424. retweetId,
  3425. doTask = true
  3426. } = _ref3;
  3427. try {
  3428. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3429. scripts_echoLog({
  3430. type: 'whiteList',
  3431. text: 'Twitter.unretweet',
  3432. id: retweetId
  3433. });
  3434. return true;
  3435. }
  3436. const logStatus = scripts_echoLog({
  3437. type: `${doTask ? '' : 'un'}retweetting`,
  3438. text: retweetId
  3439. });
  3440. const {
  3441. result,
  3442. statusText,
  3443. status,
  3444. data
  3445. } = await tools_httpRequest({
  3446. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3447. method: 'POST',
  3448. headers: {
  3449. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3450. 'Content-Type': 'application/x-www-form-urlencoded',
  3451. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3452. },
  3453. data: $.param({
  3454. tweet_mode: 'extended',
  3455. id: retweetId
  3456. }),
  3457. responseType: 'json'
  3458. });
  3459. if (result === 'Success') {
  3460. var _data$response2, _data$response2$error, _data$response2$error2;
  3461. 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) {
  3462. logStatus.success();
  3463. if (doTask) {
  3464. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3465. }
  3466. return true;
  3467. }
  3468. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3469. return false;
  3470. }
  3471. logStatus.error(`${result}:${statusText}(${status})`);
  3472. return false;
  3473. } catch (error) {
  3474. throwError(error, 'Twitter.toggleRetweet');
  3475. return false;
  3476. }
  3477. }
  3478. function Twitter_setCache2(name, id) {
  3479. try {
  3480. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3481. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3482. } catch (error) {
  3483. throwError(error, 'Twitter.setCache');
  3484. }
  3485. }
  3486. const social_Twitter = Twitter;
  3487. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3488. Vk_checkPrivateRedeclaration(obj, privateSet);
  3489. privateSet.add(obj);
  3490. }
  3491. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3492. Vk_checkPrivateRedeclaration(obj, privateMap);
  3493. privateMap.set(obj, value);
  3494. }
  3495. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3496. if (privateCollection.has(obj)) {
  3497. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3498. }
  3499. }
  3500. function Vk_defineProperty(obj, key, value) {
  3501. if (key in obj) {
  3502. Object.defineProperty(obj, key, {
  3503. value: value,
  3504. enumerable: true,
  3505. configurable: true,
  3506. writable: true
  3507. });
  3508. } else {
  3509. obj[key] = value;
  3510. }
  3511. return obj;
  3512. }
  3513. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3514. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3515. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3516. return value;
  3517. }
  3518. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3519. if (descriptor.set) {
  3520. descriptor.set.call(receiver, value);
  3521. } else {
  3522. if (!descriptor.writable) {
  3523. throw new TypeError('attempted to set read only private field');
  3524. }
  3525. descriptor.value = value;
  3526. }
  3527. }
  3528. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3529. if (!privateSet.has(receiver)) {
  3530. throw new TypeError('attempted to get private field on non-instance');
  3531. }
  3532. return fn;
  3533. }
  3534. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3535. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3536. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3537. }
  3538. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3539. if (!privateMap.has(receiver)) {
  3540. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3541. }
  3542. return privateMap.get(receiver);
  3543. }
  3544. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3545. if (descriptor.get) {
  3546. return descriptor.get.call(receiver);
  3547. }
  3548. return descriptor.value;
  3549. }
  3550. const Vk_defaultTasksTemplate = {
  3551. names: []
  3552. };
  3553. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3554. var _username = new WeakMap();
  3555. var Vk_cache = new WeakMap();
  3556. var Vk_initialized = new WeakMap();
  3557. var Vk_verifyAuth = new WeakSet();
  3558. var _toggleGroup = new WeakSet();
  3559. var _togglePublic = new WeakSet();
  3560. var _sendWall = new WeakSet();
  3561. var _deleteWall = new WeakSet();
  3562. var _getId = new WeakSet();
  3563. var _toggleVk = new WeakSet();
  3564. var Vk_setCache = new WeakSet();
  3565. class Vk extends social_Social {
  3566. constructor() {
  3567. var _GM_getValue;
  3568. super(...arguments);
  3569. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3570. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3571. Vk_classPrivateMethodInitSpec(this, _getId);
  3572. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3573. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3574. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3575. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3576. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3577. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3578. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || JSON.parse(Vk_defaultTasks));
  3579. Vk_classPrivateFieldInitSpec(this, _username, {
  3580. writable: true,
  3581. value: ''
  3582. });
  3583. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3584. writable: true,
  3585. value: GM_getValue('vkCache') || {}
  3586. });
  3587. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3588. writable: true,
  3589. value: false
  3590. });
  3591. }
  3592. async init() {
  3593. try {
  3594. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3595. return true;
  3596. }
  3597. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3598. if (isVerified) {
  3599. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3600. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3601. return true;
  3602. }
  3603. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3604. return false;
  3605. } catch (error) {
  3606. throwError(error, 'Vk.init');
  3607. return false;
  3608. }
  3609. }
  3610. async toggle(_ref) {
  3611. let {
  3612. doTask = true,
  3613. nameLinks = []
  3614. } = _ref;
  3615. try {
  3616. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3617. scripts_echoLog({
  3618. text: i18n('needInit')
  3619. });
  3620. return false;
  3621. }
  3622. const prom = [];
  3623. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3624. scripts_echoLog({
  3625. type: 'globalOptionsSkip',
  3626. text: 'vk.names'
  3627. });
  3628. } else {
  3629. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3630. var _link$match;
  3631. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3632. });
  3633. if (realNames.length > 0) {
  3634. for (const name of realNames) {
  3635. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3636. name: name,
  3637. doTask: doTask
  3638. }));
  3639. await delay(1e3);
  3640. }
  3641. }
  3642. }
  3643. return Promise.all(prom).then(() => true);
  3644. } catch (error) {
  3645. throwError(error, 'Vk.toggle');
  3646. return false;
  3647. }
  3648. }
  3649. }
  3650. async function Vk_verifyAuth2() {
  3651. try {
  3652. const logStatus = scripts_echoLog({
  3653. text: i18n('verifyAuth', 'Vk')
  3654. });
  3655. const {
  3656. result,
  3657. statusText,
  3658. status,
  3659. data
  3660. } = await tools_httpRequest({
  3661. url: 'https://vk.com/im',
  3662. method: 'GET'
  3663. });
  3664. if (result === 'Success') {
  3665. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3666. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3667. return false;
  3668. }
  3669. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3670. var _data$responseText$ma;
  3671. 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]) || '');
  3672. logStatus.success();
  3673. return true;
  3674. }
  3675. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3676. return false;
  3677. }
  3678. logStatus.error(`${result}:${statusText}(${status})`);
  3679. return false;
  3680. } catch (error) {
  3681. throwError(error, 'Vk.verifyAuth');
  3682. return false;
  3683. }
  3684. }
  3685. async function _toggleGroup2(name, dataParam) {
  3686. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3687. try {
  3688. const logStatus = scripts_echoLog({
  3689. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3690. text: name
  3691. });
  3692. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3693. logStatus.success();
  3694. return true;
  3695. }
  3696. const reqData = {
  3697. act: doTask ? 'enter' : 'leave',
  3698. al: 1,
  3699. gid: dataParam.groupId,
  3700. hash: dataParam.groupHash
  3701. };
  3702. if (doTask) {
  3703. reqData.context = '_';
  3704. }
  3705. const {
  3706. result,
  3707. statusText,
  3708. status,
  3709. data
  3710. } = await tools_httpRequest({
  3711. url: 'https://vk.com/al_groups.php',
  3712. method: 'POST',
  3713. headers: {
  3714. origin: 'https://vk.com',
  3715. referer: `https://vk.com/${name}`,
  3716. 'content-type': 'application/x-www-form-urlencoded'
  3717. },
  3718. data: $.param(reqData)
  3719. });
  3720. if (result === 'Success') {
  3721. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3722. logStatus.success();
  3723. if (doTask) {
  3724. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3725. }
  3726. return true;
  3727. }
  3728. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3729. return false;
  3730. }
  3731. logStatus.error(`${result}:${statusText}(${status})`);
  3732. return false;
  3733. } catch (error) {
  3734. throwError(error, 'Vk.toggleGroup');
  3735. return false;
  3736. }
  3737. }
  3738. async function _togglePublic2(name, dataParam) {
  3739. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3740. try {
  3741. const logStatus = scripts_echoLog({
  3742. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3743. text: name
  3744. });
  3745. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3746. logStatus.success();
  3747. return true;
  3748. }
  3749. const {
  3750. result,
  3751. statusText,
  3752. status,
  3753. data
  3754. } = await tools_httpRequest({
  3755. url: 'https://vk.com/al_public.php',
  3756. method: 'POST',
  3757. headers: {
  3758. origin: 'https://vk.com',
  3759. referer: `https://vk.com/${name}`,
  3760. 'content-type': 'application/x-www-form-urlencoded'
  3761. },
  3762. data: $.param({
  3763. act: doTask ? 'a_enter' : 'a_leave',
  3764. al: 1,
  3765. pid: dataParam.publicPid,
  3766. hash: dataParam.publicHash
  3767. })
  3768. });
  3769. if (result === 'Success') {
  3770. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3771. logStatus.success();
  3772. if (doTask) {
  3773. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3774. }
  3775. return true;
  3776. }
  3777. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3778. return false;
  3779. }
  3780. logStatus.error(`${result}:${statusText}(${status})`);
  3781. return false;
  3782. } catch (error) {
  3783. throwError(error, 'Vk.togglePublic');
  3784. return false;
  3785. }
  3786. }
  3787. async function _sendWall2(name) {
  3788. try {
  3789. const logStatus = scripts_echoLog({
  3790. type: 'sendingVkWall',
  3791. text: name
  3792. });
  3793. const {
  3794. result,
  3795. statusText,
  3796. status,
  3797. data
  3798. } = await tools_httpRequest({
  3799. url: 'https://vk.com/like.php',
  3800. method: 'POST',
  3801. headers: {
  3802. origin: 'https://vk.com',
  3803. referer: `https://vk.com/${name}`,
  3804. 'content-type': 'application/x-www-form-urlencoded'
  3805. },
  3806. data: $.param({
  3807. act: 'publish_box',
  3808. al: 1,
  3809. object: name
  3810. })
  3811. });
  3812. if (result === 'Success') {
  3813. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3814. var _data$responseText$ma2;
  3815. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3816. if (hash) {
  3817. const {
  3818. result: resultR,
  3819. statusText: statusTextR,
  3820. status: statusR,
  3821. data: dataR
  3822. } = await tools_httpRequest({
  3823. url: 'https://vk.com/like.php',
  3824. method: 'POST',
  3825. headers: {
  3826. origin: 'https://vk.com',
  3827. referer: `https://vk.com/${name}`,
  3828. 'content-type': 'application/x-www-form-urlencoded'
  3829. },
  3830. data: $.param({
  3831. Message: '',
  3832. act: 'a_do_publish',
  3833. al: 1,
  3834. close_comments: 0,
  3835. friends_only: 0,
  3836. from: 'box',
  3837. hash: hash,
  3838. list: '',
  3839. mark_as_ads: 0,
  3840. mute_notifications: 0,
  3841. object: name,
  3842. ret_data: 1,
  3843. to: 0
  3844. })
  3845. });
  3846. if (resultR === 'Success') {
  3847. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3848. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3849. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3850. 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) {
  3851. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3852. logStatus.success();
  3853. 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);
  3854. 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);
  3855. if (postId && ownerId) {
  3856. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3857. }
  3858. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3859. return true;
  3860. }
  3861. }
  3862. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3863. return false;
  3864. }
  3865. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3866. return false;
  3867. }
  3868. logStatus.error('Error: Get "hash" failed');
  3869. return false;
  3870. }
  3871. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3872. return false;
  3873. }
  3874. logStatus.error(`${result}:${statusText}(${status})`);
  3875. return false;
  3876. } catch (error) {
  3877. throwError(error, 'Vk.sendWall');
  3878. return false;
  3879. }
  3880. }
  3881. async function _deleteWall2(name, dataParams) {
  3882. try {
  3883. const logStatus = scripts_echoLog({
  3884. type: 'deletingVkWall',
  3885. text: name
  3886. });
  3887. const {
  3888. result,
  3889. statusText,
  3890. status,
  3891. data
  3892. } = await tools_httpRequest({
  3893. url: 'https://vk.com/al_wall.php?act=delete',
  3894. method: 'POST',
  3895. headers: {
  3896. origin: 'https://vk.com',
  3897. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3898. 'content-type': 'application/x-www-form-urlencoded'
  3899. },
  3900. data: $.param({
  3901. act: 'delete',
  3902. al: 1,
  3903. confirm: 0,
  3904. from: 'wkview',
  3905. hash: dataParams.wallHash,
  3906. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3907. })
  3908. });
  3909. if (result === 'Success') {
  3910. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3911. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3912. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3913. 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]) {
  3914. logStatus.success();
  3915. return true;
  3916. }
  3917. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3918. return false;
  3919. }
  3920. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3921. return false;
  3922. }
  3923. logStatus.error(`${result}:${statusText}(${status})`);
  3924. return false;
  3925. } catch (error) {
  3926. throwError(error, 'Vk.deleteWall');
  3927. return false;
  3928. }
  3929. }
  3930. async function _getId2(name, doTask) {
  3931. try {
  3932. let url = `https://vk.com/${name}`;
  3933. if (/^wall-/.test(name)) {
  3934. if (doTask) {
  3935. return {
  3936. type: 'sendWall'
  3937. };
  3938. }
  3939. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3940. return {
  3941. type: 'unSupport'
  3942. };
  3943. }
  3944. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3945. }
  3946. const logStatus = scripts_echoLog({
  3947. type: 'gettingVkId',
  3948. text: name
  3949. });
  3950. const {
  3951. result,
  3952. statusText,
  3953. status,
  3954. data
  3955. } = await tools_httpRequest({
  3956. url: url,
  3957. method: 'GET'
  3958. });
  3959. if (result === 'Success') {
  3960. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3961. var _data$responseText$ma3, _data$responseText$ma4;
  3962. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3963. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3964. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3965. const publicJoined = !data.responseText.includes('Public.subscribe');
  3966. if (groupAct && groupId && groupHash) {
  3967. logStatus.success();
  3968. return {
  3969. groupAct: groupAct,
  3970. groupId: groupId,
  3971. groupHash: groupHash,
  3972. type: 'group'
  3973. };
  3974. } else if (publicHash && publicPid) {
  3975. logStatus.success();
  3976. return {
  3977. publicHash: publicHash,
  3978. publicPid: publicPid,
  3979. publicJoined: publicJoined,
  3980. type: 'public'
  3981. };
  3982. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3983. var _data$responseText$ma5;
  3984. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3985. if (wallHash) {
  3986. logStatus.success();
  3987. return {
  3988. type: 'deleteWall',
  3989. wallHash: wallHash
  3990. };
  3991. }
  3992. } else if (name.includes('wall') && doTask) {
  3993. logStatus.success();
  3994. return {
  3995. type: 'sendWall'
  3996. };
  3997. }
  3998. logStatus.error('Error: Parameters not found!');
  3999. return false;
  4000. }
  4001. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4002. return false;
  4003. }
  4004. logStatus.error(`${result}:${statusText}(${status})`);
  4005. return false;
  4006. } catch (error) {
  4007. throwError(error, 'Vk.getId');
  4008. return false;
  4009. }
  4010. }
  4011. async function _toggleVk2(_ref2) {
  4012. let {
  4013. name,
  4014. doTask = true
  4015. } = _ref2;
  4016. try {
  4017. if (!doTask && this.whiteList.names.includes(name)) {
  4018. scripts_echoLog({
  4019. type: 'whiteList',
  4020. text: 'Vk.undoTask',
  4021. id: name
  4022. });
  4023. return true;
  4024. }
  4025. const formatName = name.replace(/\/$/, '');
  4026. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4027. if (!data) {
  4028. return false;
  4029. }
  4030. switch (data.type) {
  4031. case 'group':
  4032. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4033.  
  4034. case 'public':
  4035. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4036.  
  4037. case 'sendWall':
  4038. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4039.  
  4040. case 'deleteWall':
  4041. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4042.  
  4043. default:
  4044. return false;
  4045. }
  4046. } catch (error) {
  4047. throwError(error, 'Vk.toggleVk');
  4048. return false;
  4049. }
  4050. }
  4051. function Vk_setCache2(name, postId) {
  4052. try {
  4053. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4054. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4055. } catch (error) {
  4056. throwError(error, 'Vk.setCache');
  4057. }
  4058. }
  4059. const social_Vk = Vk;
  4060. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4061. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4062. privateSet.add(obj);
  4063. }
  4064. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4065. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4066. privateMap.set(obj, value);
  4067. }
  4068. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4069. if (privateCollection.has(obj)) {
  4070. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4071. }
  4072. }
  4073. function Youtube_defineProperty(obj, key, value) {
  4074. if (key in obj) {
  4075. Object.defineProperty(obj, key, {
  4076. value: value,
  4077. enumerable: true,
  4078. configurable: true,
  4079. writable: true
  4080. });
  4081. } else {
  4082. obj[key] = value;
  4083. }
  4084. return obj;
  4085. }
  4086. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4087. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4088. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4089. return value;
  4090. }
  4091. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4092. if (descriptor.set) {
  4093. descriptor.set.call(receiver, value);
  4094. } else {
  4095. if (!descriptor.writable) {
  4096. throw new TypeError('attempted to set read only private field');
  4097. }
  4098. descriptor.value = value;
  4099. }
  4100. }
  4101. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4102. if (!privateSet.has(receiver)) {
  4103. throw new TypeError('attempted to get private field on non-instance');
  4104. }
  4105. return fn;
  4106. }
  4107. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4108. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4109. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4110. }
  4111. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4112. if (!privateMap.has(receiver)) {
  4113. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4114. }
  4115. return privateMap.get(receiver);
  4116. }
  4117. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4118. if (descriptor.get) {
  4119. return descriptor.get.call(receiver);
  4120. }
  4121. return descriptor.value;
  4122. }
  4123. const Youtube_defaultTasksTemplate = {
  4124. channels: [],
  4125. likes: []
  4126. };
  4127. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4128. const getInfo = async function(link, type) {
  4129. try {
  4130. const logStatus = scripts_echoLog({
  4131. text: i18n('gettingYtbToken')
  4132. });
  4133. const {
  4134. result,
  4135. statusText,
  4136. status,
  4137. data
  4138. } = await tools_httpRequest({
  4139. url: link,
  4140. method: 'GET'
  4141. });
  4142. if (result === 'Success') {
  4143. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4144. var _data$responseText$ma, _ref;
  4145. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4146. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4147. return {
  4148. needLogin: true
  4149. };
  4150. }
  4151. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4152. 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]) || '{}';
  4153. const {
  4154. client,
  4155. request
  4156. } = JSON.parse(context);
  4157. if (apiKey && client && request) {
  4158. client.hl = 'en';
  4159. if (type === 'channel') {
  4160. var _data$responseText$ma2;
  4161. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4162. if (channelId) {
  4163. logStatus.success();
  4164. return {
  4165. params: {
  4166. apiKey: apiKey,
  4167. client: client,
  4168. request: request,
  4169. channelId: channelId
  4170. }
  4171. };
  4172. }
  4173. logStatus.error('Error: Get "channelId" failed!');
  4174. return {};
  4175. } else if (type === 'likeVideo') {
  4176. var _data$responseText$ma3, _data$responseText$ma4;
  4177. 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];
  4178. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4179. if (videoId) {
  4180. logStatus.success();
  4181. return {
  4182. params: {
  4183. apiKey: apiKey,
  4184. client: client,
  4185. request: request,
  4186. videoId: videoId,
  4187. likeParams: likeParams
  4188. }
  4189. };
  4190. }
  4191. logStatus.error('Error: Get "videoId" failed!');
  4192. return {};
  4193. }
  4194. logStatus.error('Error: Unknown type');
  4195. return {};
  4196. }
  4197. logStatus.error('Error: Parameter "apiKey" not found!');
  4198. return {};
  4199. }
  4200. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4201. return {};
  4202. }
  4203. logStatus.error(`${result}:${statusText}(${status})`);
  4204. return {};
  4205. } catch (error) {
  4206. throwError(error, 'Youtube.getInfo');
  4207. return {};
  4208. }
  4209. };
  4210. var Youtube_auth = new WeakMap();
  4211. var Youtube_initialized = new WeakMap();
  4212. var _verifyChannel = new WeakMap();
  4213. var Youtube_verifyAuth = new WeakSet();
  4214. var Youtube_updateAuth = new WeakSet();
  4215. var _getInfo = new WeakSet();
  4216. var Youtube_toggleChannel = new WeakSet();
  4217. var _toggleLikeVideo = new WeakSet();
  4218. class Youtube extends social_Social {
  4219. constructor() {
  4220. var _GM_getValue;
  4221. super(...arguments);
  4222. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4223. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4224. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4225. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4226. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4227. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4228. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || JSON.parse(Youtube_defaultTasks));
  4229. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4230. writable: true,
  4231. value: GM_getValue('youtubeAuth') || {}
  4232. });
  4233. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4234. writable: true,
  4235. value: false
  4236. });
  4237. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4238. writable: true,
  4239. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4240. });
  4241. }
  4242. async init() {
  4243. try {
  4244. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4245. return true;
  4246. }
  4247. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4248. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4249. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4250. return true;
  4251. }
  4252. return false;
  4253. }
  4254. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4255. if (isVerified) {
  4256. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4257. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4258. return true;
  4259. }
  4260. GM_setValue('youtubeAuth', null);
  4261. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4262. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4263. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4264. return true;
  4265. }
  4266. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4267. return false;
  4268. } catch (error) {
  4269. throwError(error, 'Youtube.init');
  4270. return false;
  4271. }
  4272. }
  4273. async toggle(_ref2) {
  4274. let {
  4275. doTask = true,
  4276. channelLinks = [],
  4277. videoLinks = []
  4278. } = _ref2;
  4279. try {
  4280. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4281. scripts_echoLog({
  4282. text: i18n('needInit')
  4283. });
  4284. return false;
  4285. }
  4286. const prom = [];
  4287. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4288. scripts_echoLog({
  4289. type: 'globalOptionsSkip',
  4290. text: 'youtube.channels'
  4291. });
  4292. } else {
  4293. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4294. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4295. var _link$match;
  4296. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4297. }
  4298. return link;
  4299. });
  4300. if (realChannels.length > 0) {
  4301. for (const channel of realChannels) {
  4302. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4303. link: channel,
  4304. doTask: doTask
  4305. }));
  4306. await delay(1e3);
  4307. }
  4308. }
  4309. }
  4310. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4311. scripts_echoLog({
  4312. type: 'globalOptionsSkip',
  4313. text: 'youtube.likes'
  4314. });
  4315. } else {
  4316. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4317. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4318. var _link$match2;
  4319. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4320. }
  4321. return link;
  4322. });
  4323. if (realLikes.length > 0) {
  4324. for (const video of realLikes) {
  4325. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4326. link: video,
  4327. doTask: doTask
  4328. }));
  4329. await delay(1e3);
  4330. }
  4331. }
  4332. }
  4333. return Promise.all(prom).then(() => true);
  4334. } catch (error) {
  4335. throwError(error, 'Youtube.toggle');
  4336. return false;
  4337. }
  4338. }
  4339. }
  4340. async function Youtube_verifyAuth2() {
  4341. try {
  4342. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4343. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4344. doTask: true,
  4345. verify: true
  4346. });
  4347. } catch (error) {
  4348. throwError(error, 'Youtube.verifyAuth');
  4349. return false;
  4350. }
  4351. }
  4352. async function Youtube_updateAuth2() {
  4353. try {
  4354. const logStatus = scripts_echoLog({
  4355. text: i18n('updatingAuth', 'Youtube')
  4356. });
  4357. return await new Promise(resolve => {
  4358. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4359. active: true,
  4360. insert: true,
  4361. setParent: true
  4362. });
  4363. newTab.onclose = async () => {
  4364. const auth = GM_getValue('youtubeAuth');
  4365. if (auth) {
  4366. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4367. logStatus.success();
  4368. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4369. resolve(result);
  4370. });
  4371. } else {
  4372. logStatus.error('Error: Update youtube auth failed!');
  4373. resolve(false);
  4374. }
  4375. };
  4376. });
  4377. } catch (error) {
  4378. throwError(error, 'Discord.updateAuth');
  4379. return false;
  4380. }
  4381. }
  4382. function _getInfo2(link, type) {
  4383. return getInfo(link, type);
  4384. }
  4385. async function Youtube_toggleChannel2(_ref3) {
  4386. let {
  4387. link,
  4388. doTask = true,
  4389. verify = false
  4390. } = _ref3;
  4391. try {
  4392. const {
  4393. params,
  4394. needLogin
  4395. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4396. const {
  4397. apiKey,
  4398. client,
  4399. request,
  4400. channelId
  4401. } = params || {};
  4402. if (needLogin) {
  4403. scripts_echoLog({
  4404. html: i18n('loginYtb')
  4405. });
  4406. return false;
  4407. }
  4408. if (!(apiKey && client && request && channelId)) {
  4409. scripts_echoLog({
  4410. text: '"getYtbToken" failed'
  4411. });
  4412. return false;
  4413. }
  4414. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4415. scripts_echoLog({
  4416. type: 'whiteList',
  4417. text: 'Youtube.unfollowChannel',
  4418. id: channelId
  4419. });
  4420. return true;
  4421. }
  4422. const logStatus = verify ? scripts_echoLog({
  4423. text: i18n('verifyingAuth', 'Youtube')
  4424. }) : scripts_echoLog({
  4425. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4426. text: channelId
  4427. });
  4428. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4429. const {
  4430. result,
  4431. statusText,
  4432. status,
  4433. data
  4434. } = await tools_httpRequest({
  4435. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4436. method: 'POST',
  4437. headers: {
  4438. origin: 'https://www.youtube.com',
  4439. referer: `https://www.youtube.com/channel/${channelId}`,
  4440. 'content-type': 'application/json',
  4441. 'x-goog-authuser': '0',
  4442. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4443. 'x-origin': 'https://www.youtube.com',
  4444. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4445. },
  4446. data: JSON.stringify({
  4447. context: {
  4448. client: client,
  4449. request: {
  4450. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4451. internalExperimentFlags: [],
  4452. consistencyTokenJars: []
  4453. },
  4454. user: {}
  4455. },
  4456. channelIds: [ channelId ],
  4457. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4458. })
  4459. });
  4460. if (result === 'Success') {
  4461. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4462. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4463. logStatus.success();
  4464. if (doTask && !verify) {
  4465. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4466. }
  4467. return true;
  4468. }
  4469. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4470. logStatus.success();
  4471. return true;
  4472. }
  4473. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4474. return false;
  4475. }
  4476. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4477. return false;
  4478. }
  4479. logStatus.error(`${result}:${statusText}(${status})`);
  4480. return false;
  4481. } catch (error) {
  4482. throwError(error, 'Youtube.toggleChannel');
  4483. return false;
  4484. }
  4485. }
  4486. async function _toggleLikeVideo2(_ref4) {
  4487. let {
  4488. link,
  4489. doTask = true
  4490. } = _ref4;
  4491. try {
  4492. const {
  4493. params,
  4494. needLogin
  4495. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4496. const {
  4497. apiKey,
  4498. client,
  4499. request,
  4500. videoId,
  4501. likeParams
  4502. } = params || {};
  4503. if (needLogin) {
  4504. scripts_echoLog({
  4505. html: `${i18n('loginYtb')}`
  4506. });
  4507. return false;
  4508. }
  4509. if (!(apiKey && client && request && videoId && likeParams)) {
  4510. scripts_echoLog({
  4511. text: '"getYtbToken" failed'
  4512. });
  4513. return false;
  4514. }
  4515. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4516. scripts_echoLog({
  4517. type: 'whiteList',
  4518. text: 'Youtube.unlikeVideo',
  4519. id: videoId
  4520. });
  4521. return true;
  4522. }
  4523. const logStatus = scripts_echoLog({
  4524. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4525. text: videoId
  4526. });
  4527. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4528. const likeVideoData = {
  4529. context: {
  4530. client: client,
  4531. request: {
  4532. sessionId: request.sessionId,
  4533. internalExperimentFlags: [],
  4534. consistencyTokenJars: []
  4535. },
  4536. user: {}
  4537. },
  4538. target: {
  4539. videoId: videoId
  4540. }
  4541. };
  4542. if (doTask) {
  4543. if (likeParams) {
  4544. likeVideoData.params = likeParams;
  4545. } else {
  4546. logStatus.error('Empty likeParams');
  4547. return false;
  4548. }
  4549. }
  4550. const {
  4551. result,
  4552. statusText,
  4553. status,
  4554. data
  4555. } = await tools_httpRequest({
  4556. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4557. method: 'POST',
  4558. headers: {
  4559. origin: 'https://www.youtube.com',
  4560. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4561. 'content-type': 'application/json',
  4562. 'x-goog-authuser': '0',
  4563. 'x-goog-visitor-id': client.visitorData,
  4564. 'x-origin': 'https://www.youtube.com',
  4565. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4566. },
  4567. data: JSON.stringify(likeVideoData)
  4568. });
  4569. if (result === 'Success') {
  4570. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4571. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4572. logStatus.success();
  4573. if (doTask) {
  4574. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4575. }
  4576. return true;
  4577. }
  4578. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4579. return false;
  4580. }
  4581. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4582. return false;
  4583. }
  4584. logStatus.error(`${result}:${statusText}(${status})`);
  4585. return false;
  4586. } catch (error) {
  4587. throwError(error, 'Youtube.toggleLikeVideo');
  4588. return false;
  4589. }
  4590. }
  4591. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4592. Steam_checkPrivateRedeclaration(obj, privateSet);
  4593. privateSet.add(obj);
  4594. }
  4595. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4596. Steam_checkPrivateRedeclaration(obj, privateMap);
  4597. privateMap.set(obj, value);
  4598. }
  4599. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4600. if (privateCollection.has(obj)) {
  4601. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4602. }
  4603. }
  4604. function Steam_defineProperty(obj, key, value) {
  4605. if (key in obj) {
  4606. Object.defineProperty(obj, key, {
  4607. value: value,
  4608. enumerable: true,
  4609. configurable: true,
  4610. writable: true
  4611. });
  4612. } else {
  4613. obj[key] = value;
  4614. }
  4615. return obj;
  4616. }
  4617. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4618. if (!privateSet.has(receiver)) {
  4619. throw new TypeError('attempted to get private field on non-instance');
  4620. }
  4621. return fn;
  4622. }
  4623. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4624. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4625. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4626. return value;
  4627. }
  4628. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4629. if (descriptor.set) {
  4630. descriptor.set.call(receiver, value);
  4631. } else {
  4632. if (!descriptor.writable) {
  4633. throw new TypeError('attempted to set read only private field');
  4634. }
  4635. descriptor.value = value;
  4636. }
  4637. }
  4638. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4639. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4640. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4641. }
  4642. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4643. if (!privateMap.has(receiver)) {
  4644. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4645. }
  4646. return privateMap.get(receiver);
  4647. }
  4648. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4649. if (descriptor.get) {
  4650. return descriptor.get.call(receiver);
  4651. }
  4652. return descriptor.value;
  4653. }
  4654. const Steam_defaultTasksTemplate = {
  4655. groups: [],
  4656. wishlists: [],
  4657. follows: [],
  4658. forums: [],
  4659. workshops: [],
  4660. workshopVotes: [],
  4661. curators: [],
  4662. curatorLikes: [],
  4663. announcements: [],
  4664. licenses: [],
  4665. playtests: []
  4666. };
  4667. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4668. var Steam_cache = new WeakMap();
  4669. var Steam_auth = new WeakMap();
  4670. var _storeInitialized = new WeakMap();
  4671. var _communityInitialized = new WeakMap();
  4672. var _area = new WeakMap();
  4673. var _updateStoreAuth = new WeakSet();
  4674. var _updateCommunityAuth = new WeakSet();
  4675. var _getAreaInfo = new WeakSet();
  4676. var _changeArea = new WeakSet();
  4677. var _joinGroup = new WeakSet();
  4678. var _leaveGroup = new WeakSet();
  4679. var _getGroupId = new WeakSet();
  4680. var _addToWishlist = new WeakSet();
  4681. var _removeFromWishlist = new WeakSet();
  4682. var _toggleFollowGame = new WeakSet();
  4683. var _isFollowedGame = new WeakSet();
  4684. var _toggleForum = new WeakSet();
  4685. var _getForumId = new WeakSet();
  4686. var _toggleFavoriteWorkshop = new WeakSet();
  4687. var _getWorkshopAppId = new WeakSet();
  4688. var _voteUpWorkshop = new WeakSet();
  4689. var _toggleCurator = new WeakSet();
  4690. var _toggleCuratorLike = new WeakSet();
  4691. var _getAnnouncementParams = new WeakSet();
  4692. var _likeAnnouncement = new WeakSet();
  4693. var _appid2subid = new WeakSet();
  4694. var _getLicenses = new WeakSet();
  4695. var _addLicense = new WeakSet();
  4696. var _addFreeLicense = new WeakSet();
  4697. var _requestPlayTestAccess = new WeakSet();
  4698. var Steam_setCache = new WeakSet();
  4699. class Steam extends social_Social {
  4700. constructor() {
  4701. var _GM_getValue;
  4702. super(...arguments);
  4703. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4704. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4705. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4706. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4707. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4708. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4709. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4710. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4711. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4712. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4713. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4714. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4715. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4716. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4717. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4718. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4719. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4720. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4721. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4722. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4723. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4724. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4725. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4726. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4727. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4728. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4729. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4730. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || JSON.parse(Steam_defaultTasks));
  4731. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4732. writable: true,
  4733. value: GM_getValue('steamCache') || {
  4734. group: {},
  4735. forum: {},
  4736. workshop: {},
  4737. curator: {}
  4738. }
  4739. });
  4740. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4741. writable: true,
  4742. value: {}
  4743. });
  4744. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4745. writable: true,
  4746. value: false
  4747. });
  4748. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4749. writable: true,
  4750. value: false
  4751. });
  4752. Steam_classPrivateFieldInitSpec(this, _area, {
  4753. writable: true,
  4754. value: 'CN'
  4755. });
  4756. }
  4757. async init() {
  4758. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4759. try {
  4760. if (type === 'store') {
  4761. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4762. return true;
  4763. }
  4764. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4765. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4766. return true;
  4767. }
  4768. if (type === 'community') {
  4769. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4770. return true;
  4771. }
  4772. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4773. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4774. return true;
  4775. }
  4776. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4777. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4778. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4779. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4780. return true;
  4781. }
  4782. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4783. return false;
  4784. } catch (error) {
  4785. throwError(error, 'Steam.init');
  4786. return false;
  4787. }
  4788. }
  4789. async getCuratorId(path, name) {
  4790. try {
  4791. const logStatus = scripts_echoLog({
  4792. type: 'gettingCuratorId',
  4793. text: `${path}/${name}`
  4794. });
  4795. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4796. if (curatorId) {
  4797. logStatus.success();
  4798. return curatorId;
  4799. }
  4800. const {
  4801. result,
  4802. statusText,
  4803. status,
  4804. data
  4805. } = await tools_httpRequest({
  4806. url: `https://store.steampowered.com/${path}/${name}`,
  4807. method: 'GET',
  4808. headers: {
  4809. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4810. }
  4811. });
  4812. if (result === 'Success') {
  4813. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4814. var _data$responseText$ma;
  4815. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4816. if (curatorId) {
  4817. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4818. logStatus.success();
  4819. return curatorId;
  4820. }
  4821. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4822. return false;
  4823. }
  4824. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4825. return false;
  4826. }
  4827. logStatus.error(`${result}:${statusText}(${status})`);
  4828. return false;
  4829. } catch (error) {
  4830. throwError(error, 'Steam.getCuratorID');
  4831. return false;
  4832. }
  4833. }
  4834. async toggle(_ref) {
  4835. let {
  4836. doTask = true,
  4837. groupLinks = [],
  4838. wishlistLinks = [],
  4839. followLinks = [],
  4840. forumLinks = [],
  4841. workshopLinks = [],
  4842. workshopVoteLinks = [],
  4843. curatorLinks = [],
  4844. curatorLikeLinks = [],
  4845. announcementLinks = [],
  4846. licenseLinks = [],
  4847. playtestLinks = []
  4848. } = _ref;
  4849. try {
  4850. if ([ ...groupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4851. scripts_echoLog({
  4852. text: i18n('needInit')
  4853. });
  4854. return false;
  4855. }
  4856. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4857. scripts_echoLog({
  4858. text: i18n('needInit')
  4859. });
  4860. return false;
  4861. }
  4862. const prom = [];
  4863. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4864. scripts_echoLog({
  4865. type: 'globalOptionsSkip',
  4866. text: 'steam.groups'
  4867. });
  4868. } else {
  4869. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4870. var _link$match;
  4871. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4872. });
  4873. if (realGroups.length > 0) {
  4874. for (const group of realGroups) {
  4875. if (doTask) {
  4876. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4877. } else {
  4878. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4879. }
  4880. await delay(1e3);
  4881. }
  4882. }
  4883. }
  4884. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4885. scripts_echoLog({
  4886. type: 'globalOptionsSkip',
  4887. text: 'steam.wishlists'
  4888. });
  4889. } else {
  4890. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4891. var _link$match2;
  4892. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4893. });
  4894. if (realWishlists.length > 0) {
  4895. for (const game of realWishlists) {
  4896. if (doTask) {
  4897. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4898. } else {
  4899. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4900. }
  4901. await delay(1e3);
  4902. }
  4903. }
  4904. }
  4905. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4906. scripts_echoLog({
  4907. type: 'globalOptionsSkip',
  4908. text: 'steam.follows'
  4909. });
  4910. } else {
  4911. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4912. var _link$match3;
  4913. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4914. });
  4915. if (realFollows.length > 0) {
  4916. for (const game of realFollows) {
  4917. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4918. await delay(1e3);
  4919. }
  4920. }
  4921. }
  4922. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4923. scripts_echoLog({
  4924. type: 'globalOptionsSkip',
  4925. text: 'steam.forums'
  4926. });
  4927. } else {
  4928. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4929. var _link$match4;
  4930. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4931. });
  4932. if (realForums.length > 0) {
  4933. for (const forum of realForums) {
  4934. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4935. await delay(1e3);
  4936. }
  4937. }
  4938. }
  4939. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4940. scripts_echoLog({
  4941. type: 'globalOptionsSkip',
  4942. text: 'steam.workshops'
  4943. });
  4944. } else {
  4945. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4946. var _link$match5;
  4947. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4948. });
  4949. if (realWorkshops.length > 0) {
  4950. for (const workshop of realWorkshops) {
  4951. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4952. await delay(1e3);
  4953. }
  4954. }
  4955. }
  4956. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4957. scripts_echoLog({
  4958. type: 'globalOptionsSkip',
  4959. text: 'steam.workshopVotes'
  4960. });
  4961. } else {
  4962. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4963. var _link$match6;
  4964. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4965. });
  4966. if (doTask && realworkshopVotes.length > 0) {
  4967. for (const workshop of realworkshopVotes) {
  4968. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4969. await delay(1e3);
  4970. }
  4971. }
  4972. }
  4973. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4974. scripts_echoLog({
  4975. type: 'globalOptionsSkip',
  4976. text: 'steam.curators'
  4977. });
  4978. } else {
  4979. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4980. var _link$match7;
  4981. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4982. });
  4983. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4984. var _link$match8;
  4985. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4986. });
  4987. if (realCurators.length > 0) {
  4988. for (const curator of realCurators) {
  4989. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  4990. await delay(1e3);
  4991. }
  4992. }
  4993. if (realCuratorLikes.length > 0) {
  4994. for (const curatorLike of realCuratorLikes) {
  4995. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  4996. await delay(1e3);
  4997. }
  4998. }
  4999. }
  5000. if (doTask && !globalOptions.doTask.steam.announcements) {
  5001. scripts_echoLog({
  5002. type: 'globalOptionsSkip',
  5003. text: 'steam.announcements'
  5004. });
  5005. } else {
  5006. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5007. var _link$match10;
  5008. if (link.includes('store.steampowered.com')) {
  5009. var _link$match9;
  5010. return (_link$match9 = link.match(/store\.steampowered\.com\/news\/app\/([\d]+)\/view\/([\d]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5011. }
  5012. return (_link$match10 = link.match(/steamcommunity\.com\/games\/([\d]+)\/announcements\/detail\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10.slice(1, 3).join('/');
  5013. });
  5014. if (doTask && realAnnouncements.length > 0) {
  5015. for (const id of realAnnouncements) {
  5016. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5017. await delay(1e3);
  5018. }
  5019. }
  5020. }
  5021. if (doTask && !globalOptions.doTask.steam.licenses) {
  5022. scripts_echoLog({
  5023. type: 'globalOptionsSkip',
  5024. text: 'steam.licenses'
  5025. });
  5026. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5027. for (const id of licenseLinks) {
  5028. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5029. await delay(1e3);
  5030. }
  5031. }
  5032. if (doTask && !globalOptions.doTask.steam.playtests) {
  5033. scripts_echoLog({
  5034. type: 'globalOptionsSkip',
  5035. text: 'steam.playtests'
  5036. });
  5037. } else {
  5038. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5039. var _link$match11;
  5040. return (_link$match11 = link.match(/app\/([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1];
  5041. });
  5042. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5043. for (const id of realPlaytests) {
  5044. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5045. await delay(1e3);
  5046. }
  5047. }
  5048. }
  5049. return Promise.all(prom).then(async () => {
  5050. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5051. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5052. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5053. }
  5054. return true;
  5055. });
  5056. } catch (error) {
  5057. throwError(error, 'Steam.toggle');
  5058. return false;
  5059. }
  5060. }
  5061. }
  5062. async function _updateStoreAuth2() {
  5063. try {
  5064. const logStatus = scripts_echoLog({
  5065. text: i18n('updatingAuth', i18n('steamStore'))
  5066. });
  5067. const {
  5068. result,
  5069. statusText,
  5070. status,
  5071. data
  5072. } = await tools_httpRequest({
  5073. url: 'https://store.steampowered.com/stats/',
  5074. method: 'GET'
  5075. });
  5076. if (result === 'Success') {
  5077. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5078. var _data$responseText$ma2;
  5079. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5080. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5081. return false;
  5082. }
  5083. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5084. if (storeSessionID) {
  5085. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5086. logStatus.success();
  5087. return true;
  5088. }
  5089. logStatus.error('Error: Get "sessionID" failed');
  5090. return false;
  5091. }
  5092. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5093. return false;
  5094. }
  5095. logStatus.error(`${result}:${statusText}(${status})`);
  5096. return false;
  5097. } catch (error) {
  5098. throwError(error, 'Steam.updateStoreAuth');
  5099. return false;
  5100. }
  5101. }
  5102. async function _updateCommunityAuth2() {
  5103. try {
  5104. const logStatus = scripts_echoLog({
  5105. text: i18n('updatingAuth', i18n('steamCommunity'))
  5106. });
  5107. const {
  5108. result,
  5109. statusText,
  5110. status,
  5111. data
  5112. } = await tools_httpRequest({
  5113. url: 'https://steamcommunity.com/my',
  5114. method: 'GET'
  5115. });
  5116. if (result === 'Success') {
  5117. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5118. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5119. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5120. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5121. return false;
  5122. }
  5123. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5124. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5125. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5126. if (steam64Id) {
  5127. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5128. }
  5129. if (userName) {
  5130. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5131. }
  5132. if (communitySessionID) {
  5133. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5134. logStatus.success();
  5135. return true;
  5136. }
  5137. logStatus.error('Error: Get "sessionID" failed');
  5138. return false;
  5139. }
  5140. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5141. return false;
  5142. }
  5143. logStatus.error(`${result}:${statusText}(${status})`);
  5144. return false;
  5145. } catch (error) {
  5146. throwError(error, 'Steam.updateCommunityAuth');
  5147. return false;
  5148. }
  5149. }
  5150. async function _getAreaInfo2() {
  5151. try {
  5152. const logStatus = scripts_echoLog({
  5153. text: i18n('gettingAreaInfo')
  5154. });
  5155. const {
  5156. result,
  5157. statusText,
  5158. status,
  5159. data
  5160. } = await tools_httpRequest({
  5161. url: 'https://store.steampowered.com/cart/',
  5162. method: 'GET'
  5163. });
  5164. if (result === 'Success') {
  5165. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5166. var _data$responseText$ma6;
  5167. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5168. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5169. if (currentArea && areas.length > 0) {
  5170. Steam_classPrivateFieldSet(this, _area, currentArea);
  5171. logStatus.success();
  5172. return {
  5173. currentArea: currentArea,
  5174. areas: areas
  5175. };
  5176. }
  5177. logStatus.error('Error: get country info filed');
  5178. return {};
  5179. }
  5180. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5181. return {};
  5182. }
  5183. logStatus.error(`${result}:${statusText}(${status})`);
  5184. return {};
  5185. } catch (error) {
  5186. throwError(error, 'Steam.getAreaInfo');
  5187. return {};
  5188. }
  5189. }
  5190. async function _changeArea2(area) {
  5191. try {
  5192. let aimedArea = area;
  5193. if (!aimedArea) {
  5194. const {
  5195. currentArea,
  5196. areas
  5197. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5198. if (!currentArea || !areas) {
  5199. return false;
  5200. }
  5201. if (currentArea !== 'CN') {
  5202. scripts_echoLog({
  5203. text: 'notNeededChangeArea'
  5204. });
  5205. return 'skip';
  5206. }
  5207. const anotherArea = areas.filter(area => area && area !== 'CN');
  5208. if (!anotherArea || anotherArea.length === 0) {
  5209. scripts_echoLog({
  5210. text: 'noAnotherArea'
  5211. });
  5212. return false;
  5213. }
  5214. [ aimedArea ] = anotherArea;
  5215. }
  5216. const logStatus = scripts_echoLog({
  5217. text: i18n('changingArea', aimedArea)
  5218. });
  5219. const {
  5220. result,
  5221. statusText,
  5222. status,
  5223. data
  5224. } = await tools_httpRequest({
  5225. url: 'https://store.steampowered.com/account/setcountry',
  5226. method: 'POST',
  5227. headers: {
  5228. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5229. },
  5230. data: $.param({
  5231. cc: aimedArea,
  5232. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5233. })
  5234. });
  5235. if (result === 'Success') {
  5236. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5237. const {
  5238. currentArea
  5239. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5240. if (currentArea === aimedArea) {
  5241. logStatus.success();
  5242. return currentArea;
  5243. }
  5244. logStatus.error('Error: change country filed');
  5245. return 'CN';
  5246. }
  5247. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5248. return 'CN';
  5249. }
  5250. logStatus.error(`${result}:${statusText}(${status})`);
  5251. return 'CN';
  5252. } catch (error) {
  5253. throwError(error, 'Steam.changeArea');
  5254. return false;
  5255. }
  5256. }
  5257. async function _joinGroup2(groupName) {
  5258. try {
  5259. const logStatus = scripts_echoLog({
  5260. type: 'joiningSteamGroup',
  5261. text: groupName
  5262. });
  5263. const {
  5264. result,
  5265. statusText,
  5266. status,
  5267. data
  5268. } = await tools_httpRequest({
  5269. url: `https://steamcommunity.com/groups/${groupName}`,
  5270. method: 'POST',
  5271. headers: {
  5272. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5273. },
  5274. data: $.param({
  5275. action: 'join',
  5276. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5277. })
  5278. });
  5279. if (result === 'Success') {
  5280. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5281. logStatus.success();
  5282. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5283. return true;
  5284. }
  5285. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5286. return false;
  5287. }
  5288. logStatus.error(`${result}:${statusText}(${status})`);
  5289. return false;
  5290. } catch (error) {
  5291. throwError(error, 'Steam.joinGroup');
  5292. return false;
  5293. }
  5294. }
  5295. async function _leaveGroup2(groupName) {
  5296. try {
  5297. if (this.whiteList.groups.includes(groupName)) {
  5298. scripts_echoLog({
  5299. type: 'whiteList',
  5300. text: 'Steam.leaveGroup',
  5301. id: groupName
  5302. });
  5303. return true;
  5304. }
  5305. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5306. if (!groupId) {
  5307. return false;
  5308. }
  5309. const logStatus = scripts_echoLog({
  5310. type: 'leavingSteamGroup',
  5311. text: groupName
  5312. });
  5313. const {
  5314. result,
  5315. statusText,
  5316. status,
  5317. data
  5318. } = await tools_httpRequest({
  5319. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5320. method: 'POST',
  5321. headers: {
  5322. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5323. },
  5324. data: $.param({
  5325. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5326. action: 'leaveGroup',
  5327. groupId: groupId
  5328. })
  5329. });
  5330. if (result === 'Success') {
  5331. 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) {
  5332. logStatus.success();
  5333. return true;
  5334. }
  5335. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5336. return false;
  5337. }
  5338. logStatus.error(`${result}:${statusText}(${status})`);
  5339. return false;
  5340. } catch (error) {
  5341. throwError(error, 'Steam.leaveGroup');
  5342. return false;
  5343. }
  5344. }
  5345. async function _getGroupId2(groupName) {
  5346. try {
  5347. const logStatus = scripts_echoLog({
  5348. type: 'gettingSteamGroupId',
  5349. text: groupName
  5350. });
  5351. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5352. if (groupId) {
  5353. logStatus.success();
  5354. return groupId;
  5355. }
  5356. const {
  5357. result,
  5358. statusText,
  5359. status,
  5360. data
  5361. } = await tools_httpRequest({
  5362. url: `https://steamcommunity.com/groups/${groupName}`,
  5363. method: 'GET',
  5364. headers: {
  5365. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5366. }
  5367. });
  5368. if (result === 'Success') {
  5369. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5370. var _data$responseText$ma7;
  5371. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5372. if (groupId) {
  5373. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5374. logStatus.success();
  5375. return groupId;
  5376. }
  5377. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5378. return false;
  5379. }
  5380. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5381. return false;
  5382. }
  5383. logStatus.error(`${result}:${statusText}(${status})`);
  5384. return false;
  5385. } catch (error) {
  5386. throwError(error, 'Steam.getGroupID');
  5387. return false;
  5388. }
  5389. }
  5390. async function _addToWishlist2(gameId) {
  5391. try {
  5392. var _data$response;
  5393. const logStatus = scripts_echoLog({
  5394. type: 'addingToWishlist',
  5395. text: gameId
  5396. });
  5397. const {
  5398. result,
  5399. data
  5400. } = await tools_httpRequest({
  5401. url: 'https://store.steampowered.com/api/addtowishlist',
  5402. method: 'POST',
  5403. headers: {
  5404. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5405. },
  5406. data: $.param({
  5407. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5408. appid: gameId
  5409. }),
  5410. dataType: 'json'
  5411. });
  5412. 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) {
  5413. logStatus.success();
  5414. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5415. return true;
  5416. }
  5417. const {
  5418. result: resultR,
  5419. statusText: statusTextR,
  5420. status: statusR,
  5421. data: dataR
  5422. } = await tools_httpRequest({
  5423. url: `https://store.steampowered.com/app/${gameId}`,
  5424. method: 'GET'
  5425. });
  5426. if (resultR === 'Success') {
  5427. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5428. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5429. logStatus.warning(i18n('changeAreaNotice'));
  5430. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5431. return false;
  5432. }
  5433. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5434. }
  5435. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5436. logStatus.success();
  5437. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5438. return true;
  5439. } 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"')) {
  5440. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5441. return false;
  5442. }
  5443. logStatus.success();
  5444. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5445. return true;
  5446. }
  5447. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5448. return false;
  5449. }
  5450. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5451. return false;
  5452. } catch (error) {
  5453. throwError(error, 'Steam.addToWishlist');
  5454. return false;
  5455. }
  5456. }
  5457. async function _removeFromWishlist2(gameId) {
  5458. try {
  5459. var _data$response2;
  5460. if (this.whiteList.wishlists.includes(gameId)) {
  5461. scripts_echoLog({
  5462. type: 'whiteList',
  5463. text: 'Steam.removeFromWishlist',
  5464. id: gameId
  5465. });
  5466. return true;
  5467. }
  5468. const logStatus = scripts_echoLog({
  5469. type: 'removingFromWishlist',
  5470. text: gameId
  5471. });
  5472. const {
  5473. result,
  5474. data
  5475. } = await tools_httpRequest({
  5476. url: 'https://store.steampowered.com/api/removefromwishlist',
  5477. method: 'POST',
  5478. headers: {
  5479. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5480. },
  5481. data: $.param({
  5482. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5483. appid: gameId
  5484. }),
  5485. dataType: 'json'
  5486. });
  5487. 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) {
  5488. logStatus.success();
  5489. return true;
  5490. }
  5491. const {
  5492. result: resultR,
  5493. statusText: statusTextR,
  5494. status: statusR,
  5495. data: dataR
  5496. } = await tools_httpRequest({
  5497. url: `https://store.steampowered.com/app/${gameId}`,
  5498. method: 'GET'
  5499. });
  5500. if (resultR === 'Success') {
  5501. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5502. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5503. logStatus.warning(i18n('changeAreaNotice'));
  5504. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5505. if (!result || result === 'CN' || result === 'skip') {
  5506. return false;
  5507. }
  5508. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5509. }
  5510. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5511. logStatus.success();
  5512. return true;
  5513. }
  5514. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5515. return false;
  5516. }
  5517. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5518. return false;
  5519. }
  5520. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5521. return false;
  5522. } catch (error) {
  5523. throwError(error, 'Steam.removeFromWishlist');
  5524. return false;
  5525. }
  5526. }
  5527. async function _toggleFollowGame2(gameId, doTask) {
  5528. try {
  5529. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5530. scripts_echoLog({
  5531. type: 'whiteList',
  5532. text: 'Steam.unfollowGame',
  5533. id: gameId
  5534. });
  5535. return true;
  5536. }
  5537. const logStatus = scripts_echoLog({
  5538. type: `${doTask ? '' : 'un'}followingGame`,
  5539. text: gameId
  5540. });
  5541. const requestData = {
  5542. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5543. appid: gameId
  5544. };
  5545. if (!doTask) {
  5546. requestData.unfollow = '1';
  5547. }
  5548. const {
  5549. result,
  5550. data
  5551. } = await tools_httpRequest({
  5552. url: 'https://store.steampowered.com/explore/followgame/',
  5553. method: 'POST',
  5554. headers: {
  5555. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5556. },
  5557. data: $.param(requestData)
  5558. });
  5559. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5560. logStatus.success();
  5561. return true;
  5562. }
  5563. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5564. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5565. logStatus.warning(i18n('changeAreaNotice'));
  5566. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5567. return false;
  5568. }
  5569. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5570. }
  5571. if (doTask === followed) {
  5572. logStatus.success();
  5573. if (doTask) {
  5574. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5575. }
  5576. return true;
  5577. }
  5578. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5579. return false;
  5580. } catch (error) {
  5581. throwError(error, 'Steam.toggleFollowGame');
  5582. return false;
  5583. }
  5584. }
  5585. async function _isFollowedGame2(gameId) {
  5586. try {
  5587. const {
  5588. result,
  5589. data
  5590. } = await tools_httpRequest({
  5591. url: `https://store.steampowered.com/app/${gameId}`,
  5592. method: 'GET'
  5593. });
  5594. if (result === 'Success') {
  5595. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5596. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5597. return 'areaLocked';
  5598. }
  5599. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5600. return true;
  5601. }
  5602. return false;
  5603. }
  5604. return false;
  5605. }
  5606. return false;
  5607. } catch (error) {
  5608. throwError(error, 'Steam.isFollowedGame');
  5609. return false;
  5610. }
  5611. }
  5612. async function _toggleForum2(gameId) {
  5613. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5614. try {
  5615. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5616. scripts_echoLog({
  5617. type: 'whiteList',
  5618. text: 'Steam.unsubscribeForum',
  5619. id: gameId
  5620. });
  5621. return true;
  5622. }
  5623. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5624. if (!forumId) {
  5625. return false;
  5626. }
  5627. const logStatus = scripts_echoLog({
  5628. type: `${doTask ? '' : 'un'}subscribingForum`,
  5629. text: gameId
  5630. });
  5631. const [ id, feature ] = forumId.split('_');
  5632. const {
  5633. result,
  5634. statusText,
  5635. status,
  5636. data
  5637. } = await tools_httpRequest({
  5638. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5639. method: 'POST',
  5640. responseType: 'json',
  5641. headers: {
  5642. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5643. },
  5644. data: $.param({
  5645. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5646. })
  5647. });
  5648. if (result === 'Success') {
  5649. var _data$response3, _data$response4;
  5650. 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)) {
  5651. if (doTask) {
  5652. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5653. }
  5654. logStatus.success();
  5655. return true;
  5656. }
  5657. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5658. return true;
  5659. }
  5660. logStatus.error(`${result}:${statusText}(${status})`);
  5661. return true;
  5662. } catch (error) {
  5663. throwError(error, 'Steam.toggleForum');
  5664. return true;
  5665. }
  5666. }
  5667. async function _getForumId2(gameId) {
  5668. try {
  5669. const logStatus = scripts_echoLog({
  5670. type: 'gettingForumId',
  5671. text: gameId
  5672. });
  5673. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5674. if (forumId) {
  5675. logStatus.success();
  5676. return forumId;
  5677. }
  5678. const {
  5679. result,
  5680. statusText,
  5681. status,
  5682. data
  5683. } = await tools_httpRequest({
  5684. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5685. method: 'GET'
  5686. });
  5687. if (result === 'Success') {
  5688. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5689. var _data$responseText, _data$responseText$ma8;
  5690. const forumId = (_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : (_data$responseText$ma8 = _data$responseText.match(/General_([\d]+(_[\d]+)?)/)) === null || _data$responseText$ma8 === void 0 ? void 0 : _data$responseText$ma8[1];
  5691. if (forumId) {
  5692. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5693. logStatus.success();
  5694. return forumId;
  5695. }
  5696. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5697. return false;
  5698. }
  5699. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5700. return false;
  5701. }
  5702. logStatus.error(`${result}:${statusText}(${status})`);
  5703. return false;
  5704. } catch (error) {
  5705. throwError(error, 'Steam.getForumId');
  5706. return false;
  5707. }
  5708. }
  5709. async function _toggleFavoriteWorkshop2(id) {
  5710. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5711. try {
  5712. if (!doTask && this.whiteList.workshops.includes(id)) {
  5713. scripts_echoLog({
  5714. type: 'whiteList',
  5715. text: 'Steam.unfavoriteWorkshop',
  5716. id: id
  5717. });
  5718. return true;
  5719. }
  5720. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5721. if (!appid) {
  5722. return false;
  5723. }
  5724. const logStatus = scripts_echoLog({
  5725. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5726. text: id
  5727. });
  5728. const {
  5729. result,
  5730. statusText,
  5731. status,
  5732. data
  5733. } = await tools_httpRequest({
  5734. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5735. method: 'POST',
  5736. headers: {
  5737. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5738. },
  5739. data: $.param({
  5740. id: id,
  5741. appid: appid,
  5742. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5743. })
  5744. });
  5745. if (result === 'Success') {
  5746. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5747. if (doTask) {
  5748. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5749. }
  5750. logStatus.success();
  5751. return true;
  5752. }
  5753. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5754. return false;
  5755. }
  5756. logStatus.error(`${result}:${statusText}(${status})`);
  5757. return false;
  5758. } catch (error) {
  5759. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5760. return false;
  5761. }
  5762. }
  5763. async function _getWorkshopAppId2(id) {
  5764. try {
  5765. const logStatus = scripts_echoLog({
  5766. type: 'gettingWorkshopAppId',
  5767. text: id
  5768. });
  5769. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5770. if (appId) {
  5771. logStatus.success();
  5772. return appId;
  5773. }
  5774. const {
  5775. result,
  5776. statusText,
  5777. status,
  5778. data
  5779. } = await tools_httpRequest({
  5780. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5781. method: 'GET'
  5782. });
  5783. if (result === 'Success') {
  5784. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5785. var _data$responseText$ma9;
  5786. const appId = (_data$responseText$ma9 = data.responseText.match(/<input type="hidden" name="appid" value="([\d]+?)" \/>/)) === null || _data$responseText$ma9 === void 0 ? void 0 : _data$responseText$ma9[1];
  5787. if (appId) {
  5788. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5789. logStatus.success();
  5790. return appId;
  5791. }
  5792. logStatus.error('Error: getWorkshopAppId failed');
  5793. return false;
  5794. }
  5795. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5796. return false;
  5797. }
  5798. logStatus.error(`${result}:${statusText}(${status})`);
  5799. return false;
  5800. } catch (error) {
  5801. throwError(error, 'Steam.getWorkshopAppId');
  5802. return false;
  5803. }
  5804. }
  5805. async function _voteUpWorkshop2(id) {
  5806. try {
  5807. const logStatus = scripts_echoLog({
  5808. type: 'votingUpWorkshop',
  5809. text: id
  5810. });
  5811. const {
  5812. result,
  5813. statusText,
  5814. status,
  5815. data
  5816. } = await tools_httpRequest({
  5817. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5818. method: 'POST',
  5819. responseType: 'json',
  5820. headers: {
  5821. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5822. },
  5823. data: $.param({
  5824. id: id,
  5825. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5826. })
  5827. });
  5828. if (result === 'Success') {
  5829. var _data$response5;
  5830. 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) {
  5831. logStatus.success();
  5832. return true;
  5833. }
  5834. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5835. return true;
  5836. }
  5837. logStatus.error(`${result}:${statusText}(${status})`);
  5838. return true;
  5839. } catch (error) {
  5840. throwError(error, 'Steam.voteupWorkshop');
  5841. return true;
  5842. }
  5843. }
  5844. async function _toggleCurator2(curatorId) {
  5845. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5846. try {
  5847. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5848. scripts_echoLog({
  5849. type: 'whiteList',
  5850. text: 'Steam.unfollowCurator',
  5851. id: curatorId
  5852. });
  5853. return true;
  5854. }
  5855. const logStatus = scripts_echoLog({
  5856. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5857. text: curatorId
  5858. });
  5859. const {
  5860. result,
  5861. statusText,
  5862. status,
  5863. data
  5864. } = await tools_httpRequest({
  5865. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5866. method: 'POST',
  5867. headers: {
  5868. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5869. },
  5870. data: $.param({
  5871. clanid: curatorId,
  5872. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5873. follow: doTask
  5874. }),
  5875. dataType: 'json'
  5876. });
  5877. if (result === 'Success') {
  5878. var _data$response6, _data$response6$succe, _data$response7;
  5879. 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) {
  5880. logStatus.success();
  5881. return true;
  5882. }
  5883. 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})`);
  5884. return false;
  5885. }
  5886. logStatus.error(`${result}:${statusText}(${status})`);
  5887. return false;
  5888. } catch (error) {
  5889. throwError(error, 'Steam.toggleCurator');
  5890. return false;
  5891. }
  5892. }
  5893. async function _toggleCuratorLike2(link) {
  5894. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5895. try {
  5896. const [ path, name ] = link.split('/');
  5897. if (!(path && name)) {
  5898. scripts_echoLog({
  5899. text: i18n('errorLink', link)
  5900. });
  5901. return false;
  5902. }
  5903. const curatorId = await this.getCuratorId(path, name);
  5904. if (curatorId) {
  5905. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5906. }
  5907. return false;
  5908. } catch (error) {
  5909. throwError(error, 'Steam.toggleCuratorLike');
  5910. return false;
  5911. }
  5912. }
  5913. async function _getAnnouncementParams2(appId, viewId) {
  5914. try {
  5915. const logStatus = scripts_echoLog({
  5916. type: 'gettingAnnouncementParams',
  5917. text: appId,
  5918. id: viewId
  5919. });
  5920. const {
  5921. result,
  5922. statusText,
  5923. status,
  5924. data
  5925. } = await tools_httpRequest({
  5926. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5927. method: 'GET',
  5928. headers: {
  5929. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5930. }
  5931. });
  5932. if (result === 'Success') {
  5933. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5934. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5935. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5936. logStatus.warning(i18n('changeAreaNotice'));
  5937. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5938. return {};
  5939. }
  5940. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5941. }
  5942. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5943. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5944. const gid = (_data$responseText$ma12 = data.responseText.match(/announcementGID&quot;:&quot;([\d]+?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  5945. if (authWgToken && clanId) {
  5946. logStatus.success();
  5947. return {
  5948. authWgToken: authWgToken,
  5949. clanId: clanId,
  5950. gid: gid
  5951. };
  5952. }
  5953. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5954. return {};
  5955. }
  5956. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5957. return {};
  5958. }
  5959. logStatus.error(`${result}:${statusText}(${status})`);
  5960. return {};
  5961. } catch (error) {
  5962. throwError(error, 'Steam.likeAnnouncement');
  5963. return {};
  5964. }
  5965. }
  5966. async function _likeAnnouncement2(id) {
  5967. try {
  5968. const [ appId, viewId ] = id.split('/');
  5969. if (!(appId && viewId)) {
  5970. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  5971. return false;
  5972. }
  5973. const {
  5974. authWgToken,
  5975. clanId,
  5976. gid
  5977. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5978. if (!(authWgToken && clanId)) {
  5979. return false;
  5980. }
  5981. const logStatus = scripts_echoLog({
  5982. type: 'likingAnnouncement',
  5983. text: appId,
  5984. id: viewId
  5985. });
  5986. const {
  5987. result,
  5988. statusText,
  5989. status,
  5990. data
  5991. } = await tools_httpRequest({
  5992. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5993. method: 'POST',
  5994. headers: {
  5995. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5996. Host: 'store.steampowered.com',
  5997. Origin: 'https://store.steampowered.com',
  5998. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5999. },
  6000. data: $.param({
  6001. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6002. wgauthtoken: authWgToken,
  6003. voteup: 1,
  6004. clanid: clanId,
  6005. ajax: 1
  6006. }),
  6007. dataType: 'json'
  6008. });
  6009. if (result === 'Success') {
  6010. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6011. logStatus.success();
  6012. return true;
  6013. }
  6014. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6015. return false;
  6016. }
  6017. logStatus.error(`${result}:${statusText}(${status})`);
  6018. return false;
  6019. } catch (error) {
  6020. throwError(error, 'Steam.likeAnnouncement');
  6021. return false;
  6022. }
  6023. }
  6024. async function _appid2subid2(id) {
  6025. try {
  6026. const logStatus = scripts_echoLog({
  6027. type: 'gettingSubid',
  6028. text: id
  6029. });
  6030. const {
  6031. result,
  6032. statusText,
  6033. status,
  6034. data
  6035. } = await tools_httpRequest({
  6036. url: `https://store.steampowered.com/app/${id}`,
  6037. method: 'GET',
  6038. headers: {
  6039. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6040. }
  6041. });
  6042. if (result === 'Success') {
  6043. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6044. var _data$responseText$ma13;
  6045. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6046. logStatus.warning(i18n('changeAreaNotice'));
  6047. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6048. if (!result || result === 'CN' || result === 'skip') {
  6049. return false;
  6050. }
  6051. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6052. }
  6053. const subid = (_data$responseText$ma13 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6054. if (subid) {
  6055. logStatus.success();
  6056. return subid;
  6057. }
  6058. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6059. return false;
  6060. }
  6061. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6062. return false;
  6063. }
  6064. logStatus.error(`${result}:${statusText}(${status})`);
  6065. return false;
  6066. } catch (error) {
  6067. throwError(error, 'Steam.appid2subid');
  6068. return false;
  6069. }
  6070. }
  6071. async function _getLicenses2() {
  6072. try {
  6073. const logStatus = scripts_echoLog({
  6074. text: i18n('gettingLicenses')
  6075. });
  6076. const {
  6077. result,
  6078. statusText,
  6079. status,
  6080. data
  6081. } = await tools_httpRequest({
  6082. url: 'https://store.steampowered.com/account/licenses/',
  6083. method: 'GET'
  6084. });
  6085. if (result === 'Success') {
  6086. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6087. logStatus.success();
  6088. return [ ...data.responseText.matchAll(/RemoveFreeLicense\([\s]*?([\d]+)/g) ].map(arr => arr[1]).filter(subid => subid);
  6089. }
  6090. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6091. return false;
  6092. }
  6093. logStatus.error(`${result}:${statusText}(${status})`);
  6094. return false;
  6095. } catch (error) {
  6096. throwError(error, 'Steam.getLicenses');
  6097. return false;
  6098. }
  6099. }
  6100. async function _addLicense2(id) {
  6101. try {
  6102. const [ type, ids ] = id.split('-');
  6103. if (type === 'appid') {
  6104. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6105. if (!subid) {
  6106. return false;
  6107. }
  6108. const logStatus = scripts_echoLog({
  6109. type: 'addingFreeLicense',
  6110. text: ids
  6111. });
  6112. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6113. return false;
  6114. }
  6115. const {
  6116. result,
  6117. statusText,
  6118. status,
  6119. data
  6120. } = await tools_httpRequest({
  6121. url: `https://store.steampowered.com/app/${ids}`,
  6122. method: 'GET'
  6123. });
  6124. if (result === 'Success') {
  6125. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6126. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6127. logStatus.success();
  6128. return true;
  6129. }
  6130. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6131. return false;
  6132. }
  6133. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6134. return false;
  6135. }
  6136. logStatus.error(`${result}:${statusText}(${status})`);
  6137. return false;
  6138. } else if (type === 'subid') {
  6139. const logStatusArr = {};
  6140. for (const subid of ids.split(',')) {
  6141. const logStatus = scripts_echoLog({
  6142. type: 'addingFreeLicenseSubid',
  6143. text: subid
  6144. });
  6145. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6146. return false;
  6147. }
  6148. logStatusArr[subid] = logStatus;
  6149. }
  6150. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6151. if (!licenses) {
  6152. return false;
  6153. }
  6154. for (const subid of ids.split(',')) {
  6155. if (licenses.includes(subid)) {
  6156. logStatusArr[subid].success();
  6157. } else {
  6158. logStatusArr[subid].error();
  6159. }
  6160. }
  6161. return true;
  6162. }
  6163. return false;
  6164. } catch (error) {
  6165. throwError(error, 'Steam.addLicense');
  6166. return false;
  6167. }
  6168. }
  6169. async function _addFreeLicense2(id, logStatusPre) {
  6170. try {
  6171. const logStatus = logStatusPre || scripts_echoLog({
  6172. type: 'addingFreeLicenseSubid',
  6173. text: id
  6174. });
  6175. const {
  6176. result,
  6177. statusText,
  6178. status,
  6179. data
  6180. } = await tools_httpRequest({
  6181. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6182. method: 'POST',
  6183. headers: {
  6184. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6185. Host: 'store.steampowered.com',
  6186. Origin: 'https://store.steampowered.com',
  6187. Referer: 'https://store.steampowered.com/account/licenses/'
  6188. },
  6189. data: $.param({
  6190. action: 'add_to_cart',
  6191. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6192. subid: id
  6193. }),
  6194. dataType: 'json'
  6195. });
  6196. if (result === 'Success') {
  6197. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6198. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6199. logStatus.warning(i18n('changeAreaNotice'));
  6200. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6201. if (!result || result === 'CN') {
  6202. return false;
  6203. }
  6204. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6205. }
  6206. logStatus.success();
  6207. return true;
  6208. }
  6209. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6210. return false;
  6211. }
  6212. logStatus.error(`${result}:${statusText}(${status})`);
  6213. return false;
  6214. } catch (error) {
  6215. throwError(error, 'Steam.addFreeLicense');
  6216. return false;
  6217. }
  6218. }
  6219. async function _requestPlayTestAccess2(id) {
  6220. try {
  6221. const logStatus = scripts_echoLog({
  6222. type: 'requestingPlayTestAccess',
  6223. text: id
  6224. });
  6225. const {
  6226. result,
  6227. statusText,
  6228. status,
  6229. data
  6230. } = await tools_httpRequest({
  6231. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6232. method: 'POST',
  6233. headers: {
  6234. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6235. Host: 'store.steampowered.com',
  6236. Origin: 'https://store.steampowered.com',
  6237. Referer: `https://store.steampowered.com/app/${id}`
  6238. },
  6239. data: $.param({
  6240. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6241. }),
  6242. dataType: 'json'
  6243. });
  6244. if (result === 'Success') {
  6245. var _data$response8;
  6246. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.success) === 1) {
  6247. logStatus.success();
  6248. return true;
  6249. }
  6250. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6251. return false;
  6252. }
  6253. logStatus.error(`${result}:${statusText}(${status})`);
  6254. return false;
  6255. } catch (error) {
  6256. throwError(error, 'Steam.requestPlayTestAccess');
  6257. return false;
  6258. }
  6259. }
  6260. function Steam_setCache2(type, name, id) {
  6261. try {
  6262. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6263. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6264. } catch (error) {
  6265. throwError(error, 'Steam.setCache');
  6266. }
  6267. }
  6268. const social_Steam = Steam;
  6269. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6270. Website_checkPrivateRedeclaration(obj, privateSet);
  6271. privateSet.add(obj);
  6272. }
  6273. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6274. if (privateCollection.has(obj)) {
  6275. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6276. }
  6277. }
  6278. function Website_defineProperty(obj, key, value) {
  6279. if (key in obj) {
  6280. Object.defineProperty(obj, key, {
  6281. value: value,
  6282. enumerable: true,
  6283. configurable: true,
  6284. writable: true
  6285. });
  6286. } else {
  6287. obj[key] = value;
  6288. }
  6289. return obj;
  6290. }
  6291. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6292. if (!privateSet.has(receiver)) {
  6293. throw new TypeError('attempted to get private field on non-instance');
  6294. }
  6295. return fn;
  6296. }
  6297. var _bind = new WeakSet();
  6298. class Website {
  6299. constructor() {
  6300. Website_classPrivateMethodInitSpec(this, _bind);
  6301. Website_defineProperty(this, 'undoneTasks', void 0);
  6302. Website_defineProperty(this, 'socialTasks', void 0);
  6303. Website_defineProperty(this, 'giveawayId', void 0);
  6304. Website_defineProperty(this, 'socialInitialized', {
  6305. discord: false,
  6306. instagram: false,
  6307. reddit: false,
  6308. twitch: false,
  6309. twitter: false,
  6310. vk: false,
  6311. youtube: false,
  6312. steamStore: false,
  6313. steamCommunity: false
  6314. });
  6315. Website_defineProperty(this, 'initialized', false);
  6316. Website_defineProperty(this, 'social', {});
  6317. }
  6318. async initSocial(action) {
  6319. try {
  6320. const pro = [];
  6321. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6322. if (tasks.discord) {
  6323. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6324. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6325. this.social.discord = new social_Discord();
  6326. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6327. }
  6328. }
  6329. if (tasks.instagram) {
  6330. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6331. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6332. this.social.instagram = new social_Instagram();
  6333. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6334. }
  6335. }
  6336. if (tasks.reddit) {
  6337. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6338. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6339. this.social.reddit = new social_Reddit();
  6340. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6341. }
  6342. }
  6343. if (tasks.twitch) {
  6344. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6345. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6346. this.social.twitch = new social_Twitch();
  6347. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6348. }
  6349. }
  6350. if (tasks.twitter) {
  6351. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6352. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6353. this.social.twitter = new social_Twitter();
  6354. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6355. }
  6356. }
  6357. if (tasks.vk) {
  6358. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6359. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6360. this.social.vk = new social_Vk();
  6361. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6362. }
  6363. }
  6364. if (tasks.youtube) {
  6365. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6366. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6367. this.social.youtube = new Youtube();
  6368. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6369. }
  6370. }
  6371. if (tasks.steam) {
  6372. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6373. if (steamLength > 0) {
  6374. if (!this.social.steam) {
  6375. this.social.steam = new social_Steam();
  6376. }
  6377. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6378. var _tasks$steam, _tasks$steam$type;
  6379. return [ 'groupLinks', '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;
  6380. }).reduce((total, number) => total + number, 0);
  6381. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6382. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6383. }
  6384. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6385. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6386. }
  6387. }
  6388. }
  6389. if (tasks.links && tasks.links.length > 0) {
  6390. this.social.visitLink = visitLink;
  6391. }
  6392. return await Promise.all(pro).then(result => {
  6393. let checked = true;
  6394. for (const data of result) {
  6395. if (data.result) {
  6396. this.socialInitialized[data.name] = data.result;
  6397. } else {
  6398. checked = false;
  6399. }
  6400. }
  6401. return checked;
  6402. });
  6403. } catch (error) {
  6404. throwError(error, 'Website.initSocial');
  6405. return false;
  6406. }
  6407. }
  6408. uniqueTasks(allTasks) {
  6409. const result = {};
  6410. for (const [ social, types ] of Object.entries(allTasks)) {
  6411. result[social] = {};
  6412. for (const [ type, tasks ] of Object.entries(types)) {
  6413. result[social][type] = unique(tasks);
  6414. }
  6415. }
  6416. return result;
  6417. }
  6418. async toggleTask(action) {
  6419. try {
  6420. if (!this.initialized && !this.init()) {
  6421. return false;
  6422. }
  6423. if (!await this.classifyTask(action)) {
  6424. return false;
  6425. }
  6426. if (!await this.initSocial(action)) {
  6427. return false;
  6428. }
  6429. const pro = [];
  6430. const doTask = action === 'do';
  6431. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6432. if (this.social.discord) {
  6433. pro.push(this.social.discord.toggle({
  6434. doTask: doTask,
  6435. ...tasks.discord
  6436. }));
  6437. }
  6438. if (this.social.instagram) {
  6439. pro.push(this.social.instagram.toggle({
  6440. doTask: doTask,
  6441. ...tasks.instagram
  6442. }));
  6443. }
  6444. if (this.social.reddit) {
  6445. pro.push(this.social.reddit.toggle({
  6446. doTask: doTask,
  6447. ...tasks.reddit
  6448. }));
  6449. }
  6450. if (this.social.twitch) {
  6451. pro.push(this.social.twitch.toggle({
  6452. doTask: doTask,
  6453. ...tasks.twitch
  6454. }));
  6455. }
  6456. if (this.social.twitter) {
  6457. pro.push(this.social.twitter.toggle({
  6458. doTask: doTask,
  6459. ...tasks.twitter
  6460. }));
  6461. }
  6462. if (this.social.vk) {
  6463. pro.push(this.social.vk.toggle({
  6464. doTask: doTask,
  6465. ...tasks.vk
  6466. }));
  6467. }
  6468. if (this.social.youtube) {
  6469. pro.push(this.social.youtube.toggle({
  6470. doTask: doTask,
  6471. ...tasks.youtube
  6472. }));
  6473. }
  6474. if (this.social.steam) {
  6475. pro.push(this.social.steam.toggle({
  6476. doTask: doTask,
  6477. ...tasks.steam
  6478. }));
  6479. }
  6480. if (this.social.visitLink && tasks.links && doTask) {
  6481. for (const link of tasks.links) {
  6482. pro.push(this.social.visitLink(link));
  6483. }
  6484. }
  6485. if (doTask && tasks.extra && this.extraDoTask) {
  6486. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6487. if (hasExtra) {
  6488. pro.push(this.extraDoTask(tasks.extra));
  6489. }
  6490. }
  6491. await Promise.all(pro);
  6492. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6493. return true;
  6494. } catch (error) {
  6495. throwError(error, 'Website.toggleTask');
  6496. return false;
  6497. }
  6498. }
  6499. async doTask() {
  6500. try {
  6501. return await this.toggleTask('do');
  6502. } catch (error) {
  6503. throwError(error, 'Website.doTask');
  6504. return false;
  6505. }
  6506. }
  6507. async undoTask() {
  6508. try {
  6509. return await this.toggleTask('undo');
  6510. } catch (error) {
  6511. throwError(error, 'Website.undoTask');
  6512. return false;
  6513. }
  6514. }
  6515. }
  6516. async function _bind2(name, init) {
  6517. try {
  6518. return {
  6519. name: name,
  6520. result: await init
  6521. };
  6522. } catch (error) {
  6523. throwError(error, 'Website.bind');
  6524. return {
  6525. name: name,
  6526. result: false
  6527. };
  6528. }
  6529. }
  6530. const website_Website = Website;
  6531. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6532. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6533. privateSet.add(obj);
  6534. }
  6535. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6536. if (privateCollection.has(obj)) {
  6537. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6538. }
  6539. }
  6540. function FreeAnyWhere_defineProperty(obj, key, value) {
  6541. if (key in obj) {
  6542. Object.defineProperty(obj, key, {
  6543. value: value,
  6544. enumerable: true,
  6545. configurable: true,
  6546. writable: true
  6547. });
  6548. } else {
  6549. obj[key] = value;
  6550. }
  6551. return obj;
  6552. }
  6553. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6554. if (!privateSet.has(receiver)) {
  6555. throw new TypeError('attempted to get private field on non-instance');
  6556. }
  6557. return fn;
  6558. }
  6559. const FreeAnyWhere_defaultTasksTemplate = {
  6560. steam: {
  6561. groupLinks: [],
  6562. wishlistLinks: [],
  6563. curatorLinks: [],
  6564. followLinks: []
  6565. },
  6566. vk: {
  6567. nameLinks: []
  6568. }
  6569. };
  6570. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6571. var _getGiveawayId = new WeakSet();
  6572. var _verify = new WeakSet();
  6573. class FreeAnyWhere extends website_Website {
  6574. constructor() {
  6575. super(...arguments);
  6576. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6577. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6578. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6579. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6580. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6581. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6582. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6583. }
  6584. static test() {
  6585. return window.location.host === 'freeanywhere.net';
  6586. }
  6587. init() {
  6588. try {
  6589. const logStatus = scripts_echoLog({
  6590. text: i18n('initing')
  6591. });
  6592. if ($('a[href="#/login"]').length > 0) {
  6593. window.open('/#/login', '_self');
  6594. logStatus.warning(i18n('needLogin'));
  6595. return false;
  6596. }
  6597. if (window.location.href.includes('/login')) {
  6598. logStatus.warning(i18n('needLogin'));
  6599. return false;
  6600. }
  6601. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6602. var _window$location$href;
  6603. 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];
  6604. if (!id) {
  6605. logStatus.error(i18n('getFailed', 'Id'));
  6606. return false;
  6607. }
  6608. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6609. }
  6610. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6611. return false;
  6612. }
  6613. this.initialized = true;
  6614. logStatus.success();
  6615. return true;
  6616. } catch (error) {
  6617. throwError(error, 'Freeanywhere.init');
  6618. return false;
  6619. }
  6620. }
  6621. async classifyTask(action) {
  6622. try {
  6623. const logStatus = scripts_echoLog({
  6624. text: i18n('getTasksInfo')
  6625. });
  6626. if (action === 'undo') {
  6627. var _GM_getValue;
  6628. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6629. }
  6630. const {
  6631. result,
  6632. statusText,
  6633. status,
  6634. data
  6635. } = await tools_httpRequest({
  6636. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6637. method: 'GET',
  6638. headers: {
  6639. authorization: `Token ${window.localStorage.getItem('token')}`,
  6640. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6641. },
  6642. responseType: 'json'
  6643. });
  6644. if (result === 'Success') {
  6645. var _data$response;
  6646. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6647. if (tasks) {
  6648. if (action === 'verify') {
  6649. this.tasks = [];
  6650. }
  6651. for (const task of tasks) {
  6652. const type = task.challenge;
  6653. const social = task.challenge_provider;
  6654. const taskInfo = {
  6655. id: task.id,
  6656. title: task.title
  6657. };
  6658. if (action === 'verify' && !task.is_success) {
  6659. this.tasks.push(taskInfo);
  6660. continue;
  6661. }
  6662. switch (social) {
  6663. case 'steam':
  6664. taskInfo.social = 'steam';
  6665. switch (type) {
  6666. case 'WL':
  6667. if (action === 'undo') {
  6668. this.socialTasks.steam.wishlistLinks.push(task.link);
  6669. }
  6670. if (action === 'do' && !task.is_success) {
  6671. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6672. }
  6673. break;
  6674.  
  6675. case 'JTG':
  6676. if (action === 'undo') {
  6677. this.socialTasks.steam.groupLinks.push(task.link);
  6678. }
  6679. if (action === 'do' && !task.is_success) {
  6680. this.undoneTasks.steam.groupLinks.push(task.link);
  6681. }
  6682. break;
  6683.  
  6684. case 'STC':
  6685. if (action === 'undo') {
  6686. this.socialTasks.steam.curatorLinks.push(task.link);
  6687. }
  6688. if (action === 'do' && !task.is_success) {
  6689. this.undoneTasks.steam.curatorLinks.push(task.link);
  6690. }
  6691. break;
  6692.  
  6693. case 'GF':
  6694. if (action === 'undo') {
  6695. this.socialTasks.steam.followLinks.push(task.link);
  6696. }
  6697. if (action === 'do' && !task.is_success) {
  6698. this.undoneTasks.steam.followLinks.push(task.link);
  6699. }
  6700. break;
  6701. }
  6702. break;
  6703.  
  6704. case 'vk-oauth2':
  6705. if (action === 'undo') {
  6706. this.socialTasks.vk.nameLinks.push(task.link);
  6707. }
  6708. if (action === 'do' && !task.is_success) {
  6709. this.undoneTasks.vk.nameLinks.push(task.link);
  6710. }
  6711. break;
  6712.  
  6713. case 'website':
  6714. break;
  6715.  
  6716. default:
  6717. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6718. break;
  6719. }
  6720. }
  6721. logStatus.success();
  6722. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6723. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6724. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6725. tasks: this.socialTasks,
  6726. time: new Date().getTime()
  6727. });
  6728. return true;
  6729. }
  6730. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6731. console.error(data);
  6732. return false;
  6733. }
  6734. logStatus.error(`${result}:${statusText}(${status})`);
  6735. return false;
  6736. } catch (error) {
  6737. throwError(error, 'Freeanywhere.classifyTask');
  6738. return false;
  6739. }
  6740. }
  6741. async verifyTask() {
  6742. try {
  6743. if (!this.initialized && !this.init()) {
  6744. return false;
  6745. }
  6746. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6747. return false;
  6748. }
  6749. const pro = [];
  6750. for (const task of this.tasks) {
  6751. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6752. await delay(1e3);
  6753. }
  6754. await Promise.all(pro);
  6755. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6756. return !!await this.getKey(true);
  6757. } catch (error) {
  6758. throwError(error, 'Freeanywhere.verifyTask');
  6759. return false;
  6760. }
  6761. }
  6762. async getKey(initialized) {
  6763. try {
  6764. if (!initialized && !this.initialized && !this.init()) {
  6765. return false;
  6766. }
  6767. const logStatus = scripts_echoLog({
  6768. text: i18n('gettingKey')
  6769. });
  6770. const {
  6771. result,
  6772. statusText,
  6773. status,
  6774. data
  6775. } = await tools_httpRequest({
  6776. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6777. method: 'GET',
  6778. dataType: 'json',
  6779. headers: {
  6780. authorization: `Token ${window.localStorage.getItem('token')}`
  6781. }
  6782. });
  6783. if (result === 'Success') {
  6784. var _data$response2;
  6785. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6786. logStatus.success();
  6787. scripts_echoLog({}).success(data.response.reward);
  6788. return data.response.reward;
  6789. }
  6790. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6791. return false;
  6792. }
  6793. logStatus.error(`${result}:${statusText}(${status})`);
  6794. return false;
  6795. } catch (error) {
  6796. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6797. return false;
  6798. }
  6799. }
  6800. }
  6801. function _getGiveawayId2() {
  6802. try {
  6803. var _window$location$href2;
  6804. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6805. if (giveawayId) {
  6806. this.giveawayId = giveawayId;
  6807. return true;
  6808. }
  6809. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6810. return false;
  6811. } catch (error) {
  6812. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6813. }
  6814. }
  6815. async function _verify2(task) {
  6816. try {
  6817. const logStatus = scripts_echoLog({
  6818. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6819. });
  6820. const {
  6821. result,
  6822. statusText,
  6823. status,
  6824. data
  6825. } = await tools_httpRequest({
  6826. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6827. method: 'GET',
  6828. dataType: 'json',
  6829. headers: {
  6830. authorization: `Token ${window.localStorage.getItem('token')}`,
  6831. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6832. }
  6833. });
  6834. if (result === 'Success') {
  6835. var _data$response3;
  6836. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6837. logStatus.success();
  6838. return true;
  6839. }
  6840. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6841. return false;
  6842. }
  6843. logStatus.error(`${result}:${statusText}(${status})`);
  6844. return false;
  6845. } catch (error) {
  6846. throwError(error, 'Freeanywhere.verify');
  6847. return false;
  6848. }
  6849. }
  6850. const website_FreeAnyWhere = FreeAnyWhere;
  6851. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6852. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6853. privateSet.add(obj);
  6854. }
  6855. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6856. if (privateCollection.has(obj)) {
  6857. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6858. }
  6859. }
  6860. function GiveawaySu_defineProperty(obj, key, value) {
  6861. if (key in obj) {
  6862. Object.defineProperty(obj, key, {
  6863. value: value,
  6864. enumerable: true,
  6865. configurable: true,
  6866. writable: true
  6867. });
  6868. } else {
  6869. obj[key] = value;
  6870. }
  6871. return obj;
  6872. }
  6873. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6874. if (!privateSet.has(receiver)) {
  6875. throw new TypeError('attempted to get private field on non-instance');
  6876. }
  6877. return fn;
  6878. }
  6879. const GiveawaySu_defaultTasks = {
  6880. steam: {
  6881. groupLinks: [],
  6882. wishlistLinks: [],
  6883. curatorLinks: [],
  6884. curatorLikeLinks: [],
  6885. followLinks: [],
  6886. forumLinks: [],
  6887. announcementLinks: [],
  6888. workshopVoteLinks: [],
  6889. playtestLinks: []
  6890. },
  6891. discord: {
  6892. serverLinks: []
  6893. },
  6894. instagram: {
  6895. userLinks: []
  6896. },
  6897. vk: {
  6898. nameLinks: []
  6899. },
  6900. twitch: {
  6901. channelLinks: []
  6902. },
  6903. reddit: {
  6904. redditLinks: []
  6905. },
  6906. youtube: {
  6907. channelLinks: [],
  6908. likeLinks: []
  6909. }
  6910. };
  6911. var _checkLogin = new WeakSet();
  6912. var _checkLeftKey = new WeakSet();
  6913. var GiveawaySu_getGiveawayId = new WeakSet();
  6914. class GiveawaySu extends website_Website {
  6915. constructor() {
  6916. super(...arguments);
  6917. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6918. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6919. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6920. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6921. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6922. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6923. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6924. }
  6925. static test() {
  6926. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6927. }
  6928. async after() {
  6929. try {
  6930. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6931. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6932. }
  6933. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6934. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6935. }
  6936. scripts_echoLog({}).warning(i18n('gsNotice'));
  6937. } catch (error) {
  6938. throwError(error, 'Giveawaysu.after');
  6939. }
  6940. }
  6941. init() {
  6942. try {
  6943. const logStatus = scripts_echoLog({
  6944. text: i18n('initing')
  6945. });
  6946. if ($('a.steam-login').length > 0) {
  6947. window.open('/steam/redirect', '_self');
  6948. logStatus.warning(i18n('needLogin'));
  6949. return false;
  6950. }
  6951. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6952. return false;
  6953. }
  6954. this.initialized = true;
  6955. logStatus.success();
  6956. return true;
  6957. } catch (error) {
  6958. throwError(error, 'Giveawaysu.init');
  6959. return false;
  6960. }
  6961. }
  6962. async classifyTask(action) {
  6963. try {
  6964. const logStatus = scripts_echoLog({
  6965. text: i18n('getTasksInfo')
  6966. });
  6967. if (action === 'undo') {
  6968. var _GM_getValue;
  6969. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6970. return true;
  6971. }
  6972. const pro = [];
  6973. const tasks = $('#actions tr');
  6974. if ($('div.bind-discord').is(':visible')) {
  6975. $('div.bind-discord a')[0].click();
  6976. }
  6977. if ($('div.bind-twitch').is(':visible')) {
  6978. $('div.bind-twitch a')[0].click();
  6979. }
  6980. for (const task of tasks) {
  6981. pro.push(new Promise(resolve => {
  6982. const td = $(task).find('td:not(".hidden")');
  6983. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6984. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6985. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6986. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6987. const taskName = taskDes.text().trim();
  6988. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6989. return resolve(true);
  6990. }
  6991. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6992. if (!taskLink) {
  6993. return resolve(false);
  6994. }
  6995. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6996. this.undoneTasks.steam.groupLinks.push(taskLink);
  6997. } else if (/like.*announcement/gi.test(taskName)) {
  6998. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6999. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7000. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7001. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7002. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7003. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7004. this.undoneTasks.steam.forumLinks.push(taskLink);
  7005. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7006. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7007. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7008. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7009. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7010. this.undoneTasks.discord.serverLinks.push(taskLink);
  7011. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7012. this.undoneTasks.instagram.userLinks.push(taskLink);
  7013. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7014. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7015. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7016. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7017. } else if (/watch.*art/gim.test(taskName)) {
  7018. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7019. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7020. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7021. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7022. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7023. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7024. this.undoneTasks.vk.nameLinks.push(taskLink);
  7025. } else {
  7026. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7027. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7028. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7029. }
  7030. if (/follow.*button/gim.test(taskName)) {
  7031. this.undoneTasks.steam.followLinks.push(taskLink);
  7032. }
  7033. }
  7034. }
  7035. resolve(true);
  7036. }).catch(error => {
  7037. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7038. return false;
  7039. });
  7040. }));
  7041. }
  7042. await Promise.all(pro);
  7043. logStatus.success();
  7044. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7045. this.socialTasks = this.undoneTasks;
  7046. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7047. tasks: this.socialTasks,
  7048. time: new Date().getTime()
  7049. });
  7050. return true;
  7051. } catch (error) {
  7052. throwError(error, 'Giveawaysu.classifyTask');
  7053. return false;
  7054. }
  7055. }
  7056. }
  7057. function _checkLogin2() {
  7058. try {
  7059. if (!globalOptions.other.checkLogin) {
  7060. return true;
  7061. }
  7062. if ($('a.steam-login').length > 0) {
  7063. window.open('/steam/redirect', '_self');
  7064. }
  7065. return true;
  7066. } catch (error) {
  7067. throwError(error, 'Giveawaysu.checkLogin');
  7068. return false;
  7069. }
  7070. }
  7071. async function _checkLeftKey2() {
  7072. try {
  7073. if (!globalOptions.other.checkLeftKey) {
  7074. return true;
  7075. }
  7076. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7077. await external_Swal_default().fire({
  7078. icon: 'warning',
  7079. title: i18n('notice'),
  7080. text: i18n('noKeysLeft'),
  7081. confirmButtonText: i18n('confirm'),
  7082. cancelButtonText: i18n('cancel'),
  7083. showCancelButton: true
  7084. }).then(_ref => {
  7085. let {
  7086. value
  7087. } = _ref;
  7088. if (value) {
  7089. window.close();
  7090. }
  7091. });
  7092. }
  7093. return true;
  7094. } catch (error) {
  7095. throwError(error, 'Giveawaysu.checkLeftKey');
  7096. return false;
  7097. }
  7098. }
  7099. function GiveawaySu_getGiveawayId2() {
  7100. var _window$location$href;
  7101. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7102. if (giveawayId) {
  7103. this.giveawayId = giveawayId;
  7104. return true;
  7105. }
  7106. scripts_echoLog({
  7107. text: i18n('getFailed', 'GiveawayId')
  7108. });
  7109. return false;
  7110. }
  7111. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7112. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7113. privateSet.add(obj);
  7114. }
  7115. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7116. if (privateCollection.has(obj)) {
  7117. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7118. }
  7119. }
  7120. function Indiedb_defineProperty(obj, key, value) {
  7121. if (key in obj) {
  7122. Object.defineProperty(obj, key, {
  7123. value: value,
  7124. enumerable: true,
  7125. configurable: true,
  7126. writable: true
  7127. });
  7128. } else {
  7129. obj[key] = value;
  7130. }
  7131. return obj;
  7132. }
  7133. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7134. if (!privateSet.has(receiver)) {
  7135. throw new TypeError('attempted to get private field on non-instance');
  7136. }
  7137. return fn;
  7138. }
  7139. var _join = new WeakSet();
  7140. var _do = new WeakSet();
  7141. var Indiedb_checkLogin = new WeakSet();
  7142. var Indiedb_checkLeftKey = new WeakSet();
  7143. class Indiedb {
  7144. constructor() {
  7145. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7146. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7147. Indiedb_classPrivateMethodInitSpec(this, _do);
  7148. Indiedb_classPrivateMethodInitSpec(this, _join);
  7149. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7150. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7151. }
  7152. static test() {
  7153. return window.location.host === 'www.indiedb.com';
  7154. }
  7155. async after() {
  7156. try {
  7157. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7158. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7159. }
  7160. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7161. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7162. }
  7163. } catch (error) {
  7164. throwError(error, 'Indiedb.after');
  7165. }
  7166. }
  7167. async doTask() {
  7168. try {
  7169. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7170. return false;
  7171. }
  7172. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7173. } catch (error) {
  7174. throwError(error, 'Indiedb.doTask');
  7175. return false;
  7176. }
  7177. }
  7178. }
  7179. async function _join2() {
  7180. try {
  7181. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7182. scripts_echoLog({}).error(i18n('needLogin'));
  7183. return false;
  7184. }
  7185. const currentoption = $('a.buttonenter.buttongiveaway');
  7186. if (/join giveaway/gim.test(currentoption.text())) {
  7187. const logStatus = scripts_echoLog({
  7188. text: `${i18n('joiningGiveaway')}...`
  7189. });
  7190. const {
  7191. result,
  7192. statusText,
  7193. status,
  7194. data
  7195. } = await tools_httpRequest({
  7196. url: currentoption.attr('href'),
  7197. method: 'POST',
  7198. data: 'ajax=t',
  7199. dataType: 'json',
  7200. headers: {
  7201. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7202. accept: 'application/json, text/javascript, */*; q=0.01',
  7203. origin: window.location.origin
  7204. }
  7205. });
  7206. if (result === 'Success') {
  7207. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7208. var _data$response, _data$response4, _data$response5;
  7209. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7210. var _data$response2, _data$response3;
  7211. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7212. $('#giveawaysjoined').slideDown();
  7213. $('#giveawaysrecommend').slideDown();
  7214. 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}` : ''}`);
  7215. return true;
  7216. }
  7217. 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}` : ''}`);
  7218. return false;
  7219. }
  7220. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7221. return false;
  7222. }
  7223. logStatus.error(`${result}:${statusText}(${status})`);
  7224. return false;
  7225. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7226. return true;
  7227. }
  7228. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7229. return false;
  7230. } catch (error) {
  7231. throwError(error, 'Indiedb.init');
  7232. return false;
  7233. }
  7234. }
  7235. async function _do2() {
  7236. try {
  7237. const id = $('script').map((index, script) => {
  7238. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7239. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7240. 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] ];
  7241. }
  7242. return null;
  7243. });
  7244. if (id.length === 2) {
  7245. const pro = [];
  7246. const tasks = $('#giveawaysjoined a[class*=promo]');
  7247. for (const task of tasks) {
  7248. const promo = $(task);
  7249. if (!promo.hasClass('buttonentered')) {
  7250. const status = scripts_echoLog({
  7251. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7252. });
  7253. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7254. let text = '';
  7255. if (promo.hasClass('facebookpromo')) {
  7256. text = 'facebookpromo';
  7257. } else if (promo.hasClass('twitterpromo')) {
  7258. text = 'twitterpromo';
  7259. } else {
  7260. text = 'visitpromo';
  7261. }
  7262. pro.push(new Promise(resolve => {
  7263. $.ajax({
  7264. type: 'POST',
  7265. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7266. timeout: 6e4,
  7267. dataType: 'json',
  7268. data: {
  7269. ajax: 't'
  7270. },
  7271. error(response, error, exception) {
  7272. console.log({
  7273. response: response,
  7274. error: error,
  7275. exception: exception
  7276. });
  7277. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7278. resolve(true);
  7279. },
  7280. success(response) {
  7281. console.log(response);
  7282. if (response.success) {
  7283. status.success(`Success:${response.text}`);
  7284. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7285. resolve(true);
  7286. } else {
  7287. status.error(`Error:${response.text}`);
  7288. resolve(true);
  7289. }
  7290. }
  7291. });
  7292. }));
  7293. } else if (promo.hasClass('emailoptinpromo')) {
  7294. pro.push(new Promise(resolve => {
  7295. $.ajax({
  7296. type: 'POST',
  7297. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7298. timeout: 6e4,
  7299. dataType: 'json',
  7300. data: {
  7301. ajax: 't',
  7302. emailsystoggle: 4
  7303. },
  7304. error(response, error, exception) {
  7305. console.log({
  7306. response: response,
  7307. error: error,
  7308. exception: exception
  7309. });
  7310. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7311. resolve(true);
  7312. },
  7313. success(response) {
  7314. console.log(response);
  7315. if (response.success) {
  7316. status.success(`Success:${response.text}`);
  7317. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7318. resolve(true);
  7319. } else {
  7320. status.error(`Error:${response.text}`);
  7321. resolve(true);
  7322. }
  7323. }
  7324. });
  7325. }));
  7326. } else if (promo.hasClass('watchingpromo')) {
  7327. pro.push(new Promise(resolve => {
  7328. var _promo$attr;
  7329. const data = getUrlQuery(promo.attr('href'));
  7330. data.ajax = 't';
  7331. $.ajax({
  7332. type: 'POST',
  7333. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7334. timeout: 6e4,
  7335. dataType: 'json',
  7336. data: data,
  7337. error(response, error, exception) {
  7338. console.log({
  7339. response: response,
  7340. error: error,
  7341. exception: exception
  7342. });
  7343. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7344. resolve(true);
  7345. },
  7346. success(response) {
  7347. console.log(response);
  7348. if (response.success) {
  7349. status.success(`Success:${response.text}`);
  7350. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7351. resolve(true);
  7352. } else {
  7353. status.error(`Error:${response.text}`);
  7354. resolve(true);
  7355. }
  7356. }
  7357. });
  7358. }));
  7359. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7360. pro.push(new Promise(resolve => {
  7361. $.ajax({
  7362. type: 'POST',
  7363. url: urlPath(promo.attr('href')),
  7364. timeout: 6e4,
  7365. dataType: 'json',
  7366. data: {
  7367. ajax: 't'
  7368. },
  7369. error(response, error, exception) {
  7370. console.log({
  7371. response: response,
  7372. error: error,
  7373. exception: exception
  7374. });
  7375. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7376. resolve(true);
  7377. },
  7378. success(response) {
  7379. console.log(response);
  7380. if (response.success) {
  7381. status.success(`Success:${response.text}`);
  7382. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7383. resolve(true);
  7384. } else {
  7385. status.error(`Error:${response.text}`);
  7386. resolve(true);
  7387. }
  7388. }
  7389. });
  7390. }));
  7391. } else {
  7392. status.error(`Error:${i18n('unKnownTaskType')}`);
  7393. }
  7394. }
  7395. }
  7396. await Promise.all(pro);
  7397. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7398. return true;
  7399. }
  7400. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7401. return false;
  7402. } catch (error) {
  7403. throwError(error, 'Indiedb.classifyTask');
  7404. return false;
  7405. }
  7406. }
  7407. function Indiedb_checkLogin2() {
  7408. try {
  7409. if (!globalOptions.other.checkLogin) {
  7410. return true;
  7411. }
  7412. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7413. window.open('/members/login', '_self');
  7414. }
  7415. return true;
  7416. } catch (error) {
  7417. throwError(error, 'Indiedb.checkLogin');
  7418. return false;
  7419. }
  7420. }
  7421. async function Indiedb_checkLeftKey2() {
  7422. try {
  7423. if (!globalOptions.other.checkLeftKey) {
  7424. return true;
  7425. }
  7426. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7427. await external_Swal_default().fire({
  7428. icon: 'warning',
  7429. title: i18n('notice'),
  7430. text: i18n('giveawayEnded'),
  7431. confirmButtonText: i18n('confirm'),
  7432. cancelButtonText: i18n('cancel'),
  7433. showCancelButton: true
  7434. }).then(_ref => {
  7435. let {
  7436. value
  7437. } = _ref;
  7438. if (value) {
  7439. window.close();
  7440. }
  7441. });
  7442. }
  7443. return true;
  7444. } catch (error) {
  7445. throwError(error, 'Indiedb.checkLeftKey');
  7446. return false;
  7447. }
  7448. }
  7449. const website_Indiedb = Indiedb;
  7450. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7451. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7452. privateSet.add(obj);
  7453. }
  7454. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7455. if (privateCollection.has(obj)) {
  7456. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7457. }
  7458. }
  7459. function Keyhub_defineProperty(obj, key, value) {
  7460. if (key in obj) {
  7461. Object.defineProperty(obj, key, {
  7462. value: value,
  7463. enumerable: true,
  7464. configurable: true,
  7465. writable: true
  7466. });
  7467. } else {
  7468. obj[key] = value;
  7469. }
  7470. return obj;
  7471. }
  7472. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7473. if (!privateSet.has(receiver)) {
  7474. throw new TypeError('attempted to get private field on non-instance');
  7475. }
  7476. return fn;
  7477. }
  7478. const Keyhub_defaultTasksTemplate = {
  7479. steam: {
  7480. groupLinks: [],
  7481. wishlistLinks: [],
  7482. curatorLinks: []
  7483. },
  7484. discord: {
  7485. serverLinks: []
  7486. },
  7487. links: []
  7488. };
  7489. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7490. var Keyhub_getGiveawayId = new WeakSet();
  7491. var Keyhub_checkLeftKey = new WeakSet();
  7492. var Keyhub_checkLogin = new WeakSet();
  7493. class Keyhub extends website_Website {
  7494. constructor() {
  7495. super(...arguments);
  7496. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7497. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7498. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7499. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7500. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7501. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7502. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7503. }
  7504. static test() {
  7505. return window.location.host === 'key-hub.eu';
  7506. }
  7507. async after() {
  7508. try {
  7509. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7510. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7511. }
  7512. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7513. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7514. }
  7515. } catch (error) {
  7516. throwError(error, 'Keyhub.after');
  7517. }
  7518. }
  7519. init() {
  7520. try {
  7521. const logStatus = scripts_echoLog({
  7522. text: i18n('initing')
  7523. });
  7524. if ($('a[href*="/connect/steam"]').length > 0) {
  7525. window.open('/connect/steam', '_self');
  7526. logStatus.warning(i18n('needLogin'));
  7527. return false;
  7528. }
  7529. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7530. return false;
  7531. }
  7532. $('#VPNoverlay').hide();
  7533. $('#mainArticleSection').show();
  7534. this.initialized = true;
  7535. logStatus.success();
  7536. return true;
  7537. } catch (error) {
  7538. throwError(error, 'Keyhub.init');
  7539. return false;
  7540. }
  7541. }
  7542. async classifyTask(action) {
  7543. try {
  7544. const logStatus = scripts_echoLog({
  7545. text: i18n('getTasksInfo')
  7546. });
  7547. if (action === 'undo') {
  7548. var _GM_getValue;
  7549. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7550. }
  7551. const tasks = $('.task a');
  7552. for (const task of tasks) {
  7553. let link = $(task).attr('href');
  7554. const taskDes = $(task).text().trim();
  7555. if (!link) {
  7556. continue;
  7557. }
  7558. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7559. link = await getRedirectLink(link) || link;
  7560. }
  7561. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7562. window.open(link, '_blank');
  7563. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7564. if (action === 'undo') {
  7565. this.socialTasks.steam.groupLinks.push(link);
  7566. }
  7567. if (action === 'do') {
  7568. this.undoneTasks.steam.groupLinks.push(link);
  7569. }
  7570. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7571. if (action === 'undo') {
  7572. this.socialTasks.steam.wishlistLinks.push(link);
  7573. }
  7574. if (action === 'do') {
  7575. this.undoneTasks.steam.wishlistLinks.push(link);
  7576. }
  7577. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7578. if (action === 'undo') {
  7579. this.socialTasks.steam.curatorLinks.push(link);
  7580. }
  7581. if (action === 'do') {
  7582. this.undoneTasks.steam.curatorLinks.push(link);
  7583. }
  7584. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7585. if (action === 'undo') {
  7586. this.socialTasks.discord.serverLinks.push(link);
  7587. }
  7588. if (action === 'do') {
  7589. this.undoneTasks.discord.serverLinks.push(link);
  7590. }
  7591. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link)) {} else {
  7592. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7593. }
  7594. }
  7595. logStatus.success();
  7596. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7597. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7598. GM_setValue(`khTasks-${this.giveawayId}`, {
  7599. tasks: this.socialTasks,
  7600. time: new Date().getTime()
  7601. });
  7602. return true;
  7603. } catch (error) {
  7604. throwError(error, 'Keyhub.classifyTask');
  7605. return false;
  7606. }
  7607. }
  7608. verifyTask() {
  7609. try {
  7610. scripts_echoLog({
  7611. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7612. });
  7613. $.get(window.location.href, res => {
  7614. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7615. });
  7616. } catch (error) {
  7617. throwError(error, 'keyhub.verifyTask');
  7618. }
  7619. }
  7620. }
  7621. function Keyhub_getGiveawayId2() {
  7622. try {
  7623. var _window$location$href;
  7624. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7625. if (giveawayId) {
  7626. this.giveawayId = giveawayId;
  7627. return true;
  7628. }
  7629. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7630. return false;
  7631. } catch (error) {
  7632. throwError(error, 'Keyhub.getGiveawayId');
  7633. return false;
  7634. }
  7635. }
  7636. async function Keyhub_checkLeftKey2() {
  7637. try {
  7638. if (!globalOptions.other.checkLeftKey) {
  7639. return true;
  7640. }
  7641. const leftKey = $('#keysleft').text().trim();
  7642. if (leftKey === '0') {
  7643. await external_Swal_default().fire({
  7644. icon: 'warning',
  7645. title: i18n('notice'),
  7646. text: i18n('noKeysLeft'),
  7647. confirmButtonText: i18n('confirm'),
  7648. cancelButtonText: i18n('cancel'),
  7649. showCancelButton: true
  7650. }).then(_ref => {
  7651. let {
  7652. value
  7653. } = _ref;
  7654. if (value) {
  7655. window.close();
  7656. }
  7657. });
  7658. }
  7659. return true;
  7660. } catch (error) {
  7661. throwError(error, 'Keyhub.checkLeftKey');
  7662. return false;
  7663. }
  7664. }
  7665. function Keyhub_checkLogin2() {
  7666. try {
  7667. if (!globalOptions.other.checkLogin) {
  7668. return true;
  7669. }
  7670. if ($('a[href*="/connect/steam"]').length > 0) {
  7671. window.open('/connect/steam', '_self');
  7672. }
  7673. return true;
  7674. } catch (error) {
  7675. throwError(error, 'Keyhub.checkLogin');
  7676. return false;
  7677. }
  7678. }
  7679. const website_Keyhub = Keyhub;
  7680. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7681. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7682. privateSet.add(obj);
  7683. }
  7684. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7685. if (privateCollection.has(obj)) {
  7686. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7687. }
  7688. }
  7689. function Givekey_defineProperty(obj, key, value) {
  7690. if (key in obj) {
  7691. Object.defineProperty(obj, key, {
  7692. value: value,
  7693. enumerable: true,
  7694. configurable: true,
  7695. writable: true
  7696. });
  7697. } else {
  7698. obj[key] = value;
  7699. }
  7700. return obj;
  7701. }
  7702. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7703. if (!privateSet.has(receiver)) {
  7704. throw new TypeError('attempted to get private field on non-instance');
  7705. }
  7706. return fn;
  7707. }
  7708. const Givekey_defaultTasksTemplate = {
  7709. steam: {
  7710. groupLinks: [],
  7711. wishlistLinks: [],
  7712. curatorLinks: [],
  7713. curatorLikeLinks: []
  7714. },
  7715. twitter: {
  7716. userLinks: []
  7717. },
  7718. vk: {
  7719. nameLinks: []
  7720. },
  7721. discord: {
  7722. serverLinks: []
  7723. }
  7724. };
  7725. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  7726. var Givekey_verify = new WeakSet();
  7727. var Givekey_getGiveawayId = new WeakSet();
  7728. var Givekey_checkLeftKey = new WeakSet();
  7729. class Givekey extends website_Website {
  7730. constructor() {
  7731. super(...arguments);
  7732. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7733. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7734. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7735. Givekey_defineProperty(this, 'name', 'Givekey');
  7736. Givekey_defineProperty(this, 'tasks', []);
  7737. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  7738. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  7739. Givekey_defineProperty(this, 'userId', void 0);
  7740. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7741. }
  7742. static test() {
  7743. return window.location.host === 'givekey.ru';
  7744. }
  7745. async after() {
  7746. try {
  7747. await new Promise(resolve => {
  7748. const checker = setInterval(() => {
  7749. if ($('#navbarDropdown').length > 0) {
  7750. clearInterval(checker);
  7751. resolve(true);
  7752. }
  7753. });
  7754. });
  7755. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7756. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7757. }
  7758. } catch (error) {
  7759. throwError(error, 'Givekey.after');
  7760. return false;
  7761. }
  7762. }
  7763. init() {
  7764. try {
  7765. const logStatus = scripts_echoLog({
  7766. text: i18n('initing')
  7767. });
  7768. if ($('a[href*="/auth/steam"]').length > 0) {
  7769. window.open('/auth/steam', '_self');
  7770. logStatus.warning(i18n('needLogin'));
  7771. return false;
  7772. }
  7773. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7774. return false;
  7775. }
  7776. const userId = $('meta[name="user-id"]').attr('content');
  7777. if (!userId) {
  7778. logStatus.error(i18n('getFailed', i18n('userId')));
  7779. return false;
  7780. }
  7781. this.userId = userId;
  7782. this.initialized = true;
  7783. logStatus.success();
  7784. return true;
  7785. } catch (error) {
  7786. throwError(error, 'Givekey.init');
  7787. return false;
  7788. }
  7789. }
  7790. async classifyTask(action) {
  7791. try {
  7792. const logStatus = scripts_echoLog({
  7793. text: i18n('getTasksInfo')
  7794. });
  7795. if (action === 'undo') {
  7796. var _GM_getValue;
  7797. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  7798. }
  7799. const tasks = $('.card-body:has("button") .row');
  7800. for (const task of tasks) {
  7801. const taskEle = $(task);
  7802. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7803. if (isSuccess && action !== 'undo') {
  7804. continue;
  7805. }
  7806. const checkButton = taskEle.find('#task_check');
  7807. const taskId = checkButton.attr('data-id');
  7808. if (taskId) {
  7809. this.tasks.push(taskId);
  7810. }
  7811. if (action === 'verify') {
  7812. continue;
  7813. }
  7814. let href = taskEle.find('a').attr('href') || null;
  7815. const text = taskEle.find('a').text().trim();
  7816. const icon = taskEle.find('i');
  7817. if (!href || !text) {
  7818. continue;
  7819. }
  7820. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7821. href = await getRedirectLink(href);
  7822. }
  7823. if (!href) {
  7824. continue;
  7825. }
  7826. if (/^https?:\/\/vk\.com\//.test(href)) {
  7827. this.socialTasks.vk.nameLinks.push(href);
  7828. if (action === 'do' && !isSuccess) {
  7829. this.undoneTasks.vk.nameLinks.push(href);
  7830. }
  7831. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7832. this.socialTasks.steam.groupLinks.push(href);
  7833. if (action === 'do' && !isSuccess) {
  7834. this.undoneTasks.steam.groupLinks.push(href);
  7835. }
  7836. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7837. this.socialTasks.steam.wishlistLinks.push(href);
  7838. if (action === 'do' && !isSuccess) {
  7839. this.undoneTasks.steam.wishlistLinks.push(href);
  7840. }
  7841. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7842. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7843. this.socialTasks.steam.curatorLinks.push(href);
  7844. if (action === 'do' && !isSuccess) {
  7845. this.undoneTasks.steam.curatorLinks.push(href);
  7846. }
  7847. } else {
  7848. this.socialTasks.steam.curatorLikeLinks.push(href);
  7849. if (action === 'do' && !isSuccess) {
  7850. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7851. }
  7852. }
  7853. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7854. this.socialTasks.twitter.userLinks.push(href);
  7855. if (action === 'do' && !isSuccess) {
  7856. this.undoneTasks.twitter.userLinks.push(href);
  7857. }
  7858. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  7859. this.socialTasks.discord.serverLinks.push(href);
  7860. if (action === 'do' && !isSuccess) {
  7861. this.undoneTasks.discord.serverLinks.push(href);
  7862. }
  7863. } else {
  7864. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7865. }
  7866. }
  7867. logStatus.success();
  7868. this.tasks = unique(this.tasks);
  7869. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7870. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7871. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7872. tasks: this.socialTasks,
  7873. time: new Date().getTime()
  7874. });
  7875. return true;
  7876. } catch (error) {
  7877. throwError(error, 'Givekey.classifyTask');
  7878. return false;
  7879. }
  7880. }
  7881. async verifyTask() {
  7882. try {
  7883. if (!this.initialized && !this.init()) {
  7884. return false;
  7885. }
  7886. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7887. return false;
  7888. }
  7889. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7890. const taskLength = this.tasks.length;
  7891. for (let i = 0; i < taskLength; i++) {
  7892. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7893. if (i < taskLength - 1) {
  7894. await delay(15e3);
  7895. }
  7896. }
  7897. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7898. scripts_echoLog({
  7899. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7900. });
  7901. return true;
  7902. } catch (error) {
  7903. throwError(error, 'Givekey.verifyTask');
  7904. return false;
  7905. }
  7906. }
  7907. }
  7908. async function Givekey_verify2(task) {
  7909. try {
  7910. const logStatus = scripts_echoLog({
  7911. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7912. });
  7913. return await new Promise(resolve => {
  7914. $.ajax({
  7915. url: 'https://givekey.ru/giveaway/task',
  7916. method: 'POST',
  7917. data: `id=${task}&user_id=${this.userId}`,
  7918. dataType: 'json',
  7919. headers: {
  7920. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7921. },
  7922. success: data => {
  7923. if (data.btn) {
  7924. $(`button[data-id=${this.userId}]`).html(data.btn);
  7925. }
  7926. if (data.status === 'ok') {
  7927. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7928. logStatus.success();
  7929. resolve(true);
  7930. } else if (data.status === 'end') {
  7931. logStatus.success();
  7932. scripts_echoLog({}).success(data.key);
  7933. resolve(true);
  7934. } else {
  7935. logStatus.error(`Error:${data.msg}`);
  7936. resolve(false);
  7937. }
  7938. },
  7939. error: xhr => {
  7940. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7941. resolve(false);
  7942. }
  7943. });
  7944. });
  7945. } catch (error) {
  7946. throwError(error, 'Givekey.verify');
  7947. return false;
  7948. }
  7949. }
  7950. function Givekey_getGiveawayId2() {
  7951. try {
  7952. var _window$location$href;
  7953. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7954. if (giveawayId) {
  7955. this.giveawayId = giveawayId;
  7956. return true;
  7957. }
  7958. scripts_echoLog({
  7959. text: i18n('getFailed', 'GiveawayId')
  7960. });
  7961. return false;
  7962. } catch (error) {
  7963. throwError(error, 'Givekey.getGiveawayId');
  7964. return false;
  7965. }
  7966. }
  7967. async function Givekey_checkLeftKey2() {
  7968. try {
  7969. if (!globalOptions.other.checkLeftKey) {
  7970. return true;
  7971. }
  7972. if (!$('#keys_count').text()) {
  7973. await external_Swal_default().fire({
  7974. icon: 'warning',
  7975. title: i18n('notice'),
  7976. text: i18n('noKeysLeft'),
  7977. confirmButtonText: i18n('confirm'),
  7978. cancelButtonText: i18n('cancel'),
  7979. showCancelButton: true
  7980. }).then(_ref => {
  7981. let {
  7982. value
  7983. } = _ref;
  7984. if (value) {
  7985. window.close();
  7986. }
  7987. });
  7988. }
  7989. return true;
  7990. } catch (error) {
  7991. throwError(error, 'Givekey.checkLeftKey');
  7992. return false;
  7993. }
  7994. }
  7995. const website_Givekey = Givekey;
  7996. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7997. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7998. privateSet.add(obj);
  7999. }
  8000. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8001. if (privateCollection.has(obj)) {
  8002. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8003. }
  8004. }
  8005. function GiveeClub_defineProperty(obj, key, value) {
  8006. if (key in obj) {
  8007. Object.defineProperty(obj, key, {
  8008. value: value,
  8009. enumerable: true,
  8010. configurable: true,
  8011. writable: true
  8012. });
  8013. } else {
  8014. obj[key] = value;
  8015. }
  8016. return obj;
  8017. }
  8018. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8019. if (!privateSet.has(receiver)) {
  8020. throw new TypeError('attempted to get private field on non-instance');
  8021. }
  8022. return fn;
  8023. }
  8024. var GiveeClub_checkLogin = new WeakSet();
  8025. var GiveeClub_getGiveawayId = new WeakSet();
  8026. var GiveeClub_checkLeftKey = new WeakSet();
  8027. class GiveeClub extends GiveawaySu {
  8028. constructor() {
  8029. super(...arguments);
  8030. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8031. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8032. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8033. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8034. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  8035. }
  8036. static test() {
  8037. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8038. }
  8039. async after() {
  8040. try {
  8041. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8042. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8043. }
  8044. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8045. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8046. }
  8047. } catch (error) {
  8048. throwError(error, 'GiveeClub.after');
  8049. }
  8050. }
  8051. init() {
  8052. try {
  8053. const logStatus = scripts_echoLog({
  8054. text: i18n('initing')
  8055. });
  8056. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8057. logStatus.warning(i18n('needLogin'));
  8058. return false;
  8059. }
  8060. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8061. return false;
  8062. }
  8063. this.initialized = true;
  8064. logStatus.success();
  8065. return true;
  8066. } catch (error) {
  8067. throwError(error, 'GiveeClub.init');
  8068. return false;
  8069. }
  8070. }
  8071. async classifyTask(action) {
  8072. try {
  8073. const logStatus = scripts_echoLog({
  8074. text: i18n('getTasksInfo')
  8075. });
  8076. if (action === 'undo') {
  8077. var _GM_getValue;
  8078. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8079. return true;
  8080. }
  8081. const pro = [];
  8082. const tasks = $('.event-actions tr');
  8083. for (const task of tasks) {
  8084. pro.push(new Promise(resolve => {
  8085. const taskDes = $(task).find('.event-action-label a');
  8086. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8087. const taskName = taskDes.text().trim();
  8088. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8089. return resolve(true);
  8090. }
  8091. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8092. if (!taskLink) {
  8093. return resolve(false);
  8094. }
  8095. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8096. this.undoneTasks.steam.groupLinks.push(taskLink);
  8097. } else if (/like.*announcement/gi.test(taskName)) {
  8098. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8099. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8100. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8101. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  8102. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8103. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8104. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8105. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8106. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8107. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8108. this.undoneTasks.steam.forumLinks.push(taskLink);
  8109. } else if (taskIcon.includes('discord')) {
  8110. this.undoneTasks.discord.serverLinks.push(taskLink);
  8111. } else if (taskIcon.includes('instagram')) {
  8112. this.undoneTasks.instagram.userLinks.push(taskLink);
  8113. } else if (taskIcon.includes('twitch')) {
  8114. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8115. } else if (taskIcon.includes('reddit')) {
  8116. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8117. } else if (/watch.*art/gim.test(taskName)) {
  8118. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8119. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8120. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8121. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8122. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8123. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8124. this.undoneTasks.vk.nameLinks.push(taskLink);
  8125. } else {
  8126. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8127. if (/follow.*button/gim.test(taskName)) {
  8128. this.undoneTasks.steam.followLinks.push(taskLink);
  8129. }
  8130. }
  8131. }
  8132. resolve(true);
  8133. }).catch(error => {
  8134. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8135. return false;
  8136. });
  8137. }));
  8138. }
  8139. await Promise.all(pro);
  8140. logStatus.success();
  8141. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8142. this.socialTasks = this.undoneTasks;
  8143. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8144. tasks: this.socialTasks,
  8145. time: new Date().getTime()
  8146. });
  8147. return true;
  8148. } catch (error) {
  8149. throwError(error, 'GiveeClub.classifyTask');
  8150. return false;
  8151. }
  8152. }
  8153. }
  8154. function GiveeClub_checkLogin2() {
  8155. try {
  8156. if (!globalOptions.other.checkLogin) {
  8157. return true;
  8158. }
  8159. if ($('a[href*="/account/auth"]').length > 0) {
  8160. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8161. }
  8162. return true;
  8163. } catch (error) {
  8164. throwError(error, 'GiveeClub.checkLogin');
  8165. return false;
  8166. }
  8167. }
  8168. function GiveeClub_getGiveawayId2() {
  8169. var _window$location$href;
  8170. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8171. if (giveawayId) {
  8172. this.giveawayId = giveawayId;
  8173. return true;
  8174. }
  8175. scripts_echoLog({
  8176. text: i18n('getFailed', 'GiveawayId')
  8177. });
  8178. return false;
  8179. }
  8180. async function GiveeClub_checkLeftKey2() {
  8181. try {
  8182. if (!globalOptions.other.checkLeftKey) {
  8183. return true;
  8184. }
  8185. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8186. await external_Swal_default().fire({
  8187. icon: 'warning',
  8188. title: i18n('notice'),
  8189. text: i18n('giveawayEnded'),
  8190. confirmButtonText: i18n('confirm'),
  8191. cancelButtonText: i18n('cancel'),
  8192. showCancelButton: true
  8193. }).then(_ref => {
  8194. let {
  8195. value
  8196. } = _ref;
  8197. if (value) {
  8198. window.close();
  8199. }
  8200. });
  8201. }
  8202. return true;
  8203. } catch (error) {
  8204. throwError(error, 'Giveawaysu.checkLeftKey');
  8205. return false;
  8206. }
  8207. }
  8208. const website_GiveeClub = GiveeClub;
  8209. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8210. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8211. privateSet.add(obj);
  8212. }
  8213. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8214. if (privateCollection.has(obj)) {
  8215. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8216. }
  8217. }
  8218. function OpiumPulses_defineProperty(obj, key, value) {
  8219. if (key in obj) {
  8220. Object.defineProperty(obj, key, {
  8221. value: value,
  8222. enumerable: true,
  8223. configurable: true,
  8224. writable: true
  8225. });
  8226. } else {
  8227. obj[key] = value;
  8228. }
  8229. return obj;
  8230. }
  8231. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8232. if (!privateSet.has(receiver)) {
  8233. throw new TypeError('attempted to get private field on non-instance');
  8234. }
  8235. return fn;
  8236. }
  8237. const defaultOptions = {
  8238. maxPoint: '99999999'
  8239. };
  8240. var _toggleTask = new WeakSet();
  8241. var OpiumPulses_checkLogin = new WeakSet();
  8242. class OpiumPulses {
  8243. constructor() {
  8244. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8245. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8246. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8247. OpiumPulses_defineProperty(this, 'options', {
  8248. ...defaultOptions,
  8249. ...GM_getValue('OpiumPulsesOptions')
  8250. });
  8251. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8252. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8253. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8254. }
  8255. static test() {
  8256. return window.location.host === 'www.opiumpulses.com';
  8257. }
  8258. async after() {
  8259. try {
  8260. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8261. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8262. }
  8263. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8264. } catch (error) {
  8265. throwError(error, 'OpiumPulses.after');
  8266. }
  8267. }
  8268. async doFreeTask() {
  8269. try {
  8270. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8271. } catch (error) {
  8272. throwError(error, 'OpiumPulses.doFreeTask');
  8273. }
  8274. }
  8275. async doPointTask() {
  8276. try {
  8277. var _$$text$match;
  8278. 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);
  8279. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8280. } catch (error) {
  8281. throwError(error, 'OpiumPulses.doPointTask');
  8282. }
  8283. }
  8284. init() {
  8285. return true;
  8286. }
  8287. classifyTask() {
  8288. return true;
  8289. }
  8290. }
  8291. async function _toggleTask2(type) {
  8292. try {
  8293. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8294. for (const item of items) {
  8295. var _$$find$text$match;
  8296. 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);
  8297. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8298. if (type === 'points' && needPoints > this.myPoints) {
  8299. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8300. } else if (type === 'points' && !needPoints) {
  8301. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8302. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8303. var _aElement$attr;
  8304. const logStatus = scripts_echoLog({
  8305. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8306. });
  8307. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8308. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8309. var _aElement$attr2, _aElement$attr2$match;
  8310. 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];
  8311. if (giveawayId) {
  8312. checkUser(giveawayId);
  8313. }
  8314. }
  8315. if (!aElement.attr('href')) {
  8316. logStatus.error('Error: No "href".');
  8317. continue;
  8318. }
  8319. const {
  8320. result,
  8321. statusText,
  8322. status,
  8323. data
  8324. } = await tools_httpRequest({
  8325. url: aElement.attr('href'),
  8326. method: 'GET'
  8327. });
  8328. if (result === 'Success') {
  8329. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8330. var _data$responseText$ma;
  8331. logStatus.success();
  8332. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8333. if (type === 'points' && points) {
  8334. this.myPoints = parseInt(points, 10);
  8335. }
  8336. } else {
  8337. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8338. }
  8339. } else {
  8340. logStatus.error(`${result}:${statusText}(${status})`);
  8341. }
  8342. }
  8343. }
  8344. scripts_echoLog({
  8345. text: '-----END-----'
  8346. });
  8347. } catch (error) {
  8348. throwError(error, 'OpiumPulses.toggleTask');
  8349. }
  8350. }
  8351. function OpiumPulses_checkLogin2() {
  8352. try {
  8353. if (!globalOptions.other.checkLogin) {
  8354. return true;
  8355. }
  8356. if ($('a[href*="/site/login"]').length > 1) {
  8357. window.open('/site/login', '_self');
  8358. }
  8359. return true;
  8360. } catch (error) {
  8361. throwError(error, 'OpiumPulses.checkLogin');
  8362. return false;
  8363. }
  8364. }
  8365. const website_OpiumPulses = OpiumPulses;
  8366. const external_dayjs_namespaceObject = dayjs;
  8367. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8368. const leftKeyChecker = {
  8369. async classify(link) {
  8370. try {
  8371. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8372. return await this.giveawaySu(link);
  8373. }
  8374. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8375. return await this.giveeClub(link);
  8376. }
  8377. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8378. return await this.gleam(link);
  8379. }
  8380. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8381. return await this.indieDb(link);
  8382. }
  8383. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8384. return await this.keyhub(link);
  8385. }
  8386. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8387. return await this.opquests(link);
  8388. }
  8389. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8390. return await this.itch(link);
  8391. }
  8392. return false;
  8393. } catch (error) {
  8394. throwError(error, 'leftKeyChecker.classify');
  8395. return false;
  8396. }
  8397. },
  8398. async giveawaySu(link) {
  8399. try {
  8400. const {
  8401. result,
  8402. data
  8403. } = await tools_httpRequest({
  8404. url: link,
  8405. method: 'GET'
  8406. });
  8407. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8408. if (data.responseText.includes('class="steam-login"')) {
  8409. return false;
  8410. }
  8411. if (data.responseText.includes('class="giveaway-ended"')) {
  8412. return 'Ended';
  8413. }
  8414. return 'Active';
  8415. }
  8416. return false;
  8417. } catch (error) {
  8418. throwError(error, 'leftKeyChecker.giveawaySu');
  8419. return false;
  8420. }
  8421. },
  8422. async giveeClub(link) {
  8423. try {
  8424. const {
  8425. result,
  8426. data
  8427. } = await tools_httpRequest({
  8428. url: link,
  8429. method: 'GET'
  8430. });
  8431. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8432. if (data.responseText.includes('class="event-winner"')) {
  8433. return 'Won';
  8434. }
  8435. if (data.responseText.includes('class="event-ended"')) {
  8436. return 'Ended';
  8437. }
  8438. return 'Active';
  8439. }
  8440. return false;
  8441. } catch (error) {
  8442. throwError(error, 'leftKeyChecker.giveeClub');
  8443. return false;
  8444. }
  8445. },
  8446. async gleam(link) {
  8447. try {
  8448. const {
  8449. result,
  8450. data
  8451. } = await tools_httpRequest({
  8452. url: link,
  8453. method: 'GET'
  8454. });
  8455. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8456. var _data$responseText$ma, _$$attr, _$$attr$match;
  8457. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8458. return 'Won';
  8459. }
  8460. 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];
  8461. if (!campaignDiv) {
  8462. return false;
  8463. }
  8464. 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];
  8465. if (!campaignString) {
  8466. return false;
  8467. }
  8468. const {
  8469. campaign
  8470. } = JSON.parse(campaignString);
  8471. if (campaign.banned) {
  8472. return 'Banned';
  8473. }
  8474. if (campaign.finished) {
  8475. return 'Ended';
  8476. }
  8477. if (campaign.paused) {
  8478. return 'Paused';
  8479. }
  8480. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8481. return 'NotStart';
  8482. }
  8483. return 'Active';
  8484. }
  8485. return false;
  8486. } catch (error) {
  8487. throwError(error, 'leftKeyChecker.gleam');
  8488. return false;
  8489. }
  8490. },
  8491. async indieDb(link) {
  8492. try {
  8493. const {
  8494. result,
  8495. data
  8496. } = await tools_httpRequest({
  8497. url: link,
  8498. method: 'GET'
  8499. });
  8500. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8501. if (data.responseText.includes('Congrats you WON')) {
  8502. return 'Won';
  8503. }
  8504. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8505. return 'Ended';
  8506. }
  8507. return 'Active';
  8508. }
  8509. return false;
  8510. } catch (error) {
  8511. throwError(error, 'leftKeyChecker.indieDb');
  8512. return false;
  8513. }
  8514. },
  8515. async keyhub(link) {
  8516. try {
  8517. const {
  8518. result,
  8519. data
  8520. } = await tools_httpRequest({
  8521. url: link,
  8522. method: 'GET'
  8523. });
  8524. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8525. var _data$responseText$ma2;
  8526. 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];
  8527. if (!keysleft) {
  8528. return false;
  8529. }
  8530. if (keysleft === '0') {
  8531. return 'Ended';
  8532. }
  8533. return `Active(${keysleft})`;
  8534. }
  8535. return false;
  8536. } catch (error) {
  8537. throwError(error, 'leftKeyChecker.keyhub');
  8538. return false;
  8539. }
  8540. },
  8541. async opquests(link) {
  8542. try {
  8543. const {
  8544. result,
  8545. data
  8546. } = await tools_httpRequest({
  8547. url: link,
  8548. method: 'GET'
  8549. });
  8550. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8551. var _data$responseText$ma3;
  8552. 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];
  8553. if (!keysleft) {
  8554. return false;
  8555. }
  8556. if (keysleft === '0') {
  8557. return 'Ended';
  8558. }
  8559. return `Active(${keysleft})`;
  8560. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8561. return 'Ended';
  8562. }
  8563. return false;
  8564. } catch (error) {
  8565. throwError(error, 'leftKeyChecker.opquests');
  8566. return false;
  8567. }
  8568. },
  8569. async itch(link) {
  8570. try {
  8571. const {
  8572. result,
  8573. data
  8574. } = await tools_httpRequest({
  8575. url: link,
  8576. method: 'GET'
  8577. });
  8578. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8579. var _data$responseText$ma4;
  8580. 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];
  8581. if (!endDate) {
  8582. return false;
  8583. }
  8584. if (new Date().getTime() > new Date(endDate).getTime()) {
  8585. return 'Ended';
  8586. }
  8587. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8588. }
  8589. return false;
  8590. } catch (error) {
  8591. throwError(error, 'leftKeyChecker.opquests');
  8592. return false;
  8593. }
  8594. }
  8595. };
  8596. const website_leftKeyChecker = leftKeyChecker;
  8597. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8598. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8599. privateSet.add(obj);
  8600. }
  8601. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8602. if (privateCollection.has(obj)) {
  8603. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8604. }
  8605. }
  8606. function Keylol_defineProperty(obj, key, value) {
  8607. if (key in obj) {
  8608. Object.defineProperty(obj, key, {
  8609. value: value,
  8610. enumerable: true,
  8611. configurable: true,
  8612. writable: true
  8613. });
  8614. } else {
  8615. obj[key] = value;
  8616. }
  8617. return obj;
  8618. }
  8619. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8620. if (!privateSet.has(receiver)) {
  8621. throw new TypeError('attempted to get private field on non-instance');
  8622. }
  8623. return fn;
  8624. }
  8625. const Keylol_defaultTasksTemplate = {
  8626. steam: {
  8627. groupLinks: [],
  8628. wishlistLinks: [],
  8629. curatorLinks: [],
  8630. curatorLikeLinks: [],
  8631. followLinks: [],
  8632. forumLinks: [],
  8633. announcementLinks: [],
  8634. workshopVoteLinks: [],
  8635. licenseLinks: []
  8636. },
  8637. discord: {
  8638. serverLinks: []
  8639. },
  8640. instagram: {
  8641. userLinks: []
  8642. },
  8643. vk: {
  8644. nameLinks: []
  8645. },
  8646. twitch: {
  8647. channelLinks: []
  8648. },
  8649. reddit: {
  8650. redditLinks: []
  8651. },
  8652. twitter: {
  8653. userLinks: [],
  8654. retweetLinks: []
  8655. },
  8656. youtube: {
  8657. channelLinks: [],
  8658. likeLinks: []
  8659. }
  8660. };
  8661. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  8662. var _addBtn = new WeakSet();
  8663. class Keylol extends website_Website {
  8664. constructor() {
  8665. super(...arguments);
  8666. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8667. Keylol_defineProperty(this, 'name', 'Keylol');
  8668. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  8669. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  8670. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8671. }
  8672. static test() {
  8673. var _$$eq$attr, _$$eq$attr2;
  8674. 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')));
  8675. }
  8676. init() {
  8677. return true;
  8678. }
  8679. after() {
  8680. try {
  8681. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8682. const mainPost = $(selector);
  8683. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8684. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8685. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8686. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8687. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8688. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8689. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8690. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8691. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8692. if (discordLinks.length > 0) {
  8693. for (const discordLink of discordLinks) {
  8694. const link = $(discordLink).attr('href');
  8695. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8696. continue;
  8697. }
  8698. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8699. }
  8700. }
  8701. if (redditLinks.length > 0) {
  8702. for (const redditLink of redditLinks) {
  8703. const link = $(redditLink).attr('href');
  8704. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8705. continue;
  8706. }
  8707. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8708. }
  8709. }
  8710. if (insLinks.length > 0) {
  8711. for (const insLink of insLinks) {
  8712. const link = $(insLink).attr('href');
  8713. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8714. continue;
  8715. }
  8716. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8717. }
  8718. }
  8719. if (twitterLinks.length > 0) {
  8720. for (const twitterLink of twitterLinks) {
  8721. const link = $(twitterLink).attr('href');
  8722. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8723. continue;
  8724. }
  8725. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8726. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8727. } else {
  8728. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8729. }
  8730. }
  8731. }
  8732. if (twitchLinks.length > 0) {
  8733. for (const twitchLink of twitchLinks) {
  8734. const link = $(twitchLink).attr('href');
  8735. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8736. continue;
  8737. }
  8738. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8739. }
  8740. }
  8741. if (vkLinks.length > 0) {
  8742. for (const vkLink of vkLinks) {
  8743. const link = $(vkLink).attr('href');
  8744. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8745. continue;
  8746. }
  8747. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8748. }
  8749. }
  8750. if (steamStoreLinks.length > 0) {
  8751. for (const steamStoreLink of steamStoreLinks) {
  8752. const link = $(steamStoreLink).attr('href');
  8753. if (!link) {
  8754. continue;
  8755. }
  8756. if (/app\/[\d]+/.test(link)) {
  8757. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8758. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8759. } else if (/curator\/[\d]+/.test(link)) {
  8760. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8761. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8762. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8763. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8764. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8765. }
  8766. }
  8767. }
  8768. if (steamCommunityLinks.length > 0) {
  8769. for (const steamCommunityLink of steamCommunityLinks) {
  8770. const link = $(steamCommunityLink).attr('href');
  8771. if (!link) {
  8772. continue;
  8773. }
  8774. if (/groups\/.+/.test(link)) {
  8775. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8776. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8777. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8778. }
  8779. }
  8780. }
  8781. if (ytbLinks.length > 0) {
  8782. for (const ytbLink of ytbLinks) {
  8783. const link = $(ytbLink).attr('href');
  8784. if (!link) {
  8785. continue;
  8786. }
  8787. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8788. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8789. }
  8790. }
  8791. const giveawayLinks = mainPost.find('a[href*="giveaway.su/giveaway/view/"],a[href*="givee.club/"],a[href*="gleam.io/"],a[href*="www.indiedb.com/giveaways/"],a[href*="key-hub.eu/giveaway/"],a[href*="opquests.com/quests/"],a[href*="itch.io/s/"]');
  8792. if (giveawayLinks.length > 0) {
  8793. for (const giveawayLink of giveawayLinks) {
  8794. const link = $(giveawayLink).attr('href');
  8795. if (!link) {
  8796. continue;
  8797. }
  8798. website_leftKeyChecker.classify(link).then(status => {
  8799. if (!status) {
  8800. return;
  8801. }
  8802. if (/^Active/.test(status)) {
  8803. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  8804. return;
  8805. }
  8806. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  8807. }).catch(error => {
  8808. throwError(error, 'keylol.after -> leftKeyChecker');
  8809. });
  8810. }
  8811. }
  8812. if (this.name === 'Keylol') {
  8813. const asfLinks = mainPost.find('a[href^="#asf"]');
  8814. if (asfLinks.length > 0) {
  8815. for (const asfLink of asfLinks) {
  8816. const link = $(asfLink).attr('href');
  8817. if (!link) {
  8818. continue;
  8819. }
  8820. 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', '')}`);
  8821. }
  8822. }
  8823. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]');
  8824. if (subLinks.length > 0) {
  8825. for (const subLink of subLinks) {
  8826. var _link$match;
  8827. const link = $(subLink).attr('href');
  8828. if (!link) {
  8829. continue;
  8830. }
  8831. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  8832. if (!subid) {
  8833. continue;
  8834. }
  8835. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  8836. }
  8837. }
  8838. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense")');
  8839. if (asfLinks2.length > 0) {
  8840. for (const asfLink of asfLinks2) {
  8841. const subid = [ ...asfLink.innerText.matchAll(/s\/([\d]+)/g) ].map(arr => arr[1]);
  8842. if (subid.length === 0) {
  8843. continue;
  8844. }
  8845. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  8846. }
  8847. }
  8848. }
  8849. } catch (error) {
  8850. throwError(error, 'keylol.after');
  8851. }
  8852. }
  8853. classifyTask(action) {
  8854. try {
  8855. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  8856. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  8857. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8858. for (const btn of selectedBtns) {
  8859. const button = $(btn);
  8860. const social = button.attr('data-social');
  8861. const type = button.attr('data-type');
  8862. const link = button.attr('data-link');
  8863. if (!(social && type && link)) {
  8864. continue;
  8865. }
  8866. if (action === 'do') {
  8867. this.undoneTasks[social][type].push(link);
  8868. }
  8869. if (action === 'undo') {
  8870. this.socialTasks[social][type].push(link);
  8871. }
  8872. }
  8873. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8874. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8875. return true;
  8876. } catch (error) {
  8877. throwError(error, 'Keylol.classifyTask');
  8878. return false;
  8879. }
  8880. }
  8881. selectAll() {
  8882. try {
  8883. $('.auto-task-keylol').attr('selected', 'selected');
  8884. } catch (error) {
  8885. throwError(error, 'Keylol.selectAll');
  8886. }
  8887. }
  8888. selectNone() {
  8889. try {
  8890. $('.auto-task-keylol').removeAttr('selected');
  8891. } catch (error) {
  8892. throwError(error, 'Keylol.selectNone');
  8893. }
  8894. }
  8895. invertSelect() {
  8896. try {
  8897. $('.auto-task-keylol').each((index, element) => {
  8898. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8899. });
  8900. } catch (error) {
  8901. throwError(error, 'Keylol.invertSelect');
  8902. }
  8903. }
  8904. }
  8905. function _addBtn2(before, social, linkType, link) {
  8906. try {
  8907. $(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>`);
  8908. } catch (error) {
  8909. throwError(error, 'keylol.addBtn');
  8910. }
  8911. }
  8912. const website_Keylol = Keylol;
  8913. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8914. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8915. privateSet.add(obj);
  8916. }
  8917. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8918. if (privateCollection.has(obj)) {
  8919. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8920. }
  8921. }
  8922. function Opquests_defineProperty(obj, key, value) {
  8923. if (key in obj) {
  8924. Object.defineProperty(obj, key, {
  8925. value: value,
  8926. enumerable: true,
  8927. configurable: true,
  8928. writable: true
  8929. });
  8930. } else {
  8931. obj[key] = value;
  8932. }
  8933. return obj;
  8934. }
  8935. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8936. if (!privateSet.has(receiver)) {
  8937. throw new TypeError('attempted to get private field on non-instance');
  8938. }
  8939. return fn;
  8940. }
  8941. const Opquests_defaultTasks = {
  8942. steam: {
  8943. groupLinks: [],
  8944. wishlistLinks: [],
  8945. followLinks: [],
  8946. curatorLikeLinks: []
  8947. }
  8948. };
  8949. var Opquests_getGiveawayId = new WeakSet();
  8950. var Opquests_checkLogin = new WeakSet();
  8951. class Opquests extends website_Website {
  8952. constructor() {
  8953. super(...arguments);
  8954. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8955. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8956. Opquests_defineProperty(this, 'name', 'Opquests');
  8957. Opquests_defineProperty(this, 'undoneTasks', {
  8958. ...Opquests_defaultTasks
  8959. });
  8960. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8961. }
  8962. static test() {
  8963. return window.location.host === 'opquests.com';
  8964. }
  8965. async after() {
  8966. try {
  8967. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8968. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8969. }
  8970. } catch (error) {
  8971. throwError(error, 'Opquests.after');
  8972. }
  8973. }
  8974. init() {
  8975. try {
  8976. const logStatus = scripts_echoLog({
  8977. text: i18n('initing')
  8978. });
  8979. if ($('a[href*="/auth/redirect"]').length > 0) {
  8980. window.open('/auth/redirect', '_self');
  8981. logStatus.warning(i18n('needLogin'));
  8982. return false;
  8983. }
  8984. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8985. return false;
  8986. }
  8987. this.initialized = true;
  8988. logStatus.success();
  8989. return true;
  8990. } catch (error) {
  8991. throwError(error, 'Opquests.init');
  8992. return false;
  8993. }
  8994. }
  8995. async classifyTask(action) {
  8996. try {
  8997. if (action === 'undo') {
  8998. scripts_echoLog({
  8999. text: i18n('cannotUndo')
  9000. });
  9001. return false;
  9002. }
  9003. const logStatus = scripts_echoLog({
  9004. text: i18n('getTasksInfo')
  9005. });
  9006. const tasks = $('.w-full:contains("Validate") .items-center');
  9007. for (const task of tasks) {
  9008. const link = $(task).find('a:contains("Open")').attr('href');
  9009. const taskDes = $(task).find('div').eq(1).text().trim();
  9010. if (!link) {
  9011. continue;
  9012. }
  9013. if (/steamcommunity\.com\/groups\//.test(link)) {
  9014. this.undoneTasks.steam.groupLinks.push(link);
  9015. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9016. if (/wishlist/gim.test(taskDes)) {
  9017. this.undoneTasks.steam.wishlistLinks.push(link);
  9018. } else if (/follow/gim.test(taskDes)) {
  9019. this.undoneTasks.steam.followLinks.push(link);
  9020. }
  9021. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9022. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9023. } else {
  9024. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9025. }
  9026. }
  9027. logStatus.success();
  9028. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9029. return true;
  9030. } catch (error) {
  9031. throwError(error, 'Opquests.classifyTask');
  9032. return false;
  9033. }
  9034. }
  9035. }
  9036. function Opquests_getGiveawayId2() {
  9037. try {
  9038. var _window$location$href;
  9039. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9040. if (giveawayId) {
  9041. this.giveawayId = giveawayId;
  9042. return true;
  9043. }
  9044. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9045. return false;
  9046. } catch (error) {
  9047. throwError(error, 'Opquests.getGiveawayId');
  9048. return false;
  9049. }
  9050. }
  9051. function Opquests_checkLogin2() {
  9052. try {
  9053. if (!globalOptions.other.checkLogin) {
  9054. return true;
  9055. }
  9056. if ($('a[href*="/auth/redirect"]').length > 0) {
  9057. window.open('/auth/redirect', '_self');
  9058. }
  9059. return true;
  9060. } catch (error) {
  9061. throwError(error, 'Opquests.checkLogin');
  9062. return false;
  9063. }
  9064. }
  9065. const website_Opquests = Opquests;
  9066. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9067. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9068. privateSet.add(obj);
  9069. }
  9070. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9071. if (privateCollection.has(obj)) {
  9072. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9073. }
  9074. }
  9075. function Gleam_defineProperty(obj, key, value) {
  9076. if (key in obj) {
  9077. Object.defineProperty(obj, key, {
  9078. value: value,
  9079. enumerable: true,
  9080. configurable: true,
  9081. writable: true
  9082. });
  9083. } else {
  9084. obj[key] = value;
  9085. }
  9086. return obj;
  9087. }
  9088. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9089. if (!privateSet.has(receiver)) {
  9090. throw new TypeError('attempted to get private field on non-instance');
  9091. }
  9092. return fn;
  9093. }
  9094. const Gleam_defaultTasksTemplate = {
  9095. steam: {
  9096. groupLinks: [],
  9097. wishlistLinks: [],
  9098. followLinks: [],
  9099. curatorLinks: [],
  9100. curatorLikeLinks: []
  9101. },
  9102. twitter: {
  9103. userLinks: [],
  9104. retweetLinks: []
  9105. },
  9106. twitch: {
  9107. channelLinks: []
  9108. },
  9109. discord: {
  9110. serverLinks: []
  9111. },
  9112. youtube: {
  9113. channelLinks: []
  9114. },
  9115. extra: {
  9116. gleam: []
  9117. }
  9118. };
  9119. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9120. const Gleam_defaultOptions = {
  9121. vlootUsername: '',
  9122. gameroundUsername: ''
  9123. };
  9124. var _checkSync = new WeakSet();
  9125. var _doGleamTask = new WeakSet();
  9126. var Gleam_getGiveawayId = new WeakSet();
  9127. var _getGleamLink = new WeakSet();
  9128. var Gleam_checkLeftKey = new WeakSet();
  9129. class Gleam extends website_Website {
  9130. constructor() {
  9131. super(...arguments);
  9132. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9133. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9134. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9135. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9136. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9137. Gleam_defineProperty(this, 'name', 'Gleam');
  9138. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9139. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9140. Gleam_defineProperty(this, 'options', {
  9141. ...Gleam_defaultOptions,
  9142. ...GM_getValue('GleamOptions')
  9143. });
  9144. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9145. }
  9146. static test() {
  9147. return window.location.host === 'gleam.io';
  9148. }
  9149. async after() {
  9150. try {
  9151. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9152. const checkComplete = setInterval(() => {
  9153. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9154. clearInterval(checkComplete);
  9155. window.close();
  9156. }
  9157. });
  9158. for (const task of $('.entry-content .entry-method')) {
  9159. const taskInfo = $(task).find('.user-links');
  9160. const expandInfo = $(task).find('.expandable');
  9161. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9162. if (aElements.length > 0) {
  9163. for (const element of aElements) {
  9164. const $element = $(element);
  9165. const href = $element.attr('href');
  9166. $element.removeAttr('href')[0].click();
  9167. $element.attr('href', href);
  9168. await delay(1e3);
  9169. }
  9170. }
  9171. taskInfo[0].click();
  9172. await delay(1e3);
  9173. }
  9174. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9175. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9176. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9177. }
  9178. } catch (error) {
  9179. throwError(error, 'Gleam.after');
  9180. return false;
  9181. }
  9182. }
  9183. init() {
  9184. try {
  9185. const logStatus = scripts_echoLog({
  9186. text: i18n('initing')
  9187. });
  9188. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9189. return false;
  9190. }
  9191. this.initialized = true;
  9192. logStatus.success();
  9193. return true;
  9194. } catch (error) {
  9195. throwError(error, 'Gleam.init');
  9196. return false;
  9197. }
  9198. }
  9199. async classifyTask(action) {
  9200. try {
  9201. const logStatus = scripts_echoLog({
  9202. text: i18n('getTasksInfo')
  9203. });
  9204. if (action === 'undo') {
  9205. var _GM_getValue;
  9206. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9207. }
  9208. const tasks = $('.entry-content .entry-method');
  9209. for (const task of tasks) {
  9210. var _socialIcon$attr;
  9211. const $task = $(task);
  9212. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9213. continue;
  9214. }
  9215. const socialIcon = $task.find('.icon-wrapper i');
  9216. const taskInfo = $task.find('.user-links');
  9217. const taskText = taskInfo.text().trim();
  9218. const expandInfo = $task.find('.expandable');
  9219. const aElements = expandInfo.find('a.btn');
  9220. if (aElements.length > 0) {
  9221. for (const element of aElements) {
  9222. const $element = $(element);
  9223. const href = $element.attr('href');
  9224. $element.removeAttr('href')[0].click();
  9225. $element.attr('href', href);
  9226. }
  9227. }
  9228. if (socialIcon.hasClass('fa-twitter')) {
  9229. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9230. if (!link) {
  9231. continue;
  9232. }
  9233. if (/follow/gi.test(taskText)) {
  9234. if (action === 'undo') {
  9235. this.socialTasks.twitter.userLinks.push(link);
  9236. }
  9237. if (action === 'do') {
  9238. this.undoneTasks.twitter.userLinks.push(link);
  9239. }
  9240. } else if (/retweet/gim.test(taskText)) {
  9241. if (action === 'undo') {
  9242. this.socialTasks.twitter.retweetLinks.push(link);
  9243. }
  9244. if (action === 'do') {
  9245. this.undoneTasks.twitter.retweetLinks.push(link);
  9246. }
  9247. }
  9248. } else if (socialIcon.hasClass('fa-twitch')) {
  9249. if (/follow/gim.test(taskText)) {
  9250. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9251. if (!link) {
  9252. continue;
  9253. }
  9254. if (action === 'undo') {
  9255. this.socialTasks.twitch.channelLinks.push(link);
  9256. }
  9257. if (action === 'do') {
  9258. this.undoneTasks.twitch.channelLinks.push(link);
  9259. }
  9260. }
  9261. } else if (socialIcon.hasClass('fa-discord')) {
  9262. if (/join/gim.test(taskText)) {
  9263. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9264. if (!link) {
  9265. var _$task$find$attr, _$task$find$attr$matc;
  9266. 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];
  9267. if (!ggLink) {
  9268. continue;
  9269. }
  9270. link = `https://discord.com/invite/${ggLink}`;
  9271. }
  9272. if (action === 'undo') {
  9273. this.socialTasks.discord.serverLinks.push(link);
  9274. }
  9275. if (action === 'do') {
  9276. this.undoneTasks.discord.serverLinks.push(link);
  9277. }
  9278. }
  9279. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9280. continue;
  9281. } else if (socialIcon.hasClass('fa-youtube')) {
  9282. if (/subscribe/gim.test(taskText)) {
  9283. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9284. if (!link) {
  9285. continue;
  9286. }
  9287. if (action === 'undo') {
  9288. this.socialTasks.youtube.channelLinks.push(link);
  9289. }
  9290. if (action === 'do') {
  9291. this.undoneTasks.youtube.channelLinks.push(link);
  9292. }
  9293. }
  9294. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9295. if (/join.*group/gi.test(taskText)) {
  9296. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9297. if (!link) {
  9298. continue;
  9299. }
  9300. if (action === 'undo') {
  9301. this.socialTasks.steam.groupLinks.push(link);
  9302. }
  9303. if (action === 'do') {
  9304. this.undoneTasks.steam.groupLinks.push(link);
  9305. }
  9306. } else if (/follow.*curator/gi.test(taskText)) {
  9307. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9308. if (!link) {
  9309. continue;
  9310. }
  9311. if (action === 'undo') {
  9312. this.socialTasks.steam.curatorLinks.push(link);
  9313. }
  9314. if (action === 'do') {
  9315. this.undoneTasks.steam.curatorLinks.push(link);
  9316. }
  9317. }
  9318. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9319. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9320. for (const button of continueBtn) {
  9321. button.click();
  9322. await delay(500);
  9323. expandInfo.find('input').val(this.options.vlootUsername);
  9324. }
  9325. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9326. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9327. for (const button of continueBtn) {
  9328. button.click();
  9329. await delay(500);
  9330. expandInfo.find('input').val(this.options.gameroundUsername);
  9331. }
  9332. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9333. if (action !== 'do') {
  9334. continue;
  9335. }
  9336. const link = aElements.attr('href');
  9337. if (!link) {
  9338. continue;
  9339. }
  9340. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9341. if (!gleamLink) {
  9342. continue;
  9343. }
  9344. this.undoneTasks.extra.gleam.push(gleamLink);
  9345. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-telegram-plane') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  9346. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9347. }
  9348. }
  9349. logStatus.success();
  9350. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9351. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9352. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9353. tasks: this.socialTasks,
  9354. time: new Date().getTime()
  9355. });
  9356. return true;
  9357. } catch (error) {
  9358. throwError(error, 'Gleam.classifyTask');
  9359. return false;
  9360. }
  9361. }
  9362. async extraDoTask(_ref) {
  9363. let {
  9364. gleam
  9365. } = _ref;
  9366. try {
  9367. const pro = [];
  9368. for (const link of gleam) {
  9369. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9370. }
  9371. return Promise.all(pro).then(() => true);
  9372. } catch (error) {
  9373. throwError(error, 'Gleam.extraDoTask');
  9374. return false;
  9375. }
  9376. }
  9377. async verifyTask() {
  9378. try {
  9379. scripts_echoLog({
  9380. text: `${i18n('verifyingTask')}...`
  9381. });
  9382. const tasks = $('.entry-content .entry-method');
  9383. for (const task of tasks) {
  9384. const $task = $(task);
  9385. if ($task.find('i.fa-question').length === 0) {
  9386. continue;
  9387. }
  9388. const taskInfo = $task.find('.user-links');
  9389. taskInfo[0].click();
  9390. await delay(500);
  9391. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9392. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9393. for (const button of continueBtn) {
  9394. button.click();
  9395. await delay(500);
  9396. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9397. }
  9398. }
  9399. scripts_echoLog({
  9400. text: i18n('verifiedGleamTasks')
  9401. });
  9402. } catch (error) {
  9403. throwError(error, 'Gleam.verifyTask');
  9404. return false;
  9405. }
  9406. }
  9407. }
  9408. async function _checkSync2() {
  9409. try {
  9410. return await new Promise(resolve => {
  9411. const checker = setInterval(() => {
  9412. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9413. clearInterval(checker);
  9414. resolve(true);
  9415. }
  9416. }, 500);
  9417. });
  9418. } catch (error) {
  9419. throwError(error, 'Gleam.checkSync');
  9420. return false;
  9421. }
  9422. }
  9423. async function _doGleamTask2(link) {
  9424. try {
  9425. const logStatus = scripts_echoLog({
  9426. text: i18n('doingGleamTask')
  9427. });
  9428. return await new Promise(resolve => {
  9429. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9430. active: true,
  9431. insert: true,
  9432. setParent: true
  9433. }).onclose = () => {
  9434. logStatus.success();
  9435. resolve(true);
  9436. };
  9437. });
  9438. } catch (error) {
  9439. throwError(error, 'Gleam.doGleamTask');
  9440. return false;
  9441. }
  9442. }
  9443. function Gleam_getGiveawayId2() {
  9444. try {
  9445. const giveawayId = window.location.pathname;
  9446. if (giveawayId) {
  9447. this.giveawayId = giveawayId;
  9448. return true;
  9449. }
  9450. scripts_echoLog({
  9451. text: i18n('getFailed', 'GiveawayId')
  9452. });
  9453. return false;
  9454. } catch (error) {
  9455. throwError(error, 'Gleam.getGiveawayId');
  9456. return false;
  9457. }
  9458. }
  9459. async function _getGleamLink2(link) {
  9460. try {
  9461. const logStatus = scripts_echoLog({
  9462. text: i18n('gettingGleamLink')
  9463. });
  9464. const {
  9465. result,
  9466. statusText,
  9467. status,
  9468. data
  9469. } = await tools_httpRequest({
  9470. url: link,
  9471. method: 'GET'
  9472. });
  9473. if (result === 'Success') {
  9474. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9475. var _data$responseText$ma;
  9476. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9477. if (gleamLink) {
  9478. logStatus.success();
  9479. return gleamLink;
  9480. }
  9481. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9482. return false;
  9483. }
  9484. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9485. return false;
  9486. }
  9487. logStatus.error(`${result}:${statusText}(${status})`);
  9488. return false;
  9489. } catch (error) {
  9490. throwError(error, 'Gleam.getGleamLink');
  9491. return false;
  9492. }
  9493. }
  9494. async function Gleam_checkLeftKey2() {
  9495. try {
  9496. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9497. if (!globalOptions.other.checkLeftKey) {
  9498. return true;
  9499. }
  9500. 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];
  9501. if (!campaignString) {
  9502. return false;
  9503. }
  9504. const {
  9505. campaign,
  9506. incentive
  9507. } = JSON.parse(campaignString);
  9508. 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];
  9509. let ownedKey = false;
  9510. if (controllerString) {
  9511. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9512. 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) {
  9513. ownedKey = true;
  9514. }
  9515. }
  9516. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9517. await external_Swal_default().fire({
  9518. icon: 'warning',
  9519. title: i18n('notice'),
  9520. text: i18n('giveawayNotWork'),
  9521. confirmButtonText: i18n('confirm'),
  9522. cancelButtonText: i18n('cancel'),
  9523. showCancelButton: true
  9524. }).then(_ref2 => {
  9525. let {
  9526. value
  9527. } = _ref2;
  9528. if (value) {
  9529. window.close();
  9530. }
  9531. });
  9532. }
  9533. return true;
  9534. } catch (error) {
  9535. throwError(error, 'Gleam.checkLeftKey');
  9536. return false;
  9537. }
  9538. }
  9539. const website_Gleam = Gleam;
  9540. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9541. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9542. privateSet.add(obj);
  9543. }
  9544. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9545. if (privateCollection.has(obj)) {
  9546. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9547. }
  9548. }
  9549. function SweepWidget_defineProperty(obj, key, value) {
  9550. if (key in obj) {
  9551. Object.defineProperty(obj, key, {
  9552. value: value,
  9553. enumerable: true,
  9554. configurable: true,
  9555. writable: true
  9556. });
  9557. } else {
  9558. obj[key] = value;
  9559. }
  9560. return obj;
  9561. }
  9562. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9563. if (!privateSet.has(receiver)) {
  9564. throw new TypeError('attempted to get private field on non-instance');
  9565. }
  9566. return fn;
  9567. }
  9568. const SweepWidget_defaultOptions = {
  9569. username: '',
  9570. email: ''
  9571. };
  9572. var SweepWidget_checkLogin = new WeakSet();
  9573. var SweepWidget_getGiveawayId = new WeakSet();
  9574. var _checkEnter = new WeakSet();
  9575. var _checkFinish = new WeakSet();
  9576. class SweepWidget extends website_Website {
  9577. constructor() {
  9578. super(...arguments);
  9579. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9580. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9581. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9582. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9583. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9584. SweepWidget_defineProperty(this, 'options', {
  9585. ...SweepWidget_defaultOptions,
  9586. ...GM_getValue('SweepWidgetOptions')
  9587. });
  9588. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9589. }
  9590. static test() {
  9591. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9592. }
  9593. async after() {
  9594. try {
  9595. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9596. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9597. }
  9598. } catch (error) {
  9599. throwError(error, 'SweepWidget.after');
  9600. }
  9601. }
  9602. init() {
  9603. try {
  9604. const logStatus = scripts_echoLog({
  9605. text: i18n('initing')
  9606. });
  9607. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9608. logStatus.warning(i18n('needLogin'));
  9609. return false;
  9610. }
  9611. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9612. return false;
  9613. }
  9614. this.initialized = true;
  9615. logStatus.success();
  9616. return true;
  9617. } catch (error) {
  9618. throwError(error, 'SweepWidget.init');
  9619. return false;
  9620. }
  9621. }
  9622. classifyTask() {
  9623. return true;
  9624. }
  9625. async doTask() {
  9626. try {
  9627. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9628. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9629. $('input[name="sw__login_name"]').val(this.options.username);
  9630. }
  9631. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9632. $('input[name="sw__login_email"]').val(this.options.email);
  9633. }
  9634. if ($('#sw_login_button:visible').length > 0) {
  9635. $('#sw_login_button')[0].click();
  9636. }
  9637. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9638. return false;
  9639. }
  9640. }
  9641. const logStatus = scripts_echoLog({
  9642. text: i18n('SweepWidgetNotice')
  9643. });
  9644. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9645. for (const task of tasks) {
  9646. var _aElement$, _$task$find$removeAtt;
  9647. const $task = $(task);
  9648. if ($task.find('i.fa-check:visible').length > 0) {
  9649. continue;
  9650. }
  9651. const title = $task.find('.sw_text_inner');
  9652. title[0].click();
  9653. const aElement = $task.find('a.sw_link');
  9654. const link = aElement.attr('href');
  9655. aElement.attr('href', '#a').attr('target', '_self');
  9656. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9657. await delay(300);
  9658. aElement.attr('href', link).attr('target', '_blank');
  9659. $task.find('input[type="text"]').val('test');
  9660. const verifyBtn = $task.find('input.sw_verify');
  9661. if (verifyBtn.prop('disabled') === true) {
  9662. title[0].click();
  9663. await delay(300);
  9664. title[0].click();
  9665. await delay(300);
  9666. }
  9667. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9668. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9669. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9670. }
  9671. logStatus.success();
  9672. return true;
  9673. } catch (error) {
  9674. throwError(error, 'SweepWidget.doTask');
  9675. return false;
  9676. }
  9677. }
  9678. }
  9679. function SweepWidget_checkLogin2() {
  9680. try {
  9681. if ($('#twitter_login_button').length > 0) {
  9682. $('#twitter_login_button')[0].click();
  9683. }
  9684. return true;
  9685. } catch (error) {
  9686. throwError(error, 'SweepWidget.checkLogin');
  9687. return false;
  9688. }
  9689. }
  9690. function SweepWidget_getGiveawayId2() {
  9691. try {
  9692. var _window$location$href;
  9693. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9694. if (giveawayId) {
  9695. this.giveawayId = giveawayId;
  9696. return true;
  9697. }
  9698. scripts_echoLog({
  9699. text: i18n('getFailed', 'GiveawayId')
  9700. });
  9701. return false;
  9702. } catch (error) {
  9703. throwError(error, 'SweepWidget.getGiveawayId');
  9704. return false;
  9705. }
  9706. }
  9707. async function _checkEnter2() {
  9708. try {
  9709. return new Promise(resolve => {
  9710. const checker = setInterval(() => {
  9711. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9712. clearInterval(checker);
  9713. resolve(true);
  9714. }
  9715. });
  9716. });
  9717. } catch (error) {
  9718. throwError(error, 'SweepWidget.checkEnter');
  9719. return false;
  9720. }
  9721. }
  9722. async function _checkFinish2($task) {
  9723. try {
  9724. return new Promise(resolve => {
  9725. const checker = setInterval(() => {
  9726. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9727. clearInterval(checker);
  9728. resolve(true);
  9729. }
  9730. });
  9731. });
  9732. } catch (error) {
  9733. throwError(error, 'SweepWidget.checkFinish');
  9734. return false;
  9735. }
  9736. }
  9737. const website_SweepWidget = SweepWidget;
  9738. const defaultWhiteList = {
  9739. discord: {
  9740. servers: []
  9741. },
  9742. instagram: {
  9743. users: []
  9744. },
  9745. twitch: {
  9746. channels: []
  9747. },
  9748. twitter: {
  9749. users: [],
  9750. retweets: [],
  9751. likes: []
  9752. },
  9753. vk: {
  9754. names: []
  9755. },
  9756. youtube: {
  9757. channels: [],
  9758. likes: []
  9759. },
  9760. reddit: {
  9761. reddits: []
  9762. },
  9763. steam: {
  9764. groups: [],
  9765. wishlists: [],
  9766. follows: [],
  9767. forums: [],
  9768. workshops: [],
  9769. curators: [],
  9770. workshopVotes: [],
  9771. curatorLikes: [],
  9772. announcements: [],
  9773. licenses: [],
  9774. playtests: []
  9775. }
  9776. };
  9777. const link2id = async function(type) {
  9778. 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;
  9779. try {
  9780. const link = $('#socialLink').val();
  9781. let id = '';
  9782. switch (type) {
  9783. case 'discord.servers':
  9784. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9785. break;
  9786.  
  9787. case 'instagram.users':
  9788. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9789. break;
  9790.  
  9791. case 'twitch.channels':
  9792. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9793. break;
  9794.  
  9795. case 'twitter.users':
  9796. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9797. break;
  9798.  
  9799. case 'twitter.retweets':
  9800. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9801. break;
  9802.  
  9803. case 'vk.names':
  9804. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9805. break;
  9806.  
  9807. case 'youtube.channels':
  9808. 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) || '';
  9809. break;
  9810.  
  9811. case 'youtube.likes':
  9812. 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) || '';
  9813. break;
  9814.  
  9815. case 'reddit.reddits':
  9816. 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]) || '';
  9817. break;
  9818.  
  9819. case 'steam.groups':
  9820. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9821. break;
  9822.  
  9823. case 'steam.wishlists':
  9824. case 'steam.follows':
  9825. case 'steam.forums':
  9826. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9827. break;
  9828.  
  9829. case 'steam.workshops':
  9830. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9831. break;
  9832.  
  9833. case 'steam.curators':
  9834. {
  9835. if (link.includes('curator')) {
  9836. var _link$match12;
  9837. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9838. } else {
  9839. var _link$match13;
  9840. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9841. if (!param || param.length !== 2) {
  9842. break;
  9843. }
  9844. const steam = new social_Steam();
  9845. if (await steam.init()) {
  9846. id = await steam.getCuratorId(param[0], param[1]) || '';
  9847. }
  9848. }
  9849. }
  9850. break;
  9851. }
  9852. return id;
  9853. } catch (error) {
  9854. throwError(error, 'link2id');
  9855. return i18n('getFailed', 'id');
  9856. }
  9857. };
  9858. const disabledType = {
  9859. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9860. twitter: [ 'likes' ]
  9861. };
  9862. const whiteListOptions = function(showType) {
  9863. try {
  9864. const whiteList = {
  9865. ...defaultWhiteList,
  9866. ...GM_getValue('whiteList') || {}
  9867. };
  9868. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9869. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9870. for (const [ social, types ] of Object.entries(whiteList)) {
  9871. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9872. var _disabledType$social;
  9873. 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>`;
  9874. }).join('');
  9875. }
  9876. whiteListOptionsForm += '</tbody></table></form>';
  9877. if (showType === 'swal') {
  9878. external_Swal_default().fire({
  9879. title: i18n('whiteListOptions'),
  9880. html: whiteListOptionsForm,
  9881. showConfirmButton: false,
  9882. showCloseButton: true
  9883. });
  9884. } else {
  9885. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9886. }
  9887. $('.editWhiteList').on('click', function() {
  9888. var _whiteList$social;
  9889. const value = $(this).attr('data-value');
  9890. if (!value) {
  9891. return;
  9892. }
  9893. const [ social, type ] = value.split('.');
  9894. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9895. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9896. return;
  9897. }
  9898. external_Swal_default().fire({
  9899. title: i18n('changeWhiteListOption', value),
  9900. input: 'textarea',
  9901. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9902. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9903. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9904. inputValue: whiteList[social][type].join('\n'),
  9905. showConfirmButton: true,
  9906. confirmButtonText: i18n('save'),
  9907. showCancelButton: true,
  9908. cancelButtonText: i18n('close'),
  9909. showDenyButton: true,
  9910. denyButtonText: i18n('return')
  9911. }).then(_ref => {
  9912. let {
  9913. isDenied,
  9914. isConfirmed,
  9915. value
  9916. } = _ref;
  9917. if (isDenied) {
  9918. if (showType === 'swal') {
  9919. whiteListOptions(showType);
  9920. }
  9921. return;
  9922. } else if (isConfirmed) {
  9923. whiteList[social][type] = value.split('\n');
  9924. GM_setValue('whiteList', whiteList);
  9925. external_Swal_default().fire({
  9926. title: i18n('changeWhiteListSuccess'),
  9927. icon: 'success'
  9928. });
  9929. }
  9930. });
  9931. $('#link2id').on('click', async function() {
  9932. const type = $(this).attr('data-type');
  9933. $('#socialLink').val(await link2id(type));
  9934. });
  9935. });
  9936. } catch (error) {
  9937. throwError(error, 'whiteListOptions');
  9938. }
  9939. };
  9940. const whiteList = whiteListOptions;
  9941. const setGistData = async (token, gistId, fileName, content) => {
  9942. try {
  9943. const logStatus = scripts_echoLog({
  9944. text: i18n('settingData')
  9945. });
  9946. const contentData = JSON.stringify({
  9947. files: {
  9948. [fileName]: {
  9949. content: JSON.stringify(content)
  9950. }
  9951. }
  9952. });
  9953. const {
  9954. result,
  9955. statusText,
  9956. status,
  9957. data
  9958. } = await tools_httpRequest({
  9959. url: `https://api.github.com/gists/${gistId}`,
  9960. headers: {
  9961. Accept: 'application/vnd.github.v3+json',
  9962. Authorization: `token ${token}`
  9963. },
  9964. data: contentData,
  9965. responseType: 'json',
  9966. method: 'POST',
  9967. timeout: 3e4
  9968. });
  9969. if (result === 'Success') {
  9970. var _data$response$files, _data$response$files$;
  9971. 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)) {
  9972. logStatus.success();
  9973. return true;
  9974. }
  9975. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9976. return false;
  9977. }
  9978. logStatus.error(`${result}:${statusText}(${status})`);
  9979. return false;
  9980. } catch (error) {
  9981. throwError(error, 'setGistData');
  9982. return false;
  9983. }
  9984. };
  9985. const getGistData = async function(token, gistId, fileName) {
  9986. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9987. try {
  9988. const logStatus = scripts_echoLog({
  9989. text: i18n('gettingData')
  9990. });
  9991. const {
  9992. result,
  9993. statusText,
  9994. status,
  9995. data
  9996. } = await tools_httpRequest({
  9997. url: `https://api.github.com/gists/${gistId}`,
  9998. headers: {
  9999. Accept: 'application/vnd.github.v3+json',
  10000. Authorization: `token ${token}`
  10001. },
  10002. responseType: 'json',
  10003. method: 'GET',
  10004. timeout: 3e4
  10005. });
  10006. if (result === 'Success') {
  10007. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10008. var _data$response, _data$response$files2, _data$response$files3;
  10009. 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;
  10010. let formatedContent;
  10011. if (!content) {
  10012. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10013. return false;
  10014. }
  10015. if (test) {
  10016. logStatus.success();
  10017. return true;
  10018. }
  10019. try {
  10020. formatedContent = JSON.parse(content);
  10021. } catch (error) {
  10022. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10023. return false;
  10024. }
  10025. logStatus.success();
  10026. return formatedContent;
  10027. }
  10028. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10029. return false;
  10030. }
  10031. logStatus.error(`${result}:${statusText}(${status})`);
  10032. return false;
  10033. } catch (error) {
  10034. throwError(error, 'getGistData');
  10035. return false;
  10036. }
  10037. };
  10038. const syncOptions = () => {
  10039. try {
  10040. const {
  10041. TOKEN,
  10042. GIST_ID,
  10043. FILE_NAME,
  10044. SYNC_HISTORY
  10045. } = GM_getValue('gistOptions') || {
  10046. TOKEN: '',
  10047. GIST_ID: '',
  10048. FILE_NAME: '',
  10049. SYNC_HISTORY: true
  10050. };
  10051. external_Swal_default().fire({
  10052. title: i18n('gistOptions'),
  10053. 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;">
  10054. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10055. ${i18n('downloadFromGist')}</button></p>`,
  10056. focusConfirm: false,
  10057. showLoaderOnConfirm: true,
  10058. 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>`,
  10059. preConfirm: async () => {
  10060. const token = $('#github-token').val();
  10061. const gistId = $('#gist-id').val();
  10062. const fileName = $('#file-name').val();
  10063. const syncHistory = $('#sync-history').prop('checked');
  10064. GM_setValue('gistOptions', {
  10065. TOKEN: token,
  10066. GIST_ID: gistId,
  10067. FILE_NAME: fileName,
  10068. SYNC_HISTORY: syncHistory
  10069. });
  10070. return await getGistData(token, gistId, fileName, true);
  10071. },
  10072. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10073. confirmButtonText: i18n('saveAndTest'),
  10074. showCancelButton: true,
  10075. cancelButtonText: i18n('close')
  10076. }).then(_ref => {
  10077. let {
  10078. value
  10079. } = _ref;
  10080. if (value) {
  10081. external_Swal_default().fire({
  10082. icon: 'success',
  10083. title: i18n('testSuccess')
  10084. }).then(syncOptions);
  10085. } else if (value !== undefined) {
  10086. external_Swal_default().fire({
  10087. icon: 'error',
  10088. title: i18n('testFailed')
  10089. }).then(syncOptions);
  10090. }
  10091. });
  10092. $('#upload-data').on('click', async () => {
  10093. const {
  10094. TOKEN,
  10095. GIST_ID,
  10096. FILE_NAME
  10097. } = GM_getValue('gistOptions') || {};
  10098. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10099. return external_Swal_default().fire({
  10100. icon: 'error',
  10101. title: i18n('saveAndTestNotice')
  10102. }).then(syncOptions);
  10103. }
  10104. external_Swal_default().fire({
  10105. icon: 'info',
  10106. title: i18n('processingData')
  10107. });
  10108. const data = {};
  10109. const names = GM_listValues();
  10110. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10111. for (const name of names) {
  10112. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10113. continue;
  10114. }
  10115. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10116. continue;
  10117. }
  10118. data[name] = GM_getValue(name);
  10119. }
  10120. external_Swal_default().update({
  10121. icon: 'info',
  10122. title: i18n('updatingData')
  10123. });
  10124. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10125. external_Swal_default().fire({
  10126. icon: 'success',
  10127. title: i18n('syncDataSuccess')
  10128. });
  10129. } else {
  10130. external_Swal_default().fire({
  10131. icon: 'error',
  10132. title: i18n('syncDataFailed')
  10133. });
  10134. }
  10135. });
  10136. $('#download-data').on('click', async () => {
  10137. const {
  10138. TOKEN,
  10139. GIST_ID,
  10140. FILE_NAME
  10141. } = GM_getValue('gistOptions') || {};
  10142. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10143. return external_Swal_default().fire({
  10144. icon: 'error',
  10145. title: i18n('saveAndTestNotice')
  10146. }).then(syncOptions);
  10147. }
  10148. external_Swal_default().fire({
  10149. icon: 'info',
  10150. title: i18n('downloadingData')
  10151. });
  10152. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10153. if (!data) {
  10154. return external_Swal_default().fire({
  10155. icon: 'error',
  10156. title: i18n('checkedNoData')
  10157. }).then(syncOptions);
  10158. }
  10159. external_Swal_default().update({
  10160. icon: 'info',
  10161. title: i18n('savingData')
  10162. });
  10163. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10164. for (const [ name, value ] of Object.entries(data)) {
  10165. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10166. continue;
  10167. }
  10168. GM_setValue(name, value);
  10169. }
  10170. external_Swal_default().fire({
  10171. icon: 'success',
  10172. title: i18n('syncDataSuccess')
  10173. });
  10174. });
  10175. } catch (error) {
  10176. throwError(error, 'syncOptions');
  10177. }
  10178. };
  10179. const dataSync = syncOptions;
  10180. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10181. Setting_checkPrivateRedeclaration(obj, privateSet);
  10182. privateSet.add(obj);
  10183. }
  10184. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10185. if (privateCollection.has(obj)) {
  10186. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10187. }
  10188. }
  10189. function Setting_defineProperty(obj, key, value) {
  10190. if (key in obj) {
  10191. Object.defineProperty(obj, key, {
  10192. value: value,
  10193. enumerable: true,
  10194. configurable: true,
  10195. writable: true
  10196. });
  10197. } else {
  10198. obj[key] = value;
  10199. }
  10200. return obj;
  10201. }
  10202. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10203. if (!privateSet.has(receiver)) {
  10204. throw new TypeError('attempted to get private field on non-instance');
  10205. }
  10206. return fn;
  10207. }
  10208. var Setting_getId = new WeakSet();
  10209. var _environment = new WeakSet();
  10210. class Setting {
  10211. constructor() {
  10212. Setting_classPrivateMethodInitSpec(this, _environment);
  10213. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10214. Setting_defineProperty(this, 'name', 'Setting');
  10215. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10216. Setting_defineProperty(this, 'syncData', dataSync);
  10217. }
  10218. tasksHistory() {
  10219. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10220. }
  10221. static test() {
  10222. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10223. }
  10224. before() {
  10225. $('body').html('').addClass('auto-task-options');
  10226. }
  10227. after() {
  10228. try {
  10229. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10230. changeGlobalOptions('page');
  10231. whiteList('page');
  10232. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10233. $('#getTwitterUserId').on('click', () => {
  10234. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10235. });
  10236. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10237. $('#getYoutubeChannelId').on('click', () => {
  10238. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10239. });
  10240. $('input[name^="position"]').on('input', function() {
  10241. const type = $(this).attr('name').replace('position.', '');
  10242. const xLabel = 'rightleft';
  10243. const yLabel = 'topbottpm';
  10244. switch (type) {
  10245. case 'buttonSideX':
  10246. case 'buttonSideY':
  10247. case 'buttonDistance':
  10248. {
  10249. const distance = $('input[name="position.buttonDistance"]').val();
  10250. const sideX = $('input[name="position.buttonSideX"]').val();
  10251. const sideY = $('input[name="position.buttonSideY"]').val();
  10252. if (![ 'right', 'left' ].includes(sideX)) {
  10253. break;
  10254. }
  10255. if (![ 'top', 'bottom' ].includes(sideY)) {
  10256. break;
  10257. }
  10258. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10259. break;
  10260. }
  10261. const distanceArr = distance.split(',');
  10262. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10263. break;
  10264. }
  10265.  
  10266. case 'showButtonSideX':
  10267. case 'showButtonSideY':
  10268. case 'showButtonDistance':
  10269. {
  10270. const distance = $('input[name="position.showButtonDistance"]').val();
  10271. const sideX = $('input[name="position.showButtonSideX"]').val();
  10272. const sideY = $('input[name="position.showButtonSideY"]').val();
  10273. if (![ 'right', 'left' ].includes(sideX)) {
  10274. break;
  10275. }
  10276. if (![ 'top', 'bottom' ].includes(sideY)) {
  10277. break;
  10278. }
  10279. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10280. break;
  10281. }
  10282. const distanceArr = distance.split(',');
  10283. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10284. break;
  10285. }
  10286.  
  10287. case 'logSideX':
  10288. case 'logSideY':
  10289. case 'logDistance':
  10290. {
  10291. const distance = $('input[name="position.logDistance"]').val();
  10292. const sideX = $('input[name="position.logSideX"]').val();
  10293. const sideY = $('input[name="position.logSideY"]').val();
  10294. if (![ 'right', 'left' ].includes(sideX)) {
  10295. break;
  10296. }
  10297. if (![ 'top', 'bottom' ].includes(sideY)) {
  10298. break;
  10299. }
  10300. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10301. break;
  10302. }
  10303. const distanceArr = distance.split(',');
  10304. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10305. break;
  10306. }
  10307.  
  10308. default:
  10309. break;
  10310. }
  10311. });
  10312. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10313. let functionKey = '';
  10314. if (event.altKey) {
  10315. functionKey += 'alt + ';
  10316. } else if (event.ctrlKey) {
  10317. functionKey += 'ctrl + ';
  10318. } else if (event.shiftKey) {
  10319. functionKey += 'shift + ';
  10320. }
  10321. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10322. });
  10323. } catch (error) {
  10324. throwError(error, 'Setting.after');
  10325. }
  10326. }
  10327. saveGlobalOptions() {
  10328. saveData();
  10329. }
  10330. }
  10331. function Setting_getId2(social) {
  10332. try {
  10333. external_Swal_default().fire({
  10334. title: i18n('getId', i18n(social)),
  10335. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10336. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10337. showCancelButton: true,
  10338. cancelButtonText: i18n('close'),
  10339. showConfirmButton: false
  10340. });
  10341. $('#link2id').on('click', async function() {
  10342. const link = $('#socialLink').val();
  10343. if (!link) {
  10344. return;
  10345. }
  10346. const type = $(this).attr('data-type');
  10347. if (type === 'twitterUser') {
  10348. var _link$match;
  10349. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10350. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10351. } else if (type === 'youtubeChannel') {
  10352. var _link$match2, _await$getInfo, _await$getInfo$params;
  10353. 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;
  10354. $('#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) || '');
  10355. }
  10356. });
  10357. } catch (error) {
  10358. throwError(error, 'Setting.getId');
  10359. }
  10360. }
  10361. function _environment2() {
  10362. try {
  10363. const userAgent = (0, javascript_utils_umd_min.ua)();
  10364. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10365. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10366. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10367. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10368. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10369. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10370. </tbody></table></form>`;
  10371. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10372. } catch (error) {
  10373. throwError(error, 'Setting.environment');
  10374. }
  10375. }
  10376. const website_Setting = Setting;
  10377. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10378. History_checkPrivateRedeclaration(obj, privateSet);
  10379. privateSet.add(obj);
  10380. }
  10381. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10382. if (privateCollection.has(obj)) {
  10383. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10384. }
  10385. }
  10386. function History_defineProperty(obj, key, value) {
  10387. if (key in obj) {
  10388. Object.defineProperty(obj, key, {
  10389. value: value,
  10390. enumerable: true,
  10391. configurable: true,
  10392. writable: true
  10393. });
  10394. } else {
  10395. obj[key] = value;
  10396. }
  10397. return obj;
  10398. }
  10399. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10400. if (!privateSet.has(receiver)) {
  10401. throw new TypeError('attempted to get private field on non-instance');
  10402. }
  10403. return fn;
  10404. }
  10405. var _addItem = new WeakSet();
  10406. class History extends website_Keylol {
  10407. constructor() {
  10408. super(...arguments);
  10409. History_classPrivateMethodInitSpec(this, _addItem);
  10410. History_defineProperty(this, 'name', 'History');
  10411. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10412. }
  10413. static test() {
  10414. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10415. }
  10416. before() {
  10417. try {
  10418. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10419. const data = GM_listValues() || [];
  10420. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10421. for (const item of tasksHistory) {
  10422. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10423. }
  10424. } catch (error) {
  10425. throwError(error, 'History.before');
  10426. }
  10427. }
  10428. clearHistory() {
  10429. try {
  10430. const data = GM_listValues() || [];
  10431. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10432. for (const item of tasksHistory) {
  10433. GM_deleteValue(item);
  10434. }
  10435. external_Swal_default().fire({
  10436. title: i18n('clearHistoryFinished'),
  10437. icon: 'success'
  10438. });
  10439. } catch (error) {
  10440. throwError(error, 'History.after');
  10441. }
  10442. }
  10443. }
  10444. function _addItem2(item) {
  10445. try {
  10446. const tasksData = GM_getValue(item);
  10447. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10448. return;
  10449. }
  10450. let html = '';
  10451. let title = '';
  10452. let link = '';
  10453. const [ website, id ] = item.split('-');
  10454. switch (website) {
  10455. case 'fawTasks':
  10456. title = `Freeanywhere[${id}]`;
  10457. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10458. break;
  10459.  
  10460. case 'gasTasks':
  10461. title = `Giveawaysu[${id}]`;
  10462. link = `https://giveaway.su/giveaway/view/${id}`;
  10463. break;
  10464.  
  10465. case 'gcTasks':
  10466. title = `GiveeClub[${id}]`;
  10467. link = `https://givee.club/event/${id}`;
  10468. break;
  10469.  
  10470. case 'gkTasks':
  10471. title = `Givekey[${id}]`;
  10472. link = `https://givekey.ru/giveaway/${id}`;
  10473. break;
  10474.  
  10475. case 'gleamTasks':
  10476. title = `Gleam[${id}]`;
  10477. link = `https://gleam.io${id}`;
  10478. break;
  10479.  
  10480. case 'khTasks':
  10481. title = `keyhub[${id}]`;
  10482. link = `https://key-hub.eu/giveaway/${id}`;
  10483. break;
  10484.  
  10485. case 'prysTasks':
  10486. title = `Prys[${id}]`;
  10487. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10488. break;
  10489.  
  10490. default:
  10491. return;
  10492. }
  10493. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10494. for (const [ type, tasks ] of Object.entries(types)) {
  10495. for (const task of tasks) {
  10496. 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>`;
  10497. }
  10498. }
  10499. }
  10500. $('.container').append(`<div class="card"><div class="title"><a href="${link}" target="_blank">${title}</a><span class="delete-task" data-name="${item}" title="${i18n('deleteTask')}"><svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2734" width="32" height="32"><path d="M607.897867 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L575.903242 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 351.94087C639.892491 753.593818 625.61532 768.043004 607.897867 768.043004z" p-id="2735" fill="#d81e06"></path><path d="M415.930119 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L383.935495 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625 17.717453 0 31.994625 14.277171 31.994625 31.994625l0 351.94087C447.924744 753.593818 433.647573 768.043004 415.930119 768.043004z" p-id="2736" fill="#d81e06"></path><path d="M928.016126 223.962372l-159.973123 0L768.043004 159.973123c0-52.980346-42.659499-95.983874-95.295817-95.983874L351.94087 63.989249c-52.980346 0-95.983874 43.003528-95.983874 95.983874l0 63.989249-159.973123 0c-17.717453 0-31.994625 14.277171-31.994625 31.994625s14.277171 31.994625 31.994625 31.994625l832.032253 0c17.717453 0 31.994625-14.277171 31.994625-31.994625S945.73358 223.962372 928.016126 223.962372zM319.946246 159.973123c0-17.545439 14.449185-31.994625 31.994625-31.994625l320.806316 0c17.545439 0 31.306568 14.105157 31.306568 31.994625l0 63.989249L319.946246 223.962372 319.946246 159.973123 319.946246 159.973123z" p-id="2737" fill="#d81e06"></path><path d="M736.048379 960.010751 288.123635 960.010751c-52.980346 0-95.983874-43.003528-95.983874-95.983874L192.139761 383.591466c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 480.435411c0 17.717453 14.449185 31.994625 31.994625 31.994625l448.096758 0c17.717453 0 31.994625-14.277171 31.994625-31.994625L768.215018 384.795565c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 479.231312C832.032253 916.835209 789.028725 960.010751 736.048379 960.010751z" p-id="2738" fill="#d81e06"></path></svg></span></div><ul>${html}</ul><span class="time">${i18n('lastChangeTime')}: ${external_dayjs_namespaceObject(tasksData.time).format('YYYY-MM-DD HH:mm:ss')}</span></div>`);
  10501. $('span.delete-task').on('click', function() {
  10502. const itemName = $(this).attr('data-name');
  10503. if (itemName) {
  10504. GM_deleteValue(itemName);
  10505. external_Swal_default().fire({
  10506. title: i18n('clearTaskFinished'),
  10507. text: itemName,
  10508. icon: 'success'
  10509. });
  10510. } else {
  10511. external_Swal_default().fire({
  10512. title: i18n('clearTaskFailed'),
  10513. icon: 'error'
  10514. });
  10515. }
  10516. });
  10517. } catch (error) {
  10518. throwError(error, 'History.addItem');
  10519. }
  10520. }
  10521. const website_History = History;
  10522. 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 ];
  10523. const websiteOptions = function(website, options) {
  10524. try {
  10525. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10526. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10527. for (const [ option, value ] of Object.entries(options)) {
  10528. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10529. }
  10530. websiteOptionsForm += '</tbody></table></form>';
  10531. external_Swal_default().fire({
  10532. title: i18n('websiteOptions'),
  10533. html: websiteOptionsForm,
  10534. showConfirmButton: true,
  10535. confirmButtonText: i18n('save'),
  10536. showCancelButton: true,
  10537. cancelButtonText: i18n('close')
  10538. }).then(_ref => {
  10539. let {
  10540. isConfirmed
  10541. } = _ref;
  10542. if (isConfirmed) {
  10543. $('#websiteOptionsForm').serializeArray().map(value => {
  10544. options[value.name] = value.value;
  10545. return value;
  10546. });
  10547. GM_setValue(`${website}Options`, options);
  10548. external_Swal_default().fire({
  10549. title: i18n('changeWebsiteOptionsSuccess'),
  10550. icon: 'success'
  10551. });
  10552. }
  10553. });
  10554. } catch (error) {
  10555. throwError(error, 'websiteOptions');
  10556. }
  10557. };
  10558. const options = websiteOptions;
  10559. const external_keyboardJS_namespaceObject = keyboardJS;
  10560. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10561. const checkUpdate = async (updateLink, auto) => {
  10562. try {
  10563. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10564. const {
  10565. result,
  10566. statusText,
  10567. status,
  10568. data
  10569. } = await tools_httpRequest({
  10570. url: checkUrl,
  10571. responseType: 'json',
  10572. method: 'GET',
  10573. timeout: 3e4
  10574. });
  10575. if (result === 'Success') {
  10576. var _data$response;
  10577. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10578. return data.response;
  10579. }
  10580. if (!auto) {
  10581. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10582. }
  10583. return false;
  10584. }
  10585. if (!auto) {
  10586. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10587. }
  10588. return false;
  10589. } catch (error) {
  10590. throwError(error, 'checkUpdate');
  10591. return false;
  10592. }
  10593. };
  10594. const hasNewVersion = (currentVersion, remoteVersion) => {
  10595. try {
  10596. const [ currentRealVersion ] = currentVersion.split('-');
  10597. const [ remoteRealVersion ] = remoteVersion.split('-');
  10598. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10599. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10600. if (remoteVersion1 > currentVersion1) {
  10601. return true;
  10602. }
  10603. if (remoteVersion1 < currentVersion1) {
  10604. return false;
  10605. }
  10606. if (remoteVersion2 > currentVersion2) {
  10607. return true;
  10608. }
  10609. if (remoteVersion2 < currentVersion2) {
  10610. return false;
  10611. }
  10612. if (remoteVersion3 > currentVersion3) {
  10613. return true;
  10614. }
  10615. return false;
  10616. } catch (error) {
  10617. throwError(error, 'compareVersion');
  10618. return false;
  10619. }
  10620. };
  10621. const updateChecker = async () => {
  10622. try {
  10623. const currentVersion = GM_info.script.version;
  10624. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10625. const updateLinks = {
  10626. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10627. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10628. standby: 'https://auto-task-v4.hclonely.com/'
  10629. };
  10630. let version;
  10631. let updateLink = '';
  10632. let packageData;
  10633. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10634. updateLink = updateLinks[updateSource];
  10635. packageData = await checkUpdate(updateLink, false);
  10636. } else {
  10637. updateLink = updateLinks.github;
  10638. packageData = await checkUpdate(updateLink, true);
  10639. if (!packageData) {
  10640. updateLink = updateLinks.jsdelivr;
  10641. packageData = await checkUpdate(updateLink, true);
  10642. if (!packageData) {
  10643. updateLink = updateLinks.standby;
  10644. packageData = await checkUpdate(updateLink, true);
  10645. }
  10646. }
  10647. }
  10648. if (packageData) {
  10649. version = packageData.version || currentVersion;
  10650. } else {
  10651. version = currentVersion;
  10652. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10653. }
  10654. if (packageData && hasNewVersion(currentVersion, version)) {
  10655. var _packageData$change;
  10656. scripts_echoLog({
  10657. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10658. });
  10659. scripts_echoLog({
  10660. html: `<li>${i18n('updateText', version)}</li><ol class="update-text">${(_packageData$change = packageData.change) === null || _packageData$change === void 0 ? void 0 : _packageData$change.map(change => `<li>${change}</li>`).join('')}</ol>`
  10661. });
  10662. }
  10663. } catch (error) {
  10664. throwError(error, 'updateChecker');
  10665. }
  10666. };
  10667. const scripts_updateChecker = updateChecker;
  10668. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  10669. if (window.location.hostname === 'discord.com') {
  10670. const LocalStorage = window.localStorage;
  10671. if (window.location.hash === '#auth') {
  10672. var _LocalStorage$getItem;
  10673. window.localStorage.removeItem = () => true;
  10674. 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, '');
  10675. if (discordAuth && /^mfa\./.test(discordAuth)) {
  10676. GM_setValue('discordAuth', {
  10677. auth: discordAuth
  10678. });
  10679. window.close();
  10680. external_Swal_default().fire('', i18n('closePageNotice'));
  10681. } else {
  10682. external_Swal_default().fire({
  10683. text: i18n('getDiscordAuthFailed'),
  10684. icon: 'error'
  10685. });
  10686. }
  10687. } else {
  10688. var _LocalStorage$getItem2;
  10689. 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, '');
  10690. if (discordAuth && /^mfa\./.test(discordAuth)) {
  10691. GM_setValue('discordAuth', {
  10692. auth: discordAuth
  10693. });
  10694. }
  10695. }
  10696. }
  10697. const loadScript = async () => {
  10698. var _website, _website2, _website3, _website4, _website5, _website6;
  10699. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10700. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10701. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10702. if (isLogin) {
  10703. var _commonOptions, _commonOptions$header;
  10704. GM_setValue('twitchAuth', {
  10705. authToken: authToken,
  10706. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10707. });
  10708. window.close();
  10709. external_Swal_default().fire('', i18n('closePageNotice'));
  10710. } else {
  10711. external_Swal_default().fire('', i18n('needLogin'));
  10712. }
  10713. }
  10714. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10715. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10716. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10717. if (isLogin && ct0) {
  10718. GM_setValue('twitterAuth', {
  10719. ct0: ct0
  10720. });
  10721. window.close();
  10722. external_Swal_default().fire('', i18n('closePageNotice'));
  10723. } else {
  10724. external_Swal_default().fire('', i18n('needLogin'));
  10725. }
  10726. }
  10727. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10728. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10729. if (PAPISID) {
  10730. GM_setValue('youtubeAuth', {
  10731. PAPISID: PAPISID
  10732. });
  10733. window.close();
  10734. external_Swal_default().fire('', i18n('closePageNotice'));
  10735. } else {
  10736. external_Swal_default().fire('', i18n('needLogin'));
  10737. }
  10738. }
  10739. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10740. const betaButton = $('#redesign-beta-optin-btn');
  10741. if (betaButton.length > 0) {
  10742. GM_setValue('redditAuth', '#auth');
  10743. return betaButton[0].click();
  10744. }
  10745. GM_setValue('redditAuth', null);
  10746. window.close();
  10747. external_Swal_default().fire('', i18n('closePageNotice'));
  10748. }
  10749. let website;
  10750. for (const Website of Websites) {
  10751. if (Website.test()) {
  10752. website = new Website();
  10753. break;
  10754. }
  10755. }
  10756. if (!website) {
  10757. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10758. return;
  10759. }
  10760. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10761. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10762. }
  10763. $('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>`);
  10764. $('div.show-button-div').on('click', () => {
  10765. $('#auto-task-buttons').show();
  10766. $('div.show-button-div').hide();
  10767. });
  10768. const toggleLog = () => {
  10769. const $this = $('#toggle-log');
  10770. const status = $this.attr('data-status');
  10771. if (status === 'show') {
  10772. $('#auto-task-info').hide();
  10773. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10774. } else {
  10775. $('#auto-task-info').show();
  10776. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10777. }
  10778. };
  10779. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10780. if (website.doTask) {
  10781. website.doTask();
  10782. }
  10783. });
  10784. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10785. if (website.undoTask) {
  10786. website.doTask();
  10787. }
  10788. });
  10789. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10790. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10791. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10792. }
  10793. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10794. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10795. for (const button of website.buttons) {
  10796. if (website[button]) {
  10797. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10798. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10799. website[button]();
  10800. });
  10801. $('#auto-task-buttons').append(btnElement);
  10802. }
  10803. }
  10804. }
  10805. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10806. ${i18n('hideButton')}</a></p>`);
  10807. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10808. $('#auto-task-buttons').hide();
  10809. $('div.show-button-div').show();
  10810. });
  10811. 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'}">
  10812. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10813. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10814. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10815. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10816. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10817. options(website.name, website.options);
  10818. });
  10819. }
  10820. if (website.name !== 'Setting') {
  10821. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10822. changeGlobalOptions('swal');
  10823. });
  10824. GM_registerMenuCommand(i18n('settingPage'), () => {
  10825. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10826. });
  10827. }
  10828. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10829. if (!GM_getValue('notice')) {
  10830. var _echoLog$font;
  10831. external_Swal_default().fire({
  10832. title: i18n('swalNotice'),
  10833. icon: 'warning'
  10834. }).then(() => {
  10835. window.open(i18n('noticeLink'), '_blank');
  10836. GM_setValue('notice', new Date().getTime());
  10837. });
  10838. (_echoLog$font = scripts_echoLog({
  10839. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10840. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10841. GM_setValue('notice', new Date().getTime());
  10842. });
  10843. }
  10844. scripts_updateChecker();
  10845. };
  10846. if (window.location.hostname === 'opquests.com') {
  10847. loadScript();
  10848. } else {
  10849. $(loadScript);
  10850. }
  10851. }();
  10852. })();