auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.12-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 unsafeWindow
  45. // @grant window.close
  46. // @grant window.localStorage
  47.  
  48. // @connect cdn.jsdelivr.net
  49. // @connect store.steampowered.com
  50. // @connect steamcommunity.com
  51. // @connect twitter.com
  52. // @connect api.twitter.com
  53. // @connect youtube.com
  54. // @connect www.youtube.com
  55. // @connect facebook.com
  56. // @connect instagram.com
  57. // @connect vk.com
  58. // @connect twitch.tv
  59. // @connect www.twitch.tv
  60. // @connect gql.twitch.tv
  61. // @connect github.com
  62. // @connect discordapp.com
  63. // @connect discord.gg
  64. // @connect discord.com
  65. // @connect www.reddit.com
  66. // @connect oauth.reddit.com
  67. // @connect raw.githubusercontent.com
  68. // @connect t.me
  69. // @connect bit.ly
  70. // @connect giveaway.su
  71. // @connect google.com
  72. // @connect www.vloot.io
  73. // @connect givee.club
  74. // @connect gleam.io
  75. // @connect www.indiedb.com
  76. // @connect key-hub.eu
  77. // @connect opquests.com
  78. // @connect itch.io
  79. // @connect auto-task-v4.hclonely.com
  80. // @connect *
  81. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  82. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  83. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  84. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  85. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11
  86. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  87. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  88.  
  89. // @compatible Tampermonkey Only
  90. // @noframes
  91. // ==/UserScript==
  92.  
  93. console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
  94.  
  95. (function() {
  96. var __webpack_modules__ = {
  97. 514: function(__unused_webpack_module, exports) {
  98. !function(e, n) {
  99. true ? n(exports) : 0;
  100. }(this, function(e) {
  101. 'use strict';
  102. var t = function() {
  103. return (t = Object.assign || function(e) {
  104. for (var n, o = 1, t = arguments.length; o < t; o++) {
  105. for (var r in n = arguments[o]) {
  106. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  107. }
  108. }
  109. return e;
  110. }).apply(this, arguments);
  111. };
  112. function r(e, n, o) {
  113. if (o || 2 === arguments.length) {
  114. for (var t, r = 0, i = n.length; r < i; r++) {
  115. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  116. }
  117. }
  118. return e.concat(t || Array.prototype.slice.call(n));
  119. }
  120. function d(e) {
  121. return '[object Object]' === n(e);
  122. }
  123. function l(e, n) {
  124. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  125. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  126. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  127. });
  128. }
  129. var n = function(e) {
  130. return Object.prototype.toString.call(e);
  131. };
  132. var o = (i.prototype.init = function() {
  133. try {
  134. this.getSystemName(), this.getBrowserName();
  135. } catch (e) {
  136. console.warn('[UA formatter error] '.concat(e));
  137. }
  138. }, i.prototype.getEngine = function() {
  139. var e = this.agent;
  140. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  141. }, i.prototype.getSystemName = function() {
  142. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  143. try {
  144. var o = '';
  145. if (/Windows/i.test(n)) {
  146. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  147. switch (this.info.os = 'Windows', t) {
  148. case '6.3':
  149. o = '8.1';
  150. break;
  151.  
  152. case '6.2':
  153. o = '8';
  154. break;
  155.  
  156. case '6.1':
  157. o = '7';
  158. break;
  159.  
  160. case '5.2':
  161. case '5.1':
  162. o = 'XP';
  163. break;
  164.  
  165. default:
  166. o = t;
  167. }
  168. return this.info.device = 'PC', void (this.info.osVersion = o);
  169. }
  170. if (/^Macintosh/i.test(n)) {
  171. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  172. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  173. }
  174. if (/^iPad/i.test(n)) {
  175. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  176. void (this.info.osVersion = o.replace(/_/g, '.'));
  177. }
  178. if (/^iPhone/i.test(n)) {
  179. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  180. void (this.info.osVersion = o.replace(/_/g, '.'));
  181. }
  182. if (-1 !== n.indexOf('Android')) {
  183. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  184. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  185. }
  186. if (/Linux\s[a-z\d_]+/.test(n)) {
  187. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  188. }
  189. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  190. } catch (e) {
  191. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  192. }
  193. }, i.prototype.getBrowserName = function() {
  194. var e = Object.keys(this.browserNameMap).map(function(e) {
  195. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  196. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  197. return -1 !== e.findIndex(function(e) {
  198. return e.test(n);
  199. });
  200. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  201. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  202. }, i.prototype._formatBrowserVersion = function(e) {
  203. var n, o, t, r;
  204. try {
  205. 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++) {
  206. var d = u[f], l = d[0], h = d[1];
  207. if (new RegExp(l).test(s)) {
  208. c = h;
  209. break;
  210. }
  211. }
  212. var p = {
  213. browserVersion: null != a ? a : 'Unknown',
  214. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  215. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  216. };
  217. return 'Trident' === s && (p.browserVersion = {
  218. '4.0': 8,
  219. '5.0': 9,
  220. '6.0': 10,
  221. '7.0': 11
  222. }[a]), p;
  223. } catch (e) {
  224. return console.warn('[UA formatter error] '.concat(e)), {
  225. browser: 'Unknown',
  226. browserVersion: 'Unknown'
  227. };
  228. }
  229. }, i);
  230. function i(e) {
  231. this.agent = '', this.info = {
  232. browser: '',
  233. browserZH: '',
  234. browserVersion: '',
  235. os: '',
  236. osVersion: '',
  237. device: 'Unknown',
  238. engine: 'WebKit'
  239. }, this.browserNameMap = {
  240. MicroMessenger: {
  241. en: 'MicroMessenger',
  242. zh: '微信'
  243. },
  244. MetaSr: {
  245. en: 'MetaSr',
  246. zh: '搜狗浏览器'
  247. },
  248. 'QQ(Browser)?': {
  249. en: 'QQBrowser',
  250. zh: 'QQ浏览器'
  251. },
  252. UCBrowser: {
  253. en: 'UCBrowser',
  254. zh: 'UC浏览器'
  255. },
  256. '2345Explorer': {
  257. en: '2345Explorer',
  258. zh: '2345极速浏览器'
  259. },
  260. Mb2345Browser: {
  261. en: 'Mb2345Browser',
  262. zh: '2345手机浏览器'
  263. },
  264. Trident: {
  265. en: 'Internet Explorer'
  266. },
  267. 'Edge?': {
  268. en: 'Edge'
  269. },
  270. OPR: {
  271. en: 'Opera'
  272. },
  273. Vivaldi: {
  274. en: 'Vivaldi'
  275. },
  276. Firefox: {
  277. en: 'Firefox'
  278. },
  279. Chrome: {
  280. en: 'Chrome'
  281. },
  282. Safari: {
  283. en: 'Safari'
  284. }
  285. }, this.agent = e, this.init();
  286. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  287. this.info = t(t({}, this.info), {
  288. engine: this.getEngine(),
  289. browserVersion: 'Safari' === o ? n : e
  290. });
  291. }
  292. function s() {
  293. this.cookies = {}, this.init();
  294. }
  295. var a = new (s.prototype.init = function() {
  296. var o = {};
  297. document.cookie.split(/;\s/).forEach(function(e) {
  298. var n = e.split(/=/), e = n[0], n = n[1];
  299. o[e] = n;
  300. }), this.cookies = o;
  301. }, s.prototype.getItem = function(e) {
  302. return this.cookies[e];
  303. }, s.prototype.getAllItems = function() {
  304. return this.cookies;
  305. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  306. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  307. }, s)();
  308. e.countDown = function e(n, o, t, r) {
  309. if (!window) {
  310. throw new Error('window is not defind.');
  311. }
  312. if (0 < n) {
  313. return r && r(), n--, window[o] = window.setTimeout(function() {
  314. e(n, o, t, r);
  315. }, 1e3), function() {
  316. return clearTimeout(window[o]);
  317. };
  318. }
  319. clearTimeout(window[o]), t && t();
  320. }, e.createRandomID = function(e) {
  321. void 0 === e && (e = 12);
  322. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  323. n.push(o[Math.round(Math.random() * t)]);
  324. }
  325. return n.join('');
  326. }, e.dCookie = a, e.debounce = function(o, t, r) {
  327. var i;
  328. void 0 === t && (t = 0);
  329. var s = r = void 0 === r ? !1 : r;
  330. return function() {
  331. var e = this, n = arguments;
  332. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  333. r ? s = !0 : o.apply(e, n);
  334. }, t);
  335. };
  336. }, e.deepCopy = function e(n) {
  337. if (d(n) || Array.isArray(n)) {
  338. var o, t = Array.isArray(n) ? [] : {};
  339. for (o in n) {
  340. t[o] = e(n[o]);
  341. }
  342. return t;
  343. }
  344. return n;
  345. }, e.formatQueryParams = function(e) {
  346. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  347. if (!e) {
  348. return {};
  349. }
  350. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  351. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  352. return t[n] = o, e;
  353. });
  354. }
  355. return t;
  356. }, e.formatThousandth = function(e) {
  357. 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, '$&,');
  358. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  359. }, e.generateTree = function e(n, o, t, r) {
  360. for (var i = [], s = 0; s < n.length; s++) {
  361. var a = n[s];
  362. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  363. }
  364. return i;
  365. }, e.isEmpty = function(e) {
  366. 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);
  367. }, e.isFunction = function(e) {
  368. return '[object Function]' === n(e);
  369. }, e.isImageUrl = function(e) {
  370. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  371. }, e.isObject = d, e.isRegexp = function(e) {
  372. return '[object RegExp]' === n(e);
  373. }, e.objectKeyToCamelCase = function e(n, o, t) {
  374. if (Array.isArray(n)) {
  375. for (var r = [], i = 0; i < n.length; i++) {
  376. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  377. }
  378. } else if (d(n)) {
  379. r = {};
  380. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  381. var f = (u = c[a])[0], u = u[1];
  382. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  383. }
  384. } else {
  385. r = n;
  386. }
  387. return r;
  388. }, e.realType = n, e.searchParams = function(e, n) {
  389. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  390. new URLSearchParams(e).get(n);
  391. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  392. return e.replace(/([A-Z])/g, function(e) {
  393. return '_'.concat(e.toLocaleLowerCase());
  394. });
  395. }, e.ua = function(e) {
  396. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  397. }, Object.defineProperty(e, '__esModule', {
  398. value: !0
  399. });
  400. });
  401. },
  402. 786: function(module, __webpack_exports__, __webpack_require__) {
  403. 'use strict';
  404. __webpack_require__.d(__webpack_exports__, {
  405. Z: function() {
  406. return __WEBPACK_DEFAULT_EXPORT__;
  407. }
  408. });
  409. 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);
  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___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__);
  411. 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);
  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___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__);
  413. 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());
  414. ___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}', '' ]);
  415. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  416. },
  417. 400: function(module) {
  418. 'use strict';
  419. module.exports = function(cssWithMappingToString) {
  420. var list = [];
  421. list.toString = function toString() {
  422. return this.map(function(item) {
  423. var content = '';
  424. var needLayer = typeof item[5] !== 'undefined';
  425. if (item[4]) {
  426. content += '@supports ('.concat(item[4], ') {');
  427. }
  428. if (item[2]) {
  429. content += '@media '.concat(item[2], ' {');
  430. }
  431. if (needLayer) {
  432. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  433. }
  434. content += cssWithMappingToString(item);
  435. if (needLayer) {
  436. content += '}';
  437. }
  438. if (item[2]) {
  439. content += '}';
  440. }
  441. if (item[4]) {
  442. content += '}';
  443. }
  444. return content;
  445. }).join('');
  446. };
  447. list.i = function i(modules, media, dedupe, supports, layer) {
  448. if (typeof modules === 'string') {
  449. modules = [ [ null, modules, undefined ] ];
  450. }
  451. var alreadyImportedModules = {};
  452. if (dedupe) {
  453. for (var k = 0; k < this.length; k++) {
  454. var id = this[k][0];
  455. if (id != null) {
  456. alreadyImportedModules[id] = true;
  457. }
  458. }
  459. }
  460. for (var _k = 0; _k < modules.length; _k++) {
  461. var item = [].concat(modules[_k]);
  462. if (dedupe && alreadyImportedModules[item[0]]) {
  463. continue;
  464. }
  465. if (typeof layer !== 'undefined') {
  466. if (typeof item[5] === 'undefined') {
  467. item[5] = layer;
  468. } else {
  469. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  470. item[5] = layer;
  471. }
  472. }
  473. if (media) {
  474. if (!item[2]) {
  475. item[2] = media;
  476. } else {
  477. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  478. item[2] = media;
  479. }
  480. }
  481. if (supports) {
  482. if (!item[4]) {
  483. item[4] = ''.concat(supports);
  484. } else {
  485. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  486. item[4] = supports;
  487. }
  488. }
  489. list.push(item);
  490. }
  491. };
  492. return list;
  493. };
  494. },
  495. 220: function(module) {
  496. 'use strict';
  497. module.exports = function(i) {
  498. return i[1];
  499. };
  500. }
  501. };
  502. var __webpack_module_cache__ = {};
  503. function __webpack_require__(moduleId) {
  504. var cachedModule = __webpack_module_cache__[moduleId];
  505. if (cachedModule !== undefined) {
  506. return cachedModule.exports;
  507. }
  508. var module = __webpack_module_cache__[moduleId] = {
  509. id: moduleId,
  510. exports: {}
  511. };
  512. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  513. return module.exports;
  514. }
  515. !function() {
  516. __webpack_require__.n = function(module) {
  517. var getter = module && module.__esModule ? function() {
  518. return module['default'];
  519. } : function() {
  520. return module;
  521. };
  522. __webpack_require__.d(getter, {
  523. a: getter
  524. });
  525. return getter;
  526. };
  527. }();
  528. !function() {
  529. __webpack_require__.d = function(exports, definition) {
  530. for (var key in definition) {
  531. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  532. Object.defineProperty(exports, key, {
  533. enumerable: true,
  534. get: definition[key]
  535. });
  536. }
  537. }
  538. };
  539. }();
  540. !function() {
  541. __webpack_require__.o = function(obj, prop) {
  542. return Object.prototype.hasOwnProperty.call(obj, prop);
  543. };
  544. }();
  545. var __webpack_exports__ = {};
  546. !function() {
  547. 'use strict';
  548. const external_Swal_namespaceObject = Swal;
  549. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  550. const external_Cookies_namespaceObject = Cookies;
  551. var auto_task = __webpack_require__(786);
  552. var javascript_utils_umd_min = __webpack_require__(514);
  553. const httpRequest = async function(options) {
  554. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  555. try {
  556. const result = await new Promise(resolve => {
  557. if (options.dataType) {
  558. options.responseType = options.dataType;
  559. }
  560. const requestObj = {
  561. ...{
  562. timeout: 3e4,
  563. ontimeout(data) {
  564. resolve({
  565. result: 'Error',
  566. statusText: 'Timeout',
  567. status: 601,
  568. data: data,
  569. options: options
  570. });
  571. },
  572. onabort(data) {
  573. resolve({
  574. result: 'Error',
  575. statusText: 'Aborted',
  576. status: 602,
  577. data: data,
  578. options: options
  579. });
  580. },
  581. onerror(data) {
  582. resolve({
  583. result: 'Error',
  584. statusText: 'Error',
  585. status: 603,
  586. data: data,
  587. options: options
  588. });
  589. },
  590. onload(data) {
  591. resolve({
  592. result: 'Success',
  593. statusText: 'Load',
  594. status: 600,
  595. data: data,
  596. options: options
  597. });
  598. }
  599. },
  600. ...options
  601. };
  602. GM_xmlhttpRequest(requestObj);
  603. });
  604. console.log('发送请求:', result);
  605. if (result.status !== 600 && times < 2) {
  606. return await httpRequest(options, times + 1);
  607. }
  608. return result;
  609. } catch (error) {
  610. throwError(error, 'httpRequest');
  611. console.log('发送请求:', {
  612. errorMsg: error,
  613. options: options
  614. });
  615. return {
  616. result: 'JsError',
  617. statusText: 'Error',
  618. status: 604,
  619. error: error,
  620. options: options
  621. };
  622. }
  623. };
  624. const tools_httpRequest = httpRequest;
  625. const echoLog = _ref => {
  626. let {
  627. type,
  628. text,
  629. html,
  630. id
  631. } = _ref;
  632. const emptyStatus = {
  633. success: () => emptyStatus,
  634. error: () => emptyStatus,
  635. warning: () => emptyStatus,
  636. info: () => emptyStatus,
  637. view: () => emptyStatus
  638. };
  639. try {
  640. var _ele$;
  641. let ele;
  642. if (type) {
  643. switch (type) {
  644. case 'joiningSteamGroup':
  645. case 'leavingSteamGroup':
  646. case 'gettingSteamGroupId':
  647. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>...<font></font></li>`);
  648. break;
  649.  
  650. case 'subscribingForum':
  651. case 'unsubscribingForum':
  652. case 'gettingForumId':
  653. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>...<font></font></li>`);
  654. break;
  655.  
  656. case 'followingCurator':
  657. case 'unfollowingCurator':
  658. case 'getCuratorId':
  659. 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>`);
  660. break;
  661.  
  662. case 'addingToWishlist':
  663. case 'removingFromWishlist':
  664. case 'followingGame':
  665. case 'unfollowingGame':
  666. case 'gettingSubid':
  667. case 'addingFreeLicense':
  668. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>...<font></font></li>`);
  669. break;
  670.  
  671. case 'favoritingWorkshop':
  672. case 'unfavoritingWorkshop':
  673. case 'gettingWorkshopAppId':
  674. case 'votingUpWorkshop':
  675. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  676. ${text}</a>...<font></font></li>`);
  677. break;
  678.  
  679. case 'gettingAnnouncementParams':
  680. case 'likingAnnouncement':
  681. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  682. ${id}</a>...<font></font></li>`);
  683. break;
  684.  
  685. case 'joiningDiscordServer':
  686. case 'gettingDiscordGuild':
  687. ele = $(`<li>${i18n(type)}<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>...<font></font></li>`);
  688. break;
  689.  
  690. case 'leavingDiscordServer':
  691. ele = $(`<li>${i18n(type)}<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>...<font></font></li>`);
  692. break;
  693.  
  694. case 'updateDiscordAuth':
  695. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  696. break;
  697.  
  698. case 'followingTwitchChannel':
  699. case 'unfollowingTwitchChannel':
  700. case 'gettingTwitchChannelId':
  701. ele = $(`<li>${i18n(type)}<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>...<font></font></li>`);
  702. break;
  703.  
  704. case 'gettingInsUserId':
  705. case 'followingIns':
  706. case 'unfollowingIns':
  707. ele = $(`<li>${i18n(type)}<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  708. break;
  709.  
  710. case 'gettingTwitterUserId':
  711. case 'followingTwitterUser':
  712. case 'unfollowingTwitterUser':
  713. ele = $(`<li>${i18n(type)}<a href="https://twitter.com/${text}" target="_blank">${text}</a>...<font></font></li>`);
  714. break;
  715.  
  716. case 'retweetting':
  717. case 'unretweetting':
  718. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  719. break;
  720.  
  721. case 'joiningReddit':
  722. case 'leavingReddit':
  723. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  724. break;
  725.  
  726. case 'followingRedditUser':
  727. case 'unfollowingRedditUser':
  728. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  729. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>...<font></font></li>`);
  730. break;
  731.  
  732. case 'followingYtbChannel':
  733. case 'unfollowingYtbChannel':
  734. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>...<font></font></li>`);
  735. break;
  736.  
  737. case 'likingYtbVideo':
  738. case 'unlikingYtbVideo':
  739. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>...<font></font></li>`);
  740. break;
  741.  
  742. case 'gettingVkId':
  743. case 'joiningVkGroup':
  744. case 'leavingVkGroup':
  745. case 'joiningVkPublic':
  746. case 'leavingVkPublic':
  747. case 'sendingVkWall':
  748. case 'deletingVkWall':
  749. ele = $(`<li>${i18n(type)}<a href="https://vk.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  750. break;
  751.  
  752. case 'visitingLink':
  753. ele = $(`<li>${i18n('visitingLink')}<a href="${text}" target="_blank">${text}</a>...<font></font></li>`);
  754. break;
  755.  
  756. case 'verifyingInsAuth':
  757. case 'text':
  758. ele = $(`<li>${i18n(text)}<font></font></li>`);
  759. break;
  760.  
  761. case 'html':
  762. ele = $(text || html);
  763. break;
  764.  
  765. case 'whiteList':
  766. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  767. break;
  768.  
  769. case 'globalOptionsSkip':
  770. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  771. break;
  772.  
  773. default:
  774. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  775. break;
  776. }
  777. } else if (text) {
  778. ele = $(`<li>${i18n(text)}<font></font></li>`);
  779. } else if (html) {
  780. ele = $(html);
  781. } else {
  782. ele = $('<li><font></font></li>');
  783. }
  784. ele.addClass('card-text');
  785. $('#auto-task-info').append(ele);
  786. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  787. const font = ele.find('font');
  788. const status = {
  789. font: font,
  790. success() {
  791. var _this$font, _this$font2, _this$font3;
  792. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  793. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  794. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  795. 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);
  796. return this;
  797. },
  798. error() {
  799. var _this$font4, _this$font5, _this$font6;
  800. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  801. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  802. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  803. 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);
  804. return this;
  805. },
  806. warning() {
  807. var _this$font7, _this$font8, _this$font9;
  808. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  809. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  810. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  811. 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);
  812. return this;
  813. },
  814. info() {
  815. var _this$font10, _this$font11, _this$font12;
  816. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  817. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  818. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  819. 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);
  820. return this;
  821. },
  822. view() {
  823. var _this$font13;
  824. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  825. return this;
  826. }
  827. };
  828. return status;
  829. } catch (error) {
  830. throwError(error, 'echoLog');
  831. return emptyStatus;
  832. }
  833. };
  834. const scripts_echoLog = echoLog;
  835. const unique = array => {
  836. try {
  837. return [ ...new Set(array) ];
  838. } catch (error) {
  839. throwError(error, 'unique');
  840. return [];
  841. }
  842. };
  843. const delay = function() {
  844. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  845. return new Promise(resolve => {
  846. setTimeout(() => {
  847. resolve(true);
  848. }, time);
  849. });
  850. };
  851. const getRedirectLink = async link => {
  852. try {
  853. if (!link) {
  854. return null;
  855. }
  856. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  857. if (redirectLinksCache[link]) {
  858. redirectLinksCache[link];
  859. }
  860. return await tools_httpRequest({
  861. url: link,
  862. method: 'GET'
  863. }).then(_ref => {
  864. let {
  865. data
  866. } = _ref;
  867. if (data !== null && data !== void 0 && data.finalUrl) {
  868. redirectLinksCache[link] = data.finalUrl;
  869. GM_setValue('redirectLinks', redirectLinksCache);
  870. return data.finalUrl;
  871. }
  872. return null;
  873. });
  874. } catch (error) {
  875. throwError(error, 'getRedirectLink');
  876. return null;
  877. }
  878. };
  879. const visitLink = async (link, options) => {
  880. try {
  881. const logStatus = scripts_echoLog({
  882. type: 'visitLink',
  883. text: link
  884. });
  885. return await tools_httpRequest({
  886. url: link,
  887. method: 'GET',
  888. ...options
  889. }).then(_ref2 => {
  890. let {
  891. result,
  892. statusText,
  893. status
  894. } = _ref2;
  895. if (result === 'Success') {
  896. logStatus.success();
  897. return true;
  898. }
  899. logStatus.error(`${result}:${statusText}(${status})`);
  900. return false;
  901. });
  902. } catch (error) {
  903. throwError(error, 'visitLink');
  904. return false;
  905. }
  906. };
  907. const getUrlQuery = url => {
  908. try {
  909. const query = {};
  910. if (url) {
  911. if (url.includes('?')) {
  912. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  913. query[key] = value;
  914. return str;
  915. });
  916. }
  917. } else {
  918. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  919. query[key] = value;
  920. return str;
  921. });
  922. }
  923. return query;
  924. } catch (error) {
  925. throwError(error, 'getUrlQuery');
  926. return {};
  927. }
  928. };
  929. const getUuid = () => {
  930. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  931. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  932. };
  933. const stringToColour = str => {
  934. try {
  935. let hash = 0;
  936. for (let i = 0; i < str.length; i++) {
  937. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  938. }
  939. let colour = '#';
  940. for (let i = 0; i < 3; i++) {
  941. const value = hash >> i * 8 & 255;
  942. colour += `00${value.toString(16)}`.slice(-2);
  943. }
  944. return colour;
  945. } catch (error) {
  946. throwError(error, 'stringToColour');
  947. return '#fff';
  948. }
  949. };
  950. const defaultGlobalOptions = {
  951. doTask: {
  952. discord: {
  953. servers: true
  954. },
  955. instagram: {
  956. users: true
  957. },
  958. twitch: {
  959. channels: true
  960. },
  961. twitter: {
  962. users: true,
  963. retweets: true
  964. },
  965. vk: {
  966. names: true
  967. },
  968. youtube: {
  969. channels: true,
  970. likes: true
  971. },
  972. reddit: {
  973. reddits: true
  974. },
  975. steam: {
  976. groups: true,
  977. wishlists: true,
  978. follows: true,
  979. forums: true,
  980. workshops: true,
  981. curators: true,
  982. workshopVotes: true,
  983. announcements: true
  984. }
  985. },
  986. undoTask: {
  987. discord: {
  988. servers: true
  989. },
  990. instagram: {
  991. users: true
  992. },
  993. twitch: {
  994. channels: true
  995. },
  996. twitter: {
  997. users: true,
  998. retweets: true
  999. },
  1000. vk: {
  1001. names: true
  1002. },
  1003. youtube: {
  1004. channels: true,
  1005. likes: true
  1006. },
  1007. reddit: {
  1008. reddits: true
  1009. },
  1010. steam: {
  1011. groups: true,
  1012. wishlists: true,
  1013. follows: true,
  1014. forums: true,
  1015. workshops: true,
  1016. curators: true
  1017. }
  1018. },
  1019. position: {
  1020. buttonSideX: 'right',
  1021. buttonSideY: 'top',
  1022. buttonDistance: '15,30',
  1023. showButtonSideX: 'right',
  1024. showButtonSideY: 'top',
  1025. showButtonDistance: '15,30',
  1026. logSideX: 'right',
  1027. logSideY: 'bottom',
  1028. logDistance: '10,10'
  1029. },
  1030. hotKey: {
  1031. doTaskKey: 'alt + d',
  1032. undoTaskKey: 'alt + u',
  1033. toggleLogKey: 'alt + l'
  1034. },
  1035. other: {
  1036. twitterVerifyId: '783214',
  1037. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1038. autoUpdateSource: 'jsdelivr',
  1039. language: 'zh',
  1040. checkLogin: true,
  1041. checkLeftKey: true,
  1042. defaultShowButton: true,
  1043. defaultShowLog: true
  1044. }
  1045. };
  1046. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1047. const assignObject = (obj1, obj2) => {
  1048. try {
  1049. const newObj = {};
  1050. for (const [ key, value ] of Object.entries(obj1)) {
  1051. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1052. newObj[key] = assignObject(value, obj2[key]);
  1053. } else {
  1054. newObj[key] = obj2[key] ?? value;
  1055. }
  1056. }
  1057. return newObj;
  1058. } catch (error) {
  1059. throwError(error, 'assignObject');
  1060. return defaultGlobalOptions;
  1061. }
  1062. };
  1063. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1064. const saveData = () => {
  1065. try {
  1066. const data = {};
  1067. $('#globalOptionsForm').serializeArray().map(value => {
  1068. data[value.name] = value.value;
  1069. return value;
  1070. });
  1071. $.makeArray($('#globalOptionsForm input')).map(element => {
  1072. const name = $(element).attr('name');
  1073. const keys = name.split('.');
  1074. if (keys.length === 3) {
  1075. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1076. } else if (keys.length === 2) {
  1077. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1078. }
  1079. return element;
  1080. });
  1081. GM_setValue('globalOptions', globalOptions);
  1082. external_Swal_default().fire({
  1083. title: i18n('changeGlobalOptionsSuccess'),
  1084. icon: 'success'
  1085. });
  1086. } catch (error) {
  1087. throwError(error, 'saveData');
  1088. }
  1089. };
  1090. const changeGlobalOptions = showType => {
  1091. try {
  1092. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1093. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1094. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1095. for (const [ option, data2 ] of Object.entries(data1)) {
  1096. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1097. if (typeof data2 === 'boolean') {
  1098. 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>`;
  1099. } else {
  1100. 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>`;
  1101. }
  1102. } else {
  1103. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1104. 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>`;
  1105. }
  1106. }
  1107. }
  1108. }
  1109. globalOptionsForm += '</tbody></table></form>';
  1110. if (showType === 'swal') {
  1111. external_Swal_default().fire({
  1112. title: i18n('globalOptions'),
  1113. html: globalOptionsForm,
  1114. showConfirmButton: true,
  1115. confirmButtonText: i18n('save'),
  1116. showCancelButton: true,
  1117. cancelButtonText: i18n('close')
  1118. }).then(_ref => {
  1119. let {
  1120. isConfirmed
  1121. } = _ref;
  1122. if (isConfirmed) {
  1123. saveData();
  1124. }
  1125. });
  1126. } else {
  1127. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1128. }
  1129. } catch (error) {
  1130. throwError(error, 'changeGlobalOptions');
  1131. }
  1132. };
  1133. const data = {
  1134. website: '网站',
  1135. type: '类型',
  1136. edit: '编辑',
  1137. whiteList: '白名单',
  1138. skipTask: '跳过撤销任务',
  1139. whiteListOptions: '白名单设置',
  1140. changeWhiteListOption: '设置白名单(%0)',
  1141. whiteListNotFound: '找不到此项白名单: %0',
  1142. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1143. changeWebsiteOptions: '网站设置',
  1144. changeGlobalOptions: '全局设置',
  1145. ok: '是',
  1146. save: '保存',
  1147. close: '关闭',
  1148. return: '返回',
  1149. option: '选项',
  1150. value: '值',
  1151. websiteOptions: '当前网站设置',
  1152. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1153. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1154. needLogin: '请先登录!',
  1155. getTasksInfo: '正在获取并处理任务信息...',
  1156. gettingKey: '正在获取Key...',
  1157. verifyingTask: '正在验证任务',
  1158. notice: '自动任务脚本提醒',
  1159. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1160. giveawayEnded: '此活动已结束,是否关闭?',
  1161. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1162. confirm: '确定',
  1163. cancel: '取消',
  1164. unKnown: '未知',
  1165. unKnownTaskType: '未识别的任务',
  1166. doing: '正在做任务',
  1167. allTasksComplete: '所有任务已完成!',
  1168. getTaskIdFailed: '获取任务Id失败!',
  1169. initSuccess: '%0 初始化成功!',
  1170. initFailed: '%0 初始化失败!',
  1171. errorLink: '链接错误: %0',
  1172. needInit: '请先初始化',
  1173. verifyingAuth: '正在验证%0凭证...',
  1174. updatingAuth: '正在更新%0凭证...',
  1175. initing: '正在初始化...',
  1176. getFailed: '获取%0失败!',
  1177. checkLoginFailed: '检测登录状态失败!',
  1178. checkLeftKeyFailed: '检测剩余Key失败!',
  1179. userId: '用户Id',
  1180. joiningGiveaway: '正在加入赠Key',
  1181. needJoinGiveaway: '需要先加入赠Key',
  1182. cannotUndo: '此网站不支持取消任务',
  1183. verifyAuth: '正在验证 %0 凭证...',
  1184. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1185. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1186. visitingLink: '正在访问链接: ',
  1187. doTask: '做任务',
  1188. undoTask: '撤销任务',
  1189. verifyTask: '验证任务',
  1190. getKey: '获取Key',
  1191. selectAll: '全选',
  1192. selectNone: '全不选',
  1193. invertSelect: '反选',
  1194. doFreeTask: '加入免费赠品',
  1195. doPointTask: '加入点数赠品',
  1196. skipTaskOption: '设置中已配置跳过任务',
  1197. other: '其他',
  1198. globalOptions: '全局设置',
  1199. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1200. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1201. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1202. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1203. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1204. saveGlobalOptions: '保存全局设置',
  1205. settingPage: '设置页面',
  1206. name: '名称',
  1207. version: '版本',
  1208. scriptManager: '脚本管理器',
  1209. script: '脚本',
  1210. environment: '环境',
  1211. os: '系统',
  1212. browser: '浏览器',
  1213. getId: '获取 %0 id',
  1214. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1215. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1216. showButton: '显示按钮',
  1217. hideButton: '隐藏按钮',
  1218. showLog: '显示日志',
  1219. hideLog: '隐藏日志',
  1220. defaultShowButton: '默认显示按钮',
  1221. defaultShowLog: '默认显示日志',
  1222. position: '组件位置',
  1223. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1224. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1225. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1226. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1227. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1228. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1229. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1230. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1231. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1232. hotKey: '快捷键',
  1233. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1234. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1235. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1236. tasksHistory: '任务历史',
  1237. clearHistory: '清空历史',
  1238. clearHistoryFinished: '已清空任务历史!',
  1239. deleteTask: '删除任务',
  1240. lastChangeTime: '最后一次修改时间',
  1241. clearTaskFinished: '删除以下任务完成!',
  1242. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1243. syncData: '数据同步',
  1244. settingData: '正在上传数据...',
  1245. gettingData: '正在获取数据...',
  1246. help: '帮助',
  1247. fileName: '文件名',
  1248. upload2gist: '同步到Gist',
  1249. downloadFromGist: '从Gist同步',
  1250. saveAndTest: '保存配置并测试',
  1251. testSuccess: '测试成功!',
  1252. testFailed: '测试失败!',
  1253. saveAndTestNotice: '请先保存配置并测试!',
  1254. processingData: '正在处理数据...',
  1255. updatingData: '正在上传数据...',
  1256. syncDataSuccess: '同步数据成功!',
  1257. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1258. downloadingData: '正在下载数据...',
  1259. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1260. savingData: '正在保存数据...',
  1261. syncHistory: '同步任务历史',
  1262. checkUpdateFailed: '检测更新失败',
  1263. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1264. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1265. gistOptions: 'Gist 设置',
  1266. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1267. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1268. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1269. toGithub: '前往Github反馈',
  1270. toKeylol: '前往其乐论坛反馈',
  1271. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1272. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1273. updateText: '%0 版本更新内容:',
  1274. Active: '进行中',
  1275. Ended: '已结束',
  1276. Banned: '已封禁',
  1277. Paused: '已暂停',
  1278. notStart: '未开始',
  1279. groups: '组',
  1280. wishlists: '愿望单',
  1281. follows: '游戏关注',
  1282. forums: '论坛',
  1283. workshops: '创意工坊收藏',
  1284. curators: '鉴赏家',
  1285. workshopVotes: '创意工坊点赞',
  1286. announcements: '社区通知',
  1287. steamCommunity: 'Steam社区',
  1288. steamStore: 'Steam商店',
  1289. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1290. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1291. joiningSteamGroup: '正在加入Steam组',
  1292. leavingSteamGroup: '正在退出Steam组',
  1293. gettingSteamGroupId: '正在获取Steam组Id',
  1294. subscribingForum: '正在订阅Steam论坛',
  1295. unsubscribingForum: '正在取消订阅Steam论坛',
  1296. gettingForumId: '正在获取Steam论坛Id',
  1297. followingCurator: '正在关注Steam鉴赏家',
  1298. unfollowingCurator: '正在取关Steam鉴赏家',
  1299. addingToWishlist: '正在添加游戏到Steam愿望单',
  1300. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1301. followingGame: '正在关注Steam游戏',
  1302. unfollowingGame: '正在取关Steam游戏',
  1303. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1304. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1305. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1306. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1307. gettingAnnouncementParams: '正在获取Steam通知信息',
  1308. likingAnnouncement: '正在点赞Steam通知',
  1309. changingArea: '正在更换Steam地区: %0...',
  1310. notNeededChangeArea: '当前地区不需要更换',
  1311. noAnotherArea: '请检测是否开启正确开启代理',
  1312. gettingAreaInfo: '正在获取Steam地区信息...',
  1313. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1314. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1315. gettingSubid: '正在获取游戏subid',
  1316. addingFreeLicense: '正在入库',
  1317. missParams: '缺少参数',
  1318. servers: '服务器',
  1319. joiningDiscordServer: '正在加入Discord服务器',
  1320. leavingDiscordServer: '正在退出Discord服务器',
  1321. gettingDiscordGuild: '正在获取Discord服务器Id',
  1322. users: '用户',
  1323. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1324. insBanned: '您的Instagram账户已被封禁',
  1325. verifyingInsAuth: '正在验证Instagram凭证...',
  1326. gettingInsUserId: '正在获取Instagram用户Id',
  1327. followingIns: '正在关注Instagram用户',
  1328. unfollowingIns: '正在取关Instagram用户',
  1329. reddits: '社区/用户',
  1330. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1331. changingRedditVersion: '正在切换Reddit为新版页面...',
  1332. joiningReddit: '正在加入Reddit社区',
  1333. leavingReddit: '正在退出Reddit社区',
  1334. followingRedditUser: '正在关注Reddit用户',
  1335. unfollowingRedditUser: '正在取关Reddit用户',
  1336. channels: '频道',
  1337. followingTwitchChannel: '正在关注Twitch频道',
  1338. unfollowingTwitchChannel: '正在取关Twitch频道',
  1339. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1340. twitterUser: '推特用户',
  1341. retweets: '转推',
  1342. followingTwitterUser: '正在关注推特用户',
  1343. unfollowingTwitterUser: '正在取关推特用户',
  1344. retweetting: '正在转推',
  1345. unretweetting: '正在撤销转推',
  1346. names: '组/社区/动态',
  1347. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1348. gettingVkId: '正在获取Vk任务Id',
  1349. joiningVkGroup: '正在加入Vk组',
  1350. leavingVkGroup: '正在退出Vk组',
  1351. joiningVkPublic: '正在加入Vk社区',
  1352. leavingVkPublic: '正在退出Vk社区',
  1353. sendingVkWall: '正在转发Vk动态',
  1354. deletingVkWall: '正在撤销转发Vk动态',
  1355. youtubeChannel: 'YouTube频道',
  1356. likes: '点赞',
  1357. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1358. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1359. gettingYtbToken: '正在获取YouTube Token...',
  1360. followingYtbChannel: '正在订阅YouTube频道',
  1361. unfollowingYtbChannel: '正在退订YouTube频道',
  1362. likingYtbVideo: '正在点赞YouTube视频',
  1363. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1364. giveKeyNoticeBefore: '每次验证间隔15s',
  1365. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1366. noPoints: '点数不够,跳过抽奖',
  1367. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1368. joiningLottery: '正在加入抽奖',
  1369. doingGleamTask: '正在做Gleam任务...',
  1370. gettingGleamLink: '正在获取Gleam任务链接...',
  1371. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1372. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1373. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1374. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1375. };
  1376. const zh_CN = data;
  1377. const en_US_data = {
  1378. website: 'Website',
  1379. type: 'Type',
  1380. edit: 'Edit',
  1381. whiteList: 'Whitelist',
  1382. skipTask: 'Skip undo task',
  1383. whiteListOptions: 'Whitelist options',
  1384. changeWhiteListOption: 'Whitelist option(%0)',
  1385. whiteListNotFound: 'Cannot find this whitelist: %0',
  1386. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1387. changeWebsiteOptions: 'Website options',
  1388. changeGlobalOptions: 'Global options',
  1389. ok: 'OK',
  1390. save: 'Save',
  1391. close: 'Close',
  1392. return: 'Return',
  1393. option: 'Option',
  1394. value: 'Value',
  1395. websiteOptions: 'Current website settings',
  1396. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1397. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1398. needLogin: 'Please log in first!',
  1399. getTasksInfo: 'Obtaining and processing task information...',
  1400. gettingKey: 'Getting Key...',
  1401. verifyingTask: 'Verifying task',
  1402. notice: 'Automatic task script notice',
  1403. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1404. giveawayEnded: 'This event has ended, do you want to close it?',
  1405. 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?',
  1406. confirm: 'Confirm',
  1407. cancel: 'Cancel',
  1408. unKnown: 'Unknown',
  1409. unKnownTaskType: 'Unrecognized task',
  1410. doing: 'Doing a task',
  1411. allTasksComplete: 'All tasks have been completed!',
  1412. getTaskIdFailed: 'Failed to obtain task Id!',
  1413. initSuccess: '%0 was initialized successfully!',
  1414. initFailed: '%0 initialization failed!',
  1415. errorLink: 'Link error: %0',
  1416. needInit: 'Please initialize first',
  1417. verifyingAuth: 'Verifying %0 token...',
  1418. updatingAuth: 'Update %0 token...',
  1419. initing: 'Initializing...',
  1420. getFailed: 'Failed to get %0!',
  1421. checkLoginFailed: 'Failed to detect login status!',
  1422. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1423. userId: 'User Id',
  1424. joiningGiveaway: 'Joining giveaway',
  1425. needJoinGiveaway: 'Need to join the giveaway first',
  1426. cannotUndo: 'This website does not support canceling tasks',
  1427. verifyAuth: 'Verifying %0 token...',
  1428. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1429. errorReport: 'A script error is detected, do you want to report the BUG?',
  1430. visitingLink: 'Visiting link: ',
  1431. doTask: 'DoTask',
  1432. undoTask: 'UndoTask',
  1433. verifyTask: 'Verify',
  1434. getKey: 'GetKey',
  1435. selectAll: 'SelectAll',
  1436. selectNone: 'SelectNone',
  1437. invertSelect: 'InvertSelect',
  1438. doFreeTask: 'FreeTask',
  1439. doPointTask: 'PointTask',
  1440. skipTaskOption: 'Skip task has been configured in the settings',
  1441. other: 'Other',
  1442. globalOptions: 'Global Options',
  1443. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1444. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1445. 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.',
  1446. 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.',
  1447. 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.',
  1448. saveGlobalOptions: 'SaveSettings',
  1449. settingPage: 'Setting Page',
  1450. name: 'Name',
  1451. version: 'Version',
  1452. scriptManager: 'Script Manager',
  1453. script: 'Script',
  1454. environment: 'Environment',
  1455. os: 'OS',
  1456. browser: 'Browser',
  1457. getId: 'Get %0 id',
  1458. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1459. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1460. showButton: 'ShowButton',
  1461. hideButton: 'HideButton',
  1462. showLog: 'ShowLog',
  1463. hideLog: 'HideLog',
  1464. defaultShowButton: 'Default display button',
  1465. defaultShowLog: 'Display log by default',
  1466. position: 'Component position',
  1467. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1468. 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',
  1469. 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',
  1470. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1471. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1472. 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',
  1473. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1474. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1475. 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',
  1476. hotKey: 'Shortcut key',
  1477. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1478. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1479. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1480. tasksHistory: 'TasksHistory',
  1481. clearHistory: 'Clear history',
  1482. clearHistoryFinished: 'The mission history has been cleared!',
  1483. deleteTask: 'Delete task',
  1484. lastChangeTime: 'Last Change Time',
  1485. clearTaskFinished: 'Delete the following tasks completed!',
  1486. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1487. syncData: 'DataSync',
  1488. settingData: 'Uploading data...',
  1489. gettingData: 'Getting data...',
  1490. help: 'Help',
  1491. fileName: 'Filename',
  1492. upload2gist: 'Sync to Gist',
  1493. downloadFromGist: 'Sync from Gist',
  1494. saveAndTest: 'Save configuration and test',
  1495. testSuccess: 'Test success!',
  1496. testFailed: 'Test failed!',
  1497. saveAndTestNotice: 'Please save the configuration and test first!',
  1498. processingData: 'Processing data...',
  1499. updatingData: 'Uploading data...',
  1500. syncDataSuccess: 'Synchronized data successfully!',
  1501. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1502. downloadingData: 'Downloading data...',
  1503. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1504. savingData: 'Saving data...',
  1505. syncHistory: 'Synchronize tasks history',
  1506. checkUpdateFailed: 'Check update failed',
  1507. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1508. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1509. gistOptions: 'Gist Settings',
  1510. 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!',
  1511. 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!',
  1512. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1513. toGithub: 'Feedback(Github)',
  1514. toKeylol: 'Feedback(Keylol)',
  1515. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1516. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1517. updateText: 'Updates in version %0:',
  1518. Active: 'Active',
  1519. Ended: 'Ended',
  1520. Banned: 'Banned',
  1521. Paused: 'Paused',
  1522. notStart: 'notStart',
  1523. groups: 'Group',
  1524. wishlists: 'Wishlist',
  1525. follows: 'Follow Game',
  1526. forums: 'Forum',
  1527. workshops: 'Favorite Workshop',
  1528. curators: 'Curator',
  1529. workshopVotes: 'Voteup Workshop',
  1530. announcements: 'Announcement',
  1531. steamCommunity: 'Steam Community',
  1532. steamStore: 'Steam Store',
  1533. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1534. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1535. joiningSteamGroup: 'Joining Steam Group',
  1536. leavingSteamGroup: 'Leaving Steam Group',
  1537. gettingSteamGroupId: 'Getting Steam Group Id',
  1538. subscribingForum: 'Subscribing the Steam Forum',
  1539. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1540. gettingForumId: 'Getting Steam Forum Id',
  1541. followingCurator: 'Following Steam Curator',
  1542. unfollowingCurator: 'Unfollowing Steam Curator',
  1543. addingToWishlist: 'Adding the game to the Steam wishlist',
  1544. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1545. followingGame: 'Following Steam games',
  1546. unfollowingGame: 'Unfollowing Steam games',
  1547. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1548. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1549. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1550. votingUpWorkshop: 'Liking Steam workshop items',
  1551. gettingAnnouncementParams: 'Getting Steam announcement information',
  1552. likingAnnouncement: 'Liking Steam announcement',
  1553. changingArea: 'Changing Steam area: %0...',
  1554. notNeededChangeArea: 'The current area does not need to be changed',
  1555. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1556. gettingAreaInfo: 'Getting Steam area information...',
  1557. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1558. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1559. gettingSubid: 'Getting subid',
  1560. addingFreeLicense: 'Adding free license',
  1561. missParams: 'Missing parameters',
  1562. servers: 'Server',
  1563. joiningDiscordServer: 'Joining Discord Server',
  1564. leavingDiscordServer: 'Leaving Discord Server',
  1565. gettingDiscordGuild: 'Getting Discord server Id',
  1566. users: 'User',
  1567. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1568. insBanned: 'Your Instagram account has been banned',
  1569. verifyingInsAuth: 'Verifying Instagram token...',
  1570. gettingInsUserId: 'Getting Instagram user Id',
  1571. followingIns: 'Following Instagram user',
  1572. unfollowingIns: 'Unfollowing Instagram user',
  1573. reddits: 'Reddit/User',
  1574. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1575. changingRedditVersion: 'Switching Reddit to a new version page...',
  1576. joiningReddit: 'Joining the Reddit',
  1577. leavingReddit: 'Leaving the Reddit',
  1578. followingRedditUser: 'Following Reddit User',
  1579. unfollowingRedditUser: 'Unfollowing Reddit User',
  1580. channels: 'Channel',
  1581. followingTwitchChannel: 'Following Twitch Channel',
  1582. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1583. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1584. twitterUser: 'Twitter User',
  1585. retweets: 'Retweet',
  1586. followingTwitterUser: 'Following Twitter User',
  1587. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1588. retweetting: 'Retweetting',
  1589. unretweetting: 'Unretweetting',
  1590. names: 'Group/Public/Wall',
  1591. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1592. gettingVkId: 'Getting Vk task Id',
  1593. joiningVkGroup: 'Joining Vk Group',
  1594. leavingVkGroup: 'Leaving Vk Group',
  1595. joiningVkPublic: 'Joining Vk Public',
  1596. leavingVkPublic: 'Leaving Vk Public',
  1597. sendingVkWall: 'Sending Vk Wall',
  1598. deletingVkWall: 'Deleting Vk Wall',
  1599. youtubeChannel: 'YouTube Channel',
  1600. likes: 'Like',
  1601. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1602. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1603. gettingYtbToken: 'Getting YouTube Token...',
  1604. followingYtbChannel: 'Subscribing to YouTube channel',
  1605. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1606. likingYtbVideo: 'Liking YouTube video',
  1607. unlikingYtbVideo: 'Unliking YouTube video',
  1608. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1609. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1610. noPoints: 'Not enough points, skip the lottery',
  1611. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1612. joiningLottery: 'Joining the lottery',
  1613. doingGleamTask: 'Doing Gleam Task...',
  1614. gettingGleamLink: 'Getting Gleam task link...',
  1615. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1616. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1617. 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!',
  1618. 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...'
  1619. };
  1620. const en_US = en_US_data;
  1621. const languages = {
  1622. zh: zh_CN,
  1623. en: en_US
  1624. };
  1625. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1626. const I18n = function(key) {
  1627. var _languages$language;
  1628. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1629. argvs[_key - 1] = arguments[_key];
  1630. }
  1631. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1632. return key;
  1633. }
  1634. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1635. };
  1636. const i18n = I18n;
  1637. function throwError(error, name) {
  1638. external_Swal_default().fire({
  1639. title: i18n('errorReport'),
  1640. icon: 'error',
  1641. showCancelButton: true,
  1642. confirmButtonText: i18n('toGithub'),
  1643. showDenyButton: true,
  1644. denyButtonText: i18n('toKeylol'),
  1645. cancelButtonText: i18n('close')
  1646. }).then(_ref => {
  1647. let {
  1648. isDenied,
  1649. isConfirmed
  1650. } = _ref;
  1651. if (isConfirmed) {
  1652. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`脚本报错: ${name}`)}&labels=bug&body=${encodeURIComponent(`错误链接: [${window.location.href}](${window.location.href})
  1653.  
  1654. 环境:
  1655. \`\`\`
  1656. ${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}
  1657. \`\`\`
  1658. 脚本管理器: \`${GM_info.scriptHandler} ${GM_info.version}\`
  1659. 脚本版本: \`${GM_info.script.version}\`
  1660.  
  1661. 报错信息:
  1662. \`\`\`
  1663. ${error.stack}
  1664. \`\`\`
  1665.  
  1666. 执行日志:
  1667. \`\`\`
  1668. ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}
  1669. \`\`\`
  1670. `)}`, '_blank');
  1671. } else if (isDenied) {
  1672. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1673.  
  1674. 环境:
  1675.  
  1676. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1677.  
  1678. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1679. 脚本版本: ${GM_info.script.version}
  1680.  
  1681. 报错信息:
  1682. [code]${error.stack}[/code]
  1683.  
  1684. 执行日志:
  1685. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1686. GM_setClipboard(text);
  1687. external_Swal_default().fire({
  1688. title: i18n('copySuccess'),
  1689. icon: 'success',
  1690. confirmButtonText: i18n('ok')
  1691. }).then(() => {
  1692. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1693. });
  1694. }
  1695. });
  1696. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1697. }
  1698. function _defineProperty(obj, key, value) {
  1699. if (key in obj) {
  1700. Object.defineProperty(obj, key, {
  1701. value: value,
  1702. enumerable: true,
  1703. configurable: true,
  1704. writable: true
  1705. });
  1706. } else {
  1707. obj[key] = value;
  1708. }
  1709. return obj;
  1710. }
  1711. class Social {
  1712. constructor() {
  1713. _defineProperty(this, 'tasks', void 0);
  1714. }
  1715. getRealParams(name, links, doTask, link2param) {
  1716. try {
  1717. let realParams = [];
  1718. if (links.length > 0) {
  1719. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1720. }
  1721. if (!doTask && this.tasks[name].length > 0) {
  1722. realParams = [ ...realParams, ...this.tasks[name] ];
  1723. }
  1724. return unique(realParams);
  1725. } catch (error) {
  1726. throwError(error, 'Social.getRealParams');
  1727. return [];
  1728. }
  1729. }
  1730. }
  1731. const social_Social = Social;
  1732. function _classPrivateMethodInitSpec(obj, privateSet) {
  1733. _checkPrivateRedeclaration(obj, privateSet);
  1734. privateSet.add(obj);
  1735. }
  1736. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1737. _checkPrivateRedeclaration(obj, privateMap);
  1738. privateMap.set(obj, value);
  1739. }
  1740. function _checkPrivateRedeclaration(obj, privateCollection) {
  1741. if (privateCollection.has(obj)) {
  1742. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1743. }
  1744. }
  1745. function Discord_defineProperty(obj, key, value) {
  1746. if (key in obj) {
  1747. Object.defineProperty(obj, key, {
  1748. value: value,
  1749. enumerable: true,
  1750. configurable: true,
  1751. writable: true
  1752. });
  1753. } else {
  1754. obj[key] = value;
  1755. }
  1756. return obj;
  1757. }
  1758. function _classPrivateFieldSet(receiver, privateMap, value) {
  1759. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1760. _classApplyDescriptorSet(receiver, descriptor, value);
  1761. return value;
  1762. }
  1763. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1764. if (descriptor.set) {
  1765. descriptor.set.call(receiver, value);
  1766. } else {
  1767. if (!descriptor.writable) {
  1768. throw new TypeError('attempted to set read only private field');
  1769. }
  1770. descriptor.value = value;
  1771. }
  1772. }
  1773. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1774. if (!privateSet.has(receiver)) {
  1775. throw new TypeError('attempted to get private field on non-instance');
  1776. }
  1777. return fn;
  1778. }
  1779. function _classPrivateFieldGet(receiver, privateMap) {
  1780. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1781. return _classApplyDescriptorGet(receiver, descriptor);
  1782. }
  1783. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1784. if (!privateMap.has(receiver)) {
  1785. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1786. }
  1787. return privateMap.get(receiver);
  1788. }
  1789. function _classApplyDescriptorGet(receiver, descriptor) {
  1790. if (descriptor.get) {
  1791. return descriptor.get.call(receiver);
  1792. }
  1793. return descriptor.value;
  1794. }
  1795. const defaultTasks = JSON.stringify({
  1796. servers: []
  1797. });
  1798. var _auth = new WeakMap();
  1799. var _cache = new WeakMap();
  1800. var _initialized = new WeakMap();
  1801. var _verifyAuth = new WeakSet();
  1802. var _updateAuth = new WeakSet();
  1803. var _joinServer = new WeakSet();
  1804. var _leaveServer = new WeakSet();
  1805. var _getGuild = new WeakSet();
  1806. var _setCache = new WeakSet();
  1807. class Discord extends social_Social {
  1808. constructor() {
  1809. var _GM_getValue;
  1810. super(...arguments);
  1811. _classPrivateMethodInitSpec(this, _setCache);
  1812. _classPrivateMethodInitSpec(this, _getGuild);
  1813. _classPrivateMethodInitSpec(this, _leaveServer);
  1814. _classPrivateMethodInitSpec(this, _joinServer);
  1815. _classPrivateMethodInitSpec(this, _updateAuth);
  1816. _classPrivateMethodInitSpec(this, _verifyAuth);
  1817. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1818. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || JSON.parse(defaultTasks));
  1819. _classPrivateFieldInitSpec(this, _auth, {
  1820. writable: true,
  1821. value: GM_getValue('discordAuth') || {}
  1822. });
  1823. _classPrivateFieldInitSpec(this, _cache, {
  1824. writable: true,
  1825. value: GM_getValue('discordCache') || {}
  1826. });
  1827. _classPrivateFieldInitSpec(this, _initialized, {
  1828. writable: true,
  1829. value: false
  1830. });
  1831. }
  1832. async init() {
  1833. try {
  1834. if (_classPrivateFieldGet(this, _initialized)) {
  1835. return true;
  1836. }
  1837. if (!_classPrivateFieldGet(this, _auth).auth) {
  1838. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1839. _classPrivateFieldSet(this, _initialized, true);
  1840. return true;
  1841. }
  1842. return false;
  1843. }
  1844. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1845. if (isVerified) {
  1846. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1847. _classPrivateFieldSet(this, _initialized, true);
  1848. return true;
  1849. }
  1850. GM_setValue('discordAuth', {
  1851. auth: null
  1852. });
  1853. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1854. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1855. _classPrivateFieldSet(this, _initialized, true);
  1856. return true;
  1857. }
  1858. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1859. return false;
  1860. } catch (error) {
  1861. throwError(error, 'Discord.init');
  1862. return false;
  1863. }
  1864. }
  1865. async toggle(_ref) {
  1866. let {
  1867. doTask = true,
  1868. serverLinks = []
  1869. } = _ref;
  1870. try {
  1871. if (!_classPrivateFieldGet(this, _initialized)) {
  1872. scripts_echoLog({
  1873. text: i18n('needInit')
  1874. });
  1875. return false;
  1876. }
  1877. const prom = [];
  1878. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1879. scripts_echoLog({
  1880. type: 'globalOptionsSkip',
  1881. text: 'discord.servers'
  1882. });
  1883. } else {
  1884. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1885. var _link$match;
  1886. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1887. });
  1888. if (realServers.length > 0) {
  1889. for (const server of realServers) {
  1890. if (doTask) {
  1891. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1892. } else {
  1893. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1894. }
  1895. await delay(1e3);
  1896. }
  1897. }
  1898. }
  1899. return await Promise.all(prom).then(() => true);
  1900. } catch (error) {
  1901. throwError(error, 'Discord.toggleServers');
  1902. return false;
  1903. }
  1904. }
  1905. }
  1906. async function _verifyAuth2() {
  1907. try {
  1908. const logStatus = scripts_echoLog({
  1909. text: i18n('verifyingAuth', 'Discord')
  1910. });
  1911. const {
  1912. result,
  1913. statusText,
  1914. status,
  1915. data
  1916. } = await tools_httpRequest({
  1917. url: 'https://discord.com/api/v6/users/@me',
  1918. method: 'HEAD',
  1919. headers: {
  1920. authorization: _classPrivateFieldGet(this, _auth).auth
  1921. }
  1922. });
  1923. if (result === 'Success') {
  1924. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1925. logStatus.success();
  1926. return true;
  1927. }
  1928. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1929. return false;
  1930. }
  1931. logStatus.error(`${result}:${statusText}(${status})`);
  1932. return false;
  1933. } catch (error) {
  1934. throwError(error, 'Discord.verifyAuth');
  1935. return false;
  1936. }
  1937. }
  1938. async function _updateAuth2() {
  1939. try {
  1940. const logStatus = scripts_echoLog({
  1941. text: i18n('updatingAuth', 'Discord')
  1942. });
  1943. return await new Promise(resolve => {
  1944. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1945. active: true,
  1946. insert: true,
  1947. setParent: true
  1948. });
  1949. newTab.onclose = async () => {
  1950. var _GM_getValue2;
  1951. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1952. if (auth) {
  1953. _classPrivateFieldSet(this, _auth, {
  1954. auth: auth
  1955. });
  1956. logStatus.success();
  1957. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1958. } else {
  1959. logStatus.error('Error: Update discord auth failed!');
  1960. resolve(false);
  1961. }
  1962. };
  1963. });
  1964. } catch (error) {
  1965. throwError(error, 'Discord.updateAuth');
  1966. return false;
  1967. }
  1968. }
  1969. async function _joinServer2(inviteId) {
  1970. try {
  1971. const logStatus = scripts_echoLog({
  1972. type: 'joiningDiscordServer',
  1973. text: inviteId
  1974. });
  1975. const {
  1976. result,
  1977. statusText,
  1978. status,
  1979. data
  1980. } = await tools_httpRequest({
  1981. url: `https://discord.com/api/v6/invites/${inviteId}`,
  1982. method: 'POST',
  1983. dataType: 'json',
  1984. headers: {
  1985. authorization: _classPrivateFieldGet(this, _auth).auth
  1986. }
  1987. });
  1988. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1989. var _data$response, _data$response$guild;
  1990. logStatus.success();
  1991. 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);
  1992. if (guild) {
  1993. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  1994. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1995. }
  1996. return true;
  1997. }
  1998. logStatus.error(`${result}:${statusText}(${status})`);
  1999. return false;
  2000. } catch (error) {
  2001. throwError(error, 'Discord.joinServer');
  2002. return false;
  2003. }
  2004. }
  2005. async function _leaveServer2(inviteId) {
  2006. try {
  2007. if (this.whiteList.servers.includes(inviteId)) {
  2008. scripts_echoLog({
  2009. type: 'whiteList',
  2010. text: 'Discord.leaveServer',
  2011. id: inviteId
  2012. });
  2013. return true;
  2014. }
  2015. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2016. if (!guild) {
  2017. return false;
  2018. }
  2019. const logStatus = scripts_echoLog({
  2020. type: 'leavingDiscordServer',
  2021. text: guild
  2022. });
  2023. const {
  2024. result,
  2025. statusText,
  2026. status,
  2027. data
  2028. } = await tools_httpRequest({
  2029. url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
  2030. method: 'DELETE',
  2031. headers: {
  2032. authorization: _classPrivateFieldGet(this, _auth).auth
  2033. }
  2034. });
  2035. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2036. logStatus.success();
  2037. return true;
  2038. }
  2039. logStatus.error(`${result}:${statusText}(${status})`);
  2040. return false;
  2041. } catch (error) {
  2042. throwError(error, 'Discord.leaveServer');
  2043. return false;
  2044. }
  2045. }
  2046. async function _getGuild2(inviteId) {
  2047. try {
  2048. const logStatus = scripts_echoLog({
  2049. type: 'gettingDiscordGuild',
  2050. text: inviteId
  2051. });
  2052. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2053. if (guild) {
  2054. logStatus.success();
  2055. return guild;
  2056. }
  2057. const {
  2058. result,
  2059. statusText,
  2060. status,
  2061. data
  2062. } = await tools_httpRequest({
  2063. url: `https://discord.com/invite/${inviteId}`,
  2064. method: 'GET'
  2065. });
  2066. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2067. var _data$responseText$ma;
  2068. 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];
  2069. if (guild) {
  2070. logStatus.success();
  2071. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2072. return guild;
  2073. }
  2074. logStatus.error(`${result}:${statusText}(${status})`);
  2075. return false;
  2076. }
  2077. logStatus.error(`${result}:${statusText}(${status})`);
  2078. return false;
  2079. } catch (error) {
  2080. throwError(error, 'Discord.getGuild');
  2081. return false;
  2082. }
  2083. }
  2084. function _setCache2(inviteId, guild) {
  2085. try {
  2086. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2087. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2088. } catch (error) {
  2089. throwError(error, 'Discord.setCache');
  2090. }
  2091. }
  2092. const social_Discord = Discord;
  2093. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2094. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2095. privateSet.add(obj);
  2096. }
  2097. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2098. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2099. privateMap.set(obj, value);
  2100. }
  2101. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2102. if (privateCollection.has(obj)) {
  2103. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2104. }
  2105. }
  2106. function Instagram_defineProperty(obj, key, value) {
  2107. if (key in obj) {
  2108. Object.defineProperty(obj, key, {
  2109. value: value,
  2110. enumerable: true,
  2111. configurable: true,
  2112. writable: true
  2113. });
  2114. } else {
  2115. obj[key] = value;
  2116. }
  2117. return obj;
  2118. }
  2119. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2120. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2121. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2122. return value;
  2123. }
  2124. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2125. if (descriptor.set) {
  2126. descriptor.set.call(receiver, value);
  2127. } else {
  2128. if (!descriptor.writable) {
  2129. throw new TypeError('attempted to set read only private field');
  2130. }
  2131. descriptor.value = value;
  2132. }
  2133. }
  2134. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2135. if (!privateSet.has(receiver)) {
  2136. throw new TypeError('attempted to get private field on non-instance');
  2137. }
  2138. return fn;
  2139. }
  2140. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2141. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2142. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2143. }
  2144. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2145. if (!privateMap.has(receiver)) {
  2146. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2147. }
  2148. return privateMap.get(receiver);
  2149. }
  2150. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2151. if (descriptor.get) {
  2152. return descriptor.get.call(receiver);
  2153. }
  2154. return descriptor.value;
  2155. }
  2156. const Instagram_defaultTasks = JSON.stringify({
  2157. users: []
  2158. });
  2159. var Instagram_cache = new WeakMap();
  2160. var Instagram_auth = new WeakMap();
  2161. var Instagram_initialized = new WeakMap();
  2162. var _getUserInfo = new WeakSet();
  2163. var _followUser = new WeakSet();
  2164. var _unfollowUser = new WeakSet();
  2165. var Instagram_setCache = new WeakSet();
  2166. class Instagram extends social_Social {
  2167. constructor() {
  2168. var _GM_getValue;
  2169. super(...arguments);
  2170. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2171. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2172. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2173. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2174. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2175. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || JSON.parse(Instagram_defaultTasks));
  2176. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2177. writable: true,
  2178. value: GM_getValue('instagramCache') || {}
  2179. });
  2180. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2181. writable: true,
  2182. value: {}
  2183. });
  2184. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2185. writable: true,
  2186. value: false
  2187. });
  2188. }
  2189. async init() {
  2190. try {
  2191. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2192. return true;
  2193. }
  2194. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2195. if (isVerified) {
  2196. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2197. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2198. return true;
  2199. }
  2200. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2201. return false;
  2202. } catch (error) {
  2203. throwError(error, 'Instagram.init');
  2204. return false;
  2205. }
  2206. }
  2207. async toggle(_ref) {
  2208. let {
  2209. doTask = true,
  2210. userLinks = []
  2211. } = _ref;
  2212. try {
  2213. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2214. scripts_echoLog({
  2215. text: i18n('needInit')
  2216. });
  2217. return false;
  2218. }
  2219. const prom = [];
  2220. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2221. scripts_echoLog({
  2222. type: 'globalOptionsSkip',
  2223. text: 'instagram.users'
  2224. });
  2225. } else {
  2226. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2227. var _link$match;
  2228. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2229. });
  2230. if (realUsers.length > 0) {
  2231. for (const username of realUsers) {
  2232. if (doTask) {
  2233. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2234. } else {
  2235. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2236. }
  2237. await delay(1e3);
  2238. }
  2239. }
  2240. }
  2241. return await Promise.all(prom).then(() => true);
  2242. } catch (error) {
  2243. throwError(error, 'Instagram.toggleUsers');
  2244. return false;
  2245. }
  2246. }
  2247. }
  2248. async function _getUserInfo2() {
  2249. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2250. try {
  2251. const logStatus = scripts_echoLog({
  2252. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2253. text: name
  2254. });
  2255. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2256. if (userId && name !== 'instagram') {
  2257. logStatus.success();
  2258. return userId;
  2259. }
  2260. const {
  2261. result,
  2262. statusText,
  2263. status,
  2264. data
  2265. } = await tools_httpRequest({
  2266. url: `https://www.instagram.com/${name}/`,
  2267. method: 'GET'
  2268. });
  2269. if (result === 'Success') {
  2270. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2271. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2272. return false;
  2273. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2274. logStatus.error(`Error:${i18n('insBanned')}`);
  2275. return false;
  2276. }
  2277. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2278. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2279. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2280. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2281. if (name === 'instagram') {
  2282. if (csrftoken && hash) {
  2283. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2284. csrftoken: csrftoken,
  2285. hash: hash
  2286. });
  2287. return true;
  2288. }
  2289. return false;
  2290. }
  2291. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2292. if (id) {
  2293. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2294. logStatus.success();
  2295. return id;
  2296. }
  2297. logStatus.error('Error: Get ins data error!');
  2298. return false;
  2299. }
  2300. logStatus.error(`${result}:${statusText}(${status})`);
  2301. return false;
  2302. }
  2303. return false;
  2304. } catch (error) {
  2305. throwError(error, 'Instagram.getUserInfo');
  2306. return false;
  2307. }
  2308. }
  2309. async function _followUser2(name) {
  2310. try {
  2311. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2312. if (!id) {
  2313. return false;
  2314. }
  2315. const logStatus = scripts_echoLog({
  2316. type: 'followingIns',
  2317. text: name
  2318. });
  2319. const {
  2320. result,
  2321. statusText,
  2322. status,
  2323. data
  2324. } = await tools_httpRequest({
  2325. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2326. method: 'POST',
  2327. dataType: 'json',
  2328. headers: {
  2329. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2330. origin: 'https://www.instagram.com',
  2331. referer: `https://www.instagram.com/${name}/`,
  2332. 'content-type': 'application/x-www-form-urlencoded',
  2333. 'sec-fetch-site': 'same-origin',
  2334. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2335. }
  2336. });
  2337. if (result === 'Success') {
  2338. var _data$response, _data$response2;
  2339. 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') {
  2340. logStatus.success();
  2341. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2342. return true;
  2343. }
  2344. 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})`}`);
  2345. return false;
  2346. }
  2347. logStatus.error(`${result}:${statusText}(${status})`);
  2348. return false;
  2349. } catch (error) {
  2350. throwError(error, 'Instagram.followUser');
  2351. return false;
  2352. }
  2353. }
  2354. async function _unfollowUser2(name) {
  2355. try {
  2356. if (this.whiteList.users.includes(name)) {
  2357. scripts_echoLog({
  2358. type: 'whiteList',
  2359. text: 'Instagram.unfollowUser',
  2360. id: name
  2361. });
  2362. return true;
  2363. }
  2364. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2365. if (!id) {
  2366. return false;
  2367. }
  2368. const logStatus = scripts_echoLog({
  2369. type: 'unfollowingIns',
  2370. text: name
  2371. });
  2372. const {
  2373. result,
  2374. statusText,
  2375. status,
  2376. data
  2377. } = await tools_httpRequest({
  2378. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2379. method: 'POST',
  2380. dataType: 'json',
  2381. headers: {
  2382. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2383. origin: 'https://www.instagram.com',
  2384. referer: `https://www.instagram.com/${name}/`,
  2385. 'content-type': 'application/x-www-form-urlencoded',
  2386. 'sec-fetch-site': 'same-origin',
  2387. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2388. }
  2389. });
  2390. if (result === 'Success') {
  2391. var _data$response3;
  2392. 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') {
  2393. logStatus.success();
  2394. return true;
  2395. }
  2396. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2397. return false;
  2398. }
  2399. logStatus.error(`${result}:${statusText}(${status})`);
  2400. return false;
  2401. } catch (error) {
  2402. throwError(error, 'Instagram.unfollowUser');
  2403. return false;
  2404. }
  2405. }
  2406. function Instagram_setCache2(name, id) {
  2407. try {
  2408. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2409. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2410. } catch (error) {
  2411. throwError(error, 'Instagram.setCache');
  2412. }
  2413. }
  2414. const social_Instagram = Instagram;
  2415. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2416. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2417. privateSet.add(obj);
  2418. }
  2419. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2420. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2421. privateMap.set(obj, value);
  2422. }
  2423. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2424. if (privateCollection.has(obj)) {
  2425. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2426. }
  2427. }
  2428. function Reddit_defineProperty(obj, key, value) {
  2429. if (key in obj) {
  2430. Object.defineProperty(obj, key, {
  2431. value: value,
  2432. enumerable: true,
  2433. configurable: true,
  2434. writable: true
  2435. });
  2436. } else {
  2437. obj[key] = value;
  2438. }
  2439. return obj;
  2440. }
  2441. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2442. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2443. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2444. return value;
  2445. }
  2446. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2447. if (descriptor.set) {
  2448. descriptor.set.call(receiver, value);
  2449. } else {
  2450. if (!descriptor.writable) {
  2451. throw new TypeError('attempted to set read only private field');
  2452. }
  2453. descriptor.value = value;
  2454. }
  2455. }
  2456. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2457. if (!privateSet.has(receiver)) {
  2458. throw new TypeError('attempted to get private field on non-instance');
  2459. }
  2460. return fn;
  2461. }
  2462. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2463. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2464. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2465. }
  2466. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2467. if (!privateMap.has(receiver)) {
  2468. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2469. }
  2470. return privateMap.get(receiver);
  2471. }
  2472. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2473. if (descriptor.get) {
  2474. return descriptor.get.call(receiver);
  2475. }
  2476. return descriptor.value;
  2477. }
  2478. const Reddit_defaultTasks = JSON.stringify({
  2479. reddits: []
  2480. });
  2481. var Reddit_auth = new WeakMap();
  2482. var Reddit_initialized = new WeakMap();
  2483. var _useBeta = new WeakSet();
  2484. var Reddit_updateAuth = new WeakSet();
  2485. class Reddit extends social_Social {
  2486. constructor() {
  2487. var _GM_getValue;
  2488. super(...arguments);
  2489. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2490. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2491. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2492. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || JSON.parse(Reddit_defaultTasks));
  2493. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2494. writable: true,
  2495. value: void 0
  2496. });
  2497. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2498. writable: true,
  2499. value: false
  2500. });
  2501. }
  2502. async init() {
  2503. try {
  2504. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2505. return true;
  2506. }
  2507. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2508. if (isVerified) {
  2509. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2510. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2511. return true;
  2512. }
  2513. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2514. return false;
  2515. } catch (error) {
  2516. throwError(error, 'Reddit.init');
  2517. return false;
  2518. }
  2519. }
  2520. async toggleTask(_ref) {
  2521. let {
  2522. name,
  2523. doTask = true
  2524. } = _ref;
  2525. try {
  2526. if (!doTask && this.whiteList.reddits.includes(name)) {
  2527. scripts_echoLog({
  2528. type: 'whiteList',
  2529. text: 'Reddit.undoTask',
  2530. id: name
  2531. });
  2532. return true;
  2533. }
  2534. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2535. if (/^u_/.test(name)) {
  2536. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2537. }
  2538. const logStatus = scripts_echoLog({
  2539. type: type,
  2540. text: name
  2541. });
  2542. const {
  2543. result,
  2544. statusText,
  2545. status,
  2546. data
  2547. } = await tools_httpRequest({
  2548. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2549. method: 'POST',
  2550. headers: {
  2551. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2552. 'content-type': 'application/x-www-form-urlencoded'
  2553. },
  2554. data: $.param({
  2555. action: doTask ? 'sub' : 'unsub',
  2556. sr_name: name,
  2557. api_type: 'json'
  2558. })
  2559. });
  2560. if (result === 'Success') {
  2561. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2562. logStatus.success();
  2563. if (doTask) {
  2564. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2565. }
  2566. return true;
  2567. }
  2568. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2569. return false;
  2570. }
  2571. logStatus.error(`${result}:${statusText}(${status})`);
  2572. return false;
  2573. } catch (error) {
  2574. throwError(error, 'Reddit.toggleTask');
  2575. return false;
  2576. }
  2577. }
  2578. async toggle(_ref2) {
  2579. let {
  2580. doTask = true,
  2581. redditLinks = []
  2582. } = _ref2;
  2583. try {
  2584. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2585. scripts_echoLog({
  2586. text: i18n('needInit')
  2587. });
  2588. return false;
  2589. }
  2590. const prom = [];
  2591. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2592. scripts_echoLog({
  2593. type: 'globalOptionsSkip',
  2594. text: 'reddit.reddits'
  2595. });
  2596. } else {
  2597. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2598. var _link$match, _link$match2;
  2599. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2600. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2601. if (userName) {
  2602. return name || userName;
  2603. }
  2604. return name;
  2605. });
  2606. if (realReddits.length > 0) {
  2607. for (const name of realReddits) {
  2608. prom.push(this.toggleTask({
  2609. name: name,
  2610. doTask: doTask
  2611. }));
  2612. await delay(1e3);
  2613. }
  2614. }
  2615. }
  2616. return await Promise.all(prom).then(() => true);
  2617. } catch (error) {
  2618. throwError(error, 'Reddit.toggle');
  2619. return false;
  2620. }
  2621. }
  2622. }
  2623. async function _useBeta2() {
  2624. try {
  2625. const logStatus = scripts_echoLog({
  2626. text: i18n('changingRedditVersion')
  2627. });
  2628. GM_setValue('redditAuth', null);
  2629. return await new Promise(resolve => {
  2630. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2631. active: true,
  2632. insert: true,
  2633. setParent: true
  2634. });
  2635. newTab.onclose = async () => {
  2636. logStatus.success();
  2637. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2638. };
  2639. });
  2640. } catch (error) {
  2641. throwError(error, 'Reddit.useBeta');
  2642. return false;
  2643. }
  2644. }
  2645. async function Reddit_updateAuth2() {
  2646. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2647. try {
  2648. const logStatus = scripts_echoLog({
  2649. text: i18n('updatingAuth', 'Reddit')
  2650. });
  2651. const {
  2652. result,
  2653. statusText,
  2654. status,
  2655. data
  2656. } = await tools_httpRequest({
  2657. url: 'https://www.reddit.com/',
  2658. method: 'GET',
  2659. nochche: true,
  2660. headers: {
  2661. 'Cache-Control': 'no-cache'
  2662. }
  2663. });
  2664. if (result === 'Success') {
  2665. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2666. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2667. return false;
  2668. }
  2669. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2670. var _data$responseText$ma;
  2671. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2672. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2673. }
  2674. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2675. if (accessToken) {
  2676. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2677. token: accessToken
  2678. });
  2679. logStatus.success();
  2680. return true;
  2681. }
  2682. logStatus.error('Error: Parameter "accessToken" not found!');
  2683. return false;
  2684. }
  2685. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2686. return false;
  2687. }
  2688. logStatus.error(`${result}:${statusText}(${status})`);
  2689. return false;
  2690. } catch (error) {
  2691. throwError(error, 'Reddit.updateAuth');
  2692. return false;
  2693. }
  2694. }
  2695. const social_Reddit = Reddit;
  2696. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2697. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2698. privateSet.add(obj);
  2699. }
  2700. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2701. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2702. privateMap.set(obj, value);
  2703. }
  2704. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2705. if (privateCollection.has(obj)) {
  2706. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2707. }
  2708. }
  2709. function Twitch_defineProperty(obj, key, value) {
  2710. if (key in obj) {
  2711. Object.defineProperty(obj, key, {
  2712. value: value,
  2713. enumerable: true,
  2714. configurable: true,
  2715. writable: true
  2716. });
  2717. } else {
  2718. obj[key] = value;
  2719. }
  2720. return obj;
  2721. }
  2722. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2723. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2724. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2725. return value;
  2726. }
  2727. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2728. if (descriptor.set) {
  2729. descriptor.set.call(receiver, value);
  2730. } else {
  2731. if (!descriptor.writable) {
  2732. throw new TypeError('attempted to set read only private field');
  2733. }
  2734. descriptor.value = value;
  2735. }
  2736. }
  2737. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2738. if (!privateSet.has(receiver)) {
  2739. throw new TypeError('attempted to get private field on non-instance');
  2740. }
  2741. return fn;
  2742. }
  2743. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2744. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2745. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2746. }
  2747. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2748. if (!privateMap.has(receiver)) {
  2749. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2750. }
  2751. return privateMap.get(receiver);
  2752. }
  2753. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2754. if (descriptor.get) {
  2755. return descriptor.get.call(receiver);
  2756. }
  2757. return descriptor.value;
  2758. }
  2759. const Twitch_defaultTasks = JSON.stringify({
  2760. channels: []
  2761. });
  2762. var Twitch_auth = new WeakMap();
  2763. var Twitch_cache = new WeakMap();
  2764. var Twitch_initialized = new WeakMap();
  2765. var Twitch_verifyAuth = new WeakSet();
  2766. var Twitch_updateAuth = new WeakSet();
  2767. var _toggleChannel = new WeakSet();
  2768. var _getChannelId = new WeakSet();
  2769. var Twitch_setCache = new WeakSet();
  2770. class Twitch extends social_Social {
  2771. constructor() {
  2772. var _GM_getValue;
  2773. super(...arguments);
  2774. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2775. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2776. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2777. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2778. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2779. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2780. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || JSON.parse(Twitch_defaultTasks));
  2781. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2782. writable: true,
  2783. value: GM_getValue('twitchAuth') || {}
  2784. });
  2785. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2786. writable: true,
  2787. value: GM_getValue('twitchCache') || {}
  2788. });
  2789. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2790. writable: true,
  2791. value: false
  2792. });
  2793. }
  2794. async init() {
  2795. try {
  2796. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2797. return true;
  2798. }
  2799. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2800. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2801. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2802. return true;
  2803. }
  2804. return false;
  2805. }
  2806. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2807. if (isVerified) {
  2808. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2809. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2810. return true;
  2811. }
  2812. GM_setValue('twitchAuth', null);
  2813. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2814. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2815. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2816. return true;
  2817. }
  2818. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2819. return false;
  2820. } catch (error) {
  2821. throwError(error, 'Twitch.init');
  2822. return false;
  2823. }
  2824. }
  2825. async toggle(_ref) {
  2826. let {
  2827. doTask = true,
  2828. channelLinks = []
  2829. } = _ref;
  2830. try {
  2831. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2832. scripts_echoLog({
  2833. text: i18n('needInit')
  2834. });
  2835. return false;
  2836. }
  2837. const prom = [];
  2838. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2839. scripts_echoLog({
  2840. type: 'globalOptionsSkip',
  2841. text: 'twitch.channels'
  2842. });
  2843. } else {
  2844. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2845. var _link$match;
  2846. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2847. });
  2848. if (realChannels.length > 0) {
  2849. for (const channel of realChannels) {
  2850. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2851. name: channel,
  2852. doTask: doTask
  2853. }));
  2854. await delay(1e3);
  2855. }
  2856. }
  2857. }
  2858. return Promise.all(prom).then(() => true);
  2859. } catch (error) {
  2860. throwError(error, 'Twitch.toggle');
  2861. return false;
  2862. }
  2863. }
  2864. }
  2865. async function Twitch_verifyAuth2() {
  2866. try {
  2867. const logStatus = scripts_echoLog({
  2868. text: i18n('verifyingAuth', 'Twitch')
  2869. });
  2870. const {
  2871. result,
  2872. statusText,
  2873. status,
  2874. data
  2875. } = await tools_httpRequest({
  2876. url: 'https://gql.twitch.tv/gql',
  2877. method: 'POST',
  2878. dataType: 'json',
  2879. headers: {
  2880. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2881. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2882. },
  2883. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2884. });
  2885. if (result === 'Success') {
  2886. var _data$response, _data$response$, _data$response$$data;
  2887. 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) {
  2888. logStatus.success();
  2889. return true;
  2890. }
  2891. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2892. return false;
  2893. }
  2894. logStatus.error(`${result}:${statusText}(${status})`);
  2895. return false;
  2896. } catch (error) {
  2897. throwError(error, 'Twitch.verifyAuth');
  2898. return false;
  2899. }
  2900. }
  2901. async function Twitch_updateAuth2() {
  2902. try {
  2903. const logStatus = scripts_echoLog({
  2904. text: i18n('updatingAuth', 'Twitch')
  2905. });
  2906. return await new Promise(resolve => {
  2907. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2908. active: true,
  2909. insert: true,
  2910. setParent: true
  2911. });
  2912. newTab.onclose = async () => {
  2913. const auth = GM_getValue('twitchAuth');
  2914. if (auth) {
  2915. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2916. logStatus.success();
  2917. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2918. } else {
  2919. logStatus.error('Error: Update twitch auth failed!');
  2920. resolve(false);
  2921. }
  2922. };
  2923. });
  2924. } catch (error) {
  2925. throwError(error, 'Twitch.updateAuth');
  2926. return false;
  2927. }
  2928. }
  2929. async function _toggleChannel2(_ref2) {
  2930. let {
  2931. name,
  2932. doTask = true
  2933. } = _ref2;
  2934. try {
  2935. if (!doTask && this.whiteList.channels.includes(name)) {
  2936. scripts_echoLog({
  2937. type: 'whiteList',
  2938. text: 'Twitch.unfollowChannel',
  2939. id: name
  2940. });
  2941. return true;
  2942. }
  2943. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2944. if (!channelId) {
  2945. return false;
  2946. }
  2947. const logStatus = scripts_echoLog({
  2948. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2949. text: name
  2950. });
  2951. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2952. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2953. const {
  2954. result,
  2955. statusText,
  2956. status,
  2957. data
  2958. } = await tools_httpRequest({
  2959. url: 'https://gql.twitch.tv/gql',
  2960. method: 'POST',
  2961. dataType: 'json',
  2962. headers: {
  2963. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2964. },
  2965. data: doTask ? followData : unfollowData
  2966. });
  2967. if (result === 'Success') {
  2968. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2969. logStatus.success();
  2970. if (doTask) {
  2971. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2972. }
  2973. return true;
  2974. }
  2975. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2976. return false;
  2977. }
  2978. logStatus.error(`${result}:${statusText}(${status})`);
  2979. return false;
  2980. } catch (error) {
  2981. throwError(error, 'Twitch.toggleChannel');
  2982. return false;
  2983. }
  2984. }
  2985. async function _getChannelId2(name) {
  2986. try {
  2987. const logStatus = scripts_echoLog({
  2988. type: 'gettingTwitchChannelId',
  2989. text: name
  2990. });
  2991. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  2992. if (channelId) {
  2993. logStatus.success();
  2994. return channelId;
  2995. }
  2996. const {
  2997. result,
  2998. statusText,
  2999. status,
  3000. data
  3001. } = await tools_httpRequest({
  3002. url: 'https://gql.twitch.tv/gql',
  3003. method: 'POST',
  3004. headers: {
  3005. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3006. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3007. },
  3008. responseType: 'json',
  3009. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3010. });
  3011. if (result === 'Success') {
  3012. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3013. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3014. 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);
  3015. if (channelId) {
  3016. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3017. logStatus.success();
  3018. return channelId;
  3019. }
  3020. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3021. return false;
  3022. }
  3023. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3024. return false;
  3025. }
  3026. logStatus.error(`${result}:${statusText}(${status})`);
  3027. return false;
  3028. } catch (error) {
  3029. throwError(error, 'Twitch.getChannelId');
  3030. return false;
  3031. }
  3032. }
  3033. function Twitch_setCache2(name, id) {
  3034. try {
  3035. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3036. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3037. } catch (error) {
  3038. throwError(error, 'Twitch.setCache');
  3039. }
  3040. }
  3041. const social_Twitch = Twitch;
  3042. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3043. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3044. privateSet.add(obj);
  3045. }
  3046. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3047. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3048. privateMap.set(obj, value);
  3049. }
  3050. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3051. if (privateCollection.has(obj)) {
  3052. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3053. }
  3054. }
  3055. function Twitter_defineProperty(obj, key, value) {
  3056. if (key in obj) {
  3057. Object.defineProperty(obj, key, {
  3058. value: value,
  3059. enumerable: true,
  3060. configurable: true,
  3061. writable: true
  3062. });
  3063. } else {
  3064. obj[key] = value;
  3065. }
  3066. return obj;
  3067. }
  3068. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3069. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3070. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3071. return value;
  3072. }
  3073. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3074. if (descriptor.set) {
  3075. descriptor.set.call(receiver, value);
  3076. } else {
  3077. if (!descriptor.writable) {
  3078. throw new TypeError('attempted to set read only private field');
  3079. }
  3080. descriptor.value = value;
  3081. }
  3082. }
  3083. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3084. if (!privateSet.has(receiver)) {
  3085. throw new TypeError('attempted to get private field on non-instance');
  3086. }
  3087. return fn;
  3088. }
  3089. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3090. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3091. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3092. }
  3093. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3094. if (!privateMap.has(receiver)) {
  3095. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3096. }
  3097. return privateMap.get(receiver);
  3098. }
  3099. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3100. if (descriptor.get) {
  3101. return descriptor.get.call(receiver);
  3102. }
  3103. return descriptor.value;
  3104. }
  3105. const Twitter_defaultTasks = JSON.stringify({
  3106. users: [],
  3107. retweets: [],
  3108. likes: []
  3109. });
  3110. var _verifyId = new WeakMap();
  3111. var Twitter_auth = new WeakMap();
  3112. var Twitter_cache = new WeakMap();
  3113. var Twitter_initialized = new WeakMap();
  3114. var Twitter_verifyAuth = new WeakSet();
  3115. var Twitter_updateAuth = new WeakSet();
  3116. var _toggleUser = new WeakSet();
  3117. var _toggleRetweet = new WeakSet();
  3118. var Twitter_setCache = new WeakSet();
  3119. class Twitter extends social_Social {
  3120. constructor() {
  3121. var _GM_getValue;
  3122. super(...arguments);
  3123. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3124. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3125. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3126. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3127. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3128. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3129. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || JSON.parse(Twitter_defaultTasks));
  3130. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3131. writable: true,
  3132. value: globalOptions.other.twitterVerifyId
  3133. });
  3134. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3135. writable: true,
  3136. value: GM_getValue('twitterAuth') || {}
  3137. });
  3138. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3139. writable: true,
  3140. value: GM_getValue('twitterCache') || {}
  3141. });
  3142. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3143. writable: true,
  3144. value: false
  3145. });
  3146. }
  3147. async init() {
  3148. try {
  3149. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3150. return true;
  3151. }
  3152. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3153. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3154. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3155. return true;
  3156. }
  3157. return false;
  3158. }
  3159. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3160. if (isVerified) {
  3161. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3162. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3163. return true;
  3164. }
  3165. GM_setValue('twitterAuth', null);
  3166. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3167. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3168. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3169. return true;
  3170. }
  3171. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3172. return false;
  3173. } catch (error) {
  3174. throwError(error, 'Twitter.init');
  3175. return false;
  3176. }
  3177. }
  3178. async userName2id(name) {
  3179. try {
  3180. const logStatus = scripts_echoLog({
  3181. type: 'gettingTwitterUserId',
  3182. text: name
  3183. });
  3184. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3185. if (userId) {
  3186. logStatus.success();
  3187. return userId;
  3188. }
  3189. const {
  3190. result,
  3191. statusText,
  3192. status,
  3193. data
  3194. } = await tools_httpRequest({
  3195. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3196. method: 'GET',
  3197. headers: {
  3198. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3199. 'content-type': 'application/json'
  3200. },
  3201. responseType: 'json',
  3202. anonymous: true
  3203. });
  3204. if (result === 'Success') {
  3205. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3206. var _response, _response$data, _response$data$user;
  3207. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3208. if (!response) {
  3209. try {
  3210. response = JSON.parse(data.responseText);
  3211. } catch (error) {
  3212. response = null;
  3213. }
  3214. }
  3215. 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);
  3216. if (userId) {
  3217. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3218. logStatus.success();
  3219. return userId;
  3220. }
  3221. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3222. return false;
  3223. }
  3224. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3225. return false;
  3226. }
  3227. logStatus.error(`${result}:${statusText}(${status})`);
  3228. return false;
  3229. } catch (error) {
  3230. throwError(error, 'Twitter.getUserId');
  3231. return false;
  3232. }
  3233. }
  3234. async toggle(_ref) {
  3235. let {
  3236. doTask = true,
  3237. userLinks = [],
  3238. retweetLinks = []
  3239. } = _ref;
  3240. try {
  3241. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3242. scripts_echoLog({
  3243. text: i18n('needInit')
  3244. });
  3245. return false;
  3246. }
  3247. const prom = [];
  3248. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3249. scripts_echoLog({
  3250. type: 'globalOptionsSkip',
  3251. text: 'twitter.users'
  3252. });
  3253. } else {
  3254. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3255. var _link$match;
  3256. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3257. });
  3258. if (realUsers.length > 0) {
  3259. for (const user of realUsers) {
  3260. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3261. name: user,
  3262. doTask: doTask
  3263. }));
  3264. await delay(1e3);
  3265. }
  3266. }
  3267. }
  3268. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3269. scripts_echoLog({
  3270. type: 'globalOptionsSkip',
  3271. text: 'twitter.retweets'
  3272. });
  3273. } else {
  3274. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3275. var _link$match2;
  3276. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3277. });
  3278. if (realRetweets.length > 0) {
  3279. for (const retweet of realRetweets) {
  3280. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3281. retweetId: retweet,
  3282. doTask: doTask
  3283. }));
  3284. await delay(1e3);
  3285. }
  3286. }
  3287. }
  3288. return Promise.all(prom).then(() => true);
  3289. } catch (error) {
  3290. throwError(error, 'Twitter.toggle');
  3291. return false;
  3292. }
  3293. }
  3294. }
  3295. async function Twitter_verifyAuth2() {
  3296. try {
  3297. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3298. name: 'verify',
  3299. doTask: true,
  3300. verify: true
  3301. });
  3302. } catch (error) {
  3303. throwError(error, 'Twitter.verifyAuth');
  3304. return false;
  3305. }
  3306. }
  3307. async function Twitter_updateAuth2() {
  3308. try {
  3309. const logStatus = scripts_echoLog({
  3310. text: i18n('updatingAuth', 'Twitter')
  3311. });
  3312. return await new Promise(resolve => {
  3313. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3314. active: true,
  3315. insert: true,
  3316. setParent: true
  3317. });
  3318. newTab.onclose = async () => {
  3319. const auth = GM_getValue('twitterAuth');
  3320. if (auth) {
  3321. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3322. logStatus.success();
  3323. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3324. } else {
  3325. logStatus.error('Error: Update twitter auth failed!');
  3326. resolve(false);
  3327. }
  3328. };
  3329. });
  3330. } catch (error) {
  3331. throwError(error, 'Twitter.updateToken');
  3332. return false;
  3333. }
  3334. }
  3335. async function _toggleUser2(_ref2) {
  3336. let {
  3337. name,
  3338. doTask = true,
  3339. verify = false
  3340. } = _ref2;
  3341. try {
  3342. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3343. scripts_echoLog({
  3344. type: 'whiteList',
  3345. text: 'Twitter.unfollowUser',
  3346. id: name
  3347. });
  3348. return true;
  3349. }
  3350. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3351. if (!userId) {
  3352. return false;
  3353. }
  3354. const logStatus = verify ? scripts_echoLog({
  3355. text: i18n('verifyingAuth', 'Twitter')
  3356. }) : scripts_echoLog({
  3357. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3358. text: name
  3359. });
  3360. const {
  3361. result,
  3362. statusText,
  3363. status,
  3364. data
  3365. } = await tools_httpRequest({
  3366. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3367. method: 'POST',
  3368. headers: {
  3369. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3370. 'Content-Type': 'application/x-www-form-urlencoded',
  3371. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3372. },
  3373. responseType: 'json',
  3374. data: $.param({
  3375. include_profile_interstitial_type: 1,
  3376. include_blocking: 1,
  3377. include_blocked_by: 1,
  3378. include_followed_by: 1,
  3379. include_want_retweets: 1,
  3380. include_mute_edge: 1,
  3381. include_can_dm: 1,
  3382. include_can_media_tag: 1,
  3383. skip_status: 1,
  3384. id: userId
  3385. })
  3386. });
  3387. if (result === 'Success') {
  3388. var _data$response, _data$response$errors, _data$response$errors2;
  3389. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3390. logStatus.success();
  3391. if (doTask && !verify) {
  3392. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3393. }
  3394. return true;
  3395. }
  3396. 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) {
  3397. logStatus.success();
  3398. return true;
  3399. }
  3400. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3401. return false;
  3402. }
  3403. logStatus.error(`${result}:${statusText}(${status})`);
  3404. return false;
  3405. } catch (error) {
  3406. throwError(error, 'Twitter.toggleUser');
  3407. return false;
  3408. }
  3409. }
  3410. async function _toggleRetweet2(_ref3) {
  3411. let {
  3412. retweetId,
  3413. doTask = true
  3414. } = _ref3;
  3415. try {
  3416. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3417. scripts_echoLog({
  3418. type: 'whiteList',
  3419. text: 'Twitter.unretweet',
  3420. id: retweetId
  3421. });
  3422. return true;
  3423. }
  3424. const logStatus = scripts_echoLog({
  3425. type: `${doTask ? '' : 'un'}retweetting`,
  3426. text: retweetId
  3427. });
  3428. const {
  3429. result,
  3430. statusText,
  3431. status,
  3432. data
  3433. } = await tools_httpRequest({
  3434. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3435. method: 'POST',
  3436. headers: {
  3437. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3438. 'Content-Type': 'application/x-www-form-urlencoded',
  3439. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3440. },
  3441. data: $.param({
  3442. tweet_mode: 'extended',
  3443. id: retweetId
  3444. }),
  3445. responseType: 'json'
  3446. });
  3447. if (result === 'Success') {
  3448. var _data$response2, _data$response2$error, _data$response2$error2;
  3449. 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) {
  3450. logStatus.success();
  3451. if (doTask) {
  3452. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3453. }
  3454. return true;
  3455. }
  3456. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3457. return false;
  3458. }
  3459. logStatus.error(`${result}:${statusText}(${status})`);
  3460. return false;
  3461. } catch (error) {
  3462. throwError(error, 'Twitter.toggleRetweet');
  3463. return false;
  3464. }
  3465. }
  3466. function Twitter_setCache2(name, id) {
  3467. try {
  3468. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3469. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3470. } catch (error) {
  3471. throwError(error, 'Twitter.setCache');
  3472. }
  3473. }
  3474. const social_Twitter = Twitter;
  3475. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3476. Vk_checkPrivateRedeclaration(obj, privateSet);
  3477. privateSet.add(obj);
  3478. }
  3479. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3480. Vk_checkPrivateRedeclaration(obj, privateMap);
  3481. privateMap.set(obj, value);
  3482. }
  3483. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3484. if (privateCollection.has(obj)) {
  3485. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3486. }
  3487. }
  3488. function Vk_defineProperty(obj, key, value) {
  3489. if (key in obj) {
  3490. Object.defineProperty(obj, key, {
  3491. value: value,
  3492. enumerable: true,
  3493. configurable: true,
  3494. writable: true
  3495. });
  3496. } else {
  3497. obj[key] = value;
  3498. }
  3499. return obj;
  3500. }
  3501. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3502. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3503. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3504. return value;
  3505. }
  3506. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3507. if (descriptor.set) {
  3508. descriptor.set.call(receiver, value);
  3509. } else {
  3510. if (!descriptor.writable) {
  3511. throw new TypeError('attempted to set read only private field');
  3512. }
  3513. descriptor.value = value;
  3514. }
  3515. }
  3516. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3517. if (!privateSet.has(receiver)) {
  3518. throw new TypeError('attempted to get private field on non-instance');
  3519. }
  3520. return fn;
  3521. }
  3522. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3523. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3524. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3525. }
  3526. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3527. if (!privateMap.has(receiver)) {
  3528. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3529. }
  3530. return privateMap.get(receiver);
  3531. }
  3532. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3533. if (descriptor.get) {
  3534. return descriptor.get.call(receiver);
  3535. }
  3536. return descriptor.value;
  3537. }
  3538. const Vk_defaultTasks = JSON.stringify({
  3539. names: []
  3540. });
  3541. var _username = new WeakMap();
  3542. var Vk_cache = new WeakMap();
  3543. var Vk_initialized = new WeakMap();
  3544. var Vk_verifyAuth = new WeakSet();
  3545. var _toggleGroup = new WeakSet();
  3546. var _togglePublic = new WeakSet();
  3547. var _sendWall = new WeakSet();
  3548. var _deleteWall = new WeakSet();
  3549. var _getId = new WeakSet();
  3550. var _toggleVk = new WeakSet();
  3551. var Vk_setCache = new WeakSet();
  3552. class Vk extends social_Social {
  3553. constructor() {
  3554. var _GM_getValue;
  3555. super(...arguments);
  3556. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3557. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3558. Vk_classPrivateMethodInitSpec(this, _getId);
  3559. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3560. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3561. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3562. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3563. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3564. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3565. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || JSON.parse(Vk_defaultTasks));
  3566. Vk_classPrivateFieldInitSpec(this, _username, {
  3567. writable: true,
  3568. value: ''
  3569. });
  3570. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3571. writable: true,
  3572. value: GM_getValue('vkCache') || {}
  3573. });
  3574. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3575. writable: true,
  3576. value: false
  3577. });
  3578. }
  3579. async init() {
  3580. try {
  3581. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3582. return true;
  3583. }
  3584. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3585. if (isVerified) {
  3586. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3587. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3588. return true;
  3589. }
  3590. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3591. return false;
  3592. } catch (error) {
  3593. throwError(error, 'Vk.init');
  3594. return false;
  3595. }
  3596. }
  3597. async toggle(_ref) {
  3598. let {
  3599. doTask = true,
  3600. nameLinks = []
  3601. } = _ref;
  3602. try {
  3603. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3604. scripts_echoLog({
  3605. text: i18n('needInit')
  3606. });
  3607. return false;
  3608. }
  3609. const prom = [];
  3610. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3611. scripts_echoLog({
  3612. type: 'globalOptionsSkip',
  3613. text: 'vk.names'
  3614. });
  3615. } else {
  3616. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3617. var _link$match;
  3618. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3619. });
  3620. if (realNames.length > 0) {
  3621. for (const name of realNames) {
  3622. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3623. name: name,
  3624. doTask: doTask
  3625. }));
  3626. await delay(1e3);
  3627. }
  3628. }
  3629. }
  3630. return Promise.all(prom).then(() => true);
  3631. } catch (error) {
  3632. throwError(error, 'Vk.toggle');
  3633. return false;
  3634. }
  3635. }
  3636. }
  3637. async function Vk_verifyAuth2() {
  3638. try {
  3639. const logStatus = scripts_echoLog({
  3640. text: i18n('verifyAuth', 'Vk')
  3641. });
  3642. const {
  3643. result,
  3644. statusText,
  3645. status,
  3646. data
  3647. } = await tools_httpRequest({
  3648. url: 'https://vk.com/im',
  3649. method: 'GET'
  3650. });
  3651. if (result === 'Success') {
  3652. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3653. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3654. return false;
  3655. }
  3656. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3657. var _data$responseText$ma;
  3658. 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]) || '');
  3659. logStatus.success();
  3660. return true;
  3661. }
  3662. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3663. return false;
  3664. }
  3665. logStatus.error(`${result}:${statusText}(${status})`);
  3666. return false;
  3667. } catch (error) {
  3668. throwError(error, 'Vk.verifyAuth');
  3669. return false;
  3670. }
  3671. }
  3672. async function _toggleGroup2(name, dataParam) {
  3673. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3674. try {
  3675. const logStatus = scripts_echoLog({
  3676. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3677. text: name
  3678. });
  3679. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3680. logStatus.success();
  3681. return true;
  3682. }
  3683. const reqData = {
  3684. act: doTask ? 'enter' : 'leave',
  3685. al: 1,
  3686. gid: dataParam.groupId,
  3687. hash: dataParam.groupHash
  3688. };
  3689. if (doTask) {
  3690. reqData.context = '_';
  3691. }
  3692. const {
  3693. result,
  3694. statusText,
  3695. status,
  3696. data
  3697. } = await tools_httpRequest({
  3698. url: 'https://vk.com/al_groups.php',
  3699. method: 'POST',
  3700. headers: {
  3701. origin: 'https://vk.com',
  3702. referer: `https://vk.com/${name}`,
  3703. 'content-type': 'application/x-www-form-urlencoded'
  3704. },
  3705. data: $.param(reqData)
  3706. });
  3707. if (result === 'Success') {
  3708. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3709. logStatus.success();
  3710. if (doTask) {
  3711. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3712. }
  3713. return true;
  3714. }
  3715. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3716. return false;
  3717. }
  3718. logStatus.error(`${result}:${statusText}(${status})`);
  3719. return false;
  3720. } catch (error) {
  3721. throwError(error, 'Vk.toggleGroup');
  3722. return false;
  3723. }
  3724. }
  3725. async function _togglePublic2(name, dataParam) {
  3726. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3727. try {
  3728. const logStatus = scripts_echoLog({
  3729. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3730. text: name
  3731. });
  3732. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3733. logStatus.success();
  3734. return true;
  3735. }
  3736. const {
  3737. result,
  3738. statusText,
  3739. status,
  3740. data
  3741. } = await tools_httpRequest({
  3742. url: 'https://vk.com/al_public.php',
  3743. method: 'POST',
  3744. headers: {
  3745. origin: 'https://vk.com',
  3746. referer: `https://vk.com/${name}`,
  3747. 'content-type': 'application/x-www-form-urlencoded'
  3748. },
  3749. data: $.param({
  3750. act: doTask ? 'a_enter' : 'a_leave',
  3751. al: 1,
  3752. pid: dataParam.publicPid,
  3753. hash: dataParam.publicHash
  3754. })
  3755. });
  3756. if (result === 'Success') {
  3757. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3758. logStatus.success();
  3759. if (doTask) {
  3760. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3761. }
  3762. return true;
  3763. }
  3764. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3765. return false;
  3766. }
  3767. logStatus.error(`${result}:${statusText}(${status})`);
  3768. return false;
  3769. } catch (error) {
  3770. throwError(error, 'Vk.togglePublic');
  3771. return false;
  3772. }
  3773. }
  3774. async function _sendWall2(name) {
  3775. try {
  3776. const logStatus = scripts_echoLog({
  3777. type: 'sendingVkWall',
  3778. text: name
  3779. });
  3780. const {
  3781. result,
  3782. statusText,
  3783. status,
  3784. data
  3785. } = await tools_httpRequest({
  3786. url: 'https://vk.com/like.php',
  3787. method: 'POST',
  3788. headers: {
  3789. origin: 'https://vk.com',
  3790. referer: `https://vk.com/${name}`,
  3791. 'content-type': 'application/x-www-form-urlencoded'
  3792. },
  3793. data: $.param({
  3794. act: 'publish_box',
  3795. al: 1,
  3796. object: name
  3797. })
  3798. });
  3799. if (result === 'Success') {
  3800. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3801. var _data$responseText$ma2;
  3802. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3803. if (hash) {
  3804. const {
  3805. result: resultR,
  3806. statusText: statusTextR,
  3807. status: statusR,
  3808. data: dataR
  3809. } = await tools_httpRequest({
  3810. url: 'https://vk.com/like.php',
  3811. method: 'POST',
  3812. headers: {
  3813. origin: 'https://vk.com',
  3814. referer: `https://vk.com/${name}`,
  3815. 'content-type': 'application/x-www-form-urlencoded'
  3816. },
  3817. data: $.param({
  3818. Message: '',
  3819. act: 'a_do_publish',
  3820. al: 1,
  3821. close_comments: 0,
  3822. friends_only: 0,
  3823. from: 'box',
  3824. hash: hash,
  3825. list: '',
  3826. mark_as_ads: 0,
  3827. mute_notifications: 0,
  3828. object: name,
  3829. ret_data: 1,
  3830. to: 0
  3831. })
  3832. });
  3833. if (resultR === 'Success') {
  3834. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3835. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3836. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3837. 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) {
  3838. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3839. logStatus.success();
  3840. 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);
  3841. 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);
  3842. if (postId && ownerId) {
  3843. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3844. }
  3845. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3846. return true;
  3847. }
  3848. }
  3849. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3850. return false;
  3851. }
  3852. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3853. return false;
  3854. }
  3855. logStatus.error('Error: Get "hash" failed');
  3856. return false;
  3857. }
  3858. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3859. return false;
  3860. }
  3861. logStatus.error(`${result}:${statusText}(${status})`);
  3862. return false;
  3863. } catch (error) {
  3864. throwError(error, 'Vk.sendWall');
  3865. return false;
  3866. }
  3867. }
  3868. async function _deleteWall2(name, dataParams) {
  3869. try {
  3870. const logStatus = scripts_echoLog({
  3871. type: 'deletingVkWall',
  3872. text: name
  3873. });
  3874. const {
  3875. result,
  3876. statusText,
  3877. status,
  3878. data
  3879. } = await tools_httpRequest({
  3880. url: 'https://vk.com/al_wall.php?act=delete',
  3881. method: 'POST',
  3882. headers: {
  3883. origin: 'https://vk.com',
  3884. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3885. 'content-type': 'application/x-www-form-urlencoded'
  3886. },
  3887. data: $.param({
  3888. act: 'delete',
  3889. al: 1,
  3890. confirm: 0,
  3891. from: 'wkview',
  3892. hash: dataParams.wallHash,
  3893. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3894. })
  3895. });
  3896. if (result === 'Success') {
  3897. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3898. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3899. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3900. 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]) {
  3901. logStatus.success();
  3902. return true;
  3903. }
  3904. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3905. return false;
  3906. }
  3907. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3908. return false;
  3909. }
  3910. logStatus.error(`${result}:${statusText}(${status})`);
  3911. return false;
  3912. } catch (error) {
  3913. throwError(error, 'Vk.deleteWall');
  3914. return false;
  3915. }
  3916. }
  3917. async function _getId2(name, doTask) {
  3918. try {
  3919. let url = `https://vk.com/${name}`;
  3920. if (/^wall-/.test(name)) {
  3921. if (doTask) {
  3922. return {
  3923. type: 'sendWall'
  3924. };
  3925. }
  3926. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3927. return {
  3928. type: 'unSupport'
  3929. };
  3930. }
  3931. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3932. }
  3933. const logStatus = scripts_echoLog({
  3934. type: 'gettingVkId',
  3935. text: name
  3936. });
  3937. const {
  3938. result,
  3939. statusText,
  3940. status,
  3941. data
  3942. } = await tools_httpRequest({
  3943. url: url,
  3944. method: 'GET'
  3945. });
  3946. if (result === 'Success') {
  3947. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3948. var _data$responseText$ma3, _data$responseText$ma4;
  3949. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3950. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3951. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3952. const publicJoined = !data.responseText.includes('Public.subscribe');
  3953. if (groupAct && groupId && groupHash) {
  3954. logStatus.success();
  3955. return {
  3956. groupAct: groupAct,
  3957. groupId: groupId,
  3958. groupHash: groupHash,
  3959. type: 'group'
  3960. };
  3961. } else if (publicHash && publicPid) {
  3962. logStatus.success();
  3963. return {
  3964. publicHash: publicHash,
  3965. publicPid: publicPid,
  3966. publicJoined: publicJoined,
  3967. type: 'public'
  3968. };
  3969. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3970. var _data$responseText$ma5;
  3971. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3972. if (wallHash) {
  3973. logStatus.success();
  3974. return {
  3975. type: 'deleteWall',
  3976. wallHash: wallHash
  3977. };
  3978. }
  3979. } else if (name.includes('wall') && doTask) {
  3980. logStatus.success();
  3981. return {
  3982. type: 'sendWall'
  3983. };
  3984. }
  3985. logStatus.error('Error: Parameters not found!');
  3986. return false;
  3987. }
  3988. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3989. return false;
  3990. }
  3991. logStatus.error(`${result}:${statusText}(${status})`);
  3992. return false;
  3993. } catch (error) {
  3994. throwError(error, 'Vk.getId');
  3995. return false;
  3996. }
  3997. }
  3998. async function _toggleVk2(_ref2) {
  3999. let {
  4000. name,
  4001. doTask = true
  4002. } = _ref2;
  4003. try {
  4004. if (!doTask && this.whiteList.names.includes(name)) {
  4005. scripts_echoLog({
  4006. type: 'whiteList',
  4007. text: 'Vk.undoTask',
  4008. id: name
  4009. });
  4010. return true;
  4011. }
  4012. const formatName = name.replace(/\/$/, '');
  4013. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4014. if (!data) {
  4015. return false;
  4016. }
  4017. switch (data.type) {
  4018. case 'group':
  4019. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4020.  
  4021. case 'public':
  4022. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4023.  
  4024. case 'sendWall':
  4025. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4026.  
  4027. case 'deleteWall':
  4028. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4029.  
  4030. default:
  4031. return false;
  4032. }
  4033. } catch (error) {
  4034. throwError(error, 'Vk.toggleVk');
  4035. return false;
  4036. }
  4037. }
  4038. function Vk_setCache2(name, postId) {
  4039. try {
  4040. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4041. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4042. } catch (error) {
  4043. throwError(error, 'Vk.setCache');
  4044. }
  4045. }
  4046. const social_Vk = Vk;
  4047. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4048. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4049. privateSet.add(obj);
  4050. }
  4051. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4052. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4053. privateMap.set(obj, value);
  4054. }
  4055. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4056. if (privateCollection.has(obj)) {
  4057. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4058. }
  4059. }
  4060. function Youtube_defineProperty(obj, key, value) {
  4061. if (key in obj) {
  4062. Object.defineProperty(obj, key, {
  4063. value: value,
  4064. enumerable: true,
  4065. configurable: true,
  4066. writable: true
  4067. });
  4068. } else {
  4069. obj[key] = value;
  4070. }
  4071. return obj;
  4072. }
  4073. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4074. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4075. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4076. return value;
  4077. }
  4078. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4079. if (descriptor.set) {
  4080. descriptor.set.call(receiver, value);
  4081. } else {
  4082. if (!descriptor.writable) {
  4083. throw new TypeError('attempted to set read only private field');
  4084. }
  4085. descriptor.value = value;
  4086. }
  4087. }
  4088. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4089. if (!privateSet.has(receiver)) {
  4090. throw new TypeError('attempted to get private field on non-instance');
  4091. }
  4092. return fn;
  4093. }
  4094. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4095. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4096. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4097. }
  4098. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4099. if (!privateMap.has(receiver)) {
  4100. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4101. }
  4102. return privateMap.get(receiver);
  4103. }
  4104. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4105. if (descriptor.get) {
  4106. return descriptor.get.call(receiver);
  4107. }
  4108. return descriptor.value;
  4109. }
  4110. const Youtube_defaultTasks = JSON.stringify({
  4111. channels: [],
  4112. likes: []
  4113. });
  4114. const getInfo = async function(link, type) {
  4115. try {
  4116. const logStatus = scripts_echoLog({
  4117. text: i18n('gettingYtbToken')
  4118. });
  4119. const {
  4120. result,
  4121. statusText,
  4122. status,
  4123. data
  4124. } = await tools_httpRequest({
  4125. url: link,
  4126. method: 'GET'
  4127. });
  4128. if (result === 'Success') {
  4129. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4130. var _data$responseText$ma, _ref;
  4131. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4132. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4133. return {
  4134. needLogin: true
  4135. };
  4136. }
  4137. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4138. 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]) || '{}';
  4139. const {
  4140. client,
  4141. request
  4142. } = JSON.parse(context);
  4143. if (apiKey && client && request) {
  4144. client.hl = 'en';
  4145. if (type === 'channel') {
  4146. var _data$responseText$ma2;
  4147. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4148. if (channelId) {
  4149. logStatus.success();
  4150. return {
  4151. params: {
  4152. apiKey: apiKey,
  4153. client: client,
  4154. request: request,
  4155. channelId: channelId
  4156. }
  4157. };
  4158. }
  4159. logStatus.error('Error: Get "channelId" failed!');
  4160. return {};
  4161. } else if (type === 'likeVideo') {
  4162. var _data$responseText$ma3, _data$responseText$ma4;
  4163. 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];
  4164. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4165. if (videoId) {
  4166. logStatus.success();
  4167. return {
  4168. params: {
  4169. apiKey: apiKey,
  4170. client: client,
  4171. request: request,
  4172. videoId: videoId,
  4173. likeParams: likeParams
  4174. }
  4175. };
  4176. }
  4177. logStatus.error('Error: Get "videoId" failed!');
  4178. return {};
  4179. }
  4180. logStatus.error('Error: Unknown type');
  4181. return {};
  4182. }
  4183. logStatus.error('Error: Parameter "apiKey" not found!');
  4184. return {};
  4185. }
  4186. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4187. return {};
  4188. }
  4189. logStatus.error(`${result}:${statusText}(${status})`);
  4190. return {};
  4191. } catch (error) {
  4192. throwError(error, 'Youtube.getInfo');
  4193. return {};
  4194. }
  4195. };
  4196. var Youtube_auth = new WeakMap();
  4197. var Youtube_initialized = new WeakMap();
  4198. var _verifyChannel = new WeakMap();
  4199. var Youtube_verifyAuth = new WeakSet();
  4200. var Youtube_updateAuth = new WeakSet();
  4201. var _getInfo = new WeakSet();
  4202. var Youtube_toggleChannel = new WeakSet();
  4203. var _toggleLikeVideo = new WeakSet();
  4204. class Youtube extends social_Social {
  4205. constructor() {
  4206. var _GM_getValue;
  4207. super(...arguments);
  4208. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4209. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4210. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4211. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4212. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4213. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4214. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || JSON.parse(Youtube_defaultTasks));
  4215. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4216. writable: true,
  4217. value: GM_getValue('youtubeAuth') || {}
  4218. });
  4219. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4220. writable: true,
  4221. value: false
  4222. });
  4223. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4224. writable: true,
  4225. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4226. });
  4227. }
  4228. async init() {
  4229. try {
  4230. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4231. return true;
  4232. }
  4233. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4234. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4235. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4236. return true;
  4237. }
  4238. return false;
  4239. }
  4240. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4241. if (isVerified) {
  4242. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4243. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4244. return true;
  4245. }
  4246. GM_setValue('youtubeAuth', null);
  4247. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4248. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4249. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4250. return true;
  4251. }
  4252. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4253. return false;
  4254. } catch (error) {
  4255. throwError(error, 'Youtube.init');
  4256. return false;
  4257. }
  4258. }
  4259. async toggle(_ref2) {
  4260. let {
  4261. doTask = true,
  4262. channelLinks = [],
  4263. videoLinks = []
  4264. } = _ref2;
  4265. try {
  4266. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4267. scripts_echoLog({
  4268. text: i18n('needInit')
  4269. });
  4270. return false;
  4271. }
  4272. const prom = [];
  4273. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4274. scripts_echoLog({
  4275. type: 'globalOptionsSkip',
  4276. text: 'youtube.channels'
  4277. });
  4278. } else {
  4279. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4280. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4281. var _link$match;
  4282. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4283. }
  4284. return link;
  4285. });
  4286. if (realChannels.length > 0) {
  4287. for (const channel of realChannels) {
  4288. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4289. link: channel,
  4290. doTask: doTask
  4291. }));
  4292. await delay(1e3);
  4293. }
  4294. }
  4295. }
  4296. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4297. scripts_echoLog({
  4298. type: 'globalOptionsSkip',
  4299. text: 'youtube.likes'
  4300. });
  4301. } else {
  4302. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4303. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4304. var _link$match2;
  4305. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4306. }
  4307. return link;
  4308. });
  4309. if (realLikes.length > 0) {
  4310. for (const video of realLikes) {
  4311. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4312. link: video,
  4313. doTask: doTask
  4314. }));
  4315. await delay(1e3);
  4316. }
  4317. }
  4318. }
  4319. return Promise.all(prom).then(() => true);
  4320. } catch (error) {
  4321. throwError(error, 'Youtube.toggle');
  4322. return false;
  4323. }
  4324. }
  4325. }
  4326. async function Youtube_verifyAuth2() {
  4327. try {
  4328. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4329. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4330. doTask: true,
  4331. verify: true
  4332. });
  4333. } catch (error) {
  4334. throwError(error, 'Youtube.verifyAuth');
  4335. return false;
  4336. }
  4337. }
  4338. async function Youtube_updateAuth2() {
  4339. try {
  4340. const logStatus = scripts_echoLog({
  4341. text: i18n('updatingAuth', 'Youtube')
  4342. });
  4343. return await new Promise(resolve => {
  4344. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4345. active: true,
  4346. insert: true,
  4347. setParent: true
  4348. });
  4349. newTab.onclose = async () => {
  4350. const auth = GM_getValue('youtubeAuth');
  4351. if (auth) {
  4352. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4353. logStatus.success();
  4354. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4355. resolve(result);
  4356. });
  4357. } else {
  4358. logStatus.error('Error: Update youtube auth failed!');
  4359. resolve(false);
  4360. }
  4361. };
  4362. });
  4363. } catch (error) {
  4364. throwError(error, 'Discord.updateAuth');
  4365. return false;
  4366. }
  4367. }
  4368. function _getInfo2(link, type) {
  4369. return getInfo(link, type);
  4370. }
  4371. async function Youtube_toggleChannel2(_ref3) {
  4372. let {
  4373. link,
  4374. doTask = true,
  4375. verify = false
  4376. } = _ref3;
  4377. try {
  4378. const {
  4379. params,
  4380. needLogin
  4381. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4382. const {
  4383. apiKey,
  4384. client,
  4385. request,
  4386. channelId
  4387. } = params || {};
  4388. if (needLogin) {
  4389. scripts_echoLog({
  4390. html: i18n('loginYtb')
  4391. });
  4392. return false;
  4393. }
  4394. if (!(apiKey && client && request && channelId)) {
  4395. scripts_echoLog({
  4396. text: '"getYtbToken" failed'
  4397. });
  4398. return false;
  4399. }
  4400. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4401. scripts_echoLog({
  4402. type: 'whiteList',
  4403. text: 'Youtube.unfollowChannel',
  4404. id: channelId
  4405. });
  4406. return true;
  4407. }
  4408. const logStatus = verify ? scripts_echoLog({
  4409. text: i18n('verifyingAuth', 'Youtube')
  4410. }) : scripts_echoLog({
  4411. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4412. text: channelId
  4413. });
  4414. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4415. const {
  4416. result,
  4417. statusText,
  4418. status,
  4419. data
  4420. } = await tools_httpRequest({
  4421. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4422. method: 'POST',
  4423. headers: {
  4424. origin: 'https://www.youtube.com',
  4425. referer: `https://www.youtube.com/channel/${channelId}`,
  4426. 'content-type': 'application/json',
  4427. 'x-goog-authuser': '0',
  4428. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4429. 'x-origin': 'https://www.youtube.com',
  4430. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4431. },
  4432. data: JSON.stringify({
  4433. context: {
  4434. client: client,
  4435. request: {
  4436. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4437. internalExperimentFlags: [],
  4438. consistencyTokenJars: []
  4439. },
  4440. user: {}
  4441. },
  4442. channelIds: [ channelId ],
  4443. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4444. })
  4445. });
  4446. if (result === 'Success') {
  4447. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4448. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4449. logStatus.success();
  4450. if (doTask && !verify) {
  4451. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4452. }
  4453. return true;
  4454. }
  4455. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4456. logStatus.success();
  4457. return true;
  4458. }
  4459. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4460. return false;
  4461. }
  4462. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4463. return false;
  4464. }
  4465. logStatus.error(`${result}:${statusText}(${status})`);
  4466. return false;
  4467. } catch (error) {
  4468. throwError(error, 'Youtube.toggleChannel');
  4469. return false;
  4470. }
  4471. }
  4472. async function _toggleLikeVideo2(_ref4) {
  4473. let {
  4474. link,
  4475. doTask = true
  4476. } = _ref4;
  4477. try {
  4478. const {
  4479. params,
  4480. needLogin
  4481. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4482. const {
  4483. apiKey,
  4484. client,
  4485. request,
  4486. videoId,
  4487. likeParams
  4488. } = params || {};
  4489. if (needLogin) {
  4490. scripts_echoLog({
  4491. html: `${i18n('loginYtb')}`
  4492. });
  4493. return false;
  4494. }
  4495. if (!(apiKey && client && request && videoId && likeParams)) {
  4496. scripts_echoLog({
  4497. text: '"getYtbToken" failed'
  4498. });
  4499. return false;
  4500. }
  4501. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4502. scripts_echoLog({
  4503. type: 'whiteList',
  4504. text: 'Youtube.unlikeVideo',
  4505. id: videoId
  4506. });
  4507. return true;
  4508. }
  4509. const logStatus = scripts_echoLog({
  4510. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4511. text: videoId
  4512. });
  4513. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4514. const likeVideoData = {
  4515. context: {
  4516. client: client,
  4517. request: {
  4518. sessionId: request.sessionId,
  4519. internalExperimentFlags: [],
  4520. consistencyTokenJars: []
  4521. },
  4522. user: {}
  4523. },
  4524. target: {
  4525. videoId: videoId
  4526. }
  4527. };
  4528. if (doTask) {
  4529. if (likeParams) {
  4530. likeVideoData.params = likeParams;
  4531. } else {
  4532. logStatus.error('Empty likeParams');
  4533. return false;
  4534. }
  4535. }
  4536. const {
  4537. result,
  4538. statusText,
  4539. status,
  4540. data
  4541. } = await tools_httpRequest({
  4542. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4543. method: 'POST',
  4544. headers: {
  4545. origin: 'https://www.youtube.com',
  4546. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4547. 'content-type': 'application/json',
  4548. 'x-goog-authuser': '0',
  4549. 'x-goog-visitor-id': client.visitorData,
  4550. 'x-origin': 'https://www.youtube.com',
  4551. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4552. },
  4553. data: JSON.stringify(likeVideoData)
  4554. });
  4555. if (result === 'Success') {
  4556. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4557. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4558. logStatus.success();
  4559. if (doTask) {
  4560. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4561. }
  4562. return true;
  4563. }
  4564. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4565. return false;
  4566. }
  4567. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4568. return false;
  4569. }
  4570. logStatus.error(`${result}:${statusText}(${status})`);
  4571. return false;
  4572. } catch (error) {
  4573. throwError(error, 'Youtube.toggleLikeVideo');
  4574. return false;
  4575. }
  4576. }
  4577. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4578. Steam_checkPrivateRedeclaration(obj, privateSet);
  4579. privateSet.add(obj);
  4580. }
  4581. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4582. Steam_checkPrivateRedeclaration(obj, privateMap);
  4583. privateMap.set(obj, value);
  4584. }
  4585. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4586. if (privateCollection.has(obj)) {
  4587. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4588. }
  4589. }
  4590. function Steam_defineProperty(obj, key, value) {
  4591. if (key in obj) {
  4592. Object.defineProperty(obj, key, {
  4593. value: value,
  4594. enumerable: true,
  4595. configurable: true,
  4596. writable: true
  4597. });
  4598. } else {
  4599. obj[key] = value;
  4600. }
  4601. return obj;
  4602. }
  4603. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4604. if (!privateSet.has(receiver)) {
  4605. throw new TypeError('attempted to get private field on non-instance');
  4606. }
  4607. return fn;
  4608. }
  4609. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4610. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4611. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4612. return value;
  4613. }
  4614. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4615. if (descriptor.set) {
  4616. descriptor.set.call(receiver, value);
  4617. } else {
  4618. if (!descriptor.writable) {
  4619. throw new TypeError('attempted to set read only private field');
  4620. }
  4621. descriptor.value = value;
  4622. }
  4623. }
  4624. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4625. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4626. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4627. }
  4628. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4629. if (!privateMap.has(receiver)) {
  4630. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4631. }
  4632. return privateMap.get(receiver);
  4633. }
  4634. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4635. if (descriptor.get) {
  4636. return descriptor.get.call(receiver);
  4637. }
  4638. return descriptor.value;
  4639. }
  4640. const Steam_defaultTasks = JSON.stringify({
  4641. groups: [],
  4642. wishlists: [],
  4643. follows: [],
  4644. forums: [],
  4645. workshops: [],
  4646. workshopVotes: [],
  4647. curators: [],
  4648. curatorLikes: [],
  4649. announcements: []
  4650. });
  4651. var Steam_cache = new WeakMap();
  4652. var Steam_auth = new WeakMap();
  4653. var _storeInitialized = new WeakMap();
  4654. var _communityInitialized = new WeakMap();
  4655. var _area = new WeakMap();
  4656. var _updateStoreAuth = new WeakSet();
  4657. var _updateCommunityAuth = new WeakSet();
  4658. var _getAreaInfo = new WeakSet();
  4659. var _changeArea = new WeakSet();
  4660. var _joinGroup = new WeakSet();
  4661. var _leaveGroup = new WeakSet();
  4662. var _getGroupId = new WeakSet();
  4663. var _addToWishlist = new WeakSet();
  4664. var _removeFromWishlist = new WeakSet();
  4665. var _toggleFollowGame = new WeakSet();
  4666. var _isFollowedGame = new WeakSet();
  4667. var _toggleForum = new WeakSet();
  4668. var _getForumId = new WeakSet();
  4669. var _toggleFavoriteWorkshop = new WeakSet();
  4670. var _getWorkshopAppId = new WeakSet();
  4671. var _voteUpWorkshop = new WeakSet();
  4672. var _toggleCurator = new WeakSet();
  4673. var _toggleCuratorLike = new WeakSet();
  4674. var _getAnnouncementParams = new WeakSet();
  4675. var _likeAnnouncement = new WeakSet();
  4676. var _appid2subid = new WeakSet();
  4677. var _addLicense = new WeakSet();
  4678. var _addFreeLicense = new WeakSet();
  4679. var Steam_setCache = new WeakSet();
  4680. class Steam extends social_Social {
  4681. constructor() {
  4682. var _GM_getValue;
  4683. super(...arguments);
  4684. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4685. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4686. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4687. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4688. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4689. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4690. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4691. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4692. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4693. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4694. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4695. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4696. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4697. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4698. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4699. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4700. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4701. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4702. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4703. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4704. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4705. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4706. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4707. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4708. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4709. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || JSON.parse(Steam_defaultTasks));
  4710. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4711. writable: true,
  4712. value: GM_getValue('steamCache') || {
  4713. group: {},
  4714. forum: {},
  4715. workshop: {},
  4716. curator: {}
  4717. }
  4718. });
  4719. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4720. writable: true,
  4721. value: {}
  4722. });
  4723. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4724. writable: true,
  4725. value: false
  4726. });
  4727. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4728. writable: true,
  4729. value: false
  4730. });
  4731. Steam_classPrivateFieldInitSpec(this, _area, {
  4732. writable: true,
  4733. value: 'CN'
  4734. });
  4735. }
  4736. async init() {
  4737. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4738. try {
  4739. if (type === 'store') {
  4740. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4741. return true;
  4742. }
  4743. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4744. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4745. return true;
  4746. }
  4747. if (type === 'community') {
  4748. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4749. return true;
  4750. }
  4751. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4752. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4753. return true;
  4754. }
  4755. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4756. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4757. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4758. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4759. return true;
  4760. }
  4761. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4762. return false;
  4763. } catch (error) {
  4764. throwError(error, 'Steam.init');
  4765. return false;
  4766. }
  4767. }
  4768. async getCuratorId(path, name) {
  4769. try {
  4770. const logStatus = scripts_echoLog({
  4771. type: 'gettingCuratorId',
  4772. text: `${path}/${name}`
  4773. });
  4774. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4775. if (curatorId) {
  4776. logStatus.success();
  4777. return curatorId;
  4778. }
  4779. const {
  4780. result,
  4781. statusText,
  4782. status,
  4783. data
  4784. } = await tools_httpRequest({
  4785. url: `https://store.steampowered.com/${path}/${name}`,
  4786. method: 'GET',
  4787. headers: {
  4788. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4789. }
  4790. });
  4791. if (result === 'Success') {
  4792. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4793. var _data$responseText$ma;
  4794. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4795. if (curatorId) {
  4796. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4797. logStatus.success();
  4798. return curatorId;
  4799. }
  4800. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4801. return false;
  4802. }
  4803. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4804. return false;
  4805. }
  4806. logStatus.error(`${result}:${statusText}(${status})`);
  4807. return false;
  4808. } catch (error) {
  4809. throwError(error, 'Steam.getCuratorID');
  4810. return false;
  4811. }
  4812. }
  4813. async toggle(_ref) {
  4814. let {
  4815. doTask = true,
  4816. groupLinks = [],
  4817. wishlistLinks = [],
  4818. followLinks = [],
  4819. forumLinks = [],
  4820. workshopLinks = [],
  4821. workshopVoteLinks = [],
  4822. curatorLinks = [],
  4823. curatorLikeLinks = [],
  4824. announcementLinks = [],
  4825. licenseLinks = []
  4826. } = _ref;
  4827. try {
  4828. if ([ ...groupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4829. scripts_echoLog({
  4830. text: i18n('needInit')
  4831. });
  4832. return false;
  4833. }
  4834. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4835. scripts_echoLog({
  4836. text: i18n('needInit')
  4837. });
  4838. return false;
  4839. }
  4840. const prom = [];
  4841. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4842. scripts_echoLog({
  4843. type: 'globalOptionsSkip',
  4844. text: 'steam.groups'
  4845. });
  4846. } else {
  4847. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4848. var _link$match;
  4849. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4850. });
  4851. if (realGroups.length > 0) {
  4852. for (const group of realGroups) {
  4853. if (doTask) {
  4854. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4855. } else {
  4856. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4857. }
  4858. await delay(1e3);
  4859. }
  4860. }
  4861. }
  4862. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4863. scripts_echoLog({
  4864. type: 'globalOptionsSkip',
  4865. text: 'steam.wishlists'
  4866. });
  4867. } else {
  4868. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4869. var _link$match2;
  4870. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4871. });
  4872. if (realWishlists.length > 0) {
  4873. for (const game of realWishlists) {
  4874. if (doTask) {
  4875. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4876. } else {
  4877. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4878. }
  4879. await delay(1e3);
  4880. }
  4881. }
  4882. }
  4883. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4884. scripts_echoLog({
  4885. type: 'globalOptionsSkip',
  4886. text: 'steam.follows'
  4887. });
  4888. } else {
  4889. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4890. var _link$match3;
  4891. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4892. });
  4893. if (realFollows.length > 0) {
  4894. for (const game of realFollows) {
  4895. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4896. await delay(1e3);
  4897. }
  4898. }
  4899. }
  4900. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4901. scripts_echoLog({
  4902. type: 'globalOptionsSkip',
  4903. text: 'steam.forums'
  4904. });
  4905. } else {
  4906. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4907. var _link$match4;
  4908. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4909. });
  4910. if (realForums.length > 0) {
  4911. for (const forum of realForums) {
  4912. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4913. await delay(1e3);
  4914. }
  4915. }
  4916. }
  4917. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4918. scripts_echoLog({
  4919. type: 'globalOptionsSkip',
  4920. text: 'steam.workshops'
  4921. });
  4922. } else {
  4923. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4924. var _link$match5;
  4925. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4926. });
  4927. if (realWorkshops.length > 0) {
  4928. for (const workshop of realWorkshops) {
  4929. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4930. await delay(1e3);
  4931. }
  4932. }
  4933. }
  4934. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4935. scripts_echoLog({
  4936. type: 'globalOptionsSkip',
  4937. text: 'steam.workshopVotes'
  4938. });
  4939. } else {
  4940. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4941. var _link$match6;
  4942. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4943. });
  4944. if (doTask && realworkshopVotes.length > 0) {
  4945. for (const workshop of realworkshopVotes) {
  4946. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4947. await delay(1e3);
  4948. }
  4949. }
  4950. }
  4951. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4952. scripts_echoLog({
  4953. type: 'globalOptionsSkip',
  4954. text: 'steam.curators'
  4955. });
  4956. } else {
  4957. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4958. var _link$match7;
  4959. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4960. });
  4961. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4962. var _link$match8;
  4963. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4964. });
  4965. if (realCurators.length > 0) {
  4966. for (const curator of realCurators) {
  4967. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  4968. await delay(1e3);
  4969. }
  4970. }
  4971. if (realCuratorLikes.length > 0) {
  4972. for (const curatorLike of realCuratorLikes) {
  4973. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  4974. await delay(1e3);
  4975. }
  4976. }
  4977. }
  4978. if (doTask && !globalOptions.doTask.steam.announcements) {
  4979. scripts_echoLog({
  4980. type: 'globalOptionsSkip',
  4981. text: 'steam.announcements'
  4982. });
  4983. } else {
  4984. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  4985. var _link$match10;
  4986. if (link.includes('store.steampowered.com')) {
  4987. var _link$match9;
  4988. 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('/');
  4989. }
  4990. 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('/');
  4991. });
  4992. if (doTask && realAnnouncements.length > 0) {
  4993. for (const id of realAnnouncements) {
  4994. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  4995. await delay(1e3);
  4996. }
  4997. }
  4998. }
  4999. if (doTask && licenseLinks.length > 0) {
  5000. for (const id of licenseLinks) {
  5001. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5002. await delay(1e3);
  5003. }
  5004. }
  5005. return Promise.all(prom).then(async () => {
  5006. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5007. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5008. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5009. }
  5010. return true;
  5011. });
  5012. } catch (error) {
  5013. throwError(error, 'Steam.toggle');
  5014. return false;
  5015. }
  5016. }
  5017. }
  5018. async function _updateStoreAuth2() {
  5019. try {
  5020. const logStatus = scripts_echoLog({
  5021. text: i18n('updatingAuth', i18n('steamStore'))
  5022. });
  5023. const {
  5024. result,
  5025. statusText,
  5026. status,
  5027. data
  5028. } = await tools_httpRequest({
  5029. url: 'https://store.steampowered.com/stats/',
  5030. method: 'GET'
  5031. });
  5032. if (result === 'Success') {
  5033. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5034. var _data$responseText$ma2;
  5035. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5036. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5037. return false;
  5038. }
  5039. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5040. if (storeSessionID) {
  5041. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5042. logStatus.success();
  5043. return true;
  5044. }
  5045. logStatus.error('Error: Get "sessionID" failed');
  5046. return false;
  5047. }
  5048. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5049. return false;
  5050. }
  5051. logStatus.error(`${result}:${statusText}(${status})`);
  5052. return false;
  5053. } catch (error) {
  5054. throwError(error, 'Steam.updateStoreAuth');
  5055. return false;
  5056. }
  5057. }
  5058. async function _updateCommunityAuth2() {
  5059. try {
  5060. const logStatus = scripts_echoLog({
  5061. text: i18n('updatingAuth', i18n('steamCommunity'))
  5062. });
  5063. const {
  5064. result,
  5065. statusText,
  5066. status,
  5067. data
  5068. } = await tools_httpRequest({
  5069. url: 'https://steamcommunity.com/my',
  5070. method: 'GET'
  5071. });
  5072. if (result === 'Success') {
  5073. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5074. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5075. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5076. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5077. return false;
  5078. }
  5079. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5080. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5081. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5082. if (steam64Id) {
  5083. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5084. }
  5085. if (userName) {
  5086. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5087. }
  5088. if (communitySessionID) {
  5089. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5090. logStatus.success();
  5091. return true;
  5092. }
  5093. logStatus.error('Error: Get "sessionID" failed');
  5094. return false;
  5095. }
  5096. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5097. return false;
  5098. }
  5099. logStatus.error(`${result}:${statusText}(${status})`);
  5100. return false;
  5101. } catch (error) {
  5102. throwError(error, 'Steam.updateCommunityAuth');
  5103. return false;
  5104. }
  5105. }
  5106. async function _getAreaInfo2() {
  5107. try {
  5108. const logStatus = scripts_echoLog({
  5109. text: i18n('gettingAreaInfo')
  5110. });
  5111. const {
  5112. result,
  5113. statusText,
  5114. status,
  5115. data
  5116. } = await tools_httpRequest({
  5117. url: 'https://store.steampowered.com/cart/',
  5118. method: 'GET'
  5119. });
  5120. if (result === 'Success') {
  5121. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5122. var _data$responseText$ma6;
  5123. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5124. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5125. if (currentArea && areas.length > 0) {
  5126. Steam_classPrivateFieldSet(this, _area, currentArea);
  5127. logStatus.success();
  5128. return {
  5129. currentArea: currentArea,
  5130. areas: areas
  5131. };
  5132. }
  5133. logStatus.error('Error: get country info filed');
  5134. return {};
  5135. }
  5136. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5137. return {};
  5138. }
  5139. logStatus.error(`${result}:${statusText}(${status})`);
  5140. return {};
  5141. } catch (error) {
  5142. throwError(error, 'Steam.getAreaInfo');
  5143. return {};
  5144. }
  5145. }
  5146. async function _changeArea2(area) {
  5147. try {
  5148. let aimedArea = area;
  5149. if (!aimedArea) {
  5150. const {
  5151. currentArea,
  5152. areas
  5153. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5154. if (!currentArea || !areas) {
  5155. return false;
  5156. }
  5157. if (currentArea !== 'CN') {
  5158. scripts_echoLog({
  5159. text: 'notNeededChangeArea'
  5160. });
  5161. return 'skip';
  5162. }
  5163. const anotherArea = areas.filter(area => area && area !== 'CN');
  5164. if (!anotherArea || anotherArea.length === 0) {
  5165. scripts_echoLog({
  5166. text: 'noAnotherArea'
  5167. });
  5168. return false;
  5169. }
  5170. [ aimedArea ] = anotherArea;
  5171. }
  5172. const logStatus = scripts_echoLog({
  5173. text: i18n('changingArea', aimedArea)
  5174. });
  5175. const {
  5176. result,
  5177. statusText,
  5178. status,
  5179. data
  5180. } = await tools_httpRequest({
  5181. url: 'https://store.steampowered.com/account/setcountry',
  5182. method: 'POST',
  5183. headers: {
  5184. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5185. },
  5186. data: $.param({
  5187. cc: aimedArea,
  5188. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5189. })
  5190. });
  5191. if (result === 'Success') {
  5192. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5193. const {
  5194. currentArea
  5195. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5196. if (currentArea === aimedArea) {
  5197. logStatus.success();
  5198. return currentArea;
  5199. }
  5200. logStatus.error('Error: change country filed');
  5201. return 'CN';
  5202. }
  5203. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5204. return 'CN';
  5205. }
  5206. logStatus.error(`${result}:${statusText}(${status})`);
  5207. return 'CN';
  5208. } catch (error) {
  5209. throwError(error, 'Steam.changeArea');
  5210. return false;
  5211. }
  5212. }
  5213. async function _joinGroup2(groupName) {
  5214. try {
  5215. const logStatus = scripts_echoLog({
  5216. type: 'joiningSteamGroup',
  5217. text: groupName
  5218. });
  5219. const {
  5220. result,
  5221. statusText,
  5222. status,
  5223. data
  5224. } = await tools_httpRequest({
  5225. url: `https://steamcommunity.com/groups/${groupName}`,
  5226. method: 'POST',
  5227. headers: {
  5228. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5229. },
  5230. data: $.param({
  5231. action: 'join',
  5232. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5233. })
  5234. });
  5235. if (result === 'Success') {
  5236. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5237. logStatus.success();
  5238. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5239. return true;
  5240. }
  5241. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5242. return false;
  5243. }
  5244. logStatus.error(`${result}:${statusText}(${status})`);
  5245. return false;
  5246. } catch (error) {
  5247. throwError(error, 'Steam.joinGroup');
  5248. return false;
  5249. }
  5250. }
  5251. async function _leaveGroup2(groupName) {
  5252. try {
  5253. if (this.whiteList.groups.includes(groupName)) {
  5254. scripts_echoLog({
  5255. type: 'whiteList',
  5256. text: 'Steam.leaveGroup',
  5257. id: groupName
  5258. });
  5259. return true;
  5260. }
  5261. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5262. if (!groupId) {
  5263. return false;
  5264. }
  5265. const logStatus = scripts_echoLog({
  5266. type: 'leavingSteamGroup',
  5267. text: groupName
  5268. });
  5269. const {
  5270. result,
  5271. statusText,
  5272. status,
  5273. data
  5274. } = await tools_httpRequest({
  5275. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5276. method: 'POST',
  5277. headers: {
  5278. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5279. },
  5280. data: $.param({
  5281. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5282. action: 'leaveGroup',
  5283. groupId: groupId
  5284. })
  5285. });
  5286. if (result === 'Success') {
  5287. 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) {
  5288. logStatus.success();
  5289. return true;
  5290. }
  5291. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5292. return false;
  5293. }
  5294. logStatus.error(`${result}:${statusText}(${status})`);
  5295. return false;
  5296. } catch (error) {
  5297. throwError(error, 'Steam.leaveGroup');
  5298. return false;
  5299. }
  5300. }
  5301. async function _getGroupId2(groupName) {
  5302. try {
  5303. const logStatus = scripts_echoLog({
  5304. type: 'gettingSteamGroupId',
  5305. text: groupName
  5306. });
  5307. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5308. if (groupId) {
  5309. logStatus.success();
  5310. return groupId;
  5311. }
  5312. const {
  5313. result,
  5314. statusText,
  5315. status,
  5316. data
  5317. } = await tools_httpRequest({
  5318. url: `https://steamcommunity.com/groups/${groupName}`,
  5319. method: 'GET',
  5320. headers: {
  5321. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5322. }
  5323. });
  5324. if (result === 'Success') {
  5325. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5326. var _data$responseText$ma7;
  5327. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5328. if (groupId) {
  5329. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5330. logStatus.success();
  5331. return groupId;
  5332. }
  5333. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5334. return false;
  5335. }
  5336. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5337. return false;
  5338. }
  5339. logStatus.error(`${result}:${statusText}(${status})`);
  5340. return false;
  5341. } catch (error) {
  5342. throwError(error, 'Steam.getGroupID');
  5343. return false;
  5344. }
  5345. }
  5346. async function _addToWishlist2(gameId) {
  5347. try {
  5348. var _data$response;
  5349. const logStatus = scripts_echoLog({
  5350. type: 'addingToWishlist',
  5351. text: gameId
  5352. });
  5353. const {
  5354. result,
  5355. data
  5356. } = await tools_httpRequest({
  5357. url: 'https://store.steampowered.com/api/addtowishlist',
  5358. method: 'POST',
  5359. headers: {
  5360. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5361. },
  5362. data: $.param({
  5363. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5364. appid: gameId
  5365. }),
  5366. dataType: 'json'
  5367. });
  5368. 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) {
  5369. logStatus.success();
  5370. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5371. return true;
  5372. }
  5373. const {
  5374. result: resultR,
  5375. statusText: statusTextR,
  5376. status: statusR,
  5377. data: dataR
  5378. } = await tools_httpRequest({
  5379. url: `https://store.steampowered.com/app/${gameId}`,
  5380. method: 'GET'
  5381. });
  5382. if (resultR === 'Success') {
  5383. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5384. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5385. logStatus.warning(i18n('changeAreaNotice'));
  5386. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5387. return false;
  5388. }
  5389. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5390. }
  5391. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5392. logStatus.success();
  5393. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5394. return true;
  5395. } 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"')) {
  5396. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5397. return false;
  5398. }
  5399. logStatus.success();
  5400. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5401. return true;
  5402. }
  5403. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5404. return false;
  5405. }
  5406. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5407. return false;
  5408. } catch (error) {
  5409. throwError(error, 'Steam.addToWishlist');
  5410. return false;
  5411. }
  5412. }
  5413. async function _removeFromWishlist2(gameId) {
  5414. try {
  5415. var _data$response2;
  5416. if (this.whiteList.wishlists.includes(gameId)) {
  5417. scripts_echoLog({
  5418. type: 'whiteList',
  5419. text: 'Steam.removeFromWishlist',
  5420. id: gameId
  5421. });
  5422. return true;
  5423. }
  5424. const logStatus = scripts_echoLog({
  5425. type: 'removingFromWishlist',
  5426. text: gameId
  5427. });
  5428. const {
  5429. result,
  5430. data
  5431. } = await tools_httpRequest({
  5432. url: 'https://store.steampowered.com/api/removefromwishlist',
  5433. method: 'POST',
  5434. headers: {
  5435. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5436. },
  5437. data: $.param({
  5438. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5439. appid: gameId
  5440. }),
  5441. dataType: 'json'
  5442. });
  5443. 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) {
  5444. logStatus.success();
  5445. return true;
  5446. }
  5447. const {
  5448. result: resultR,
  5449. statusText: statusTextR,
  5450. status: statusR,
  5451. data: dataR
  5452. } = await tools_httpRequest({
  5453. url: `https://store.steampowered.com/app/${gameId}`,
  5454. method: 'GET'
  5455. });
  5456. if (resultR === 'Success') {
  5457. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5458. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5459. logStatus.warning(i18n('changeAreaNotice'));
  5460. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5461. if (!result || result === 'CN' || result === 'skip') {
  5462. return false;
  5463. }
  5464. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5465. }
  5466. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5467. logStatus.success();
  5468. return true;
  5469. }
  5470. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5471. return false;
  5472. }
  5473. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5474. return false;
  5475. }
  5476. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5477. return false;
  5478. } catch (error) {
  5479. throwError(error, 'Steam.removeFromWishlist');
  5480. return false;
  5481. }
  5482. }
  5483. async function _toggleFollowGame2(gameId, doTask) {
  5484. try {
  5485. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5486. scripts_echoLog({
  5487. type: 'whiteList',
  5488. text: 'Steam.unfollowGame',
  5489. id: gameId
  5490. });
  5491. return true;
  5492. }
  5493. const logStatus = scripts_echoLog({
  5494. type: `${doTask ? '' : 'un'}followingGame`,
  5495. text: gameId
  5496. });
  5497. const requestData = {
  5498. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5499. appid: gameId
  5500. };
  5501. if (!doTask) {
  5502. requestData.unfollow = '1';
  5503. }
  5504. const {
  5505. result,
  5506. data
  5507. } = await tools_httpRequest({
  5508. url: 'https://store.steampowered.com/explore/followgame/',
  5509. method: 'POST',
  5510. headers: {
  5511. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5512. },
  5513. data: $.param(requestData)
  5514. });
  5515. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5516. logStatus.success();
  5517. return true;
  5518. }
  5519. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5520. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5521. logStatus.warning(i18n('changeAreaNotice'));
  5522. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5523. return false;
  5524. }
  5525. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5526. }
  5527. if (doTask === followed) {
  5528. logStatus.success();
  5529. if (doTask) {
  5530. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5531. }
  5532. return true;
  5533. }
  5534. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5535. return false;
  5536. } catch (error) {
  5537. throwError(error, 'Steam.toggleFollowGame');
  5538. return false;
  5539. }
  5540. }
  5541. async function _isFollowedGame2(gameId) {
  5542. try {
  5543. const {
  5544. result,
  5545. data
  5546. } = await tools_httpRequest({
  5547. url: `https://store.steampowered.com/app/${gameId}`,
  5548. method: 'GET'
  5549. });
  5550. if (result === 'Success') {
  5551. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5552. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5553. return 'areaLocked';
  5554. }
  5555. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5556. return true;
  5557. }
  5558. return false;
  5559. }
  5560. return false;
  5561. }
  5562. return false;
  5563. } catch (error) {
  5564. throwError(error, 'Steam.isFollowedGame');
  5565. return false;
  5566. }
  5567. }
  5568. async function _toggleForum2(gameId) {
  5569. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5570. try {
  5571. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5572. scripts_echoLog({
  5573. type: 'whiteList',
  5574. text: 'Steam.unsubscribeForum',
  5575. id: gameId
  5576. });
  5577. return true;
  5578. }
  5579. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5580. if (!forumId) {
  5581. return false;
  5582. }
  5583. const logStatus = scripts_echoLog({
  5584. type: `${doTask ? '' : 'un'}subscribingForum`,
  5585. text: gameId
  5586. });
  5587. const [ id, feature ] = forumId.split('_');
  5588. const {
  5589. result,
  5590. statusText,
  5591. status,
  5592. data
  5593. } = await tools_httpRequest({
  5594. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5595. method: 'POST',
  5596. responseType: 'json',
  5597. headers: {
  5598. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5599. },
  5600. data: $.param({
  5601. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5602. })
  5603. });
  5604. if (result === 'Success') {
  5605. var _data$response3, _data$response4;
  5606. 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)) {
  5607. if (doTask) {
  5608. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5609. }
  5610. logStatus.success();
  5611. return true;
  5612. }
  5613. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5614. return true;
  5615. }
  5616. logStatus.error(`${result}:${statusText}(${status})`);
  5617. return true;
  5618. } catch (error) {
  5619. throwError(error, 'Steam.toggleForum');
  5620. return true;
  5621. }
  5622. }
  5623. async function _getForumId2(gameId) {
  5624. try {
  5625. const logStatus = scripts_echoLog({
  5626. type: 'gettingForumId',
  5627. text: gameId
  5628. });
  5629. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5630. if (forumId) {
  5631. logStatus.success();
  5632. return forumId;
  5633. }
  5634. const {
  5635. result,
  5636. statusText,
  5637. status,
  5638. data
  5639. } = await tools_httpRequest({
  5640. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5641. method: 'GET'
  5642. });
  5643. if (result === 'Success') {
  5644. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5645. var _data$responseText, _data$responseText$ma8;
  5646. 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];
  5647. if (forumId) {
  5648. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5649. logStatus.success();
  5650. return forumId;
  5651. }
  5652. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5653. return false;
  5654. }
  5655. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5656. return false;
  5657. }
  5658. logStatus.error(`${result}:${statusText}(${status})`);
  5659. return false;
  5660. } catch (error) {
  5661. throwError(error, 'Steam.getForumId');
  5662. return false;
  5663. }
  5664. }
  5665. async function _toggleFavoriteWorkshop2(id) {
  5666. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5667. try {
  5668. if (!doTask && this.whiteList.workshops.includes(id)) {
  5669. scripts_echoLog({
  5670. type: 'whiteList',
  5671. text: 'Steam.unfavoriteWorkshop',
  5672. id: id
  5673. });
  5674. return true;
  5675. }
  5676. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5677. if (!appid) {
  5678. return false;
  5679. }
  5680. const logStatus = scripts_echoLog({
  5681. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5682. text: id
  5683. });
  5684. const {
  5685. result,
  5686. statusText,
  5687. status,
  5688. data
  5689. } = await tools_httpRequest({
  5690. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5691. method: 'POST',
  5692. headers: {
  5693. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5694. },
  5695. data: $.param({
  5696. id: id,
  5697. appid: appid,
  5698. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5699. })
  5700. });
  5701. if (result === 'Success') {
  5702. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5703. if (doTask) {
  5704. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5705. }
  5706. logStatus.success();
  5707. return true;
  5708. }
  5709. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5710. return false;
  5711. }
  5712. logStatus.error(`${result}:${statusText}(${status})`);
  5713. return false;
  5714. } catch (error) {
  5715. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5716. return false;
  5717. }
  5718. }
  5719. async function _getWorkshopAppId2(id) {
  5720. try {
  5721. const logStatus = scripts_echoLog({
  5722. type: 'gettingWorkshopAppId',
  5723. text: id
  5724. });
  5725. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5726. if (appId) {
  5727. logStatus.success();
  5728. return appId;
  5729. }
  5730. const {
  5731. result,
  5732. statusText,
  5733. status,
  5734. data
  5735. } = await tools_httpRequest({
  5736. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5737. method: 'GET'
  5738. });
  5739. if (result === 'Success') {
  5740. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5741. var _data$responseText$ma9;
  5742. 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];
  5743. if (appId) {
  5744. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5745. logStatus.success();
  5746. return appId;
  5747. }
  5748. logStatus.error('Error: getWorkshopAppId failed');
  5749. return false;
  5750. }
  5751. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5752. return false;
  5753. }
  5754. logStatus.error(`${result}:${statusText}(${status})`);
  5755. return false;
  5756. } catch (error) {
  5757. throwError(error, 'Steam.getWorkshopAppId');
  5758. return false;
  5759. }
  5760. }
  5761. async function _voteUpWorkshop2(id) {
  5762. try {
  5763. const logStatus = scripts_echoLog({
  5764. type: 'votingUpWorkshop',
  5765. text: id
  5766. });
  5767. const {
  5768. result,
  5769. statusText,
  5770. status,
  5771. data
  5772. } = await tools_httpRequest({
  5773. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5774. method: 'POST',
  5775. responseType: 'json',
  5776. headers: {
  5777. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5778. },
  5779. data: $.param({
  5780. id: id,
  5781. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5782. })
  5783. });
  5784. if (result === 'Success') {
  5785. var _data$response5;
  5786. 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) {
  5787. logStatus.success();
  5788. return true;
  5789. }
  5790. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5791. return true;
  5792. }
  5793. logStatus.error(`${result}:${statusText}(${status})`);
  5794. return true;
  5795. } catch (error) {
  5796. throwError(error, 'Steam.voteupWorkshop');
  5797. return true;
  5798. }
  5799. }
  5800. async function _toggleCurator2(curatorId) {
  5801. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5802. try {
  5803. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5804. scripts_echoLog({
  5805. type: 'whiteList',
  5806. text: 'Steam.unfollowCurator',
  5807. id: curatorId
  5808. });
  5809. return true;
  5810. }
  5811. const logStatus = scripts_echoLog({
  5812. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5813. text: curatorId
  5814. });
  5815. const {
  5816. result,
  5817. statusText,
  5818. status,
  5819. data
  5820. } = await tools_httpRequest({
  5821. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5822. method: 'POST',
  5823. headers: {
  5824. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5825. },
  5826. data: $.param({
  5827. clanid: curatorId,
  5828. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5829. follow: doTask
  5830. }),
  5831. dataType: 'json'
  5832. });
  5833. if (result === 'Success') {
  5834. var _data$response6, _data$response6$succe, _data$response7;
  5835. 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) {
  5836. logStatus.success();
  5837. return true;
  5838. }
  5839. 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})`);
  5840. return false;
  5841. }
  5842. logStatus.error(`${result}:${statusText}(${status})`);
  5843. return false;
  5844. } catch (error) {
  5845. throwError(error, 'Steam.toggleCurator');
  5846. return false;
  5847. }
  5848. }
  5849. async function _toggleCuratorLike2(link) {
  5850. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5851. try {
  5852. const [ path, name ] = link.split('/');
  5853. if (!(path && name)) {
  5854. scripts_echoLog({
  5855. text: i18n('errorLink', link)
  5856. });
  5857. return false;
  5858. }
  5859. const curatorId = await this.getCuratorId(path, name);
  5860. if (curatorId) {
  5861. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5862. }
  5863. return false;
  5864. } catch (error) {
  5865. throwError(error, 'Steam.toggleCuratorLike');
  5866. return false;
  5867. }
  5868. }
  5869. async function _getAnnouncementParams2(appId, viewId) {
  5870. try {
  5871. const logStatus = scripts_echoLog({
  5872. type: 'gettingAnnouncementParams',
  5873. text: appId,
  5874. id: viewId
  5875. });
  5876. const {
  5877. result,
  5878. statusText,
  5879. status,
  5880. data
  5881. } = await tools_httpRequest({
  5882. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5883. method: 'GET',
  5884. headers: {
  5885. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5886. }
  5887. });
  5888. if (result === 'Success') {
  5889. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5890. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5891. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5892. logStatus.warning(i18n('changeAreaNotice'));
  5893. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5894. return {};
  5895. }
  5896. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5897. }
  5898. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5899. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5900. 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];
  5901. if (authWgToken && clanId) {
  5902. logStatus.success();
  5903. return {
  5904. authWgToken: authWgToken,
  5905. clanId: clanId,
  5906. gid: gid
  5907. };
  5908. }
  5909. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5910. return {};
  5911. }
  5912. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5913. return {};
  5914. }
  5915. logStatus.error(`${result}:${statusText}(${status})`);
  5916. return {};
  5917. } catch (error) {
  5918. throwError(error, 'Steam.likeAnnouncement');
  5919. return {};
  5920. }
  5921. }
  5922. async function _likeAnnouncement2(id) {
  5923. try {
  5924. const [ appId, viewId ] = id.split('/');
  5925. if (!(appId && viewId)) {
  5926. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  5927. return false;
  5928. }
  5929. const {
  5930. authWgToken,
  5931. clanId,
  5932. gid
  5933. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5934. if (!(authWgToken && clanId)) {
  5935. return false;
  5936. }
  5937. const logStatus = scripts_echoLog({
  5938. type: 'likingAnnouncement',
  5939. text: appId,
  5940. id: viewId
  5941. });
  5942. const {
  5943. result,
  5944. statusText,
  5945. status,
  5946. data
  5947. } = await tools_httpRequest({
  5948. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5949. method: 'POST',
  5950. headers: {
  5951. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5952. Host: 'store.steampowered.com',
  5953. Origin: 'https://store.steampowered.com',
  5954. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5955. },
  5956. data: $.param({
  5957. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5958. wgauthtoken: authWgToken,
  5959. voteup: 1,
  5960. clanid: clanId,
  5961. ajax: 1
  5962. }),
  5963. dataType: 'json'
  5964. });
  5965. if (result === 'Success') {
  5966. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5967. logStatus.success();
  5968. return true;
  5969. }
  5970. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5971. return false;
  5972. }
  5973. logStatus.error(`${result}:${statusText}(${status})`);
  5974. return false;
  5975. } catch (error) {
  5976. throwError(error, 'Steam.likeAnnouncement');
  5977. return false;
  5978. }
  5979. }
  5980. async function _appid2subid2(id) {
  5981. try {
  5982. const logStatus = scripts_echoLog({
  5983. type: 'gettingSubid',
  5984. text: id
  5985. });
  5986. const {
  5987. result,
  5988. statusText,
  5989. status,
  5990. data
  5991. } = await tools_httpRequest({
  5992. url: `https://store.steampowered.com/app/${id}`,
  5993. method: 'GET',
  5994. headers: {
  5995. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5996. }
  5997. });
  5998. if (result === 'Success') {
  5999. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6000. var _data$responseText$ma13;
  6001. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6002. logStatus.warning(i18n('changeAreaNotice'));
  6003. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6004. if (!result || result === 'CN' || result === 'skip') {
  6005. return false;
  6006. }
  6007. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6008. }
  6009. const subid = (_data$responseText$ma13 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6010. if (subid) {
  6011. logStatus.success();
  6012. return subid;
  6013. }
  6014. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6015. return false;
  6016. }
  6017. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6018. return false;
  6019. }
  6020. logStatus.error(`${result}:${statusText}(${status})`);
  6021. return false;
  6022. } catch (error) {
  6023. throwError(error, 'Steam.appid2subid');
  6024. return false;
  6025. }
  6026. }
  6027. async function _addLicense2(id) {
  6028. try {
  6029. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6030. if (!subid) {
  6031. return false;
  6032. }
  6033. const logStatus = scripts_echoLog({
  6034. type: 'addingFreeLicense',
  6035. text: id
  6036. });
  6037. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6038. return false;
  6039. }
  6040. const {
  6041. result,
  6042. statusText,
  6043. status,
  6044. data
  6045. } = await tools_httpRequest({
  6046. url: `https://store.steampowered.com/app/${id}`,
  6047. method: 'GET'
  6048. });
  6049. if (result === 'Success') {
  6050. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6051. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6052. logStatus.success();
  6053. return true;
  6054. }
  6055. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6056. return false;
  6057. }
  6058. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6059. return false;
  6060. }
  6061. logStatus.error(`${result}:${statusText}(${status})`);
  6062. return false;
  6063. } catch (error) {
  6064. throwError(error, 'Steam.addLicense');
  6065. return false;
  6066. }
  6067. }
  6068. async function _addFreeLicense2(id, logStatus) {
  6069. try {
  6070. const {
  6071. result,
  6072. statusText,
  6073. status,
  6074. data
  6075. } = await tools_httpRequest({
  6076. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6077. method: 'POST',
  6078. headers: {
  6079. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6080. Host: 'store.steampowered.com',
  6081. Origin: 'https://store.steampowered.com',
  6082. Referer: 'https://store.steampowered.com/account/licenses/'
  6083. },
  6084. data: $.param({
  6085. action: 'add_to_cart',
  6086. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6087. subid: id
  6088. }),
  6089. dataType: 'json'
  6090. });
  6091. if (result === 'Success') {
  6092. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6093. logStatus.success();
  6094. return true;
  6095. }
  6096. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6097. return false;
  6098. }
  6099. logStatus.error(`${result}:${statusText}(${status})`);
  6100. return false;
  6101. } catch (error) {
  6102. throwError(error, 'Steam.addFreeLicense');
  6103. return false;
  6104. }
  6105. }
  6106. function Steam_setCache2(type, name, id) {
  6107. try {
  6108. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6109. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6110. } catch (error) {
  6111. throwError(error, 'Steam.setCache');
  6112. }
  6113. }
  6114. const social_Steam = Steam;
  6115. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6116. Website_checkPrivateRedeclaration(obj, privateSet);
  6117. privateSet.add(obj);
  6118. }
  6119. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6120. if (privateCollection.has(obj)) {
  6121. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6122. }
  6123. }
  6124. function Website_defineProperty(obj, key, value) {
  6125. if (key in obj) {
  6126. Object.defineProperty(obj, key, {
  6127. value: value,
  6128. enumerable: true,
  6129. configurable: true,
  6130. writable: true
  6131. });
  6132. } else {
  6133. obj[key] = value;
  6134. }
  6135. return obj;
  6136. }
  6137. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6138. if (!privateSet.has(receiver)) {
  6139. throw new TypeError('attempted to get private field on non-instance');
  6140. }
  6141. return fn;
  6142. }
  6143. var _bind = new WeakSet();
  6144. class Website {
  6145. constructor() {
  6146. Website_classPrivateMethodInitSpec(this, _bind);
  6147. Website_defineProperty(this, 'undoneTasks', void 0);
  6148. Website_defineProperty(this, 'socialTasks', void 0);
  6149. Website_defineProperty(this, 'giveawayId', void 0);
  6150. Website_defineProperty(this, 'socialInitialized', {
  6151. discord: false,
  6152. instagram: false,
  6153. reddit: false,
  6154. twitch: false,
  6155. twitter: false,
  6156. vk: false,
  6157. youtube: false,
  6158. steamStore: false,
  6159. steamCommunity: false
  6160. });
  6161. Website_defineProperty(this, 'initialized', false);
  6162. Website_defineProperty(this, 'social', {});
  6163. }
  6164. async initSocial(action) {
  6165. try {
  6166. const pro = [];
  6167. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6168. if (tasks.discord) {
  6169. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6170. if (hasDiscord && !this.socialInitialized.discord && !this.social.discord) {
  6171. this.social.discord = new social_Discord();
  6172. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6173. }
  6174. }
  6175. if (tasks.instagram) {
  6176. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6177. if (hasInstagram && !this.socialInitialized.instagram && !this.social.instagram) {
  6178. this.social.instagram = new social_Instagram();
  6179. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6180. }
  6181. }
  6182. if (tasks.reddit) {
  6183. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6184. if (hasReddit && !this.socialInitialized.reddit && !this.social.reddit) {
  6185. this.social.reddit = new social_Reddit();
  6186. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6187. }
  6188. }
  6189. if (tasks.twitch) {
  6190. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6191. if (hasTwitch && !this.socialInitialized.twitch && !this.social.twitch) {
  6192. this.social.twitch = new social_Twitch();
  6193. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6194. }
  6195. }
  6196. if (tasks.twitter) {
  6197. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6198. if (hasTwitter && !this.socialInitialized.twitter && !this.social.twitter) {
  6199. this.social.twitter = new social_Twitter();
  6200. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6201. }
  6202. }
  6203. if (tasks.vk) {
  6204. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6205. if (hasVk && !this.socialInitialized.vk && !this.social.vk) {
  6206. this.social.vk = new social_Vk();
  6207. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6208. }
  6209. }
  6210. if (tasks.youtube) {
  6211. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6212. if (hasYoutube && !this.socialInitialized.youtube && !this.social.youtube) {
  6213. this.social.youtube = new Youtube();
  6214. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6215. }
  6216. }
  6217. if (tasks.steam) {
  6218. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6219. if (steamLength > 0) {
  6220. if (!this.social.steam) {
  6221. this.social.steam = new social_Steam();
  6222. }
  6223. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6224. var _tasks$steam, _tasks$steam$type;
  6225. 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;
  6226. }).reduce((total, number) => total + number, 0);
  6227. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6228. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6229. }
  6230. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6231. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6232. }
  6233. }
  6234. }
  6235. if (tasks.links && tasks.links.length > 0) {
  6236. this.social.visitLink = visitLink;
  6237. }
  6238. return await Promise.all(pro).then(result => {
  6239. let checked = true;
  6240. for (const data of result) {
  6241. if (data.result) {
  6242. this.socialInitialized[data.name] = data.result;
  6243. } else {
  6244. checked = false;
  6245. }
  6246. }
  6247. return checked;
  6248. });
  6249. } catch (error) {
  6250. throwError(error, 'Website.initSocial');
  6251. return false;
  6252. }
  6253. }
  6254. uniqueTasks(allTasks) {
  6255. const result = {};
  6256. for (const [ social, types ] of Object.entries(allTasks)) {
  6257. result[social] = {};
  6258. for (const [ type, tasks ] of Object.entries(types)) {
  6259. result[social][type] = unique(tasks);
  6260. }
  6261. }
  6262. return result;
  6263. }
  6264. async toggleTask(action) {
  6265. try {
  6266. if (!this.initialized && !this.init()) {
  6267. return false;
  6268. }
  6269. if (!await this.classifyTask(action)) {
  6270. return false;
  6271. }
  6272. if (!await this.initSocial(action)) {
  6273. return false;
  6274. }
  6275. const pro = [];
  6276. const doTask = action === 'do';
  6277. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6278. if (this.social.discord) {
  6279. pro.push(this.social.discord.toggle({
  6280. doTask: doTask,
  6281. ...tasks.discord
  6282. }));
  6283. }
  6284. if (this.social.instagram) {
  6285. pro.push(this.social.instagram.toggle({
  6286. doTask: doTask,
  6287. ...tasks.instagram
  6288. }));
  6289. }
  6290. if (this.social.reddit) {
  6291. pro.push(this.social.reddit.toggle({
  6292. doTask: doTask,
  6293. ...tasks.reddit
  6294. }));
  6295. }
  6296. if (this.social.twitch) {
  6297. pro.push(this.social.twitch.toggle({
  6298. doTask: doTask,
  6299. ...tasks.twitch
  6300. }));
  6301. }
  6302. if (this.social.twitter) {
  6303. pro.push(this.social.twitter.toggle({
  6304. doTask: doTask,
  6305. ...tasks.twitter
  6306. }));
  6307. }
  6308. if (this.social.vk) {
  6309. pro.push(this.social.vk.toggle({
  6310. doTask: doTask,
  6311. ...tasks.vk
  6312. }));
  6313. }
  6314. if (this.social.youtube) {
  6315. pro.push(this.social.youtube.toggle({
  6316. doTask: doTask,
  6317. ...tasks.youtube
  6318. }));
  6319. }
  6320. if (this.social.steam) {
  6321. pro.push(this.social.steam.toggle({
  6322. doTask: doTask,
  6323. ...tasks.steam
  6324. }));
  6325. }
  6326. if (this.social.visitLink && tasks.links && doTask) {
  6327. for (const link of tasks.links) {
  6328. pro.push(this.social.visitLink(link));
  6329. }
  6330. }
  6331. if (doTask && tasks.extra && this.extraDoTask) {
  6332. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6333. if (hasExtra) {
  6334. pro.push(this.extraDoTask(tasks.extra));
  6335. }
  6336. }
  6337. await Promise.all(pro);
  6338. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6339. return true;
  6340. } catch (error) {
  6341. throwError(error, 'Website.toggleTask');
  6342. return false;
  6343. }
  6344. }
  6345. async doTask() {
  6346. try {
  6347. return await this.toggleTask('do');
  6348. } catch (error) {
  6349. throwError(error, 'Website.doTask');
  6350. return false;
  6351. }
  6352. }
  6353. async undoTask() {
  6354. try {
  6355. return await this.toggleTask('undo');
  6356. } catch (error) {
  6357. throwError(error, 'Website.undoTask');
  6358. return false;
  6359. }
  6360. }
  6361. }
  6362. async function _bind2(name, init) {
  6363. try {
  6364. return {
  6365. name: name,
  6366. result: await init
  6367. };
  6368. } catch (error) {
  6369. throwError(error, 'Website.bind');
  6370. return {
  6371. name: name,
  6372. result: false
  6373. };
  6374. }
  6375. }
  6376. const website_Website = Website;
  6377. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6378. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6379. privateSet.add(obj);
  6380. }
  6381. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6382. if (privateCollection.has(obj)) {
  6383. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6384. }
  6385. }
  6386. function FreeAnyWhere_defineProperty(obj, key, value) {
  6387. if (key in obj) {
  6388. Object.defineProperty(obj, key, {
  6389. value: value,
  6390. enumerable: true,
  6391. configurable: true,
  6392. writable: true
  6393. });
  6394. } else {
  6395. obj[key] = value;
  6396. }
  6397. return obj;
  6398. }
  6399. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6400. if (!privateSet.has(receiver)) {
  6401. throw new TypeError('attempted to get private field on non-instance');
  6402. }
  6403. return fn;
  6404. }
  6405. const FreeAnyWhere_defaultTasks = JSON.stringify({
  6406. steam: {
  6407. groupLinks: [],
  6408. wishlistLinks: [],
  6409. curatorLinks: [],
  6410. followLinks: []
  6411. },
  6412. vk: {
  6413. nameLinks: []
  6414. }
  6415. });
  6416. var _getGiveawayId = new WeakSet();
  6417. var _verify = new WeakSet();
  6418. class FreeAnyWhere extends website_Website {
  6419. constructor() {
  6420. super(...arguments);
  6421. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6422. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6423. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6424. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6425. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6426. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6427. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6428. }
  6429. static test() {
  6430. return window.location.host === 'freeanywhere.net';
  6431. }
  6432. init() {
  6433. try {
  6434. const logStatus = scripts_echoLog({
  6435. text: i18n('initing')
  6436. });
  6437. if ($('a[href="#/login"]').length > 0) {
  6438. window.open('/#/login', '_self');
  6439. logStatus.warning(i18n('needLogin'));
  6440. return false;
  6441. }
  6442. if (window.location.href.includes('/login')) {
  6443. logStatus.warning(i18n('needLogin'));
  6444. return false;
  6445. }
  6446. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6447. var _window$location$href;
  6448. 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];
  6449. if (!id) {
  6450. logStatus.error(i18n('getFailed', 'Id'));
  6451. return false;
  6452. }
  6453. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6454. }
  6455. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6456. return false;
  6457. }
  6458. this.initialized = true;
  6459. logStatus.success();
  6460. return true;
  6461. } catch (error) {
  6462. throwError(error, 'Freeanywhere.init');
  6463. return false;
  6464. }
  6465. }
  6466. async classifyTask(action) {
  6467. try {
  6468. const logStatus = scripts_echoLog({
  6469. text: i18n('getTasksInfo')
  6470. });
  6471. if (action === 'undo') {
  6472. var _GM_getValue;
  6473. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6474. }
  6475. const {
  6476. result,
  6477. statusText,
  6478. status,
  6479. data
  6480. } = await tools_httpRequest({
  6481. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6482. method: 'GET',
  6483. headers: {
  6484. authorization: `Token ${window.localStorage.getItem('token')}`,
  6485. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6486. },
  6487. responseType: 'json'
  6488. });
  6489. if (result === 'Success') {
  6490. var _data$response;
  6491. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6492. if (tasks) {
  6493. if (action === 'verify') {
  6494. this.tasks = [];
  6495. }
  6496. for (const task of tasks) {
  6497. const type = task.challenge;
  6498. const social = task.challenge_provider;
  6499. const taskInfo = {
  6500. id: task.id,
  6501. title: task.title
  6502. };
  6503. if (action === 'verify' && !task.is_success) {
  6504. this.tasks.push(taskInfo);
  6505. continue;
  6506. }
  6507. switch (social) {
  6508. case 'steam':
  6509. taskInfo.social = 'steam';
  6510. switch (type) {
  6511. case 'WL':
  6512. if (action === 'undo') {
  6513. this.socialTasks.steam.wishlistLinks.push(task.link);
  6514. }
  6515. if (action === 'do' && !task.is_success) {
  6516. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6517. }
  6518. break;
  6519.  
  6520. case 'JTG':
  6521. if (action === 'undo') {
  6522. this.socialTasks.steam.groupLinks.push(task.link);
  6523. }
  6524. if (action === 'do' && !task.is_success) {
  6525. this.undoneTasks.steam.groupLinks.push(task.link);
  6526. }
  6527. break;
  6528.  
  6529. case 'STC':
  6530. if (action === 'undo') {
  6531. this.socialTasks.steam.curatorLinks.push(task.link);
  6532. }
  6533. if (action === 'do' && !task.is_success) {
  6534. this.undoneTasks.steam.curatorLinks.push(task.link);
  6535. }
  6536. break;
  6537.  
  6538. case 'GF':
  6539. if (action === 'undo') {
  6540. this.socialTasks.steam.followLinks.push(task.link);
  6541. }
  6542. if (action === 'do' && !task.is_success) {
  6543. this.undoneTasks.steam.followLinks.push(task.link);
  6544. }
  6545. break;
  6546. }
  6547. break;
  6548.  
  6549. case 'vk-oauth2':
  6550. if (action === 'undo') {
  6551. this.socialTasks.vk.nameLinks.push(task.link);
  6552. }
  6553. if (action === 'do' && !task.is_success) {
  6554. this.undoneTasks.vk.nameLinks.push(task.link);
  6555. }
  6556. break;
  6557.  
  6558. case 'website':
  6559. break;
  6560.  
  6561. default:
  6562. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6563. break;
  6564. }
  6565. }
  6566. logStatus.success();
  6567. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6568. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6569. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6570. tasks: this.socialTasks,
  6571. time: new Date().getTime()
  6572. });
  6573. return true;
  6574. }
  6575. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6576. console.error(data);
  6577. return false;
  6578. }
  6579. logStatus.error(`${result}:${statusText}(${status})`);
  6580. return false;
  6581. } catch (error) {
  6582. throwError(error, 'Freeanywhere.classifyTask');
  6583. return false;
  6584. }
  6585. }
  6586. async verifyTask() {
  6587. try {
  6588. if (!this.initialized && !this.init()) {
  6589. return false;
  6590. }
  6591. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6592. return false;
  6593. }
  6594. const pro = [];
  6595. for (const task of this.tasks) {
  6596. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6597. await delay(1e3);
  6598. }
  6599. await Promise.all(pro);
  6600. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6601. return !!await this.getKey(true);
  6602. } catch (error) {
  6603. throwError(error, 'Freeanywhere.verifyTask');
  6604. return false;
  6605. }
  6606. }
  6607. async getKey(initialized) {
  6608. try {
  6609. if (!initialized && !this.initialized && !this.init()) {
  6610. return false;
  6611. }
  6612. const logStatus = scripts_echoLog({
  6613. text: i18n('gettingKey')
  6614. });
  6615. const {
  6616. result,
  6617. statusText,
  6618. status,
  6619. data
  6620. } = await tools_httpRequest({
  6621. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6622. method: 'GET',
  6623. dataType: 'json',
  6624. headers: {
  6625. authorization: `Token ${window.localStorage.getItem('token')}`
  6626. }
  6627. });
  6628. if (result === 'Success') {
  6629. var _data$response2;
  6630. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6631. logStatus.success();
  6632. scripts_echoLog({}).success(data.response.reward);
  6633. return data.response.reward;
  6634. }
  6635. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6636. return false;
  6637. }
  6638. logStatus.error(`${result}:${statusText}(${status})`);
  6639. return false;
  6640. } catch (error) {
  6641. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6642. return false;
  6643. }
  6644. }
  6645. }
  6646. function _getGiveawayId2() {
  6647. try {
  6648. var _window$location$href2;
  6649. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6650. if (giveawayId) {
  6651. this.giveawayId = giveawayId;
  6652. return true;
  6653. }
  6654. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6655. return false;
  6656. } catch (error) {
  6657. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6658. }
  6659. }
  6660. async function _verify2(task) {
  6661. try {
  6662. const logStatus = scripts_echoLog({
  6663. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6664. });
  6665. const {
  6666. result,
  6667. statusText,
  6668. status,
  6669. data
  6670. } = await tools_httpRequest({
  6671. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6672. method: 'GET',
  6673. dataType: 'json',
  6674. headers: {
  6675. authorization: `Token ${window.localStorage.getItem('token')}`,
  6676. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6677. }
  6678. });
  6679. if (result === 'Success') {
  6680. var _data$response3;
  6681. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6682. logStatus.success();
  6683. return true;
  6684. }
  6685. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6686. return false;
  6687. }
  6688. logStatus.error(`${result}:${statusText}(${status})`);
  6689. return false;
  6690. } catch (error) {
  6691. throwError(error, 'Freeanywhere.verify');
  6692. return false;
  6693. }
  6694. }
  6695. const website_FreeAnyWhere = FreeAnyWhere;
  6696. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6697. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6698. privateSet.add(obj);
  6699. }
  6700. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6701. if (privateCollection.has(obj)) {
  6702. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6703. }
  6704. }
  6705. function GiveawaySu_defineProperty(obj, key, value) {
  6706. if (key in obj) {
  6707. Object.defineProperty(obj, key, {
  6708. value: value,
  6709. enumerable: true,
  6710. configurable: true,
  6711. writable: true
  6712. });
  6713. } else {
  6714. obj[key] = value;
  6715. }
  6716. return obj;
  6717. }
  6718. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6719. if (!privateSet.has(receiver)) {
  6720. throw new TypeError('attempted to get private field on non-instance');
  6721. }
  6722. return fn;
  6723. }
  6724. const GiveawaySu_defaultTasks = {
  6725. steam: {
  6726. groupLinks: [],
  6727. wishlistLinks: [],
  6728. curatorLinks: [],
  6729. curatorLikeLinks: [],
  6730. followLinks: [],
  6731. forumLinks: [],
  6732. announcementLinks: [],
  6733. workshopVoteLinks: []
  6734. },
  6735. discord: {
  6736. serverLinks: []
  6737. },
  6738. instagram: {
  6739. userLinks: []
  6740. },
  6741. vk: {
  6742. nameLinks: []
  6743. },
  6744. twitch: {
  6745. channelLinks: []
  6746. },
  6747. reddit: {
  6748. redditLinks: []
  6749. },
  6750. youtube: {
  6751. channelLinks: [],
  6752. likeLinks: []
  6753. }
  6754. };
  6755. var _checkLogin = new WeakSet();
  6756. var _checkLeftKey = new WeakSet();
  6757. var GiveawaySu_getGiveawayId = new WeakSet();
  6758. class GiveawaySu extends website_Website {
  6759. constructor() {
  6760. super(...arguments);
  6761. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6762. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6763. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6764. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6765. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6766. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6767. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6768. }
  6769. static test() {
  6770. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6771. }
  6772. async after() {
  6773. try {
  6774. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6775. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6776. }
  6777. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6778. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6779. }
  6780. scripts_echoLog({}).warning(i18n('gsNotice'));
  6781. } catch (error) {
  6782. throwError(error, 'Giveawaysu.after');
  6783. }
  6784. }
  6785. init() {
  6786. try {
  6787. const logStatus = scripts_echoLog({
  6788. text: i18n('initing')
  6789. });
  6790. if ($('a.steam-login').length > 0) {
  6791. window.open('/steam/redirect', '_self');
  6792. logStatus.warning(i18n('needLogin'));
  6793. return false;
  6794. }
  6795. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6796. return false;
  6797. }
  6798. this.initialized = true;
  6799. logStatus.success();
  6800. return true;
  6801. } catch (error) {
  6802. throwError(error, 'Giveawaysu.init');
  6803. return false;
  6804. }
  6805. }
  6806. async classifyTask(action) {
  6807. try {
  6808. const logStatus = scripts_echoLog({
  6809. text: i18n('getTasksInfo')
  6810. });
  6811. if (action === 'undo') {
  6812. var _GM_getValue;
  6813. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6814. return true;
  6815. }
  6816. const pro = [];
  6817. const tasks = $('#actions tr');
  6818. if ($('div.bind-discord').is(':visible')) {
  6819. $('div.bind-discord a')[0].click();
  6820. }
  6821. if ($('div.bind-twitch').is(':visible')) {
  6822. $('div.bind-twitch a')[0].click();
  6823. }
  6824. for (const task of tasks) {
  6825. pro.push(new Promise(resolve => {
  6826. const td = $(task).find('td:not(".hidden")');
  6827. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6828. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6829. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6830. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6831. const taskName = taskDes.text().trim();
  6832. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6833. return resolve(true);
  6834. }
  6835. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6836. if (!taskLink) {
  6837. return resolve(false);
  6838. }
  6839. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6840. this.undoneTasks.steam.groupLinks.push(taskLink);
  6841. } else if (/like.*announcement/gi.test(taskName)) {
  6842. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6843. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6844. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6845. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6846. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6847. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6848. this.undoneTasks.steam.forumLinks.push(taskLink);
  6849. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6850. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6851. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6852. this.undoneTasks.discord.serverLinks.push(taskLink);
  6853. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6854. this.undoneTasks.instagram.userLinks.push(taskLink);
  6855. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6856. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6857. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6858. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6859. } else if (/watch.*art/gim.test(taskName)) {
  6860. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6861. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6862. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6863. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6864. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6865. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6866. this.undoneTasks.vk.nameLinks.push(taskLink);
  6867. } else {
  6868. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6869. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6870. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6871. }
  6872. if (/follow.*button/gim.test(taskName)) {
  6873. this.undoneTasks.steam.followLinks.push(taskLink);
  6874. }
  6875. }
  6876. }
  6877. resolve(true);
  6878. }).catch(error => {
  6879. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6880. return false;
  6881. });
  6882. }));
  6883. }
  6884. await Promise.all(pro);
  6885. logStatus.success();
  6886. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6887. this.socialTasks = this.undoneTasks;
  6888. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6889. tasks: this.socialTasks,
  6890. time: new Date().getTime()
  6891. });
  6892. return true;
  6893. } catch (error) {
  6894. throwError(error, 'Giveawaysu.classifyTask');
  6895. return false;
  6896. }
  6897. }
  6898. }
  6899. function _checkLogin2() {
  6900. try {
  6901. if (!globalOptions.other.checkLogin) {
  6902. return true;
  6903. }
  6904. if ($('a.steam-login').length > 0) {
  6905. window.open('/steam/redirect', '_self');
  6906. }
  6907. return true;
  6908. } catch (error) {
  6909. throwError(error, 'Giveawaysu.checkLogin');
  6910. return false;
  6911. }
  6912. }
  6913. async function _checkLeftKey2() {
  6914. try {
  6915. if (!globalOptions.other.checkLeftKey) {
  6916. return true;
  6917. }
  6918. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  6919. await external_Swal_default().fire({
  6920. icon: 'warning',
  6921. title: i18n('notice'),
  6922. text: i18n('noKeysLeft'),
  6923. confirmButtonText: i18n('confirm'),
  6924. cancelButtonText: i18n('cancel'),
  6925. showCancelButton: true
  6926. }).then(_ref => {
  6927. let {
  6928. value
  6929. } = _ref;
  6930. if (value) {
  6931. window.close();
  6932. }
  6933. });
  6934. }
  6935. return true;
  6936. } catch (error) {
  6937. throwError(error, 'Giveawaysu.checkLeftKey');
  6938. return false;
  6939. }
  6940. }
  6941. function GiveawaySu_getGiveawayId2() {
  6942. var _window$location$href;
  6943. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6944. if (giveawayId) {
  6945. this.giveawayId = giveawayId;
  6946. return true;
  6947. }
  6948. scripts_echoLog({
  6949. text: i18n('getFailed', 'GiveawayId')
  6950. });
  6951. return false;
  6952. }
  6953. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  6954. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  6955. privateSet.add(obj);
  6956. }
  6957. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  6958. if (privateCollection.has(obj)) {
  6959. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6960. }
  6961. }
  6962. function Indiedb_defineProperty(obj, key, value) {
  6963. if (key in obj) {
  6964. Object.defineProperty(obj, key, {
  6965. value: value,
  6966. enumerable: true,
  6967. configurable: true,
  6968. writable: true
  6969. });
  6970. } else {
  6971. obj[key] = value;
  6972. }
  6973. return obj;
  6974. }
  6975. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  6976. if (!privateSet.has(receiver)) {
  6977. throw new TypeError('attempted to get private field on non-instance');
  6978. }
  6979. return fn;
  6980. }
  6981. var _join = new WeakSet();
  6982. var _do = new WeakSet();
  6983. var Indiedb_checkLogin = new WeakSet();
  6984. var Indiedb_checkLeftKey = new WeakSet();
  6985. class Indiedb {
  6986. constructor() {
  6987. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  6988. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  6989. Indiedb_classPrivateMethodInitSpec(this, _do);
  6990. Indiedb_classPrivateMethodInitSpec(this, _join);
  6991. Indiedb_defineProperty(this, 'name', 'Indiedb');
  6992. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  6993. }
  6994. static test() {
  6995. return window.location.host === 'www.indiedb.com';
  6996. }
  6997. async after() {
  6998. try {
  6999. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7000. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7001. }
  7002. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7003. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7004. }
  7005. } catch (error) {
  7006. throwError(error, 'Indiedb.after');
  7007. }
  7008. }
  7009. async doTask() {
  7010. try {
  7011. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7012. return false;
  7013. }
  7014. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7015. } catch (error) {
  7016. throwError(error, 'Indiedb.doTask');
  7017. return false;
  7018. }
  7019. }
  7020. }
  7021. async function _join2() {
  7022. try {
  7023. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7024. scripts_echoLog({}).error(i18n('needLogin'));
  7025. return false;
  7026. }
  7027. const currentoption = $('a.buttonenter.buttongiveaway');
  7028. if (/join giveaway/gim.test(currentoption.text())) {
  7029. const logStatus = scripts_echoLog({
  7030. text: `${i18n('joiningGiveaway')}...`
  7031. });
  7032. const {
  7033. result,
  7034. statusText,
  7035. status,
  7036. data
  7037. } = await tools_httpRequest({
  7038. url: currentoption.attr('href'),
  7039. method: 'POST',
  7040. data: 'ajax=t',
  7041. dataType: 'json',
  7042. headers: {
  7043. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7044. accept: 'application/json, text/javascript, */*; q=0.01',
  7045. origin: window.location.origin
  7046. }
  7047. });
  7048. if (result === 'Success') {
  7049. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7050. var _data$response, _data$response4, _data$response5;
  7051. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7052. var _data$response2, _data$response3;
  7053. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7054. $('#giveawaysjoined').slideDown();
  7055. $('#giveawaysrecommend').slideDown();
  7056. 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}` : ''}`);
  7057. return true;
  7058. }
  7059. 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}` : ''}`);
  7060. return false;
  7061. }
  7062. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7063. return false;
  7064. }
  7065. logStatus.error(`${result}:${statusText}(${status})`);
  7066. return false;
  7067. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7068. return true;
  7069. }
  7070. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7071. return false;
  7072. } catch (error) {
  7073. throwError(error, 'Indiedb.init');
  7074. return false;
  7075. }
  7076. }
  7077. async function _do2() {
  7078. try {
  7079. const id = $('script').map((index, script) => {
  7080. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7081. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7082. 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] ];
  7083. }
  7084. return null;
  7085. });
  7086. if (id.length === 2) {
  7087. const pro = [];
  7088. const tasks = $('#giveawaysjoined a[class*=promo]');
  7089. for (const task of tasks) {
  7090. const promo = $(task);
  7091. if (!promo.hasClass('buttonentered')) {
  7092. const status = scripts_echoLog({
  7093. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7094. });
  7095. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7096. let text = '';
  7097. if (promo.hasClass('facebookpromo')) {
  7098. text = 'facebookpromo';
  7099. } else if (promo.hasClass('twitterpromo')) {
  7100. text = 'twitterpromo';
  7101. } else {
  7102. text = 'visitpromo';
  7103. }
  7104. pro.push(new Promise(resolve => {
  7105. $.ajax({
  7106. type: 'POST',
  7107. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7108. timeout: 6e4,
  7109. dataType: 'json',
  7110. data: {
  7111. ajax: 't'
  7112. },
  7113. error(response, error, exception) {
  7114. console.log({
  7115. response: response,
  7116. error: error,
  7117. exception: exception
  7118. });
  7119. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7120. resolve(true);
  7121. },
  7122. success(response) {
  7123. console.log(response);
  7124. if (response.success) {
  7125. status.success(`Success:${response.text}`);
  7126. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7127. resolve(true);
  7128. } else {
  7129. status.error(`Error:${response.text}`);
  7130. resolve(true);
  7131. }
  7132. }
  7133. });
  7134. }));
  7135. } else if (promo.hasClass('emailoptinpromo')) {
  7136. pro.push(new Promise(resolve => {
  7137. $.ajax({
  7138. type: 'POST',
  7139. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7140. timeout: 6e4,
  7141. dataType: 'json',
  7142. data: {
  7143. ajax: 't',
  7144. emailsystoggle: 4
  7145. },
  7146. error(response, error, exception) {
  7147. console.log({
  7148. response: response,
  7149. error: error,
  7150. exception: exception
  7151. });
  7152. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7153. resolve(true);
  7154. },
  7155. success(response) {
  7156. console.log(response);
  7157. if (response.success) {
  7158. status.success(`Success:${response.text}`);
  7159. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7160. resolve(true);
  7161. } else {
  7162. status.error(`Error:${response.text}`);
  7163. resolve(true);
  7164. }
  7165. }
  7166. });
  7167. }));
  7168. } else if (promo.hasClass('watchingpromo')) {
  7169. pro.push(new Promise(resolve => {
  7170. var _promo$attr;
  7171. const data = getUrlQuery(promo.attr('href'));
  7172. data.ajax = 't';
  7173. $.ajax({
  7174. type: 'POST',
  7175. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7176. timeout: 6e4,
  7177. dataType: 'json',
  7178. data: data,
  7179. error(response, error, exception) {
  7180. console.log({
  7181. response: response,
  7182. error: error,
  7183. exception: exception
  7184. });
  7185. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7186. resolve(true);
  7187. },
  7188. success(response) {
  7189. console.log(response);
  7190. if (response.success) {
  7191. status.success(`Success:${response.text}`);
  7192. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7193. resolve(true);
  7194. } else {
  7195. status.error(`Error:${response.text}`);
  7196. resolve(true);
  7197. }
  7198. }
  7199. });
  7200. }));
  7201. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7202. pro.push(new Promise(resolve => {
  7203. $.ajax({
  7204. type: 'POST',
  7205. url: urlPath(promo.attr('href')),
  7206. timeout: 6e4,
  7207. dataType: 'json',
  7208. data: {
  7209. ajax: 't'
  7210. },
  7211. error(response, error, exception) {
  7212. console.log({
  7213. response: response,
  7214. error: error,
  7215. exception: exception
  7216. });
  7217. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7218. resolve(true);
  7219. },
  7220. success(response) {
  7221. console.log(response);
  7222. if (response.success) {
  7223. status.success(`Success:${response.text}`);
  7224. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7225. resolve(true);
  7226. } else {
  7227. status.error(`Error:${response.text}`);
  7228. resolve(true);
  7229. }
  7230. }
  7231. });
  7232. }));
  7233. } else {
  7234. status.error(`Error:${i18n('unKnownTaskType')}`);
  7235. }
  7236. }
  7237. }
  7238. await Promise.all(pro);
  7239. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7240. return true;
  7241. }
  7242. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7243. return false;
  7244. } catch (error) {
  7245. throwError(error, 'Indiedb.classifyTask');
  7246. return false;
  7247. }
  7248. }
  7249. function Indiedb_checkLogin2() {
  7250. try {
  7251. if (!globalOptions.other.checkLogin) {
  7252. return true;
  7253. }
  7254. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7255. window.open('/members/login', '_self');
  7256. }
  7257. return true;
  7258. } catch (error) {
  7259. throwError(error, 'Indiedb.checkLogin');
  7260. return false;
  7261. }
  7262. }
  7263. async function Indiedb_checkLeftKey2() {
  7264. try {
  7265. if (!globalOptions.other.checkLeftKey) {
  7266. return true;
  7267. }
  7268. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7269. await external_Swal_default().fire({
  7270. icon: 'warning',
  7271. title: i18n('notice'),
  7272. text: i18n('giveawayEnded'),
  7273. confirmButtonText: i18n('confirm'),
  7274. cancelButtonText: i18n('cancel'),
  7275. showCancelButton: true
  7276. }).then(_ref => {
  7277. let {
  7278. value
  7279. } = _ref;
  7280. if (value) {
  7281. window.close();
  7282. }
  7283. });
  7284. }
  7285. return true;
  7286. } catch (error) {
  7287. throwError(error, 'Indiedb.checkLeftKey');
  7288. return false;
  7289. }
  7290. }
  7291. const website_Indiedb = Indiedb;
  7292. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7293. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7294. privateSet.add(obj);
  7295. }
  7296. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7297. if (privateCollection.has(obj)) {
  7298. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7299. }
  7300. }
  7301. function Keyhub_defineProperty(obj, key, value) {
  7302. if (key in obj) {
  7303. Object.defineProperty(obj, key, {
  7304. value: value,
  7305. enumerable: true,
  7306. configurable: true,
  7307. writable: true
  7308. });
  7309. } else {
  7310. obj[key] = value;
  7311. }
  7312. return obj;
  7313. }
  7314. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7315. if (!privateSet.has(receiver)) {
  7316. throw new TypeError('attempted to get private field on non-instance');
  7317. }
  7318. return fn;
  7319. }
  7320. const Keyhub_defaultTasks = JSON.stringify({
  7321. steam: {
  7322. groupLinks: [],
  7323. wishlistLinks: [],
  7324. curatorLinks: []
  7325. },
  7326. discord: {
  7327. serverLinks: []
  7328. },
  7329. links: []
  7330. });
  7331. var Keyhub_getGiveawayId = new WeakSet();
  7332. var Keyhub_checkLeftKey = new WeakSet();
  7333. var Keyhub_checkLogin = new WeakSet();
  7334. class Keyhub extends website_Website {
  7335. constructor() {
  7336. super(...arguments);
  7337. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7338. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7339. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7340. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7341. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7342. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7343. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7344. }
  7345. static test() {
  7346. return window.location.host === 'key-hub.eu';
  7347. }
  7348. async after() {
  7349. try {
  7350. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7351. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7352. }
  7353. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7354. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7355. }
  7356. } catch (error) {
  7357. throwError(error, 'Keyhub.after');
  7358. }
  7359. }
  7360. init() {
  7361. try {
  7362. const logStatus = scripts_echoLog({
  7363. text: i18n('initing')
  7364. });
  7365. if ($('a[href*="/connect/steam"]').length > 0) {
  7366. window.open('/connect/steam', '_self');
  7367. logStatus.warning(i18n('needLogin'));
  7368. return false;
  7369. }
  7370. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7371. return false;
  7372. }
  7373. $('#VPNoverlay').hide();
  7374. $('#mainArticleSection').show();
  7375. this.initialized = true;
  7376. logStatus.success();
  7377. return true;
  7378. } catch (error) {
  7379. throwError(error, 'Keyhub.init');
  7380. return false;
  7381. }
  7382. }
  7383. async classifyTask(action) {
  7384. try {
  7385. const logStatus = scripts_echoLog({
  7386. text: i18n('getTasksInfo')
  7387. });
  7388. if (action === 'undo') {
  7389. var _GM_getValue;
  7390. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7391. }
  7392. const tasks = $('.task a');
  7393. for (const task of tasks) {
  7394. let link = $(task).attr('href');
  7395. const taskDes = $(task).text().trim();
  7396. if (!link) {
  7397. continue;
  7398. }
  7399. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7400. link = await getRedirectLink(link) || link;
  7401. }
  7402. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7403. window.open(link, '_blank');
  7404. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7405. if (action === 'undo') {
  7406. this.socialTasks.steam.groupLinks.push(link);
  7407. }
  7408. if (action === 'do') {
  7409. this.undoneTasks.steam.groupLinks.push(link);
  7410. }
  7411. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7412. if (action === 'undo') {
  7413. this.socialTasks.steam.wishlistLinks.push(link);
  7414. }
  7415. if (action === 'do') {
  7416. this.undoneTasks.steam.wishlistLinks.push(link);
  7417. }
  7418. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7419. if (action === 'undo') {
  7420. this.socialTasks.steam.curatorLinks.push(link);
  7421. }
  7422. if (action === 'do') {
  7423. this.undoneTasks.steam.curatorLinks.push(link);
  7424. }
  7425. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7426. if (action === 'undo') {
  7427. this.socialTasks.discord.serverLinks.push(link);
  7428. }
  7429. if (action === 'do') {
  7430. this.undoneTasks.discord.serverLinks.push(link);
  7431. }
  7432. } else if (/^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link)) {} else {
  7433. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7434. }
  7435. }
  7436. logStatus.success();
  7437. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7438. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7439. GM_setValue(`khTasks-${this.giveawayId}`, {
  7440. tasks: this.socialTasks,
  7441. time: new Date().getTime()
  7442. });
  7443. return true;
  7444. } catch (error) {
  7445. throwError(error, 'Keyhub.classifyTask');
  7446. return false;
  7447. }
  7448. }
  7449. verifyTask() {
  7450. try {
  7451. scripts_echoLog({
  7452. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7453. });
  7454. $.get(window.location.href, res => {
  7455. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7456. });
  7457. } catch (error) {
  7458. throwError(error, 'keyhub.verifyTask');
  7459. }
  7460. }
  7461. }
  7462. function Keyhub_getGiveawayId2() {
  7463. try {
  7464. var _window$location$href;
  7465. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7466. if (giveawayId) {
  7467. this.giveawayId = giveawayId;
  7468. return true;
  7469. }
  7470. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7471. return false;
  7472. } catch (error) {
  7473. throwError(error, 'Keyhub.getGiveawayId');
  7474. return false;
  7475. }
  7476. }
  7477. async function Keyhub_checkLeftKey2() {
  7478. try {
  7479. if (!globalOptions.other.checkLeftKey) {
  7480. return true;
  7481. }
  7482. const leftKey = $('#keysleft').text().trim();
  7483. if (leftKey === '0') {
  7484. await external_Swal_default().fire({
  7485. icon: 'warning',
  7486. title: i18n('notice'),
  7487. text: i18n('noKeysLeft'),
  7488. confirmButtonText: i18n('confirm'),
  7489. cancelButtonText: i18n('cancel'),
  7490. showCancelButton: true
  7491. }).then(_ref => {
  7492. let {
  7493. value
  7494. } = _ref;
  7495. if (value) {
  7496. window.close();
  7497. }
  7498. });
  7499. }
  7500. return true;
  7501. } catch (error) {
  7502. throwError(error, 'Keyhub.checkLeftKey');
  7503. return false;
  7504. }
  7505. }
  7506. function Keyhub_checkLogin2() {
  7507. try {
  7508. if (!globalOptions.other.checkLogin) {
  7509. return true;
  7510. }
  7511. if ($('a[href*="/connect/steam"]').length > 0) {
  7512. window.open('/connect/steam', '_self');
  7513. }
  7514. return true;
  7515. } catch (error) {
  7516. throwError(error, 'Keyhub.checkLogin');
  7517. return false;
  7518. }
  7519. }
  7520. const website_Keyhub = Keyhub;
  7521. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7522. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7523. privateSet.add(obj);
  7524. }
  7525. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7526. if (privateCollection.has(obj)) {
  7527. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7528. }
  7529. }
  7530. function Givekey_defineProperty(obj, key, value) {
  7531. if (key in obj) {
  7532. Object.defineProperty(obj, key, {
  7533. value: value,
  7534. enumerable: true,
  7535. configurable: true,
  7536. writable: true
  7537. });
  7538. } else {
  7539. obj[key] = value;
  7540. }
  7541. return obj;
  7542. }
  7543. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7544. if (!privateSet.has(receiver)) {
  7545. throw new TypeError('attempted to get private field on non-instance');
  7546. }
  7547. return fn;
  7548. }
  7549. const Givekey_defaultTasks = JSON.stringify({
  7550. steam: {
  7551. groupLinks: [],
  7552. wishlistLinks: [],
  7553. curatorLinks: [],
  7554. curatorLikeLinks: []
  7555. },
  7556. twitter: {
  7557. userLinks: []
  7558. },
  7559. vk: {
  7560. nameLinks: []
  7561. },
  7562. discord: {
  7563. serverLinks: []
  7564. }
  7565. });
  7566. var Givekey_verify = new WeakSet();
  7567. var Givekey_getGiveawayId = new WeakSet();
  7568. var Givekey_checkLeftKey = new WeakSet();
  7569. class Givekey extends website_Website {
  7570. constructor() {
  7571. super(...arguments);
  7572. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7573. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7574. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7575. Givekey_defineProperty(this, 'name', 'Givekey');
  7576. Givekey_defineProperty(this, 'tasks', []);
  7577. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  7578. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  7579. Givekey_defineProperty(this, 'userId', void 0);
  7580. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7581. }
  7582. static test() {
  7583. return window.location.host === 'givekey.ru';
  7584. }
  7585. async after() {
  7586. try {
  7587. await new Promise(resolve => {
  7588. const checker = setInterval(() => {
  7589. if ($('#navbarDropdown').length > 0) {
  7590. clearInterval(checker);
  7591. resolve(true);
  7592. }
  7593. });
  7594. });
  7595. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7596. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7597. }
  7598. } catch (error) {
  7599. throwError(error, 'Givekey.after');
  7600. return false;
  7601. }
  7602. }
  7603. init() {
  7604. try {
  7605. const logStatus = scripts_echoLog({
  7606. text: i18n('initing')
  7607. });
  7608. if ($('a[href*="/auth/steam"]').length > 0) {
  7609. window.open('/auth/steam', '_self');
  7610. logStatus.warning(i18n('needLogin'));
  7611. return false;
  7612. }
  7613. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7614. return false;
  7615. }
  7616. const userId = $('meta[name="user-id"]').attr('content');
  7617. if (!userId) {
  7618. logStatus.error(i18n('getFailed', i18n('userId')));
  7619. return false;
  7620. }
  7621. this.userId = userId;
  7622. this.initialized = true;
  7623. logStatus.success();
  7624. return true;
  7625. } catch (error) {
  7626. throwError(error, 'Givekey.init');
  7627. return false;
  7628. }
  7629. }
  7630. async classifyTask(action) {
  7631. try {
  7632. const logStatus = scripts_echoLog({
  7633. text: i18n('getTasksInfo')
  7634. });
  7635. if (action === 'undo') {
  7636. var _GM_getValue;
  7637. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  7638. }
  7639. const tasks = $('.card-body:has("button") .row');
  7640. for (const task of tasks) {
  7641. const taskEle = $(task);
  7642. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7643. if (isSuccess && action !== 'undo') {
  7644. continue;
  7645. }
  7646. const checkButton = taskEle.find('#task_check');
  7647. const taskId = checkButton.attr('data-id');
  7648. if (taskId) {
  7649. this.tasks.push(taskId);
  7650. }
  7651. if (action === 'verify') {
  7652. continue;
  7653. }
  7654. let href = taskEle.find('a').attr('href') || null;
  7655. const text = taskEle.find('a').text().trim();
  7656. const icon = taskEle.find('i');
  7657. if (!href || !text) {
  7658. continue;
  7659. }
  7660. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7661. href = await getRedirectLink(href);
  7662. }
  7663. if (!href) {
  7664. continue;
  7665. }
  7666. if (/^https?:\/\/vk\.com\//.test(href)) {
  7667. this.socialTasks.vk.nameLinks.push(href);
  7668. if (action === 'do' && !isSuccess) {
  7669. this.undoneTasks.vk.nameLinks.push(href);
  7670. }
  7671. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7672. this.socialTasks.steam.groupLinks.push(href);
  7673. if (action === 'do' && !isSuccess) {
  7674. this.undoneTasks.steam.groupLinks.push(href);
  7675. }
  7676. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7677. this.socialTasks.steam.wishlistLinks.push(href);
  7678. if (action === 'do' && !isSuccess) {
  7679. this.undoneTasks.steam.wishlistLinks.push(href);
  7680. }
  7681. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7682. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7683. this.socialTasks.steam.curatorLinks.push(href);
  7684. if (action === 'do' && !isSuccess) {
  7685. this.undoneTasks.steam.curatorLinks.push(href);
  7686. }
  7687. } else {
  7688. this.socialTasks.steam.curatorLikeLinks.push(href);
  7689. if (action === 'do' && !isSuccess) {
  7690. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7691. }
  7692. }
  7693. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7694. this.socialTasks.twitter.userLinks.push(href);
  7695. if (action === 'do' && !isSuccess) {
  7696. this.undoneTasks.twitter.userLinks.push(href);
  7697. }
  7698. } else if (icon.hasClass('fa-discord')) {
  7699. this.socialTasks.discord.serverLinks.push(href);
  7700. if (action === 'do' && !isSuccess) {
  7701. this.undoneTasks.discord.serverLinks.push(href);
  7702. }
  7703. } else {
  7704. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7705. }
  7706. }
  7707. logStatus.success();
  7708. this.tasks = unique(this.tasks);
  7709. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7710. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7711. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7712. tasks: this.socialTasks,
  7713. time: new Date().getTime()
  7714. });
  7715. return true;
  7716. } catch (error) {
  7717. throwError(error, 'Givekey.classifyTask');
  7718. return false;
  7719. }
  7720. }
  7721. async verifyTask() {
  7722. try {
  7723. if (!this.initialized && !this.init()) {
  7724. return false;
  7725. }
  7726. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7727. return false;
  7728. }
  7729. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7730. const taskLength = this.tasks.length;
  7731. for (let i = 0; i < taskLength; i++) {
  7732. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7733. if (i < taskLength - 1) {
  7734. await delay(15e3);
  7735. }
  7736. }
  7737. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7738. scripts_echoLog({
  7739. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7740. });
  7741. return true;
  7742. } catch (error) {
  7743. throwError(error, 'Givekey.verifyTask');
  7744. return false;
  7745. }
  7746. }
  7747. }
  7748. async function Givekey_verify2(task) {
  7749. try {
  7750. const logStatus = scripts_echoLog({
  7751. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7752. });
  7753. return await new Promise(resolve => {
  7754. $.ajax({
  7755. url: 'https://givekey.ru/giveaway/task',
  7756. method: 'POST',
  7757. data: `id=${task}&user_id=${this.userId}`,
  7758. dataType: 'json',
  7759. headers: {
  7760. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7761. },
  7762. success: data => {
  7763. if (data.btn) {
  7764. $(`button[data-id=${this.userId}]`).html(data.btn);
  7765. }
  7766. if (data.status === 'ok') {
  7767. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7768. logStatus.success();
  7769. resolve(true);
  7770. } else if (data.status === 'end') {
  7771. logStatus.success();
  7772. scripts_echoLog({}).success(data.key);
  7773. resolve(true);
  7774. } else {
  7775. logStatus.error(`Error:${data.msg}`);
  7776. resolve(false);
  7777. }
  7778. },
  7779. error: xhr => {
  7780. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7781. resolve(false);
  7782. }
  7783. });
  7784. });
  7785. } catch (error) {
  7786. throwError(error, 'Givekey.verify');
  7787. return false;
  7788. }
  7789. }
  7790. function Givekey_getGiveawayId2() {
  7791. try {
  7792. var _window$location$href;
  7793. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7794. if (giveawayId) {
  7795. this.giveawayId = giveawayId;
  7796. return true;
  7797. }
  7798. scripts_echoLog({
  7799. text: i18n('getFailed', 'GiveawayId')
  7800. });
  7801. return false;
  7802. } catch (error) {
  7803. throwError(error, 'Givekey.getGiveawayId');
  7804. return false;
  7805. }
  7806. }
  7807. async function Givekey_checkLeftKey2() {
  7808. try {
  7809. if (!globalOptions.other.checkLeftKey) {
  7810. return true;
  7811. }
  7812. if (!$('#keys_count').text()) {
  7813. await external_Swal_default().fire({
  7814. icon: 'warning',
  7815. title: i18n('notice'),
  7816. text: i18n('noKeysLeft'),
  7817. confirmButtonText: i18n('confirm'),
  7818. cancelButtonText: i18n('cancel'),
  7819. showCancelButton: true
  7820. }).then(_ref => {
  7821. let {
  7822. value
  7823. } = _ref;
  7824. if (value) {
  7825. window.close();
  7826. }
  7827. });
  7828. }
  7829. return true;
  7830. } catch (error) {
  7831. throwError(error, 'Givekey.checkLeftKey');
  7832. return false;
  7833. }
  7834. }
  7835. const website_Givekey = Givekey;
  7836. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7837. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7838. privateSet.add(obj);
  7839. }
  7840. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  7841. if (privateCollection.has(obj)) {
  7842. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7843. }
  7844. }
  7845. function GiveeClub_defineProperty(obj, key, value) {
  7846. if (key in obj) {
  7847. Object.defineProperty(obj, key, {
  7848. value: value,
  7849. enumerable: true,
  7850. configurable: true,
  7851. writable: true
  7852. });
  7853. } else {
  7854. obj[key] = value;
  7855. }
  7856. return obj;
  7857. }
  7858. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  7859. if (!privateSet.has(receiver)) {
  7860. throw new TypeError('attempted to get private field on non-instance');
  7861. }
  7862. return fn;
  7863. }
  7864. var GiveeClub_checkLogin = new WeakSet();
  7865. var GiveeClub_getGiveawayId = new WeakSet();
  7866. var GiveeClub_checkLeftKey = new WeakSet();
  7867. class GiveeClub extends GiveawaySu {
  7868. constructor() {
  7869. super(...arguments);
  7870. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  7871. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  7872. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  7873. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  7874. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7875. }
  7876. static test() {
  7877. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7878. }
  7879. async after() {
  7880. try {
  7881. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7882. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7883. }
  7884. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  7885. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7886. }
  7887. } catch (error) {
  7888. throwError(error, 'GiveeClub.after');
  7889. }
  7890. }
  7891. init() {
  7892. try {
  7893. const logStatus = scripts_echoLog({
  7894. text: i18n('initing')
  7895. });
  7896. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7897. logStatus.warning(i18n('needLogin'));
  7898. return false;
  7899. }
  7900. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  7901. return false;
  7902. }
  7903. this.initialized = true;
  7904. logStatus.success();
  7905. return true;
  7906. } catch (error) {
  7907. throwError(error, 'GiveeClub.init');
  7908. return false;
  7909. }
  7910. }
  7911. async classifyTask(action) {
  7912. try {
  7913. const logStatus = scripts_echoLog({
  7914. text: i18n('getTasksInfo')
  7915. });
  7916. if (action === 'undo') {
  7917. var _GM_getValue;
  7918. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7919. return true;
  7920. }
  7921. const pro = [];
  7922. const tasks = $('.event-actions tr');
  7923. for (const task of tasks) {
  7924. pro.push(new Promise(resolve => {
  7925. const taskDes = $(task).find('.event-action-label a');
  7926. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7927. const taskName = taskDes.text().trim();
  7928. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  7929. return resolve(true);
  7930. }
  7931. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7932. if (!taskLink) {
  7933. return resolve(false);
  7934. }
  7935. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7936. this.undoneTasks.steam.groupLinks.push(taskLink);
  7937. } else if (/like.*announcement/gi.test(taskName)) {
  7938. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7939. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7940. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7941. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  7942. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  7943. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7944. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7945. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7946. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7947. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7948. this.undoneTasks.steam.forumLinks.push(taskLink);
  7949. } else if (taskIcon.includes('discord')) {
  7950. this.undoneTasks.discord.serverLinks.push(taskLink);
  7951. } else if (taskIcon.includes('instagram')) {
  7952. this.undoneTasks.instagram.userLinks.push(taskLink);
  7953. } else if (taskIcon.includes('twitch')) {
  7954. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7955. } else if (taskIcon.includes('reddit')) {
  7956. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7957. } else if (/watch.*art/gim.test(taskName)) {
  7958. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7959. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7960. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7961. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7962. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7963. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7964. this.undoneTasks.vk.nameLinks.push(taskLink);
  7965. } else {
  7966. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7967. if (/follow.*button/gim.test(taskName)) {
  7968. this.undoneTasks.steam.followLinks.push(taskLink);
  7969. }
  7970. }
  7971. }
  7972. resolve(true);
  7973. }).catch(error => {
  7974. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7975. return false;
  7976. });
  7977. }));
  7978. }
  7979. await Promise.all(pro);
  7980. logStatus.success();
  7981. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7982. this.socialTasks = this.undoneTasks;
  7983. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7984. tasks: this.socialTasks,
  7985. time: new Date().getTime()
  7986. });
  7987. return true;
  7988. } catch (error) {
  7989. throwError(error, 'GiveeClub.classifyTask');
  7990. return false;
  7991. }
  7992. }
  7993. }
  7994. function GiveeClub_checkLogin2() {
  7995. try {
  7996. if (!globalOptions.other.checkLogin) {
  7997. return true;
  7998. }
  7999. if ($('a[href*="/account/auth"]').length > 0) {
  8000. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8001. }
  8002. return true;
  8003. } catch (error) {
  8004. throwError(error, 'GiveeClub.checkLogin');
  8005. return false;
  8006. }
  8007. }
  8008. function GiveeClub_getGiveawayId2() {
  8009. var _window$location$href;
  8010. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8011. if (giveawayId) {
  8012. this.giveawayId = giveawayId;
  8013. return true;
  8014. }
  8015. scripts_echoLog({
  8016. text: i18n('getFailed', 'GiveawayId')
  8017. });
  8018. return false;
  8019. }
  8020. async function GiveeClub_checkLeftKey2() {
  8021. try {
  8022. if (!globalOptions.other.checkLeftKey) {
  8023. return true;
  8024. }
  8025. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8026. await external_Swal_default().fire({
  8027. icon: 'warning',
  8028. title: i18n('notice'),
  8029. text: i18n('giveawayEnded'),
  8030. confirmButtonText: i18n('confirm'),
  8031. cancelButtonText: i18n('cancel'),
  8032. showCancelButton: true
  8033. }).then(_ref => {
  8034. let {
  8035. value
  8036. } = _ref;
  8037. if (value) {
  8038. window.close();
  8039. }
  8040. });
  8041. }
  8042. return true;
  8043. } catch (error) {
  8044. throwError(error, 'Giveawaysu.checkLeftKey');
  8045. return false;
  8046. }
  8047. }
  8048. const website_GiveeClub = GiveeClub;
  8049. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8050. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8051. privateSet.add(obj);
  8052. }
  8053. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8054. if (privateCollection.has(obj)) {
  8055. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8056. }
  8057. }
  8058. function OpiumPulses_defineProperty(obj, key, value) {
  8059. if (key in obj) {
  8060. Object.defineProperty(obj, key, {
  8061. value: value,
  8062. enumerable: true,
  8063. configurable: true,
  8064. writable: true
  8065. });
  8066. } else {
  8067. obj[key] = value;
  8068. }
  8069. return obj;
  8070. }
  8071. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8072. if (!privateSet.has(receiver)) {
  8073. throw new TypeError('attempted to get private field on non-instance');
  8074. }
  8075. return fn;
  8076. }
  8077. const defaultOptions = {
  8078. maxPoint: '99999999'
  8079. };
  8080. var _toggleTask = new WeakSet();
  8081. var OpiumPulses_checkLogin = new WeakSet();
  8082. class OpiumPulses {
  8083. constructor() {
  8084. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8085. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8086. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8087. OpiumPulses_defineProperty(this, 'options', {
  8088. ...defaultOptions,
  8089. ...GM_getValue('OpiumPulsesOptions')
  8090. });
  8091. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8092. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8093. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8094. }
  8095. static test() {
  8096. return window.location.host === 'www.opiumpulses.com';
  8097. }
  8098. async after() {
  8099. try {
  8100. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8101. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8102. }
  8103. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8104. } catch (error) {
  8105. throwError(error, 'OpiumPulses.after');
  8106. }
  8107. }
  8108. async doFreeTask() {
  8109. try {
  8110. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8111. } catch (error) {
  8112. throwError(error, 'OpiumPulses.doFreeTask');
  8113. }
  8114. }
  8115. async doPointTask() {
  8116. try {
  8117. var _$$text$match;
  8118. 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);
  8119. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8120. } catch (error) {
  8121. throwError(error, 'OpiumPulses.doPointTask');
  8122. }
  8123. }
  8124. init() {
  8125. return true;
  8126. }
  8127. classifyTask() {
  8128. return true;
  8129. }
  8130. }
  8131. async function _toggleTask2(type) {
  8132. try {
  8133. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8134. for (const item of items) {
  8135. var _$$find$text$match;
  8136. 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);
  8137. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8138. if (type === 'points' && needPoints > this.myPoints) {
  8139. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8140. } else if (type === 'points' && !needPoints) {
  8141. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8142. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8143. var _aElement$attr;
  8144. const logStatus = scripts_echoLog({
  8145. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8146. });
  8147. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8148. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8149. var _aElement$attr2, _aElement$attr2$match;
  8150. 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];
  8151. if (giveawayId) {
  8152. checkUser(giveawayId);
  8153. }
  8154. }
  8155. if (!aElement.attr('href')) {
  8156. logStatus.error('Error: No "href".');
  8157. continue;
  8158. }
  8159. const {
  8160. result,
  8161. statusText,
  8162. status,
  8163. data
  8164. } = await tools_httpRequest({
  8165. url: aElement.attr('href'),
  8166. method: 'GET'
  8167. });
  8168. if (result === 'Success') {
  8169. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8170. var _data$responseText$ma;
  8171. logStatus.success();
  8172. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8173. if (type === 'points' && points) {
  8174. this.myPoints = parseInt(points, 10);
  8175. }
  8176. } else {
  8177. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8178. }
  8179. } else {
  8180. logStatus.error(`${result}:${statusText}(${status})`);
  8181. }
  8182. }
  8183. }
  8184. scripts_echoLog({
  8185. text: '-----END-----'
  8186. });
  8187. } catch (error) {
  8188. throwError(error, 'OpiumPulses.toggleTask');
  8189. }
  8190. }
  8191. function OpiumPulses_checkLogin2() {
  8192. try {
  8193. if (!globalOptions.other.checkLogin) {
  8194. return true;
  8195. }
  8196. if ($('a[href*="/site/login"]').length > 1) {
  8197. window.open('/site/login', '_self');
  8198. }
  8199. return true;
  8200. } catch (error) {
  8201. throwError(error, 'OpiumPulses.checkLogin');
  8202. return false;
  8203. }
  8204. }
  8205. const website_OpiumPulses = OpiumPulses;
  8206. const external_dayjs_namespaceObject = dayjs;
  8207. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8208. const leftKeyChecker = {
  8209. async classify(link) {
  8210. try {
  8211. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8212. return await this.giveawaySu(link);
  8213. }
  8214. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8215. return await this.giveeClub(link);
  8216. }
  8217. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8218. return await this.gleam(link);
  8219. }
  8220. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8221. return await this.indieDb(link);
  8222. }
  8223. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8224. return await this.keyhub(link);
  8225. }
  8226. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8227. return await this.opquests(link);
  8228. }
  8229. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8230. return await this.itch(link);
  8231. }
  8232. return false;
  8233. } catch (error) {
  8234. throwError(error, 'leftKeyChecker.classify');
  8235. return false;
  8236. }
  8237. },
  8238. async giveawaySu(link) {
  8239. try {
  8240. const {
  8241. result,
  8242. data
  8243. } = await tools_httpRequest({
  8244. url: link,
  8245. method: 'GET'
  8246. });
  8247. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8248. if (data.responseText.includes('class="steam-login"')) {
  8249. return false;
  8250. }
  8251. if (data.responseText.includes('class="giveaway-ended"')) {
  8252. return 'Ended';
  8253. }
  8254. return 'Active';
  8255. }
  8256. return false;
  8257. } catch (error) {
  8258. throwError(error, 'leftKeyChecker.giveawaySu');
  8259. return false;
  8260. }
  8261. },
  8262. async giveeClub(link) {
  8263. try {
  8264. const {
  8265. result,
  8266. data
  8267. } = await tools_httpRequest({
  8268. url: link,
  8269. method: 'GET'
  8270. });
  8271. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8272. if (data.responseText.includes('class="event-winner"')) {
  8273. return 'Won';
  8274. }
  8275. if (data.responseText.includes('class="event-ended"')) {
  8276. return 'Ended';
  8277. }
  8278. return 'Active';
  8279. }
  8280. return false;
  8281. } catch (error) {
  8282. throwError(error, 'leftKeyChecker.giveeClub');
  8283. return false;
  8284. }
  8285. },
  8286. async gleam(link) {
  8287. try {
  8288. const {
  8289. result,
  8290. data
  8291. } = await tools_httpRequest({
  8292. url: link,
  8293. method: 'GET'
  8294. });
  8295. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8296. var _data$responseText$ma, _$$attr, _$$attr$match;
  8297. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8298. return 'Won';
  8299. }
  8300. 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];
  8301. if (!campaignDiv) {
  8302. return false;
  8303. }
  8304. 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];
  8305. if (!campaignString) {
  8306. return false;
  8307. }
  8308. const {
  8309. campaign
  8310. } = JSON.parse(campaignString);
  8311. if (campaign.banned) {
  8312. return 'Banned';
  8313. }
  8314. if (campaign.finished) {
  8315. return 'Ended';
  8316. }
  8317. if (campaign.paused) {
  8318. return 'Paused';
  8319. }
  8320. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8321. return 'NotStart';
  8322. }
  8323. return 'Active';
  8324. }
  8325. return false;
  8326. } catch (error) {
  8327. throwError(error, 'leftKeyChecker.gleam');
  8328. return false;
  8329. }
  8330. },
  8331. async indieDb(link) {
  8332. try {
  8333. const {
  8334. result,
  8335. data
  8336. } = await tools_httpRequest({
  8337. url: link,
  8338. method: 'GET'
  8339. });
  8340. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8341. if (data.responseText.includes('Congrats you WON')) {
  8342. return 'Won';
  8343. }
  8344. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8345. return 'Ended';
  8346. }
  8347. return 'Active';
  8348. }
  8349. return false;
  8350. } catch (error) {
  8351. throwError(error, 'leftKeyChecker.indieDb');
  8352. return false;
  8353. }
  8354. },
  8355. async keyhub(link) {
  8356. try {
  8357. const {
  8358. result,
  8359. data
  8360. } = await tools_httpRequest({
  8361. url: link,
  8362. method: 'GET'
  8363. });
  8364. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8365. var _data$responseText$ma2;
  8366. 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];
  8367. if (!keysleft) {
  8368. return false;
  8369. }
  8370. if (keysleft === '0') {
  8371. return 'Ended';
  8372. }
  8373. return `Active(${keysleft})`;
  8374. }
  8375. return false;
  8376. } catch (error) {
  8377. throwError(error, 'leftKeyChecker.keyhub');
  8378. return false;
  8379. }
  8380. },
  8381. async opquests(link) {
  8382. try {
  8383. const {
  8384. result,
  8385. data
  8386. } = await tools_httpRequest({
  8387. url: link,
  8388. method: 'GET'
  8389. });
  8390. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8391. var _data$responseText$ma3;
  8392. 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];
  8393. if (!keysleft) {
  8394. return false;
  8395. }
  8396. if (keysleft === '0') {
  8397. return 'Ended';
  8398. }
  8399. return `Active(${keysleft})`;
  8400. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8401. return 'Ended';
  8402. }
  8403. return false;
  8404. } catch (error) {
  8405. throwError(error, 'leftKeyChecker.opquests');
  8406. return false;
  8407. }
  8408. },
  8409. async itch(link) {
  8410. try {
  8411. const {
  8412. result,
  8413. data
  8414. } = await tools_httpRequest({
  8415. url: link,
  8416. method: 'GET'
  8417. });
  8418. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8419. var _data$responseText$ma4;
  8420. 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];
  8421. if (!endDate) {
  8422. return false;
  8423. }
  8424. if (new Date().getTime() > new Date(endDate).getTime()) {
  8425. return 'Ended';
  8426. }
  8427. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8428. }
  8429. return false;
  8430. } catch (error) {
  8431. throwError(error, 'leftKeyChecker.opquests');
  8432. return false;
  8433. }
  8434. }
  8435. };
  8436. const website_leftKeyChecker = leftKeyChecker;
  8437. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8438. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8439. privateSet.add(obj);
  8440. }
  8441. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8442. if (privateCollection.has(obj)) {
  8443. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8444. }
  8445. }
  8446. function Keylol_defineProperty(obj, key, value) {
  8447. if (key in obj) {
  8448. Object.defineProperty(obj, key, {
  8449. value: value,
  8450. enumerable: true,
  8451. configurable: true,
  8452. writable: true
  8453. });
  8454. } else {
  8455. obj[key] = value;
  8456. }
  8457. return obj;
  8458. }
  8459. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8460. if (!privateSet.has(receiver)) {
  8461. throw new TypeError('attempted to get private field on non-instance');
  8462. }
  8463. return fn;
  8464. }
  8465. const Keylol_defaultTasks = JSON.stringify({
  8466. steam: {
  8467. groupLinks: [],
  8468. wishlistLinks: [],
  8469. curatorLinks: [],
  8470. curatorLikeLinks: [],
  8471. followLinks: [],
  8472. forumLinks: [],
  8473. announcementLinks: [],
  8474. workshopVoteLinks: [],
  8475. licenseLinks: []
  8476. },
  8477. discord: {
  8478. serverLinks: []
  8479. },
  8480. instagram: {
  8481. userLinks: []
  8482. },
  8483. vk: {
  8484. nameLinks: []
  8485. },
  8486. twitch: {
  8487. channelLinks: []
  8488. },
  8489. reddit: {
  8490. redditLinks: []
  8491. },
  8492. twitter: {
  8493. userLinks: [],
  8494. retweetLinks: []
  8495. },
  8496. youtube: {
  8497. channelLinks: [],
  8498. likeLinks: []
  8499. }
  8500. });
  8501. var _addBtn = new WeakSet();
  8502. class Keylol extends website_Website {
  8503. constructor() {
  8504. super(...arguments);
  8505. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8506. Keylol_defineProperty(this, 'name', 'Keylol');
  8507. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  8508. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  8509. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8510. }
  8511. static test() {
  8512. var _$$eq$attr;
  8513. 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'));
  8514. }
  8515. init() {
  8516. return true;
  8517. }
  8518. after() {
  8519. try {
  8520. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8521. const mainPost = $(selector);
  8522. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8523. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8524. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8525. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8526. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8527. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8528. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8529. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8530. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8531. if (discordLinks.length > 0) {
  8532. for (const discordLink of discordLinks) {
  8533. const link = $(discordLink).attr('href');
  8534. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8535. continue;
  8536. }
  8537. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8538. }
  8539. }
  8540. if (redditLinks.length > 0) {
  8541. for (const redditLink of redditLinks) {
  8542. const link = $(redditLink).attr('href');
  8543. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8544. continue;
  8545. }
  8546. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8547. }
  8548. }
  8549. if (insLinks.length > 0) {
  8550. for (const insLink of insLinks) {
  8551. const link = $(insLink).attr('href');
  8552. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8553. continue;
  8554. }
  8555. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8556. }
  8557. }
  8558. if (twitterLinks.length > 0) {
  8559. for (const twitterLink of twitterLinks) {
  8560. const link = $(twitterLink).attr('href');
  8561. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8562. continue;
  8563. }
  8564. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8565. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8566. } else {
  8567. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8568. }
  8569. }
  8570. }
  8571. if (twitchLinks.length > 0) {
  8572. for (const twitchLink of twitchLinks) {
  8573. const link = $(twitchLink).attr('href');
  8574. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8575. continue;
  8576. }
  8577. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8578. }
  8579. }
  8580. if (vkLinks.length > 0) {
  8581. for (const vkLink of vkLinks) {
  8582. const link = $(vkLink).attr('href');
  8583. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8584. continue;
  8585. }
  8586. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8587. }
  8588. }
  8589. if (steamStoreLinks.length > 0) {
  8590. for (const steamStoreLink of steamStoreLinks) {
  8591. const link = $(steamStoreLink).attr('href');
  8592. if (!link) {
  8593. continue;
  8594. }
  8595. if (/app\/[\d]+/.test(link)) {
  8596. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8597. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8598. } else if (/curator\/[\d]+/.test(link)) {
  8599. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8600. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8601. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8602. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8603. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8604. }
  8605. }
  8606. }
  8607. if (steamCommunityLinks.length > 0) {
  8608. for (const steamCommunityLink of steamCommunityLinks) {
  8609. const link = $(steamCommunityLink).attr('href');
  8610. if (!link) {
  8611. continue;
  8612. }
  8613. if (/groups\/.+/.test(link)) {
  8614. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8615. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8616. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8617. }
  8618. }
  8619. }
  8620. if (ytbLinks.length > 0) {
  8621. for (const ytbLink of ytbLinks) {
  8622. const link = $(ytbLink).attr('href');
  8623. if (!link) {
  8624. continue;
  8625. }
  8626. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8627. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8628. }
  8629. }
  8630. 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/"]');
  8631. if (giveawayLinks.length > 0) {
  8632. for (const giveawayLink of giveawayLinks) {
  8633. const link = $(giveawayLink).attr('href');
  8634. if (!link) {
  8635. continue;
  8636. }
  8637. website_leftKeyChecker.classify(link).then(status => {
  8638. if (!status) {
  8639. return;
  8640. }
  8641. if (/^Active/.test(status)) {
  8642. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  8643. return;
  8644. }
  8645. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  8646. }).catch(error => {
  8647. throwError(error, 'keylol.after -> leftKeyChecker');
  8648. });
  8649. }
  8650. }
  8651. if (this.name === 'Keylol') {
  8652. const asfLinks = mainPost.find('a[href^="#asf"]');
  8653. if (asfLinks.length > 0) {
  8654. for (const asfLink of asfLinks) {
  8655. const link = $(asfLink).attr('href');
  8656. if (!link) {
  8657. continue;
  8658. }
  8659. 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', ''));
  8660. }
  8661. }
  8662. }
  8663. } catch (error) {
  8664. throwError(error, 'keylol.after');
  8665. }
  8666. }
  8667. classifyTask(action) {
  8668. try {
  8669. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  8670. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  8671. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8672. for (const btn of selectedBtns) {
  8673. const button = $(btn);
  8674. const social = button.attr('data-social');
  8675. const type = button.attr('data-type');
  8676. const link = button.attr('data-link');
  8677. if (!(social && type && link)) {
  8678. continue;
  8679. }
  8680. if (action === 'do') {
  8681. this.undoneTasks[social][type].push(link);
  8682. }
  8683. if (action === 'undo') {
  8684. this.socialTasks[social][type].push(link);
  8685. }
  8686. }
  8687. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8688. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8689. return true;
  8690. } catch (error) {
  8691. throwError(error, 'Keylol.classifyTask');
  8692. return false;
  8693. }
  8694. }
  8695. selectAll() {
  8696. try {
  8697. $('.auto-task-keylol').attr('selected', 'selected');
  8698. } catch (error) {
  8699. throwError(error, 'Keylol.selectAll');
  8700. }
  8701. }
  8702. selectNone() {
  8703. try {
  8704. $('.auto-task-keylol').removeAttr('selected');
  8705. } catch (error) {
  8706. throwError(error, 'Keylol.selectNone');
  8707. }
  8708. }
  8709. invertSelect() {
  8710. try {
  8711. $('.auto-task-keylol').each((index, element) => {
  8712. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8713. });
  8714. } catch (error) {
  8715. throwError(error, 'Keylol.invertSelect');
  8716. }
  8717. }
  8718. }
  8719. function _addBtn2(before, social, linkType, link) {
  8720. try {
  8721. $(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>`);
  8722. } catch (error) {
  8723. throwError(error, 'keylol.addBtn');
  8724. }
  8725. }
  8726. const website_Keylol = Keylol;
  8727. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8728. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8729. privateSet.add(obj);
  8730. }
  8731. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8732. if (privateCollection.has(obj)) {
  8733. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8734. }
  8735. }
  8736. function Opquests_defineProperty(obj, key, value) {
  8737. if (key in obj) {
  8738. Object.defineProperty(obj, key, {
  8739. value: value,
  8740. enumerable: true,
  8741. configurable: true,
  8742. writable: true
  8743. });
  8744. } else {
  8745. obj[key] = value;
  8746. }
  8747. return obj;
  8748. }
  8749. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8750. if (!privateSet.has(receiver)) {
  8751. throw new TypeError('attempted to get private field on non-instance');
  8752. }
  8753. return fn;
  8754. }
  8755. const Opquests_defaultTasks = {
  8756. steam: {
  8757. groupLinks: [],
  8758. wishlistLinks: [],
  8759. followLinks: [],
  8760. curatorLikeLinks: []
  8761. }
  8762. };
  8763. var Opquests_getGiveawayId = new WeakSet();
  8764. var Opquests_checkLogin = new WeakSet();
  8765. class Opquests extends website_Website {
  8766. constructor() {
  8767. super(...arguments);
  8768. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8769. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8770. Opquests_defineProperty(this, 'name', 'Opquests');
  8771. Opquests_defineProperty(this, 'undoneTasks', {
  8772. ...Opquests_defaultTasks
  8773. });
  8774. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8775. }
  8776. static test() {
  8777. return window.location.host === 'opquests.com';
  8778. }
  8779. async after() {
  8780. try {
  8781. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8782. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8783. }
  8784. } catch (error) {
  8785. throwError(error, 'Opquests.after');
  8786. }
  8787. }
  8788. init() {
  8789. try {
  8790. const logStatus = scripts_echoLog({
  8791. text: i18n('initing')
  8792. });
  8793. if ($('a[href*="/auth/redirect"]').length > 0) {
  8794. window.open('/auth/redirect', '_self');
  8795. logStatus.warning(i18n('needLogin'));
  8796. return false;
  8797. }
  8798. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8799. return false;
  8800. }
  8801. this.initialized = true;
  8802. logStatus.success();
  8803. return true;
  8804. } catch (error) {
  8805. throwError(error, 'Opquests.init');
  8806. return false;
  8807. }
  8808. }
  8809. async classifyTask(action) {
  8810. try {
  8811. if (action === 'undo') {
  8812. scripts_echoLog({
  8813. text: i18n('cannotUndo')
  8814. });
  8815. return false;
  8816. }
  8817. const logStatus = scripts_echoLog({
  8818. text: i18n('getTasksInfo')
  8819. });
  8820. const tasks = $('.w-full:contains("Validate") .items-center');
  8821. for (const task of tasks) {
  8822. const link = $(task).find('a:contains("Open")').attr('href');
  8823. const taskDes = $(task).find('div').eq(1).text().trim();
  8824. if (!link) {
  8825. continue;
  8826. }
  8827. if (/steamcommunity\.com\/groups\//.test(link)) {
  8828. this.undoneTasks.steam.groupLinks.push(link);
  8829. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8830. if (/wishlist/gim.test(taskDes)) {
  8831. this.undoneTasks.steam.wishlistLinks.push(link);
  8832. } else if (/follow/gim.test(taskDes)) {
  8833. this.undoneTasks.steam.followLinks.push(link);
  8834. }
  8835. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  8836. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8837. } else {
  8838. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8839. }
  8840. }
  8841. logStatus.success();
  8842. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8843. return true;
  8844. } catch (error) {
  8845. throwError(error, 'Opquests.classifyTask');
  8846. return false;
  8847. }
  8848. }
  8849. }
  8850. function Opquests_getGiveawayId2() {
  8851. try {
  8852. var _window$location$href;
  8853. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8854. if (giveawayId) {
  8855. this.giveawayId = giveawayId;
  8856. return true;
  8857. }
  8858. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8859. return false;
  8860. } catch (error) {
  8861. throwError(error, 'Opquests.getGiveawayId');
  8862. return false;
  8863. }
  8864. }
  8865. function Opquests_checkLogin2() {
  8866. try {
  8867. if (!globalOptions.other.checkLogin) {
  8868. return true;
  8869. }
  8870. if ($('a[href*="/auth/redirect"]').length > 0) {
  8871. window.open('/auth/redirect', '_self');
  8872. }
  8873. return true;
  8874. } catch (error) {
  8875. throwError(error, 'Opquests.checkLogin');
  8876. return false;
  8877. }
  8878. }
  8879. const website_Opquests = Opquests;
  8880. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  8881. Gleam_checkPrivateRedeclaration(obj, privateSet);
  8882. privateSet.add(obj);
  8883. }
  8884. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  8885. if (privateCollection.has(obj)) {
  8886. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8887. }
  8888. }
  8889. function Gleam_defineProperty(obj, key, value) {
  8890. if (key in obj) {
  8891. Object.defineProperty(obj, key, {
  8892. value: value,
  8893. enumerable: true,
  8894. configurable: true,
  8895. writable: true
  8896. });
  8897. } else {
  8898. obj[key] = value;
  8899. }
  8900. return obj;
  8901. }
  8902. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  8903. if (!privateSet.has(receiver)) {
  8904. throw new TypeError('attempted to get private field on non-instance');
  8905. }
  8906. return fn;
  8907. }
  8908. const Gleam_defaultTasks = JSON.stringify({
  8909. steam: {
  8910. groupLinks: [],
  8911. wishlistLinks: [],
  8912. followLinks: [],
  8913. curatorLinks: [],
  8914. curatorLikeLinks: []
  8915. },
  8916. twitter: {
  8917. userLinks: [],
  8918. retweetLinks: []
  8919. },
  8920. twitch: {
  8921. channelLinks: []
  8922. },
  8923. discord: {
  8924. serverLinks: []
  8925. },
  8926. youtube: {
  8927. channelLinks: []
  8928. },
  8929. extra: {
  8930. gleam: []
  8931. }
  8932. });
  8933. const Gleam_defaultOptions = {
  8934. vlootUsername: '',
  8935. gameroundUsername: ''
  8936. };
  8937. var _checkSync = new WeakSet();
  8938. var _doGleamTask = new WeakSet();
  8939. var Gleam_getGiveawayId = new WeakSet();
  8940. var _getGleamLink = new WeakSet();
  8941. var Gleam_checkLeftKey = new WeakSet();
  8942. class Gleam extends website_Website {
  8943. constructor() {
  8944. super(...arguments);
  8945. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  8946. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  8947. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  8948. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  8949. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  8950. Gleam_defineProperty(this, 'name', 'Gleam');
  8951. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  8952. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  8953. Gleam_defineProperty(this, 'options', {
  8954. ...Gleam_defaultOptions,
  8955. ...GM_getValue('GleamOptions')
  8956. });
  8957. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8958. }
  8959. static test() {
  8960. return window.location.host === 'gleam.io';
  8961. }
  8962. async after() {
  8963. try {
  8964. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8965. const checkComplete = setInterval(() => {
  8966. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8967. clearInterval(checkComplete);
  8968. window.close();
  8969. }
  8970. });
  8971. for (const task of $('.entry-content .entry-method')) {
  8972. const taskInfo = $(task).find('.user-links');
  8973. const expandInfo = $(task).find('.expandable');
  8974. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8975. if (aElements.length > 0) {
  8976. for (const element of aElements) {
  8977. const $element = $(element);
  8978. const href = $element.attr('href');
  8979. $element.removeAttr('href')[0].click();
  8980. $element.attr('href', href);
  8981. await delay(1e3);
  8982. }
  8983. }
  8984. taskInfo[0].click();
  8985. await delay(1e3);
  8986. }
  8987. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8988. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  8989. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8990. }
  8991. } catch (error) {
  8992. throwError(error, 'Gleam.after');
  8993. return false;
  8994. }
  8995. }
  8996. init() {
  8997. try {
  8998. const logStatus = scripts_echoLog({
  8999. text: i18n('initing')
  9000. });
  9001. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9002. return false;
  9003. }
  9004. this.initialized = true;
  9005. logStatus.success();
  9006. return true;
  9007. } catch (error) {
  9008. throwError(error, 'Gleam.init');
  9009. return false;
  9010. }
  9011. }
  9012. async classifyTask(action) {
  9013. try {
  9014. const logStatus = scripts_echoLog({
  9015. text: i18n('getTasksInfo')
  9016. });
  9017. if (action === 'undo') {
  9018. var _GM_getValue;
  9019. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9020. }
  9021. const tasks = $('.entry-content .entry-method');
  9022. for (const task of tasks) {
  9023. var _socialIcon$attr;
  9024. const $task = $(task);
  9025. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9026. continue;
  9027. }
  9028. const socialIcon = $task.find('.icon-wrapper i');
  9029. const taskInfo = $task.find('.user-links');
  9030. const taskText = taskInfo.text().trim();
  9031. const expandInfo = $task.find('.expandable');
  9032. const aElements = expandInfo.find('a.btn');
  9033. if (aElements.length > 0) {
  9034. for (const element of aElements) {
  9035. const $element = $(element);
  9036. const href = $element.attr('href');
  9037. $element.removeAttr('href')[0].click();
  9038. $element.attr('href', href);
  9039. }
  9040. }
  9041. if (socialIcon.hasClass('fa-twitter')) {
  9042. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9043. if (!link) {
  9044. continue;
  9045. }
  9046. if (/follow/gi.test(taskText)) {
  9047. if (action === 'undo') {
  9048. this.socialTasks.twitter.userLinks.push(link);
  9049. }
  9050. if (action === 'do') {
  9051. this.undoneTasks.twitter.userLinks.push(link);
  9052. }
  9053. } else if (/retweet/gim.test(taskText)) {
  9054. if (action === 'undo') {
  9055. this.socialTasks.twitter.retweetLinks.push(link);
  9056. }
  9057. if (action === 'do') {
  9058. this.undoneTasks.twitter.retweetLinks.push(link);
  9059. }
  9060. }
  9061. } else if (socialIcon.hasClass('fa-twitch')) {
  9062. if (/follow/gim.test(taskText)) {
  9063. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9064. if (!link) {
  9065. continue;
  9066. }
  9067. if (action === 'undo') {
  9068. this.socialTasks.twitch.channelLinks.push(link);
  9069. }
  9070. if (action === 'do') {
  9071. this.undoneTasks.twitch.channelLinks.push(link);
  9072. }
  9073. }
  9074. } else if (socialIcon.hasClass('fa-discord')) {
  9075. if (/join/gim.test(taskText)) {
  9076. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9077. if (!link) {
  9078. var _$task$find$attr, _$task$find$attr$matc;
  9079. 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];
  9080. if (!ggLink) {
  9081. continue;
  9082. }
  9083. link = `https://discord.com/invite/${ggLink}`;
  9084. }
  9085. if (action === 'undo') {
  9086. this.socialTasks.discord.serverLinks.push(link);
  9087. }
  9088. if (action === 'do') {
  9089. this.undoneTasks.discord.serverLinks.push(link);
  9090. }
  9091. }
  9092. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9093. continue;
  9094. } else if (socialIcon.hasClass('fa-youtube')) {
  9095. if (/subscribe/gim.test(taskText)) {
  9096. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9097. if (!link) {
  9098. continue;
  9099. }
  9100. if (action === 'undo') {
  9101. this.socialTasks.youtube.channelLinks.push(link);
  9102. }
  9103. if (action === 'do') {
  9104. this.undoneTasks.youtube.channelLinks.push(link);
  9105. }
  9106. }
  9107. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9108. if (/join.*group/gi.test(taskText)) {
  9109. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9110. if (!link) {
  9111. continue;
  9112. }
  9113. if (action === 'undo') {
  9114. this.socialTasks.steam.groupLinks.push(link);
  9115. }
  9116. if (action === 'do') {
  9117. this.undoneTasks.steam.groupLinks.push(link);
  9118. }
  9119. } else if (/follow.*curator/gi.test(taskText)) {
  9120. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9121. if (!link) {
  9122. continue;
  9123. }
  9124. if (action === 'undo') {
  9125. this.socialTasks.steam.curatorLinks.push(link);
  9126. }
  9127. if (action === 'do') {
  9128. this.undoneTasks.steam.curatorLinks.push(link);
  9129. }
  9130. }
  9131. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9132. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9133. for (const button of continueBtn) {
  9134. button.click();
  9135. await delay(500);
  9136. expandInfo.find('input').val(this.options.vlootUsername);
  9137. }
  9138. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9139. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9140. for (const button of continueBtn) {
  9141. button.click();
  9142. await delay(500);
  9143. expandInfo.find('input').val(this.options.gameroundUsername);
  9144. }
  9145. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9146. if (action !== 'do') {
  9147. continue;
  9148. }
  9149. const link = aElements.attr('href');
  9150. if (!link) {
  9151. continue;
  9152. }
  9153. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9154. if (!gleamLink) {
  9155. continue;
  9156. }
  9157. this.undoneTasks.extra.gleam.push(gleamLink);
  9158. } 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 {
  9159. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9160. }
  9161. }
  9162. logStatus.success();
  9163. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9164. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9165. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9166. tasks: this.socialTasks,
  9167. time: new Date().getTime()
  9168. });
  9169. return true;
  9170. } catch (error) {
  9171. throwError(error, 'Gleam.classifyTask');
  9172. return false;
  9173. }
  9174. }
  9175. async extraDoTask(_ref) {
  9176. let {
  9177. gleam
  9178. } = _ref;
  9179. try {
  9180. const pro = [];
  9181. for (const link of gleam) {
  9182. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9183. }
  9184. return Promise.all(pro).then(() => true);
  9185. } catch (error) {
  9186. throwError(error, 'Gleam.extraDoTask');
  9187. return false;
  9188. }
  9189. }
  9190. async verifyTask() {
  9191. try {
  9192. scripts_echoLog({
  9193. text: `${i18n('verifyingTask')}...`
  9194. });
  9195. const tasks = $('.entry-content .entry-method');
  9196. for (const task of tasks) {
  9197. const $task = $(task);
  9198. if ($task.find('i.fa-question').length === 0) {
  9199. continue;
  9200. }
  9201. const taskInfo = $task.find('.user-links');
  9202. taskInfo[0].click();
  9203. await delay(500);
  9204. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9205. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9206. for (const button of continueBtn) {
  9207. button.click();
  9208. await delay(500);
  9209. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9210. }
  9211. }
  9212. scripts_echoLog({
  9213. text: i18n('verifiedGleamTasks')
  9214. });
  9215. } catch (error) {
  9216. throwError(error, 'Gleam.verifyTask');
  9217. return false;
  9218. }
  9219. }
  9220. }
  9221. async function _checkSync2() {
  9222. try {
  9223. return await new Promise(resolve => {
  9224. const checker = setInterval(() => {
  9225. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9226. clearInterval(checker);
  9227. resolve(true);
  9228. }
  9229. }, 500);
  9230. });
  9231. } catch (error) {
  9232. throwError(error, 'Gleam.checkSync');
  9233. return false;
  9234. }
  9235. }
  9236. async function _doGleamTask2(link) {
  9237. try {
  9238. const logStatus = scripts_echoLog({
  9239. text: i18n('doingGleamTask')
  9240. });
  9241. return await new Promise(resolve => {
  9242. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9243. active: true,
  9244. insert: true,
  9245. setParent: true
  9246. }).onclose = () => {
  9247. logStatus.success();
  9248. resolve(true);
  9249. };
  9250. });
  9251. } catch (error) {
  9252. throwError(error, 'Gleam.doGleamTask');
  9253. return false;
  9254. }
  9255. }
  9256. function Gleam_getGiveawayId2() {
  9257. try {
  9258. const giveawayId = window.location.pathname;
  9259. if (giveawayId) {
  9260. this.giveawayId = giveawayId;
  9261. return true;
  9262. }
  9263. scripts_echoLog({
  9264. text: i18n('getFailed', 'GiveawayId')
  9265. });
  9266. return false;
  9267. } catch (error) {
  9268. throwError(error, 'Gleam.getGiveawayId');
  9269. return false;
  9270. }
  9271. }
  9272. async function _getGleamLink2(link) {
  9273. try {
  9274. const logStatus = scripts_echoLog({
  9275. text: i18n('gettingGleamLink')
  9276. });
  9277. const {
  9278. result,
  9279. statusText,
  9280. status,
  9281. data
  9282. } = await tools_httpRequest({
  9283. url: link,
  9284. method: 'GET'
  9285. });
  9286. if (result === 'Success') {
  9287. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9288. var _data$responseText$ma;
  9289. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9290. if (gleamLink) {
  9291. logStatus.success();
  9292. return gleamLink;
  9293. }
  9294. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9295. return false;
  9296. }
  9297. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9298. return false;
  9299. }
  9300. logStatus.error(`${result}:${statusText}(${status})`);
  9301. return false;
  9302. } catch (error) {
  9303. throwError(error, 'Gleam.getGleamLink');
  9304. return false;
  9305. }
  9306. }
  9307. async function Gleam_checkLeftKey2() {
  9308. try {
  9309. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9310. if (!globalOptions.other.checkLeftKey) {
  9311. return true;
  9312. }
  9313. 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];
  9314. if (!campaignString) {
  9315. return false;
  9316. }
  9317. const {
  9318. campaign,
  9319. incentive
  9320. } = JSON.parse(campaignString);
  9321. 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];
  9322. let ownedKey = false;
  9323. if (controllerString) {
  9324. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9325. 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) {
  9326. ownedKey = true;
  9327. }
  9328. }
  9329. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9330. await external_Swal_default().fire({
  9331. icon: 'warning',
  9332. title: i18n('notice'),
  9333. text: i18n('giveawayNotWork'),
  9334. confirmButtonText: i18n('confirm'),
  9335. cancelButtonText: i18n('cancel'),
  9336. showCancelButton: true
  9337. }).then(_ref2 => {
  9338. let {
  9339. value
  9340. } = _ref2;
  9341. if (value) {
  9342. window.close();
  9343. }
  9344. });
  9345. }
  9346. return true;
  9347. } catch (error) {
  9348. throwError(error, 'Gleam.checkLeftKey');
  9349. return false;
  9350. }
  9351. }
  9352. const website_Gleam = Gleam;
  9353. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9354. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9355. privateSet.add(obj);
  9356. }
  9357. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9358. if (privateCollection.has(obj)) {
  9359. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9360. }
  9361. }
  9362. function SweepWidget_defineProperty(obj, key, value) {
  9363. if (key in obj) {
  9364. Object.defineProperty(obj, key, {
  9365. value: value,
  9366. enumerable: true,
  9367. configurable: true,
  9368. writable: true
  9369. });
  9370. } else {
  9371. obj[key] = value;
  9372. }
  9373. return obj;
  9374. }
  9375. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9376. if (!privateSet.has(receiver)) {
  9377. throw new TypeError('attempted to get private field on non-instance');
  9378. }
  9379. return fn;
  9380. }
  9381. const SweepWidget_defaultOptions = {
  9382. username: '',
  9383. email: ''
  9384. };
  9385. var SweepWidget_checkLogin = new WeakSet();
  9386. var SweepWidget_getGiveawayId = new WeakSet();
  9387. var _checkEnter = new WeakSet();
  9388. var _checkFinish = new WeakSet();
  9389. class SweepWidget extends website_Website {
  9390. constructor() {
  9391. super(...arguments);
  9392. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9393. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9394. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9395. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9396. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9397. SweepWidget_defineProperty(this, 'options', {
  9398. ...SweepWidget_defaultOptions,
  9399. ...GM_getValue('SweepWidgetOptions')
  9400. });
  9401. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9402. }
  9403. static test() {
  9404. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9405. }
  9406. async after() {
  9407. try {
  9408. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9409. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9410. }
  9411. } catch (error) {
  9412. throwError(error, 'SweepWidget.after');
  9413. }
  9414. }
  9415. init() {
  9416. try {
  9417. const logStatus = scripts_echoLog({
  9418. text: i18n('initing')
  9419. });
  9420. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9421. logStatus.warning(i18n('needLogin'));
  9422. return false;
  9423. }
  9424. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9425. return false;
  9426. }
  9427. this.initialized = true;
  9428. logStatus.success();
  9429. return true;
  9430. } catch (error) {
  9431. throwError(error, 'SweepWidget.init');
  9432. return false;
  9433. }
  9434. }
  9435. classifyTask() {
  9436. return true;
  9437. }
  9438. async doTask() {
  9439. try {
  9440. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9441. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9442. $('input[name="sw__login_name"]').val(this.options.username);
  9443. }
  9444. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9445. $('input[name="sw__login_email"]').val(this.options.email);
  9446. }
  9447. if ($('#sw_login_button:visible').length > 0) {
  9448. $('#sw_login_button')[0].click();
  9449. }
  9450. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9451. return false;
  9452. }
  9453. }
  9454. const logStatus = scripts_echoLog({
  9455. text: i18n('SweepWidgetNotice')
  9456. });
  9457. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9458. for (const task of tasks) {
  9459. var _aElement$, _$task$find$removeAtt;
  9460. const $task = $(task);
  9461. if ($task.find('i.fa-check:visible').length > 0) {
  9462. continue;
  9463. }
  9464. const title = $task.find('.sw_text_inner');
  9465. title[0].click();
  9466. const aElement = $task.find('a.sw_link');
  9467. const link = aElement.attr('href');
  9468. aElement.attr('href', '#a').attr('target', '_self');
  9469. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9470. await delay(300);
  9471. aElement.attr('href', link).attr('target', '_blank');
  9472. $task.find('input[type="text"]').val('test');
  9473. const verifyBtn = $task.find('input.sw_verify');
  9474. if (verifyBtn.prop('disabled') === true) {
  9475. title[0].click();
  9476. await delay(300);
  9477. title[0].click();
  9478. await delay(300);
  9479. }
  9480. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9481. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9482. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9483. }
  9484. logStatus.success();
  9485. return true;
  9486. } catch (error) {
  9487. throwError(error, 'SweepWidget.doTask');
  9488. return false;
  9489. }
  9490. }
  9491. }
  9492. function SweepWidget_checkLogin2() {
  9493. try {
  9494. if ($('#twitter_login_button').length > 0) {
  9495. $('#twitter_login_button')[0].click();
  9496. }
  9497. return true;
  9498. } catch (error) {
  9499. throwError(error, 'SweepWidget.checkLogin');
  9500. return false;
  9501. }
  9502. }
  9503. function SweepWidget_getGiveawayId2() {
  9504. try {
  9505. var _window$location$href;
  9506. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9507. if (giveawayId) {
  9508. this.giveawayId = giveawayId;
  9509. return true;
  9510. }
  9511. scripts_echoLog({
  9512. text: i18n('getFailed', 'GiveawayId')
  9513. });
  9514. return false;
  9515. } catch (error) {
  9516. throwError(error, 'SweepWidget.getGiveawayId');
  9517. return false;
  9518. }
  9519. }
  9520. async function _checkEnter2() {
  9521. try {
  9522. return new Promise(resolve => {
  9523. const checker = setInterval(() => {
  9524. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9525. clearInterval(checker);
  9526. resolve(true);
  9527. }
  9528. });
  9529. });
  9530. } catch (error) {
  9531. throwError(error, 'SweepWidget.checkEnter');
  9532. return false;
  9533. }
  9534. }
  9535. async function _checkFinish2($task) {
  9536. try {
  9537. return new Promise(resolve => {
  9538. const checker = setInterval(() => {
  9539. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9540. clearInterval(checker);
  9541. resolve(true);
  9542. }
  9543. });
  9544. });
  9545. } catch (error) {
  9546. throwError(error, 'SweepWidget.checkFinish');
  9547. return false;
  9548. }
  9549. }
  9550. const website_SweepWidget = SweepWidget;
  9551. const defaultWhiteList = {
  9552. discord: {
  9553. servers: []
  9554. },
  9555. instagram: {
  9556. users: []
  9557. },
  9558. twitch: {
  9559. channels: []
  9560. },
  9561. twitter: {
  9562. users: [],
  9563. retweets: [],
  9564. likes: []
  9565. },
  9566. vk: {
  9567. names: []
  9568. },
  9569. youtube: {
  9570. channels: [],
  9571. likes: []
  9572. },
  9573. reddit: {
  9574. reddits: []
  9575. },
  9576. steam: {
  9577. groups: [],
  9578. wishlists: [],
  9579. follows: [],
  9580. forums: [],
  9581. workshops: [],
  9582. curators: [],
  9583. workshopVotes: [],
  9584. curatorLikes: [],
  9585. announcements: []
  9586. }
  9587. };
  9588. const link2id = async function(type) {
  9589. 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;
  9590. try {
  9591. const link = $('#socialLink').val();
  9592. let id = '';
  9593. switch (type) {
  9594. case 'discord.servers':
  9595. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9596. break;
  9597.  
  9598. case 'instagram.users':
  9599. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9600. break;
  9601.  
  9602. case 'twitch.channels':
  9603. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9604. break;
  9605.  
  9606. case 'twitter.users':
  9607. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9608. break;
  9609.  
  9610. case 'twitter.retweets':
  9611. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9612. break;
  9613.  
  9614. case 'vk.names':
  9615. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9616. break;
  9617.  
  9618. case 'youtube.channels':
  9619. 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) || '';
  9620. break;
  9621.  
  9622. case 'youtube.likes':
  9623. 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) || '';
  9624. break;
  9625.  
  9626. case 'reddit.reddits':
  9627. 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]) || '';
  9628. break;
  9629.  
  9630. case 'steam.groups':
  9631. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9632. break;
  9633.  
  9634. case 'steam.wishlists':
  9635. case 'steam.follows':
  9636. case 'steam.forums':
  9637. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9638. break;
  9639.  
  9640. case 'steam.workshops':
  9641. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9642. break;
  9643.  
  9644. case 'steam.curators':
  9645. {
  9646. if (link.includes('curator')) {
  9647. var _link$match12;
  9648. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9649. } else {
  9650. var _link$match13;
  9651. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9652. if (!param || param.length !== 2) {
  9653. break;
  9654. }
  9655. const steam = new social_Steam();
  9656. if (await steam.init()) {
  9657. id = await steam.getCuratorId(param[0], param[1]) || '';
  9658. }
  9659. }
  9660. }
  9661. break;
  9662. }
  9663. return id;
  9664. } catch (error) {
  9665. throwError(error, 'link2id');
  9666. return i18n('getFailed', 'id');
  9667. }
  9668. };
  9669. const disabledType = {
  9670. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9671. twitter: [ 'likes' ]
  9672. };
  9673. const whiteListOptions = function(showType) {
  9674. try {
  9675. const whiteList = {
  9676. ...defaultWhiteList,
  9677. ...GM_getValue('whiteList') || {}
  9678. };
  9679. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9680. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9681. for (const [ social, types ] of Object.entries(whiteList)) {
  9682. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9683. var _disabledType$social;
  9684. 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>`;
  9685. }).join('');
  9686. }
  9687. whiteListOptionsForm += '</tbody></table></form>';
  9688. if (showType === 'swal') {
  9689. external_Swal_default().fire({
  9690. title: i18n('whiteListOptions'),
  9691. html: whiteListOptionsForm,
  9692. showConfirmButton: false,
  9693. showCloseButton: true
  9694. });
  9695. } else {
  9696. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9697. }
  9698. $('.editWhiteList').on('click', function() {
  9699. var _whiteList$social;
  9700. const value = $(this).attr('data-value');
  9701. if (!value) {
  9702. return;
  9703. }
  9704. const [ social, type ] = value.split('.');
  9705. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9706. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9707. return;
  9708. }
  9709. external_Swal_default().fire({
  9710. title: i18n('changeWhiteListOption', value),
  9711. input: 'textarea',
  9712. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9713. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9714. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9715. inputValue: whiteList[social][type].join('\n'),
  9716. showConfirmButton: true,
  9717. confirmButtonText: i18n('save'),
  9718. showCancelButton: true,
  9719. cancelButtonText: i18n('close'),
  9720. showDenyButton: true,
  9721. denyButtonText: i18n('return')
  9722. }).then(_ref => {
  9723. let {
  9724. isDenied,
  9725. isConfirmed,
  9726. value
  9727. } = _ref;
  9728. if (isDenied) {
  9729. if (showType === 'swal') {
  9730. whiteListOptions(showType);
  9731. }
  9732. return;
  9733. } else if (isConfirmed) {
  9734. whiteList[social][type] = value.split('\n');
  9735. GM_setValue('whiteList', whiteList);
  9736. external_Swal_default().fire({
  9737. title: i18n('changeWhiteListSuccess'),
  9738. icon: 'success'
  9739. });
  9740. }
  9741. });
  9742. $('#link2id').on('click', async function() {
  9743. const type = $(this).attr('data-type');
  9744. $('#socialLink').val(await link2id(type));
  9745. });
  9746. });
  9747. } catch (error) {
  9748. throwError(error, 'whiteListOptions');
  9749. }
  9750. };
  9751. const whiteList = whiteListOptions;
  9752. const setGistData = async (token, gistId, fileName, content) => {
  9753. try {
  9754. const logStatus = scripts_echoLog({
  9755. text: i18n('settingData')
  9756. });
  9757. const contentData = JSON.stringify({
  9758. files: {
  9759. [fileName]: {
  9760. content: JSON.stringify(content)
  9761. }
  9762. }
  9763. });
  9764. const {
  9765. result,
  9766. statusText,
  9767. status,
  9768. data
  9769. } = await tools_httpRequest({
  9770. url: `https://api.github.com/gists/${gistId}`,
  9771. headers: {
  9772. Accept: 'application/vnd.github.v3+json',
  9773. Authorization: `token ${token}`
  9774. },
  9775. data: contentData,
  9776. responseType: 'json',
  9777. method: 'POST',
  9778. timeout: 3e4
  9779. });
  9780. if (result === 'Success') {
  9781. var _data$response$files, _data$response$files$;
  9782. 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)) {
  9783. logStatus.success();
  9784. return true;
  9785. }
  9786. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9787. return false;
  9788. }
  9789. logStatus.error(`${result}:${statusText}(${status})`);
  9790. return false;
  9791. } catch (error) {
  9792. throwError(error, 'setGistData');
  9793. return false;
  9794. }
  9795. };
  9796. const getGistData = async (token, gistId, fileName) => {
  9797. try {
  9798. const logStatus = scripts_echoLog({
  9799. text: i18n('gettingData')
  9800. });
  9801. const {
  9802. result,
  9803. statusText,
  9804. status,
  9805. data
  9806. } = await tools_httpRequest({
  9807. url: `https://api.github.com/gists/${gistId}`,
  9808. headers: {
  9809. Accept: 'application/vnd.github.v3+json',
  9810. Authorization: `token ${token}`
  9811. },
  9812. responseType: 'json',
  9813. method: 'GET',
  9814. timeout: 3e4
  9815. });
  9816. if (result === 'Success') {
  9817. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9818. var _data$response, _data$response$files2, _data$response$files3;
  9819. logStatus.success();
  9820. 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);
  9821. }
  9822. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9823. return false;
  9824. }
  9825. logStatus.error(`${result}:${statusText}(${status})`);
  9826. return false;
  9827. } catch (error) {
  9828. throwError(error, 'getGistData');
  9829. return false;
  9830. }
  9831. };
  9832. const syncOptions = () => {
  9833. try {
  9834. const {
  9835. TOKEN,
  9836. GIST_ID,
  9837. FILE_NAME,
  9838. SYNC_HISTORY
  9839. } = GM_getValue('gistOptions') || {
  9840. TOKEN: '',
  9841. GIST_ID: '',
  9842. FILE_NAME: '',
  9843. SYNC_HISTORY: true
  9844. };
  9845. external_Swal_default().fire({
  9846. title: i18n('gistOptions'),
  9847. 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;">
  9848. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9849. ${i18n('downloadFromGist')}</button></p>`,
  9850. focusConfirm: false,
  9851. showLoaderOnConfirm: true,
  9852. 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>`,
  9853. preConfirm: async () => {
  9854. const token = $('#github-token').val();
  9855. const gistId = $('#gist-id').val();
  9856. const fileName = $('#file-name').val();
  9857. const syncHistory = $('#sync-history').prop('checked');
  9858. GM_setValue('gistOptions', {
  9859. TOKEN: token,
  9860. GIST_ID: gistId,
  9861. FILE_NAME: fileName,
  9862. SYNC_HISTORY: syncHistory
  9863. });
  9864. return await getGistData(token, gistId, fileName);
  9865. },
  9866. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9867. confirmButtonText: i18n('saveAndTest'),
  9868. showCancelButton: true,
  9869. cancelButtonText: i18n('close')
  9870. }).then(_ref => {
  9871. let {
  9872. value
  9873. } = _ref;
  9874. if (value) {
  9875. external_Swal_default().fire({
  9876. icon: 'success',
  9877. title: i18n('testSuccess')
  9878. }).then(syncOptions);
  9879. } else if (value !== undefined) {
  9880. external_Swal_default().fire({
  9881. icon: 'error',
  9882. title: i18n('testFailed')
  9883. }).then(syncOptions);
  9884. }
  9885. });
  9886. $('#upload-data').on('click', async () => {
  9887. const {
  9888. TOKEN,
  9889. GIST_ID,
  9890. FILE_NAME
  9891. } = GM_getValue('gistOptions') || {};
  9892. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9893. return external_Swal_default().fire({
  9894. icon: 'error',
  9895. title: i18n('saveAndTestNotice')
  9896. }).then(syncOptions);
  9897. }
  9898. external_Swal_default().fire({
  9899. icon: 'info',
  9900. title: i18n('processingData')
  9901. });
  9902. const data = {};
  9903. const names = GM_listValues();
  9904. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9905. for (const name of names) {
  9906. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9907. continue;
  9908. }
  9909. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9910. continue;
  9911. }
  9912. data[name] = GM_getValue(name);
  9913. }
  9914. external_Swal_default().update({
  9915. icon: 'info',
  9916. title: i18n('updatingData')
  9917. });
  9918. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9919. external_Swal_default().fire({
  9920. icon: 'success',
  9921. title: i18n('syncDataSuccess')
  9922. });
  9923. } else {
  9924. external_Swal_default().fire({
  9925. icon: 'error',
  9926. title: i18n('syncDataFailed')
  9927. });
  9928. }
  9929. });
  9930. $('#download-data').on('click', async () => {
  9931. const {
  9932. TOKEN,
  9933. GIST_ID,
  9934. FILE_NAME
  9935. } = GM_getValue('gistOptions') || {};
  9936. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9937. return external_Swal_default().fire({
  9938. icon: 'error',
  9939. title: i18n('saveAndTestNotice')
  9940. }).then(syncOptions);
  9941. }
  9942. external_Swal_default().fire({
  9943. icon: 'info',
  9944. title: i18n('downloadingData')
  9945. });
  9946. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9947. if (!data) {
  9948. return external_Swal_default().fire({
  9949. icon: 'error',
  9950. title: i18n('checkedNoData')
  9951. }).then(syncOptions);
  9952. }
  9953. external_Swal_default().update({
  9954. icon: 'info',
  9955. title: i18n('savingData')
  9956. });
  9957. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9958. for (const [ name, value ] of Object.entries(data)) {
  9959. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9960. continue;
  9961. }
  9962. GM_setValue(name, value);
  9963. }
  9964. external_Swal_default().fire({
  9965. icon: 'success',
  9966. title: i18n('syncDataSuccess')
  9967. });
  9968. });
  9969. } catch (error) {
  9970. throwError(error, 'syncOptions');
  9971. }
  9972. };
  9973. const dataSync = syncOptions;
  9974. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  9975. Setting_checkPrivateRedeclaration(obj, privateSet);
  9976. privateSet.add(obj);
  9977. }
  9978. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  9979. if (privateCollection.has(obj)) {
  9980. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9981. }
  9982. }
  9983. function Setting_defineProperty(obj, key, value) {
  9984. if (key in obj) {
  9985. Object.defineProperty(obj, key, {
  9986. value: value,
  9987. enumerable: true,
  9988. configurable: true,
  9989. writable: true
  9990. });
  9991. } else {
  9992. obj[key] = value;
  9993. }
  9994. return obj;
  9995. }
  9996. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  9997. if (!privateSet.has(receiver)) {
  9998. throw new TypeError('attempted to get private field on non-instance');
  9999. }
  10000. return fn;
  10001. }
  10002. var Setting_getId = new WeakSet();
  10003. var _environment = new WeakSet();
  10004. class Setting {
  10005. constructor() {
  10006. Setting_classPrivateMethodInitSpec(this, _environment);
  10007. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10008. Setting_defineProperty(this, 'name', 'Setting');
  10009. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10010. Setting_defineProperty(this, 'syncData', dataSync);
  10011. }
  10012. tasksHistory() {
  10013. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10014. }
  10015. static test() {
  10016. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10017. }
  10018. before() {
  10019. $('body').html('').addClass('auto-task-options');
  10020. }
  10021. after() {
  10022. try {
  10023. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10024. changeGlobalOptions('page');
  10025. whiteList('page');
  10026. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10027. $('#getTwitterUserId').on('click', () => {
  10028. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10029. });
  10030. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10031. $('#getYoutubeChannelId').on('click', () => {
  10032. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10033. });
  10034. $('input[name^="position"]').on('input', function() {
  10035. const type = $(this).attr('name').replace('position.', '');
  10036. const xLabel = 'rightleft';
  10037. const yLabel = 'topbottpm';
  10038. switch (type) {
  10039. case 'buttonSideX':
  10040. case 'buttonSideY':
  10041. case 'buttonDistance':
  10042. {
  10043. const distance = $('input[name="position.buttonDistance"]').val();
  10044. const sideX = $('input[name="position.buttonSideX"]').val();
  10045. const sideY = $('input[name="position.buttonSideY"]').val();
  10046. if (![ 'right', 'left' ].includes(sideX)) {
  10047. break;
  10048. }
  10049. if (![ 'top', 'bottom' ].includes(sideY)) {
  10050. break;
  10051. }
  10052. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10053. break;
  10054. }
  10055. const distanceArr = distance.split(',');
  10056. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10057. break;
  10058. }
  10059.  
  10060. case 'showButtonSideX':
  10061. case 'showButtonSideY':
  10062. case 'showButtonDistance':
  10063. {
  10064. const distance = $('input[name="position.showButtonDistance"]').val();
  10065. const sideX = $('input[name="position.showButtonSideX"]').val();
  10066. const sideY = $('input[name="position.showButtonSideY"]').val();
  10067. if (![ 'right', 'left' ].includes(sideX)) {
  10068. break;
  10069. }
  10070. if (![ 'top', 'bottom' ].includes(sideY)) {
  10071. break;
  10072. }
  10073. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10074. break;
  10075. }
  10076. const distanceArr = distance.split(',');
  10077. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10078. break;
  10079. }
  10080.  
  10081. case 'logSideX':
  10082. case 'logSideY':
  10083. case 'logDistance':
  10084. {
  10085. const distance = $('input[name="position.logDistance"]').val();
  10086. const sideX = $('input[name="position.logSideX"]').val();
  10087. const sideY = $('input[name="position.logSideY"]').val();
  10088. if (![ 'right', 'left' ].includes(sideX)) {
  10089. break;
  10090. }
  10091. if (![ 'top', 'bottom' ].includes(sideY)) {
  10092. break;
  10093. }
  10094. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10095. break;
  10096. }
  10097. const distanceArr = distance.split(',');
  10098. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10099. break;
  10100. }
  10101.  
  10102. default:
  10103. break;
  10104. }
  10105. });
  10106. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10107. let functionKey = '';
  10108. if (event.altKey) {
  10109. functionKey += 'alt + ';
  10110. } else if (event.ctrlKey) {
  10111. functionKey += 'ctrl + ';
  10112. } else if (event.shiftKey) {
  10113. functionKey += 'shift + ';
  10114. }
  10115. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10116. });
  10117. } catch (error) {
  10118. throwError(error, 'Setting.after');
  10119. }
  10120. }
  10121. saveGlobalOptions() {
  10122. saveData();
  10123. }
  10124. }
  10125. function Setting_getId2(social) {
  10126. try {
  10127. external_Swal_default().fire({
  10128. title: i18n('getId', i18n(social)),
  10129. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10130. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10131. showCancelButton: true,
  10132. cancelButtonText: i18n('close'),
  10133. showConfirmButton: false
  10134. });
  10135. $('#link2id').on('click', async function() {
  10136. const link = $('#socialLink').val();
  10137. if (!link) {
  10138. return;
  10139. }
  10140. const type = $(this).attr('data-type');
  10141. if (type === 'twitterUser') {
  10142. var _link$match;
  10143. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10144. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10145. } else if (type === 'youtubeChannel') {
  10146. var _link$match2, _await$getInfo, _await$getInfo$params;
  10147. 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;
  10148. $('#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) || '');
  10149. }
  10150. });
  10151. } catch (error) {
  10152. throwError(error, 'Setting.getId');
  10153. }
  10154. }
  10155. function _environment2() {
  10156. try {
  10157. const userAgent = (0, javascript_utils_umd_min.ua)();
  10158. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10159. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10160. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10161. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10162. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10163. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10164. </tbody></table></form>`;
  10165. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10166. } catch (error) {
  10167. throwError(error, 'Setting.environment');
  10168. }
  10169. }
  10170. const website_Setting = Setting;
  10171. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10172. History_checkPrivateRedeclaration(obj, privateSet);
  10173. privateSet.add(obj);
  10174. }
  10175. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10176. if (privateCollection.has(obj)) {
  10177. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10178. }
  10179. }
  10180. function History_defineProperty(obj, key, value) {
  10181. if (key in obj) {
  10182. Object.defineProperty(obj, key, {
  10183. value: value,
  10184. enumerable: true,
  10185. configurable: true,
  10186. writable: true
  10187. });
  10188. } else {
  10189. obj[key] = value;
  10190. }
  10191. return obj;
  10192. }
  10193. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10194. if (!privateSet.has(receiver)) {
  10195. throw new TypeError('attempted to get private field on non-instance');
  10196. }
  10197. return fn;
  10198. }
  10199. var _addItem = new WeakSet();
  10200. class History extends website_Keylol {
  10201. constructor() {
  10202. super(...arguments);
  10203. History_classPrivateMethodInitSpec(this, _addItem);
  10204. History_defineProperty(this, 'name', 'History');
  10205. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10206. }
  10207. static test() {
  10208. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10209. }
  10210. before() {
  10211. try {
  10212. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10213. const data = GM_listValues() || [];
  10214. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10215. for (const item of tasksHistory) {
  10216. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10217. }
  10218. } catch (error) {
  10219. throwError(error, 'History.before');
  10220. }
  10221. }
  10222. clearHistory() {
  10223. try {
  10224. const data = GM_listValues() || [];
  10225. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10226. for (const item of tasksHistory) {
  10227. GM_deleteValue(item);
  10228. }
  10229. external_Swal_default().fire({
  10230. title: i18n('clearHistoryFinished'),
  10231. icon: 'success'
  10232. });
  10233. } catch (error) {
  10234. throwError(error, 'History.after');
  10235. }
  10236. }
  10237. }
  10238. function _addItem2(item) {
  10239. try {
  10240. const tasksData = GM_getValue(item);
  10241. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10242. return;
  10243. }
  10244. let html = '';
  10245. let title = '';
  10246. let link = '';
  10247. const [ website, id ] = item.split('-');
  10248. switch (website) {
  10249. case 'fawTasks':
  10250. title = `Freeanywhere[${id}]`;
  10251. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10252. break;
  10253.  
  10254. case 'gasTasks':
  10255. title = `Giveawaysu[${id}]`;
  10256. link = `https://giveaway.su/giveaway/view/${id}`;
  10257. break;
  10258.  
  10259. case 'gcTasks':
  10260. title = `GiveeClub[${id}]`;
  10261. link = `https://givee.club/event/${id}`;
  10262. break;
  10263.  
  10264. case 'gkTasks':
  10265. title = `Givekey[${id}]`;
  10266. link = `https://givekey.ru/giveaway/${id}`;
  10267. break;
  10268.  
  10269. case 'gleamTasks':
  10270. title = `Gleam[${id}]`;
  10271. link = `https://gleam.io${id}`;
  10272. break;
  10273.  
  10274. case 'khTasks':
  10275. title = `keyhub[${id}]`;
  10276. link = `https://key-hub.eu/giveaway/${id}`;
  10277. break;
  10278.  
  10279. case 'prysTasks':
  10280. title = `Prys[${id}]`;
  10281. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10282. break;
  10283.  
  10284. default:
  10285. return;
  10286. }
  10287. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10288. for (const [ type, tasks ] of Object.entries(types)) {
  10289. for (const task of tasks) {
  10290. 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>`;
  10291. }
  10292. }
  10293. }
  10294. $('.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>`);
  10295. $('span.delete-task').on('click', function() {
  10296. const itemName = $(this).attr('data-name');
  10297. if (itemName) {
  10298. GM_deleteValue(itemName);
  10299. external_Swal_default().fire({
  10300. title: i18n('clearTaskFinished'),
  10301. text: itemName,
  10302. icon: 'success'
  10303. });
  10304. } else {
  10305. external_Swal_default().fire({
  10306. title: i18n('clearTaskFailed'),
  10307. icon: 'error'
  10308. });
  10309. }
  10310. });
  10311. } catch (error) {
  10312. throwError(error, 'History.addItem');
  10313. }
  10314. }
  10315. const website_History = History;
  10316. 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 ];
  10317. const websiteOptions = function(website, options) {
  10318. try {
  10319. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10320. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10321. for (const [ option, value ] of Object.entries(options)) {
  10322. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10323. }
  10324. websiteOptionsForm += '</tbody></table></form>';
  10325. external_Swal_default().fire({
  10326. title: i18n('websiteOptions'),
  10327. html: websiteOptionsForm,
  10328. showConfirmButton: true,
  10329. confirmButtonText: i18n('save'),
  10330. showCancelButton: true,
  10331. cancelButtonText: i18n('close')
  10332. }).then(_ref => {
  10333. let {
  10334. isConfirmed
  10335. } = _ref;
  10336. if (isConfirmed) {
  10337. $('#websiteOptionsForm').serializeArray().map(value => {
  10338. options[value.name] = value.value;
  10339. return value;
  10340. });
  10341. GM_setValue(`${website}Options`, options);
  10342. external_Swal_default().fire({
  10343. title: i18n('changeWebsiteOptionsSuccess'),
  10344. icon: 'success'
  10345. });
  10346. }
  10347. });
  10348. } catch (error) {
  10349. throwError(error, 'websiteOptions');
  10350. }
  10351. };
  10352. const options = websiteOptions;
  10353. const external_keyboardJS_namespaceObject = keyboardJS;
  10354. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10355. const checkUpdate = async (updateLink, auto) => {
  10356. try {
  10357. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10358. const {
  10359. result,
  10360. statusText,
  10361. status,
  10362. data
  10363. } = await tools_httpRequest({
  10364. url: checkUrl,
  10365. responseType: 'json',
  10366. method: 'GET',
  10367. timeout: 3e4
  10368. });
  10369. if (result === 'Success') {
  10370. var _data$response;
  10371. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10372. return data.response;
  10373. }
  10374. if (!auto) {
  10375. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10376. }
  10377. return false;
  10378. }
  10379. if (!auto) {
  10380. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10381. }
  10382. return false;
  10383. } catch (error) {
  10384. throwError(error, 'checkUpdate');
  10385. return false;
  10386. }
  10387. };
  10388. const hasNewVersion = (currentVersion, remoteVersion) => {
  10389. try {
  10390. const [ currentRealVersion ] = currentVersion.split('-');
  10391. const [ remoteRealVersion ] = remoteVersion.split('-');
  10392. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10393. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10394. if (remoteVersion1 > currentVersion1) {
  10395. return true;
  10396. }
  10397. if (remoteVersion1 < currentVersion1) {
  10398. return false;
  10399. }
  10400. if (remoteVersion2 > currentVersion2) {
  10401. return true;
  10402. }
  10403. if (remoteVersion2 < currentVersion2) {
  10404. return false;
  10405. }
  10406. if (remoteVersion3 > currentVersion3) {
  10407. return true;
  10408. }
  10409. return false;
  10410. } catch (error) {
  10411. throwError(error, 'compareVersion');
  10412. return false;
  10413. }
  10414. };
  10415. const updateChecker = async () => {
  10416. try {
  10417. const currentVersion = GM_info.script.version;
  10418. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10419. const updateLinks = {
  10420. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10421. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10422. standby: 'https://auto-task-v4.hclonely.com/'
  10423. };
  10424. let version;
  10425. let updateLink = '';
  10426. let packageData;
  10427. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10428. updateLink = updateLinks[updateSource];
  10429. packageData = await checkUpdate(updateLink, false);
  10430. } else {
  10431. updateLink = updateLinks.github;
  10432. packageData = await checkUpdate(updateLink, true);
  10433. if (!packageData) {
  10434. updateLink = updateLinks.jsdelivr;
  10435. packageData = await checkUpdate(updateLink, true);
  10436. if (!packageData) {
  10437. updateLink = updateLinks.standby;
  10438. packageData = await checkUpdate(updateLink, true);
  10439. }
  10440. }
  10441. }
  10442. if (packageData) {
  10443. version = packageData.version || currentVersion;
  10444. } else {
  10445. version = currentVersion;
  10446. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10447. }
  10448. if (packageData && hasNewVersion(currentVersion, version)) {
  10449. var _packageData$change;
  10450. scripts_echoLog({
  10451. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10452. });
  10453. scripts_echoLog({
  10454. 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>`
  10455. });
  10456. }
  10457. } catch (error) {
  10458. throwError(error, 'updateChecker');
  10459. }
  10460. };
  10461. const scripts_updateChecker = updateChecker;
  10462. if (window.location.hostname === 'discord.com') {
  10463. var _window$localStorage, _window$localStorage$;
  10464. 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, '');
  10465. GM_setValue('discordAuth', {
  10466. auth: discordAuth
  10467. });
  10468. if (discordAuth && window.location.hash === '#auth') {
  10469. window.close();
  10470. external_Swal_default().fire('', i18n('closePageNotice'));
  10471. }
  10472. }
  10473. const loadScript = async () => {
  10474. var _website, _website2, _website3, _website4, _website5, _website6;
  10475. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10476. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10477. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10478. if (isLogin) {
  10479. var _commonOptions, _commonOptions$header;
  10480. GM_setValue('twitchAuth', {
  10481. authToken: authToken,
  10482. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10483. });
  10484. window.close();
  10485. external_Swal_default().fire('', i18n('closePageNotice'));
  10486. } else {
  10487. external_Swal_default().fire('', i18n('needLogin'));
  10488. }
  10489. }
  10490. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10491. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10492. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10493. if (isLogin && ct0) {
  10494. GM_setValue('twitterAuth', {
  10495. ct0: ct0
  10496. });
  10497. window.close();
  10498. external_Swal_default().fire('', i18n('closePageNotice'));
  10499. } else {
  10500. external_Swal_default().fire('', i18n('needLogin'));
  10501. }
  10502. }
  10503. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10504. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10505. if (PAPISID) {
  10506. GM_setValue('youtubeAuth', {
  10507. PAPISID: PAPISID
  10508. });
  10509. window.close();
  10510. external_Swal_default().fire('', i18n('closePageNotice'));
  10511. } else {
  10512. external_Swal_default().fire('', i18n('needLogin'));
  10513. }
  10514. }
  10515. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10516. const betaButton = $('#redesign-beta-optin-btn');
  10517. if (betaButton.length > 0) {
  10518. GM_setValue('redditAuth', '#auth');
  10519. return betaButton[0].click();
  10520. }
  10521. GM_setValue('redditAuth', null);
  10522. window.close();
  10523. external_Swal_default().fire('', i18n('closePageNotice'));
  10524. }
  10525. let website;
  10526. for (const Website of Websites) {
  10527. if (Website.test()) {
  10528. website = new Website();
  10529. break;
  10530. }
  10531. }
  10532. if (!website) {
  10533. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10534. return;
  10535. }
  10536. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10537. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10538. }
  10539. $('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>`);
  10540. $('div.show-button-div').on('click', () => {
  10541. $('#auto-task-buttons').show();
  10542. $('div.show-button-div').hide();
  10543. });
  10544. const toggleLog = () => {
  10545. const $this = $('#toggle-log');
  10546. const status = $this.attr('data-status');
  10547. if (status === 'show') {
  10548. $('#auto-task-info').hide();
  10549. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10550. } else {
  10551. $('#auto-task-info').show();
  10552. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10553. }
  10554. };
  10555. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10556. if (website.doTask) {
  10557. website.doTask();
  10558. }
  10559. });
  10560. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10561. if (website.undoTask) {
  10562. website.doTask();
  10563. }
  10564. });
  10565. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10566. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10567. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10568. }
  10569. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10570. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10571. for (const button of website.buttons) {
  10572. if (website[button]) {
  10573. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10574. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10575. website[button]();
  10576. });
  10577. $('#auto-task-buttons').append(btnElement);
  10578. }
  10579. }
  10580. }
  10581. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10582. ${i18n('hideButton')}</a></p>`);
  10583. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10584. $('#auto-task-buttons').hide();
  10585. $('div.show-button-div').show();
  10586. });
  10587. 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'}">
  10588. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10589. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10590. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10591. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10592. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10593. options(website.name, website.options);
  10594. });
  10595. }
  10596. if (website.name !== 'Setting') {
  10597. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10598. changeGlobalOptions('swal');
  10599. });
  10600. GM_registerMenuCommand(i18n('settingPage'), () => {
  10601. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10602. });
  10603. }
  10604. GM_addStyle(auto_task.Z);
  10605. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10606. if (!GM_getValue('notice')) {
  10607. var _echoLog$font;
  10608. external_Swal_default().fire({
  10609. title: i18n('swalNotice'),
  10610. icon: 'warning'
  10611. }).then(() => {
  10612. window.open(i18n('noticeLink'), '_blank');
  10613. GM_setValue('notice', new Date().getTime());
  10614. });
  10615. (_echoLog$font = scripts_echoLog({
  10616. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10617. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10618. GM_setValue('notice', new Date().getTime());
  10619. });
  10620. }
  10621. scripts_updateChecker();
  10622. };
  10623. if (window.location.hostname === 'opquests.com') {
  10624. loadScript();
  10625. } else {
  10626. $(loadScript);
  10627. }
  10628. }();
  10629. })();