auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.13-beta
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12. // @icon https://auto-task-v4.hclonely.com/favicon.ico
  13.  
  14. // @include *://freeanywhere.net/*
  15. // @include *://giveaway.su/giveaway/view/*
  16. // @include *://givee.club/*/event/*
  17. // @include *://givekey.ru/giveaway/*
  18. // @include *://www.indiedb.com/giveaways*
  19. // @include *://key-hub.eu/giveaway/*
  20. // @include *://keylol.com/*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://prys.revadike.com/giveaway/?id=*
  23. // @include *://opquests.com/quests/*
  24. // @include *://gleam.io/*
  25. // @include *://sweepwidget.com/view/*
  26. // @include *://discord.com/*
  27. // @include *://www.twitch.tv/*
  28. // @include *://www.youtube.com/*
  29. // @include *://*.reddit.com/*
  30. // @include *://twitter.com/settings/account?k*
  31. // @include https://auto-task-v4.hclonely.com/setting.html
  32. // @include https://auto-task-v4.hclonely.com/history.html
  33.  
  34. // @grant GM_setValue
  35. // @grant GM_getValue
  36. // @grant GM_listValues
  37. // @grant GM_deleteValue
  38. // @grant GM_addStyle
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_info
  42. // @grant GM_openInTab
  43. // @grant GM_setClipboard
  44. // @grant GM_getResourceText
  45. // @grant unsafeWindow
  46. // @grant window.close
  47. // @grant window.localStorage
  48.  
  49. // @connect cdn.jsdelivr.net
  50. // @connect store.steampowered.com
  51. // @connect steamcommunity.com
  52. // @connect twitter.com
  53. // @connect api.twitter.com
  54. // @connect youtube.com
  55. // @connect www.youtube.com
  56. // @connect facebook.com
  57. // @connect instagram.com
  58. // @connect vk.com
  59. // @connect twitch.tv
  60. // @connect www.twitch.tv
  61. // @connect gql.twitch.tv
  62. // @connect github.com
  63. // @connect discordapp.com
  64. // @connect discord.gg
  65. // @connect discord.com
  66. // @connect www.reddit.com
  67. // @connect oauth.reddit.com
  68. // @connect raw.githubusercontent.com
  69. // @connect t.me
  70. // @connect bit.ly
  71. // @connect giveaway.su
  72. // @connect google.com
  73. // @connect www.vloot.io
  74. // @connect givee.club
  75. // @connect gleam.io
  76. // @connect www.indiedb.com
  77. // @connect key-hub.eu
  78. // @connect opquests.com
  79. // @connect itch.io
  80. // @connect auto-task-v4.hclonely.com
  81. // @connect *
  82. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  83. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  84. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  85. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  86. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  87. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  88. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  89. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  90.  
  91. // @noframes
  92. // ==/UserScript==
  93.  
  94. console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
  95.  
  96. (function() {
  97. var __webpack_modules__ = {
  98. 514: function(__unused_webpack_module, exports) {
  99. !function(e, n) {
  100. true ? n(exports) : 0;
  101. }(this, function(e) {
  102. 'use strict';
  103. var t = function() {
  104. return (t = Object.assign || function(e) {
  105. for (var n, o = 1, t = arguments.length; o < t; o++) {
  106. for (var r in n = arguments[o]) {
  107. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  108. }
  109. }
  110. return e;
  111. }).apply(this, arguments);
  112. };
  113. function r(e, n, o) {
  114. if (o || 2 === arguments.length) {
  115. for (var t, r = 0, i = n.length; r < i; r++) {
  116. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  117. }
  118. }
  119. return e.concat(t || Array.prototype.slice.call(n));
  120. }
  121. function d(e) {
  122. return '[object Object]' === n(e);
  123. }
  124. function l(e, n) {
  125. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  126. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  127. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  128. });
  129. }
  130. var n = function(e) {
  131. return Object.prototype.toString.call(e);
  132. };
  133. var o = (i.prototype.init = function() {
  134. try {
  135. this.getSystemName(), this.getBrowserName();
  136. } catch (e) {
  137. console.warn('[UA formatter error] '.concat(e));
  138. }
  139. }, i.prototype.getEngine = function() {
  140. var e = this.agent;
  141. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  142. }, i.prototype.getSystemName = function() {
  143. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  144. try {
  145. var o = '';
  146. if (/Windows/i.test(n)) {
  147. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  148. switch (this.info.os = 'Windows', t) {
  149. case '6.3':
  150. o = '8.1';
  151. break;
  152.  
  153. case '6.2':
  154. o = '8';
  155. break;
  156.  
  157. case '6.1':
  158. o = '7';
  159. break;
  160.  
  161. case '5.2':
  162. case '5.1':
  163. o = 'XP';
  164. break;
  165.  
  166. default:
  167. o = t;
  168. }
  169. return this.info.device = 'PC', void (this.info.osVersion = o);
  170. }
  171. if (/^Macintosh/i.test(n)) {
  172. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  173. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  174. }
  175. if (/^iPad/i.test(n)) {
  176. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  177. void (this.info.osVersion = o.replace(/_/g, '.'));
  178. }
  179. if (/^iPhone/i.test(n)) {
  180. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  181. void (this.info.osVersion = o.replace(/_/g, '.'));
  182. }
  183. if (-1 !== n.indexOf('Android')) {
  184. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  185. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  186. }
  187. if (/Linux\s[a-z\d_]+/.test(n)) {
  188. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  189. }
  190. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  191. } catch (e) {
  192. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  193. }
  194. }, i.prototype.getBrowserName = function() {
  195. var e = Object.keys(this.browserNameMap).map(function(e) {
  196. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  197. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  198. return -1 !== e.findIndex(function(e) {
  199. return e.test(n);
  200. });
  201. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  202. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  203. }, i.prototype._formatBrowserVersion = function(e) {
  204. var n, o, t, r;
  205. try {
  206. for (var i = null !== (o = null === (n = e.match(/(?<name>[a-z\d]+)(\/|\s)(?<version>(\d+\.)+\d+)/i)) || void 0 === n ? void 0 : n.groups) && void 0 !== o ? o : {}, s = i.name, a = i.version, c = {}, f = 0, u = Object.entries(this.browserNameMap); f < u.length; f++) {
  207. var d = u[f], l = d[0], h = d[1];
  208. if (new RegExp(l).test(s)) {
  209. c = h;
  210. break;
  211. }
  212. }
  213. var p = {
  214. browserVersion: null != a ? a : 'Unknown',
  215. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  216. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  217. };
  218. return 'Trident' === s && (p.browserVersion = {
  219. '4.0': 8,
  220. '5.0': 9,
  221. '6.0': 10,
  222. '7.0': 11
  223. }[a]), p;
  224. } catch (e) {
  225. return console.warn('[UA formatter error] '.concat(e)), {
  226. browser: 'Unknown',
  227. browserVersion: 'Unknown'
  228. };
  229. }
  230. }, i);
  231. function i(e) {
  232. this.agent = '', this.info = {
  233. browser: '',
  234. browserZH: '',
  235. browserVersion: '',
  236. os: '',
  237. osVersion: '',
  238. device: 'Unknown',
  239. engine: 'WebKit'
  240. }, this.browserNameMap = {
  241. MicroMessenger: {
  242. en: 'MicroMessenger',
  243. zh: '微信'
  244. },
  245. MetaSr: {
  246. en: 'MetaSr',
  247. zh: '搜狗浏览器'
  248. },
  249. 'QQ(Browser)?': {
  250. en: 'QQBrowser',
  251. zh: 'QQ浏览器'
  252. },
  253. UCBrowser: {
  254. en: 'UCBrowser',
  255. zh: 'UC浏览器'
  256. },
  257. '2345Explorer': {
  258. en: '2345Explorer',
  259. zh: '2345极速浏览器'
  260. },
  261. Mb2345Browser: {
  262. en: 'Mb2345Browser',
  263. zh: '2345手机浏览器'
  264. },
  265. Trident: {
  266. en: 'Internet Explorer'
  267. },
  268. 'Edge?': {
  269. en: 'Edge'
  270. },
  271. OPR: {
  272. en: 'Opera'
  273. },
  274. Vivaldi: {
  275. en: 'Vivaldi'
  276. },
  277. Firefox: {
  278. en: 'Firefox'
  279. },
  280. Chrome: {
  281. en: 'Chrome'
  282. },
  283. Safari: {
  284. en: 'Safari'
  285. }
  286. }, this.agent = e, this.init();
  287. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  288. this.info = t(t({}, this.info), {
  289. engine: this.getEngine(),
  290. browserVersion: 'Safari' === o ? n : e
  291. });
  292. }
  293. function s() {
  294. this.cookies = {}, this.init();
  295. }
  296. var a = new (s.prototype.init = function() {
  297. var o = {};
  298. document.cookie.split(/;\s/).forEach(function(e) {
  299. var n = e.split(/=/), e = n[0], n = n[1];
  300. o[e] = n;
  301. }), this.cookies = o;
  302. }, s.prototype.getItem = function(e) {
  303. return this.cookies[e];
  304. }, s.prototype.getAllItems = function() {
  305. return this.cookies;
  306. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  307. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  308. }, s)();
  309. e.countDown = function e(n, o, t, r) {
  310. if (!window) {
  311. throw new Error('window is not defind.');
  312. }
  313. if (0 < n) {
  314. return r && r(), n--, window[o] = window.setTimeout(function() {
  315. e(n, o, t, r);
  316. }, 1e3), function() {
  317. return clearTimeout(window[o]);
  318. };
  319. }
  320. clearTimeout(window[o]), t && t();
  321. }, e.createRandomID = function(e) {
  322. void 0 === e && (e = 12);
  323. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  324. n.push(o[Math.round(Math.random() * t)]);
  325. }
  326. return n.join('');
  327. }, e.dCookie = a, e.debounce = function(o, t, r) {
  328. var i;
  329. void 0 === t && (t = 0);
  330. var s = r = void 0 === r ? !1 : r;
  331. return function() {
  332. var e = this, n = arguments;
  333. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  334. r ? s = !0 : o.apply(e, n);
  335. }, t);
  336. };
  337. }, e.deepCopy = function e(n) {
  338. if (d(n) || Array.isArray(n)) {
  339. var o, t = Array.isArray(n) ? [] : {};
  340. for (o in n) {
  341. t[o] = e(n[o]);
  342. }
  343. return t;
  344. }
  345. return n;
  346. }, e.formatQueryParams = function(e) {
  347. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  348. if (!e) {
  349. return {};
  350. }
  351. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  352. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  353. return t[n] = o, e;
  354. });
  355. }
  356. return t;
  357. }, e.formatThousandth = function(e) {
  358. var n = ''.concat(e).split('.'), e = n[0], n = n[1], n = void 0 === n ? '' : n, e = e.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
  359. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  360. }, e.generateTree = function e(n, o, t, r) {
  361. for (var i = [], s = 0; s < n.length; s++) {
  362. var a = n[s];
  363. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  364. }
  365. return i;
  366. }, e.isEmpty = function(e) {
  367. return Array.isArray(e) ? 0 === e.length : d(e) ? 0 === Object.keys(e).length : [ '[object Set]', '[object Map]' ].includes(n(e)) ? 0 === e.size : [ null, void 0, '' ].includes(e);
  368. }, e.isFunction = function(e) {
  369. return '[object Function]' === n(e);
  370. }, e.isImageUrl = function(e) {
  371. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  372. }, e.isObject = d, e.isRegexp = function(e) {
  373. return '[object RegExp]' === n(e);
  374. }, e.objectKeyToCamelCase = function e(n, o, t) {
  375. if (Array.isArray(n)) {
  376. for (var r = [], i = 0; i < n.length; i++) {
  377. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  378. }
  379. } else if (d(n)) {
  380. r = {};
  381. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  382. var f = (u = c[a])[0], u = u[1];
  383. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  384. }
  385. } else {
  386. r = n;
  387. }
  388. return r;
  389. }, e.realType = n, e.searchParams = function(e, n) {
  390. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  391. new URLSearchParams(e).get(n);
  392. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  393. return e.replace(/([A-Z])/g, function(e) {
  394. return '_'.concat(e.toLocaleLowerCase());
  395. });
  396. }, e.ua = function(e) {
  397. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  398. }, Object.defineProperty(e, '__esModule', {
  399. value: !0
  400. });
  401. });
  402. },
  403. 786: function(module, __webpack_exports__, __webpack_require__) {
  404. 'use strict';
  405. __webpack_require__.d(__webpack_exports__, {
  406. Z: function() {
  407. return __WEBPACK_DEFAULT_EXPORT__;
  408. }
  409. });
  410. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  411. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  412. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  413. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  414. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default());
  415. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(10px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px rgba(5,190,5,0.4)}body.auto-task-options .auto-task-form table label input:checked~span i{left:84px}body.auto-task-options .auto-task-form table label input:checked~span i::before{background:#05be05;box-shadow:35px 0 0 #05be05}body.auto-task-options .auto-task-form table label input:checked~span i::after{bottom:12px;height:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;background:#05be05}body.auto-task-options .auto-task-form table label span{position:absolute;top:0;left:0;width:100%;height:100%;background:#fe0000;border-radius:80px;transition:.5s;box-shadow:0 15px 25px rgba(254,0,0,0.4)}body.auto-task-options .auto-task-form table label span i{position:absolute;top:4px;left:4px;width:72px;height:72px;background:#fff;border-radius:50%}body.auto-task-options .auto-task-form table label span i::before{content:"";position:absolute;top:22px;left:12px;width:12px;height:12px;border-radius:50%;background:#fe0000;box-shadow:35px 0 0 #fe0000;transition:.5s}body.auto-task-options .auto-task-form table label span i::after{content:"";position:absolute;bottom:15px;left:calc(50% - 15px);width:30px;height:6px;border-radius:6px;background:#fe0000;transition:.5s}body.auto-task-history{font-size:15px;font-weight:400;line-height:1.5}body.auto-task-history .container a{color:#007bff;text-decoration:none;background-color:transparent}body.auto-task-history .container .card{width:80%;max-width:800px;border-radius:10px;background:rgba(118,118,118,0.10196);border-top:1px solid rgba(255,255,255,0.50196);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px rgba(0,0,0,0.10196);margin:20px auto;position:relative;display:flex;flex-direction:column;word-wrap:break-word;-webkit-background-clip:border-box;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}body.auto-task-history .container .card .title{text-align:center;font-size:30px;font-weight:bold;margin:5px 0}body.auto-task-history .container .card .title a:hover{text-decoration:none;background:#93e1ff;border-radius:10px;padding:3px}body.auto-task-history .container .card ul{margin-bottom:25px}body.auto-task-history .container .card ul li{margin-bottom:5px;line-height:20px}body.auto-task-history .container .card ul a:hover{text-decoration:underline}body.auto-task-history .container .card .delete-task{right:10px;width:38px;height:35px;position:absolute;font-size:24px;cursor:pointer;border-radius:10px}body.auto-task-history .container .card .delete-task:hover{background:#fff}body.auto-task-history .container .card .time{right:5px;position:absolute;bottom:0;color:#e83e8c;font-family:\'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace\';font-size:15px}#auto-task-buttons,.show-button-div{position:fixed;top:30px;right:15px;width:170px;z-index:999999999 !important;transform:scale(0.9)}#auto-task-buttons p,.show-button-div p{line-height:30px;height:40px;text-align:center;margin:5px !important}#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn{width:150px;height:40px;line-height:30px;font-size:20px}.show-button-div{width:20px}.auto-task-capitalize{text-transform:capitalize !important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{box-shadow:inset 0px 0px 4px 1px rgba(100,150,200,.5) !important}.swal2-checkbox-custom{align-items:center;justify-content:center;background:#fff;color:inherit;margin:1em auto}.swal2-checkbox-custom input{flex-shrink:0;margin:0 .4em}.giveaway-actions #getKey{display:none !important}.auto-task-giveaway-status{color:#fff;border-radius:10px;padding:0 5px;margin-left:5px}.auto-task-giveaway-status.active{background-color:#5cb85c}.auto-task-giveaway-status.not-active{background-color:#d9534f}.left-keys.lk-green,.left-keys.lk-yellow,.left-keys.lk-red,.left-keys.lk-black{display:none !important}', '' ]);
  416. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  417. },
  418. 400: function(module) {
  419. 'use strict';
  420. module.exports = function(cssWithMappingToString) {
  421. var list = [];
  422. list.toString = function toString() {
  423. return this.map(function(item) {
  424. var content = '';
  425. var needLayer = typeof item[5] !== 'undefined';
  426. if (item[4]) {
  427. content += '@supports ('.concat(item[4], ') {');
  428. }
  429. if (item[2]) {
  430. content += '@media '.concat(item[2], ' {');
  431. }
  432. if (needLayer) {
  433. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  434. }
  435. content += cssWithMappingToString(item);
  436. if (needLayer) {
  437. content += '}';
  438. }
  439. if (item[2]) {
  440. content += '}';
  441. }
  442. if (item[4]) {
  443. content += '}';
  444. }
  445. return content;
  446. }).join('');
  447. };
  448. list.i = function i(modules, media, dedupe, supports, layer) {
  449. if (typeof modules === 'string') {
  450. modules = [ [ null, modules, undefined ] ];
  451. }
  452. var alreadyImportedModules = {};
  453. if (dedupe) {
  454. for (var k = 0; k < this.length; k++) {
  455. var id = this[k][0];
  456. if (id != null) {
  457. alreadyImportedModules[id] = true;
  458. }
  459. }
  460. }
  461. for (var _k = 0; _k < modules.length; _k++) {
  462. var item = [].concat(modules[_k]);
  463. if (dedupe && alreadyImportedModules[item[0]]) {
  464. continue;
  465. }
  466. if (typeof layer !== 'undefined') {
  467. if (typeof item[5] === 'undefined') {
  468. item[5] = layer;
  469. } else {
  470. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  471. item[5] = layer;
  472. }
  473. }
  474. if (media) {
  475. if (!item[2]) {
  476. item[2] = media;
  477. } else {
  478. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  479. item[2] = media;
  480. }
  481. }
  482. if (supports) {
  483. if (!item[4]) {
  484. item[4] = ''.concat(supports);
  485. } else {
  486. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  487. item[4] = supports;
  488. }
  489. }
  490. list.push(item);
  491. }
  492. };
  493. return list;
  494. };
  495. },
  496. 220: function(module) {
  497. 'use strict';
  498. module.exports = function(i) {
  499. return i[1];
  500. };
  501. }
  502. };
  503. var __webpack_module_cache__ = {};
  504. function __webpack_require__(moduleId) {
  505. var cachedModule = __webpack_module_cache__[moduleId];
  506. if (cachedModule !== undefined) {
  507. return cachedModule.exports;
  508. }
  509. var module = __webpack_module_cache__[moduleId] = {
  510. id: moduleId,
  511. exports: {}
  512. };
  513. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  514. return module.exports;
  515. }
  516. !function() {
  517. __webpack_require__.n = function(module) {
  518. var getter = module && module.__esModule ? function() {
  519. return module['default'];
  520. } : function() {
  521. return module;
  522. };
  523. __webpack_require__.d(getter, {
  524. a: getter
  525. });
  526. return getter;
  527. };
  528. }();
  529. !function() {
  530. __webpack_require__.d = function(exports, definition) {
  531. for (var key in definition) {
  532. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  533. Object.defineProperty(exports, key, {
  534. enumerable: true,
  535. get: definition[key]
  536. });
  537. }
  538. }
  539. };
  540. }();
  541. !function() {
  542. __webpack_require__.o = function(obj, prop) {
  543. return Object.prototype.hasOwnProperty.call(obj, prop);
  544. };
  545. }();
  546. var __webpack_exports__ = {};
  547. !function() {
  548. 'use strict';
  549. const external_Swal_namespaceObject = Swal;
  550. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  551. const external_Cookies_namespaceObject = Cookies;
  552. var auto_task = __webpack_require__(786);
  553. var javascript_utils_umd_min = __webpack_require__(514);
  554. const httpRequest = async function(options) {
  555. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  556. try {
  557. const result = await new Promise(resolve => {
  558. if (options.dataType) {
  559. options.responseType = options.dataType;
  560. }
  561. const requestObj = {
  562. ...{
  563. timeout: 3e4,
  564. ontimeout(data) {
  565. resolve({
  566. result: 'Error',
  567. statusText: 'Timeout',
  568. status: 601,
  569. data: data,
  570. options: options
  571. });
  572. },
  573. onabort(data) {
  574. resolve({
  575. result: 'Error',
  576. statusText: 'Aborted',
  577. status: 602,
  578. data: data,
  579. options: options
  580. });
  581. },
  582. onerror(data) {
  583. resolve({
  584. result: 'Error',
  585. statusText: 'Error',
  586. status: 603,
  587. data: data,
  588. options: options
  589. });
  590. },
  591. onload(data) {
  592. resolve({
  593. result: 'Success',
  594. statusText: 'Load',
  595. status: 600,
  596. data: data,
  597. options: options
  598. });
  599. }
  600. },
  601. ...options
  602. };
  603. GM_xmlhttpRequest(requestObj);
  604. });
  605. console.log('发送请求:', result);
  606. if (result.status !== 600 && times < 2) {
  607. return await httpRequest(options, times + 1);
  608. }
  609. return result;
  610. } catch (error) {
  611. throwError(error, 'httpRequest');
  612. console.log('发送请求:', {
  613. errorMsg: error,
  614. options: options
  615. });
  616. return {
  617. result: 'JsError',
  618. statusText: 'Error',
  619. status: 604,
  620. error: error,
  621. options: options
  622. };
  623. }
  624. };
  625. const tools_httpRequest = httpRequest;
  626. const echoLog = _ref => {
  627. let {
  628. type,
  629. text,
  630. html,
  631. id
  632. } = _ref;
  633. const emptyStatus = {
  634. success: () => emptyStatus,
  635. error: () => emptyStatus,
  636. warning: () => emptyStatus,
  637. info: () => emptyStatus,
  638. view: () => emptyStatus
  639. };
  640. try {
  641. var _ele$;
  642. let ele;
  643. if (type) {
  644. switch (type) {
  645. case 'joiningSteamGroup':
  646. case 'leavingSteamGroup':
  647. case 'gettingSteamGroupId':
  648. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>...<font></font></li>`);
  649. break;
  650.  
  651. case 'subscribingForum':
  652. case 'unsubscribingForum':
  653. case 'gettingForumId':
  654. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>...<font></font></li>`);
  655. break;
  656.  
  657. case 'followingCurator':
  658. case 'unfollowingCurator':
  659. case 'getCuratorId':
  660. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/${text !== null && text !== void 0 && text.includes('/') ? text : `curator/${text}`}" target="_blank">${text}</a>...<font></font></li>`);
  661. break;
  662.  
  663. case 'addingToWishlist':
  664. case 'removingFromWishlist':
  665. case 'followingGame':
  666. case 'unfollowingGame':
  667. case 'gettingSubid':
  668. case 'addingFreeLicense':
  669. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>...<font></font></li>`);
  670. break;
  671.  
  672. case 'favoritingWorkshop':
  673. case 'unfavoritingWorkshop':
  674. case 'gettingWorkshopAppId':
  675. case 'votingUpWorkshop':
  676. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  677. ${text}</a>...<font></font></li>`);
  678. break;
  679.  
  680. case 'gettingAnnouncementParams':
  681. case 'likingAnnouncement':
  682. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  683. ${id}</a>...<font></font></li>`);
  684. break;
  685.  
  686. case 'joiningDiscordServer':
  687. case 'gettingDiscordGuild':
  688. ele = $(`<li>${i18n(type)}<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>...<font></font></li>`);
  689. break;
  690.  
  691. case 'leavingDiscordServer':
  692. ele = $(`<li>${i18n(type)}<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>...<font></font></li>`);
  693. break;
  694.  
  695. case 'updateDiscordAuth':
  696. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  697. break;
  698.  
  699. case 'followingTwitchChannel':
  700. case 'unfollowingTwitchChannel':
  701. case 'gettingTwitchChannelId':
  702. ele = $(`<li>${i18n(type)}<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>...<font></font></li>`);
  703. break;
  704.  
  705. case 'gettingInsUserId':
  706. case 'followingIns':
  707. case 'unfollowingIns':
  708. ele = $(`<li>${i18n(type)}<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  709. break;
  710.  
  711. case 'gettingTwitterUserId':
  712. case 'followingTwitterUser':
  713. case 'unfollowingTwitterUser':
  714. ele = $(`<li>${i18n(type)}<a href="https://twitter.com/${text}" target="_blank">${text}</a>...<font></font></li>`);
  715. break;
  716.  
  717. case 'retweetting':
  718. case 'unretweetting':
  719. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  720. break;
  721.  
  722. case 'joiningReddit':
  723. case 'leavingReddit':
  724. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  725. break;
  726.  
  727. case 'followingRedditUser':
  728. case 'unfollowingRedditUser':
  729. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  730. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>...<font></font></li>`);
  731. break;
  732.  
  733. case 'followingYtbChannel':
  734. case 'unfollowingYtbChannel':
  735. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>...<font></font></li>`);
  736. break;
  737.  
  738. case 'likingYtbVideo':
  739. case 'unlikingYtbVideo':
  740. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>...<font></font></li>`);
  741. break;
  742.  
  743. case 'gettingVkId':
  744. case 'joiningVkGroup':
  745. case 'leavingVkGroup':
  746. case 'joiningVkPublic':
  747. case 'leavingVkPublic':
  748. case 'sendingVkWall':
  749. case 'deletingVkWall':
  750. ele = $(`<li>${i18n(type)}<a href="https://vk.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  751. break;
  752.  
  753. case 'visitingLink':
  754. ele = $(`<li>${i18n('visitingLink')}<a href="${text}" target="_blank">${text}</a>...<font></font></li>`);
  755. break;
  756.  
  757. case 'verifyingInsAuth':
  758. case 'text':
  759. ele = $(`<li>${i18n(text)}<font></font></li>`);
  760. break;
  761.  
  762. case 'html':
  763. ele = $(text || html);
  764. break;
  765.  
  766. case 'whiteList':
  767. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  768. break;
  769.  
  770. case 'globalOptionsSkip':
  771. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  772. break;
  773.  
  774. default:
  775. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  776. break;
  777. }
  778. } else if (text) {
  779. ele = $(`<li>${i18n(text)}<font></font></li>`);
  780. } else if (html) {
  781. ele = $(html);
  782. } else {
  783. ele = $('<li><font></font></li>');
  784. }
  785. ele.addClass('card-text');
  786. $('#auto-task-info').append(ele);
  787. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  788. const font = ele.find('font');
  789. const status = {
  790. font: font,
  791. success() {
  792. var _this$font, _this$font2, _this$font3;
  793. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  794. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  795. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  796. 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);
  797. return this;
  798. },
  799. error() {
  800. var _this$font4, _this$font5, _this$font6;
  801. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  802. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  803. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  804. 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);
  805. return this;
  806. },
  807. warning() {
  808. var _this$font7, _this$font8, _this$font9;
  809. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  810. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  811. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  812. 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);
  813. return this;
  814. },
  815. info() {
  816. var _this$font10, _this$font11, _this$font12;
  817. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  818. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  819. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  820. 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);
  821. return this;
  822. },
  823. view() {
  824. var _this$font13;
  825. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  826. return this;
  827. }
  828. };
  829. return status;
  830. } catch (error) {
  831. throwError(error, 'echoLog');
  832. return emptyStatus;
  833. }
  834. };
  835. const scripts_echoLog = echoLog;
  836. const unique = array => {
  837. try {
  838. return [ ...new Set(array) ];
  839. } catch (error) {
  840. throwError(error, 'unique');
  841. return [];
  842. }
  843. };
  844. const delay = function() {
  845. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  846. return new Promise(resolve => {
  847. setTimeout(() => {
  848. resolve(true);
  849. }, time);
  850. });
  851. };
  852. const getRedirectLink = async link => {
  853. try {
  854. if (!link) {
  855. return null;
  856. }
  857. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  858. if (redirectLinksCache[link]) {
  859. redirectLinksCache[link];
  860. }
  861. return await tools_httpRequest({
  862. url: link,
  863. method: 'GET'
  864. }).then(_ref => {
  865. let {
  866. data
  867. } = _ref;
  868. if (data !== null && data !== void 0 && data.finalUrl) {
  869. redirectLinksCache[link] = data.finalUrl;
  870. GM_setValue('redirectLinks', redirectLinksCache);
  871. return data.finalUrl;
  872. }
  873. return null;
  874. });
  875. } catch (error) {
  876. throwError(error, 'getRedirectLink');
  877. return null;
  878. }
  879. };
  880. const visitLink = async (link, options) => {
  881. try {
  882. const logStatus = scripts_echoLog({
  883. type: 'visitLink',
  884. text: link
  885. });
  886. return await tools_httpRequest({
  887. url: link,
  888. method: 'GET',
  889. ...options
  890. }).then(_ref2 => {
  891. let {
  892. result,
  893. statusText,
  894. status
  895. } = _ref2;
  896. if (result === 'Success') {
  897. logStatus.success();
  898. return true;
  899. }
  900. logStatus.error(`${result}:${statusText}(${status})`);
  901. return false;
  902. });
  903. } catch (error) {
  904. throwError(error, 'visitLink');
  905. return false;
  906. }
  907. };
  908. const getUrlQuery = url => {
  909. try {
  910. const query = {};
  911. if (url) {
  912. if (url.includes('?')) {
  913. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  914. query[key] = value;
  915. return str;
  916. });
  917. }
  918. } else {
  919. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  920. query[key] = value;
  921. return str;
  922. });
  923. }
  924. return query;
  925. } catch (error) {
  926. throwError(error, 'getUrlQuery');
  927. return {};
  928. }
  929. };
  930. const getUuid = () => {
  931. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  932. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  933. };
  934. const stringToColour = str => {
  935. try {
  936. let hash = 0;
  937. for (let i = 0; i < str.length; i++) {
  938. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  939. }
  940. let colour = '#';
  941. for (let i = 0; i < 3; i++) {
  942. const value = hash >> i * 8 & 255;
  943. colour += `00${value.toString(16)}`.slice(-2);
  944. }
  945. return colour;
  946. } catch (error) {
  947. throwError(error, 'stringToColour');
  948. return '#fff';
  949. }
  950. };
  951. const defaultGlobalOptions = {
  952. doTask: {
  953. discord: {
  954. servers: true
  955. },
  956. instagram: {
  957. users: true
  958. },
  959. twitch: {
  960. channels: true
  961. },
  962. twitter: {
  963. users: true,
  964. retweets: true
  965. },
  966. vk: {
  967. names: true
  968. },
  969. youtube: {
  970. channels: true,
  971. likes: true
  972. },
  973. reddit: {
  974. reddits: true
  975. },
  976. steam: {
  977. groups: true,
  978. wishlists: true,
  979. follows: true,
  980. forums: true,
  981. workshops: true,
  982. curators: true,
  983. workshopVotes: true,
  984. announcements: true
  985. }
  986. },
  987. undoTask: {
  988. discord: {
  989. servers: true
  990. },
  991. instagram: {
  992. users: true
  993. },
  994. twitch: {
  995. channels: true
  996. },
  997. twitter: {
  998. users: true,
  999. retweets: true
  1000. },
  1001. vk: {
  1002. names: true
  1003. },
  1004. youtube: {
  1005. channels: true,
  1006. likes: true
  1007. },
  1008. reddit: {
  1009. reddits: true
  1010. },
  1011. steam: {
  1012. groups: true,
  1013. wishlists: true,
  1014. follows: true,
  1015. forums: true,
  1016. workshops: true,
  1017. curators: true
  1018. }
  1019. },
  1020. position: {
  1021. buttonSideX: 'right',
  1022. buttonSideY: 'top',
  1023. buttonDistance: '15,30',
  1024. showButtonSideX: 'right',
  1025. showButtonSideY: 'top',
  1026. showButtonDistance: '15,30',
  1027. logSideX: 'right',
  1028. logSideY: 'bottom',
  1029. logDistance: '10,10'
  1030. },
  1031. hotKey: {
  1032. doTaskKey: 'alt + d',
  1033. undoTaskKey: 'alt + u',
  1034. toggleLogKey: 'alt + l'
  1035. },
  1036. other: {
  1037. twitterVerifyId: '783214',
  1038. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1039. autoUpdateSource: 'jsdelivr',
  1040. language: 'zh',
  1041. checkLogin: true,
  1042. checkLeftKey: true,
  1043. defaultShowButton: true,
  1044. defaultShowLog: true
  1045. }
  1046. };
  1047. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1048. const assignObject = (obj1, obj2) => {
  1049. try {
  1050. const newObj = {};
  1051. for (const [ key, value ] of Object.entries(obj1)) {
  1052. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1053. newObj[key] = assignObject(value, obj2[key]);
  1054. } else {
  1055. newObj[key] = obj2[key] ?? value;
  1056. }
  1057. }
  1058. return newObj;
  1059. } catch (error) {
  1060. throwError(error, 'assignObject');
  1061. return defaultGlobalOptions;
  1062. }
  1063. };
  1064. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1065. const saveData = () => {
  1066. try {
  1067. const data = {};
  1068. $('#globalOptionsForm').serializeArray().map(value => {
  1069. data[value.name] = value.value;
  1070. return value;
  1071. });
  1072. $.makeArray($('#globalOptionsForm input')).map(element => {
  1073. const name = $(element).attr('name');
  1074. const keys = name.split('.');
  1075. if (keys.length === 3) {
  1076. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1077. } else if (keys.length === 2) {
  1078. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1079. }
  1080. return element;
  1081. });
  1082. GM_setValue('globalOptions', globalOptions);
  1083. external_Swal_default().fire({
  1084. title: i18n('changeGlobalOptionsSuccess'),
  1085. icon: 'success'
  1086. });
  1087. } catch (error) {
  1088. throwError(error, 'saveData');
  1089. }
  1090. };
  1091. const changeGlobalOptions = showType => {
  1092. try {
  1093. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1094. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1095. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1096. for (const [ option, data2 ] of Object.entries(data1)) {
  1097. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1098. if (typeof data2 === 'boolean') {
  1099. 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>`;
  1100. } else {
  1101. 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>`;
  1102. }
  1103. } else {
  1104. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1105. 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>`;
  1106. }
  1107. }
  1108. }
  1109. }
  1110. globalOptionsForm += '</tbody></table></form>';
  1111. if (showType === 'swal') {
  1112. external_Swal_default().fire({
  1113. title: i18n('globalOptions'),
  1114. html: globalOptionsForm,
  1115. showConfirmButton: true,
  1116. confirmButtonText: i18n('save'),
  1117. showCancelButton: true,
  1118. cancelButtonText: i18n('close')
  1119. }).then(_ref => {
  1120. let {
  1121. isConfirmed
  1122. } = _ref;
  1123. if (isConfirmed) {
  1124. saveData();
  1125. }
  1126. });
  1127. } else {
  1128. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1129. }
  1130. } catch (error) {
  1131. throwError(error, 'changeGlobalOptions');
  1132. }
  1133. };
  1134. const data = {
  1135. website: '网站',
  1136. type: '类型',
  1137. edit: '编辑',
  1138. whiteList: '白名单',
  1139. skipTask: '跳过撤销任务',
  1140. whiteListOptions: '白名单设置',
  1141. changeWhiteListOption: '设置白名单(%0)',
  1142. whiteListNotFound: '找不到此项白名单: %0',
  1143. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1144. changeWebsiteOptions: '网站设置',
  1145. changeGlobalOptions: '全局设置',
  1146. ok: '是',
  1147. save: '保存',
  1148. close: '关闭',
  1149. return: '返回',
  1150. option: '选项',
  1151. value: '值',
  1152. websiteOptions: '当前网站设置',
  1153. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1154. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1155. needLogin: '请先登录!',
  1156. getTasksInfo: '正在获取并处理任务信息...',
  1157. gettingKey: '正在获取Key...',
  1158. verifyingTask: '正在验证任务',
  1159. notice: '自动任务脚本提醒',
  1160. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1161. giveawayEnded: '此活动已结束,是否关闭?',
  1162. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1163. confirm: '确定',
  1164. cancel: '取消',
  1165. unKnown: '未知',
  1166. unKnownTaskType: '未识别的任务',
  1167. doing: '正在做任务',
  1168. allTasksComplete: '所有任务已完成!',
  1169. getTaskIdFailed: '获取任务Id失败!',
  1170. initSuccess: '%0 初始化成功!',
  1171. initFailed: '%0 初始化失败!',
  1172. errorLink: '链接错误: %0',
  1173. needInit: '请先初始化',
  1174. verifyingAuth: '正在验证%0凭证...',
  1175. updatingAuth: '正在更新%0凭证...',
  1176. initing: '正在初始化...',
  1177. getFailed: '获取%0失败!',
  1178. checkLoginFailed: '检测登录状态失败!',
  1179. checkLeftKeyFailed: '检测剩余Key失败!',
  1180. userId: '用户Id',
  1181. joiningGiveaway: '正在加入赠Key',
  1182. needJoinGiveaway: '需要先加入赠Key',
  1183. cannotUndo: '此网站不支持取消任务',
  1184. verifyAuth: '正在验证 %0 凭证...',
  1185. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1186. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1187. visitingLink: '正在访问链接: ',
  1188. doTask: '做任务',
  1189. undoTask: '撤销任务',
  1190. verifyTask: '验证任务',
  1191. getKey: '获取Key',
  1192. selectAll: '全选',
  1193. selectNone: '全不选',
  1194. invertSelect: '反选',
  1195. doFreeTask: '加入免费赠品',
  1196. doPointTask: '加入点数赠品',
  1197. skipTaskOption: '设置中已配置跳过任务',
  1198. other: '其他',
  1199. globalOptions: '全局设置',
  1200. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1201. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1202. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1203. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1204. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1205. saveGlobalOptions: '保存全局设置',
  1206. settingPage: '设置页面',
  1207. name: '名称',
  1208. version: '版本',
  1209. scriptManager: '脚本管理器',
  1210. script: '脚本',
  1211. environment: '环境',
  1212. os: '系统',
  1213. browser: '浏览器',
  1214. getId: '获取 %0 id',
  1215. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1216. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1217. showButton: '显示按钮',
  1218. hideButton: '隐藏按钮',
  1219. showLog: '显示日志',
  1220. hideLog: '隐藏日志',
  1221. defaultShowButton: '默认显示按钮',
  1222. defaultShowLog: '默认显示日志',
  1223. position: '组件位置',
  1224. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1225. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1226. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1227. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1228. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1229. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1230. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1231. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1232. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1233. hotKey: '快捷键',
  1234. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1235. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1236. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1237. tasksHistory: '任务历史',
  1238. clearHistory: '清空历史',
  1239. clearHistoryFinished: '已清空任务历史!',
  1240. deleteTask: '删除任务',
  1241. lastChangeTime: '最后一次修改时间',
  1242. clearTaskFinished: '删除以下任务完成!',
  1243. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1244. syncData: '数据同步',
  1245. settingData: '正在上传数据...',
  1246. gettingData: '正在获取数据...',
  1247. help: '帮助',
  1248. fileName: '文件名',
  1249. upload2gist: '同步到Gist',
  1250. downloadFromGist: '从Gist同步',
  1251. saveAndTest: '保存配置并测试',
  1252. testSuccess: '测试成功!',
  1253. testFailed: '测试失败!',
  1254. saveAndTestNotice: '请先保存配置并测试!',
  1255. processingData: '正在处理数据...',
  1256. updatingData: '正在上传数据...',
  1257. syncDataSuccess: '同步数据成功!',
  1258. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1259. downloadingData: '正在下载数据...',
  1260. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1261. savingData: '正在保存数据...',
  1262. syncHistory: '同步任务历史',
  1263. checkUpdateFailed: '检测更新失败',
  1264. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1265. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1266. gistOptions: 'Gist 设置',
  1267. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1268. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1269. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1270. toGithub: '前往Github反馈',
  1271. toKeylol: '前往其乐论坛反馈',
  1272. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1273. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1274. updateText: '%0 版本更新内容:',
  1275. Active: '进行中',
  1276. Ended: '已结束',
  1277. Banned: '已封禁',
  1278. Paused: '已暂停',
  1279. notStart: '未开始',
  1280. groups: '组',
  1281. wishlists: '愿望单',
  1282. follows: '游戏关注',
  1283. forums: '论坛',
  1284. workshops: '创意工坊收藏',
  1285. curators: '鉴赏家',
  1286. workshopVotes: '创意工坊点赞',
  1287. announcements: '社区通知',
  1288. steamCommunity: 'Steam社区',
  1289. steamStore: 'Steam商店',
  1290. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1291. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1292. joiningSteamGroup: '正在加入Steam组',
  1293. leavingSteamGroup: '正在退出Steam组',
  1294. gettingSteamGroupId: '正在获取Steam组Id',
  1295. subscribingForum: '正在订阅Steam论坛',
  1296. unsubscribingForum: '正在取消订阅Steam论坛',
  1297. gettingForumId: '正在获取Steam论坛Id',
  1298. followingCurator: '正在关注Steam鉴赏家',
  1299. unfollowingCurator: '正在取关Steam鉴赏家',
  1300. addingToWishlist: '正在添加游戏到Steam愿望单',
  1301. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1302. followingGame: '正在关注Steam游戏',
  1303. unfollowingGame: '正在取关Steam游戏',
  1304. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1305. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1306. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1307. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1308. gettingAnnouncementParams: '正在获取Steam通知信息',
  1309. likingAnnouncement: '正在点赞Steam通知',
  1310. changingArea: '正在更换Steam地区: %0...',
  1311. notNeededChangeArea: '当前地区不需要更换',
  1312. noAnotherArea: '请检测是否开启正确开启代理',
  1313. gettingAreaInfo: '正在获取Steam地区信息...',
  1314. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1315. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1316. gettingSubid: '正在获取游戏subid',
  1317. addingFreeLicense: '正在入库',
  1318. missParams: '缺少参数',
  1319. servers: '服务器',
  1320. joiningDiscordServer: '正在加入Discord服务器',
  1321. leavingDiscordServer: '正在退出Discord服务器',
  1322. gettingDiscordGuild: '正在获取Discord服务器Id',
  1323. users: '用户',
  1324. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1325. insBanned: '您的Instagram账户已被封禁',
  1326. verifyingInsAuth: '正在验证Instagram凭证...',
  1327. gettingInsUserId: '正在获取Instagram用户Id',
  1328. followingIns: '正在关注Instagram用户',
  1329. unfollowingIns: '正在取关Instagram用户',
  1330. reddits: '社区/用户',
  1331. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1332. changingRedditVersion: '正在切换Reddit为新版页面...',
  1333. joiningReddit: '正在加入Reddit社区',
  1334. leavingReddit: '正在退出Reddit社区',
  1335. followingRedditUser: '正在关注Reddit用户',
  1336. unfollowingRedditUser: '正在取关Reddit用户',
  1337. channels: '频道',
  1338. followingTwitchChannel: '正在关注Twitch频道',
  1339. unfollowingTwitchChannel: '正在取关Twitch频道',
  1340. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1341. twitterUser: '推特用户',
  1342. retweets: '转推',
  1343. followingTwitterUser: '正在关注推特用户',
  1344. unfollowingTwitterUser: '正在取关推特用户',
  1345. retweetting: '正在转推',
  1346. unretweetting: '正在撤销转推',
  1347. names: '组/社区/动态',
  1348. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1349. gettingVkId: '正在获取Vk任务Id',
  1350. joiningVkGroup: '正在加入Vk组',
  1351. leavingVkGroup: '正在退出Vk组',
  1352. joiningVkPublic: '正在加入Vk社区',
  1353. leavingVkPublic: '正在退出Vk社区',
  1354. sendingVkWall: '正在转发Vk动态',
  1355. deletingVkWall: '正在撤销转发Vk动态',
  1356. youtubeChannel: 'YouTube频道',
  1357. likes: '点赞',
  1358. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1359. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1360. gettingYtbToken: '正在获取YouTube Token...',
  1361. followingYtbChannel: '正在订阅YouTube频道',
  1362. unfollowingYtbChannel: '正在退订YouTube频道',
  1363. likingYtbVideo: '正在点赞YouTube视频',
  1364. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1365. giveKeyNoticeBefore: '每次验证间隔15s',
  1366. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1367. noPoints: '点数不够,跳过抽奖',
  1368. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1369. joiningLottery: '正在加入抽奖',
  1370. doingGleamTask: '正在做Gleam任务...',
  1371. gettingGleamLink: '正在获取Gleam任务链接...',
  1372. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1373. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1374. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1375. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1376. };
  1377. const zh_CN = data;
  1378. const en_US_data = {
  1379. website: 'Website',
  1380. type: 'Type',
  1381. edit: 'Edit',
  1382. whiteList: 'Whitelist',
  1383. skipTask: 'Skip undo task',
  1384. whiteListOptions: 'Whitelist options',
  1385. changeWhiteListOption: 'Whitelist option(%0)',
  1386. whiteListNotFound: 'Cannot find this whitelist: %0',
  1387. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1388. changeWebsiteOptions: 'Website options',
  1389. changeGlobalOptions: 'Global options',
  1390. ok: 'OK',
  1391. save: 'Save',
  1392. close: 'Close',
  1393. return: 'Return',
  1394. option: 'Option',
  1395. value: 'Value',
  1396. websiteOptions: 'Current website settings',
  1397. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1398. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1399. needLogin: 'Please log in first!',
  1400. getTasksInfo: 'Obtaining and processing task information...',
  1401. gettingKey: 'Getting Key...',
  1402. verifyingTask: 'Verifying task',
  1403. notice: 'Automatic task script notice',
  1404. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1405. giveawayEnded: 'This event has ended, do you want to close it?',
  1406. 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?',
  1407. confirm: 'Confirm',
  1408. cancel: 'Cancel',
  1409. unKnown: 'Unknown',
  1410. unKnownTaskType: 'Unrecognized task',
  1411. doing: 'Doing a task',
  1412. allTasksComplete: 'All tasks have been completed!',
  1413. getTaskIdFailed: 'Failed to obtain task Id!',
  1414. initSuccess: '%0 was initialized successfully!',
  1415. initFailed: '%0 initialization failed!',
  1416. errorLink: 'Link error: %0',
  1417. needInit: 'Please initialize first',
  1418. verifyingAuth: 'Verifying %0 token...',
  1419. updatingAuth: 'Update %0 token...',
  1420. initing: 'Initializing...',
  1421. getFailed: 'Failed to get %0!',
  1422. checkLoginFailed: 'Failed to detect login status!',
  1423. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1424. userId: 'User Id',
  1425. joiningGiveaway: 'Joining giveaway',
  1426. needJoinGiveaway: 'Need to join the giveaway first',
  1427. cannotUndo: 'This website does not support canceling tasks',
  1428. verifyAuth: 'Verifying %0 token...',
  1429. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1430. errorReport: 'A script error is detected, do you want to report the BUG?',
  1431. visitingLink: 'Visiting link: ',
  1432. doTask: 'DoTask',
  1433. undoTask: 'UndoTask',
  1434. verifyTask: 'Verify',
  1435. getKey: 'GetKey',
  1436. selectAll: 'SelectAll',
  1437. selectNone: 'SelectNone',
  1438. invertSelect: 'InvertSelect',
  1439. doFreeTask: 'FreeTask',
  1440. doPointTask: 'PointTask',
  1441. skipTaskOption: 'Skip task has been configured in the settings',
  1442. other: 'Other',
  1443. globalOptions: 'Global Options',
  1444. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1445. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1446. 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.',
  1447. 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.',
  1448. 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.',
  1449. saveGlobalOptions: 'SaveSettings',
  1450. settingPage: 'Setting Page',
  1451. name: 'Name',
  1452. version: 'Version',
  1453. scriptManager: 'Script Manager',
  1454. script: 'Script',
  1455. environment: 'Environment',
  1456. os: 'OS',
  1457. browser: 'Browser',
  1458. getId: 'Get %0 id',
  1459. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1460. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1461. showButton: 'ShowButton',
  1462. hideButton: 'HideButton',
  1463. showLog: 'ShowLog',
  1464. hideLog: 'HideLog',
  1465. defaultShowButton: 'Default display button',
  1466. defaultShowLog: 'Display log by default',
  1467. position: 'Component position',
  1468. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1469. 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',
  1470. 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',
  1471. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1472. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1473. 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',
  1474. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1475. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1476. 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',
  1477. hotKey: 'Shortcut key',
  1478. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1479. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1480. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1481. tasksHistory: 'TasksHistory',
  1482. clearHistory: 'Clear history',
  1483. clearHistoryFinished: 'The mission history has been cleared!',
  1484. deleteTask: 'Delete task',
  1485. lastChangeTime: 'Last Change Time',
  1486. clearTaskFinished: 'Delete the following tasks completed!',
  1487. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1488. syncData: 'DataSync',
  1489. settingData: 'Uploading data...',
  1490. gettingData: 'Getting data...',
  1491. help: 'Help',
  1492. fileName: 'Filename',
  1493. upload2gist: 'Sync to Gist',
  1494. downloadFromGist: 'Sync from Gist',
  1495. saveAndTest: 'Save configuration and test',
  1496. testSuccess: 'Test success!',
  1497. testFailed: 'Test failed!',
  1498. saveAndTestNotice: 'Please save the configuration and test first!',
  1499. processingData: 'Processing data...',
  1500. updatingData: 'Uploading data...',
  1501. syncDataSuccess: 'Synchronized data successfully!',
  1502. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1503. downloadingData: 'Downloading data...',
  1504. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1505. savingData: 'Saving data...',
  1506. syncHistory: 'Synchronize tasks history',
  1507. checkUpdateFailed: 'Check update failed',
  1508. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1509. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1510. gistOptions: 'Gist Settings',
  1511. 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!',
  1512. 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!',
  1513. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1514. toGithub: 'Feedback(Github)',
  1515. toKeylol: 'Feedback(Keylol)',
  1516. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1517. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1518. updateText: 'Updates in version %0:',
  1519. Active: 'Active',
  1520. Ended: 'Ended',
  1521. Banned: 'Banned',
  1522. Paused: 'Paused',
  1523. notStart: 'notStart',
  1524. groups: 'Group',
  1525. wishlists: 'Wishlist',
  1526. follows: 'Follow Game',
  1527. forums: 'Forum',
  1528. workshops: 'Favorite Workshop',
  1529. curators: 'Curator',
  1530. workshopVotes: 'Voteup Workshop',
  1531. announcements: 'Announcement',
  1532. steamCommunity: 'Steam Community',
  1533. steamStore: 'Steam Store',
  1534. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1535. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1536. joiningSteamGroup: 'Joining Steam Group',
  1537. leavingSteamGroup: 'Leaving Steam Group',
  1538. gettingSteamGroupId: 'Getting Steam Group Id',
  1539. subscribingForum: 'Subscribing the Steam Forum',
  1540. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1541. gettingForumId: 'Getting Steam Forum Id',
  1542. followingCurator: 'Following Steam Curator',
  1543. unfollowingCurator: 'Unfollowing Steam Curator',
  1544. addingToWishlist: 'Adding the game to the Steam wishlist',
  1545. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1546. followingGame: 'Following Steam games',
  1547. unfollowingGame: 'Unfollowing Steam games',
  1548. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1549. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1550. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1551. votingUpWorkshop: 'Liking Steam workshop items',
  1552. gettingAnnouncementParams: 'Getting Steam announcement information',
  1553. likingAnnouncement: 'Liking Steam announcement',
  1554. changingArea: 'Changing Steam area: %0...',
  1555. notNeededChangeArea: 'The current area does not need to be changed',
  1556. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1557. gettingAreaInfo: 'Getting Steam area information...',
  1558. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1559. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1560. gettingSubid: 'Getting subid',
  1561. addingFreeLicense: 'Adding free license',
  1562. missParams: 'Missing parameters',
  1563. servers: 'Server',
  1564. joiningDiscordServer: 'Joining Discord Server',
  1565. leavingDiscordServer: 'Leaving Discord Server',
  1566. gettingDiscordGuild: 'Getting Discord server Id',
  1567. users: 'User',
  1568. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1569. insBanned: 'Your Instagram account has been banned',
  1570. verifyingInsAuth: 'Verifying Instagram token...',
  1571. gettingInsUserId: 'Getting Instagram user Id',
  1572. followingIns: 'Following Instagram user',
  1573. unfollowingIns: 'Unfollowing Instagram user',
  1574. reddits: 'Reddit/User',
  1575. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1576. changingRedditVersion: 'Switching Reddit to a new version page...',
  1577. joiningReddit: 'Joining the Reddit',
  1578. leavingReddit: 'Leaving the Reddit',
  1579. followingRedditUser: 'Following Reddit User',
  1580. unfollowingRedditUser: 'Unfollowing Reddit User',
  1581. channels: 'Channel',
  1582. followingTwitchChannel: 'Following Twitch Channel',
  1583. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1584. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1585. twitterUser: 'Twitter User',
  1586. retweets: 'Retweet',
  1587. followingTwitterUser: 'Following Twitter User',
  1588. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1589. retweetting: 'Retweetting',
  1590. unretweetting: 'Unretweetting',
  1591. names: 'Group/Public/Wall',
  1592. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1593. gettingVkId: 'Getting Vk task Id',
  1594. joiningVkGroup: 'Joining Vk Group',
  1595. leavingVkGroup: 'Leaving Vk Group',
  1596. joiningVkPublic: 'Joining Vk Public',
  1597. leavingVkPublic: 'Leaving Vk Public',
  1598. sendingVkWall: 'Sending Vk Wall',
  1599. deletingVkWall: 'Deleting Vk Wall',
  1600. youtubeChannel: 'YouTube Channel',
  1601. likes: 'Like',
  1602. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1603. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1604. gettingYtbToken: 'Getting YouTube Token...',
  1605. followingYtbChannel: 'Subscribing to YouTube channel',
  1606. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1607. likingYtbVideo: 'Liking YouTube video',
  1608. unlikingYtbVideo: 'Unliking YouTube video',
  1609. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1610. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1611. noPoints: 'Not enough points, skip the lottery',
  1612. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1613. joiningLottery: 'Joining the lottery',
  1614. doingGleamTask: 'Doing Gleam Task...',
  1615. gettingGleamLink: 'Getting Gleam task link...',
  1616. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1617. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1618. 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!',
  1619. 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...'
  1620. };
  1621. const en_US = en_US_data;
  1622. const languages = {
  1623. zh: zh_CN,
  1624. en: en_US
  1625. };
  1626. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1627. const I18n = function(key) {
  1628. var _languages$language;
  1629. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1630. argvs[_key - 1] = arguments[_key];
  1631. }
  1632. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1633. return key;
  1634. }
  1635. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1636. };
  1637. const i18n = I18n;
  1638. function throwError(error, name) {
  1639. external_Swal_default().fire({
  1640. title: i18n('errorReport'),
  1641. icon: 'error',
  1642. showCancelButton: true,
  1643. confirmButtonText: i18n('toGithub'),
  1644. showDenyButton: true,
  1645. denyButtonText: i18n('toKeylol'),
  1646. cancelButtonText: i18n('close')
  1647. }).then(_ref => {
  1648. let {
  1649. isDenied,
  1650. isConfirmed
  1651. } = _ref;
  1652. if (isConfirmed) {
  1653. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`脚本报错: ${name}`)}&labels=bug&body=${encodeURIComponent(`错误链接: [${window.location.href}](${window.location.href})
  1654.  
  1655. 环境:
  1656. \`\`\`
  1657. ${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}
  1658. \`\`\`
  1659. 脚本管理器: \`${GM_info.scriptHandler} ${GM_info.version}\`
  1660. 脚本版本: \`${GM_info.script.version}\`
  1661.  
  1662. 报错信息:
  1663. \`\`\`
  1664. ${error.stack}
  1665. \`\`\`
  1666.  
  1667. 执行日志:
  1668. \`\`\`
  1669. ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}
  1670. \`\`\`
  1671. `)}`, '_blank');
  1672. } else if (isDenied) {
  1673. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1674.  
  1675. 环境:
  1676.  
  1677. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1678.  
  1679. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1680. 脚本版本: ${GM_info.script.version}
  1681.  
  1682. 报错信息:
  1683. [code]${error.stack}[/code]
  1684.  
  1685. 执行日志:
  1686. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1687. GM_setClipboard(text);
  1688. external_Swal_default().fire({
  1689. title: i18n('copySuccess'),
  1690. icon: 'success',
  1691. confirmButtonText: i18n('ok')
  1692. }).then(() => {
  1693. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1694. });
  1695. }
  1696. });
  1697. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1698. }
  1699. function _defineProperty(obj, key, value) {
  1700. if (key in obj) {
  1701. Object.defineProperty(obj, key, {
  1702. value: value,
  1703. enumerable: true,
  1704. configurable: true,
  1705. writable: true
  1706. });
  1707. } else {
  1708. obj[key] = value;
  1709. }
  1710. return obj;
  1711. }
  1712. class Social {
  1713. constructor() {
  1714. _defineProperty(this, 'tasks', void 0);
  1715. }
  1716. getRealParams(name, links, doTask, link2param) {
  1717. try {
  1718. let realParams = [];
  1719. if (links.length > 0) {
  1720. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1721. }
  1722. if (!doTask && this.tasks[name].length > 0) {
  1723. realParams = [ ...realParams, ...this.tasks[name] ];
  1724. }
  1725. return unique(realParams);
  1726. } catch (error) {
  1727. throwError(error, 'Social.getRealParams');
  1728. return [];
  1729. }
  1730. }
  1731. }
  1732. const social_Social = Social;
  1733. function _classPrivateMethodInitSpec(obj, privateSet) {
  1734. _checkPrivateRedeclaration(obj, privateSet);
  1735. privateSet.add(obj);
  1736. }
  1737. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1738. _checkPrivateRedeclaration(obj, privateMap);
  1739. privateMap.set(obj, value);
  1740. }
  1741. function _checkPrivateRedeclaration(obj, privateCollection) {
  1742. if (privateCollection.has(obj)) {
  1743. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1744. }
  1745. }
  1746. function Discord_defineProperty(obj, key, value) {
  1747. if (key in obj) {
  1748. Object.defineProperty(obj, key, {
  1749. value: value,
  1750. enumerable: true,
  1751. configurable: true,
  1752. writable: true
  1753. });
  1754. } else {
  1755. obj[key] = value;
  1756. }
  1757. return obj;
  1758. }
  1759. function _classPrivateFieldSet(receiver, privateMap, value) {
  1760. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1761. _classApplyDescriptorSet(receiver, descriptor, value);
  1762. return value;
  1763. }
  1764. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1765. if (descriptor.set) {
  1766. descriptor.set.call(receiver, value);
  1767. } else {
  1768. if (!descriptor.writable) {
  1769. throw new TypeError('attempted to set read only private field');
  1770. }
  1771. descriptor.value = value;
  1772. }
  1773. }
  1774. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1775. if (!privateSet.has(receiver)) {
  1776. throw new TypeError('attempted to get private field on non-instance');
  1777. }
  1778. return fn;
  1779. }
  1780. function _classPrivateFieldGet(receiver, privateMap) {
  1781. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1782. return _classApplyDescriptorGet(receiver, descriptor);
  1783. }
  1784. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1785. if (!privateMap.has(receiver)) {
  1786. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1787. }
  1788. return privateMap.get(receiver);
  1789. }
  1790. function _classApplyDescriptorGet(receiver, descriptor) {
  1791. if (descriptor.get) {
  1792. return descriptor.get.call(receiver);
  1793. }
  1794. return descriptor.value;
  1795. }
  1796. const defaultTasks = JSON.stringify({
  1797. servers: []
  1798. });
  1799. var _auth = new WeakMap();
  1800. var _cache = new WeakMap();
  1801. var _initialized = new WeakMap();
  1802. var _verifyAuth = new WeakSet();
  1803. var _updateAuth = new WeakSet();
  1804. var _joinServer = new WeakSet();
  1805. var _leaveServer = new WeakSet();
  1806. var _getGuild = new WeakSet();
  1807. var _setCache = new WeakSet();
  1808. class Discord extends social_Social {
  1809. constructor() {
  1810. var _GM_getValue;
  1811. super(...arguments);
  1812. _classPrivateMethodInitSpec(this, _setCache);
  1813. _classPrivateMethodInitSpec(this, _getGuild);
  1814. _classPrivateMethodInitSpec(this, _leaveServer);
  1815. _classPrivateMethodInitSpec(this, _joinServer);
  1816. _classPrivateMethodInitSpec(this, _updateAuth);
  1817. _classPrivateMethodInitSpec(this, _verifyAuth);
  1818. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1819. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || JSON.parse(defaultTasks));
  1820. _classPrivateFieldInitSpec(this, _auth, {
  1821. writable: true,
  1822. value: GM_getValue('discordAuth') || {}
  1823. });
  1824. _classPrivateFieldInitSpec(this, _cache, {
  1825. writable: true,
  1826. value: GM_getValue('discordCache') || {}
  1827. });
  1828. _classPrivateFieldInitSpec(this, _initialized, {
  1829. writable: true,
  1830. value: false
  1831. });
  1832. }
  1833. async init() {
  1834. try {
  1835. if (_classPrivateFieldGet(this, _initialized)) {
  1836. return true;
  1837. }
  1838. if (!_classPrivateFieldGet(this, _auth).auth) {
  1839. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1840. _classPrivateFieldSet(this, _initialized, true);
  1841. return true;
  1842. }
  1843. return false;
  1844. }
  1845. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1846. if (isVerified) {
  1847. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1848. _classPrivateFieldSet(this, _initialized, true);
  1849. return true;
  1850. }
  1851. GM_setValue('discordAuth', {
  1852. auth: null
  1853. });
  1854. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1855. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1856. _classPrivateFieldSet(this, _initialized, true);
  1857. return true;
  1858. }
  1859. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1860. return false;
  1861. } catch (error) {
  1862. throwError(error, 'Discord.init');
  1863. return false;
  1864. }
  1865. }
  1866. async toggle(_ref) {
  1867. let {
  1868. doTask = true,
  1869. serverLinks = []
  1870. } = _ref;
  1871. try {
  1872. if (!_classPrivateFieldGet(this, _initialized)) {
  1873. scripts_echoLog({
  1874. text: i18n('needInit')
  1875. });
  1876. return false;
  1877. }
  1878. const prom = [];
  1879. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1880. scripts_echoLog({
  1881. type: 'globalOptionsSkip',
  1882. text: 'discord.servers'
  1883. });
  1884. } else {
  1885. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1886. var _link$match;
  1887. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1888. });
  1889. if (realServers.length > 0) {
  1890. for (const server of realServers) {
  1891. if (doTask) {
  1892. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1893. } else {
  1894. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1895. }
  1896. await delay(1e3);
  1897. }
  1898. }
  1899. }
  1900. return await Promise.all(prom).then(() => true);
  1901. } catch (error) {
  1902. throwError(error, 'Discord.toggleServers');
  1903. return false;
  1904. }
  1905. }
  1906. }
  1907. async function _verifyAuth2() {
  1908. try {
  1909. const logStatus = scripts_echoLog({
  1910. text: i18n('verifyingAuth', 'Discord')
  1911. });
  1912. const {
  1913. result,
  1914. statusText,
  1915. status,
  1916. data
  1917. } = await tools_httpRequest({
  1918. url: 'https://discord.com/api/v6/users/@me',
  1919. method: 'HEAD',
  1920. headers: {
  1921. authorization: _classPrivateFieldGet(this, _auth).auth
  1922. }
  1923. });
  1924. if (result === 'Success') {
  1925. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1926. logStatus.success();
  1927. return true;
  1928. }
  1929. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1930. return false;
  1931. }
  1932. logStatus.error(`${result}:${statusText}(${status})`);
  1933. return false;
  1934. } catch (error) {
  1935. throwError(error, 'Discord.verifyAuth');
  1936. return false;
  1937. }
  1938. }
  1939. async function _updateAuth2() {
  1940. try {
  1941. const logStatus = scripts_echoLog({
  1942. text: i18n('updatingAuth', 'Discord')
  1943. });
  1944. return await new Promise(resolve => {
  1945. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1946. active: true,
  1947. insert: true,
  1948. setParent: true
  1949. });
  1950. newTab.onclose = async () => {
  1951. var _GM_getValue2;
  1952. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1953. if (auth) {
  1954. _classPrivateFieldSet(this, _auth, {
  1955. auth: auth
  1956. });
  1957. logStatus.success();
  1958. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1959. } else {
  1960. logStatus.error('Error: Update discord auth failed!');
  1961. resolve(false);
  1962. }
  1963. };
  1964. });
  1965. } catch (error) {
  1966. throwError(error, 'Discord.updateAuth');
  1967. return false;
  1968. }
  1969. }
  1970. async function _joinServer2(inviteId) {
  1971. try {
  1972. const logStatus = scripts_echoLog({
  1973. type: 'joiningDiscordServer',
  1974. text: inviteId
  1975. });
  1976. const {
  1977. result,
  1978. statusText,
  1979. status,
  1980. data
  1981. } = await tools_httpRequest({
  1982. url: `https://discord.com/api/v6/invites/${inviteId}`,
  1983. method: 'POST',
  1984. dataType: 'json',
  1985. headers: {
  1986. authorization: _classPrivateFieldGet(this, _auth).auth
  1987. }
  1988. });
  1989. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1990. var _data$response, _data$response$guild;
  1991. logStatus.success();
  1992. 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);
  1993. if (guild) {
  1994. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  1995. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1996. }
  1997. return true;
  1998. }
  1999. logStatus.error(`${result}:${statusText}(${status})`);
  2000. return false;
  2001. } catch (error) {
  2002. throwError(error, 'Discord.joinServer');
  2003. return false;
  2004. }
  2005. }
  2006. async function _leaveServer2(inviteId) {
  2007. try {
  2008. if (this.whiteList.servers.includes(inviteId)) {
  2009. scripts_echoLog({
  2010. type: 'whiteList',
  2011. text: 'Discord.leaveServer',
  2012. id: inviteId
  2013. });
  2014. return true;
  2015. }
  2016. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2017. if (!guild) {
  2018. return false;
  2019. }
  2020. const logStatus = scripts_echoLog({
  2021. type: 'leavingDiscordServer',
  2022. text: guild
  2023. });
  2024. const {
  2025. result,
  2026. statusText,
  2027. status,
  2028. data
  2029. } = await tools_httpRequest({
  2030. url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
  2031. method: 'DELETE',
  2032. headers: {
  2033. authorization: _classPrivateFieldGet(this, _auth).auth
  2034. }
  2035. });
  2036. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2037. logStatus.success();
  2038. return true;
  2039. }
  2040. logStatus.error(`${result}:${statusText}(${status})`);
  2041. return false;
  2042. } catch (error) {
  2043. throwError(error, 'Discord.leaveServer');
  2044. return false;
  2045. }
  2046. }
  2047. async function _getGuild2(inviteId) {
  2048. try {
  2049. const logStatus = scripts_echoLog({
  2050. type: 'gettingDiscordGuild',
  2051. text: inviteId
  2052. });
  2053. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2054. if (guild) {
  2055. logStatus.success();
  2056. return guild;
  2057. }
  2058. const {
  2059. result,
  2060. statusText,
  2061. status,
  2062. data
  2063. } = await tools_httpRequest({
  2064. url: `https://discord.com/invite/${inviteId}`,
  2065. method: 'GET'
  2066. });
  2067. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2068. var _data$responseText$ma;
  2069. const guild = (_data$responseText$ma = data.responseText.match(/https?:\/\/cdn\.discordapp\.com\/icons\/([\d]+?)\//)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2070. if (guild) {
  2071. logStatus.success();
  2072. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2073. return guild;
  2074. }
  2075. logStatus.error(`${result}:${statusText}(${status})`);
  2076. return false;
  2077. }
  2078. logStatus.error(`${result}:${statusText}(${status})`);
  2079. return false;
  2080. } catch (error) {
  2081. throwError(error, 'Discord.getGuild');
  2082. return false;
  2083. }
  2084. }
  2085. function _setCache2(inviteId, guild) {
  2086. try {
  2087. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2088. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2089. } catch (error) {
  2090. throwError(error, 'Discord.setCache');
  2091. }
  2092. }
  2093. const social_Discord = Discord;
  2094. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2095. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2096. privateSet.add(obj);
  2097. }
  2098. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2099. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2100. privateMap.set(obj, value);
  2101. }
  2102. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2103. if (privateCollection.has(obj)) {
  2104. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2105. }
  2106. }
  2107. function Instagram_defineProperty(obj, key, value) {
  2108. if (key in obj) {
  2109. Object.defineProperty(obj, key, {
  2110. value: value,
  2111. enumerable: true,
  2112. configurable: true,
  2113. writable: true
  2114. });
  2115. } else {
  2116. obj[key] = value;
  2117. }
  2118. return obj;
  2119. }
  2120. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2121. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2122. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2123. return value;
  2124. }
  2125. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2126. if (descriptor.set) {
  2127. descriptor.set.call(receiver, value);
  2128. } else {
  2129. if (!descriptor.writable) {
  2130. throw new TypeError('attempted to set read only private field');
  2131. }
  2132. descriptor.value = value;
  2133. }
  2134. }
  2135. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2136. if (!privateSet.has(receiver)) {
  2137. throw new TypeError('attempted to get private field on non-instance');
  2138. }
  2139. return fn;
  2140. }
  2141. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2142. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2143. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2144. }
  2145. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2146. if (!privateMap.has(receiver)) {
  2147. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2148. }
  2149. return privateMap.get(receiver);
  2150. }
  2151. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2152. if (descriptor.get) {
  2153. return descriptor.get.call(receiver);
  2154. }
  2155. return descriptor.value;
  2156. }
  2157. const Instagram_defaultTasks = JSON.stringify({
  2158. users: []
  2159. });
  2160. var Instagram_cache = new WeakMap();
  2161. var Instagram_auth = new WeakMap();
  2162. var Instagram_initialized = new WeakMap();
  2163. var _getUserInfo = new WeakSet();
  2164. var _followUser = new WeakSet();
  2165. var _unfollowUser = new WeakSet();
  2166. var Instagram_setCache = new WeakSet();
  2167. class Instagram extends social_Social {
  2168. constructor() {
  2169. var _GM_getValue;
  2170. super(...arguments);
  2171. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2172. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2173. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2174. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2175. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2176. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || JSON.parse(Instagram_defaultTasks));
  2177. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2178. writable: true,
  2179. value: GM_getValue('instagramCache') || {}
  2180. });
  2181. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2182. writable: true,
  2183. value: {}
  2184. });
  2185. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2186. writable: true,
  2187. value: false
  2188. });
  2189. }
  2190. async init() {
  2191. try {
  2192. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2193. return true;
  2194. }
  2195. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2196. if (isVerified) {
  2197. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2198. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2199. return true;
  2200. }
  2201. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2202. return false;
  2203. } catch (error) {
  2204. throwError(error, 'Instagram.init');
  2205. return false;
  2206. }
  2207. }
  2208. async toggle(_ref) {
  2209. let {
  2210. doTask = true,
  2211. userLinks = []
  2212. } = _ref;
  2213. try {
  2214. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2215. scripts_echoLog({
  2216. text: i18n('needInit')
  2217. });
  2218. return false;
  2219. }
  2220. const prom = [];
  2221. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2222. scripts_echoLog({
  2223. type: 'globalOptionsSkip',
  2224. text: 'instagram.users'
  2225. });
  2226. } else {
  2227. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2228. var _link$match;
  2229. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2230. });
  2231. if (realUsers.length > 0) {
  2232. for (const username of realUsers) {
  2233. if (doTask) {
  2234. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2235. } else {
  2236. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2237. }
  2238. await delay(1e3);
  2239. }
  2240. }
  2241. }
  2242. return await Promise.all(prom).then(() => true);
  2243. } catch (error) {
  2244. throwError(error, 'Instagram.toggleUsers');
  2245. return false;
  2246. }
  2247. }
  2248. }
  2249. async function _getUserInfo2() {
  2250. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2251. try {
  2252. const logStatus = scripts_echoLog({
  2253. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2254. text: name
  2255. });
  2256. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2257. if (userId && name !== 'instagram') {
  2258. logStatus.success();
  2259. return userId;
  2260. }
  2261. const {
  2262. result,
  2263. statusText,
  2264. status,
  2265. data
  2266. } = await tools_httpRequest({
  2267. url: `https://www.instagram.com/${name}/`,
  2268. method: 'GET'
  2269. });
  2270. if (result === 'Success') {
  2271. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2272. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2273. return false;
  2274. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2275. logStatus.error(`Error:${i18n('insBanned')}`);
  2276. return false;
  2277. }
  2278. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2279. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2280. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2281. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2282. if (name === 'instagram') {
  2283. if (csrftoken && hash) {
  2284. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2285. csrftoken: csrftoken,
  2286. hash: hash
  2287. });
  2288. return true;
  2289. }
  2290. return false;
  2291. }
  2292. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2293. if (id) {
  2294. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2295. logStatus.success();
  2296. return id;
  2297. }
  2298. logStatus.error('Error: Get ins data error!');
  2299. return false;
  2300. }
  2301. logStatus.error(`${result}:${statusText}(${status})`);
  2302. return false;
  2303. }
  2304. return false;
  2305. } catch (error) {
  2306. throwError(error, 'Instagram.getUserInfo');
  2307. return false;
  2308. }
  2309. }
  2310. async function _followUser2(name) {
  2311. try {
  2312. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2313. if (!id) {
  2314. return false;
  2315. }
  2316. const logStatus = scripts_echoLog({
  2317. type: 'followingIns',
  2318. text: name
  2319. });
  2320. const {
  2321. result,
  2322. statusText,
  2323. status,
  2324. data
  2325. } = await tools_httpRequest({
  2326. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2327. method: 'POST',
  2328. dataType: 'json',
  2329. headers: {
  2330. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2331. origin: 'https://www.instagram.com',
  2332. referer: `https://www.instagram.com/${name}/`,
  2333. 'content-type': 'application/x-www-form-urlencoded',
  2334. 'sec-fetch-site': 'same-origin',
  2335. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2336. }
  2337. });
  2338. if (result === 'Success') {
  2339. var _data$response, _data$response2;
  2340. 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') {
  2341. logStatus.success();
  2342. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2343. return true;
  2344. }
  2345. 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})`}`);
  2346. return false;
  2347. }
  2348. logStatus.error(`${result}:${statusText}(${status})`);
  2349. return false;
  2350. } catch (error) {
  2351. throwError(error, 'Instagram.followUser');
  2352. return false;
  2353. }
  2354. }
  2355. async function _unfollowUser2(name) {
  2356. try {
  2357. if (this.whiteList.users.includes(name)) {
  2358. scripts_echoLog({
  2359. type: 'whiteList',
  2360. text: 'Instagram.unfollowUser',
  2361. id: name
  2362. });
  2363. return true;
  2364. }
  2365. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2366. if (!id) {
  2367. return false;
  2368. }
  2369. const logStatus = scripts_echoLog({
  2370. type: 'unfollowingIns',
  2371. text: name
  2372. });
  2373. const {
  2374. result,
  2375. statusText,
  2376. status,
  2377. data
  2378. } = await tools_httpRequest({
  2379. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2380. method: 'POST',
  2381. dataType: 'json',
  2382. headers: {
  2383. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2384. origin: 'https://www.instagram.com',
  2385. referer: `https://www.instagram.com/${name}/`,
  2386. 'content-type': 'application/x-www-form-urlencoded',
  2387. 'sec-fetch-site': 'same-origin',
  2388. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2389. }
  2390. });
  2391. if (result === 'Success') {
  2392. var _data$response3;
  2393. 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') {
  2394. logStatus.success();
  2395. return true;
  2396. }
  2397. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2398. return false;
  2399. }
  2400. logStatus.error(`${result}:${statusText}(${status})`);
  2401. return false;
  2402. } catch (error) {
  2403. throwError(error, 'Instagram.unfollowUser');
  2404. return false;
  2405. }
  2406. }
  2407. function Instagram_setCache2(name, id) {
  2408. try {
  2409. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2410. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2411. } catch (error) {
  2412. throwError(error, 'Instagram.setCache');
  2413. }
  2414. }
  2415. const social_Instagram = Instagram;
  2416. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2417. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2418. privateSet.add(obj);
  2419. }
  2420. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2421. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2422. privateMap.set(obj, value);
  2423. }
  2424. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2425. if (privateCollection.has(obj)) {
  2426. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2427. }
  2428. }
  2429. function Reddit_defineProperty(obj, key, value) {
  2430. if (key in obj) {
  2431. Object.defineProperty(obj, key, {
  2432. value: value,
  2433. enumerable: true,
  2434. configurable: true,
  2435. writable: true
  2436. });
  2437. } else {
  2438. obj[key] = value;
  2439. }
  2440. return obj;
  2441. }
  2442. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2443. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2444. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2445. return value;
  2446. }
  2447. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2448. if (descriptor.set) {
  2449. descriptor.set.call(receiver, value);
  2450. } else {
  2451. if (!descriptor.writable) {
  2452. throw new TypeError('attempted to set read only private field');
  2453. }
  2454. descriptor.value = value;
  2455. }
  2456. }
  2457. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2458. if (!privateSet.has(receiver)) {
  2459. throw new TypeError('attempted to get private field on non-instance');
  2460. }
  2461. return fn;
  2462. }
  2463. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2464. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2465. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2466. }
  2467. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2468. if (!privateMap.has(receiver)) {
  2469. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2470. }
  2471. return privateMap.get(receiver);
  2472. }
  2473. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2474. if (descriptor.get) {
  2475. return descriptor.get.call(receiver);
  2476. }
  2477. return descriptor.value;
  2478. }
  2479. const Reddit_defaultTasks = JSON.stringify({
  2480. reddits: []
  2481. });
  2482. var Reddit_auth = new WeakMap();
  2483. var Reddit_initialized = new WeakMap();
  2484. var _useBeta = new WeakSet();
  2485. var Reddit_updateAuth = new WeakSet();
  2486. class Reddit extends social_Social {
  2487. constructor() {
  2488. var _GM_getValue;
  2489. super(...arguments);
  2490. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2491. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2492. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2493. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || JSON.parse(Reddit_defaultTasks));
  2494. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2495. writable: true,
  2496. value: void 0
  2497. });
  2498. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2499. writable: true,
  2500. value: false
  2501. });
  2502. }
  2503. async init() {
  2504. try {
  2505. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2506. return true;
  2507. }
  2508. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2509. if (isVerified) {
  2510. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2511. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2512. return true;
  2513. }
  2514. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2515. return false;
  2516. } catch (error) {
  2517. throwError(error, 'Reddit.init');
  2518. return false;
  2519. }
  2520. }
  2521. async toggleTask(_ref) {
  2522. let {
  2523. name,
  2524. doTask = true
  2525. } = _ref;
  2526. try {
  2527. if (!doTask && this.whiteList.reddits.includes(name)) {
  2528. scripts_echoLog({
  2529. type: 'whiteList',
  2530. text: 'Reddit.undoTask',
  2531. id: name
  2532. });
  2533. return true;
  2534. }
  2535. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2536. if (/^u_/.test(name)) {
  2537. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2538. }
  2539. const logStatus = scripts_echoLog({
  2540. type: type,
  2541. text: name
  2542. });
  2543. const {
  2544. result,
  2545. statusText,
  2546. status,
  2547. data
  2548. } = await tools_httpRequest({
  2549. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2550. method: 'POST',
  2551. headers: {
  2552. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2553. 'content-type': 'application/x-www-form-urlencoded'
  2554. },
  2555. data: $.param({
  2556. action: doTask ? 'sub' : 'unsub',
  2557. sr_name: name,
  2558. api_type: 'json'
  2559. })
  2560. });
  2561. if (result === 'Success') {
  2562. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2563. logStatus.success();
  2564. if (doTask) {
  2565. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2566. }
  2567. return true;
  2568. }
  2569. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2570. return false;
  2571. }
  2572. logStatus.error(`${result}:${statusText}(${status})`);
  2573. return false;
  2574. } catch (error) {
  2575. throwError(error, 'Reddit.toggleTask');
  2576. return false;
  2577. }
  2578. }
  2579. async toggle(_ref2) {
  2580. let {
  2581. doTask = true,
  2582. redditLinks = []
  2583. } = _ref2;
  2584. try {
  2585. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2586. scripts_echoLog({
  2587. text: i18n('needInit')
  2588. });
  2589. return false;
  2590. }
  2591. const prom = [];
  2592. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2593. scripts_echoLog({
  2594. type: 'globalOptionsSkip',
  2595. text: 'reddit.reddits'
  2596. });
  2597. } else {
  2598. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2599. var _link$match, _link$match2;
  2600. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2601. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2602. if (userName) {
  2603. return name || userName;
  2604. }
  2605. return name;
  2606. });
  2607. if (realReddits.length > 0) {
  2608. for (const name of realReddits) {
  2609. prom.push(this.toggleTask({
  2610. name: name,
  2611. doTask: doTask
  2612. }));
  2613. await delay(1e3);
  2614. }
  2615. }
  2616. }
  2617. return await Promise.all(prom).then(() => true);
  2618. } catch (error) {
  2619. throwError(error, 'Reddit.toggle');
  2620. return false;
  2621. }
  2622. }
  2623. }
  2624. async function _useBeta2() {
  2625. try {
  2626. const logStatus = scripts_echoLog({
  2627. text: i18n('changingRedditVersion')
  2628. });
  2629. GM_setValue('redditAuth', null);
  2630. return await new Promise(resolve => {
  2631. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2632. active: true,
  2633. insert: true,
  2634. setParent: true
  2635. });
  2636. newTab.onclose = async () => {
  2637. logStatus.success();
  2638. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2639. };
  2640. });
  2641. } catch (error) {
  2642. throwError(error, 'Reddit.useBeta');
  2643. return false;
  2644. }
  2645. }
  2646. async function Reddit_updateAuth2() {
  2647. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2648. try {
  2649. const logStatus = scripts_echoLog({
  2650. text: i18n('updatingAuth', 'Reddit')
  2651. });
  2652. const {
  2653. result,
  2654. statusText,
  2655. status,
  2656. data
  2657. } = await tools_httpRequest({
  2658. url: 'https://www.reddit.com/',
  2659. method: 'GET',
  2660. nochche: true,
  2661. headers: {
  2662. 'Cache-Control': 'no-cache'
  2663. }
  2664. });
  2665. if (result === 'Success') {
  2666. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2667. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2668. return false;
  2669. }
  2670. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2671. var _data$responseText$ma;
  2672. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2673. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2674. }
  2675. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2676. if (accessToken) {
  2677. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2678. token: accessToken
  2679. });
  2680. logStatus.success();
  2681. return true;
  2682. }
  2683. logStatus.error('Error: Parameter "accessToken" not found!');
  2684. return false;
  2685. }
  2686. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2687. return false;
  2688. }
  2689. logStatus.error(`${result}:${statusText}(${status})`);
  2690. return false;
  2691. } catch (error) {
  2692. throwError(error, 'Reddit.updateAuth');
  2693. return false;
  2694. }
  2695. }
  2696. const social_Reddit = Reddit;
  2697. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2698. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2699. privateSet.add(obj);
  2700. }
  2701. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2702. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2703. privateMap.set(obj, value);
  2704. }
  2705. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2706. if (privateCollection.has(obj)) {
  2707. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2708. }
  2709. }
  2710. function Twitch_defineProperty(obj, key, value) {
  2711. if (key in obj) {
  2712. Object.defineProperty(obj, key, {
  2713. value: value,
  2714. enumerable: true,
  2715. configurable: true,
  2716. writable: true
  2717. });
  2718. } else {
  2719. obj[key] = value;
  2720. }
  2721. return obj;
  2722. }
  2723. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2724. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2725. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2726. return value;
  2727. }
  2728. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2729. if (descriptor.set) {
  2730. descriptor.set.call(receiver, value);
  2731. } else {
  2732. if (!descriptor.writable) {
  2733. throw new TypeError('attempted to set read only private field');
  2734. }
  2735. descriptor.value = value;
  2736. }
  2737. }
  2738. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2739. if (!privateSet.has(receiver)) {
  2740. throw new TypeError('attempted to get private field on non-instance');
  2741. }
  2742. return fn;
  2743. }
  2744. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2745. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2746. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2747. }
  2748. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2749. if (!privateMap.has(receiver)) {
  2750. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2751. }
  2752. return privateMap.get(receiver);
  2753. }
  2754. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2755. if (descriptor.get) {
  2756. return descriptor.get.call(receiver);
  2757. }
  2758. return descriptor.value;
  2759. }
  2760. const Twitch_defaultTasks = JSON.stringify({
  2761. channels: []
  2762. });
  2763. var Twitch_auth = new WeakMap();
  2764. var Twitch_cache = new WeakMap();
  2765. var Twitch_initialized = new WeakMap();
  2766. var Twitch_verifyAuth = new WeakSet();
  2767. var Twitch_updateAuth = new WeakSet();
  2768. var _toggleChannel = new WeakSet();
  2769. var _getChannelId = new WeakSet();
  2770. var Twitch_setCache = new WeakSet();
  2771. class Twitch extends social_Social {
  2772. constructor() {
  2773. var _GM_getValue;
  2774. super(...arguments);
  2775. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2776. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2777. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2778. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2779. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2780. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2781. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || JSON.parse(Twitch_defaultTasks));
  2782. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2783. writable: true,
  2784. value: GM_getValue('twitchAuth') || {}
  2785. });
  2786. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2787. writable: true,
  2788. value: GM_getValue('twitchCache') || {}
  2789. });
  2790. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2791. writable: true,
  2792. value: false
  2793. });
  2794. }
  2795. async init() {
  2796. try {
  2797. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2798. return true;
  2799. }
  2800. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2801. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2802. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2803. return true;
  2804. }
  2805. return false;
  2806. }
  2807. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2808. if (isVerified) {
  2809. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2810. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2811. return true;
  2812. }
  2813. GM_setValue('twitchAuth', null);
  2814. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2815. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2816. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2817. return true;
  2818. }
  2819. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2820. return false;
  2821. } catch (error) {
  2822. throwError(error, 'Twitch.init');
  2823. return false;
  2824. }
  2825. }
  2826. async toggle(_ref) {
  2827. let {
  2828. doTask = true,
  2829. channelLinks = []
  2830. } = _ref;
  2831. try {
  2832. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2833. scripts_echoLog({
  2834. text: i18n('needInit')
  2835. });
  2836. return false;
  2837. }
  2838. const prom = [];
  2839. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2840. scripts_echoLog({
  2841. type: 'globalOptionsSkip',
  2842. text: 'twitch.channels'
  2843. });
  2844. } else {
  2845. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2846. var _link$match;
  2847. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2848. });
  2849. if (realChannels.length > 0) {
  2850. for (const channel of realChannels) {
  2851. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2852. name: channel,
  2853. doTask: doTask
  2854. }));
  2855. await delay(1e3);
  2856. }
  2857. }
  2858. }
  2859. return Promise.all(prom).then(() => true);
  2860. } catch (error) {
  2861. throwError(error, 'Twitch.toggle');
  2862. return false;
  2863. }
  2864. }
  2865. }
  2866. async function Twitch_verifyAuth2() {
  2867. try {
  2868. const logStatus = scripts_echoLog({
  2869. text: i18n('verifyingAuth', 'Twitch')
  2870. });
  2871. const {
  2872. result,
  2873. statusText,
  2874. status,
  2875. data
  2876. } = await tools_httpRequest({
  2877. url: 'https://gql.twitch.tv/gql',
  2878. method: 'POST',
  2879. dataType: 'json',
  2880. headers: {
  2881. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2882. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2883. },
  2884. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2885. });
  2886. if (result === 'Success') {
  2887. var _data$response, _data$response$, _data$response$$data;
  2888. 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) {
  2889. logStatus.success();
  2890. return true;
  2891. }
  2892. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2893. return false;
  2894. }
  2895. logStatus.error(`${result}:${statusText}(${status})`);
  2896. return false;
  2897. } catch (error) {
  2898. throwError(error, 'Twitch.verifyAuth');
  2899. return false;
  2900. }
  2901. }
  2902. async function Twitch_updateAuth2() {
  2903. try {
  2904. const logStatus = scripts_echoLog({
  2905. text: i18n('updatingAuth', 'Twitch')
  2906. });
  2907. return await new Promise(resolve => {
  2908. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2909. active: true,
  2910. insert: true,
  2911. setParent: true
  2912. });
  2913. newTab.onclose = async () => {
  2914. const auth = GM_getValue('twitchAuth');
  2915. if (auth) {
  2916. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2917. logStatus.success();
  2918. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2919. } else {
  2920. logStatus.error('Error: Update twitch auth failed!');
  2921. resolve(false);
  2922. }
  2923. };
  2924. });
  2925. } catch (error) {
  2926. throwError(error, 'Twitch.updateAuth');
  2927. return false;
  2928. }
  2929. }
  2930. async function _toggleChannel2(_ref2) {
  2931. let {
  2932. name,
  2933. doTask = true
  2934. } = _ref2;
  2935. try {
  2936. if (!doTask && this.whiteList.channels.includes(name)) {
  2937. scripts_echoLog({
  2938. type: 'whiteList',
  2939. text: 'Twitch.unfollowChannel',
  2940. id: name
  2941. });
  2942. return true;
  2943. }
  2944. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2945. if (!channelId) {
  2946. return false;
  2947. }
  2948. const logStatus = scripts_echoLog({
  2949. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2950. text: name
  2951. });
  2952. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2953. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2954. const {
  2955. result,
  2956. statusText,
  2957. status,
  2958. data
  2959. } = await tools_httpRequest({
  2960. url: 'https://gql.twitch.tv/gql',
  2961. method: 'POST',
  2962. dataType: 'json',
  2963. headers: {
  2964. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2965. },
  2966. data: doTask ? followData : unfollowData
  2967. });
  2968. if (result === 'Success') {
  2969. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2970. logStatus.success();
  2971. if (doTask) {
  2972. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2973. }
  2974. return true;
  2975. }
  2976. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2977. return false;
  2978. }
  2979. logStatus.error(`${result}:${statusText}(${status})`);
  2980. return false;
  2981. } catch (error) {
  2982. throwError(error, 'Twitch.toggleChannel');
  2983. return false;
  2984. }
  2985. }
  2986. async function _getChannelId2(name) {
  2987. try {
  2988. const logStatus = scripts_echoLog({
  2989. type: 'gettingTwitchChannelId',
  2990. text: name
  2991. });
  2992. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  2993. if (channelId) {
  2994. logStatus.success();
  2995. return channelId;
  2996. }
  2997. const {
  2998. result,
  2999. statusText,
  3000. status,
  3001. data
  3002. } = await tools_httpRequest({
  3003. url: 'https://gql.twitch.tv/gql',
  3004. method: 'POST',
  3005. headers: {
  3006. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3007. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3008. },
  3009. responseType: 'json',
  3010. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3011. });
  3012. if (result === 'Success') {
  3013. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3014. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3015. 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);
  3016. if (channelId) {
  3017. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3018. logStatus.success();
  3019. return channelId;
  3020. }
  3021. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3022. return false;
  3023. }
  3024. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3025. return false;
  3026. }
  3027. logStatus.error(`${result}:${statusText}(${status})`);
  3028. return false;
  3029. } catch (error) {
  3030. throwError(error, 'Twitch.getChannelId');
  3031. return false;
  3032. }
  3033. }
  3034. function Twitch_setCache2(name, id) {
  3035. try {
  3036. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3037. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3038. } catch (error) {
  3039. throwError(error, 'Twitch.setCache');
  3040. }
  3041. }
  3042. const social_Twitch = Twitch;
  3043. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3044. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3045. privateSet.add(obj);
  3046. }
  3047. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3048. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3049. privateMap.set(obj, value);
  3050. }
  3051. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3052. if (privateCollection.has(obj)) {
  3053. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3054. }
  3055. }
  3056. function Twitter_defineProperty(obj, key, value) {
  3057. if (key in obj) {
  3058. Object.defineProperty(obj, key, {
  3059. value: value,
  3060. enumerable: true,
  3061. configurable: true,
  3062. writable: true
  3063. });
  3064. } else {
  3065. obj[key] = value;
  3066. }
  3067. return obj;
  3068. }
  3069. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3070. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3071. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3072. return value;
  3073. }
  3074. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3075. if (descriptor.set) {
  3076. descriptor.set.call(receiver, value);
  3077. } else {
  3078. if (!descriptor.writable) {
  3079. throw new TypeError('attempted to set read only private field');
  3080. }
  3081. descriptor.value = value;
  3082. }
  3083. }
  3084. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3085. if (!privateSet.has(receiver)) {
  3086. throw new TypeError('attempted to get private field on non-instance');
  3087. }
  3088. return fn;
  3089. }
  3090. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3091. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3092. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3093. }
  3094. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3095. if (!privateMap.has(receiver)) {
  3096. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3097. }
  3098. return privateMap.get(receiver);
  3099. }
  3100. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3101. if (descriptor.get) {
  3102. return descriptor.get.call(receiver);
  3103. }
  3104. return descriptor.value;
  3105. }
  3106. const Twitter_defaultTasks = JSON.stringify({
  3107. users: [],
  3108. retweets: [],
  3109. likes: []
  3110. });
  3111. var _verifyId = new WeakMap();
  3112. var Twitter_auth = new WeakMap();
  3113. var Twitter_cache = new WeakMap();
  3114. var Twitter_initialized = new WeakMap();
  3115. var Twitter_verifyAuth = new WeakSet();
  3116. var Twitter_updateAuth = new WeakSet();
  3117. var _toggleUser = new WeakSet();
  3118. var _toggleRetweet = new WeakSet();
  3119. var Twitter_setCache = new WeakSet();
  3120. class Twitter extends social_Social {
  3121. constructor() {
  3122. var _GM_getValue;
  3123. super(...arguments);
  3124. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3125. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3126. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3127. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3128. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3129. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3130. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || JSON.parse(Twitter_defaultTasks));
  3131. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3132. writable: true,
  3133. value: globalOptions.other.twitterVerifyId
  3134. });
  3135. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3136. writable: true,
  3137. value: GM_getValue('twitterAuth') || {}
  3138. });
  3139. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3140. writable: true,
  3141. value: GM_getValue('twitterCache') || {}
  3142. });
  3143. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3144. writable: true,
  3145. value: false
  3146. });
  3147. }
  3148. async init() {
  3149. try {
  3150. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3151. return true;
  3152. }
  3153. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3154. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3155. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3156. return true;
  3157. }
  3158. return false;
  3159. }
  3160. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3161. if (isVerified) {
  3162. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3163. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3164. return true;
  3165. }
  3166. GM_setValue('twitterAuth', null);
  3167. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3168. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3169. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3170. return true;
  3171. }
  3172. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3173. return false;
  3174. } catch (error) {
  3175. throwError(error, 'Twitter.init');
  3176. return false;
  3177. }
  3178. }
  3179. async userName2id(name) {
  3180. try {
  3181. const logStatus = scripts_echoLog({
  3182. type: 'gettingTwitterUserId',
  3183. text: name
  3184. });
  3185. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3186. if (userId) {
  3187. logStatus.success();
  3188. return userId;
  3189. }
  3190. const {
  3191. result,
  3192. statusText,
  3193. status,
  3194. data
  3195. } = await tools_httpRequest({
  3196. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3197. method: 'GET',
  3198. headers: {
  3199. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3200. 'content-type': 'application/json'
  3201. },
  3202. responseType: 'json',
  3203. anonymous: true
  3204. });
  3205. if (result === 'Success') {
  3206. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3207. var _response, _response$data, _response$data$user;
  3208. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3209. if (!response) {
  3210. try {
  3211. response = JSON.parse(data.responseText);
  3212. } catch (error) {
  3213. response = null;
  3214. }
  3215. }
  3216. 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);
  3217. if (userId) {
  3218. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3219. logStatus.success();
  3220. return userId;
  3221. }
  3222. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3223. return false;
  3224. }
  3225. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3226. return false;
  3227. }
  3228. logStatus.error(`${result}:${statusText}(${status})`);
  3229. return false;
  3230. } catch (error) {
  3231. throwError(error, 'Twitter.getUserId');
  3232. return false;
  3233. }
  3234. }
  3235. async toggle(_ref) {
  3236. let {
  3237. doTask = true,
  3238. userLinks = [],
  3239. retweetLinks = []
  3240. } = _ref;
  3241. try {
  3242. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3243. scripts_echoLog({
  3244. text: i18n('needInit')
  3245. });
  3246. return false;
  3247. }
  3248. const prom = [];
  3249. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3250. scripts_echoLog({
  3251. type: 'globalOptionsSkip',
  3252. text: 'twitter.users'
  3253. });
  3254. } else {
  3255. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3256. var _link$match;
  3257. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3258. });
  3259. if (realUsers.length > 0) {
  3260. for (const user of realUsers) {
  3261. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3262. name: user,
  3263. doTask: doTask
  3264. }));
  3265. await delay(1e3);
  3266. }
  3267. }
  3268. }
  3269. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3270. scripts_echoLog({
  3271. type: 'globalOptionsSkip',
  3272. text: 'twitter.retweets'
  3273. });
  3274. } else {
  3275. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3276. var _link$match2;
  3277. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3278. });
  3279. if (realRetweets.length > 0) {
  3280. for (const retweet of realRetweets) {
  3281. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3282. retweetId: retweet,
  3283. doTask: doTask
  3284. }));
  3285. await delay(1e3);
  3286. }
  3287. }
  3288. }
  3289. return Promise.all(prom).then(() => true);
  3290. } catch (error) {
  3291. throwError(error, 'Twitter.toggle');
  3292. return false;
  3293. }
  3294. }
  3295. }
  3296. async function Twitter_verifyAuth2() {
  3297. try {
  3298. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3299. name: 'verify',
  3300. doTask: true,
  3301. verify: true
  3302. });
  3303. } catch (error) {
  3304. throwError(error, 'Twitter.verifyAuth');
  3305. return false;
  3306. }
  3307. }
  3308. async function Twitter_updateAuth2() {
  3309. try {
  3310. const logStatus = scripts_echoLog({
  3311. text: i18n('updatingAuth', 'Twitter')
  3312. });
  3313. return await new Promise(resolve => {
  3314. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3315. active: true,
  3316. insert: true,
  3317. setParent: true
  3318. });
  3319. newTab.onclose = async () => {
  3320. const auth = GM_getValue('twitterAuth');
  3321. if (auth) {
  3322. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3323. logStatus.success();
  3324. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3325. } else {
  3326. logStatus.error('Error: Update twitter auth failed!');
  3327. resolve(false);
  3328. }
  3329. };
  3330. });
  3331. } catch (error) {
  3332. throwError(error, 'Twitter.updateToken');
  3333. return false;
  3334. }
  3335. }
  3336. async function _toggleUser2(_ref2) {
  3337. let {
  3338. name,
  3339. doTask = true,
  3340. verify = false
  3341. } = _ref2;
  3342. try {
  3343. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3344. scripts_echoLog({
  3345. type: 'whiteList',
  3346. text: 'Twitter.unfollowUser',
  3347. id: name
  3348. });
  3349. return true;
  3350. }
  3351. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3352. if (!userId) {
  3353. return false;
  3354. }
  3355. const logStatus = verify ? scripts_echoLog({
  3356. text: i18n('verifyingAuth', 'Twitter')
  3357. }) : scripts_echoLog({
  3358. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3359. text: name
  3360. });
  3361. const {
  3362. result,
  3363. statusText,
  3364. status,
  3365. data
  3366. } = await tools_httpRequest({
  3367. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3368. method: 'POST',
  3369. headers: {
  3370. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3371. 'Content-Type': 'application/x-www-form-urlencoded',
  3372. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3373. },
  3374. responseType: 'json',
  3375. data: $.param({
  3376. include_profile_interstitial_type: 1,
  3377. include_blocking: 1,
  3378. include_blocked_by: 1,
  3379. include_followed_by: 1,
  3380. include_want_retweets: 1,
  3381. include_mute_edge: 1,
  3382. include_can_dm: 1,
  3383. include_can_media_tag: 1,
  3384. skip_status: 1,
  3385. id: userId
  3386. })
  3387. });
  3388. if (result === 'Success') {
  3389. var _data$response, _data$response$errors, _data$response$errors2;
  3390. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3391. logStatus.success();
  3392. if (doTask && !verify) {
  3393. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3394. }
  3395. return true;
  3396. }
  3397. 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) {
  3398. logStatus.success();
  3399. return true;
  3400. }
  3401. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3402. return false;
  3403. }
  3404. logStatus.error(`${result}:${statusText}(${status})`);
  3405. return false;
  3406. } catch (error) {
  3407. throwError(error, 'Twitter.toggleUser');
  3408. return false;
  3409. }
  3410. }
  3411. async function _toggleRetweet2(_ref3) {
  3412. let {
  3413. retweetId,
  3414. doTask = true
  3415. } = _ref3;
  3416. try {
  3417. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3418. scripts_echoLog({
  3419. type: 'whiteList',
  3420. text: 'Twitter.unretweet',
  3421. id: retweetId
  3422. });
  3423. return true;
  3424. }
  3425. const logStatus = scripts_echoLog({
  3426. type: `${doTask ? '' : 'un'}retweetting`,
  3427. text: retweetId
  3428. });
  3429. const {
  3430. result,
  3431. statusText,
  3432. status,
  3433. data
  3434. } = await tools_httpRequest({
  3435. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3436. method: 'POST',
  3437. headers: {
  3438. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3439. 'Content-Type': 'application/x-www-form-urlencoded',
  3440. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3441. },
  3442. data: $.param({
  3443. tweet_mode: 'extended',
  3444. id: retweetId
  3445. }),
  3446. responseType: 'json'
  3447. });
  3448. if (result === 'Success') {
  3449. var _data$response2, _data$response2$error, _data$response2$error2;
  3450. 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) {
  3451. logStatus.success();
  3452. if (doTask) {
  3453. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3454. }
  3455. return true;
  3456. }
  3457. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3458. return false;
  3459. }
  3460. logStatus.error(`${result}:${statusText}(${status})`);
  3461. return false;
  3462. } catch (error) {
  3463. throwError(error, 'Twitter.toggleRetweet');
  3464. return false;
  3465. }
  3466. }
  3467. function Twitter_setCache2(name, id) {
  3468. try {
  3469. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3470. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3471. } catch (error) {
  3472. throwError(error, 'Twitter.setCache');
  3473. }
  3474. }
  3475. const social_Twitter = Twitter;
  3476. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3477. Vk_checkPrivateRedeclaration(obj, privateSet);
  3478. privateSet.add(obj);
  3479. }
  3480. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3481. Vk_checkPrivateRedeclaration(obj, privateMap);
  3482. privateMap.set(obj, value);
  3483. }
  3484. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3485. if (privateCollection.has(obj)) {
  3486. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3487. }
  3488. }
  3489. function Vk_defineProperty(obj, key, value) {
  3490. if (key in obj) {
  3491. Object.defineProperty(obj, key, {
  3492. value: value,
  3493. enumerable: true,
  3494. configurable: true,
  3495. writable: true
  3496. });
  3497. } else {
  3498. obj[key] = value;
  3499. }
  3500. return obj;
  3501. }
  3502. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3503. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3504. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3505. return value;
  3506. }
  3507. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3508. if (descriptor.set) {
  3509. descriptor.set.call(receiver, value);
  3510. } else {
  3511. if (!descriptor.writable) {
  3512. throw new TypeError('attempted to set read only private field');
  3513. }
  3514. descriptor.value = value;
  3515. }
  3516. }
  3517. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3518. if (!privateSet.has(receiver)) {
  3519. throw new TypeError('attempted to get private field on non-instance');
  3520. }
  3521. return fn;
  3522. }
  3523. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3524. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3525. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3526. }
  3527. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3528. if (!privateMap.has(receiver)) {
  3529. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3530. }
  3531. return privateMap.get(receiver);
  3532. }
  3533. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3534. if (descriptor.get) {
  3535. return descriptor.get.call(receiver);
  3536. }
  3537. return descriptor.value;
  3538. }
  3539. const Vk_defaultTasks = JSON.stringify({
  3540. names: []
  3541. });
  3542. var _username = new WeakMap();
  3543. var Vk_cache = new WeakMap();
  3544. var Vk_initialized = new WeakMap();
  3545. var Vk_verifyAuth = new WeakSet();
  3546. var _toggleGroup = new WeakSet();
  3547. var _togglePublic = new WeakSet();
  3548. var _sendWall = new WeakSet();
  3549. var _deleteWall = new WeakSet();
  3550. var _getId = new WeakSet();
  3551. var _toggleVk = new WeakSet();
  3552. var Vk_setCache = new WeakSet();
  3553. class Vk extends social_Social {
  3554. constructor() {
  3555. var _GM_getValue;
  3556. super(...arguments);
  3557. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3558. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3559. Vk_classPrivateMethodInitSpec(this, _getId);
  3560. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3561. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3562. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3563. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3564. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3565. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3566. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || JSON.parse(Vk_defaultTasks));
  3567. Vk_classPrivateFieldInitSpec(this, _username, {
  3568. writable: true,
  3569. value: ''
  3570. });
  3571. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3572. writable: true,
  3573. value: GM_getValue('vkCache') || {}
  3574. });
  3575. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3576. writable: true,
  3577. value: false
  3578. });
  3579. }
  3580. async init() {
  3581. try {
  3582. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3583. return true;
  3584. }
  3585. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3586. if (isVerified) {
  3587. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3588. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3589. return true;
  3590. }
  3591. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3592. return false;
  3593. } catch (error) {
  3594. throwError(error, 'Vk.init');
  3595. return false;
  3596. }
  3597. }
  3598. async toggle(_ref) {
  3599. let {
  3600. doTask = true,
  3601. nameLinks = []
  3602. } = _ref;
  3603. try {
  3604. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3605. scripts_echoLog({
  3606. text: i18n('needInit')
  3607. });
  3608. return false;
  3609. }
  3610. const prom = [];
  3611. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3612. scripts_echoLog({
  3613. type: 'globalOptionsSkip',
  3614. text: 'vk.names'
  3615. });
  3616. } else {
  3617. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3618. var _link$match;
  3619. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3620. });
  3621. if (realNames.length > 0) {
  3622. for (const name of realNames) {
  3623. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3624. name: name,
  3625. doTask: doTask
  3626. }));
  3627. await delay(1e3);
  3628. }
  3629. }
  3630. }
  3631. return Promise.all(prom).then(() => true);
  3632. } catch (error) {
  3633. throwError(error, 'Vk.toggle');
  3634. return false;
  3635. }
  3636. }
  3637. }
  3638. async function Vk_verifyAuth2() {
  3639. try {
  3640. const logStatus = scripts_echoLog({
  3641. text: i18n('verifyAuth', 'Vk')
  3642. });
  3643. const {
  3644. result,
  3645. statusText,
  3646. status,
  3647. data
  3648. } = await tools_httpRequest({
  3649. url: 'https://vk.com/im',
  3650. method: 'GET'
  3651. });
  3652. if (result === 'Success') {
  3653. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3654. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3655. return false;
  3656. }
  3657. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3658. var _data$responseText$ma;
  3659. 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]) || '');
  3660. logStatus.success();
  3661. return true;
  3662. }
  3663. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3664. return false;
  3665. }
  3666. logStatus.error(`${result}:${statusText}(${status})`);
  3667. return false;
  3668. } catch (error) {
  3669. throwError(error, 'Vk.verifyAuth');
  3670. return false;
  3671. }
  3672. }
  3673. async function _toggleGroup2(name, dataParam) {
  3674. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3675. try {
  3676. const logStatus = scripts_echoLog({
  3677. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3678. text: name
  3679. });
  3680. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3681. logStatus.success();
  3682. return true;
  3683. }
  3684. const reqData = {
  3685. act: doTask ? 'enter' : 'leave',
  3686. al: 1,
  3687. gid: dataParam.groupId,
  3688. hash: dataParam.groupHash
  3689. };
  3690. if (doTask) {
  3691. reqData.context = '_';
  3692. }
  3693. const {
  3694. result,
  3695. statusText,
  3696. status,
  3697. data
  3698. } = await tools_httpRequest({
  3699. url: 'https://vk.com/al_groups.php',
  3700. method: 'POST',
  3701. headers: {
  3702. origin: 'https://vk.com',
  3703. referer: `https://vk.com/${name}`,
  3704. 'content-type': 'application/x-www-form-urlencoded'
  3705. },
  3706. data: $.param(reqData)
  3707. });
  3708. if (result === 'Success') {
  3709. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3710. logStatus.success();
  3711. if (doTask) {
  3712. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3713. }
  3714. return true;
  3715. }
  3716. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3717. return false;
  3718. }
  3719. logStatus.error(`${result}:${statusText}(${status})`);
  3720. return false;
  3721. } catch (error) {
  3722. throwError(error, 'Vk.toggleGroup');
  3723. return false;
  3724. }
  3725. }
  3726. async function _togglePublic2(name, dataParam) {
  3727. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3728. try {
  3729. const logStatus = scripts_echoLog({
  3730. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3731. text: name
  3732. });
  3733. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3734. logStatus.success();
  3735. return true;
  3736. }
  3737. const {
  3738. result,
  3739. statusText,
  3740. status,
  3741. data
  3742. } = await tools_httpRequest({
  3743. url: 'https://vk.com/al_public.php',
  3744. method: 'POST',
  3745. headers: {
  3746. origin: 'https://vk.com',
  3747. referer: `https://vk.com/${name}`,
  3748. 'content-type': 'application/x-www-form-urlencoded'
  3749. },
  3750. data: $.param({
  3751. act: doTask ? 'a_enter' : 'a_leave',
  3752. al: 1,
  3753. pid: dataParam.publicPid,
  3754. hash: dataParam.publicHash
  3755. })
  3756. });
  3757. if (result === 'Success') {
  3758. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3759. logStatus.success();
  3760. if (doTask) {
  3761. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3762. }
  3763. return true;
  3764. }
  3765. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3766. return false;
  3767. }
  3768. logStatus.error(`${result}:${statusText}(${status})`);
  3769. return false;
  3770. } catch (error) {
  3771. throwError(error, 'Vk.togglePublic');
  3772. return false;
  3773. }
  3774. }
  3775. async function _sendWall2(name) {
  3776. try {
  3777. const logStatus = scripts_echoLog({
  3778. type: 'sendingVkWall',
  3779. text: name
  3780. });
  3781. const {
  3782. result,
  3783. statusText,
  3784. status,
  3785. data
  3786. } = await tools_httpRequest({
  3787. url: 'https://vk.com/like.php',
  3788. method: 'POST',
  3789. headers: {
  3790. origin: 'https://vk.com',
  3791. referer: `https://vk.com/${name}`,
  3792. 'content-type': 'application/x-www-form-urlencoded'
  3793. },
  3794. data: $.param({
  3795. act: 'publish_box',
  3796. al: 1,
  3797. object: name
  3798. })
  3799. });
  3800. if (result === 'Success') {
  3801. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3802. var _data$responseText$ma2;
  3803. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3804. if (hash) {
  3805. const {
  3806. result: resultR,
  3807. statusText: statusTextR,
  3808. status: statusR,
  3809. data: dataR
  3810. } = await tools_httpRequest({
  3811. url: 'https://vk.com/like.php',
  3812. method: 'POST',
  3813. headers: {
  3814. origin: 'https://vk.com',
  3815. referer: `https://vk.com/${name}`,
  3816. 'content-type': 'application/x-www-form-urlencoded'
  3817. },
  3818. data: $.param({
  3819. Message: '',
  3820. act: 'a_do_publish',
  3821. al: 1,
  3822. close_comments: 0,
  3823. friends_only: 0,
  3824. from: 'box',
  3825. hash: hash,
  3826. list: '',
  3827. mark_as_ads: 0,
  3828. mute_notifications: 0,
  3829. object: name,
  3830. ret_data: 1,
  3831. to: 0
  3832. })
  3833. });
  3834. if (resultR === 'Success') {
  3835. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3836. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3837. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3838. 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) {
  3839. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3840. logStatus.success();
  3841. 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);
  3842. 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);
  3843. if (postId && ownerId) {
  3844. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3845. }
  3846. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3847. return true;
  3848. }
  3849. }
  3850. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3851. return false;
  3852. }
  3853. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3854. return false;
  3855. }
  3856. logStatus.error('Error: Get "hash" failed');
  3857. return false;
  3858. }
  3859. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3860. return false;
  3861. }
  3862. logStatus.error(`${result}:${statusText}(${status})`);
  3863. return false;
  3864. } catch (error) {
  3865. throwError(error, 'Vk.sendWall');
  3866. return false;
  3867. }
  3868. }
  3869. async function _deleteWall2(name, dataParams) {
  3870. try {
  3871. const logStatus = scripts_echoLog({
  3872. type: 'deletingVkWall',
  3873. text: name
  3874. });
  3875. const {
  3876. result,
  3877. statusText,
  3878. status,
  3879. data
  3880. } = await tools_httpRequest({
  3881. url: 'https://vk.com/al_wall.php?act=delete',
  3882. method: 'POST',
  3883. headers: {
  3884. origin: 'https://vk.com',
  3885. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3886. 'content-type': 'application/x-www-form-urlencoded'
  3887. },
  3888. data: $.param({
  3889. act: 'delete',
  3890. al: 1,
  3891. confirm: 0,
  3892. from: 'wkview',
  3893. hash: dataParams.wallHash,
  3894. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3895. })
  3896. });
  3897. if (result === 'Success') {
  3898. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3899. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3900. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3901. 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]) {
  3902. logStatus.success();
  3903. return true;
  3904. }
  3905. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3906. return false;
  3907. }
  3908. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3909. return false;
  3910. }
  3911. logStatus.error(`${result}:${statusText}(${status})`);
  3912. return false;
  3913. } catch (error) {
  3914. throwError(error, 'Vk.deleteWall');
  3915. return false;
  3916. }
  3917. }
  3918. async function _getId2(name, doTask) {
  3919. try {
  3920. let url = `https://vk.com/${name}`;
  3921. if (/^wall-/.test(name)) {
  3922. if (doTask) {
  3923. return {
  3924. type: 'sendWall'
  3925. };
  3926. }
  3927. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3928. return {
  3929. type: 'unSupport'
  3930. };
  3931. }
  3932. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3933. }
  3934. const logStatus = scripts_echoLog({
  3935. type: 'gettingVkId',
  3936. text: name
  3937. });
  3938. const {
  3939. result,
  3940. statusText,
  3941. status,
  3942. data
  3943. } = await tools_httpRequest({
  3944. url: url,
  3945. method: 'GET'
  3946. });
  3947. if (result === 'Success') {
  3948. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3949. var _data$responseText$ma3, _data$responseText$ma4;
  3950. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3951. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3952. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3953. const publicJoined = !data.responseText.includes('Public.subscribe');
  3954. if (groupAct && groupId && groupHash) {
  3955. logStatus.success();
  3956. return {
  3957. groupAct: groupAct,
  3958. groupId: groupId,
  3959. groupHash: groupHash,
  3960. type: 'group'
  3961. };
  3962. } else if (publicHash && publicPid) {
  3963. logStatus.success();
  3964. return {
  3965. publicHash: publicHash,
  3966. publicPid: publicPid,
  3967. publicJoined: publicJoined,
  3968. type: 'public'
  3969. };
  3970. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3971. var _data$responseText$ma5;
  3972. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3973. if (wallHash) {
  3974. logStatus.success();
  3975. return {
  3976. type: 'deleteWall',
  3977. wallHash: wallHash
  3978. };
  3979. }
  3980. } else if (name.includes('wall') && doTask) {
  3981. logStatus.success();
  3982. return {
  3983. type: 'sendWall'
  3984. };
  3985. }
  3986. logStatus.error('Error: Parameters not found!');
  3987. return false;
  3988. }
  3989. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3990. return false;
  3991. }
  3992. logStatus.error(`${result}:${statusText}(${status})`);
  3993. return false;
  3994. } catch (error) {
  3995. throwError(error, 'Vk.getId');
  3996. return false;
  3997. }
  3998. }
  3999. async function _toggleVk2(_ref2) {
  4000. let {
  4001. name,
  4002. doTask = true
  4003. } = _ref2;
  4004. try {
  4005. if (!doTask && this.whiteList.names.includes(name)) {
  4006. scripts_echoLog({
  4007. type: 'whiteList',
  4008. text: 'Vk.undoTask',
  4009. id: name
  4010. });
  4011. return true;
  4012. }
  4013. const formatName = name.replace(/\/$/, '');
  4014. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4015. if (!data) {
  4016. return false;
  4017. }
  4018. switch (data.type) {
  4019. case 'group':
  4020. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4021.  
  4022. case 'public':
  4023. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4024.  
  4025. case 'sendWall':
  4026. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4027.  
  4028. case 'deleteWall':
  4029. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4030.  
  4031. default:
  4032. return false;
  4033. }
  4034. } catch (error) {
  4035. throwError(error, 'Vk.toggleVk');
  4036. return false;
  4037. }
  4038. }
  4039. function Vk_setCache2(name, postId) {
  4040. try {
  4041. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4042. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4043. } catch (error) {
  4044. throwError(error, 'Vk.setCache');
  4045. }
  4046. }
  4047. const social_Vk = Vk;
  4048. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4049. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4050. privateSet.add(obj);
  4051. }
  4052. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4053. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4054. privateMap.set(obj, value);
  4055. }
  4056. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4057. if (privateCollection.has(obj)) {
  4058. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4059. }
  4060. }
  4061. function Youtube_defineProperty(obj, key, value) {
  4062. if (key in obj) {
  4063. Object.defineProperty(obj, key, {
  4064. value: value,
  4065. enumerable: true,
  4066. configurable: true,
  4067. writable: true
  4068. });
  4069. } else {
  4070. obj[key] = value;
  4071. }
  4072. return obj;
  4073. }
  4074. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4075. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4076. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4077. return value;
  4078. }
  4079. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4080. if (descriptor.set) {
  4081. descriptor.set.call(receiver, value);
  4082. } else {
  4083. if (!descriptor.writable) {
  4084. throw new TypeError('attempted to set read only private field');
  4085. }
  4086. descriptor.value = value;
  4087. }
  4088. }
  4089. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4090. if (!privateSet.has(receiver)) {
  4091. throw new TypeError('attempted to get private field on non-instance');
  4092. }
  4093. return fn;
  4094. }
  4095. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4096. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4097. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4098. }
  4099. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4100. if (!privateMap.has(receiver)) {
  4101. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4102. }
  4103. return privateMap.get(receiver);
  4104. }
  4105. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4106. if (descriptor.get) {
  4107. return descriptor.get.call(receiver);
  4108. }
  4109. return descriptor.value;
  4110. }
  4111. const Youtube_defaultTasks = JSON.stringify({
  4112. channels: [],
  4113. likes: []
  4114. });
  4115. const getInfo = async function(link, type) {
  4116. try {
  4117. const logStatus = scripts_echoLog({
  4118. text: i18n('gettingYtbToken')
  4119. });
  4120. const {
  4121. result,
  4122. statusText,
  4123. status,
  4124. data
  4125. } = await tools_httpRequest({
  4126. url: link,
  4127. method: 'GET'
  4128. });
  4129. if (result === 'Success') {
  4130. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4131. var _data$responseText$ma, _ref;
  4132. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4133. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4134. return {
  4135. needLogin: true
  4136. };
  4137. }
  4138. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4139. 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]) || '{}';
  4140. const {
  4141. client,
  4142. request
  4143. } = JSON.parse(context);
  4144. if (apiKey && client && request) {
  4145. client.hl = 'en';
  4146. if (type === 'channel') {
  4147. var _data$responseText$ma2;
  4148. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4149. if (channelId) {
  4150. logStatus.success();
  4151. return {
  4152. params: {
  4153. apiKey: apiKey,
  4154. client: client,
  4155. request: request,
  4156. channelId: channelId
  4157. }
  4158. };
  4159. }
  4160. logStatus.error('Error: Get "channelId" failed!');
  4161. return {};
  4162. } else if (type === 'likeVideo') {
  4163. var _data$responseText$ma3, _data$responseText$ma4;
  4164. 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];
  4165. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4166. if (videoId) {
  4167. logStatus.success();
  4168. return {
  4169. params: {
  4170. apiKey: apiKey,
  4171. client: client,
  4172. request: request,
  4173. videoId: videoId,
  4174. likeParams: likeParams
  4175. }
  4176. };
  4177. }
  4178. logStatus.error('Error: Get "videoId" failed!');
  4179. return {};
  4180. }
  4181. logStatus.error('Error: Unknown type');
  4182. return {};
  4183. }
  4184. logStatus.error('Error: Parameter "apiKey" not found!');
  4185. return {};
  4186. }
  4187. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4188. return {};
  4189. }
  4190. logStatus.error(`${result}:${statusText}(${status})`);
  4191. return {};
  4192. } catch (error) {
  4193. throwError(error, 'Youtube.getInfo');
  4194. return {};
  4195. }
  4196. };
  4197. var Youtube_auth = new WeakMap();
  4198. var Youtube_initialized = new WeakMap();
  4199. var _verifyChannel = new WeakMap();
  4200. var Youtube_verifyAuth = new WeakSet();
  4201. var Youtube_updateAuth = new WeakSet();
  4202. var _getInfo = new WeakSet();
  4203. var Youtube_toggleChannel = new WeakSet();
  4204. var _toggleLikeVideo = new WeakSet();
  4205. class Youtube extends social_Social {
  4206. constructor() {
  4207. var _GM_getValue;
  4208. super(...arguments);
  4209. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4210. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4211. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4212. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4213. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4214. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4215. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || JSON.parse(Youtube_defaultTasks));
  4216. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4217. writable: true,
  4218. value: GM_getValue('youtubeAuth') || {}
  4219. });
  4220. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4221. writable: true,
  4222. value: false
  4223. });
  4224. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4225. writable: true,
  4226. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4227. });
  4228. }
  4229. async init() {
  4230. try {
  4231. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4232. return true;
  4233. }
  4234. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4235. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4236. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4237. return true;
  4238. }
  4239. return false;
  4240. }
  4241. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4242. if (isVerified) {
  4243. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4244. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4245. return true;
  4246. }
  4247. GM_setValue('youtubeAuth', null);
  4248. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4249. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4250. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4251. return true;
  4252. }
  4253. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4254. return false;
  4255. } catch (error) {
  4256. throwError(error, 'Youtube.init');
  4257. return false;
  4258. }
  4259. }
  4260. async toggle(_ref2) {
  4261. let {
  4262. doTask = true,
  4263. channelLinks = [],
  4264. videoLinks = []
  4265. } = _ref2;
  4266. try {
  4267. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4268. scripts_echoLog({
  4269. text: i18n('needInit')
  4270. });
  4271. return false;
  4272. }
  4273. const prom = [];
  4274. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4275. scripts_echoLog({
  4276. type: 'globalOptionsSkip',
  4277. text: 'youtube.channels'
  4278. });
  4279. } else {
  4280. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4281. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4282. var _link$match;
  4283. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4284. }
  4285. return link;
  4286. });
  4287. if (realChannels.length > 0) {
  4288. for (const channel of realChannels) {
  4289. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4290. link: channel,
  4291. doTask: doTask
  4292. }));
  4293. await delay(1e3);
  4294. }
  4295. }
  4296. }
  4297. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4298. scripts_echoLog({
  4299. type: 'globalOptionsSkip',
  4300. text: 'youtube.likes'
  4301. });
  4302. } else {
  4303. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4304. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4305. var _link$match2;
  4306. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4307. }
  4308. return link;
  4309. });
  4310. if (realLikes.length > 0) {
  4311. for (const video of realLikes) {
  4312. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4313. link: video,
  4314. doTask: doTask
  4315. }));
  4316. await delay(1e3);
  4317. }
  4318. }
  4319. }
  4320. return Promise.all(prom).then(() => true);
  4321. } catch (error) {
  4322. throwError(error, 'Youtube.toggle');
  4323. return false;
  4324. }
  4325. }
  4326. }
  4327. async function Youtube_verifyAuth2() {
  4328. try {
  4329. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4330. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4331. doTask: true,
  4332. verify: true
  4333. });
  4334. } catch (error) {
  4335. throwError(error, 'Youtube.verifyAuth');
  4336. return false;
  4337. }
  4338. }
  4339. async function Youtube_updateAuth2() {
  4340. try {
  4341. const logStatus = scripts_echoLog({
  4342. text: i18n('updatingAuth', 'Youtube')
  4343. });
  4344. return await new Promise(resolve => {
  4345. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4346. active: true,
  4347. insert: true,
  4348. setParent: true
  4349. });
  4350. newTab.onclose = async () => {
  4351. const auth = GM_getValue('youtubeAuth');
  4352. if (auth) {
  4353. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4354. logStatus.success();
  4355. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4356. resolve(result);
  4357. });
  4358. } else {
  4359. logStatus.error('Error: Update youtube auth failed!');
  4360. resolve(false);
  4361. }
  4362. };
  4363. });
  4364. } catch (error) {
  4365. throwError(error, 'Discord.updateAuth');
  4366. return false;
  4367. }
  4368. }
  4369. function _getInfo2(link, type) {
  4370. return getInfo(link, type);
  4371. }
  4372. async function Youtube_toggleChannel2(_ref3) {
  4373. let {
  4374. link,
  4375. doTask = true,
  4376. verify = false
  4377. } = _ref3;
  4378. try {
  4379. const {
  4380. params,
  4381. needLogin
  4382. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4383. const {
  4384. apiKey,
  4385. client,
  4386. request,
  4387. channelId
  4388. } = params || {};
  4389. if (needLogin) {
  4390. scripts_echoLog({
  4391. html: i18n('loginYtb')
  4392. });
  4393. return false;
  4394. }
  4395. if (!(apiKey && client && request && channelId)) {
  4396. scripts_echoLog({
  4397. text: '"getYtbToken" failed'
  4398. });
  4399. return false;
  4400. }
  4401. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4402. scripts_echoLog({
  4403. type: 'whiteList',
  4404. text: 'Youtube.unfollowChannel',
  4405. id: channelId
  4406. });
  4407. return true;
  4408. }
  4409. const logStatus = verify ? scripts_echoLog({
  4410. text: i18n('verifyingAuth', 'Youtube')
  4411. }) : scripts_echoLog({
  4412. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4413. text: channelId
  4414. });
  4415. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4416. const {
  4417. result,
  4418. statusText,
  4419. status,
  4420. data
  4421. } = await tools_httpRequest({
  4422. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4423. method: 'POST',
  4424. headers: {
  4425. origin: 'https://www.youtube.com',
  4426. referer: `https://www.youtube.com/channel/${channelId}`,
  4427. 'content-type': 'application/json',
  4428. 'x-goog-authuser': '0',
  4429. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4430. 'x-origin': 'https://www.youtube.com',
  4431. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4432. },
  4433. data: JSON.stringify({
  4434. context: {
  4435. client: client,
  4436. request: {
  4437. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4438. internalExperimentFlags: [],
  4439. consistencyTokenJars: []
  4440. },
  4441. user: {}
  4442. },
  4443. channelIds: [ channelId ],
  4444. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4445. })
  4446. });
  4447. if (result === 'Success') {
  4448. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4449. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4450. logStatus.success();
  4451. if (doTask && !verify) {
  4452. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4453. }
  4454. return true;
  4455. }
  4456. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4457. logStatus.success();
  4458. return true;
  4459. }
  4460. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4461. return false;
  4462. }
  4463. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4464. return false;
  4465. }
  4466. logStatus.error(`${result}:${statusText}(${status})`);
  4467. return false;
  4468. } catch (error) {
  4469. throwError(error, 'Youtube.toggleChannel');
  4470. return false;
  4471. }
  4472. }
  4473. async function _toggleLikeVideo2(_ref4) {
  4474. let {
  4475. link,
  4476. doTask = true
  4477. } = _ref4;
  4478. try {
  4479. const {
  4480. params,
  4481. needLogin
  4482. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4483. const {
  4484. apiKey,
  4485. client,
  4486. request,
  4487. videoId,
  4488. likeParams
  4489. } = params || {};
  4490. if (needLogin) {
  4491. scripts_echoLog({
  4492. html: `${i18n('loginYtb')}`
  4493. });
  4494. return false;
  4495. }
  4496. if (!(apiKey && client && request && videoId && likeParams)) {
  4497. scripts_echoLog({
  4498. text: '"getYtbToken" failed'
  4499. });
  4500. return false;
  4501. }
  4502. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4503. scripts_echoLog({
  4504. type: 'whiteList',
  4505. text: 'Youtube.unlikeVideo',
  4506. id: videoId
  4507. });
  4508. return true;
  4509. }
  4510. const logStatus = scripts_echoLog({
  4511. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4512. text: videoId
  4513. });
  4514. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4515. const likeVideoData = {
  4516. context: {
  4517. client: client,
  4518. request: {
  4519. sessionId: request.sessionId,
  4520. internalExperimentFlags: [],
  4521. consistencyTokenJars: []
  4522. },
  4523. user: {}
  4524. },
  4525. target: {
  4526. videoId: videoId
  4527. }
  4528. };
  4529. if (doTask) {
  4530. if (likeParams) {
  4531. likeVideoData.params = likeParams;
  4532. } else {
  4533. logStatus.error('Empty likeParams');
  4534. return false;
  4535. }
  4536. }
  4537. const {
  4538. result,
  4539. statusText,
  4540. status,
  4541. data
  4542. } = await tools_httpRequest({
  4543. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4544. method: 'POST',
  4545. headers: {
  4546. origin: 'https://www.youtube.com',
  4547. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4548. 'content-type': 'application/json',
  4549. 'x-goog-authuser': '0',
  4550. 'x-goog-visitor-id': client.visitorData,
  4551. 'x-origin': 'https://www.youtube.com',
  4552. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4553. },
  4554. data: JSON.stringify(likeVideoData)
  4555. });
  4556. if (result === 'Success') {
  4557. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4558. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4559. logStatus.success();
  4560. if (doTask) {
  4561. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4562. }
  4563. return true;
  4564. }
  4565. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4566. return false;
  4567. }
  4568. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4569. return false;
  4570. }
  4571. logStatus.error(`${result}:${statusText}(${status})`);
  4572. return false;
  4573. } catch (error) {
  4574. throwError(error, 'Youtube.toggleLikeVideo');
  4575. return false;
  4576. }
  4577. }
  4578. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4579. Steam_checkPrivateRedeclaration(obj, privateSet);
  4580. privateSet.add(obj);
  4581. }
  4582. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4583. Steam_checkPrivateRedeclaration(obj, privateMap);
  4584. privateMap.set(obj, value);
  4585. }
  4586. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4587. if (privateCollection.has(obj)) {
  4588. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4589. }
  4590. }
  4591. function Steam_defineProperty(obj, key, value) {
  4592. if (key in obj) {
  4593. Object.defineProperty(obj, key, {
  4594. value: value,
  4595. enumerable: true,
  4596. configurable: true,
  4597. writable: true
  4598. });
  4599. } else {
  4600. obj[key] = value;
  4601. }
  4602. return obj;
  4603. }
  4604. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4605. if (!privateSet.has(receiver)) {
  4606. throw new TypeError('attempted to get private field on non-instance');
  4607. }
  4608. return fn;
  4609. }
  4610. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4611. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4612. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4613. return value;
  4614. }
  4615. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4616. if (descriptor.set) {
  4617. descriptor.set.call(receiver, value);
  4618. } else {
  4619. if (!descriptor.writable) {
  4620. throw new TypeError('attempted to set read only private field');
  4621. }
  4622. descriptor.value = value;
  4623. }
  4624. }
  4625. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4626. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4627. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4628. }
  4629. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4630. if (!privateMap.has(receiver)) {
  4631. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4632. }
  4633. return privateMap.get(receiver);
  4634. }
  4635. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4636. if (descriptor.get) {
  4637. return descriptor.get.call(receiver);
  4638. }
  4639. return descriptor.value;
  4640. }
  4641. const Steam_defaultTasks = JSON.stringify({
  4642. groups: [],
  4643. wishlists: [],
  4644. follows: [],
  4645. forums: [],
  4646. workshops: [],
  4647. workshopVotes: [],
  4648. curators: [],
  4649. curatorLikes: [],
  4650. announcements: []
  4651. });
  4652. var Steam_cache = new WeakMap();
  4653. var Steam_auth = new WeakMap();
  4654. var _storeInitialized = new WeakMap();
  4655. var _communityInitialized = new WeakMap();
  4656. var _area = new WeakMap();
  4657. var _updateStoreAuth = new WeakSet();
  4658. var _updateCommunityAuth = new WeakSet();
  4659. var _getAreaInfo = new WeakSet();
  4660. var _changeArea = new WeakSet();
  4661. var _joinGroup = new WeakSet();
  4662. var _leaveGroup = new WeakSet();
  4663. var _getGroupId = new WeakSet();
  4664. var _addToWishlist = new WeakSet();
  4665. var _removeFromWishlist = new WeakSet();
  4666. var _toggleFollowGame = new WeakSet();
  4667. var _isFollowedGame = new WeakSet();
  4668. var _toggleForum = new WeakSet();
  4669. var _getForumId = new WeakSet();
  4670. var _toggleFavoriteWorkshop = new WeakSet();
  4671. var _getWorkshopAppId = new WeakSet();
  4672. var _voteUpWorkshop = new WeakSet();
  4673. var _toggleCurator = new WeakSet();
  4674. var _toggleCuratorLike = new WeakSet();
  4675. var _getAnnouncementParams = new WeakSet();
  4676. var _likeAnnouncement = new WeakSet();
  4677. var _appid2subid = new WeakSet();
  4678. var _addLicense = new WeakSet();
  4679. var _addFreeLicense = new WeakSet();
  4680. var Steam_setCache = new WeakSet();
  4681. class Steam extends social_Social {
  4682. constructor() {
  4683. var _GM_getValue;
  4684. super(...arguments);
  4685. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4686. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4687. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4688. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4689. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4690. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4691. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4692. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4693. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4694. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4695. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4696. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4697. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4698. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4699. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4700. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4701. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4702. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4703. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4704. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4705. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4706. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4707. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4708. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4709. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4710. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || JSON.parse(Steam_defaultTasks));
  4711. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4712. writable: true,
  4713. value: GM_getValue('steamCache') || {
  4714. group: {},
  4715. forum: {},
  4716. workshop: {},
  4717. curator: {}
  4718. }
  4719. });
  4720. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4721. writable: true,
  4722. value: {}
  4723. });
  4724. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4725. writable: true,
  4726. value: false
  4727. });
  4728. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4729. writable: true,
  4730. value: false
  4731. });
  4732. Steam_classPrivateFieldInitSpec(this, _area, {
  4733. writable: true,
  4734. value: 'CN'
  4735. });
  4736. }
  4737. async init() {
  4738. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4739. try {
  4740. if (type === 'store') {
  4741. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4742. return true;
  4743. }
  4744. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4745. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4746. return true;
  4747. }
  4748. if (type === 'community') {
  4749. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4750. return true;
  4751. }
  4752. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4753. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4754. return true;
  4755. }
  4756. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4757. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4758. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4759. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4760. return true;
  4761. }
  4762. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4763. return false;
  4764. } catch (error) {
  4765. throwError(error, 'Steam.init');
  4766. return false;
  4767. }
  4768. }
  4769. async getCuratorId(path, name) {
  4770. try {
  4771. const logStatus = scripts_echoLog({
  4772. type: 'gettingCuratorId',
  4773. text: `${path}/${name}`
  4774. });
  4775. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4776. if (curatorId) {
  4777. logStatus.success();
  4778. return curatorId;
  4779. }
  4780. const {
  4781. result,
  4782. statusText,
  4783. status,
  4784. data
  4785. } = await tools_httpRequest({
  4786. url: `https://store.steampowered.com/${path}/${name}`,
  4787. method: 'GET',
  4788. headers: {
  4789. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4790. }
  4791. });
  4792. if (result === 'Success') {
  4793. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4794. var _data$responseText$ma;
  4795. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4796. if (curatorId) {
  4797. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4798. logStatus.success();
  4799. return curatorId;
  4800. }
  4801. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4802. return false;
  4803. }
  4804. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4805. return false;
  4806. }
  4807. logStatus.error(`${result}:${statusText}(${status})`);
  4808. return false;
  4809. } catch (error) {
  4810. throwError(error, 'Steam.getCuratorID');
  4811. return false;
  4812. }
  4813. }
  4814. async toggle(_ref) {
  4815. let {
  4816. doTask = true,
  4817. groupLinks = [],
  4818. wishlistLinks = [],
  4819. followLinks = [],
  4820. forumLinks = [],
  4821. workshopLinks = [],
  4822. workshopVoteLinks = [],
  4823. curatorLinks = [],
  4824. curatorLikeLinks = [],
  4825. announcementLinks = [],
  4826. licenseLinks = []
  4827. } = _ref;
  4828. try {
  4829. if ([ ...groupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4830. scripts_echoLog({
  4831. text: i18n('needInit')
  4832. });
  4833. return false;
  4834. }
  4835. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4836. scripts_echoLog({
  4837. text: i18n('needInit')
  4838. });
  4839. return false;
  4840. }
  4841. const prom = [];
  4842. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4843. scripts_echoLog({
  4844. type: 'globalOptionsSkip',
  4845. text: 'steam.groups'
  4846. });
  4847. } else {
  4848. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4849. var _link$match;
  4850. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4851. });
  4852. if (realGroups.length > 0) {
  4853. for (const group of realGroups) {
  4854. if (doTask) {
  4855. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4856. } else {
  4857. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4858. }
  4859. await delay(1e3);
  4860. }
  4861. }
  4862. }
  4863. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4864. scripts_echoLog({
  4865. type: 'globalOptionsSkip',
  4866. text: 'steam.wishlists'
  4867. });
  4868. } else {
  4869. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4870. var _link$match2;
  4871. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4872. });
  4873. if (realWishlists.length > 0) {
  4874. for (const game of realWishlists) {
  4875. if (doTask) {
  4876. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4877. } else {
  4878. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4879. }
  4880. await delay(1e3);
  4881. }
  4882. }
  4883. }
  4884. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4885. scripts_echoLog({
  4886. type: 'globalOptionsSkip',
  4887. text: 'steam.follows'
  4888. });
  4889. } else {
  4890. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4891. var _link$match3;
  4892. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4893. });
  4894. if (realFollows.length > 0) {
  4895. for (const game of realFollows) {
  4896. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4897. await delay(1e3);
  4898. }
  4899. }
  4900. }
  4901. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4902. scripts_echoLog({
  4903. type: 'globalOptionsSkip',
  4904. text: 'steam.forums'
  4905. });
  4906. } else {
  4907. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4908. var _link$match4;
  4909. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4910. });
  4911. if (realForums.length > 0) {
  4912. for (const forum of realForums) {
  4913. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4914. await delay(1e3);
  4915. }
  4916. }
  4917. }
  4918. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4919. scripts_echoLog({
  4920. type: 'globalOptionsSkip',
  4921. text: 'steam.workshops'
  4922. });
  4923. } else {
  4924. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4925. var _link$match5;
  4926. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4927. });
  4928. if (realWorkshops.length > 0) {
  4929. for (const workshop of realWorkshops) {
  4930. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4931. await delay(1e3);
  4932. }
  4933. }
  4934. }
  4935. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4936. scripts_echoLog({
  4937. type: 'globalOptionsSkip',
  4938. text: 'steam.workshopVotes'
  4939. });
  4940. } else {
  4941. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4942. var _link$match6;
  4943. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4944. });
  4945. if (doTask && realworkshopVotes.length > 0) {
  4946. for (const workshop of realworkshopVotes) {
  4947. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4948. await delay(1e3);
  4949. }
  4950. }
  4951. }
  4952. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4953. scripts_echoLog({
  4954. type: 'globalOptionsSkip',
  4955. text: 'steam.curators'
  4956. });
  4957. } else {
  4958. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4959. var _link$match7;
  4960. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4961. });
  4962. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4963. var _link$match8;
  4964. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4965. });
  4966. if (realCurators.length > 0) {
  4967. for (const curator of realCurators) {
  4968. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  4969. await delay(1e3);
  4970. }
  4971. }
  4972. if (realCuratorLikes.length > 0) {
  4973. for (const curatorLike of realCuratorLikes) {
  4974. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  4975. await delay(1e3);
  4976. }
  4977. }
  4978. }
  4979. if (doTask && !globalOptions.doTask.steam.announcements) {
  4980. scripts_echoLog({
  4981. type: 'globalOptionsSkip',
  4982. text: 'steam.announcements'
  4983. });
  4984. } else {
  4985. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  4986. var _link$match10;
  4987. if (link.includes('store.steampowered.com')) {
  4988. var _link$match9;
  4989. return (_link$match9 = link.match(/store\.steampowered\.com\/news\/app\/([\d]+)\/view\/([\d]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  4990. }
  4991. return (_link$match10 = link.match(/steamcommunity\.com\/games\/([\d]+)\/announcements\/detail\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10.slice(1, 3).join('/');
  4992. });
  4993. if (doTask && realAnnouncements.length > 0) {
  4994. for (const id of realAnnouncements) {
  4995. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  4996. await delay(1e3);
  4997. }
  4998. }
  4999. }
  5000. if (doTask && licenseLinks.length > 0) {
  5001. for (const id of licenseLinks) {
  5002. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5003. await delay(1e3);
  5004. }
  5005. }
  5006. return Promise.all(prom).then(async () => {
  5007. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5008. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5009. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5010. }
  5011. return true;
  5012. });
  5013. } catch (error) {
  5014. throwError(error, 'Steam.toggle');
  5015. return false;
  5016. }
  5017. }
  5018. }
  5019. async function _updateStoreAuth2() {
  5020. try {
  5021. const logStatus = scripts_echoLog({
  5022. text: i18n('updatingAuth', i18n('steamStore'))
  5023. });
  5024. const {
  5025. result,
  5026. statusText,
  5027. status,
  5028. data
  5029. } = await tools_httpRequest({
  5030. url: 'https://store.steampowered.com/stats/',
  5031. method: 'GET'
  5032. });
  5033. if (result === 'Success') {
  5034. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5035. var _data$responseText$ma2;
  5036. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5037. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5038. return false;
  5039. }
  5040. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5041. if (storeSessionID) {
  5042. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5043. logStatus.success();
  5044. return true;
  5045. }
  5046. logStatus.error('Error: Get "sessionID" failed');
  5047. return false;
  5048. }
  5049. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5050. return false;
  5051. }
  5052. logStatus.error(`${result}:${statusText}(${status})`);
  5053. return false;
  5054. } catch (error) {
  5055. throwError(error, 'Steam.updateStoreAuth');
  5056. return false;
  5057. }
  5058. }
  5059. async function _updateCommunityAuth2() {
  5060. try {
  5061. const logStatus = scripts_echoLog({
  5062. text: i18n('updatingAuth', i18n('steamCommunity'))
  5063. });
  5064. const {
  5065. result,
  5066. statusText,
  5067. status,
  5068. data
  5069. } = await tools_httpRequest({
  5070. url: 'https://steamcommunity.com/my',
  5071. method: 'GET'
  5072. });
  5073. if (result === 'Success') {
  5074. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5075. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5076. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5077. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5078. return false;
  5079. }
  5080. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5081. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5082. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5083. if (steam64Id) {
  5084. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5085. }
  5086. if (userName) {
  5087. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5088. }
  5089. if (communitySessionID) {
  5090. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5091. logStatus.success();
  5092. return true;
  5093. }
  5094. logStatus.error('Error: Get "sessionID" failed');
  5095. return false;
  5096. }
  5097. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5098. return false;
  5099. }
  5100. logStatus.error(`${result}:${statusText}(${status})`);
  5101. return false;
  5102. } catch (error) {
  5103. throwError(error, 'Steam.updateCommunityAuth');
  5104. return false;
  5105. }
  5106. }
  5107. async function _getAreaInfo2() {
  5108. try {
  5109. const logStatus = scripts_echoLog({
  5110. text: i18n('gettingAreaInfo')
  5111. });
  5112. const {
  5113. result,
  5114. statusText,
  5115. status,
  5116. data
  5117. } = await tools_httpRequest({
  5118. url: 'https://store.steampowered.com/cart/',
  5119. method: 'GET'
  5120. });
  5121. if (result === 'Success') {
  5122. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5123. var _data$responseText$ma6;
  5124. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5125. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5126. if (currentArea && areas.length > 0) {
  5127. Steam_classPrivateFieldSet(this, _area, currentArea);
  5128. logStatus.success();
  5129. return {
  5130. currentArea: currentArea,
  5131. areas: areas
  5132. };
  5133. }
  5134. logStatus.error('Error: get country info filed');
  5135. return {};
  5136. }
  5137. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5138. return {};
  5139. }
  5140. logStatus.error(`${result}:${statusText}(${status})`);
  5141. return {};
  5142. } catch (error) {
  5143. throwError(error, 'Steam.getAreaInfo');
  5144. return {};
  5145. }
  5146. }
  5147. async function _changeArea2(area) {
  5148. try {
  5149. let aimedArea = area;
  5150. if (!aimedArea) {
  5151. const {
  5152. currentArea,
  5153. areas
  5154. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5155. if (!currentArea || !areas) {
  5156. return false;
  5157. }
  5158. if (currentArea !== 'CN') {
  5159. scripts_echoLog({
  5160. text: 'notNeededChangeArea'
  5161. });
  5162. return 'skip';
  5163. }
  5164. const anotherArea = areas.filter(area => area && area !== 'CN');
  5165. if (!anotherArea || anotherArea.length === 0) {
  5166. scripts_echoLog({
  5167. text: 'noAnotherArea'
  5168. });
  5169. return false;
  5170. }
  5171. [ aimedArea ] = anotherArea;
  5172. }
  5173. const logStatus = scripts_echoLog({
  5174. text: i18n('changingArea', aimedArea)
  5175. });
  5176. const {
  5177. result,
  5178. statusText,
  5179. status,
  5180. data
  5181. } = await tools_httpRequest({
  5182. url: 'https://store.steampowered.com/account/setcountry',
  5183. method: 'POST',
  5184. headers: {
  5185. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5186. },
  5187. data: $.param({
  5188. cc: aimedArea,
  5189. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5190. })
  5191. });
  5192. if (result === 'Success') {
  5193. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5194. const {
  5195. currentArea
  5196. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5197. if (currentArea === aimedArea) {
  5198. logStatus.success();
  5199. return currentArea;
  5200. }
  5201. logStatus.error('Error: change country filed');
  5202. return 'CN';
  5203. }
  5204. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5205. return 'CN';
  5206. }
  5207. logStatus.error(`${result}:${statusText}(${status})`);
  5208. return 'CN';
  5209. } catch (error) {
  5210. throwError(error, 'Steam.changeArea');
  5211. return false;
  5212. }
  5213. }
  5214. async function _joinGroup2(groupName) {
  5215. try {
  5216. const logStatus = scripts_echoLog({
  5217. type: 'joiningSteamGroup',
  5218. text: groupName
  5219. });
  5220. const {
  5221. result,
  5222. statusText,
  5223. status,
  5224. data
  5225. } = await tools_httpRequest({
  5226. url: `https://steamcommunity.com/groups/${groupName}`,
  5227. method: 'POST',
  5228. headers: {
  5229. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5230. },
  5231. data: $.param({
  5232. action: 'join',
  5233. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5234. })
  5235. });
  5236. if (result === 'Success') {
  5237. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5238. logStatus.success();
  5239. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5240. return true;
  5241. }
  5242. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5243. return false;
  5244. }
  5245. logStatus.error(`${result}:${statusText}(${status})`);
  5246. return false;
  5247. } catch (error) {
  5248. throwError(error, 'Steam.joinGroup');
  5249. return false;
  5250. }
  5251. }
  5252. async function _leaveGroup2(groupName) {
  5253. try {
  5254. if (this.whiteList.groups.includes(groupName)) {
  5255. scripts_echoLog({
  5256. type: 'whiteList',
  5257. text: 'Steam.leaveGroup',
  5258. id: groupName
  5259. });
  5260. return true;
  5261. }
  5262. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5263. if (!groupId) {
  5264. return false;
  5265. }
  5266. const logStatus = scripts_echoLog({
  5267. type: 'leavingSteamGroup',
  5268. text: groupName
  5269. });
  5270. const {
  5271. result,
  5272. statusText,
  5273. status,
  5274. data
  5275. } = await tools_httpRequest({
  5276. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5277. method: 'POST',
  5278. headers: {
  5279. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5280. },
  5281. data: $.param({
  5282. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5283. action: 'leaveGroup',
  5284. groupId: groupId
  5285. })
  5286. });
  5287. if (result === 'Success') {
  5288. 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) {
  5289. logStatus.success();
  5290. return true;
  5291. }
  5292. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5293. return false;
  5294. }
  5295. logStatus.error(`${result}:${statusText}(${status})`);
  5296. return false;
  5297. } catch (error) {
  5298. throwError(error, 'Steam.leaveGroup');
  5299. return false;
  5300. }
  5301. }
  5302. async function _getGroupId2(groupName) {
  5303. try {
  5304. const logStatus = scripts_echoLog({
  5305. type: 'gettingSteamGroupId',
  5306. text: groupName
  5307. });
  5308. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5309. if (groupId) {
  5310. logStatus.success();
  5311. return groupId;
  5312. }
  5313. const {
  5314. result,
  5315. statusText,
  5316. status,
  5317. data
  5318. } = await tools_httpRequest({
  5319. url: `https://steamcommunity.com/groups/${groupName}`,
  5320. method: 'GET',
  5321. headers: {
  5322. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5323. }
  5324. });
  5325. if (result === 'Success') {
  5326. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5327. var _data$responseText$ma7;
  5328. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5329. if (groupId) {
  5330. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5331. logStatus.success();
  5332. return groupId;
  5333. }
  5334. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5335. return false;
  5336. }
  5337. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5338. return false;
  5339. }
  5340. logStatus.error(`${result}:${statusText}(${status})`);
  5341. return false;
  5342. } catch (error) {
  5343. throwError(error, 'Steam.getGroupID');
  5344. return false;
  5345. }
  5346. }
  5347. async function _addToWishlist2(gameId) {
  5348. try {
  5349. var _data$response;
  5350. const logStatus = scripts_echoLog({
  5351. type: 'addingToWishlist',
  5352. text: gameId
  5353. });
  5354. const {
  5355. result,
  5356. data
  5357. } = await tools_httpRequest({
  5358. url: 'https://store.steampowered.com/api/addtowishlist',
  5359. method: 'POST',
  5360. headers: {
  5361. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5362. },
  5363. data: $.param({
  5364. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5365. appid: gameId
  5366. }),
  5367. dataType: 'json'
  5368. });
  5369. 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) {
  5370. logStatus.success();
  5371. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5372. return true;
  5373. }
  5374. const {
  5375. result: resultR,
  5376. statusText: statusTextR,
  5377. status: statusR,
  5378. data: dataR
  5379. } = await tools_httpRequest({
  5380. url: `https://store.steampowered.com/app/${gameId}`,
  5381. method: 'GET'
  5382. });
  5383. if (resultR === 'Success') {
  5384. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5385. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5386. logStatus.warning(i18n('changeAreaNotice'));
  5387. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5388. return false;
  5389. }
  5390. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5391. }
  5392. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5393. logStatus.success();
  5394. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5395. return true;
  5396. } 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"')) {
  5397. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5398. return false;
  5399. }
  5400. logStatus.success();
  5401. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5402. return true;
  5403. }
  5404. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5405. return false;
  5406. }
  5407. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5408. return false;
  5409. } catch (error) {
  5410. throwError(error, 'Steam.addToWishlist');
  5411. return false;
  5412. }
  5413. }
  5414. async function _removeFromWishlist2(gameId) {
  5415. try {
  5416. var _data$response2;
  5417. if (this.whiteList.wishlists.includes(gameId)) {
  5418. scripts_echoLog({
  5419. type: 'whiteList',
  5420. text: 'Steam.removeFromWishlist',
  5421. id: gameId
  5422. });
  5423. return true;
  5424. }
  5425. const logStatus = scripts_echoLog({
  5426. type: 'removingFromWishlist',
  5427. text: gameId
  5428. });
  5429. const {
  5430. result,
  5431. data
  5432. } = await tools_httpRequest({
  5433. url: 'https://store.steampowered.com/api/removefromwishlist',
  5434. method: 'POST',
  5435. headers: {
  5436. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5437. },
  5438. data: $.param({
  5439. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5440. appid: gameId
  5441. }),
  5442. dataType: 'json'
  5443. });
  5444. 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) {
  5445. logStatus.success();
  5446. return true;
  5447. }
  5448. const {
  5449. result: resultR,
  5450. statusText: statusTextR,
  5451. status: statusR,
  5452. data: dataR
  5453. } = await tools_httpRequest({
  5454. url: `https://store.steampowered.com/app/${gameId}`,
  5455. method: 'GET'
  5456. });
  5457. if (resultR === 'Success') {
  5458. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5459. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5460. logStatus.warning(i18n('changeAreaNotice'));
  5461. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5462. if (!result || result === 'CN' || result === 'skip') {
  5463. return false;
  5464. }
  5465. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5466. }
  5467. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5468. logStatus.success();
  5469. return true;
  5470. }
  5471. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5472. return false;
  5473. }
  5474. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5475. return false;
  5476. }
  5477. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5478. return false;
  5479. } catch (error) {
  5480. throwError(error, 'Steam.removeFromWishlist');
  5481. return false;
  5482. }
  5483. }
  5484. async function _toggleFollowGame2(gameId, doTask) {
  5485. try {
  5486. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5487. scripts_echoLog({
  5488. type: 'whiteList',
  5489. text: 'Steam.unfollowGame',
  5490. id: gameId
  5491. });
  5492. return true;
  5493. }
  5494. const logStatus = scripts_echoLog({
  5495. type: `${doTask ? '' : 'un'}followingGame`,
  5496. text: gameId
  5497. });
  5498. const requestData = {
  5499. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5500. appid: gameId
  5501. };
  5502. if (!doTask) {
  5503. requestData.unfollow = '1';
  5504. }
  5505. const {
  5506. result,
  5507. data
  5508. } = await tools_httpRequest({
  5509. url: 'https://store.steampowered.com/explore/followgame/',
  5510. method: 'POST',
  5511. headers: {
  5512. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5513. },
  5514. data: $.param(requestData)
  5515. });
  5516. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5517. logStatus.success();
  5518. return true;
  5519. }
  5520. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5521. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5522. logStatus.warning(i18n('changeAreaNotice'));
  5523. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5524. return false;
  5525. }
  5526. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5527. }
  5528. if (doTask === followed) {
  5529. logStatus.success();
  5530. if (doTask) {
  5531. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5532. }
  5533. return true;
  5534. }
  5535. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5536. return false;
  5537. } catch (error) {
  5538. throwError(error, 'Steam.toggleFollowGame');
  5539. return false;
  5540. }
  5541. }
  5542. async function _isFollowedGame2(gameId) {
  5543. try {
  5544. const {
  5545. result,
  5546. data
  5547. } = await tools_httpRequest({
  5548. url: `https://store.steampowered.com/app/${gameId}`,
  5549. method: 'GET'
  5550. });
  5551. if (result === 'Success') {
  5552. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5553. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5554. return 'areaLocked';
  5555. }
  5556. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5557. return true;
  5558. }
  5559. return false;
  5560. }
  5561. return false;
  5562. }
  5563. return false;
  5564. } catch (error) {
  5565. throwError(error, 'Steam.isFollowedGame');
  5566. return false;
  5567. }
  5568. }
  5569. async function _toggleForum2(gameId) {
  5570. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5571. try {
  5572. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5573. scripts_echoLog({
  5574. type: 'whiteList',
  5575. text: 'Steam.unsubscribeForum',
  5576. id: gameId
  5577. });
  5578. return true;
  5579. }
  5580. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5581. if (!forumId) {
  5582. return false;
  5583. }
  5584. const logStatus = scripts_echoLog({
  5585. type: `${doTask ? '' : 'un'}subscribingForum`,
  5586. text: gameId
  5587. });
  5588. const [ id, feature ] = forumId.split('_');
  5589. const {
  5590. result,
  5591. statusText,
  5592. status,
  5593. data
  5594. } = await tools_httpRequest({
  5595. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5596. method: 'POST',
  5597. responseType: 'json',
  5598. headers: {
  5599. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5600. },
  5601. data: $.param({
  5602. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5603. })
  5604. });
  5605. if (result === 'Success') {
  5606. var _data$response3, _data$response4;
  5607. 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)) {
  5608. if (doTask) {
  5609. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5610. }
  5611. logStatus.success();
  5612. return true;
  5613. }
  5614. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5615. return true;
  5616. }
  5617. logStatus.error(`${result}:${statusText}(${status})`);
  5618. return true;
  5619. } catch (error) {
  5620. throwError(error, 'Steam.toggleForum');
  5621. return true;
  5622. }
  5623. }
  5624. async function _getForumId2(gameId) {
  5625. try {
  5626. const logStatus = scripts_echoLog({
  5627. type: 'gettingForumId',
  5628. text: gameId
  5629. });
  5630. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5631. if (forumId) {
  5632. logStatus.success();
  5633. return forumId;
  5634. }
  5635. const {
  5636. result,
  5637. statusText,
  5638. status,
  5639. data
  5640. } = await tools_httpRequest({
  5641. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5642. method: 'GET'
  5643. });
  5644. if (result === 'Success') {
  5645. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5646. var _data$responseText, _data$responseText$ma8;
  5647. const forumId = (_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : (_data$responseText$ma8 = _data$responseText.match(/General_([\d]+(_[\d]+)?)/)) === null || _data$responseText$ma8 === void 0 ? void 0 : _data$responseText$ma8[1];
  5648. if (forumId) {
  5649. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5650. logStatus.success();
  5651. return forumId;
  5652. }
  5653. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5654. return false;
  5655. }
  5656. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5657. return false;
  5658. }
  5659. logStatus.error(`${result}:${statusText}(${status})`);
  5660. return false;
  5661. } catch (error) {
  5662. throwError(error, 'Steam.getForumId');
  5663. return false;
  5664. }
  5665. }
  5666. async function _toggleFavoriteWorkshop2(id) {
  5667. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5668. try {
  5669. if (!doTask && this.whiteList.workshops.includes(id)) {
  5670. scripts_echoLog({
  5671. type: 'whiteList',
  5672. text: 'Steam.unfavoriteWorkshop',
  5673. id: id
  5674. });
  5675. return true;
  5676. }
  5677. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5678. if (!appid) {
  5679. return false;
  5680. }
  5681. const logStatus = scripts_echoLog({
  5682. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5683. text: id
  5684. });
  5685. const {
  5686. result,
  5687. statusText,
  5688. status,
  5689. data
  5690. } = await tools_httpRequest({
  5691. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5692. method: 'POST',
  5693. headers: {
  5694. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5695. },
  5696. data: $.param({
  5697. id: id,
  5698. appid: appid,
  5699. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5700. })
  5701. });
  5702. if (result === 'Success') {
  5703. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5704. if (doTask) {
  5705. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5706. }
  5707. logStatus.success();
  5708. return true;
  5709. }
  5710. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5711. return false;
  5712. }
  5713. logStatus.error(`${result}:${statusText}(${status})`);
  5714. return false;
  5715. } catch (error) {
  5716. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5717. return false;
  5718. }
  5719. }
  5720. async function _getWorkshopAppId2(id) {
  5721. try {
  5722. const logStatus = scripts_echoLog({
  5723. type: 'gettingWorkshopAppId',
  5724. text: id
  5725. });
  5726. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5727. if (appId) {
  5728. logStatus.success();
  5729. return appId;
  5730. }
  5731. const {
  5732. result,
  5733. statusText,
  5734. status,
  5735. data
  5736. } = await tools_httpRequest({
  5737. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5738. method: 'GET'
  5739. });
  5740. if (result === 'Success') {
  5741. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5742. var _data$responseText$ma9;
  5743. const appId = (_data$responseText$ma9 = data.responseText.match(/<input type="hidden" name="appid" value="([\d]+?)" \/>/)) === null || _data$responseText$ma9 === void 0 ? void 0 : _data$responseText$ma9[1];
  5744. if (appId) {
  5745. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5746. logStatus.success();
  5747. return appId;
  5748. }
  5749. logStatus.error('Error: getWorkshopAppId failed');
  5750. return false;
  5751. }
  5752. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5753. return false;
  5754. }
  5755. logStatus.error(`${result}:${statusText}(${status})`);
  5756. return false;
  5757. } catch (error) {
  5758. throwError(error, 'Steam.getWorkshopAppId');
  5759. return false;
  5760. }
  5761. }
  5762. async function _voteUpWorkshop2(id) {
  5763. try {
  5764. const logStatus = scripts_echoLog({
  5765. type: 'votingUpWorkshop',
  5766. text: id
  5767. });
  5768. const {
  5769. result,
  5770. statusText,
  5771. status,
  5772. data
  5773. } = await tools_httpRequest({
  5774. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5775. method: 'POST',
  5776. responseType: 'json',
  5777. headers: {
  5778. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5779. },
  5780. data: $.param({
  5781. id: id,
  5782. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5783. })
  5784. });
  5785. if (result === 'Success') {
  5786. var _data$response5;
  5787. 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) {
  5788. logStatus.success();
  5789. return true;
  5790. }
  5791. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5792. return true;
  5793. }
  5794. logStatus.error(`${result}:${statusText}(${status})`);
  5795. return true;
  5796. } catch (error) {
  5797. throwError(error, 'Steam.voteupWorkshop');
  5798. return true;
  5799. }
  5800. }
  5801. async function _toggleCurator2(curatorId) {
  5802. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5803. try {
  5804. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5805. scripts_echoLog({
  5806. type: 'whiteList',
  5807. text: 'Steam.unfollowCurator',
  5808. id: curatorId
  5809. });
  5810. return true;
  5811. }
  5812. const logStatus = scripts_echoLog({
  5813. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5814. text: curatorId
  5815. });
  5816. const {
  5817. result,
  5818. statusText,
  5819. status,
  5820. data
  5821. } = await tools_httpRequest({
  5822. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5823. method: 'POST',
  5824. headers: {
  5825. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5826. },
  5827. data: $.param({
  5828. clanid: curatorId,
  5829. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5830. follow: doTask
  5831. }),
  5832. dataType: 'json'
  5833. });
  5834. if (result === 'Success') {
  5835. var _data$response6, _data$response6$succe, _data$response7;
  5836. 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) {
  5837. logStatus.success();
  5838. return true;
  5839. }
  5840. 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})`);
  5841. return false;
  5842. }
  5843. logStatus.error(`${result}:${statusText}(${status})`);
  5844. return false;
  5845. } catch (error) {
  5846. throwError(error, 'Steam.toggleCurator');
  5847. return false;
  5848. }
  5849. }
  5850. async function _toggleCuratorLike2(link) {
  5851. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5852. try {
  5853. const [ path, name ] = link.split('/');
  5854. if (!(path && name)) {
  5855. scripts_echoLog({
  5856. text: i18n('errorLink', link)
  5857. });
  5858. return false;
  5859. }
  5860. const curatorId = await this.getCuratorId(path, name);
  5861. if (curatorId) {
  5862. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5863. }
  5864. return false;
  5865. } catch (error) {
  5866. throwError(error, 'Steam.toggleCuratorLike');
  5867. return false;
  5868. }
  5869. }
  5870. async function _getAnnouncementParams2(appId, viewId) {
  5871. try {
  5872. const logStatus = scripts_echoLog({
  5873. type: 'gettingAnnouncementParams',
  5874. text: appId,
  5875. id: viewId
  5876. });
  5877. const {
  5878. result,
  5879. statusText,
  5880. status,
  5881. data
  5882. } = await tools_httpRequest({
  5883. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5884. method: 'GET',
  5885. headers: {
  5886. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5887. }
  5888. });
  5889. if (result === 'Success') {
  5890. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5891. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5892. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5893. logStatus.warning(i18n('changeAreaNotice'));
  5894. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5895. return {};
  5896. }
  5897. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5898. }
  5899. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5900. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5901. const gid = (_data$responseText$ma12 = data.responseText.match(/announcementGID&quot;:&quot;([\d]+?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  5902. if (authWgToken && clanId) {
  5903. logStatus.success();
  5904. return {
  5905. authWgToken: authWgToken,
  5906. clanId: clanId,
  5907. gid: gid
  5908. };
  5909. }
  5910. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5911. return {};
  5912. }
  5913. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5914. return {};
  5915. }
  5916. logStatus.error(`${result}:${statusText}(${status})`);
  5917. return {};
  5918. } catch (error) {
  5919. throwError(error, 'Steam.likeAnnouncement');
  5920. return {};
  5921. }
  5922. }
  5923. async function _likeAnnouncement2(id) {
  5924. try {
  5925. const [ appId, viewId ] = id.split('/');
  5926. if (!(appId && viewId)) {
  5927. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  5928. return false;
  5929. }
  5930. const {
  5931. authWgToken,
  5932. clanId,
  5933. gid
  5934. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5935. if (!(authWgToken && clanId)) {
  5936. return false;
  5937. }
  5938. const logStatus = scripts_echoLog({
  5939. type: 'likingAnnouncement',
  5940. text: appId,
  5941. id: viewId
  5942. });
  5943. const {
  5944. result,
  5945. statusText,
  5946. status,
  5947. data
  5948. } = await tools_httpRequest({
  5949. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5950. method: 'POST',
  5951. headers: {
  5952. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5953. Host: 'store.steampowered.com',
  5954. Origin: 'https://store.steampowered.com',
  5955. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5956. },
  5957. data: $.param({
  5958. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5959. wgauthtoken: authWgToken,
  5960. voteup: 1,
  5961. clanid: clanId,
  5962. ajax: 1
  5963. }),
  5964. dataType: 'json'
  5965. });
  5966. if (result === 'Success') {
  5967. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5968. logStatus.success();
  5969. return true;
  5970. }
  5971. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5972. return false;
  5973. }
  5974. logStatus.error(`${result}:${statusText}(${status})`);
  5975. return false;
  5976. } catch (error) {
  5977. throwError(error, 'Steam.likeAnnouncement');
  5978. return false;
  5979. }
  5980. }
  5981. async function _appid2subid2(id) {
  5982. try {
  5983. const logStatus = scripts_echoLog({
  5984. type: 'gettingSubid',
  5985. text: id
  5986. });
  5987. const {
  5988. result,
  5989. statusText,
  5990. status,
  5991. data
  5992. } = await tools_httpRequest({
  5993. url: `https://store.steampowered.com/app/${id}`,
  5994. method: 'GET',
  5995. headers: {
  5996. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5997. }
  5998. });
  5999. if (result === 'Success') {
  6000. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6001. var _data$responseText$ma13;
  6002. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6003. logStatus.warning(i18n('changeAreaNotice'));
  6004. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6005. if (!result || result === 'CN' || result === 'skip') {
  6006. return false;
  6007. }
  6008. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6009. }
  6010. const subid = (_data$responseText$ma13 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6011. if (subid) {
  6012. logStatus.success();
  6013. return subid;
  6014. }
  6015. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6016. return false;
  6017. }
  6018. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6019. return false;
  6020. }
  6021. logStatus.error(`${result}:${statusText}(${status})`);
  6022. return false;
  6023. } catch (error) {
  6024. throwError(error, 'Steam.appid2subid');
  6025. return false;
  6026. }
  6027. }
  6028. async function _addLicense2(id) {
  6029. try {
  6030. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6031. if (!subid) {
  6032. return false;
  6033. }
  6034. const logStatus = scripts_echoLog({
  6035. type: 'addingFreeLicense',
  6036. text: id
  6037. });
  6038. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6039. return false;
  6040. }
  6041. const {
  6042. result,
  6043. statusText,
  6044. status,
  6045. data
  6046. } = await tools_httpRequest({
  6047. url: `https://store.steampowered.com/app/${id}`,
  6048. method: 'GET'
  6049. });
  6050. if (result === 'Success') {
  6051. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6052. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6053. logStatus.success();
  6054. return true;
  6055. }
  6056. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6057. return false;
  6058. }
  6059. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6060. return false;
  6061. }
  6062. logStatus.error(`${result}:${statusText}(${status})`);
  6063. return false;
  6064. } catch (error) {
  6065. throwError(error, 'Steam.addLicense');
  6066. return false;
  6067. }
  6068. }
  6069. async function _addFreeLicense2(id, logStatus) {
  6070. try {
  6071. const {
  6072. result,
  6073. statusText,
  6074. status,
  6075. data
  6076. } = await tools_httpRequest({
  6077. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6078. method: 'POST',
  6079. headers: {
  6080. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6081. Host: 'store.steampowered.com',
  6082. Origin: 'https://store.steampowered.com',
  6083. Referer: 'https://store.steampowered.com/account/licenses/'
  6084. },
  6085. data: $.param({
  6086. action: 'add_to_cart',
  6087. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6088. subid: id
  6089. }),
  6090. dataType: 'json'
  6091. });
  6092. if (result === 'Success') {
  6093. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6094. logStatus.success();
  6095. return true;
  6096. }
  6097. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6098. return false;
  6099. }
  6100. logStatus.error(`${result}:${statusText}(${status})`);
  6101. return false;
  6102. } catch (error) {
  6103. throwError(error, 'Steam.addFreeLicense');
  6104. return false;
  6105. }
  6106. }
  6107. function Steam_setCache2(type, name, id) {
  6108. try {
  6109. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6110. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6111. } catch (error) {
  6112. throwError(error, 'Steam.setCache');
  6113. }
  6114. }
  6115. const social_Steam = Steam;
  6116. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6117. Website_checkPrivateRedeclaration(obj, privateSet);
  6118. privateSet.add(obj);
  6119. }
  6120. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6121. if (privateCollection.has(obj)) {
  6122. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6123. }
  6124. }
  6125. function Website_defineProperty(obj, key, value) {
  6126. if (key in obj) {
  6127. Object.defineProperty(obj, key, {
  6128. value: value,
  6129. enumerable: true,
  6130. configurable: true,
  6131. writable: true
  6132. });
  6133. } else {
  6134. obj[key] = value;
  6135. }
  6136. return obj;
  6137. }
  6138. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6139. if (!privateSet.has(receiver)) {
  6140. throw new TypeError('attempted to get private field on non-instance');
  6141. }
  6142. return fn;
  6143. }
  6144. var _bind = new WeakSet();
  6145. class Website {
  6146. constructor() {
  6147. Website_classPrivateMethodInitSpec(this, _bind);
  6148. Website_defineProperty(this, 'undoneTasks', void 0);
  6149. Website_defineProperty(this, 'socialTasks', void 0);
  6150. Website_defineProperty(this, 'giveawayId', void 0);
  6151. Website_defineProperty(this, 'socialInitialized', {
  6152. discord: false,
  6153. instagram: false,
  6154. reddit: false,
  6155. twitch: false,
  6156. twitter: false,
  6157. vk: false,
  6158. youtube: false,
  6159. steamStore: false,
  6160. steamCommunity: false
  6161. });
  6162. Website_defineProperty(this, 'initialized', false);
  6163. Website_defineProperty(this, 'social', {});
  6164. }
  6165. async initSocial(action) {
  6166. try {
  6167. const pro = [];
  6168. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6169. if (tasks.discord) {
  6170. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6171. if (hasDiscord && !this.socialInitialized.discord && !this.social.discord) {
  6172. this.social.discord = new social_Discord();
  6173. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6174. }
  6175. }
  6176. if (tasks.instagram) {
  6177. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6178. if (hasInstagram && !this.socialInitialized.instagram && !this.social.instagram) {
  6179. this.social.instagram = new social_Instagram();
  6180. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6181. }
  6182. }
  6183. if (tasks.reddit) {
  6184. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6185. if (hasReddit && !this.socialInitialized.reddit && !this.social.reddit) {
  6186. this.social.reddit = new social_Reddit();
  6187. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6188. }
  6189. }
  6190. if (tasks.twitch) {
  6191. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6192. if (hasTwitch && !this.socialInitialized.twitch && !this.social.twitch) {
  6193. this.social.twitch = new social_Twitch();
  6194. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6195. }
  6196. }
  6197. if (tasks.twitter) {
  6198. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6199. if (hasTwitter && !this.socialInitialized.twitter && !this.social.twitter) {
  6200. this.social.twitter = new social_Twitter();
  6201. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6202. }
  6203. }
  6204. if (tasks.vk) {
  6205. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6206. if (hasVk && !this.socialInitialized.vk && !this.social.vk) {
  6207. this.social.vk = new social_Vk();
  6208. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6209. }
  6210. }
  6211. if (tasks.youtube) {
  6212. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6213. if (hasYoutube && !this.socialInitialized.youtube && !this.social.youtube) {
  6214. this.social.youtube = new Youtube();
  6215. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6216. }
  6217. }
  6218. if (tasks.steam) {
  6219. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6220. if (steamLength > 0) {
  6221. if (!this.social.steam) {
  6222. this.social.steam = new social_Steam();
  6223. }
  6224. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6225. var _tasks$steam, _tasks$steam$type;
  6226. return [ 'groupLinks', 'forumLinks', 'workshopLinks', 'workshopVoteLinks' ].includes(type) ? ((_tasks$steam = tasks.steam) === null || _tasks$steam === void 0 ? void 0 : (_tasks$steam$type = _tasks$steam[type]) === null || _tasks$steam$type === void 0 ? void 0 : _tasks$steam$type.length) || 0 : 0;
  6227. }).reduce((total, number) => total + number, 0);
  6228. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6229. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6230. }
  6231. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6232. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6233. }
  6234. }
  6235. }
  6236. if (tasks.links && tasks.links.length > 0) {
  6237. this.social.visitLink = visitLink;
  6238. }
  6239. return await Promise.all(pro).then(result => {
  6240. let checked = true;
  6241. for (const data of result) {
  6242. if (data.result) {
  6243. this.socialInitialized[data.name] = data.result;
  6244. } else {
  6245. checked = false;
  6246. }
  6247. }
  6248. return checked;
  6249. });
  6250. } catch (error) {
  6251. throwError(error, 'Website.initSocial');
  6252. return false;
  6253. }
  6254. }
  6255. uniqueTasks(allTasks) {
  6256. const result = {};
  6257. for (const [ social, types ] of Object.entries(allTasks)) {
  6258. result[social] = {};
  6259. for (const [ type, tasks ] of Object.entries(types)) {
  6260. result[social][type] = unique(tasks);
  6261. }
  6262. }
  6263. return result;
  6264. }
  6265. async toggleTask(action) {
  6266. try {
  6267. if (!this.initialized && !this.init()) {
  6268. return false;
  6269. }
  6270. if (!await this.classifyTask(action)) {
  6271. return false;
  6272. }
  6273. if (!await this.initSocial(action)) {
  6274. return false;
  6275. }
  6276. const pro = [];
  6277. const doTask = action === 'do';
  6278. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6279. if (this.social.discord) {
  6280. pro.push(this.social.discord.toggle({
  6281. doTask: doTask,
  6282. ...tasks.discord
  6283. }));
  6284. }
  6285. if (this.social.instagram) {
  6286. pro.push(this.social.instagram.toggle({
  6287. doTask: doTask,
  6288. ...tasks.instagram
  6289. }));
  6290. }
  6291. if (this.social.reddit) {
  6292. pro.push(this.social.reddit.toggle({
  6293. doTask: doTask,
  6294. ...tasks.reddit
  6295. }));
  6296. }
  6297. if (this.social.twitch) {
  6298. pro.push(this.social.twitch.toggle({
  6299. doTask: doTask,
  6300. ...tasks.twitch
  6301. }));
  6302. }
  6303. if (this.social.twitter) {
  6304. pro.push(this.social.twitter.toggle({
  6305. doTask: doTask,
  6306. ...tasks.twitter
  6307. }));
  6308. }
  6309. if (this.social.vk) {
  6310. pro.push(this.social.vk.toggle({
  6311. doTask: doTask,
  6312. ...tasks.vk
  6313. }));
  6314. }
  6315. if (this.social.youtube) {
  6316. pro.push(this.social.youtube.toggle({
  6317. doTask: doTask,
  6318. ...tasks.youtube
  6319. }));
  6320. }
  6321. if (this.social.steam) {
  6322. pro.push(this.social.steam.toggle({
  6323. doTask: doTask,
  6324. ...tasks.steam
  6325. }));
  6326. }
  6327. if (this.social.visitLink && tasks.links && doTask) {
  6328. for (const link of tasks.links) {
  6329. pro.push(this.social.visitLink(link));
  6330. }
  6331. }
  6332. if (doTask && tasks.extra && this.extraDoTask) {
  6333. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6334. if (hasExtra) {
  6335. pro.push(this.extraDoTask(tasks.extra));
  6336. }
  6337. }
  6338. await Promise.all(pro);
  6339. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6340. return true;
  6341. } catch (error) {
  6342. throwError(error, 'Website.toggleTask');
  6343. return false;
  6344. }
  6345. }
  6346. async doTask() {
  6347. try {
  6348. return await this.toggleTask('do');
  6349. } catch (error) {
  6350. throwError(error, 'Website.doTask');
  6351. return false;
  6352. }
  6353. }
  6354. async undoTask() {
  6355. try {
  6356. return await this.toggleTask('undo');
  6357. } catch (error) {
  6358. throwError(error, 'Website.undoTask');
  6359. return false;
  6360. }
  6361. }
  6362. }
  6363. async function _bind2(name, init) {
  6364. try {
  6365. return {
  6366. name: name,
  6367. result: await init
  6368. };
  6369. } catch (error) {
  6370. throwError(error, 'Website.bind');
  6371. return {
  6372. name: name,
  6373. result: false
  6374. };
  6375. }
  6376. }
  6377. const website_Website = Website;
  6378. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6379. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6380. privateSet.add(obj);
  6381. }
  6382. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6383. if (privateCollection.has(obj)) {
  6384. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6385. }
  6386. }
  6387. function FreeAnyWhere_defineProperty(obj, key, value) {
  6388. if (key in obj) {
  6389. Object.defineProperty(obj, key, {
  6390. value: value,
  6391. enumerable: true,
  6392. configurable: true,
  6393. writable: true
  6394. });
  6395. } else {
  6396. obj[key] = value;
  6397. }
  6398. return obj;
  6399. }
  6400. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6401. if (!privateSet.has(receiver)) {
  6402. throw new TypeError('attempted to get private field on non-instance');
  6403. }
  6404. return fn;
  6405. }
  6406. const FreeAnyWhere_defaultTasks = JSON.stringify({
  6407. steam: {
  6408. groupLinks: [],
  6409. wishlistLinks: [],
  6410. curatorLinks: [],
  6411. followLinks: []
  6412. },
  6413. vk: {
  6414. nameLinks: []
  6415. }
  6416. });
  6417. var _getGiveawayId = new WeakSet();
  6418. var _verify = new WeakSet();
  6419. class FreeAnyWhere extends website_Website {
  6420. constructor() {
  6421. super(...arguments);
  6422. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6423. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6424. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6425. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6426. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6427. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6428. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6429. }
  6430. static test() {
  6431. return window.location.host === 'freeanywhere.net';
  6432. }
  6433. init() {
  6434. try {
  6435. const logStatus = scripts_echoLog({
  6436. text: i18n('initing')
  6437. });
  6438. if ($('a[href="#/login"]').length > 0) {
  6439. window.open('/#/login', '_self');
  6440. logStatus.warning(i18n('needLogin'));
  6441. return false;
  6442. }
  6443. if (window.location.href.includes('/login')) {
  6444. logStatus.warning(i18n('needLogin'));
  6445. return false;
  6446. }
  6447. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6448. var _window$location$href;
  6449. 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];
  6450. if (!id) {
  6451. logStatus.error(i18n('getFailed', 'Id'));
  6452. return false;
  6453. }
  6454. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6455. }
  6456. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6457. return false;
  6458. }
  6459. this.initialized = true;
  6460. logStatus.success();
  6461. return true;
  6462. } catch (error) {
  6463. throwError(error, 'Freeanywhere.init');
  6464. return false;
  6465. }
  6466. }
  6467. async classifyTask(action) {
  6468. try {
  6469. const logStatus = scripts_echoLog({
  6470. text: i18n('getTasksInfo')
  6471. });
  6472. if (action === 'undo') {
  6473. var _GM_getValue;
  6474. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6475. }
  6476. const {
  6477. result,
  6478. statusText,
  6479. status,
  6480. data
  6481. } = await tools_httpRequest({
  6482. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6483. method: 'GET',
  6484. headers: {
  6485. authorization: `Token ${window.localStorage.getItem('token')}`,
  6486. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6487. },
  6488. responseType: 'json'
  6489. });
  6490. if (result === 'Success') {
  6491. var _data$response;
  6492. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6493. if (tasks) {
  6494. if (action === 'verify') {
  6495. this.tasks = [];
  6496. }
  6497. for (const task of tasks) {
  6498. const type = task.challenge;
  6499. const social = task.challenge_provider;
  6500. const taskInfo = {
  6501. id: task.id,
  6502. title: task.title
  6503. };
  6504. if (action === 'verify' && !task.is_success) {
  6505. this.tasks.push(taskInfo);
  6506. continue;
  6507. }
  6508. switch (social) {
  6509. case 'steam':
  6510. taskInfo.social = 'steam';
  6511. switch (type) {
  6512. case 'WL':
  6513. if (action === 'undo') {
  6514. this.socialTasks.steam.wishlistLinks.push(task.link);
  6515. }
  6516. if (action === 'do' && !task.is_success) {
  6517. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6518. }
  6519. break;
  6520.  
  6521. case 'JTG':
  6522. if (action === 'undo') {
  6523. this.socialTasks.steam.groupLinks.push(task.link);
  6524. }
  6525. if (action === 'do' && !task.is_success) {
  6526. this.undoneTasks.steam.groupLinks.push(task.link);
  6527. }
  6528. break;
  6529.  
  6530. case 'STC':
  6531. if (action === 'undo') {
  6532. this.socialTasks.steam.curatorLinks.push(task.link);
  6533. }
  6534. if (action === 'do' && !task.is_success) {
  6535. this.undoneTasks.steam.curatorLinks.push(task.link);
  6536. }
  6537. break;
  6538.  
  6539. case 'GF':
  6540. if (action === 'undo') {
  6541. this.socialTasks.steam.followLinks.push(task.link);
  6542. }
  6543. if (action === 'do' && !task.is_success) {
  6544. this.undoneTasks.steam.followLinks.push(task.link);
  6545. }
  6546. break;
  6547. }
  6548. break;
  6549.  
  6550. case 'vk-oauth2':
  6551. if (action === 'undo') {
  6552. this.socialTasks.vk.nameLinks.push(task.link);
  6553. }
  6554. if (action === 'do' && !task.is_success) {
  6555. this.undoneTasks.vk.nameLinks.push(task.link);
  6556. }
  6557. break;
  6558.  
  6559. case 'website':
  6560. break;
  6561.  
  6562. default:
  6563. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6564. break;
  6565. }
  6566. }
  6567. logStatus.success();
  6568. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6569. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6570. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6571. tasks: this.socialTasks,
  6572. time: new Date().getTime()
  6573. });
  6574. return true;
  6575. }
  6576. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6577. console.error(data);
  6578. return false;
  6579. }
  6580. logStatus.error(`${result}:${statusText}(${status})`);
  6581. return false;
  6582. } catch (error) {
  6583. throwError(error, 'Freeanywhere.classifyTask');
  6584. return false;
  6585. }
  6586. }
  6587. async verifyTask() {
  6588. try {
  6589. if (!this.initialized && !this.init()) {
  6590. return false;
  6591. }
  6592. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6593. return false;
  6594. }
  6595. const pro = [];
  6596. for (const task of this.tasks) {
  6597. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6598. await delay(1e3);
  6599. }
  6600. await Promise.all(pro);
  6601. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6602. return !!await this.getKey(true);
  6603. } catch (error) {
  6604. throwError(error, 'Freeanywhere.verifyTask');
  6605. return false;
  6606. }
  6607. }
  6608. async getKey(initialized) {
  6609. try {
  6610. if (!initialized && !this.initialized && !this.init()) {
  6611. return false;
  6612. }
  6613. const logStatus = scripts_echoLog({
  6614. text: i18n('gettingKey')
  6615. });
  6616. const {
  6617. result,
  6618. statusText,
  6619. status,
  6620. data
  6621. } = await tools_httpRequest({
  6622. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6623. method: 'GET',
  6624. dataType: 'json',
  6625. headers: {
  6626. authorization: `Token ${window.localStorage.getItem('token')}`
  6627. }
  6628. });
  6629. if (result === 'Success') {
  6630. var _data$response2;
  6631. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6632. logStatus.success();
  6633. scripts_echoLog({}).success(data.response.reward);
  6634. return data.response.reward;
  6635. }
  6636. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6637. return false;
  6638. }
  6639. logStatus.error(`${result}:${statusText}(${status})`);
  6640. return false;
  6641. } catch (error) {
  6642. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6643. return false;
  6644. }
  6645. }
  6646. }
  6647. function _getGiveawayId2() {
  6648. try {
  6649. var _window$location$href2;
  6650. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6651. if (giveawayId) {
  6652. this.giveawayId = giveawayId;
  6653. return true;
  6654. }
  6655. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6656. return false;
  6657. } catch (error) {
  6658. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6659. }
  6660. }
  6661. async function _verify2(task) {
  6662. try {
  6663. const logStatus = scripts_echoLog({
  6664. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6665. });
  6666. const {
  6667. result,
  6668. statusText,
  6669. status,
  6670. data
  6671. } = await tools_httpRequest({
  6672. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6673. method: 'GET',
  6674. dataType: 'json',
  6675. headers: {
  6676. authorization: `Token ${window.localStorage.getItem('token')}`,
  6677. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6678. }
  6679. });
  6680. if (result === 'Success') {
  6681. var _data$response3;
  6682. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6683. logStatus.success();
  6684. return true;
  6685. }
  6686. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6687. return false;
  6688. }
  6689. logStatus.error(`${result}:${statusText}(${status})`);
  6690. return false;
  6691. } catch (error) {
  6692. throwError(error, 'Freeanywhere.verify');
  6693. return false;
  6694. }
  6695. }
  6696. const website_FreeAnyWhere = FreeAnyWhere;
  6697. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6698. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6699. privateSet.add(obj);
  6700. }
  6701. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6702. if (privateCollection.has(obj)) {
  6703. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6704. }
  6705. }
  6706. function GiveawaySu_defineProperty(obj, key, value) {
  6707. if (key in obj) {
  6708. Object.defineProperty(obj, key, {
  6709. value: value,
  6710. enumerable: true,
  6711. configurable: true,
  6712. writable: true
  6713. });
  6714. } else {
  6715. obj[key] = value;
  6716. }
  6717. return obj;
  6718. }
  6719. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6720. if (!privateSet.has(receiver)) {
  6721. throw new TypeError('attempted to get private field on non-instance');
  6722. }
  6723. return fn;
  6724. }
  6725. const GiveawaySu_defaultTasks = {
  6726. steam: {
  6727. groupLinks: [],
  6728. wishlistLinks: [],
  6729. curatorLinks: [],
  6730. curatorLikeLinks: [],
  6731. followLinks: [],
  6732. forumLinks: [],
  6733. announcementLinks: [],
  6734. workshopVoteLinks: []
  6735. },
  6736. discord: {
  6737. serverLinks: []
  6738. },
  6739. instagram: {
  6740. userLinks: []
  6741. },
  6742. vk: {
  6743. nameLinks: []
  6744. },
  6745. twitch: {
  6746. channelLinks: []
  6747. },
  6748. reddit: {
  6749. redditLinks: []
  6750. },
  6751. youtube: {
  6752. channelLinks: [],
  6753. likeLinks: []
  6754. }
  6755. };
  6756. var _checkLogin = new WeakSet();
  6757. var _checkLeftKey = new WeakSet();
  6758. var GiveawaySu_getGiveawayId = new WeakSet();
  6759. class GiveawaySu extends website_Website {
  6760. constructor() {
  6761. super(...arguments);
  6762. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6763. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6764. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6765. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6766. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6767. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6768. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6769. }
  6770. static test() {
  6771. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6772. }
  6773. async after() {
  6774. try {
  6775. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6776. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6777. }
  6778. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6779. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6780. }
  6781. scripts_echoLog({}).warning(i18n('gsNotice'));
  6782. } catch (error) {
  6783. throwError(error, 'Giveawaysu.after');
  6784. }
  6785. }
  6786. init() {
  6787. try {
  6788. const logStatus = scripts_echoLog({
  6789. text: i18n('initing')
  6790. });
  6791. if ($('a.steam-login').length > 0) {
  6792. window.open('/steam/redirect', '_self');
  6793. logStatus.warning(i18n('needLogin'));
  6794. return false;
  6795. }
  6796. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6797. return false;
  6798. }
  6799. this.initialized = true;
  6800. logStatus.success();
  6801. return true;
  6802. } catch (error) {
  6803. throwError(error, 'Giveawaysu.init');
  6804. return false;
  6805. }
  6806. }
  6807. async classifyTask(action) {
  6808. try {
  6809. const logStatus = scripts_echoLog({
  6810. text: i18n('getTasksInfo')
  6811. });
  6812. if (action === 'undo') {
  6813. var _GM_getValue;
  6814. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6815. return true;
  6816. }
  6817. const pro = [];
  6818. const tasks = $('#actions tr');
  6819. if ($('div.bind-discord').is(':visible')) {
  6820. $('div.bind-discord a')[0].click();
  6821. }
  6822. if ($('div.bind-twitch').is(':visible')) {
  6823. $('div.bind-twitch a')[0].click();
  6824. }
  6825. for (const task of tasks) {
  6826. pro.push(new Promise(resolve => {
  6827. const td = $(task).find('td:not(".hidden")');
  6828. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6829. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6830. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6831. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6832. const taskName = taskDes.text().trim();
  6833. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6834. return resolve(true);
  6835. }
  6836. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6837. if (!taskLink) {
  6838. return resolve(false);
  6839. }
  6840. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6841. this.undoneTasks.steam.groupLinks.push(taskLink);
  6842. } else if (/like.*announcement/gi.test(taskName)) {
  6843. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6844. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6845. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6846. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6847. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6848. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6849. this.undoneTasks.steam.forumLinks.push(taskLink);
  6850. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6851. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6852. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6853. this.undoneTasks.discord.serverLinks.push(taskLink);
  6854. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6855. this.undoneTasks.instagram.userLinks.push(taskLink);
  6856. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6857. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6858. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6859. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6860. } else if (/watch.*art/gim.test(taskName)) {
  6861. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6862. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6863. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6864. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6865. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6866. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6867. this.undoneTasks.vk.nameLinks.push(taskLink);
  6868. } else {
  6869. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6870. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6871. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6872. }
  6873. if (/follow.*button/gim.test(taskName)) {
  6874. this.undoneTasks.steam.followLinks.push(taskLink);
  6875. }
  6876. }
  6877. }
  6878. resolve(true);
  6879. }).catch(error => {
  6880. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6881. return false;
  6882. });
  6883. }));
  6884. }
  6885. await Promise.all(pro);
  6886. logStatus.success();
  6887. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6888. this.socialTasks = this.undoneTasks;
  6889. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6890. tasks: this.socialTasks,
  6891. time: new Date().getTime()
  6892. });
  6893. return true;
  6894. } catch (error) {
  6895. throwError(error, 'Giveawaysu.classifyTask');
  6896. return false;
  6897. }
  6898. }
  6899. }
  6900. function _checkLogin2() {
  6901. try {
  6902. if (!globalOptions.other.checkLogin) {
  6903. return true;
  6904. }
  6905. if ($('a.steam-login').length > 0) {
  6906. window.open('/steam/redirect', '_self');
  6907. }
  6908. return true;
  6909. } catch (error) {
  6910. throwError(error, 'Giveawaysu.checkLogin');
  6911. return false;
  6912. }
  6913. }
  6914. async function _checkLeftKey2() {
  6915. try {
  6916. if (!globalOptions.other.checkLeftKey) {
  6917. return true;
  6918. }
  6919. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  6920. await external_Swal_default().fire({
  6921. icon: 'warning',
  6922. title: i18n('notice'),
  6923. text: i18n('noKeysLeft'),
  6924. confirmButtonText: i18n('confirm'),
  6925. cancelButtonText: i18n('cancel'),
  6926. showCancelButton: true
  6927. }).then(_ref => {
  6928. let {
  6929. value
  6930. } = _ref;
  6931. if (value) {
  6932. window.close();
  6933. }
  6934. });
  6935. }
  6936. return true;
  6937. } catch (error) {
  6938. throwError(error, 'Giveawaysu.checkLeftKey');
  6939. return false;
  6940. }
  6941. }
  6942. function GiveawaySu_getGiveawayId2() {
  6943. var _window$location$href;
  6944. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6945. if (giveawayId) {
  6946. this.giveawayId = giveawayId;
  6947. return true;
  6948. }
  6949. scripts_echoLog({
  6950. text: i18n('getFailed', 'GiveawayId')
  6951. });
  6952. return false;
  6953. }
  6954. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  6955. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  6956. privateSet.add(obj);
  6957. }
  6958. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  6959. if (privateCollection.has(obj)) {
  6960. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6961. }
  6962. }
  6963. function Indiedb_defineProperty(obj, key, value) {
  6964. if (key in obj) {
  6965. Object.defineProperty(obj, key, {
  6966. value: value,
  6967. enumerable: true,
  6968. configurable: true,
  6969. writable: true
  6970. });
  6971. } else {
  6972. obj[key] = value;
  6973. }
  6974. return obj;
  6975. }
  6976. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  6977. if (!privateSet.has(receiver)) {
  6978. throw new TypeError('attempted to get private field on non-instance');
  6979. }
  6980. return fn;
  6981. }
  6982. var _join = new WeakSet();
  6983. var _do = new WeakSet();
  6984. var Indiedb_checkLogin = new WeakSet();
  6985. var Indiedb_checkLeftKey = new WeakSet();
  6986. class Indiedb {
  6987. constructor() {
  6988. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  6989. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  6990. Indiedb_classPrivateMethodInitSpec(this, _do);
  6991. Indiedb_classPrivateMethodInitSpec(this, _join);
  6992. Indiedb_defineProperty(this, 'name', 'Indiedb');
  6993. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  6994. }
  6995. static test() {
  6996. return window.location.host === 'www.indiedb.com';
  6997. }
  6998. async after() {
  6999. try {
  7000. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7001. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7002. }
  7003. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7004. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7005. }
  7006. } catch (error) {
  7007. throwError(error, 'Indiedb.after');
  7008. }
  7009. }
  7010. async doTask() {
  7011. try {
  7012. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7013. return false;
  7014. }
  7015. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7016. } catch (error) {
  7017. throwError(error, 'Indiedb.doTask');
  7018. return false;
  7019. }
  7020. }
  7021. }
  7022. async function _join2() {
  7023. try {
  7024. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7025. scripts_echoLog({}).error(i18n('needLogin'));
  7026. return false;
  7027. }
  7028. const currentoption = $('a.buttonenter.buttongiveaway');
  7029. if (/join giveaway/gim.test(currentoption.text())) {
  7030. const logStatus = scripts_echoLog({
  7031. text: `${i18n('joiningGiveaway')}...`
  7032. });
  7033. const {
  7034. result,
  7035. statusText,
  7036. status,
  7037. data
  7038. } = await tools_httpRequest({
  7039. url: currentoption.attr('href'),
  7040. method: 'POST',
  7041. data: 'ajax=t',
  7042. dataType: 'json',
  7043. headers: {
  7044. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7045. accept: 'application/json, text/javascript, */*; q=0.01',
  7046. origin: window.location.origin
  7047. }
  7048. });
  7049. if (result === 'Success') {
  7050. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7051. var _data$response, _data$response4, _data$response5;
  7052. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7053. var _data$response2, _data$response3;
  7054. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7055. $('#giveawaysjoined').slideDown();
  7056. $('#giveawaysrecommend').slideDown();
  7057. 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}` : ''}`);
  7058. return true;
  7059. }
  7060. 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}` : ''}`);
  7061. return false;
  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. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7069. return true;
  7070. }
  7071. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7072. return false;
  7073. } catch (error) {
  7074. throwError(error, 'Indiedb.init');
  7075. return false;
  7076. }
  7077. }
  7078. async function _do2() {
  7079. try {
  7080. const id = $('script').map((index, script) => {
  7081. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7082. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7083. 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] ];
  7084. }
  7085. return null;
  7086. });
  7087. if (id.length === 2) {
  7088. const pro = [];
  7089. const tasks = $('#giveawaysjoined a[class*=promo]');
  7090. for (const task of tasks) {
  7091. const promo = $(task);
  7092. if (!promo.hasClass('buttonentered')) {
  7093. const status = scripts_echoLog({
  7094. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7095. });
  7096. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7097. let text = '';
  7098. if (promo.hasClass('facebookpromo')) {
  7099. text = 'facebookpromo';
  7100. } else if (promo.hasClass('twitterpromo')) {
  7101. text = 'twitterpromo';
  7102. } else {
  7103. text = 'visitpromo';
  7104. }
  7105. pro.push(new Promise(resolve => {
  7106. $.ajax({
  7107. type: 'POST',
  7108. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7109. timeout: 6e4,
  7110. dataType: 'json',
  7111. data: {
  7112. ajax: 't'
  7113. },
  7114. error(response, error, exception) {
  7115. console.log({
  7116. response: response,
  7117. error: error,
  7118. exception: exception
  7119. });
  7120. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7121. resolve(true);
  7122. },
  7123. success(response) {
  7124. console.log(response);
  7125. if (response.success) {
  7126. status.success(`Success:${response.text}`);
  7127. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7128. resolve(true);
  7129. } else {
  7130. status.error(`Error:${response.text}`);
  7131. resolve(true);
  7132. }
  7133. }
  7134. });
  7135. }));
  7136. } else if (promo.hasClass('emailoptinpromo')) {
  7137. pro.push(new Promise(resolve => {
  7138. $.ajax({
  7139. type: 'POST',
  7140. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7141. timeout: 6e4,
  7142. dataType: 'json',
  7143. data: {
  7144. ajax: 't',
  7145. emailsystoggle: 4
  7146. },
  7147. error(response, error, exception) {
  7148. console.log({
  7149. response: response,
  7150. error: error,
  7151. exception: exception
  7152. });
  7153. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7154. resolve(true);
  7155. },
  7156. success(response) {
  7157. console.log(response);
  7158. if (response.success) {
  7159. status.success(`Success:${response.text}`);
  7160. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7161. resolve(true);
  7162. } else {
  7163. status.error(`Error:${response.text}`);
  7164. resolve(true);
  7165. }
  7166. }
  7167. });
  7168. }));
  7169. } else if (promo.hasClass('watchingpromo')) {
  7170. pro.push(new Promise(resolve => {
  7171. var _promo$attr;
  7172. const data = getUrlQuery(promo.attr('href'));
  7173. data.ajax = 't';
  7174. $.ajax({
  7175. type: 'POST',
  7176. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7177. timeout: 6e4,
  7178. dataType: 'json',
  7179. data: data,
  7180. error(response, error, exception) {
  7181. console.log({
  7182. response: response,
  7183. error: error,
  7184. exception: exception
  7185. });
  7186. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7187. resolve(true);
  7188. },
  7189. success(response) {
  7190. console.log(response);
  7191. if (response.success) {
  7192. status.success(`Success:${response.text}`);
  7193. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7194. resolve(true);
  7195. } else {
  7196. status.error(`Error:${response.text}`);
  7197. resolve(true);
  7198. }
  7199. }
  7200. });
  7201. }));
  7202. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7203. pro.push(new Promise(resolve => {
  7204. $.ajax({
  7205. type: 'POST',
  7206. url: urlPath(promo.attr('href')),
  7207. timeout: 6e4,
  7208. dataType: 'json',
  7209. data: {
  7210. ajax: 't'
  7211. },
  7212. error(response, error, exception) {
  7213. console.log({
  7214. response: response,
  7215. error: error,
  7216. exception: exception
  7217. });
  7218. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7219. resolve(true);
  7220. },
  7221. success(response) {
  7222. console.log(response);
  7223. if (response.success) {
  7224. status.success(`Success:${response.text}`);
  7225. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7226. resolve(true);
  7227. } else {
  7228. status.error(`Error:${response.text}`);
  7229. resolve(true);
  7230. }
  7231. }
  7232. });
  7233. }));
  7234. } else {
  7235. status.error(`Error:${i18n('unKnownTaskType')}`);
  7236. }
  7237. }
  7238. }
  7239. await Promise.all(pro);
  7240. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7241. return true;
  7242. }
  7243. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7244. return false;
  7245. } catch (error) {
  7246. throwError(error, 'Indiedb.classifyTask');
  7247. return false;
  7248. }
  7249. }
  7250. function Indiedb_checkLogin2() {
  7251. try {
  7252. if (!globalOptions.other.checkLogin) {
  7253. return true;
  7254. }
  7255. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7256. window.open('/members/login', '_self');
  7257. }
  7258. return true;
  7259. } catch (error) {
  7260. throwError(error, 'Indiedb.checkLogin');
  7261. return false;
  7262. }
  7263. }
  7264. async function Indiedb_checkLeftKey2() {
  7265. try {
  7266. if (!globalOptions.other.checkLeftKey) {
  7267. return true;
  7268. }
  7269. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7270. await external_Swal_default().fire({
  7271. icon: 'warning',
  7272. title: i18n('notice'),
  7273. text: i18n('giveawayEnded'),
  7274. confirmButtonText: i18n('confirm'),
  7275. cancelButtonText: i18n('cancel'),
  7276. showCancelButton: true
  7277. }).then(_ref => {
  7278. let {
  7279. value
  7280. } = _ref;
  7281. if (value) {
  7282. window.close();
  7283. }
  7284. });
  7285. }
  7286. return true;
  7287. } catch (error) {
  7288. throwError(error, 'Indiedb.checkLeftKey');
  7289. return false;
  7290. }
  7291. }
  7292. const website_Indiedb = Indiedb;
  7293. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7294. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7295. privateSet.add(obj);
  7296. }
  7297. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7298. if (privateCollection.has(obj)) {
  7299. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7300. }
  7301. }
  7302. function Keyhub_defineProperty(obj, key, value) {
  7303. if (key in obj) {
  7304. Object.defineProperty(obj, key, {
  7305. value: value,
  7306. enumerable: true,
  7307. configurable: true,
  7308. writable: true
  7309. });
  7310. } else {
  7311. obj[key] = value;
  7312. }
  7313. return obj;
  7314. }
  7315. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7316. if (!privateSet.has(receiver)) {
  7317. throw new TypeError('attempted to get private field on non-instance');
  7318. }
  7319. return fn;
  7320. }
  7321. const Keyhub_defaultTasks = JSON.stringify({
  7322. steam: {
  7323. groupLinks: [],
  7324. wishlistLinks: [],
  7325. curatorLinks: []
  7326. },
  7327. discord: {
  7328. serverLinks: []
  7329. },
  7330. links: []
  7331. });
  7332. var Keyhub_getGiveawayId = new WeakSet();
  7333. var Keyhub_checkLeftKey = new WeakSet();
  7334. var Keyhub_checkLogin = new WeakSet();
  7335. class Keyhub extends website_Website {
  7336. constructor() {
  7337. super(...arguments);
  7338. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7339. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7340. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7341. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7342. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7343. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7344. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7345. }
  7346. static test() {
  7347. return window.location.host === 'key-hub.eu';
  7348. }
  7349. async after() {
  7350. try {
  7351. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7352. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7353. }
  7354. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7355. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7356. }
  7357. } catch (error) {
  7358. throwError(error, 'Keyhub.after');
  7359. }
  7360. }
  7361. init() {
  7362. try {
  7363. const logStatus = scripts_echoLog({
  7364. text: i18n('initing')
  7365. });
  7366. if ($('a[href*="/connect/steam"]').length > 0) {
  7367. window.open('/connect/steam', '_self');
  7368. logStatus.warning(i18n('needLogin'));
  7369. return false;
  7370. }
  7371. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7372. return false;
  7373. }
  7374. $('#VPNoverlay').hide();
  7375. $('#mainArticleSection').show();
  7376. this.initialized = true;
  7377. logStatus.success();
  7378. return true;
  7379. } catch (error) {
  7380. throwError(error, 'Keyhub.init');
  7381. return false;
  7382. }
  7383. }
  7384. async classifyTask(action) {
  7385. try {
  7386. const logStatus = scripts_echoLog({
  7387. text: i18n('getTasksInfo')
  7388. });
  7389. if (action === 'undo') {
  7390. var _GM_getValue;
  7391. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7392. }
  7393. const tasks = $('.task a');
  7394. for (const task of tasks) {
  7395. let link = $(task).attr('href');
  7396. const taskDes = $(task).text().trim();
  7397. if (!link) {
  7398. continue;
  7399. }
  7400. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7401. link = await getRedirectLink(link) || link;
  7402. }
  7403. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7404. window.open(link, '_blank');
  7405. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7406. if (action === 'undo') {
  7407. this.socialTasks.steam.groupLinks.push(link);
  7408. }
  7409. if (action === 'do') {
  7410. this.undoneTasks.steam.groupLinks.push(link);
  7411. }
  7412. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7413. if (action === 'undo') {
  7414. this.socialTasks.steam.wishlistLinks.push(link);
  7415. }
  7416. if (action === 'do') {
  7417. this.undoneTasks.steam.wishlistLinks.push(link);
  7418. }
  7419. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7420. if (action === 'undo') {
  7421. this.socialTasks.steam.curatorLinks.push(link);
  7422. }
  7423. if (action === 'do') {
  7424. this.undoneTasks.steam.curatorLinks.push(link);
  7425. }
  7426. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7427. if (action === 'undo') {
  7428. this.socialTasks.discord.serverLinks.push(link);
  7429. }
  7430. if (action === 'do') {
  7431. this.undoneTasks.discord.serverLinks.push(link);
  7432. }
  7433. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link)) {} else {
  7434. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7435. }
  7436. }
  7437. logStatus.success();
  7438. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7439. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7440. GM_setValue(`khTasks-${this.giveawayId}`, {
  7441. tasks: this.socialTasks,
  7442. time: new Date().getTime()
  7443. });
  7444. return true;
  7445. } catch (error) {
  7446. throwError(error, 'Keyhub.classifyTask');
  7447. return false;
  7448. }
  7449. }
  7450. verifyTask() {
  7451. try {
  7452. scripts_echoLog({
  7453. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7454. });
  7455. $.get(window.location.href, res => {
  7456. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7457. });
  7458. } catch (error) {
  7459. throwError(error, 'keyhub.verifyTask');
  7460. }
  7461. }
  7462. }
  7463. function Keyhub_getGiveawayId2() {
  7464. try {
  7465. var _window$location$href;
  7466. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7467. if (giveawayId) {
  7468. this.giveawayId = giveawayId;
  7469. return true;
  7470. }
  7471. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7472. return false;
  7473. } catch (error) {
  7474. throwError(error, 'Keyhub.getGiveawayId');
  7475. return false;
  7476. }
  7477. }
  7478. async function Keyhub_checkLeftKey2() {
  7479. try {
  7480. if (!globalOptions.other.checkLeftKey) {
  7481. return true;
  7482. }
  7483. const leftKey = $('#keysleft').text().trim();
  7484. if (leftKey === '0') {
  7485. await external_Swal_default().fire({
  7486. icon: 'warning',
  7487. title: i18n('notice'),
  7488. text: i18n('noKeysLeft'),
  7489. confirmButtonText: i18n('confirm'),
  7490. cancelButtonText: i18n('cancel'),
  7491. showCancelButton: true
  7492. }).then(_ref => {
  7493. let {
  7494. value
  7495. } = _ref;
  7496. if (value) {
  7497. window.close();
  7498. }
  7499. });
  7500. }
  7501. return true;
  7502. } catch (error) {
  7503. throwError(error, 'Keyhub.checkLeftKey');
  7504. return false;
  7505. }
  7506. }
  7507. function Keyhub_checkLogin2() {
  7508. try {
  7509. if (!globalOptions.other.checkLogin) {
  7510. return true;
  7511. }
  7512. if ($('a[href*="/connect/steam"]').length > 0) {
  7513. window.open('/connect/steam', '_self');
  7514. }
  7515. return true;
  7516. } catch (error) {
  7517. throwError(error, 'Keyhub.checkLogin');
  7518. return false;
  7519. }
  7520. }
  7521. const website_Keyhub = Keyhub;
  7522. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7523. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7524. privateSet.add(obj);
  7525. }
  7526. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7527. if (privateCollection.has(obj)) {
  7528. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7529. }
  7530. }
  7531. function Givekey_defineProperty(obj, key, value) {
  7532. if (key in obj) {
  7533. Object.defineProperty(obj, key, {
  7534. value: value,
  7535. enumerable: true,
  7536. configurable: true,
  7537. writable: true
  7538. });
  7539. } else {
  7540. obj[key] = value;
  7541. }
  7542. return obj;
  7543. }
  7544. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7545. if (!privateSet.has(receiver)) {
  7546. throw new TypeError('attempted to get private field on non-instance');
  7547. }
  7548. return fn;
  7549. }
  7550. const Givekey_defaultTasks = JSON.stringify({
  7551. steam: {
  7552. groupLinks: [],
  7553. wishlistLinks: [],
  7554. curatorLinks: [],
  7555. curatorLikeLinks: []
  7556. },
  7557. twitter: {
  7558. userLinks: []
  7559. },
  7560. vk: {
  7561. nameLinks: []
  7562. },
  7563. discord: {
  7564. serverLinks: []
  7565. }
  7566. });
  7567. var Givekey_verify = new WeakSet();
  7568. var Givekey_getGiveawayId = new WeakSet();
  7569. var Givekey_checkLeftKey = new WeakSet();
  7570. class Givekey extends website_Website {
  7571. constructor() {
  7572. super(...arguments);
  7573. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7574. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7575. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7576. Givekey_defineProperty(this, 'name', 'Givekey');
  7577. Givekey_defineProperty(this, 'tasks', []);
  7578. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  7579. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  7580. Givekey_defineProperty(this, 'userId', void 0);
  7581. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7582. }
  7583. static test() {
  7584. return window.location.host === 'givekey.ru';
  7585. }
  7586. async after() {
  7587. try {
  7588. await new Promise(resolve => {
  7589. const checker = setInterval(() => {
  7590. if ($('#navbarDropdown').length > 0) {
  7591. clearInterval(checker);
  7592. resolve(true);
  7593. }
  7594. });
  7595. });
  7596. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7597. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7598. }
  7599. } catch (error) {
  7600. throwError(error, 'Givekey.after');
  7601. return false;
  7602. }
  7603. }
  7604. init() {
  7605. try {
  7606. const logStatus = scripts_echoLog({
  7607. text: i18n('initing')
  7608. });
  7609. if ($('a[href*="/auth/steam"]').length > 0) {
  7610. window.open('/auth/steam', '_self');
  7611. logStatus.warning(i18n('needLogin'));
  7612. return false;
  7613. }
  7614. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7615. return false;
  7616. }
  7617. const userId = $('meta[name="user-id"]').attr('content');
  7618. if (!userId) {
  7619. logStatus.error(i18n('getFailed', i18n('userId')));
  7620. return false;
  7621. }
  7622. this.userId = userId;
  7623. this.initialized = true;
  7624. logStatus.success();
  7625. return true;
  7626. } catch (error) {
  7627. throwError(error, 'Givekey.init');
  7628. return false;
  7629. }
  7630. }
  7631. async classifyTask(action) {
  7632. try {
  7633. const logStatus = scripts_echoLog({
  7634. text: i18n('getTasksInfo')
  7635. });
  7636. if (action === 'undo') {
  7637. var _GM_getValue;
  7638. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  7639. }
  7640. const tasks = $('.card-body:has("button") .row');
  7641. for (const task of tasks) {
  7642. const taskEle = $(task);
  7643. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7644. if (isSuccess && action !== 'undo') {
  7645. continue;
  7646. }
  7647. const checkButton = taskEle.find('#task_check');
  7648. const taskId = checkButton.attr('data-id');
  7649. if (taskId) {
  7650. this.tasks.push(taskId);
  7651. }
  7652. if (action === 'verify') {
  7653. continue;
  7654. }
  7655. let href = taskEle.find('a').attr('href') || null;
  7656. const text = taskEle.find('a').text().trim();
  7657. const icon = taskEle.find('i');
  7658. if (!href || !text) {
  7659. continue;
  7660. }
  7661. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7662. href = await getRedirectLink(href);
  7663. }
  7664. if (!href) {
  7665. continue;
  7666. }
  7667. if (/^https?:\/\/vk\.com\//.test(href)) {
  7668. this.socialTasks.vk.nameLinks.push(href);
  7669. if (action === 'do' && !isSuccess) {
  7670. this.undoneTasks.vk.nameLinks.push(href);
  7671. }
  7672. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7673. this.socialTasks.steam.groupLinks.push(href);
  7674. if (action === 'do' && !isSuccess) {
  7675. this.undoneTasks.steam.groupLinks.push(href);
  7676. }
  7677. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7678. this.socialTasks.steam.wishlistLinks.push(href);
  7679. if (action === 'do' && !isSuccess) {
  7680. this.undoneTasks.steam.wishlistLinks.push(href);
  7681. }
  7682. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7683. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7684. this.socialTasks.steam.curatorLinks.push(href);
  7685. if (action === 'do' && !isSuccess) {
  7686. this.undoneTasks.steam.curatorLinks.push(href);
  7687. }
  7688. } else {
  7689. this.socialTasks.steam.curatorLikeLinks.push(href);
  7690. if (action === 'do' && !isSuccess) {
  7691. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7692. }
  7693. }
  7694. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7695. this.socialTasks.twitter.userLinks.push(href);
  7696. if (action === 'do' && !isSuccess) {
  7697. this.undoneTasks.twitter.userLinks.push(href);
  7698. }
  7699. } else if (icon.hasClass('fa-discord')) {
  7700. this.socialTasks.discord.serverLinks.push(href);
  7701. if (action === 'do' && !isSuccess) {
  7702. this.undoneTasks.discord.serverLinks.push(href);
  7703. }
  7704. } else {
  7705. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7706. }
  7707. }
  7708. logStatus.success();
  7709. this.tasks = unique(this.tasks);
  7710. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7711. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7712. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7713. tasks: this.socialTasks,
  7714. time: new Date().getTime()
  7715. });
  7716. return true;
  7717. } catch (error) {
  7718. throwError(error, 'Givekey.classifyTask');
  7719. return false;
  7720. }
  7721. }
  7722. async verifyTask() {
  7723. try {
  7724. if (!this.initialized && !this.init()) {
  7725. return false;
  7726. }
  7727. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7728. return false;
  7729. }
  7730. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7731. const taskLength = this.tasks.length;
  7732. for (let i = 0; i < taskLength; i++) {
  7733. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7734. if (i < taskLength - 1) {
  7735. await delay(15e3);
  7736. }
  7737. }
  7738. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7739. scripts_echoLog({
  7740. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7741. });
  7742. return true;
  7743. } catch (error) {
  7744. throwError(error, 'Givekey.verifyTask');
  7745. return false;
  7746. }
  7747. }
  7748. }
  7749. async function Givekey_verify2(task) {
  7750. try {
  7751. const logStatus = scripts_echoLog({
  7752. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7753. });
  7754. return await new Promise(resolve => {
  7755. $.ajax({
  7756. url: 'https://givekey.ru/giveaway/task',
  7757. method: 'POST',
  7758. data: `id=${task}&user_id=${this.userId}`,
  7759. dataType: 'json',
  7760. headers: {
  7761. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7762. },
  7763. success: data => {
  7764. if (data.btn) {
  7765. $(`button[data-id=${this.userId}]`).html(data.btn);
  7766. }
  7767. if (data.status === 'ok') {
  7768. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7769. logStatus.success();
  7770. resolve(true);
  7771. } else if (data.status === 'end') {
  7772. logStatus.success();
  7773. scripts_echoLog({}).success(data.key);
  7774. resolve(true);
  7775. } else {
  7776. logStatus.error(`Error:${data.msg}`);
  7777. resolve(false);
  7778. }
  7779. },
  7780. error: xhr => {
  7781. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7782. resolve(false);
  7783. }
  7784. });
  7785. });
  7786. } catch (error) {
  7787. throwError(error, 'Givekey.verify');
  7788. return false;
  7789. }
  7790. }
  7791. function Givekey_getGiveawayId2() {
  7792. try {
  7793. var _window$location$href;
  7794. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7795. if (giveawayId) {
  7796. this.giveawayId = giveawayId;
  7797. return true;
  7798. }
  7799. scripts_echoLog({
  7800. text: i18n('getFailed', 'GiveawayId')
  7801. });
  7802. return false;
  7803. } catch (error) {
  7804. throwError(error, 'Givekey.getGiveawayId');
  7805. return false;
  7806. }
  7807. }
  7808. async function Givekey_checkLeftKey2() {
  7809. try {
  7810. if (!globalOptions.other.checkLeftKey) {
  7811. return true;
  7812. }
  7813. if (!$('#keys_count').text()) {
  7814. await external_Swal_default().fire({
  7815. icon: 'warning',
  7816. title: i18n('notice'),
  7817. text: i18n('noKeysLeft'),
  7818. confirmButtonText: i18n('confirm'),
  7819. cancelButtonText: i18n('cancel'),
  7820. showCancelButton: true
  7821. }).then(_ref => {
  7822. let {
  7823. value
  7824. } = _ref;
  7825. if (value) {
  7826. window.close();
  7827. }
  7828. });
  7829. }
  7830. return true;
  7831. } catch (error) {
  7832. throwError(error, 'Givekey.checkLeftKey');
  7833. return false;
  7834. }
  7835. }
  7836. const website_Givekey = Givekey;
  7837. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7838. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7839. privateSet.add(obj);
  7840. }
  7841. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  7842. if (privateCollection.has(obj)) {
  7843. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7844. }
  7845. }
  7846. function GiveeClub_defineProperty(obj, key, value) {
  7847. if (key in obj) {
  7848. Object.defineProperty(obj, key, {
  7849. value: value,
  7850. enumerable: true,
  7851. configurable: true,
  7852. writable: true
  7853. });
  7854. } else {
  7855. obj[key] = value;
  7856. }
  7857. return obj;
  7858. }
  7859. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  7860. if (!privateSet.has(receiver)) {
  7861. throw new TypeError('attempted to get private field on non-instance');
  7862. }
  7863. return fn;
  7864. }
  7865. var GiveeClub_checkLogin = new WeakSet();
  7866. var GiveeClub_getGiveawayId = new WeakSet();
  7867. var GiveeClub_checkLeftKey = new WeakSet();
  7868. class GiveeClub extends GiveawaySu {
  7869. constructor() {
  7870. super(...arguments);
  7871. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  7872. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  7873. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  7874. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  7875. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7876. }
  7877. static test() {
  7878. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7879. }
  7880. async after() {
  7881. try {
  7882. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7883. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7884. }
  7885. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  7886. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7887. }
  7888. } catch (error) {
  7889. throwError(error, 'GiveeClub.after');
  7890. }
  7891. }
  7892. init() {
  7893. try {
  7894. const logStatus = scripts_echoLog({
  7895. text: i18n('initing')
  7896. });
  7897. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7898. logStatus.warning(i18n('needLogin'));
  7899. return false;
  7900. }
  7901. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  7902. return false;
  7903. }
  7904. this.initialized = true;
  7905. logStatus.success();
  7906. return true;
  7907. } catch (error) {
  7908. throwError(error, 'GiveeClub.init');
  7909. return false;
  7910. }
  7911. }
  7912. async classifyTask(action) {
  7913. try {
  7914. const logStatus = scripts_echoLog({
  7915. text: i18n('getTasksInfo')
  7916. });
  7917. if (action === 'undo') {
  7918. var _GM_getValue;
  7919. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7920. return true;
  7921. }
  7922. const pro = [];
  7923. const tasks = $('.event-actions tr');
  7924. for (const task of tasks) {
  7925. pro.push(new Promise(resolve => {
  7926. const taskDes = $(task).find('.event-action-label a');
  7927. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7928. const taskName = taskDes.text().trim();
  7929. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  7930. return resolve(true);
  7931. }
  7932. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7933. if (!taskLink) {
  7934. return resolve(false);
  7935. }
  7936. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7937. this.undoneTasks.steam.groupLinks.push(taskLink);
  7938. } else if (/like.*announcement/gi.test(taskName)) {
  7939. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7940. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7941. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7942. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  7943. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  7944. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7945. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7946. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7947. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7948. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7949. this.undoneTasks.steam.forumLinks.push(taskLink);
  7950. } else if (taskIcon.includes('discord')) {
  7951. this.undoneTasks.discord.serverLinks.push(taskLink);
  7952. } else if (taskIcon.includes('instagram')) {
  7953. this.undoneTasks.instagram.userLinks.push(taskLink);
  7954. } else if (taskIcon.includes('twitch')) {
  7955. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7956. } else if (taskIcon.includes('reddit')) {
  7957. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7958. } else if (/watch.*art/gim.test(taskName)) {
  7959. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7960. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7961. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7962. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7963. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7964. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7965. this.undoneTasks.vk.nameLinks.push(taskLink);
  7966. } else {
  7967. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7968. if (/follow.*button/gim.test(taskName)) {
  7969. this.undoneTasks.steam.followLinks.push(taskLink);
  7970. }
  7971. }
  7972. }
  7973. resolve(true);
  7974. }).catch(error => {
  7975. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7976. return false;
  7977. });
  7978. }));
  7979. }
  7980. await Promise.all(pro);
  7981. logStatus.success();
  7982. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7983. this.socialTasks = this.undoneTasks;
  7984. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7985. tasks: this.socialTasks,
  7986. time: new Date().getTime()
  7987. });
  7988. return true;
  7989. } catch (error) {
  7990. throwError(error, 'GiveeClub.classifyTask');
  7991. return false;
  7992. }
  7993. }
  7994. }
  7995. function GiveeClub_checkLogin2() {
  7996. try {
  7997. if (!globalOptions.other.checkLogin) {
  7998. return true;
  7999. }
  8000. if ($('a[href*="/account/auth"]').length > 0) {
  8001. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8002. }
  8003. return true;
  8004. } catch (error) {
  8005. throwError(error, 'GiveeClub.checkLogin');
  8006. return false;
  8007. }
  8008. }
  8009. function GiveeClub_getGiveawayId2() {
  8010. var _window$location$href;
  8011. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8012. if (giveawayId) {
  8013. this.giveawayId = giveawayId;
  8014. return true;
  8015. }
  8016. scripts_echoLog({
  8017. text: i18n('getFailed', 'GiveawayId')
  8018. });
  8019. return false;
  8020. }
  8021. async function GiveeClub_checkLeftKey2() {
  8022. try {
  8023. if (!globalOptions.other.checkLeftKey) {
  8024. return true;
  8025. }
  8026. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8027. await external_Swal_default().fire({
  8028. icon: 'warning',
  8029. title: i18n('notice'),
  8030. text: i18n('giveawayEnded'),
  8031. confirmButtonText: i18n('confirm'),
  8032. cancelButtonText: i18n('cancel'),
  8033. showCancelButton: true
  8034. }).then(_ref => {
  8035. let {
  8036. value
  8037. } = _ref;
  8038. if (value) {
  8039. window.close();
  8040. }
  8041. });
  8042. }
  8043. return true;
  8044. } catch (error) {
  8045. throwError(error, 'Giveawaysu.checkLeftKey');
  8046. return false;
  8047. }
  8048. }
  8049. const website_GiveeClub = GiveeClub;
  8050. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8051. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8052. privateSet.add(obj);
  8053. }
  8054. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8055. if (privateCollection.has(obj)) {
  8056. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8057. }
  8058. }
  8059. function OpiumPulses_defineProperty(obj, key, value) {
  8060. if (key in obj) {
  8061. Object.defineProperty(obj, key, {
  8062. value: value,
  8063. enumerable: true,
  8064. configurable: true,
  8065. writable: true
  8066. });
  8067. } else {
  8068. obj[key] = value;
  8069. }
  8070. return obj;
  8071. }
  8072. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8073. if (!privateSet.has(receiver)) {
  8074. throw new TypeError('attempted to get private field on non-instance');
  8075. }
  8076. return fn;
  8077. }
  8078. const defaultOptions = {
  8079. maxPoint: '99999999'
  8080. };
  8081. var _toggleTask = new WeakSet();
  8082. var OpiumPulses_checkLogin = new WeakSet();
  8083. class OpiumPulses {
  8084. constructor() {
  8085. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8086. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8087. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8088. OpiumPulses_defineProperty(this, 'options', {
  8089. ...defaultOptions,
  8090. ...GM_getValue('OpiumPulsesOptions')
  8091. });
  8092. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8093. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8094. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8095. }
  8096. static test() {
  8097. return window.location.host === 'www.opiumpulses.com';
  8098. }
  8099. async after() {
  8100. try {
  8101. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8102. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8103. }
  8104. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8105. } catch (error) {
  8106. throwError(error, 'OpiumPulses.after');
  8107. }
  8108. }
  8109. async doFreeTask() {
  8110. try {
  8111. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8112. } catch (error) {
  8113. throwError(error, 'OpiumPulses.doFreeTask');
  8114. }
  8115. }
  8116. async doPointTask() {
  8117. try {
  8118. var _$$text$match;
  8119. 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);
  8120. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8121. } catch (error) {
  8122. throwError(error, 'OpiumPulses.doPointTask');
  8123. }
  8124. }
  8125. init() {
  8126. return true;
  8127. }
  8128. classifyTask() {
  8129. return true;
  8130. }
  8131. }
  8132. async function _toggleTask2(type) {
  8133. try {
  8134. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8135. for (const item of items) {
  8136. var _$$find$text$match;
  8137. 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);
  8138. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8139. if (type === 'points' && needPoints > this.myPoints) {
  8140. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8141. } else if (type === 'points' && !needPoints) {
  8142. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8143. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8144. var _aElement$attr;
  8145. const logStatus = scripts_echoLog({
  8146. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8147. });
  8148. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8149. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8150. var _aElement$attr2, _aElement$attr2$match;
  8151. 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];
  8152. if (giveawayId) {
  8153. checkUser(giveawayId);
  8154. }
  8155. }
  8156. if (!aElement.attr('href')) {
  8157. logStatus.error('Error: No "href".');
  8158. continue;
  8159. }
  8160. const {
  8161. result,
  8162. statusText,
  8163. status,
  8164. data
  8165. } = await tools_httpRequest({
  8166. url: aElement.attr('href'),
  8167. method: 'GET'
  8168. });
  8169. if (result === 'Success') {
  8170. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8171. var _data$responseText$ma;
  8172. logStatus.success();
  8173. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8174. if (type === 'points' && points) {
  8175. this.myPoints = parseInt(points, 10);
  8176. }
  8177. } else {
  8178. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8179. }
  8180. } else {
  8181. logStatus.error(`${result}:${statusText}(${status})`);
  8182. }
  8183. }
  8184. }
  8185. scripts_echoLog({
  8186. text: '-----END-----'
  8187. });
  8188. } catch (error) {
  8189. throwError(error, 'OpiumPulses.toggleTask');
  8190. }
  8191. }
  8192. function OpiumPulses_checkLogin2() {
  8193. try {
  8194. if (!globalOptions.other.checkLogin) {
  8195. return true;
  8196. }
  8197. if ($('a[href*="/site/login"]').length > 1) {
  8198. window.open('/site/login', '_self');
  8199. }
  8200. return true;
  8201. } catch (error) {
  8202. throwError(error, 'OpiumPulses.checkLogin');
  8203. return false;
  8204. }
  8205. }
  8206. const website_OpiumPulses = OpiumPulses;
  8207. const external_dayjs_namespaceObject = dayjs;
  8208. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8209. const leftKeyChecker = {
  8210. async classify(link) {
  8211. try {
  8212. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8213. return await this.giveawaySu(link);
  8214. }
  8215. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8216. return await this.giveeClub(link);
  8217. }
  8218. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8219. return await this.gleam(link);
  8220. }
  8221. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8222. return await this.indieDb(link);
  8223. }
  8224. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8225. return await this.keyhub(link);
  8226. }
  8227. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8228. return await this.opquests(link);
  8229. }
  8230. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8231. return await this.itch(link);
  8232. }
  8233. return false;
  8234. } catch (error) {
  8235. throwError(error, 'leftKeyChecker.classify');
  8236. return false;
  8237. }
  8238. },
  8239. async giveawaySu(link) {
  8240. try {
  8241. const {
  8242. result,
  8243. data
  8244. } = await tools_httpRequest({
  8245. url: link,
  8246. method: 'GET'
  8247. });
  8248. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8249. if (data.responseText.includes('class="steam-login"')) {
  8250. return false;
  8251. }
  8252. if (data.responseText.includes('class="giveaway-ended"')) {
  8253. return 'Ended';
  8254. }
  8255. return 'Active';
  8256. }
  8257. return false;
  8258. } catch (error) {
  8259. throwError(error, 'leftKeyChecker.giveawaySu');
  8260. return false;
  8261. }
  8262. },
  8263. async giveeClub(link) {
  8264. try {
  8265. const {
  8266. result,
  8267. data
  8268. } = await tools_httpRequest({
  8269. url: link,
  8270. method: 'GET'
  8271. });
  8272. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8273. if (data.responseText.includes('class="event-winner"')) {
  8274. return 'Won';
  8275. }
  8276. if (data.responseText.includes('class="event-ended"')) {
  8277. return 'Ended';
  8278. }
  8279. return 'Active';
  8280. }
  8281. return false;
  8282. } catch (error) {
  8283. throwError(error, 'leftKeyChecker.giveeClub');
  8284. return false;
  8285. }
  8286. },
  8287. async gleam(link) {
  8288. try {
  8289. const {
  8290. result,
  8291. data
  8292. } = await tools_httpRequest({
  8293. url: link,
  8294. method: 'GET'
  8295. });
  8296. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8297. var _data$responseText$ma, _$$attr, _$$attr$match;
  8298. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8299. return 'Won';
  8300. }
  8301. 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];
  8302. if (!campaignDiv) {
  8303. return false;
  8304. }
  8305. 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];
  8306. if (!campaignString) {
  8307. return false;
  8308. }
  8309. const {
  8310. campaign
  8311. } = JSON.parse(campaignString);
  8312. if (campaign.banned) {
  8313. return 'Banned';
  8314. }
  8315. if (campaign.finished) {
  8316. return 'Ended';
  8317. }
  8318. if (campaign.paused) {
  8319. return 'Paused';
  8320. }
  8321. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8322. return 'NotStart';
  8323. }
  8324. return 'Active';
  8325. }
  8326. return false;
  8327. } catch (error) {
  8328. throwError(error, 'leftKeyChecker.gleam');
  8329. return false;
  8330. }
  8331. },
  8332. async indieDb(link) {
  8333. try {
  8334. const {
  8335. result,
  8336. data
  8337. } = await tools_httpRequest({
  8338. url: link,
  8339. method: 'GET'
  8340. });
  8341. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8342. if (data.responseText.includes('Congrats you WON')) {
  8343. return 'Won';
  8344. }
  8345. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8346. return 'Ended';
  8347. }
  8348. return 'Active';
  8349. }
  8350. return false;
  8351. } catch (error) {
  8352. throwError(error, 'leftKeyChecker.indieDb');
  8353. return false;
  8354. }
  8355. },
  8356. async keyhub(link) {
  8357. try {
  8358. const {
  8359. result,
  8360. data
  8361. } = await tools_httpRequest({
  8362. url: link,
  8363. method: 'GET'
  8364. });
  8365. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8366. var _data$responseText$ma2;
  8367. 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];
  8368. if (!keysleft) {
  8369. return false;
  8370. }
  8371. if (keysleft === '0') {
  8372. return 'Ended';
  8373. }
  8374. return `Active(${keysleft})`;
  8375. }
  8376. return false;
  8377. } catch (error) {
  8378. throwError(error, 'leftKeyChecker.keyhub');
  8379. return false;
  8380. }
  8381. },
  8382. async opquests(link) {
  8383. try {
  8384. const {
  8385. result,
  8386. data
  8387. } = await tools_httpRequest({
  8388. url: link,
  8389. method: 'GET'
  8390. });
  8391. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8392. var _data$responseText$ma3;
  8393. 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];
  8394. if (!keysleft) {
  8395. return false;
  8396. }
  8397. if (keysleft === '0') {
  8398. return 'Ended';
  8399. }
  8400. return `Active(${keysleft})`;
  8401. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8402. return 'Ended';
  8403. }
  8404. return false;
  8405. } catch (error) {
  8406. throwError(error, 'leftKeyChecker.opquests');
  8407. return false;
  8408. }
  8409. },
  8410. async itch(link) {
  8411. try {
  8412. const {
  8413. result,
  8414. data
  8415. } = await tools_httpRequest({
  8416. url: link,
  8417. method: 'GET'
  8418. });
  8419. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8420. var _data$responseText$ma4;
  8421. 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];
  8422. if (!endDate) {
  8423. return false;
  8424. }
  8425. if (new Date().getTime() > new Date(endDate).getTime()) {
  8426. return 'Ended';
  8427. }
  8428. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8429. }
  8430. return false;
  8431. } catch (error) {
  8432. throwError(error, 'leftKeyChecker.opquests');
  8433. return false;
  8434. }
  8435. }
  8436. };
  8437. const website_leftKeyChecker = leftKeyChecker;
  8438. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8439. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8440. privateSet.add(obj);
  8441. }
  8442. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8443. if (privateCollection.has(obj)) {
  8444. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8445. }
  8446. }
  8447. function Keylol_defineProperty(obj, key, value) {
  8448. if (key in obj) {
  8449. Object.defineProperty(obj, key, {
  8450. value: value,
  8451. enumerable: true,
  8452. configurable: true,
  8453. writable: true
  8454. });
  8455. } else {
  8456. obj[key] = value;
  8457. }
  8458. return obj;
  8459. }
  8460. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8461. if (!privateSet.has(receiver)) {
  8462. throw new TypeError('attempted to get private field on non-instance');
  8463. }
  8464. return fn;
  8465. }
  8466. const Keylol_defaultTasks = JSON.stringify({
  8467. steam: {
  8468. groupLinks: [],
  8469. wishlistLinks: [],
  8470. curatorLinks: [],
  8471. curatorLikeLinks: [],
  8472. followLinks: [],
  8473. forumLinks: [],
  8474. announcementLinks: [],
  8475. workshopVoteLinks: [],
  8476. licenseLinks: []
  8477. },
  8478. discord: {
  8479. serverLinks: []
  8480. },
  8481. instagram: {
  8482. userLinks: []
  8483. },
  8484. vk: {
  8485. nameLinks: []
  8486. },
  8487. twitch: {
  8488. channelLinks: []
  8489. },
  8490. reddit: {
  8491. redditLinks: []
  8492. },
  8493. twitter: {
  8494. userLinks: [],
  8495. retweetLinks: []
  8496. },
  8497. youtube: {
  8498. channelLinks: [],
  8499. likeLinks: []
  8500. }
  8501. });
  8502. var _addBtn = new WeakSet();
  8503. class Keylol extends website_Website {
  8504. constructor() {
  8505. super(...arguments);
  8506. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8507. Keylol_defineProperty(this, 'name', 'Keylol');
  8508. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  8509. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  8510. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8511. }
  8512. static test() {
  8513. var _$$eq$attr;
  8514. 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'));
  8515. }
  8516. init() {
  8517. return true;
  8518. }
  8519. after() {
  8520. try {
  8521. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8522. const mainPost = $(selector);
  8523. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8524. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8525. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8526. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8527. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8528. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8529. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8530. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8531. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8532. if (discordLinks.length > 0) {
  8533. for (const discordLink of discordLinks) {
  8534. const link = $(discordLink).attr('href');
  8535. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8536. continue;
  8537. }
  8538. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8539. }
  8540. }
  8541. if (redditLinks.length > 0) {
  8542. for (const redditLink of redditLinks) {
  8543. const link = $(redditLink).attr('href');
  8544. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8545. continue;
  8546. }
  8547. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8548. }
  8549. }
  8550. if (insLinks.length > 0) {
  8551. for (const insLink of insLinks) {
  8552. const link = $(insLink).attr('href');
  8553. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8554. continue;
  8555. }
  8556. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8557. }
  8558. }
  8559. if (twitterLinks.length > 0) {
  8560. for (const twitterLink of twitterLinks) {
  8561. const link = $(twitterLink).attr('href');
  8562. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8563. continue;
  8564. }
  8565. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8566. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8567. } else {
  8568. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8569. }
  8570. }
  8571. }
  8572. if (twitchLinks.length > 0) {
  8573. for (const twitchLink of twitchLinks) {
  8574. const link = $(twitchLink).attr('href');
  8575. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8576. continue;
  8577. }
  8578. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8579. }
  8580. }
  8581. if (vkLinks.length > 0) {
  8582. for (const vkLink of vkLinks) {
  8583. const link = $(vkLink).attr('href');
  8584. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8585. continue;
  8586. }
  8587. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8588. }
  8589. }
  8590. if (steamStoreLinks.length > 0) {
  8591. for (const steamStoreLink of steamStoreLinks) {
  8592. const link = $(steamStoreLink).attr('href');
  8593. if (!link) {
  8594. continue;
  8595. }
  8596. if (/app\/[\d]+/.test(link)) {
  8597. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8598. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8599. } else if (/curator\/[\d]+/.test(link)) {
  8600. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8601. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8602. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8603. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8604. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8605. }
  8606. }
  8607. }
  8608. if (steamCommunityLinks.length > 0) {
  8609. for (const steamCommunityLink of steamCommunityLinks) {
  8610. const link = $(steamCommunityLink).attr('href');
  8611. if (!link) {
  8612. continue;
  8613. }
  8614. if (/groups\/.+/.test(link)) {
  8615. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8616. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8617. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8618. }
  8619. }
  8620. }
  8621. if (ytbLinks.length > 0) {
  8622. for (const ytbLink of ytbLinks) {
  8623. const link = $(ytbLink).attr('href');
  8624. if (!link) {
  8625. continue;
  8626. }
  8627. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8628. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8629. }
  8630. }
  8631. const giveawayLinks = mainPost.find('a[href*="giveaway.su/giveaway/view/"],a[href*="givee.club/"],a[href*="gleam.io/"],a[href*="www.indiedb.com/giveaways/"],a[href*="key-hub.eu/giveaway/"],a[href*="opquests.com/quests/"],a[href*="itch.io/s/"]');
  8632. if (giveawayLinks.length > 0) {
  8633. for (const giveawayLink of giveawayLinks) {
  8634. const link = $(giveawayLink).attr('href');
  8635. if (!link) {
  8636. continue;
  8637. }
  8638. website_leftKeyChecker.classify(link).then(status => {
  8639. if (!status) {
  8640. return;
  8641. }
  8642. if (/^Active/.test(status)) {
  8643. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  8644. return;
  8645. }
  8646. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  8647. }).catch(error => {
  8648. throwError(error, 'keylol.after -> leftKeyChecker');
  8649. });
  8650. }
  8651. }
  8652. if (this.name === 'Keylol') {
  8653. const asfLinks = mainPost.find('a[href^="#asf"]');
  8654. if (asfLinks.length > 0) {
  8655. for (const asfLink of asfLinks) {
  8656. const link = $(asfLink).attr('href');
  8657. if (!link) {
  8658. continue;
  8659. }
  8660. 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', link.replace('#asf', ''));
  8661. }
  8662. }
  8663. }
  8664. } catch (error) {
  8665. throwError(error, 'keylol.after');
  8666. }
  8667. }
  8668. classifyTask(action) {
  8669. try {
  8670. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  8671. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  8672. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8673. for (const btn of selectedBtns) {
  8674. const button = $(btn);
  8675. const social = button.attr('data-social');
  8676. const type = button.attr('data-type');
  8677. const link = button.attr('data-link');
  8678. if (!(social && type && link)) {
  8679. continue;
  8680. }
  8681. if (action === 'do') {
  8682. this.undoneTasks[social][type].push(link);
  8683. }
  8684. if (action === 'undo') {
  8685. this.socialTasks[social][type].push(link);
  8686. }
  8687. }
  8688. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8689. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8690. return true;
  8691. } catch (error) {
  8692. throwError(error, 'Keylol.classifyTask');
  8693. return false;
  8694. }
  8695. }
  8696. selectAll() {
  8697. try {
  8698. $('.auto-task-keylol').attr('selected', 'selected');
  8699. } catch (error) {
  8700. throwError(error, 'Keylol.selectAll');
  8701. }
  8702. }
  8703. selectNone() {
  8704. try {
  8705. $('.auto-task-keylol').removeAttr('selected');
  8706. } catch (error) {
  8707. throwError(error, 'Keylol.selectNone');
  8708. }
  8709. }
  8710. invertSelect() {
  8711. try {
  8712. $('.auto-task-keylol').each((index, element) => {
  8713. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8714. });
  8715. } catch (error) {
  8716. throwError(error, 'Keylol.invertSelect');
  8717. }
  8718. }
  8719. }
  8720. function _addBtn2(before, social, linkType, link) {
  8721. try {
  8722. $(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>`);
  8723. } catch (error) {
  8724. throwError(error, 'keylol.addBtn');
  8725. }
  8726. }
  8727. const website_Keylol = Keylol;
  8728. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8729. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8730. privateSet.add(obj);
  8731. }
  8732. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8733. if (privateCollection.has(obj)) {
  8734. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8735. }
  8736. }
  8737. function Opquests_defineProperty(obj, key, value) {
  8738. if (key in obj) {
  8739. Object.defineProperty(obj, key, {
  8740. value: value,
  8741. enumerable: true,
  8742. configurable: true,
  8743. writable: true
  8744. });
  8745. } else {
  8746. obj[key] = value;
  8747. }
  8748. return obj;
  8749. }
  8750. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8751. if (!privateSet.has(receiver)) {
  8752. throw new TypeError('attempted to get private field on non-instance');
  8753. }
  8754. return fn;
  8755. }
  8756. const Opquests_defaultTasks = {
  8757. steam: {
  8758. groupLinks: [],
  8759. wishlistLinks: [],
  8760. followLinks: [],
  8761. curatorLikeLinks: []
  8762. }
  8763. };
  8764. var Opquests_getGiveawayId = new WeakSet();
  8765. var Opquests_checkLogin = new WeakSet();
  8766. class Opquests extends website_Website {
  8767. constructor() {
  8768. super(...arguments);
  8769. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8770. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8771. Opquests_defineProperty(this, 'name', 'Opquests');
  8772. Opquests_defineProperty(this, 'undoneTasks', {
  8773. ...Opquests_defaultTasks
  8774. });
  8775. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8776. }
  8777. static test() {
  8778. return window.location.host === 'opquests.com';
  8779. }
  8780. async after() {
  8781. try {
  8782. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8783. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8784. }
  8785. } catch (error) {
  8786. throwError(error, 'Opquests.after');
  8787. }
  8788. }
  8789. init() {
  8790. try {
  8791. const logStatus = scripts_echoLog({
  8792. text: i18n('initing')
  8793. });
  8794. if ($('a[href*="/auth/redirect"]').length > 0) {
  8795. window.open('/auth/redirect', '_self');
  8796. logStatus.warning(i18n('needLogin'));
  8797. return false;
  8798. }
  8799. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8800. return false;
  8801. }
  8802. this.initialized = true;
  8803. logStatus.success();
  8804. return true;
  8805. } catch (error) {
  8806. throwError(error, 'Opquests.init');
  8807. return false;
  8808. }
  8809. }
  8810. async classifyTask(action) {
  8811. try {
  8812. if (action === 'undo') {
  8813. scripts_echoLog({
  8814. text: i18n('cannotUndo')
  8815. });
  8816. return false;
  8817. }
  8818. const logStatus = scripts_echoLog({
  8819. text: i18n('getTasksInfo')
  8820. });
  8821. const tasks = $('.w-full:contains("Validate") .items-center');
  8822. for (const task of tasks) {
  8823. const link = $(task).find('a:contains("Open")').attr('href');
  8824. const taskDes = $(task).find('div').eq(1).text().trim();
  8825. if (!link) {
  8826. continue;
  8827. }
  8828. if (/steamcommunity\.com\/groups\//.test(link)) {
  8829. this.undoneTasks.steam.groupLinks.push(link);
  8830. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8831. if (/wishlist/gim.test(taskDes)) {
  8832. this.undoneTasks.steam.wishlistLinks.push(link);
  8833. } else if (/follow/gim.test(taskDes)) {
  8834. this.undoneTasks.steam.followLinks.push(link);
  8835. }
  8836. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  8837. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8838. } else {
  8839. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8840. }
  8841. }
  8842. logStatus.success();
  8843. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8844. return true;
  8845. } catch (error) {
  8846. throwError(error, 'Opquests.classifyTask');
  8847. return false;
  8848. }
  8849. }
  8850. }
  8851. function Opquests_getGiveawayId2() {
  8852. try {
  8853. var _window$location$href;
  8854. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8855. if (giveawayId) {
  8856. this.giveawayId = giveawayId;
  8857. return true;
  8858. }
  8859. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8860. return false;
  8861. } catch (error) {
  8862. throwError(error, 'Opquests.getGiveawayId');
  8863. return false;
  8864. }
  8865. }
  8866. function Opquests_checkLogin2() {
  8867. try {
  8868. if (!globalOptions.other.checkLogin) {
  8869. return true;
  8870. }
  8871. if ($('a[href*="/auth/redirect"]').length > 0) {
  8872. window.open('/auth/redirect', '_self');
  8873. }
  8874. return true;
  8875. } catch (error) {
  8876. throwError(error, 'Opquests.checkLogin');
  8877. return false;
  8878. }
  8879. }
  8880. const website_Opquests = Opquests;
  8881. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  8882. Gleam_checkPrivateRedeclaration(obj, privateSet);
  8883. privateSet.add(obj);
  8884. }
  8885. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  8886. if (privateCollection.has(obj)) {
  8887. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8888. }
  8889. }
  8890. function Gleam_defineProperty(obj, key, value) {
  8891. if (key in obj) {
  8892. Object.defineProperty(obj, key, {
  8893. value: value,
  8894. enumerable: true,
  8895. configurable: true,
  8896. writable: true
  8897. });
  8898. } else {
  8899. obj[key] = value;
  8900. }
  8901. return obj;
  8902. }
  8903. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  8904. if (!privateSet.has(receiver)) {
  8905. throw new TypeError('attempted to get private field on non-instance');
  8906. }
  8907. return fn;
  8908. }
  8909. const Gleam_defaultTasks = JSON.stringify({
  8910. steam: {
  8911. groupLinks: [],
  8912. wishlistLinks: [],
  8913. followLinks: [],
  8914. curatorLinks: [],
  8915. curatorLikeLinks: []
  8916. },
  8917. twitter: {
  8918. userLinks: [],
  8919. retweetLinks: []
  8920. },
  8921. twitch: {
  8922. channelLinks: []
  8923. },
  8924. discord: {
  8925. serverLinks: []
  8926. },
  8927. youtube: {
  8928. channelLinks: []
  8929. },
  8930. extra: {
  8931. gleam: []
  8932. }
  8933. });
  8934. const Gleam_defaultOptions = {
  8935. vlootUsername: '',
  8936. gameroundUsername: ''
  8937. };
  8938. var _checkSync = new WeakSet();
  8939. var _doGleamTask = new WeakSet();
  8940. var Gleam_getGiveawayId = new WeakSet();
  8941. var _getGleamLink = new WeakSet();
  8942. var Gleam_checkLeftKey = new WeakSet();
  8943. class Gleam extends website_Website {
  8944. constructor() {
  8945. super(...arguments);
  8946. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  8947. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  8948. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  8949. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  8950. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  8951. Gleam_defineProperty(this, 'name', 'Gleam');
  8952. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  8953. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  8954. Gleam_defineProperty(this, 'options', {
  8955. ...Gleam_defaultOptions,
  8956. ...GM_getValue('GleamOptions')
  8957. });
  8958. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8959. }
  8960. static test() {
  8961. return window.location.host === 'gleam.io';
  8962. }
  8963. async after() {
  8964. try {
  8965. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8966. const checkComplete = setInterval(() => {
  8967. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8968. clearInterval(checkComplete);
  8969. window.close();
  8970. }
  8971. });
  8972. for (const task of $('.entry-content .entry-method')) {
  8973. const taskInfo = $(task).find('.user-links');
  8974. const expandInfo = $(task).find('.expandable');
  8975. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8976. if (aElements.length > 0) {
  8977. for (const element of aElements) {
  8978. const $element = $(element);
  8979. const href = $element.attr('href');
  8980. $element.removeAttr('href')[0].click();
  8981. $element.attr('href', href);
  8982. await delay(1e3);
  8983. }
  8984. }
  8985. taskInfo[0].click();
  8986. await delay(1e3);
  8987. }
  8988. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8989. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  8990. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8991. }
  8992. } catch (error) {
  8993. throwError(error, 'Gleam.after');
  8994. return false;
  8995. }
  8996. }
  8997. init() {
  8998. try {
  8999. const logStatus = scripts_echoLog({
  9000. text: i18n('initing')
  9001. });
  9002. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9003. return false;
  9004. }
  9005. this.initialized = true;
  9006. logStatus.success();
  9007. return true;
  9008. } catch (error) {
  9009. throwError(error, 'Gleam.init');
  9010. return false;
  9011. }
  9012. }
  9013. async classifyTask(action) {
  9014. try {
  9015. const logStatus = scripts_echoLog({
  9016. text: i18n('getTasksInfo')
  9017. });
  9018. if (action === 'undo') {
  9019. var _GM_getValue;
  9020. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9021. }
  9022. const tasks = $('.entry-content .entry-method');
  9023. for (const task of tasks) {
  9024. var _socialIcon$attr;
  9025. const $task = $(task);
  9026. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9027. continue;
  9028. }
  9029. const socialIcon = $task.find('.icon-wrapper i');
  9030. const taskInfo = $task.find('.user-links');
  9031. const taskText = taskInfo.text().trim();
  9032. const expandInfo = $task.find('.expandable');
  9033. const aElements = expandInfo.find('a.btn');
  9034. if (aElements.length > 0) {
  9035. for (const element of aElements) {
  9036. const $element = $(element);
  9037. const href = $element.attr('href');
  9038. $element.removeAttr('href')[0].click();
  9039. $element.attr('href', href);
  9040. }
  9041. }
  9042. if (socialIcon.hasClass('fa-twitter')) {
  9043. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9044. if (!link) {
  9045. continue;
  9046. }
  9047. if (/follow/gi.test(taskText)) {
  9048. if (action === 'undo') {
  9049. this.socialTasks.twitter.userLinks.push(link);
  9050. }
  9051. if (action === 'do') {
  9052. this.undoneTasks.twitter.userLinks.push(link);
  9053. }
  9054. } else if (/retweet/gim.test(taskText)) {
  9055. if (action === 'undo') {
  9056. this.socialTasks.twitter.retweetLinks.push(link);
  9057. }
  9058. if (action === 'do') {
  9059. this.undoneTasks.twitter.retweetLinks.push(link);
  9060. }
  9061. }
  9062. } else if (socialIcon.hasClass('fa-twitch')) {
  9063. if (/follow/gim.test(taskText)) {
  9064. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9065. if (!link) {
  9066. continue;
  9067. }
  9068. if (action === 'undo') {
  9069. this.socialTasks.twitch.channelLinks.push(link);
  9070. }
  9071. if (action === 'do') {
  9072. this.undoneTasks.twitch.channelLinks.push(link);
  9073. }
  9074. }
  9075. } else if (socialIcon.hasClass('fa-discord')) {
  9076. if (/join/gim.test(taskText)) {
  9077. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9078. if (!link) {
  9079. var _$task$find$attr, _$task$find$attr$matc;
  9080. 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];
  9081. if (!ggLink) {
  9082. continue;
  9083. }
  9084. link = `https://discord.com/invite/${ggLink}`;
  9085. }
  9086. if (action === 'undo') {
  9087. this.socialTasks.discord.serverLinks.push(link);
  9088. }
  9089. if (action === 'do') {
  9090. this.undoneTasks.discord.serverLinks.push(link);
  9091. }
  9092. }
  9093. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9094. continue;
  9095. } else if (socialIcon.hasClass('fa-youtube')) {
  9096. if (/subscribe/gim.test(taskText)) {
  9097. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9098. if (!link) {
  9099. continue;
  9100. }
  9101. if (action === 'undo') {
  9102. this.socialTasks.youtube.channelLinks.push(link);
  9103. }
  9104. if (action === 'do') {
  9105. this.undoneTasks.youtube.channelLinks.push(link);
  9106. }
  9107. }
  9108. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9109. if (/join.*group/gi.test(taskText)) {
  9110. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9111. if (!link) {
  9112. continue;
  9113. }
  9114. if (action === 'undo') {
  9115. this.socialTasks.steam.groupLinks.push(link);
  9116. }
  9117. if (action === 'do') {
  9118. this.undoneTasks.steam.groupLinks.push(link);
  9119. }
  9120. } else if (/follow.*curator/gi.test(taskText)) {
  9121. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9122. if (!link) {
  9123. continue;
  9124. }
  9125. if (action === 'undo') {
  9126. this.socialTasks.steam.curatorLinks.push(link);
  9127. }
  9128. if (action === 'do') {
  9129. this.undoneTasks.steam.curatorLinks.push(link);
  9130. }
  9131. }
  9132. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9133. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9134. for (const button of continueBtn) {
  9135. button.click();
  9136. await delay(500);
  9137. expandInfo.find('input').val(this.options.vlootUsername);
  9138. }
  9139. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9140. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9141. for (const button of continueBtn) {
  9142. button.click();
  9143. await delay(500);
  9144. expandInfo.find('input').val(this.options.gameroundUsername);
  9145. }
  9146. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9147. if (action !== 'do') {
  9148. continue;
  9149. }
  9150. const link = aElements.attr('href');
  9151. if (!link) {
  9152. continue;
  9153. }
  9154. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9155. if (!gleamLink) {
  9156. continue;
  9157. }
  9158. this.undoneTasks.extra.gleam.push(gleamLink);
  9159. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-telegram-plane') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  9160. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9161. }
  9162. }
  9163. logStatus.success();
  9164. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9165. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9166. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9167. tasks: this.socialTasks,
  9168. time: new Date().getTime()
  9169. });
  9170. return true;
  9171. } catch (error) {
  9172. throwError(error, 'Gleam.classifyTask');
  9173. return false;
  9174. }
  9175. }
  9176. async extraDoTask(_ref) {
  9177. let {
  9178. gleam
  9179. } = _ref;
  9180. try {
  9181. const pro = [];
  9182. for (const link of gleam) {
  9183. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9184. }
  9185. return Promise.all(pro).then(() => true);
  9186. } catch (error) {
  9187. throwError(error, 'Gleam.extraDoTask');
  9188. return false;
  9189. }
  9190. }
  9191. async verifyTask() {
  9192. try {
  9193. scripts_echoLog({
  9194. text: `${i18n('verifyingTask')}...`
  9195. });
  9196. const tasks = $('.entry-content .entry-method');
  9197. for (const task of tasks) {
  9198. const $task = $(task);
  9199. if ($task.find('i.fa-question').length === 0) {
  9200. continue;
  9201. }
  9202. const taskInfo = $task.find('.user-links');
  9203. taskInfo[0].click();
  9204. await delay(500);
  9205. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9206. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9207. for (const button of continueBtn) {
  9208. button.click();
  9209. await delay(500);
  9210. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9211. }
  9212. }
  9213. scripts_echoLog({
  9214. text: i18n('verifiedGleamTasks')
  9215. });
  9216. } catch (error) {
  9217. throwError(error, 'Gleam.verifyTask');
  9218. return false;
  9219. }
  9220. }
  9221. }
  9222. async function _checkSync2() {
  9223. try {
  9224. return await new Promise(resolve => {
  9225. const checker = setInterval(() => {
  9226. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9227. clearInterval(checker);
  9228. resolve(true);
  9229. }
  9230. }, 500);
  9231. });
  9232. } catch (error) {
  9233. throwError(error, 'Gleam.checkSync');
  9234. return false;
  9235. }
  9236. }
  9237. async function _doGleamTask2(link) {
  9238. try {
  9239. const logStatus = scripts_echoLog({
  9240. text: i18n('doingGleamTask')
  9241. });
  9242. return await new Promise(resolve => {
  9243. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9244. active: true,
  9245. insert: true,
  9246. setParent: true
  9247. }).onclose = () => {
  9248. logStatus.success();
  9249. resolve(true);
  9250. };
  9251. });
  9252. } catch (error) {
  9253. throwError(error, 'Gleam.doGleamTask');
  9254. return false;
  9255. }
  9256. }
  9257. function Gleam_getGiveawayId2() {
  9258. try {
  9259. const giveawayId = window.location.pathname;
  9260. if (giveawayId) {
  9261. this.giveawayId = giveawayId;
  9262. return true;
  9263. }
  9264. scripts_echoLog({
  9265. text: i18n('getFailed', 'GiveawayId')
  9266. });
  9267. return false;
  9268. } catch (error) {
  9269. throwError(error, 'Gleam.getGiveawayId');
  9270. return false;
  9271. }
  9272. }
  9273. async function _getGleamLink2(link) {
  9274. try {
  9275. const logStatus = scripts_echoLog({
  9276. text: i18n('gettingGleamLink')
  9277. });
  9278. const {
  9279. result,
  9280. statusText,
  9281. status,
  9282. data
  9283. } = await tools_httpRequest({
  9284. url: link,
  9285. method: 'GET'
  9286. });
  9287. if (result === 'Success') {
  9288. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9289. var _data$responseText$ma;
  9290. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9291. if (gleamLink) {
  9292. logStatus.success();
  9293. return gleamLink;
  9294. }
  9295. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9296. return false;
  9297. }
  9298. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9299. return false;
  9300. }
  9301. logStatus.error(`${result}:${statusText}(${status})`);
  9302. return false;
  9303. } catch (error) {
  9304. throwError(error, 'Gleam.getGleamLink');
  9305. return false;
  9306. }
  9307. }
  9308. async function Gleam_checkLeftKey2() {
  9309. try {
  9310. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9311. if (!globalOptions.other.checkLeftKey) {
  9312. return true;
  9313. }
  9314. 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];
  9315. if (!campaignString) {
  9316. return false;
  9317. }
  9318. const {
  9319. campaign,
  9320. incentive
  9321. } = JSON.parse(campaignString);
  9322. 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];
  9323. let ownedKey = false;
  9324. if (controllerString) {
  9325. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9326. 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) {
  9327. ownedKey = true;
  9328. }
  9329. }
  9330. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9331. await external_Swal_default().fire({
  9332. icon: 'warning',
  9333. title: i18n('notice'),
  9334. text: i18n('giveawayNotWork'),
  9335. confirmButtonText: i18n('confirm'),
  9336. cancelButtonText: i18n('cancel'),
  9337. showCancelButton: true
  9338. }).then(_ref2 => {
  9339. let {
  9340. value
  9341. } = _ref2;
  9342. if (value) {
  9343. window.close();
  9344. }
  9345. });
  9346. }
  9347. return true;
  9348. } catch (error) {
  9349. throwError(error, 'Gleam.checkLeftKey');
  9350. return false;
  9351. }
  9352. }
  9353. const website_Gleam = Gleam;
  9354. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9355. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9356. privateSet.add(obj);
  9357. }
  9358. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9359. if (privateCollection.has(obj)) {
  9360. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9361. }
  9362. }
  9363. function SweepWidget_defineProperty(obj, key, value) {
  9364. if (key in obj) {
  9365. Object.defineProperty(obj, key, {
  9366. value: value,
  9367. enumerable: true,
  9368. configurable: true,
  9369. writable: true
  9370. });
  9371. } else {
  9372. obj[key] = value;
  9373. }
  9374. return obj;
  9375. }
  9376. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9377. if (!privateSet.has(receiver)) {
  9378. throw new TypeError('attempted to get private field on non-instance');
  9379. }
  9380. return fn;
  9381. }
  9382. const SweepWidget_defaultOptions = {
  9383. username: '',
  9384. email: ''
  9385. };
  9386. var SweepWidget_checkLogin = new WeakSet();
  9387. var SweepWidget_getGiveawayId = new WeakSet();
  9388. var _checkEnter = new WeakSet();
  9389. var _checkFinish = new WeakSet();
  9390. class SweepWidget extends website_Website {
  9391. constructor() {
  9392. super(...arguments);
  9393. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9394. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9395. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9396. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9397. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9398. SweepWidget_defineProperty(this, 'options', {
  9399. ...SweepWidget_defaultOptions,
  9400. ...GM_getValue('SweepWidgetOptions')
  9401. });
  9402. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9403. }
  9404. static test() {
  9405. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9406. }
  9407. async after() {
  9408. try {
  9409. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9410. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9411. }
  9412. } catch (error) {
  9413. throwError(error, 'SweepWidget.after');
  9414. }
  9415. }
  9416. init() {
  9417. try {
  9418. const logStatus = scripts_echoLog({
  9419. text: i18n('initing')
  9420. });
  9421. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9422. logStatus.warning(i18n('needLogin'));
  9423. return false;
  9424. }
  9425. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9426. return false;
  9427. }
  9428. this.initialized = true;
  9429. logStatus.success();
  9430. return true;
  9431. } catch (error) {
  9432. throwError(error, 'SweepWidget.init');
  9433. return false;
  9434. }
  9435. }
  9436. classifyTask() {
  9437. return true;
  9438. }
  9439. async doTask() {
  9440. try {
  9441. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9442. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9443. $('input[name="sw__login_name"]').val(this.options.username);
  9444. }
  9445. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9446. $('input[name="sw__login_email"]').val(this.options.email);
  9447. }
  9448. if ($('#sw_login_button:visible').length > 0) {
  9449. $('#sw_login_button')[0].click();
  9450. }
  9451. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9452. return false;
  9453. }
  9454. }
  9455. const logStatus = scripts_echoLog({
  9456. text: i18n('SweepWidgetNotice')
  9457. });
  9458. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9459. for (const task of tasks) {
  9460. var _aElement$, _$task$find$removeAtt;
  9461. const $task = $(task);
  9462. if ($task.find('i.fa-check:visible').length > 0) {
  9463. continue;
  9464. }
  9465. const title = $task.find('.sw_text_inner');
  9466. title[0].click();
  9467. const aElement = $task.find('a.sw_link');
  9468. const link = aElement.attr('href');
  9469. aElement.attr('href', '#a').attr('target', '_self');
  9470. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9471. await delay(300);
  9472. aElement.attr('href', link).attr('target', '_blank');
  9473. $task.find('input[type="text"]').val('test');
  9474. const verifyBtn = $task.find('input.sw_verify');
  9475. if (verifyBtn.prop('disabled') === true) {
  9476. title[0].click();
  9477. await delay(300);
  9478. title[0].click();
  9479. await delay(300);
  9480. }
  9481. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9482. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9483. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9484. }
  9485. logStatus.success();
  9486. return true;
  9487. } catch (error) {
  9488. throwError(error, 'SweepWidget.doTask');
  9489. return false;
  9490. }
  9491. }
  9492. }
  9493. function SweepWidget_checkLogin2() {
  9494. try {
  9495. if ($('#twitter_login_button').length > 0) {
  9496. $('#twitter_login_button')[0].click();
  9497. }
  9498. return true;
  9499. } catch (error) {
  9500. throwError(error, 'SweepWidget.checkLogin');
  9501. return false;
  9502. }
  9503. }
  9504. function SweepWidget_getGiveawayId2() {
  9505. try {
  9506. var _window$location$href;
  9507. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9508. if (giveawayId) {
  9509. this.giveawayId = giveawayId;
  9510. return true;
  9511. }
  9512. scripts_echoLog({
  9513. text: i18n('getFailed', 'GiveawayId')
  9514. });
  9515. return false;
  9516. } catch (error) {
  9517. throwError(error, 'SweepWidget.getGiveawayId');
  9518. return false;
  9519. }
  9520. }
  9521. async function _checkEnter2() {
  9522. try {
  9523. return new Promise(resolve => {
  9524. const checker = setInterval(() => {
  9525. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9526. clearInterval(checker);
  9527. resolve(true);
  9528. }
  9529. });
  9530. });
  9531. } catch (error) {
  9532. throwError(error, 'SweepWidget.checkEnter');
  9533. return false;
  9534. }
  9535. }
  9536. async function _checkFinish2($task) {
  9537. try {
  9538. return new Promise(resolve => {
  9539. const checker = setInterval(() => {
  9540. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9541. clearInterval(checker);
  9542. resolve(true);
  9543. }
  9544. });
  9545. });
  9546. } catch (error) {
  9547. throwError(error, 'SweepWidget.checkFinish');
  9548. return false;
  9549. }
  9550. }
  9551. const website_SweepWidget = SweepWidget;
  9552. const defaultWhiteList = {
  9553. discord: {
  9554. servers: []
  9555. },
  9556. instagram: {
  9557. users: []
  9558. },
  9559. twitch: {
  9560. channels: []
  9561. },
  9562. twitter: {
  9563. users: [],
  9564. retweets: [],
  9565. likes: []
  9566. },
  9567. vk: {
  9568. names: []
  9569. },
  9570. youtube: {
  9571. channels: [],
  9572. likes: []
  9573. },
  9574. reddit: {
  9575. reddits: []
  9576. },
  9577. steam: {
  9578. groups: [],
  9579. wishlists: [],
  9580. follows: [],
  9581. forums: [],
  9582. workshops: [],
  9583. curators: [],
  9584. workshopVotes: [],
  9585. curatorLikes: [],
  9586. announcements: []
  9587. }
  9588. };
  9589. const link2id = async function(type) {
  9590. 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;
  9591. try {
  9592. const link = $('#socialLink').val();
  9593. let id = '';
  9594. switch (type) {
  9595. case 'discord.servers':
  9596. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9597. break;
  9598.  
  9599. case 'instagram.users':
  9600. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9601. break;
  9602.  
  9603. case 'twitch.channels':
  9604. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9605. break;
  9606.  
  9607. case 'twitter.users':
  9608. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9609. break;
  9610.  
  9611. case 'twitter.retweets':
  9612. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9613. break;
  9614.  
  9615. case 'vk.names':
  9616. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9617. break;
  9618.  
  9619. case 'youtube.channels':
  9620. 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) || '';
  9621. break;
  9622.  
  9623. case 'youtube.likes':
  9624. 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) || '';
  9625. break;
  9626.  
  9627. case 'reddit.reddits':
  9628. 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]) || '';
  9629. break;
  9630.  
  9631. case 'steam.groups':
  9632. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9633. break;
  9634.  
  9635. case 'steam.wishlists':
  9636. case 'steam.follows':
  9637. case 'steam.forums':
  9638. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9639. break;
  9640.  
  9641. case 'steam.workshops':
  9642. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9643. break;
  9644.  
  9645. case 'steam.curators':
  9646. {
  9647. if (link.includes('curator')) {
  9648. var _link$match12;
  9649. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9650. } else {
  9651. var _link$match13;
  9652. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9653. if (!param || param.length !== 2) {
  9654. break;
  9655. }
  9656. const steam = new social_Steam();
  9657. if (await steam.init()) {
  9658. id = await steam.getCuratorId(param[0], param[1]) || '';
  9659. }
  9660. }
  9661. }
  9662. break;
  9663. }
  9664. return id;
  9665. } catch (error) {
  9666. throwError(error, 'link2id');
  9667. return i18n('getFailed', 'id');
  9668. }
  9669. };
  9670. const disabledType = {
  9671. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9672. twitter: [ 'likes' ]
  9673. };
  9674. const whiteListOptions = function(showType) {
  9675. try {
  9676. const whiteList = {
  9677. ...defaultWhiteList,
  9678. ...GM_getValue('whiteList') || {}
  9679. };
  9680. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9681. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9682. for (const [ social, types ] of Object.entries(whiteList)) {
  9683. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9684. var _disabledType$social;
  9685. 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>`;
  9686. }).join('');
  9687. }
  9688. whiteListOptionsForm += '</tbody></table></form>';
  9689. if (showType === 'swal') {
  9690. external_Swal_default().fire({
  9691. title: i18n('whiteListOptions'),
  9692. html: whiteListOptionsForm,
  9693. showConfirmButton: false,
  9694. showCloseButton: true
  9695. });
  9696. } else {
  9697. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9698. }
  9699. $('.editWhiteList').on('click', function() {
  9700. var _whiteList$social;
  9701. const value = $(this).attr('data-value');
  9702. if (!value) {
  9703. return;
  9704. }
  9705. const [ social, type ] = value.split('.');
  9706. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9707. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9708. return;
  9709. }
  9710. external_Swal_default().fire({
  9711. title: i18n('changeWhiteListOption', value),
  9712. input: 'textarea',
  9713. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9714. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9715. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9716. inputValue: whiteList[social][type].join('\n'),
  9717. showConfirmButton: true,
  9718. confirmButtonText: i18n('save'),
  9719. showCancelButton: true,
  9720. cancelButtonText: i18n('close'),
  9721. showDenyButton: true,
  9722. denyButtonText: i18n('return')
  9723. }).then(_ref => {
  9724. let {
  9725. isDenied,
  9726. isConfirmed,
  9727. value
  9728. } = _ref;
  9729. if (isDenied) {
  9730. if (showType === 'swal') {
  9731. whiteListOptions(showType);
  9732. }
  9733. return;
  9734. } else if (isConfirmed) {
  9735. whiteList[social][type] = value.split('\n');
  9736. GM_setValue('whiteList', whiteList);
  9737. external_Swal_default().fire({
  9738. title: i18n('changeWhiteListSuccess'),
  9739. icon: 'success'
  9740. });
  9741. }
  9742. });
  9743. $('#link2id').on('click', async function() {
  9744. const type = $(this).attr('data-type');
  9745. $('#socialLink').val(await link2id(type));
  9746. });
  9747. });
  9748. } catch (error) {
  9749. throwError(error, 'whiteListOptions');
  9750. }
  9751. };
  9752. const whiteList = whiteListOptions;
  9753. const setGistData = async (token, gistId, fileName, content) => {
  9754. try {
  9755. const logStatus = scripts_echoLog({
  9756. text: i18n('settingData')
  9757. });
  9758. const contentData = JSON.stringify({
  9759. files: {
  9760. [fileName]: {
  9761. content: JSON.stringify(content)
  9762. }
  9763. }
  9764. });
  9765. const {
  9766. result,
  9767. statusText,
  9768. status,
  9769. data
  9770. } = await tools_httpRequest({
  9771. url: `https://api.github.com/gists/${gistId}`,
  9772. headers: {
  9773. Accept: 'application/vnd.github.v3+json',
  9774. Authorization: `token ${token}`
  9775. },
  9776. data: contentData,
  9777. responseType: 'json',
  9778. method: 'POST',
  9779. timeout: 3e4
  9780. });
  9781. if (result === 'Success') {
  9782. var _data$response$files, _data$response$files$;
  9783. 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)) {
  9784. logStatus.success();
  9785. return true;
  9786. }
  9787. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9788. return false;
  9789. }
  9790. logStatus.error(`${result}:${statusText}(${status})`);
  9791. return false;
  9792. } catch (error) {
  9793. throwError(error, 'setGistData');
  9794. return false;
  9795. }
  9796. };
  9797. const getGistData = async (token, gistId, fileName) => {
  9798. try {
  9799. const logStatus = scripts_echoLog({
  9800. text: i18n('gettingData')
  9801. });
  9802. const {
  9803. result,
  9804. statusText,
  9805. status,
  9806. data
  9807. } = await tools_httpRequest({
  9808. url: `https://api.github.com/gists/${gistId}`,
  9809. headers: {
  9810. Accept: 'application/vnd.github.v3+json',
  9811. Authorization: `token ${token}`
  9812. },
  9813. responseType: 'json',
  9814. method: 'GET',
  9815. timeout: 3e4
  9816. });
  9817. if (result === 'Success') {
  9818. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9819. var _data$response, _data$response$files2, _data$response$files3;
  9820. logStatus.success();
  9821. return JSON.parse(((_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$files2 = _data$response.files) === null || _data$response$files2 === void 0 ? void 0 : (_data$response$files3 = _data$response$files2[fileName]) === null || _data$response$files3 === void 0 ? void 0 : _data$response$files3.content) || null);
  9822. }
  9823. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9824. return false;
  9825. }
  9826. logStatus.error(`${result}:${statusText}(${status})`);
  9827. return false;
  9828. } catch (error) {
  9829. throwError(error, 'getGistData');
  9830. return false;
  9831. }
  9832. };
  9833. const syncOptions = () => {
  9834. try {
  9835. const {
  9836. TOKEN,
  9837. GIST_ID,
  9838. FILE_NAME,
  9839. SYNC_HISTORY
  9840. } = GM_getValue('gistOptions') || {
  9841. TOKEN: '',
  9842. GIST_ID: '',
  9843. FILE_NAME: '',
  9844. SYNC_HISTORY: true
  9845. };
  9846. external_Swal_default().fire({
  9847. title: i18n('gistOptions'),
  9848. 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;">
  9849. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9850. ${i18n('downloadFromGist')}</button></p>`,
  9851. focusConfirm: false,
  9852. showLoaderOnConfirm: true,
  9853. 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>`,
  9854. preConfirm: async () => {
  9855. const token = $('#github-token').val();
  9856. const gistId = $('#gist-id').val();
  9857. const fileName = $('#file-name').val();
  9858. const syncHistory = $('#sync-history').prop('checked');
  9859. GM_setValue('gistOptions', {
  9860. TOKEN: token,
  9861. GIST_ID: gistId,
  9862. FILE_NAME: fileName,
  9863. SYNC_HISTORY: syncHistory
  9864. });
  9865. return await getGistData(token, gistId, fileName);
  9866. },
  9867. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9868. confirmButtonText: i18n('saveAndTest'),
  9869. showCancelButton: true,
  9870. cancelButtonText: i18n('close')
  9871. }).then(_ref => {
  9872. let {
  9873. value
  9874. } = _ref;
  9875. if (value) {
  9876. external_Swal_default().fire({
  9877. icon: 'success',
  9878. title: i18n('testSuccess')
  9879. }).then(syncOptions);
  9880. } else if (value !== undefined) {
  9881. external_Swal_default().fire({
  9882. icon: 'error',
  9883. title: i18n('testFailed')
  9884. }).then(syncOptions);
  9885. }
  9886. });
  9887. $('#upload-data').on('click', async () => {
  9888. const {
  9889. TOKEN,
  9890. GIST_ID,
  9891. FILE_NAME
  9892. } = GM_getValue('gistOptions') || {};
  9893. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9894. return external_Swal_default().fire({
  9895. icon: 'error',
  9896. title: i18n('saveAndTestNotice')
  9897. }).then(syncOptions);
  9898. }
  9899. external_Swal_default().fire({
  9900. icon: 'info',
  9901. title: i18n('processingData')
  9902. });
  9903. const data = {};
  9904. const names = GM_listValues();
  9905. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9906. for (const name of names) {
  9907. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9908. continue;
  9909. }
  9910. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9911. continue;
  9912. }
  9913. data[name] = GM_getValue(name);
  9914. }
  9915. external_Swal_default().update({
  9916. icon: 'info',
  9917. title: i18n('updatingData')
  9918. });
  9919. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9920. external_Swal_default().fire({
  9921. icon: 'success',
  9922. title: i18n('syncDataSuccess')
  9923. });
  9924. } else {
  9925. external_Swal_default().fire({
  9926. icon: 'error',
  9927. title: i18n('syncDataFailed')
  9928. });
  9929. }
  9930. });
  9931. $('#download-data').on('click', async () => {
  9932. const {
  9933. TOKEN,
  9934. GIST_ID,
  9935. FILE_NAME
  9936. } = GM_getValue('gistOptions') || {};
  9937. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9938. return external_Swal_default().fire({
  9939. icon: 'error',
  9940. title: i18n('saveAndTestNotice')
  9941. }).then(syncOptions);
  9942. }
  9943. external_Swal_default().fire({
  9944. icon: 'info',
  9945. title: i18n('downloadingData')
  9946. });
  9947. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9948. if (!data) {
  9949. return external_Swal_default().fire({
  9950. icon: 'error',
  9951. title: i18n('checkedNoData')
  9952. }).then(syncOptions);
  9953. }
  9954. external_Swal_default().update({
  9955. icon: 'info',
  9956. title: i18n('savingData')
  9957. });
  9958. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9959. for (const [ name, value ] of Object.entries(data)) {
  9960. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9961. continue;
  9962. }
  9963. GM_setValue(name, value);
  9964. }
  9965. external_Swal_default().fire({
  9966. icon: 'success',
  9967. title: i18n('syncDataSuccess')
  9968. });
  9969. });
  9970. } catch (error) {
  9971. throwError(error, 'syncOptions');
  9972. }
  9973. };
  9974. const dataSync = syncOptions;
  9975. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  9976. Setting_checkPrivateRedeclaration(obj, privateSet);
  9977. privateSet.add(obj);
  9978. }
  9979. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  9980. if (privateCollection.has(obj)) {
  9981. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9982. }
  9983. }
  9984. function Setting_defineProperty(obj, key, value) {
  9985. if (key in obj) {
  9986. Object.defineProperty(obj, key, {
  9987. value: value,
  9988. enumerable: true,
  9989. configurable: true,
  9990. writable: true
  9991. });
  9992. } else {
  9993. obj[key] = value;
  9994. }
  9995. return obj;
  9996. }
  9997. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  9998. if (!privateSet.has(receiver)) {
  9999. throw new TypeError('attempted to get private field on non-instance');
  10000. }
  10001. return fn;
  10002. }
  10003. var Setting_getId = new WeakSet();
  10004. var _environment = new WeakSet();
  10005. class Setting {
  10006. constructor() {
  10007. Setting_classPrivateMethodInitSpec(this, _environment);
  10008. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10009. Setting_defineProperty(this, 'name', 'Setting');
  10010. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10011. Setting_defineProperty(this, 'syncData', dataSync);
  10012. }
  10013. tasksHistory() {
  10014. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10015. }
  10016. static test() {
  10017. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10018. }
  10019. before() {
  10020. $('body').html('').addClass('auto-task-options');
  10021. }
  10022. after() {
  10023. try {
  10024. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10025. changeGlobalOptions('page');
  10026. whiteList('page');
  10027. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10028. $('#getTwitterUserId').on('click', () => {
  10029. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10030. });
  10031. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10032. $('#getYoutubeChannelId').on('click', () => {
  10033. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10034. });
  10035. $('input[name^="position"]').on('input', function() {
  10036. const type = $(this).attr('name').replace('position.', '');
  10037. const xLabel = 'rightleft';
  10038. const yLabel = 'topbottpm';
  10039. switch (type) {
  10040. case 'buttonSideX':
  10041. case 'buttonSideY':
  10042. case 'buttonDistance':
  10043. {
  10044. const distance = $('input[name="position.buttonDistance"]').val();
  10045. const sideX = $('input[name="position.buttonSideX"]').val();
  10046. const sideY = $('input[name="position.buttonSideY"]').val();
  10047. if (![ 'right', 'left' ].includes(sideX)) {
  10048. break;
  10049. }
  10050. if (![ 'top', 'bottom' ].includes(sideY)) {
  10051. break;
  10052. }
  10053. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10054. break;
  10055. }
  10056. const distanceArr = distance.split(',');
  10057. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10058. break;
  10059. }
  10060.  
  10061. case 'showButtonSideX':
  10062. case 'showButtonSideY':
  10063. case 'showButtonDistance':
  10064. {
  10065. const distance = $('input[name="position.showButtonDistance"]').val();
  10066. const sideX = $('input[name="position.showButtonSideX"]').val();
  10067. const sideY = $('input[name="position.showButtonSideY"]').val();
  10068. if (![ 'right', 'left' ].includes(sideX)) {
  10069. break;
  10070. }
  10071. if (![ 'top', 'bottom' ].includes(sideY)) {
  10072. break;
  10073. }
  10074. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10075. break;
  10076. }
  10077. const distanceArr = distance.split(',');
  10078. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10079. break;
  10080. }
  10081.  
  10082. case 'logSideX':
  10083. case 'logSideY':
  10084. case 'logDistance':
  10085. {
  10086. const distance = $('input[name="position.logDistance"]').val();
  10087. const sideX = $('input[name="position.logSideX"]').val();
  10088. const sideY = $('input[name="position.logSideY"]').val();
  10089. if (![ 'right', 'left' ].includes(sideX)) {
  10090. break;
  10091. }
  10092. if (![ 'top', 'bottom' ].includes(sideY)) {
  10093. break;
  10094. }
  10095. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10096. break;
  10097. }
  10098. const distanceArr = distance.split(',');
  10099. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10100. break;
  10101. }
  10102.  
  10103. default:
  10104. break;
  10105. }
  10106. });
  10107. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10108. let functionKey = '';
  10109. if (event.altKey) {
  10110. functionKey += 'alt + ';
  10111. } else if (event.ctrlKey) {
  10112. functionKey += 'ctrl + ';
  10113. } else if (event.shiftKey) {
  10114. functionKey += 'shift + ';
  10115. }
  10116. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10117. });
  10118. } catch (error) {
  10119. throwError(error, 'Setting.after');
  10120. }
  10121. }
  10122. saveGlobalOptions() {
  10123. saveData();
  10124. }
  10125. }
  10126. function Setting_getId2(social) {
  10127. try {
  10128. external_Swal_default().fire({
  10129. title: i18n('getId', i18n(social)),
  10130. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10131. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10132. showCancelButton: true,
  10133. cancelButtonText: i18n('close'),
  10134. showConfirmButton: false
  10135. });
  10136. $('#link2id').on('click', async function() {
  10137. const link = $('#socialLink').val();
  10138. if (!link) {
  10139. return;
  10140. }
  10141. const type = $(this).attr('data-type');
  10142. if (type === 'twitterUser') {
  10143. var _link$match;
  10144. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10145. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10146. } else if (type === 'youtubeChannel') {
  10147. var _link$match2, _await$getInfo, _await$getInfo$params;
  10148. 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;
  10149. $('#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) || '');
  10150. }
  10151. });
  10152. } catch (error) {
  10153. throwError(error, 'Setting.getId');
  10154. }
  10155. }
  10156. function _environment2() {
  10157. try {
  10158. const userAgent = (0, javascript_utils_umd_min.ua)();
  10159. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10160. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10161. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10162. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10163. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10164. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10165. </tbody></table></form>`;
  10166. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10167. } catch (error) {
  10168. throwError(error, 'Setting.environment');
  10169. }
  10170. }
  10171. const website_Setting = Setting;
  10172. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10173. History_checkPrivateRedeclaration(obj, privateSet);
  10174. privateSet.add(obj);
  10175. }
  10176. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10177. if (privateCollection.has(obj)) {
  10178. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10179. }
  10180. }
  10181. function History_defineProperty(obj, key, value) {
  10182. if (key in obj) {
  10183. Object.defineProperty(obj, key, {
  10184. value: value,
  10185. enumerable: true,
  10186. configurable: true,
  10187. writable: true
  10188. });
  10189. } else {
  10190. obj[key] = value;
  10191. }
  10192. return obj;
  10193. }
  10194. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10195. if (!privateSet.has(receiver)) {
  10196. throw new TypeError('attempted to get private field on non-instance');
  10197. }
  10198. return fn;
  10199. }
  10200. var _addItem = new WeakSet();
  10201. class History extends website_Keylol {
  10202. constructor() {
  10203. super(...arguments);
  10204. History_classPrivateMethodInitSpec(this, _addItem);
  10205. History_defineProperty(this, 'name', 'History');
  10206. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10207. }
  10208. static test() {
  10209. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10210. }
  10211. before() {
  10212. try {
  10213. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10214. const data = GM_listValues() || [];
  10215. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10216. for (const item of tasksHistory) {
  10217. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10218. }
  10219. } catch (error) {
  10220. throwError(error, 'History.before');
  10221. }
  10222. }
  10223. clearHistory() {
  10224. try {
  10225. const data = GM_listValues() || [];
  10226. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10227. for (const item of tasksHistory) {
  10228. GM_deleteValue(item);
  10229. }
  10230. external_Swal_default().fire({
  10231. title: i18n('clearHistoryFinished'),
  10232. icon: 'success'
  10233. });
  10234. } catch (error) {
  10235. throwError(error, 'History.after');
  10236. }
  10237. }
  10238. }
  10239. function _addItem2(item) {
  10240. try {
  10241. const tasksData = GM_getValue(item);
  10242. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10243. return;
  10244. }
  10245. let html = '';
  10246. let title = '';
  10247. let link = '';
  10248. const [ website, id ] = item.split('-');
  10249. switch (website) {
  10250. case 'fawTasks':
  10251. title = `Freeanywhere[${id}]`;
  10252. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10253. break;
  10254.  
  10255. case 'gasTasks':
  10256. title = `Giveawaysu[${id}]`;
  10257. link = `https://giveaway.su/giveaway/view/${id}`;
  10258. break;
  10259.  
  10260. case 'gcTasks':
  10261. title = `GiveeClub[${id}]`;
  10262. link = `https://givee.club/event/${id}`;
  10263. break;
  10264.  
  10265. case 'gkTasks':
  10266. title = `Givekey[${id}]`;
  10267. link = `https://givekey.ru/giveaway/${id}`;
  10268. break;
  10269.  
  10270. case 'gleamTasks':
  10271. title = `Gleam[${id}]`;
  10272. link = `https://gleam.io${id}`;
  10273. break;
  10274.  
  10275. case 'khTasks':
  10276. title = `keyhub[${id}]`;
  10277. link = `https://key-hub.eu/giveaway/${id}`;
  10278. break;
  10279.  
  10280. case 'prysTasks':
  10281. title = `Prys[${id}]`;
  10282. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10283. break;
  10284.  
  10285. default:
  10286. return;
  10287. }
  10288. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10289. for (const [ type, tasks ] of Object.entries(types)) {
  10290. for (const task of tasks) {
  10291. 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>`;
  10292. }
  10293. }
  10294. }
  10295. $('.container').append(`<div class="card"><div class="title"><a href="${link}" target="_blank">${title}</a><span class="delete-task" data-name="${item}" title="${i18n('deleteTask')}"><svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2734" width="32" height="32"><path d="M607.897867 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L575.903242 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 351.94087C639.892491 753.593818 625.61532 768.043004 607.897867 768.043004z" p-id="2735" fill="#d81e06"></path><path d="M415.930119 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L383.935495 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625 17.717453 0 31.994625 14.277171 31.994625 31.994625l0 351.94087C447.924744 753.593818 433.647573 768.043004 415.930119 768.043004z" p-id="2736" fill="#d81e06"></path><path d="M928.016126 223.962372l-159.973123 0L768.043004 159.973123c0-52.980346-42.659499-95.983874-95.295817-95.983874L351.94087 63.989249c-52.980346 0-95.983874 43.003528-95.983874 95.983874l0 63.989249-159.973123 0c-17.717453 0-31.994625 14.277171-31.994625 31.994625s14.277171 31.994625 31.994625 31.994625l832.032253 0c17.717453 0 31.994625-14.277171 31.994625-31.994625S945.73358 223.962372 928.016126 223.962372zM319.946246 159.973123c0-17.545439 14.449185-31.994625 31.994625-31.994625l320.806316 0c17.545439 0 31.306568 14.105157 31.306568 31.994625l0 63.989249L319.946246 223.962372 319.946246 159.973123 319.946246 159.973123z" p-id="2737" fill="#d81e06"></path><path d="M736.048379 960.010751 288.123635 960.010751c-52.980346 0-95.983874-43.003528-95.983874-95.983874L192.139761 383.591466c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 480.435411c0 17.717453 14.449185 31.994625 31.994625 31.994625l448.096758 0c17.717453 0 31.994625-14.277171 31.994625-31.994625L768.215018 384.795565c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 479.231312C832.032253 916.835209 789.028725 960.010751 736.048379 960.010751z" p-id="2738" fill="#d81e06"></path></svg></span></div><ul>${html}</ul><span class="time">${i18n('lastChangeTime')}: ${external_dayjs_namespaceObject(tasksData.time).format('YYYY-MM-DD HH:mm:ss')}</span></div>`);
  10296. $('span.delete-task').on('click', function() {
  10297. const itemName = $(this).attr('data-name');
  10298. if (itemName) {
  10299. GM_deleteValue(itemName);
  10300. external_Swal_default().fire({
  10301. title: i18n('clearTaskFinished'),
  10302. text: itemName,
  10303. icon: 'success'
  10304. });
  10305. } else {
  10306. external_Swal_default().fire({
  10307. title: i18n('clearTaskFailed'),
  10308. icon: 'error'
  10309. });
  10310. }
  10311. });
  10312. } catch (error) {
  10313. throwError(error, 'History.addItem');
  10314. }
  10315. }
  10316. const website_History = History;
  10317. 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 ];
  10318. const websiteOptions = function(website, options) {
  10319. try {
  10320. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10321. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10322. for (const [ option, value ] of Object.entries(options)) {
  10323. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10324. }
  10325. websiteOptionsForm += '</tbody></table></form>';
  10326. external_Swal_default().fire({
  10327. title: i18n('websiteOptions'),
  10328. html: websiteOptionsForm,
  10329. showConfirmButton: true,
  10330. confirmButtonText: i18n('save'),
  10331. showCancelButton: true,
  10332. cancelButtonText: i18n('close')
  10333. }).then(_ref => {
  10334. let {
  10335. isConfirmed
  10336. } = _ref;
  10337. if (isConfirmed) {
  10338. $('#websiteOptionsForm').serializeArray().map(value => {
  10339. options[value.name] = value.value;
  10340. return value;
  10341. });
  10342. GM_setValue(`${website}Options`, options);
  10343. external_Swal_default().fire({
  10344. title: i18n('changeWebsiteOptionsSuccess'),
  10345. icon: 'success'
  10346. });
  10347. }
  10348. });
  10349. } catch (error) {
  10350. throwError(error, 'websiteOptions');
  10351. }
  10352. };
  10353. const options = websiteOptions;
  10354. const external_keyboardJS_namespaceObject = keyboardJS;
  10355. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10356. const checkUpdate = async (updateLink, auto) => {
  10357. try {
  10358. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10359. const {
  10360. result,
  10361. statusText,
  10362. status,
  10363. data
  10364. } = await tools_httpRequest({
  10365. url: checkUrl,
  10366. responseType: 'json',
  10367. method: 'GET',
  10368. timeout: 3e4
  10369. });
  10370. if (result === 'Success') {
  10371. var _data$response;
  10372. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10373. return data.response;
  10374. }
  10375. if (!auto) {
  10376. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10377. }
  10378. return false;
  10379. }
  10380. if (!auto) {
  10381. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10382. }
  10383. return false;
  10384. } catch (error) {
  10385. throwError(error, 'checkUpdate');
  10386. return false;
  10387. }
  10388. };
  10389. const hasNewVersion = (currentVersion, remoteVersion) => {
  10390. try {
  10391. const [ currentRealVersion ] = currentVersion.split('-');
  10392. const [ remoteRealVersion ] = remoteVersion.split('-');
  10393. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10394. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10395. if (remoteVersion1 > currentVersion1) {
  10396. return true;
  10397. }
  10398. if (remoteVersion1 < currentVersion1) {
  10399. return false;
  10400. }
  10401. if (remoteVersion2 > currentVersion2) {
  10402. return true;
  10403. }
  10404. if (remoteVersion2 < currentVersion2) {
  10405. return false;
  10406. }
  10407. if (remoteVersion3 > currentVersion3) {
  10408. return true;
  10409. }
  10410. return false;
  10411. } catch (error) {
  10412. throwError(error, 'compareVersion');
  10413. return false;
  10414. }
  10415. };
  10416. const updateChecker = async () => {
  10417. try {
  10418. const currentVersion = GM_info.script.version;
  10419. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10420. const updateLinks = {
  10421. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10422. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10423. standby: 'https://auto-task-v4.hclonely.com/'
  10424. };
  10425. let version;
  10426. let updateLink = '';
  10427. let packageData;
  10428. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10429. updateLink = updateLinks[updateSource];
  10430. packageData = await checkUpdate(updateLink, false);
  10431. } else {
  10432. updateLink = updateLinks.github;
  10433. packageData = await checkUpdate(updateLink, true);
  10434. if (!packageData) {
  10435. updateLink = updateLinks.jsdelivr;
  10436. packageData = await checkUpdate(updateLink, true);
  10437. if (!packageData) {
  10438. updateLink = updateLinks.standby;
  10439. packageData = await checkUpdate(updateLink, true);
  10440. }
  10441. }
  10442. }
  10443. if (packageData) {
  10444. version = packageData.version || currentVersion;
  10445. } else {
  10446. version = currentVersion;
  10447. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10448. }
  10449. if (packageData && hasNewVersion(currentVersion, version)) {
  10450. var _packageData$change;
  10451. scripts_echoLog({
  10452. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10453. });
  10454. scripts_echoLog({
  10455. html: `<li>${i18n('updateText', version)}</li><ol class="update-text">${(_packageData$change = packageData.change) === null || _packageData$change === void 0 ? void 0 : _packageData$change.map(change => `<li>${change}</li>`).join('')}</ol>`
  10456. });
  10457. }
  10458. } catch (error) {
  10459. throwError(error, 'updateChecker');
  10460. }
  10461. };
  10462. const scripts_updateChecker = updateChecker;
  10463. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  10464. if (window.location.hostname === 'discord.com') {
  10465. var _window$localStorage, _window$localStorage$;
  10466. const discordAuth = (_window$localStorage = window.localStorage) === null || _window$localStorage === void 0 ? void 0 : (_window$localStorage$ = _window$localStorage.getItem('token')) === null || _window$localStorage$ === void 0 ? void 0 : _window$localStorage$.replace(/^"|"$/g, '');
  10467. GM_setValue('discordAuth', {
  10468. auth: discordAuth
  10469. });
  10470. if (discordAuth && window.location.hash === '#auth') {
  10471. window.close();
  10472. external_Swal_default().fire('', i18n('closePageNotice'));
  10473. }
  10474. }
  10475. const loadScript = async () => {
  10476. var _website, _website2, _website3, _website4, _website5, _website6;
  10477. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10478. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10479. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10480. if (isLogin) {
  10481. var _commonOptions, _commonOptions$header;
  10482. GM_setValue('twitchAuth', {
  10483. authToken: authToken,
  10484. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10485. });
  10486. window.close();
  10487. external_Swal_default().fire('', i18n('closePageNotice'));
  10488. } else {
  10489. external_Swal_default().fire('', i18n('needLogin'));
  10490. }
  10491. }
  10492. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10493. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10494. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10495. if (isLogin && ct0) {
  10496. GM_setValue('twitterAuth', {
  10497. ct0: ct0
  10498. });
  10499. window.close();
  10500. external_Swal_default().fire('', i18n('closePageNotice'));
  10501. } else {
  10502. external_Swal_default().fire('', i18n('needLogin'));
  10503. }
  10504. }
  10505. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10506. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10507. if (PAPISID) {
  10508. GM_setValue('youtubeAuth', {
  10509. PAPISID: PAPISID
  10510. });
  10511. window.close();
  10512. external_Swal_default().fire('', i18n('closePageNotice'));
  10513. } else {
  10514. external_Swal_default().fire('', i18n('needLogin'));
  10515. }
  10516. }
  10517. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10518. const betaButton = $('#redesign-beta-optin-btn');
  10519. if (betaButton.length > 0) {
  10520. GM_setValue('redditAuth', '#auth');
  10521. return betaButton[0].click();
  10522. }
  10523. GM_setValue('redditAuth', null);
  10524. window.close();
  10525. external_Swal_default().fire('', i18n('closePageNotice'));
  10526. }
  10527. let website;
  10528. for (const Website of Websites) {
  10529. if (Website.test()) {
  10530. website = new Website();
  10531. break;
  10532. }
  10533. }
  10534. if (!website) {
  10535. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10536. return;
  10537. }
  10538. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10539. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10540. }
  10541. $('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>`);
  10542. $('div.show-button-div').on('click', () => {
  10543. $('#auto-task-buttons').show();
  10544. $('div.show-button-div').hide();
  10545. });
  10546. const toggleLog = () => {
  10547. const $this = $('#toggle-log');
  10548. const status = $this.attr('data-status');
  10549. if (status === 'show') {
  10550. $('#auto-task-info').hide();
  10551. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10552. } else {
  10553. $('#auto-task-info').show();
  10554. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10555. }
  10556. };
  10557. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10558. if (website.doTask) {
  10559. website.doTask();
  10560. }
  10561. });
  10562. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10563. if (website.undoTask) {
  10564. website.doTask();
  10565. }
  10566. });
  10567. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10568. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10569. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10570. }
  10571. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10572. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10573. for (const button of website.buttons) {
  10574. if (website[button]) {
  10575. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10576. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10577. website[button]();
  10578. });
  10579. $('#auto-task-buttons').append(btnElement);
  10580. }
  10581. }
  10582. }
  10583. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10584. ${i18n('hideButton')}</a></p>`);
  10585. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10586. $('#auto-task-buttons').hide();
  10587. $('div.show-button-div').show();
  10588. });
  10589. 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'}">
  10590. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10591. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10592. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10593. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10594. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10595. options(website.name, website.options);
  10596. });
  10597. }
  10598. if (website.name !== 'Setting') {
  10599. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10600. changeGlobalOptions('swal');
  10601. });
  10602. GM_registerMenuCommand(i18n('settingPage'), () => {
  10603. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10604. });
  10605. }
  10606. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10607. if (!GM_getValue('notice')) {
  10608. var _echoLog$font;
  10609. external_Swal_default().fire({
  10610. title: i18n('swalNotice'),
  10611. icon: 'warning'
  10612. }).then(() => {
  10613. window.open(i18n('noticeLink'), '_blank');
  10614. GM_setValue('notice', new Date().getTime());
  10615. });
  10616. (_echoLog$font = scripts_echoLog({
  10617. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10618. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10619. GM_setValue('notice', new Date().getTime());
  10620. });
  10621. }
  10622. scripts_updateChecker();
  10623. };
  10624. if (window.location.hostname === 'opquests.com') {
  10625. loadScript();
  10626. } else {
  10627. $(loadScript);
  10628. }
  10629. }();
  10630. })();