auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.18-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. groups: '组',
  1288. wishlists: '愿望单',
  1289. follows: '游戏关注',
  1290. forums: '论坛',
  1291. workshops: '创意工坊收藏',
  1292. curators: '鉴赏家',
  1293. workshopVotes: '创意工坊点赞',
  1294. announcements: '社区通知',
  1295. steamCommunity: 'Steam社区',
  1296. steamStore: 'Steam商店',
  1297. licenses: '入库免费游戏',
  1298. playtests: '请求访问权限',
  1299. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1300. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1301. joiningSteamGroup: '正在加入Steam组',
  1302. leavingSteamGroup: '正在退出Steam组',
  1303. gettingSteamGroupId: '正在获取Steam组Id',
  1304. subscribingForum: '正在订阅Steam论坛',
  1305. unsubscribingForum: '正在取消订阅Steam论坛',
  1306. gettingForumId: '正在获取Steam论坛Id',
  1307. followingCurator: '正在关注Steam鉴赏家',
  1308. unfollowingCurator: '正在取关Steam鉴赏家',
  1309. addingToWishlist: '正在添加游戏到Steam愿望单',
  1310. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1311. followingGame: '正在关注Steam游戏',
  1312. unfollowingGame: '正在取关Steam游戏',
  1313. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1314. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1315. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1316. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1317. gettingAnnouncementParams: '正在获取Steam通知信息',
  1318. likingAnnouncement: '正在点赞Steam通知',
  1319. changingArea: '正在更换Steam地区: %0...',
  1320. notNeededChangeArea: '当前地区不需要更换',
  1321. noAnotherArea: '请检测是否开启正确开启代理',
  1322. gettingAreaInfo: '正在获取Steam地区信息...',
  1323. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1324. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1325. gettingSubid: '正在获取游戏subid',
  1326. addingFreeLicense: '正在入库',
  1327. missParams: '缺少参数',
  1328. gettingLicenses: '正在获取Licenses...',
  1329. requestingPlayTestAccess: '正在请求访问权限',
  1330. servers: '服务器',
  1331. joiningDiscordServer: '正在加入Discord服务器',
  1332. leavingDiscordServer: '正在退出Discord服务器',
  1333. gettingDiscordGuild: '正在获取Discord服务器Id',
  1334. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1335. users: '用户',
  1336. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1337. insBanned: '您的Instagram账户已被封禁',
  1338. verifyingInsAuth: '正在验证Instagram凭证...',
  1339. gettingInsUserId: '正在获取Instagram用户Id',
  1340. followingIns: '正在关注Instagram用户',
  1341. unfollowingIns: '正在取关Instagram用户',
  1342. reddits: '社区/用户',
  1343. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1344. changingRedditVersion: '正在切换Reddit为新版页面...',
  1345. joiningReddit: '正在加入Reddit社区',
  1346. leavingReddit: '正在退出Reddit社区',
  1347. followingRedditUser: '正在关注Reddit用户',
  1348. unfollowingRedditUser: '正在取关Reddit用户',
  1349. channels: '频道',
  1350. followingTwitchChannel: '正在关注Twitch频道',
  1351. unfollowingTwitchChannel: '正在取关Twitch频道',
  1352. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1353. twitterUser: '推特用户',
  1354. retweets: '转推',
  1355. followingTwitterUser: '正在关注推特用户',
  1356. unfollowingTwitterUser: '正在取关推特用户',
  1357. retweetting: '正在转推',
  1358. unretweetting: '正在撤销转推',
  1359. names: '组/社区/动态',
  1360. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1361. gettingVkId: '正在获取Vk任务Id',
  1362. joiningVkGroup: '正在加入Vk组',
  1363. leavingVkGroup: '正在退出Vk组',
  1364. joiningVkPublic: '正在加入Vk社区',
  1365. leavingVkPublic: '正在退出Vk社区',
  1366. sendingVkWall: '正在转发Vk动态',
  1367. deletingVkWall: '正在撤销转发Vk动态',
  1368. youtubeChannel: 'YouTube频道',
  1369. likes: '点赞',
  1370. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1371. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1372. gettingYtbToken: '正在获取YouTube Token...',
  1373. followingYtbChannel: '正在订阅YouTube频道',
  1374. unfollowingYtbChannel: '正在退订YouTube频道',
  1375. likingYtbVideo: '正在点赞YouTube视频',
  1376. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1377. giveKeyNoticeBefore: '每次验证间隔15s',
  1378. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1379. noPoints: '点数不够,跳过抽奖',
  1380. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1381. joiningLottery: '正在加入抽奖',
  1382. doingGleamTask: '正在做Gleam任务...',
  1383. gettingGleamLink: '正在获取Gleam任务链接...',
  1384. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1385. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1386. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1387. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1388. };
  1389. const zh_CN = data;
  1390. const en_US_data = {
  1391. website: 'Website',
  1392. type: 'Type',
  1393. edit: 'Edit',
  1394. whiteList: 'Whitelist',
  1395. skipTask: 'Skip undo task',
  1396. whiteListOptions: 'Whitelist options',
  1397. changeWhiteListOption: 'Whitelist option(%0)',
  1398. whiteListNotFound: 'Cannot find this whitelist: %0',
  1399. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1400. changeWebsiteOptions: 'Website options',
  1401. changeGlobalOptions: 'Global options',
  1402. ok: 'OK',
  1403. save: 'Save',
  1404. close: 'Close',
  1405. return: 'Return',
  1406. option: 'Option',
  1407. value: 'Value',
  1408. websiteOptions: 'Current website settings',
  1409. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1410. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1411. needLogin: 'Please log in first!',
  1412. getTasksInfo: 'Obtaining and processing task information...',
  1413. gettingKey: 'Getting Key...',
  1414. verifyingTask: 'Verifying task',
  1415. notice: 'Automatic task script notice',
  1416. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1417. giveawayEnded: 'This event has ended, do you want to close it?',
  1418. 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?',
  1419. confirm: 'Confirm',
  1420. cancel: 'Cancel',
  1421. unKnown: 'Unknown',
  1422. unKnownTaskType: 'Unrecognized task',
  1423. doing: 'Doing a task',
  1424. allTasksComplete: 'All tasks have been completed!',
  1425. getTaskIdFailed: 'Failed to obtain task Id!',
  1426. initSuccess: '%0 was initialized successfully!',
  1427. initFailed: '%0 initialization failed!',
  1428. errorLink: 'Link error: %0',
  1429. needInit: 'Please initialize first',
  1430. verifyingAuth: 'Verifying %0 token...',
  1431. updatingAuth: 'Update %0 token...',
  1432. initing: 'Initializing...',
  1433. getFailed: 'Failed to get %0!',
  1434. checkLoginFailed: 'Failed to detect login status!',
  1435. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1436. userId: 'User Id',
  1437. joiningGiveaway: 'Joining giveaway',
  1438. needJoinGiveaway: 'Need to join the giveaway first',
  1439. cannotUndo: 'This website does not support canceling tasks',
  1440. verifyAuth: 'Verifying %0 token...',
  1441. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1442. errorReport: 'A script error is detected, do you want to report the BUG?',
  1443. visitingLink: 'Visiting link: ',
  1444. doTask: 'DoTask',
  1445. undoTask: 'UndoTask',
  1446. verifyTask: 'Verify',
  1447. getKey: 'GetKey',
  1448. selectAll: 'SelectAll',
  1449. selectNone: 'SelectNone',
  1450. invertSelect: 'InvertSelect',
  1451. doFreeTask: 'FreeTask',
  1452. doPointTask: 'PointTask',
  1453. skipTaskOption: 'Skip task has been configured in the settings',
  1454. other: 'Other',
  1455. globalOptions: 'Global Options',
  1456. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1457. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1458. 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.',
  1459. 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.',
  1460. 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.',
  1461. saveGlobalOptions: 'SaveSettings',
  1462. settingPage: 'Setting Page',
  1463. name: 'Name',
  1464. version: 'Version',
  1465. scriptManager: 'Script Manager',
  1466. script: 'Script',
  1467. environment: 'Environment',
  1468. os: 'OS',
  1469. browser: 'Browser',
  1470. getId: 'Get %0 id',
  1471. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1472. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1473. showButton: 'ShowButton',
  1474. hideButton: 'HideButton',
  1475. showLog: 'ShowLog',
  1476. hideLog: 'HideLog',
  1477. defaultShowButton: 'Default display button',
  1478. defaultShowLog: 'Display log by default',
  1479. position: 'Component position',
  1480. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1481. 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',
  1482. 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',
  1483. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1484. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1485. 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',
  1486. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1487. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1488. 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',
  1489. hotKey: 'Shortcut key',
  1490. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1491. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1492. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1493. tasksHistory: 'TasksHistory',
  1494. clearHistory: 'Clear history',
  1495. clearHistoryFinished: 'The mission history has been cleared!',
  1496. deleteTask: 'Delete task',
  1497. lastChangeTime: 'Last Change Time',
  1498. clearTaskFinished: 'Delete the following tasks completed!',
  1499. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1500. syncData: 'DataSync',
  1501. settingData: 'Uploading data...',
  1502. gettingData: 'Getting data...',
  1503. help: 'Help',
  1504. fileName: 'Filename',
  1505. upload2gist: 'Sync to Gist',
  1506. downloadFromGist: 'Sync from Gist',
  1507. saveAndTest: 'Save configuration and test',
  1508. testSuccess: 'Test success!',
  1509. testFailed: 'Test failed!',
  1510. saveAndTestNotice: 'Please save the configuration and test first!',
  1511. processingData: 'Processing data...',
  1512. updatingData: 'Uploading data...',
  1513. syncDataSuccess: 'Synchronized data successfully!',
  1514. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1515. downloadingData: 'Downloading data...',
  1516. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1517. savingData: 'Saving data...',
  1518. syncHistory: 'Synchronize tasks history',
  1519. checkUpdateFailed: 'Check update failed',
  1520. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1521. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1522. gistOptions: 'Gist Settings',
  1523. 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!',
  1524. 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!',
  1525. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1526. toGithub: 'Feedback(Github)',
  1527. toKeylol: 'Feedback(Keylol)',
  1528. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1529. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1530. updateText: 'Updates in version %0:',
  1531. Active: 'Active',
  1532. Ended: 'Ended',
  1533. Banned: 'Banned',
  1534. Paused: 'Paused',
  1535. notStart: 'notStart',
  1536. groups: 'Group',
  1537. wishlists: 'Wishlist',
  1538. follows: 'Follow Game',
  1539. forums: 'Forum',
  1540. workshops: 'Favorite Workshop',
  1541. curators: 'Curator',
  1542. workshopVotes: 'Voteup Workshop',
  1543. announcements: 'Announcement',
  1544. steamCommunity: 'Steam Community',
  1545. steamStore: 'Steam Store',
  1546. licenses: 'Add License',
  1547. playtests: 'Playtest Access',
  1548. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1549. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1550. joiningSteamGroup: 'Joining Steam Group',
  1551. leavingSteamGroup: 'Leaving Steam Group',
  1552. gettingSteamGroupId: 'Getting Steam Group Id',
  1553. subscribingForum: 'Subscribing the Steam Forum',
  1554. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1555. gettingForumId: 'Getting Steam Forum Id',
  1556. followingCurator: 'Following Steam Curator',
  1557. unfollowingCurator: 'Unfollowing Steam Curator',
  1558. addingToWishlist: 'Adding the game to the Steam wishlist',
  1559. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1560. followingGame: 'Following Steam games',
  1561. unfollowingGame: 'Unfollowing Steam games',
  1562. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1563. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1564. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1565. votingUpWorkshop: 'Liking Steam workshop items',
  1566. gettingAnnouncementParams: 'Getting Steam announcement information',
  1567. likingAnnouncement: 'Liking Steam announcement',
  1568. changingArea: 'Changing Steam area: %0...',
  1569. notNeededChangeArea: 'The current area does not need to be changed',
  1570. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1571. gettingAreaInfo: 'Getting Steam area information...',
  1572. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1573. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1574. gettingSubid: 'Getting subid',
  1575. addingFreeLicense: 'Adding free license',
  1576. missParams: 'Missing parameters',
  1577. gettingLicenses: 'Getting licenses...',
  1578. requestingPlayTestAccess: 'Requesting play test access',
  1579. servers: 'Server',
  1580. joiningDiscordServer: 'Joining Discord Server',
  1581. leavingDiscordServer: 'Leaving Discord Server',
  1582. gettingDiscordGuild: 'Getting Discord server Id',
  1583. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1584. users: 'User',
  1585. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1586. insBanned: 'Your Instagram account has been banned',
  1587. verifyingInsAuth: 'Verifying Instagram token...',
  1588. gettingInsUserId: 'Getting Instagram user Id',
  1589. followingIns: 'Following Instagram user',
  1590. unfollowingIns: 'Unfollowing Instagram user',
  1591. reddits: 'Reddit/User',
  1592. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1593. changingRedditVersion: 'Switching Reddit to a new version page...',
  1594. joiningReddit: 'Joining the Reddit',
  1595. leavingReddit: 'Leaving the Reddit',
  1596. followingRedditUser: 'Following Reddit User',
  1597. unfollowingRedditUser: 'Unfollowing Reddit User',
  1598. channels: 'Channel',
  1599. followingTwitchChannel: 'Following Twitch Channel',
  1600. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1601. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1602. twitterUser: 'Twitter User',
  1603. retweets: 'Retweet',
  1604. followingTwitterUser: 'Following Twitter User',
  1605. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1606. retweetting: 'Retweetting',
  1607. unretweetting: 'Unretweetting',
  1608. names: 'Group/Public/Wall',
  1609. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1610. gettingVkId: 'Getting Vk task Id',
  1611. joiningVkGroup: 'Joining Vk Group',
  1612. leavingVkGroup: 'Leaving Vk Group',
  1613. joiningVkPublic: 'Joining Vk Public',
  1614. leavingVkPublic: 'Leaving Vk Public',
  1615. sendingVkWall: 'Sending Vk Wall',
  1616. deletingVkWall: 'Deleting Vk Wall',
  1617. youtubeChannel: 'YouTube Channel',
  1618. likes: 'Like',
  1619. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1620. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1621. gettingYtbToken: 'Getting YouTube Token...',
  1622. followingYtbChannel: 'Subscribing to YouTube channel',
  1623. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1624. likingYtbVideo: 'Liking YouTube video',
  1625. unlikingYtbVideo: 'Unliking YouTube video',
  1626. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1627. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1628. noPoints: 'Not enough points, skip the lottery',
  1629. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1630. joiningLottery: 'Joining the lottery',
  1631. doingGleamTask: 'Doing Gleam Task...',
  1632. gettingGleamLink: 'Getting Gleam task link...',
  1633. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1634. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1635. 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!',
  1636. 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...'
  1637. };
  1638. const en_US = en_US_data;
  1639. const languages = {
  1640. zh: zh_CN,
  1641. en: en_US
  1642. };
  1643. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1644. const I18n = function(key) {
  1645. var _languages$language;
  1646. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1647. argvs[_key - 1] = arguments[_key];
  1648. }
  1649. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1650. return key;
  1651. }
  1652. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1653. };
  1654. const i18n = I18n;
  1655. function throwError(error, name) {
  1656. external_Swal_default().fire({
  1657. title: i18n('errorReport'),
  1658. icon: 'error',
  1659. showCancelButton: true,
  1660. confirmButtonText: i18n('toGithub'),
  1661. showDenyButton: true,
  1662. denyButtonText: i18n('toKeylol'),
  1663. cancelButtonText: i18n('close')
  1664. }).then(_ref => {
  1665. let {
  1666. isDenied,
  1667. isConfirmed
  1668. } = _ref;
  1669. if (isConfirmed) {
  1670. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`脚本报错: ${name}`)}&labels=bug&body=${encodeURIComponent(`错误链接: [${window.location.href}](${window.location.href})
  1671.  
  1672. 环境:
  1673. \`\`\`
  1674. ${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}
  1675. \`\`\`
  1676. 脚本管理器: \`${GM_info.scriptHandler} ${GM_info.version}\`
  1677. 脚本版本: \`${GM_info.script.version}\`
  1678.  
  1679. 报错信息:
  1680. \`\`\`
  1681. ${error.stack}
  1682. \`\`\`
  1683.  
  1684. 执行日志:
  1685. \`\`\`
  1686. ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}
  1687. \`\`\`
  1688. `)}`, '_blank');
  1689. } else if (isDenied) {
  1690. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1691.  
  1692. 环境:
  1693.  
  1694. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1695.  
  1696. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1697. 脚本版本: ${GM_info.script.version}
  1698.  
  1699. 报错信息:
  1700. [code]${error.stack}[/code]
  1701.  
  1702. 执行日志:
  1703. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1704. GM_setClipboard(text);
  1705. external_Swal_default().fire({
  1706. title: i18n('copySuccess'),
  1707. icon: 'success',
  1708. confirmButtonText: i18n('ok')
  1709. }).then(() => {
  1710. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1711. });
  1712. }
  1713. });
  1714. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1715. }
  1716. function _defineProperty(obj, key, value) {
  1717. if (key in obj) {
  1718. Object.defineProperty(obj, key, {
  1719. value: value,
  1720. enumerable: true,
  1721. configurable: true,
  1722. writable: true
  1723. });
  1724. } else {
  1725. obj[key] = value;
  1726. }
  1727. return obj;
  1728. }
  1729. class Social {
  1730. constructor() {
  1731. _defineProperty(this, 'tasks', void 0);
  1732. }
  1733. getRealParams(name, links, doTask, link2param) {
  1734. try {
  1735. let realParams = [];
  1736. if (links.length > 0) {
  1737. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1738. }
  1739. if (!doTask && this.tasks[name].length > 0) {
  1740. realParams = [ ...realParams, ...this.tasks[name] ];
  1741. }
  1742. return unique(realParams);
  1743. } catch (error) {
  1744. throwError(error, 'Social.getRealParams');
  1745. return [];
  1746. }
  1747. }
  1748. }
  1749. const social_Social = Social;
  1750. function _classPrivateMethodInitSpec(obj, privateSet) {
  1751. _checkPrivateRedeclaration(obj, privateSet);
  1752. privateSet.add(obj);
  1753. }
  1754. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1755. _checkPrivateRedeclaration(obj, privateMap);
  1756. privateMap.set(obj, value);
  1757. }
  1758. function _checkPrivateRedeclaration(obj, privateCollection) {
  1759. if (privateCollection.has(obj)) {
  1760. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1761. }
  1762. }
  1763. function Discord_defineProperty(obj, key, value) {
  1764. if (key in obj) {
  1765. Object.defineProperty(obj, key, {
  1766. value: value,
  1767. enumerable: true,
  1768. configurable: true,
  1769. writable: true
  1770. });
  1771. } else {
  1772. obj[key] = value;
  1773. }
  1774. return obj;
  1775. }
  1776. function _classPrivateFieldSet(receiver, privateMap, value) {
  1777. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1778. _classApplyDescriptorSet(receiver, descriptor, value);
  1779. return value;
  1780. }
  1781. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1782. if (descriptor.set) {
  1783. descriptor.set.call(receiver, value);
  1784. } else {
  1785. if (!descriptor.writable) {
  1786. throw new TypeError('attempted to set read only private field');
  1787. }
  1788. descriptor.value = value;
  1789. }
  1790. }
  1791. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1792. if (!privateSet.has(receiver)) {
  1793. throw new TypeError('attempted to get private field on non-instance');
  1794. }
  1795. return fn;
  1796. }
  1797. function _classPrivateFieldGet(receiver, privateMap) {
  1798. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1799. return _classApplyDescriptorGet(receiver, descriptor);
  1800. }
  1801. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1802. if (!privateMap.has(receiver)) {
  1803. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1804. }
  1805. return privateMap.get(receiver);
  1806. }
  1807. function _classApplyDescriptorGet(receiver, descriptor) {
  1808. if (descriptor.get) {
  1809. return descriptor.get.call(receiver);
  1810. }
  1811. return descriptor.value;
  1812. }
  1813. const defaultTasksTemplate = {
  1814. servers: []
  1815. };
  1816. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1817. var _auth = new WeakMap();
  1818. var _cache = new WeakMap();
  1819. var _initialized = new WeakMap();
  1820. var _verifyAuth = new WeakSet();
  1821. var _updateAuth = new WeakSet();
  1822. var _joinServer = new WeakSet();
  1823. var _leaveServer = new WeakSet();
  1824. var _getGuild = new WeakSet();
  1825. var _setCache = new WeakSet();
  1826. class Discord extends social_Social {
  1827. constructor() {
  1828. var _GM_getValue;
  1829. super(...arguments);
  1830. _classPrivateMethodInitSpec(this, _setCache);
  1831. _classPrivateMethodInitSpec(this, _getGuild);
  1832. _classPrivateMethodInitSpec(this, _leaveServer);
  1833. _classPrivateMethodInitSpec(this, _joinServer);
  1834. _classPrivateMethodInitSpec(this, _updateAuth);
  1835. _classPrivateMethodInitSpec(this, _verifyAuth);
  1836. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1837. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || JSON.parse(defaultTasks));
  1838. _classPrivateFieldInitSpec(this, _auth, {
  1839. writable: true,
  1840. value: GM_getValue('discordAuth') || {}
  1841. });
  1842. _classPrivateFieldInitSpec(this, _cache, {
  1843. writable: true,
  1844. value: GM_getValue('discordCache') || {}
  1845. });
  1846. _classPrivateFieldInitSpec(this, _initialized, {
  1847. writable: true,
  1848. value: false
  1849. });
  1850. }
  1851. async init() {
  1852. try {
  1853. if (_classPrivateFieldGet(this, _initialized)) {
  1854. return true;
  1855. }
  1856. if (!_classPrivateFieldGet(this, _auth).auth) {
  1857. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1858. _classPrivateFieldSet(this, _initialized, true);
  1859. return true;
  1860. }
  1861. return false;
  1862. }
  1863. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1864. if (isVerified) {
  1865. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1866. _classPrivateFieldSet(this, _initialized, true);
  1867. return true;
  1868. }
  1869. GM_setValue('discordAuth', {
  1870. auth: null
  1871. });
  1872. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1873. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1874. _classPrivateFieldSet(this, _initialized, true);
  1875. return true;
  1876. }
  1877. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1878. return false;
  1879. } catch (error) {
  1880. throwError(error, 'Discord.init');
  1881. return false;
  1882. }
  1883. }
  1884. async toggle(_ref) {
  1885. let {
  1886. doTask = true,
  1887. serverLinks = []
  1888. } = _ref;
  1889. try {
  1890. if (!_classPrivateFieldGet(this, _initialized)) {
  1891. scripts_echoLog({
  1892. text: i18n('needInit')
  1893. });
  1894. return false;
  1895. }
  1896. const prom = [];
  1897. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1898. scripts_echoLog({
  1899. type: 'globalOptionsSkip',
  1900. text: 'discord.servers'
  1901. });
  1902. } else {
  1903. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1904. var _link$match;
  1905. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1906. });
  1907. if (realServers.length > 0) {
  1908. for (const server of realServers) {
  1909. if (doTask) {
  1910. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1911. } else {
  1912. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1913. }
  1914. await delay(1e3);
  1915. }
  1916. }
  1917. }
  1918. return await Promise.all(prom).then(() => true);
  1919. } catch (error) {
  1920. throwError(error, 'Discord.toggleServers');
  1921. return false;
  1922. }
  1923. }
  1924. }
  1925. async function _verifyAuth2() {
  1926. try {
  1927. const logStatus = scripts_echoLog({
  1928. text: i18n('verifyingAuth', 'Discord')
  1929. });
  1930. const {
  1931. result,
  1932. statusText,
  1933. status,
  1934. data
  1935. } = await tools_httpRequest({
  1936. url: 'https://discord.com/api/v6/users/@me',
  1937. method: 'HEAD',
  1938. headers: {
  1939. authorization: _classPrivateFieldGet(this, _auth).auth
  1940. }
  1941. });
  1942. if (result === 'Success') {
  1943. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1944. logStatus.success();
  1945. return true;
  1946. }
  1947. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1948. return false;
  1949. }
  1950. logStatus.error(`${result}:${statusText}(${status})`);
  1951. return false;
  1952. } catch (error) {
  1953. throwError(error, 'Discord.verifyAuth');
  1954. return false;
  1955. }
  1956. }
  1957. async function _updateAuth2() {
  1958. try {
  1959. const logStatus = scripts_echoLog({
  1960. text: i18n('updatingAuth', 'Discord')
  1961. });
  1962. return await new Promise(resolve => {
  1963. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1964. active: true,
  1965. insert: true,
  1966. setParent: true
  1967. });
  1968. newTab.onclose = async () => {
  1969. var _GM_getValue2;
  1970. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1971. if (auth) {
  1972. _classPrivateFieldSet(this, _auth, {
  1973. auth: auth
  1974. });
  1975. logStatus.success();
  1976. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1977. } else {
  1978. logStatus.error('Error: Update discord auth failed!');
  1979. resolve(false);
  1980. }
  1981. };
  1982. });
  1983. } catch (error) {
  1984. throwError(error, 'Discord.updateAuth');
  1985. return false;
  1986. }
  1987. }
  1988. async function _joinServer2(inviteId) {
  1989. try {
  1990. const logStatus = scripts_echoLog({
  1991. type: 'joiningDiscordServer',
  1992. text: inviteId
  1993. });
  1994. const {
  1995. result,
  1996. statusText,
  1997. status,
  1998. data
  1999. } = await tools_httpRequest({
  2000. url: `https://discord.com/api/v6/invites/${inviteId}`,
  2001. method: 'POST',
  2002. dataType: 'json',
  2003. headers: {
  2004. authorization: _classPrivateFieldGet(this, _auth).auth
  2005. }
  2006. });
  2007. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2008. var _data$response, _data$response$guild;
  2009. logStatus.success();
  2010. 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);
  2011. if (guild) {
  2012. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2013. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2014. }
  2015. return true;
  2016. }
  2017. logStatus.error(`${result}:${statusText}(${status})`);
  2018. return false;
  2019. } catch (error) {
  2020. throwError(error, 'Discord.joinServer');
  2021. return false;
  2022. }
  2023. }
  2024. async function _leaveServer2(inviteId) {
  2025. try {
  2026. if (this.whiteList.servers.includes(inviteId)) {
  2027. scripts_echoLog({
  2028. type: 'whiteList',
  2029. text: 'Discord.leaveServer',
  2030. id: inviteId
  2031. });
  2032. return true;
  2033. }
  2034. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2035. if (!guild) {
  2036. return false;
  2037. }
  2038. const logStatus = scripts_echoLog({
  2039. type: 'leavingDiscordServer',
  2040. text: guild
  2041. });
  2042. const {
  2043. result,
  2044. statusText,
  2045. status,
  2046. data
  2047. } = await tools_httpRequest({
  2048. url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
  2049. method: 'DELETE',
  2050. headers: {
  2051. authorization: _classPrivateFieldGet(this, _auth).auth
  2052. }
  2053. });
  2054. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2055. logStatus.success();
  2056. return true;
  2057. }
  2058. logStatus.error(`${result}:${statusText}(${status})`);
  2059. return false;
  2060. } catch (error) {
  2061. throwError(error, 'Discord.leaveServer');
  2062. return false;
  2063. }
  2064. }
  2065. async function _getGuild2(inviteId) {
  2066. try {
  2067. const logStatus = scripts_echoLog({
  2068. type: 'gettingDiscordGuild',
  2069. text: inviteId
  2070. });
  2071. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2072. if (guild) {
  2073. logStatus.success();
  2074. return guild;
  2075. }
  2076. const {
  2077. result,
  2078. statusText,
  2079. status,
  2080. data
  2081. } = await tools_httpRequest({
  2082. url: `https://discord.com/invite/${inviteId}`,
  2083. method: 'GET'
  2084. });
  2085. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2086. var _data$responseText$ma;
  2087. const guild = (_data$responseText$ma = data.responseText.match(/https?:\/\/cdn\.discordapp\.com\/icons\/([\d]+?)\//)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2088. if (guild) {
  2089. logStatus.success();
  2090. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2091. return guild;
  2092. }
  2093. logStatus.error(`${result}:${statusText}(${status})`);
  2094. return false;
  2095. }
  2096. logStatus.error(`${result}:${statusText}(${status})`);
  2097. return false;
  2098. } catch (error) {
  2099. throwError(error, 'Discord.getGuild');
  2100. return false;
  2101. }
  2102. }
  2103. function _setCache2(inviteId, guild) {
  2104. try {
  2105. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2106. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2107. } catch (error) {
  2108. throwError(error, 'Discord.setCache');
  2109. }
  2110. }
  2111. const social_Discord = Discord;
  2112. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2113. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2114. privateSet.add(obj);
  2115. }
  2116. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2117. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2118. privateMap.set(obj, value);
  2119. }
  2120. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2121. if (privateCollection.has(obj)) {
  2122. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2123. }
  2124. }
  2125. function Instagram_defineProperty(obj, key, value) {
  2126. if (key in obj) {
  2127. Object.defineProperty(obj, key, {
  2128. value: value,
  2129. enumerable: true,
  2130. configurable: true,
  2131. writable: true
  2132. });
  2133. } else {
  2134. obj[key] = value;
  2135. }
  2136. return obj;
  2137. }
  2138. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2139. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2140. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2141. return value;
  2142. }
  2143. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2144. if (descriptor.set) {
  2145. descriptor.set.call(receiver, value);
  2146. } else {
  2147. if (!descriptor.writable) {
  2148. throw new TypeError('attempted to set read only private field');
  2149. }
  2150. descriptor.value = value;
  2151. }
  2152. }
  2153. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2154. if (!privateSet.has(receiver)) {
  2155. throw new TypeError('attempted to get private field on non-instance');
  2156. }
  2157. return fn;
  2158. }
  2159. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2160. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2161. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2162. }
  2163. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2164. if (!privateMap.has(receiver)) {
  2165. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2166. }
  2167. return privateMap.get(receiver);
  2168. }
  2169. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2170. if (descriptor.get) {
  2171. return descriptor.get.call(receiver);
  2172. }
  2173. return descriptor.value;
  2174. }
  2175. const Instagram_defaultTasksTemplate = {
  2176. users: []
  2177. };
  2178. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2179. var Instagram_cache = new WeakMap();
  2180. var Instagram_auth = new WeakMap();
  2181. var Instagram_initialized = new WeakMap();
  2182. var _getUserInfo = new WeakSet();
  2183. var _followUser = new WeakSet();
  2184. var _unfollowUser = new WeakSet();
  2185. var Instagram_setCache = new WeakSet();
  2186. class Instagram extends social_Social {
  2187. constructor() {
  2188. var _GM_getValue;
  2189. super(...arguments);
  2190. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2191. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2192. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2193. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2194. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2195. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || JSON.parse(Instagram_defaultTasks));
  2196. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2197. writable: true,
  2198. value: GM_getValue('instagramCache') || {}
  2199. });
  2200. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2201. writable: true,
  2202. value: {}
  2203. });
  2204. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2205. writable: true,
  2206. value: false
  2207. });
  2208. }
  2209. async init() {
  2210. try {
  2211. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2212. return true;
  2213. }
  2214. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2215. if (isVerified) {
  2216. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2217. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2218. return true;
  2219. }
  2220. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2221. return false;
  2222. } catch (error) {
  2223. throwError(error, 'Instagram.init');
  2224. return false;
  2225. }
  2226. }
  2227. async toggle(_ref) {
  2228. let {
  2229. doTask = true,
  2230. userLinks = []
  2231. } = _ref;
  2232. try {
  2233. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2234. scripts_echoLog({
  2235. text: i18n('needInit')
  2236. });
  2237. return false;
  2238. }
  2239. const prom = [];
  2240. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2241. scripts_echoLog({
  2242. type: 'globalOptionsSkip',
  2243. text: 'instagram.users'
  2244. });
  2245. } else {
  2246. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2247. var _link$match;
  2248. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2249. });
  2250. if (realUsers.length > 0) {
  2251. for (const username of realUsers) {
  2252. if (doTask) {
  2253. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2254. } else {
  2255. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2256. }
  2257. await delay(1e3);
  2258. }
  2259. }
  2260. }
  2261. return await Promise.all(prom).then(() => true);
  2262. } catch (error) {
  2263. throwError(error, 'Instagram.toggleUsers');
  2264. return false;
  2265. }
  2266. }
  2267. }
  2268. async function _getUserInfo2() {
  2269. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2270. try {
  2271. const logStatus = scripts_echoLog({
  2272. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2273. text: name
  2274. });
  2275. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2276. if (userId && name !== 'instagram') {
  2277. logStatus.success();
  2278. return userId;
  2279. }
  2280. const {
  2281. result,
  2282. statusText,
  2283. status,
  2284. data
  2285. } = await tools_httpRequest({
  2286. url: `https://www.instagram.com/${name}/`,
  2287. method: 'GET'
  2288. });
  2289. if (result === 'Success') {
  2290. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2291. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2292. return false;
  2293. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2294. logStatus.error(`Error:${i18n('insBanned')}`);
  2295. return false;
  2296. }
  2297. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2298. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2299. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2300. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2301. if (name === 'instagram') {
  2302. if (csrftoken && hash) {
  2303. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2304. csrftoken: csrftoken,
  2305. hash: hash
  2306. });
  2307. return true;
  2308. }
  2309. return false;
  2310. }
  2311. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2312. if (id) {
  2313. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2314. logStatus.success();
  2315. return id;
  2316. }
  2317. logStatus.error('Error: Get ins data error!');
  2318. return false;
  2319. }
  2320. logStatus.error(`${result}:${statusText}(${status})`);
  2321. return false;
  2322. }
  2323. return false;
  2324. } catch (error) {
  2325. throwError(error, 'Instagram.getUserInfo');
  2326. return false;
  2327. }
  2328. }
  2329. async function _followUser2(name) {
  2330. try {
  2331. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2332. if (!id) {
  2333. return false;
  2334. }
  2335. const logStatus = scripts_echoLog({
  2336. type: 'followingIns',
  2337. text: name
  2338. });
  2339. const {
  2340. result,
  2341. statusText,
  2342. status,
  2343. data
  2344. } = await tools_httpRequest({
  2345. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2346. method: 'POST',
  2347. dataType: 'json',
  2348. headers: {
  2349. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2350. origin: 'https://www.instagram.com',
  2351. referer: `https://www.instagram.com/${name}/`,
  2352. 'content-type': 'application/x-www-form-urlencoded',
  2353. 'sec-fetch-site': 'same-origin',
  2354. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2355. }
  2356. });
  2357. if (result === 'Success') {
  2358. var _data$response, _data$response2;
  2359. 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') {
  2360. logStatus.success();
  2361. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2362. return true;
  2363. }
  2364. 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})`}`);
  2365. return false;
  2366. }
  2367. logStatus.error(`${result}:${statusText}(${status})`);
  2368. return false;
  2369. } catch (error) {
  2370. throwError(error, 'Instagram.followUser');
  2371. return false;
  2372. }
  2373. }
  2374. async function _unfollowUser2(name) {
  2375. try {
  2376. if (this.whiteList.users.includes(name)) {
  2377. scripts_echoLog({
  2378. type: 'whiteList',
  2379. text: 'Instagram.unfollowUser',
  2380. id: name
  2381. });
  2382. return true;
  2383. }
  2384. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2385. if (!id) {
  2386. return false;
  2387. }
  2388. const logStatus = scripts_echoLog({
  2389. type: 'unfollowingIns',
  2390. text: name
  2391. });
  2392. const {
  2393. result,
  2394. statusText,
  2395. status,
  2396. data
  2397. } = await tools_httpRequest({
  2398. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2399. method: 'POST',
  2400. dataType: 'json',
  2401. headers: {
  2402. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2403. origin: 'https://www.instagram.com',
  2404. referer: `https://www.instagram.com/${name}/`,
  2405. 'content-type': 'application/x-www-form-urlencoded',
  2406. 'sec-fetch-site': 'same-origin',
  2407. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2408. }
  2409. });
  2410. if (result === 'Success') {
  2411. var _data$response3;
  2412. 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') {
  2413. logStatus.success();
  2414. return true;
  2415. }
  2416. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2417. return false;
  2418. }
  2419. logStatus.error(`${result}:${statusText}(${status})`);
  2420. return false;
  2421. } catch (error) {
  2422. throwError(error, 'Instagram.unfollowUser');
  2423. return false;
  2424. }
  2425. }
  2426. function Instagram_setCache2(name, id) {
  2427. try {
  2428. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2429. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2430. } catch (error) {
  2431. throwError(error, 'Instagram.setCache');
  2432. }
  2433. }
  2434. const social_Instagram = Instagram;
  2435. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2436. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2437. privateSet.add(obj);
  2438. }
  2439. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2440. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2441. privateMap.set(obj, value);
  2442. }
  2443. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2444. if (privateCollection.has(obj)) {
  2445. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2446. }
  2447. }
  2448. function Reddit_defineProperty(obj, key, value) {
  2449. if (key in obj) {
  2450. Object.defineProperty(obj, key, {
  2451. value: value,
  2452. enumerable: true,
  2453. configurable: true,
  2454. writable: true
  2455. });
  2456. } else {
  2457. obj[key] = value;
  2458. }
  2459. return obj;
  2460. }
  2461. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2462. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2463. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2464. return value;
  2465. }
  2466. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2467. if (descriptor.set) {
  2468. descriptor.set.call(receiver, value);
  2469. } else {
  2470. if (!descriptor.writable) {
  2471. throw new TypeError('attempted to set read only private field');
  2472. }
  2473. descriptor.value = value;
  2474. }
  2475. }
  2476. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2477. if (!privateSet.has(receiver)) {
  2478. throw new TypeError('attempted to get private field on non-instance');
  2479. }
  2480. return fn;
  2481. }
  2482. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2483. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2484. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2485. }
  2486. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2487. if (!privateMap.has(receiver)) {
  2488. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2489. }
  2490. return privateMap.get(receiver);
  2491. }
  2492. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2493. if (descriptor.get) {
  2494. return descriptor.get.call(receiver);
  2495. }
  2496. return descriptor.value;
  2497. }
  2498. const Reddit_defaultTasksTemplate = {
  2499. reddits: []
  2500. };
  2501. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2502. var Reddit_auth = new WeakMap();
  2503. var Reddit_initialized = new WeakMap();
  2504. var _useBeta = new WeakSet();
  2505. var Reddit_updateAuth = new WeakSet();
  2506. class Reddit extends social_Social {
  2507. constructor() {
  2508. var _GM_getValue;
  2509. super(...arguments);
  2510. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2511. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2512. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2513. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || JSON.parse(Reddit_defaultTasks));
  2514. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2515. writable: true,
  2516. value: void 0
  2517. });
  2518. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2519. writable: true,
  2520. value: false
  2521. });
  2522. }
  2523. async init() {
  2524. try {
  2525. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2526. return true;
  2527. }
  2528. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2529. if (isVerified) {
  2530. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2531. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2532. return true;
  2533. }
  2534. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2535. return false;
  2536. } catch (error) {
  2537. throwError(error, 'Reddit.init');
  2538. return false;
  2539. }
  2540. }
  2541. async toggleTask(_ref) {
  2542. let {
  2543. name,
  2544. doTask = true
  2545. } = _ref;
  2546. try {
  2547. if (!doTask && this.whiteList.reddits.includes(name)) {
  2548. scripts_echoLog({
  2549. type: 'whiteList',
  2550. text: 'Reddit.undoTask',
  2551. id: name
  2552. });
  2553. return true;
  2554. }
  2555. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2556. if (/^u_/.test(name)) {
  2557. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2558. }
  2559. const logStatus = scripts_echoLog({
  2560. type: type,
  2561. text: name
  2562. });
  2563. const {
  2564. result,
  2565. statusText,
  2566. status,
  2567. data
  2568. } = await tools_httpRequest({
  2569. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2570. method: 'POST',
  2571. headers: {
  2572. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2573. 'content-type': 'application/x-www-form-urlencoded'
  2574. },
  2575. data: $.param({
  2576. action: doTask ? 'sub' : 'unsub',
  2577. sr_name: name,
  2578. api_type: 'json'
  2579. })
  2580. });
  2581. if (result === 'Success') {
  2582. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2583. logStatus.success();
  2584. if (doTask) {
  2585. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2586. }
  2587. return true;
  2588. }
  2589. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2590. return false;
  2591. }
  2592. logStatus.error(`${result}:${statusText}(${status})`);
  2593. return false;
  2594. } catch (error) {
  2595. throwError(error, 'Reddit.toggleTask');
  2596. return false;
  2597. }
  2598. }
  2599. async toggle(_ref2) {
  2600. let {
  2601. doTask = true,
  2602. redditLinks = []
  2603. } = _ref2;
  2604. try {
  2605. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2606. scripts_echoLog({
  2607. text: i18n('needInit')
  2608. });
  2609. return false;
  2610. }
  2611. const prom = [];
  2612. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2613. scripts_echoLog({
  2614. type: 'globalOptionsSkip',
  2615. text: 'reddit.reddits'
  2616. });
  2617. } else {
  2618. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2619. var _link$match, _link$match2;
  2620. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2621. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2622. if (userName) {
  2623. return name || userName;
  2624. }
  2625. return name;
  2626. });
  2627. if (realReddits.length > 0) {
  2628. for (const name of realReddits) {
  2629. prom.push(this.toggleTask({
  2630. name: name,
  2631. doTask: doTask
  2632. }));
  2633. await delay(1e3);
  2634. }
  2635. }
  2636. }
  2637. return await Promise.all(prom).then(() => true);
  2638. } catch (error) {
  2639. throwError(error, 'Reddit.toggle');
  2640. return false;
  2641. }
  2642. }
  2643. }
  2644. async function _useBeta2() {
  2645. try {
  2646. const logStatus = scripts_echoLog({
  2647. text: i18n('changingRedditVersion')
  2648. });
  2649. GM_setValue('redditAuth', null);
  2650. return await new Promise(resolve => {
  2651. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2652. active: true,
  2653. insert: true,
  2654. setParent: true
  2655. });
  2656. newTab.onclose = async () => {
  2657. logStatus.success();
  2658. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2659. };
  2660. });
  2661. } catch (error) {
  2662. throwError(error, 'Reddit.useBeta');
  2663. return false;
  2664. }
  2665. }
  2666. async function Reddit_updateAuth2() {
  2667. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2668. try {
  2669. const logStatus = scripts_echoLog({
  2670. text: i18n('updatingAuth', 'Reddit')
  2671. });
  2672. const {
  2673. result,
  2674. statusText,
  2675. status,
  2676. data
  2677. } = await tools_httpRequest({
  2678. url: 'https://www.reddit.com/',
  2679. method: 'GET',
  2680. nochche: true,
  2681. headers: {
  2682. 'Cache-Control': 'no-cache'
  2683. }
  2684. });
  2685. if (result === 'Success') {
  2686. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2687. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2688. return false;
  2689. }
  2690. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2691. var _data$responseText$ma;
  2692. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2693. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2694. }
  2695. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2696. if (accessToken) {
  2697. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2698. token: accessToken
  2699. });
  2700. logStatus.success();
  2701. return true;
  2702. }
  2703. logStatus.error('Error: Parameter "accessToken" not found!');
  2704. return false;
  2705. }
  2706. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2707. return false;
  2708. }
  2709. logStatus.error(`${result}:${statusText}(${status})`);
  2710. return false;
  2711. } catch (error) {
  2712. throwError(error, 'Reddit.updateAuth');
  2713. return false;
  2714. }
  2715. }
  2716. const social_Reddit = Reddit;
  2717. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2718. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2719. privateSet.add(obj);
  2720. }
  2721. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2722. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2723. privateMap.set(obj, value);
  2724. }
  2725. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2726. if (privateCollection.has(obj)) {
  2727. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2728. }
  2729. }
  2730. function Twitch_defineProperty(obj, key, value) {
  2731. if (key in obj) {
  2732. Object.defineProperty(obj, key, {
  2733. value: value,
  2734. enumerable: true,
  2735. configurable: true,
  2736. writable: true
  2737. });
  2738. } else {
  2739. obj[key] = value;
  2740. }
  2741. return obj;
  2742. }
  2743. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2744. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2745. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2746. return value;
  2747. }
  2748. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2749. if (descriptor.set) {
  2750. descriptor.set.call(receiver, value);
  2751. } else {
  2752. if (!descriptor.writable) {
  2753. throw new TypeError('attempted to set read only private field');
  2754. }
  2755. descriptor.value = value;
  2756. }
  2757. }
  2758. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2759. if (!privateSet.has(receiver)) {
  2760. throw new TypeError('attempted to get private field on non-instance');
  2761. }
  2762. return fn;
  2763. }
  2764. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2765. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2766. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2767. }
  2768. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2769. if (!privateMap.has(receiver)) {
  2770. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2771. }
  2772. return privateMap.get(receiver);
  2773. }
  2774. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2775. if (descriptor.get) {
  2776. return descriptor.get.call(receiver);
  2777. }
  2778. return descriptor.value;
  2779. }
  2780. const Twitch_defaultTasksTemplate = {
  2781. channels: []
  2782. };
  2783. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2784. var Twitch_auth = new WeakMap();
  2785. var Twitch_cache = new WeakMap();
  2786. var Twitch_initialized = new WeakMap();
  2787. var Twitch_verifyAuth = new WeakSet();
  2788. var Twitch_updateAuth = new WeakSet();
  2789. var _toggleChannel = new WeakSet();
  2790. var _getChannelId = new WeakSet();
  2791. var Twitch_setCache = new WeakSet();
  2792. class Twitch extends social_Social {
  2793. constructor() {
  2794. var _GM_getValue;
  2795. super(...arguments);
  2796. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2797. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2798. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2799. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2800. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2801. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2802. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || JSON.parse(Twitch_defaultTasks));
  2803. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2804. writable: true,
  2805. value: GM_getValue('twitchAuth') || {}
  2806. });
  2807. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2808. writable: true,
  2809. value: GM_getValue('twitchCache') || {}
  2810. });
  2811. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2812. writable: true,
  2813. value: false
  2814. });
  2815. }
  2816. async init() {
  2817. try {
  2818. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2819. return true;
  2820. }
  2821. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2822. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2823. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2824. return true;
  2825. }
  2826. return false;
  2827. }
  2828. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2829. if (isVerified) {
  2830. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2831. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2832. return true;
  2833. }
  2834. GM_setValue('twitchAuth', null);
  2835. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2836. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2837. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2838. return true;
  2839. }
  2840. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2841. return false;
  2842. } catch (error) {
  2843. throwError(error, 'Twitch.init');
  2844. return false;
  2845. }
  2846. }
  2847. async toggle(_ref) {
  2848. let {
  2849. doTask = true,
  2850. channelLinks = []
  2851. } = _ref;
  2852. try {
  2853. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2854. scripts_echoLog({
  2855. text: i18n('needInit')
  2856. });
  2857. return false;
  2858. }
  2859. const prom = [];
  2860. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2861. scripts_echoLog({
  2862. type: 'globalOptionsSkip',
  2863. text: 'twitch.channels'
  2864. });
  2865. } else {
  2866. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2867. var _link$match;
  2868. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2869. });
  2870. if (realChannels.length > 0) {
  2871. for (const channel of realChannels) {
  2872. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2873. name: channel,
  2874. doTask: doTask
  2875. }));
  2876. await delay(1e3);
  2877. }
  2878. }
  2879. }
  2880. return Promise.all(prom).then(() => true);
  2881. } catch (error) {
  2882. throwError(error, 'Twitch.toggle');
  2883. return false;
  2884. }
  2885. }
  2886. }
  2887. async function Twitch_verifyAuth2() {
  2888. try {
  2889. const logStatus = scripts_echoLog({
  2890. text: i18n('verifyingAuth', 'Twitch')
  2891. });
  2892. const {
  2893. result,
  2894. statusText,
  2895. status,
  2896. data
  2897. } = await tools_httpRequest({
  2898. url: 'https://gql.twitch.tv/gql',
  2899. method: 'POST',
  2900. dataType: 'json',
  2901. headers: {
  2902. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2903. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2904. },
  2905. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2906. });
  2907. if (result === 'Success') {
  2908. var _data$response, _data$response$, _data$response$$data;
  2909. 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) {
  2910. logStatus.success();
  2911. return true;
  2912. }
  2913. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2914. return false;
  2915. }
  2916. logStatus.error(`${result}:${statusText}(${status})`);
  2917. return false;
  2918. } catch (error) {
  2919. throwError(error, 'Twitch.verifyAuth');
  2920. return false;
  2921. }
  2922. }
  2923. async function Twitch_updateAuth2() {
  2924. try {
  2925. const logStatus = scripts_echoLog({
  2926. text: i18n('updatingAuth', 'Twitch')
  2927. });
  2928. return await new Promise(resolve => {
  2929. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2930. active: true,
  2931. insert: true,
  2932. setParent: true
  2933. });
  2934. newTab.onclose = async () => {
  2935. const auth = GM_getValue('twitchAuth');
  2936. if (auth) {
  2937. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2938. logStatus.success();
  2939. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2940. } else {
  2941. logStatus.error('Error: Update twitch auth failed!');
  2942. resolve(false);
  2943. }
  2944. };
  2945. });
  2946. } catch (error) {
  2947. throwError(error, 'Twitch.updateAuth');
  2948. return false;
  2949. }
  2950. }
  2951. async function _toggleChannel2(_ref2) {
  2952. let {
  2953. name,
  2954. doTask = true
  2955. } = _ref2;
  2956. try {
  2957. if (!doTask && this.whiteList.channels.includes(name)) {
  2958. scripts_echoLog({
  2959. type: 'whiteList',
  2960. text: 'Twitch.unfollowChannel',
  2961. id: name
  2962. });
  2963. return true;
  2964. }
  2965. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2966. if (!channelId) {
  2967. return false;
  2968. }
  2969. const logStatus = scripts_echoLog({
  2970. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2971. text: name
  2972. });
  2973. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2974. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2975. const {
  2976. result,
  2977. statusText,
  2978. status,
  2979. data
  2980. } = await tools_httpRequest({
  2981. url: 'https://gql.twitch.tv/gql',
  2982. method: 'POST',
  2983. dataType: 'json',
  2984. headers: {
  2985. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2986. },
  2987. data: doTask ? followData : unfollowData
  2988. });
  2989. if (result === 'Success') {
  2990. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2991. logStatus.success();
  2992. if (doTask) {
  2993. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2994. }
  2995. return true;
  2996. }
  2997. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2998. return false;
  2999. }
  3000. logStatus.error(`${result}:${statusText}(${status})`);
  3001. return false;
  3002. } catch (error) {
  3003. throwError(error, 'Twitch.toggleChannel');
  3004. return false;
  3005. }
  3006. }
  3007. async function _getChannelId2(name) {
  3008. try {
  3009. const logStatus = scripts_echoLog({
  3010. type: 'gettingTwitchChannelId',
  3011. text: name
  3012. });
  3013. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3014. if (channelId) {
  3015. logStatus.success();
  3016. return channelId;
  3017. }
  3018. const {
  3019. result,
  3020. statusText,
  3021. status,
  3022. data
  3023. } = await tools_httpRequest({
  3024. url: 'https://gql.twitch.tv/gql',
  3025. method: 'POST',
  3026. headers: {
  3027. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3028. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3029. },
  3030. responseType: 'json',
  3031. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3032. });
  3033. if (result === 'Success') {
  3034. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3035. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3036. 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);
  3037. if (channelId) {
  3038. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3039. logStatus.success();
  3040. return channelId;
  3041. }
  3042. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3043. return false;
  3044. }
  3045. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3046. return false;
  3047. }
  3048. logStatus.error(`${result}:${statusText}(${status})`);
  3049. return false;
  3050. } catch (error) {
  3051. throwError(error, 'Twitch.getChannelId');
  3052. return false;
  3053. }
  3054. }
  3055. function Twitch_setCache2(name, id) {
  3056. try {
  3057. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3058. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3059. } catch (error) {
  3060. throwError(error, 'Twitch.setCache');
  3061. }
  3062. }
  3063. const social_Twitch = Twitch;
  3064. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3065. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3066. privateSet.add(obj);
  3067. }
  3068. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3069. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3070. privateMap.set(obj, value);
  3071. }
  3072. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3073. if (privateCollection.has(obj)) {
  3074. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3075. }
  3076. }
  3077. function Twitter_defineProperty(obj, key, value) {
  3078. if (key in obj) {
  3079. Object.defineProperty(obj, key, {
  3080. value: value,
  3081. enumerable: true,
  3082. configurable: true,
  3083. writable: true
  3084. });
  3085. } else {
  3086. obj[key] = value;
  3087. }
  3088. return obj;
  3089. }
  3090. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3091. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3092. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3093. return value;
  3094. }
  3095. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3096. if (descriptor.set) {
  3097. descriptor.set.call(receiver, value);
  3098. } else {
  3099. if (!descriptor.writable) {
  3100. throw new TypeError('attempted to set read only private field');
  3101. }
  3102. descriptor.value = value;
  3103. }
  3104. }
  3105. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3106. if (!privateSet.has(receiver)) {
  3107. throw new TypeError('attempted to get private field on non-instance');
  3108. }
  3109. return fn;
  3110. }
  3111. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3112. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3113. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3114. }
  3115. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3116. if (!privateMap.has(receiver)) {
  3117. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3118. }
  3119. return privateMap.get(receiver);
  3120. }
  3121. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3122. if (descriptor.get) {
  3123. return descriptor.get.call(receiver);
  3124. }
  3125. return descriptor.value;
  3126. }
  3127. const Twitter_defaultTasksTemplate = {
  3128. users: [],
  3129. retweets: [],
  3130. likes: []
  3131. };
  3132. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3133. var _verifyId = new WeakMap();
  3134. var Twitter_auth = new WeakMap();
  3135. var Twitter_cache = new WeakMap();
  3136. var Twitter_initialized = new WeakMap();
  3137. var Twitter_verifyAuth = new WeakSet();
  3138. var Twitter_updateAuth = new WeakSet();
  3139. var _toggleUser = new WeakSet();
  3140. var _toggleRetweet = new WeakSet();
  3141. var Twitter_setCache = new WeakSet();
  3142. class Twitter extends social_Social {
  3143. constructor() {
  3144. var _GM_getValue;
  3145. super(...arguments);
  3146. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3147. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3148. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3149. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3150. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3151. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3152. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || JSON.parse(Twitter_defaultTasks));
  3153. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3154. writable: true,
  3155. value: globalOptions.other.twitterVerifyId
  3156. });
  3157. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3158. writable: true,
  3159. value: GM_getValue('twitterAuth') || {}
  3160. });
  3161. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3162. writable: true,
  3163. value: GM_getValue('twitterCache') || {}
  3164. });
  3165. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3166. writable: true,
  3167. value: false
  3168. });
  3169. }
  3170. async init() {
  3171. try {
  3172. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3173. return true;
  3174. }
  3175. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3176. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3177. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3178. return true;
  3179. }
  3180. return false;
  3181. }
  3182. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3183. if (isVerified) {
  3184. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3185. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3186. return true;
  3187. }
  3188. GM_setValue('twitterAuth', null);
  3189. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3190. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3191. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3192. return true;
  3193. }
  3194. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3195. return false;
  3196. } catch (error) {
  3197. throwError(error, 'Twitter.init');
  3198. return false;
  3199. }
  3200. }
  3201. async userName2id(name) {
  3202. try {
  3203. const logStatus = scripts_echoLog({
  3204. type: 'gettingTwitterUserId',
  3205. text: name
  3206. });
  3207. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3208. if (userId) {
  3209. logStatus.success();
  3210. return userId;
  3211. }
  3212. const {
  3213. result,
  3214. statusText,
  3215. status,
  3216. data
  3217. } = await tools_httpRequest({
  3218. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3219. method: 'GET',
  3220. headers: {
  3221. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3222. 'content-type': 'application/json'
  3223. },
  3224. responseType: 'json',
  3225. anonymous: true
  3226. });
  3227. if (result === 'Success') {
  3228. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3229. var _response, _response$data, _response$data$user;
  3230. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3231. if (!response) {
  3232. try {
  3233. response = JSON.parse(data.responseText);
  3234. } catch (error) {
  3235. response = null;
  3236. }
  3237. }
  3238. 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);
  3239. if (userId) {
  3240. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3241. logStatus.success();
  3242. return userId;
  3243. }
  3244. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3245. return false;
  3246. }
  3247. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3248. return false;
  3249. }
  3250. logStatus.error(`${result}:${statusText}(${status})`);
  3251. return false;
  3252. } catch (error) {
  3253. throwError(error, 'Twitter.getUserId');
  3254. return false;
  3255. }
  3256. }
  3257. async toggle(_ref) {
  3258. let {
  3259. doTask = true,
  3260. userLinks = [],
  3261. retweetLinks = []
  3262. } = _ref;
  3263. try {
  3264. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3265. scripts_echoLog({
  3266. text: i18n('needInit')
  3267. });
  3268. return false;
  3269. }
  3270. const prom = [];
  3271. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3272. scripts_echoLog({
  3273. type: 'globalOptionsSkip',
  3274. text: 'twitter.users'
  3275. });
  3276. } else {
  3277. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3278. var _link$match;
  3279. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3280. });
  3281. if (realUsers.length > 0) {
  3282. for (const user of realUsers) {
  3283. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3284. name: user,
  3285. doTask: doTask
  3286. }));
  3287. await delay(1e3);
  3288. }
  3289. }
  3290. }
  3291. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3292. scripts_echoLog({
  3293. type: 'globalOptionsSkip',
  3294. text: 'twitter.retweets'
  3295. });
  3296. } else {
  3297. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3298. var _link$match2;
  3299. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3300. });
  3301. if (realRetweets.length > 0) {
  3302. for (const retweet of realRetweets) {
  3303. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3304. retweetId: retweet,
  3305. doTask: doTask
  3306. }));
  3307. await delay(1e3);
  3308. }
  3309. }
  3310. }
  3311. return Promise.all(prom).then(() => true);
  3312. } catch (error) {
  3313. throwError(error, 'Twitter.toggle');
  3314. return false;
  3315. }
  3316. }
  3317. }
  3318. async function Twitter_verifyAuth2() {
  3319. try {
  3320. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3321. name: 'verify',
  3322. doTask: true,
  3323. verify: true
  3324. });
  3325. } catch (error) {
  3326. throwError(error, 'Twitter.verifyAuth');
  3327. return false;
  3328. }
  3329. }
  3330. async function Twitter_updateAuth2() {
  3331. try {
  3332. const logStatus = scripts_echoLog({
  3333. text: i18n('updatingAuth', 'Twitter')
  3334. });
  3335. return await new Promise(resolve => {
  3336. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3337. active: true,
  3338. insert: true,
  3339. setParent: true
  3340. });
  3341. newTab.onclose = async () => {
  3342. const auth = GM_getValue('twitterAuth');
  3343. if (auth) {
  3344. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3345. logStatus.success();
  3346. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3347. } else {
  3348. logStatus.error('Error: Update twitter auth failed!');
  3349. resolve(false);
  3350. }
  3351. };
  3352. });
  3353. } catch (error) {
  3354. throwError(error, 'Twitter.updateToken');
  3355. return false;
  3356. }
  3357. }
  3358. async function _toggleUser2(_ref2) {
  3359. let {
  3360. name,
  3361. doTask = true,
  3362. verify = false
  3363. } = _ref2;
  3364. try {
  3365. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3366. scripts_echoLog({
  3367. type: 'whiteList',
  3368. text: 'Twitter.unfollowUser',
  3369. id: name
  3370. });
  3371. return true;
  3372. }
  3373. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3374. if (!userId) {
  3375. return false;
  3376. }
  3377. const logStatus = verify ? scripts_echoLog({
  3378. text: i18n('verifyingAuth', 'Twitter')
  3379. }) : scripts_echoLog({
  3380. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3381. text: name
  3382. });
  3383. const {
  3384. result,
  3385. statusText,
  3386. status,
  3387. data
  3388. } = await tools_httpRequest({
  3389. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3390. method: 'POST',
  3391. headers: {
  3392. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3393. 'Content-Type': 'application/x-www-form-urlencoded',
  3394. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3395. },
  3396. responseType: 'json',
  3397. data: $.param({
  3398. include_profile_interstitial_type: 1,
  3399. include_blocking: 1,
  3400. include_blocked_by: 1,
  3401. include_followed_by: 1,
  3402. include_want_retweets: 1,
  3403. include_mute_edge: 1,
  3404. include_can_dm: 1,
  3405. include_can_media_tag: 1,
  3406. skip_status: 1,
  3407. id: userId
  3408. })
  3409. });
  3410. if (result === 'Success') {
  3411. var _data$response, _data$response$errors, _data$response$errors2;
  3412. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3413. logStatus.success();
  3414. if (doTask && !verify) {
  3415. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3416. }
  3417. return true;
  3418. }
  3419. 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) {
  3420. logStatus.success();
  3421. return true;
  3422. }
  3423. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3424. return false;
  3425. }
  3426. logStatus.error(`${result}:${statusText}(${status})`);
  3427. return false;
  3428. } catch (error) {
  3429. throwError(error, 'Twitter.toggleUser');
  3430. return false;
  3431. }
  3432. }
  3433. async function _toggleRetweet2(_ref3) {
  3434. let {
  3435. retweetId,
  3436. doTask = true
  3437. } = _ref3;
  3438. try {
  3439. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3440. scripts_echoLog({
  3441. type: 'whiteList',
  3442. text: 'Twitter.unretweet',
  3443. id: retweetId
  3444. });
  3445. return true;
  3446. }
  3447. const logStatus = scripts_echoLog({
  3448. type: `${doTask ? '' : 'un'}retweetting`,
  3449. text: retweetId
  3450. });
  3451. const {
  3452. result,
  3453. statusText,
  3454. status,
  3455. data
  3456. } = await tools_httpRequest({
  3457. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3458. method: 'POST',
  3459. headers: {
  3460. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3461. 'Content-Type': 'application/x-www-form-urlencoded',
  3462. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3463. },
  3464. data: $.param({
  3465. tweet_mode: 'extended',
  3466. id: retweetId
  3467. }),
  3468. responseType: 'json'
  3469. });
  3470. if (result === 'Success') {
  3471. var _data$response2, _data$response2$error, _data$response2$error2;
  3472. 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) {
  3473. logStatus.success();
  3474. if (doTask) {
  3475. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3476. }
  3477. return true;
  3478. }
  3479. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3480. return false;
  3481. }
  3482. logStatus.error(`${result}:${statusText}(${status})`);
  3483. return false;
  3484. } catch (error) {
  3485. throwError(error, 'Twitter.toggleRetweet');
  3486. return false;
  3487. }
  3488. }
  3489. function Twitter_setCache2(name, id) {
  3490. try {
  3491. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3492. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3493. } catch (error) {
  3494. throwError(error, 'Twitter.setCache');
  3495. }
  3496. }
  3497. const social_Twitter = Twitter;
  3498. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3499. Vk_checkPrivateRedeclaration(obj, privateSet);
  3500. privateSet.add(obj);
  3501. }
  3502. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3503. Vk_checkPrivateRedeclaration(obj, privateMap);
  3504. privateMap.set(obj, value);
  3505. }
  3506. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3507. if (privateCollection.has(obj)) {
  3508. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3509. }
  3510. }
  3511. function Vk_defineProperty(obj, key, value) {
  3512. if (key in obj) {
  3513. Object.defineProperty(obj, key, {
  3514. value: value,
  3515. enumerable: true,
  3516. configurable: true,
  3517. writable: true
  3518. });
  3519. } else {
  3520. obj[key] = value;
  3521. }
  3522. return obj;
  3523. }
  3524. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3525. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3526. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3527. return value;
  3528. }
  3529. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3530. if (descriptor.set) {
  3531. descriptor.set.call(receiver, value);
  3532. } else {
  3533. if (!descriptor.writable) {
  3534. throw new TypeError('attempted to set read only private field');
  3535. }
  3536. descriptor.value = value;
  3537. }
  3538. }
  3539. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3540. if (!privateSet.has(receiver)) {
  3541. throw new TypeError('attempted to get private field on non-instance');
  3542. }
  3543. return fn;
  3544. }
  3545. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3546. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3547. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3548. }
  3549. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3550. if (!privateMap.has(receiver)) {
  3551. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3552. }
  3553. return privateMap.get(receiver);
  3554. }
  3555. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3556. if (descriptor.get) {
  3557. return descriptor.get.call(receiver);
  3558. }
  3559. return descriptor.value;
  3560. }
  3561. const Vk_defaultTasksTemplate = {
  3562. names: []
  3563. };
  3564. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3565. var _username = new WeakMap();
  3566. var Vk_cache = new WeakMap();
  3567. var Vk_initialized = new WeakMap();
  3568. var Vk_verifyAuth = new WeakSet();
  3569. var _toggleGroup = new WeakSet();
  3570. var _togglePublic = new WeakSet();
  3571. var _sendWall = new WeakSet();
  3572. var _deleteWall = new WeakSet();
  3573. var _getId = new WeakSet();
  3574. var _toggleVk = new WeakSet();
  3575. var Vk_setCache = new WeakSet();
  3576. class Vk extends social_Social {
  3577. constructor() {
  3578. var _GM_getValue;
  3579. super(...arguments);
  3580. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3581. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3582. Vk_classPrivateMethodInitSpec(this, _getId);
  3583. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3584. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3585. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3586. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3587. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3588. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3589. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || JSON.parse(Vk_defaultTasks));
  3590. Vk_classPrivateFieldInitSpec(this, _username, {
  3591. writable: true,
  3592. value: ''
  3593. });
  3594. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3595. writable: true,
  3596. value: GM_getValue('vkCache') || {}
  3597. });
  3598. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3599. writable: true,
  3600. value: false
  3601. });
  3602. }
  3603. async init() {
  3604. try {
  3605. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3606. return true;
  3607. }
  3608. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3609. if (isVerified) {
  3610. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3611. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3612. return true;
  3613. }
  3614. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3615. return false;
  3616. } catch (error) {
  3617. throwError(error, 'Vk.init');
  3618. return false;
  3619. }
  3620. }
  3621. async toggle(_ref) {
  3622. let {
  3623. doTask = true,
  3624. nameLinks = []
  3625. } = _ref;
  3626. try {
  3627. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3628. scripts_echoLog({
  3629. text: i18n('needInit')
  3630. });
  3631. return false;
  3632. }
  3633. const prom = [];
  3634. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3635. scripts_echoLog({
  3636. type: 'globalOptionsSkip',
  3637. text: 'vk.names'
  3638. });
  3639. } else {
  3640. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3641. var _link$match;
  3642. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3643. });
  3644. if (realNames.length > 0) {
  3645. for (const name of realNames) {
  3646. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3647. name: name,
  3648. doTask: doTask
  3649. }));
  3650. await delay(1e3);
  3651. }
  3652. }
  3653. }
  3654. return Promise.all(prom).then(() => true);
  3655. } catch (error) {
  3656. throwError(error, 'Vk.toggle');
  3657. return false;
  3658. }
  3659. }
  3660. }
  3661. async function Vk_verifyAuth2() {
  3662. try {
  3663. const logStatus = scripts_echoLog({
  3664. text: i18n('verifyAuth', 'Vk')
  3665. });
  3666. const {
  3667. result,
  3668. statusText,
  3669. status,
  3670. data
  3671. } = await tools_httpRequest({
  3672. url: 'https://vk.com/im',
  3673. method: 'GET'
  3674. });
  3675. if (result === 'Success') {
  3676. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3677. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3678. return false;
  3679. }
  3680. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3681. var _data$responseText$ma;
  3682. 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]) || '');
  3683. logStatus.success();
  3684. return true;
  3685. }
  3686. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3687. return false;
  3688. }
  3689. logStatus.error(`${result}:${statusText}(${status})`);
  3690. return false;
  3691. } catch (error) {
  3692. throwError(error, 'Vk.verifyAuth');
  3693. return false;
  3694. }
  3695. }
  3696. async function _toggleGroup2(name, dataParam) {
  3697. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3698. try {
  3699. const logStatus = scripts_echoLog({
  3700. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3701. text: name
  3702. });
  3703. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3704. logStatus.success();
  3705. return true;
  3706. }
  3707. const reqData = {
  3708. act: doTask ? 'enter' : 'leave',
  3709. al: 1,
  3710. gid: dataParam.groupId,
  3711. hash: dataParam.groupHash
  3712. };
  3713. if (doTask) {
  3714. reqData.context = '_';
  3715. }
  3716. const {
  3717. result,
  3718. statusText,
  3719. status,
  3720. data
  3721. } = await tools_httpRequest({
  3722. url: 'https://vk.com/al_groups.php',
  3723. method: 'POST',
  3724. headers: {
  3725. origin: 'https://vk.com',
  3726. referer: `https://vk.com/${name}`,
  3727. 'content-type': 'application/x-www-form-urlencoded'
  3728. },
  3729. data: $.param(reqData)
  3730. });
  3731. if (result === 'Success') {
  3732. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3733. logStatus.success();
  3734. if (doTask) {
  3735. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3736. }
  3737. return true;
  3738. }
  3739. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3740. return false;
  3741. }
  3742. logStatus.error(`${result}:${statusText}(${status})`);
  3743. return false;
  3744. } catch (error) {
  3745. throwError(error, 'Vk.toggleGroup');
  3746. return false;
  3747. }
  3748. }
  3749. async function _togglePublic2(name, dataParam) {
  3750. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3751. try {
  3752. const logStatus = scripts_echoLog({
  3753. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3754. text: name
  3755. });
  3756. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3757. logStatus.success();
  3758. return true;
  3759. }
  3760. const {
  3761. result,
  3762. statusText,
  3763. status,
  3764. data
  3765. } = await tools_httpRequest({
  3766. url: 'https://vk.com/al_public.php',
  3767. method: 'POST',
  3768. headers: {
  3769. origin: 'https://vk.com',
  3770. referer: `https://vk.com/${name}`,
  3771. 'content-type': 'application/x-www-form-urlencoded'
  3772. },
  3773. data: $.param({
  3774. act: doTask ? 'a_enter' : 'a_leave',
  3775. al: 1,
  3776. pid: dataParam.publicPid,
  3777. hash: dataParam.publicHash
  3778. })
  3779. });
  3780. if (result === 'Success') {
  3781. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3782. logStatus.success();
  3783. if (doTask) {
  3784. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3785. }
  3786. return true;
  3787. }
  3788. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3789. return false;
  3790. }
  3791. logStatus.error(`${result}:${statusText}(${status})`);
  3792. return false;
  3793. } catch (error) {
  3794. throwError(error, 'Vk.togglePublic');
  3795. return false;
  3796. }
  3797. }
  3798. async function _sendWall2(name) {
  3799. try {
  3800. const logStatus = scripts_echoLog({
  3801. type: 'sendingVkWall',
  3802. text: name
  3803. });
  3804. const {
  3805. result,
  3806. statusText,
  3807. status,
  3808. data
  3809. } = await tools_httpRequest({
  3810. url: 'https://vk.com/like.php',
  3811. method: 'POST',
  3812. headers: {
  3813. origin: 'https://vk.com',
  3814. referer: `https://vk.com/${name}`,
  3815. 'content-type': 'application/x-www-form-urlencoded'
  3816. },
  3817. data: $.param({
  3818. act: 'publish_box',
  3819. al: 1,
  3820. object: name
  3821. })
  3822. });
  3823. if (result === 'Success') {
  3824. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3825. var _data$responseText$ma2;
  3826. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3827. if (hash) {
  3828. const {
  3829. result: resultR,
  3830. statusText: statusTextR,
  3831. status: statusR,
  3832. data: dataR
  3833. } = await tools_httpRequest({
  3834. url: 'https://vk.com/like.php',
  3835. method: 'POST',
  3836. headers: {
  3837. origin: 'https://vk.com',
  3838. referer: `https://vk.com/${name}`,
  3839. 'content-type': 'application/x-www-form-urlencoded'
  3840. },
  3841. data: $.param({
  3842. Message: '',
  3843. act: 'a_do_publish',
  3844. al: 1,
  3845. close_comments: 0,
  3846. friends_only: 0,
  3847. from: 'box',
  3848. hash: hash,
  3849. list: '',
  3850. mark_as_ads: 0,
  3851. mute_notifications: 0,
  3852. object: name,
  3853. ret_data: 1,
  3854. to: 0
  3855. })
  3856. });
  3857. if (resultR === 'Success') {
  3858. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3859. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3860. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3861. 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) {
  3862. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3863. logStatus.success();
  3864. 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);
  3865. 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);
  3866. if (postId && ownerId) {
  3867. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3868. }
  3869. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3870. return true;
  3871. }
  3872. }
  3873. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3874. return false;
  3875. }
  3876. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3877. return false;
  3878. }
  3879. logStatus.error('Error: Get "hash" failed');
  3880. return false;
  3881. }
  3882. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3883. return false;
  3884. }
  3885. logStatus.error(`${result}:${statusText}(${status})`);
  3886. return false;
  3887. } catch (error) {
  3888. throwError(error, 'Vk.sendWall');
  3889. return false;
  3890. }
  3891. }
  3892. async function _deleteWall2(name, dataParams) {
  3893. try {
  3894. const logStatus = scripts_echoLog({
  3895. type: 'deletingVkWall',
  3896. text: name
  3897. });
  3898. const {
  3899. result,
  3900. statusText,
  3901. status,
  3902. data
  3903. } = await tools_httpRequest({
  3904. url: 'https://vk.com/al_wall.php?act=delete',
  3905. method: 'POST',
  3906. headers: {
  3907. origin: 'https://vk.com',
  3908. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3909. 'content-type': 'application/x-www-form-urlencoded'
  3910. },
  3911. data: $.param({
  3912. act: 'delete',
  3913. al: 1,
  3914. confirm: 0,
  3915. from: 'wkview',
  3916. hash: dataParams.wallHash,
  3917. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3918. })
  3919. });
  3920. if (result === 'Success') {
  3921. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3922. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3923. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3924. 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]) {
  3925. logStatus.success();
  3926. return true;
  3927. }
  3928. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3929. return false;
  3930. }
  3931. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3932. return false;
  3933. }
  3934. logStatus.error(`${result}:${statusText}(${status})`);
  3935. return false;
  3936. } catch (error) {
  3937. throwError(error, 'Vk.deleteWall');
  3938. return false;
  3939. }
  3940. }
  3941. async function _getId2(name, doTask) {
  3942. try {
  3943. let url = `https://vk.com/${name}`;
  3944. if (/^wall-/.test(name)) {
  3945. if (doTask) {
  3946. return {
  3947. type: 'sendWall'
  3948. };
  3949. }
  3950. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3951. return {
  3952. type: 'unSupport'
  3953. };
  3954. }
  3955. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3956. }
  3957. const logStatus = scripts_echoLog({
  3958. type: 'gettingVkId',
  3959. text: name
  3960. });
  3961. const {
  3962. result,
  3963. statusText,
  3964. status,
  3965. data
  3966. } = await tools_httpRequest({
  3967. url: url,
  3968. method: 'GET'
  3969. });
  3970. if (result === 'Success') {
  3971. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3972. var _data$responseText$ma3, _data$responseText$ma4;
  3973. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3974. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3975. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3976. const publicJoined = !data.responseText.includes('Public.subscribe');
  3977. if (groupAct && groupId && groupHash) {
  3978. logStatus.success();
  3979. return {
  3980. groupAct: groupAct,
  3981. groupId: groupId,
  3982. groupHash: groupHash,
  3983. type: 'group'
  3984. };
  3985. } else if (publicHash && publicPid) {
  3986. logStatus.success();
  3987. return {
  3988. publicHash: publicHash,
  3989. publicPid: publicPid,
  3990. publicJoined: publicJoined,
  3991. type: 'public'
  3992. };
  3993. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3994. var _data$responseText$ma5;
  3995. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3996. if (wallHash) {
  3997. logStatus.success();
  3998. return {
  3999. type: 'deleteWall',
  4000. wallHash: wallHash
  4001. };
  4002. }
  4003. } else if (name.includes('wall') && doTask) {
  4004. logStatus.success();
  4005. return {
  4006. type: 'sendWall'
  4007. };
  4008. }
  4009. logStatus.error('Error: Parameters not found!');
  4010. return false;
  4011. }
  4012. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4013. return false;
  4014. }
  4015. logStatus.error(`${result}:${statusText}(${status})`);
  4016. return false;
  4017. } catch (error) {
  4018. throwError(error, 'Vk.getId');
  4019. return false;
  4020. }
  4021. }
  4022. async function _toggleVk2(_ref2) {
  4023. let {
  4024. name,
  4025. doTask = true
  4026. } = _ref2;
  4027. try {
  4028. if (!doTask && this.whiteList.names.includes(name)) {
  4029. scripts_echoLog({
  4030. type: 'whiteList',
  4031. text: 'Vk.undoTask',
  4032. id: name
  4033. });
  4034. return true;
  4035. }
  4036. const formatName = name.replace(/\/$/, '');
  4037. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4038. if (!data) {
  4039. return false;
  4040. }
  4041. switch (data.type) {
  4042. case 'group':
  4043. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4044.  
  4045. case 'public':
  4046. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4047.  
  4048. case 'sendWall':
  4049. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4050.  
  4051. case 'deleteWall':
  4052. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4053.  
  4054. default:
  4055. return false;
  4056. }
  4057. } catch (error) {
  4058. throwError(error, 'Vk.toggleVk');
  4059. return false;
  4060. }
  4061. }
  4062. function Vk_setCache2(name, postId) {
  4063. try {
  4064. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4065. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4066. } catch (error) {
  4067. throwError(error, 'Vk.setCache');
  4068. }
  4069. }
  4070. const social_Vk = Vk;
  4071. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4072. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4073. privateSet.add(obj);
  4074. }
  4075. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4076. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4077. privateMap.set(obj, value);
  4078. }
  4079. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4080. if (privateCollection.has(obj)) {
  4081. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4082. }
  4083. }
  4084. function Youtube_defineProperty(obj, key, value) {
  4085. if (key in obj) {
  4086. Object.defineProperty(obj, key, {
  4087. value: value,
  4088. enumerable: true,
  4089. configurable: true,
  4090. writable: true
  4091. });
  4092. } else {
  4093. obj[key] = value;
  4094. }
  4095. return obj;
  4096. }
  4097. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4098. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4099. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4100. return value;
  4101. }
  4102. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4103. if (descriptor.set) {
  4104. descriptor.set.call(receiver, value);
  4105. } else {
  4106. if (!descriptor.writable) {
  4107. throw new TypeError('attempted to set read only private field');
  4108. }
  4109. descriptor.value = value;
  4110. }
  4111. }
  4112. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4113. if (!privateSet.has(receiver)) {
  4114. throw new TypeError('attempted to get private field on non-instance');
  4115. }
  4116. return fn;
  4117. }
  4118. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4119. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4120. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4121. }
  4122. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4123. if (!privateMap.has(receiver)) {
  4124. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4125. }
  4126. return privateMap.get(receiver);
  4127. }
  4128. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4129. if (descriptor.get) {
  4130. return descriptor.get.call(receiver);
  4131. }
  4132. return descriptor.value;
  4133. }
  4134. const Youtube_defaultTasksTemplate = {
  4135. channels: [],
  4136. likes: []
  4137. };
  4138. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4139. const getInfo = async function(link, type) {
  4140. try {
  4141. const logStatus = scripts_echoLog({
  4142. text: i18n('gettingYtbToken')
  4143. });
  4144. const {
  4145. result,
  4146. statusText,
  4147. status,
  4148. data
  4149. } = await tools_httpRequest({
  4150. url: link,
  4151. method: 'GET'
  4152. });
  4153. if (result === 'Success') {
  4154. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4155. var _data$responseText$ma, _ref;
  4156. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4157. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4158. return {
  4159. needLogin: true
  4160. };
  4161. }
  4162. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4163. 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]) || '{}';
  4164. const {
  4165. client,
  4166. request
  4167. } = JSON.parse(context);
  4168. if (apiKey && client && request) {
  4169. client.hl = 'en';
  4170. if (type === 'channel') {
  4171. var _data$responseText$ma2;
  4172. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4173. if (channelId) {
  4174. logStatus.success();
  4175. return {
  4176. params: {
  4177. apiKey: apiKey,
  4178. client: client,
  4179. request: request,
  4180. channelId: channelId
  4181. }
  4182. };
  4183. }
  4184. logStatus.error('Error: Get "channelId" failed!');
  4185. return {};
  4186. } else if (type === 'likeVideo') {
  4187. var _data$responseText$ma3, _data$responseText$ma4;
  4188. 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];
  4189. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4190. if (videoId) {
  4191. logStatus.success();
  4192. return {
  4193. params: {
  4194. apiKey: apiKey,
  4195. client: client,
  4196. request: request,
  4197. videoId: videoId,
  4198. likeParams: likeParams
  4199. }
  4200. };
  4201. }
  4202. logStatus.error('Error: Get "videoId" failed!');
  4203. return {};
  4204. }
  4205. logStatus.error('Error: Unknown type');
  4206. return {};
  4207. }
  4208. logStatus.error('Error: Parameter "apiKey" not found!');
  4209. return {};
  4210. }
  4211. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4212. return {};
  4213. }
  4214. logStatus.error(`${result}:${statusText}(${status})`);
  4215. return {};
  4216. } catch (error) {
  4217. throwError(error, 'Youtube.getInfo');
  4218. return {};
  4219. }
  4220. };
  4221. var Youtube_auth = new WeakMap();
  4222. var Youtube_initialized = new WeakMap();
  4223. var _verifyChannel = new WeakMap();
  4224. var Youtube_verifyAuth = new WeakSet();
  4225. var Youtube_updateAuth = new WeakSet();
  4226. var _getInfo = new WeakSet();
  4227. var Youtube_toggleChannel = new WeakSet();
  4228. var _toggleLikeVideo = new WeakSet();
  4229. class Youtube extends social_Social {
  4230. constructor() {
  4231. var _GM_getValue;
  4232. super(...arguments);
  4233. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4234. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4235. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4236. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4237. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4238. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4239. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || JSON.parse(Youtube_defaultTasks));
  4240. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4241. writable: true,
  4242. value: GM_getValue('youtubeAuth') || {}
  4243. });
  4244. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4245. writable: true,
  4246. value: false
  4247. });
  4248. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4249. writable: true,
  4250. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4251. });
  4252. }
  4253. async init() {
  4254. try {
  4255. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4256. return true;
  4257. }
  4258. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4259. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4260. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4261. return true;
  4262. }
  4263. return false;
  4264. }
  4265. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4266. if (isVerified) {
  4267. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4268. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4269. return true;
  4270. }
  4271. GM_setValue('youtubeAuth', null);
  4272. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4273. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4274. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4275. return true;
  4276. }
  4277. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4278. return false;
  4279. } catch (error) {
  4280. throwError(error, 'Youtube.init');
  4281. return false;
  4282. }
  4283. }
  4284. async toggle(_ref2) {
  4285. let {
  4286. doTask = true,
  4287. channelLinks = [],
  4288. videoLinks = []
  4289. } = _ref2;
  4290. try {
  4291. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4292. scripts_echoLog({
  4293. text: i18n('needInit')
  4294. });
  4295. return false;
  4296. }
  4297. const prom = [];
  4298. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4299. scripts_echoLog({
  4300. type: 'globalOptionsSkip',
  4301. text: 'youtube.channels'
  4302. });
  4303. } else {
  4304. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4305. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4306. var _link$match;
  4307. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4308. }
  4309. return link;
  4310. });
  4311. if (realChannels.length > 0) {
  4312. for (const channel of realChannels) {
  4313. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4314. link: channel,
  4315. doTask: doTask
  4316. }));
  4317. await delay(1e3);
  4318. }
  4319. }
  4320. }
  4321. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4322. scripts_echoLog({
  4323. type: 'globalOptionsSkip',
  4324. text: 'youtube.likes'
  4325. });
  4326. } else {
  4327. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4328. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4329. var _link$match2;
  4330. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4331. }
  4332. return link;
  4333. });
  4334. if (realLikes.length > 0) {
  4335. for (const video of realLikes) {
  4336. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4337. link: video,
  4338. doTask: doTask
  4339. }));
  4340. await delay(1e3);
  4341. }
  4342. }
  4343. }
  4344. return Promise.all(prom).then(() => true);
  4345. } catch (error) {
  4346. throwError(error, 'Youtube.toggle');
  4347. return false;
  4348. }
  4349. }
  4350. }
  4351. async function Youtube_verifyAuth2() {
  4352. try {
  4353. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4354. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4355. doTask: true,
  4356. verify: true
  4357. });
  4358. } catch (error) {
  4359. throwError(error, 'Youtube.verifyAuth');
  4360. return false;
  4361. }
  4362. }
  4363. async function Youtube_updateAuth2() {
  4364. try {
  4365. const logStatus = scripts_echoLog({
  4366. text: i18n('updatingAuth', 'Youtube')
  4367. });
  4368. return await new Promise(resolve => {
  4369. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4370. active: true,
  4371. insert: true,
  4372. setParent: true
  4373. });
  4374. newTab.onclose = async () => {
  4375. const auth = GM_getValue('youtubeAuth');
  4376. if (auth) {
  4377. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4378. logStatus.success();
  4379. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4380. resolve(result);
  4381. });
  4382. } else {
  4383. logStatus.error('Error: Update youtube auth failed!');
  4384. resolve(false);
  4385. }
  4386. };
  4387. });
  4388. } catch (error) {
  4389. throwError(error, 'Discord.updateAuth');
  4390. return false;
  4391. }
  4392. }
  4393. function _getInfo2(link, type) {
  4394. return getInfo(link, type);
  4395. }
  4396. async function Youtube_toggleChannel2(_ref3) {
  4397. let {
  4398. link,
  4399. doTask = true,
  4400. verify = false
  4401. } = _ref3;
  4402. try {
  4403. const {
  4404. params,
  4405. needLogin
  4406. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4407. const {
  4408. apiKey,
  4409. client,
  4410. request,
  4411. channelId
  4412. } = params || {};
  4413. if (needLogin) {
  4414. scripts_echoLog({
  4415. html: i18n('loginYtb')
  4416. });
  4417. return false;
  4418. }
  4419. if (!(apiKey && client && request && channelId)) {
  4420. scripts_echoLog({
  4421. text: '"getYtbToken" failed'
  4422. });
  4423. return false;
  4424. }
  4425. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4426. scripts_echoLog({
  4427. type: 'whiteList',
  4428. text: 'Youtube.unfollowChannel',
  4429. id: channelId
  4430. });
  4431. return true;
  4432. }
  4433. const logStatus = verify ? scripts_echoLog({
  4434. text: i18n('verifyingAuth', 'Youtube')
  4435. }) : scripts_echoLog({
  4436. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4437. text: channelId
  4438. });
  4439. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4440. const {
  4441. result,
  4442. statusText,
  4443. status,
  4444. data
  4445. } = await tools_httpRequest({
  4446. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4447. method: 'POST',
  4448. headers: {
  4449. origin: 'https://www.youtube.com',
  4450. referer: `https://www.youtube.com/channel/${channelId}`,
  4451. 'content-type': 'application/json',
  4452. 'x-goog-authuser': '0',
  4453. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4454. 'x-origin': 'https://www.youtube.com',
  4455. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4456. },
  4457. data: JSON.stringify({
  4458. context: {
  4459. client: client,
  4460. request: {
  4461. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4462. internalExperimentFlags: [],
  4463. consistencyTokenJars: []
  4464. },
  4465. user: {}
  4466. },
  4467. channelIds: [ channelId ],
  4468. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4469. })
  4470. });
  4471. if (result === 'Success') {
  4472. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4473. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4474. logStatus.success();
  4475. if (doTask && !verify) {
  4476. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4477. }
  4478. return true;
  4479. }
  4480. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4481. logStatus.success();
  4482. return true;
  4483. }
  4484. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4485. return false;
  4486. }
  4487. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4488. return false;
  4489. }
  4490. logStatus.error(`${result}:${statusText}(${status})`);
  4491. return false;
  4492. } catch (error) {
  4493. throwError(error, 'Youtube.toggleChannel');
  4494. return false;
  4495. }
  4496. }
  4497. async function _toggleLikeVideo2(_ref4) {
  4498. let {
  4499. link,
  4500. doTask = true
  4501. } = _ref4;
  4502. try {
  4503. const {
  4504. params,
  4505. needLogin
  4506. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4507. const {
  4508. apiKey,
  4509. client,
  4510. request,
  4511. videoId,
  4512. likeParams
  4513. } = params || {};
  4514. if (needLogin) {
  4515. scripts_echoLog({
  4516. html: `${i18n('loginYtb')}`
  4517. });
  4518. return false;
  4519. }
  4520. if (!(apiKey && client && request && videoId && likeParams)) {
  4521. scripts_echoLog({
  4522. text: '"getYtbToken" failed'
  4523. });
  4524. return false;
  4525. }
  4526. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4527. scripts_echoLog({
  4528. type: 'whiteList',
  4529. text: 'Youtube.unlikeVideo',
  4530. id: videoId
  4531. });
  4532. return true;
  4533. }
  4534. const logStatus = scripts_echoLog({
  4535. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4536. text: videoId
  4537. });
  4538. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4539. const likeVideoData = {
  4540. context: {
  4541. client: client,
  4542. request: {
  4543. sessionId: request.sessionId,
  4544. internalExperimentFlags: [],
  4545. consistencyTokenJars: []
  4546. },
  4547. user: {}
  4548. },
  4549. target: {
  4550. videoId: videoId
  4551. }
  4552. };
  4553. if (doTask) {
  4554. if (likeParams) {
  4555. likeVideoData.params = likeParams;
  4556. } else {
  4557. logStatus.error('Empty likeParams');
  4558. return false;
  4559. }
  4560. }
  4561. const {
  4562. result,
  4563. statusText,
  4564. status,
  4565. data
  4566. } = await tools_httpRequest({
  4567. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4568. method: 'POST',
  4569. headers: {
  4570. origin: 'https://www.youtube.com',
  4571. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4572. 'content-type': 'application/json',
  4573. 'x-goog-authuser': '0',
  4574. 'x-goog-visitor-id': client.visitorData,
  4575. 'x-origin': 'https://www.youtube.com',
  4576. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4577. },
  4578. data: JSON.stringify(likeVideoData)
  4579. });
  4580. if (result === 'Success') {
  4581. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4582. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4583. logStatus.success();
  4584. if (doTask) {
  4585. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4586. }
  4587. return true;
  4588. }
  4589. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4590. return false;
  4591. }
  4592. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4593. return false;
  4594. }
  4595. logStatus.error(`${result}:${statusText}(${status})`);
  4596. return false;
  4597. } catch (error) {
  4598. throwError(error, 'Youtube.toggleLikeVideo');
  4599. return false;
  4600. }
  4601. }
  4602. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4603. Steam_checkPrivateRedeclaration(obj, privateSet);
  4604. privateSet.add(obj);
  4605. }
  4606. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4607. Steam_checkPrivateRedeclaration(obj, privateMap);
  4608. privateMap.set(obj, value);
  4609. }
  4610. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4611. if (privateCollection.has(obj)) {
  4612. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4613. }
  4614. }
  4615. function Steam_defineProperty(obj, key, value) {
  4616. if (key in obj) {
  4617. Object.defineProperty(obj, key, {
  4618. value: value,
  4619. enumerable: true,
  4620. configurable: true,
  4621. writable: true
  4622. });
  4623. } else {
  4624. obj[key] = value;
  4625. }
  4626. return obj;
  4627. }
  4628. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4629. if (!privateSet.has(receiver)) {
  4630. throw new TypeError('attempted to get private field on non-instance');
  4631. }
  4632. return fn;
  4633. }
  4634. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4635. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4636. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4637. return value;
  4638. }
  4639. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4640. if (descriptor.set) {
  4641. descriptor.set.call(receiver, value);
  4642. } else {
  4643. if (!descriptor.writable) {
  4644. throw new TypeError('attempted to set read only private field');
  4645. }
  4646. descriptor.value = value;
  4647. }
  4648. }
  4649. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4650. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4651. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4652. }
  4653. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4654. if (!privateMap.has(receiver)) {
  4655. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4656. }
  4657. return privateMap.get(receiver);
  4658. }
  4659. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4660. if (descriptor.get) {
  4661. return descriptor.get.call(receiver);
  4662. }
  4663. return descriptor.value;
  4664. }
  4665. const Steam_defaultTasksTemplate = {
  4666. groups: [],
  4667. wishlists: [],
  4668. follows: [],
  4669. forums: [],
  4670. workshops: [],
  4671. workshopVotes: [],
  4672. curators: [],
  4673. curatorLikes: [],
  4674. announcements: [],
  4675. licenses: [],
  4676. playtests: []
  4677. };
  4678. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4679. var Steam_cache = new WeakMap();
  4680. var Steam_auth = new WeakMap();
  4681. var _storeInitialized = new WeakMap();
  4682. var _communityInitialized = new WeakMap();
  4683. var _area = new WeakMap();
  4684. var _updateStoreAuth = new WeakSet();
  4685. var _updateCommunityAuth = new WeakSet();
  4686. var _getAreaInfo = new WeakSet();
  4687. var _changeArea = new WeakSet();
  4688. var _joinGroup = new WeakSet();
  4689. var _leaveGroup = new WeakSet();
  4690. var _getGroupId = new WeakSet();
  4691. var _addToWishlist = new WeakSet();
  4692. var _removeFromWishlist = new WeakSet();
  4693. var _toggleFollowGame = new WeakSet();
  4694. var _isFollowedGame = new WeakSet();
  4695. var _toggleForum = new WeakSet();
  4696. var _getForumId = new WeakSet();
  4697. var _toggleFavoriteWorkshop = new WeakSet();
  4698. var _getWorkshopAppId = new WeakSet();
  4699. var _voteUpWorkshop = new WeakSet();
  4700. var _toggleCurator = new WeakSet();
  4701. var _toggleCuratorLike = new WeakSet();
  4702. var _getAnnouncementParams = new WeakSet();
  4703. var _likeAnnouncement = new WeakSet();
  4704. var _appid2subid = new WeakSet();
  4705. var _getLicenses = new WeakSet();
  4706. var _addLicense = new WeakSet();
  4707. var _addFreeLicense = new WeakSet();
  4708. var _requestPlayTestAccess = new WeakSet();
  4709. var Steam_setCache = new WeakSet();
  4710. class Steam extends social_Social {
  4711. constructor() {
  4712. var _GM_getValue;
  4713. super(...arguments);
  4714. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4715. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4716. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4717. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4718. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4719. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4720. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4721. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4722. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4723. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4724. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4725. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4726. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4727. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4728. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4729. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4730. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4731. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4732. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4733. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4734. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4735. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4736. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4737. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4738. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4739. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4740. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4741. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || JSON.parse(Steam_defaultTasks));
  4742. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4743. writable: true,
  4744. value: GM_getValue('steamCache') || {
  4745. group: {},
  4746. forum: {},
  4747. workshop: {},
  4748. curator: {}
  4749. }
  4750. });
  4751. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4752. writable: true,
  4753. value: {}
  4754. });
  4755. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4756. writable: true,
  4757. value: false
  4758. });
  4759. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4760. writable: true,
  4761. value: false
  4762. });
  4763. Steam_classPrivateFieldInitSpec(this, _area, {
  4764. writable: true,
  4765. value: 'CN'
  4766. });
  4767. }
  4768. async init() {
  4769. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4770. try {
  4771. if (type === 'store') {
  4772. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4773. return true;
  4774. }
  4775. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4776. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4777. return true;
  4778. }
  4779. if (type === 'community') {
  4780. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4781. return true;
  4782. }
  4783. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4784. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4785. return true;
  4786. }
  4787. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4788. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4789. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4790. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4791. return true;
  4792. }
  4793. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4794. return false;
  4795. } catch (error) {
  4796. throwError(error, 'Steam.init');
  4797. return false;
  4798. }
  4799. }
  4800. async getCuratorId(path, name) {
  4801. try {
  4802. const logStatus = scripts_echoLog({
  4803. type: 'gettingCuratorId',
  4804. text: `${path}/${name}`
  4805. });
  4806. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4807. if (curatorId) {
  4808. logStatus.success();
  4809. return curatorId;
  4810. }
  4811. const {
  4812. result,
  4813. statusText,
  4814. status,
  4815. data
  4816. } = await tools_httpRequest({
  4817. url: `https://store.steampowered.com/${path}/${name}`,
  4818. method: 'GET',
  4819. headers: {
  4820. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4821. }
  4822. });
  4823. if (result === 'Success') {
  4824. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4825. var _data$responseText$ma;
  4826. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4827. if (curatorId) {
  4828. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4829. logStatus.success();
  4830. return curatorId;
  4831. }
  4832. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4833. return false;
  4834. }
  4835. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4836. return false;
  4837. }
  4838. logStatus.error(`${result}:${statusText}(${status})`);
  4839. return false;
  4840. } catch (error) {
  4841. throwError(error, 'Steam.getCuratorID');
  4842. return false;
  4843. }
  4844. }
  4845. async toggle(_ref) {
  4846. let {
  4847. doTask = true,
  4848. groupLinks = [],
  4849. wishlistLinks = [],
  4850. followLinks = [],
  4851. forumLinks = [],
  4852. workshopLinks = [],
  4853. workshopVoteLinks = [],
  4854. curatorLinks = [],
  4855. curatorLikeLinks = [],
  4856. announcementLinks = [],
  4857. licenseLinks = [],
  4858. playtestLinks = []
  4859. } = _ref;
  4860. try {
  4861. if ([ ...groupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4862. scripts_echoLog({
  4863. text: i18n('needInit')
  4864. });
  4865. return false;
  4866. }
  4867. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4868. scripts_echoLog({
  4869. text: i18n('needInit')
  4870. });
  4871. return false;
  4872. }
  4873. const prom = [];
  4874. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4875. scripts_echoLog({
  4876. type: 'globalOptionsSkip',
  4877. text: 'steam.groups'
  4878. });
  4879. } else {
  4880. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4881. var _link$match;
  4882. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4883. });
  4884. if (realGroups.length > 0) {
  4885. for (const group of realGroups) {
  4886. if (doTask) {
  4887. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4888. } else {
  4889. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4890. }
  4891. await delay(1e3);
  4892. }
  4893. }
  4894. }
  4895. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4896. scripts_echoLog({
  4897. type: 'globalOptionsSkip',
  4898. text: 'steam.wishlists'
  4899. });
  4900. } else {
  4901. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4902. var _link$match2;
  4903. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4904. });
  4905. if (realWishlists.length > 0) {
  4906. for (const game of realWishlists) {
  4907. if (doTask) {
  4908. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4909. } else {
  4910. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4911. }
  4912. await delay(1e3);
  4913. }
  4914. }
  4915. }
  4916. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4917. scripts_echoLog({
  4918. type: 'globalOptionsSkip',
  4919. text: 'steam.follows'
  4920. });
  4921. } else {
  4922. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4923. var _link$match3;
  4924. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4925. });
  4926. if (realFollows.length > 0) {
  4927. for (const game of realFollows) {
  4928. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4929. await delay(1e3);
  4930. }
  4931. }
  4932. }
  4933. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4934. scripts_echoLog({
  4935. type: 'globalOptionsSkip',
  4936. text: 'steam.forums'
  4937. });
  4938. } else {
  4939. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4940. var _link$match4;
  4941. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4942. });
  4943. if (realForums.length > 0) {
  4944. for (const forum of realForums) {
  4945. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4946. await delay(1e3);
  4947. }
  4948. }
  4949. }
  4950. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4951. scripts_echoLog({
  4952. type: 'globalOptionsSkip',
  4953. text: 'steam.workshops'
  4954. });
  4955. } else {
  4956. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4957. var _link$match5;
  4958. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4959. });
  4960. if (realWorkshops.length > 0) {
  4961. for (const workshop of realWorkshops) {
  4962. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4963. await delay(1e3);
  4964. }
  4965. }
  4966. }
  4967. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4968. scripts_echoLog({
  4969. type: 'globalOptionsSkip',
  4970. text: 'steam.workshopVotes'
  4971. });
  4972. } else {
  4973. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4974. var _link$match6;
  4975. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4976. });
  4977. if (doTask && realworkshopVotes.length > 0) {
  4978. for (const workshop of realworkshopVotes) {
  4979. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4980. await delay(1e3);
  4981. }
  4982. }
  4983. }
  4984. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4985. scripts_echoLog({
  4986. type: 'globalOptionsSkip',
  4987. text: 'steam.curators'
  4988. });
  4989. } else {
  4990. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4991. var _link$match7;
  4992. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4993. });
  4994. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4995. var _link$match8;
  4996. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4997. });
  4998. if (realCurators.length > 0) {
  4999. for (const curator of realCurators) {
  5000. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5001. await delay(1e3);
  5002. }
  5003. }
  5004. if (realCuratorLikes.length > 0) {
  5005. for (const curatorLike of realCuratorLikes) {
  5006. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5007. await delay(1e3);
  5008. }
  5009. }
  5010. }
  5011. if (doTask && !globalOptions.doTask.steam.announcements) {
  5012. scripts_echoLog({
  5013. type: 'globalOptionsSkip',
  5014. text: 'steam.announcements'
  5015. });
  5016. } else {
  5017. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5018. var _link$match10;
  5019. if (link.includes('store.steampowered.com')) {
  5020. var _link$match9;
  5021. 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('/');
  5022. }
  5023. 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('/');
  5024. });
  5025. if (doTask && realAnnouncements.length > 0) {
  5026. for (const id of realAnnouncements) {
  5027. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5028. await delay(1e3);
  5029. }
  5030. }
  5031. }
  5032. if (doTask && !globalOptions.doTask.steam.licenses) {
  5033. scripts_echoLog({
  5034. type: 'globalOptionsSkip',
  5035. text: 'steam.licenses'
  5036. });
  5037. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5038. for (const id of licenseLinks) {
  5039. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5040. await delay(1e3);
  5041. }
  5042. }
  5043. if (doTask && !globalOptions.doTask.steam.playtests) {
  5044. scripts_echoLog({
  5045. type: 'globalOptionsSkip',
  5046. text: 'steam.playtests'
  5047. });
  5048. } else {
  5049. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5050. var _link$match11;
  5051. return (_link$match11 = link.match(/app\/([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1];
  5052. });
  5053. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5054. for (const id of realPlaytests) {
  5055. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5056. await delay(1e3);
  5057. }
  5058. }
  5059. }
  5060. return Promise.all(prom).then(async () => {
  5061. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5062. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5063. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5064. }
  5065. return true;
  5066. });
  5067. } catch (error) {
  5068. throwError(error, 'Steam.toggle');
  5069. return false;
  5070. }
  5071. }
  5072. }
  5073. async function _updateStoreAuth2() {
  5074. try {
  5075. const logStatus = scripts_echoLog({
  5076. text: i18n('updatingAuth', i18n('steamStore'))
  5077. });
  5078. const {
  5079. result,
  5080. statusText,
  5081. status,
  5082. data
  5083. } = await tools_httpRequest({
  5084. url: 'https://store.steampowered.com/stats/',
  5085. method: 'GET'
  5086. });
  5087. if (result === 'Success') {
  5088. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5089. var _data$responseText$ma2;
  5090. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5091. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5092. return false;
  5093. }
  5094. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5095. if (storeSessionID) {
  5096. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5097. logStatus.success();
  5098. return true;
  5099. }
  5100. logStatus.error('Error: Get "sessionID" failed');
  5101. return false;
  5102. }
  5103. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5104. return false;
  5105. }
  5106. logStatus.error(`${result}:${statusText}(${status})`);
  5107. return false;
  5108. } catch (error) {
  5109. throwError(error, 'Steam.updateStoreAuth');
  5110. return false;
  5111. }
  5112. }
  5113. async function _updateCommunityAuth2() {
  5114. try {
  5115. const logStatus = scripts_echoLog({
  5116. text: i18n('updatingAuth', i18n('steamCommunity'))
  5117. });
  5118. const {
  5119. result,
  5120. statusText,
  5121. status,
  5122. data
  5123. } = await tools_httpRequest({
  5124. url: 'https://steamcommunity.com/my',
  5125. method: 'GET'
  5126. });
  5127. if (result === 'Success') {
  5128. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5129. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5130. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5131. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5132. return false;
  5133. }
  5134. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5135. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5136. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5137. if (steam64Id) {
  5138. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5139. }
  5140. if (userName) {
  5141. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5142. }
  5143. if (communitySessionID) {
  5144. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5145. logStatus.success();
  5146. return true;
  5147. }
  5148. logStatus.error('Error: Get "sessionID" failed');
  5149. return false;
  5150. }
  5151. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5152. return false;
  5153. }
  5154. logStatus.error(`${result}:${statusText}(${status})`);
  5155. return false;
  5156. } catch (error) {
  5157. throwError(error, 'Steam.updateCommunityAuth');
  5158. return false;
  5159. }
  5160. }
  5161. async function _getAreaInfo2() {
  5162. try {
  5163. const logStatus = scripts_echoLog({
  5164. text: i18n('gettingAreaInfo')
  5165. });
  5166. const {
  5167. result,
  5168. statusText,
  5169. status,
  5170. data
  5171. } = await tools_httpRequest({
  5172. url: 'https://store.steampowered.com/cart/',
  5173. method: 'GET'
  5174. });
  5175. if (result === 'Success') {
  5176. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5177. var _data$responseText$ma6;
  5178. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5179. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5180. if (currentArea && areas.length > 0) {
  5181. Steam_classPrivateFieldSet(this, _area, currentArea);
  5182. logStatus.success();
  5183. return {
  5184. currentArea: currentArea,
  5185. areas: areas
  5186. };
  5187. }
  5188. logStatus.error('Error: get country info filed');
  5189. return {};
  5190. }
  5191. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5192. return {};
  5193. }
  5194. logStatus.error(`${result}:${statusText}(${status})`);
  5195. return {};
  5196. } catch (error) {
  5197. throwError(error, 'Steam.getAreaInfo');
  5198. return {};
  5199. }
  5200. }
  5201. async function _changeArea2(area) {
  5202. try {
  5203. let aimedArea = area;
  5204. if (!aimedArea) {
  5205. const {
  5206. currentArea,
  5207. areas
  5208. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5209. if (!currentArea || !areas) {
  5210. return false;
  5211. }
  5212. if (currentArea !== 'CN') {
  5213. scripts_echoLog({
  5214. text: 'notNeededChangeArea'
  5215. });
  5216. return 'skip';
  5217. }
  5218. const anotherArea = areas.filter(area => area && area !== 'CN');
  5219. if (!anotherArea || anotherArea.length === 0) {
  5220. scripts_echoLog({
  5221. text: 'noAnotherArea'
  5222. });
  5223. return false;
  5224. }
  5225. [ aimedArea ] = anotherArea;
  5226. }
  5227. const logStatus = scripts_echoLog({
  5228. text: i18n('changingArea', aimedArea)
  5229. });
  5230. const {
  5231. result,
  5232. statusText,
  5233. status,
  5234. data
  5235. } = await tools_httpRequest({
  5236. url: 'https://store.steampowered.com/account/setcountry',
  5237. method: 'POST',
  5238. headers: {
  5239. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5240. },
  5241. data: $.param({
  5242. cc: aimedArea,
  5243. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5244. })
  5245. });
  5246. if (result === 'Success') {
  5247. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5248. const {
  5249. currentArea
  5250. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5251. if (currentArea === aimedArea) {
  5252. logStatus.success();
  5253. return currentArea;
  5254. }
  5255. logStatus.error('Error: change country filed');
  5256. return 'CN';
  5257. }
  5258. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5259. return 'CN';
  5260. }
  5261. logStatus.error(`${result}:${statusText}(${status})`);
  5262. return 'CN';
  5263. } catch (error) {
  5264. throwError(error, 'Steam.changeArea');
  5265. return false;
  5266. }
  5267. }
  5268. async function _joinGroup2(groupName) {
  5269. try {
  5270. const logStatus = scripts_echoLog({
  5271. type: 'joiningSteamGroup',
  5272. text: groupName
  5273. });
  5274. const {
  5275. result,
  5276. statusText,
  5277. status,
  5278. data
  5279. } = await tools_httpRequest({
  5280. url: `https://steamcommunity.com/groups/${groupName}`,
  5281. method: 'POST',
  5282. headers: {
  5283. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5284. },
  5285. data: $.param({
  5286. action: 'join',
  5287. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5288. })
  5289. });
  5290. if (result === 'Success') {
  5291. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5292. logStatus.success();
  5293. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5294. return true;
  5295. }
  5296. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5297. return false;
  5298. }
  5299. logStatus.error(`${result}:${statusText}(${status})`);
  5300. return false;
  5301. } catch (error) {
  5302. throwError(error, 'Steam.joinGroup');
  5303. return false;
  5304. }
  5305. }
  5306. async function _leaveGroup2(groupName) {
  5307. try {
  5308. if (this.whiteList.groups.includes(groupName)) {
  5309. scripts_echoLog({
  5310. type: 'whiteList',
  5311. text: 'Steam.leaveGroup',
  5312. id: groupName
  5313. });
  5314. return true;
  5315. }
  5316. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5317. if (!groupId) {
  5318. return false;
  5319. }
  5320. const logStatus = scripts_echoLog({
  5321. type: 'leavingSteamGroup',
  5322. text: groupName
  5323. });
  5324. const {
  5325. result,
  5326. statusText,
  5327. status,
  5328. data
  5329. } = await tools_httpRequest({
  5330. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5331. method: 'POST',
  5332. headers: {
  5333. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5334. },
  5335. data: $.param({
  5336. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5337. action: 'leaveGroup',
  5338. groupId: groupId
  5339. })
  5340. });
  5341. if (result === 'Success') {
  5342. 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) {
  5343. logStatus.success();
  5344. return true;
  5345. }
  5346. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5347. return false;
  5348. }
  5349. logStatus.error(`${result}:${statusText}(${status})`);
  5350. return false;
  5351. } catch (error) {
  5352. throwError(error, 'Steam.leaveGroup');
  5353. return false;
  5354. }
  5355. }
  5356. async function _getGroupId2(groupName) {
  5357. try {
  5358. const logStatus = scripts_echoLog({
  5359. type: 'gettingSteamGroupId',
  5360. text: groupName
  5361. });
  5362. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5363. if (groupId) {
  5364. logStatus.success();
  5365. return groupId;
  5366. }
  5367. const {
  5368. result,
  5369. statusText,
  5370. status,
  5371. data
  5372. } = await tools_httpRequest({
  5373. url: `https://steamcommunity.com/groups/${groupName}`,
  5374. method: 'GET',
  5375. headers: {
  5376. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5377. }
  5378. });
  5379. if (result === 'Success') {
  5380. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5381. var _data$responseText$ma7;
  5382. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5383. if (groupId) {
  5384. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5385. logStatus.success();
  5386. return groupId;
  5387. }
  5388. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5389. return false;
  5390. }
  5391. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5392. return false;
  5393. }
  5394. logStatus.error(`${result}:${statusText}(${status})`);
  5395. return false;
  5396. } catch (error) {
  5397. throwError(error, 'Steam.getGroupID');
  5398. return false;
  5399. }
  5400. }
  5401. async function _addToWishlist2(gameId) {
  5402. try {
  5403. var _data$response;
  5404. const logStatus = scripts_echoLog({
  5405. type: 'addingToWishlist',
  5406. text: gameId
  5407. });
  5408. const {
  5409. result,
  5410. data
  5411. } = await tools_httpRequest({
  5412. url: 'https://store.steampowered.com/api/addtowishlist',
  5413. method: 'POST',
  5414. headers: {
  5415. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5416. },
  5417. data: $.param({
  5418. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5419. appid: gameId
  5420. }),
  5421. dataType: 'json'
  5422. });
  5423. 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) {
  5424. logStatus.success();
  5425. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5426. return true;
  5427. }
  5428. const {
  5429. result: resultR,
  5430. statusText: statusTextR,
  5431. status: statusR,
  5432. data: dataR
  5433. } = await tools_httpRequest({
  5434. url: `https://store.steampowered.com/app/${gameId}`,
  5435. method: 'GET'
  5436. });
  5437. if (resultR === 'Success') {
  5438. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5439. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5440. logStatus.warning(i18n('changeAreaNotice'));
  5441. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5442. return false;
  5443. }
  5444. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5445. }
  5446. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5447. logStatus.success();
  5448. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5449. return true;
  5450. } 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"')) {
  5451. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5452. return false;
  5453. }
  5454. logStatus.success();
  5455. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5456. return true;
  5457. }
  5458. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5459. return false;
  5460. }
  5461. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5462. return false;
  5463. } catch (error) {
  5464. throwError(error, 'Steam.addToWishlist');
  5465. return false;
  5466. }
  5467. }
  5468. async function _removeFromWishlist2(gameId) {
  5469. try {
  5470. var _data$response2;
  5471. if (this.whiteList.wishlists.includes(gameId)) {
  5472. scripts_echoLog({
  5473. type: 'whiteList',
  5474. text: 'Steam.removeFromWishlist',
  5475. id: gameId
  5476. });
  5477. return true;
  5478. }
  5479. const logStatus = scripts_echoLog({
  5480. type: 'removingFromWishlist',
  5481. text: gameId
  5482. });
  5483. const {
  5484. result,
  5485. data
  5486. } = await tools_httpRequest({
  5487. url: 'https://store.steampowered.com/api/removefromwishlist',
  5488. method: 'POST',
  5489. headers: {
  5490. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5491. },
  5492. data: $.param({
  5493. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5494. appid: gameId
  5495. }),
  5496. dataType: 'json'
  5497. });
  5498. 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) {
  5499. logStatus.success();
  5500. return true;
  5501. }
  5502. const {
  5503. result: resultR,
  5504. statusText: statusTextR,
  5505. status: statusR,
  5506. data: dataR
  5507. } = await tools_httpRequest({
  5508. url: `https://store.steampowered.com/app/${gameId}`,
  5509. method: 'GET'
  5510. });
  5511. if (resultR === 'Success') {
  5512. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5513. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5514. logStatus.warning(i18n('changeAreaNotice'));
  5515. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5516. if (!result || result === 'CN' || result === 'skip') {
  5517. return false;
  5518. }
  5519. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5520. }
  5521. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5522. logStatus.success();
  5523. return true;
  5524. }
  5525. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5526. return false;
  5527. }
  5528. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5529. return false;
  5530. }
  5531. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5532. return false;
  5533. } catch (error) {
  5534. throwError(error, 'Steam.removeFromWishlist');
  5535. return false;
  5536. }
  5537. }
  5538. async function _toggleFollowGame2(gameId, doTask) {
  5539. try {
  5540. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5541. scripts_echoLog({
  5542. type: 'whiteList',
  5543. text: 'Steam.unfollowGame',
  5544. id: gameId
  5545. });
  5546. return true;
  5547. }
  5548. const logStatus = scripts_echoLog({
  5549. type: `${doTask ? '' : 'un'}followingGame`,
  5550. text: gameId
  5551. });
  5552. const requestData = {
  5553. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5554. appid: gameId
  5555. };
  5556. if (!doTask) {
  5557. requestData.unfollow = '1';
  5558. }
  5559. const {
  5560. result,
  5561. data
  5562. } = await tools_httpRequest({
  5563. url: 'https://store.steampowered.com/explore/followgame/',
  5564. method: 'POST',
  5565. headers: {
  5566. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5567. },
  5568. data: $.param(requestData)
  5569. });
  5570. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5571. logStatus.success();
  5572. return true;
  5573. }
  5574. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5575. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5576. logStatus.warning(i18n('changeAreaNotice'));
  5577. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5578. return false;
  5579. }
  5580. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5581. }
  5582. if (doTask === followed) {
  5583. logStatus.success();
  5584. if (doTask) {
  5585. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5586. }
  5587. return true;
  5588. }
  5589. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5590. return false;
  5591. } catch (error) {
  5592. throwError(error, 'Steam.toggleFollowGame');
  5593. return false;
  5594. }
  5595. }
  5596. async function _isFollowedGame2(gameId) {
  5597. try {
  5598. const {
  5599. result,
  5600. data
  5601. } = await tools_httpRequest({
  5602. url: `https://store.steampowered.com/app/${gameId}`,
  5603. method: 'GET'
  5604. });
  5605. if (result === 'Success') {
  5606. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5607. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5608. return 'areaLocked';
  5609. }
  5610. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5611. return true;
  5612. }
  5613. return false;
  5614. }
  5615. return false;
  5616. }
  5617. return false;
  5618. } catch (error) {
  5619. throwError(error, 'Steam.isFollowedGame');
  5620. return false;
  5621. }
  5622. }
  5623. async function _toggleForum2(gameId) {
  5624. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5625. try {
  5626. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5627. scripts_echoLog({
  5628. type: 'whiteList',
  5629. text: 'Steam.unsubscribeForum',
  5630. id: gameId
  5631. });
  5632. return true;
  5633. }
  5634. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5635. if (!forumId) {
  5636. return false;
  5637. }
  5638. const logStatus = scripts_echoLog({
  5639. type: `${doTask ? '' : 'un'}subscribingForum`,
  5640. text: gameId
  5641. });
  5642. const [ id, feature ] = forumId.split('_');
  5643. const {
  5644. result,
  5645. statusText,
  5646. status,
  5647. data
  5648. } = await tools_httpRequest({
  5649. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5650. method: 'POST',
  5651. responseType: 'json',
  5652. headers: {
  5653. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5654. },
  5655. data: $.param({
  5656. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5657. })
  5658. });
  5659. if (result === 'Success') {
  5660. var _data$response3, _data$response4;
  5661. 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)) {
  5662. if (doTask) {
  5663. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5664. }
  5665. logStatus.success();
  5666. return true;
  5667. }
  5668. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5669. return true;
  5670. }
  5671. logStatus.error(`${result}:${statusText}(${status})`);
  5672. return true;
  5673. } catch (error) {
  5674. throwError(error, 'Steam.toggleForum');
  5675. return true;
  5676. }
  5677. }
  5678. async function _getForumId2(gameId) {
  5679. try {
  5680. const logStatus = scripts_echoLog({
  5681. type: 'gettingForumId',
  5682. text: gameId
  5683. });
  5684. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5685. if (forumId) {
  5686. logStatus.success();
  5687. return forumId;
  5688. }
  5689. const {
  5690. result,
  5691. statusText,
  5692. status,
  5693. data
  5694. } = await tools_httpRequest({
  5695. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5696. method: 'GET'
  5697. });
  5698. if (result === 'Success') {
  5699. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5700. var _data$responseText, _data$responseText$ma8;
  5701. 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];
  5702. if (forumId) {
  5703. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5704. logStatus.success();
  5705. return forumId;
  5706. }
  5707. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5708. return false;
  5709. }
  5710. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5711. return false;
  5712. }
  5713. logStatus.error(`${result}:${statusText}(${status})`);
  5714. return false;
  5715. } catch (error) {
  5716. throwError(error, 'Steam.getForumId');
  5717. return false;
  5718. }
  5719. }
  5720. async function _toggleFavoriteWorkshop2(id) {
  5721. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5722. try {
  5723. if (!doTask && this.whiteList.workshops.includes(id)) {
  5724. scripts_echoLog({
  5725. type: 'whiteList',
  5726. text: 'Steam.unfavoriteWorkshop',
  5727. id: id
  5728. });
  5729. return true;
  5730. }
  5731. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5732. if (!appid) {
  5733. return false;
  5734. }
  5735. const logStatus = scripts_echoLog({
  5736. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5737. text: id
  5738. });
  5739. const {
  5740. result,
  5741. statusText,
  5742. status,
  5743. data
  5744. } = await tools_httpRequest({
  5745. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5746. method: 'POST',
  5747. headers: {
  5748. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5749. },
  5750. data: $.param({
  5751. id: id,
  5752. appid: appid,
  5753. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5754. })
  5755. });
  5756. if (result === 'Success') {
  5757. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5758. if (doTask) {
  5759. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5760. }
  5761. logStatus.success();
  5762. return true;
  5763. }
  5764. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5765. return false;
  5766. }
  5767. logStatus.error(`${result}:${statusText}(${status})`);
  5768. return false;
  5769. } catch (error) {
  5770. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5771. return false;
  5772. }
  5773. }
  5774. async function _getWorkshopAppId2(id) {
  5775. try {
  5776. const logStatus = scripts_echoLog({
  5777. type: 'gettingWorkshopAppId',
  5778. text: id
  5779. });
  5780. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5781. if (appId) {
  5782. logStatus.success();
  5783. return appId;
  5784. }
  5785. const {
  5786. result,
  5787. statusText,
  5788. status,
  5789. data
  5790. } = await tools_httpRequest({
  5791. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5792. method: 'GET'
  5793. });
  5794. if (result === 'Success') {
  5795. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5796. var _data$responseText$ma9;
  5797. 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];
  5798. if (appId) {
  5799. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5800. logStatus.success();
  5801. return appId;
  5802. }
  5803. logStatus.error('Error: getWorkshopAppId failed');
  5804. return false;
  5805. }
  5806. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5807. return false;
  5808. }
  5809. logStatus.error(`${result}:${statusText}(${status})`);
  5810. return false;
  5811. } catch (error) {
  5812. throwError(error, 'Steam.getWorkshopAppId');
  5813. return false;
  5814. }
  5815. }
  5816. async function _voteUpWorkshop2(id) {
  5817. try {
  5818. const logStatus = scripts_echoLog({
  5819. type: 'votingUpWorkshop',
  5820. text: id
  5821. });
  5822. const {
  5823. result,
  5824. statusText,
  5825. status,
  5826. data
  5827. } = await tools_httpRequest({
  5828. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5829. method: 'POST',
  5830. responseType: 'json',
  5831. headers: {
  5832. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5833. },
  5834. data: $.param({
  5835. id: id,
  5836. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5837. })
  5838. });
  5839. if (result === 'Success') {
  5840. var _data$response5;
  5841. 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) {
  5842. logStatus.success();
  5843. return true;
  5844. }
  5845. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5846. return true;
  5847. }
  5848. logStatus.error(`${result}:${statusText}(${status})`);
  5849. return true;
  5850. } catch (error) {
  5851. throwError(error, 'Steam.voteupWorkshop');
  5852. return true;
  5853. }
  5854. }
  5855. async function _toggleCurator2(curatorId) {
  5856. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5857. try {
  5858. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5859. scripts_echoLog({
  5860. type: 'whiteList',
  5861. text: 'Steam.unfollowCurator',
  5862. id: curatorId
  5863. });
  5864. return true;
  5865. }
  5866. const logStatus = scripts_echoLog({
  5867. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5868. text: curatorId
  5869. });
  5870. const {
  5871. result,
  5872. statusText,
  5873. status,
  5874. data
  5875. } = await tools_httpRequest({
  5876. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5877. method: 'POST',
  5878. headers: {
  5879. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5880. },
  5881. data: $.param({
  5882. clanid: curatorId,
  5883. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5884. follow: doTask
  5885. }),
  5886. dataType: 'json'
  5887. });
  5888. if (result === 'Success') {
  5889. var _data$response6, _data$response6$succe, _data$response7;
  5890. 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) {
  5891. logStatus.success();
  5892. return true;
  5893. }
  5894. 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})`);
  5895. return false;
  5896. }
  5897. logStatus.error(`${result}:${statusText}(${status})`);
  5898. return false;
  5899. } catch (error) {
  5900. throwError(error, 'Steam.toggleCurator');
  5901. return false;
  5902. }
  5903. }
  5904. async function _toggleCuratorLike2(link) {
  5905. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5906. try {
  5907. const [ path, name ] = link.split('/');
  5908. if (!(path && name)) {
  5909. scripts_echoLog({
  5910. text: i18n('errorLink', link)
  5911. });
  5912. return false;
  5913. }
  5914. const curatorId = await this.getCuratorId(path, name);
  5915. if (curatorId) {
  5916. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5917. }
  5918. return false;
  5919. } catch (error) {
  5920. throwError(error, 'Steam.toggleCuratorLike');
  5921. return false;
  5922. }
  5923. }
  5924. async function _getAnnouncementParams2(appId, viewId) {
  5925. try {
  5926. const logStatus = scripts_echoLog({
  5927. type: 'gettingAnnouncementParams',
  5928. text: appId,
  5929. id: viewId
  5930. });
  5931. const {
  5932. result,
  5933. statusText,
  5934. status,
  5935. data
  5936. } = await tools_httpRequest({
  5937. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5938. method: 'GET',
  5939. headers: {
  5940. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5941. }
  5942. });
  5943. if (result === 'Success') {
  5944. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5945. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5946. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5947. logStatus.warning(i18n('changeAreaNotice'));
  5948. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5949. return {};
  5950. }
  5951. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5952. }
  5953. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5954. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5955. 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];
  5956. if (authWgToken && clanId) {
  5957. logStatus.success();
  5958. return {
  5959. authWgToken: authWgToken,
  5960. clanId: clanId,
  5961. gid: gid
  5962. };
  5963. }
  5964. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5965. return {};
  5966. }
  5967. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5968. return {};
  5969. }
  5970. logStatus.error(`${result}:${statusText}(${status})`);
  5971. return {};
  5972. } catch (error) {
  5973. throwError(error, 'Steam.likeAnnouncement');
  5974. return {};
  5975. }
  5976. }
  5977. async function _likeAnnouncement2(id) {
  5978. try {
  5979. const [ appId, viewId ] = id.split('/');
  5980. if (!(appId && viewId)) {
  5981. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  5982. return false;
  5983. }
  5984. const {
  5985. authWgToken,
  5986. clanId,
  5987. gid
  5988. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5989. if (!(authWgToken && clanId)) {
  5990. return false;
  5991. }
  5992. const logStatus = scripts_echoLog({
  5993. type: 'likingAnnouncement',
  5994. text: appId,
  5995. id: viewId
  5996. });
  5997. const {
  5998. result,
  5999. statusText,
  6000. status,
  6001. data
  6002. } = await tools_httpRequest({
  6003. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6004. method: 'POST',
  6005. headers: {
  6006. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6007. Host: 'store.steampowered.com',
  6008. Origin: 'https://store.steampowered.com',
  6009. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6010. },
  6011. data: $.param({
  6012. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6013. wgauthtoken: authWgToken,
  6014. voteup: 1,
  6015. clanid: clanId,
  6016. ajax: 1
  6017. }),
  6018. dataType: 'json'
  6019. });
  6020. if (result === 'Success') {
  6021. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6022. logStatus.success();
  6023. return true;
  6024. }
  6025. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6026. return false;
  6027. }
  6028. logStatus.error(`${result}:${statusText}(${status})`);
  6029. return false;
  6030. } catch (error) {
  6031. throwError(error, 'Steam.likeAnnouncement');
  6032. return false;
  6033. }
  6034. }
  6035. async function _appid2subid2(id) {
  6036. try {
  6037. const logStatus = scripts_echoLog({
  6038. type: 'gettingSubid',
  6039. text: id
  6040. });
  6041. const {
  6042. result,
  6043. statusText,
  6044. status,
  6045. data
  6046. } = await tools_httpRequest({
  6047. url: `https://store.steampowered.com/app/${id}`,
  6048. method: 'GET',
  6049. headers: {
  6050. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6051. }
  6052. });
  6053. if (result === 'Success') {
  6054. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6055. var _data$responseText$ma13;
  6056. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6057. logStatus.warning(i18n('changeAreaNotice'));
  6058. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6059. if (!result || result === 'CN' || result === 'skip') {
  6060. return false;
  6061. }
  6062. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6063. }
  6064. const subid = (_data$responseText$ma13 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6065. if (subid) {
  6066. logStatus.success();
  6067. return subid;
  6068. }
  6069. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6070. return false;
  6071. }
  6072. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6073. return false;
  6074. }
  6075. logStatus.error(`${result}:${statusText}(${status})`);
  6076. return false;
  6077. } catch (error) {
  6078. throwError(error, 'Steam.appid2subid');
  6079. return false;
  6080. }
  6081. }
  6082. async function _getLicenses2() {
  6083. try {
  6084. const logStatus = scripts_echoLog({
  6085. text: i18n('gettingLicenses')
  6086. });
  6087. const {
  6088. result,
  6089. statusText,
  6090. status,
  6091. data
  6092. } = await tools_httpRequest({
  6093. url: 'https://store.steampowered.com/account/licenses/',
  6094. method: 'GET'
  6095. });
  6096. if (result === 'Success') {
  6097. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6098. logStatus.success();
  6099. return [ ...data.responseText.matchAll(/RemoveFreeLicense\([\s]*?([\d]+)/g) ].map(arr => arr[1]).filter(subid => subid);
  6100. }
  6101. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6102. return false;
  6103. }
  6104. logStatus.error(`${result}:${statusText}(${status})`);
  6105. return false;
  6106. } catch (error) {
  6107. throwError(error, 'Steam.getLicenses');
  6108. return false;
  6109. }
  6110. }
  6111. async function _addLicense2(id) {
  6112. try {
  6113. const [ type, ids ] = id.split('-');
  6114. if (type === 'appid') {
  6115. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6116. if (!subid) {
  6117. return false;
  6118. }
  6119. const logStatus = scripts_echoLog({
  6120. type: 'addingFreeLicense',
  6121. text: ids
  6122. });
  6123. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6124. return false;
  6125. }
  6126. const {
  6127. result,
  6128. statusText,
  6129. status,
  6130. data
  6131. } = await tools_httpRequest({
  6132. url: `https://store.steampowered.com/app/${ids}`,
  6133. method: 'GET'
  6134. });
  6135. if (result === 'Success') {
  6136. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6137. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6138. logStatus.success();
  6139. return true;
  6140. }
  6141. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6142. return false;
  6143. }
  6144. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6145. return false;
  6146. }
  6147. logStatus.error(`${result}:${statusText}(${status})`);
  6148. return false;
  6149. } else if (type === 'subid') {
  6150. const logStatusArr = {};
  6151. for (const subid of ids.split(',')) {
  6152. const logStatus = scripts_echoLog({
  6153. type: 'addingFreeLicenseSubid',
  6154. text: subid
  6155. });
  6156. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6157. return false;
  6158. }
  6159. logStatusArr[subid] = logStatus;
  6160. }
  6161. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6162. if (!licenses) {
  6163. return false;
  6164. }
  6165. for (const subid of ids.split(',')) {
  6166. if (licenses.includes(subid)) {
  6167. logStatusArr[subid].success();
  6168. } else {
  6169. logStatusArr[subid].error();
  6170. }
  6171. }
  6172. return true;
  6173. }
  6174. return false;
  6175. } catch (error) {
  6176. throwError(error, 'Steam.addLicense');
  6177. return false;
  6178. }
  6179. }
  6180. async function _addFreeLicense2(id, logStatus) {
  6181. try {
  6182. const {
  6183. result,
  6184. statusText,
  6185. status,
  6186. data
  6187. } = await tools_httpRequest({
  6188. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6189. method: 'POST',
  6190. headers: {
  6191. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6192. Host: 'store.steampowered.com',
  6193. Origin: 'https://store.steampowered.com',
  6194. Referer: 'https://store.steampowered.com/account/licenses/'
  6195. },
  6196. data: $.param({
  6197. action: 'add_to_cart',
  6198. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6199. subid: id
  6200. }),
  6201. dataType: 'json'
  6202. });
  6203. if (result === 'Success') {
  6204. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6205. return true;
  6206. }
  6207. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6208. return false;
  6209. }
  6210. logStatus.error(`${result}:${statusText}(${status})`);
  6211. return false;
  6212. } catch (error) {
  6213. logStatus.error();
  6214. throwError(error, 'Steam.addFreeLicense');
  6215. return false;
  6216. }
  6217. }
  6218. async function _requestPlayTestAccess2(id) {
  6219. try {
  6220. const logStatus = scripts_echoLog({
  6221. type: 'requestingPlayTestAccess',
  6222. text: id
  6223. });
  6224. const {
  6225. result,
  6226. statusText,
  6227. status,
  6228. data
  6229. } = await tools_httpRequest({
  6230. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6231. method: 'POST',
  6232. headers: {
  6233. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6234. Host: 'store.steampowered.com',
  6235. Origin: 'https://store.steampowered.com',
  6236. Referer: `https://store.steampowered.com/app/${id}`
  6237. },
  6238. data: $.param({
  6239. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6240. }),
  6241. dataType: 'json'
  6242. });
  6243. if (result === 'Success') {
  6244. var _data$response8;
  6245. 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) {
  6246. logStatus.success();
  6247. return true;
  6248. }
  6249. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6250. return false;
  6251. }
  6252. logStatus.error(`${result}:${statusText}(${status})`);
  6253. return false;
  6254. } catch (error) {
  6255. throwError(error, 'Steam.requestPlayTestAccess');
  6256. return false;
  6257. }
  6258. }
  6259. function Steam_setCache2(type, name, id) {
  6260. try {
  6261. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6262. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6263. } catch (error) {
  6264. throwError(error, 'Steam.setCache');
  6265. }
  6266. }
  6267. const social_Steam = Steam;
  6268. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6269. Website_checkPrivateRedeclaration(obj, privateSet);
  6270. privateSet.add(obj);
  6271. }
  6272. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6273. if (privateCollection.has(obj)) {
  6274. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6275. }
  6276. }
  6277. function Website_defineProperty(obj, key, value) {
  6278. if (key in obj) {
  6279. Object.defineProperty(obj, key, {
  6280. value: value,
  6281. enumerable: true,
  6282. configurable: true,
  6283. writable: true
  6284. });
  6285. } else {
  6286. obj[key] = value;
  6287. }
  6288. return obj;
  6289. }
  6290. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6291. if (!privateSet.has(receiver)) {
  6292. throw new TypeError('attempted to get private field on non-instance');
  6293. }
  6294. return fn;
  6295. }
  6296. var _bind = new WeakSet();
  6297. class Website {
  6298. constructor() {
  6299. Website_classPrivateMethodInitSpec(this, _bind);
  6300. Website_defineProperty(this, 'undoneTasks', void 0);
  6301. Website_defineProperty(this, 'socialTasks', void 0);
  6302. Website_defineProperty(this, 'giveawayId', void 0);
  6303. Website_defineProperty(this, 'socialInitialized', {
  6304. discord: false,
  6305. instagram: false,
  6306. reddit: false,
  6307. twitch: false,
  6308. twitter: false,
  6309. vk: false,
  6310. youtube: false,
  6311. steamStore: false,
  6312. steamCommunity: false
  6313. });
  6314. Website_defineProperty(this, 'initialized', false);
  6315. Website_defineProperty(this, 'social', {});
  6316. }
  6317. async initSocial(action) {
  6318. try {
  6319. const pro = [];
  6320. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6321. if (tasks.discord) {
  6322. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6323. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6324. this.social.discord = new social_Discord();
  6325. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6326. }
  6327. }
  6328. if (tasks.instagram) {
  6329. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6330. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6331. this.social.instagram = new social_Instagram();
  6332. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6333. }
  6334. }
  6335. if (tasks.reddit) {
  6336. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6337. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6338. this.social.reddit = new social_Reddit();
  6339. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6340. }
  6341. }
  6342. if (tasks.twitch) {
  6343. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6344. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6345. this.social.twitch = new social_Twitch();
  6346. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6347. }
  6348. }
  6349. if (tasks.twitter) {
  6350. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6351. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6352. this.social.twitter = new social_Twitter();
  6353. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6354. }
  6355. }
  6356. if (tasks.vk) {
  6357. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6358. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6359. this.social.vk = new social_Vk();
  6360. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6361. }
  6362. }
  6363. if (tasks.youtube) {
  6364. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6365. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6366. this.social.youtube = new Youtube();
  6367. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6368. }
  6369. }
  6370. if (tasks.steam) {
  6371. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6372. if (steamLength > 0) {
  6373. if (!this.social.steam) {
  6374. this.social.steam = new social_Steam();
  6375. }
  6376. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6377. var _tasks$steam, _tasks$steam$type;
  6378. 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;
  6379. }).reduce((total, number) => total + number, 0);
  6380. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6381. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6382. }
  6383. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6384. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6385. }
  6386. }
  6387. }
  6388. if (tasks.links && tasks.links.length > 0) {
  6389. this.social.visitLink = visitLink;
  6390. }
  6391. return await Promise.all(pro).then(result => {
  6392. let checked = true;
  6393. for (const data of result) {
  6394. if (data.result) {
  6395. this.socialInitialized[data.name] = data.result;
  6396. } else {
  6397. checked = false;
  6398. }
  6399. }
  6400. return checked;
  6401. });
  6402. } catch (error) {
  6403. throwError(error, 'Website.initSocial');
  6404. return false;
  6405. }
  6406. }
  6407. uniqueTasks(allTasks) {
  6408. const result = {};
  6409. for (const [ social, types ] of Object.entries(allTasks)) {
  6410. result[social] = {};
  6411. for (const [ type, tasks ] of Object.entries(types)) {
  6412. result[social][type] = unique(tasks);
  6413. }
  6414. }
  6415. return result;
  6416. }
  6417. async toggleTask(action) {
  6418. try {
  6419. if (!this.initialized && !this.init()) {
  6420. return false;
  6421. }
  6422. if (!await this.classifyTask(action)) {
  6423. return false;
  6424. }
  6425. if (!await this.initSocial(action)) {
  6426. return false;
  6427. }
  6428. const pro = [];
  6429. const doTask = action === 'do';
  6430. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6431. if (this.social.discord) {
  6432. pro.push(this.social.discord.toggle({
  6433. doTask: doTask,
  6434. ...tasks.discord
  6435. }));
  6436. }
  6437. if (this.social.instagram) {
  6438. pro.push(this.social.instagram.toggle({
  6439. doTask: doTask,
  6440. ...tasks.instagram
  6441. }));
  6442. }
  6443. if (this.social.reddit) {
  6444. pro.push(this.social.reddit.toggle({
  6445. doTask: doTask,
  6446. ...tasks.reddit
  6447. }));
  6448. }
  6449. if (this.social.twitch) {
  6450. pro.push(this.social.twitch.toggle({
  6451. doTask: doTask,
  6452. ...tasks.twitch
  6453. }));
  6454. }
  6455. if (this.social.twitter) {
  6456. pro.push(this.social.twitter.toggle({
  6457. doTask: doTask,
  6458. ...tasks.twitter
  6459. }));
  6460. }
  6461. if (this.social.vk) {
  6462. pro.push(this.social.vk.toggle({
  6463. doTask: doTask,
  6464. ...tasks.vk
  6465. }));
  6466. }
  6467. if (this.social.youtube) {
  6468. pro.push(this.social.youtube.toggle({
  6469. doTask: doTask,
  6470. ...tasks.youtube
  6471. }));
  6472. }
  6473. if (this.social.steam) {
  6474. pro.push(this.social.steam.toggle({
  6475. doTask: doTask,
  6476. ...tasks.steam
  6477. }));
  6478. }
  6479. if (this.social.visitLink && tasks.links && doTask) {
  6480. for (const link of tasks.links) {
  6481. pro.push(this.social.visitLink(link));
  6482. }
  6483. }
  6484. if (doTask && tasks.extra && this.extraDoTask) {
  6485. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6486. if (hasExtra) {
  6487. pro.push(this.extraDoTask(tasks.extra));
  6488. }
  6489. }
  6490. await Promise.all(pro);
  6491. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6492. return true;
  6493. } catch (error) {
  6494. throwError(error, 'Website.toggleTask');
  6495. return false;
  6496. }
  6497. }
  6498. async doTask() {
  6499. try {
  6500. return await this.toggleTask('do');
  6501. } catch (error) {
  6502. throwError(error, 'Website.doTask');
  6503. return false;
  6504. }
  6505. }
  6506. async undoTask() {
  6507. try {
  6508. return await this.toggleTask('undo');
  6509. } catch (error) {
  6510. throwError(error, 'Website.undoTask');
  6511. return false;
  6512. }
  6513. }
  6514. }
  6515. async function _bind2(name, init) {
  6516. try {
  6517. return {
  6518. name: name,
  6519. result: await init
  6520. };
  6521. } catch (error) {
  6522. throwError(error, 'Website.bind');
  6523. return {
  6524. name: name,
  6525. result: false
  6526. };
  6527. }
  6528. }
  6529. const website_Website = Website;
  6530. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6531. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6532. privateSet.add(obj);
  6533. }
  6534. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6535. if (privateCollection.has(obj)) {
  6536. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6537. }
  6538. }
  6539. function FreeAnyWhere_defineProperty(obj, key, value) {
  6540. if (key in obj) {
  6541. Object.defineProperty(obj, key, {
  6542. value: value,
  6543. enumerable: true,
  6544. configurable: true,
  6545. writable: true
  6546. });
  6547. } else {
  6548. obj[key] = value;
  6549. }
  6550. return obj;
  6551. }
  6552. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6553. if (!privateSet.has(receiver)) {
  6554. throw new TypeError('attempted to get private field on non-instance');
  6555. }
  6556. return fn;
  6557. }
  6558. const FreeAnyWhere_defaultTasksTemplate = {
  6559. steam: {
  6560. groupLinks: [],
  6561. wishlistLinks: [],
  6562. curatorLinks: [],
  6563. followLinks: []
  6564. },
  6565. vk: {
  6566. nameLinks: []
  6567. }
  6568. };
  6569. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6570. var _getGiveawayId = new WeakSet();
  6571. var _verify = new WeakSet();
  6572. class FreeAnyWhere extends website_Website {
  6573. constructor() {
  6574. super(...arguments);
  6575. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6576. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6577. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6578. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6579. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6580. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6581. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6582. }
  6583. static test() {
  6584. return window.location.host === 'freeanywhere.net';
  6585. }
  6586. init() {
  6587. try {
  6588. const logStatus = scripts_echoLog({
  6589. text: i18n('initing')
  6590. });
  6591. if ($('a[href="#/login"]').length > 0) {
  6592. window.open('/#/login', '_self');
  6593. logStatus.warning(i18n('needLogin'));
  6594. return false;
  6595. }
  6596. if (window.location.href.includes('/login')) {
  6597. logStatus.warning(i18n('needLogin'));
  6598. return false;
  6599. }
  6600. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6601. var _window$location$href;
  6602. 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];
  6603. if (!id) {
  6604. logStatus.error(i18n('getFailed', 'Id'));
  6605. return false;
  6606. }
  6607. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6608. }
  6609. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6610. return false;
  6611. }
  6612. this.initialized = true;
  6613. logStatus.success();
  6614. return true;
  6615. } catch (error) {
  6616. throwError(error, 'Freeanywhere.init');
  6617. return false;
  6618. }
  6619. }
  6620. async classifyTask(action) {
  6621. try {
  6622. const logStatus = scripts_echoLog({
  6623. text: i18n('getTasksInfo')
  6624. });
  6625. if (action === 'undo') {
  6626. var _GM_getValue;
  6627. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6628. }
  6629. const {
  6630. result,
  6631. statusText,
  6632. status,
  6633. data
  6634. } = await tools_httpRequest({
  6635. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6636. method: 'GET',
  6637. headers: {
  6638. authorization: `Token ${window.localStorage.getItem('token')}`,
  6639. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6640. },
  6641. responseType: 'json'
  6642. });
  6643. if (result === 'Success') {
  6644. var _data$response;
  6645. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6646. if (tasks) {
  6647. if (action === 'verify') {
  6648. this.tasks = [];
  6649. }
  6650. for (const task of tasks) {
  6651. const type = task.challenge;
  6652. const social = task.challenge_provider;
  6653. const taskInfo = {
  6654. id: task.id,
  6655. title: task.title
  6656. };
  6657. if (action === 'verify' && !task.is_success) {
  6658. this.tasks.push(taskInfo);
  6659. continue;
  6660. }
  6661. switch (social) {
  6662. case 'steam':
  6663. taskInfo.social = 'steam';
  6664. switch (type) {
  6665. case 'WL':
  6666. if (action === 'undo') {
  6667. this.socialTasks.steam.wishlistLinks.push(task.link);
  6668. }
  6669. if (action === 'do' && !task.is_success) {
  6670. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6671. }
  6672. break;
  6673.  
  6674. case 'JTG':
  6675. if (action === 'undo') {
  6676. this.socialTasks.steam.groupLinks.push(task.link);
  6677. }
  6678. if (action === 'do' && !task.is_success) {
  6679. this.undoneTasks.steam.groupLinks.push(task.link);
  6680. }
  6681. break;
  6682.  
  6683. case 'STC':
  6684. if (action === 'undo') {
  6685. this.socialTasks.steam.curatorLinks.push(task.link);
  6686. }
  6687. if (action === 'do' && !task.is_success) {
  6688. this.undoneTasks.steam.curatorLinks.push(task.link);
  6689. }
  6690. break;
  6691.  
  6692. case 'GF':
  6693. if (action === 'undo') {
  6694. this.socialTasks.steam.followLinks.push(task.link);
  6695. }
  6696. if (action === 'do' && !task.is_success) {
  6697. this.undoneTasks.steam.followLinks.push(task.link);
  6698. }
  6699. break;
  6700. }
  6701. break;
  6702.  
  6703. case 'vk-oauth2':
  6704. if (action === 'undo') {
  6705. this.socialTasks.vk.nameLinks.push(task.link);
  6706. }
  6707. if (action === 'do' && !task.is_success) {
  6708. this.undoneTasks.vk.nameLinks.push(task.link);
  6709. }
  6710. break;
  6711.  
  6712. case 'website':
  6713. break;
  6714.  
  6715. default:
  6716. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6717. break;
  6718. }
  6719. }
  6720. logStatus.success();
  6721. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6722. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6723. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6724. tasks: this.socialTasks,
  6725. time: new Date().getTime()
  6726. });
  6727. return true;
  6728. }
  6729. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6730. console.error(data);
  6731. return false;
  6732. }
  6733. logStatus.error(`${result}:${statusText}(${status})`);
  6734. return false;
  6735. } catch (error) {
  6736. throwError(error, 'Freeanywhere.classifyTask');
  6737. return false;
  6738. }
  6739. }
  6740. async verifyTask() {
  6741. try {
  6742. if (!this.initialized && !this.init()) {
  6743. return false;
  6744. }
  6745. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6746. return false;
  6747. }
  6748. const pro = [];
  6749. for (const task of this.tasks) {
  6750. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6751. await delay(1e3);
  6752. }
  6753. await Promise.all(pro);
  6754. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6755. return !!await this.getKey(true);
  6756. } catch (error) {
  6757. throwError(error, 'Freeanywhere.verifyTask');
  6758. return false;
  6759. }
  6760. }
  6761. async getKey(initialized) {
  6762. try {
  6763. if (!initialized && !this.initialized && !this.init()) {
  6764. return false;
  6765. }
  6766. const logStatus = scripts_echoLog({
  6767. text: i18n('gettingKey')
  6768. });
  6769. const {
  6770. result,
  6771. statusText,
  6772. status,
  6773. data
  6774. } = await tools_httpRequest({
  6775. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6776. method: 'GET',
  6777. dataType: 'json',
  6778. headers: {
  6779. authorization: `Token ${window.localStorage.getItem('token')}`
  6780. }
  6781. });
  6782. if (result === 'Success') {
  6783. var _data$response2;
  6784. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6785. logStatus.success();
  6786. scripts_echoLog({}).success(data.response.reward);
  6787. return data.response.reward;
  6788. }
  6789. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6790. return false;
  6791. }
  6792. logStatus.error(`${result}:${statusText}(${status})`);
  6793. return false;
  6794. } catch (error) {
  6795. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6796. return false;
  6797. }
  6798. }
  6799. }
  6800. function _getGiveawayId2() {
  6801. try {
  6802. var _window$location$href2;
  6803. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6804. if (giveawayId) {
  6805. this.giveawayId = giveawayId;
  6806. return true;
  6807. }
  6808. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6809. return false;
  6810. } catch (error) {
  6811. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6812. }
  6813. }
  6814. async function _verify2(task) {
  6815. try {
  6816. const logStatus = scripts_echoLog({
  6817. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6818. });
  6819. const {
  6820. result,
  6821. statusText,
  6822. status,
  6823. data
  6824. } = await tools_httpRequest({
  6825. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6826. method: 'GET',
  6827. dataType: 'json',
  6828. headers: {
  6829. authorization: `Token ${window.localStorage.getItem('token')}`,
  6830. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6831. }
  6832. });
  6833. if (result === 'Success') {
  6834. var _data$response3;
  6835. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6836. logStatus.success();
  6837. return true;
  6838. }
  6839. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6840. return false;
  6841. }
  6842. logStatus.error(`${result}:${statusText}(${status})`);
  6843. return false;
  6844. } catch (error) {
  6845. throwError(error, 'Freeanywhere.verify');
  6846. return false;
  6847. }
  6848. }
  6849. const website_FreeAnyWhere = FreeAnyWhere;
  6850. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6851. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6852. privateSet.add(obj);
  6853. }
  6854. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6855. if (privateCollection.has(obj)) {
  6856. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6857. }
  6858. }
  6859. function GiveawaySu_defineProperty(obj, key, value) {
  6860. if (key in obj) {
  6861. Object.defineProperty(obj, key, {
  6862. value: value,
  6863. enumerable: true,
  6864. configurable: true,
  6865. writable: true
  6866. });
  6867. } else {
  6868. obj[key] = value;
  6869. }
  6870. return obj;
  6871. }
  6872. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6873. if (!privateSet.has(receiver)) {
  6874. throw new TypeError('attempted to get private field on non-instance');
  6875. }
  6876. return fn;
  6877. }
  6878. const GiveawaySu_defaultTasks = {
  6879. steam: {
  6880. groupLinks: [],
  6881. wishlistLinks: [],
  6882. curatorLinks: [],
  6883. curatorLikeLinks: [],
  6884. followLinks: [],
  6885. forumLinks: [],
  6886. announcementLinks: [],
  6887. workshopVoteLinks: [],
  6888. playtestLinks: []
  6889. },
  6890. discord: {
  6891. serverLinks: []
  6892. },
  6893. instagram: {
  6894. userLinks: []
  6895. },
  6896. vk: {
  6897. nameLinks: []
  6898. },
  6899. twitch: {
  6900. channelLinks: []
  6901. },
  6902. reddit: {
  6903. redditLinks: []
  6904. },
  6905. youtube: {
  6906. channelLinks: [],
  6907. likeLinks: []
  6908. }
  6909. };
  6910. var _checkLogin = new WeakSet();
  6911. var _checkLeftKey = new WeakSet();
  6912. var GiveawaySu_getGiveawayId = new WeakSet();
  6913. class GiveawaySu extends website_Website {
  6914. constructor() {
  6915. super(...arguments);
  6916. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6917. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6918. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6919. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6920. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6921. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6922. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6923. }
  6924. static test() {
  6925. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6926. }
  6927. async after() {
  6928. try {
  6929. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6930. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6931. }
  6932. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6933. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6934. }
  6935. scripts_echoLog({}).warning(i18n('gsNotice'));
  6936. } catch (error) {
  6937. throwError(error, 'Giveawaysu.after');
  6938. }
  6939. }
  6940. init() {
  6941. try {
  6942. const logStatus = scripts_echoLog({
  6943. text: i18n('initing')
  6944. });
  6945. if ($('a.steam-login').length > 0) {
  6946. window.open('/steam/redirect', '_self');
  6947. logStatus.warning(i18n('needLogin'));
  6948. return false;
  6949. }
  6950. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6951. return false;
  6952. }
  6953. this.initialized = true;
  6954. logStatus.success();
  6955. return true;
  6956. } catch (error) {
  6957. throwError(error, 'Giveawaysu.init');
  6958. return false;
  6959. }
  6960. }
  6961. async classifyTask(action) {
  6962. try {
  6963. const logStatus = scripts_echoLog({
  6964. text: i18n('getTasksInfo')
  6965. });
  6966. if (action === 'undo') {
  6967. var _GM_getValue;
  6968. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6969. return true;
  6970. }
  6971. const pro = [];
  6972. const tasks = $('#actions tr');
  6973. if ($('div.bind-discord').is(':visible')) {
  6974. $('div.bind-discord a')[0].click();
  6975. }
  6976. if ($('div.bind-twitch').is(':visible')) {
  6977. $('div.bind-twitch a')[0].click();
  6978. }
  6979. for (const task of tasks) {
  6980. pro.push(new Promise(resolve => {
  6981. const td = $(task).find('td:not(".hidden")');
  6982. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6983. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6984. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6985. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6986. const taskName = taskDes.text().trim();
  6987. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6988. return resolve(true);
  6989. }
  6990. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6991. if (!taskLink) {
  6992. return resolve(false);
  6993. }
  6994. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6995. this.undoneTasks.steam.groupLinks.push(taskLink);
  6996. } else if (/like.*announcement/gi.test(taskName)) {
  6997. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6998. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6999. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7000. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7001. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7002. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7003. this.undoneTasks.steam.forumLinks.push(taskLink);
  7004. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7005. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7006. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7007. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7008. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7009. this.undoneTasks.discord.serverLinks.push(taskLink);
  7010. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7011. this.undoneTasks.instagram.userLinks.push(taskLink);
  7012. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7013. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7014. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7015. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7016. } else if (/watch.*art/gim.test(taskName)) {
  7017. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7018. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7019. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7020. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7021. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7022. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7023. this.undoneTasks.vk.nameLinks.push(taskLink);
  7024. } else {
  7025. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7026. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7027. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7028. }
  7029. if (/follow.*button/gim.test(taskName)) {
  7030. this.undoneTasks.steam.followLinks.push(taskLink);
  7031. }
  7032. }
  7033. }
  7034. resolve(true);
  7035. }).catch(error => {
  7036. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7037. return false;
  7038. });
  7039. }));
  7040. }
  7041. await Promise.all(pro);
  7042. logStatus.success();
  7043. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7044. this.socialTasks = this.undoneTasks;
  7045. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7046. tasks: this.socialTasks,
  7047. time: new Date().getTime()
  7048. });
  7049. return true;
  7050. } catch (error) {
  7051. throwError(error, 'Giveawaysu.classifyTask');
  7052. return false;
  7053. }
  7054. }
  7055. }
  7056. function _checkLogin2() {
  7057. try {
  7058. if (!globalOptions.other.checkLogin) {
  7059. return true;
  7060. }
  7061. if ($('a.steam-login').length > 0) {
  7062. window.open('/steam/redirect', '_self');
  7063. }
  7064. return true;
  7065. } catch (error) {
  7066. throwError(error, 'Giveawaysu.checkLogin');
  7067. return false;
  7068. }
  7069. }
  7070. async function _checkLeftKey2() {
  7071. try {
  7072. if (!globalOptions.other.checkLeftKey) {
  7073. return true;
  7074. }
  7075. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7076. await external_Swal_default().fire({
  7077. icon: 'warning',
  7078. title: i18n('notice'),
  7079. text: i18n('noKeysLeft'),
  7080. confirmButtonText: i18n('confirm'),
  7081. cancelButtonText: i18n('cancel'),
  7082. showCancelButton: true
  7083. }).then(_ref => {
  7084. let {
  7085. value
  7086. } = _ref;
  7087. if (value) {
  7088. window.close();
  7089. }
  7090. });
  7091. }
  7092. return true;
  7093. } catch (error) {
  7094. throwError(error, 'Giveawaysu.checkLeftKey');
  7095. return false;
  7096. }
  7097. }
  7098. function GiveawaySu_getGiveawayId2() {
  7099. var _window$location$href;
  7100. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7101. if (giveawayId) {
  7102. this.giveawayId = giveawayId;
  7103. return true;
  7104. }
  7105. scripts_echoLog({
  7106. text: i18n('getFailed', 'GiveawayId')
  7107. });
  7108. return false;
  7109. }
  7110. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7111. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7112. privateSet.add(obj);
  7113. }
  7114. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7115. if (privateCollection.has(obj)) {
  7116. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7117. }
  7118. }
  7119. function Indiedb_defineProperty(obj, key, value) {
  7120. if (key in obj) {
  7121. Object.defineProperty(obj, key, {
  7122. value: value,
  7123. enumerable: true,
  7124. configurable: true,
  7125. writable: true
  7126. });
  7127. } else {
  7128. obj[key] = value;
  7129. }
  7130. return obj;
  7131. }
  7132. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7133. if (!privateSet.has(receiver)) {
  7134. throw new TypeError('attempted to get private field on non-instance');
  7135. }
  7136. return fn;
  7137. }
  7138. var _join = new WeakSet();
  7139. var _do = new WeakSet();
  7140. var Indiedb_checkLogin = new WeakSet();
  7141. var Indiedb_checkLeftKey = new WeakSet();
  7142. class Indiedb {
  7143. constructor() {
  7144. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7145. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7146. Indiedb_classPrivateMethodInitSpec(this, _do);
  7147. Indiedb_classPrivateMethodInitSpec(this, _join);
  7148. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7149. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7150. }
  7151. static test() {
  7152. return window.location.host === 'www.indiedb.com';
  7153. }
  7154. async after() {
  7155. try {
  7156. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7157. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7158. }
  7159. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7160. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7161. }
  7162. } catch (error) {
  7163. throwError(error, 'Indiedb.after');
  7164. }
  7165. }
  7166. async doTask() {
  7167. try {
  7168. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7169. return false;
  7170. }
  7171. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7172. } catch (error) {
  7173. throwError(error, 'Indiedb.doTask');
  7174. return false;
  7175. }
  7176. }
  7177. }
  7178. async function _join2() {
  7179. try {
  7180. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7181. scripts_echoLog({}).error(i18n('needLogin'));
  7182. return false;
  7183. }
  7184. const currentoption = $('a.buttonenter.buttongiveaway');
  7185. if (/join giveaway/gim.test(currentoption.text())) {
  7186. const logStatus = scripts_echoLog({
  7187. text: `${i18n('joiningGiveaway')}...`
  7188. });
  7189. const {
  7190. result,
  7191. statusText,
  7192. status,
  7193. data
  7194. } = await tools_httpRequest({
  7195. url: currentoption.attr('href'),
  7196. method: 'POST',
  7197. data: 'ajax=t',
  7198. dataType: 'json',
  7199. headers: {
  7200. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7201. accept: 'application/json, text/javascript, */*; q=0.01',
  7202. origin: window.location.origin
  7203. }
  7204. });
  7205. if (result === 'Success') {
  7206. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7207. var _data$response, _data$response4, _data$response5;
  7208. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7209. var _data$response2, _data$response3;
  7210. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7211. $('#giveawaysjoined').slideDown();
  7212. $('#giveawaysrecommend').slideDown();
  7213. 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}` : ''}`);
  7214. return true;
  7215. }
  7216. 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}` : ''}`);
  7217. return false;
  7218. }
  7219. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7220. return false;
  7221. }
  7222. logStatus.error(`${result}:${statusText}(${status})`);
  7223. return false;
  7224. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7225. return true;
  7226. }
  7227. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7228. return false;
  7229. } catch (error) {
  7230. throwError(error, 'Indiedb.init');
  7231. return false;
  7232. }
  7233. }
  7234. async function _do2() {
  7235. try {
  7236. const id = $('script').map((index, script) => {
  7237. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7238. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7239. 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] ];
  7240. }
  7241. return null;
  7242. });
  7243. if (id.length === 2) {
  7244. const pro = [];
  7245. const tasks = $('#giveawaysjoined a[class*=promo]');
  7246. for (const task of tasks) {
  7247. const promo = $(task);
  7248. if (!promo.hasClass('buttonentered')) {
  7249. const status = scripts_echoLog({
  7250. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7251. });
  7252. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7253. let text = '';
  7254. if (promo.hasClass('facebookpromo')) {
  7255. text = 'facebookpromo';
  7256. } else if (promo.hasClass('twitterpromo')) {
  7257. text = 'twitterpromo';
  7258. } else {
  7259. text = 'visitpromo';
  7260. }
  7261. pro.push(new Promise(resolve => {
  7262. $.ajax({
  7263. type: 'POST',
  7264. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7265. timeout: 6e4,
  7266. dataType: 'json',
  7267. data: {
  7268. ajax: 't'
  7269. },
  7270. error(response, error, exception) {
  7271. console.log({
  7272. response: response,
  7273. error: error,
  7274. exception: exception
  7275. });
  7276. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7277. resolve(true);
  7278. },
  7279. success(response) {
  7280. console.log(response);
  7281. if (response.success) {
  7282. status.success(`Success:${response.text}`);
  7283. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7284. resolve(true);
  7285. } else {
  7286. status.error(`Error:${response.text}`);
  7287. resolve(true);
  7288. }
  7289. }
  7290. });
  7291. }));
  7292. } else if (promo.hasClass('emailoptinpromo')) {
  7293. pro.push(new Promise(resolve => {
  7294. $.ajax({
  7295. type: 'POST',
  7296. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7297. timeout: 6e4,
  7298. dataType: 'json',
  7299. data: {
  7300. ajax: 't',
  7301. emailsystoggle: 4
  7302. },
  7303. error(response, error, exception) {
  7304. console.log({
  7305. response: response,
  7306. error: error,
  7307. exception: exception
  7308. });
  7309. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7310. resolve(true);
  7311. },
  7312. success(response) {
  7313. console.log(response);
  7314. if (response.success) {
  7315. status.success(`Success:${response.text}`);
  7316. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7317. resolve(true);
  7318. } else {
  7319. status.error(`Error:${response.text}`);
  7320. resolve(true);
  7321. }
  7322. }
  7323. });
  7324. }));
  7325. } else if (promo.hasClass('watchingpromo')) {
  7326. pro.push(new Promise(resolve => {
  7327. var _promo$attr;
  7328. const data = getUrlQuery(promo.attr('href'));
  7329. data.ajax = 't';
  7330. $.ajax({
  7331. type: 'POST',
  7332. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7333. timeout: 6e4,
  7334. dataType: 'json',
  7335. data: data,
  7336. error(response, error, exception) {
  7337. console.log({
  7338. response: response,
  7339. error: error,
  7340. exception: exception
  7341. });
  7342. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7343. resolve(true);
  7344. },
  7345. success(response) {
  7346. console.log(response);
  7347. if (response.success) {
  7348. status.success(`Success:${response.text}`);
  7349. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7350. resolve(true);
  7351. } else {
  7352. status.error(`Error:${response.text}`);
  7353. resolve(true);
  7354. }
  7355. }
  7356. });
  7357. }));
  7358. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7359. pro.push(new Promise(resolve => {
  7360. $.ajax({
  7361. type: 'POST',
  7362. url: urlPath(promo.attr('href')),
  7363. timeout: 6e4,
  7364. dataType: 'json',
  7365. data: {
  7366. ajax: 't'
  7367. },
  7368. error(response, error, exception) {
  7369. console.log({
  7370. response: response,
  7371. error: error,
  7372. exception: exception
  7373. });
  7374. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7375. resolve(true);
  7376. },
  7377. success(response) {
  7378. console.log(response);
  7379. if (response.success) {
  7380. status.success(`Success:${response.text}`);
  7381. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7382. resolve(true);
  7383. } else {
  7384. status.error(`Error:${response.text}`);
  7385. resolve(true);
  7386. }
  7387. }
  7388. });
  7389. }));
  7390. } else {
  7391. status.error(`Error:${i18n('unKnownTaskType')}`);
  7392. }
  7393. }
  7394. }
  7395. await Promise.all(pro);
  7396. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7397. return true;
  7398. }
  7399. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7400. return false;
  7401. } catch (error) {
  7402. throwError(error, 'Indiedb.classifyTask');
  7403. return false;
  7404. }
  7405. }
  7406. function Indiedb_checkLogin2() {
  7407. try {
  7408. if (!globalOptions.other.checkLogin) {
  7409. return true;
  7410. }
  7411. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7412. window.open('/members/login', '_self');
  7413. }
  7414. return true;
  7415. } catch (error) {
  7416. throwError(error, 'Indiedb.checkLogin');
  7417. return false;
  7418. }
  7419. }
  7420. async function Indiedb_checkLeftKey2() {
  7421. try {
  7422. if (!globalOptions.other.checkLeftKey) {
  7423. return true;
  7424. }
  7425. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7426. await external_Swal_default().fire({
  7427. icon: 'warning',
  7428. title: i18n('notice'),
  7429. text: i18n('giveawayEnded'),
  7430. confirmButtonText: i18n('confirm'),
  7431. cancelButtonText: i18n('cancel'),
  7432. showCancelButton: true
  7433. }).then(_ref => {
  7434. let {
  7435. value
  7436. } = _ref;
  7437. if (value) {
  7438. window.close();
  7439. }
  7440. });
  7441. }
  7442. return true;
  7443. } catch (error) {
  7444. throwError(error, 'Indiedb.checkLeftKey');
  7445. return false;
  7446. }
  7447. }
  7448. const website_Indiedb = Indiedb;
  7449. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7450. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7451. privateSet.add(obj);
  7452. }
  7453. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7454. if (privateCollection.has(obj)) {
  7455. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7456. }
  7457. }
  7458. function Keyhub_defineProperty(obj, key, value) {
  7459. if (key in obj) {
  7460. Object.defineProperty(obj, key, {
  7461. value: value,
  7462. enumerable: true,
  7463. configurable: true,
  7464. writable: true
  7465. });
  7466. } else {
  7467. obj[key] = value;
  7468. }
  7469. return obj;
  7470. }
  7471. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7472. if (!privateSet.has(receiver)) {
  7473. throw new TypeError('attempted to get private field on non-instance');
  7474. }
  7475. return fn;
  7476. }
  7477. const Keyhub_defaultTasksTemplate = {
  7478. steam: {
  7479. groupLinks: [],
  7480. wishlistLinks: [],
  7481. curatorLinks: []
  7482. },
  7483. discord: {
  7484. serverLinks: []
  7485. },
  7486. links: []
  7487. };
  7488. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7489. var Keyhub_getGiveawayId = new WeakSet();
  7490. var Keyhub_checkLeftKey = new WeakSet();
  7491. var Keyhub_checkLogin = new WeakSet();
  7492. class Keyhub extends website_Website {
  7493. constructor() {
  7494. super(...arguments);
  7495. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7496. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7497. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7498. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7499. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7500. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7501. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7502. }
  7503. static test() {
  7504. return window.location.host === 'key-hub.eu';
  7505. }
  7506. async after() {
  7507. try {
  7508. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7509. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7510. }
  7511. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7512. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7513. }
  7514. } catch (error) {
  7515. throwError(error, 'Keyhub.after');
  7516. }
  7517. }
  7518. init() {
  7519. try {
  7520. const logStatus = scripts_echoLog({
  7521. text: i18n('initing')
  7522. });
  7523. if ($('a[href*="/connect/steam"]').length > 0) {
  7524. window.open('/connect/steam', '_self');
  7525. logStatus.warning(i18n('needLogin'));
  7526. return false;
  7527. }
  7528. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7529. return false;
  7530. }
  7531. $('#VPNoverlay').hide();
  7532. $('#mainArticleSection').show();
  7533. this.initialized = true;
  7534. logStatus.success();
  7535. return true;
  7536. } catch (error) {
  7537. throwError(error, 'Keyhub.init');
  7538. return false;
  7539. }
  7540. }
  7541. async classifyTask(action) {
  7542. try {
  7543. const logStatus = scripts_echoLog({
  7544. text: i18n('getTasksInfo')
  7545. });
  7546. if (action === 'undo') {
  7547. var _GM_getValue;
  7548. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7549. }
  7550. const tasks = $('.task a');
  7551. for (const task of tasks) {
  7552. let link = $(task).attr('href');
  7553. const taskDes = $(task).text().trim();
  7554. if (!link) {
  7555. continue;
  7556. }
  7557. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7558. link = await getRedirectLink(link) || link;
  7559. }
  7560. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7561. window.open(link, '_blank');
  7562. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7563. if (action === 'undo') {
  7564. this.socialTasks.steam.groupLinks.push(link);
  7565. }
  7566. if (action === 'do') {
  7567. this.undoneTasks.steam.groupLinks.push(link);
  7568. }
  7569. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7570. if (action === 'undo') {
  7571. this.socialTasks.steam.wishlistLinks.push(link);
  7572. }
  7573. if (action === 'do') {
  7574. this.undoneTasks.steam.wishlistLinks.push(link);
  7575. }
  7576. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7577. if (action === 'undo') {
  7578. this.socialTasks.steam.curatorLinks.push(link);
  7579. }
  7580. if (action === 'do') {
  7581. this.undoneTasks.steam.curatorLinks.push(link);
  7582. }
  7583. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7584. if (action === 'undo') {
  7585. this.socialTasks.discord.serverLinks.push(link);
  7586. }
  7587. if (action === 'do') {
  7588. this.undoneTasks.discord.serverLinks.push(link);
  7589. }
  7590. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link)) {} else {
  7591. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7592. }
  7593. }
  7594. logStatus.success();
  7595. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7596. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7597. GM_setValue(`khTasks-${this.giveawayId}`, {
  7598. tasks: this.socialTasks,
  7599. time: new Date().getTime()
  7600. });
  7601. return true;
  7602. } catch (error) {
  7603. throwError(error, 'Keyhub.classifyTask');
  7604. return false;
  7605. }
  7606. }
  7607. verifyTask() {
  7608. try {
  7609. scripts_echoLog({
  7610. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7611. });
  7612. $.get(window.location.href, res => {
  7613. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7614. });
  7615. } catch (error) {
  7616. throwError(error, 'keyhub.verifyTask');
  7617. }
  7618. }
  7619. }
  7620. function Keyhub_getGiveawayId2() {
  7621. try {
  7622. var _window$location$href;
  7623. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7624. if (giveawayId) {
  7625. this.giveawayId = giveawayId;
  7626. return true;
  7627. }
  7628. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7629. return false;
  7630. } catch (error) {
  7631. throwError(error, 'Keyhub.getGiveawayId');
  7632. return false;
  7633. }
  7634. }
  7635. async function Keyhub_checkLeftKey2() {
  7636. try {
  7637. if (!globalOptions.other.checkLeftKey) {
  7638. return true;
  7639. }
  7640. const leftKey = $('#keysleft').text().trim();
  7641. if (leftKey === '0') {
  7642. await external_Swal_default().fire({
  7643. icon: 'warning',
  7644. title: i18n('notice'),
  7645. text: i18n('noKeysLeft'),
  7646. confirmButtonText: i18n('confirm'),
  7647. cancelButtonText: i18n('cancel'),
  7648. showCancelButton: true
  7649. }).then(_ref => {
  7650. let {
  7651. value
  7652. } = _ref;
  7653. if (value) {
  7654. window.close();
  7655. }
  7656. });
  7657. }
  7658. return true;
  7659. } catch (error) {
  7660. throwError(error, 'Keyhub.checkLeftKey');
  7661. return false;
  7662. }
  7663. }
  7664. function Keyhub_checkLogin2() {
  7665. try {
  7666. if (!globalOptions.other.checkLogin) {
  7667. return true;
  7668. }
  7669. if ($('a[href*="/connect/steam"]').length > 0) {
  7670. window.open('/connect/steam', '_self');
  7671. }
  7672. return true;
  7673. } catch (error) {
  7674. throwError(error, 'Keyhub.checkLogin');
  7675. return false;
  7676. }
  7677. }
  7678. const website_Keyhub = Keyhub;
  7679. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7680. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7681. privateSet.add(obj);
  7682. }
  7683. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7684. if (privateCollection.has(obj)) {
  7685. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7686. }
  7687. }
  7688. function Givekey_defineProperty(obj, key, value) {
  7689. if (key in obj) {
  7690. Object.defineProperty(obj, key, {
  7691. value: value,
  7692. enumerable: true,
  7693. configurable: true,
  7694. writable: true
  7695. });
  7696. } else {
  7697. obj[key] = value;
  7698. }
  7699. return obj;
  7700. }
  7701. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7702. if (!privateSet.has(receiver)) {
  7703. throw new TypeError('attempted to get private field on non-instance');
  7704. }
  7705. return fn;
  7706. }
  7707. const Givekey_defaultTasksTemplate = {
  7708. steam: {
  7709. groupLinks: [],
  7710. wishlistLinks: [],
  7711. curatorLinks: [],
  7712. curatorLikeLinks: []
  7713. },
  7714. twitter: {
  7715. userLinks: []
  7716. },
  7717. vk: {
  7718. nameLinks: []
  7719. },
  7720. discord: {
  7721. serverLinks: []
  7722. }
  7723. };
  7724. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  7725. var Givekey_verify = new WeakSet();
  7726. var Givekey_getGiveawayId = new WeakSet();
  7727. var Givekey_checkLeftKey = new WeakSet();
  7728. class Givekey extends website_Website {
  7729. constructor() {
  7730. super(...arguments);
  7731. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7732. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7733. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7734. Givekey_defineProperty(this, 'name', 'Givekey');
  7735. Givekey_defineProperty(this, 'tasks', []);
  7736. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  7737. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  7738. Givekey_defineProperty(this, 'userId', void 0);
  7739. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7740. }
  7741. static test() {
  7742. return window.location.host === 'givekey.ru';
  7743. }
  7744. async after() {
  7745. try {
  7746. await new Promise(resolve => {
  7747. const checker = setInterval(() => {
  7748. if ($('#navbarDropdown').length > 0) {
  7749. clearInterval(checker);
  7750. resolve(true);
  7751. }
  7752. });
  7753. });
  7754. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7755. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7756. }
  7757. } catch (error) {
  7758. throwError(error, 'Givekey.after');
  7759. return false;
  7760. }
  7761. }
  7762. init() {
  7763. try {
  7764. const logStatus = scripts_echoLog({
  7765. text: i18n('initing')
  7766. });
  7767. if ($('a[href*="/auth/steam"]').length > 0) {
  7768. window.open('/auth/steam', '_self');
  7769. logStatus.warning(i18n('needLogin'));
  7770. return false;
  7771. }
  7772. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7773. return false;
  7774. }
  7775. const userId = $('meta[name="user-id"]').attr('content');
  7776. if (!userId) {
  7777. logStatus.error(i18n('getFailed', i18n('userId')));
  7778. return false;
  7779. }
  7780. this.userId = userId;
  7781. this.initialized = true;
  7782. logStatus.success();
  7783. return true;
  7784. } catch (error) {
  7785. throwError(error, 'Givekey.init');
  7786. return false;
  7787. }
  7788. }
  7789. async classifyTask(action) {
  7790. try {
  7791. const logStatus = scripts_echoLog({
  7792. text: i18n('getTasksInfo')
  7793. });
  7794. if (action === 'undo') {
  7795. var _GM_getValue;
  7796. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  7797. }
  7798. const tasks = $('.card-body:has("button") .row');
  7799. for (const task of tasks) {
  7800. const taskEle = $(task);
  7801. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7802. if (isSuccess && action !== 'undo') {
  7803. continue;
  7804. }
  7805. const checkButton = taskEle.find('#task_check');
  7806. const taskId = checkButton.attr('data-id');
  7807. if (taskId) {
  7808. this.tasks.push(taskId);
  7809. }
  7810. if (action === 'verify') {
  7811. continue;
  7812. }
  7813. let href = taskEle.find('a').attr('href') || null;
  7814. const text = taskEle.find('a').text().trim();
  7815. const icon = taskEle.find('i');
  7816. if (!href || !text) {
  7817. continue;
  7818. }
  7819. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7820. href = await getRedirectLink(href);
  7821. }
  7822. if (!href) {
  7823. continue;
  7824. }
  7825. if (/^https?:\/\/vk\.com\//.test(href)) {
  7826. this.socialTasks.vk.nameLinks.push(href);
  7827. if (action === 'do' && !isSuccess) {
  7828. this.undoneTasks.vk.nameLinks.push(href);
  7829. }
  7830. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7831. this.socialTasks.steam.groupLinks.push(href);
  7832. if (action === 'do' && !isSuccess) {
  7833. this.undoneTasks.steam.groupLinks.push(href);
  7834. }
  7835. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7836. this.socialTasks.steam.wishlistLinks.push(href);
  7837. if (action === 'do' && !isSuccess) {
  7838. this.undoneTasks.steam.wishlistLinks.push(href);
  7839. }
  7840. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7841. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7842. this.socialTasks.steam.curatorLinks.push(href);
  7843. if (action === 'do' && !isSuccess) {
  7844. this.undoneTasks.steam.curatorLinks.push(href);
  7845. }
  7846. } else {
  7847. this.socialTasks.steam.curatorLikeLinks.push(href);
  7848. if (action === 'do' && !isSuccess) {
  7849. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7850. }
  7851. }
  7852. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7853. this.socialTasks.twitter.userLinks.push(href);
  7854. if (action === 'do' && !isSuccess) {
  7855. this.undoneTasks.twitter.userLinks.push(href);
  7856. }
  7857. } else if (icon.hasClass('fa-discord')) {
  7858. this.socialTasks.discord.serverLinks.push(href);
  7859. if (action === 'do' && !isSuccess) {
  7860. this.undoneTasks.discord.serverLinks.push(href);
  7861. }
  7862. } else {
  7863. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7864. }
  7865. }
  7866. logStatus.success();
  7867. this.tasks = unique(this.tasks);
  7868. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7869. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7870. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7871. tasks: this.socialTasks,
  7872. time: new Date().getTime()
  7873. });
  7874. return true;
  7875. } catch (error) {
  7876. throwError(error, 'Givekey.classifyTask');
  7877. return false;
  7878. }
  7879. }
  7880. async verifyTask() {
  7881. try {
  7882. if (!this.initialized && !this.init()) {
  7883. return false;
  7884. }
  7885. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7886. return false;
  7887. }
  7888. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7889. const taskLength = this.tasks.length;
  7890. for (let i = 0; i < taskLength; i++) {
  7891. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7892. if (i < taskLength - 1) {
  7893. await delay(15e3);
  7894. }
  7895. }
  7896. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7897. scripts_echoLog({
  7898. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7899. });
  7900. return true;
  7901. } catch (error) {
  7902. throwError(error, 'Givekey.verifyTask');
  7903. return false;
  7904. }
  7905. }
  7906. }
  7907. async function Givekey_verify2(task) {
  7908. try {
  7909. const logStatus = scripts_echoLog({
  7910. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7911. });
  7912. return await new Promise(resolve => {
  7913. $.ajax({
  7914. url: 'https://givekey.ru/giveaway/task',
  7915. method: 'POST',
  7916. data: `id=${task}&user_id=${this.userId}`,
  7917. dataType: 'json',
  7918. headers: {
  7919. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7920. },
  7921. success: data => {
  7922. if (data.btn) {
  7923. $(`button[data-id=${this.userId}]`).html(data.btn);
  7924. }
  7925. if (data.status === 'ok') {
  7926. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7927. logStatus.success();
  7928. resolve(true);
  7929. } else if (data.status === 'end') {
  7930. logStatus.success();
  7931. scripts_echoLog({}).success(data.key);
  7932. resolve(true);
  7933. } else {
  7934. logStatus.error(`Error:${data.msg}`);
  7935. resolve(false);
  7936. }
  7937. },
  7938. error: xhr => {
  7939. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7940. resolve(false);
  7941. }
  7942. });
  7943. });
  7944. } catch (error) {
  7945. throwError(error, 'Givekey.verify');
  7946. return false;
  7947. }
  7948. }
  7949. function Givekey_getGiveawayId2() {
  7950. try {
  7951. var _window$location$href;
  7952. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7953. if (giveawayId) {
  7954. this.giveawayId = giveawayId;
  7955. return true;
  7956. }
  7957. scripts_echoLog({
  7958. text: i18n('getFailed', 'GiveawayId')
  7959. });
  7960. return false;
  7961. } catch (error) {
  7962. throwError(error, 'Givekey.getGiveawayId');
  7963. return false;
  7964. }
  7965. }
  7966. async function Givekey_checkLeftKey2() {
  7967. try {
  7968. if (!globalOptions.other.checkLeftKey) {
  7969. return true;
  7970. }
  7971. if (!$('#keys_count').text()) {
  7972. await external_Swal_default().fire({
  7973. icon: 'warning',
  7974. title: i18n('notice'),
  7975. text: i18n('noKeysLeft'),
  7976. confirmButtonText: i18n('confirm'),
  7977. cancelButtonText: i18n('cancel'),
  7978. showCancelButton: true
  7979. }).then(_ref => {
  7980. let {
  7981. value
  7982. } = _ref;
  7983. if (value) {
  7984. window.close();
  7985. }
  7986. });
  7987. }
  7988. return true;
  7989. } catch (error) {
  7990. throwError(error, 'Givekey.checkLeftKey');
  7991. return false;
  7992. }
  7993. }
  7994. const website_Givekey = Givekey;
  7995. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7996. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7997. privateSet.add(obj);
  7998. }
  7999. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8000. if (privateCollection.has(obj)) {
  8001. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8002. }
  8003. }
  8004. function GiveeClub_defineProperty(obj, key, value) {
  8005. if (key in obj) {
  8006. Object.defineProperty(obj, key, {
  8007. value: value,
  8008. enumerable: true,
  8009. configurable: true,
  8010. writable: true
  8011. });
  8012. } else {
  8013. obj[key] = value;
  8014. }
  8015. return obj;
  8016. }
  8017. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8018. if (!privateSet.has(receiver)) {
  8019. throw new TypeError('attempted to get private field on non-instance');
  8020. }
  8021. return fn;
  8022. }
  8023. var GiveeClub_checkLogin = new WeakSet();
  8024. var GiveeClub_getGiveawayId = new WeakSet();
  8025. var GiveeClub_checkLeftKey = new WeakSet();
  8026. class GiveeClub extends GiveawaySu {
  8027. constructor() {
  8028. super(...arguments);
  8029. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8030. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8031. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8032. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8033. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  8034. }
  8035. static test() {
  8036. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8037. }
  8038. async after() {
  8039. try {
  8040. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8041. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8042. }
  8043. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8044. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8045. }
  8046. } catch (error) {
  8047. throwError(error, 'GiveeClub.after');
  8048. }
  8049. }
  8050. init() {
  8051. try {
  8052. const logStatus = scripts_echoLog({
  8053. text: i18n('initing')
  8054. });
  8055. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8056. logStatus.warning(i18n('needLogin'));
  8057. return false;
  8058. }
  8059. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8060. return false;
  8061. }
  8062. this.initialized = true;
  8063. logStatus.success();
  8064. return true;
  8065. } catch (error) {
  8066. throwError(error, 'GiveeClub.init');
  8067. return false;
  8068. }
  8069. }
  8070. async classifyTask(action) {
  8071. try {
  8072. const logStatus = scripts_echoLog({
  8073. text: i18n('getTasksInfo')
  8074. });
  8075. if (action === 'undo') {
  8076. var _GM_getValue;
  8077. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8078. return true;
  8079. }
  8080. const pro = [];
  8081. const tasks = $('.event-actions tr');
  8082. for (const task of tasks) {
  8083. pro.push(new Promise(resolve => {
  8084. const taskDes = $(task).find('.event-action-label a');
  8085. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8086. const taskName = taskDes.text().trim();
  8087. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8088. return resolve(true);
  8089. }
  8090. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8091. if (!taskLink) {
  8092. return resolve(false);
  8093. }
  8094. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8095. this.undoneTasks.steam.groupLinks.push(taskLink);
  8096. } else if (/like.*announcement/gi.test(taskName)) {
  8097. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8098. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8099. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8100. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  8101. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8102. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8103. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8104. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8105. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8106. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8107. this.undoneTasks.steam.forumLinks.push(taskLink);
  8108. } else if (taskIcon.includes('discord')) {
  8109. this.undoneTasks.discord.serverLinks.push(taskLink);
  8110. } else if (taskIcon.includes('instagram')) {
  8111. this.undoneTasks.instagram.userLinks.push(taskLink);
  8112. } else if (taskIcon.includes('twitch')) {
  8113. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8114. } else if (taskIcon.includes('reddit')) {
  8115. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8116. } else if (/watch.*art/gim.test(taskName)) {
  8117. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8118. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8119. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8120. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8121. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8122. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8123. this.undoneTasks.vk.nameLinks.push(taskLink);
  8124. } else {
  8125. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8126. if (/follow.*button/gim.test(taskName)) {
  8127. this.undoneTasks.steam.followLinks.push(taskLink);
  8128. }
  8129. }
  8130. }
  8131. resolve(true);
  8132. }).catch(error => {
  8133. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8134. return false;
  8135. });
  8136. }));
  8137. }
  8138. await Promise.all(pro);
  8139. logStatus.success();
  8140. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8141. this.socialTasks = this.undoneTasks;
  8142. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8143. tasks: this.socialTasks,
  8144. time: new Date().getTime()
  8145. });
  8146. return true;
  8147. } catch (error) {
  8148. throwError(error, 'GiveeClub.classifyTask');
  8149. return false;
  8150. }
  8151. }
  8152. }
  8153. function GiveeClub_checkLogin2() {
  8154. try {
  8155. if (!globalOptions.other.checkLogin) {
  8156. return true;
  8157. }
  8158. if ($('a[href*="/account/auth"]').length > 0) {
  8159. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8160. }
  8161. return true;
  8162. } catch (error) {
  8163. throwError(error, 'GiveeClub.checkLogin');
  8164. return false;
  8165. }
  8166. }
  8167. function GiveeClub_getGiveawayId2() {
  8168. var _window$location$href;
  8169. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8170. if (giveawayId) {
  8171. this.giveawayId = giveawayId;
  8172. return true;
  8173. }
  8174. scripts_echoLog({
  8175. text: i18n('getFailed', 'GiveawayId')
  8176. });
  8177. return false;
  8178. }
  8179. async function GiveeClub_checkLeftKey2() {
  8180. try {
  8181. if (!globalOptions.other.checkLeftKey) {
  8182. return true;
  8183. }
  8184. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8185. await external_Swal_default().fire({
  8186. icon: 'warning',
  8187. title: i18n('notice'),
  8188. text: i18n('giveawayEnded'),
  8189. confirmButtonText: i18n('confirm'),
  8190. cancelButtonText: i18n('cancel'),
  8191. showCancelButton: true
  8192. }).then(_ref => {
  8193. let {
  8194. value
  8195. } = _ref;
  8196. if (value) {
  8197. window.close();
  8198. }
  8199. });
  8200. }
  8201. return true;
  8202. } catch (error) {
  8203. throwError(error, 'Giveawaysu.checkLeftKey');
  8204. return false;
  8205. }
  8206. }
  8207. const website_GiveeClub = GiveeClub;
  8208. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8209. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8210. privateSet.add(obj);
  8211. }
  8212. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8213. if (privateCollection.has(obj)) {
  8214. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8215. }
  8216. }
  8217. function OpiumPulses_defineProperty(obj, key, value) {
  8218. if (key in obj) {
  8219. Object.defineProperty(obj, key, {
  8220. value: value,
  8221. enumerable: true,
  8222. configurable: true,
  8223. writable: true
  8224. });
  8225. } else {
  8226. obj[key] = value;
  8227. }
  8228. return obj;
  8229. }
  8230. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8231. if (!privateSet.has(receiver)) {
  8232. throw new TypeError('attempted to get private field on non-instance');
  8233. }
  8234. return fn;
  8235. }
  8236. const defaultOptions = {
  8237. maxPoint: '99999999'
  8238. };
  8239. var _toggleTask = new WeakSet();
  8240. var OpiumPulses_checkLogin = new WeakSet();
  8241. class OpiumPulses {
  8242. constructor() {
  8243. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8244. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8245. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8246. OpiumPulses_defineProperty(this, 'options', {
  8247. ...defaultOptions,
  8248. ...GM_getValue('OpiumPulsesOptions')
  8249. });
  8250. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8251. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8252. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8253. }
  8254. static test() {
  8255. return window.location.host === 'www.opiumpulses.com';
  8256. }
  8257. async after() {
  8258. try {
  8259. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8260. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8261. }
  8262. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8263. } catch (error) {
  8264. throwError(error, 'OpiumPulses.after');
  8265. }
  8266. }
  8267. async doFreeTask() {
  8268. try {
  8269. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8270. } catch (error) {
  8271. throwError(error, 'OpiumPulses.doFreeTask');
  8272. }
  8273. }
  8274. async doPointTask() {
  8275. try {
  8276. var _$$text$match;
  8277. 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);
  8278. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8279. } catch (error) {
  8280. throwError(error, 'OpiumPulses.doPointTask');
  8281. }
  8282. }
  8283. init() {
  8284. return true;
  8285. }
  8286. classifyTask() {
  8287. return true;
  8288. }
  8289. }
  8290. async function _toggleTask2(type) {
  8291. try {
  8292. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8293. for (const item of items) {
  8294. var _$$find$text$match;
  8295. 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);
  8296. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8297. if (type === 'points' && needPoints > this.myPoints) {
  8298. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8299. } else if (type === 'points' && !needPoints) {
  8300. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8301. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8302. var _aElement$attr;
  8303. const logStatus = scripts_echoLog({
  8304. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8305. });
  8306. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8307. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8308. var _aElement$attr2, _aElement$attr2$match;
  8309. 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];
  8310. if (giveawayId) {
  8311. checkUser(giveawayId);
  8312. }
  8313. }
  8314. if (!aElement.attr('href')) {
  8315. logStatus.error('Error: No "href".');
  8316. continue;
  8317. }
  8318. const {
  8319. result,
  8320. statusText,
  8321. status,
  8322. data
  8323. } = await tools_httpRequest({
  8324. url: aElement.attr('href'),
  8325. method: 'GET'
  8326. });
  8327. if (result === 'Success') {
  8328. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8329. var _data$responseText$ma;
  8330. logStatus.success();
  8331. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8332. if (type === 'points' && points) {
  8333. this.myPoints = parseInt(points, 10);
  8334. }
  8335. } else {
  8336. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8337. }
  8338. } else {
  8339. logStatus.error(`${result}:${statusText}(${status})`);
  8340. }
  8341. }
  8342. }
  8343. scripts_echoLog({
  8344. text: '-----END-----'
  8345. });
  8346. } catch (error) {
  8347. throwError(error, 'OpiumPulses.toggleTask');
  8348. }
  8349. }
  8350. function OpiumPulses_checkLogin2() {
  8351. try {
  8352. if (!globalOptions.other.checkLogin) {
  8353. return true;
  8354. }
  8355. if ($('a[href*="/site/login"]').length > 1) {
  8356. window.open('/site/login', '_self');
  8357. }
  8358. return true;
  8359. } catch (error) {
  8360. throwError(error, 'OpiumPulses.checkLogin');
  8361. return false;
  8362. }
  8363. }
  8364. const website_OpiumPulses = OpiumPulses;
  8365. const external_dayjs_namespaceObject = dayjs;
  8366. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8367. const leftKeyChecker = {
  8368. async classify(link) {
  8369. try {
  8370. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8371. return await this.giveawaySu(link);
  8372. }
  8373. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8374. return await this.giveeClub(link);
  8375. }
  8376. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8377. return await this.gleam(link);
  8378. }
  8379. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8380. return await this.indieDb(link);
  8381. }
  8382. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8383. return await this.keyhub(link);
  8384. }
  8385. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8386. return await this.opquests(link);
  8387. }
  8388. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8389. return await this.itch(link);
  8390. }
  8391. return false;
  8392. } catch (error) {
  8393. throwError(error, 'leftKeyChecker.classify');
  8394. return false;
  8395. }
  8396. },
  8397. async giveawaySu(link) {
  8398. try {
  8399. const {
  8400. result,
  8401. data
  8402. } = await tools_httpRequest({
  8403. url: link,
  8404. method: 'GET'
  8405. });
  8406. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8407. if (data.responseText.includes('class="steam-login"')) {
  8408. return false;
  8409. }
  8410. if (data.responseText.includes('class="giveaway-ended"')) {
  8411. return 'Ended';
  8412. }
  8413. return 'Active';
  8414. }
  8415. return false;
  8416. } catch (error) {
  8417. throwError(error, 'leftKeyChecker.giveawaySu');
  8418. return false;
  8419. }
  8420. },
  8421. async giveeClub(link) {
  8422. try {
  8423. const {
  8424. result,
  8425. data
  8426. } = await tools_httpRequest({
  8427. url: link,
  8428. method: 'GET'
  8429. });
  8430. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8431. if (data.responseText.includes('class="event-winner"')) {
  8432. return 'Won';
  8433. }
  8434. if (data.responseText.includes('class="event-ended"')) {
  8435. return 'Ended';
  8436. }
  8437. return 'Active';
  8438. }
  8439. return false;
  8440. } catch (error) {
  8441. throwError(error, 'leftKeyChecker.giveeClub');
  8442. return false;
  8443. }
  8444. },
  8445. async gleam(link) {
  8446. try {
  8447. const {
  8448. result,
  8449. data
  8450. } = await tools_httpRequest({
  8451. url: link,
  8452. method: 'GET'
  8453. });
  8454. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8455. var _data$responseText$ma, _$$attr, _$$attr$match;
  8456. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8457. return 'Won';
  8458. }
  8459. 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];
  8460. if (!campaignDiv) {
  8461. return false;
  8462. }
  8463. 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];
  8464. if (!campaignString) {
  8465. return false;
  8466. }
  8467. const {
  8468. campaign
  8469. } = JSON.parse(campaignString);
  8470. if (campaign.banned) {
  8471. return 'Banned';
  8472. }
  8473. if (campaign.finished) {
  8474. return 'Ended';
  8475. }
  8476. if (campaign.paused) {
  8477. return 'Paused';
  8478. }
  8479. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8480. return 'NotStart';
  8481. }
  8482. return 'Active';
  8483. }
  8484. return false;
  8485. } catch (error) {
  8486. throwError(error, 'leftKeyChecker.gleam');
  8487. return false;
  8488. }
  8489. },
  8490. async indieDb(link) {
  8491. try {
  8492. const {
  8493. result,
  8494. data
  8495. } = await tools_httpRequest({
  8496. url: link,
  8497. method: 'GET'
  8498. });
  8499. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8500. if (data.responseText.includes('Congrats you WON')) {
  8501. return 'Won';
  8502. }
  8503. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8504. return 'Ended';
  8505. }
  8506. return 'Active';
  8507. }
  8508. return false;
  8509. } catch (error) {
  8510. throwError(error, 'leftKeyChecker.indieDb');
  8511. return false;
  8512. }
  8513. },
  8514. async keyhub(link) {
  8515. try {
  8516. const {
  8517. result,
  8518. data
  8519. } = await tools_httpRequest({
  8520. url: link,
  8521. method: 'GET'
  8522. });
  8523. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8524. var _data$responseText$ma2;
  8525. 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];
  8526. if (!keysleft) {
  8527. return false;
  8528. }
  8529. if (keysleft === '0') {
  8530. return 'Ended';
  8531. }
  8532. return `Active(${keysleft})`;
  8533. }
  8534. return false;
  8535. } catch (error) {
  8536. throwError(error, 'leftKeyChecker.keyhub');
  8537. return false;
  8538. }
  8539. },
  8540. async opquests(link) {
  8541. try {
  8542. const {
  8543. result,
  8544. data
  8545. } = await tools_httpRequest({
  8546. url: link,
  8547. method: 'GET'
  8548. });
  8549. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8550. var _data$responseText$ma3;
  8551. 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];
  8552. if (!keysleft) {
  8553. return false;
  8554. }
  8555. if (keysleft === '0') {
  8556. return 'Ended';
  8557. }
  8558. return `Active(${keysleft})`;
  8559. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8560. return 'Ended';
  8561. }
  8562. return false;
  8563. } catch (error) {
  8564. throwError(error, 'leftKeyChecker.opquests');
  8565. return false;
  8566. }
  8567. },
  8568. async itch(link) {
  8569. try {
  8570. const {
  8571. result,
  8572. data
  8573. } = await tools_httpRequest({
  8574. url: link,
  8575. method: 'GET'
  8576. });
  8577. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8578. var _data$responseText$ma4;
  8579. 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];
  8580. if (!endDate) {
  8581. return false;
  8582. }
  8583. if (new Date().getTime() > new Date(endDate).getTime()) {
  8584. return 'Ended';
  8585. }
  8586. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8587. }
  8588. return false;
  8589. } catch (error) {
  8590. throwError(error, 'leftKeyChecker.opquests');
  8591. return false;
  8592. }
  8593. }
  8594. };
  8595. const website_leftKeyChecker = leftKeyChecker;
  8596. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8597. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8598. privateSet.add(obj);
  8599. }
  8600. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8601. if (privateCollection.has(obj)) {
  8602. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8603. }
  8604. }
  8605. function Keylol_defineProperty(obj, key, value) {
  8606. if (key in obj) {
  8607. Object.defineProperty(obj, key, {
  8608. value: value,
  8609. enumerable: true,
  8610. configurable: true,
  8611. writable: true
  8612. });
  8613. } else {
  8614. obj[key] = value;
  8615. }
  8616. return obj;
  8617. }
  8618. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8619. if (!privateSet.has(receiver)) {
  8620. throw new TypeError('attempted to get private field on non-instance');
  8621. }
  8622. return fn;
  8623. }
  8624. const Keylol_defaultTasksTemplate = {
  8625. steam: {
  8626. groupLinks: [],
  8627. wishlistLinks: [],
  8628. curatorLinks: [],
  8629. curatorLikeLinks: [],
  8630. followLinks: [],
  8631. forumLinks: [],
  8632. announcementLinks: [],
  8633. workshopVoteLinks: [],
  8634. licenseLinks: []
  8635. },
  8636. discord: {
  8637. serverLinks: []
  8638. },
  8639. instagram: {
  8640. userLinks: []
  8641. },
  8642. vk: {
  8643. nameLinks: []
  8644. },
  8645. twitch: {
  8646. channelLinks: []
  8647. },
  8648. reddit: {
  8649. redditLinks: []
  8650. },
  8651. twitter: {
  8652. userLinks: [],
  8653. retweetLinks: []
  8654. },
  8655. youtube: {
  8656. channelLinks: [],
  8657. likeLinks: []
  8658. }
  8659. };
  8660. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  8661. var _addBtn = new WeakSet();
  8662. class Keylol extends website_Website {
  8663. constructor() {
  8664. super(...arguments);
  8665. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8666. Keylol_defineProperty(this, 'name', 'Keylol');
  8667. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  8668. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  8669. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8670. }
  8671. static test() {
  8672. var _$$eq$attr;
  8673. 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'));
  8674. }
  8675. init() {
  8676. return true;
  8677. }
  8678. after() {
  8679. try {
  8680. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8681. const mainPost = $(selector);
  8682. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8683. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8684. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8685. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8686. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8687. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8688. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8689. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8690. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8691. if (discordLinks.length > 0) {
  8692. for (const discordLink of discordLinks) {
  8693. const link = $(discordLink).attr('href');
  8694. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8695. continue;
  8696. }
  8697. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8698. }
  8699. }
  8700. if (redditLinks.length > 0) {
  8701. for (const redditLink of redditLinks) {
  8702. const link = $(redditLink).attr('href');
  8703. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8704. continue;
  8705. }
  8706. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8707. }
  8708. }
  8709. if (insLinks.length > 0) {
  8710. for (const insLink of insLinks) {
  8711. const link = $(insLink).attr('href');
  8712. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8713. continue;
  8714. }
  8715. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8716. }
  8717. }
  8718. if (twitterLinks.length > 0) {
  8719. for (const twitterLink of twitterLinks) {
  8720. const link = $(twitterLink).attr('href');
  8721. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8722. continue;
  8723. }
  8724. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8725. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8726. } else {
  8727. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8728. }
  8729. }
  8730. }
  8731. if (twitchLinks.length > 0) {
  8732. for (const twitchLink of twitchLinks) {
  8733. const link = $(twitchLink).attr('href');
  8734. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8735. continue;
  8736. }
  8737. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8738. }
  8739. }
  8740. if (vkLinks.length > 0) {
  8741. for (const vkLink of vkLinks) {
  8742. const link = $(vkLink).attr('href');
  8743. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8744. continue;
  8745. }
  8746. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8747. }
  8748. }
  8749. if (steamStoreLinks.length > 0) {
  8750. for (const steamStoreLink of steamStoreLinks) {
  8751. const link = $(steamStoreLink).attr('href');
  8752. if (!link) {
  8753. continue;
  8754. }
  8755. if (/app\/[\d]+/.test(link)) {
  8756. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8757. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8758. } else if (/curator\/[\d]+/.test(link)) {
  8759. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8760. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8761. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8762. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8763. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8764. }
  8765. }
  8766. }
  8767. if (steamCommunityLinks.length > 0) {
  8768. for (const steamCommunityLink of steamCommunityLinks) {
  8769. const link = $(steamCommunityLink).attr('href');
  8770. if (!link) {
  8771. continue;
  8772. }
  8773. if (/groups\/.+/.test(link)) {
  8774. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8775. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8776. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8777. }
  8778. }
  8779. }
  8780. if (ytbLinks.length > 0) {
  8781. for (const ytbLink of ytbLinks) {
  8782. const link = $(ytbLink).attr('href');
  8783. if (!link) {
  8784. continue;
  8785. }
  8786. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8787. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8788. }
  8789. }
  8790. 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/"]');
  8791. if (giveawayLinks.length > 0) {
  8792. for (const giveawayLink of giveawayLinks) {
  8793. const link = $(giveawayLink).attr('href');
  8794. if (!link) {
  8795. continue;
  8796. }
  8797. website_leftKeyChecker.classify(link).then(status => {
  8798. if (!status) {
  8799. return;
  8800. }
  8801. if (/^Active/.test(status)) {
  8802. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  8803. return;
  8804. }
  8805. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  8806. }).catch(error => {
  8807. throwError(error, 'keylol.after -> leftKeyChecker');
  8808. });
  8809. }
  8810. }
  8811. if (this.name === 'Keylol') {
  8812. const asfLinks = mainPost.find('a[href^="#asf"]');
  8813. if (asfLinks.length > 0) {
  8814. for (const asfLink of asfLinks) {
  8815. const link = $(asfLink).attr('href');
  8816. if (!link) {
  8817. continue;
  8818. }
  8819. 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', '')}`);
  8820. }
  8821. }
  8822. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense")');
  8823. if (asfLinks2.length > 0) {
  8824. for (const asfLink of asfLinks2) {
  8825. const subid = [ ...asfLink.innerText.matchAll(/s\/([\d]+)/g) ].map(arr => arr[1]);
  8826. if (subid.length === 0) {
  8827. continue;
  8828. }
  8829. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  8830. }
  8831. }
  8832. }
  8833. } catch (error) {
  8834. throwError(error, 'keylol.after');
  8835. }
  8836. }
  8837. classifyTask(action) {
  8838. try {
  8839. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  8840. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  8841. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8842. for (const btn of selectedBtns) {
  8843. const button = $(btn);
  8844. const social = button.attr('data-social');
  8845. const type = button.attr('data-type');
  8846. const link = button.attr('data-link');
  8847. if (!(social && type && link)) {
  8848. continue;
  8849. }
  8850. if (action === 'do') {
  8851. this.undoneTasks[social][type].push(link);
  8852. }
  8853. if (action === 'undo') {
  8854. this.socialTasks[social][type].push(link);
  8855. }
  8856. }
  8857. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8858. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8859. return true;
  8860. } catch (error) {
  8861. throwError(error, 'Keylol.classifyTask');
  8862. return false;
  8863. }
  8864. }
  8865. selectAll() {
  8866. try {
  8867. $('.auto-task-keylol').attr('selected', 'selected');
  8868. } catch (error) {
  8869. throwError(error, 'Keylol.selectAll');
  8870. }
  8871. }
  8872. selectNone() {
  8873. try {
  8874. $('.auto-task-keylol').removeAttr('selected');
  8875. } catch (error) {
  8876. throwError(error, 'Keylol.selectNone');
  8877. }
  8878. }
  8879. invertSelect() {
  8880. try {
  8881. $('.auto-task-keylol').each((index, element) => {
  8882. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8883. });
  8884. } catch (error) {
  8885. throwError(error, 'Keylol.invertSelect');
  8886. }
  8887. }
  8888. }
  8889. function _addBtn2(before, social, linkType, link) {
  8890. try {
  8891. $(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>`);
  8892. } catch (error) {
  8893. throwError(error, 'keylol.addBtn');
  8894. }
  8895. }
  8896. const website_Keylol = Keylol;
  8897. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8898. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8899. privateSet.add(obj);
  8900. }
  8901. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8902. if (privateCollection.has(obj)) {
  8903. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8904. }
  8905. }
  8906. function Opquests_defineProperty(obj, key, value) {
  8907. if (key in obj) {
  8908. Object.defineProperty(obj, key, {
  8909. value: value,
  8910. enumerable: true,
  8911. configurable: true,
  8912. writable: true
  8913. });
  8914. } else {
  8915. obj[key] = value;
  8916. }
  8917. return obj;
  8918. }
  8919. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8920. if (!privateSet.has(receiver)) {
  8921. throw new TypeError('attempted to get private field on non-instance');
  8922. }
  8923. return fn;
  8924. }
  8925. const Opquests_defaultTasks = {
  8926. steam: {
  8927. groupLinks: [],
  8928. wishlistLinks: [],
  8929. followLinks: [],
  8930. curatorLikeLinks: []
  8931. }
  8932. };
  8933. var Opquests_getGiveawayId = new WeakSet();
  8934. var Opquests_checkLogin = new WeakSet();
  8935. class Opquests extends website_Website {
  8936. constructor() {
  8937. super(...arguments);
  8938. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8939. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8940. Opquests_defineProperty(this, 'name', 'Opquests');
  8941. Opquests_defineProperty(this, 'undoneTasks', {
  8942. ...Opquests_defaultTasks
  8943. });
  8944. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8945. }
  8946. static test() {
  8947. return window.location.host === 'opquests.com';
  8948. }
  8949. async after() {
  8950. try {
  8951. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8952. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8953. }
  8954. } catch (error) {
  8955. throwError(error, 'Opquests.after');
  8956. }
  8957. }
  8958. init() {
  8959. try {
  8960. const logStatus = scripts_echoLog({
  8961. text: i18n('initing')
  8962. });
  8963. if ($('a[href*="/auth/redirect"]').length > 0) {
  8964. window.open('/auth/redirect', '_self');
  8965. logStatus.warning(i18n('needLogin'));
  8966. return false;
  8967. }
  8968. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8969. return false;
  8970. }
  8971. this.initialized = true;
  8972. logStatus.success();
  8973. return true;
  8974. } catch (error) {
  8975. throwError(error, 'Opquests.init');
  8976. return false;
  8977. }
  8978. }
  8979. async classifyTask(action) {
  8980. try {
  8981. if (action === 'undo') {
  8982. scripts_echoLog({
  8983. text: i18n('cannotUndo')
  8984. });
  8985. return false;
  8986. }
  8987. const logStatus = scripts_echoLog({
  8988. text: i18n('getTasksInfo')
  8989. });
  8990. const tasks = $('.w-full:contains("Validate") .items-center');
  8991. for (const task of tasks) {
  8992. const link = $(task).find('a:contains("Open")').attr('href');
  8993. const taskDes = $(task).find('div').eq(1).text().trim();
  8994. if (!link) {
  8995. continue;
  8996. }
  8997. if (/steamcommunity\.com\/groups\//.test(link)) {
  8998. this.undoneTasks.steam.groupLinks.push(link);
  8999. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9000. if (/wishlist/gim.test(taskDes)) {
  9001. this.undoneTasks.steam.wishlistLinks.push(link);
  9002. } else if (/follow/gim.test(taskDes)) {
  9003. this.undoneTasks.steam.followLinks.push(link);
  9004. }
  9005. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9006. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9007. } else {
  9008. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9009. }
  9010. }
  9011. logStatus.success();
  9012. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9013. return true;
  9014. } catch (error) {
  9015. throwError(error, 'Opquests.classifyTask');
  9016. return false;
  9017. }
  9018. }
  9019. }
  9020. function Opquests_getGiveawayId2() {
  9021. try {
  9022. var _window$location$href;
  9023. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9024. if (giveawayId) {
  9025. this.giveawayId = giveawayId;
  9026. return true;
  9027. }
  9028. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9029. return false;
  9030. } catch (error) {
  9031. throwError(error, 'Opquests.getGiveawayId');
  9032. return false;
  9033. }
  9034. }
  9035. function Opquests_checkLogin2() {
  9036. try {
  9037. if (!globalOptions.other.checkLogin) {
  9038. return true;
  9039. }
  9040. if ($('a[href*="/auth/redirect"]').length > 0) {
  9041. window.open('/auth/redirect', '_self');
  9042. }
  9043. return true;
  9044. } catch (error) {
  9045. throwError(error, 'Opquests.checkLogin');
  9046. return false;
  9047. }
  9048. }
  9049. const website_Opquests = Opquests;
  9050. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9051. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9052. privateSet.add(obj);
  9053. }
  9054. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9055. if (privateCollection.has(obj)) {
  9056. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9057. }
  9058. }
  9059. function Gleam_defineProperty(obj, key, value) {
  9060. if (key in obj) {
  9061. Object.defineProperty(obj, key, {
  9062. value: value,
  9063. enumerable: true,
  9064. configurable: true,
  9065. writable: true
  9066. });
  9067. } else {
  9068. obj[key] = value;
  9069. }
  9070. return obj;
  9071. }
  9072. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9073. if (!privateSet.has(receiver)) {
  9074. throw new TypeError('attempted to get private field on non-instance');
  9075. }
  9076. return fn;
  9077. }
  9078. const Gleam_defaultTasksTemplate = {
  9079. steam: {
  9080. groupLinks: [],
  9081. wishlistLinks: [],
  9082. followLinks: [],
  9083. curatorLinks: [],
  9084. curatorLikeLinks: []
  9085. },
  9086. twitter: {
  9087. userLinks: [],
  9088. retweetLinks: []
  9089. },
  9090. twitch: {
  9091. channelLinks: []
  9092. },
  9093. discord: {
  9094. serverLinks: []
  9095. },
  9096. youtube: {
  9097. channelLinks: []
  9098. },
  9099. extra: {
  9100. gleam: []
  9101. }
  9102. };
  9103. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9104. const Gleam_defaultOptions = {
  9105. vlootUsername: '',
  9106. gameroundUsername: ''
  9107. };
  9108. var _checkSync = new WeakSet();
  9109. var _doGleamTask = new WeakSet();
  9110. var Gleam_getGiveawayId = new WeakSet();
  9111. var _getGleamLink = new WeakSet();
  9112. var Gleam_checkLeftKey = new WeakSet();
  9113. class Gleam extends website_Website {
  9114. constructor() {
  9115. super(...arguments);
  9116. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9117. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9118. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9119. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9120. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9121. Gleam_defineProperty(this, 'name', 'Gleam');
  9122. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9123. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9124. Gleam_defineProperty(this, 'options', {
  9125. ...Gleam_defaultOptions,
  9126. ...GM_getValue('GleamOptions')
  9127. });
  9128. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9129. }
  9130. static test() {
  9131. return window.location.host === 'gleam.io';
  9132. }
  9133. async after() {
  9134. try {
  9135. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9136. const checkComplete = setInterval(() => {
  9137. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9138. clearInterval(checkComplete);
  9139. window.close();
  9140. }
  9141. });
  9142. for (const task of $('.entry-content .entry-method')) {
  9143. const taskInfo = $(task).find('.user-links');
  9144. const expandInfo = $(task).find('.expandable');
  9145. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9146. if (aElements.length > 0) {
  9147. for (const element of aElements) {
  9148. const $element = $(element);
  9149. const href = $element.attr('href');
  9150. $element.removeAttr('href')[0].click();
  9151. $element.attr('href', href);
  9152. await delay(1e3);
  9153. }
  9154. }
  9155. taskInfo[0].click();
  9156. await delay(1e3);
  9157. }
  9158. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9159. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9160. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9161. }
  9162. } catch (error) {
  9163. throwError(error, 'Gleam.after');
  9164. return false;
  9165. }
  9166. }
  9167. init() {
  9168. try {
  9169. const logStatus = scripts_echoLog({
  9170. text: i18n('initing')
  9171. });
  9172. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9173. return false;
  9174. }
  9175. this.initialized = true;
  9176. logStatus.success();
  9177. return true;
  9178. } catch (error) {
  9179. throwError(error, 'Gleam.init');
  9180. return false;
  9181. }
  9182. }
  9183. async classifyTask(action) {
  9184. try {
  9185. const logStatus = scripts_echoLog({
  9186. text: i18n('getTasksInfo')
  9187. });
  9188. if (action === 'undo') {
  9189. var _GM_getValue;
  9190. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9191. }
  9192. const tasks = $('.entry-content .entry-method');
  9193. for (const task of tasks) {
  9194. var _socialIcon$attr;
  9195. const $task = $(task);
  9196. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9197. continue;
  9198. }
  9199. const socialIcon = $task.find('.icon-wrapper i');
  9200. const taskInfo = $task.find('.user-links');
  9201. const taskText = taskInfo.text().trim();
  9202. const expandInfo = $task.find('.expandable');
  9203. const aElements = expandInfo.find('a.btn');
  9204. if (aElements.length > 0) {
  9205. for (const element of aElements) {
  9206. const $element = $(element);
  9207. const href = $element.attr('href');
  9208. $element.removeAttr('href')[0].click();
  9209. $element.attr('href', href);
  9210. }
  9211. }
  9212. if (socialIcon.hasClass('fa-twitter')) {
  9213. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9214. if (!link) {
  9215. continue;
  9216. }
  9217. if (/follow/gi.test(taskText)) {
  9218. if (action === 'undo') {
  9219. this.socialTasks.twitter.userLinks.push(link);
  9220. }
  9221. if (action === 'do') {
  9222. this.undoneTasks.twitter.userLinks.push(link);
  9223. }
  9224. } else if (/retweet/gim.test(taskText)) {
  9225. if (action === 'undo') {
  9226. this.socialTasks.twitter.retweetLinks.push(link);
  9227. }
  9228. if (action === 'do') {
  9229. this.undoneTasks.twitter.retweetLinks.push(link);
  9230. }
  9231. }
  9232. } else if (socialIcon.hasClass('fa-twitch')) {
  9233. if (/follow/gim.test(taskText)) {
  9234. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9235. if (!link) {
  9236. continue;
  9237. }
  9238. if (action === 'undo') {
  9239. this.socialTasks.twitch.channelLinks.push(link);
  9240. }
  9241. if (action === 'do') {
  9242. this.undoneTasks.twitch.channelLinks.push(link);
  9243. }
  9244. }
  9245. } else if (socialIcon.hasClass('fa-discord')) {
  9246. if (/join/gim.test(taskText)) {
  9247. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9248. if (!link) {
  9249. var _$task$find$attr, _$task$find$attr$matc;
  9250. 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];
  9251. if (!ggLink) {
  9252. continue;
  9253. }
  9254. link = `https://discord.com/invite/${ggLink}`;
  9255. }
  9256. if (action === 'undo') {
  9257. this.socialTasks.discord.serverLinks.push(link);
  9258. }
  9259. if (action === 'do') {
  9260. this.undoneTasks.discord.serverLinks.push(link);
  9261. }
  9262. }
  9263. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9264. continue;
  9265. } else if (socialIcon.hasClass('fa-youtube')) {
  9266. if (/subscribe/gim.test(taskText)) {
  9267. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9268. if (!link) {
  9269. continue;
  9270. }
  9271. if (action === 'undo') {
  9272. this.socialTasks.youtube.channelLinks.push(link);
  9273. }
  9274. if (action === 'do') {
  9275. this.undoneTasks.youtube.channelLinks.push(link);
  9276. }
  9277. }
  9278. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9279. if (/join.*group/gi.test(taskText)) {
  9280. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9281. if (!link) {
  9282. continue;
  9283. }
  9284. if (action === 'undo') {
  9285. this.socialTasks.steam.groupLinks.push(link);
  9286. }
  9287. if (action === 'do') {
  9288. this.undoneTasks.steam.groupLinks.push(link);
  9289. }
  9290. } else if (/follow.*curator/gi.test(taskText)) {
  9291. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9292. if (!link) {
  9293. continue;
  9294. }
  9295. if (action === 'undo') {
  9296. this.socialTasks.steam.curatorLinks.push(link);
  9297. }
  9298. if (action === 'do') {
  9299. this.undoneTasks.steam.curatorLinks.push(link);
  9300. }
  9301. }
  9302. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9303. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9304. for (const button of continueBtn) {
  9305. button.click();
  9306. await delay(500);
  9307. expandInfo.find('input').val(this.options.vlootUsername);
  9308. }
  9309. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9310. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9311. for (const button of continueBtn) {
  9312. button.click();
  9313. await delay(500);
  9314. expandInfo.find('input').val(this.options.gameroundUsername);
  9315. }
  9316. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9317. if (action !== 'do') {
  9318. continue;
  9319. }
  9320. const link = aElements.attr('href');
  9321. if (!link) {
  9322. continue;
  9323. }
  9324. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9325. if (!gleamLink) {
  9326. continue;
  9327. }
  9328. this.undoneTasks.extra.gleam.push(gleamLink);
  9329. } 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 {
  9330. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9331. }
  9332. }
  9333. logStatus.success();
  9334. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9335. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9336. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9337. tasks: this.socialTasks,
  9338. time: new Date().getTime()
  9339. });
  9340. return true;
  9341. } catch (error) {
  9342. throwError(error, 'Gleam.classifyTask');
  9343. return false;
  9344. }
  9345. }
  9346. async extraDoTask(_ref) {
  9347. let {
  9348. gleam
  9349. } = _ref;
  9350. try {
  9351. const pro = [];
  9352. for (const link of gleam) {
  9353. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9354. }
  9355. return Promise.all(pro).then(() => true);
  9356. } catch (error) {
  9357. throwError(error, 'Gleam.extraDoTask');
  9358. return false;
  9359. }
  9360. }
  9361. async verifyTask() {
  9362. try {
  9363. scripts_echoLog({
  9364. text: `${i18n('verifyingTask')}...`
  9365. });
  9366. const tasks = $('.entry-content .entry-method');
  9367. for (const task of tasks) {
  9368. const $task = $(task);
  9369. if ($task.find('i.fa-question').length === 0) {
  9370. continue;
  9371. }
  9372. const taskInfo = $task.find('.user-links');
  9373. taskInfo[0].click();
  9374. await delay(500);
  9375. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9376. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9377. for (const button of continueBtn) {
  9378. button.click();
  9379. await delay(500);
  9380. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9381. }
  9382. }
  9383. scripts_echoLog({
  9384. text: i18n('verifiedGleamTasks')
  9385. });
  9386. } catch (error) {
  9387. throwError(error, 'Gleam.verifyTask');
  9388. return false;
  9389. }
  9390. }
  9391. }
  9392. async function _checkSync2() {
  9393. try {
  9394. return await new Promise(resolve => {
  9395. const checker = setInterval(() => {
  9396. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9397. clearInterval(checker);
  9398. resolve(true);
  9399. }
  9400. }, 500);
  9401. });
  9402. } catch (error) {
  9403. throwError(error, 'Gleam.checkSync');
  9404. return false;
  9405. }
  9406. }
  9407. async function _doGleamTask2(link) {
  9408. try {
  9409. const logStatus = scripts_echoLog({
  9410. text: i18n('doingGleamTask')
  9411. });
  9412. return await new Promise(resolve => {
  9413. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9414. active: true,
  9415. insert: true,
  9416. setParent: true
  9417. }).onclose = () => {
  9418. logStatus.success();
  9419. resolve(true);
  9420. };
  9421. });
  9422. } catch (error) {
  9423. throwError(error, 'Gleam.doGleamTask');
  9424. return false;
  9425. }
  9426. }
  9427. function Gleam_getGiveawayId2() {
  9428. try {
  9429. const giveawayId = window.location.pathname;
  9430. if (giveawayId) {
  9431. this.giveawayId = giveawayId;
  9432. return true;
  9433. }
  9434. scripts_echoLog({
  9435. text: i18n('getFailed', 'GiveawayId')
  9436. });
  9437. return false;
  9438. } catch (error) {
  9439. throwError(error, 'Gleam.getGiveawayId');
  9440. return false;
  9441. }
  9442. }
  9443. async function _getGleamLink2(link) {
  9444. try {
  9445. const logStatus = scripts_echoLog({
  9446. text: i18n('gettingGleamLink')
  9447. });
  9448. const {
  9449. result,
  9450. statusText,
  9451. status,
  9452. data
  9453. } = await tools_httpRequest({
  9454. url: link,
  9455. method: 'GET'
  9456. });
  9457. if (result === 'Success') {
  9458. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9459. var _data$responseText$ma;
  9460. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9461. if (gleamLink) {
  9462. logStatus.success();
  9463. return gleamLink;
  9464. }
  9465. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9466. return false;
  9467. }
  9468. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9469. return false;
  9470. }
  9471. logStatus.error(`${result}:${statusText}(${status})`);
  9472. return false;
  9473. } catch (error) {
  9474. throwError(error, 'Gleam.getGleamLink');
  9475. return false;
  9476. }
  9477. }
  9478. async function Gleam_checkLeftKey2() {
  9479. try {
  9480. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9481. if (!globalOptions.other.checkLeftKey) {
  9482. return true;
  9483. }
  9484. 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];
  9485. if (!campaignString) {
  9486. return false;
  9487. }
  9488. const {
  9489. campaign,
  9490. incentive
  9491. } = JSON.parse(campaignString);
  9492. 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];
  9493. let ownedKey = false;
  9494. if (controllerString) {
  9495. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9496. 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) {
  9497. ownedKey = true;
  9498. }
  9499. }
  9500. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9501. await external_Swal_default().fire({
  9502. icon: 'warning',
  9503. title: i18n('notice'),
  9504. text: i18n('giveawayNotWork'),
  9505. confirmButtonText: i18n('confirm'),
  9506. cancelButtonText: i18n('cancel'),
  9507. showCancelButton: true
  9508. }).then(_ref2 => {
  9509. let {
  9510. value
  9511. } = _ref2;
  9512. if (value) {
  9513. window.close();
  9514. }
  9515. });
  9516. }
  9517. return true;
  9518. } catch (error) {
  9519. throwError(error, 'Gleam.checkLeftKey');
  9520. return false;
  9521. }
  9522. }
  9523. const website_Gleam = Gleam;
  9524. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9525. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9526. privateSet.add(obj);
  9527. }
  9528. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9529. if (privateCollection.has(obj)) {
  9530. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9531. }
  9532. }
  9533. function SweepWidget_defineProperty(obj, key, value) {
  9534. if (key in obj) {
  9535. Object.defineProperty(obj, key, {
  9536. value: value,
  9537. enumerable: true,
  9538. configurable: true,
  9539. writable: true
  9540. });
  9541. } else {
  9542. obj[key] = value;
  9543. }
  9544. return obj;
  9545. }
  9546. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9547. if (!privateSet.has(receiver)) {
  9548. throw new TypeError('attempted to get private field on non-instance');
  9549. }
  9550. return fn;
  9551. }
  9552. const SweepWidget_defaultOptions = {
  9553. username: '',
  9554. email: ''
  9555. };
  9556. var SweepWidget_checkLogin = new WeakSet();
  9557. var SweepWidget_getGiveawayId = new WeakSet();
  9558. var _checkEnter = new WeakSet();
  9559. var _checkFinish = new WeakSet();
  9560. class SweepWidget extends website_Website {
  9561. constructor() {
  9562. super(...arguments);
  9563. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9564. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9565. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9566. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9567. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9568. SweepWidget_defineProperty(this, 'options', {
  9569. ...SweepWidget_defaultOptions,
  9570. ...GM_getValue('SweepWidgetOptions')
  9571. });
  9572. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9573. }
  9574. static test() {
  9575. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9576. }
  9577. async after() {
  9578. try {
  9579. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9580. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9581. }
  9582. } catch (error) {
  9583. throwError(error, 'SweepWidget.after');
  9584. }
  9585. }
  9586. init() {
  9587. try {
  9588. const logStatus = scripts_echoLog({
  9589. text: i18n('initing')
  9590. });
  9591. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9592. logStatus.warning(i18n('needLogin'));
  9593. return false;
  9594. }
  9595. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9596. return false;
  9597. }
  9598. this.initialized = true;
  9599. logStatus.success();
  9600. return true;
  9601. } catch (error) {
  9602. throwError(error, 'SweepWidget.init');
  9603. return false;
  9604. }
  9605. }
  9606. classifyTask() {
  9607. return true;
  9608. }
  9609. async doTask() {
  9610. try {
  9611. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9612. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9613. $('input[name="sw__login_name"]').val(this.options.username);
  9614. }
  9615. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9616. $('input[name="sw__login_email"]').val(this.options.email);
  9617. }
  9618. if ($('#sw_login_button:visible').length > 0) {
  9619. $('#sw_login_button')[0].click();
  9620. }
  9621. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9622. return false;
  9623. }
  9624. }
  9625. const logStatus = scripts_echoLog({
  9626. text: i18n('SweepWidgetNotice')
  9627. });
  9628. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9629. for (const task of tasks) {
  9630. var _aElement$, _$task$find$removeAtt;
  9631. const $task = $(task);
  9632. if ($task.find('i.fa-check:visible').length > 0) {
  9633. continue;
  9634. }
  9635. const title = $task.find('.sw_text_inner');
  9636. title[0].click();
  9637. const aElement = $task.find('a.sw_link');
  9638. const link = aElement.attr('href');
  9639. aElement.attr('href', '#a').attr('target', '_self');
  9640. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9641. await delay(300);
  9642. aElement.attr('href', link).attr('target', '_blank');
  9643. $task.find('input[type="text"]').val('test');
  9644. const verifyBtn = $task.find('input.sw_verify');
  9645. if (verifyBtn.prop('disabled') === true) {
  9646. title[0].click();
  9647. await delay(300);
  9648. title[0].click();
  9649. await delay(300);
  9650. }
  9651. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9652. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9653. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9654. }
  9655. logStatus.success();
  9656. return true;
  9657. } catch (error) {
  9658. throwError(error, 'SweepWidget.doTask');
  9659. return false;
  9660. }
  9661. }
  9662. }
  9663. function SweepWidget_checkLogin2() {
  9664. try {
  9665. if ($('#twitter_login_button').length > 0) {
  9666. $('#twitter_login_button')[0].click();
  9667. }
  9668. return true;
  9669. } catch (error) {
  9670. throwError(error, 'SweepWidget.checkLogin');
  9671. return false;
  9672. }
  9673. }
  9674. function SweepWidget_getGiveawayId2() {
  9675. try {
  9676. var _window$location$href;
  9677. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9678. if (giveawayId) {
  9679. this.giveawayId = giveawayId;
  9680. return true;
  9681. }
  9682. scripts_echoLog({
  9683. text: i18n('getFailed', 'GiveawayId')
  9684. });
  9685. return false;
  9686. } catch (error) {
  9687. throwError(error, 'SweepWidget.getGiveawayId');
  9688. return false;
  9689. }
  9690. }
  9691. async function _checkEnter2() {
  9692. try {
  9693. return new Promise(resolve => {
  9694. const checker = setInterval(() => {
  9695. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9696. clearInterval(checker);
  9697. resolve(true);
  9698. }
  9699. });
  9700. });
  9701. } catch (error) {
  9702. throwError(error, 'SweepWidget.checkEnter');
  9703. return false;
  9704. }
  9705. }
  9706. async function _checkFinish2($task) {
  9707. try {
  9708. return new Promise(resolve => {
  9709. const checker = setInterval(() => {
  9710. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9711. clearInterval(checker);
  9712. resolve(true);
  9713. }
  9714. });
  9715. });
  9716. } catch (error) {
  9717. throwError(error, 'SweepWidget.checkFinish');
  9718. return false;
  9719. }
  9720. }
  9721. const website_SweepWidget = SweepWidget;
  9722. const defaultWhiteList = {
  9723. discord: {
  9724. servers: []
  9725. },
  9726. instagram: {
  9727. users: []
  9728. },
  9729. twitch: {
  9730. channels: []
  9731. },
  9732. twitter: {
  9733. users: [],
  9734. retweets: [],
  9735. likes: []
  9736. },
  9737. vk: {
  9738. names: []
  9739. },
  9740. youtube: {
  9741. channels: [],
  9742. likes: []
  9743. },
  9744. reddit: {
  9745. reddits: []
  9746. },
  9747. steam: {
  9748. groups: [],
  9749. wishlists: [],
  9750. follows: [],
  9751. forums: [],
  9752. workshops: [],
  9753. curators: [],
  9754. workshopVotes: [],
  9755. curatorLikes: [],
  9756. announcements: [],
  9757. licenses: [],
  9758. playtests: []
  9759. }
  9760. };
  9761. const link2id = async function(type) {
  9762. 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;
  9763. try {
  9764. const link = $('#socialLink').val();
  9765. let id = '';
  9766. switch (type) {
  9767. case 'discord.servers':
  9768. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9769. break;
  9770.  
  9771. case 'instagram.users':
  9772. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9773. break;
  9774.  
  9775. case 'twitch.channels':
  9776. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9777. break;
  9778.  
  9779. case 'twitter.users':
  9780. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9781. break;
  9782.  
  9783. case 'twitter.retweets':
  9784. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9785. break;
  9786.  
  9787. case 'vk.names':
  9788. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9789. break;
  9790.  
  9791. case 'youtube.channels':
  9792. 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) || '';
  9793. break;
  9794.  
  9795. case 'youtube.likes':
  9796. 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) || '';
  9797. break;
  9798.  
  9799. case 'reddit.reddits':
  9800. 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]) || '';
  9801. break;
  9802.  
  9803. case 'steam.groups':
  9804. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9805. break;
  9806.  
  9807. case 'steam.wishlists':
  9808. case 'steam.follows':
  9809. case 'steam.forums':
  9810. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9811. break;
  9812.  
  9813. case 'steam.workshops':
  9814. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9815. break;
  9816.  
  9817. case 'steam.curators':
  9818. {
  9819. if (link.includes('curator')) {
  9820. var _link$match12;
  9821. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9822. } else {
  9823. var _link$match13;
  9824. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9825. if (!param || param.length !== 2) {
  9826. break;
  9827. }
  9828. const steam = new social_Steam();
  9829. if (await steam.init()) {
  9830. id = await steam.getCuratorId(param[0], param[1]) || '';
  9831. }
  9832. }
  9833. }
  9834. break;
  9835. }
  9836. return id;
  9837. } catch (error) {
  9838. throwError(error, 'link2id');
  9839. return i18n('getFailed', 'id');
  9840. }
  9841. };
  9842. const disabledType = {
  9843. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9844. twitter: [ 'likes' ]
  9845. };
  9846. const whiteListOptions = function(showType) {
  9847. try {
  9848. const whiteList = {
  9849. ...defaultWhiteList,
  9850. ...GM_getValue('whiteList') || {}
  9851. };
  9852. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9853. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9854. for (const [ social, types ] of Object.entries(whiteList)) {
  9855. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9856. var _disabledType$social;
  9857. 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>`;
  9858. }).join('');
  9859. }
  9860. whiteListOptionsForm += '</tbody></table></form>';
  9861. if (showType === 'swal') {
  9862. external_Swal_default().fire({
  9863. title: i18n('whiteListOptions'),
  9864. html: whiteListOptionsForm,
  9865. showConfirmButton: false,
  9866. showCloseButton: true
  9867. });
  9868. } else {
  9869. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9870. }
  9871. $('.editWhiteList').on('click', function() {
  9872. var _whiteList$social;
  9873. const value = $(this).attr('data-value');
  9874. if (!value) {
  9875. return;
  9876. }
  9877. const [ social, type ] = value.split('.');
  9878. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9879. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9880. return;
  9881. }
  9882. external_Swal_default().fire({
  9883. title: i18n('changeWhiteListOption', value),
  9884. input: 'textarea',
  9885. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9886. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9887. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9888. inputValue: whiteList[social][type].join('\n'),
  9889. showConfirmButton: true,
  9890. confirmButtonText: i18n('save'),
  9891. showCancelButton: true,
  9892. cancelButtonText: i18n('close'),
  9893. showDenyButton: true,
  9894. denyButtonText: i18n('return')
  9895. }).then(_ref => {
  9896. let {
  9897. isDenied,
  9898. isConfirmed,
  9899. value
  9900. } = _ref;
  9901. if (isDenied) {
  9902. if (showType === 'swal') {
  9903. whiteListOptions(showType);
  9904. }
  9905. return;
  9906. } else if (isConfirmed) {
  9907. whiteList[social][type] = value.split('\n');
  9908. GM_setValue('whiteList', whiteList);
  9909. external_Swal_default().fire({
  9910. title: i18n('changeWhiteListSuccess'),
  9911. icon: 'success'
  9912. });
  9913. }
  9914. });
  9915. $('#link2id').on('click', async function() {
  9916. const type = $(this).attr('data-type');
  9917. $('#socialLink').val(await link2id(type));
  9918. });
  9919. });
  9920. } catch (error) {
  9921. throwError(error, 'whiteListOptions');
  9922. }
  9923. };
  9924. const whiteList = whiteListOptions;
  9925. const setGistData = async (token, gistId, fileName, content) => {
  9926. try {
  9927. const logStatus = scripts_echoLog({
  9928. text: i18n('settingData')
  9929. });
  9930. const contentData = JSON.stringify({
  9931. files: {
  9932. [fileName]: {
  9933. content: JSON.stringify(content)
  9934. }
  9935. }
  9936. });
  9937. const {
  9938. result,
  9939. statusText,
  9940. status,
  9941. data
  9942. } = await tools_httpRequest({
  9943. url: `https://api.github.com/gists/${gistId}`,
  9944. headers: {
  9945. Accept: 'application/vnd.github.v3+json',
  9946. Authorization: `token ${token}`
  9947. },
  9948. data: contentData,
  9949. responseType: 'json',
  9950. method: 'POST',
  9951. timeout: 3e4
  9952. });
  9953. if (result === 'Success') {
  9954. var _data$response$files, _data$response$files$;
  9955. 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)) {
  9956. logStatus.success();
  9957. return true;
  9958. }
  9959. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9960. return false;
  9961. }
  9962. logStatus.error(`${result}:${statusText}(${status})`);
  9963. return false;
  9964. } catch (error) {
  9965. throwError(error, 'setGistData');
  9966. return false;
  9967. }
  9968. };
  9969. const getGistData = async (token, gistId, fileName) => {
  9970. try {
  9971. const logStatus = scripts_echoLog({
  9972. text: i18n('gettingData')
  9973. });
  9974. const {
  9975. result,
  9976. statusText,
  9977. status,
  9978. data
  9979. } = await tools_httpRequest({
  9980. url: `https://api.github.com/gists/${gistId}`,
  9981. headers: {
  9982. Accept: 'application/vnd.github.v3+json',
  9983. Authorization: `token ${token}`
  9984. },
  9985. responseType: 'json',
  9986. method: 'GET',
  9987. timeout: 3e4
  9988. });
  9989. if (result === 'Success') {
  9990. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9991. var _data$response, _data$response$files2, _data$response$files3;
  9992. logStatus.success();
  9993. return JSON.parse(((_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) || null);
  9994. }
  9995. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9996. return false;
  9997. }
  9998. logStatus.error(`${result}:${statusText}(${status})`);
  9999. return false;
  10000. } catch (error) {
  10001. throwError(error, 'getGistData');
  10002. return false;
  10003. }
  10004. };
  10005. const syncOptions = () => {
  10006. try {
  10007. const {
  10008. TOKEN,
  10009. GIST_ID,
  10010. FILE_NAME,
  10011. SYNC_HISTORY
  10012. } = GM_getValue('gistOptions') || {
  10013. TOKEN: '',
  10014. GIST_ID: '',
  10015. FILE_NAME: '',
  10016. SYNC_HISTORY: true
  10017. };
  10018. external_Swal_default().fire({
  10019. title: i18n('gistOptions'),
  10020. 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;">
  10021. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10022. ${i18n('downloadFromGist')}</button></p>`,
  10023. focusConfirm: false,
  10024. showLoaderOnConfirm: true,
  10025. 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>`,
  10026. preConfirm: async () => {
  10027. const token = $('#github-token').val();
  10028. const gistId = $('#gist-id').val();
  10029. const fileName = $('#file-name').val();
  10030. const syncHistory = $('#sync-history').prop('checked');
  10031. GM_setValue('gistOptions', {
  10032. TOKEN: token,
  10033. GIST_ID: gistId,
  10034. FILE_NAME: fileName,
  10035. SYNC_HISTORY: syncHistory
  10036. });
  10037. return await getGistData(token, gistId, fileName);
  10038. },
  10039. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10040. confirmButtonText: i18n('saveAndTest'),
  10041. showCancelButton: true,
  10042. cancelButtonText: i18n('close')
  10043. }).then(_ref => {
  10044. let {
  10045. value
  10046. } = _ref;
  10047. if (value) {
  10048. external_Swal_default().fire({
  10049. icon: 'success',
  10050. title: i18n('testSuccess')
  10051. }).then(syncOptions);
  10052. } else if (value !== undefined) {
  10053. external_Swal_default().fire({
  10054. icon: 'error',
  10055. title: i18n('testFailed')
  10056. }).then(syncOptions);
  10057. }
  10058. });
  10059. $('#upload-data').on('click', async () => {
  10060. const {
  10061. TOKEN,
  10062. GIST_ID,
  10063. FILE_NAME
  10064. } = GM_getValue('gistOptions') || {};
  10065. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10066. return external_Swal_default().fire({
  10067. icon: 'error',
  10068. title: i18n('saveAndTestNotice')
  10069. }).then(syncOptions);
  10070. }
  10071. external_Swal_default().fire({
  10072. icon: 'info',
  10073. title: i18n('processingData')
  10074. });
  10075. const data = {};
  10076. const names = GM_listValues();
  10077. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10078. for (const name of names) {
  10079. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10080. continue;
  10081. }
  10082. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10083. continue;
  10084. }
  10085. data[name] = GM_getValue(name);
  10086. }
  10087. external_Swal_default().update({
  10088. icon: 'info',
  10089. title: i18n('updatingData')
  10090. });
  10091. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10092. external_Swal_default().fire({
  10093. icon: 'success',
  10094. title: i18n('syncDataSuccess')
  10095. });
  10096. } else {
  10097. external_Swal_default().fire({
  10098. icon: 'error',
  10099. title: i18n('syncDataFailed')
  10100. });
  10101. }
  10102. });
  10103. $('#download-data').on('click', async () => {
  10104. const {
  10105. TOKEN,
  10106. GIST_ID,
  10107. FILE_NAME
  10108. } = GM_getValue('gistOptions') || {};
  10109. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10110. return external_Swal_default().fire({
  10111. icon: 'error',
  10112. title: i18n('saveAndTestNotice')
  10113. }).then(syncOptions);
  10114. }
  10115. external_Swal_default().fire({
  10116. icon: 'info',
  10117. title: i18n('downloadingData')
  10118. });
  10119. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10120. if (!data) {
  10121. return external_Swal_default().fire({
  10122. icon: 'error',
  10123. title: i18n('checkedNoData')
  10124. }).then(syncOptions);
  10125. }
  10126. external_Swal_default().update({
  10127. icon: 'info',
  10128. title: i18n('savingData')
  10129. });
  10130. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10131. for (const [ name, value ] of Object.entries(data)) {
  10132. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10133. continue;
  10134. }
  10135. GM_setValue(name, value);
  10136. }
  10137. external_Swal_default().fire({
  10138. icon: 'success',
  10139. title: i18n('syncDataSuccess')
  10140. });
  10141. });
  10142. } catch (error) {
  10143. throwError(error, 'syncOptions');
  10144. }
  10145. };
  10146. const dataSync = syncOptions;
  10147. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10148. Setting_checkPrivateRedeclaration(obj, privateSet);
  10149. privateSet.add(obj);
  10150. }
  10151. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10152. if (privateCollection.has(obj)) {
  10153. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10154. }
  10155. }
  10156. function Setting_defineProperty(obj, key, value) {
  10157. if (key in obj) {
  10158. Object.defineProperty(obj, key, {
  10159. value: value,
  10160. enumerable: true,
  10161. configurable: true,
  10162. writable: true
  10163. });
  10164. } else {
  10165. obj[key] = value;
  10166. }
  10167. return obj;
  10168. }
  10169. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10170. if (!privateSet.has(receiver)) {
  10171. throw new TypeError('attempted to get private field on non-instance');
  10172. }
  10173. return fn;
  10174. }
  10175. var Setting_getId = new WeakSet();
  10176. var _environment = new WeakSet();
  10177. class Setting {
  10178. constructor() {
  10179. Setting_classPrivateMethodInitSpec(this, _environment);
  10180. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10181. Setting_defineProperty(this, 'name', 'Setting');
  10182. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10183. Setting_defineProperty(this, 'syncData', dataSync);
  10184. }
  10185. tasksHistory() {
  10186. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10187. }
  10188. static test() {
  10189. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10190. }
  10191. before() {
  10192. $('body').html('').addClass('auto-task-options');
  10193. }
  10194. after() {
  10195. try {
  10196. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10197. changeGlobalOptions('page');
  10198. whiteList('page');
  10199. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10200. $('#getTwitterUserId').on('click', () => {
  10201. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10202. });
  10203. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10204. $('#getYoutubeChannelId').on('click', () => {
  10205. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10206. });
  10207. $('input[name^="position"]').on('input', function() {
  10208. const type = $(this).attr('name').replace('position.', '');
  10209. const xLabel = 'rightleft';
  10210. const yLabel = 'topbottpm';
  10211. switch (type) {
  10212. case 'buttonSideX':
  10213. case 'buttonSideY':
  10214. case 'buttonDistance':
  10215. {
  10216. const distance = $('input[name="position.buttonDistance"]').val();
  10217. const sideX = $('input[name="position.buttonSideX"]').val();
  10218. const sideY = $('input[name="position.buttonSideY"]').val();
  10219. if (![ 'right', 'left' ].includes(sideX)) {
  10220. break;
  10221. }
  10222. if (![ 'top', 'bottom' ].includes(sideY)) {
  10223. break;
  10224. }
  10225. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10226. break;
  10227. }
  10228. const distanceArr = distance.split(',');
  10229. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10230. break;
  10231. }
  10232.  
  10233. case 'showButtonSideX':
  10234. case 'showButtonSideY':
  10235. case 'showButtonDistance':
  10236. {
  10237. const distance = $('input[name="position.showButtonDistance"]').val();
  10238. const sideX = $('input[name="position.showButtonSideX"]').val();
  10239. const sideY = $('input[name="position.showButtonSideY"]').val();
  10240. if (![ 'right', 'left' ].includes(sideX)) {
  10241. break;
  10242. }
  10243. if (![ 'top', 'bottom' ].includes(sideY)) {
  10244. break;
  10245. }
  10246. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10247. break;
  10248. }
  10249. const distanceArr = distance.split(',');
  10250. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10251. break;
  10252. }
  10253.  
  10254. case 'logSideX':
  10255. case 'logSideY':
  10256. case 'logDistance':
  10257. {
  10258. const distance = $('input[name="position.logDistance"]').val();
  10259. const sideX = $('input[name="position.logSideX"]').val();
  10260. const sideY = $('input[name="position.logSideY"]').val();
  10261. if (![ 'right', 'left' ].includes(sideX)) {
  10262. break;
  10263. }
  10264. if (![ 'top', 'bottom' ].includes(sideY)) {
  10265. break;
  10266. }
  10267. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10268. break;
  10269. }
  10270. const distanceArr = distance.split(',');
  10271. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10272. break;
  10273. }
  10274.  
  10275. default:
  10276. break;
  10277. }
  10278. });
  10279. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10280. let functionKey = '';
  10281. if (event.altKey) {
  10282. functionKey += 'alt + ';
  10283. } else if (event.ctrlKey) {
  10284. functionKey += 'ctrl + ';
  10285. } else if (event.shiftKey) {
  10286. functionKey += 'shift + ';
  10287. }
  10288. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10289. });
  10290. } catch (error) {
  10291. throwError(error, 'Setting.after');
  10292. }
  10293. }
  10294. saveGlobalOptions() {
  10295. saveData();
  10296. }
  10297. }
  10298. function Setting_getId2(social) {
  10299. try {
  10300. external_Swal_default().fire({
  10301. title: i18n('getId', i18n(social)),
  10302. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10303. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10304. showCancelButton: true,
  10305. cancelButtonText: i18n('close'),
  10306. showConfirmButton: false
  10307. });
  10308. $('#link2id').on('click', async function() {
  10309. const link = $('#socialLink').val();
  10310. if (!link) {
  10311. return;
  10312. }
  10313. const type = $(this).attr('data-type');
  10314. if (type === 'twitterUser') {
  10315. var _link$match;
  10316. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10317. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10318. } else if (type === 'youtubeChannel') {
  10319. var _link$match2, _await$getInfo, _await$getInfo$params;
  10320. 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;
  10321. $('#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) || '');
  10322. }
  10323. });
  10324. } catch (error) {
  10325. throwError(error, 'Setting.getId');
  10326. }
  10327. }
  10328. function _environment2() {
  10329. try {
  10330. const userAgent = (0, javascript_utils_umd_min.ua)();
  10331. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10332. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10333. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10334. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10335. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10336. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10337. </tbody></table></form>`;
  10338. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10339. } catch (error) {
  10340. throwError(error, 'Setting.environment');
  10341. }
  10342. }
  10343. const website_Setting = Setting;
  10344. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10345. History_checkPrivateRedeclaration(obj, privateSet);
  10346. privateSet.add(obj);
  10347. }
  10348. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10349. if (privateCollection.has(obj)) {
  10350. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10351. }
  10352. }
  10353. function History_defineProperty(obj, key, value) {
  10354. if (key in obj) {
  10355. Object.defineProperty(obj, key, {
  10356. value: value,
  10357. enumerable: true,
  10358. configurable: true,
  10359. writable: true
  10360. });
  10361. } else {
  10362. obj[key] = value;
  10363. }
  10364. return obj;
  10365. }
  10366. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10367. if (!privateSet.has(receiver)) {
  10368. throw new TypeError('attempted to get private field on non-instance');
  10369. }
  10370. return fn;
  10371. }
  10372. var _addItem = new WeakSet();
  10373. class History extends website_Keylol {
  10374. constructor() {
  10375. super(...arguments);
  10376. History_classPrivateMethodInitSpec(this, _addItem);
  10377. History_defineProperty(this, 'name', 'History');
  10378. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10379. }
  10380. static test() {
  10381. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10382. }
  10383. before() {
  10384. try {
  10385. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10386. const data = GM_listValues() || [];
  10387. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10388. for (const item of tasksHistory) {
  10389. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10390. }
  10391. } catch (error) {
  10392. throwError(error, 'History.before');
  10393. }
  10394. }
  10395. clearHistory() {
  10396. try {
  10397. const data = GM_listValues() || [];
  10398. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10399. for (const item of tasksHistory) {
  10400. GM_deleteValue(item);
  10401. }
  10402. external_Swal_default().fire({
  10403. title: i18n('clearHistoryFinished'),
  10404. icon: 'success'
  10405. });
  10406. } catch (error) {
  10407. throwError(error, 'History.after');
  10408. }
  10409. }
  10410. }
  10411. function _addItem2(item) {
  10412. try {
  10413. const tasksData = GM_getValue(item);
  10414. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10415. return;
  10416. }
  10417. let html = '';
  10418. let title = '';
  10419. let link = '';
  10420. const [ website, id ] = item.split('-');
  10421. switch (website) {
  10422. case 'fawTasks':
  10423. title = `Freeanywhere[${id}]`;
  10424. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10425. break;
  10426.  
  10427. case 'gasTasks':
  10428. title = `Giveawaysu[${id}]`;
  10429. link = `https://giveaway.su/giveaway/view/${id}`;
  10430. break;
  10431.  
  10432. case 'gcTasks':
  10433. title = `GiveeClub[${id}]`;
  10434. link = `https://givee.club/event/${id}`;
  10435. break;
  10436.  
  10437. case 'gkTasks':
  10438. title = `Givekey[${id}]`;
  10439. link = `https://givekey.ru/giveaway/${id}`;
  10440. break;
  10441.  
  10442. case 'gleamTasks':
  10443. title = `Gleam[${id}]`;
  10444. link = `https://gleam.io${id}`;
  10445. break;
  10446.  
  10447. case 'khTasks':
  10448. title = `keyhub[${id}]`;
  10449. link = `https://key-hub.eu/giveaway/${id}`;
  10450. break;
  10451.  
  10452. case 'prysTasks':
  10453. title = `Prys[${id}]`;
  10454. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10455. break;
  10456.  
  10457. default:
  10458. return;
  10459. }
  10460. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10461. for (const [ type, tasks ] of Object.entries(types)) {
  10462. for (const task of tasks) {
  10463. 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>`;
  10464. }
  10465. }
  10466. }
  10467. $('.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>`);
  10468. $('span.delete-task').on('click', function() {
  10469. const itemName = $(this).attr('data-name');
  10470. if (itemName) {
  10471. GM_deleteValue(itemName);
  10472. external_Swal_default().fire({
  10473. title: i18n('clearTaskFinished'),
  10474. text: itemName,
  10475. icon: 'success'
  10476. });
  10477. } else {
  10478. external_Swal_default().fire({
  10479. title: i18n('clearTaskFailed'),
  10480. icon: 'error'
  10481. });
  10482. }
  10483. });
  10484. } catch (error) {
  10485. throwError(error, 'History.addItem');
  10486. }
  10487. }
  10488. const website_History = History;
  10489. 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 ];
  10490. const websiteOptions = function(website, options) {
  10491. try {
  10492. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10493. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10494. for (const [ option, value ] of Object.entries(options)) {
  10495. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10496. }
  10497. websiteOptionsForm += '</tbody></table></form>';
  10498. external_Swal_default().fire({
  10499. title: i18n('websiteOptions'),
  10500. html: websiteOptionsForm,
  10501. showConfirmButton: true,
  10502. confirmButtonText: i18n('save'),
  10503. showCancelButton: true,
  10504. cancelButtonText: i18n('close')
  10505. }).then(_ref => {
  10506. let {
  10507. isConfirmed
  10508. } = _ref;
  10509. if (isConfirmed) {
  10510. $('#websiteOptionsForm').serializeArray().map(value => {
  10511. options[value.name] = value.value;
  10512. return value;
  10513. });
  10514. GM_setValue(`${website}Options`, options);
  10515. external_Swal_default().fire({
  10516. title: i18n('changeWebsiteOptionsSuccess'),
  10517. icon: 'success'
  10518. });
  10519. }
  10520. });
  10521. } catch (error) {
  10522. throwError(error, 'websiteOptions');
  10523. }
  10524. };
  10525. const options = websiteOptions;
  10526. const external_keyboardJS_namespaceObject = keyboardJS;
  10527. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10528. const checkUpdate = async (updateLink, auto) => {
  10529. try {
  10530. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10531. const {
  10532. result,
  10533. statusText,
  10534. status,
  10535. data
  10536. } = await tools_httpRequest({
  10537. url: checkUrl,
  10538. responseType: 'json',
  10539. method: 'GET',
  10540. timeout: 3e4
  10541. });
  10542. if (result === 'Success') {
  10543. var _data$response;
  10544. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10545. return data.response;
  10546. }
  10547. if (!auto) {
  10548. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10549. }
  10550. return false;
  10551. }
  10552. if (!auto) {
  10553. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10554. }
  10555. return false;
  10556. } catch (error) {
  10557. throwError(error, 'checkUpdate');
  10558. return false;
  10559. }
  10560. };
  10561. const hasNewVersion = (currentVersion, remoteVersion) => {
  10562. try {
  10563. const [ currentRealVersion ] = currentVersion.split('-');
  10564. const [ remoteRealVersion ] = remoteVersion.split('-');
  10565. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10566. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10567. if (remoteVersion1 > currentVersion1) {
  10568. return true;
  10569. }
  10570. if (remoteVersion1 < currentVersion1) {
  10571. return false;
  10572. }
  10573. if (remoteVersion2 > currentVersion2) {
  10574. return true;
  10575. }
  10576. if (remoteVersion2 < currentVersion2) {
  10577. return false;
  10578. }
  10579. if (remoteVersion3 > currentVersion3) {
  10580. return true;
  10581. }
  10582. return false;
  10583. } catch (error) {
  10584. throwError(error, 'compareVersion');
  10585. return false;
  10586. }
  10587. };
  10588. const updateChecker = async () => {
  10589. try {
  10590. const currentVersion = GM_info.script.version;
  10591. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10592. const updateLinks = {
  10593. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10594. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10595. standby: 'https://auto-task-v4.hclonely.com/'
  10596. };
  10597. let version;
  10598. let updateLink = '';
  10599. let packageData;
  10600. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10601. updateLink = updateLinks[updateSource];
  10602. packageData = await checkUpdate(updateLink, false);
  10603. } else {
  10604. updateLink = updateLinks.github;
  10605. packageData = await checkUpdate(updateLink, true);
  10606. if (!packageData) {
  10607. updateLink = updateLinks.jsdelivr;
  10608. packageData = await checkUpdate(updateLink, true);
  10609. if (!packageData) {
  10610. updateLink = updateLinks.standby;
  10611. packageData = await checkUpdate(updateLink, true);
  10612. }
  10613. }
  10614. }
  10615. if (packageData) {
  10616. version = packageData.version || currentVersion;
  10617. } else {
  10618. version = currentVersion;
  10619. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10620. }
  10621. if (packageData && hasNewVersion(currentVersion, version)) {
  10622. var _packageData$change;
  10623. scripts_echoLog({
  10624. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10625. });
  10626. scripts_echoLog({
  10627. 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>`
  10628. });
  10629. }
  10630. } catch (error) {
  10631. throwError(error, 'updateChecker');
  10632. }
  10633. };
  10634. const scripts_updateChecker = updateChecker;
  10635. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  10636. if (window.location.hostname === 'discord.com') {
  10637. const LocalStorage = window.localStorage;
  10638. if (window.location.hash === '#auth') {
  10639. var _LocalStorage$getItem;
  10640. window.localStorage.removeItem = () => true;
  10641. 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, '');
  10642. if (discordAuth && /^mfa\./.test(discordAuth)) {
  10643. GM_setValue('discordAuth', {
  10644. auth: discordAuth
  10645. });
  10646. window.close();
  10647. external_Swal_default().fire('', i18n('closePageNotice'));
  10648. } else {
  10649. external_Swal_default().fire({
  10650. text: i18n('getDiscordAuthFailed'),
  10651. icon: 'error'
  10652. });
  10653. }
  10654. } else {
  10655. var _LocalStorage$getItem2;
  10656. 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, '');
  10657. if (discordAuth && /^mfa\./.test(discordAuth)) {
  10658. GM_setValue('discordAuth', {
  10659. auth: discordAuth
  10660. });
  10661. }
  10662. }
  10663. }
  10664. const loadScript = async () => {
  10665. var _website, _website2, _website3, _website4, _website5, _website6;
  10666. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10667. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10668. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10669. if (isLogin) {
  10670. var _commonOptions, _commonOptions$header;
  10671. GM_setValue('twitchAuth', {
  10672. authToken: authToken,
  10673. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10674. });
  10675. window.close();
  10676. external_Swal_default().fire('', i18n('closePageNotice'));
  10677. } else {
  10678. external_Swal_default().fire('', i18n('needLogin'));
  10679. }
  10680. }
  10681. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10682. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10683. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10684. if (isLogin && ct0) {
  10685. GM_setValue('twitterAuth', {
  10686. ct0: ct0
  10687. });
  10688. window.close();
  10689. external_Swal_default().fire('', i18n('closePageNotice'));
  10690. } else {
  10691. external_Swal_default().fire('', i18n('needLogin'));
  10692. }
  10693. }
  10694. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10695. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10696. if (PAPISID) {
  10697. GM_setValue('youtubeAuth', {
  10698. PAPISID: PAPISID
  10699. });
  10700. window.close();
  10701. external_Swal_default().fire('', i18n('closePageNotice'));
  10702. } else {
  10703. external_Swal_default().fire('', i18n('needLogin'));
  10704. }
  10705. }
  10706. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10707. const betaButton = $('#redesign-beta-optin-btn');
  10708. if (betaButton.length > 0) {
  10709. GM_setValue('redditAuth', '#auth');
  10710. return betaButton[0].click();
  10711. }
  10712. GM_setValue('redditAuth', null);
  10713. window.close();
  10714. external_Swal_default().fire('', i18n('closePageNotice'));
  10715. }
  10716. let website;
  10717. for (const Website of Websites) {
  10718. if (Website.test()) {
  10719. website = new Website();
  10720. break;
  10721. }
  10722. }
  10723. if (!website) {
  10724. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10725. return;
  10726. }
  10727. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10728. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10729. }
  10730. $('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>`);
  10731. $('div.show-button-div').on('click', () => {
  10732. $('#auto-task-buttons').show();
  10733. $('div.show-button-div').hide();
  10734. });
  10735. const toggleLog = () => {
  10736. const $this = $('#toggle-log');
  10737. const status = $this.attr('data-status');
  10738. if (status === 'show') {
  10739. $('#auto-task-info').hide();
  10740. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10741. } else {
  10742. $('#auto-task-info').show();
  10743. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10744. }
  10745. };
  10746. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10747. if (website.doTask) {
  10748. website.doTask();
  10749. }
  10750. });
  10751. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10752. if (website.undoTask) {
  10753. website.doTask();
  10754. }
  10755. });
  10756. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10757. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10758. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10759. }
  10760. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10761. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10762. for (const button of website.buttons) {
  10763. if (website[button]) {
  10764. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10765. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10766. website[button]();
  10767. });
  10768. $('#auto-task-buttons').append(btnElement);
  10769. }
  10770. }
  10771. }
  10772. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10773. ${i18n('hideButton')}</a></p>`);
  10774. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10775. $('#auto-task-buttons').hide();
  10776. $('div.show-button-div').show();
  10777. });
  10778. 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'}">
  10779. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10780. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10781. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10782. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10783. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10784. options(website.name, website.options);
  10785. });
  10786. }
  10787. if (website.name !== 'Setting') {
  10788. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10789. changeGlobalOptions('swal');
  10790. });
  10791. GM_registerMenuCommand(i18n('settingPage'), () => {
  10792. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10793. });
  10794. }
  10795. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10796. if (!GM_getValue('notice')) {
  10797. var _echoLog$font;
  10798. external_Swal_default().fire({
  10799. title: i18n('swalNotice'),
  10800. icon: 'warning'
  10801. }).then(() => {
  10802. window.open(i18n('noticeLink'), '_blank');
  10803. GM_setValue('notice', new Date().getTime());
  10804. });
  10805. (_echoLog$font = scripts_echoLog({
  10806. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10807. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10808. GM_setValue('notice', new Date().getTime());
  10809. });
  10810. }
  10811. scripts_updateChecker();
  10812. };
  10813. if (window.location.hostname === 'opquests.com') {
  10814. loadScript();
  10815. } else {
  10816. $(loadScript);
  10817. }
  10818. }();
  10819. })();