auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.10
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12. // @icon https://auto-task-v4.hclonely.com/favicon.ico
  13.  
  14. // @include *://freeanywhere.net/*
  15. // @include *://giveaway.su/giveaway/view/*
  16. // @include *://givee.club/*/event/*
  17. // @include *://givekey.ru/giveaway/*
  18. // @include *://www.indiedb.com/giveaways*
  19. // @include *://key-hub.eu/giveaway/*
  20. // @include *://keylol.com/*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://prys.revadike.com/giveaway/?id=*
  23. // @include *://opquests.com/quests/*
  24. // @include *://gleam.io/*
  25. // @include *://sweepwidget.com/view/*
  26. // @include *://discord.com/*
  27. // @include *://www.twitch.tv/*
  28. // @include *://www.youtube.com/*
  29. // @include *://*.reddit.com/*
  30. // @include *://twitter.com/settings/account?k*
  31. // @include https://auto-task-v4.hclonely.com/setting.html
  32. // @include https://auto-task-v4.hclonely.com/history.html
  33.  
  34. // @grant GM_setValue
  35. // @grant GM_getValue
  36. // @grant GM_listValues
  37. // @grant GM_deleteValue
  38. // @grant GM_addStyle
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_info
  42. // @grant GM_openInTab
  43. // @grant GM_setClipboard
  44. // @grant GM_getResourceText
  45. // @grant unsafeWindow
  46. // @grant window.close
  47. // @grant window.localStorage
  48.  
  49. // @connect cdn.jsdelivr.net
  50. // @connect store.steampowered.com
  51. // @connect steamcommunity.com
  52. // @connect twitter.com
  53. // @connect api.twitter.com
  54. // @connect youtube.com
  55. // @connect www.youtube.com
  56. // @connect facebook.com
  57. // @connect instagram.com
  58. // @connect vk.com
  59. // @connect twitch.tv
  60. // @connect www.twitch.tv
  61. // @connect gql.twitch.tv
  62. // @connect github.com
  63. // @connect discordapp.com
  64. // @connect discord.gg
  65. // @connect discord.com
  66. // @connect www.reddit.com
  67. // @connect oauth.reddit.com
  68. // @connect raw.githubusercontent.com
  69. // @connect t.me
  70. // @connect bit.ly
  71. // @connect giveaway.su
  72. // @connect google.com
  73. // @connect www.vloot.io
  74. // @connect givee.club
  75. // @connect gleam.io
  76. // @connect www.indiedb.com
  77. // @connect key-hub.eu
  78. // @connect opquests.com
  79. // @connect itch.io
  80. // @connect auto-task-v4.hclonely.com
  81. // @connect *
  82. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  83. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  84. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  85. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  86. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  87. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  88. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  89. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  90.  
  91. // @noframes
  92. // ==/UserScript==
  93.  
  94. console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
  95.  
  96. (function() {
  97. var __webpack_modules__ = {
  98. 514: function(__unused_webpack_module, exports) {
  99. !function(e, n) {
  100. true ? n(exports) : 0;
  101. }(this, function(e) {
  102. 'use strict';
  103. var t = function() {
  104. return (t = Object.assign || function(e) {
  105. for (var n, o = 1, t = arguments.length; o < t; o++) {
  106. for (var r in n = arguments[o]) {
  107. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  108. }
  109. }
  110. return e;
  111. }).apply(this, arguments);
  112. };
  113. function r(e, n, o) {
  114. if (o || 2 === arguments.length) {
  115. for (var t, r = 0, i = n.length; r < i; r++) {
  116. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  117. }
  118. }
  119. return e.concat(t || Array.prototype.slice.call(n));
  120. }
  121. function d(e) {
  122. return '[object Object]' === n(e);
  123. }
  124. function l(e, n) {
  125. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  126. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  127. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  128. });
  129. }
  130. var n = function(e) {
  131. return Object.prototype.toString.call(e);
  132. };
  133. var o = (i.prototype.init = function() {
  134. try {
  135. this.getSystemName(), this.getBrowserName();
  136. } catch (e) {
  137. console.warn('[UA formatter error] '.concat(e));
  138. }
  139. }, i.prototype.getEngine = function() {
  140. var e = this.agent;
  141. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  142. }, i.prototype.getSystemName = function() {
  143. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  144. try {
  145. var o = '';
  146. if (/Windows/i.test(n)) {
  147. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  148. switch (this.info.os = 'Windows', t) {
  149. case '6.3':
  150. o = '8.1';
  151. break;
  152.  
  153. case '6.2':
  154. o = '8';
  155. break;
  156.  
  157. case '6.1':
  158. o = '7';
  159. break;
  160.  
  161. case '5.2':
  162. case '5.1':
  163. o = 'XP';
  164. break;
  165.  
  166. default:
  167. o = t;
  168. }
  169. return this.info.device = 'PC', void (this.info.osVersion = o);
  170. }
  171. if (/^Macintosh/i.test(n)) {
  172. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  173. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  174. }
  175. if (/^iPad/i.test(n)) {
  176. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  177. void (this.info.osVersion = o.replace(/_/g, '.'));
  178. }
  179. if (/^iPhone/i.test(n)) {
  180. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  181. void (this.info.osVersion = o.replace(/_/g, '.'));
  182. }
  183. if (-1 !== n.indexOf('Android')) {
  184. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  185. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  186. }
  187. if (/Linux\s[a-z\d_]+/.test(n)) {
  188. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  189. }
  190. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  191. } catch (e) {
  192. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  193. }
  194. }, i.prototype.getBrowserName = function() {
  195. var e = Object.keys(this.browserNameMap).map(function(e) {
  196. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  197. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  198. return -1 !== e.findIndex(function(e) {
  199. return e.test(n);
  200. });
  201. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  202. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  203. }, i.prototype._formatBrowserVersion = function(e) {
  204. var n, o, t, r;
  205. try {
  206. for (var i = null !== (o = null === (n = e.match(/(?<name>[a-z\d]+)(\/|\s)(?<version>(\d+\.)+\d+)/i)) || void 0 === n ? void 0 : n.groups) && void 0 !== o ? o : {}, s = i.name, a = i.version, c = {}, f = 0, u = Object.entries(this.browserNameMap); f < u.length; f++) {
  207. var d = u[f], l = d[0], h = d[1];
  208. if (new RegExp(l).test(s)) {
  209. c = h;
  210. break;
  211. }
  212. }
  213. var p = {
  214. browserVersion: null != a ? a : 'Unknown',
  215. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  216. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  217. };
  218. return 'Trident' === s && (p.browserVersion = {
  219. '4.0': 8,
  220. '5.0': 9,
  221. '6.0': 10,
  222. '7.0': 11
  223. }[a]), p;
  224. } catch (e) {
  225. return console.warn('[UA formatter error] '.concat(e)), {
  226. browser: 'Unknown',
  227. browserVersion: 'Unknown'
  228. };
  229. }
  230. }, i);
  231. function i(e) {
  232. this.agent = '', this.info = {
  233. browser: '',
  234. browserZH: '',
  235. browserVersion: '',
  236. os: '',
  237. osVersion: '',
  238. device: 'Unknown',
  239. engine: 'WebKit'
  240. }, this.browserNameMap = {
  241. MicroMessenger: {
  242. en: 'MicroMessenger',
  243. zh: '微信'
  244. },
  245. MetaSr: {
  246. en: 'MetaSr',
  247. zh: '搜狗浏览器'
  248. },
  249. 'QQ(Browser)?': {
  250. en: 'QQBrowser',
  251. zh: 'QQ浏览器'
  252. },
  253. UCBrowser: {
  254. en: 'UCBrowser',
  255. zh: 'UC浏览器'
  256. },
  257. '2345Explorer': {
  258. en: '2345Explorer',
  259. zh: '2345极速浏览器'
  260. },
  261. Mb2345Browser: {
  262. en: 'Mb2345Browser',
  263. zh: '2345手机浏览器'
  264. },
  265. Trident: {
  266. en: 'Internet Explorer'
  267. },
  268. 'Edge?': {
  269. en: 'Edge'
  270. },
  271. OPR: {
  272. en: 'Opera'
  273. },
  274. Vivaldi: {
  275. en: 'Vivaldi'
  276. },
  277. Firefox: {
  278. en: 'Firefox'
  279. },
  280. Chrome: {
  281. en: 'Chrome'
  282. },
  283. Safari: {
  284. en: 'Safari'
  285. }
  286. }, this.agent = e, this.init();
  287. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  288. this.info = t(t({}, this.info), {
  289. engine: this.getEngine(),
  290. browserVersion: 'Safari' === o ? n : e
  291. });
  292. }
  293. function s() {
  294. this.cookies = {}, this.init();
  295. }
  296. var a = new (s.prototype.init = function() {
  297. var o = {};
  298. document.cookie.split(/;\s/).forEach(function(e) {
  299. var n = e.split(/=/), e = n[0], n = n[1];
  300. o[e] = n;
  301. }), this.cookies = o;
  302. }, s.prototype.getItem = function(e) {
  303. return this.cookies[e];
  304. }, s.prototype.getAllItems = function() {
  305. return this.cookies;
  306. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  307. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  308. }, s)();
  309. e.countDown = function e(n, o, t, r) {
  310. if (!window) {
  311. throw new Error('window is not defind.');
  312. }
  313. if (0 < n) {
  314. return r && r(), n--, window[o] = window.setTimeout(function() {
  315. e(n, o, t, r);
  316. }, 1e3), function() {
  317. return clearTimeout(window[o]);
  318. };
  319. }
  320. clearTimeout(window[o]), t && t();
  321. }, e.createRandomID = function(e) {
  322. void 0 === e && (e = 12);
  323. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  324. n.push(o[Math.round(Math.random() * t)]);
  325. }
  326. return n.join('');
  327. }, e.dCookie = a, e.debounce = function(o, t, r) {
  328. var i;
  329. void 0 === t && (t = 0);
  330. var s = r = void 0 === r ? !1 : r;
  331. return function() {
  332. var e = this, n = arguments;
  333. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  334. r ? s = !0 : o.apply(e, n);
  335. }, t);
  336. };
  337. }, e.deepCopy = function e(n) {
  338. if (d(n) || Array.isArray(n)) {
  339. var o, t = Array.isArray(n) ? [] : {};
  340. for (o in n) {
  341. t[o] = e(n[o]);
  342. }
  343. return t;
  344. }
  345. return n;
  346. }, e.formatQueryParams = function(e) {
  347. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  348. if (!e) {
  349. return {};
  350. }
  351. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  352. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  353. return t[n] = o, e;
  354. });
  355. }
  356. return t;
  357. }, e.formatThousandth = function(e) {
  358. var n = ''.concat(e).split('.'), e = n[0], n = n[1], n = void 0 === n ? '' : n, e = e.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
  359. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  360. }, e.generateTree = function e(n, o, t, r) {
  361. for (var i = [], s = 0; s < n.length; s++) {
  362. var a = n[s];
  363. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  364. }
  365. return i;
  366. }, e.isEmpty = function(e) {
  367. return Array.isArray(e) ? 0 === e.length : d(e) ? 0 === Object.keys(e).length : [ '[object Set]', '[object Map]' ].includes(n(e)) ? 0 === e.size : [ null, void 0, '' ].includes(e);
  368. }, e.isFunction = function(e) {
  369. return '[object Function]' === n(e);
  370. }, e.isImageUrl = function(e) {
  371. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  372. }, e.isObject = d, e.isRegexp = function(e) {
  373. return '[object RegExp]' === n(e);
  374. }, e.objectKeyToCamelCase = function e(n, o, t) {
  375. if (Array.isArray(n)) {
  376. for (var r = [], i = 0; i < n.length; i++) {
  377. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  378. }
  379. } else if (d(n)) {
  380. r = {};
  381. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  382. var f = (u = c[a])[0], u = u[1];
  383. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  384. }
  385. } else {
  386. r = n;
  387. }
  388. return r;
  389. }, e.realType = n, e.searchParams = function(e, n) {
  390. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  391. new URLSearchParams(e).get(n);
  392. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  393. return e.replace(/([A-Z])/g, function(e) {
  394. return '_'.concat(e.toLocaleLowerCase());
  395. });
  396. }, e.ua = function(e) {
  397. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  398. }, Object.defineProperty(e, '__esModule', {
  399. value: !0
  400. });
  401. });
  402. },
  403. 786: function(module, __webpack_exports__, __webpack_require__) {
  404. 'use strict';
  405. __webpack_require__.d(__webpack_exports__, {
  406. Z: function() {
  407. return __WEBPACK_DEFAULT_EXPORT__;
  408. }
  409. });
  410. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  411. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  412. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  413. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  414. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default());
  415. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(10px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px rgba(5,190,5,0.4)}body.auto-task-options .auto-task-form table label input:checked~span i{left:84px}body.auto-task-options .auto-task-form table label input:checked~span i::before{background:#05be05;box-shadow:35px 0 0 #05be05}body.auto-task-options .auto-task-form table label input:checked~span i::after{bottom:12px;height:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;background:#05be05}body.auto-task-options .auto-task-form table label span{position:absolute;top:0;left:0;width:100%;height:100%;background:#fe0000;border-radius:80px;transition:.5s;box-shadow:0 15px 25px rgba(254,0,0,0.4)}body.auto-task-options .auto-task-form table label span i{position:absolute;top:4px;left:4px;width:72px;height:72px;background:#fff;border-radius:50%}body.auto-task-options .auto-task-form table label span i::before{content:"";position:absolute;top:22px;left:12px;width:12px;height:12px;border-radius:50%;background:#fe0000;box-shadow:35px 0 0 #fe0000;transition:.5s}body.auto-task-options .auto-task-form table label span i::after{content:"";position:absolute;bottom:15px;left:calc(50% - 15px);width:30px;height:6px;border-radius:6px;background:#fe0000;transition:.5s}body.auto-task-history{font-size:15px;font-weight:400;line-height:1.5}body.auto-task-history .container a{color:#007bff;text-decoration:none;background-color:transparent}body.auto-task-history .container .card{width:80%;max-width:800px;border-radius:10px;background:rgba(118,118,118,0.10196);border-top:1px solid rgba(255,255,255,0.50196);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px rgba(0,0,0,0.10196);margin:20px auto;position:relative;display:flex;flex-direction:column;word-wrap:break-word;-webkit-background-clip:border-box;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}body.auto-task-history .container .card .title{text-align:center;font-size:30px;font-weight:bold;margin:5px 0}body.auto-task-history .container .card .title a:hover{text-decoration:none;background:#93e1ff;border-radius:10px;padding:3px}body.auto-task-history .container .card ul{margin-bottom:25px}body.auto-task-history .container .card ul li{margin-bottom:5px;line-height:20px}body.auto-task-history .container .card ul a:hover{text-decoration:underline}body.auto-task-history .container .card .delete-task{right:10px;width:38px;height:35px;position:absolute;font-size:24px;cursor:pointer;border-radius:10px}body.auto-task-history .container .card .delete-task:hover{background:#fff}body.auto-task-history .container .card .time{right:5px;position:absolute;bottom:0;color:#e83e8c;font-family:\'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace\';font-size:15px}#auto-task-buttons,.show-button-div{position:fixed;top:30px;right:15px;width:170px;z-index:999999999 !important;transform:scale(0.9)}#auto-task-buttons p,.show-button-div p{line-height:30px;height:40px;text-align:center;margin:5px !important}#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn{width:150px;height:40px;line-height:30px;font-size:20px}.show-button-div{width:20px}.auto-task-capitalize{text-transform:capitalize !important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{box-shadow:inset 0px 0px 4px 1px rgba(100,150,200,.5) !important}.swal2-checkbox-custom{align-items:center;justify-content:center;background:#fff;color:inherit;margin:1em auto}.swal2-checkbox-custom input{flex-shrink:0;margin:0 .4em}.giveaway-actions #getKey{display:none !important}.auto-task-giveaway-status{color:#fff;border-radius:10px;padding:0 5px;margin-left:5px}.auto-task-giveaway-status.active{background-color:#5cb85c}.auto-task-giveaway-status.not-active{background-color:#d9534f}.left-keys.lk-green,.left-keys.lk-yellow,.left-keys.lk-red,.left-keys.lk-black{display:none !important}', '' ]);
  416. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  417. },
  418. 400: function(module) {
  419. 'use strict';
  420. module.exports = function(cssWithMappingToString) {
  421. var list = [];
  422. list.toString = function toString() {
  423. return this.map(function(item) {
  424. var content = '';
  425. var needLayer = typeof item[5] !== 'undefined';
  426. if (item[4]) {
  427. content += '@supports ('.concat(item[4], ') {');
  428. }
  429. if (item[2]) {
  430. content += '@media '.concat(item[2], ' {');
  431. }
  432. if (needLayer) {
  433. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  434. }
  435. content += cssWithMappingToString(item);
  436. if (needLayer) {
  437. content += '}';
  438. }
  439. if (item[2]) {
  440. content += '}';
  441. }
  442. if (item[4]) {
  443. content += '}';
  444. }
  445. return content;
  446. }).join('');
  447. };
  448. list.i = function i(modules, media, dedupe, supports, layer) {
  449. if (typeof modules === 'string') {
  450. modules = [ [ null, modules, undefined ] ];
  451. }
  452. var alreadyImportedModules = {};
  453. if (dedupe) {
  454. for (var k = 0; k < this.length; k++) {
  455. var id = this[k][0];
  456. if (id != null) {
  457. alreadyImportedModules[id] = true;
  458. }
  459. }
  460. }
  461. for (var _k = 0; _k < modules.length; _k++) {
  462. var item = [].concat(modules[_k]);
  463. if (dedupe && alreadyImportedModules[item[0]]) {
  464. continue;
  465. }
  466. if (typeof layer !== 'undefined') {
  467. if (typeof item[5] === 'undefined') {
  468. item[5] = layer;
  469. } else {
  470. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  471. item[5] = layer;
  472. }
  473. }
  474. if (media) {
  475. if (!item[2]) {
  476. item[2] = media;
  477. } else {
  478. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  479. item[2] = media;
  480. }
  481. }
  482. if (supports) {
  483. if (!item[4]) {
  484. item[4] = ''.concat(supports);
  485. } else {
  486. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  487. item[4] = supports;
  488. }
  489. }
  490. list.push(item);
  491. }
  492. };
  493. return list;
  494. };
  495. },
  496. 220: function(module) {
  497. 'use strict';
  498. module.exports = function(i) {
  499. return i[1];
  500. };
  501. }
  502. };
  503. var __webpack_module_cache__ = {};
  504. function __webpack_require__(moduleId) {
  505. var cachedModule = __webpack_module_cache__[moduleId];
  506. if (cachedModule !== undefined) {
  507. return cachedModule.exports;
  508. }
  509. var module = __webpack_module_cache__[moduleId] = {
  510. id: moduleId,
  511. exports: {}
  512. };
  513. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  514. return module.exports;
  515. }
  516. !function() {
  517. __webpack_require__.n = function(module) {
  518. var getter = module && module.__esModule ? function() {
  519. return module['default'];
  520. } : function() {
  521. return module;
  522. };
  523. __webpack_require__.d(getter, {
  524. a: getter
  525. });
  526. return getter;
  527. };
  528. }();
  529. !function() {
  530. __webpack_require__.d = function(exports, definition) {
  531. for (var key in definition) {
  532. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  533. Object.defineProperty(exports, key, {
  534. enumerable: true,
  535. get: definition[key]
  536. });
  537. }
  538. }
  539. };
  540. }();
  541. !function() {
  542. __webpack_require__.o = function(obj, prop) {
  543. return Object.prototype.hasOwnProperty.call(obj, prop);
  544. };
  545. }();
  546. var __webpack_exports__ = {};
  547. !function() {
  548. 'use strict';
  549. const external_Swal_namespaceObject = Swal;
  550. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  551. const external_Cookies_namespaceObject = Cookies;
  552. var auto_task = __webpack_require__(786);
  553. var javascript_utils_umd_min = __webpack_require__(514);
  554. const httpRequest = async function(options) {
  555. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  556. if (window.TRACE) {
  557. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  558. }
  559. try {
  560. const result = await new Promise(resolve => {
  561. if (options.dataType) {
  562. options.responseType = options.dataType;
  563. }
  564. const requestObj = {
  565. ...{
  566. timeout: 3e4,
  567. ontimeout(data) {
  568. resolve({
  569. result: 'Error',
  570. statusText: 'Timeout',
  571. status: 601,
  572. data: data,
  573. options: options
  574. });
  575. },
  576. onabort(data) {
  577. resolve({
  578. result: 'Error',
  579. statusText: 'Aborted',
  580. status: 602,
  581. data: data,
  582. options: options
  583. });
  584. },
  585. onerror(data) {
  586. resolve({
  587. result: 'Error',
  588. statusText: 'Error',
  589. status: 603,
  590. data: data,
  591. options: options
  592. });
  593. },
  594. onload(data) {
  595. resolve({
  596. result: 'Success',
  597. statusText: 'Load',
  598. status: 600,
  599. data: data,
  600. options: options
  601. });
  602. }
  603. },
  604. ...options
  605. };
  606. GM_xmlhttpRequest(requestObj);
  607. });
  608. if (window.DEBUG) {
  609. console.log('%cAuto-Task[httpRequest]:', 'color:blue', JSON.stringify(result));
  610. }
  611. if (result.status !== 600 && times < 2) {
  612. return await httpRequest(options, times + 1);
  613. }
  614. return result;
  615. } catch (error) {
  616. console.log('%cAuto-Task[httpRequest]:', 'color:red', JSON.stringify({
  617. errorMsg: error,
  618. options: options
  619. }));
  620. throwError(error, 'httpRequest');
  621. return {
  622. result: 'JsError',
  623. statusText: 'Error',
  624. status: 604,
  625. error: error,
  626. options: options
  627. };
  628. }
  629. };
  630. const tools_httpRequest = httpRequest;
  631. const echoLog = _ref => {
  632. let {
  633. type,
  634. text,
  635. html,
  636. id
  637. } = _ref;
  638. const emptyStatus = {
  639. success: () => emptyStatus,
  640. error: () => emptyStatus,
  641. warning: () => emptyStatus,
  642. info: () => emptyStatus,
  643. view: () => emptyStatus
  644. };
  645. try {
  646. var _ele$;
  647. let ele;
  648. if (type) {
  649. switch (type) {
  650. case 'joiningSteamGroup':
  651. case 'leavingSteamGroup':
  652. case 'gettingSteamGroupId':
  653. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  654. break;
  655.  
  656. case 'joiningSteamOfficialGroup':
  657. case 'leavingSteamOfficialGroup':
  658. case 'gettingSteamOfficialGroupId':
  659. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/games/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  660. break;
  661.  
  662. case 'subscribingForum':
  663. case 'unsubscribingForum':
  664. case 'gettingForumId':
  665. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>]...<font></font></li>`);
  666. break;
  667.  
  668. case 'followingCurator':
  669. case 'unfollowingCurator':
  670. case 'getCuratorId':
  671. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/${text !== null && text !== void 0 && text.includes('/') ? text : `curator/${text}`}" target="_blank">${text}</a>]...<font></font></li>`);
  672. break;
  673.  
  674. case 'addingToWishlist':
  675. case 'removingFromWishlist':
  676. case 'followingGame':
  677. case 'unfollowingGame':
  678. case 'gettingSubid':
  679. case 'addingFreeLicense':
  680. case 'requestingPlayTestAccess':
  681. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  682. break;
  683.  
  684. case 'addingFreeLicenseSubid':
  685. ele = $(`<li>${i18n('addingFreeLicense')}[<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  686. break;
  687.  
  688. case 'favoritingWorkshop':
  689. case 'unfavoritingWorkshop':
  690. case 'gettingWorkshopAppId':
  691. case 'votingUpWorkshop':
  692. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  693. ${text}</a>]...<font></font></li>`);
  694. break;
  695.  
  696. case 'gettingAnnouncementParams':
  697. case 'likingAnnouncement':
  698. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  699. ${id}</a>]...<font></font></li>`);
  700. break;
  701.  
  702. case 'joiningDiscordServer':
  703. case 'gettingDiscordGuild':
  704. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  705. break;
  706.  
  707. case 'leavingDiscordServer':
  708. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  709. break;
  710.  
  711. case 'updateDiscordAuth':
  712. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  713. break;
  714.  
  715. case 'followingTwitchChannel':
  716. case 'unfollowingTwitchChannel':
  717. case 'gettingTwitchChannelId':
  718. ele = $(`<li>${i18n(type)}[<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  719. break;
  720.  
  721. case 'gettingInsUserId':
  722. case 'followingIns':
  723. case 'unfollowingIns':
  724. ele = $(`<li>${i18n(type)}[<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  725. break;
  726.  
  727. case 'gettingTwitterUserId':
  728. case 'followingTwitterUser':
  729. case 'unfollowingTwitterUser':
  730. ele = $(`<li>${i18n(type)}[<a href="https://twitter.com/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  731. break;
  732.  
  733. case 'retweetting':
  734. case 'unretweetting':
  735. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  736. break;
  737.  
  738. case 'joiningReddit':
  739. case 'leavingReddit':
  740. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  741. break;
  742.  
  743. case 'followingRedditUser':
  744. case 'unfollowingRedditUser':
  745. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  746. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>]...<font></font></li>`);
  747. break;
  748.  
  749. case 'followingYtbChannel':
  750. case 'unfollowingYtbChannel':
  751. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  752. break;
  753.  
  754. case 'likingYtbVideo':
  755. case 'unlikingYtbVideo':
  756. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>]...<font></font></li>`);
  757. break;
  758.  
  759. case 'gettingVkId':
  760. case 'joiningVkGroup':
  761. case 'leavingVkGroup':
  762. case 'joiningVkPublic':
  763. case 'leavingVkPublic':
  764. case 'sendingVkWall':
  765. case 'deletingVkWall':
  766. ele = $(`<li>${i18n(type)}[<a href="https://vk.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  767. break;
  768.  
  769. case 'visitingLink':
  770. ele = $(`<li>${i18n('visitingLink')}[<a href="${text}" target="_blank">${text}</a>]...<font></font></li>`);
  771. break;
  772.  
  773. case 'verifyingInsAuth':
  774. case 'text':
  775. ele = $(`<li>${i18n(text)}<font></font></li>`);
  776. break;
  777.  
  778. case 'html':
  779. ele = $(text || html);
  780. break;
  781.  
  782. case 'whiteList':
  783. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  784. break;
  785.  
  786. case 'globalOptionsSkip':
  787. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  788. break;
  789.  
  790. default:
  791. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  792. break;
  793. }
  794. } else if (text) {
  795. ele = $(`<li>${i18n(text)}<font></font></li>`);
  796. } else if (html) {
  797. ele = $(html);
  798. } else {
  799. ele = $('<li><font></font></li>');
  800. }
  801. ele.addClass('card-text');
  802. $('#auto-task-info').append(ele);
  803. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  804. const font = ele.find('font');
  805. const status = {
  806. font: font,
  807. success() {
  808. var _this$font, _this$font2, _this$font3;
  809. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  810. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  811. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  812. html ? (_this$font2 = this.font) === null || _this$font2 === void 0 ? void 0 : _this$font2.html(text) : (_this$font3 = this.font) === null || _this$font3 === void 0 ? void 0 : _this$font3.text(text);
  813. return this;
  814. },
  815. error() {
  816. var _this$font4, _this$font5, _this$font6;
  817. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  818. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  819. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  820. html ? (_this$font5 = this.font) === null || _this$font5 === void 0 ? void 0 : _this$font5.html(text) : (_this$font6 = this.font) === null || _this$font6 === void 0 ? void 0 : _this$font6.text(text);
  821. return this;
  822. },
  823. warning() {
  824. var _this$font7, _this$font8, _this$font9;
  825. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  826. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  827. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  828. html ? (_this$font8 = this.font) === null || _this$font8 === void 0 ? void 0 : _this$font8.html(text) : (_this$font9 = this.font) === null || _this$font9 === void 0 ? void 0 : _this$font9.text(text);
  829. return this;
  830. },
  831. info() {
  832. var _this$font10, _this$font11, _this$font12;
  833. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  834. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  835. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  836. html ? (_this$font11 = this.font) === null || _this$font11 === void 0 ? void 0 : _this$font11.html(text) : (_this$font12 = this.font) === null || _this$font12 === void 0 ? void 0 : _this$font12.text(text);
  837. return this;
  838. },
  839. view() {
  840. var _this$font13;
  841. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  842. return this;
  843. }
  844. };
  845. return status;
  846. } catch (error) {
  847. throwError(error, 'echoLog');
  848. return emptyStatus;
  849. }
  850. };
  851. const scripts_echoLog = echoLog;
  852. const unique = array => {
  853. try {
  854. return [ ...new Set(array) ];
  855. } catch (error) {
  856. throwError(error, 'unique');
  857. return [];
  858. }
  859. };
  860. const delay = function() {
  861. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  862. return new Promise(resolve => {
  863. setTimeout(() => {
  864. resolve(true);
  865. }, time);
  866. });
  867. };
  868. const getRedirectLink = async link => {
  869. try {
  870. if (!link) {
  871. return null;
  872. }
  873. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  874. if (redirectLinksCache[link]) {
  875. redirectLinksCache[link];
  876. }
  877. return await tools_httpRequest({
  878. url: link,
  879. method: 'GET'
  880. }).then(_ref => {
  881. let {
  882. data
  883. } = _ref;
  884. if (data !== null && data !== void 0 && data.finalUrl) {
  885. redirectLinksCache[link] = data.finalUrl;
  886. GM_setValue('redirectLinks', redirectLinksCache);
  887. return data.finalUrl;
  888. }
  889. return null;
  890. });
  891. } catch (error) {
  892. throwError(error, 'getRedirectLink');
  893. return null;
  894. }
  895. };
  896. const visitLink = async (link, options) => {
  897. try {
  898. const logStatus = scripts_echoLog({
  899. type: 'visitLink',
  900. text: link
  901. });
  902. return await tools_httpRequest({
  903. url: link,
  904. method: 'GET',
  905. ...options
  906. }).then(_ref2 => {
  907. let {
  908. result,
  909. statusText,
  910. status
  911. } = _ref2;
  912. if (result === 'Success') {
  913. logStatus.success();
  914. return true;
  915. }
  916. logStatus.error(`${result}:${statusText}(${status})`);
  917. return false;
  918. });
  919. } catch (error) {
  920. throwError(error, 'visitLink');
  921. return false;
  922. }
  923. };
  924. const getUrlQuery = url => {
  925. try {
  926. const query = {};
  927. if (url) {
  928. if (url.includes('?')) {
  929. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  930. query[key] = value;
  931. return str;
  932. });
  933. }
  934. } else {
  935. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  936. query[key] = value;
  937. return str;
  938. });
  939. }
  940. return query;
  941. } catch (error) {
  942. throwError(error, 'getUrlQuery');
  943. return {};
  944. }
  945. };
  946. const getUuid = () => {
  947. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  948. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  949. };
  950. const stringToColour = str => {
  951. try {
  952. let hash = 0;
  953. for (let i = 0; i < str.length; i++) {
  954. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  955. }
  956. let colour = '#';
  957. for (let i = 0; i < 3; i++) {
  958. const value = hash >> i * 8 & 255;
  959. colour += `00${value.toString(16)}`.slice(-2);
  960. }
  961. return colour;
  962. } catch (error) {
  963. throwError(error, 'stringToColour');
  964. return '#fff';
  965. }
  966. };
  967. const defaultGlobalOptions = {
  968. doTask: {
  969. discord: {
  970. servers: true
  971. },
  972. instagram: {
  973. users: true
  974. },
  975. twitch: {
  976. channels: true
  977. },
  978. twitter: {
  979. users: true,
  980. retweets: true
  981. },
  982. vk: {
  983. names: true
  984. },
  985. youtube: {
  986. channels: true,
  987. likes: true
  988. },
  989. reddit: {
  990. reddits: true
  991. },
  992. steam: {
  993. groups: true,
  994. officialGroups: true,
  995. wishlists: true,
  996. follows: true,
  997. forums: true,
  998. workshops: true,
  999. curators: true,
  1000. workshopVotes: true,
  1001. announcements: true,
  1002. licenses: true,
  1003. playtests: true
  1004. }
  1005. },
  1006. undoTask: {
  1007. discord: {
  1008. servers: true
  1009. },
  1010. instagram: {
  1011. users: true
  1012. },
  1013. twitch: {
  1014. channels: true
  1015. },
  1016. twitter: {
  1017. users: true,
  1018. retweets: true
  1019. },
  1020. vk: {
  1021. names: true
  1022. },
  1023. youtube: {
  1024. channels: true,
  1025. likes: true
  1026. },
  1027. reddit: {
  1028. reddits: true
  1029. },
  1030. steam: {
  1031. groups: true,
  1032. officialGroups: true,
  1033. wishlists: true,
  1034. follows: true,
  1035. forums: true,
  1036. workshops: true,
  1037. curators: true
  1038. }
  1039. },
  1040. position: {
  1041. buttonSideX: 'right',
  1042. buttonSideY: 'top',
  1043. buttonDistance: '15,30',
  1044. showButtonSideX: 'right',
  1045. showButtonSideY: 'top',
  1046. showButtonDistance: '15,30',
  1047. logSideX: 'right',
  1048. logSideY: 'bottom',
  1049. logDistance: '10,10'
  1050. },
  1051. hotKey: {
  1052. doTaskKey: 'alt + d',
  1053. undoTaskKey: 'alt + u',
  1054. toggleLogKey: 'alt + l'
  1055. },
  1056. other: {
  1057. twitterVerifyId: '783214',
  1058. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1059. autoUpdateSource: 'jsdelivr',
  1060. language: 'zh',
  1061. checkLogin: true,
  1062. checkLeftKey: true,
  1063. defaultShowButton: true,
  1064. defaultShowLog: true,
  1065. debug: false,
  1066. receivePreview: true
  1067. }
  1068. };
  1069. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1070. const assignObject = (obj1, obj2) => {
  1071. try {
  1072. const newObj = {};
  1073. for (const [ key, value ] of Object.entries(obj1)) {
  1074. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1075. newObj[key] = assignObject(value, obj2[key]);
  1076. } else {
  1077. newObj[key] = obj2[key] ?? value;
  1078. }
  1079. }
  1080. return newObj;
  1081. } catch (error) {
  1082. throwError(error, 'assignObject');
  1083. return defaultGlobalOptions;
  1084. }
  1085. };
  1086. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1087. const saveData = () => {
  1088. try {
  1089. const data = {};
  1090. $('#globalOptionsForm').serializeArray().map(value => {
  1091. data[value.name] = value.value;
  1092. return value;
  1093. });
  1094. $.makeArray($('#globalOptionsForm input')).map(element => {
  1095. const name = $(element).attr('name');
  1096. const keys = name.split('.');
  1097. if (keys.length === 3) {
  1098. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1099. } else if (keys.length === 2) {
  1100. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1101. }
  1102. return element;
  1103. });
  1104. GM_setValue('globalOptions', globalOptions);
  1105. external_Swal_default().fire({
  1106. title: i18n('changeGlobalOptionsSuccess'),
  1107. icon: 'success'
  1108. });
  1109. } catch (error) {
  1110. throwError(error, 'saveData');
  1111. }
  1112. };
  1113. const changeGlobalOptions = showType => {
  1114. try {
  1115. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1116. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1117. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1118. for (const [ option, data2 ] of Object.entries(data1)) {
  1119. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1120. if (typeof data2 === 'boolean') {
  1121. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><label><input type="checkbox" name="${type}.${option}"${data2 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1122. } else {
  1123. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><input class="editOption" type="text" name="${type}.${option}" value="${data2}"/></td></tr>`;
  1124. }
  1125. } else {
  1126. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1127. globalOptionsForm += `<tr style="background-color: ${stringToColour(option)}66">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).map(key => Object.keys(data1[key]).length).reduce((acr, cur) => acr + cur)}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${option}.${i18n(socialType)}</td><td><label><input type="checkbox" name="${type}.${option}.${socialType}"${data3 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1128. }
  1129. }
  1130. }
  1131. }
  1132. globalOptionsForm += '</tbody></table></form>';
  1133. if (showType === 'swal') {
  1134. external_Swal_default().fire({
  1135. title: i18n('globalOptions'),
  1136. html: globalOptionsForm,
  1137. showConfirmButton: true,
  1138. confirmButtonText: i18n('save'),
  1139. showCancelButton: true,
  1140. cancelButtonText: i18n('close')
  1141. }).then(_ref => {
  1142. let {
  1143. isConfirmed
  1144. } = _ref;
  1145. if (isConfirmed) {
  1146. saveData();
  1147. }
  1148. });
  1149. } else {
  1150. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1151. }
  1152. } catch (error) {
  1153. throwError(error, 'changeGlobalOptions');
  1154. }
  1155. };
  1156. const data = {
  1157. website: '网站',
  1158. type: '类型',
  1159. edit: '编辑',
  1160. whiteList: '白名单',
  1161. skipTask: '跳过撤销任务',
  1162. whiteListOptions: '白名单设置',
  1163. changeWhiteListOption: '设置白名单(%0)',
  1164. whiteListNotFound: '找不到此项白名单: %0',
  1165. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1166. changeWebsiteOptions: '网站设置',
  1167. changeGlobalOptions: '全局设置',
  1168. ok: '是',
  1169. save: '保存',
  1170. close: '关闭',
  1171. return: '返回',
  1172. option: '选项',
  1173. value: '值',
  1174. websiteOptions: '当前网站设置',
  1175. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1176. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1177. needLogin: '请先登录!',
  1178. getTasksInfo: '正在获取并处理任务信息...',
  1179. gettingKey: '正在获取Key...',
  1180. verifyingTask: '正在验证任务',
  1181. notice: '自动任务脚本提醒',
  1182. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1183. giveawayEnded: '此活动已结束,是否关闭?',
  1184. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1185. confirm: '确定',
  1186. cancel: '取消',
  1187. unKnown: '未知',
  1188. unKnownTaskType: '未识别的任务',
  1189. doing: '正在做任务',
  1190. allTasksComplete: '所有任务已完成!',
  1191. getTaskIdFailed: '获取任务Id失败!',
  1192. initSuccess: '%0 初始化成功!',
  1193. initFailed: '%0 初始化失败!',
  1194. errorLink: '链接错误: %0',
  1195. needInit: '请先初始化',
  1196. verifyingAuth: '正在验证%0凭证...',
  1197. updatingAuth: '正在更新%0凭证...',
  1198. initing: '正在初始化...',
  1199. getFailed: '获取%0失败!',
  1200. checkLoginFailed: '检测登录状态失败!',
  1201. checkLeftKeyFailed: '检测剩余Key失败!',
  1202. userId: '用户Id',
  1203. joiningGiveaway: '正在加入赠Key',
  1204. needJoinGiveaway: '需要先加入赠Key',
  1205. cannotUndo: '此网站不支持取消任务',
  1206. verifyAuth: '正在验证 %0 凭证...',
  1207. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1208. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1209. visitingLink: '正在访问链接: ',
  1210. doTask: '做任务',
  1211. undoTask: '撤销任务',
  1212. verifyTask: '验证任务',
  1213. getKey: '获取Key',
  1214. selectAll: '全选',
  1215. selectNone: '全不选',
  1216. invertSelect: '反选',
  1217. doFreeTask: '加入免费赠品',
  1218. doPointTask: '加入点数赠品',
  1219. skipTaskOption: '设置中已配置跳过任务',
  1220. other: '其他',
  1221. globalOptions: '全局设置',
  1222. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1223. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1224. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1225. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1226. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1227. saveGlobalOptions: '保存全局设置',
  1228. settingPage: '设置页面',
  1229. name: '名称',
  1230. version: '版本',
  1231. scriptManager: '脚本管理器',
  1232. script: '脚本',
  1233. environment: '环境',
  1234. os: '系统',
  1235. browser: '浏览器',
  1236. getId: '获取 %0 id',
  1237. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1238. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1239. showButton: '显示按钮',
  1240. hideButton: '隐藏按钮',
  1241. showLog: '显示日志',
  1242. hideLog: '隐藏日志',
  1243. defaultShowButton: '默认显示按钮',
  1244. defaultShowLog: '默认显示日志',
  1245. debug: '输出调试日志,不要开启此选项!',
  1246. receivePreview: '接收预览版更新',
  1247. position: '组件位置',
  1248. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1249. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1250. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1251. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1252. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1253. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1254. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1255. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1256. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1257. hotKey: '快捷键',
  1258. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1259. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1260. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1261. tasksHistory: '任务历史',
  1262. clearHistory: '清空历史',
  1263. clearHistoryFinished: '已清空任务历史!',
  1264. deleteTask: '删除任务',
  1265. lastChangeTime: '最后一次修改时间',
  1266. clearTaskFinished: '删除以下任务完成!',
  1267. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1268. syncData: '数据同步',
  1269. settingData: '正在上传数据...',
  1270. gettingData: '正在获取数据...',
  1271. help: '帮助',
  1272. fileName: '文件名',
  1273. upload2gist: '同步到Gist',
  1274. downloadFromGist: '从Gist同步',
  1275. saveAndTest: '保存配置并测试',
  1276. testSuccess: '测试成功!',
  1277. testFailed: '测试失败!',
  1278. saveAndTestNotice: '请先保存配置并测试!',
  1279. processingData: '正在处理数据...',
  1280. updatingData: '正在上传数据...',
  1281. syncDataSuccess: '同步数据成功!',
  1282. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1283. downloadingData: '正在下载数据...',
  1284. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1285. savingData: '正在保存数据...',
  1286. syncHistory: '同步任务历史',
  1287. checkUpdateFailed: '检测更新失败',
  1288. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1289. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1290. gistOptions: 'Gist 设置',
  1291. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1292. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1293. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1294. toGithub: '前往Github反馈',
  1295. toKeylol: '前往其乐论坛反馈',
  1296. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1297. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1298. updateText: '%0 版本更新内容:',
  1299. Active: '进行中',
  1300. Ended: '已结束',
  1301. Banned: '已封禁',
  1302. Paused: '已暂停',
  1303. notStart: '未开始',
  1304. noRemoteData: '检测到远程无数据',
  1305. errorRemoteDataFormat: '远程数据格式错误',
  1306. updateHistory: '历史更新记录<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">点此查看</a>',
  1307. groups: '组',
  1308. officialGroups: '官方组',
  1309. wishlists: '愿望单',
  1310. follows: '游戏关注',
  1311. forums: '论坛',
  1312. workshops: '创意工坊收藏',
  1313. curators: '鉴赏家',
  1314. workshopVotes: '创意工坊点赞',
  1315. announcements: '社区通知',
  1316. steamCommunity: 'Steam社区',
  1317. steamStore: 'Steam商店',
  1318. licenses: '入库免费游戏',
  1319. playtests: '请求访问权限',
  1320. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1321. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1322. joiningSteamGroup: '正在加入Steam组',
  1323. leavingSteamGroup: '正在退出Steam组',
  1324. gettingSteamGroupId: '正在获取Steam组Id',
  1325. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1326. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1327. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1328. subscribingForum: '正在订阅Steam论坛',
  1329. unsubscribingForum: '正在取消订阅Steam论坛',
  1330. gettingForumId: '正在获取Steam论坛Id',
  1331. followingCurator: '正在关注Steam鉴赏家',
  1332. unfollowingCurator: '正在取关Steam鉴赏家',
  1333. gettingCuratorId: '正在获取Steam鉴赏家Id',
  1334. addingToWishlist: '正在添加游戏到Steam愿望单',
  1335. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1336. followingGame: '正在关注Steam游戏',
  1337. unfollowingGame: '正在取关Steam游戏',
  1338. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1339. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1340. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1341. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1342. gettingAnnouncementParams: '正在获取Steam通知信息',
  1343. likingAnnouncement: '正在点赞Steam通知',
  1344. changingArea: '正在更换Steam地区: %0...',
  1345. notNeededChangeArea: '当前地区不需要更换',
  1346. noAnotherArea: '请检测是否开启正确开启代理',
  1347. gettingAreaInfo: '正在获取Steam地区信息...',
  1348. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1349. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1350. gettingSubid: '正在获取游戏subid',
  1351. addingFreeLicense: '正在入库',
  1352. missParams: '缺少参数',
  1353. gettingLicenses: '正在获取Licenses...',
  1354. requestingPlayTestAccess: '正在请求访问权限',
  1355. tryChangeAreaNotice: '此功能无法检测游戏是否限区,因此会尝试换区后再入库,换区失败也不影响后续入库',
  1356. servers: '服务器',
  1357. joiningDiscordServer: '正在加入Discord服务器',
  1358. leavingDiscordServer: '正在退出Discord服务器',
  1359. gettingDiscordGuild: '正在获取Discord服务器Id',
  1360. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1361. discordImportantNotice: '重要提醒!!!',
  1362. discordImportantNoticeText: '由于Discord网站后台更新,目前使用此脚本加组后可能会导致Discord帐号被强制退出,且需要两步验证才能正常登录,请谨慎使用!!!',
  1363. continue: '继续',
  1364. skipDiscordTask: '跳过Discord任务',
  1365. continueAndDontRemindAgain: '继续且不再提醒',
  1366. users: '用户',
  1367. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1368. insBanned: '您的Instagram账户已被封禁',
  1369. verifyingInsAuth: '正在验证Instagram凭证...',
  1370. gettingInsUserId: '正在获取Instagram用户Id',
  1371. followingIns: '正在关注Instagram用户',
  1372. unfollowingIns: '正在取关Instagram用户',
  1373. reddits: '社区/用户',
  1374. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1375. changingRedditVersion: '正在切换Reddit为新版页面...',
  1376. joiningReddit: '正在加入Reddit社区',
  1377. leavingReddit: '正在退出Reddit社区',
  1378. followingRedditUser: '正在关注Reddit用户',
  1379. unfollowingRedditUser: '正在取关Reddit用户',
  1380. channels: '频道',
  1381. followingTwitchChannel: '正在关注Twitch频道',
  1382. unfollowingTwitchChannel: '正在取关Twitch频道',
  1383. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1384. twitterUser: '推特用户',
  1385. retweets: '转推',
  1386. gettingTwitterUserId: '正在获取推特用户Id',
  1387. followingTwitterUser: '正在关注推特用户',
  1388. unfollowingTwitterUser: '正在取关推特用户',
  1389. retweetting: '正在转推',
  1390. unretweetting: '正在撤销转推',
  1391. names: '组/社区/动态',
  1392. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1393. gettingVkId: '正在获取Vk任务Id',
  1394. joiningVkGroup: '正在加入Vk组',
  1395. leavingVkGroup: '正在退出Vk组',
  1396. joiningVkPublic: '正在加入Vk社区',
  1397. leavingVkPublic: '正在退出Vk社区',
  1398. sendingVkWall: '正在转发Vk动态',
  1399. deletingVkWall: '正在撤销转发Vk动态',
  1400. youtubeChannel: 'YouTube频道',
  1401. likes: '点赞',
  1402. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1403. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1404. gettingYtbToken: '正在获取YouTube Token...',
  1405. followingYtbChannel: '正在订阅YouTube频道',
  1406. unfollowingYtbChannel: '正在退订YouTube频道',
  1407. likingYtbVideo: '正在点赞YouTube视频',
  1408. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1409. giveKeyNoticeBefore: '每次验证间隔15s',
  1410. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1411. noPoints: '点数不够,跳过抽奖',
  1412. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1413. joiningLottery: '正在加入抽奖',
  1414. doingGleamTask: '正在做Gleam任务...',
  1415. gettingGleamLink: '正在获取Gleam任务链接...',
  1416. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1417. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1418. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1419. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1420. };
  1421. const zh_CN = data;
  1422. const en_US_data = {
  1423. website: 'Website',
  1424. type: 'Type',
  1425. edit: 'Edit',
  1426. whiteList: 'Whitelist',
  1427. skipTask: 'Skip undo task',
  1428. whiteListOptions: 'Whitelist options',
  1429. changeWhiteListOption: 'Whitelist option(%0)',
  1430. whiteListNotFound: 'Cannot find this whitelist: %0',
  1431. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1432. changeWebsiteOptions: 'Website options',
  1433. changeGlobalOptions: 'Global options',
  1434. ok: 'OK',
  1435. save: 'Save',
  1436. close: 'Close',
  1437. return: 'Return',
  1438. option: 'Option',
  1439. value: 'Value',
  1440. websiteOptions: 'Current website settings',
  1441. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1442. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1443. needLogin: 'Please log in first!',
  1444. getTasksInfo: 'Obtaining and processing task information...',
  1445. gettingKey: 'Getting Key...',
  1446. verifyingTask: 'Verifying task',
  1447. notice: 'Automatic task script notice',
  1448. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1449. giveawayEnded: 'This event has ended, do you want to close it?',
  1450. giveawayNotWork: 'This activity is unavailable for some reasons (banned/ended/paused/not started...)' + ' (if it is a script misjudgment, please give us feedback in time), is it closed?',
  1451. confirm: 'Confirm',
  1452. cancel: 'Cancel',
  1453. unKnown: 'Unknown',
  1454. unKnownTaskType: 'Unrecognized task',
  1455. doing: 'Doing a task',
  1456. allTasksComplete: 'All tasks have been completed!',
  1457. getTaskIdFailed: 'Failed to obtain task Id!',
  1458. initSuccess: '%0 was initialized successfully!',
  1459. initFailed: '%0 initialization failed!',
  1460. errorLink: 'Link error: %0',
  1461. needInit: 'Please initialize first',
  1462. verifyingAuth: 'Verifying %0 token...',
  1463. updatingAuth: 'Update %0 token...',
  1464. initing: 'Initializing...',
  1465. getFailed: 'Failed to get %0!',
  1466. checkLoginFailed: 'Failed to detect login status!',
  1467. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1468. userId: 'User Id',
  1469. joiningGiveaway: 'Joining giveaway',
  1470. needJoinGiveaway: 'Need to join the giveaway first',
  1471. cannotUndo: 'This website does not support canceling tasks',
  1472. verifyAuth: 'Verifying %0 token...',
  1473. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1474. errorReport: 'A script error is detected, do you want to report the BUG?',
  1475. visitingLink: 'Visiting link: ',
  1476. doTask: 'DoTask',
  1477. undoTask: 'UndoTask',
  1478. verifyTask: 'Verify',
  1479. getKey: 'GetKey',
  1480. selectAll: 'SelectAll',
  1481. selectNone: 'SelectNone',
  1482. invertSelect: 'InvertSelect',
  1483. doFreeTask: 'FreeTask',
  1484. doPointTask: 'PointTask',
  1485. skipTaskOption: 'Skip task has been configured in the settings',
  1486. other: 'Other',
  1487. globalOptions: 'Global Options',
  1488. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1489. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1490. twitterVerifyId: 'Verify Twitter token by trying to follow the account.</br>The default is the official Twitter account 783214.</br>' + 'If you don\'t want to follow the official account, you can change it to your own account.',
  1491. youtubeVerifyChannel: 'Verify YouTube token by trying to subscribe to the channel.</br>' + 'The default is the official YouTube channel UCrXUsMBcfTVqwAS7DKg9C0Q.</br>' + 'If you don\'t want to follow the official channel, you can change it to your own channel.',
  1492. autoUpdateSource: 'The source to update</br>github: Fast update.</br>jsdelivr: Update is delayed.</br>' + 'standby: Standby source.</br>auto: Try to update using github, jsdelivr, standby sources in turn.',
  1493. saveGlobalOptions: 'SaveSettings',
  1494. settingPage: 'Setting Page',
  1495. name: 'Name',
  1496. version: 'Version',
  1497. scriptManager: 'Script Manager',
  1498. script: 'Script',
  1499. environment: 'Environment',
  1500. os: 'OS',
  1501. browser: 'Browser',
  1502. getId: 'Get %0 id',
  1503. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1504. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1505. showButton: 'ShowButton',
  1506. hideButton: 'HideButton',
  1507. showLog: 'ShowLog',
  1508. hideLog: 'HideLog',
  1509. defaultShowButton: 'Default display button',
  1510. defaultShowLog: 'Display log by default',
  1511. debug: 'Output debug log, do not enable this option!',
  1512. receivePreview: 'Receive preview updates',
  1513. position: 'Component position',
  1514. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1515. buttonSideY: 'The button area is positioned in the vertical direction (real-time preview function is only available on the settings page).' + '</br>top: top | bottom: bottom',
  1516. buttonDistance: 'The distance between the button area and the edge (the real-time preview function is only available on the setting page).' + '</br> Format: X distance, Y distance',
  1517. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1518. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1519. showButtonDistance: 'The distance between the ShowButton and the edge (real-time preview function is only available on the setting page).' + '</br> Format: X distance, Y distance',
  1520. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1521. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1522. logDistance: 'The distance between the log area and the edge (the real-time preview function is only available on the setting page).' + '</br> Format: X distance, Y distance',
  1523. hotKey: 'Shortcut key',
  1524. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1525. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1526. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1527. tasksHistory: 'TasksHistory',
  1528. clearHistory: 'Clear history',
  1529. clearHistoryFinished: 'The mission history has been cleared!',
  1530. deleteTask: 'Delete task',
  1531. lastChangeTime: 'Last Change Time',
  1532. clearTaskFinished: 'Delete the following tasks completed!',
  1533. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1534. syncData: 'DataSync',
  1535. settingData: 'Uploading data...',
  1536. gettingData: 'Getting data...',
  1537. help: 'Help',
  1538. fileName: 'Filename',
  1539. upload2gist: 'Sync to Gist',
  1540. downloadFromGist: 'Sync from Gist',
  1541. saveAndTest: 'Save configuration and test',
  1542. testSuccess: 'Test success!',
  1543. testFailed: 'Test failed!',
  1544. saveAndTestNotice: 'Please save the configuration and test first!',
  1545. processingData: 'Processing data...',
  1546. updatingData: 'Uploading data...',
  1547. syncDataSuccess: 'Synchronized data successfully!',
  1548. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1549. downloadingData: 'Downloading data...',
  1550. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1551. savingData: 'Saving data...',
  1552. syncHistory: 'Synchronize tasks history',
  1553. checkUpdateFailed: 'Check update failed',
  1554. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1555. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1556. gistOptions: 'Gist Settings',
  1557. swalNotice: 'It is detected that you are installing the V4 version script for the first time' + ', please go to read the READ ME FIRST content before use!',
  1558. echoNotice: 'It is detected that you are installing the V4 version script for the first time' + ', please <a class="high-light" href="%0" target="_blank">click here</a> to read the READ ME FIRST content before use!',
  1559. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1560. toGithub: 'Feedback(Github)',
  1561. toKeylol: 'Feedback(Keylol)',
  1562. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1563. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1564. updateText: 'Updates in version %0:',
  1565. Active: 'Active',
  1566. Ended: 'Ended',
  1567. Banned: 'Banned',
  1568. Paused: 'Paused',
  1569. notStart: 'notStart',
  1570. noRemoteData: 'No data remotely',
  1571. errorRemoteDataFormat: 'Remote data has wrong format',
  1572. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1573. groups: 'Group',
  1574. officialGroups: 'Official Group',
  1575. wishlists: 'Wishlist',
  1576. follows: 'Follow Game',
  1577. forums: 'Forum',
  1578. workshops: 'Favorite Workshop',
  1579. curators: 'Curator',
  1580. workshopVotes: 'Voteup Workshop',
  1581. announcements: 'Announcement',
  1582. steamCommunity: 'Steam Community',
  1583. steamStore: 'Steam Store',
  1584. licenses: 'Add License',
  1585. playtests: 'Playtest Access',
  1586. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1587. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1588. joiningSteamGroup: 'Joining Steam Group',
  1589. leavingSteamGroup: 'Leaving Steam Group',
  1590. gettingSteamGroupId: 'Getting Steam Group Id',
  1591. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1592. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1593. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1594. subscribingForum: 'Subscribing the Steam Forum',
  1595. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1596. gettingForumId: 'Getting Steam Forum Id',
  1597. followingCurator: 'Following Steam Curator',
  1598. unfollowingCurator: 'Unfollowing Steam Curator',
  1599. gettingCuratorId: 'Getting Steam Curator Id',
  1600. addingToWishlist: 'Adding the game to the Steam wishlist',
  1601. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1602. followingGame: 'Following Steam games',
  1603. unfollowingGame: 'Unfollowing Steam games',
  1604. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1605. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1606. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1607. votingUpWorkshop: 'Liking Steam workshop items',
  1608. gettingAnnouncementParams: 'Getting Steam announcement information',
  1609. likingAnnouncement: 'Liking Steam announcement',
  1610. changingArea: 'Changing Steam area: %0...',
  1611. notNeededChangeArea: 'The current area does not need to be changed',
  1612. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1613. gettingAreaInfo: 'Getting Steam area information...',
  1614. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1615. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1616. gettingSubid: 'Getting subid',
  1617. addingFreeLicense: 'Adding free license',
  1618. missParams: 'Missing parameters',
  1619. gettingLicenses: 'Getting licenses...',
  1620. requestingPlayTestAccess: 'Requesting play test access',
  1621. tryChangeAreaNotice: 'This function cannot detect whether the game is limited, so it will try to change the area before entering the library' + '. Failure to change the area will not affect the subsequent storage.',
  1622. servers: 'Server',
  1623. joiningDiscordServer: 'Joining Discord Server',
  1624. leavingDiscordServer: 'Leaving Discord Server',
  1625. gettingDiscordGuild: 'Getting Discord server Id',
  1626. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1627. discordImportantNotice: 'Important Reminder! ! !',
  1628. discordImportantNoticeText: 'Due to the background update of the Discord website, currently using this script to join a group may cause the Discord account to be forcibly logged out, and two-step verification is required to log in normally, please use it with caution! ! !',
  1629. continue: 'Continue',
  1630. skipDiscordTask: 'Skip',
  1631. continueAndDontRemindAgain: 'Continue without Reminders',
  1632. users: 'User',
  1633. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1634. insBanned: 'Your Instagram account has been banned',
  1635. verifyingInsAuth: 'Verifying Instagram token...',
  1636. gettingInsUserId: 'Getting Instagram user Id',
  1637. followingIns: 'Following Instagram user',
  1638. unfollowingIns: 'Unfollowing Instagram user',
  1639. reddits: 'Reddit/User',
  1640. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1641. changingRedditVersion: 'Switching Reddit to a new version page...',
  1642. joiningReddit: 'Joining the Reddit',
  1643. leavingReddit: 'Leaving the Reddit',
  1644. followingRedditUser: 'Following Reddit User',
  1645. unfollowingRedditUser: 'Unfollowing Reddit User',
  1646. channels: 'Channel',
  1647. followingTwitchChannel: 'Following Twitch Channel',
  1648. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1649. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1650. twitterUser: 'Twitter User',
  1651. retweets: 'Retweet',
  1652. gettingTwitterUserId: 'Getting Twitter User Id',
  1653. followingTwitterUser: 'Following Twitter User',
  1654. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1655. retweetting: 'Retweetting',
  1656. unretweetting: 'Unretweetting',
  1657. names: 'Group/Public/Wall',
  1658. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1659. gettingVkId: 'Getting Vk task Id',
  1660. joiningVkGroup: 'Joining Vk Group',
  1661. leavingVkGroup: 'Leaving Vk Group',
  1662. joiningVkPublic: 'Joining Vk Public',
  1663. leavingVkPublic: 'Leaving Vk Public',
  1664. sendingVkWall: 'Sending Vk Wall',
  1665. deletingVkWall: 'Deleting Vk Wall',
  1666. youtubeChannel: 'YouTube Channel',
  1667. likes: 'Like',
  1668. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1669. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1670. gettingYtbToken: 'Getting YouTube Token...',
  1671. followingYtbChannel: 'Subscribing to YouTube channel',
  1672. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1673. likingYtbVideo: 'Liking YouTube video',
  1674. unlikingYtbVideo: 'Unliking YouTube video',
  1675. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1676. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1677. noPoints: 'Not enough points, skip the lottery',
  1678. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1679. joiningLottery: 'Joining the lottery',
  1680. doingGleamTask: 'Doing Gleam Task...',
  1681. gettingGleamLink: 'Getting Gleam task link...',
  1682. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1683. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1684. gsNotice: 'In order to avoid getting the "0000-0000-0000" key, the "Grab Key" button has been hidden,' + ' please close the script when obtaining the key!',
  1685. SweepWidgetNotice: 'The task is being processed and verified. ' + 'There is an interval of 1~3s for each verification task to prevent the triggering of too fast verification warning...'
  1686. };
  1687. const en_US = en_US_data;
  1688. const languages = {
  1689. zh: zh_CN,
  1690. en: en_US
  1691. };
  1692. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1693. const I18n = function(key) {
  1694. var _languages$language;
  1695. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1696. argvs[_key - 1] = arguments[_key];
  1697. }
  1698. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1699. return key;
  1700. }
  1701. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1702. };
  1703. const i18n = I18n;
  1704. function throwError(error, name) {
  1705. if (window.TRACE) {
  1706. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1707. }
  1708. external_Swal_default().fire({
  1709. title: i18n('errorReport'),
  1710. icon: 'error',
  1711. showCancelButton: true,
  1712. confirmButtonText: i18n('toGithub'),
  1713. showDenyButton: true,
  1714. denyButtonText: i18n('toKeylol'),
  1715. cancelButtonText: i18n('close')
  1716. }).then(_ref => {
  1717. let {
  1718. isDenied,
  1719. isConfirmed
  1720. } = _ref;
  1721. if (isConfirmed) {
  1722. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`[BUG] 脚本报错: ${name}`)}&labels=bug&template=bug_report.yml&website=${encodeURIComponent(window.location.href)}&browser=${encodeURIComponent(JSON.stringify((0,
  1723. javascript_utils_umd_min.ua)(), null, 4))}&manager=${encodeURIComponent(`${GM_info.scriptHandler} ${GM_info.version}`)}&user-script=${encodeURIComponent(GM_info.script.version)}&logs=${encodeURIComponent(error.stack || 'null')}&run-logs=${encodeURIComponent($.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n'))}`, '_blank');
  1724. } else if (isDenied) {
  1725. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1726.  
  1727. 环境:
  1728.  
  1729. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1730.  
  1731. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1732. 脚本版本: ${GM_info.script.version}
  1733.  
  1734. 报错信息:
  1735. [code]${error.stack}[/code]
  1736.  
  1737. 执行日志:
  1738. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1739. GM_setClipboard(text);
  1740. external_Swal_default().fire({
  1741. title: i18n('copySuccess'),
  1742. icon: 'success',
  1743. confirmButtonText: i18n('ok')
  1744. }).then(() => {
  1745. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1746. });
  1747. }
  1748. });
  1749. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1750. }
  1751. function _defineProperty(obj, key, value) {
  1752. if (key in obj) {
  1753. Object.defineProperty(obj, key, {
  1754. value: value,
  1755. enumerable: true,
  1756. configurable: true,
  1757. writable: true
  1758. });
  1759. } else {
  1760. obj[key] = value;
  1761. }
  1762. return obj;
  1763. }
  1764. class Social {
  1765. constructor() {
  1766. _defineProperty(this, 'tasks', void 0);
  1767. }
  1768. getRealParams(name, links, doTask, link2param) {
  1769. try {
  1770. let realParams = [];
  1771. if (links.length > 0) {
  1772. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1773. }
  1774. if (!doTask && this.tasks[name].length > 0) {
  1775. realParams = [ ...realParams, ...this.tasks[name] ];
  1776. }
  1777. return unique(realParams);
  1778. } catch (error) {
  1779. throwError(error, 'Social.getRealParams');
  1780. return [];
  1781. }
  1782. }
  1783. }
  1784. const social_Social = Social;
  1785. function _classPrivateMethodInitSpec(obj, privateSet) {
  1786. _checkPrivateRedeclaration(obj, privateSet);
  1787. privateSet.add(obj);
  1788. }
  1789. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1790. _checkPrivateRedeclaration(obj, privateMap);
  1791. privateMap.set(obj, value);
  1792. }
  1793. function _checkPrivateRedeclaration(obj, privateCollection) {
  1794. if (privateCollection.has(obj)) {
  1795. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1796. }
  1797. }
  1798. function Discord_defineProperty(obj, key, value) {
  1799. if (key in obj) {
  1800. Object.defineProperty(obj, key, {
  1801. value: value,
  1802. enumerable: true,
  1803. configurable: true,
  1804. writable: true
  1805. });
  1806. } else {
  1807. obj[key] = value;
  1808. }
  1809. return obj;
  1810. }
  1811. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1812. if (!privateSet.has(receiver)) {
  1813. throw new TypeError('attempted to get private field on non-instance');
  1814. }
  1815. return fn;
  1816. }
  1817. function _classPrivateFieldGet(receiver, privateMap) {
  1818. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1819. return _classApplyDescriptorGet(receiver, descriptor);
  1820. }
  1821. function _classApplyDescriptorGet(receiver, descriptor) {
  1822. if (descriptor.get) {
  1823. return descriptor.get.call(receiver);
  1824. }
  1825. return descriptor.value;
  1826. }
  1827. function _classPrivateFieldSet(receiver, privateMap, value) {
  1828. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1829. _classApplyDescriptorSet(receiver, descriptor, value);
  1830. return value;
  1831. }
  1832. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1833. if (!privateMap.has(receiver)) {
  1834. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1835. }
  1836. return privateMap.get(receiver);
  1837. }
  1838. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1839. if (descriptor.set) {
  1840. descriptor.set.call(receiver, value);
  1841. } else {
  1842. if (!descriptor.writable) {
  1843. throw new TypeError('attempted to set read only private field');
  1844. }
  1845. descriptor.value = value;
  1846. }
  1847. }
  1848. const defaultTasksTemplate = {
  1849. servers: []
  1850. };
  1851. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1852. var _auth = new WeakMap();
  1853. var _cache = new WeakMap();
  1854. var _initialized = new WeakMap();
  1855. var _verifyAuth = new WeakSet();
  1856. var _updateAuth = new WeakSet();
  1857. var _joinServer = new WeakSet();
  1858. var _leaveServer = new WeakSet();
  1859. var _getGuild = new WeakSet();
  1860. var _setCache = new WeakSet();
  1861. class Discord extends social_Social {
  1862. constructor() {
  1863. var _GM_getValue;
  1864. super(...arguments);
  1865. _classPrivateMethodInitSpec(this, _setCache);
  1866. _classPrivateMethodInitSpec(this, _getGuild);
  1867. _classPrivateMethodInitSpec(this, _leaveServer);
  1868. _classPrivateMethodInitSpec(this, _joinServer);
  1869. _classPrivateMethodInitSpec(this, _updateAuth);
  1870. _classPrivateMethodInitSpec(this, _verifyAuth);
  1871. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1872. Discord_defineProperty(this, 'whiteList', {
  1873. ...JSON.parse(defaultTasks),
  1874. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1875. });
  1876. _classPrivateFieldInitSpec(this, _auth, {
  1877. writable: true,
  1878. value: GM_getValue('discordAuth') || {}
  1879. });
  1880. _classPrivateFieldInitSpec(this, _cache, {
  1881. writable: true,
  1882. value: GM_getValue('discordCache') || {}
  1883. });
  1884. _classPrivateFieldInitSpec(this, _initialized, {
  1885. writable: true,
  1886. value: false
  1887. });
  1888. }
  1889. async init() {
  1890. try {
  1891. if (!GM_getValue('dontRemindDiscordAgain')) {
  1892. const result = await external_Swal_default().fire({
  1893. title: i18n('discordImportantNotice'),
  1894. text: i18n('discordImportantNoticeText'),
  1895. showCancelButton: true,
  1896. showDenyButton: true,
  1897. confirmButtonText: i18n('continue'),
  1898. cancelButtonText: i18n('skipDiscordTask'),
  1899. denyButtonText: i18n('continueAndDontRemindAgain')
  1900. }).then(_ref => {
  1901. let {
  1902. isConfirmed,
  1903. isDenied
  1904. } = _ref;
  1905. if (isConfirmed) {
  1906. return true;
  1907. }
  1908. if (isDenied) {
  1909. GM_setValue('dontRemindDiscordAgain', true);
  1910. return true;
  1911. }
  1912. return false;
  1913. });
  1914. if (!result) {
  1915. _classPrivateFieldSet(this, _initialized, false);
  1916. return 'skip';
  1917. }
  1918. }
  1919. if (_classPrivateFieldGet(this, _initialized)) {
  1920. return true;
  1921. }
  1922. if (!_classPrivateFieldGet(this, _auth).auth) {
  1923. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1924. _classPrivateFieldSet(this, _initialized, true);
  1925. return true;
  1926. }
  1927. return false;
  1928. }
  1929. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1930. if (isVerified) {
  1931. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1932. _classPrivateFieldSet(this, _initialized, true);
  1933. return true;
  1934. }
  1935. GM_setValue('discordAuth', {
  1936. auth: null
  1937. });
  1938. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1939. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1940. _classPrivateFieldSet(this, _initialized, true);
  1941. return true;
  1942. }
  1943. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1944. return false;
  1945. } catch (error) {
  1946. throwError(error, 'Discord.init');
  1947. return false;
  1948. }
  1949. }
  1950. async toggle(_ref2) {
  1951. let {
  1952. doTask = true,
  1953. serverLinks = []
  1954. } = _ref2;
  1955. try {
  1956. if (!_classPrivateFieldGet(this, _initialized)) {
  1957. scripts_echoLog({
  1958. text: i18n('needInit')
  1959. });
  1960. return false;
  1961. }
  1962. const prom = [];
  1963. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1964. scripts_echoLog({
  1965. type: 'globalOptionsSkip',
  1966. text: 'discord.servers'
  1967. });
  1968. } else {
  1969. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1970. var _link$match;
  1971. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1972. });
  1973. if (realServers.length > 0) {
  1974. for (const server of realServers) {
  1975. if (doTask) {
  1976. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1977. } else {
  1978. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1979. }
  1980. await delay(1e3);
  1981. }
  1982. }
  1983. }
  1984. return await Promise.all(prom).then(() => true);
  1985. } catch (error) {
  1986. throwError(error, 'Discord.toggleServers');
  1987. return false;
  1988. }
  1989. }
  1990. }
  1991. async function _verifyAuth2() {
  1992. try {
  1993. const logStatus = scripts_echoLog({
  1994. text: i18n('verifyingAuth', 'Discord')
  1995. });
  1996. const {
  1997. result,
  1998. statusText,
  1999. status,
  2000. data
  2001. } = await tools_httpRequest({
  2002. url: 'https://discord.com/api/v6/users/@me',
  2003. method: 'HEAD',
  2004. headers: {
  2005. authorization: _classPrivateFieldGet(this, _auth).auth
  2006. }
  2007. });
  2008. if (result === 'Success') {
  2009. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2010. logStatus.success();
  2011. return true;
  2012. }
  2013. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2014. return false;
  2015. }
  2016. logStatus.error(`${result}:${statusText}(${status})`);
  2017. return false;
  2018. } catch (error) {
  2019. throwError(error, 'Discord.verifyAuth');
  2020. return false;
  2021. }
  2022. }
  2023. async function _updateAuth2() {
  2024. try {
  2025. const logStatus = scripts_echoLog({
  2026. text: i18n('updatingAuth', 'Discord')
  2027. });
  2028. return await new Promise(resolve => {
  2029. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  2030. active: true,
  2031. insert: true,
  2032. setParent: true
  2033. });
  2034. newTab.onclose = async () => {
  2035. var _GM_getValue2;
  2036. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  2037. if (auth) {
  2038. _classPrivateFieldSet(this, _auth, {
  2039. auth: auth
  2040. });
  2041. logStatus.success();
  2042. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  2043. } else {
  2044. logStatus.error('Error: Update discord auth failed!');
  2045. resolve(false);
  2046. }
  2047. };
  2048. });
  2049. } catch (error) {
  2050. throwError(error, 'Discord.updateAuth');
  2051. return false;
  2052. }
  2053. }
  2054. async function _joinServer2(inviteId) {
  2055. try {
  2056. const logStatus = scripts_echoLog({
  2057. type: 'joiningDiscordServer',
  2058. text: inviteId
  2059. });
  2060. const {
  2061. result,
  2062. statusText,
  2063. status,
  2064. data
  2065. } = await tools_httpRequest({
  2066. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2067. method: 'POST',
  2068. dataType: 'json',
  2069. headers: {
  2070. authorization: _classPrivateFieldGet(this, _auth).auth,
  2071. origin: 'https://discord.com',
  2072. referer: `https://discord.com/invite/${inviteId}`
  2073. }
  2074. });
  2075. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2076. var _data$response, _data$response$guild;
  2077. logStatus.success();
  2078. const guild = String((_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$guild = _data$response.guild) === null || _data$response$guild === void 0 ? void 0 : _data$response$guild.id);
  2079. if (guild) {
  2080. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2081. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2082. }
  2083. return true;
  2084. }
  2085. logStatus.error(`${result}:${statusText}(${status})`);
  2086. return false;
  2087. } catch (error) {
  2088. throwError(error, 'Discord.joinServer');
  2089. return false;
  2090. }
  2091. }
  2092. async function _leaveServer2(inviteId) {
  2093. try {
  2094. if (this.whiteList.servers.includes(inviteId)) {
  2095. scripts_echoLog({
  2096. type: 'whiteList',
  2097. text: 'Discord.leaveServer',
  2098. id: inviteId
  2099. });
  2100. return true;
  2101. }
  2102. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2103. if (!guild) {
  2104. return false;
  2105. }
  2106. const logStatus = scripts_echoLog({
  2107. type: 'leavingDiscordServer',
  2108. text: guild
  2109. });
  2110. const {
  2111. result,
  2112. statusText,
  2113. status,
  2114. data
  2115. } = await tools_httpRequest({
  2116. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2117. method: 'DELETE',
  2118. headers: {
  2119. authorization: _classPrivateFieldGet(this, _auth).auth
  2120. }
  2121. });
  2122. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2123. logStatus.success();
  2124. return true;
  2125. }
  2126. logStatus.error(`${result}:${statusText}(${status})`);
  2127. return false;
  2128. } catch (error) {
  2129. throwError(error, 'Discord.leaveServer');
  2130. return false;
  2131. }
  2132. }
  2133. async function _getGuild2(inviteId) {
  2134. try {
  2135. const logStatus = scripts_echoLog({
  2136. type: 'gettingDiscordGuild',
  2137. text: inviteId
  2138. });
  2139. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2140. if (guild) {
  2141. logStatus.success();
  2142. return guild;
  2143. }
  2144. const {
  2145. result,
  2146. statusText,
  2147. status,
  2148. data
  2149. } = await tools_httpRequest({
  2150. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2151. responseType: 'json',
  2152. method: 'GET'
  2153. });
  2154. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2155. var _data$response2, _data$response2$guild;
  2156. const guild = (_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$guild = _data$response2.guild) === null || _data$response2$guild === void 0 ? void 0 : _data$response2$guild.id;
  2157. if (guild) {
  2158. logStatus.success();
  2159. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2160. return guild;
  2161. }
  2162. logStatus.error(`${result}:${statusText}(${status})`);
  2163. return false;
  2164. }
  2165. logStatus.error(`${result}:${statusText}(${status})`);
  2166. return false;
  2167. } catch (error) {
  2168. throwError(error, 'Discord.getGuild');
  2169. return false;
  2170. }
  2171. }
  2172. function _setCache2(inviteId, guild) {
  2173. try {
  2174. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2175. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2176. } catch (error) {
  2177. throwError(error, 'Discord.setCache');
  2178. }
  2179. }
  2180. const social_Discord = Discord;
  2181. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2182. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2183. privateSet.add(obj);
  2184. }
  2185. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2186. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2187. privateMap.set(obj, value);
  2188. }
  2189. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2190. if (privateCollection.has(obj)) {
  2191. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2192. }
  2193. }
  2194. function Instagram_defineProperty(obj, key, value) {
  2195. if (key in obj) {
  2196. Object.defineProperty(obj, key, {
  2197. value: value,
  2198. enumerable: true,
  2199. configurable: true,
  2200. writable: true
  2201. });
  2202. } else {
  2203. obj[key] = value;
  2204. }
  2205. return obj;
  2206. }
  2207. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2208. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2209. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2210. return value;
  2211. }
  2212. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2213. if (descriptor.set) {
  2214. descriptor.set.call(receiver, value);
  2215. } else {
  2216. if (!descriptor.writable) {
  2217. throw new TypeError('attempted to set read only private field');
  2218. }
  2219. descriptor.value = value;
  2220. }
  2221. }
  2222. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2223. if (!privateSet.has(receiver)) {
  2224. throw new TypeError('attempted to get private field on non-instance');
  2225. }
  2226. return fn;
  2227. }
  2228. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2229. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2230. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2231. }
  2232. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2233. if (!privateMap.has(receiver)) {
  2234. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2235. }
  2236. return privateMap.get(receiver);
  2237. }
  2238. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2239. if (descriptor.get) {
  2240. return descriptor.get.call(receiver);
  2241. }
  2242. return descriptor.value;
  2243. }
  2244. const Instagram_defaultTasksTemplate = {
  2245. users: []
  2246. };
  2247. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2248. var Instagram_cache = new WeakMap();
  2249. var Instagram_auth = new WeakMap();
  2250. var Instagram_initialized = new WeakMap();
  2251. var _getUserInfo = new WeakSet();
  2252. var _followUser = new WeakSet();
  2253. var _unfollowUser = new WeakSet();
  2254. var Instagram_setCache = new WeakSet();
  2255. class Instagram extends social_Social {
  2256. constructor() {
  2257. var _GM_getValue;
  2258. super(...arguments);
  2259. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2260. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2261. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2262. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2263. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2264. Instagram_defineProperty(this, 'whiteList', {
  2265. ...JSON.parse(Instagram_defaultTasks),
  2266. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2267. });
  2268. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2269. writable: true,
  2270. value: GM_getValue('instagramCache') || {}
  2271. });
  2272. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2273. writable: true,
  2274. value: {}
  2275. });
  2276. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2277. writable: true,
  2278. value: false
  2279. });
  2280. }
  2281. async init() {
  2282. try {
  2283. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2284. return true;
  2285. }
  2286. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2287. if (isVerified) {
  2288. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2289. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2290. return true;
  2291. }
  2292. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2293. return false;
  2294. } catch (error) {
  2295. throwError(error, 'Instagram.init');
  2296. return false;
  2297. }
  2298. }
  2299. async toggle(_ref) {
  2300. let {
  2301. doTask = true,
  2302. userLinks = []
  2303. } = _ref;
  2304. try {
  2305. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2306. scripts_echoLog({
  2307. text: i18n('needInit')
  2308. });
  2309. return false;
  2310. }
  2311. const prom = [];
  2312. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2313. scripts_echoLog({
  2314. type: 'globalOptionsSkip',
  2315. text: 'instagram.users'
  2316. });
  2317. } else {
  2318. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2319. var _link$match;
  2320. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2321. });
  2322. if (realUsers.length > 0) {
  2323. for (const username of realUsers) {
  2324. if (doTask) {
  2325. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2326. } else {
  2327. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2328. }
  2329. await delay(1e3);
  2330. }
  2331. }
  2332. }
  2333. return await Promise.all(prom).then(() => true);
  2334. } catch (error) {
  2335. throwError(error, 'Instagram.toggleUsers');
  2336. return false;
  2337. }
  2338. }
  2339. }
  2340. async function _getUserInfo2() {
  2341. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2342. try {
  2343. const logStatus = scripts_echoLog({
  2344. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2345. text: name
  2346. });
  2347. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2348. if (userId && name !== 'instagram') {
  2349. logStatus.success();
  2350. return userId;
  2351. }
  2352. const {
  2353. result,
  2354. statusText,
  2355. status,
  2356. data
  2357. } = await tools_httpRequest({
  2358. url: `https://www.instagram.com/${name}/`,
  2359. method: 'GET'
  2360. });
  2361. if (result === 'Success') {
  2362. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2363. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2364. return false;
  2365. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2366. logStatus.error(`Error:${i18n('insBanned')}`);
  2367. return false;
  2368. }
  2369. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2370. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2371. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2372. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2373. if (name === 'instagram') {
  2374. if (csrftoken && hash) {
  2375. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2376. csrftoken: csrftoken,
  2377. hash: hash
  2378. });
  2379. return true;
  2380. }
  2381. return false;
  2382. }
  2383. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2384. if (id) {
  2385. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2386. logStatus.success();
  2387. return id;
  2388. }
  2389. logStatus.error('Error: Get ins data error!');
  2390. return false;
  2391. }
  2392. logStatus.error(`${result}:${statusText}(${status})`);
  2393. return false;
  2394. }
  2395. return false;
  2396. } catch (error) {
  2397. throwError(error, 'Instagram.getUserInfo');
  2398. return false;
  2399. }
  2400. }
  2401. async function _followUser2(name) {
  2402. try {
  2403. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2404. if (!id) {
  2405. return false;
  2406. }
  2407. const logStatus = scripts_echoLog({
  2408. type: 'followingIns',
  2409. text: name
  2410. });
  2411. const {
  2412. result,
  2413. statusText,
  2414. status,
  2415. data
  2416. } = await tools_httpRequest({
  2417. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2418. method: 'POST',
  2419. dataType: 'json',
  2420. headers: {
  2421. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2422. origin: 'https://www.instagram.com',
  2423. referer: `https://www.instagram.com/${name}/`,
  2424. 'content-type': 'application/x-www-form-urlencoded',
  2425. 'sec-fetch-site': 'same-origin',
  2426. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2427. }
  2428. });
  2429. if (result === 'Success') {
  2430. var _data$response, _data$response2;
  2431. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.result) === 'following') {
  2432. logStatus.success();
  2433. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2434. return true;
  2435. }
  2436. logStatus.error(`Error:${(data === null || data === void 0 ? void 0 : (_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : _data$response2.feedback_message) || `${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`}`);
  2437. return false;
  2438. }
  2439. logStatus.error(`${result}:${statusText}(${status})`);
  2440. return false;
  2441. } catch (error) {
  2442. throwError(error, 'Instagram.followUser');
  2443. return false;
  2444. }
  2445. }
  2446. async function _unfollowUser2(name) {
  2447. try {
  2448. if (this.whiteList.users.includes(name)) {
  2449. scripts_echoLog({
  2450. type: 'whiteList',
  2451. text: 'Instagram.unfollowUser',
  2452. id: name
  2453. });
  2454. return true;
  2455. }
  2456. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2457. if (!id) {
  2458. return false;
  2459. }
  2460. const logStatus = scripts_echoLog({
  2461. type: 'unfollowingIns',
  2462. text: name
  2463. });
  2464. const {
  2465. result,
  2466. statusText,
  2467. status,
  2468. data
  2469. } = await tools_httpRequest({
  2470. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2471. method: 'POST',
  2472. dataType: 'json',
  2473. headers: {
  2474. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2475. origin: 'https://www.instagram.com',
  2476. referer: `https://www.instagram.com/${name}/`,
  2477. 'content-type': 'application/x-www-form-urlencoded',
  2478. 'sec-fetch-site': 'same-origin',
  2479. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2480. }
  2481. });
  2482. if (result === 'Success') {
  2483. var _data$response3;
  2484. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response3 = data.response) === null || _data$response3 === void 0 ? void 0 : _data$response3.status) === 'ok') {
  2485. logStatus.success();
  2486. return true;
  2487. }
  2488. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2489. return false;
  2490. }
  2491. logStatus.error(`${result}:${statusText}(${status})`);
  2492. return false;
  2493. } catch (error) {
  2494. throwError(error, 'Instagram.unfollowUser');
  2495. return false;
  2496. }
  2497. }
  2498. function Instagram_setCache2(name, id) {
  2499. try {
  2500. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2501. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2502. } catch (error) {
  2503. throwError(error, 'Instagram.setCache');
  2504. }
  2505. }
  2506. const social_Instagram = Instagram;
  2507. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2508. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2509. privateSet.add(obj);
  2510. }
  2511. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2512. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2513. privateMap.set(obj, value);
  2514. }
  2515. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2516. if (privateCollection.has(obj)) {
  2517. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2518. }
  2519. }
  2520. function Reddit_defineProperty(obj, key, value) {
  2521. if (key in obj) {
  2522. Object.defineProperty(obj, key, {
  2523. value: value,
  2524. enumerable: true,
  2525. configurable: true,
  2526. writable: true
  2527. });
  2528. } else {
  2529. obj[key] = value;
  2530. }
  2531. return obj;
  2532. }
  2533. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2534. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2535. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2536. return value;
  2537. }
  2538. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2539. if (descriptor.set) {
  2540. descriptor.set.call(receiver, value);
  2541. } else {
  2542. if (!descriptor.writable) {
  2543. throw new TypeError('attempted to set read only private field');
  2544. }
  2545. descriptor.value = value;
  2546. }
  2547. }
  2548. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2549. if (!privateSet.has(receiver)) {
  2550. throw new TypeError('attempted to get private field on non-instance');
  2551. }
  2552. return fn;
  2553. }
  2554. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2555. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2556. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2557. }
  2558. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2559. if (!privateMap.has(receiver)) {
  2560. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2561. }
  2562. return privateMap.get(receiver);
  2563. }
  2564. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2565. if (descriptor.get) {
  2566. return descriptor.get.call(receiver);
  2567. }
  2568. return descriptor.value;
  2569. }
  2570. const Reddit_defaultTasksTemplate = {
  2571. reddits: []
  2572. };
  2573. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2574. var Reddit_auth = new WeakMap();
  2575. var Reddit_initialized = new WeakMap();
  2576. var _useBeta = new WeakSet();
  2577. var Reddit_updateAuth = new WeakSet();
  2578. class Reddit extends social_Social {
  2579. constructor() {
  2580. var _GM_getValue;
  2581. super(...arguments);
  2582. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2583. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2584. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2585. Reddit_defineProperty(this, 'whiteList', {
  2586. ...JSON.parse(Reddit_defaultTasks),
  2587. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2588. });
  2589. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2590. writable: true,
  2591. value: void 0
  2592. });
  2593. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2594. writable: true,
  2595. value: false
  2596. });
  2597. }
  2598. async init() {
  2599. try {
  2600. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2601. return true;
  2602. }
  2603. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2604. if (isVerified) {
  2605. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2606. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2607. return true;
  2608. }
  2609. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2610. return false;
  2611. } catch (error) {
  2612. throwError(error, 'Reddit.init');
  2613. return false;
  2614. }
  2615. }
  2616. async toggleTask(_ref) {
  2617. let {
  2618. name,
  2619. doTask = true
  2620. } = _ref;
  2621. try {
  2622. if (!doTask && this.whiteList.reddits.includes(name)) {
  2623. scripts_echoLog({
  2624. type: 'whiteList',
  2625. text: 'Reddit.undoTask',
  2626. id: name
  2627. });
  2628. return true;
  2629. }
  2630. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2631. if (/^u_/.test(name)) {
  2632. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2633. }
  2634. const logStatus = scripts_echoLog({
  2635. type: type,
  2636. text: name
  2637. });
  2638. const {
  2639. result,
  2640. statusText,
  2641. status,
  2642. data
  2643. } = await tools_httpRequest({
  2644. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2645. method: 'POST',
  2646. headers: {
  2647. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2648. 'content-type': 'application/x-www-form-urlencoded'
  2649. },
  2650. data: $.param({
  2651. action: doTask ? 'sub' : 'unsub',
  2652. sr_name: name,
  2653. api_type: 'json'
  2654. })
  2655. });
  2656. if (result === 'Success') {
  2657. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2658. logStatus.success();
  2659. if (doTask) {
  2660. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2661. }
  2662. return true;
  2663. }
  2664. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2665. return false;
  2666. }
  2667. logStatus.error(`${result}:${statusText}(${status})`);
  2668. return false;
  2669. } catch (error) {
  2670. throwError(error, 'Reddit.toggleTask');
  2671. return false;
  2672. }
  2673. }
  2674. async toggle(_ref2) {
  2675. let {
  2676. doTask = true,
  2677. redditLinks = []
  2678. } = _ref2;
  2679. try {
  2680. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2681. scripts_echoLog({
  2682. text: i18n('needInit')
  2683. });
  2684. return false;
  2685. }
  2686. const prom = [];
  2687. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2688. scripts_echoLog({
  2689. type: 'globalOptionsSkip',
  2690. text: 'reddit.reddits'
  2691. });
  2692. } else {
  2693. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2694. var _link$match, _link$match2;
  2695. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2696. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2697. if (userName) {
  2698. return name || userName;
  2699. }
  2700. return name;
  2701. });
  2702. if (realReddits.length > 0) {
  2703. for (const name of realReddits) {
  2704. prom.push(this.toggleTask({
  2705. name: name,
  2706. doTask: doTask
  2707. }));
  2708. await delay(1e3);
  2709. }
  2710. }
  2711. }
  2712. return await Promise.all(prom).then(() => true);
  2713. } catch (error) {
  2714. throwError(error, 'Reddit.toggle');
  2715. return false;
  2716. }
  2717. }
  2718. }
  2719. async function _useBeta2() {
  2720. try {
  2721. const logStatus = scripts_echoLog({
  2722. text: i18n('changingRedditVersion')
  2723. });
  2724. GM_setValue('redditAuth', null);
  2725. return await new Promise(resolve => {
  2726. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2727. active: true,
  2728. insert: true,
  2729. setParent: true
  2730. });
  2731. newTab.onclose = async () => {
  2732. logStatus.success();
  2733. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2734. };
  2735. });
  2736. } catch (error) {
  2737. throwError(error, 'Reddit.useBeta');
  2738. return false;
  2739. }
  2740. }
  2741. async function Reddit_updateAuth2() {
  2742. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2743. try {
  2744. const logStatus = scripts_echoLog({
  2745. text: i18n('updatingAuth', 'Reddit')
  2746. });
  2747. const {
  2748. result,
  2749. statusText,
  2750. status,
  2751. data
  2752. } = await tools_httpRequest({
  2753. url: 'https://www.reddit.com/',
  2754. method: 'GET',
  2755. nochche: true,
  2756. headers: {
  2757. 'Cache-Control': 'no-cache'
  2758. }
  2759. });
  2760. if (result === 'Success') {
  2761. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2762. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2763. return false;
  2764. }
  2765. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2766. var _data$responseText$ma;
  2767. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2768. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2769. }
  2770. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2771. if (accessToken) {
  2772. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2773. token: accessToken
  2774. });
  2775. logStatus.success();
  2776. return true;
  2777. }
  2778. logStatus.error('Error: Parameter "accessToken" not found!');
  2779. return false;
  2780. }
  2781. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2782. return false;
  2783. }
  2784. logStatus.error(`${result}:${statusText}(${status})`);
  2785. return false;
  2786. } catch (error) {
  2787. throwError(error, 'Reddit.updateAuth');
  2788. return false;
  2789. }
  2790. }
  2791. const social_Reddit = Reddit;
  2792. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2793. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2794. privateSet.add(obj);
  2795. }
  2796. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2797. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2798. privateMap.set(obj, value);
  2799. }
  2800. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2801. if (privateCollection.has(obj)) {
  2802. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2803. }
  2804. }
  2805. function Twitch_defineProperty(obj, key, value) {
  2806. if (key in obj) {
  2807. Object.defineProperty(obj, key, {
  2808. value: value,
  2809. enumerable: true,
  2810. configurable: true,
  2811. writable: true
  2812. });
  2813. } else {
  2814. obj[key] = value;
  2815. }
  2816. return obj;
  2817. }
  2818. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2819. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2820. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2821. return value;
  2822. }
  2823. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2824. if (descriptor.set) {
  2825. descriptor.set.call(receiver, value);
  2826. } else {
  2827. if (!descriptor.writable) {
  2828. throw new TypeError('attempted to set read only private field');
  2829. }
  2830. descriptor.value = value;
  2831. }
  2832. }
  2833. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2834. if (!privateSet.has(receiver)) {
  2835. throw new TypeError('attempted to get private field on non-instance');
  2836. }
  2837. return fn;
  2838. }
  2839. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2840. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2841. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2842. }
  2843. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2844. if (!privateMap.has(receiver)) {
  2845. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2846. }
  2847. return privateMap.get(receiver);
  2848. }
  2849. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2850. if (descriptor.get) {
  2851. return descriptor.get.call(receiver);
  2852. }
  2853. return descriptor.value;
  2854. }
  2855. const Twitch_defaultTasksTemplate = {
  2856. channels: []
  2857. };
  2858. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2859. var Twitch_auth = new WeakMap();
  2860. var Twitch_cache = new WeakMap();
  2861. var Twitch_initialized = new WeakMap();
  2862. var Twitch_verifyAuth = new WeakSet();
  2863. var Twitch_updateAuth = new WeakSet();
  2864. var _toggleChannel = new WeakSet();
  2865. var _getChannelId = new WeakSet();
  2866. var Twitch_setCache = new WeakSet();
  2867. class Twitch extends social_Social {
  2868. constructor() {
  2869. var _GM_getValue;
  2870. super(...arguments);
  2871. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2872. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2873. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2874. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2875. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2876. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2877. Twitch_defineProperty(this, 'whiteList', {
  2878. ...JSON.parse(Twitch_defaultTasks),
  2879. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2880. });
  2881. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2882. writable: true,
  2883. value: GM_getValue('twitchAuth') || {}
  2884. });
  2885. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2886. writable: true,
  2887. value: GM_getValue('twitchCache') || {}
  2888. });
  2889. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2890. writable: true,
  2891. value: false
  2892. });
  2893. }
  2894. async init() {
  2895. try {
  2896. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2897. return true;
  2898. }
  2899. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2900. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2901. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2902. return true;
  2903. }
  2904. return false;
  2905. }
  2906. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2907. if (isVerified) {
  2908. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2909. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2910. return true;
  2911. }
  2912. GM_setValue('twitchAuth', null);
  2913. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2914. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2915. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2916. return true;
  2917. }
  2918. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2919. return false;
  2920. } catch (error) {
  2921. throwError(error, 'Twitch.init');
  2922. return false;
  2923. }
  2924. }
  2925. async toggle(_ref) {
  2926. let {
  2927. doTask = true,
  2928. channelLinks = []
  2929. } = _ref;
  2930. try {
  2931. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2932. scripts_echoLog({
  2933. text: i18n('needInit')
  2934. });
  2935. return false;
  2936. }
  2937. const prom = [];
  2938. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2939. scripts_echoLog({
  2940. type: 'globalOptionsSkip',
  2941. text: 'twitch.channels'
  2942. });
  2943. } else {
  2944. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2945. var _link$match;
  2946. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2947. });
  2948. if (realChannels.length > 0) {
  2949. for (const channel of realChannels) {
  2950. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2951. name: channel,
  2952. doTask: doTask
  2953. }));
  2954. await delay(1e3);
  2955. }
  2956. }
  2957. }
  2958. return Promise.all(prom).then(() => true);
  2959. } catch (error) {
  2960. throwError(error, 'Twitch.toggle');
  2961. return false;
  2962. }
  2963. }
  2964. }
  2965. async function Twitch_verifyAuth2() {
  2966. try {
  2967. const logStatus = scripts_echoLog({
  2968. text: i18n('verifyingAuth', 'Twitch')
  2969. });
  2970. const {
  2971. result,
  2972. statusText,
  2973. status,
  2974. data
  2975. } = await tools_httpRequest({
  2976. url: 'https://gql.twitch.tv/gql',
  2977. method: 'POST',
  2978. dataType: 'json',
  2979. headers: {
  2980. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2981. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2982. },
  2983. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2984. });
  2985. if (result === 'Success') {
  2986. var _data$response, _data$response$, _data$response$$data;
  2987. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response = data.response) !== null && _data$response !== void 0 && (_data$response$ = _data$response[0]) !== null && _data$response$ !== void 0 && (_data$response$$data = _data$response$.data) !== null && _data$response$$data !== void 0 && _data$response$$data.currentUser) {
  2988. logStatus.success();
  2989. return true;
  2990. }
  2991. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2992. return false;
  2993. }
  2994. logStatus.error(`${result}:${statusText}(${status})`);
  2995. return false;
  2996. } catch (error) {
  2997. throwError(error, 'Twitch.verifyAuth');
  2998. return false;
  2999. }
  3000. }
  3001. async function Twitch_updateAuth2() {
  3002. try {
  3003. const logStatus = scripts_echoLog({
  3004. text: i18n('updatingAuth', 'Twitch')
  3005. });
  3006. return await new Promise(resolve => {
  3007. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  3008. active: true,
  3009. insert: true,
  3010. setParent: true
  3011. });
  3012. newTab.onclose = async () => {
  3013. const auth = GM_getValue('twitchAuth');
  3014. if (auth) {
  3015. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  3016. logStatus.success();
  3017. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  3018. } else {
  3019. logStatus.error('Error: Update twitch auth failed!');
  3020. resolve(false);
  3021. }
  3022. };
  3023. });
  3024. } catch (error) {
  3025. throwError(error, 'Twitch.updateAuth');
  3026. return false;
  3027. }
  3028. }
  3029. async function _toggleChannel2(_ref2) {
  3030. let {
  3031. name,
  3032. doTask = true
  3033. } = _ref2;
  3034. try {
  3035. if (!doTask && this.whiteList.channels.includes(name)) {
  3036. scripts_echoLog({
  3037. type: 'whiteList',
  3038. text: 'Twitch.unfollowChannel',
  3039. id: name
  3040. });
  3041. return true;
  3042. }
  3043. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  3044. if (!channelId) {
  3045. return false;
  3046. }
  3047. const logStatus = scripts_echoLog({
  3048. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  3049. text: name
  3050. });
  3051. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  3052. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  3053. const {
  3054. result,
  3055. statusText,
  3056. status,
  3057. data
  3058. } = await tools_httpRequest({
  3059. url: 'https://gql.twitch.tv/gql',
  3060. method: 'POST',
  3061. dataType: 'json',
  3062. headers: {
  3063. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  3064. },
  3065. data: doTask ? followData : unfollowData
  3066. });
  3067. if (result === 'Success') {
  3068. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3069. logStatus.success();
  3070. if (doTask) {
  3071. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3072. }
  3073. return true;
  3074. }
  3075. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3076. return false;
  3077. }
  3078. logStatus.error(`${result}:${statusText}(${status})`);
  3079. return false;
  3080. } catch (error) {
  3081. throwError(error, 'Twitch.toggleChannel');
  3082. return false;
  3083. }
  3084. }
  3085. async function _getChannelId2(name) {
  3086. try {
  3087. const logStatus = scripts_echoLog({
  3088. type: 'gettingTwitchChannelId',
  3089. text: name
  3090. });
  3091. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3092. if (channelId) {
  3093. logStatus.success();
  3094. return channelId;
  3095. }
  3096. const {
  3097. result,
  3098. statusText,
  3099. status,
  3100. data
  3101. } = await tools_httpRequest({
  3102. url: 'https://gql.twitch.tv/gql',
  3103. method: 'POST',
  3104. headers: {
  3105. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3106. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3107. },
  3108. responseType: 'json',
  3109. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3110. });
  3111. if (result === 'Success') {
  3112. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3113. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3114. const channelId = String((_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$ = _data$response2[0]) === null || _data$response2$ === void 0 ? void 0 : (_data$response2$$data = _data$response2$.data) === null || _data$response2$$data === void 0 ? void 0 : (_data$response2$$data2 = _data$response2$$data.user) === null || _data$response2$$data2 === void 0 ? void 0 : _data$response2$$data2.id);
  3115. if (channelId) {
  3116. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3117. logStatus.success();
  3118. return channelId;
  3119. }
  3120. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3121. return false;
  3122. }
  3123. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3124. return false;
  3125. }
  3126. logStatus.error(`${result}:${statusText}(${status})`);
  3127. return false;
  3128. } catch (error) {
  3129. throwError(error, 'Twitch.getChannelId');
  3130. return false;
  3131. }
  3132. }
  3133. function Twitch_setCache2(name, id) {
  3134. try {
  3135. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3136. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3137. } catch (error) {
  3138. throwError(error, 'Twitch.setCache');
  3139. }
  3140. }
  3141. const social_Twitch = Twitch;
  3142. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3143. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3144. privateSet.add(obj);
  3145. }
  3146. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3147. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3148. privateMap.set(obj, value);
  3149. }
  3150. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3151. if (privateCollection.has(obj)) {
  3152. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3153. }
  3154. }
  3155. function Twitter_defineProperty(obj, key, value) {
  3156. if (key in obj) {
  3157. Object.defineProperty(obj, key, {
  3158. value: value,
  3159. enumerable: true,
  3160. configurable: true,
  3161. writable: true
  3162. });
  3163. } else {
  3164. obj[key] = value;
  3165. }
  3166. return obj;
  3167. }
  3168. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3169. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3170. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3171. return value;
  3172. }
  3173. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3174. if (descriptor.set) {
  3175. descriptor.set.call(receiver, value);
  3176. } else {
  3177. if (!descriptor.writable) {
  3178. throw new TypeError('attempted to set read only private field');
  3179. }
  3180. descriptor.value = value;
  3181. }
  3182. }
  3183. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3184. if (!privateSet.has(receiver)) {
  3185. throw new TypeError('attempted to get private field on non-instance');
  3186. }
  3187. return fn;
  3188. }
  3189. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3190. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3191. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3192. }
  3193. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3194. if (!privateMap.has(receiver)) {
  3195. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3196. }
  3197. return privateMap.get(receiver);
  3198. }
  3199. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3200. if (descriptor.get) {
  3201. return descriptor.get.call(receiver);
  3202. }
  3203. return descriptor.value;
  3204. }
  3205. const Twitter_defaultTasksTemplate = {
  3206. users: [],
  3207. retweets: [],
  3208. likes: []
  3209. };
  3210. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3211. var _verifyId = new WeakMap();
  3212. var Twitter_auth = new WeakMap();
  3213. var Twitter_cache = new WeakMap();
  3214. var Twitter_initialized = new WeakMap();
  3215. var Twitter_verifyAuth = new WeakSet();
  3216. var Twitter_updateAuth = new WeakSet();
  3217. var _toggleUser = new WeakSet();
  3218. var _toggleRetweet = new WeakSet();
  3219. var Twitter_setCache = new WeakSet();
  3220. class Twitter extends social_Social {
  3221. constructor() {
  3222. var _GM_getValue;
  3223. super(...arguments);
  3224. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3225. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3226. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3227. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3228. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3229. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3230. Twitter_defineProperty(this, 'whiteList', {
  3231. ...JSON.parse(Twitter_defaultTasks),
  3232. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3233. });
  3234. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3235. writable: true,
  3236. value: globalOptions.other.twitterVerifyId
  3237. });
  3238. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3239. writable: true,
  3240. value: GM_getValue('twitterAuth') || {}
  3241. });
  3242. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3243. writable: true,
  3244. value: GM_getValue('twitterCache') || {}
  3245. });
  3246. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3247. writable: true,
  3248. value: false
  3249. });
  3250. }
  3251. async init() {
  3252. try {
  3253. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3254. return true;
  3255. }
  3256. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3257. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3258. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3259. return true;
  3260. }
  3261. return false;
  3262. }
  3263. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3264. if (isVerified) {
  3265. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3266. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3267. return true;
  3268. }
  3269. GM_setValue('twitterAuth', null);
  3270. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3271. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3272. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3273. return true;
  3274. }
  3275. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3276. return false;
  3277. } catch (error) {
  3278. throwError(error, 'Twitter.init');
  3279. return false;
  3280. }
  3281. }
  3282. async userName2id(name) {
  3283. try {
  3284. const logStatus = scripts_echoLog({
  3285. type: 'gettingTwitterUserId',
  3286. text: name
  3287. });
  3288. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3289. if (userId) {
  3290. logStatus.success();
  3291. return userId;
  3292. }
  3293. const {
  3294. result,
  3295. statusText,
  3296. status,
  3297. data
  3298. } = await tools_httpRequest({
  3299. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3300. method: 'GET',
  3301. headers: {
  3302. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3303. 'content-type': 'application/json'
  3304. },
  3305. responseType: 'json',
  3306. anonymous: true
  3307. });
  3308. if (result === 'Success') {
  3309. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3310. var _response, _response$data, _response$data$user;
  3311. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3312. if (!response) {
  3313. try {
  3314. response = JSON.parse(data.responseText);
  3315. } catch (error) {
  3316. response = null;
  3317. }
  3318. }
  3319. 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);
  3320. if (userId) {
  3321. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3322. logStatus.success();
  3323. return userId;
  3324. }
  3325. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3326. return false;
  3327. }
  3328. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3329. return false;
  3330. }
  3331. logStatus.error(`${result}:${statusText}(${status})`);
  3332. return false;
  3333. } catch (error) {
  3334. throwError(error, 'Twitter.getUserId');
  3335. return false;
  3336. }
  3337. }
  3338. async toggle(_ref) {
  3339. let {
  3340. doTask = true,
  3341. userLinks = [],
  3342. retweetLinks = []
  3343. } = _ref;
  3344. try {
  3345. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3346. scripts_echoLog({
  3347. text: i18n('needInit')
  3348. });
  3349. return false;
  3350. }
  3351. const prom = [];
  3352. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3353. scripts_echoLog({
  3354. type: 'globalOptionsSkip',
  3355. text: 'twitter.users'
  3356. });
  3357. } else {
  3358. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3359. var _link$match;
  3360. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3361. });
  3362. if (realUsers.length > 0) {
  3363. for (const user of realUsers) {
  3364. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3365. name: user,
  3366. doTask: doTask
  3367. }));
  3368. await delay(1e3);
  3369. }
  3370. }
  3371. }
  3372. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3373. scripts_echoLog({
  3374. type: 'globalOptionsSkip',
  3375. text: 'twitter.retweets'
  3376. });
  3377. } else {
  3378. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3379. var _link$match2;
  3380. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3381. });
  3382. if (realRetweets.length > 0) {
  3383. for (const retweet of realRetweets) {
  3384. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3385. retweetId: retweet,
  3386. doTask: doTask
  3387. }));
  3388. await delay(1e3);
  3389. }
  3390. }
  3391. }
  3392. return Promise.all(prom).then(() => true);
  3393. } catch (error) {
  3394. throwError(error, 'Twitter.toggle');
  3395. return false;
  3396. }
  3397. }
  3398. }
  3399. async function Twitter_verifyAuth2() {
  3400. try {
  3401. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3402. name: 'verify',
  3403. doTask: true,
  3404. verify: true
  3405. });
  3406. } catch (error) {
  3407. throwError(error, 'Twitter.verifyAuth');
  3408. return false;
  3409. }
  3410. }
  3411. async function Twitter_updateAuth2() {
  3412. try {
  3413. const logStatus = scripts_echoLog({
  3414. text: i18n('updatingAuth', 'Twitter')
  3415. });
  3416. return await new Promise(resolve => {
  3417. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3418. active: true,
  3419. insert: true,
  3420. setParent: true
  3421. });
  3422. newTab.onclose = async () => {
  3423. const auth = GM_getValue('twitterAuth');
  3424. if (auth) {
  3425. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3426. logStatus.success();
  3427. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3428. } else {
  3429. logStatus.error('Error: Update twitter auth failed!');
  3430. resolve(false);
  3431. }
  3432. };
  3433. });
  3434. } catch (error) {
  3435. throwError(error, 'Twitter.updateToken');
  3436. return false;
  3437. }
  3438. }
  3439. async function _toggleUser2(_ref2) {
  3440. let {
  3441. name,
  3442. doTask = true,
  3443. verify = false
  3444. } = _ref2;
  3445. try {
  3446. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3447. scripts_echoLog({
  3448. type: 'whiteList',
  3449. text: 'Twitter.unfollowUser',
  3450. id: name
  3451. });
  3452. return true;
  3453. }
  3454. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3455. if (!userId) {
  3456. return false;
  3457. }
  3458. const logStatus = verify ? scripts_echoLog({
  3459. text: i18n('verifyingAuth', 'Twitter')
  3460. }) : scripts_echoLog({
  3461. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3462. text: name
  3463. });
  3464. const {
  3465. result,
  3466. statusText,
  3467. status,
  3468. data
  3469. } = await tools_httpRequest({
  3470. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3471. method: 'POST',
  3472. headers: {
  3473. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3474. 'Content-Type': 'application/x-www-form-urlencoded',
  3475. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3476. },
  3477. responseType: 'json',
  3478. data: $.param({
  3479. include_profile_interstitial_type: 1,
  3480. include_blocking: 1,
  3481. include_blocked_by: 1,
  3482. include_followed_by: 1,
  3483. include_want_retweets: 1,
  3484. include_mute_edge: 1,
  3485. include_can_dm: 1,
  3486. include_can_media_tag: 1,
  3487. skip_status: 1,
  3488. id: userId
  3489. })
  3490. });
  3491. if (result === 'Success') {
  3492. var _data$response, _data$response$errors, _data$response$errors2;
  3493. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3494. logStatus.success();
  3495. if (doTask && !verify) {
  3496. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3497. }
  3498. return true;
  3499. }
  3500. 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) {
  3501. logStatus.success();
  3502. return true;
  3503. }
  3504. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3505. return false;
  3506. }
  3507. logStatus.error(`${result}:${statusText}(${status})`);
  3508. return false;
  3509. } catch (error) {
  3510. throwError(error, 'Twitter.toggleUser');
  3511. return false;
  3512. }
  3513. }
  3514. async function _toggleRetweet2(_ref3) {
  3515. let {
  3516. retweetId,
  3517. doTask = true
  3518. } = _ref3;
  3519. try {
  3520. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3521. scripts_echoLog({
  3522. type: 'whiteList',
  3523. text: 'Twitter.unretweet',
  3524. id: retweetId
  3525. });
  3526. return true;
  3527. }
  3528. const logStatus = scripts_echoLog({
  3529. type: `${doTask ? '' : 'un'}retweetting`,
  3530. text: retweetId
  3531. });
  3532. const {
  3533. result,
  3534. statusText,
  3535. status,
  3536. data
  3537. } = await tools_httpRequest({
  3538. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3539. method: 'POST',
  3540. headers: {
  3541. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3542. 'Content-Type': 'application/x-www-form-urlencoded',
  3543. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3544. },
  3545. data: $.param({
  3546. tweet_mode: 'extended',
  3547. id: retweetId
  3548. }),
  3549. responseType: 'json'
  3550. });
  3551. if (result === 'Success') {
  3552. var _data$response2, _data$response2$error, _data$response2$error2;
  3553. 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) {
  3554. logStatus.success();
  3555. if (doTask) {
  3556. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3557. }
  3558. return true;
  3559. }
  3560. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3561. return false;
  3562. }
  3563. logStatus.error(`${result}:${statusText}(${status})`);
  3564. return false;
  3565. } catch (error) {
  3566. throwError(error, 'Twitter.toggleRetweet');
  3567. return false;
  3568. }
  3569. }
  3570. function Twitter_setCache2(name, id) {
  3571. try {
  3572. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3573. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3574. } catch (error) {
  3575. throwError(error, 'Twitter.setCache');
  3576. }
  3577. }
  3578. const social_Twitter = Twitter;
  3579. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3580. Vk_checkPrivateRedeclaration(obj, privateSet);
  3581. privateSet.add(obj);
  3582. }
  3583. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3584. Vk_checkPrivateRedeclaration(obj, privateMap);
  3585. privateMap.set(obj, value);
  3586. }
  3587. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3588. if (privateCollection.has(obj)) {
  3589. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3590. }
  3591. }
  3592. function Vk_defineProperty(obj, key, value) {
  3593. if (key in obj) {
  3594. Object.defineProperty(obj, key, {
  3595. value: value,
  3596. enumerable: true,
  3597. configurable: true,
  3598. writable: true
  3599. });
  3600. } else {
  3601. obj[key] = value;
  3602. }
  3603. return obj;
  3604. }
  3605. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3606. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3607. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3608. return value;
  3609. }
  3610. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3611. if (descriptor.set) {
  3612. descriptor.set.call(receiver, value);
  3613. } else {
  3614. if (!descriptor.writable) {
  3615. throw new TypeError('attempted to set read only private field');
  3616. }
  3617. descriptor.value = value;
  3618. }
  3619. }
  3620. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3621. if (!privateSet.has(receiver)) {
  3622. throw new TypeError('attempted to get private field on non-instance');
  3623. }
  3624. return fn;
  3625. }
  3626. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3627. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3628. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3629. }
  3630. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3631. if (!privateMap.has(receiver)) {
  3632. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3633. }
  3634. return privateMap.get(receiver);
  3635. }
  3636. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3637. if (descriptor.get) {
  3638. return descriptor.get.call(receiver);
  3639. }
  3640. return descriptor.value;
  3641. }
  3642. const Vk_defaultTasksTemplate = {
  3643. names: []
  3644. };
  3645. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3646. var _username = new WeakMap();
  3647. var Vk_cache = new WeakMap();
  3648. var Vk_initialized = new WeakMap();
  3649. var Vk_verifyAuth = new WeakSet();
  3650. var _toggleGroup = new WeakSet();
  3651. var _togglePublic = new WeakSet();
  3652. var _sendWall = new WeakSet();
  3653. var _deleteWall = new WeakSet();
  3654. var _getId = new WeakSet();
  3655. var _toggleVk = new WeakSet();
  3656. var Vk_setCache = new WeakSet();
  3657. class Vk extends social_Social {
  3658. constructor() {
  3659. var _GM_getValue;
  3660. super(...arguments);
  3661. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3662. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3663. Vk_classPrivateMethodInitSpec(this, _getId);
  3664. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3665. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3666. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3667. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3668. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3669. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3670. Vk_defineProperty(this, 'whiteList', {
  3671. ...JSON.parse(Vk_defaultTasks),
  3672. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3673. });
  3674. Vk_classPrivateFieldInitSpec(this, _username, {
  3675. writable: true,
  3676. value: ''
  3677. });
  3678. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3679. writable: true,
  3680. value: GM_getValue('vkCache') || {}
  3681. });
  3682. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3683. writable: true,
  3684. value: false
  3685. });
  3686. }
  3687. async init() {
  3688. try {
  3689. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3690. return true;
  3691. }
  3692. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3693. if (isVerified) {
  3694. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3695. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3696. return true;
  3697. }
  3698. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3699. return false;
  3700. } catch (error) {
  3701. throwError(error, 'Vk.init');
  3702. return false;
  3703. }
  3704. }
  3705. async toggle(_ref) {
  3706. let {
  3707. doTask = true,
  3708. nameLinks = []
  3709. } = _ref;
  3710. try {
  3711. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3712. scripts_echoLog({
  3713. text: i18n('needInit')
  3714. });
  3715. return false;
  3716. }
  3717. const prom = [];
  3718. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3719. scripts_echoLog({
  3720. type: 'globalOptionsSkip',
  3721. text: 'vk.names'
  3722. });
  3723. } else {
  3724. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3725. var _link$match;
  3726. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3727. });
  3728. if (realNames.length > 0) {
  3729. for (const name of realNames) {
  3730. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3731. name: name,
  3732. doTask: doTask
  3733. }));
  3734. await delay(1e3);
  3735. }
  3736. }
  3737. }
  3738. return Promise.all(prom).then(() => true);
  3739. } catch (error) {
  3740. throwError(error, 'Vk.toggle');
  3741. return false;
  3742. }
  3743. }
  3744. }
  3745. async function Vk_verifyAuth2() {
  3746. try {
  3747. const logStatus = scripts_echoLog({
  3748. text: i18n('verifyAuth', 'Vk')
  3749. });
  3750. const {
  3751. result,
  3752. statusText,
  3753. status,
  3754. data
  3755. } = await tools_httpRequest({
  3756. url: 'https://vk.com/im',
  3757. method: 'GET'
  3758. });
  3759. if (result === 'Success') {
  3760. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3761. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3762. return false;
  3763. }
  3764. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3765. var _data$responseText$ma;
  3766. 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]) || '');
  3767. logStatus.success();
  3768. return true;
  3769. }
  3770. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3771. return false;
  3772. }
  3773. logStatus.error(`${result}:${statusText}(${status})`);
  3774. return false;
  3775. } catch (error) {
  3776. throwError(error, 'Vk.verifyAuth');
  3777. return false;
  3778. }
  3779. }
  3780. async function _toggleGroup2(name, dataParam) {
  3781. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3782. try {
  3783. const logStatus = scripts_echoLog({
  3784. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3785. text: name
  3786. });
  3787. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3788. logStatus.success();
  3789. return true;
  3790. }
  3791. const reqData = {
  3792. act: doTask ? 'enter' : 'leave',
  3793. al: 1,
  3794. gid: dataParam.groupId,
  3795. hash: dataParam.groupHash
  3796. };
  3797. if (doTask) {
  3798. reqData.context = '_';
  3799. }
  3800. const {
  3801. result,
  3802. statusText,
  3803. status,
  3804. data
  3805. } = await tools_httpRequest({
  3806. url: 'https://vk.com/al_groups.php',
  3807. method: 'POST',
  3808. headers: {
  3809. origin: 'https://vk.com',
  3810. referer: `https://vk.com/${name}`,
  3811. 'content-type': 'application/x-www-form-urlencoded'
  3812. },
  3813. data: $.param(reqData)
  3814. });
  3815. if (result === 'Success') {
  3816. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3817. logStatus.success();
  3818. if (doTask) {
  3819. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3820. }
  3821. return true;
  3822. }
  3823. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3824. return false;
  3825. }
  3826. logStatus.error(`${result}:${statusText}(${status})`);
  3827. return false;
  3828. } catch (error) {
  3829. throwError(error, 'Vk.toggleGroup');
  3830. return false;
  3831. }
  3832. }
  3833. async function _togglePublic2(name, dataParam) {
  3834. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3835. try {
  3836. const logStatus = scripts_echoLog({
  3837. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3838. text: name
  3839. });
  3840. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3841. logStatus.success();
  3842. return true;
  3843. }
  3844. const {
  3845. result,
  3846. statusText,
  3847. status,
  3848. data
  3849. } = await tools_httpRequest({
  3850. url: 'https://vk.com/al_public.php',
  3851. method: 'POST',
  3852. headers: {
  3853. origin: 'https://vk.com',
  3854. referer: `https://vk.com/${name}`,
  3855. 'content-type': 'application/x-www-form-urlencoded'
  3856. },
  3857. data: $.param({
  3858. act: doTask ? 'a_enter' : 'a_leave',
  3859. al: 1,
  3860. pid: dataParam.publicPid,
  3861. hash: dataParam.publicHash
  3862. })
  3863. });
  3864. if (result === 'Success') {
  3865. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3866. logStatus.success();
  3867. if (doTask) {
  3868. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3869. }
  3870. return true;
  3871. }
  3872. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3873. return false;
  3874. }
  3875. logStatus.error(`${result}:${statusText}(${status})`);
  3876. return false;
  3877. } catch (error) {
  3878. throwError(error, 'Vk.togglePublic');
  3879. return false;
  3880. }
  3881. }
  3882. async function _sendWall2(name) {
  3883. try {
  3884. const logStatus = scripts_echoLog({
  3885. type: 'sendingVkWall',
  3886. text: name
  3887. });
  3888. const {
  3889. result,
  3890. statusText,
  3891. status,
  3892. data
  3893. } = await tools_httpRequest({
  3894. url: 'https://vk.com/like.php',
  3895. method: 'POST',
  3896. headers: {
  3897. origin: 'https://vk.com',
  3898. referer: `https://vk.com/${name}`,
  3899. 'content-type': 'application/x-www-form-urlencoded'
  3900. },
  3901. data: $.param({
  3902. act: 'publish_box',
  3903. al: 1,
  3904. object: name
  3905. })
  3906. });
  3907. if (result === 'Success') {
  3908. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3909. var _data$responseText$ma2;
  3910. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3911. if (hash) {
  3912. const {
  3913. result: resultR,
  3914. statusText: statusTextR,
  3915. status: statusR,
  3916. data: dataR
  3917. } = await tools_httpRequest({
  3918. url: 'https://vk.com/like.php',
  3919. method: 'POST',
  3920. headers: {
  3921. origin: 'https://vk.com',
  3922. referer: `https://vk.com/${name}`,
  3923. 'content-type': 'application/x-www-form-urlencoded'
  3924. },
  3925. data: $.param({
  3926. Message: '',
  3927. act: 'a_do_publish',
  3928. al: 1,
  3929. close_comments: 0,
  3930. friends_only: 0,
  3931. from: 'box',
  3932. hash: hash,
  3933. list: '',
  3934. mark_as_ads: 0,
  3935. mute_notifications: 0,
  3936. object: name,
  3937. ret_data: 1,
  3938. to: 0
  3939. })
  3940. });
  3941. if (resultR === 'Success') {
  3942. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3943. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3944. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3945. 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) {
  3946. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3947. logStatus.success();
  3948. 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);
  3949. 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);
  3950. if (postId && ownerId) {
  3951. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3952. }
  3953. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3954. return true;
  3955. }
  3956. }
  3957. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3958. return false;
  3959. }
  3960. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3961. return false;
  3962. }
  3963. logStatus.error('Error: Get "hash" failed');
  3964. return false;
  3965. }
  3966. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3967. return false;
  3968. }
  3969. logStatus.error(`${result}:${statusText}(${status})`);
  3970. return false;
  3971. } catch (error) {
  3972. throwError(error, 'Vk.sendWall');
  3973. return false;
  3974. }
  3975. }
  3976. async function _deleteWall2(name, dataParams) {
  3977. try {
  3978. const logStatus = scripts_echoLog({
  3979. type: 'deletingVkWall',
  3980. text: name
  3981. });
  3982. const {
  3983. result,
  3984. statusText,
  3985. status,
  3986. data
  3987. } = await tools_httpRequest({
  3988. url: 'https://vk.com/al_wall.php?act=delete',
  3989. method: 'POST',
  3990. headers: {
  3991. origin: 'https://vk.com',
  3992. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3993. 'content-type': 'application/x-www-form-urlencoded'
  3994. },
  3995. data: $.param({
  3996. act: 'delete',
  3997. al: 1,
  3998. confirm: 0,
  3999. from: 'wkview',
  4000. hash: dataParams.wallHash,
  4001. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  4002. })
  4003. });
  4004. if (result === 'Success') {
  4005. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4006. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  4007. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  4008. 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]) {
  4009. logStatus.success();
  4010. return true;
  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(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4016. return false;
  4017. }
  4018. logStatus.error(`${result}:${statusText}(${status})`);
  4019. return false;
  4020. } catch (error) {
  4021. throwError(error, 'Vk.deleteWall');
  4022. return false;
  4023. }
  4024. }
  4025. async function _getId2(name, doTask) {
  4026. try {
  4027. let url = `https://vk.com/${name}`;
  4028. if (/^wall-/.test(name)) {
  4029. if (doTask) {
  4030. return {
  4031. type: 'sendWall'
  4032. };
  4033. }
  4034. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  4035. return {
  4036. type: 'unSupport'
  4037. };
  4038. }
  4039. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  4040. }
  4041. const logStatus = scripts_echoLog({
  4042. type: 'gettingVkId',
  4043. text: name
  4044. });
  4045. const {
  4046. result,
  4047. statusText,
  4048. status,
  4049. data
  4050. } = await tools_httpRequest({
  4051. url: url,
  4052. method: 'GET'
  4053. });
  4054. if (result === 'Success') {
  4055. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4056. var _data$responseText$ma3, _data$responseText$ma4;
  4057. const [ , groupAct, groupId, , groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), (&#39;|')(.*?)(&#39;|')/) || [];
  4058. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4059. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4060. const publicJoined = !data.responseText.includes('Public.subscribe');
  4061. if (groupAct && groupId && groupHash) {
  4062. logStatus.success();
  4063. return {
  4064. groupAct: groupAct,
  4065. groupId: groupId,
  4066. groupHash: groupHash,
  4067. type: 'group'
  4068. };
  4069. } else if (publicHash && publicPid) {
  4070. logStatus.success();
  4071. return {
  4072. publicHash: publicHash,
  4073. publicPid: publicPid,
  4074. publicJoined: publicJoined,
  4075. type: 'public'
  4076. };
  4077. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4078. var _data$responseText$ma5;
  4079. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4080. if (wallHash) {
  4081. logStatus.success();
  4082. return {
  4083. type: 'deleteWall',
  4084. wallHash: wallHash
  4085. };
  4086. }
  4087. } else if (name.includes('wall') && doTask) {
  4088. logStatus.success();
  4089. return {
  4090. type: 'sendWall'
  4091. };
  4092. }
  4093. logStatus.error('Error: Parameters not found!');
  4094. return false;
  4095. }
  4096. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4097. return false;
  4098. }
  4099. logStatus.error(`${result}:${statusText}(${status})`);
  4100. return false;
  4101. } catch (error) {
  4102. throwError(error, 'Vk.getId');
  4103. return false;
  4104. }
  4105. }
  4106. async function _toggleVk2(_ref2) {
  4107. let {
  4108. name,
  4109. doTask = true
  4110. } = _ref2;
  4111. try {
  4112. if (!doTask && this.whiteList.names.includes(name)) {
  4113. scripts_echoLog({
  4114. type: 'whiteList',
  4115. text: 'Vk.undoTask',
  4116. id: name
  4117. });
  4118. return true;
  4119. }
  4120. const formatName = name.replace(/\/$/, '');
  4121. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4122. if (!data) {
  4123. return false;
  4124. }
  4125. switch (data.type) {
  4126. case 'group':
  4127. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4128.  
  4129. case 'public':
  4130. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4131.  
  4132. case 'sendWall':
  4133. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4134.  
  4135. case 'deleteWall':
  4136. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4137.  
  4138. default:
  4139. return false;
  4140. }
  4141. } catch (error) {
  4142. throwError(error, 'Vk.toggleVk');
  4143. return false;
  4144. }
  4145. }
  4146. function Vk_setCache2(name, postId) {
  4147. try {
  4148. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4149. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4150. } catch (error) {
  4151. throwError(error, 'Vk.setCache');
  4152. }
  4153. }
  4154. const social_Vk = Vk;
  4155. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4156. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4157. privateSet.add(obj);
  4158. }
  4159. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4160. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4161. privateMap.set(obj, value);
  4162. }
  4163. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4164. if (privateCollection.has(obj)) {
  4165. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4166. }
  4167. }
  4168. function Youtube_defineProperty(obj, key, value) {
  4169. if (key in obj) {
  4170. Object.defineProperty(obj, key, {
  4171. value: value,
  4172. enumerable: true,
  4173. configurable: true,
  4174. writable: true
  4175. });
  4176. } else {
  4177. obj[key] = value;
  4178. }
  4179. return obj;
  4180. }
  4181. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4182. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4183. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4184. return value;
  4185. }
  4186. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4187. if (descriptor.set) {
  4188. descriptor.set.call(receiver, value);
  4189. } else {
  4190. if (!descriptor.writable) {
  4191. throw new TypeError('attempted to set read only private field');
  4192. }
  4193. descriptor.value = value;
  4194. }
  4195. }
  4196. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4197. if (!privateSet.has(receiver)) {
  4198. throw new TypeError('attempted to get private field on non-instance');
  4199. }
  4200. return fn;
  4201. }
  4202. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4203. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4204. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4205. }
  4206. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4207. if (!privateMap.has(receiver)) {
  4208. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4209. }
  4210. return privateMap.get(receiver);
  4211. }
  4212. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4213. if (descriptor.get) {
  4214. return descriptor.get.call(receiver);
  4215. }
  4216. return descriptor.value;
  4217. }
  4218. const Youtube_defaultTasksTemplate = {
  4219. channels: [],
  4220. likes: []
  4221. };
  4222. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4223. const getInfo = async function(link, type) {
  4224. try {
  4225. const logStatus = scripts_echoLog({
  4226. text: i18n('gettingYtbToken')
  4227. });
  4228. const {
  4229. result,
  4230. statusText,
  4231. status,
  4232. data
  4233. } = await tools_httpRequest({
  4234. url: link,
  4235. method: 'GET'
  4236. });
  4237. if (result === 'Success') {
  4238. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4239. var _data$responseText$ma, _ref;
  4240. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4241. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4242. return {
  4243. needLogin: true
  4244. };
  4245. }
  4246. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4247. 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]) || '{}';
  4248. const {
  4249. client,
  4250. request
  4251. } = JSON.parse(context);
  4252. if (apiKey && client && request) {
  4253. client.hl = 'en';
  4254. if (type === 'channel') {
  4255. var _data$responseText$ma2;
  4256. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4257. if (channelId) {
  4258. logStatus.success();
  4259. return {
  4260. params: {
  4261. apiKey: apiKey,
  4262. client: client,
  4263. request: request,
  4264. channelId: channelId
  4265. }
  4266. };
  4267. }
  4268. logStatus.error('Error: Get "channelId" failed!');
  4269. return {};
  4270. } else if (type === 'likeVideo') {
  4271. var _data$responseText$ma3, _data$responseText$ma4;
  4272. 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];
  4273. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4274. if (videoId) {
  4275. logStatus.success();
  4276. return {
  4277. params: {
  4278. apiKey: apiKey,
  4279. client: client,
  4280. request: request,
  4281. videoId: videoId,
  4282. likeParams: likeParams
  4283. }
  4284. };
  4285. }
  4286. logStatus.error('Error: Get "videoId" failed!');
  4287. return {};
  4288. }
  4289. logStatus.error('Error: Unknown type');
  4290. return {};
  4291. }
  4292. logStatus.error('Error: Parameter "apiKey" not found!');
  4293. return {};
  4294. }
  4295. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4296. return {};
  4297. }
  4298. logStatus.error(`${result}:${statusText}(${status})`);
  4299. return {};
  4300. } catch (error) {
  4301. throwError(error, 'Youtube.getInfo');
  4302. return {};
  4303. }
  4304. };
  4305. var Youtube_auth = new WeakMap();
  4306. var Youtube_initialized = new WeakMap();
  4307. var _verifyChannel = new WeakMap();
  4308. var Youtube_verifyAuth = new WeakSet();
  4309. var Youtube_updateAuth = new WeakSet();
  4310. var _getInfo = new WeakSet();
  4311. var Youtube_toggleChannel = new WeakSet();
  4312. var _toggleLikeVideo = new WeakSet();
  4313. class Youtube extends social_Social {
  4314. constructor() {
  4315. var _GM_getValue;
  4316. super(...arguments);
  4317. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4318. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4319. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4320. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4321. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4322. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4323. Youtube_defineProperty(this, 'whiteList', {
  4324. ...JSON.parse(Youtube_defaultTasks),
  4325. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4326. });
  4327. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4328. writable: true,
  4329. value: GM_getValue('youtubeAuth') || {}
  4330. });
  4331. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4332. writable: true,
  4333. value: false
  4334. });
  4335. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4336. writable: true,
  4337. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4338. });
  4339. }
  4340. async init() {
  4341. try {
  4342. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4343. return true;
  4344. }
  4345. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4346. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4347. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4348. return true;
  4349. }
  4350. return false;
  4351. }
  4352. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4353. if (isVerified) {
  4354. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4355. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4356. return true;
  4357. }
  4358. GM_setValue('youtubeAuth', null);
  4359. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4360. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4361. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4362. return true;
  4363. }
  4364. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4365. return false;
  4366. } catch (error) {
  4367. throwError(error, 'Youtube.init');
  4368. return false;
  4369. }
  4370. }
  4371. async toggle(_ref2) {
  4372. let {
  4373. doTask = true,
  4374. channelLinks = [],
  4375. videoLinks = []
  4376. } = _ref2;
  4377. try {
  4378. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4379. scripts_echoLog({
  4380. text: i18n('needInit')
  4381. });
  4382. return false;
  4383. }
  4384. const prom = [];
  4385. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4386. scripts_echoLog({
  4387. type: 'globalOptionsSkip',
  4388. text: 'youtube.channels'
  4389. });
  4390. } else {
  4391. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4392. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4393. var _link$match;
  4394. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4395. }
  4396. return link;
  4397. });
  4398. if (realChannels.length > 0) {
  4399. for (const channel of realChannels) {
  4400. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4401. link: channel,
  4402. doTask: doTask
  4403. }));
  4404. await delay(1e3);
  4405. }
  4406. }
  4407. }
  4408. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4409. scripts_echoLog({
  4410. type: 'globalOptionsSkip',
  4411. text: 'youtube.likes'
  4412. });
  4413. } else {
  4414. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4415. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4416. var _link$match2;
  4417. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4418. }
  4419. return link;
  4420. });
  4421. if (realLikes.length > 0) {
  4422. for (const video of realLikes) {
  4423. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4424. link: video,
  4425. doTask: doTask
  4426. }));
  4427. await delay(1e3);
  4428. }
  4429. }
  4430. }
  4431. return Promise.all(prom).then(() => true);
  4432. } catch (error) {
  4433. throwError(error, 'Youtube.toggle');
  4434. return false;
  4435. }
  4436. }
  4437. }
  4438. async function Youtube_verifyAuth2() {
  4439. try {
  4440. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4441. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4442. doTask: true,
  4443. verify: true
  4444. });
  4445. } catch (error) {
  4446. throwError(error, 'Youtube.verifyAuth');
  4447. return false;
  4448. }
  4449. }
  4450. async function Youtube_updateAuth2() {
  4451. try {
  4452. const logStatus = scripts_echoLog({
  4453. text: i18n('updatingAuth', 'Youtube')
  4454. });
  4455. return await new Promise(resolve => {
  4456. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4457. active: true,
  4458. insert: true,
  4459. setParent: true
  4460. });
  4461. newTab.onclose = async () => {
  4462. const auth = GM_getValue('youtubeAuth');
  4463. if (auth) {
  4464. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4465. logStatus.success();
  4466. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4467. resolve(result);
  4468. });
  4469. } else {
  4470. logStatus.error('Error: Update youtube auth failed!');
  4471. resolve(false);
  4472. }
  4473. };
  4474. });
  4475. } catch (error) {
  4476. throwError(error, 'Discord.updateAuth');
  4477. return false;
  4478. }
  4479. }
  4480. function _getInfo2(link, type) {
  4481. return getInfo(link, type);
  4482. }
  4483. async function Youtube_toggleChannel2(_ref3) {
  4484. let {
  4485. link,
  4486. doTask = true,
  4487. verify = false
  4488. } = _ref3;
  4489. try {
  4490. const {
  4491. params,
  4492. needLogin
  4493. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4494. const {
  4495. apiKey,
  4496. client,
  4497. request,
  4498. channelId
  4499. } = params || {};
  4500. if (needLogin) {
  4501. scripts_echoLog({
  4502. html: i18n('loginYtb')
  4503. });
  4504. return false;
  4505. }
  4506. if (!(apiKey && client && request && channelId)) {
  4507. scripts_echoLog({
  4508. text: '"getYtbToken" failed'
  4509. });
  4510. return false;
  4511. }
  4512. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4513. scripts_echoLog({
  4514. type: 'whiteList',
  4515. text: 'Youtube.unfollowChannel',
  4516. id: channelId
  4517. });
  4518. return true;
  4519. }
  4520. const logStatus = verify ? scripts_echoLog({
  4521. text: i18n('verifyingAuth', 'Youtube')
  4522. }) : scripts_echoLog({
  4523. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4524. text: channelId
  4525. });
  4526. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4527. const {
  4528. result,
  4529. statusText,
  4530. status,
  4531. data
  4532. } = await tools_httpRequest({
  4533. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4534. method: 'POST',
  4535. headers: {
  4536. origin: 'https://www.youtube.com',
  4537. referer: `https://www.youtube.com/channel/${channelId}`,
  4538. 'content-type': 'application/json',
  4539. 'x-goog-authuser': '0',
  4540. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4541. 'x-origin': 'https://www.youtube.com',
  4542. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4543. },
  4544. data: JSON.stringify({
  4545. context: {
  4546. client: client,
  4547. request: {
  4548. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4549. internalExperimentFlags: [],
  4550. consistencyTokenJars: []
  4551. },
  4552. user: {}
  4553. },
  4554. channelIds: [ channelId ],
  4555. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4556. })
  4557. });
  4558. if (result === 'Success') {
  4559. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4560. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4561. logStatus.success();
  4562. if (doTask && !verify) {
  4563. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4564. }
  4565. return true;
  4566. }
  4567. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4568. logStatus.success();
  4569. return true;
  4570. }
  4571. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4572. return false;
  4573. }
  4574. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4575. return false;
  4576. }
  4577. logStatus.error(`${result}:${statusText}(${status})`);
  4578. return false;
  4579. } catch (error) {
  4580. throwError(error, 'Youtube.toggleChannel');
  4581. return false;
  4582. }
  4583. }
  4584. async function _toggleLikeVideo2(_ref4) {
  4585. let {
  4586. link,
  4587. doTask = true
  4588. } = _ref4;
  4589. try {
  4590. const {
  4591. params,
  4592. needLogin
  4593. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4594. const {
  4595. apiKey,
  4596. client,
  4597. request,
  4598. videoId,
  4599. likeParams
  4600. } = params || {};
  4601. if (needLogin) {
  4602. scripts_echoLog({
  4603. html: `${i18n('loginYtb')}`
  4604. });
  4605. return false;
  4606. }
  4607. if (!(apiKey && client && request && videoId && likeParams)) {
  4608. scripts_echoLog({
  4609. text: '"getYtbToken" failed'
  4610. });
  4611. return false;
  4612. }
  4613. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4614. scripts_echoLog({
  4615. type: 'whiteList',
  4616. text: 'Youtube.unlikeVideo',
  4617. id: videoId
  4618. });
  4619. return true;
  4620. }
  4621. const logStatus = scripts_echoLog({
  4622. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4623. text: videoId
  4624. });
  4625. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4626. const likeVideoData = {
  4627. context: {
  4628. client: client,
  4629. request: {
  4630. sessionId: request.sessionId,
  4631. internalExperimentFlags: [],
  4632. consistencyTokenJars: []
  4633. },
  4634. user: {}
  4635. },
  4636. target: {
  4637. videoId: videoId
  4638. }
  4639. };
  4640. if (doTask) {
  4641. if (likeParams) {
  4642. likeVideoData.params = likeParams;
  4643. } else {
  4644. logStatus.error('Empty likeParams');
  4645. return false;
  4646. }
  4647. }
  4648. const {
  4649. result,
  4650. statusText,
  4651. status,
  4652. data
  4653. } = await tools_httpRequest({
  4654. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4655. method: 'POST',
  4656. headers: {
  4657. origin: 'https://www.youtube.com',
  4658. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4659. 'content-type': 'application/json',
  4660. 'x-goog-authuser': '0',
  4661. 'x-goog-visitor-id': client.visitorData,
  4662. 'x-origin': 'https://www.youtube.com',
  4663. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4664. },
  4665. data: JSON.stringify(likeVideoData)
  4666. });
  4667. if (result === 'Success') {
  4668. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4669. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4670. logStatus.success();
  4671. if (doTask) {
  4672. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4673. }
  4674. return true;
  4675. }
  4676. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4677. return false;
  4678. }
  4679. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4680. return false;
  4681. }
  4682. logStatus.error(`${result}:${statusText}(${status})`);
  4683. return false;
  4684. } catch (error) {
  4685. throwError(error, 'Youtube.toggleLikeVideo');
  4686. return false;
  4687. }
  4688. }
  4689. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4690. Steam_checkPrivateRedeclaration(obj, privateSet);
  4691. privateSet.add(obj);
  4692. }
  4693. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4694. Steam_checkPrivateRedeclaration(obj, privateMap);
  4695. privateMap.set(obj, value);
  4696. }
  4697. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4698. if (privateCollection.has(obj)) {
  4699. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4700. }
  4701. }
  4702. function Steam_defineProperty(obj, key, value) {
  4703. if (key in obj) {
  4704. Object.defineProperty(obj, key, {
  4705. value: value,
  4706. enumerable: true,
  4707. configurable: true,
  4708. writable: true
  4709. });
  4710. } else {
  4711. obj[key] = value;
  4712. }
  4713. return obj;
  4714. }
  4715. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4716. if (!privateSet.has(receiver)) {
  4717. throw new TypeError('attempted to get private field on non-instance');
  4718. }
  4719. return fn;
  4720. }
  4721. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4722. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4723. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4724. return value;
  4725. }
  4726. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4727. if (descriptor.set) {
  4728. descriptor.set.call(receiver, value);
  4729. } else {
  4730. if (!descriptor.writable) {
  4731. throw new TypeError('attempted to set read only private field');
  4732. }
  4733. descriptor.value = value;
  4734. }
  4735. }
  4736. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4737. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4738. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4739. }
  4740. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4741. if (!privateMap.has(receiver)) {
  4742. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4743. }
  4744. return privateMap.get(receiver);
  4745. }
  4746. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4747. if (descriptor.get) {
  4748. return descriptor.get.call(receiver);
  4749. }
  4750. return descriptor.value;
  4751. }
  4752. const Steam_defaultTasksTemplate = {
  4753. groups: [],
  4754. officialGroups: [],
  4755. wishlists: [],
  4756. follows: [],
  4757. forums: [],
  4758. workshops: [],
  4759. workshopVotes: [],
  4760. curators: [],
  4761. curatorLikes: [],
  4762. announcements: [],
  4763. licenses: [],
  4764. playtests: []
  4765. };
  4766. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4767. var Steam_cache = new WeakMap();
  4768. var Steam_auth = new WeakMap();
  4769. var _storeInitialized = new WeakMap();
  4770. var _communityInitialized = new WeakMap();
  4771. var _area = new WeakMap();
  4772. var _areaStatus = new WeakMap();
  4773. var _updateStoreAuth = new WeakSet();
  4774. var _updateCommunityAuth = new WeakSet();
  4775. var _getAreaInfo = new WeakSet();
  4776. var _changeArea = new WeakSet();
  4777. var _joinGroup = new WeakSet();
  4778. var _leaveGroup = new WeakSet();
  4779. var _getGroupId = new WeakSet();
  4780. var _joinOfficialGroup = new WeakSet();
  4781. var _leaveOfficialGroup = new WeakSet();
  4782. var _getOfficialGroupId = new WeakSet();
  4783. var _addToWishlist = new WeakSet();
  4784. var _removeFromWishlist = new WeakSet();
  4785. var _toggleFollowGame = new WeakSet();
  4786. var _isFollowedGame = new WeakSet();
  4787. var _toggleForum = new WeakSet();
  4788. var _getForumId = new WeakSet();
  4789. var _toggleFavoriteWorkshop = new WeakSet();
  4790. var _getWorkshopAppId = new WeakSet();
  4791. var _voteUpWorkshop = new WeakSet();
  4792. var _toggleCurator = new WeakSet();
  4793. var _toggleCuratorLike = new WeakSet();
  4794. var _getAnnouncementParams = new WeakSet();
  4795. var _likeAnnouncement = new WeakSet();
  4796. var _appid2subid = new WeakSet();
  4797. var _getLicenses = new WeakSet();
  4798. var _addLicense = new WeakSet();
  4799. var _addFreeLicense = new WeakSet();
  4800. var _requestPlayTestAccess = new WeakSet();
  4801. var Steam_setCache = new WeakSet();
  4802. class Steam extends social_Social {
  4803. constructor() {
  4804. var _GM_getValue;
  4805. super(...arguments);
  4806. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4807. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4808. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4809. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4810. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4811. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4812. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4813. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4814. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4815. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4816. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4817. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4818. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4819. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4820. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4821. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4822. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4823. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4824. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4825. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4826. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4827. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4828. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4829. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4830. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4831. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4832. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4833. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4834. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4835. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4836. Steam_defineProperty(this, 'whiteList', {
  4837. ...JSON.parse(Steam_defaultTasks),
  4838. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4839. });
  4840. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4841. writable: true,
  4842. value: {
  4843. ...{
  4844. group: {},
  4845. officialGroup: {},
  4846. forum: {},
  4847. workshop: {},
  4848. curator: {}
  4849. },
  4850. ...GM_getValue('steamCache')
  4851. }
  4852. });
  4853. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4854. writable: true,
  4855. value: {}
  4856. });
  4857. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4858. writable: true,
  4859. value: false
  4860. });
  4861. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4862. writable: true,
  4863. value: false
  4864. });
  4865. Steam_classPrivateFieldInitSpec(this, _area, {
  4866. writable: true,
  4867. value: 'CN'
  4868. });
  4869. Steam_classPrivateFieldInitSpec(this, _areaStatus, {
  4870. writable: true,
  4871. value: 'end'
  4872. });
  4873. }
  4874. async init() {
  4875. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4876. try {
  4877. if (type === 'store') {
  4878. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4879. return true;
  4880. }
  4881. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4882. if (!Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4883. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4884. return false;
  4885. }
  4886. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4887. return true;
  4888. }
  4889. if (type === 'community') {
  4890. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4891. return true;
  4892. }
  4893. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4894. if (!Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4895. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4896. return false;
  4897. }
  4898. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4899. return true;
  4900. }
  4901. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4902. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4903. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4904. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4905. return true;
  4906. }
  4907. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4908. return false;
  4909. } catch (error) {
  4910. throwError(error, 'Steam.init');
  4911. return false;
  4912. }
  4913. }
  4914. async getCuratorId(path, name) {
  4915. try {
  4916. const logStatus = scripts_echoLog({
  4917. type: 'gettingCuratorId',
  4918. text: `${path}/${name}`
  4919. });
  4920. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4921. if (curatorId) {
  4922. logStatus.success();
  4923. return curatorId;
  4924. }
  4925. const {
  4926. result,
  4927. statusText,
  4928. status,
  4929. data
  4930. } = await tools_httpRequest({
  4931. url: `https://store.steampowered.com/${path}/${name}`,
  4932. method: 'GET',
  4933. headers: {
  4934. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4935. }
  4936. });
  4937. if (result === 'Success') {
  4938. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4939. var _data$responseText$ma;
  4940. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4941. if (curatorId) {
  4942. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4943. logStatus.success();
  4944. return curatorId;
  4945. }
  4946. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4947. return false;
  4948. }
  4949. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4950. return false;
  4951. }
  4952. logStatus.error(`${result}:${statusText}(${status})`);
  4953. return false;
  4954. } catch (error) {
  4955. throwError(error, 'Steam.getCuratorID');
  4956. return false;
  4957. }
  4958. }
  4959. async toggle(_ref) {
  4960. let {
  4961. doTask = true,
  4962. groupLinks = [],
  4963. officialGroupLinks = [],
  4964. wishlistLinks = [],
  4965. followLinks = [],
  4966. forumLinks = [],
  4967. workshopLinks = [],
  4968. workshopVoteLinks = [],
  4969. curatorLinks = [],
  4970. curatorLikeLinks = [],
  4971. announcementLinks = [],
  4972. licenseLinks = [],
  4973. playtestLinks = []
  4974. } = _ref;
  4975. try {
  4976. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4977. scripts_echoLog({
  4978. text: i18n('needInit')
  4979. });
  4980. return false;
  4981. }
  4982. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4983. scripts_echoLog({
  4984. text: i18n('needInit')
  4985. });
  4986. return false;
  4987. }
  4988. const prom = [];
  4989. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4990. scripts_echoLog({
  4991. type: 'globalOptionsSkip',
  4992. text: 'steam.groups'
  4993. });
  4994. } else {
  4995. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4996. var _link$match;
  4997. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4998. });
  4999. if (realGroups.length > 0) {
  5000. for (const group of realGroups) {
  5001. if (doTask) {
  5002. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  5003. } else {
  5004. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  5005. }
  5006. await delay(1e3);
  5007. }
  5008. }
  5009. }
  5010. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  5011. scripts_echoLog({
  5012. type: 'globalOptionsSkip',
  5013. text: 'steam.officialGroups'
  5014. });
  5015. } else {
  5016. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  5017. var _link$match2;
  5018. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  5019. });
  5020. if (realOfficialGroups.length > 0) {
  5021. for (const officialGroup of realOfficialGroups) {
  5022. if (doTask) {
  5023. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  5024. } else {
  5025. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  5026. }
  5027. await delay(1e3);
  5028. }
  5029. }
  5030. }
  5031. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  5032. scripts_echoLog({
  5033. type: 'globalOptionsSkip',
  5034. text: 'steam.wishlists'
  5035. });
  5036. } else {
  5037. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  5038. var _link$match3;
  5039. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5040. });
  5041. if (realWishlists.length > 0) {
  5042. for (const game of realWishlists) {
  5043. if (doTask) {
  5044. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  5045. } else {
  5046. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  5047. }
  5048. await delay(1e3);
  5049. }
  5050. }
  5051. }
  5052. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5053. scripts_echoLog({
  5054. type: 'globalOptionsSkip',
  5055. text: 'steam.follows'
  5056. });
  5057. } else {
  5058. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5059. var _link$match4;
  5060. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5061. });
  5062. if (realFollows.length > 0) {
  5063. for (const game of realFollows) {
  5064. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  5065. await delay(1e3);
  5066. }
  5067. }
  5068. }
  5069. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5070. scripts_echoLog({
  5071. type: 'globalOptionsSkip',
  5072. text: 'steam.forums'
  5073. });
  5074. } else {
  5075. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5076. var _link$match5;
  5077. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5078. });
  5079. if (realForums.length > 0) {
  5080. for (const forum of realForums) {
  5081. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5082. await delay(1e3);
  5083. }
  5084. }
  5085. }
  5086. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5087. scripts_echoLog({
  5088. type: 'globalOptionsSkip',
  5089. text: 'steam.workshops'
  5090. });
  5091. } else {
  5092. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5093. var _link$match6;
  5094. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5095. });
  5096. if (realWorkshops.length > 0) {
  5097. for (const workshop of realWorkshops) {
  5098. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5099. await delay(1e3);
  5100. }
  5101. }
  5102. }
  5103. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5104. scripts_echoLog({
  5105. type: 'globalOptionsSkip',
  5106. text: 'steam.workshopVotes'
  5107. });
  5108. } else {
  5109. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5110. var _link$match7;
  5111. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5112. });
  5113. if (doTask && realworkshopVotes.length > 0) {
  5114. for (const workshop of realworkshopVotes) {
  5115. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5116. await delay(1e3);
  5117. }
  5118. }
  5119. }
  5120. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5121. scripts_echoLog({
  5122. type: 'globalOptionsSkip',
  5123. text: 'steam.curators'
  5124. });
  5125. } else {
  5126. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5127. var _link$match8;
  5128. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5129. });
  5130. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5131. var _link$match9;
  5132. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5133. });
  5134. if (realCurators.length > 0) {
  5135. for (const curator of realCurators) {
  5136. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5137. await delay(1e3);
  5138. }
  5139. }
  5140. if (realCuratorLikes.length > 0) {
  5141. for (const curatorLike of realCuratorLikes) {
  5142. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5143. await delay(1e3);
  5144. }
  5145. }
  5146. }
  5147. if (doTask && !globalOptions.doTask.steam.announcements) {
  5148. scripts_echoLog({
  5149. type: 'globalOptionsSkip',
  5150. text: 'steam.announcements'
  5151. });
  5152. } else {
  5153. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5154. var _link$match11;
  5155. if (link.includes('store.steampowered.com')) {
  5156. var _link$match10;
  5157. return (_link$match10 = link.match(/store\.steampowered\.com\/news\/app\/([\d]+)\/view\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10.slice(1, 3).join('/');
  5158. }
  5159. return (_link$match11 = link.match(/steamcommunity\.com\/games\/([\d]+)\/announcements\/detail\/([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11.slice(1, 3).join('/');
  5160. });
  5161. if (doTask && realAnnouncements.length > 0) {
  5162. for (const id of realAnnouncements) {
  5163. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5164. await delay(1e3);
  5165. }
  5166. }
  5167. }
  5168. if (doTask && !globalOptions.doTask.steam.licenses) {
  5169. scripts_echoLog({
  5170. type: 'globalOptionsSkip',
  5171. text: 'steam.licenses'
  5172. });
  5173. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5174. for (const id of licenseLinks) {
  5175. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5176. await delay(1e3);
  5177. }
  5178. }
  5179. if (doTask && !globalOptions.doTask.steam.playtests) {
  5180. scripts_echoLog({
  5181. type: 'globalOptionsSkip',
  5182. text: 'steam.playtests'
  5183. });
  5184. } else {
  5185. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5186. var _link$match12;
  5187. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5188. });
  5189. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5190. for (const id of realPlaytests) {
  5191. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5192. await delay(1e3);
  5193. }
  5194. }
  5195. }
  5196. return Promise.all(prom).then(async () => {
  5197. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5198. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5199. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5200. }
  5201. return true;
  5202. });
  5203. } catch (error) {
  5204. throwError(error, 'Steam.toggle');
  5205. return false;
  5206. }
  5207. }
  5208. }
  5209. async function _updateStoreAuth2() {
  5210. try {
  5211. const logStatus = scripts_echoLog({
  5212. text: i18n('updatingAuth', i18n('steamStore'))
  5213. });
  5214. const {
  5215. result,
  5216. statusText,
  5217. status,
  5218. data
  5219. } = await tools_httpRequest({
  5220. url: 'https://store.steampowered.com/stats/',
  5221. method: 'GET'
  5222. });
  5223. if (result === 'Success') {
  5224. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5225. var _data$responseText$ma2;
  5226. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5227. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5228. return false;
  5229. }
  5230. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5231. if (storeSessionID) {
  5232. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5233. logStatus.success();
  5234. return true;
  5235. }
  5236. logStatus.error('Error: Get "sessionID" failed');
  5237. return false;
  5238. }
  5239. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5240. return false;
  5241. }
  5242. logStatus.error(`${result}:${statusText}(${status})`);
  5243. return false;
  5244. } catch (error) {
  5245. throwError(error, 'Steam.updateStoreAuth');
  5246. return false;
  5247. }
  5248. }
  5249. async function _updateCommunityAuth2() {
  5250. try {
  5251. const logStatus = scripts_echoLog({
  5252. text: i18n('updatingAuth', i18n('steamCommunity'))
  5253. });
  5254. const {
  5255. result,
  5256. statusText,
  5257. status,
  5258. data
  5259. } = await tools_httpRequest({
  5260. url: 'https://steamcommunity.com/my',
  5261. method: 'GET'
  5262. });
  5263. if (result === 'Success') {
  5264. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5265. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5266. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5267. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5268. return false;
  5269. }
  5270. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5271. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5272. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5273. if (steam64Id) {
  5274. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5275. }
  5276. if (userName) {
  5277. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5278. }
  5279. if (communitySessionID) {
  5280. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5281. logStatus.success();
  5282. return true;
  5283. }
  5284. logStatus.error('Error: Get "sessionID" failed');
  5285. return false;
  5286. }
  5287. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5288. return false;
  5289. }
  5290. logStatus.error(`${result}:${statusText}(${status})`);
  5291. return false;
  5292. } catch (error) {
  5293. throwError(error, 'Steam.updateCommunityAuth');
  5294. return false;
  5295. }
  5296. }
  5297. async function _getAreaInfo2() {
  5298. try {
  5299. const logStatus = scripts_echoLog({
  5300. text: i18n('gettingAreaInfo')
  5301. });
  5302. const {
  5303. result,
  5304. statusText,
  5305. status,
  5306. data
  5307. } = await tools_httpRequest({
  5308. url: 'https://store.steampowered.com/cart/',
  5309. method: 'GET'
  5310. });
  5311. if (result === 'Success') {
  5312. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5313. var _data$responseText$ma6;
  5314. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5315. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5316. if (currentArea && areas.length > 0) {
  5317. Steam_classPrivateFieldSet(this, _area, currentArea);
  5318. logStatus.success();
  5319. return {
  5320. currentArea: currentArea,
  5321. areas: areas
  5322. };
  5323. }
  5324. logStatus.error('Error: get country info filed');
  5325. return {};
  5326. }
  5327. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5328. return {};
  5329. }
  5330. logStatus.error(`${result}:${statusText}(${status})`);
  5331. return {};
  5332. } catch (error) {
  5333. throwError(error, 'Steam.getAreaInfo');
  5334. return {};
  5335. }
  5336. }
  5337. async function _changeArea2(area) {
  5338. try {
  5339. if (Steam_classPrivateFieldGet(this, _areaStatus) === 'waiting') {
  5340. await new Promise(resolve => {
  5341. const checker = setInterval(() => {
  5342. if (Steam_classPrivateFieldGet(this, _areaStatus) !== 'waiting') {
  5343. clearInterval(checker);
  5344. resolve(true);
  5345. }
  5346. });
  5347. });
  5348. }
  5349. if (Steam_classPrivateFieldGet(this, _area) === area || !area && Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5350. return true;
  5351. }
  5352. Steam_classPrivateFieldSet(this, _areaStatus, 'waiting');
  5353. let aimedArea = area;
  5354. if (!aimedArea) {
  5355. const {
  5356. currentArea,
  5357. areas
  5358. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5359. if (!currentArea || !areas) {
  5360. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5361. return false;
  5362. }
  5363. if (currentArea !== 'CN') {
  5364. Steam_classPrivateFieldSet(this, _areaStatus, 'skip');
  5365. scripts_echoLog({
  5366. text: 'notNeededChangeArea'
  5367. });
  5368. return 'skip';
  5369. }
  5370. const anotherArea = areas.filter(area => area && area !== 'CN');
  5371. if (!anotherArea || anotherArea.length === 0) {
  5372. Steam_classPrivateFieldSet(this, _areaStatus, 'noAnotherArea');
  5373. scripts_echoLog({
  5374. text: 'noAnotherArea'
  5375. });
  5376. return false;
  5377. }
  5378. [ aimedArea ] = anotherArea;
  5379. }
  5380. const logStatus = scripts_echoLog({
  5381. text: i18n('changingArea', aimedArea)
  5382. });
  5383. const {
  5384. result,
  5385. statusText,
  5386. status,
  5387. data
  5388. } = await tools_httpRequest({
  5389. url: 'https://store.steampowered.com/account/setcountry',
  5390. method: 'POST',
  5391. headers: {
  5392. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5393. },
  5394. data: $.param({
  5395. cc: aimedArea,
  5396. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5397. })
  5398. });
  5399. if (result === 'Success') {
  5400. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5401. const {
  5402. currentArea
  5403. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5404. if (currentArea === aimedArea) {
  5405. Steam_classPrivateFieldSet(this, _areaStatus, 'success');
  5406. logStatus.success();
  5407. return currentArea;
  5408. }
  5409. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5410. logStatus.error('Error: change country filed');
  5411. return 'CN';
  5412. }
  5413. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5414. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5415. return 'CN';
  5416. }
  5417. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5418. logStatus.error(`${result}:${statusText}(${status})`);
  5419. return 'CN';
  5420. } catch (error) {
  5421. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5422. throwError(error, 'Steam.changeArea');
  5423. return false;
  5424. }
  5425. }
  5426. async function _joinGroup2(groupName) {
  5427. try {
  5428. const logStatus = scripts_echoLog({
  5429. type: 'joiningSteamGroup',
  5430. text: groupName
  5431. });
  5432. const {
  5433. result,
  5434. statusText,
  5435. status,
  5436. data
  5437. } = await tools_httpRequest({
  5438. url: `https://steamcommunity.com/groups/${groupName}`,
  5439. method: 'POST',
  5440. headers: {
  5441. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5442. },
  5443. data: $.param({
  5444. action: 'join',
  5445. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5446. })
  5447. });
  5448. if (result === 'Success') {
  5449. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5450. logStatus.success();
  5451. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5452. return true;
  5453. }
  5454. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5455. return false;
  5456. }
  5457. logStatus.error(`${result}:${statusText}(${status})`);
  5458. return false;
  5459. } catch (error) {
  5460. throwError(error, 'Steam.joinGroup');
  5461. return false;
  5462. }
  5463. }
  5464. async function _leaveGroup2(groupName) {
  5465. try {
  5466. if (this.whiteList.groups.includes(groupName)) {
  5467. scripts_echoLog({
  5468. type: 'whiteList',
  5469. text: 'Steam.leaveGroup',
  5470. id: groupName
  5471. });
  5472. return true;
  5473. }
  5474. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5475. if (!groupId) {
  5476. return false;
  5477. }
  5478. const logStatus = scripts_echoLog({
  5479. type: 'leavingSteamGroup',
  5480. text: groupName
  5481. });
  5482. const {
  5483. result,
  5484. statusText,
  5485. status,
  5486. data
  5487. } = await tools_httpRequest({
  5488. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5489. method: 'POST',
  5490. headers: {
  5491. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5492. },
  5493. data: $.param({
  5494. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5495. action: 'leaveGroup',
  5496. groupId: groupId
  5497. })
  5498. });
  5499. if (result === 'Success') {
  5500. 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) {
  5501. logStatus.success();
  5502. return true;
  5503. }
  5504. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5505. return false;
  5506. }
  5507. logStatus.error(`${result}:${statusText}(${status})`);
  5508. return false;
  5509. } catch (error) {
  5510. throwError(error, 'Steam.leaveGroup');
  5511. return false;
  5512. }
  5513. }
  5514. async function _getGroupId2(groupName) {
  5515. try {
  5516. const logStatus = scripts_echoLog({
  5517. type: 'gettingSteamGroupId',
  5518. text: groupName
  5519. });
  5520. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5521. if (groupId) {
  5522. logStatus.success();
  5523. return groupId;
  5524. }
  5525. const {
  5526. result,
  5527. statusText,
  5528. status,
  5529. data
  5530. } = await tools_httpRequest({
  5531. url: `https://steamcommunity.com/groups/${groupName}`,
  5532. method: 'GET',
  5533. headers: {
  5534. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5535. }
  5536. });
  5537. if (result === 'Success') {
  5538. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5539. var _data$responseText$ma7;
  5540. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5541. if (groupId) {
  5542. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5543. logStatus.success();
  5544. return groupId;
  5545. }
  5546. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5547. return false;
  5548. }
  5549. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5550. return false;
  5551. }
  5552. logStatus.error(`${result}:${statusText}(${status})`);
  5553. return false;
  5554. } catch (error) {
  5555. throwError(error, 'Steam.getGroupID');
  5556. return false;
  5557. }
  5558. }
  5559. async function _joinOfficialGroup2(gameId) {
  5560. try {
  5561. const logStatus = scripts_echoLog({
  5562. type: 'joiningSteamOfficialGroup',
  5563. text: gameId
  5564. });
  5565. const {
  5566. result,
  5567. statusText,
  5568. status,
  5569. data
  5570. } = await tools_httpRequest({
  5571. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5572. method: 'GET',
  5573. headers: {
  5574. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5575. }
  5576. });
  5577. if (result === 'Success') {
  5578. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5579. var _data$responseText$ma8;
  5580. logStatus.success();
  5581. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5582. const groupId = (_data$responseText$ma8 = data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)) === null || _data$responseText$ma8 === void 0 ? void 0 : _data$responseText$ma8[1];
  5583. if (groupId) {
  5584. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5585. }
  5586. return true;
  5587. }
  5588. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5589. return false;
  5590. }
  5591. logStatus.error(`${result}:${statusText}(${status})`);
  5592. return false;
  5593. } catch (error) {
  5594. throwError(error, 'Steam.joinOfficialGroup');
  5595. return false;
  5596. }
  5597. }
  5598. async function _leaveOfficialGroup2(gameId) {
  5599. try {
  5600. if (this.whiteList.officialGroups.includes(gameId)) {
  5601. scripts_echoLog({
  5602. type: 'whiteList',
  5603. text: 'Steam.leaveOfficialGroup',
  5604. id: gameId
  5605. });
  5606. return true;
  5607. }
  5608. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5609. if (!groupId) {
  5610. return false;
  5611. }
  5612. const logStatus = scripts_echoLog({
  5613. type: 'leavingSteamOfficialGroup',
  5614. text: gameId
  5615. });
  5616. const {
  5617. result,
  5618. statusText,
  5619. status,
  5620. data
  5621. } = await tools_httpRequest({
  5622. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5623. method: 'POST',
  5624. headers: {
  5625. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5626. },
  5627. data: $.param({
  5628. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5629. action: 'leaveGroup',
  5630. groupId: groupId
  5631. })
  5632. });
  5633. if (result === 'Success') {
  5634. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5635. const {
  5636. result: resultR,
  5637. statusText: statusTextR,
  5638. status: statusR,
  5639. data: dataR
  5640. } = await tools_httpRequest({
  5641. url: `https://steamcommunity.com/games/${gameId}`,
  5642. method: 'GET',
  5643. headers: {
  5644. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5645. }
  5646. });
  5647. if (resultR === 'Success') {
  5648. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5649. logStatus.success();
  5650. return true;
  5651. }
  5652. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5653. return false;
  5654. }
  5655. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5656. return false;
  5657. }
  5658. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5659. return false;
  5660. }
  5661. logStatus.error(`${result}:${statusText}(${status})`);
  5662. return false;
  5663. } catch (error) {
  5664. throwError(error, 'Steam.leaveOfficialGroup');
  5665. return false;
  5666. }
  5667. }
  5668. async function _getOfficialGroupId2(gameId) {
  5669. try {
  5670. const logStatus = scripts_echoLog({
  5671. type: 'gettingSteamOfficialGroupId',
  5672. text: gameId
  5673. });
  5674. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5675. if (groupId) {
  5676. logStatus.success();
  5677. return groupId;
  5678. }
  5679. const {
  5680. result,
  5681. statusText,
  5682. status,
  5683. data
  5684. } = await tools_httpRequest({
  5685. url: `https://steamcommunity.com/games/${gameId}`,
  5686. method: 'GET',
  5687. headers: {
  5688. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5689. }
  5690. });
  5691. if (result === 'Success') {
  5692. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5693. var _data$responseText$ma9;
  5694. const groupId = (_data$responseText$ma9 = data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)) === null || _data$responseText$ma9 === void 0 ? void 0 : _data$responseText$ma9[1];
  5695. if (groupId) {
  5696. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5697. logStatus.success();
  5698. return groupId;
  5699. }
  5700. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5701. return false;
  5702. }
  5703. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5704. return false;
  5705. }
  5706. logStatus.error(`${result}:${statusText}(${status})`);
  5707. return false;
  5708. } catch (error) {
  5709. throwError(error, 'Steam.getGroupID');
  5710. return false;
  5711. }
  5712. }
  5713. async function _addToWishlist2(gameId) {
  5714. try {
  5715. var _data$response;
  5716. const logStatus = scripts_echoLog({
  5717. type: 'addingToWishlist',
  5718. text: gameId
  5719. });
  5720. const {
  5721. result,
  5722. data
  5723. } = await tools_httpRequest({
  5724. url: 'https://store.steampowered.com/api/addtowishlist',
  5725. method: 'POST',
  5726. headers: {
  5727. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5728. },
  5729. data: $.param({
  5730. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5731. appid: gameId
  5732. }),
  5733. dataType: 'json'
  5734. });
  5735. 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) {
  5736. logStatus.success();
  5737. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5738. return true;
  5739. }
  5740. const {
  5741. result: resultR,
  5742. statusText: statusTextR,
  5743. status: statusR,
  5744. data: dataR
  5745. } = await tools_httpRequest({
  5746. url: `https://store.steampowered.com/app/${gameId}`,
  5747. method: 'GET'
  5748. });
  5749. if (resultR === 'Success') {
  5750. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5751. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5752. logStatus.warning(i18n('changeAreaNotice'));
  5753. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5754. return false;
  5755. }
  5756. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5757. }
  5758. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5759. logStatus.success();
  5760. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5761. return true;
  5762. } 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"')) {
  5763. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5764. return false;
  5765. }
  5766. logStatus.success();
  5767. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5768. return true;
  5769. }
  5770. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5771. return false;
  5772. }
  5773. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5774. return false;
  5775. } catch (error) {
  5776. throwError(error, 'Steam.addToWishlist');
  5777. return false;
  5778. }
  5779. }
  5780. async function _removeFromWishlist2(gameId) {
  5781. try {
  5782. var _data$response2;
  5783. if (this.whiteList.wishlists.includes(gameId)) {
  5784. scripts_echoLog({
  5785. type: 'whiteList',
  5786. text: 'Steam.removeFromWishlist',
  5787. id: gameId
  5788. });
  5789. return true;
  5790. }
  5791. const logStatus = scripts_echoLog({
  5792. type: 'removingFromWishlist',
  5793. text: gameId
  5794. });
  5795. const {
  5796. result,
  5797. data
  5798. } = await tools_httpRequest({
  5799. url: 'https://store.steampowered.com/api/removefromwishlist',
  5800. method: 'POST',
  5801. headers: {
  5802. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5803. },
  5804. data: $.param({
  5805. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5806. appid: gameId
  5807. }),
  5808. dataType: 'json'
  5809. });
  5810. 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) {
  5811. logStatus.success();
  5812. return true;
  5813. }
  5814. const {
  5815. result: resultR,
  5816. statusText: statusTextR,
  5817. status: statusR,
  5818. data: dataR
  5819. } = await tools_httpRequest({
  5820. url: `https://store.steampowered.com/app/${gameId}`,
  5821. method: 'GET'
  5822. });
  5823. if (resultR === 'Success') {
  5824. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5825. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5826. logStatus.warning(i18n('changeAreaNotice'));
  5827. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5828. if (!result || result === 'CN' || result === 'skip') {
  5829. return false;
  5830. }
  5831. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5832. }
  5833. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5834. logStatus.success();
  5835. return true;
  5836. }
  5837. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5838. return false;
  5839. }
  5840. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5841. return false;
  5842. }
  5843. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5844. return false;
  5845. } catch (error) {
  5846. throwError(error, 'Steam.removeFromWishlist');
  5847. return false;
  5848. }
  5849. }
  5850. async function _toggleFollowGame2(gameId, doTask) {
  5851. try {
  5852. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5853. scripts_echoLog({
  5854. type: 'whiteList',
  5855. text: 'Steam.unfollowGame',
  5856. id: gameId
  5857. });
  5858. return true;
  5859. }
  5860. const logStatus = scripts_echoLog({
  5861. type: `${doTask ? '' : 'un'}followingGame`,
  5862. text: gameId
  5863. });
  5864. const requestData = {
  5865. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5866. appid: gameId
  5867. };
  5868. if (!doTask) {
  5869. requestData.unfollow = '1';
  5870. }
  5871. const {
  5872. result,
  5873. data
  5874. } = await tools_httpRequest({
  5875. url: 'https://store.steampowered.com/explore/followgame/',
  5876. method: 'POST',
  5877. headers: {
  5878. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5879. },
  5880. data: $.param(requestData)
  5881. });
  5882. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5883. logStatus.success();
  5884. return true;
  5885. }
  5886. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5887. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5888. logStatus.warning(i18n('changeAreaNotice'));
  5889. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5890. return false;
  5891. }
  5892. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5893. }
  5894. if (doTask === followed) {
  5895. logStatus.success();
  5896. if (doTask) {
  5897. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5898. }
  5899. return true;
  5900. }
  5901. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5902. return false;
  5903. } catch (error) {
  5904. throwError(error, 'Steam.toggleFollowGame');
  5905. return false;
  5906. }
  5907. }
  5908. async function _isFollowedGame2(gameId) {
  5909. try {
  5910. const {
  5911. result,
  5912. data
  5913. } = await tools_httpRequest({
  5914. url: `https://store.steampowered.com/app/${gameId}`,
  5915. method: 'GET'
  5916. });
  5917. if (result === 'Success') {
  5918. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5919. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5920. return 'areaLocked';
  5921. }
  5922. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5923. return true;
  5924. }
  5925. return false;
  5926. }
  5927. return false;
  5928. }
  5929. return false;
  5930. } catch (error) {
  5931. throwError(error, 'Steam.isFollowedGame');
  5932. return false;
  5933. }
  5934. }
  5935. async function _toggleForum2(gameId) {
  5936. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5937. try {
  5938. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5939. scripts_echoLog({
  5940. type: 'whiteList',
  5941. text: 'Steam.unsubscribeForum',
  5942. id: gameId
  5943. });
  5944. return true;
  5945. }
  5946. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5947. if (!forumId) {
  5948. return false;
  5949. }
  5950. const logStatus = scripts_echoLog({
  5951. type: `${doTask ? '' : 'un'}subscribingForum`,
  5952. text: gameId
  5953. });
  5954. const [ id, feature ] = forumId.split('_');
  5955. const {
  5956. result,
  5957. statusText,
  5958. status,
  5959. data
  5960. } = await tools_httpRequest({
  5961. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5962. method: 'POST',
  5963. responseType: 'json',
  5964. headers: {
  5965. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5966. },
  5967. data: $.param({
  5968. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5969. })
  5970. });
  5971. if (result === 'Success') {
  5972. var _data$response3, _data$response4;
  5973. 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)) {
  5974. if (doTask) {
  5975. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5976. }
  5977. logStatus.success();
  5978. return true;
  5979. }
  5980. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5981. return true;
  5982. }
  5983. logStatus.error(`${result}:${statusText}(${status})`);
  5984. return true;
  5985. } catch (error) {
  5986. throwError(error, 'Steam.toggleForum');
  5987. return true;
  5988. }
  5989. }
  5990. async function _getForumId2(gameId) {
  5991. try {
  5992. const logStatus = scripts_echoLog({
  5993. type: 'gettingForumId',
  5994. text: gameId
  5995. });
  5996. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5997. if (forumId) {
  5998. logStatus.success();
  5999. return forumId;
  6000. }
  6001. const {
  6002. result,
  6003. statusText,
  6004. status,
  6005. data
  6006. } = await tools_httpRequest({
  6007. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  6008. method: 'GET'
  6009. });
  6010. if (result === 'Success') {
  6011. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6012. var _data$responseText, _data$responseText$ma10;
  6013. const forumId = (_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : (_data$responseText$ma10 = _data$responseText.match(/General_([\d]+(_[\d]+)?)/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  6014. if (forumId) {
  6015. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  6016. logStatus.success();
  6017. return forumId;
  6018. }
  6019. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6020. return false;
  6021. }
  6022. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6023. return false;
  6024. }
  6025. logStatus.error(`${result}:${statusText}(${status})`);
  6026. return false;
  6027. } catch (error) {
  6028. throwError(error, 'Steam.getForumId');
  6029. return false;
  6030. }
  6031. }
  6032. async function _toggleFavoriteWorkshop2(id) {
  6033. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6034. try {
  6035. if (!doTask && this.whiteList.workshops.includes(id)) {
  6036. scripts_echoLog({
  6037. type: 'whiteList',
  6038. text: 'Steam.unfavoriteWorkshop',
  6039. id: id
  6040. });
  6041. return true;
  6042. }
  6043. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  6044. if (!appid) {
  6045. return false;
  6046. }
  6047. const logStatus = scripts_echoLog({
  6048. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  6049. text: id
  6050. });
  6051. const {
  6052. result,
  6053. statusText,
  6054. status,
  6055. data
  6056. } = await tools_httpRequest({
  6057. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  6058. method: 'POST',
  6059. headers: {
  6060. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6061. },
  6062. data: $.param({
  6063. id: id,
  6064. appid: appid,
  6065. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6066. })
  6067. });
  6068. if (result === 'Success') {
  6069. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  6070. if (doTask) {
  6071. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  6072. }
  6073. logStatus.success();
  6074. return true;
  6075. }
  6076. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6077. return false;
  6078. }
  6079. logStatus.error(`${result}:${statusText}(${status})`);
  6080. return false;
  6081. } catch (error) {
  6082. throwError(error, 'Steam.toggleFavoriteWorkshop');
  6083. return false;
  6084. }
  6085. }
  6086. async function _getWorkshopAppId2(id) {
  6087. try {
  6088. const logStatus = scripts_echoLog({
  6089. type: 'gettingWorkshopAppId',
  6090. text: id
  6091. });
  6092. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  6093. if (appId) {
  6094. logStatus.success();
  6095. return appId;
  6096. }
  6097. const {
  6098. result,
  6099. statusText,
  6100. status,
  6101. data
  6102. } = await tools_httpRequest({
  6103. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6104. method: 'GET'
  6105. });
  6106. if (result === 'Success') {
  6107. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6108. var _data$responseText$ma11;
  6109. const appId = (_data$responseText$ma11 = data.responseText.match(/<input type="hidden" name="appid" value="([\d]+?)" \/>/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  6110. if (appId) {
  6111. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6112. logStatus.success();
  6113. return appId;
  6114. }
  6115. logStatus.error('Error: getWorkshopAppId failed');
  6116. return false;
  6117. }
  6118. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6119. return false;
  6120. }
  6121. logStatus.error(`${result}:${statusText}(${status})`);
  6122. return false;
  6123. } catch (error) {
  6124. throwError(error, 'Steam.getWorkshopAppId');
  6125. return false;
  6126. }
  6127. }
  6128. async function _voteUpWorkshop2(id) {
  6129. try {
  6130. const logStatus = scripts_echoLog({
  6131. type: 'votingUpWorkshop',
  6132. text: id
  6133. });
  6134. const {
  6135. result,
  6136. statusText,
  6137. status,
  6138. data
  6139. } = await tools_httpRequest({
  6140. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6141. method: 'POST',
  6142. responseType: 'json',
  6143. headers: {
  6144. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6145. },
  6146. data: $.param({
  6147. id: id,
  6148. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6149. })
  6150. });
  6151. if (result === 'Success') {
  6152. var _data$response5;
  6153. 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) {
  6154. logStatus.success();
  6155. return true;
  6156. }
  6157. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6158. return true;
  6159. }
  6160. logStatus.error(`${result}:${statusText}(${status})`);
  6161. return true;
  6162. } catch (error) {
  6163. throwError(error, 'Steam.voteupWorkshop');
  6164. return true;
  6165. }
  6166. }
  6167. async function _toggleCurator2(curatorId) {
  6168. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6169. try {
  6170. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6171. scripts_echoLog({
  6172. type: 'whiteList',
  6173. text: 'Steam.unfollowCurator',
  6174. id: curatorId
  6175. });
  6176. return true;
  6177. }
  6178. const logStatus = scripts_echoLog({
  6179. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6180. text: curatorId
  6181. });
  6182. const {
  6183. result,
  6184. statusText,
  6185. status,
  6186. data
  6187. } = await tools_httpRequest({
  6188. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6189. method: 'POST',
  6190. headers: {
  6191. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6192. },
  6193. data: $.param({
  6194. clanid: curatorId,
  6195. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6196. follow: doTask
  6197. }),
  6198. dataType: 'json'
  6199. });
  6200. if (result === 'Success') {
  6201. var _data$response6, _data$response6$succe, _data$response7;
  6202. 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) {
  6203. logStatus.success();
  6204. return true;
  6205. }
  6206. 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})`);
  6207. return false;
  6208. }
  6209. logStatus.error(`${result}:${statusText}(${status})`);
  6210. return false;
  6211. } catch (error) {
  6212. throwError(error, 'Steam.toggleCurator');
  6213. return false;
  6214. }
  6215. }
  6216. async function _toggleCuratorLike2(link) {
  6217. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6218. try {
  6219. const [ path, name ] = link.split('/');
  6220. if (!(path && name)) {
  6221. scripts_echoLog({
  6222. text: i18n('errorLink', link)
  6223. });
  6224. return false;
  6225. }
  6226. const curatorId = await this.getCuratorId(path, name);
  6227. if (curatorId) {
  6228. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6229. }
  6230. return false;
  6231. } catch (error) {
  6232. throwError(error, 'Steam.toggleCuratorLike');
  6233. return false;
  6234. }
  6235. }
  6236. async function _getAnnouncementParams2(appId, viewId) {
  6237. try {
  6238. const logStatus = scripts_echoLog({
  6239. type: 'gettingAnnouncementParams',
  6240. text: appId,
  6241. id: viewId
  6242. });
  6243. const {
  6244. result,
  6245. statusText,
  6246. status,
  6247. data
  6248. } = await tools_httpRequest({
  6249. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6250. method: 'GET',
  6251. headers: {
  6252. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6253. }
  6254. });
  6255. if (result === 'Success') {
  6256. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6257. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6258. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6259. logStatus.warning(i18n('changeAreaNotice'));
  6260. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6261. return {};
  6262. }
  6263. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6264. }
  6265. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6266. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6267. const gid = (_data$responseText$ma14 = data.responseText.match(/announcementGID&quot;:&quot;([\d]+?)&quot;/)) === null || _data$responseText$ma14 === void 0 ? void 0 : _data$responseText$ma14[1];
  6268. if (authWgToken && clanId) {
  6269. logStatus.success();
  6270. return {
  6271. authWgToken: authWgToken,
  6272. clanId: clanId,
  6273. gid: gid
  6274. };
  6275. }
  6276. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6277. return {};
  6278. }
  6279. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6280. return {};
  6281. }
  6282. logStatus.error(`${result}:${statusText}(${status})`);
  6283. return {};
  6284. } catch (error) {
  6285. throwError(error, 'Steam.likeAnnouncement');
  6286. return {};
  6287. }
  6288. }
  6289. async function _likeAnnouncement2(id) {
  6290. try {
  6291. const [ appId, viewId ] = id.split('/');
  6292. if (!(appId && viewId)) {
  6293. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6294. return false;
  6295. }
  6296. const {
  6297. authWgToken,
  6298. clanId,
  6299. gid
  6300. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6301. if (!(authWgToken && clanId)) {
  6302. return false;
  6303. }
  6304. const logStatus = scripts_echoLog({
  6305. type: 'likingAnnouncement',
  6306. text: appId,
  6307. id: viewId
  6308. });
  6309. const {
  6310. result,
  6311. statusText,
  6312. status,
  6313. data
  6314. } = await tools_httpRequest({
  6315. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6316. method: 'POST',
  6317. headers: {
  6318. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6319. Host: 'store.steampowered.com',
  6320. Origin: 'https://store.steampowered.com',
  6321. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6322. },
  6323. data: $.param({
  6324. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6325. wgauthtoken: authWgToken,
  6326. voteup: 1,
  6327. clanid: clanId,
  6328. ajax: 1
  6329. }),
  6330. dataType: 'json'
  6331. });
  6332. if (result === 'Success') {
  6333. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6334. logStatus.success();
  6335. return true;
  6336. }
  6337. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6338. return false;
  6339. }
  6340. logStatus.error(`${result}:${statusText}(${status})`);
  6341. return false;
  6342. } catch (error) {
  6343. throwError(error, 'Steam.likeAnnouncement');
  6344. return false;
  6345. }
  6346. }
  6347. async function _appid2subid2(id) {
  6348. try {
  6349. const logStatus = scripts_echoLog({
  6350. type: 'gettingSubid',
  6351. text: id
  6352. });
  6353. const {
  6354. result,
  6355. statusText,
  6356. status,
  6357. data
  6358. } = await tools_httpRequest({
  6359. url: `https://store.steampowered.com/app/${id}`,
  6360. method: 'GET',
  6361. headers: {
  6362. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6363. }
  6364. });
  6365. if (result === 'Success') {
  6366. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6367. var _data$responseText$ma15;
  6368. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6369. logStatus.warning(i18n('changeAreaNotice'));
  6370. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6371. if (!result || result === 'CN' || result === 'skip') {
  6372. return false;
  6373. }
  6374. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6375. }
  6376. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6377. if (subid) {
  6378. logStatus.success();
  6379. return subid;
  6380. }
  6381. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6382. return false;
  6383. }
  6384. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6385. return false;
  6386. }
  6387. logStatus.error(`${result}:${statusText}(${status})`);
  6388. return false;
  6389. } catch (error) {
  6390. throwError(error, 'Steam.appid2subid');
  6391. return false;
  6392. }
  6393. }
  6394. async function _getLicenses2() {
  6395. try {
  6396. const logStatus = scripts_echoLog({
  6397. text: i18n('gettingLicenses')
  6398. });
  6399. const {
  6400. result,
  6401. statusText,
  6402. status,
  6403. data
  6404. } = await tools_httpRequest({
  6405. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  6406. method: 'GET',
  6407. responseType: 'json'
  6408. });
  6409. if (result === 'Success') {
  6410. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6411. var _data$response8;
  6412. logStatus.success();
  6413. return (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.rgOwnedPackages;
  6414. }
  6415. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6416. return false;
  6417. }
  6418. logStatus.error(`${result}:${statusText}(${status})`);
  6419. return false;
  6420. } catch (error) {
  6421. throwError(error, 'Steam.getLicenses');
  6422. return false;
  6423. }
  6424. }
  6425. async function _addLicense2(id) {
  6426. try {
  6427. const [ type, ids ] = id.split('-');
  6428. if (type === 'appid') {
  6429. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6430. if (!subid) {
  6431. return false;
  6432. }
  6433. const logStatus = scripts_echoLog({
  6434. type: 'addingFreeLicense',
  6435. text: ids
  6436. });
  6437. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6438. return false;
  6439. }
  6440. const {
  6441. result,
  6442. statusText,
  6443. status,
  6444. data
  6445. } = await tools_httpRequest({
  6446. url: `https://store.steampowered.com/app/${ids}`,
  6447. method: 'GET'
  6448. });
  6449. if (result === 'Success') {
  6450. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6451. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6452. logStatus.success();
  6453. return true;
  6454. }
  6455. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6456. return false;
  6457. }
  6458. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6459. return false;
  6460. }
  6461. logStatus.error(`${result}:${statusText}(${status})`);
  6462. return false;
  6463. } else if (type === 'subid') {
  6464. if (Steam_classPrivateFieldGet(this, _area) === 'CN') {
  6465. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  6466. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6467. }
  6468. const logStatusArr = {};
  6469. const idsArr = ids.split(',');
  6470. for (const subid of idsArr) {
  6471. const logStatus = scripts_echoLog({
  6472. type: 'addingFreeLicenseSubid',
  6473. text: subid
  6474. });
  6475. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6476. return false;
  6477. }
  6478. logStatusArr[subid] = logStatus;
  6479. }
  6480. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6481. if (!licenses) {
  6482. return false;
  6483. }
  6484. for (const subid of idsArr) {
  6485. if (licenses.includes(parseInt(subid, 10))) {
  6486. logStatusArr[subid].success();
  6487. } else {
  6488. logStatusArr[subid].error();
  6489. }
  6490. }
  6491. return true;
  6492. }
  6493. return false;
  6494. } catch (error) {
  6495. throwError(error, 'Steam.addLicense');
  6496. return false;
  6497. }
  6498. }
  6499. async function _addFreeLicense2(id, logStatusPre) {
  6500. try {
  6501. const logStatus = logStatusPre || scripts_echoLog({
  6502. type: 'addingFreeLicenseSubid',
  6503. text: id
  6504. });
  6505. const {
  6506. result,
  6507. statusText,
  6508. status,
  6509. data
  6510. } = await tools_httpRequest({
  6511. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6512. method: 'POST',
  6513. headers: {
  6514. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6515. Host: 'store.steampowered.com',
  6516. Origin: 'https://store.steampowered.com',
  6517. Referer: 'https://store.steampowered.com/account/licenses/'
  6518. },
  6519. data: $.param({
  6520. action: 'add_to_cart',
  6521. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6522. subid: id
  6523. }),
  6524. dataType: 'json'
  6525. });
  6526. if (result === 'Success') {
  6527. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6528. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6529. logStatus.warning(i18n('changeAreaNotice'));
  6530. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6531. if (!result || result === 'CN') {
  6532. return false;
  6533. }
  6534. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6535. }
  6536. logStatus.success();
  6537. return true;
  6538. }
  6539. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6540. return false;
  6541. }
  6542. logStatus.error(`${result}:${statusText}(${status})`);
  6543. return false;
  6544. } catch (error) {
  6545. throwError(error, 'Steam.addFreeLicense');
  6546. return false;
  6547. }
  6548. }
  6549. async function _requestPlayTestAccess2(id) {
  6550. try {
  6551. const logStatus = scripts_echoLog({
  6552. type: 'requestingPlayTestAccess',
  6553. text: id
  6554. });
  6555. const {
  6556. result,
  6557. statusText,
  6558. status,
  6559. data
  6560. } = await tools_httpRequest({
  6561. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6562. method: 'POST',
  6563. headers: {
  6564. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6565. Host: 'store.steampowered.com',
  6566. Origin: 'https://store.steampowered.com',
  6567. Referer: `https://store.steampowered.com/app/${id}`
  6568. },
  6569. data: $.param({
  6570. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6571. }),
  6572. dataType: 'json'
  6573. });
  6574. if (result === 'Success') {
  6575. var _data$response9;
  6576. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response9 = data.response) === null || _data$response9 === void 0 ? void 0 : _data$response9.success) === 1) {
  6577. logStatus.success();
  6578. return true;
  6579. }
  6580. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6581. return false;
  6582. }
  6583. logStatus.error(`${result}:${statusText}(${status})`);
  6584. return false;
  6585. } catch (error) {
  6586. throwError(error, 'Steam.requestPlayTestAccess');
  6587. return false;
  6588. }
  6589. }
  6590. function Steam_setCache2(type, name, id) {
  6591. try {
  6592. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6593. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6594. } catch (error) {
  6595. throwError(error, 'Steam.setCache');
  6596. }
  6597. }
  6598. const social_Steam = Steam;
  6599. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6600. Website_checkPrivateRedeclaration(obj, privateSet);
  6601. privateSet.add(obj);
  6602. }
  6603. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6604. if (privateCollection.has(obj)) {
  6605. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6606. }
  6607. }
  6608. function Website_defineProperty(obj, key, value) {
  6609. if (key in obj) {
  6610. Object.defineProperty(obj, key, {
  6611. value: value,
  6612. enumerable: true,
  6613. configurable: true,
  6614. writable: true
  6615. });
  6616. } else {
  6617. obj[key] = value;
  6618. }
  6619. return obj;
  6620. }
  6621. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6622. if (!privateSet.has(receiver)) {
  6623. throw new TypeError('attempted to get private field on non-instance');
  6624. }
  6625. return fn;
  6626. }
  6627. var _bind = new WeakSet();
  6628. class Website {
  6629. constructor() {
  6630. Website_classPrivateMethodInitSpec(this, _bind);
  6631. Website_defineProperty(this, 'undoneTasks', void 0);
  6632. Website_defineProperty(this, 'socialTasks', void 0);
  6633. Website_defineProperty(this, 'giveawayId', void 0);
  6634. Website_defineProperty(this, 'socialInitialized', {
  6635. discord: false,
  6636. instagram: false,
  6637. reddit: false,
  6638. twitch: false,
  6639. twitter: false,
  6640. vk: false,
  6641. youtube: false,
  6642. steamStore: false,
  6643. steamCommunity: false
  6644. });
  6645. Website_defineProperty(this, 'initialized', false);
  6646. Website_defineProperty(this, 'social', {});
  6647. }
  6648. async initSocial(action) {
  6649. try {
  6650. const pro = [];
  6651. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6652. if (tasks.discord) {
  6653. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6654. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6655. this.social.discord = new social_Discord();
  6656. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6657. }
  6658. }
  6659. if (tasks.instagram) {
  6660. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6661. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6662. this.social.instagram = new social_Instagram();
  6663. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6664. }
  6665. }
  6666. if (tasks.reddit) {
  6667. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6668. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6669. this.social.reddit = new social_Reddit();
  6670. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6671. }
  6672. }
  6673. if (tasks.twitch) {
  6674. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6675. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6676. this.social.twitch = new social_Twitch();
  6677. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6678. }
  6679. }
  6680. if (tasks.twitter) {
  6681. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6682. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6683. this.social.twitter = new social_Twitter();
  6684. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6685. }
  6686. }
  6687. if (tasks.vk) {
  6688. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6689. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6690. this.social.vk = new social_Vk();
  6691. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6692. }
  6693. }
  6694. if (tasks.youtube) {
  6695. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6696. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6697. this.social.youtube = new Youtube();
  6698. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6699. }
  6700. }
  6701. if (tasks.steam) {
  6702. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6703. if (steamLength > 0) {
  6704. if (!this.social.steam) {
  6705. this.social.steam = new social_Steam();
  6706. }
  6707. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6708. var _tasks$steam, _tasks$steam$type;
  6709. return [ 'groupLinks', 'officialGroupLinks', 'forumLinks', 'workshopLinks', 'workshopVoteLinks' ].includes(type) ? ((_tasks$steam = tasks.steam) === null || _tasks$steam === void 0 ? void 0 : (_tasks$steam$type = _tasks$steam[type]) === null || _tasks$steam$type === void 0 ? void 0 : _tasks$steam$type.length) || 0 : 0;
  6710. }).reduce((total, number) => total + number, 0);
  6711. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6712. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6713. }
  6714. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6715. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6716. }
  6717. }
  6718. }
  6719. if (tasks.links && tasks.links.length > 0) {
  6720. this.social.visitLink = visitLink;
  6721. }
  6722. return await Promise.all(pro).then(result => {
  6723. let checked = true;
  6724. for (const data of result) {
  6725. if (data.result) {
  6726. this.socialInitialized[data.name] = data.result;
  6727. } else {
  6728. checked = false;
  6729. }
  6730. }
  6731. return checked;
  6732. });
  6733. } catch (error) {
  6734. throwError(error, 'Website.initSocial');
  6735. return false;
  6736. }
  6737. }
  6738. uniqueTasks(allTasks) {
  6739. const result = {};
  6740. for (const [ social, types ] of Object.entries(allTasks)) {
  6741. result[social] = {};
  6742. for (const [ type, tasks ] of Object.entries(types)) {
  6743. result[social][type] = unique(tasks);
  6744. }
  6745. }
  6746. return result;
  6747. }
  6748. async toggleTask(action) {
  6749. try {
  6750. if (!this.initialized && !this.init()) {
  6751. return false;
  6752. }
  6753. if (!await this.classifyTask(action)) {
  6754. return false;
  6755. }
  6756. if (!await this.initSocial(action)) {
  6757. return false;
  6758. }
  6759. const pro = [];
  6760. const doTask = action === 'do';
  6761. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6762. if (this.socialInitialized.discord !== 'skip' && this.social.discord) {
  6763. pro.push(this.social.discord.toggle({
  6764. doTask: doTask,
  6765. ...tasks.discord
  6766. }));
  6767. }
  6768. if (this.social.instagram) {
  6769. pro.push(this.social.instagram.toggle({
  6770. doTask: doTask,
  6771. ...tasks.instagram
  6772. }));
  6773. }
  6774. if (this.social.reddit) {
  6775. pro.push(this.social.reddit.toggle({
  6776. doTask: doTask,
  6777. ...tasks.reddit
  6778. }));
  6779. }
  6780. if (this.social.twitch) {
  6781. pro.push(this.social.twitch.toggle({
  6782. doTask: doTask,
  6783. ...tasks.twitch
  6784. }));
  6785. }
  6786. if (this.social.twitter) {
  6787. pro.push(this.social.twitter.toggle({
  6788. doTask: doTask,
  6789. ...tasks.twitter
  6790. }));
  6791. }
  6792. if (this.social.vk) {
  6793. pro.push(this.social.vk.toggle({
  6794. doTask: doTask,
  6795. ...tasks.vk
  6796. }));
  6797. }
  6798. if (this.social.youtube) {
  6799. pro.push(this.social.youtube.toggle({
  6800. doTask: doTask,
  6801. ...tasks.youtube
  6802. }));
  6803. }
  6804. if (this.social.steam) {
  6805. pro.push(this.social.steam.toggle({
  6806. doTask: doTask,
  6807. ...tasks.steam
  6808. }));
  6809. }
  6810. if (this.social.visitLink && tasks.links && doTask) {
  6811. for (const link of tasks.links) {
  6812. pro.push(this.social.visitLink(link));
  6813. }
  6814. }
  6815. if (doTask && tasks.extra && this.extraDoTask) {
  6816. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6817. if (hasExtra) {
  6818. pro.push(this.extraDoTask(tasks.extra));
  6819. }
  6820. }
  6821. await Promise.all(pro);
  6822. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6823. return true;
  6824. } catch (error) {
  6825. throwError(error, 'Website.toggleTask');
  6826. return false;
  6827. }
  6828. }
  6829. async doTask() {
  6830. try {
  6831. return await this.toggleTask('do');
  6832. } catch (error) {
  6833. throwError(error, 'Website.doTask');
  6834. return false;
  6835. }
  6836. }
  6837. async undoTask() {
  6838. try {
  6839. return await this.toggleTask('undo');
  6840. } catch (error) {
  6841. throwError(error, 'Website.undoTask');
  6842. return false;
  6843. }
  6844. }
  6845. }
  6846. async function _bind2(name, init) {
  6847. try {
  6848. return {
  6849. name: name,
  6850. result: await init
  6851. };
  6852. } catch (error) {
  6853. throwError(error, 'Website.bind');
  6854. return {
  6855. name: name,
  6856. result: false
  6857. };
  6858. }
  6859. }
  6860. const website_Website = Website;
  6861. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6862. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6863. privateSet.add(obj);
  6864. }
  6865. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6866. if (privateCollection.has(obj)) {
  6867. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6868. }
  6869. }
  6870. function FreeAnyWhere_defineProperty(obj, key, value) {
  6871. if (key in obj) {
  6872. Object.defineProperty(obj, key, {
  6873. value: value,
  6874. enumerable: true,
  6875. configurable: true,
  6876. writable: true
  6877. });
  6878. } else {
  6879. obj[key] = value;
  6880. }
  6881. return obj;
  6882. }
  6883. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6884. if (!privateSet.has(receiver)) {
  6885. throw new TypeError('attempted to get private field on non-instance');
  6886. }
  6887. return fn;
  6888. }
  6889. const FreeAnyWhere_defaultTasksTemplate = {
  6890. steam: {
  6891. groupLinks: [],
  6892. wishlistLinks: [],
  6893. curatorLinks: [],
  6894. followLinks: []
  6895. },
  6896. vk: {
  6897. nameLinks: []
  6898. }
  6899. };
  6900. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6901. var _getGiveawayId = new WeakSet();
  6902. var _verify = new WeakSet();
  6903. class FreeAnyWhere extends website_Website {
  6904. constructor() {
  6905. super(...arguments);
  6906. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6907. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6908. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6909. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6910. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6911. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6912. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6913. }
  6914. static test() {
  6915. return window.location.host === 'freeanywhere.net';
  6916. }
  6917. init() {
  6918. try {
  6919. const logStatus = scripts_echoLog({
  6920. text: i18n('initing')
  6921. });
  6922. if ($('a[href="#/login"]').length > 0) {
  6923. window.open('/#/login', '_self');
  6924. logStatus.warning(i18n('needLogin'));
  6925. return false;
  6926. }
  6927. if (window.location.href.includes('/login')) {
  6928. logStatus.warning(i18n('needLogin'));
  6929. return false;
  6930. }
  6931. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6932. var _window$location$href;
  6933. 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];
  6934. if (!id) {
  6935. logStatus.error(i18n('getFailed', 'Id'));
  6936. return false;
  6937. }
  6938. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6939. }
  6940. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6941. return false;
  6942. }
  6943. this.initialized = true;
  6944. logStatus.success();
  6945. return true;
  6946. } catch (error) {
  6947. throwError(error, 'Freeanywhere.init');
  6948. return false;
  6949. }
  6950. }
  6951. async classifyTask(action) {
  6952. try {
  6953. const logStatus = scripts_echoLog({
  6954. text: i18n('getTasksInfo')
  6955. });
  6956. if (action === 'undo') {
  6957. var _GM_getValue;
  6958. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6959. }
  6960. const {
  6961. result,
  6962. statusText,
  6963. status,
  6964. data
  6965. } = await tools_httpRequest({
  6966. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6967. method: 'GET',
  6968. headers: {
  6969. authorization: `Token ${window.localStorage.getItem('token')}`,
  6970. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6971. },
  6972. responseType: 'json'
  6973. });
  6974. if (result === 'Success') {
  6975. var _data$response;
  6976. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6977. if (tasks) {
  6978. if (action === 'verify') {
  6979. this.tasks = [];
  6980. }
  6981. for (const task of tasks) {
  6982. const type = task.challenge;
  6983. const social = task.challenge_provider;
  6984. const taskInfo = {
  6985. id: task.id,
  6986. title: task.title
  6987. };
  6988. if (action === 'verify' && !task.is_success) {
  6989. this.tasks.push(taskInfo);
  6990. continue;
  6991. }
  6992. switch (social) {
  6993. case 'steam':
  6994. taskInfo.social = 'steam';
  6995. switch (type) {
  6996. case 'WL':
  6997. if (action === 'undo') {
  6998. this.socialTasks.steam.wishlistLinks.push(task.link);
  6999. }
  7000. if (action === 'do' && !task.is_success) {
  7001. this.undoneTasks.steam.wishlistLinks.push(task.link);
  7002. }
  7003. break;
  7004.  
  7005. case 'JTG':
  7006. if (action === 'undo') {
  7007. this.socialTasks.steam.groupLinks.push(task.link);
  7008. }
  7009. if (action === 'do' && !task.is_success) {
  7010. this.undoneTasks.steam.groupLinks.push(task.link);
  7011. }
  7012. break;
  7013.  
  7014. case 'STC':
  7015. if (action === 'undo') {
  7016. this.socialTasks.steam.curatorLinks.push(task.link);
  7017. }
  7018. if (action === 'do' && !task.is_success) {
  7019. this.undoneTasks.steam.curatorLinks.push(task.link);
  7020. }
  7021. break;
  7022.  
  7023. case 'GF':
  7024. if (action === 'undo') {
  7025. this.socialTasks.steam.followLinks.push(task.link);
  7026. }
  7027. if (action === 'do' && !task.is_success) {
  7028. this.undoneTasks.steam.followLinks.push(task.link);
  7029. }
  7030. break;
  7031. }
  7032. break;
  7033.  
  7034. case 'vk-oauth2':
  7035. if (action === 'undo') {
  7036. this.socialTasks.vk.nameLinks.push(task.link);
  7037. }
  7038. if (action === 'do' && !task.is_success) {
  7039. this.undoneTasks.vk.nameLinks.push(task.link);
  7040. }
  7041. break;
  7042.  
  7043. case 'website':
  7044. break;
  7045.  
  7046. default:
  7047. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  7048. break;
  7049. }
  7050. }
  7051. logStatus.success();
  7052. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7053. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7054. if (window.DEBUG) {
  7055. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7056. }
  7057. GM_setValue(`fawTasks-${this.giveawayId}`, {
  7058. tasks: this.socialTasks,
  7059. time: new Date().getTime()
  7060. });
  7061. return true;
  7062. }
  7063. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7064. return false;
  7065. }
  7066. logStatus.error(`${result}:${statusText}(${status})`);
  7067. return false;
  7068. } catch (error) {
  7069. throwError(error, 'Freeanywhere.classifyTask');
  7070. return false;
  7071. }
  7072. }
  7073. async verifyTask() {
  7074. try {
  7075. if (!this.initialized && !this.init()) {
  7076. return false;
  7077. }
  7078. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7079. return false;
  7080. }
  7081. const pro = [];
  7082. for (const task of this.tasks) {
  7083. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  7084. await delay(1e3);
  7085. }
  7086. await Promise.all(pro);
  7087. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7088. return !!await this.getKey(true);
  7089. } catch (error) {
  7090. throwError(error, 'Freeanywhere.verifyTask');
  7091. return false;
  7092. }
  7093. }
  7094. async getKey(initialized) {
  7095. try {
  7096. if (!initialized && !this.initialized && !this.init()) {
  7097. return false;
  7098. }
  7099. const logStatus = scripts_echoLog({
  7100. text: i18n('gettingKey')
  7101. });
  7102. const {
  7103. result,
  7104. statusText,
  7105. status,
  7106. data
  7107. } = await tools_httpRequest({
  7108. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7109. method: 'GET',
  7110. dataType: 'json',
  7111. headers: {
  7112. authorization: `Token ${window.localStorage.getItem('token')}`
  7113. }
  7114. });
  7115. if (result === 'Success') {
  7116. var _data$response2;
  7117. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7118. logStatus.success();
  7119. scripts_echoLog({}).success(data.response.reward);
  7120. return data.response.reward;
  7121. }
  7122. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7123. return false;
  7124. }
  7125. logStatus.error(`${result}:${statusText}(${status})`);
  7126. return false;
  7127. } catch (error) {
  7128. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7129. return false;
  7130. }
  7131. }
  7132. }
  7133. function _getGiveawayId2() {
  7134. try {
  7135. var _window$location$href2;
  7136. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7137. if (giveawayId) {
  7138. this.giveawayId = giveawayId;
  7139. return true;
  7140. }
  7141. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7142. return false;
  7143. } catch (error) {
  7144. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7145. }
  7146. }
  7147. async function _verify2(task) {
  7148. try {
  7149. const logStatus = scripts_echoLog({
  7150. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7151. });
  7152. const {
  7153. result,
  7154. statusText,
  7155. status,
  7156. data
  7157. } = await tools_httpRequest({
  7158. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7159. method: 'GET',
  7160. dataType: 'json',
  7161. headers: {
  7162. authorization: `Token ${window.localStorage.getItem('token')}`,
  7163. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7164. }
  7165. });
  7166. if (result === 'Success') {
  7167. var _data$response3;
  7168. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7169. logStatus.success();
  7170. return true;
  7171. }
  7172. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7173. return false;
  7174. }
  7175. logStatus.error(`${result}:${statusText}(${status})`);
  7176. return false;
  7177. } catch (error) {
  7178. throwError(error, 'Freeanywhere.verify');
  7179. return false;
  7180. }
  7181. }
  7182. const website_FreeAnyWhere = FreeAnyWhere;
  7183. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7184. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7185. privateSet.add(obj);
  7186. }
  7187. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7188. if (privateCollection.has(obj)) {
  7189. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7190. }
  7191. }
  7192. function GiveawaySu_defineProperty(obj, key, value) {
  7193. if (key in obj) {
  7194. Object.defineProperty(obj, key, {
  7195. value: value,
  7196. enumerable: true,
  7197. configurable: true,
  7198. writable: true
  7199. });
  7200. } else {
  7201. obj[key] = value;
  7202. }
  7203. return obj;
  7204. }
  7205. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7206. if (!privateSet.has(receiver)) {
  7207. throw new TypeError('attempted to get private field on non-instance');
  7208. }
  7209. return fn;
  7210. }
  7211. const GiveawaySu_defaultTasks = {
  7212. steam: {
  7213. groupLinks: [],
  7214. wishlistLinks: [],
  7215. curatorLinks: [],
  7216. curatorLikeLinks: [],
  7217. followLinks: [],
  7218. forumLinks: [],
  7219. announcementLinks: [],
  7220. workshopVoteLinks: [],
  7221. playtestLinks: []
  7222. },
  7223. discord: {
  7224. serverLinks: []
  7225. },
  7226. instagram: {
  7227. userLinks: []
  7228. },
  7229. vk: {
  7230. nameLinks: []
  7231. },
  7232. twitch: {
  7233. channelLinks: []
  7234. },
  7235. reddit: {
  7236. redditLinks: []
  7237. },
  7238. youtube: {
  7239. channelLinks: [],
  7240. likeLinks: []
  7241. }
  7242. };
  7243. var _checkLogin = new WeakSet();
  7244. var _checkLeftKey = new WeakSet();
  7245. var GiveawaySu_getGiveawayId = new WeakSet();
  7246. class GiveawaySu extends website_Website {
  7247. constructor() {
  7248. super(...arguments);
  7249. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7250. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  7251. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7252. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7253. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7254. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7255. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7256. }
  7257. static test() {
  7258. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7259. }
  7260. async after() {
  7261. try {
  7262. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7263. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7264. }
  7265. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7266. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7267. }
  7268. scripts_echoLog({}).warning(i18n('gsNotice'));
  7269. } catch (error) {
  7270. throwError(error, 'Giveawaysu.after');
  7271. }
  7272. }
  7273. init() {
  7274. try {
  7275. const logStatus = scripts_echoLog({
  7276. text: i18n('initing')
  7277. });
  7278. if ($('a.steam-login').length > 0) {
  7279. window.open('/steam/redirect', '_self');
  7280. logStatus.warning(i18n('needLogin'));
  7281. return false;
  7282. }
  7283. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7284. return false;
  7285. }
  7286. this.initialized = true;
  7287. logStatus.success();
  7288. return true;
  7289. } catch (error) {
  7290. throwError(error, 'Giveawaysu.init');
  7291. return false;
  7292. }
  7293. }
  7294. async classifyTask(action) {
  7295. try {
  7296. const logStatus = scripts_echoLog({
  7297. text: i18n('getTasksInfo')
  7298. });
  7299. if (action === 'undo') {
  7300. var _GM_getValue;
  7301. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7302. return true;
  7303. }
  7304. const pro = [];
  7305. const tasks = $('#actions tr');
  7306. if ($('div.bind-discord').is(':visible')) {
  7307. $('div.bind-discord a')[0].click();
  7308. }
  7309. if ($('div.bind-twitch').is(':visible')) {
  7310. $('div.bind-twitch a')[0].click();
  7311. }
  7312. for (const task of tasks) {
  7313. pro.push(new Promise(resolve => {
  7314. const td = $(task).find('td:not(".hidden")');
  7315. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7316. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7317. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7318. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7319. const taskName = taskDes.text().trim();
  7320. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7321. return resolve(true);
  7322. }
  7323. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7324. if (!taskLink) {
  7325. return resolve(false);
  7326. }
  7327. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7328. this.undoneTasks.steam.groupLinks.push(taskLink);
  7329. } else if (/like.*announcement/gi.test(taskName)) {
  7330. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7331. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7332. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7333. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7334. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7335. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7336. this.undoneTasks.steam.forumLinks.push(taskLink);
  7337. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7338. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7339. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7340. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7341. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7342. this.undoneTasks.discord.serverLinks.push(taskLink);
  7343. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7344. this.undoneTasks.instagram.userLinks.push(taskLink);
  7345. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7346. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7347. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7348. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7349. } else if (/watch.*art/gim.test(taskName)) {
  7350. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7351. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7352. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7353. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7354. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7355. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7356. this.undoneTasks.vk.nameLinks.push(taskLink);
  7357. } else {
  7358. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7359. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7360. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7361. }
  7362. if (/follow.*button/gim.test(taskName)) {
  7363. this.undoneTasks.steam.followLinks.push(taskLink);
  7364. }
  7365. }
  7366. }
  7367. resolve(true);
  7368. }).catch(error => {
  7369. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7370. return false;
  7371. });
  7372. }));
  7373. }
  7374. await Promise.all(pro);
  7375. logStatus.success();
  7376. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7377. this.socialTasks = this.undoneTasks;
  7378. if (window.DEBUG) {
  7379. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7380. }
  7381. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7382. tasks: this.socialTasks,
  7383. time: new Date().getTime()
  7384. });
  7385. return true;
  7386. } catch (error) {
  7387. throwError(error, 'Giveawaysu.classifyTask');
  7388. return false;
  7389. }
  7390. }
  7391. }
  7392. function _checkLogin2() {
  7393. try {
  7394. if (!globalOptions.other.checkLogin) {
  7395. return true;
  7396. }
  7397. if ($('a.steam-login').length > 0) {
  7398. window.open('/steam/redirect', '_self');
  7399. }
  7400. return true;
  7401. } catch (error) {
  7402. throwError(error, 'Giveawaysu.checkLogin');
  7403. return false;
  7404. }
  7405. }
  7406. async function _checkLeftKey2() {
  7407. try {
  7408. if (!globalOptions.other.checkLeftKey) {
  7409. return true;
  7410. }
  7411. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7412. await external_Swal_default().fire({
  7413. icon: 'warning',
  7414. title: i18n('notice'),
  7415. text: i18n('noKeysLeft'),
  7416. confirmButtonText: i18n('confirm'),
  7417. cancelButtonText: i18n('cancel'),
  7418. showCancelButton: true
  7419. }).then(_ref => {
  7420. let {
  7421. value
  7422. } = _ref;
  7423. if (value) {
  7424. window.close();
  7425. }
  7426. });
  7427. }
  7428. return true;
  7429. } catch (error) {
  7430. throwError(error, 'Giveawaysu.checkLeftKey');
  7431. return false;
  7432. }
  7433. }
  7434. function GiveawaySu_getGiveawayId2() {
  7435. var _window$location$href;
  7436. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7437. if (giveawayId) {
  7438. this.giveawayId = giveawayId;
  7439. return true;
  7440. }
  7441. scripts_echoLog({
  7442. text: i18n('getFailed', 'GiveawayId')
  7443. });
  7444. return false;
  7445. }
  7446. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7447. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7448. privateSet.add(obj);
  7449. }
  7450. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7451. if (privateCollection.has(obj)) {
  7452. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7453. }
  7454. }
  7455. function Indiedb_defineProperty(obj, key, value) {
  7456. if (key in obj) {
  7457. Object.defineProperty(obj, key, {
  7458. value: value,
  7459. enumerable: true,
  7460. configurable: true,
  7461. writable: true
  7462. });
  7463. } else {
  7464. obj[key] = value;
  7465. }
  7466. return obj;
  7467. }
  7468. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7469. if (!privateSet.has(receiver)) {
  7470. throw new TypeError('attempted to get private field on non-instance');
  7471. }
  7472. return fn;
  7473. }
  7474. var _join = new WeakSet();
  7475. var _do = new WeakSet();
  7476. var Indiedb_checkLogin = new WeakSet();
  7477. var Indiedb_checkLeftKey = new WeakSet();
  7478. class Indiedb {
  7479. constructor() {
  7480. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7481. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7482. Indiedb_classPrivateMethodInitSpec(this, _do);
  7483. Indiedb_classPrivateMethodInitSpec(this, _join);
  7484. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7485. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7486. }
  7487. static test() {
  7488. return window.location.host === 'www.indiedb.com';
  7489. }
  7490. async after() {
  7491. try {
  7492. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7493. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7494. }
  7495. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7496. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7497. }
  7498. } catch (error) {
  7499. throwError(error, 'Indiedb.after');
  7500. }
  7501. }
  7502. async doTask() {
  7503. try {
  7504. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7505. return false;
  7506. }
  7507. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7508. } catch (error) {
  7509. throwError(error, 'Indiedb.doTask');
  7510. return false;
  7511. }
  7512. }
  7513. }
  7514. async function _join2() {
  7515. try {
  7516. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7517. scripts_echoLog({}).error(i18n('needLogin'));
  7518. return false;
  7519. }
  7520. const currentoption = $('a.buttonenter.buttongiveaway');
  7521. if (/join giveaway/gim.test(currentoption.text())) {
  7522. const logStatus = scripts_echoLog({
  7523. text: `${i18n('joiningGiveaway')}...`
  7524. });
  7525. const {
  7526. result,
  7527. statusText,
  7528. status,
  7529. data
  7530. } = await tools_httpRequest({
  7531. url: currentoption.attr('href'),
  7532. method: 'POST',
  7533. data: 'ajax=t',
  7534. dataType: 'json',
  7535. headers: {
  7536. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7537. accept: 'application/json, text/javascript, */*; q=0.01',
  7538. origin: window.location.origin
  7539. }
  7540. });
  7541. if (result === 'Success') {
  7542. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7543. var _data$response, _data$response4, _data$response5;
  7544. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7545. var _data$response2, _data$response3;
  7546. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7547. $('#giveawaysjoined').slideDown();
  7548. $('#giveawaysrecommend').slideDown();
  7549. 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}` : ''}`);
  7550. return true;
  7551. }
  7552. 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}` : ''}`);
  7553. return false;
  7554. }
  7555. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7556. return false;
  7557. }
  7558. logStatus.error(`${result}:${statusText}(${status})`);
  7559. return false;
  7560. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7561. return true;
  7562. }
  7563. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7564. return false;
  7565. } catch (error) {
  7566. throwError(error, 'Indiedb.init');
  7567. return false;
  7568. }
  7569. }
  7570. async function _do2() {
  7571. try {
  7572. const id = $('script').map((index, script) => {
  7573. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7574. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7575. 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] ];
  7576. }
  7577. return null;
  7578. });
  7579. if (id.length === 2) {
  7580. const pro = [];
  7581. const tasks = $('#giveawaysjoined a[class*=promo]');
  7582. for (const task of tasks) {
  7583. const promo = $(task);
  7584. if (!promo.hasClass('buttonentered')) {
  7585. const status = scripts_echoLog({
  7586. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7587. });
  7588. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7589. let text = '';
  7590. if (promo.hasClass('facebookpromo')) {
  7591. text = 'facebookpromo';
  7592. } else if (promo.hasClass('twitterpromo')) {
  7593. text = 'twitterpromo';
  7594. } else {
  7595. text = 'visitpromo';
  7596. }
  7597. pro.push(new Promise(resolve => {
  7598. $.ajax({
  7599. type: 'POST',
  7600. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7601. timeout: 6e4,
  7602. dataType: 'json',
  7603. data: {
  7604. ajax: 't'
  7605. },
  7606. error(response, error, exception) {
  7607. if (window.DEBUG) {
  7608. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7609. response: response,
  7610. error: error,
  7611. exception: exception
  7612. });
  7613. }
  7614. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7615. resolve(true);
  7616. },
  7617. success(response) {
  7618. if (response.success) {
  7619. status.success(`Success:${response.text}`);
  7620. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7621. resolve(true);
  7622. } else {
  7623. status.error(`Error:${response.text}`);
  7624. resolve(true);
  7625. }
  7626. }
  7627. });
  7628. }));
  7629. } else if (promo.hasClass('emailoptinpromo')) {
  7630. pro.push(new Promise(resolve => {
  7631. $.ajax({
  7632. type: 'POST',
  7633. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7634. timeout: 6e4,
  7635. dataType: 'json',
  7636. data: {
  7637. ajax: 't',
  7638. emailsystoggle: 4
  7639. },
  7640. error(response, error, exception) {
  7641. if (window.DEBUG) {
  7642. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7643. response: response,
  7644. error: error,
  7645. exception: exception
  7646. });
  7647. }
  7648. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7649. resolve(true);
  7650. },
  7651. success(response) {
  7652. if (response.success) {
  7653. status.success(`Success:${response.text}`);
  7654. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7655. resolve(true);
  7656. } else {
  7657. status.error(`Error:${response.text}`);
  7658. resolve(true);
  7659. }
  7660. }
  7661. });
  7662. }));
  7663. } else if (promo.hasClass('watchingpromo')) {
  7664. pro.push(new Promise(resolve => {
  7665. var _promo$attr;
  7666. const data = getUrlQuery(promo.attr('href'));
  7667. data.ajax = 't';
  7668. $.ajax({
  7669. type: 'POST',
  7670. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7671. timeout: 6e4,
  7672. dataType: 'json',
  7673. data: data,
  7674. error(response, error, exception) {
  7675. if (window.DEBUG) {
  7676. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7677. response: response,
  7678. error: error,
  7679. exception: exception
  7680. });
  7681. }
  7682. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7683. resolve(true);
  7684. },
  7685. success(response) {
  7686. if (response.success) {
  7687. status.success(`Success:${response.text}`);
  7688. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7689. resolve(true);
  7690. } else {
  7691. status.error(`Error:${response.text}`);
  7692. resolve(true);
  7693. }
  7694. }
  7695. });
  7696. }));
  7697. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7698. pro.push(new Promise(resolve => {
  7699. $.ajax({
  7700. type: 'POST',
  7701. url: urlPath(promo.attr('href')),
  7702. timeout: 6e4,
  7703. dataType: 'json',
  7704. data: {
  7705. ajax: 't'
  7706. },
  7707. error(response, error, exception) {
  7708. if (window.DEBUG) {
  7709. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7710. response: response,
  7711. error: error,
  7712. exception: exception
  7713. });
  7714. }
  7715. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7716. resolve(true);
  7717. },
  7718. success(response) {
  7719. if (response.success) {
  7720. status.success(`Success:${response.text}`);
  7721. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7722. resolve(true);
  7723. } else {
  7724. status.error(`Error:${response.text}`);
  7725. resolve(true);
  7726. }
  7727. }
  7728. });
  7729. }));
  7730. } else {
  7731. status.error(`Error:${i18n('unKnownTaskType')}`);
  7732. }
  7733. }
  7734. }
  7735. await Promise.all(pro);
  7736. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7737. return true;
  7738. }
  7739. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7740. return false;
  7741. } catch (error) {
  7742. throwError(error, 'Indiedb.classifyTask');
  7743. return false;
  7744. }
  7745. }
  7746. function Indiedb_checkLogin2() {
  7747. try {
  7748. if (!globalOptions.other.checkLogin) {
  7749. return true;
  7750. }
  7751. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7752. window.open('/members/login', '_self');
  7753. }
  7754. return true;
  7755. } catch (error) {
  7756. throwError(error, 'Indiedb.checkLogin');
  7757. return false;
  7758. }
  7759. }
  7760. async function Indiedb_checkLeftKey2() {
  7761. try {
  7762. if (!globalOptions.other.checkLeftKey) {
  7763. return true;
  7764. }
  7765. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7766. await external_Swal_default().fire({
  7767. icon: 'warning',
  7768. title: i18n('notice'),
  7769. text: i18n('giveawayEnded'),
  7770. confirmButtonText: i18n('confirm'),
  7771. cancelButtonText: i18n('cancel'),
  7772. showCancelButton: true
  7773. }).then(_ref => {
  7774. let {
  7775. value
  7776. } = _ref;
  7777. if (value) {
  7778. window.close();
  7779. }
  7780. });
  7781. }
  7782. return true;
  7783. } catch (error) {
  7784. throwError(error, 'Indiedb.checkLeftKey');
  7785. return false;
  7786. }
  7787. }
  7788. const website_Indiedb = Indiedb;
  7789. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7790. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7791. privateSet.add(obj);
  7792. }
  7793. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7794. if (privateCollection.has(obj)) {
  7795. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7796. }
  7797. }
  7798. function Keyhub_defineProperty(obj, key, value) {
  7799. if (key in obj) {
  7800. Object.defineProperty(obj, key, {
  7801. value: value,
  7802. enumerable: true,
  7803. configurable: true,
  7804. writable: true
  7805. });
  7806. } else {
  7807. obj[key] = value;
  7808. }
  7809. return obj;
  7810. }
  7811. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7812. if (!privateSet.has(receiver)) {
  7813. throw new TypeError('attempted to get private field on non-instance');
  7814. }
  7815. return fn;
  7816. }
  7817. const Keyhub_defaultTasksTemplate = {
  7818. steam: {
  7819. groupLinks: [],
  7820. officialGroupLinks: [],
  7821. wishlistLinks: [],
  7822. curatorLinks: []
  7823. },
  7824. discord: {
  7825. serverLinks: []
  7826. },
  7827. links: []
  7828. };
  7829. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7830. var Keyhub_getGiveawayId = new WeakSet();
  7831. var Keyhub_checkLeftKey = new WeakSet();
  7832. var Keyhub_checkLogin = new WeakSet();
  7833. class Keyhub extends website_Website {
  7834. constructor() {
  7835. super(...arguments);
  7836. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7837. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7838. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7839. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7840. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7841. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7842. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7843. }
  7844. static test() {
  7845. return window.location.host === 'key-hub.eu';
  7846. }
  7847. async after() {
  7848. try {
  7849. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7850. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7851. }
  7852. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7853. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7854. }
  7855. $('.NSFW').hide();
  7856. } catch (error) {
  7857. throwError(error, 'Keyhub.after');
  7858. }
  7859. }
  7860. init() {
  7861. try {
  7862. const logStatus = scripts_echoLog({
  7863. text: i18n('initing')
  7864. });
  7865. if ($('a[href*="/connect/steam"]').length > 0) {
  7866. window.open('/connect/steam', '_self');
  7867. logStatus.warning(i18n('needLogin'));
  7868. return false;
  7869. }
  7870. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7871. return false;
  7872. }
  7873. $('#VPNoverlay').hide();
  7874. $('#mainArticleSection').show();
  7875. this.initialized = true;
  7876. logStatus.success();
  7877. return true;
  7878. } catch (error) {
  7879. throwError(error, 'Keyhub.init');
  7880. return false;
  7881. }
  7882. }
  7883. async classifyTask(action) {
  7884. try {
  7885. const logStatus = scripts_echoLog({
  7886. text: i18n('getTasksInfo')
  7887. });
  7888. if (action === 'undo') {
  7889. var _GM_getValue;
  7890. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7891. }
  7892. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7893. for (const task of tasks) {
  7894. let link = $(task).attr('href');
  7895. const taskDes = $(task).text().trim();
  7896. if (!link) {
  7897. continue;
  7898. }
  7899. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7900. link = await getRedirectLink(link) || link;
  7901. }
  7902. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7903. window.open(link, '_blank');
  7904. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7905. if (action === 'undo') {
  7906. this.socialTasks.steam.groupLinks.push(link);
  7907. }
  7908. if (action === 'do') {
  7909. this.undoneTasks.steam.groupLinks.push(link);
  7910. }
  7911. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7912. if (action === 'undo') {
  7913. this.socialTasks.steam.officialGroupLinks.push(link);
  7914. }
  7915. if (action === 'do') {
  7916. this.undoneTasks.steam.officialGroupLinks.push(link);
  7917. }
  7918. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7919. if (action === 'undo') {
  7920. this.socialTasks.steam.wishlistLinks.push(link);
  7921. }
  7922. if (action === 'do') {
  7923. this.undoneTasks.steam.wishlistLinks.push(link);
  7924. }
  7925. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7926. if (action === 'undo') {
  7927. this.socialTasks.steam.curatorLinks.push(link);
  7928. }
  7929. if (action === 'do') {
  7930. this.undoneTasks.steam.curatorLinks.push(link);
  7931. }
  7932. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7933. if (action === 'undo') {
  7934. this.socialTasks.discord.serverLinks.push(link);
  7935. }
  7936. if (action === 'do') {
  7937. this.undoneTasks.discord.serverLinks.push(link);
  7938. }
  7939. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link) || /^https?:\/\/www\.facebook\.com\/.*/.test(link)) {} else {
  7940. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7941. }
  7942. }
  7943. logStatus.success();
  7944. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7945. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7946. if (window.DEBUG) {
  7947. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7948. }
  7949. GM_setValue(`khTasks-${this.giveawayId}`, {
  7950. tasks: this.socialTasks,
  7951. time: new Date().getTime()
  7952. });
  7953. return true;
  7954. } catch (error) {
  7955. throwError(error, 'Keyhub.classifyTask');
  7956. return false;
  7957. }
  7958. }
  7959. verifyTask() {
  7960. try {
  7961. scripts_echoLog({
  7962. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7963. });
  7964. $.get(window.location.href, res => {
  7965. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7966. });
  7967. } catch (error) {
  7968. throwError(error, 'keyhub.verifyTask');
  7969. }
  7970. }
  7971. }
  7972. function Keyhub_getGiveawayId2() {
  7973. try {
  7974. var _window$location$href;
  7975. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7976. if (giveawayId) {
  7977. this.giveawayId = giveawayId;
  7978. return true;
  7979. }
  7980. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7981. return false;
  7982. } catch (error) {
  7983. throwError(error, 'Keyhub.getGiveawayId');
  7984. return false;
  7985. }
  7986. }
  7987. async function Keyhub_checkLeftKey2() {
  7988. try {
  7989. if (!globalOptions.other.checkLeftKey) {
  7990. return true;
  7991. }
  7992. const leftKey = $('#keysleft').text().trim();
  7993. if (leftKey === '0') {
  7994. await external_Swal_default().fire({
  7995. icon: 'warning',
  7996. title: i18n('notice'),
  7997. text: i18n('noKeysLeft'),
  7998. confirmButtonText: i18n('confirm'),
  7999. cancelButtonText: i18n('cancel'),
  8000. showCancelButton: true
  8001. }).then(_ref => {
  8002. let {
  8003. value
  8004. } = _ref;
  8005. if (value) {
  8006. window.close();
  8007. }
  8008. });
  8009. }
  8010. return true;
  8011. } catch (error) {
  8012. throwError(error, 'Keyhub.checkLeftKey');
  8013. return false;
  8014. }
  8015. }
  8016. function Keyhub_checkLogin2() {
  8017. try {
  8018. if (!globalOptions.other.checkLogin) {
  8019. return true;
  8020. }
  8021. if ($('a[href*="/connect/steam"]').length > 0) {
  8022. window.open('/connect/steam', '_self');
  8023. }
  8024. return true;
  8025. } catch (error) {
  8026. throwError(error, 'Keyhub.checkLogin');
  8027. return false;
  8028. }
  8029. }
  8030. const website_Keyhub = Keyhub;
  8031. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  8032. Givekey_checkPrivateRedeclaration(obj, privateSet);
  8033. privateSet.add(obj);
  8034. }
  8035. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  8036. if (privateCollection.has(obj)) {
  8037. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8038. }
  8039. }
  8040. function Givekey_defineProperty(obj, key, value) {
  8041. if (key in obj) {
  8042. Object.defineProperty(obj, key, {
  8043. value: value,
  8044. enumerable: true,
  8045. configurable: true,
  8046. writable: true
  8047. });
  8048. } else {
  8049. obj[key] = value;
  8050. }
  8051. return obj;
  8052. }
  8053. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  8054. if (!privateSet.has(receiver)) {
  8055. throw new TypeError('attempted to get private field on non-instance');
  8056. }
  8057. return fn;
  8058. }
  8059. const Givekey_defaultTasksTemplate = {
  8060. steam: {
  8061. groupLinks: [],
  8062. wishlistLinks: [],
  8063. curatorLinks: [],
  8064. curatorLikeLinks: []
  8065. },
  8066. twitter: {
  8067. userLinks: []
  8068. },
  8069. vk: {
  8070. nameLinks: []
  8071. },
  8072. discord: {
  8073. serverLinks: []
  8074. }
  8075. };
  8076. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  8077. var Givekey_verify = new WeakSet();
  8078. var Givekey_getGiveawayId = new WeakSet();
  8079. var Givekey_checkLeftKey = new WeakSet();
  8080. class Givekey extends website_Website {
  8081. constructor() {
  8082. super(...arguments);
  8083. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  8084. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  8085. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  8086. Givekey_defineProperty(this, 'name', 'Givekey');
  8087. Givekey_defineProperty(this, 'tasks', []);
  8088. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  8089. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  8090. Givekey_defineProperty(this, 'userId', void 0);
  8091. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8092. }
  8093. static test() {
  8094. return window.location.host === 'givekey.ru';
  8095. }
  8096. async after() {
  8097. try {
  8098. await new Promise(resolve => {
  8099. const checker = setInterval(() => {
  8100. if ($('#navbarDropdown').length > 0) {
  8101. clearInterval(checker);
  8102. resolve(true);
  8103. }
  8104. });
  8105. });
  8106. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8107. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8108. }
  8109. } catch (error) {
  8110. throwError(error, 'Givekey.after');
  8111. return false;
  8112. }
  8113. }
  8114. init() {
  8115. try {
  8116. const logStatus = scripts_echoLog({
  8117. text: i18n('initing')
  8118. });
  8119. if ($('a[href*="/auth/steam"]').length > 0) {
  8120. window.open('/auth/steam', '_self');
  8121. logStatus.warning(i18n('needLogin'));
  8122. return false;
  8123. }
  8124. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8125. return false;
  8126. }
  8127. const userId = $('meta[name="user-id"]').attr('content');
  8128. if (!userId) {
  8129. logStatus.error(i18n('getFailed', i18n('userId')));
  8130. return false;
  8131. }
  8132. this.userId = userId;
  8133. this.initialized = true;
  8134. logStatus.success();
  8135. return true;
  8136. } catch (error) {
  8137. throwError(error, 'Givekey.init');
  8138. return false;
  8139. }
  8140. }
  8141. async classifyTask(action) {
  8142. try {
  8143. const logStatus = scripts_echoLog({
  8144. text: i18n('getTasksInfo')
  8145. });
  8146. if (action === 'undo') {
  8147. var _GM_getValue;
  8148. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8149. }
  8150. const tasks = $('.card-body:has("button") .row');
  8151. for (const task of tasks) {
  8152. const taskEle = $(task);
  8153. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8154. if (isSuccess && action !== 'undo') {
  8155. continue;
  8156. }
  8157. const checkButton = taskEle.find('#task_check');
  8158. const taskId = checkButton.attr('data-id');
  8159. if (taskId) {
  8160. this.tasks.push(taskId);
  8161. }
  8162. if (action === 'verify') {
  8163. continue;
  8164. }
  8165. let href = taskEle.find('a').attr('href') || null;
  8166. const text = taskEle.find('a').text().trim();
  8167. const icon = taskEle.find('i');
  8168. if (!href || !text) {
  8169. continue;
  8170. }
  8171. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8172. href = await getRedirectLink(href);
  8173. }
  8174. if (!href) {
  8175. continue;
  8176. }
  8177. if (/^https?:\/\/vk\.com\//.test(href)) {
  8178. this.socialTasks.vk.nameLinks.push(href);
  8179. if (action === 'do' && !isSuccess) {
  8180. this.undoneTasks.vk.nameLinks.push(href);
  8181. }
  8182. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8183. this.socialTasks.steam.groupLinks.push(href);
  8184. if (action === 'do' && !isSuccess) {
  8185. this.undoneTasks.steam.groupLinks.push(href);
  8186. }
  8187. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8188. this.socialTasks.steam.wishlistLinks.push(href);
  8189. if (action === 'do' && !isSuccess) {
  8190. this.undoneTasks.steam.wishlistLinks.push(href);
  8191. }
  8192. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8193. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8194. this.socialTasks.steam.curatorLinks.push(href);
  8195. if (action === 'do' && !isSuccess) {
  8196. this.undoneTasks.steam.curatorLinks.push(href);
  8197. }
  8198. } else {
  8199. this.socialTasks.steam.curatorLikeLinks.push(href);
  8200. if (action === 'do' && !isSuccess) {
  8201. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8202. }
  8203. }
  8204. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8205. this.socialTasks.twitter.userLinks.push(href);
  8206. if (action === 'do' && !isSuccess) {
  8207. this.undoneTasks.twitter.userLinks.push(href);
  8208. }
  8209. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8210. this.socialTasks.discord.serverLinks.push(href);
  8211. if (action === 'do' && !isSuccess) {
  8212. this.undoneTasks.discord.serverLinks.push(href);
  8213. }
  8214. } else {
  8215. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8216. }
  8217. }
  8218. logStatus.success();
  8219. this.tasks = unique(this.tasks);
  8220. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8221. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8222. if (window.DEBUG) {
  8223. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8224. }
  8225. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8226. tasks: this.socialTasks,
  8227. time: new Date().getTime()
  8228. });
  8229. return true;
  8230. } catch (error) {
  8231. throwError(error, 'Givekey.classifyTask');
  8232. return false;
  8233. }
  8234. }
  8235. async verifyTask() {
  8236. try {
  8237. if (!this.initialized && !this.init()) {
  8238. return false;
  8239. }
  8240. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8241. return false;
  8242. }
  8243. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8244. const taskLength = this.tasks.length;
  8245. for (let i = 0; i < taskLength; i++) {
  8246. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8247. if (i < taskLength - 1) {
  8248. await delay(15e3);
  8249. }
  8250. }
  8251. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8252. scripts_echoLog({
  8253. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8254. });
  8255. return true;
  8256. } catch (error) {
  8257. throwError(error, 'Givekey.verifyTask');
  8258. return false;
  8259. }
  8260. }
  8261. }
  8262. async function Givekey_verify2(task) {
  8263. try {
  8264. const logStatus = scripts_echoLog({
  8265. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8266. });
  8267. return await new Promise(resolve => {
  8268. $.ajax({
  8269. url: 'https://givekey.ru/giveaway/task',
  8270. method: 'POST',
  8271. data: `id=${task}&user_id=${this.userId}`,
  8272. dataType: 'json',
  8273. headers: {
  8274. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8275. },
  8276. success: data => {
  8277. if (data.btn) {
  8278. $(`button[data-id=${this.userId}]`).html(data.btn);
  8279. }
  8280. if (data.status === 'ok') {
  8281. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8282. logStatus.success();
  8283. resolve(true);
  8284. } else if (data.status === 'end') {
  8285. logStatus.success();
  8286. scripts_echoLog({}).success(data.key);
  8287. resolve(true);
  8288. } else {
  8289. logStatus.error(`Error:${data.msg}`);
  8290. resolve(false);
  8291. }
  8292. },
  8293. error: xhr => {
  8294. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8295. resolve(false);
  8296. }
  8297. });
  8298. });
  8299. } catch (error) {
  8300. throwError(error, 'Givekey.verify');
  8301. return false;
  8302. }
  8303. }
  8304. function Givekey_getGiveawayId2() {
  8305. try {
  8306. var _window$location$href;
  8307. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8308. if (giveawayId) {
  8309. this.giveawayId = giveawayId;
  8310. return true;
  8311. }
  8312. scripts_echoLog({
  8313. text: i18n('getFailed', 'GiveawayId')
  8314. });
  8315. return false;
  8316. } catch (error) {
  8317. throwError(error, 'Givekey.getGiveawayId');
  8318. return false;
  8319. }
  8320. }
  8321. async function Givekey_checkLeftKey2() {
  8322. try {
  8323. if (!globalOptions.other.checkLeftKey) {
  8324. return true;
  8325. }
  8326. if (!$('#keys_count').text()) {
  8327. await external_Swal_default().fire({
  8328. icon: 'warning',
  8329. title: i18n('notice'),
  8330. text: i18n('noKeysLeft'),
  8331. confirmButtonText: i18n('confirm'),
  8332. cancelButtonText: i18n('cancel'),
  8333. showCancelButton: true
  8334. }).then(_ref => {
  8335. let {
  8336. value
  8337. } = _ref;
  8338. if (value) {
  8339. window.close();
  8340. }
  8341. });
  8342. }
  8343. return true;
  8344. } catch (error) {
  8345. throwError(error, 'Givekey.checkLeftKey');
  8346. return false;
  8347. }
  8348. }
  8349. const website_Givekey = Givekey;
  8350. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8351. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8352. privateSet.add(obj);
  8353. }
  8354. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8355. if (privateCollection.has(obj)) {
  8356. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8357. }
  8358. }
  8359. function GiveeClub_defineProperty(obj, key, value) {
  8360. if (key in obj) {
  8361. Object.defineProperty(obj, key, {
  8362. value: value,
  8363. enumerable: true,
  8364. configurable: true,
  8365. writable: true
  8366. });
  8367. } else {
  8368. obj[key] = value;
  8369. }
  8370. return obj;
  8371. }
  8372. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8373. if (!privateSet.has(receiver)) {
  8374. throw new TypeError('attempted to get private field on non-instance');
  8375. }
  8376. return fn;
  8377. }
  8378. var GiveeClub_checkLogin = new WeakSet();
  8379. var GiveeClub_getGiveawayId = new WeakSet();
  8380. var GiveeClub_checkLeftKey = new WeakSet();
  8381. class GiveeClub extends GiveawaySu {
  8382. constructor() {
  8383. super(...arguments);
  8384. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8385. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8386. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8387. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8388. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  8389. }
  8390. static test() {
  8391. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8392. }
  8393. async after() {
  8394. try {
  8395. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8396. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8397. }
  8398. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8399. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8400. }
  8401. } catch (error) {
  8402. throwError(error, 'GiveeClub.after');
  8403. }
  8404. }
  8405. init() {
  8406. try {
  8407. const logStatus = scripts_echoLog({
  8408. text: i18n('initing')
  8409. });
  8410. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8411. logStatus.warning(i18n('needLogin'));
  8412. return false;
  8413. }
  8414. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8415. return false;
  8416. }
  8417. this.initialized = true;
  8418. logStatus.success();
  8419. return true;
  8420. } catch (error) {
  8421. throwError(error, 'GiveeClub.init');
  8422. return false;
  8423. }
  8424. }
  8425. async classifyTask(action) {
  8426. try {
  8427. const logStatus = scripts_echoLog({
  8428. text: i18n('getTasksInfo')
  8429. });
  8430. if (action === 'undo') {
  8431. var _GM_getValue;
  8432. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8433. return true;
  8434. }
  8435. const pro = [];
  8436. const tasks = $('.event-actions tr');
  8437. for (const task of tasks) {
  8438. pro.push(new Promise(resolve => {
  8439. const taskDes = $(task).find('.event-action-label a');
  8440. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8441. const taskName = taskDes.text().trim();
  8442. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8443. return resolve(true);
  8444. }
  8445. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8446. if (!taskLink) {
  8447. return resolve(false);
  8448. }
  8449. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8450. this.undoneTasks.steam.groupLinks.push(taskLink);
  8451. } else if (/like.*announcement/gi.test(taskName)) {
  8452. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8453. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8454. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8455. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  8456. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8457. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8458. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8459. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8460. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8461. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8462. this.undoneTasks.steam.forumLinks.push(taskLink);
  8463. } else if (taskIcon.includes('discord')) {
  8464. this.undoneTasks.discord.serverLinks.push(taskLink);
  8465. } else if (taskIcon.includes('instagram')) {
  8466. this.undoneTasks.instagram.userLinks.push(taskLink);
  8467. } else if (taskIcon.includes('twitch')) {
  8468. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8469. } else if (taskIcon.includes('reddit')) {
  8470. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8471. } else if (/watch.*art/gim.test(taskName)) {
  8472. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8473. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8474. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8475. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8476. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8477. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8478. this.undoneTasks.vk.nameLinks.push(taskLink);
  8479. } else {
  8480. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8481. if (/follow.*button/gim.test(taskName)) {
  8482. this.undoneTasks.steam.followLinks.push(taskLink);
  8483. }
  8484. }
  8485. }
  8486. resolve(true);
  8487. }).catch(error => {
  8488. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8489. return false;
  8490. });
  8491. }));
  8492. }
  8493. await Promise.all(pro);
  8494. logStatus.success();
  8495. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8496. this.socialTasks = this.undoneTasks;
  8497. if (window.DEBUG) {
  8498. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8499. }
  8500. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8501. tasks: this.socialTasks,
  8502. time: new Date().getTime()
  8503. });
  8504. return true;
  8505. } catch (error) {
  8506. throwError(error, 'GiveeClub.classifyTask');
  8507. return false;
  8508. }
  8509. }
  8510. }
  8511. function GiveeClub_checkLogin2() {
  8512. try {
  8513. if (!globalOptions.other.checkLogin) {
  8514. return true;
  8515. }
  8516. if ($('a[href*="/account/auth"]').length > 0) {
  8517. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8518. }
  8519. return true;
  8520. } catch (error) {
  8521. throwError(error, 'GiveeClub.checkLogin');
  8522. return false;
  8523. }
  8524. }
  8525. function GiveeClub_getGiveawayId2() {
  8526. var _window$location$href;
  8527. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8528. if (giveawayId) {
  8529. this.giveawayId = giveawayId;
  8530. return true;
  8531. }
  8532. scripts_echoLog({
  8533. text: i18n('getFailed', 'GiveawayId')
  8534. });
  8535. return false;
  8536. }
  8537. async function GiveeClub_checkLeftKey2() {
  8538. try {
  8539. if (!globalOptions.other.checkLeftKey) {
  8540. return true;
  8541. }
  8542. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8543. await external_Swal_default().fire({
  8544. icon: 'warning',
  8545. title: i18n('notice'),
  8546. text: i18n('giveawayEnded'),
  8547. confirmButtonText: i18n('confirm'),
  8548. cancelButtonText: i18n('cancel'),
  8549. showCancelButton: true
  8550. }).then(_ref => {
  8551. let {
  8552. value
  8553. } = _ref;
  8554. if (value) {
  8555. window.close();
  8556. }
  8557. });
  8558. }
  8559. return true;
  8560. } catch (error) {
  8561. throwError(error, 'Giveawaysu.checkLeftKey');
  8562. return false;
  8563. }
  8564. }
  8565. const website_GiveeClub = GiveeClub;
  8566. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8567. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8568. privateSet.add(obj);
  8569. }
  8570. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8571. if (privateCollection.has(obj)) {
  8572. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8573. }
  8574. }
  8575. function OpiumPulses_defineProperty(obj, key, value) {
  8576. if (key in obj) {
  8577. Object.defineProperty(obj, key, {
  8578. value: value,
  8579. enumerable: true,
  8580. configurable: true,
  8581. writable: true
  8582. });
  8583. } else {
  8584. obj[key] = value;
  8585. }
  8586. return obj;
  8587. }
  8588. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8589. if (!privateSet.has(receiver)) {
  8590. throw new TypeError('attempted to get private field on non-instance');
  8591. }
  8592. return fn;
  8593. }
  8594. const defaultOptions = {
  8595. maxPoint: '99999999'
  8596. };
  8597. var _toggleTask = new WeakSet();
  8598. var OpiumPulses_checkLogin = new WeakSet();
  8599. class OpiumPulses {
  8600. constructor() {
  8601. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8602. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8603. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8604. OpiumPulses_defineProperty(this, 'options', {
  8605. ...defaultOptions,
  8606. ...GM_getValue('OpiumPulsesOptions')
  8607. });
  8608. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8609. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8610. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8611. }
  8612. static test() {
  8613. return window.location.host === 'www.opiumpulses.com';
  8614. }
  8615. async after() {
  8616. try {
  8617. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8618. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8619. }
  8620. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8621. } catch (error) {
  8622. throwError(error, 'OpiumPulses.after');
  8623. }
  8624. }
  8625. async doFreeTask() {
  8626. try {
  8627. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8628. } catch (error) {
  8629. throwError(error, 'OpiumPulses.doFreeTask');
  8630. }
  8631. }
  8632. async doPointTask() {
  8633. try {
  8634. var _$$text$match;
  8635. 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);
  8636. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8637. } catch (error) {
  8638. throwError(error, 'OpiumPulses.doPointTask');
  8639. }
  8640. }
  8641. init() {
  8642. return true;
  8643. }
  8644. classifyTask() {
  8645. return true;
  8646. }
  8647. }
  8648. async function _toggleTask2(type) {
  8649. try {
  8650. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8651. for (const item of items) {
  8652. var _$$find$text$match;
  8653. 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);
  8654. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8655. if (type === 'points' && needPoints > this.myPoints) {
  8656. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8657. } else if (type === 'points' && !needPoints) {
  8658. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8659. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8660. var _aElement$attr;
  8661. const logStatus = scripts_echoLog({
  8662. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8663. });
  8664. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8665. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8666. var _aElement$attr2, _aElement$attr2$match;
  8667. 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];
  8668. if (giveawayId) {
  8669. checkUser(giveawayId);
  8670. }
  8671. }
  8672. if (!aElement.attr('href')) {
  8673. logStatus.error('Error: No "href".');
  8674. continue;
  8675. }
  8676. const {
  8677. result,
  8678. statusText,
  8679. status,
  8680. data
  8681. } = await tools_httpRequest({
  8682. url: aElement.attr('href'),
  8683. method: 'GET'
  8684. });
  8685. if (result === 'Success') {
  8686. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8687. var _data$responseText$ma;
  8688. logStatus.success();
  8689. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8690. if (type === 'points' && points) {
  8691. this.myPoints = parseInt(points, 10);
  8692. }
  8693. } else {
  8694. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8695. }
  8696. } else {
  8697. logStatus.error(`${result}:${statusText}(${status})`);
  8698. }
  8699. }
  8700. }
  8701. scripts_echoLog({
  8702. text: '-----END-----'
  8703. });
  8704. } catch (error) {
  8705. throwError(error, 'OpiumPulses.toggleTask');
  8706. }
  8707. }
  8708. function OpiumPulses_checkLogin2() {
  8709. try {
  8710. if (!globalOptions.other.checkLogin) {
  8711. return true;
  8712. }
  8713. if ($('a[href*="/site/login"]').length > 1) {
  8714. window.open('/site/login', '_self');
  8715. }
  8716. return true;
  8717. } catch (error) {
  8718. throwError(error, 'OpiumPulses.checkLogin');
  8719. return false;
  8720. }
  8721. }
  8722. const website_OpiumPulses = OpiumPulses;
  8723. const external_dayjs_namespaceObject = dayjs;
  8724. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8725. const leftKeyChecker = {
  8726. async classify(link) {
  8727. try {
  8728. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8729. return await this.giveawaySu(link);
  8730. }
  8731. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8732. return await this.giveeClub(link);
  8733. }
  8734. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8735. return await this.gleam(link);
  8736. }
  8737. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8738. return await this.indieDb(link);
  8739. }
  8740. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8741. return await this.keyhub(link);
  8742. }
  8743. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8744. return await this.opquests(link);
  8745. }
  8746. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8747. return await this.itch(link);
  8748. }
  8749. return false;
  8750. } catch (error) {
  8751. throwError(error, 'leftKeyChecker.classify');
  8752. return false;
  8753. }
  8754. },
  8755. async giveawaySu(link) {
  8756. try {
  8757. const {
  8758. result,
  8759. data
  8760. } = await tools_httpRequest({
  8761. url: link,
  8762. method: 'GET'
  8763. });
  8764. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8765. if (data.responseText.includes('class="steam-login"')) {
  8766. return false;
  8767. }
  8768. if (data.responseText.includes('class="giveaway-ended"')) {
  8769. return 'Ended';
  8770. }
  8771. return 'Active';
  8772. }
  8773. return false;
  8774. } catch (error) {
  8775. throwError(error, 'leftKeyChecker.giveawaySu');
  8776. return false;
  8777. }
  8778. },
  8779. async giveeClub(link) {
  8780. try {
  8781. const {
  8782. result,
  8783. data
  8784. } = await tools_httpRequest({
  8785. url: link,
  8786. method: 'GET'
  8787. });
  8788. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8789. if (data.responseText.includes('class="event-winner"')) {
  8790. return 'Won';
  8791. }
  8792. if (data.responseText.includes('class="event-ended"')) {
  8793. return 'Ended';
  8794. }
  8795. return 'Active';
  8796. }
  8797. return false;
  8798. } catch (error) {
  8799. throwError(error, 'leftKeyChecker.giveeClub');
  8800. return false;
  8801. }
  8802. },
  8803. async gleam(link) {
  8804. try {
  8805. const {
  8806. result,
  8807. data
  8808. } = await tools_httpRequest({
  8809. url: link,
  8810. method: 'GET'
  8811. });
  8812. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8813. var _data$responseText$ma, _$$attr, _$$attr$match;
  8814. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8815. return 'Won';
  8816. }
  8817. 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];
  8818. if (!campaignDiv) {
  8819. return false;
  8820. }
  8821. 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];
  8822. if (!campaignString) {
  8823. return false;
  8824. }
  8825. const {
  8826. campaign
  8827. } = JSON.parse(campaignString);
  8828. if (campaign.banned) {
  8829. return 'Banned';
  8830. }
  8831. if (campaign.finished) {
  8832. return 'Ended';
  8833. }
  8834. if (campaign.paused) {
  8835. return 'Paused';
  8836. }
  8837. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8838. return 'NotStart';
  8839. }
  8840. return 'Active';
  8841. }
  8842. return false;
  8843. } catch (error) {
  8844. throwError(error, 'leftKeyChecker.gleam');
  8845. return false;
  8846. }
  8847. },
  8848. async indieDb(link) {
  8849. try {
  8850. const {
  8851. result,
  8852. data
  8853. } = await tools_httpRequest({
  8854. url: link,
  8855. method: 'GET'
  8856. });
  8857. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8858. if (data.responseText.includes('Congrats you WON')) {
  8859. return 'Won';
  8860. }
  8861. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8862. return 'Ended';
  8863. }
  8864. return 'Active';
  8865. }
  8866. return false;
  8867. } catch (error) {
  8868. throwError(error, 'leftKeyChecker.indieDb');
  8869. return false;
  8870. }
  8871. },
  8872. async keyhub(link) {
  8873. try {
  8874. const {
  8875. result,
  8876. data
  8877. } = await tools_httpRequest({
  8878. url: link,
  8879. method: 'GET'
  8880. });
  8881. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8882. var _data$responseText$ma2;
  8883. 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];
  8884. if (!keysleft) {
  8885. return false;
  8886. }
  8887. if (keysleft === '0') {
  8888. return 'Ended';
  8889. }
  8890. return `Active(${keysleft})`;
  8891. }
  8892. return false;
  8893. } catch (error) {
  8894. throwError(error, 'leftKeyChecker.keyhub');
  8895. return false;
  8896. }
  8897. },
  8898. async opquests(link) {
  8899. try {
  8900. const {
  8901. result,
  8902. data
  8903. } = await tools_httpRequest({
  8904. url: link,
  8905. method: 'GET'
  8906. });
  8907. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8908. var _data$responseText$ma3;
  8909. 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];
  8910. if (!keysleft) {
  8911. return false;
  8912. }
  8913. if (keysleft === '0') {
  8914. return 'Ended';
  8915. }
  8916. return `Active(${keysleft})`;
  8917. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8918. return 'Ended';
  8919. }
  8920. return false;
  8921. } catch (error) {
  8922. throwError(error, 'leftKeyChecker.opquests');
  8923. return false;
  8924. }
  8925. },
  8926. async itch(link) {
  8927. try {
  8928. const {
  8929. result,
  8930. data
  8931. } = await tools_httpRequest({
  8932. url: link,
  8933. method: 'GET'
  8934. });
  8935. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8936. var _data$responseText$ma4;
  8937. 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];
  8938. if (!endDate) {
  8939. return false;
  8940. }
  8941. if (new Date().getTime() > new Date(endDate).getTime()) {
  8942. return 'Ended';
  8943. }
  8944. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8945. }
  8946. return false;
  8947. } catch (error) {
  8948. throwError(error, 'leftKeyChecker.opquests');
  8949. return false;
  8950. }
  8951. }
  8952. };
  8953. const website_leftKeyChecker = leftKeyChecker;
  8954. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8955. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8956. privateSet.add(obj);
  8957. }
  8958. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8959. if (privateCollection.has(obj)) {
  8960. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8961. }
  8962. }
  8963. function Keylol_defineProperty(obj, key, value) {
  8964. if (key in obj) {
  8965. Object.defineProperty(obj, key, {
  8966. value: value,
  8967. enumerable: true,
  8968. configurable: true,
  8969. writable: true
  8970. });
  8971. } else {
  8972. obj[key] = value;
  8973. }
  8974. return obj;
  8975. }
  8976. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8977. if (!privateSet.has(receiver)) {
  8978. throw new TypeError('attempted to get private field on non-instance');
  8979. }
  8980. return fn;
  8981. }
  8982. const Keylol_defaultTasksTemplate = {
  8983. steam: {
  8984. groupLinks: [],
  8985. wishlistLinks: [],
  8986. curatorLinks: [],
  8987. curatorLikeLinks: [],
  8988. followLinks: [],
  8989. forumLinks: [],
  8990. announcementLinks: [],
  8991. workshopVoteLinks: [],
  8992. licenseLinks: []
  8993. },
  8994. discord: {
  8995. serverLinks: []
  8996. },
  8997. instagram: {
  8998. userLinks: []
  8999. },
  9000. vk: {
  9001. nameLinks: []
  9002. },
  9003. twitch: {
  9004. channelLinks: []
  9005. },
  9006. reddit: {
  9007. redditLinks: []
  9008. },
  9009. twitter: {
  9010. userLinks: [],
  9011. retweetLinks: []
  9012. },
  9013. youtube: {
  9014. channelLinks: [],
  9015. likeLinks: []
  9016. }
  9017. };
  9018. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  9019. var _addBtn = new WeakSet();
  9020. class Keylol extends website_Website {
  9021. constructor() {
  9022. super(...arguments);
  9023. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  9024. Keylol_defineProperty(this, 'name', 'Keylol');
  9025. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  9026. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  9027. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  9028. }
  9029. static test() {
  9030. var _$$eq$attr, _$$eq$attr2;
  9031. return window.location.host === 'keylol.com' && (!!((_$$eq$attr = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr !== void 0 && _$$eq$attr.includes('319')) || !!((_$$eq$attr2 = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr2 !== void 0 && _$$eq$attr2.includes('234')));
  9032. }
  9033. init() {
  9034. return true;
  9035. }
  9036. after() {
  9037. try {
  9038. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  9039. const mainPost = $(selector);
  9040. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  9041. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  9042. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  9043. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  9044. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  9045. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  9046. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  9047. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  9048. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  9049. if (discordLinks.length > 0) {
  9050. for (const discordLink of discordLinks) {
  9051. const link = $(discordLink).attr('href');
  9052. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  9053. continue;
  9054. }
  9055. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  9056. }
  9057. }
  9058. if (redditLinks.length > 0) {
  9059. for (const redditLink of redditLinks) {
  9060. const link = $(redditLink).attr('href');
  9061. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  9062. continue;
  9063. }
  9064. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  9065. }
  9066. }
  9067. if (insLinks.length > 0) {
  9068. for (const insLink of insLinks) {
  9069. const link = $(insLink).attr('href');
  9070. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  9071. continue;
  9072. }
  9073. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  9074. }
  9075. }
  9076. if (twitterLinks.length > 0) {
  9077. for (const twitterLink of twitterLinks) {
  9078. const link = $(twitterLink).attr('href');
  9079. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  9080. continue;
  9081. }
  9082. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  9083. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  9084. } else {
  9085. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  9086. }
  9087. }
  9088. }
  9089. if (twitchLinks.length > 0) {
  9090. for (const twitchLink of twitchLinks) {
  9091. const link = $(twitchLink).attr('href');
  9092. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  9093. continue;
  9094. }
  9095. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9096. }
  9097. }
  9098. if (vkLinks.length > 0) {
  9099. for (const vkLink of vkLinks) {
  9100. const link = $(vkLink).attr('href');
  9101. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9102. continue;
  9103. }
  9104. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9105. }
  9106. }
  9107. if (steamStoreLinks.length > 0) {
  9108. for (const steamStoreLink of steamStoreLinks) {
  9109. const link = $(steamStoreLink).attr('href');
  9110. if (!link) {
  9111. continue;
  9112. }
  9113. if (/curator\/[\d]+/.test(link)) {
  9114. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9115. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9116. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9117. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9118. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9119. } else if (/app\/[\d]+/.test(link)) {
  9120. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9121. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9122. }
  9123. }
  9124. }
  9125. if (steamCommunityLinks.length > 0) {
  9126. for (const steamCommunityLink of steamCommunityLinks) {
  9127. const link = $(steamCommunityLink).attr('href');
  9128. if (!link) {
  9129. continue;
  9130. }
  9131. if (/groups\/.+/.test(link)) {
  9132. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9133. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9134. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9135. }
  9136. }
  9137. }
  9138. if (ytbLinks.length > 0) {
  9139. for (const ytbLink of ytbLinks) {
  9140. const link = $(ytbLink).attr('href');
  9141. if (!link) {
  9142. continue;
  9143. }
  9144. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9145. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9146. }
  9147. }
  9148. const giveawayLinks = mainPost.find('a[href*="giveaway.su/giveaway/view/"]:visible,a[href*="givee.club/"]:visible,a[href*="gleam.io/"]:visible,a[href*="www.indiedb.com/giveaways/"]:visible,a[href*="key-hub.eu/giveaway/"]:visible,a[href*="opquests.com/quests/"]:visible,a[href*="itch.io/s/"]:visible');
  9149. if (giveawayLinks.length > 0) {
  9150. for (const giveawayLink of giveawayLinks) {
  9151. const link = $(giveawayLink).attr('href');
  9152. if (!link) {
  9153. continue;
  9154. }
  9155. website_leftKeyChecker.classify(link).then(status => {
  9156. if (!status) {
  9157. return;
  9158. }
  9159. if (/^Active/.test(status)) {
  9160. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9161. return;
  9162. }
  9163. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9164. }).catch(error => {
  9165. throwError(error, 'keylol.after -> leftKeyChecker');
  9166. });
  9167. }
  9168. }
  9169. if (this.name === 'Keylol') {
  9170. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9171. if (asfLinks.length > 0) {
  9172. for (const asfLink of asfLinks) {
  9173. const link = $(asfLink).attr('href');
  9174. if (!link) {
  9175. continue;
  9176. }
  9177. 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', '')}`);
  9178. }
  9179. }
  9180. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9181. if (subLinks.length > 0) {
  9182. for (const subLink of subLinks) {
  9183. var _link$match;
  9184. const link = $(subLink).attr('href');
  9185. if (!link) {
  9186. continue;
  9187. }
  9188. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9189. if (!subid) {
  9190. continue;
  9191. }
  9192. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9193. }
  9194. }
  9195. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9196. if (asfLinks2.length > 0) {
  9197. for (const asfLink of asfLinks2) {
  9198. const subid = asfLink.innerText.match(/[\d]+/g);
  9199. if (!subid || subid.length === 0) {
  9200. continue;
  9201. }
  9202. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9203. }
  9204. }
  9205. }
  9206. } catch (error) {
  9207. throwError(error, 'keylol.after');
  9208. }
  9209. }
  9210. classifyTask(action) {
  9211. try {
  9212. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9213. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9214. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9215. for (const btn of selectedBtns) {
  9216. const button = $(btn);
  9217. const social = button.attr('data-social');
  9218. const type = button.attr('data-type');
  9219. const link = button.attr('data-link');
  9220. if (!(social && type && link)) {
  9221. continue;
  9222. }
  9223. if (action === 'do') {
  9224. this.undoneTasks[social][type].push(link);
  9225. }
  9226. if (action === 'undo') {
  9227. this.socialTasks[social][type].push(link);
  9228. }
  9229. }
  9230. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9231. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9232. if (window.DEBUG) {
  9233. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9234. }
  9235. return true;
  9236. } catch (error) {
  9237. throwError(error, 'Keylol.classifyTask');
  9238. return false;
  9239. }
  9240. }
  9241. selectAll() {
  9242. try {
  9243. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9244. } catch (error) {
  9245. throwError(error, 'Keylol.selectAll');
  9246. }
  9247. }
  9248. selectNone() {
  9249. try {
  9250. $('.auto-task-keylol:visible').removeAttr('selected');
  9251. } catch (error) {
  9252. throwError(error, 'Keylol.selectNone');
  9253. }
  9254. }
  9255. invertSelect() {
  9256. try {
  9257. $('.auto-task-keylol:visible').each((index, element) => {
  9258. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9259. });
  9260. } catch (error) {
  9261. throwError(error, 'Keylol.invertSelect');
  9262. }
  9263. }
  9264. }
  9265. function _addBtn2(before, social, linkType, link) {
  9266. try {
  9267. $(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>`);
  9268. } catch (error) {
  9269. throwError(error, 'keylol.addBtn');
  9270. }
  9271. }
  9272. const website_Keylol = Keylol;
  9273. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9274. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9275. privateSet.add(obj);
  9276. }
  9277. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9278. if (privateCollection.has(obj)) {
  9279. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9280. }
  9281. }
  9282. function Opquests_defineProperty(obj, key, value) {
  9283. if (key in obj) {
  9284. Object.defineProperty(obj, key, {
  9285. value: value,
  9286. enumerable: true,
  9287. configurable: true,
  9288. writable: true
  9289. });
  9290. } else {
  9291. obj[key] = value;
  9292. }
  9293. return obj;
  9294. }
  9295. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9296. if (!privateSet.has(receiver)) {
  9297. throw new TypeError('attempted to get private field on non-instance');
  9298. }
  9299. return fn;
  9300. }
  9301. const Opquests_defaultTasks = {
  9302. steam: {
  9303. groupLinks: [],
  9304. wishlistLinks: [],
  9305. followLinks: [],
  9306. curatorLikeLinks: []
  9307. }
  9308. };
  9309. var Opquests_getGiveawayId = new WeakSet();
  9310. var Opquests_checkLogin = new WeakSet();
  9311. class Opquests extends website_Website {
  9312. constructor() {
  9313. super(...arguments);
  9314. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9315. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9316. Opquests_defineProperty(this, 'name', 'Opquests');
  9317. Opquests_defineProperty(this, 'undoneTasks', {
  9318. ...Opquests_defaultTasks
  9319. });
  9320. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9321. }
  9322. static test() {
  9323. return window.location.host === 'opquests.com';
  9324. }
  9325. async after() {
  9326. try {
  9327. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9328. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9329. }
  9330. } catch (error) {
  9331. throwError(error, 'Opquests.after');
  9332. }
  9333. }
  9334. init() {
  9335. try {
  9336. const logStatus = scripts_echoLog({
  9337. text: i18n('initing')
  9338. });
  9339. if ($('a[href*="/auth/redirect"]').length > 0) {
  9340. window.open('/auth/redirect', '_self');
  9341. logStatus.warning(i18n('needLogin'));
  9342. return false;
  9343. }
  9344. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9345. return false;
  9346. }
  9347. this.initialized = true;
  9348. logStatus.success();
  9349. return true;
  9350. } catch (error) {
  9351. throwError(error, 'Opquests.init');
  9352. return false;
  9353. }
  9354. }
  9355. async classifyTask(action) {
  9356. try {
  9357. if (action === 'undo') {
  9358. scripts_echoLog({
  9359. text: i18n('cannotUndo')
  9360. });
  9361. return false;
  9362. }
  9363. const logStatus = scripts_echoLog({
  9364. text: i18n('getTasksInfo')
  9365. });
  9366. const tasks = $('.w-full:contains("Validate") .items-center');
  9367. for (const task of tasks) {
  9368. const link = $(task).find('a:contains("Open")').attr('href');
  9369. const taskDes = $(task).find('div').eq(1).text().trim();
  9370. if (!link) {
  9371. continue;
  9372. }
  9373. if (/steamcommunity\.com\/groups\//.test(link)) {
  9374. this.undoneTasks.steam.groupLinks.push(link);
  9375. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9376. if (/wishlist/gim.test(taskDes)) {
  9377. this.undoneTasks.steam.wishlistLinks.push(link);
  9378. } else if (/follow/gim.test(taskDes)) {
  9379. this.undoneTasks.steam.followLinks.push(link);
  9380. }
  9381. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9382. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9383. } else {
  9384. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9385. }
  9386. }
  9387. logStatus.success();
  9388. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9389. if (window.DEBUG) {
  9390. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9391. }
  9392. return true;
  9393. } catch (error) {
  9394. throwError(error, 'Opquests.classifyTask');
  9395. return false;
  9396. }
  9397. }
  9398. }
  9399. function Opquests_getGiveawayId2() {
  9400. try {
  9401. var _window$location$href;
  9402. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9403. if (giveawayId) {
  9404. this.giveawayId = giveawayId;
  9405. return true;
  9406. }
  9407. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9408. return false;
  9409. } catch (error) {
  9410. throwError(error, 'Opquests.getGiveawayId');
  9411. return false;
  9412. }
  9413. }
  9414. function Opquests_checkLogin2() {
  9415. try {
  9416. if (!globalOptions.other.checkLogin) {
  9417. return true;
  9418. }
  9419. if ($('a[href*="/auth/redirect"]').length > 0) {
  9420. window.open('/auth/redirect', '_self');
  9421. }
  9422. return true;
  9423. } catch (error) {
  9424. throwError(error, 'Opquests.checkLogin');
  9425. return false;
  9426. }
  9427. }
  9428. const website_Opquests = Opquests;
  9429. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9430. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9431. privateSet.add(obj);
  9432. }
  9433. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9434. if (privateCollection.has(obj)) {
  9435. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9436. }
  9437. }
  9438. function Gleam_defineProperty(obj, key, value) {
  9439. if (key in obj) {
  9440. Object.defineProperty(obj, key, {
  9441. value: value,
  9442. enumerable: true,
  9443. configurable: true,
  9444. writable: true
  9445. });
  9446. } else {
  9447. obj[key] = value;
  9448. }
  9449. return obj;
  9450. }
  9451. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9452. if (!privateSet.has(receiver)) {
  9453. throw new TypeError('attempted to get private field on non-instance');
  9454. }
  9455. return fn;
  9456. }
  9457. const Gleam_defaultTasksTemplate = {
  9458. steam: {
  9459. groupLinks: [],
  9460. wishlistLinks: [],
  9461. followLinks: [],
  9462. curatorLinks: [],
  9463. curatorLikeLinks: []
  9464. },
  9465. twitter: {
  9466. userLinks: [],
  9467. retweetLinks: []
  9468. },
  9469. twitch: {
  9470. channelLinks: []
  9471. },
  9472. discord: {
  9473. serverLinks: []
  9474. },
  9475. youtube: {
  9476. channelLinks: []
  9477. },
  9478. extra: {
  9479. gleam: []
  9480. }
  9481. };
  9482. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9483. const Gleam_defaultOptions = {
  9484. vlootUsername: '',
  9485. gameroundUsername: ''
  9486. };
  9487. var _checkSync = new WeakSet();
  9488. var _doGleamTask = new WeakSet();
  9489. var Gleam_getGiveawayId = new WeakSet();
  9490. var _getGleamLink = new WeakSet();
  9491. var Gleam_checkLeftKey = new WeakSet();
  9492. class Gleam extends website_Website {
  9493. constructor() {
  9494. super(...arguments);
  9495. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9496. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9497. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9498. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9499. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9500. Gleam_defineProperty(this, 'name', 'Gleam');
  9501. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9502. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9503. Gleam_defineProperty(this, 'options', {
  9504. ...Gleam_defaultOptions,
  9505. ...GM_getValue('GleamOptions')
  9506. });
  9507. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9508. }
  9509. static test() {
  9510. return window.location.host === 'gleam.io';
  9511. }
  9512. async after() {
  9513. try {
  9514. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9515. const checkComplete = setInterval(() => {
  9516. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9517. clearInterval(checkComplete);
  9518. window.close();
  9519. }
  9520. });
  9521. for (const task of $('.entry-content .entry-method')) {
  9522. const taskInfo = $(task).find('.user-links');
  9523. const expandInfo = $(task).find('.expandable');
  9524. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9525. if (aElements.length > 0) {
  9526. for (const element of aElements) {
  9527. const $element = $(element);
  9528. const href = $element.attr('href');
  9529. $element.removeAttr('href')[0].click();
  9530. $element.attr('href', href);
  9531. await delay(1e3);
  9532. }
  9533. }
  9534. taskInfo[0].click();
  9535. await delay(1e3);
  9536. }
  9537. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9538. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9539. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9540. }
  9541. } catch (error) {
  9542. throwError(error, 'Gleam.after');
  9543. return false;
  9544. }
  9545. }
  9546. init() {
  9547. try {
  9548. const logStatus = scripts_echoLog({
  9549. text: i18n('initing')
  9550. });
  9551. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9552. return false;
  9553. }
  9554. this.initialized = true;
  9555. logStatus.success();
  9556. return true;
  9557. } catch (error) {
  9558. throwError(error, 'Gleam.init');
  9559. return false;
  9560. }
  9561. }
  9562. async classifyTask(action) {
  9563. try {
  9564. const logStatus = scripts_echoLog({
  9565. text: i18n('getTasksInfo')
  9566. });
  9567. if (action === 'undo') {
  9568. var _GM_getValue;
  9569. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9570. }
  9571. const tasks = $('.entry-content .entry-method');
  9572. for (const task of tasks) {
  9573. var _socialIcon$attr;
  9574. const $task = $(task);
  9575. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9576. continue;
  9577. }
  9578. const socialIcon = $task.find('.icon-wrapper i');
  9579. const taskInfo = $task.find('.user-links');
  9580. const taskText = taskInfo.text().trim();
  9581. const expandInfo = $task.find('.expandable');
  9582. const aElements = expandInfo.find('a.btn');
  9583. if (aElements.length > 0) {
  9584. for (const element of aElements) {
  9585. const $element = $(element);
  9586. const href = $element.attr('href');
  9587. $element.removeAttr('href')[0].click();
  9588. $element.attr('href', href);
  9589. }
  9590. }
  9591. if (socialIcon.hasClass('fa-twitter')) {
  9592. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9593. if (!link) {
  9594. continue;
  9595. }
  9596. if (/follow/gi.test(taskText)) {
  9597. if (action === 'undo') {
  9598. this.socialTasks.twitter.userLinks.push(link);
  9599. }
  9600. if (action === 'do') {
  9601. this.undoneTasks.twitter.userLinks.push(link);
  9602. }
  9603. } else if (/retweet/gim.test(taskText)) {
  9604. if (action === 'undo') {
  9605. this.socialTasks.twitter.retweetLinks.push(link);
  9606. }
  9607. if (action === 'do') {
  9608. this.undoneTasks.twitter.retweetLinks.push(link);
  9609. }
  9610. }
  9611. } else if (socialIcon.hasClass('fa-twitch')) {
  9612. if (/follow/gim.test(taskText)) {
  9613. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9614. if (!link) {
  9615. continue;
  9616. }
  9617. if (action === 'undo') {
  9618. this.socialTasks.twitch.channelLinks.push(link);
  9619. }
  9620. if (action === 'do') {
  9621. this.undoneTasks.twitch.channelLinks.push(link);
  9622. }
  9623. }
  9624. } else if (socialIcon.hasClass('fa-discord')) {
  9625. if (/join/gim.test(taskText)) {
  9626. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9627. if (!link) {
  9628. var _$task$find$attr, _$task$find$attr$matc;
  9629. 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];
  9630. if (!ggLink) {
  9631. continue;
  9632. }
  9633. link = `https://discord.com/invite/${ggLink}`;
  9634. }
  9635. if (action === 'undo') {
  9636. this.socialTasks.discord.serverLinks.push(link);
  9637. }
  9638. if (action === 'do') {
  9639. this.undoneTasks.discord.serverLinks.push(link);
  9640. }
  9641. }
  9642. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9643. continue;
  9644. } else if (socialIcon.hasClass('fa-youtube')) {
  9645. if (/subscribe/gim.test(taskText)) {
  9646. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9647. if (!link) {
  9648. continue;
  9649. }
  9650. if (action === 'undo') {
  9651. this.socialTasks.youtube.channelLinks.push(link);
  9652. }
  9653. if (action === 'do') {
  9654. this.undoneTasks.youtube.channelLinks.push(link);
  9655. }
  9656. }
  9657. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9658. if (/join.*group/gi.test(taskText)) {
  9659. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9660. if (!link) {
  9661. continue;
  9662. }
  9663. if (action === 'undo') {
  9664. this.socialTasks.steam.groupLinks.push(link);
  9665. }
  9666. if (action === 'do') {
  9667. this.undoneTasks.steam.groupLinks.push(link);
  9668. }
  9669. } else if (/follow.*curator/gi.test(taskText)) {
  9670. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9671. if (!link) {
  9672. continue;
  9673. }
  9674. if (action === 'undo') {
  9675. this.socialTasks.steam.curatorLinks.push(link);
  9676. }
  9677. if (action === 'do') {
  9678. this.undoneTasks.steam.curatorLinks.push(link);
  9679. }
  9680. }
  9681. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9682. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9683. for (const button of continueBtn) {
  9684. button.click();
  9685. await delay(500);
  9686. expandInfo.find('input').val(this.options.vlootUsername);
  9687. }
  9688. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9689. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9690. for (const button of continueBtn) {
  9691. button.click();
  9692. await delay(500);
  9693. expandInfo.find('input').val(this.options.gameroundUsername);
  9694. }
  9695. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9696. if (action !== 'do') {
  9697. continue;
  9698. }
  9699. const link = aElements.attr('href');
  9700. if (!link) {
  9701. continue;
  9702. }
  9703. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9704. if (!gleamLink) {
  9705. continue;
  9706. }
  9707. this.undoneTasks.extra.gleam.push(gleamLink);
  9708. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-instagram') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-telegram-plane') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  9709. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9710. }
  9711. }
  9712. logStatus.success();
  9713. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9714. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9715. if (window.DEBUG) {
  9716. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9717. }
  9718. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9719. tasks: this.socialTasks,
  9720. time: new Date().getTime()
  9721. });
  9722. return true;
  9723. } catch (error) {
  9724. throwError(error, 'Gleam.classifyTask');
  9725. return false;
  9726. }
  9727. }
  9728. async extraDoTask(_ref) {
  9729. let {
  9730. gleam
  9731. } = _ref;
  9732. try {
  9733. const pro = [];
  9734. for (const link of gleam) {
  9735. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9736. }
  9737. return Promise.all(pro).then(() => true);
  9738. } catch (error) {
  9739. throwError(error, 'Gleam.extraDoTask');
  9740. return false;
  9741. }
  9742. }
  9743. async verifyTask() {
  9744. try {
  9745. scripts_echoLog({
  9746. text: `${i18n('verifyingTask')}...`
  9747. });
  9748. const tasks = $('.entry-content .entry-method');
  9749. for (const task of tasks) {
  9750. const $task = $(task);
  9751. if ($task.find('i.fa-question').length === 0) {
  9752. continue;
  9753. }
  9754. const taskInfo = $task.find('.user-links');
  9755. taskInfo[0].click();
  9756. await delay(500);
  9757. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9758. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9759. for (const button of continueBtn) {
  9760. button.click();
  9761. await delay(500);
  9762. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9763. }
  9764. }
  9765. scripts_echoLog({
  9766. text: i18n('verifiedGleamTasks')
  9767. });
  9768. } catch (error) {
  9769. throwError(error, 'Gleam.verifyTask');
  9770. return false;
  9771. }
  9772. }
  9773. }
  9774. async function _checkSync2() {
  9775. try {
  9776. return await new Promise(resolve => {
  9777. const checker = setInterval(() => {
  9778. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9779. clearInterval(checker);
  9780. resolve(true);
  9781. }
  9782. }, 500);
  9783. });
  9784. } catch (error) {
  9785. throwError(error, 'Gleam.checkSync');
  9786. return false;
  9787. }
  9788. }
  9789. async function _doGleamTask2(link) {
  9790. try {
  9791. const logStatus = scripts_echoLog({
  9792. text: i18n('doingGleamTask')
  9793. });
  9794. return await new Promise(resolve => {
  9795. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9796. active: true,
  9797. insert: true,
  9798. setParent: true
  9799. }).onclose = () => {
  9800. logStatus.success();
  9801. resolve(true);
  9802. };
  9803. });
  9804. } catch (error) {
  9805. throwError(error, 'Gleam.doGleamTask');
  9806. return false;
  9807. }
  9808. }
  9809. function Gleam_getGiveawayId2() {
  9810. try {
  9811. const giveawayId = window.location.pathname;
  9812. if (giveawayId) {
  9813. this.giveawayId = giveawayId;
  9814. return true;
  9815. }
  9816. scripts_echoLog({
  9817. text: i18n('getFailed', 'GiveawayId')
  9818. });
  9819. return false;
  9820. } catch (error) {
  9821. throwError(error, 'Gleam.getGiveawayId');
  9822. return false;
  9823. }
  9824. }
  9825. async function _getGleamLink2(link) {
  9826. try {
  9827. const logStatus = scripts_echoLog({
  9828. text: i18n('gettingGleamLink')
  9829. });
  9830. const {
  9831. result,
  9832. statusText,
  9833. status,
  9834. data
  9835. } = await tools_httpRequest({
  9836. url: link,
  9837. method: 'GET'
  9838. });
  9839. if (result === 'Success') {
  9840. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9841. var _data$responseText$ma;
  9842. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9843. if (gleamLink) {
  9844. logStatus.success();
  9845. return gleamLink;
  9846. }
  9847. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9848. return false;
  9849. }
  9850. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9851. return false;
  9852. }
  9853. logStatus.error(`${result}:${statusText}(${status})`);
  9854. return false;
  9855. } catch (error) {
  9856. throwError(error, 'Gleam.getGleamLink');
  9857. return false;
  9858. }
  9859. }
  9860. async function Gleam_checkLeftKey2() {
  9861. try {
  9862. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9863. if (!globalOptions.other.checkLeftKey) {
  9864. return true;
  9865. }
  9866. 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];
  9867. if (!campaignString) {
  9868. return false;
  9869. }
  9870. const {
  9871. campaign,
  9872. incentive
  9873. } = JSON.parse(campaignString);
  9874. 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];
  9875. let ownedKey = false;
  9876. if (controllerString) {
  9877. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9878. 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) {
  9879. ownedKey = true;
  9880. }
  9881. }
  9882. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9883. await external_Swal_default().fire({
  9884. icon: 'warning',
  9885. title: i18n('notice'),
  9886. text: i18n('giveawayNotWork'),
  9887. confirmButtonText: i18n('confirm'),
  9888. cancelButtonText: i18n('cancel'),
  9889. showCancelButton: true
  9890. }).then(_ref2 => {
  9891. let {
  9892. value
  9893. } = _ref2;
  9894. if (value) {
  9895. window.close();
  9896. }
  9897. });
  9898. }
  9899. return true;
  9900. } catch (error) {
  9901. throwError(error, 'Gleam.checkLeftKey');
  9902. return false;
  9903. }
  9904. }
  9905. const website_Gleam = Gleam;
  9906. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9907. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9908. privateSet.add(obj);
  9909. }
  9910. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9911. if (privateCollection.has(obj)) {
  9912. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9913. }
  9914. }
  9915. function SweepWidget_defineProperty(obj, key, value) {
  9916. if (key in obj) {
  9917. Object.defineProperty(obj, key, {
  9918. value: value,
  9919. enumerable: true,
  9920. configurable: true,
  9921. writable: true
  9922. });
  9923. } else {
  9924. obj[key] = value;
  9925. }
  9926. return obj;
  9927. }
  9928. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9929. if (!privateSet.has(receiver)) {
  9930. throw new TypeError('attempted to get private field on non-instance');
  9931. }
  9932. return fn;
  9933. }
  9934. const SweepWidget_defaultOptions = {
  9935. username: '',
  9936. email: ''
  9937. };
  9938. var SweepWidget_checkLogin = new WeakSet();
  9939. var SweepWidget_getGiveawayId = new WeakSet();
  9940. var _checkEnter = new WeakSet();
  9941. var _checkFinish = new WeakSet();
  9942. class SweepWidget extends website_Website {
  9943. constructor() {
  9944. super(...arguments);
  9945. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9946. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9947. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9948. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9949. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9950. SweepWidget_defineProperty(this, 'options', {
  9951. ...SweepWidget_defaultOptions,
  9952. ...GM_getValue('SweepWidgetOptions')
  9953. });
  9954. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9955. }
  9956. static test() {
  9957. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9958. }
  9959. async after() {
  9960. try {
  9961. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9962. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9963. }
  9964. } catch (error) {
  9965. throwError(error, 'SweepWidget.after');
  9966. }
  9967. }
  9968. init() {
  9969. try {
  9970. const logStatus = scripts_echoLog({
  9971. text: i18n('initing')
  9972. });
  9973. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9974. logStatus.warning(i18n('needLogin'));
  9975. return false;
  9976. }
  9977. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9978. return false;
  9979. }
  9980. this.initialized = true;
  9981. logStatus.success();
  9982. return true;
  9983. } catch (error) {
  9984. throwError(error, 'SweepWidget.init');
  9985. return false;
  9986. }
  9987. }
  9988. classifyTask() {
  9989. return true;
  9990. }
  9991. async doTask() {
  9992. try {
  9993. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9994. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9995. $('input[name="sw__login_name"]').val(this.options.username);
  9996. }
  9997. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9998. $('input[name="sw__login_email"]').val(this.options.email);
  9999. }
  10000. if ($('#sw_login_button:visible').length > 0) {
  10001. $('#sw_login_button')[0].click();
  10002. }
  10003. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  10004. return false;
  10005. }
  10006. }
  10007. const logStatus = scripts_echoLog({
  10008. text: i18n('SweepWidgetNotice')
  10009. });
  10010. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  10011. for (const task of tasks) {
  10012. var _aElement$, _$task$find$removeAtt;
  10013. const $task = $(task);
  10014. if ($task.find('i.fa-check:visible').length > 0) {
  10015. continue;
  10016. }
  10017. const title = $task.find('.sw_text_inner');
  10018. title[0].click();
  10019. const aElement = $task.find('a.sw_link');
  10020. const link = aElement.attr('href');
  10021. aElement.attr('href', '#a').attr('target', '_self');
  10022. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  10023. await delay(300);
  10024. aElement.attr('href', link).attr('target', '_blank');
  10025. $task.find('input[type="text"]').val('test');
  10026. const verifyBtn = $task.find('input.sw_verify');
  10027. if (verifyBtn.prop('disabled') === true) {
  10028. title[0].click();
  10029. await delay(300);
  10030. title[0].click();
  10031. await delay(300);
  10032. }
  10033. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  10034. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  10035. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  10036. }
  10037. logStatus.success();
  10038. return true;
  10039. } catch (error) {
  10040. throwError(error, 'SweepWidget.doTask');
  10041. return false;
  10042. }
  10043. }
  10044. }
  10045. function SweepWidget_checkLogin2() {
  10046. try {
  10047. if ($('#twitter_login_button').length > 0) {
  10048. $('#twitter_login_button')[0].click();
  10049. }
  10050. return true;
  10051. } catch (error) {
  10052. throwError(error, 'SweepWidget.checkLogin');
  10053. return false;
  10054. }
  10055. }
  10056. function SweepWidget_getGiveawayId2() {
  10057. try {
  10058. var _window$location$href;
  10059. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  10060. if (giveawayId) {
  10061. this.giveawayId = giveawayId;
  10062. return true;
  10063. }
  10064. scripts_echoLog({
  10065. text: i18n('getFailed', 'GiveawayId')
  10066. });
  10067. return false;
  10068. } catch (error) {
  10069. throwError(error, 'SweepWidget.getGiveawayId');
  10070. return false;
  10071. }
  10072. }
  10073. async function _checkEnter2() {
  10074. try {
  10075. return new Promise(resolve => {
  10076. const checker = setInterval(() => {
  10077. if ($('#unlock_rewards_main_wrapper').length > 0) {
  10078. clearInterval(checker);
  10079. resolve(true);
  10080. }
  10081. });
  10082. });
  10083. } catch (error) {
  10084. throwError(error, 'SweepWidget.checkEnter');
  10085. return false;
  10086. }
  10087. }
  10088. async function _checkFinish2($task) {
  10089. try {
  10090. return new Promise(resolve => {
  10091. const checker = setInterval(() => {
  10092. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  10093. clearInterval(checker);
  10094. resolve(true);
  10095. }
  10096. });
  10097. });
  10098. } catch (error) {
  10099. throwError(error, 'SweepWidget.checkFinish');
  10100. return false;
  10101. }
  10102. }
  10103. const website_SweepWidget = SweepWidget;
  10104. const defaultWhiteList = {
  10105. discord: {
  10106. servers: []
  10107. },
  10108. instagram: {
  10109. users: []
  10110. },
  10111. twitch: {
  10112. channels: []
  10113. },
  10114. twitter: {
  10115. users: [],
  10116. retweets: [],
  10117. likes: []
  10118. },
  10119. vk: {
  10120. names: []
  10121. },
  10122. youtube: {
  10123. channels: [],
  10124. likes: []
  10125. },
  10126. reddit: {
  10127. reddits: []
  10128. },
  10129. steam: {
  10130. groups: [],
  10131. officialGroups: [],
  10132. wishlists: [],
  10133. follows: [],
  10134. forums: [],
  10135. workshops: [],
  10136. curators: [],
  10137. workshopVotes: [],
  10138. curatorLikes: [],
  10139. announcements: [],
  10140. licenses: [],
  10141. playtests: []
  10142. }
  10143. };
  10144. const link2id = async function(type) {
  10145. 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;
  10146. try {
  10147. const link = $('#socialLink').val();
  10148. let id = '';
  10149. switch (type) {
  10150. case 'discord.servers':
  10151. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10152. break;
  10153.  
  10154. case 'instagram.users':
  10155. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10156. break;
  10157.  
  10158. case 'twitch.channels':
  10159. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10160. break;
  10161.  
  10162. case 'twitter.users':
  10163. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10164. break;
  10165.  
  10166. case 'twitter.retweets':
  10167. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10168. break;
  10169.  
  10170. case 'vk.names':
  10171. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10172. break;
  10173.  
  10174. case 'youtube.channels':
  10175. 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) || '';
  10176. break;
  10177.  
  10178. case 'youtube.likes':
  10179. 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) || '';
  10180. break;
  10181.  
  10182. case 'reddit.reddits':
  10183. 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]) || '';
  10184. break;
  10185.  
  10186. case 'steam.groups':
  10187. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10188. break;
  10189.  
  10190. case 'steam.wishlists':
  10191. case 'steam.follows':
  10192. case 'steam.forums':
  10193. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10194. break;
  10195.  
  10196. case 'steam.workshops':
  10197. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10198. break;
  10199.  
  10200. case 'steam.curators':
  10201. {
  10202. if (link.includes('curator')) {
  10203. var _link$match12;
  10204. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10205. } else {
  10206. var _link$match13;
  10207. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10208. if (!param || param.length !== 2) {
  10209. break;
  10210. }
  10211. const steam = new social_Steam();
  10212. if (await steam.init()) {
  10213. id = await steam.getCuratorId(param[0], param[1]) || '';
  10214. }
  10215. }
  10216. }
  10217. break;
  10218. }
  10219. return id;
  10220. } catch (error) {
  10221. throwError(error, 'link2id');
  10222. return i18n('getFailed', 'id');
  10223. }
  10224. };
  10225. const disabledType = {
  10226. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10227. twitter: [ 'likes' ]
  10228. };
  10229. const assignWhiteList = whiteList => {
  10230. try {
  10231. const newWhiteList = {};
  10232. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10233. newWhiteList[key] = {
  10234. ...value,
  10235. ...whiteList[key]
  10236. };
  10237. }
  10238. return newWhiteList;
  10239. } catch (error) {
  10240. throwError(error, 'assignWhiteList');
  10241. return defaultWhiteList;
  10242. }
  10243. };
  10244. const whiteListOptions = function(showType) {
  10245. try {
  10246. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10247. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10248. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10249. for (const [ social, types ] of Object.entries(whiteList)) {
  10250. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10251. var _disabledType$social;
  10252. 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>`;
  10253. }).join('');
  10254. }
  10255. whiteListOptionsForm += '</tbody></table></form>';
  10256. if (showType === 'swal') {
  10257. external_Swal_default().fire({
  10258. title: i18n('whiteListOptions'),
  10259. html: whiteListOptionsForm,
  10260. showConfirmButton: false,
  10261. showCloseButton: true
  10262. });
  10263. } else {
  10264. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10265. }
  10266. $('.editWhiteList').on('click', function() {
  10267. var _whiteList$social;
  10268. const value = $(this).attr('data-value');
  10269. if (!value) {
  10270. return;
  10271. }
  10272. const [ social, type ] = value.split('.');
  10273. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10274. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10275. return;
  10276. }
  10277. external_Swal_default().fire({
  10278. title: i18n('changeWhiteListOption', value),
  10279. input: 'textarea',
  10280. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10281. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10282. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10283. inputValue: whiteList[social][type].join('\n'),
  10284. showConfirmButton: true,
  10285. confirmButtonText: i18n('save'),
  10286. showCancelButton: true,
  10287. cancelButtonText: i18n('close'),
  10288. showDenyButton: true,
  10289. denyButtonText: i18n('return')
  10290. }).then(_ref => {
  10291. let {
  10292. isDenied,
  10293. isConfirmed,
  10294. value
  10295. } = _ref;
  10296. if (isDenied) {
  10297. if (showType === 'swal') {
  10298. whiteListOptions(showType);
  10299. }
  10300. return;
  10301. } else if (isConfirmed) {
  10302. whiteList[social][type] = value.split('\n');
  10303. GM_setValue('whiteList', whiteList);
  10304. external_Swal_default().fire({
  10305. title: i18n('changeWhiteListSuccess'),
  10306. icon: 'success'
  10307. });
  10308. }
  10309. });
  10310. $('#link2id').on('click', async function() {
  10311. const type = $(this).attr('data-type');
  10312. $('#socialLink').val(await link2id(type));
  10313. });
  10314. });
  10315. } catch (error) {
  10316. throwError(error, 'whiteListOptions');
  10317. }
  10318. };
  10319. const whiteList = whiteListOptions;
  10320. const setGistData = async (token, gistId, fileName, content) => {
  10321. try {
  10322. const logStatus = scripts_echoLog({
  10323. text: i18n('settingData')
  10324. });
  10325. const contentData = JSON.stringify({
  10326. files: {
  10327. [fileName]: {
  10328. content: JSON.stringify(content)
  10329. }
  10330. }
  10331. });
  10332. const {
  10333. result,
  10334. statusText,
  10335. status,
  10336. data
  10337. } = await tools_httpRequest({
  10338. url: `https://api.github.com/gists/${gistId}`,
  10339. headers: {
  10340. Accept: 'application/vnd.github.v3+json',
  10341. Authorization: `token ${token}`
  10342. },
  10343. data: contentData,
  10344. responseType: 'json',
  10345. method: 'POST',
  10346. timeout: 3e4
  10347. });
  10348. if (result === 'Success') {
  10349. var _data$response$files, _data$response$files$;
  10350. 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)) {
  10351. logStatus.success();
  10352. return true;
  10353. }
  10354. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10355. return false;
  10356. }
  10357. logStatus.error(`${result}:${statusText}(${status})`);
  10358. return false;
  10359. } catch (error) {
  10360. throwError(error, 'setGistData');
  10361. return false;
  10362. }
  10363. };
  10364. const getGistData = async function(token, gistId, fileName) {
  10365. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10366. try {
  10367. const logStatus = scripts_echoLog({
  10368. text: i18n('gettingData')
  10369. });
  10370. const {
  10371. result,
  10372. statusText,
  10373. status,
  10374. data
  10375. } = await tools_httpRequest({
  10376. url: `https://api.github.com/gists/${gistId}`,
  10377. headers: {
  10378. Accept: 'application/vnd.github.v3+json',
  10379. Authorization: `token ${token}`
  10380. },
  10381. responseType: 'json',
  10382. method: 'GET',
  10383. timeout: 3e4
  10384. });
  10385. if (result === 'Success') {
  10386. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10387. var _data$response, _data$response$files2, _data$response$files3;
  10388. const content = (_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$files2 = _data$response.files) === null || _data$response$files2 === void 0 ? void 0 : (_data$response$files3 = _data$response$files2[fileName]) === null || _data$response$files3 === void 0 ? void 0 : _data$response$files3.content;
  10389. let formatedContent;
  10390. if (!content) {
  10391. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10392. return false;
  10393. }
  10394. if (test) {
  10395. logStatus.success();
  10396. return true;
  10397. }
  10398. try {
  10399. formatedContent = JSON.parse(content);
  10400. } catch (error) {
  10401. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10402. return false;
  10403. }
  10404. logStatus.success();
  10405. return formatedContent;
  10406. }
  10407. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10408. return false;
  10409. }
  10410. logStatus.error(`${result}:${statusText}(${status})`);
  10411. return false;
  10412. } catch (error) {
  10413. throwError(error, 'getGistData');
  10414. return false;
  10415. }
  10416. };
  10417. const syncOptions = () => {
  10418. try {
  10419. const {
  10420. TOKEN,
  10421. GIST_ID,
  10422. FILE_NAME,
  10423. SYNC_HISTORY
  10424. } = GM_getValue('gistOptions') || {
  10425. TOKEN: '',
  10426. GIST_ID: '',
  10427. FILE_NAME: '',
  10428. SYNC_HISTORY: true
  10429. };
  10430. external_Swal_default().fire({
  10431. title: i18n('gistOptions'),
  10432. 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;">
  10433. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10434. ${i18n('downloadFromGist')}</button></p>`,
  10435. focusConfirm: false,
  10436. showLoaderOnConfirm: true,
  10437. 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>`,
  10438. preConfirm: async () => {
  10439. const token = $('#github-token').val();
  10440. const gistId = $('#gist-id').val();
  10441. const fileName = $('#file-name').val();
  10442. const syncHistory = $('#sync-history').prop('checked');
  10443. GM_setValue('gistOptions', {
  10444. TOKEN: token,
  10445. GIST_ID: gistId,
  10446. FILE_NAME: fileName,
  10447. SYNC_HISTORY: syncHistory
  10448. });
  10449. return await getGistData(token, gistId, fileName, true);
  10450. },
  10451. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10452. confirmButtonText: i18n('saveAndTest'),
  10453. showCancelButton: true,
  10454. cancelButtonText: i18n('close')
  10455. }).then(_ref => {
  10456. let {
  10457. value
  10458. } = _ref;
  10459. if (value) {
  10460. external_Swal_default().fire({
  10461. icon: 'success',
  10462. title: i18n('testSuccess')
  10463. }).then(syncOptions);
  10464. } else if (value !== undefined) {
  10465. external_Swal_default().fire({
  10466. icon: 'error',
  10467. title: i18n('testFailed')
  10468. }).then(syncOptions);
  10469. }
  10470. });
  10471. $('#upload-data').on('click', async () => {
  10472. const {
  10473. TOKEN,
  10474. GIST_ID,
  10475. FILE_NAME
  10476. } = GM_getValue('gistOptions') || {};
  10477. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10478. return external_Swal_default().fire({
  10479. icon: 'error',
  10480. title: i18n('saveAndTestNotice')
  10481. }).then(syncOptions);
  10482. }
  10483. external_Swal_default().fire({
  10484. icon: 'info',
  10485. title: i18n('processingData')
  10486. });
  10487. const data = {};
  10488. const names = GM_listValues();
  10489. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10490. for (const name of names) {
  10491. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10492. continue;
  10493. }
  10494. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10495. continue;
  10496. }
  10497. data[name] = GM_getValue(name);
  10498. }
  10499. external_Swal_default().update({
  10500. icon: 'info',
  10501. title: i18n('updatingData')
  10502. });
  10503. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10504. external_Swal_default().fire({
  10505. icon: 'success',
  10506. title: i18n('syncDataSuccess')
  10507. });
  10508. } else {
  10509. external_Swal_default().fire({
  10510. icon: 'error',
  10511. title: i18n('syncDataFailed')
  10512. });
  10513. }
  10514. });
  10515. $('#download-data').on('click', async () => {
  10516. const {
  10517. TOKEN,
  10518. GIST_ID,
  10519. FILE_NAME
  10520. } = GM_getValue('gistOptions') || {};
  10521. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10522. return external_Swal_default().fire({
  10523. icon: 'error',
  10524. title: i18n('saveAndTestNotice')
  10525. }).then(syncOptions);
  10526. }
  10527. external_Swal_default().fire({
  10528. icon: 'info',
  10529. title: i18n('downloadingData')
  10530. });
  10531. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10532. if (!data) {
  10533. return external_Swal_default().fire({
  10534. icon: 'error',
  10535. title: i18n('checkedNoData')
  10536. }).then(syncOptions);
  10537. }
  10538. external_Swal_default().update({
  10539. icon: 'info',
  10540. title: i18n('savingData')
  10541. });
  10542. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10543. for (const [ name, value ] of Object.entries(data)) {
  10544. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10545. continue;
  10546. }
  10547. GM_setValue(name, value);
  10548. }
  10549. external_Swal_default().fire({
  10550. icon: 'success',
  10551. title: i18n('syncDataSuccess')
  10552. });
  10553. });
  10554. } catch (error) {
  10555. throwError(error, 'syncOptions');
  10556. }
  10557. };
  10558. const dataSync = syncOptions;
  10559. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10560. Setting_checkPrivateRedeclaration(obj, privateSet);
  10561. privateSet.add(obj);
  10562. }
  10563. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10564. if (privateCollection.has(obj)) {
  10565. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10566. }
  10567. }
  10568. function Setting_defineProperty(obj, key, value) {
  10569. if (key in obj) {
  10570. Object.defineProperty(obj, key, {
  10571. value: value,
  10572. enumerable: true,
  10573. configurable: true,
  10574. writable: true
  10575. });
  10576. } else {
  10577. obj[key] = value;
  10578. }
  10579. return obj;
  10580. }
  10581. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10582. if (!privateSet.has(receiver)) {
  10583. throw new TypeError('attempted to get private field on non-instance');
  10584. }
  10585. return fn;
  10586. }
  10587. var Setting_getId = new WeakSet();
  10588. var _environment = new WeakSet();
  10589. class Setting {
  10590. constructor() {
  10591. Setting_classPrivateMethodInitSpec(this, _environment);
  10592. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10593. Setting_defineProperty(this, 'name', 'Setting');
  10594. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10595. Setting_defineProperty(this, 'syncData', dataSync);
  10596. }
  10597. tasksHistory() {
  10598. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10599. }
  10600. static test() {
  10601. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10602. }
  10603. before() {
  10604. $('body').html('').addClass('auto-task-options');
  10605. }
  10606. after() {
  10607. try {
  10608. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10609. changeGlobalOptions('page');
  10610. whiteList('page');
  10611. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10612. $('#getTwitterUserId').on('click', () => {
  10613. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10614. });
  10615. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10616. $('#getYoutubeChannelId').on('click', () => {
  10617. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10618. });
  10619. $('input[name^="position"]').on('input', function() {
  10620. const type = $(this).attr('name').replace('position.', '');
  10621. const xLabel = 'rightleft';
  10622. const yLabel = 'topbottpm';
  10623. switch (type) {
  10624. case 'buttonSideX':
  10625. case 'buttonSideY':
  10626. case 'buttonDistance':
  10627. {
  10628. const distance = $('input[name="position.buttonDistance"]').val();
  10629. const sideX = $('input[name="position.buttonSideX"]').val();
  10630. const sideY = $('input[name="position.buttonSideY"]').val();
  10631. if (![ 'right', 'left' ].includes(sideX)) {
  10632. break;
  10633. }
  10634. if (![ 'top', 'bottom' ].includes(sideY)) {
  10635. break;
  10636. }
  10637. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10638. break;
  10639. }
  10640. const distanceArr = distance.split(',');
  10641. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10642. break;
  10643. }
  10644.  
  10645. case 'showButtonSideX':
  10646. case 'showButtonSideY':
  10647. case 'showButtonDistance':
  10648. {
  10649. const distance = $('input[name="position.showButtonDistance"]').val();
  10650. const sideX = $('input[name="position.showButtonSideX"]').val();
  10651. const sideY = $('input[name="position.showButtonSideY"]').val();
  10652. if (![ 'right', 'left' ].includes(sideX)) {
  10653. break;
  10654. }
  10655. if (![ 'top', 'bottom' ].includes(sideY)) {
  10656. break;
  10657. }
  10658. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10659. break;
  10660. }
  10661. const distanceArr = distance.split(',');
  10662. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10663. break;
  10664. }
  10665.  
  10666. case 'logSideX':
  10667. case 'logSideY':
  10668. case 'logDistance':
  10669. {
  10670. const distance = $('input[name="position.logDistance"]').val();
  10671. const sideX = $('input[name="position.logSideX"]').val();
  10672. const sideY = $('input[name="position.logSideY"]').val();
  10673. if (![ 'right', 'left' ].includes(sideX)) {
  10674. break;
  10675. }
  10676. if (![ 'top', 'bottom' ].includes(sideY)) {
  10677. break;
  10678. }
  10679. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10680. break;
  10681. }
  10682. const distanceArr = distance.split(',');
  10683. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10684. break;
  10685. }
  10686.  
  10687. default:
  10688. break;
  10689. }
  10690. });
  10691. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10692. let functionKey = '';
  10693. if (event.altKey) {
  10694. functionKey += 'alt + ';
  10695. } else if (event.ctrlKey) {
  10696. functionKey += 'ctrl + ';
  10697. } else if (event.shiftKey) {
  10698. functionKey += 'shift + ';
  10699. }
  10700. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10701. });
  10702. } catch (error) {
  10703. throwError(error, 'Setting.after');
  10704. }
  10705. }
  10706. saveGlobalOptions() {
  10707. saveData();
  10708. }
  10709. }
  10710. function Setting_getId2(social) {
  10711. try {
  10712. external_Swal_default().fire({
  10713. title: i18n('getId', i18n(social)),
  10714. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10715. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10716. showCancelButton: true,
  10717. cancelButtonText: i18n('close'),
  10718. showConfirmButton: false
  10719. });
  10720. $('#link2id').on('click', async function() {
  10721. const link = $('#socialLink').val();
  10722. if (!link) {
  10723. return;
  10724. }
  10725. const type = $(this).attr('data-type');
  10726. if (type === 'twitterUser') {
  10727. var _link$match;
  10728. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10729. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10730. } else if (type === 'youtubeChannel') {
  10731. var _link$match2, _await$getInfo, _await$getInfo$params;
  10732. 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;
  10733. $('#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) || '');
  10734. }
  10735. });
  10736. } catch (error) {
  10737. throwError(error, 'Setting.getId');
  10738. }
  10739. }
  10740. function _environment2() {
  10741. try {
  10742. const userAgent = (0, javascript_utils_umd_min.ua)();
  10743. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10744. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10745. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10746. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10747. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10748. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10749. </tbody></table></form>`;
  10750. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10751. } catch (error) {
  10752. throwError(error, 'Setting.environment');
  10753. }
  10754. }
  10755. const website_Setting = Setting;
  10756. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10757. History_checkPrivateRedeclaration(obj, privateSet);
  10758. privateSet.add(obj);
  10759. }
  10760. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10761. if (privateCollection.has(obj)) {
  10762. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10763. }
  10764. }
  10765. function History_defineProperty(obj, key, value) {
  10766. if (key in obj) {
  10767. Object.defineProperty(obj, key, {
  10768. value: value,
  10769. enumerable: true,
  10770. configurable: true,
  10771. writable: true
  10772. });
  10773. } else {
  10774. obj[key] = value;
  10775. }
  10776. return obj;
  10777. }
  10778. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10779. if (!privateSet.has(receiver)) {
  10780. throw new TypeError('attempted to get private field on non-instance');
  10781. }
  10782. return fn;
  10783. }
  10784. var _addItem = new WeakSet();
  10785. class History extends website_Keylol {
  10786. constructor() {
  10787. super(...arguments);
  10788. History_classPrivateMethodInitSpec(this, _addItem);
  10789. History_defineProperty(this, 'name', 'History');
  10790. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10791. }
  10792. static test() {
  10793. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10794. }
  10795. before() {
  10796. try {
  10797. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10798. const data = GM_listValues() || [];
  10799. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10800. for (const item of tasksHistory) {
  10801. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10802. }
  10803. } catch (error) {
  10804. throwError(error, 'History.before');
  10805. }
  10806. }
  10807. clearHistory() {
  10808. try {
  10809. const data = GM_listValues() || [];
  10810. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10811. for (const item of tasksHistory) {
  10812. GM_deleteValue(item);
  10813. }
  10814. external_Swal_default().fire({
  10815. title: i18n('clearHistoryFinished'),
  10816. icon: 'success'
  10817. });
  10818. } catch (error) {
  10819. throwError(error, 'History.after');
  10820. }
  10821. }
  10822. }
  10823. function _addItem2(item) {
  10824. try {
  10825. const tasksData = GM_getValue(item);
  10826. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10827. return;
  10828. }
  10829. let html = '';
  10830. let title = '';
  10831. let link = '';
  10832. const [ website, id ] = item.split('-');
  10833. switch (website) {
  10834. case 'fawTasks':
  10835. title = `Freeanywhere[${id}]`;
  10836. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10837. break;
  10838.  
  10839. case 'gasTasks':
  10840. title = `Giveawaysu[${id}]`;
  10841. link = `https://giveaway.su/giveaway/view/${id}`;
  10842. break;
  10843.  
  10844. case 'gcTasks':
  10845. title = `GiveeClub[${id}]`;
  10846. link = `https://givee.club/event/${id}`;
  10847. break;
  10848.  
  10849. case 'gkTasks':
  10850. title = `Givekey[${id}]`;
  10851. link = `https://givekey.ru/giveaway/${id}`;
  10852. break;
  10853.  
  10854. case 'gleamTasks':
  10855. title = `Gleam[${id}]`;
  10856. link = `https://gleam.io${id}`;
  10857. break;
  10858.  
  10859. case 'khTasks':
  10860. title = `keyhub[${id}]`;
  10861. link = `https://key-hub.eu/giveaway/${id}`;
  10862. break;
  10863.  
  10864. case 'prysTasks':
  10865. title = `Prys[${id}]`;
  10866. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10867. break;
  10868.  
  10869. default:
  10870. return;
  10871. }
  10872. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10873. for (const [ type, tasks ] of Object.entries(types)) {
  10874. for (const task of tasks) {
  10875. 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>`;
  10876. }
  10877. }
  10878. }
  10879. $('.container').append(`<div class="card" data-name="${item}"><div class="title"><a href="${link}" target="_blank">${title}</a><span class="delete-task" data-name="${item}" title="${i18n('deleteTask')}"><svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2734" width="32" height="32"><path d="M607.897867 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L575.903242 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 351.94087C639.892491 753.593818 625.61532 768.043004 607.897867 768.043004z" p-id="2735" fill="#d81e06"></path><path d="M415.930119 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L383.935495 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625 17.717453 0 31.994625 14.277171 31.994625 31.994625l0 351.94087C447.924744 753.593818 433.647573 768.043004 415.930119 768.043004z" p-id="2736" fill="#d81e06"></path><path d="M928.016126 223.962372l-159.973123 0L768.043004 159.973123c0-52.980346-42.659499-95.983874-95.295817-95.983874L351.94087 63.989249c-52.980346 0-95.983874 43.003528-95.983874 95.983874l0 63.989249-159.973123 0c-17.717453 0-31.994625 14.277171-31.994625 31.994625s14.277171 31.994625 31.994625 31.994625l832.032253 0c17.717453 0 31.994625-14.277171 31.994625-31.994625S945.73358 223.962372 928.016126 223.962372zM319.946246 159.973123c0-17.545439 14.449185-31.994625 31.994625-31.994625l320.806316 0c17.545439 0 31.306568 14.105157 31.306568 31.994625l0 63.989249L319.946246 223.962372 319.946246 159.973123 319.946246 159.973123z" p-id="2737" fill="#d81e06"></path><path d="M736.048379 960.010751 288.123635 960.010751c-52.980346 0-95.983874-43.003528-95.983874-95.983874L192.139761 383.591466c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 480.435411c0 17.717453 14.449185 31.994625 31.994625 31.994625l448.096758 0c17.717453 0 31.994625-14.277171 31.994625-31.994625L768.215018 384.795565c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 479.231312C832.032253 916.835209 789.028725 960.010751 736.048379 960.010751z" p-id="2738" fill="#d81e06"></path></svg></span></div><ul>${html}</ul><span class="time">${i18n('lastChangeTime')}: ${external_dayjs_namespaceObject(tasksData.time).format('YYYY-MM-DD HH:mm:ss')}</span></div>`);
  10880. $('span.delete-task').on('click', function() {
  10881. const itemName = $(this).attr('data-name');
  10882. if (itemName) {
  10883. GM_deleteValue(itemName);
  10884. $(`div.card[data-name="${itemName}"]`).remove();
  10885. external_Swal_default().fire({
  10886. title: i18n('clearTaskFinished'),
  10887. text: itemName,
  10888. icon: 'success'
  10889. });
  10890. } else {
  10891. external_Swal_default().fire({
  10892. title: i18n('clearTaskFailed'),
  10893. icon: 'error'
  10894. });
  10895. }
  10896. });
  10897. } catch (error) {
  10898. throwError(error, 'History.addItem');
  10899. }
  10900. }
  10901. const website_History = History;
  10902. 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 ];
  10903. const websiteOptions = function(website, options) {
  10904. try {
  10905. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10906. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10907. for (const [ option, value ] of Object.entries(options)) {
  10908. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10909. }
  10910. websiteOptionsForm += '</tbody></table></form>';
  10911. external_Swal_default().fire({
  10912. title: i18n('websiteOptions'),
  10913. html: websiteOptionsForm,
  10914. showConfirmButton: true,
  10915. confirmButtonText: i18n('save'),
  10916. showCancelButton: true,
  10917. cancelButtonText: i18n('close')
  10918. }).then(_ref => {
  10919. let {
  10920. isConfirmed
  10921. } = _ref;
  10922. if (isConfirmed) {
  10923. $('#websiteOptionsForm').serializeArray().map(value => {
  10924. options[value.name] = value.value;
  10925. return value;
  10926. });
  10927. GM_setValue(`${website}Options`, options);
  10928. external_Swal_default().fire({
  10929. title: i18n('changeWebsiteOptionsSuccess'),
  10930. icon: 'success'
  10931. });
  10932. }
  10933. });
  10934. } catch (error) {
  10935. throwError(error, 'websiteOptions');
  10936. }
  10937. };
  10938. const options = websiteOptions;
  10939. const external_keyboardJS_namespaceObject = keyboardJS;
  10940. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10941. const checkUpdate = async (updateLink, auto) => {
  10942. try {
  10943. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10944. const {
  10945. result,
  10946. statusText,
  10947. status,
  10948. data
  10949. } = await tools_httpRequest({
  10950. url: checkUrl,
  10951. responseType: 'json',
  10952. method: 'GET',
  10953. timeout: 3e4
  10954. });
  10955. if (result === 'Success') {
  10956. var _data$response;
  10957. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10958. return data.response;
  10959. }
  10960. if (!auto) {
  10961. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10962. }
  10963. return false;
  10964. }
  10965. if (!auto) {
  10966. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10967. }
  10968. return false;
  10969. } catch (error) {
  10970. throwError(error, 'checkUpdate');
  10971. return false;
  10972. }
  10973. };
  10974. const hasNewVersion = (currentVersion, remoteVersion) => {
  10975. try {
  10976. const [ currentRealVersion ] = currentVersion.split('-');
  10977. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  10978. if (isPreview && !globalOptions.other.receivePreview) {
  10979. return false;
  10980. }
  10981. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10982. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10983. if (remoteVersion1 > currentVersion1) {
  10984. return true;
  10985. }
  10986. if (remoteVersion1 < currentVersion1) {
  10987. return false;
  10988. }
  10989. if (remoteVersion2 > currentVersion2) {
  10990. return true;
  10991. }
  10992. if (remoteVersion2 < currentVersion2) {
  10993. return false;
  10994. }
  10995. if (remoteVersion3 > currentVersion3) {
  10996. return true;
  10997. }
  10998. return false;
  10999. } catch (error) {
  11000. throwError(error, 'compareVersion');
  11001. return false;
  11002. }
  11003. };
  11004. const updateChecker = async () => {
  11005. try {
  11006. const currentVersion = GM_info.script.version;
  11007. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  11008. const updateLinks = {
  11009. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  11010. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  11011. standby: 'https://auto-task-v4.hclonely.com/'
  11012. };
  11013. let version;
  11014. let updateLink = '';
  11015. let packageData;
  11016. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  11017. updateLink = updateLinks[updateSource];
  11018. packageData = await checkUpdate(updateLink, false);
  11019. } else {
  11020. updateLink = updateLinks.github;
  11021. packageData = await checkUpdate(updateLink, true);
  11022. if (!packageData) {
  11023. updateLink = updateLinks.jsdelivr;
  11024. packageData = await checkUpdate(updateLink, true);
  11025. if (!packageData) {
  11026. updateLink = updateLinks.standby;
  11027. packageData = await checkUpdate(updateLink, true);
  11028. }
  11029. }
  11030. }
  11031. if (packageData) {
  11032. version = packageData.version || currentVersion;
  11033. } else {
  11034. version = currentVersion;
  11035. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  11036. }
  11037. if (packageData && hasNewVersion(currentVersion, version)) {
  11038. var _packageData$change;
  11039. scripts_echoLog({
  11040. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  11041. });
  11042. scripts_echoLog({
  11043. html: `<li>${i18n('updateText', version)}</li><ol class="update-text">${(_packageData$change = packageData.change) === null || _packageData$change === void 0 ? void 0 : _packageData$change.map(change => `<li>${change}</li>`).join('')}<li>${i18n('updateHistory')}</li></ol>`
  11044. });
  11045. }
  11046. } catch (error) {
  11047. throwError(error, 'updateChecker');
  11048. }
  11049. };
  11050. const scripts_updateChecker = updateChecker;
  11051. var _globalOptions$other, _globalOptions$other2;
  11052. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  11053. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  11054. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  11055. const loadScript = async () => {
  11056. var _website, _website2, _website3, _website4, _website5, _website6;
  11057. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  11058. const authToken = external_Cookies_namespaceObject.get('auth-token');
  11059. const isLogin = !!external_Cookies_namespaceObject.get('login');
  11060. if (isLogin) {
  11061. var _commonOptions, _commonOptions$header;
  11062. GM_setValue('twitchAuth', {
  11063. authToken: authToken,
  11064. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  11065. });
  11066. window.close();
  11067. external_Swal_default().fire('', i18n('closePageNotice'));
  11068. } else {
  11069. external_Swal_default().fire('', i18n('needLogin'));
  11070. }
  11071. return;
  11072. }
  11073. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  11074. const ct0 = external_Cookies_namespaceObject.get('ct0');
  11075. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  11076. if (isLogin && ct0) {
  11077. GM_setValue('twitterAuth', {
  11078. ct0: ct0
  11079. });
  11080. window.close();
  11081. external_Swal_default().fire('', i18n('closePageNotice'));
  11082. } else {
  11083. external_Swal_default().fire('', i18n('needLogin'));
  11084. }
  11085. return;
  11086. }
  11087. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  11088. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  11089. if (PAPISID) {
  11090. GM_setValue('youtubeAuth', {
  11091. PAPISID: PAPISID
  11092. });
  11093. window.close();
  11094. external_Swal_default().fire('', i18n('closePageNotice'));
  11095. } else {
  11096. external_Swal_default().fire('', i18n('needLogin'));
  11097. }
  11098. return;
  11099. }
  11100. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11101. const betaButton = $('#redesign-beta-optin-btn');
  11102. if (betaButton.length > 0) {
  11103. GM_setValue('redditAuth', '#auth');
  11104. return betaButton[0].click();
  11105. }
  11106. GM_setValue('redditAuth', null);
  11107. window.close();
  11108. external_Swal_default().fire('', i18n('closePageNotice'));
  11109. return;
  11110. }
  11111. let website;
  11112. for (const Website of Websites) {
  11113. if (Website.test()) {
  11114. website = new Website();
  11115. break;
  11116. }
  11117. }
  11118. if (!website) {
  11119. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11120. return;
  11121. }
  11122. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11123. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11124. }
  11125. $('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>`);
  11126. $('div.show-button-div').on('click', () => {
  11127. $('#auto-task-buttons').show();
  11128. $('div.show-button-div').hide();
  11129. });
  11130. const toggleLog = () => {
  11131. const $this = $('#toggle-log');
  11132. const status = $this.attr('data-status');
  11133. if (status === 'show') {
  11134. $('#auto-task-info').hide();
  11135. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11136. } else {
  11137. $('#auto-task-info').show();
  11138. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11139. }
  11140. };
  11141. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11142. if (website.doTask) {
  11143. website.doTask();
  11144. }
  11145. });
  11146. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11147. if (website.undoTask) {
  11148. website.doTask();
  11149. }
  11150. });
  11151. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11152. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11153. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11154. }
  11155. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11156. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11157. for (const button of website.buttons) {
  11158. if (website[button]) {
  11159. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11160. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11161. website[button]();
  11162. });
  11163. $('#auto-task-buttons').append(btnElement);
  11164. }
  11165. }
  11166. }
  11167. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11168. ${i18n('hideButton')}</a></p>`);
  11169. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11170. $('#auto-task-buttons').hide();
  11171. $('div.show-button-div').show();
  11172. });
  11173. 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'}">
  11174. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11175. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11176. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11177. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11178. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11179. options(website.name, website.options);
  11180. });
  11181. }
  11182. if (website.name !== 'Setting') {
  11183. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11184. changeGlobalOptions('swal');
  11185. });
  11186. GM_registerMenuCommand(i18n('settingPage'), () => {
  11187. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11188. });
  11189. }
  11190. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11191. if (!GM_getValue('notice')) {
  11192. var _echoLog$font;
  11193. external_Swal_default().fire({
  11194. title: i18n('swalNotice'),
  11195. icon: 'warning'
  11196. }).then(() => {
  11197. window.open(i18n('noticeLink'), '_blank');
  11198. GM_setValue('notice', new Date().getTime());
  11199. });
  11200. (_echoLog$font = scripts_echoLog({
  11201. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11202. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11203. GM_setValue('notice', new Date().getTime());
  11204. });
  11205. }
  11206. scripts_updateChecker();
  11207. };
  11208. if (window.location.hostname === 'discord.com') {
  11209. const LocalStorage = window.localStorage;
  11210. if (window.location.hash === '#auth') {
  11211. var _LocalStorage$getItem;
  11212. window.localStorage.removeItem = () => true;
  11213. 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, '');
  11214. if (discordAuth && discordAuth.length > 0) {
  11215. GM_setValue('discordAuth', {
  11216. auth: discordAuth
  11217. });
  11218. window.close();
  11219. external_Swal_default().fire('', i18n('closePageNotice'));
  11220. } else {
  11221. external_Swal_default().fire({
  11222. text: i18n('getDiscordAuthFailed'),
  11223. icon: 'error'
  11224. });
  11225. }
  11226. } else {
  11227. var _LocalStorage$getItem2;
  11228. 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, '');
  11229. if (discordAuth && discordAuth.length > 0) {
  11230. GM_setValue('discordAuth', {
  11231. auth: discordAuth
  11232. });
  11233. }
  11234. }
  11235. } else if (window.location.hostname === 'opquests.com') {
  11236. loadScript();
  11237. } else {
  11238. $(loadScript);
  11239. }
  11240. }();
  11241. })();