auto-task-v4

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

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

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.9-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.  
  13. // @include *://freeanywhere.net/*
  14. // @include *://giveaway.su/giveaway/view/*
  15. // @include *://givee.club/*/event/*
  16. // @include *://givekey.ru/giveaway/*
  17. // @include *://www.indiedb.com/giveaways*
  18. // @include *://key-hub.eu/giveaway/*
  19. // @include *://keylol.com/*
  20. // @include *://www.opiumpulses.com/giveaways
  21. // @include *://prys.revadike.com/giveaway/?id=*
  22. // @include *://opquests.com/quests/*
  23. // @include *://gleam.io/*
  24. // @include *://sweepwidget.com/view/*
  25. // @include *://discord.com/*
  26. // @include *://www.twitch.tv/*
  27. // @include *://www.youtube.com/*
  28. // @include *://*.reddit.com/*
  29. // @include *://twitter.com/settings/account?k*
  30. // @include https://auto-task-v4.hclonely.com/setting.html
  31. // @include https://auto-task-v4.hclonely.com/history.html
  32.  
  33. // @grant GM_setValue
  34. // @grant GM_getValue
  35. // @grant GM_listValues
  36. // @grant GM_deleteValue
  37. // @grant GM_addStyle
  38. // @grant GM_xmlhttpRequest
  39. // @grant GM_registerMenuCommand
  40. // @grant GM_info
  41. // @grant GM_openInTab
  42. // @grant GM_setClipboard
  43. // @grant unsafeWindow
  44. // @grant window.close
  45. // @grant window.localStorage
  46.  
  47. // @connect cdn.jsdelivr.net
  48. // @connect store.steampowered.com
  49. // @connect steamcommunity.com
  50. // @connect twitter.com
  51. // @connect api.twitter.com
  52. // @connect youtube.com
  53. // @connect www.youtube.com
  54. // @connect facebook.com
  55. // @connect instagram.com
  56. // @connect vk.com
  57. // @connect twitch.tv
  58. // @connect www.twitch.tv
  59. // @connect gql.twitch.tv
  60. // @connect github.com
  61. // @connect discordapp.com
  62. // @connect discord.gg
  63. // @connect discord.com
  64. // @connect www.reddit.com
  65. // @connect oauth.reddit.com
  66. // @connect raw.githubusercontent.com
  67. // @connect t.me
  68. // @connect bit.ly
  69. // @connect giveaway.su
  70. // @connect google.com
  71. // @connect www.vloot.io
  72. // @connect givee.club
  73. // @connect gleam.io
  74. // @connect www.indiedb.com
  75. // @connect key-hub.eu
  76. // @connect opquests.com
  77. // @connect itch.io
  78. // @connect auto-task-v4.hclonely.com
  79. // @connect *
  80. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  81. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  82. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  83. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  84. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11
  85. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  86. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  87.  
  88. // @compatible Tampermonkey Only
  89. // @noframes
  90. // ==/UserScript==
  91.  
  92. console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
  93.  
  94. (function() {
  95. var __webpack_modules__ = {
  96. 514: function(__unused_webpack_module, exports) {
  97. !function(e, n) {
  98. true ? n(exports) : 0;
  99. }(this, function(e) {
  100. 'use strict';
  101. var t = function() {
  102. return (t = Object.assign || function(e) {
  103. for (var n, o = 1, t = arguments.length; o < t; o++) {
  104. for (var r in n = arguments[o]) {
  105. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  106. }
  107. }
  108. return e;
  109. }).apply(this, arguments);
  110. };
  111. function r(e, n, o) {
  112. if (o || 2 === arguments.length) {
  113. for (var t, r = 0, i = n.length; r < i; r++) {
  114. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  115. }
  116. }
  117. return e.concat(t || Array.prototype.slice.call(n));
  118. }
  119. function d(e) {
  120. return '[object Object]' === n(e);
  121. }
  122. function l(e, n) {
  123. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  124. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  125. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  126. });
  127. }
  128. var n = function(e) {
  129. return Object.prototype.toString.call(e);
  130. };
  131. var o = (i.prototype.init = function() {
  132. try {
  133. this.getSystemName(), this.getBrowserName();
  134. } catch (e) {
  135. console.warn('[UA formatter error] '.concat(e));
  136. }
  137. }, i.prototype.getEngine = function() {
  138. var e = this.agent;
  139. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  140. }, i.prototype.getSystemName = function() {
  141. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  142. try {
  143. var o = '';
  144. if (/Windows/i.test(n)) {
  145. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  146. switch (this.info.os = 'Windows', t) {
  147. case '6.3':
  148. o = '8.1';
  149. break;
  150.  
  151. case '6.2':
  152. o = '8';
  153. break;
  154.  
  155. case '6.1':
  156. o = '7';
  157. break;
  158.  
  159. case '5.2':
  160. case '5.1':
  161. o = 'XP';
  162. break;
  163.  
  164. default:
  165. o = t;
  166. }
  167. return this.info.device = 'PC', void (this.info.osVersion = o);
  168. }
  169. if (/^Macintosh/i.test(n)) {
  170. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  171. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  172. }
  173. if (/^iPad/i.test(n)) {
  174. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  175. void (this.info.osVersion = o.replace(/_/g, '.'));
  176. }
  177. if (/^iPhone/i.test(n)) {
  178. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  179. void (this.info.osVersion = o.replace(/_/g, '.'));
  180. }
  181. if (-1 !== n.indexOf('Android')) {
  182. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  183. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  184. }
  185. if (/Linux\s[a-z\d_]+/.test(n)) {
  186. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  187. }
  188. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  189. } catch (e) {
  190. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  191. }
  192. }, i.prototype.getBrowserName = function() {
  193. var e = Object.keys(this.browserNameMap).map(function(e) {
  194. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  195. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  196. return -1 !== e.findIndex(function(e) {
  197. return e.test(n);
  198. });
  199. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  200. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  201. }, i.prototype._formatBrowserVersion = function(e) {
  202. var n, o, t, r;
  203. try {
  204. 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++) {
  205. var d = u[f], l = d[0], h = d[1];
  206. if (new RegExp(l).test(s)) {
  207. c = h;
  208. break;
  209. }
  210. }
  211. var p = {
  212. browserVersion: null != a ? a : 'Unknown',
  213. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  214. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  215. };
  216. return 'Trident' === s && (p.browserVersion = {
  217. '4.0': 8,
  218. '5.0': 9,
  219. '6.0': 10,
  220. '7.0': 11
  221. }[a]), p;
  222. } catch (e) {
  223. return console.warn('[UA formatter error] '.concat(e)), {
  224. browser: 'Unknown',
  225. browserVersion: 'Unknown'
  226. };
  227. }
  228. }, i);
  229. function i(e) {
  230. this.agent = '', this.info = {
  231. browser: '',
  232. browserZH: '',
  233. browserVersion: '',
  234. os: '',
  235. osVersion: '',
  236. device: 'Unknown',
  237. engine: 'WebKit'
  238. }, this.browserNameMap = {
  239. MicroMessenger: {
  240. en: 'MicroMessenger',
  241. zh: '微信'
  242. },
  243. MetaSr: {
  244. en: 'MetaSr',
  245. zh: '搜狗浏览器'
  246. },
  247. 'QQ(Browser)?': {
  248. en: 'QQBrowser',
  249. zh: 'QQ浏览器'
  250. },
  251. UCBrowser: {
  252. en: 'UCBrowser',
  253. zh: 'UC浏览器'
  254. },
  255. '2345Explorer': {
  256. en: '2345Explorer',
  257. zh: '2345极速浏览器'
  258. },
  259. Mb2345Browser: {
  260. en: 'Mb2345Browser',
  261. zh: '2345手机浏览器'
  262. },
  263. Trident: {
  264. en: 'Internet Explorer'
  265. },
  266. 'Edge?': {
  267. en: 'Edge'
  268. },
  269. OPR: {
  270. en: 'Opera'
  271. },
  272. Vivaldi: {
  273. en: 'Vivaldi'
  274. },
  275. Firefox: {
  276. en: 'Firefox'
  277. },
  278. Chrome: {
  279. en: 'Chrome'
  280. },
  281. Safari: {
  282. en: 'Safari'
  283. }
  284. }, this.agent = e, this.init();
  285. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  286. this.info = t(t({}, this.info), {
  287. engine: this.getEngine(),
  288. browserVersion: 'Safari' === o ? n : e
  289. });
  290. }
  291. function s() {
  292. this.cookies = {}, this.init();
  293. }
  294. var a = new (s.prototype.init = function() {
  295. var o = {};
  296. document.cookie.split(/;\s/).forEach(function(e) {
  297. var n = e.split(/=/), e = n[0], n = n[1];
  298. o[e] = n;
  299. }), this.cookies = o;
  300. }, s.prototype.getItem = function(e) {
  301. return this.cookies[e];
  302. }, s.prototype.getAllItems = function() {
  303. return this.cookies;
  304. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  305. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  306. }, s)();
  307. e.countDown = function e(n, o, t, r) {
  308. if (!window) {
  309. throw new Error('window is not defind.');
  310. }
  311. if (0 < n) {
  312. return r && r(), n--, window[o] = window.setTimeout(function() {
  313. e(n, o, t, r);
  314. }, 1e3), function() {
  315. return clearTimeout(window[o]);
  316. };
  317. }
  318. clearTimeout(window[o]), t && t();
  319. }, e.createRandomID = function(e) {
  320. void 0 === e && (e = 12);
  321. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  322. n.push(o[Math.round(Math.random() * t)]);
  323. }
  324. return n.join('');
  325. }, e.dCookie = a, e.debounce = function(o, t, r) {
  326. var i;
  327. void 0 === t && (t = 0);
  328. var s = r = void 0 === r ? !1 : r;
  329. return function() {
  330. var e = this, n = arguments;
  331. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  332. r ? s = !0 : o.apply(e, n);
  333. }, t);
  334. };
  335. }, e.deepCopy = function e(n) {
  336. if (d(n) || Array.isArray(n)) {
  337. var o, t = Array.isArray(n) ? [] : {};
  338. for (o in n) {
  339. t[o] = e(n[o]);
  340. }
  341. return t;
  342. }
  343. return n;
  344. }, e.formatQueryParams = function(e) {
  345. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  346. if (!e) {
  347. return {};
  348. }
  349. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  350. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  351. return t[n] = o, e;
  352. });
  353. }
  354. return t;
  355. }, e.formatThousandth = function(e) {
  356. 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, '$&,');
  357. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  358. }, e.generateTree = function e(n, o, t, r) {
  359. for (var i = [], s = 0; s < n.length; s++) {
  360. var a = n[s];
  361. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  362. }
  363. return i;
  364. }, e.isEmpty = function(e) {
  365. 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);
  366. }, e.isFunction = function(e) {
  367. return '[object Function]' === n(e);
  368. }, e.isImageUrl = function(e) {
  369. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  370. }, e.isObject = d, e.isRegexp = function(e) {
  371. return '[object RegExp]' === n(e);
  372. }, e.objectKeyToCamelCase = function e(n, o, t) {
  373. if (Array.isArray(n)) {
  374. for (var r = [], i = 0; i < n.length; i++) {
  375. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  376. }
  377. } else if (d(n)) {
  378. r = {};
  379. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  380. var f = (u = c[a])[0], u = u[1];
  381. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  382. }
  383. } else {
  384. r = n;
  385. }
  386. return r;
  387. }, e.realType = n, e.searchParams = function(e, n) {
  388. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  389. new URLSearchParams(e).get(n);
  390. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  391. return e.replace(/([A-Z])/g, function(e) {
  392. return '_'.concat(e.toLocaleLowerCase());
  393. });
  394. }, e.ua = function(e) {
  395. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  396. }, Object.defineProperty(e, '__esModule', {
  397. value: !0
  398. });
  399. });
  400. },
  401. 786: function(module, __webpack_exports__, __webpack_require__) {
  402. 'use strict';
  403. __webpack_require__.d(__webpack_exports__, {
  404. Z: function() {
  405. return __WEBPACK_DEFAULT_EXPORT__;
  406. }
  407. });
  408. 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);
  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___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__);
  410. 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);
  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___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__);
  412. 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());
  413. ___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(20px);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}', '' ]);
  414. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  415. },
  416. 400: function(module) {
  417. 'use strict';
  418. module.exports = function(cssWithMappingToString) {
  419. var list = [];
  420. list.toString = function toString() {
  421. return this.map(function(item) {
  422. var content = '';
  423. var needLayer = typeof item[5] !== 'undefined';
  424. if (item[4]) {
  425. content += '@supports ('.concat(item[4], ') {');
  426. }
  427. if (item[2]) {
  428. content += '@media '.concat(item[2], ' {');
  429. }
  430. if (needLayer) {
  431. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  432. }
  433. content += cssWithMappingToString(item);
  434. if (needLayer) {
  435. content += '}';
  436. }
  437. if (item[2]) {
  438. content += '}';
  439. }
  440. if (item[4]) {
  441. content += '}';
  442. }
  443. return content;
  444. }).join('');
  445. };
  446. list.i = function i(modules, media, dedupe, supports, layer) {
  447. if (typeof modules === 'string') {
  448. modules = [ [ null, modules, undefined ] ];
  449. }
  450. var alreadyImportedModules = {};
  451. if (dedupe) {
  452. for (var k = 0; k < this.length; k++) {
  453. var id = this[k][0];
  454. if (id != null) {
  455. alreadyImportedModules[id] = true;
  456. }
  457. }
  458. }
  459. for (var _k = 0; _k < modules.length; _k++) {
  460. var item = [].concat(modules[_k]);
  461. if (dedupe && alreadyImportedModules[item[0]]) {
  462. continue;
  463. }
  464. if (typeof layer !== 'undefined') {
  465. if (typeof item[5] === 'undefined') {
  466. item[5] = layer;
  467. } else {
  468. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  469. item[5] = layer;
  470. }
  471. }
  472. if (media) {
  473. if (!item[2]) {
  474. item[2] = media;
  475. } else {
  476. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  477. item[2] = media;
  478. }
  479. }
  480. if (supports) {
  481. if (!item[4]) {
  482. item[4] = ''.concat(supports);
  483. } else {
  484. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  485. item[4] = supports;
  486. }
  487. }
  488. list.push(item);
  489. }
  490. };
  491. return list;
  492. };
  493. },
  494. 220: function(module) {
  495. 'use strict';
  496. module.exports = function(i) {
  497. return i[1];
  498. };
  499. }
  500. };
  501. var __webpack_module_cache__ = {};
  502. function __webpack_require__(moduleId) {
  503. var cachedModule = __webpack_module_cache__[moduleId];
  504. if (cachedModule !== undefined) {
  505. return cachedModule.exports;
  506. }
  507. var module = __webpack_module_cache__[moduleId] = {
  508. id: moduleId,
  509. exports: {}
  510. };
  511. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  512. return module.exports;
  513. }
  514. !function() {
  515. __webpack_require__.n = function(module) {
  516. var getter = module && module.__esModule ? function() {
  517. return module['default'];
  518. } : function() {
  519. return module;
  520. };
  521. __webpack_require__.d(getter, {
  522. a: getter
  523. });
  524. return getter;
  525. };
  526. }();
  527. !function() {
  528. __webpack_require__.d = function(exports, definition) {
  529. for (var key in definition) {
  530. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  531. Object.defineProperty(exports, key, {
  532. enumerable: true,
  533. get: definition[key]
  534. });
  535. }
  536. }
  537. };
  538. }();
  539. !function() {
  540. __webpack_require__.o = function(obj, prop) {
  541. return Object.prototype.hasOwnProperty.call(obj, prop);
  542. };
  543. }();
  544. var __webpack_exports__ = {};
  545. !function() {
  546. 'use strict';
  547. const external_Swal_namespaceObject = Swal;
  548. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  549. const external_Cookies_namespaceObject = Cookies;
  550. var auto_task = __webpack_require__(786);
  551. var javascript_utils_umd_min = __webpack_require__(514);
  552. const httpRequest = async function(options) {
  553. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  554. try {
  555. const result = await new Promise(resolve => {
  556. if (options.dataType) {
  557. options.responseType = options.dataType;
  558. }
  559. const requestObj = {
  560. ...{
  561. timeout: 3e4,
  562. ontimeout(data) {
  563. resolve({
  564. result: 'Error',
  565. statusText: 'Timeout',
  566. status: 601,
  567. data: data,
  568. options: options
  569. });
  570. },
  571. onabort(data) {
  572. resolve({
  573. result: 'Error',
  574. statusText: 'Aborted',
  575. status: 602,
  576. data: data,
  577. options: options
  578. });
  579. },
  580. onerror(data) {
  581. resolve({
  582. result: 'Error',
  583. statusText: 'Error',
  584. status: 603,
  585. data: data,
  586. options: options
  587. });
  588. },
  589. onload(data) {
  590. resolve({
  591. result: 'Success',
  592. statusText: 'Load',
  593. status: 600,
  594. data: data,
  595. options: options
  596. });
  597. }
  598. },
  599. ...options
  600. };
  601. GM_xmlhttpRequest(requestObj);
  602. });
  603. console.log('发送请求:', result);
  604. if (result.status !== 600 && times < 2) {
  605. return await httpRequest(options, times + 1);
  606. }
  607. return result;
  608. } catch (error) {
  609. throwError(error, 'httpRequest');
  610. console.log('发送请求:', {
  611. errorMsg: error,
  612. options: options
  613. });
  614. return {
  615. result: 'JsError',
  616. statusText: 'Error',
  617. status: 604,
  618. error: error,
  619. options: options
  620. };
  621. }
  622. };
  623. const tools_httpRequest = httpRequest;
  624. const echoLog = _ref => {
  625. let {
  626. type,
  627. text,
  628. html,
  629. id
  630. } = _ref;
  631. const emptyStatus = {
  632. success: () => emptyStatus,
  633. error: () => emptyStatus,
  634. warning: () => emptyStatus,
  635. info: () => emptyStatus,
  636. view: () => emptyStatus
  637. };
  638. try {
  639. var _ele$;
  640. let ele;
  641. if (type) {
  642. switch (type) {
  643. case 'joiningSteamGroup':
  644. case 'leavingSteamGroup':
  645. case 'gettingSteamGroupId':
  646. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>...<font></font></li>`);
  647. break;
  648.  
  649. case 'subscribingForum':
  650. case 'unsubscribingForum':
  651. case 'gettingForumId':
  652. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>...<font></font></li>`);
  653. break;
  654.  
  655. case 'followingCurator':
  656. case 'unfollowingCurator':
  657. case 'getCuratorId':
  658. 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>`);
  659. break;
  660.  
  661. case 'addingToWishlist':
  662. case 'removingFromWishlist':
  663. case 'followingGame':
  664. case 'unfollowingGame':
  665. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>...<font></font></li>`);
  666. break;
  667.  
  668. case 'favoritingWorkshop':
  669. case 'unfavoritingWorkshop':
  670. case 'gettingWorkshopAppId':
  671. case 'votingUpWorkshop':
  672. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  673. ${text}</a>...<font></font></li>`);
  674. break;
  675.  
  676. case 'gettingAnnouncementParams':
  677. case 'likingAnnouncement':
  678. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  679. ${id}</a>...<font></font></li>`);
  680. break;
  681.  
  682. case 'joiningDiscordServer':
  683. case 'gettingDiscordGuild':
  684. ele = $(`<li>${i18n(type)}<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>...<font></font></li>`);
  685. break;
  686.  
  687. case 'leavingDiscordServer':
  688. ele = $(`<li>${i18n(type)}<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>...<font></font></li>`);
  689. break;
  690.  
  691. case 'updateDiscordAuth':
  692. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  693. break;
  694.  
  695. case 'followingTwitchChannel':
  696. case 'unfollowingTwitchChannel':
  697. case 'gettingTwitchChannelId':
  698. ele = $(`<li>${i18n(type)}<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>...<font></font></li>`);
  699. break;
  700.  
  701. case 'gettingInsUserId':
  702. case 'followingIns':
  703. case 'unfollowingIns':
  704. ele = $(`<li>${i18n(type)}<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  705. break;
  706.  
  707. case 'gettingTwitterUserId':
  708. case 'followingTwitterUser':
  709. case 'unfollowingTwitterUser':
  710. ele = $(`<li>${i18n(type)}<a href="https://twitter.com/${text}" target="_blank">${text}</a>...<font></font></li>`);
  711. break;
  712.  
  713. case 'retweetting':
  714. case 'unretweetting':
  715. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  716. break;
  717.  
  718. case 'joiningReddit':
  719. case 'leavingReddit':
  720. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  721. break;
  722.  
  723. case 'followingRedditUser':
  724. case 'unfollowingRedditUser':
  725. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  726. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>...<font></font></li>`);
  727. break;
  728.  
  729. case 'followingYtbChannel':
  730. case 'unfollowingYtbChannel':
  731. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>...<font></font></li>`);
  732. break;
  733.  
  734. case 'likingYtbVideo':
  735. case 'unlikingYtbVideo':
  736. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>...<font></font></li>`);
  737. break;
  738.  
  739. case 'gettingVkId':
  740. case 'joiningVkGroup':
  741. case 'leavingVkGroup':
  742. case 'joiningVkPublic':
  743. case 'leavingVkPublic':
  744. case 'sendingVkWall':
  745. case 'deletingVkWall':
  746. ele = $(`<li>${i18n(type)}<a href="https://vk.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  747. break;
  748.  
  749. case 'visitingLink':
  750. ele = $(`<li>${i18n('visitingLink')}<a href="${text}" target="_blank">${text}</a>...<font></font></li>`);
  751. break;
  752.  
  753. case 'verifyingInsAuth':
  754. case 'text':
  755. ele = $(`<li>${i18n(text)}<font></font></li>`);
  756. break;
  757.  
  758. case 'html':
  759. ele = $(text || html);
  760. break;
  761.  
  762. case 'whiteList':
  763. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  764. break;
  765.  
  766. case 'globalOptionsSkip':
  767. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  768. break;
  769.  
  770. default:
  771. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  772. break;
  773. }
  774. } else if (text) {
  775. ele = $(`<li>${i18n(text)}<font></font></li>`);
  776. } else if (html) {
  777. ele = $(html);
  778. } else {
  779. ele = $('<li><font></font></li>');
  780. }
  781. ele.addClass('card-text');
  782. $('#auto-task-info').append(ele);
  783. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  784. const font = ele.find('font');
  785. const status = {
  786. font: font,
  787. success() {
  788. var _this$font, _this$font2, _this$font3;
  789. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  790. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  791. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  792. 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);
  793. return this;
  794. },
  795. error() {
  796. var _this$font4, _this$font5, _this$font6;
  797. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  798. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  799. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  800. 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);
  801. return this;
  802. },
  803. warning() {
  804. var _this$font7, _this$font8, _this$font9;
  805. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  806. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  807. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  808. 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);
  809. return this;
  810. },
  811. info() {
  812. var _this$font10, _this$font11, _this$font12;
  813. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  814. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  815. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  816. 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);
  817. return this;
  818. },
  819. view() {
  820. var _this$font13;
  821. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  822. return this;
  823. }
  824. };
  825. return status;
  826. } catch (error) {
  827. throwError(error, 'echoLog');
  828. return emptyStatus;
  829. }
  830. };
  831. const scripts_echoLog = echoLog;
  832. const unique = array => {
  833. try {
  834. return [ ...new Set(array) ];
  835. } catch (error) {
  836. throwError(error, 'unique');
  837. return [];
  838. }
  839. };
  840. const delay = function() {
  841. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  842. return new Promise(resolve => {
  843. setTimeout(() => {
  844. resolve(true);
  845. }, time);
  846. });
  847. };
  848. const getRedirectLink = async link => {
  849. try {
  850. if (!link) {
  851. return null;
  852. }
  853. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  854. if (redirectLinksCache[link]) {
  855. redirectLinksCache[link];
  856. }
  857. return await tools_httpRequest({
  858. url: link,
  859. method: 'GET'
  860. }).then(_ref => {
  861. let {
  862. data
  863. } = _ref;
  864. if (data !== null && data !== void 0 && data.finalUrl) {
  865. redirectLinksCache[link] = data.finalUrl;
  866. GM_setValue('redirectLinks', redirectLinksCache);
  867. return data.finalUrl;
  868. }
  869. return null;
  870. });
  871. } catch (error) {
  872. throwError(error, 'getRedirectLink');
  873. return null;
  874. }
  875. };
  876. const visitLink = async (link, options) => {
  877. try {
  878. const logStatus = scripts_echoLog({
  879. type: 'visitLink',
  880. text: link
  881. });
  882. return await tools_httpRequest({
  883. url: link,
  884. method: 'GET',
  885. ...options
  886. }).then(_ref2 => {
  887. let {
  888. result,
  889. statusText,
  890. status
  891. } = _ref2;
  892. if (result === 'Success') {
  893. logStatus.success();
  894. return true;
  895. }
  896. logStatus.error(`${result}:${statusText}(${status})`);
  897. return false;
  898. });
  899. } catch (error) {
  900. throwError(error, 'visitLink');
  901. return false;
  902. }
  903. };
  904. const getUrlQuery = url => {
  905. try {
  906. const query = {};
  907. if (url) {
  908. if (url.includes('?')) {
  909. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  910. query[key] = value;
  911. return str;
  912. });
  913. }
  914. } else {
  915. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  916. query[key] = value;
  917. return str;
  918. });
  919. }
  920. return query;
  921. } catch (error) {
  922. throwError(error, 'getUrlQuery');
  923. return {};
  924. }
  925. };
  926. const getUuid = () => {
  927. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  928. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  929. };
  930. const stringToColour = str => {
  931. try {
  932. let hash = 0;
  933. for (let i = 0; i < str.length; i++) {
  934. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  935. }
  936. let colour = '#';
  937. for (let i = 0; i < 3; i++) {
  938. const value = hash >> i * 8 & 255;
  939. colour += `00${value.toString(16)}`.slice(-2);
  940. }
  941. return colour;
  942. } catch (error) {
  943. throwError(error, 'stringToColour');
  944. return '#fff';
  945. }
  946. };
  947. const defaultGlobalOptions = {
  948. doTask: {
  949. discord: {
  950. servers: true
  951. },
  952. instagram: {
  953. users: true
  954. },
  955. twitch: {
  956. channels: true
  957. },
  958. twitter: {
  959. users: true,
  960. retweets: true
  961. },
  962. vk: {
  963. names: true
  964. },
  965. youtube: {
  966. channels: true,
  967. likes: true
  968. },
  969. reddit: {
  970. reddits: true
  971. },
  972. steam: {
  973. groups: true,
  974. wishlists: true,
  975. follows: true,
  976. forums: true,
  977. workshops: true,
  978. curators: true,
  979. workshopVotes: true,
  980. announcements: true
  981. }
  982. },
  983. undoTask: {
  984. discord: {
  985. servers: true
  986. },
  987. instagram: {
  988. users: true
  989. },
  990. twitch: {
  991. channels: true
  992. },
  993. twitter: {
  994. users: true,
  995. retweets: true
  996. },
  997. vk: {
  998. names: true
  999. },
  1000. youtube: {
  1001. channels: true,
  1002. likes: true
  1003. },
  1004. reddit: {
  1005. reddits: true
  1006. },
  1007. steam: {
  1008. groups: true,
  1009. wishlists: true,
  1010. follows: true,
  1011. forums: true,
  1012. workshops: true,
  1013. curators: true
  1014. }
  1015. },
  1016. position: {
  1017. buttonSideX: 'right',
  1018. buttonSideY: 'top',
  1019. buttonDistance: '15,30',
  1020. showButtonSideX: 'right',
  1021. showButtonSideY: 'top',
  1022. showButtonDistance: '15,30',
  1023. logSideX: 'right',
  1024. logSideY: 'bottom',
  1025. logDistance: '10,10'
  1026. },
  1027. hotKey: {
  1028. doTaskKey: 'alt + d',
  1029. undoTaskKey: 'alt + u',
  1030. toggleLogKey: 'alt + l'
  1031. },
  1032. other: {
  1033. twitterVerifyId: '783214',
  1034. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1035. autoUpdateSource: 'jsdelivr',
  1036. language: 'zh',
  1037. checkLogin: true,
  1038. checkLeftKey: true,
  1039. defaultShowButton: true,
  1040. defaultShowLog: true
  1041. }
  1042. };
  1043. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1044. const assignObject = (obj1, obj2) => {
  1045. try {
  1046. const newObj = {};
  1047. for (const [ key, value ] of Object.entries(obj1)) {
  1048. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1049. newObj[key] = assignObject(value, obj2[key]);
  1050. } else {
  1051. newObj[key] = obj2[key] ?? value;
  1052. }
  1053. }
  1054. return newObj;
  1055. } catch (error) {
  1056. throwError(error, 'assignObject');
  1057. return defaultGlobalOptions;
  1058. }
  1059. };
  1060. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1061. const saveData = () => {
  1062. try {
  1063. const data = {};
  1064. $('#globalOptionsForm').serializeArray().map(value => {
  1065. data[value.name] = value.value;
  1066. return value;
  1067. });
  1068. $.makeArray($('#globalOptionsForm input')).map(element => {
  1069. const name = $(element).attr('name');
  1070. const keys = name.split('.');
  1071. if (keys.length === 3) {
  1072. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1073. } else if (keys.length === 2) {
  1074. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1075. }
  1076. return element;
  1077. });
  1078. GM_setValue('globalOptions', globalOptions);
  1079. external_Swal_default().fire({
  1080. title: i18n('changeGlobalOptionsSuccess'),
  1081. icon: 'success'
  1082. });
  1083. } catch (error) {
  1084. throwError(error, 'saveData');
  1085. }
  1086. };
  1087. const changeGlobalOptions = showType => {
  1088. try {
  1089. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1090. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1091. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1092. for (const [ option, data2 ] of Object.entries(data1)) {
  1093. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1094. if (typeof data2 === 'boolean') {
  1095. 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>`;
  1096. } else {
  1097. 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>`;
  1098. }
  1099. } else {
  1100. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1101. 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>`;
  1102. }
  1103. }
  1104. }
  1105. }
  1106. globalOptionsForm += '</tbody></table></form>';
  1107. if (showType === 'swal') {
  1108. external_Swal_default().fire({
  1109. title: i18n('globalOptions'),
  1110. html: globalOptionsForm,
  1111. showConfirmButton: true,
  1112. confirmButtonText: i18n('save'),
  1113. showCancelButton: true,
  1114. cancelButtonText: i18n('close')
  1115. }).then(_ref => {
  1116. let {
  1117. isConfirmed
  1118. } = _ref;
  1119. if (isConfirmed) {
  1120. saveData();
  1121. }
  1122. });
  1123. } else {
  1124. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1125. }
  1126. } catch (error) {
  1127. throwError(error, 'changeGlobalOptions');
  1128. }
  1129. };
  1130. const data = {
  1131. website: '网站',
  1132. type: '类型',
  1133. edit: '编辑',
  1134. whiteList: '白名单',
  1135. skipTask: '跳过撤销任务',
  1136. whiteListOptions: '白名单设置',
  1137. changeWhiteListOption: '设置白名单(%0)',
  1138. whiteListNotFound: '找不到此项白名单: %0',
  1139. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1140. changeWebsiteOptions: '网站设置',
  1141. changeGlobalOptions: '全局设置',
  1142. ok: '是',
  1143. save: '保存',
  1144. close: '关闭',
  1145. return: '返回',
  1146. option: '选项',
  1147. value: '值',
  1148. websiteOptions: '当前网站设置',
  1149. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1150. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1151. needLogin: '请先登录!',
  1152. getTasksInfo: '正在获取并处理任务信息...',
  1153. gettingKey: '正在获取Key...',
  1154. verifyingTask: '正在验证任务',
  1155. notice: '自动任务脚本提醒',
  1156. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1157. giveawayEnded: '此活动已结束,是否关闭?',
  1158. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1159. confirm: '确定',
  1160. cancel: '取消',
  1161. unKnown: '未知',
  1162. unKnownTaskType: '未识别的任务',
  1163. doing: '正在做任务',
  1164. allTasksComplete: '所有任务已完成!',
  1165. getTaskIdFailed: '获取任务Id失败!',
  1166. initSuccess: '%0 初始化成功!',
  1167. initFailed: '%0 初始化失败!',
  1168. errorLink: '链接错误: %0',
  1169. needInit: '请先初始化',
  1170. verifyingAuth: '正在验证%0凭证...',
  1171. updatingAuth: '正在更新%0凭证...',
  1172. initing: '正在初始化...',
  1173. getFailed: '获取%0失败!',
  1174. checkLoginFailed: '检测登录状态失败!',
  1175. checkLeftKeyFailed: '检测剩余Key失败!',
  1176. userId: '用户Id',
  1177. joiningGiveaway: '正在加入赠Key',
  1178. needJoinGiveaway: '需要先加入赠Key',
  1179. cannotUndo: '此网站不支持取消任务',
  1180. verifyAuth: '正在验证 %0 凭证...',
  1181. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1182. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1183. visitingLink: '正在访问链接: ',
  1184. doTask: '做任务',
  1185. undoTask: '撤销任务',
  1186. verifyTask: '验证任务',
  1187. getKey: '获取Key',
  1188. selectAll: '全选',
  1189. selectNone: '全不选',
  1190. invertSelect: '反选',
  1191. doFreeTask: '加入免费赠品',
  1192. doPointTask: '加入点数赠品',
  1193. skipTaskOption: '设置中已配置跳过任务',
  1194. other: '其他',
  1195. globalOptions: '全局设置',
  1196. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1197. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1198. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1199. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1200. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1201. saveGlobalOptions: '保存全局设置',
  1202. settingPage: '设置页面',
  1203. name: '名称',
  1204. version: '版本',
  1205. scriptManager: '脚本管理器',
  1206. script: '脚本',
  1207. environment: '环境',
  1208. os: '系统',
  1209. browser: '浏览器',
  1210. getId: '获取 %0 id',
  1211. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1212. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1213. showButton: '显示按钮',
  1214. hideButton: '隐藏按钮',
  1215. showLog: '显示日志',
  1216. hideLog: '隐藏日志',
  1217. defaultShowButton: '默认显示按钮',
  1218. defaultShowLog: '默认显示日志',
  1219. position: '组件位置',
  1220. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1221. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1222. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1223. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1224. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1225. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1226. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1227. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1228. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1229. hotKey: '快捷键',
  1230. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1231. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1232. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1233. tasksHistory: '任务历史',
  1234. clearHistory: '清空历史',
  1235. clearHistoryFinished: '已清空任务历史!',
  1236. deleteTask: '删除任务',
  1237. lastChangeTime: '最后一次修改时间',
  1238. clearTaskFinished: '删除以下任务完成!',
  1239. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1240. syncData: '数据同步',
  1241. settingData: '正在上传数据...',
  1242. gettingData: '正在获取数据...',
  1243. help: '帮助',
  1244. fileName: '文件名',
  1245. upload2gist: '同步到Gist',
  1246. downloadFromGist: '从Gist同步',
  1247. saveAndTest: '保存配置并测试',
  1248. testSuccess: '测试成功!',
  1249. testFailed: '测试失败!',
  1250. saveAndTestNotice: '请先保存配置并测试!',
  1251. processingData: '正在处理数据...',
  1252. updatingData: '正在上传数据...',
  1253. syncDataSuccess: '同步数据成功!',
  1254. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1255. downloadingData: '正在下载数据...',
  1256. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1257. savingData: '正在保存数据...',
  1258. syncHistory: '同步任务历史',
  1259. checkUpdateFailed: '检测更新失败',
  1260. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1261. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1262. gistOptions: 'Gist 设置',
  1263. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1264. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1265. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1266. toGithub: '前往Github反馈',
  1267. toKeylol: '前往其乐论坛反馈',
  1268. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1269. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1270. updateText: '%0 版本更新内容:',
  1271. Active: '进行中',
  1272. Ended: '已结束',
  1273. Banned: '已封禁',
  1274. Paused: '已暂停',
  1275. notStart: '未开始',
  1276. groups: '组',
  1277. wishlists: '愿望单',
  1278. follows: '游戏关注',
  1279. forums: '论坛',
  1280. workshops: '创意工坊收藏',
  1281. curators: '鉴赏家',
  1282. workshopVotes: '创意工坊点赞',
  1283. announcements: '社区通知',
  1284. steamCommunity: 'Steam社区',
  1285. steamStore: 'Steam商店',
  1286. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1287. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1288. joiningSteamGroup: '正在加入Steam组',
  1289. leavingSteamGroup: '正在退出Steam组',
  1290. gettingSteamGroupId: '正在获取Steam组Id',
  1291. subscribingForum: '正在订阅Steam论坛',
  1292. unsubscribingForum: '正在取消订阅Steam论坛',
  1293. gettingForumId: '正在获取Steam论坛Id',
  1294. followingCurator: '正在关注Steam鉴赏家',
  1295. unfollowingCurator: '正在取关Steam鉴赏家',
  1296. addingToWishlist: '正在添加游戏到Steam愿望单',
  1297. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1298. followingGame: '正在关注Steam游戏',
  1299. unfollowingGame: '正在取关Steam游戏',
  1300. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1301. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1302. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1303. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1304. gettingAnnouncementParams: '正在获取Steam通知信息',
  1305. likingAnnouncement: '正在点赞Steam通知',
  1306. changingArea: '正在更换Steam地区: %0...',
  1307. notNeededChangeArea: '当前地区不需要更换',
  1308. noAnotherArea: '请检测是否开启正确开启代理',
  1309. gettingAreaInfo: '正在获取Steam地区信息...',
  1310. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1311. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1312. servers: '服务器',
  1313. joiningDiscordServer: '正在加入Discord服务器',
  1314. leavingDiscordServer: '正在退出Discord服务器',
  1315. gettingDiscordGuild: '正在获取Discord服务器Id',
  1316. users: '用户',
  1317. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1318. insBanned: '您的Instagram账户已被封禁',
  1319. verifyingInsAuth: '正在验证Instagram凭证...',
  1320. gettingInsUserId: '正在获取Instagram用户Id',
  1321. followingIns: '正在关注Instagram用户',
  1322. unfollowingIns: '正在取关Instagram用户',
  1323. reddits: '社区/用户',
  1324. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1325. changingRedditVersion: '正在切换Reddit为新版页面...',
  1326. joiningReddit: '正在加入Reddit社区',
  1327. leavingReddit: '正在退出Reddit社区',
  1328. followingRedditUser: '正在关注Reddit用户',
  1329. unfollowingRedditUser: '正在取关Reddit用户',
  1330. channels: '频道',
  1331. followingTwitchChannel: '正在关注Twitch频道',
  1332. unfollowingTwitchChannel: '正在取关Twitch频道',
  1333. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1334. twitterUser: '推特用户',
  1335. retweets: '转推',
  1336. followingTwitterUser: '正在关注推特用户',
  1337. unfollowingTwitterUser: '正在取关推特用户',
  1338. retweetting: '正在转推',
  1339. unretweetting: '正在撤销转推',
  1340. names: '组/社区/动态',
  1341. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1342. gettingVkId: '正在获取Vk任务Id',
  1343. joiningVkGroup: '正在加入Vk组',
  1344. leavingVkGroup: '正在退出Vk组',
  1345. joiningVkPublic: '正在加入Vk社区',
  1346. leavingVkPublic: '正在退出Vk社区',
  1347. sendingVkWall: '正在转发Vk动态',
  1348. deletingVkWall: '正在撤销转发Vk动态',
  1349. youtubeChannel: 'YouTube频道',
  1350. likes: '点赞',
  1351. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1352. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1353. gettingYtbToken: '正在获取YouTube Token...',
  1354. followingYtbChannel: '正在订阅YouTube频道',
  1355. unfollowingYtbChannel: '正在退订YouTube频道',
  1356. likingYtbVideo: '正在点赞YouTube视频',
  1357. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1358. giveKeyNoticeBefore: '每次验证间隔15s',
  1359. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1360. noPoints: '点数不够,跳过抽奖',
  1361. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1362. joiningLottery: '正在加入抽奖',
  1363. doingGleamTask: '正在做Gleam任务...',
  1364. gettingGleamLink: '正在获取Gleam任务链接...',
  1365. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1366. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1367. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1368. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1369. };
  1370. const zh_CN = data;
  1371. const en_US_data = {
  1372. website: 'Website',
  1373. type: 'Type',
  1374. edit: 'Edit',
  1375. whiteList: 'Whitelist',
  1376. skipTask: 'Skip undo task',
  1377. whiteListOptions: 'Whitelist options',
  1378. changeWhiteListOption: 'Whitelist option(%0)',
  1379. whiteListNotFound: 'Cannot find this whitelist: %0',
  1380. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1381. changeWebsiteOptions: 'Website options',
  1382. changeGlobalOptions: 'Global options',
  1383. ok: 'OK',
  1384. save: 'Save',
  1385. close: 'Close',
  1386. return: 'Return',
  1387. option: 'Option',
  1388. value: 'Value',
  1389. websiteOptions: 'Current website settings',
  1390. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1391. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1392. needLogin: 'Please log in first!',
  1393. getTasksInfo: 'Obtaining and processing task information...',
  1394. gettingKey: 'Getting Key...',
  1395. verifyingTask: 'Verifying task',
  1396. notice: 'Automatic task script notice',
  1397. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1398. giveawayEnded: 'This event has ended, do you want to close it?',
  1399. 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?',
  1400. confirm: 'Confirm',
  1401. cancel: 'Cancel',
  1402. unKnown: 'Unknown',
  1403. unKnownTaskType: 'Unrecognized task',
  1404. doing: 'Doing a task',
  1405. allTasksComplete: 'All tasks have been completed!',
  1406. getTaskIdFailed: 'Failed to obtain task Id!',
  1407. initSuccess: '%0 was initialized successfully!',
  1408. initFailed: '%0 initialization failed!',
  1409. errorLink: 'Link error: %0',
  1410. needInit: 'Please initialize first',
  1411. verifyingAuth: 'Verifying %0 token...',
  1412. updatingAuth: 'Update %0 token...',
  1413. initing: 'Initializing...',
  1414. getFailed: 'Failed to get %0!',
  1415. checkLoginFailed: 'Failed to detect login status!',
  1416. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1417. userId: 'User Id',
  1418. joiningGiveaway: 'Joining giveaway',
  1419. needJoinGiveaway: 'Need to join the giveaway first',
  1420. cannotUndo: 'This website does not support canceling tasks',
  1421. verifyAuth: 'Verifying %0 token...',
  1422. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1423. errorReport: 'A script error is detected, do you want to report the BUG?',
  1424. visitingLink: 'Visiting link: ',
  1425. doTask: 'DoTask',
  1426. undoTask: 'UndoTask',
  1427. verifyTask: 'Verify',
  1428. getKey: 'GetKey',
  1429. selectAll: 'SelectAll',
  1430. selectNone: 'SelectNone',
  1431. invertSelect: 'InvertSelect',
  1432. doFreeTask: 'FreeTask',
  1433. doPointTask: 'PointTask',
  1434. skipTaskOption: 'Skip task has been configured in the settings',
  1435. other: 'Other',
  1436. globalOptions: 'Global Options',
  1437. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1438. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1439. 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.',
  1440. 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.',
  1441. 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.',
  1442. saveGlobalOptions: 'SaveSettings',
  1443. settingPage: 'Setting Page',
  1444. name: 'Name',
  1445. version: 'Version',
  1446. scriptManager: 'Script Manager',
  1447. script: 'Script',
  1448. environment: 'Environment',
  1449. os: 'OS',
  1450. browser: 'Browser',
  1451. getId: 'Get %0 id',
  1452. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1453. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1454. showButton: 'ShowButton',
  1455. hideButton: 'HideButton',
  1456. showLog: 'ShowLog',
  1457. hideLog: 'HideLog',
  1458. defaultShowButton: 'Default display button',
  1459. defaultShowLog: 'Display log by default',
  1460. position: 'Component position',
  1461. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1462. 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',
  1463. 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',
  1464. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1465. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1466. 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',
  1467. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1468. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1469. 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',
  1470. hotKey: 'Shortcut key',
  1471. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1472. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1473. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1474. tasksHistory: 'TasksHistory',
  1475. clearHistory: 'Clear history',
  1476. clearHistoryFinished: 'The mission history has been cleared!',
  1477. deleteTask: 'Delete task',
  1478. lastChangeTime: 'Last Change Time',
  1479. clearTaskFinished: 'Delete the following tasks completed!',
  1480. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1481. syncData: 'Data synchronization',
  1482. settingData: 'Uploading data...',
  1483. gettingData: 'Getting data...',
  1484. help: 'Help',
  1485. fileName: 'Filename',
  1486. upload2gist: 'Sync to Gist',
  1487. downloadFromGist: 'Sync from Gist',
  1488. saveAndTest: 'Save configuration and test',
  1489. testSuccess: 'Test success!',
  1490. testFailed: 'Test failed!',
  1491. saveAndTestNotice: 'Please save the configuration and test first!',
  1492. processingData: 'Processing data...',
  1493. updatingData: 'Uploading data...',
  1494. syncDataSuccess: 'Synchronized data successfully!',
  1495. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1496. downloadingData: 'Downloading data...',
  1497. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1498. savingData: 'Saving data...',
  1499. syncHistory: 'Synchronize tasks history',
  1500. checkUpdateFailed: 'Check update failed',
  1501. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1502. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1503. gistOptions: 'Gist Settings',
  1504. 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!',
  1505. 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!',
  1506. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1507. toGithub: 'Feedback(Github)',
  1508. toKeylol: 'Feedback(Keylol)',
  1509. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1510. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1511. updateText: 'Updates in version %0:',
  1512. Active: 'Active',
  1513. Ended: 'Ended',
  1514. Banned: 'Banned',
  1515. Paused: 'Paused',
  1516. notStart: 'notStart',
  1517. groups: 'Group',
  1518. wishlists: 'Wishlist',
  1519. follows: 'Follow Game',
  1520. forums: 'Forum',
  1521. workshops: 'Favorite Workshop',
  1522. curators: 'Curator',
  1523. workshopVotes: 'Voteup Workshop',
  1524. announcements: 'Announcement',
  1525. steamCommunity: 'Steam Community',
  1526. steamStore: 'Steam Store',
  1527. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1528. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1529. joiningSteamGroup: 'Joining Steam Group',
  1530. leavingSteamGroup: 'Leaving Steam Group',
  1531. gettingSteamGroupId: 'Getting Steam Group Id',
  1532. subscribingForum: 'Subscribing the Steam Forum',
  1533. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1534. gettingForumId: 'Getting Steam Forum Id',
  1535. followingCurator: 'Following Steam Curator',
  1536. unfollowingCurator: 'Unfollowing Steam Curator',
  1537. addingToWishlist: 'Adding the game to the Steam wishlist',
  1538. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1539. followingGame: 'Following Steam games',
  1540. unfollowingGame: 'Unfollowing Steam games',
  1541. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1542. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1543. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1544. votingUpWorkshop: 'Liking Steam workshop items',
  1545. gettingAnnouncementParams: 'Getting Steam announcement information',
  1546. likingAnnouncement: 'Liking Steam announcement',
  1547. changingArea: 'Changing Steam area: %0...',
  1548. notNeededChangeArea: 'The current area does not need to be changed',
  1549. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1550. gettingAreaInfo: 'Getting Steam area information...',
  1551. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1552. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1553. servers: 'Server',
  1554. joiningDiscordServer: 'Joining Discord Server',
  1555. leavingDiscordServer: 'Leaving Discord Server',
  1556. gettingDiscordGuild: 'Getting Discord server Id',
  1557. users: 'User',
  1558. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1559. insBanned: 'Your Instagram account has been banned',
  1560. verifyingInsAuth: 'Verifying Instagram token...',
  1561. gettingInsUserId: 'Getting Instagram user Id',
  1562. followingIns: 'Following Instagram user',
  1563. unfollowingIns: 'Unfollowing Instagram user',
  1564. reddits: 'Reddit/User',
  1565. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1566. changingRedditVersion: 'Switching Reddit to a new version page...',
  1567. joiningReddit: 'Joining the Reddit',
  1568. leavingReddit: 'Leaving the Reddit',
  1569. followingRedditUser: 'Following Reddit User',
  1570. unfollowingRedditUser: 'Unfollowing Reddit User',
  1571. channels: 'Channel',
  1572. followingTwitchChannel: 'Following Twitch Channel',
  1573. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1574. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1575. twitterUser: 'Twitter User',
  1576. retweets: 'Retweet',
  1577. followingTwitterUser: 'Following Twitter User',
  1578. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1579. retweetting: 'Retweetting',
  1580. unretweetting: 'Unretweetting',
  1581. names: 'Group/Public/Wall',
  1582. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1583. gettingVkId: 'Getting Vk task Id',
  1584. joiningVkGroup: 'Joining Vk Group',
  1585. leavingVkGroup: 'Leaving Vk Group',
  1586. joiningVkPublic: 'Joining Vk Public',
  1587. leavingVkPublic: 'Leaving Vk Public',
  1588. sendingVkWall: 'Sending Vk Wall',
  1589. deletingVkWall: 'Deleting Vk Wall',
  1590. youtubeChannel: 'YouTube Channel',
  1591. likes: 'Like',
  1592. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1593. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1594. gettingYtbToken: 'Getting YouTube Token...',
  1595. followingYtbChannel: 'Subscribing to YouTube channel',
  1596. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1597. likingYtbVideo: 'Liking YouTube video',
  1598. unlikingYtbVideo: 'Unliking YouTube video',
  1599. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1600. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1601. noPoints: 'Not enough points, skip the lottery',
  1602. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1603. joiningLottery: 'Joining the lottery',
  1604. doingGleamTask: 'Doing Gleam Task...',
  1605. gettingGleamLink: 'Getting Gleam task link...',
  1606. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1607. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1608. 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!',
  1609. 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...'
  1610. };
  1611. const en_US = en_US_data;
  1612. const languages = {
  1613. zh: zh_CN,
  1614. en: en_US
  1615. };
  1616. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1617. const I18n = function(key) {
  1618. var _languages$language;
  1619. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1620. argvs[_key - 1] = arguments[_key];
  1621. }
  1622. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1623. return key;
  1624. }
  1625. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1626. };
  1627. const i18n = I18n;
  1628. function throwError(error, name) {
  1629. external_Swal_default().fire({
  1630. title: i18n('errorReport'),
  1631. icon: 'error',
  1632. showCancelButton: true,
  1633. confirmButtonText: i18n('toGithub'),
  1634. showDenyButton: true,
  1635. denyButtonText: i18n('toKeylol'),
  1636. cancelButtonText: i18n('close')
  1637. }).then(_ref => {
  1638. let {
  1639. isDenied,
  1640. isConfirmed
  1641. } = _ref;
  1642. if (isConfirmed) {
  1643. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`脚本报错: ${name}`)}&labels=bug&body=${encodeURIComponent(`错误链接: [${window.location.href}](${window.location.href})
  1644.  
  1645. 环境:
  1646. \`\`\`
  1647. ${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}
  1648. \`\`\`
  1649. 脚本管理器: \`${GM_info.scriptHandler} ${GM_info.version}\`
  1650. 脚本版本: \`${GM_info.script.version}\`
  1651.  
  1652. 报错信息:
  1653. \`\`\`
  1654. ${error.stack}
  1655. \`\`\`
  1656.  
  1657. 执行日志:
  1658. \`\`\`
  1659. ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}
  1660. \`\`\`
  1661. `)}`, '_blank');
  1662. } else if (isDenied) {
  1663. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1664.  
  1665. 环境:
  1666.  
  1667. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1668.  
  1669. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1670. 脚本版本: ${GM_info.script.version}
  1671.  
  1672. 报错信息:
  1673. [code]${error.stack}[/code]
  1674.  
  1675. 执行日志:
  1676. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1677. GM_setClipboard(text);
  1678. external_Swal_default().fire({
  1679. title: i18n('copySuccess'),
  1680. icon: 'success',
  1681. confirmButtonText: i18n('ok')
  1682. }).then(() => {
  1683. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1684. });
  1685. }
  1686. });
  1687. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1688. }
  1689. function _defineProperty(obj, key, value) {
  1690. if (key in obj) {
  1691. Object.defineProperty(obj, key, {
  1692. value: value,
  1693. enumerable: true,
  1694. configurable: true,
  1695. writable: true
  1696. });
  1697. } else {
  1698. obj[key] = value;
  1699. }
  1700. return obj;
  1701. }
  1702. class Social {
  1703. constructor() {
  1704. _defineProperty(this, 'tasks', void 0);
  1705. }
  1706. getRealParams(name, links, doTask, link2param) {
  1707. try {
  1708. let realParams = [];
  1709. if (links.length > 0) {
  1710. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1711. }
  1712. if (!doTask && this.tasks[name].length > 0) {
  1713. realParams = [ ...realParams, ...this.tasks[name] ];
  1714. }
  1715. return unique(realParams);
  1716. } catch (error) {
  1717. throwError(error, 'Social.getRealParams');
  1718. return [];
  1719. }
  1720. }
  1721. }
  1722. const social_Social = Social;
  1723. function _classPrivateMethodInitSpec(obj, privateSet) {
  1724. _checkPrivateRedeclaration(obj, privateSet);
  1725. privateSet.add(obj);
  1726. }
  1727. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1728. _checkPrivateRedeclaration(obj, privateMap);
  1729. privateMap.set(obj, value);
  1730. }
  1731. function _checkPrivateRedeclaration(obj, privateCollection) {
  1732. if (privateCollection.has(obj)) {
  1733. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1734. }
  1735. }
  1736. function Discord_defineProperty(obj, key, value) {
  1737. if (key in obj) {
  1738. Object.defineProperty(obj, key, {
  1739. value: value,
  1740. enumerable: true,
  1741. configurable: true,
  1742. writable: true
  1743. });
  1744. } else {
  1745. obj[key] = value;
  1746. }
  1747. return obj;
  1748. }
  1749. function _classPrivateFieldSet(receiver, privateMap, value) {
  1750. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1751. _classApplyDescriptorSet(receiver, descriptor, value);
  1752. return value;
  1753. }
  1754. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1755. if (descriptor.set) {
  1756. descriptor.set.call(receiver, value);
  1757. } else {
  1758. if (!descriptor.writable) {
  1759. throw new TypeError('attempted to set read only private field');
  1760. }
  1761. descriptor.value = value;
  1762. }
  1763. }
  1764. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1765. if (!privateSet.has(receiver)) {
  1766. throw new TypeError('attempted to get private field on non-instance');
  1767. }
  1768. return fn;
  1769. }
  1770. function _classPrivateFieldGet(receiver, privateMap) {
  1771. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1772. return _classApplyDescriptorGet(receiver, descriptor);
  1773. }
  1774. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1775. if (!privateMap.has(receiver)) {
  1776. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1777. }
  1778. return privateMap.get(receiver);
  1779. }
  1780. function _classApplyDescriptorGet(receiver, descriptor) {
  1781. if (descriptor.get) {
  1782. return descriptor.get.call(receiver);
  1783. }
  1784. return descriptor.value;
  1785. }
  1786. const defaultTasks = {
  1787. servers: []
  1788. };
  1789. var _auth = new WeakMap();
  1790. var _cache = new WeakMap();
  1791. var _initialized = new WeakMap();
  1792. var _verifyAuth = new WeakSet();
  1793. var _updateAuth = new WeakSet();
  1794. var _joinServer = new WeakSet();
  1795. var _leaveServer = new WeakSet();
  1796. var _getGuild = new WeakSet();
  1797. var _setCache = new WeakSet();
  1798. class Discord extends social_Social {
  1799. constructor() {
  1800. var _GM_getValue;
  1801. super(...arguments);
  1802. _classPrivateMethodInitSpec(this, _setCache);
  1803. _classPrivateMethodInitSpec(this, _getGuild);
  1804. _classPrivateMethodInitSpec(this, _leaveServer);
  1805. _classPrivateMethodInitSpec(this, _joinServer);
  1806. _classPrivateMethodInitSpec(this, _updateAuth);
  1807. _classPrivateMethodInitSpec(this, _verifyAuth);
  1808. Discord_defineProperty(this, 'tasks', {
  1809. ...defaultTasks
  1810. });
  1811. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || {
  1812. ...defaultTasks
  1813. });
  1814. _classPrivateFieldInitSpec(this, _auth, {
  1815. writable: true,
  1816. value: GM_getValue('discordAuth') || {}
  1817. });
  1818. _classPrivateFieldInitSpec(this, _cache, {
  1819. writable: true,
  1820. value: GM_getValue('discordCache') || {}
  1821. });
  1822. _classPrivateFieldInitSpec(this, _initialized, {
  1823. writable: true,
  1824. value: false
  1825. });
  1826. }
  1827. async init() {
  1828. try {
  1829. if (_classPrivateFieldGet(this, _initialized)) {
  1830. return true;
  1831. }
  1832. if (!_classPrivateFieldGet(this, _auth).auth) {
  1833. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1834. _classPrivateFieldSet(this, _initialized, true);
  1835. return true;
  1836. }
  1837. return false;
  1838. }
  1839. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1840. if (isVerified) {
  1841. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1842. _classPrivateFieldSet(this, _initialized, true);
  1843. return true;
  1844. }
  1845. GM_setValue('discordAuth', {
  1846. auth: null
  1847. });
  1848. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1849. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1850. _classPrivateFieldSet(this, _initialized, true);
  1851. return true;
  1852. }
  1853. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1854. return false;
  1855. } catch (error) {
  1856. throwError(error, 'Discord.init');
  1857. return false;
  1858. }
  1859. }
  1860. async toggle(_ref) {
  1861. let {
  1862. doTask = true,
  1863. serverLinks = []
  1864. } = _ref;
  1865. try {
  1866. if (!_classPrivateFieldGet(this, _initialized)) {
  1867. scripts_echoLog({
  1868. text: i18n('needInit')
  1869. });
  1870. return false;
  1871. }
  1872. const prom = [];
  1873. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1874. scripts_echoLog({
  1875. type: 'globalOptionsSkip',
  1876. text: 'discord.servers'
  1877. });
  1878. } else {
  1879. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1880. var _link$match;
  1881. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1882. });
  1883. if (realServers.length > 0) {
  1884. for (const server of realServers) {
  1885. if (doTask) {
  1886. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1887. } else {
  1888. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1889. }
  1890. await delay(1e3);
  1891. }
  1892. }
  1893. }
  1894. return await Promise.all(prom).then(() => true);
  1895. } catch (error) {
  1896. throwError(error, 'Discord.toggleServers');
  1897. return false;
  1898. }
  1899. }
  1900. }
  1901. async function _verifyAuth2() {
  1902. try {
  1903. const logStatus = scripts_echoLog({
  1904. text: i18n('verifyingAuth', 'Discord')
  1905. });
  1906. const {
  1907. result,
  1908. statusText,
  1909. status,
  1910. data
  1911. } = await tools_httpRequest({
  1912. url: 'https://discord.com/api/v6/users/@me',
  1913. method: 'HEAD',
  1914. headers: {
  1915. authorization: _classPrivateFieldGet(this, _auth).auth
  1916. }
  1917. });
  1918. if (result === 'Success') {
  1919. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1920. logStatus.success();
  1921. return true;
  1922. }
  1923. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1924. return false;
  1925. }
  1926. logStatus.error(`${result}:${statusText}(${status})`);
  1927. return false;
  1928. } catch (error) {
  1929. throwError(error, 'Discord.verifyAuth');
  1930. return false;
  1931. }
  1932. }
  1933. async function _updateAuth2() {
  1934. try {
  1935. const logStatus = scripts_echoLog({
  1936. text: i18n('updatingAuth', 'Discord')
  1937. });
  1938. return await new Promise(resolve => {
  1939. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1940. active: true,
  1941. insert: true,
  1942. setParent: true
  1943. });
  1944. newTab.onclose = async () => {
  1945. var _GM_getValue2;
  1946. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1947. if (auth) {
  1948. _classPrivateFieldSet(this, _auth, {
  1949. auth: auth
  1950. });
  1951. logStatus.success();
  1952. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1953. } else {
  1954. logStatus.error('Error: Update discord auth failed!');
  1955. resolve(false);
  1956. }
  1957. };
  1958. });
  1959. } catch (error) {
  1960. throwError(error, 'Discord.updateAuth');
  1961. return false;
  1962. }
  1963. }
  1964. async function _joinServer2(inviteId) {
  1965. try {
  1966. const logStatus = scripts_echoLog({
  1967. type: 'joiningDiscordServer',
  1968. text: inviteId
  1969. });
  1970. const {
  1971. result,
  1972. statusText,
  1973. status,
  1974. data
  1975. } = await tools_httpRequest({
  1976. url: `https://discord.com/api/v6/invites/${inviteId}`,
  1977. method: 'POST',
  1978. dataType: 'json',
  1979. headers: {
  1980. authorization: _classPrivateFieldGet(this, _auth).auth
  1981. }
  1982. });
  1983. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1984. var _data$response, _data$response$guild;
  1985. logStatus.success();
  1986. 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);
  1987. if (guild) {
  1988. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  1989. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1990. }
  1991. return true;
  1992. }
  1993. logStatus.error(`${result}:${statusText}(${status})`);
  1994. return false;
  1995. } catch (error) {
  1996. throwError(error, 'Discord.joinServer');
  1997. return false;
  1998. }
  1999. }
  2000. async function _leaveServer2(inviteId) {
  2001. try {
  2002. if (this.whiteList.servers.includes(inviteId)) {
  2003. scripts_echoLog({
  2004. type: 'whiteList',
  2005. text: 'Discord.leaveServer',
  2006. id: inviteId
  2007. });
  2008. return true;
  2009. }
  2010. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2011. if (!guild) {
  2012. return false;
  2013. }
  2014. const logStatus = scripts_echoLog({
  2015. type: 'leavingDiscordServer',
  2016. text: guild
  2017. });
  2018. const {
  2019. result,
  2020. statusText,
  2021. status,
  2022. data
  2023. } = await tools_httpRequest({
  2024. url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
  2025. method: 'DELETE',
  2026. headers: {
  2027. authorization: _classPrivateFieldGet(this, _auth).auth
  2028. }
  2029. });
  2030. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2031. logStatus.success();
  2032. return true;
  2033. }
  2034. logStatus.error(`${result}:${statusText}(${status})`);
  2035. return false;
  2036. } catch (error) {
  2037. throwError(error, 'Discord.leaveServer');
  2038. return false;
  2039. }
  2040. }
  2041. async function _getGuild2(inviteId) {
  2042. try {
  2043. const logStatus = scripts_echoLog({
  2044. type: 'gettingDiscordGuild',
  2045. text: inviteId
  2046. });
  2047. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2048. if (guild) {
  2049. logStatus.success();
  2050. return guild;
  2051. }
  2052. const {
  2053. result,
  2054. statusText,
  2055. status,
  2056. data
  2057. } = await tools_httpRequest({
  2058. url: `https://discord.com/invite/${inviteId}`,
  2059. method: 'GET'
  2060. });
  2061. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2062. var _data$responseText$ma;
  2063. 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];
  2064. if (guild) {
  2065. logStatus.success();
  2066. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2067. return guild;
  2068. }
  2069. logStatus.error(`${result}:${statusText}(${status})`);
  2070. return false;
  2071. }
  2072. logStatus.error(`${result}:${statusText}(${status})`);
  2073. return false;
  2074. } catch (error) {
  2075. throwError(error, 'Discord.getGuild');
  2076. return false;
  2077. }
  2078. }
  2079. function _setCache2(inviteId, guild) {
  2080. try {
  2081. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2082. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2083. } catch (error) {
  2084. throwError(error, 'Discord.setCache');
  2085. }
  2086. }
  2087. const social_Discord = Discord;
  2088. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2089. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2090. privateSet.add(obj);
  2091. }
  2092. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2093. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2094. privateMap.set(obj, value);
  2095. }
  2096. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2097. if (privateCollection.has(obj)) {
  2098. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2099. }
  2100. }
  2101. function Instagram_defineProperty(obj, key, value) {
  2102. if (key in obj) {
  2103. Object.defineProperty(obj, key, {
  2104. value: value,
  2105. enumerable: true,
  2106. configurable: true,
  2107. writable: true
  2108. });
  2109. } else {
  2110. obj[key] = value;
  2111. }
  2112. return obj;
  2113. }
  2114. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2115. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2116. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2117. return value;
  2118. }
  2119. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2120. if (descriptor.set) {
  2121. descriptor.set.call(receiver, value);
  2122. } else {
  2123. if (!descriptor.writable) {
  2124. throw new TypeError('attempted to set read only private field');
  2125. }
  2126. descriptor.value = value;
  2127. }
  2128. }
  2129. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2130. if (!privateSet.has(receiver)) {
  2131. throw new TypeError('attempted to get private field on non-instance');
  2132. }
  2133. return fn;
  2134. }
  2135. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2136. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2137. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2138. }
  2139. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2140. if (!privateMap.has(receiver)) {
  2141. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2142. }
  2143. return privateMap.get(receiver);
  2144. }
  2145. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2146. if (descriptor.get) {
  2147. return descriptor.get.call(receiver);
  2148. }
  2149. return descriptor.value;
  2150. }
  2151. const Instagram_defaultTasks = {
  2152. users: []
  2153. };
  2154. var Instagram_cache = new WeakMap();
  2155. var Instagram_auth = new WeakMap();
  2156. var Instagram_initialized = new WeakMap();
  2157. var _getUserInfo = new WeakSet();
  2158. var _followUser = new WeakSet();
  2159. var _unfollowUser = new WeakSet();
  2160. var Instagram_setCache = new WeakSet();
  2161. class Instagram extends social_Social {
  2162. constructor() {
  2163. var _GM_getValue;
  2164. super(...arguments);
  2165. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2166. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2167. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2168. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2169. Instagram_defineProperty(this, 'tasks', {
  2170. ...Instagram_defaultTasks
  2171. });
  2172. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || {
  2173. ...Instagram_defaultTasks
  2174. });
  2175. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2176. writable: true,
  2177. value: GM_getValue('instagramCache') || {}
  2178. });
  2179. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2180. writable: true,
  2181. value: {}
  2182. });
  2183. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2184. writable: true,
  2185. value: false
  2186. });
  2187. }
  2188. async init() {
  2189. try {
  2190. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2191. return true;
  2192. }
  2193. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2194. if (isVerified) {
  2195. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2196. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2197. return true;
  2198. }
  2199. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2200. return false;
  2201. } catch (error) {
  2202. throwError(error, 'Instagram.init');
  2203. return false;
  2204. }
  2205. }
  2206. async toggle(_ref) {
  2207. let {
  2208. doTask = true,
  2209. userLinks = []
  2210. } = _ref;
  2211. try {
  2212. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2213. scripts_echoLog({
  2214. text: i18n('needInit')
  2215. });
  2216. return false;
  2217. }
  2218. const prom = [];
  2219. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2220. scripts_echoLog({
  2221. type: 'globalOptionsSkip',
  2222. text: 'instagram.users'
  2223. });
  2224. } else {
  2225. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2226. var _link$match;
  2227. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2228. });
  2229. if (realUsers.length > 0) {
  2230. for (const username of realUsers) {
  2231. if (doTask) {
  2232. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2233. } else {
  2234. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2235. }
  2236. await delay(1e3);
  2237. }
  2238. }
  2239. }
  2240. return await Promise.all(prom).then(() => true);
  2241. } catch (error) {
  2242. throwError(error, 'Instagram.toggleUsers');
  2243. return false;
  2244. }
  2245. }
  2246. }
  2247. async function _getUserInfo2() {
  2248. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2249. try {
  2250. const logStatus = scripts_echoLog({
  2251. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2252. text: name
  2253. });
  2254. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2255. if (userId && name !== 'instagram') {
  2256. logStatus.success();
  2257. return userId;
  2258. }
  2259. const {
  2260. result,
  2261. statusText,
  2262. status,
  2263. data
  2264. } = await tools_httpRequest({
  2265. url: `https://www.instagram.com/${name}/`,
  2266. method: 'GET'
  2267. });
  2268. if (result === 'Success') {
  2269. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2270. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2271. return false;
  2272. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2273. logStatus.error(`Error:${i18n('insBanned')}`);
  2274. return false;
  2275. }
  2276. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2277. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2278. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2279. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2280. if (name === 'instagram') {
  2281. if (csrftoken && hash) {
  2282. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2283. csrftoken: csrftoken,
  2284. hash: hash
  2285. });
  2286. return true;
  2287. }
  2288. return false;
  2289. }
  2290. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2291. if (id) {
  2292. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2293. logStatus.success();
  2294. return id;
  2295. }
  2296. logStatus.error('Error: Get ins data error!');
  2297. return false;
  2298. }
  2299. logStatus.error(`${result}:${statusText}(${status})`);
  2300. return false;
  2301. }
  2302. return false;
  2303. } catch (error) {
  2304. throwError(error, 'Instagram.getUserInfo');
  2305. return false;
  2306. }
  2307. }
  2308. async function _followUser2(name) {
  2309. try {
  2310. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2311. if (!id) {
  2312. return false;
  2313. }
  2314. const logStatus = scripts_echoLog({
  2315. type: 'followingIns',
  2316. text: name
  2317. });
  2318. const {
  2319. result,
  2320. statusText,
  2321. status,
  2322. data
  2323. } = await tools_httpRequest({
  2324. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2325. method: 'POST',
  2326. dataType: 'json',
  2327. headers: {
  2328. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2329. origin: 'https://www.instagram.com',
  2330. referer: `https://www.instagram.com/${name}/`,
  2331. 'content-type': 'application/x-www-form-urlencoded',
  2332. 'sec-fetch-site': 'same-origin',
  2333. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2334. }
  2335. });
  2336. if (result === 'Success') {
  2337. var _data$response, _data$response2;
  2338. 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') {
  2339. logStatus.success();
  2340. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2341. return true;
  2342. }
  2343. 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})`}`);
  2344. return false;
  2345. }
  2346. logStatus.error(`${result}:${statusText}(${status})`);
  2347. return false;
  2348. } catch (error) {
  2349. throwError(error, 'Instagram.followUser');
  2350. return false;
  2351. }
  2352. }
  2353. async function _unfollowUser2(name) {
  2354. try {
  2355. if (this.whiteList.users.includes(name)) {
  2356. scripts_echoLog({
  2357. type: 'whiteList',
  2358. text: 'Instagram.unfollowUser',
  2359. id: name
  2360. });
  2361. return true;
  2362. }
  2363. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2364. if (!id) {
  2365. return false;
  2366. }
  2367. const logStatus = scripts_echoLog({
  2368. type: 'unfollowingIns',
  2369. text: name
  2370. });
  2371. const {
  2372. result,
  2373. statusText,
  2374. status,
  2375. data
  2376. } = await tools_httpRequest({
  2377. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2378. method: 'POST',
  2379. dataType: 'json',
  2380. headers: {
  2381. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2382. origin: 'https://www.instagram.com',
  2383. referer: `https://www.instagram.com/${name}/`,
  2384. 'content-type': 'application/x-www-form-urlencoded',
  2385. 'sec-fetch-site': 'same-origin',
  2386. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2387. }
  2388. });
  2389. if (result === 'Success') {
  2390. var _data$response3;
  2391. 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') {
  2392. logStatus.success();
  2393. return true;
  2394. }
  2395. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2396. return false;
  2397. }
  2398. logStatus.error(`${result}:${statusText}(${status})`);
  2399. return false;
  2400. } catch (error) {
  2401. throwError(error, 'Instagram.unfollowUser');
  2402. return false;
  2403. }
  2404. }
  2405. function Instagram_setCache2(name, id) {
  2406. try {
  2407. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2408. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2409. } catch (error) {
  2410. throwError(error, 'Instagram.setCache');
  2411. }
  2412. }
  2413. const social_Instagram = Instagram;
  2414. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2415. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2416. privateSet.add(obj);
  2417. }
  2418. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2419. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2420. privateMap.set(obj, value);
  2421. }
  2422. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2423. if (privateCollection.has(obj)) {
  2424. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2425. }
  2426. }
  2427. function Reddit_defineProperty(obj, key, value) {
  2428. if (key in obj) {
  2429. Object.defineProperty(obj, key, {
  2430. value: value,
  2431. enumerable: true,
  2432. configurable: true,
  2433. writable: true
  2434. });
  2435. } else {
  2436. obj[key] = value;
  2437. }
  2438. return obj;
  2439. }
  2440. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2441. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2442. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2443. return value;
  2444. }
  2445. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2446. if (descriptor.set) {
  2447. descriptor.set.call(receiver, value);
  2448. } else {
  2449. if (!descriptor.writable) {
  2450. throw new TypeError('attempted to set read only private field');
  2451. }
  2452. descriptor.value = value;
  2453. }
  2454. }
  2455. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2456. if (!privateSet.has(receiver)) {
  2457. throw new TypeError('attempted to get private field on non-instance');
  2458. }
  2459. return fn;
  2460. }
  2461. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2462. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2463. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2464. }
  2465. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2466. if (!privateMap.has(receiver)) {
  2467. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2468. }
  2469. return privateMap.get(receiver);
  2470. }
  2471. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2472. if (descriptor.get) {
  2473. return descriptor.get.call(receiver);
  2474. }
  2475. return descriptor.value;
  2476. }
  2477. const Reddit_defaultTasks = {
  2478. reddits: []
  2479. };
  2480. var Reddit_auth = new WeakMap();
  2481. var Reddit_initialized = new WeakMap();
  2482. var _useBeta = new WeakSet();
  2483. var Reddit_updateAuth = new WeakSet();
  2484. class Reddit extends social_Social {
  2485. constructor() {
  2486. var _GM_getValue;
  2487. super(...arguments);
  2488. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2489. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2490. Reddit_defineProperty(this, 'tasks', {
  2491. ...Reddit_defaultTasks
  2492. });
  2493. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || {
  2494. ...Reddit_defaultTasks
  2495. });
  2496. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2497. writable: true,
  2498. value: void 0
  2499. });
  2500. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2501. writable: true,
  2502. value: false
  2503. });
  2504. }
  2505. async init() {
  2506. try {
  2507. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2508. return true;
  2509. }
  2510. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2511. if (isVerified) {
  2512. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2513. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2514. return true;
  2515. }
  2516. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2517. return false;
  2518. } catch (error) {
  2519. throwError(error, 'Reddit.init');
  2520. return false;
  2521. }
  2522. }
  2523. async toggleTask(_ref) {
  2524. let {
  2525. name,
  2526. doTask = true
  2527. } = _ref;
  2528. try {
  2529. if (!doTask && this.whiteList.reddits.includes(name)) {
  2530. scripts_echoLog({
  2531. type: 'whiteList',
  2532. text: 'Reddit.undoTask',
  2533. id: name
  2534. });
  2535. return true;
  2536. }
  2537. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2538. if (/^u_/.test(name)) {
  2539. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2540. }
  2541. const logStatus = scripts_echoLog({
  2542. type: type,
  2543. text: name
  2544. });
  2545. const {
  2546. result,
  2547. statusText,
  2548. status,
  2549. data
  2550. } = await tools_httpRequest({
  2551. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2552. method: 'POST',
  2553. headers: {
  2554. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2555. 'content-type': 'application/x-www-form-urlencoded'
  2556. },
  2557. data: $.param({
  2558. action: doTask ? 'sub' : 'unsub',
  2559. sr_name: name,
  2560. api_type: 'json'
  2561. })
  2562. });
  2563. if (result === 'Success') {
  2564. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2565. logStatus.success();
  2566. if (doTask) {
  2567. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2568. }
  2569. return true;
  2570. }
  2571. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2572. return false;
  2573. }
  2574. logStatus.error(`${result}:${statusText}(${status})`);
  2575. return false;
  2576. } catch (error) {
  2577. throwError(error, 'Reddit.toggleTask');
  2578. return false;
  2579. }
  2580. }
  2581. async toggle(_ref2) {
  2582. let {
  2583. doTask = true,
  2584. redditLinks = []
  2585. } = _ref2;
  2586. try {
  2587. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2588. scripts_echoLog({
  2589. text: i18n('needInit')
  2590. });
  2591. return false;
  2592. }
  2593. const prom = [];
  2594. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2595. scripts_echoLog({
  2596. type: 'globalOptionsSkip',
  2597. text: 'reddit.reddits'
  2598. });
  2599. } else {
  2600. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2601. var _link$match, _link$match2;
  2602. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2603. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2604. if (userName) {
  2605. return name || userName;
  2606. }
  2607. return name;
  2608. });
  2609. if (realReddits.length > 0) {
  2610. for (const name of realReddits) {
  2611. prom.push(this.toggleTask({
  2612. name: name,
  2613. doTask: doTask
  2614. }));
  2615. await delay(1e3);
  2616. }
  2617. }
  2618. }
  2619. return await Promise.all(prom).then(() => true);
  2620. } catch (error) {
  2621. throwError(error, 'Reddit.toggle');
  2622. return false;
  2623. }
  2624. }
  2625. }
  2626. async function _useBeta2() {
  2627. try {
  2628. const logStatus = scripts_echoLog({
  2629. text: i18n('changingRedditVersion')
  2630. });
  2631. GM_setValue('redditAuth', null);
  2632. return await new Promise(resolve => {
  2633. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2634. active: true,
  2635. insert: true,
  2636. setParent: true
  2637. });
  2638. newTab.onclose = async () => {
  2639. logStatus.success();
  2640. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2641. };
  2642. });
  2643. } catch (error) {
  2644. throwError(error, 'Reddit.useBeta');
  2645. return false;
  2646. }
  2647. }
  2648. async function Reddit_updateAuth2() {
  2649. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2650. try {
  2651. const logStatus = scripts_echoLog({
  2652. text: i18n('updatingAuth', 'Reddit')
  2653. });
  2654. const {
  2655. result,
  2656. statusText,
  2657. status,
  2658. data
  2659. } = await tools_httpRequest({
  2660. url: 'https://www.reddit.com/',
  2661. method: 'GET',
  2662. nochche: true,
  2663. headers: {
  2664. 'Cache-Control': 'no-cache'
  2665. }
  2666. });
  2667. if (result === 'Success') {
  2668. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2669. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2670. return false;
  2671. }
  2672. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2673. var _data$responseText$ma;
  2674. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2675. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2676. }
  2677. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2678. if (accessToken) {
  2679. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2680. token: accessToken
  2681. });
  2682. logStatus.success();
  2683. return true;
  2684. }
  2685. logStatus.error('Error: Parameter "accessToken" not found!');
  2686. return false;
  2687. }
  2688. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2689. return false;
  2690. }
  2691. logStatus.error(`${result}:${statusText}(${status})`);
  2692. return false;
  2693. } catch (error) {
  2694. throwError(error, 'Reddit.updateAuth');
  2695. return false;
  2696. }
  2697. }
  2698. const social_Reddit = Reddit;
  2699. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2700. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2701. privateSet.add(obj);
  2702. }
  2703. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2704. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2705. privateMap.set(obj, value);
  2706. }
  2707. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2708. if (privateCollection.has(obj)) {
  2709. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2710. }
  2711. }
  2712. function Twitch_defineProperty(obj, key, value) {
  2713. if (key in obj) {
  2714. Object.defineProperty(obj, key, {
  2715. value: value,
  2716. enumerable: true,
  2717. configurable: true,
  2718. writable: true
  2719. });
  2720. } else {
  2721. obj[key] = value;
  2722. }
  2723. return obj;
  2724. }
  2725. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2726. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2727. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2728. return value;
  2729. }
  2730. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2731. if (descriptor.set) {
  2732. descriptor.set.call(receiver, value);
  2733. } else {
  2734. if (!descriptor.writable) {
  2735. throw new TypeError('attempted to set read only private field');
  2736. }
  2737. descriptor.value = value;
  2738. }
  2739. }
  2740. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2741. if (!privateSet.has(receiver)) {
  2742. throw new TypeError('attempted to get private field on non-instance');
  2743. }
  2744. return fn;
  2745. }
  2746. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2747. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2748. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2749. }
  2750. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2751. if (!privateMap.has(receiver)) {
  2752. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2753. }
  2754. return privateMap.get(receiver);
  2755. }
  2756. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2757. if (descriptor.get) {
  2758. return descriptor.get.call(receiver);
  2759. }
  2760. return descriptor.value;
  2761. }
  2762. const Twitch_defaultTasks = {
  2763. channels: []
  2764. };
  2765. var Twitch_auth = new WeakMap();
  2766. var Twitch_cache = new WeakMap();
  2767. var Twitch_initialized = new WeakMap();
  2768. var Twitch_verifyAuth = new WeakSet();
  2769. var Twitch_updateAuth = new WeakSet();
  2770. var _toggleChannel = new WeakSet();
  2771. var _getChannelId = new WeakSet();
  2772. var Twitch_setCache = new WeakSet();
  2773. class Twitch extends social_Social {
  2774. constructor() {
  2775. var _GM_getValue;
  2776. super(...arguments);
  2777. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2778. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2779. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2780. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2781. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2782. Twitch_defineProperty(this, 'tasks', {
  2783. ...Twitch_defaultTasks
  2784. });
  2785. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || {
  2786. ...Twitch_defaultTasks
  2787. });
  2788. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2789. writable: true,
  2790. value: GM_getValue('twitchAuth') || {}
  2791. });
  2792. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2793. writable: true,
  2794. value: GM_getValue('twitchCache') || {}
  2795. });
  2796. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2797. writable: true,
  2798. value: false
  2799. });
  2800. }
  2801. async init() {
  2802. try {
  2803. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2804. return true;
  2805. }
  2806. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2807. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2808. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2809. return true;
  2810. }
  2811. return false;
  2812. }
  2813. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2814. if (isVerified) {
  2815. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2816. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2817. return true;
  2818. }
  2819. GM_setValue('twitchAuth', null);
  2820. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2821. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2822. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2823. return true;
  2824. }
  2825. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2826. return false;
  2827. } catch (error) {
  2828. throwError(error, 'Twitch.init');
  2829. return false;
  2830. }
  2831. }
  2832. async toggle(_ref) {
  2833. let {
  2834. doTask = true,
  2835. channelLinks = []
  2836. } = _ref;
  2837. try {
  2838. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2839. scripts_echoLog({
  2840. text: i18n('needInit')
  2841. });
  2842. return false;
  2843. }
  2844. const prom = [];
  2845. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2846. scripts_echoLog({
  2847. type: 'globalOptionsSkip',
  2848. text: 'twitch.channels'
  2849. });
  2850. } else {
  2851. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2852. var _link$match;
  2853. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2854. });
  2855. if (realChannels.length > 0) {
  2856. for (const channel of realChannels) {
  2857. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2858. name: channel,
  2859. doTask: doTask
  2860. }));
  2861. await delay(1e3);
  2862. }
  2863. }
  2864. }
  2865. return Promise.all(prom).then(() => true);
  2866. } catch (error) {
  2867. throwError(error, 'Twitch.toggle');
  2868. return false;
  2869. }
  2870. }
  2871. }
  2872. async function Twitch_verifyAuth2() {
  2873. try {
  2874. const logStatus = scripts_echoLog({
  2875. text: i18n('verifyingAuth', 'Twitch')
  2876. });
  2877. const {
  2878. result,
  2879. statusText,
  2880. status,
  2881. data
  2882. } = await tools_httpRequest({
  2883. url: 'https://gql.twitch.tv/gql',
  2884. method: 'POST',
  2885. dataType: 'json',
  2886. headers: {
  2887. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2888. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2889. },
  2890. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2891. });
  2892. if (result === 'Success') {
  2893. var _data$response, _data$response$, _data$response$$data;
  2894. 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) {
  2895. logStatus.success();
  2896. return true;
  2897. }
  2898. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2899. return false;
  2900. }
  2901. logStatus.error(`${result}:${statusText}(${status})`);
  2902. return false;
  2903. } catch (error) {
  2904. throwError(error, 'Twitch.verifyAuth');
  2905. return false;
  2906. }
  2907. }
  2908. async function Twitch_updateAuth2() {
  2909. try {
  2910. const logStatus = scripts_echoLog({
  2911. text: i18n('updatingAuth', 'Twitch')
  2912. });
  2913. return await new Promise(resolve => {
  2914. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2915. active: true,
  2916. insert: true,
  2917. setParent: true
  2918. });
  2919. newTab.onclose = async () => {
  2920. const auth = GM_getValue('twitchAuth');
  2921. if (auth) {
  2922. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2923. logStatus.success();
  2924. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2925. } else {
  2926. logStatus.error('Error: Update twitch auth failed!');
  2927. resolve(false);
  2928. }
  2929. };
  2930. });
  2931. } catch (error) {
  2932. throwError(error, 'Twitch.updateAuth');
  2933. return false;
  2934. }
  2935. }
  2936. async function _toggleChannel2(_ref2) {
  2937. let {
  2938. name,
  2939. doTask = true
  2940. } = _ref2;
  2941. try {
  2942. if (!doTask && this.whiteList.channels.includes(name)) {
  2943. scripts_echoLog({
  2944. type: 'whiteList',
  2945. text: 'Twitch.unfollowChannel',
  2946. id: name
  2947. });
  2948. return true;
  2949. }
  2950. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2951. if (!channelId) {
  2952. return false;
  2953. }
  2954. const logStatus = scripts_echoLog({
  2955. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2956. text: name
  2957. });
  2958. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2959. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2960. const {
  2961. result,
  2962. statusText,
  2963. status,
  2964. data
  2965. } = await tools_httpRequest({
  2966. url: 'https://gql.twitch.tv/gql',
  2967. method: 'POST',
  2968. dataType: 'json',
  2969. headers: {
  2970. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2971. },
  2972. data: doTask ? followData : unfollowData
  2973. });
  2974. if (result === 'Success') {
  2975. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2976. logStatus.success();
  2977. if (doTask) {
  2978. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2979. }
  2980. return true;
  2981. }
  2982. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2983. return false;
  2984. }
  2985. logStatus.error(`${result}:${statusText}(${status})`);
  2986. return false;
  2987. } catch (error) {
  2988. throwError(error, 'Twitch.toggleChannel');
  2989. return false;
  2990. }
  2991. }
  2992. async function _getChannelId2(name) {
  2993. try {
  2994. const logStatus = scripts_echoLog({
  2995. type: 'gettingTwitchChannelId',
  2996. text: name
  2997. });
  2998. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  2999. if (channelId) {
  3000. logStatus.success();
  3001. return channelId;
  3002. }
  3003. const {
  3004. result,
  3005. statusText,
  3006. status,
  3007. data
  3008. } = await tools_httpRequest({
  3009. url: 'https://gql.twitch.tv/gql',
  3010. method: 'POST',
  3011. headers: {
  3012. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3013. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3014. },
  3015. responseType: 'json',
  3016. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3017. });
  3018. if (result === 'Success') {
  3019. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3020. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3021. 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);
  3022. if (channelId) {
  3023. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3024. logStatus.success();
  3025. return channelId;
  3026. }
  3027. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3028. return false;
  3029. }
  3030. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3031. return false;
  3032. }
  3033. logStatus.error(`${result}:${statusText}(${status})`);
  3034. return false;
  3035. } catch (error) {
  3036. throwError(error, 'Twitch.getChannelId');
  3037. return false;
  3038. }
  3039. }
  3040. function Twitch_setCache2(name, id) {
  3041. try {
  3042. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3043. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3044. } catch (error) {
  3045. throwError(error, 'Twitch.setCache');
  3046. }
  3047. }
  3048. const social_Twitch = Twitch;
  3049. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3050. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3051. privateSet.add(obj);
  3052. }
  3053. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3054. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3055. privateMap.set(obj, value);
  3056. }
  3057. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3058. if (privateCollection.has(obj)) {
  3059. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3060. }
  3061. }
  3062. function Twitter_defineProperty(obj, key, value) {
  3063. if (key in obj) {
  3064. Object.defineProperty(obj, key, {
  3065. value: value,
  3066. enumerable: true,
  3067. configurable: true,
  3068. writable: true
  3069. });
  3070. } else {
  3071. obj[key] = value;
  3072. }
  3073. return obj;
  3074. }
  3075. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3076. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3077. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3078. return value;
  3079. }
  3080. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3081. if (descriptor.set) {
  3082. descriptor.set.call(receiver, value);
  3083. } else {
  3084. if (!descriptor.writable) {
  3085. throw new TypeError('attempted to set read only private field');
  3086. }
  3087. descriptor.value = value;
  3088. }
  3089. }
  3090. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3091. if (!privateSet.has(receiver)) {
  3092. throw new TypeError('attempted to get private field on non-instance');
  3093. }
  3094. return fn;
  3095. }
  3096. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3097. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3098. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3099. }
  3100. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3101. if (!privateMap.has(receiver)) {
  3102. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3103. }
  3104. return privateMap.get(receiver);
  3105. }
  3106. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3107. if (descriptor.get) {
  3108. return descriptor.get.call(receiver);
  3109. }
  3110. return descriptor.value;
  3111. }
  3112. const Twitter_defaultTasks = {
  3113. users: [],
  3114. retweets: [],
  3115. likes: []
  3116. };
  3117. var _verifyId = new WeakMap();
  3118. var Twitter_auth = new WeakMap();
  3119. var Twitter_cache = new WeakMap();
  3120. var Twitter_initialized = new WeakMap();
  3121. var Twitter_verifyAuth = new WeakSet();
  3122. var Twitter_updateAuth = new WeakSet();
  3123. var _toggleUser = new WeakSet();
  3124. var _toggleRetweet = new WeakSet();
  3125. var Twitter_setCache = new WeakSet();
  3126. class Twitter extends social_Social {
  3127. constructor() {
  3128. var _GM_getValue;
  3129. super(...arguments);
  3130. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3131. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3132. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3133. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3134. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3135. Twitter_defineProperty(this, 'tasks', {
  3136. ...Twitter_defaultTasks
  3137. });
  3138. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || {
  3139. ...Twitter_defaultTasks
  3140. });
  3141. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3142. writable: true,
  3143. value: globalOptions.other.twitterVerifyId
  3144. });
  3145. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3146. writable: true,
  3147. value: GM_getValue('twitterAuth') || {}
  3148. });
  3149. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3150. writable: true,
  3151. value: GM_getValue('twitterCache') || {}
  3152. });
  3153. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3154. writable: true,
  3155. value: false
  3156. });
  3157. }
  3158. async init() {
  3159. try {
  3160. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3161. return true;
  3162. }
  3163. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3164. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3165. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3166. return true;
  3167. }
  3168. return false;
  3169. }
  3170. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3171. if (isVerified) {
  3172. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3173. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3174. return true;
  3175. }
  3176. GM_setValue('twitterAuth', null);
  3177. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3178. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3179. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3180. return true;
  3181. }
  3182. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3183. return false;
  3184. } catch (error) {
  3185. throwError(error, 'Twitter.init');
  3186. return false;
  3187. }
  3188. }
  3189. async userName2id(name) {
  3190. try {
  3191. const logStatus = scripts_echoLog({
  3192. type: 'gettingTwitterUserId',
  3193. text: name
  3194. });
  3195. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3196. if (userId) {
  3197. logStatus.success();
  3198. return userId;
  3199. }
  3200. const {
  3201. result,
  3202. statusText,
  3203. status,
  3204. data
  3205. } = await tools_httpRequest({
  3206. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3207. method: 'GET',
  3208. headers: {
  3209. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3210. 'content-type': 'application/json'
  3211. },
  3212. responseType: 'json',
  3213. anonymous: true
  3214. });
  3215. if (result === 'Success') {
  3216. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3217. var _response, _response$data, _response$data$user;
  3218. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3219. if (!response) {
  3220. try {
  3221. response = JSON.parse(data.responseText);
  3222. } catch (error) {
  3223. response = null;
  3224. }
  3225. }
  3226. 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);
  3227. if (userId) {
  3228. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3229. logStatus.success();
  3230. return userId;
  3231. }
  3232. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3233. return false;
  3234. }
  3235. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3236. return false;
  3237. }
  3238. logStatus.error(`${result}:${statusText}(${status})`);
  3239. return false;
  3240. } catch (error) {
  3241. throwError(error, 'Twitter.getUserId');
  3242. return false;
  3243. }
  3244. }
  3245. async toggle(_ref) {
  3246. let {
  3247. doTask = true,
  3248. userLinks = [],
  3249. retweetLinks = []
  3250. } = _ref;
  3251. try {
  3252. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3253. scripts_echoLog({
  3254. text: i18n('needInit')
  3255. });
  3256. return false;
  3257. }
  3258. const prom = [];
  3259. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3260. scripts_echoLog({
  3261. type: 'globalOptionsSkip',
  3262. text: 'twitter.users'
  3263. });
  3264. } else {
  3265. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3266. var _link$match;
  3267. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3268. });
  3269. if (realUsers.length > 0) {
  3270. for (const user of realUsers) {
  3271. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3272. name: user,
  3273. doTask: doTask
  3274. }));
  3275. await delay(1e3);
  3276. }
  3277. }
  3278. }
  3279. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3280. scripts_echoLog({
  3281. type: 'globalOptionsSkip',
  3282. text: 'twitter.retweets'
  3283. });
  3284. } else {
  3285. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3286. var _link$match2;
  3287. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3288. });
  3289. if (realRetweets.length > 0) {
  3290. for (const retweet of realRetweets) {
  3291. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3292. retweetId: retweet,
  3293. doTask: doTask
  3294. }));
  3295. await delay(1e3);
  3296. }
  3297. }
  3298. }
  3299. return Promise.all(prom).then(() => true);
  3300. } catch (error) {
  3301. throwError(error, 'Twitter.toggle');
  3302. return false;
  3303. }
  3304. }
  3305. }
  3306. async function Twitter_verifyAuth2() {
  3307. try {
  3308. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3309. name: 'verify',
  3310. doTask: true,
  3311. verify: true
  3312. });
  3313. } catch (error) {
  3314. throwError(error, 'Twitter.verifyAuth');
  3315. return false;
  3316. }
  3317. }
  3318. async function Twitter_updateAuth2() {
  3319. try {
  3320. const logStatus = scripts_echoLog({
  3321. text: i18n('updatingAuth', 'Twitter')
  3322. });
  3323. return await new Promise(resolve => {
  3324. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3325. active: true,
  3326. insert: true,
  3327. setParent: true
  3328. });
  3329. newTab.onclose = async () => {
  3330. const auth = GM_getValue('twitterAuth');
  3331. if (auth) {
  3332. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3333. logStatus.success();
  3334. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3335. } else {
  3336. logStatus.error('Error: Update twitter auth failed!');
  3337. resolve(false);
  3338. }
  3339. };
  3340. });
  3341. } catch (error) {
  3342. throwError(error, 'Twitter.updateToken');
  3343. return false;
  3344. }
  3345. }
  3346. async function _toggleUser2(_ref2) {
  3347. let {
  3348. name,
  3349. doTask = true,
  3350. verify = false
  3351. } = _ref2;
  3352. try {
  3353. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3354. scripts_echoLog({
  3355. type: 'whiteList',
  3356. text: 'Twitter.unfollowUser',
  3357. id: name
  3358. });
  3359. return true;
  3360. }
  3361. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3362. if (!userId) {
  3363. return false;
  3364. }
  3365. const logStatus = verify ? scripts_echoLog({
  3366. text: i18n('verifyingAuth', 'Twitter')
  3367. }) : scripts_echoLog({
  3368. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3369. text: name
  3370. });
  3371. const {
  3372. result,
  3373. statusText,
  3374. status,
  3375. data
  3376. } = await tools_httpRequest({
  3377. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3378. method: 'POST',
  3379. headers: {
  3380. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3381. 'Content-Type': 'application/x-www-form-urlencoded',
  3382. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3383. },
  3384. responseType: 'json',
  3385. data: $.param({
  3386. include_profile_interstitial_type: 1,
  3387. include_blocking: 1,
  3388. include_blocked_by: 1,
  3389. include_followed_by: 1,
  3390. include_want_retweets: 1,
  3391. include_mute_edge: 1,
  3392. include_can_dm: 1,
  3393. include_can_media_tag: 1,
  3394. skip_status: 1,
  3395. id: userId
  3396. })
  3397. });
  3398. if (result === 'Success') {
  3399. var _data$response, _data$response$errors, _data$response$errors2;
  3400. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3401. logStatus.success();
  3402. if (doTask && !verify) {
  3403. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3404. }
  3405. return true;
  3406. }
  3407. 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) {
  3408. logStatus.success();
  3409. return true;
  3410. }
  3411. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3412. return false;
  3413. }
  3414. logStatus.error(`${result}:${statusText}(${status})`);
  3415. return false;
  3416. } catch (error) {
  3417. throwError(error, 'Twitter.toggleUser');
  3418. return false;
  3419. }
  3420. }
  3421. async function _toggleRetweet2(_ref3) {
  3422. let {
  3423. retweetId,
  3424. doTask = true
  3425. } = _ref3;
  3426. try {
  3427. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3428. scripts_echoLog({
  3429. type: 'whiteList',
  3430. text: 'Twitter.unretweet',
  3431. id: retweetId
  3432. });
  3433. return true;
  3434. }
  3435. const logStatus = scripts_echoLog({
  3436. type: `${doTask ? '' : 'un'}retweetting`,
  3437. text: retweetId
  3438. });
  3439. const {
  3440. result,
  3441. statusText,
  3442. status,
  3443. data
  3444. } = await tools_httpRequest({
  3445. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3446. method: 'POST',
  3447. headers: {
  3448. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3449. 'Content-Type': 'application/x-www-form-urlencoded',
  3450. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3451. },
  3452. data: $.param({
  3453. tweet_mode: 'extended',
  3454. id: retweetId
  3455. }),
  3456. responseType: 'json'
  3457. });
  3458. if (result === 'Success') {
  3459. var _data$response2, _data$response2$error, _data$response2$error2;
  3460. 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) {
  3461. logStatus.success();
  3462. if (doTask) {
  3463. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3464. }
  3465. return true;
  3466. }
  3467. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3468. return false;
  3469. }
  3470. logStatus.error(`${result}:${statusText}(${status})`);
  3471. return false;
  3472. } catch (error) {
  3473. throwError(error, 'Twitter.toggleRetweet');
  3474. return false;
  3475. }
  3476. }
  3477. function Twitter_setCache2(name, id) {
  3478. try {
  3479. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3480. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3481. } catch (error) {
  3482. throwError(error, 'Twitter.setCache');
  3483. }
  3484. }
  3485. const social_Twitter = Twitter;
  3486. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3487. Vk_checkPrivateRedeclaration(obj, privateSet);
  3488. privateSet.add(obj);
  3489. }
  3490. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3491. Vk_checkPrivateRedeclaration(obj, privateMap);
  3492. privateMap.set(obj, value);
  3493. }
  3494. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3495. if (privateCollection.has(obj)) {
  3496. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3497. }
  3498. }
  3499. function Vk_defineProperty(obj, key, value) {
  3500. if (key in obj) {
  3501. Object.defineProperty(obj, key, {
  3502. value: value,
  3503. enumerable: true,
  3504. configurable: true,
  3505. writable: true
  3506. });
  3507. } else {
  3508. obj[key] = value;
  3509. }
  3510. return obj;
  3511. }
  3512. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3513. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3514. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3515. return value;
  3516. }
  3517. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3518. if (descriptor.set) {
  3519. descriptor.set.call(receiver, value);
  3520. } else {
  3521. if (!descriptor.writable) {
  3522. throw new TypeError('attempted to set read only private field');
  3523. }
  3524. descriptor.value = value;
  3525. }
  3526. }
  3527. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3528. if (!privateSet.has(receiver)) {
  3529. throw new TypeError('attempted to get private field on non-instance');
  3530. }
  3531. return fn;
  3532. }
  3533. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3534. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3535. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3536. }
  3537. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3538. if (!privateMap.has(receiver)) {
  3539. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3540. }
  3541. return privateMap.get(receiver);
  3542. }
  3543. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3544. if (descriptor.get) {
  3545. return descriptor.get.call(receiver);
  3546. }
  3547. return descriptor.value;
  3548. }
  3549. const Vk_defaultTasks = {
  3550. names: []
  3551. };
  3552. var _username = new WeakMap();
  3553. var Vk_cache = new WeakMap();
  3554. var Vk_initialized = new WeakMap();
  3555. var Vk_verifyAuth = new WeakSet();
  3556. var _toggleGroup = new WeakSet();
  3557. var _togglePublic = new WeakSet();
  3558. var _sendWall = new WeakSet();
  3559. var _deleteWall = new WeakSet();
  3560. var _getId = new WeakSet();
  3561. var _toggleVk = new WeakSet();
  3562. var Vk_setCache = new WeakSet();
  3563. class Vk extends social_Social {
  3564. constructor() {
  3565. var _GM_getValue;
  3566. super(...arguments);
  3567. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3568. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3569. Vk_classPrivateMethodInitSpec(this, _getId);
  3570. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3571. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3572. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3573. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3574. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3575. Vk_defineProperty(this, 'tasks', {
  3576. ...Vk_defaultTasks
  3577. });
  3578. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || {
  3579. ...Vk_defaultTasks
  3580. });
  3581. Vk_classPrivateFieldInitSpec(this, _username, {
  3582. writable: true,
  3583. value: ''
  3584. });
  3585. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3586. writable: true,
  3587. value: GM_getValue('vkCache') || {}
  3588. });
  3589. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3590. writable: true,
  3591. value: false
  3592. });
  3593. }
  3594. async init() {
  3595. try {
  3596. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3597. return true;
  3598. }
  3599. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3600. if (isVerified) {
  3601. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3602. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3603. return true;
  3604. }
  3605. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3606. return false;
  3607. } catch (error) {
  3608. throwError(error, 'Vk.init');
  3609. return false;
  3610. }
  3611. }
  3612. async toggle(_ref) {
  3613. let {
  3614. doTask = true,
  3615. nameLinks = []
  3616. } = _ref;
  3617. try {
  3618. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3619. scripts_echoLog({
  3620. text: i18n('needInit')
  3621. });
  3622. return false;
  3623. }
  3624. const prom = [];
  3625. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3626. scripts_echoLog({
  3627. type: 'globalOptionsSkip',
  3628. text: 'vk.names'
  3629. });
  3630. } else {
  3631. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3632. var _link$match;
  3633. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3634. });
  3635. if (realNames.length > 0) {
  3636. for (const name of realNames) {
  3637. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3638. name: name,
  3639. doTask: doTask
  3640. }));
  3641. await delay(1e3);
  3642. }
  3643. }
  3644. }
  3645. return Promise.all(prom).then(() => true);
  3646. } catch (error) {
  3647. throwError(error, 'Vk.toggle');
  3648. return false;
  3649. }
  3650. }
  3651. }
  3652. async function Vk_verifyAuth2() {
  3653. try {
  3654. const logStatus = scripts_echoLog({
  3655. text: i18n('verifyAuth', 'Vk')
  3656. });
  3657. const {
  3658. result,
  3659. statusText,
  3660. status,
  3661. data
  3662. } = await tools_httpRequest({
  3663. url: 'https://vk.com/im',
  3664. method: 'GET'
  3665. });
  3666. if (result === 'Success') {
  3667. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3668. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3669. return false;
  3670. }
  3671. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3672. var _data$responseText$ma;
  3673. 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]) || '');
  3674. logStatus.success();
  3675. return true;
  3676. }
  3677. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3678. return false;
  3679. }
  3680. logStatus.error(`${result}:${statusText}(${status})`);
  3681. return false;
  3682. } catch (error) {
  3683. throwError(error, 'Vk.verifyAuth');
  3684. return false;
  3685. }
  3686. }
  3687. async function _toggleGroup2(name, dataParam) {
  3688. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3689. try {
  3690. const logStatus = scripts_echoLog({
  3691. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3692. text: name
  3693. });
  3694. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3695. logStatus.success();
  3696. return true;
  3697. }
  3698. const reqData = {
  3699. act: doTask ? 'enter' : 'leave',
  3700. al: 1,
  3701. gid: dataParam.groupId,
  3702. hash: dataParam.groupHash
  3703. };
  3704. if (doTask) {
  3705. reqData.context = '_';
  3706. }
  3707. const {
  3708. result,
  3709. statusText,
  3710. status,
  3711. data
  3712. } = await tools_httpRequest({
  3713. url: 'https://vk.com/al_groups.php',
  3714. method: 'POST',
  3715. headers: {
  3716. origin: 'https://vk.com',
  3717. referer: `https://vk.com/${name}`,
  3718. 'content-type': 'application/x-www-form-urlencoded'
  3719. },
  3720. data: $.param(reqData)
  3721. });
  3722. if (result === 'Success') {
  3723. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3724. logStatus.success();
  3725. if (doTask) {
  3726. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3727. }
  3728. return true;
  3729. }
  3730. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3731. return false;
  3732. }
  3733. logStatus.error(`${result}:${statusText}(${status})`);
  3734. return false;
  3735. } catch (error) {
  3736. throwError(error, 'Vk.toggleGroup');
  3737. return false;
  3738. }
  3739. }
  3740. async function _togglePublic2(name, dataParam) {
  3741. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3742. try {
  3743. const logStatus = scripts_echoLog({
  3744. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3745. text: name
  3746. });
  3747. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3748. logStatus.success();
  3749. return true;
  3750. }
  3751. const {
  3752. result,
  3753. statusText,
  3754. status,
  3755. data
  3756. } = await tools_httpRequest({
  3757. url: 'https://vk.com/al_public.php',
  3758. method: 'POST',
  3759. headers: {
  3760. origin: 'https://vk.com',
  3761. referer: `https://vk.com/${name}`,
  3762. 'content-type': 'application/x-www-form-urlencoded'
  3763. },
  3764. data: $.param({
  3765. act: doTask ? 'a_enter' : 'a_leave',
  3766. al: 1,
  3767. pid: dataParam.publicPid,
  3768. hash: dataParam.publicHash
  3769. })
  3770. });
  3771. if (result === 'Success') {
  3772. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3773. logStatus.success();
  3774. if (doTask) {
  3775. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3776. }
  3777. return true;
  3778. }
  3779. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3780. return false;
  3781. }
  3782. logStatus.error(`${result}:${statusText}(${status})`);
  3783. return false;
  3784. } catch (error) {
  3785. throwError(error, 'Vk.togglePublic');
  3786. return false;
  3787. }
  3788. }
  3789. async function _sendWall2(name) {
  3790. try {
  3791. const logStatus = scripts_echoLog({
  3792. type: 'sendingVkWall',
  3793. text: name
  3794. });
  3795. const {
  3796. result,
  3797. statusText,
  3798. status,
  3799. data
  3800. } = await tools_httpRequest({
  3801. url: 'https://vk.com/like.php',
  3802. method: 'POST',
  3803. headers: {
  3804. origin: 'https://vk.com',
  3805. referer: `https://vk.com/${name}`,
  3806. 'content-type': 'application/x-www-form-urlencoded'
  3807. },
  3808. data: $.param({
  3809. act: 'publish_box',
  3810. al: 1,
  3811. object: name
  3812. })
  3813. });
  3814. if (result === 'Success') {
  3815. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3816. var _data$responseText$ma2;
  3817. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3818. if (hash) {
  3819. const {
  3820. result: resultR,
  3821. statusText: statusTextR,
  3822. status: statusR,
  3823. data: dataR
  3824. } = await tools_httpRequest({
  3825. url: 'https://vk.com/like.php',
  3826. method: 'POST',
  3827. headers: {
  3828. origin: 'https://vk.com',
  3829. referer: `https://vk.com/${name}`,
  3830. 'content-type': 'application/x-www-form-urlencoded'
  3831. },
  3832. data: $.param({
  3833. Message: '',
  3834. act: 'a_do_publish',
  3835. al: 1,
  3836. close_comments: 0,
  3837. friends_only: 0,
  3838. from: 'box',
  3839. hash: hash,
  3840. list: '',
  3841. mark_as_ads: 0,
  3842. mute_notifications: 0,
  3843. object: name,
  3844. ret_data: 1,
  3845. to: 0
  3846. })
  3847. });
  3848. if (resultR === 'Success') {
  3849. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3850. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3851. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3852. 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) {
  3853. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3854. logStatus.success();
  3855. 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);
  3856. 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);
  3857. if (postId && ownerId) {
  3858. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3859. }
  3860. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3861. return true;
  3862. }
  3863. }
  3864. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3865. return false;
  3866. }
  3867. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3868. return false;
  3869. }
  3870. logStatus.error('Error: Get "hash" failed');
  3871. return false;
  3872. }
  3873. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3874. return false;
  3875. }
  3876. logStatus.error(`${result}:${statusText}(${status})`);
  3877. return false;
  3878. } catch (error) {
  3879. throwError(error, 'Vk.sendWall');
  3880. return false;
  3881. }
  3882. }
  3883. async function _deleteWall2(name, dataParams) {
  3884. try {
  3885. const logStatus = scripts_echoLog({
  3886. type: 'deletingVkWall',
  3887. text: name
  3888. });
  3889. const {
  3890. result,
  3891. statusText,
  3892. status,
  3893. data
  3894. } = await tools_httpRequest({
  3895. url: 'https://vk.com/al_wall.php?act=delete',
  3896. method: 'POST',
  3897. headers: {
  3898. origin: 'https://vk.com',
  3899. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3900. 'content-type': 'application/x-www-form-urlencoded'
  3901. },
  3902. data: $.param({
  3903. act: 'delete',
  3904. al: 1,
  3905. confirm: 0,
  3906. from: 'wkview',
  3907. hash: dataParams.wallHash,
  3908. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3909. })
  3910. });
  3911. if (result === 'Success') {
  3912. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3913. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3914. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3915. 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]) {
  3916. logStatus.success();
  3917. return true;
  3918. }
  3919. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3920. return false;
  3921. }
  3922. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3923. return false;
  3924. }
  3925. logStatus.error(`${result}:${statusText}(${status})`);
  3926. return false;
  3927. } catch (error) {
  3928. throwError(error, 'Vk.deleteWall');
  3929. return false;
  3930. }
  3931. }
  3932. async function _getId2(name, doTask) {
  3933. try {
  3934. let url = `https://vk.com/${name}`;
  3935. if (/^wall-/.test(name)) {
  3936. if (doTask) {
  3937. return {
  3938. type: 'sendWall'
  3939. };
  3940. }
  3941. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3942. return {
  3943. type: 'unSupport'
  3944. };
  3945. }
  3946. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3947. }
  3948. const logStatus = scripts_echoLog({
  3949. type: 'gettingVkId',
  3950. text: name
  3951. });
  3952. const {
  3953. result,
  3954. statusText,
  3955. status,
  3956. data
  3957. } = await tools_httpRequest({
  3958. url: url,
  3959. method: 'GET'
  3960. });
  3961. if (result === 'Success') {
  3962. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3963. var _data$responseText$ma3, _data$responseText$ma4;
  3964. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3965. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3966. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3967. const publicJoined = !data.responseText.includes('Public.subscribe');
  3968. if (groupAct && groupId && groupHash) {
  3969. logStatus.success();
  3970. return {
  3971. groupAct: groupAct,
  3972. groupId: groupId,
  3973. groupHash: groupHash,
  3974. type: 'group'
  3975. };
  3976. } else if (publicHash && publicPid) {
  3977. logStatus.success();
  3978. return {
  3979. publicHash: publicHash,
  3980. publicPid: publicPid,
  3981. publicJoined: publicJoined,
  3982. type: 'public'
  3983. };
  3984. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3985. var _data$responseText$ma5;
  3986. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3987. if (wallHash) {
  3988. logStatus.success();
  3989. return {
  3990. type: 'deleteWall',
  3991. wallHash: wallHash
  3992. };
  3993. }
  3994. } else if (name.includes('wall') && doTask) {
  3995. logStatus.success();
  3996. return {
  3997. type: 'sendWall'
  3998. };
  3999. }
  4000. logStatus.error('Error: Parameters not found!');
  4001. return false;
  4002. }
  4003. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4004. return false;
  4005. }
  4006. logStatus.error(`${result}:${statusText}(${status})`);
  4007. return false;
  4008. } catch (error) {
  4009. throwError(error, 'Vk.getId');
  4010. return false;
  4011. }
  4012. }
  4013. async function _toggleVk2(_ref2) {
  4014. let {
  4015. name,
  4016. doTask = true
  4017. } = _ref2;
  4018. try {
  4019. if (!doTask && this.whiteList.names.includes(name)) {
  4020. scripts_echoLog({
  4021. type: 'whiteList',
  4022. text: 'Vk.undoTask',
  4023. id: name
  4024. });
  4025. return true;
  4026. }
  4027. const formatName = name.replace(/\/$/, '');
  4028. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4029. if (!data) {
  4030. return false;
  4031. }
  4032. switch (data.type) {
  4033. case 'group':
  4034. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4035.  
  4036. case 'public':
  4037. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4038.  
  4039. case 'sendWall':
  4040. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4041.  
  4042. case 'deleteWall':
  4043. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4044.  
  4045. default:
  4046. return false;
  4047. }
  4048. } catch (error) {
  4049. throwError(error, 'Vk.toggleVk');
  4050. return false;
  4051. }
  4052. }
  4053. function Vk_setCache2(name, postId) {
  4054. try {
  4055. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4056. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4057. } catch (error) {
  4058. throwError(error, 'Vk.setCache');
  4059. }
  4060. }
  4061. const social_Vk = Vk;
  4062. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4063. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4064. privateSet.add(obj);
  4065. }
  4066. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4067. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4068. privateMap.set(obj, value);
  4069. }
  4070. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4071. if (privateCollection.has(obj)) {
  4072. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4073. }
  4074. }
  4075. function Youtube_defineProperty(obj, key, value) {
  4076. if (key in obj) {
  4077. Object.defineProperty(obj, key, {
  4078. value: value,
  4079. enumerable: true,
  4080. configurable: true,
  4081. writable: true
  4082. });
  4083. } else {
  4084. obj[key] = value;
  4085. }
  4086. return obj;
  4087. }
  4088. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4089. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4090. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4091. return value;
  4092. }
  4093. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4094. if (descriptor.set) {
  4095. descriptor.set.call(receiver, value);
  4096. } else {
  4097. if (!descriptor.writable) {
  4098. throw new TypeError('attempted to set read only private field');
  4099. }
  4100. descriptor.value = value;
  4101. }
  4102. }
  4103. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4104. if (!privateSet.has(receiver)) {
  4105. throw new TypeError('attempted to get private field on non-instance');
  4106. }
  4107. return fn;
  4108. }
  4109. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4110. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4111. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4112. }
  4113. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4114. if (!privateMap.has(receiver)) {
  4115. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4116. }
  4117. return privateMap.get(receiver);
  4118. }
  4119. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4120. if (descriptor.get) {
  4121. return descriptor.get.call(receiver);
  4122. }
  4123. return descriptor.value;
  4124. }
  4125. const Youtube_defaultTasks = {
  4126. channels: [],
  4127. likes: []
  4128. };
  4129. const getInfo = async function(link, type) {
  4130. try {
  4131. const logStatus = scripts_echoLog({
  4132. text: i18n('gettingYtbToken')
  4133. });
  4134. const {
  4135. result,
  4136. statusText,
  4137. status,
  4138. data
  4139. } = await tools_httpRequest({
  4140. url: link,
  4141. method: 'GET'
  4142. });
  4143. if (result === 'Success') {
  4144. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4145. var _data$responseText$ma, _ref;
  4146. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4147. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4148. return {
  4149. needLogin: true
  4150. };
  4151. }
  4152. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4153. 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]) || '{}';
  4154. const {
  4155. client,
  4156. request
  4157. } = JSON.parse(context);
  4158. if (apiKey && client && request) {
  4159. client.hl = 'en';
  4160. if (type === 'channel') {
  4161. var _data$responseText$ma2;
  4162. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4163. if (channelId) {
  4164. logStatus.success();
  4165. return {
  4166. params: {
  4167. apiKey: apiKey,
  4168. client: client,
  4169. request: request,
  4170. channelId: channelId
  4171. }
  4172. };
  4173. }
  4174. logStatus.error('Error: Get "channelId" failed!');
  4175. return {};
  4176. } else if (type === 'likeVideo') {
  4177. var _data$responseText$ma3, _data$responseText$ma4;
  4178. 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];
  4179. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4180. if (videoId) {
  4181. logStatus.success();
  4182. return {
  4183. params: {
  4184. apiKey: apiKey,
  4185. client: client,
  4186. request: request,
  4187. videoId: videoId,
  4188. likeParams: likeParams
  4189. }
  4190. };
  4191. }
  4192. logStatus.error('Error: Get "videoId" failed!');
  4193. return {};
  4194. }
  4195. logStatus.error('Error: Unknown type');
  4196. return {};
  4197. }
  4198. logStatus.error('Error: Parameter "apiKey" not found!');
  4199. return {};
  4200. }
  4201. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4202. return {};
  4203. }
  4204. logStatus.error(`${result}:${statusText}(${status})`);
  4205. return {};
  4206. } catch (error) {
  4207. throwError(error, 'Youtube.getInfo');
  4208. return {};
  4209. }
  4210. };
  4211. var Youtube_auth = new WeakMap();
  4212. var Youtube_initialized = new WeakMap();
  4213. var _verifyChannel = new WeakMap();
  4214. var Youtube_verifyAuth = new WeakSet();
  4215. var Youtube_updateAuth = new WeakSet();
  4216. var _getInfo = new WeakSet();
  4217. var Youtube_toggleChannel = new WeakSet();
  4218. var _toggleLikeVideo = new WeakSet();
  4219. class Youtube extends social_Social {
  4220. constructor() {
  4221. var _GM_getValue;
  4222. super(...arguments);
  4223. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4224. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4225. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4226. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4227. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4228. Youtube_defineProperty(this, 'tasks', {
  4229. ...Youtube_defaultTasks
  4230. });
  4231. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || {
  4232. ...Youtube_defaultTasks
  4233. });
  4234. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4235. writable: true,
  4236. value: GM_getValue('youtubeAuth') || {}
  4237. });
  4238. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4239. writable: true,
  4240. value: false
  4241. });
  4242. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4243. writable: true,
  4244. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4245. });
  4246. }
  4247. async init() {
  4248. try {
  4249. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4250. return true;
  4251. }
  4252. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4253. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4254. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4255. return true;
  4256. }
  4257. return false;
  4258. }
  4259. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4260. if (isVerified) {
  4261. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4262. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4263. return true;
  4264. }
  4265. GM_setValue('youtubeAuth', null);
  4266. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4267. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4268. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4269. return true;
  4270. }
  4271. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4272. return false;
  4273. } catch (error) {
  4274. throwError(error, 'Youtube.init');
  4275. return false;
  4276. }
  4277. }
  4278. async toggle(_ref2) {
  4279. let {
  4280. doTask = true,
  4281. channelLinks = [],
  4282. videoLinks = []
  4283. } = _ref2;
  4284. try {
  4285. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4286. scripts_echoLog({
  4287. text: i18n('needInit')
  4288. });
  4289. return false;
  4290. }
  4291. const prom = [];
  4292. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4293. scripts_echoLog({
  4294. type: 'globalOptionsSkip',
  4295. text: 'youtube.channels'
  4296. });
  4297. } else {
  4298. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4299. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4300. var _link$match;
  4301. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4302. }
  4303. return link;
  4304. });
  4305. if (realChannels.length > 0) {
  4306. for (const channel of realChannels) {
  4307. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4308. link: channel,
  4309. doTask: doTask
  4310. }));
  4311. await delay(1e3);
  4312. }
  4313. }
  4314. }
  4315. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4316. scripts_echoLog({
  4317. type: 'globalOptionsSkip',
  4318. text: 'youtube.likes'
  4319. });
  4320. } else {
  4321. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4322. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4323. var _link$match2;
  4324. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4325. }
  4326. return link;
  4327. });
  4328. if (realLikes.length > 0) {
  4329. for (const video of realLikes) {
  4330. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4331. link: video,
  4332. doTask: doTask
  4333. }));
  4334. await delay(1e3);
  4335. }
  4336. }
  4337. }
  4338. return Promise.all(prom).then(() => true);
  4339. } catch (error) {
  4340. throwError(error, 'Youtube.toggle');
  4341. return false;
  4342. }
  4343. }
  4344. }
  4345. async function Youtube_verifyAuth2() {
  4346. try {
  4347. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4348. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4349. doTask: true,
  4350. verify: true
  4351. });
  4352. } catch (error) {
  4353. throwError(error, 'Youtube.verifyAuth');
  4354. return false;
  4355. }
  4356. }
  4357. async function Youtube_updateAuth2() {
  4358. try {
  4359. const logStatus = scripts_echoLog({
  4360. text: i18n('updatingAuth', 'Youtube')
  4361. });
  4362. return await new Promise(resolve => {
  4363. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4364. active: true,
  4365. insert: true,
  4366. setParent: true
  4367. });
  4368. newTab.onclose = async () => {
  4369. const auth = GM_getValue('youtubeAuth');
  4370. if (auth) {
  4371. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4372. logStatus.success();
  4373. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4374. resolve(result);
  4375. });
  4376. } else {
  4377. logStatus.error('Error: Update youtube auth failed!');
  4378. resolve(false);
  4379. }
  4380. };
  4381. });
  4382. } catch (error) {
  4383. throwError(error, 'Discord.updateAuth');
  4384. return false;
  4385. }
  4386. }
  4387. function _getInfo2(link, type) {
  4388. return getInfo(link, type);
  4389. }
  4390. async function Youtube_toggleChannel2(_ref3) {
  4391. let {
  4392. link,
  4393. doTask = true,
  4394. verify = false
  4395. } = _ref3;
  4396. try {
  4397. const {
  4398. params,
  4399. needLogin
  4400. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4401. const {
  4402. apiKey,
  4403. client,
  4404. request,
  4405. channelId
  4406. } = params || {};
  4407. if (needLogin) {
  4408. scripts_echoLog({
  4409. html: i18n('loginYtb')
  4410. });
  4411. return false;
  4412. }
  4413. if (!(apiKey && client && request && channelId)) {
  4414. scripts_echoLog({
  4415. text: '"getYtbToken" failed'
  4416. });
  4417. return false;
  4418. }
  4419. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4420. scripts_echoLog({
  4421. type: 'whiteList',
  4422. text: 'Youtube.unfollowChannel',
  4423. id: channelId
  4424. });
  4425. return true;
  4426. }
  4427. const logStatus = verify ? scripts_echoLog({
  4428. text: i18n('verifyingAuth', 'Youtube')
  4429. }) : scripts_echoLog({
  4430. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4431. text: channelId
  4432. });
  4433. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4434. const {
  4435. result,
  4436. statusText,
  4437. status,
  4438. data
  4439. } = await tools_httpRequest({
  4440. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4441. method: 'POST',
  4442. headers: {
  4443. origin: 'https://www.youtube.com',
  4444. referer: `https://www.youtube.com/channel/${channelId}`,
  4445. 'content-type': 'application/json',
  4446. 'x-goog-authuser': '0',
  4447. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4448. 'x-origin': 'https://www.youtube.com',
  4449. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4450. },
  4451. data: JSON.stringify({
  4452. context: {
  4453. client: client,
  4454. request: {
  4455. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4456. internalExperimentFlags: [],
  4457. consistencyTokenJars: []
  4458. },
  4459. user: {}
  4460. },
  4461. channelIds: [ channelId ],
  4462. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4463. })
  4464. });
  4465. if (result === 'Success') {
  4466. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4467. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4468. logStatus.success();
  4469. if (doTask && !verify) {
  4470. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4471. }
  4472. return true;
  4473. }
  4474. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4475. logStatus.success();
  4476. return true;
  4477. }
  4478. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4479. return false;
  4480. }
  4481. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4482. return false;
  4483. }
  4484. logStatus.error(`${result}:${statusText}(${status})`);
  4485. return false;
  4486. } catch (error) {
  4487. throwError(error, 'Youtube.toggleChannel');
  4488. return false;
  4489. }
  4490. }
  4491. async function _toggleLikeVideo2(_ref4) {
  4492. let {
  4493. link,
  4494. doTask = true
  4495. } = _ref4;
  4496. try {
  4497. const {
  4498. params,
  4499. needLogin
  4500. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4501. const {
  4502. apiKey,
  4503. client,
  4504. request,
  4505. videoId,
  4506. likeParams
  4507. } = params || {};
  4508. if (needLogin) {
  4509. scripts_echoLog({
  4510. html: `${i18n('loginYtb')}`
  4511. });
  4512. return false;
  4513. }
  4514. if (!(apiKey && client && request && videoId && likeParams)) {
  4515. scripts_echoLog({
  4516. text: '"getYtbToken" failed'
  4517. });
  4518. return false;
  4519. }
  4520. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4521. scripts_echoLog({
  4522. type: 'whiteList',
  4523. text: 'Youtube.unlikeVideo',
  4524. id: videoId
  4525. });
  4526. return true;
  4527. }
  4528. const logStatus = scripts_echoLog({
  4529. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4530. text: videoId
  4531. });
  4532. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4533. const likeVideoData = {
  4534. context: {
  4535. client: client,
  4536. request: {
  4537. sessionId: request.sessionId,
  4538. internalExperimentFlags: [],
  4539. consistencyTokenJars: []
  4540. },
  4541. user: {}
  4542. },
  4543. target: {
  4544. videoId: videoId
  4545. }
  4546. };
  4547. if (doTask) {
  4548. if (likeParams) {
  4549. likeVideoData.params = likeParams;
  4550. } else {
  4551. logStatus.error('Empty likeParams');
  4552. return false;
  4553. }
  4554. }
  4555. const {
  4556. result,
  4557. statusText,
  4558. status,
  4559. data
  4560. } = await tools_httpRequest({
  4561. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4562. method: 'POST',
  4563. headers: {
  4564. origin: 'https://www.youtube.com',
  4565. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4566. 'content-type': 'application/json',
  4567. 'x-goog-authuser': '0',
  4568. 'x-goog-visitor-id': client.visitorData,
  4569. 'x-origin': 'https://www.youtube.com',
  4570. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4571. },
  4572. data: JSON.stringify(likeVideoData)
  4573. });
  4574. if (result === 'Success') {
  4575. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4576. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4577. logStatus.success();
  4578. if (doTask) {
  4579. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4580. }
  4581. return true;
  4582. }
  4583. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4584. return false;
  4585. }
  4586. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4587. return false;
  4588. }
  4589. logStatus.error(`${result}:${statusText}(${status})`);
  4590. return false;
  4591. } catch (error) {
  4592. throwError(error, 'Youtube.toggleLikeVideo');
  4593. return false;
  4594. }
  4595. }
  4596. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4597. Steam_checkPrivateRedeclaration(obj, privateSet);
  4598. privateSet.add(obj);
  4599. }
  4600. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4601. Steam_checkPrivateRedeclaration(obj, privateMap);
  4602. privateMap.set(obj, value);
  4603. }
  4604. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4605. if (privateCollection.has(obj)) {
  4606. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4607. }
  4608. }
  4609. function Steam_defineProperty(obj, key, value) {
  4610. if (key in obj) {
  4611. Object.defineProperty(obj, key, {
  4612. value: value,
  4613. enumerable: true,
  4614. configurable: true,
  4615. writable: true
  4616. });
  4617. } else {
  4618. obj[key] = value;
  4619. }
  4620. return obj;
  4621. }
  4622. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4623. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4624. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4625. return value;
  4626. }
  4627. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4628. if (descriptor.set) {
  4629. descriptor.set.call(receiver, value);
  4630. } else {
  4631. if (!descriptor.writable) {
  4632. throw new TypeError('attempted to set read only private field');
  4633. }
  4634. descriptor.value = value;
  4635. }
  4636. }
  4637. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4638. if (!privateSet.has(receiver)) {
  4639. throw new TypeError('attempted to get private field on non-instance');
  4640. }
  4641. return fn;
  4642. }
  4643. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4644. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4645. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4646. }
  4647. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4648. if (!privateMap.has(receiver)) {
  4649. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4650. }
  4651. return privateMap.get(receiver);
  4652. }
  4653. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4654. if (descriptor.get) {
  4655. return descriptor.get.call(receiver);
  4656. }
  4657. return descriptor.value;
  4658. }
  4659. const Steam_defaultTasks = {
  4660. groups: [],
  4661. wishlists: [],
  4662. follows: [],
  4663. forums: [],
  4664. workshops: [],
  4665. workshopVotes: [],
  4666. curators: [],
  4667. curatorLikes: [],
  4668. announcements: []
  4669. };
  4670. var Steam_cache = new WeakMap();
  4671. var Steam_auth = new WeakMap();
  4672. var Steam_initialized = new WeakMap();
  4673. var _area = new WeakMap();
  4674. var _updateStoreAuth = new WeakSet();
  4675. var _updateCommunityAuth = new WeakSet();
  4676. var _getAreaInfo = new WeakSet();
  4677. var _changeArea = new WeakSet();
  4678. var _joinGroup = new WeakSet();
  4679. var _leaveGroup = new WeakSet();
  4680. var _getGroupId = new WeakSet();
  4681. var _addToWishlist = new WeakSet();
  4682. var _removeFromWishlist = new WeakSet();
  4683. var _toggleFollowGame = new WeakSet();
  4684. var _isFollowedGame = new WeakSet();
  4685. var _toggleForum = new WeakSet();
  4686. var _getForumId = new WeakSet();
  4687. var _toggleFavoriteWorkshop = new WeakSet();
  4688. var _getWorkshopAppId = new WeakSet();
  4689. var _voteUpWorkshop = new WeakSet();
  4690. var _toggleCurator = new WeakSet();
  4691. var _toggleCuratorLike = new WeakSet();
  4692. var _getAnnouncementParams = new WeakSet();
  4693. var _likeAnnouncement = new WeakSet();
  4694. var Steam_setCache = new WeakSet();
  4695. class Steam extends social_Social {
  4696. constructor() {
  4697. var _GM_getValue;
  4698. super(...arguments);
  4699. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4700. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4701. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4702. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4703. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4704. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4705. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4706. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4707. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4708. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4709. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4710. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4711. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4712. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4713. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4714. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4715. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4716. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4717. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4718. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4719. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4720. Steam_defineProperty(this, 'tasks', {
  4721. ...Steam_defaultTasks
  4722. });
  4723. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || {
  4724. ...Steam_defaultTasks
  4725. });
  4726. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4727. writable: true,
  4728. value: GM_getValue('steamCache') || {
  4729. group: {},
  4730. forum: {},
  4731. workshop: {},
  4732. curator: {}
  4733. }
  4734. });
  4735. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4736. writable: true,
  4737. value: {}
  4738. });
  4739. Steam_classPrivateFieldInitSpec(this, Steam_initialized, {
  4740. writable: true,
  4741. value: false
  4742. });
  4743. Steam_classPrivateFieldInitSpec(this, _area, {
  4744. writable: true,
  4745. value: 'CN'
  4746. });
  4747. }
  4748. async init() {
  4749. try {
  4750. if (Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4751. return true;
  4752. }
  4753. const isVerified = await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this) && await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this);
  4754. if (isVerified) {
  4755. Steam_classPrivateFieldSet(this, Steam_initialized, true);
  4756. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4757. return true;
  4758. }
  4759. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4760. return false;
  4761. } catch (error) {
  4762. throwError(error, 'Steam.init');
  4763. return false;
  4764. }
  4765. }
  4766. async getCuratorId(path, name) {
  4767. try {
  4768. const logStatus = scripts_echoLog({
  4769. type: 'gettingCuratorId',
  4770. text: `${path}/${name}`
  4771. });
  4772. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4773. if (curatorId) {
  4774. logStatus.success();
  4775. return curatorId;
  4776. }
  4777. const {
  4778. result,
  4779. statusText,
  4780. status,
  4781. data
  4782. } = await tools_httpRequest({
  4783. url: `https://store.steampowered.com/${path}/${name}`,
  4784. method: 'GET',
  4785. headers: {
  4786. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4787. }
  4788. });
  4789. if (result === 'Success') {
  4790. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4791. var _data$responseText$ma;
  4792. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4793. if (curatorId) {
  4794. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4795. logStatus.success();
  4796. return curatorId;
  4797. }
  4798. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4799. return false;
  4800. }
  4801. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4802. return false;
  4803. }
  4804. logStatus.error(`${result}:${statusText}(${status})`);
  4805. return false;
  4806. } catch (error) {
  4807. throwError(error, 'Steam.getCuratorID');
  4808. return false;
  4809. }
  4810. }
  4811. async toggle(_ref) {
  4812. let {
  4813. doTask = true,
  4814. groupLinks = [],
  4815. wishlistLinks = [],
  4816. followLinks = [],
  4817. forumLinks = [],
  4818. workshopLinks = [],
  4819. workshopVoteLinks = [],
  4820. curatorLinks = [],
  4821. curatorLikeLinks = [],
  4822. announcementLinks = []
  4823. } = _ref;
  4824. try {
  4825. if (!Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4826. scripts_echoLog({
  4827. text: i18n('needInit')
  4828. });
  4829. return false;
  4830. }
  4831. const prom = [];
  4832. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4833. scripts_echoLog({
  4834. type: 'globalOptionsSkip',
  4835. text: 'steam.groups'
  4836. });
  4837. } else {
  4838. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4839. var _link$match;
  4840. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4841. });
  4842. if (realGroups.length > 0) {
  4843. for (const group of realGroups) {
  4844. if (doTask) {
  4845. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4846. } else {
  4847. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4848. }
  4849. await delay(1e3);
  4850. }
  4851. }
  4852. }
  4853. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4854. scripts_echoLog({
  4855. type: 'globalOptionsSkip',
  4856. text: 'steam.wishlists'
  4857. });
  4858. } else {
  4859. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4860. var _link$match2;
  4861. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4862. });
  4863. if (realWishlists.length > 0) {
  4864. for (const game of realWishlists) {
  4865. if (doTask) {
  4866. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4867. } else {
  4868. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4869. }
  4870. await delay(1e3);
  4871. }
  4872. }
  4873. }
  4874. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4875. scripts_echoLog({
  4876. type: 'globalOptionsSkip',
  4877. text: 'steam.follows'
  4878. });
  4879. } else {
  4880. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4881. var _link$match3;
  4882. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4883. });
  4884. if (realFollows.length > 0) {
  4885. for (const game of realFollows) {
  4886. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4887. await delay(1e3);
  4888. }
  4889. }
  4890. }
  4891. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4892. scripts_echoLog({
  4893. type: 'globalOptionsSkip',
  4894. text: 'steam.forums'
  4895. });
  4896. } else {
  4897. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4898. var _link$match4;
  4899. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4900. });
  4901. if (realForums.length > 0) {
  4902. for (const forum of realForums) {
  4903. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4904. await delay(1e3);
  4905. }
  4906. }
  4907. }
  4908. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4909. scripts_echoLog({
  4910. type: 'globalOptionsSkip',
  4911. text: 'steam.workshops'
  4912. });
  4913. } else {
  4914. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4915. var _link$match5;
  4916. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4917. });
  4918. if (realWorkshops.length > 0) {
  4919. for (const workshop of realWorkshops) {
  4920. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4921. await delay(1e3);
  4922. }
  4923. }
  4924. }
  4925. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4926. scripts_echoLog({
  4927. type: 'globalOptionsSkip',
  4928. text: 'steam.workshopVotes'
  4929. });
  4930. } else {
  4931. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4932. var _link$match6;
  4933. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4934. });
  4935. if (doTask && realworkshopVotes.length > 0) {
  4936. for (const workshop of realworkshopVotes) {
  4937. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4938. await delay(1e3);
  4939. }
  4940. }
  4941. }
  4942. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4943. scripts_echoLog({
  4944. type: 'globalOptionsSkip',
  4945. text: 'steam.curators'
  4946. });
  4947. } else {
  4948. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4949. var _link$match7;
  4950. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4951. });
  4952. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4953. var _link$match8;
  4954. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4955. });
  4956. if (realCurators.length > 0) {
  4957. for (const curator of realCurators) {
  4958. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  4959. await delay(1e3);
  4960. }
  4961. }
  4962. if (realCuratorLikes.length > 0) {
  4963. for (const curatorLike of realCuratorLikes) {
  4964. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  4965. await delay(1e3);
  4966. }
  4967. }
  4968. }
  4969. if (doTask && !globalOptions.doTask.steam.announcements) {
  4970. scripts_echoLog({
  4971. type: 'globalOptionsSkip',
  4972. text: 'steam.announcements'
  4973. });
  4974. } else {
  4975. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  4976. var _link$match10;
  4977. if (link.includes('store.steampowered.com')) {
  4978. var _link$match9;
  4979. 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('/');
  4980. }
  4981. 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('/');
  4982. });
  4983. if (doTask && realAnnouncements.length > 0) {
  4984. for (const id of realAnnouncements) {
  4985. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  4986. await delay(1e3);
  4987. }
  4988. }
  4989. }
  4990. return Promise.all(prom).then(async () => {
  4991. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  4992. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  4993. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  4994. }
  4995. return true;
  4996. });
  4997. } catch (error) {
  4998. throwError(error, 'Steam.toggle');
  4999. return false;
  5000. }
  5001. }
  5002. }
  5003. async function _updateStoreAuth2() {
  5004. try {
  5005. const logStatus = scripts_echoLog({
  5006. text: i18n('updatingAuth', i18n('steamStore'))
  5007. });
  5008. const {
  5009. result,
  5010. statusText,
  5011. status,
  5012. data
  5013. } = await tools_httpRequest({
  5014. url: 'https://store.steampowered.com/stats/',
  5015. method: 'GET'
  5016. });
  5017. if (result === 'Success') {
  5018. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5019. var _data$responseText$ma2;
  5020. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5021. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5022. return false;
  5023. }
  5024. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5025. if (storeSessionID) {
  5026. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5027. logStatus.success();
  5028. return true;
  5029. }
  5030. logStatus.error('Error: Get "sessionID" failed');
  5031. return false;
  5032. }
  5033. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5034. return false;
  5035. }
  5036. logStatus.error(`${result}:${statusText}(${status})`);
  5037. return false;
  5038. } catch (error) {
  5039. throwError(error, 'Steam.updateStoreAuth');
  5040. return false;
  5041. }
  5042. }
  5043. async function _updateCommunityAuth2() {
  5044. try {
  5045. const logStatus = scripts_echoLog({
  5046. text: i18n('updatingAuth', i18n('steamCommunity'))
  5047. });
  5048. const {
  5049. result,
  5050. statusText,
  5051. status,
  5052. data
  5053. } = await tools_httpRequest({
  5054. url: 'https://steamcommunity.com/my',
  5055. method: 'GET'
  5056. });
  5057. if (result === 'Success') {
  5058. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5059. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5060. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5061. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5062. return false;
  5063. }
  5064. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5065. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5066. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5067. if (steam64Id) {
  5068. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5069. }
  5070. if (userName) {
  5071. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5072. }
  5073. if (communitySessionID) {
  5074. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5075. logStatus.success();
  5076. return true;
  5077. }
  5078. logStatus.error('Error: Get "sessionID" failed');
  5079. return false;
  5080. }
  5081. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5082. return false;
  5083. }
  5084. logStatus.error(`${result}:${statusText}(${status})`);
  5085. return false;
  5086. } catch (error) {
  5087. throwError(error, 'Steam.updateCommunityAuth');
  5088. return false;
  5089. }
  5090. }
  5091. async function _getAreaInfo2() {
  5092. try {
  5093. const logStatus = scripts_echoLog({
  5094. text: i18n('gettingAreaInfo')
  5095. });
  5096. const {
  5097. result,
  5098. statusText,
  5099. status,
  5100. data
  5101. } = await tools_httpRequest({
  5102. url: 'https://store.steampowered.com/cart/',
  5103. method: 'GET'
  5104. });
  5105. if (result === 'Success') {
  5106. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5107. var _data$responseText$ma6;
  5108. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5109. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5110. if (currentArea && areas.length > 0) {
  5111. Steam_classPrivateFieldSet(this, _area, currentArea);
  5112. logStatus.success();
  5113. return {
  5114. currentArea: currentArea,
  5115. areas: areas
  5116. };
  5117. }
  5118. logStatus.error('Error: get country info filed');
  5119. return {};
  5120. }
  5121. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5122. return {};
  5123. }
  5124. logStatus.error(`${result}:${statusText}(${status})`);
  5125. return {};
  5126. } catch (error) {
  5127. throwError(error, 'Steam.getAreaInfo');
  5128. return {};
  5129. }
  5130. }
  5131. async function _changeArea2(area) {
  5132. try {
  5133. let aimedArea = area;
  5134. if (!aimedArea) {
  5135. const {
  5136. currentArea,
  5137. areas
  5138. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5139. if (!currentArea || !areas) {
  5140. return false;
  5141. }
  5142. if (currentArea !== 'CN') {
  5143. scripts_echoLog({
  5144. text: 'notNeededChangeArea'
  5145. });
  5146. return 'skip';
  5147. }
  5148. const anotherArea = areas.filter(area => area && area !== 'CN');
  5149. if (!anotherArea || anotherArea.length === 0) {
  5150. scripts_echoLog({
  5151. text: 'noAnotherArea'
  5152. });
  5153. return false;
  5154. }
  5155. [ aimedArea ] = anotherArea;
  5156. }
  5157. const logStatus = scripts_echoLog({
  5158. text: i18n('changingArea', aimedArea)
  5159. });
  5160. const {
  5161. result,
  5162. statusText,
  5163. status,
  5164. data
  5165. } = await tools_httpRequest({
  5166. url: 'https://store.steampowered.com/account/setcountry',
  5167. method: 'POST',
  5168. headers: {
  5169. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5170. },
  5171. data: $.param({
  5172. cc: aimedArea,
  5173. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5174. })
  5175. });
  5176. if (result === 'Success') {
  5177. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5178. const {
  5179. currentArea
  5180. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5181. if (currentArea === aimedArea) {
  5182. logStatus.success();
  5183. return currentArea;
  5184. }
  5185. logStatus.error('Error: change country filed');
  5186. return 'CN';
  5187. }
  5188. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5189. return 'CN';
  5190. }
  5191. logStatus.error(`${result}:${statusText}(${status})`);
  5192. return 'CN';
  5193. } catch (error) {
  5194. throwError(error, 'Steam.changeArea');
  5195. return false;
  5196. }
  5197. }
  5198. async function _joinGroup2(groupName) {
  5199. try {
  5200. const logStatus = scripts_echoLog({
  5201. type: 'joiningSteamGroup',
  5202. text: groupName
  5203. });
  5204. const {
  5205. result,
  5206. statusText,
  5207. status,
  5208. data
  5209. } = await tools_httpRequest({
  5210. url: `https://steamcommunity.com/groups/${groupName}`,
  5211. method: 'POST',
  5212. headers: {
  5213. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5214. },
  5215. data: $.param({
  5216. action: 'join',
  5217. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5218. })
  5219. });
  5220. if (result === 'Success') {
  5221. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5222. logStatus.success();
  5223. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5224. return true;
  5225. }
  5226. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5227. return false;
  5228. }
  5229. logStatus.error(`${result}:${statusText}(${status})`);
  5230. return false;
  5231. } catch (error) {
  5232. throwError(error, 'Steam.joinGroup');
  5233. return false;
  5234. }
  5235. }
  5236. async function _leaveGroup2(groupName) {
  5237. try {
  5238. if (this.whiteList.groups.includes(groupName)) {
  5239. scripts_echoLog({
  5240. type: 'whiteList',
  5241. text: 'Steam.leaveGroup',
  5242. id: groupName
  5243. });
  5244. return true;
  5245. }
  5246. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5247. if (!groupId) {
  5248. return false;
  5249. }
  5250. const logStatus = scripts_echoLog({
  5251. type: 'leavingSteamGroup',
  5252. text: groupName
  5253. });
  5254. const {
  5255. result,
  5256. statusText,
  5257. status,
  5258. data
  5259. } = await tools_httpRequest({
  5260. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5261. method: 'POST',
  5262. headers: {
  5263. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5264. },
  5265. data: $.param({
  5266. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5267. action: 'leaveGroup',
  5268. groupId: groupId
  5269. })
  5270. });
  5271. if (result === 'Success') {
  5272. 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) {
  5273. logStatus.success();
  5274. return true;
  5275. }
  5276. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5277. return false;
  5278. }
  5279. logStatus.error(`${result}:${statusText}(${status})`);
  5280. return false;
  5281. } catch (error) {
  5282. throwError(error, 'Steam.leaveGroup');
  5283. return false;
  5284. }
  5285. }
  5286. async function _getGroupId2(groupName) {
  5287. try {
  5288. const logStatus = scripts_echoLog({
  5289. type: 'gettingSteamGroupId',
  5290. text: groupName
  5291. });
  5292. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5293. if (groupId) {
  5294. logStatus.success();
  5295. return groupId;
  5296. }
  5297. const {
  5298. result,
  5299. statusText,
  5300. status,
  5301. data
  5302. } = await tools_httpRequest({
  5303. url: `https://steamcommunity.com/groups/${groupName}`,
  5304. method: 'GET',
  5305. headers: {
  5306. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5307. }
  5308. });
  5309. if (result === 'Success') {
  5310. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5311. var _data$responseText$ma7;
  5312. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5313. if (groupId) {
  5314. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5315. logStatus.success();
  5316. return groupId;
  5317. }
  5318. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5319. return false;
  5320. }
  5321. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5322. return false;
  5323. }
  5324. logStatus.error(`${result}:${statusText}(${status})`);
  5325. return false;
  5326. } catch (error) {
  5327. throwError(error, 'Steam.getGroupID');
  5328. return false;
  5329. }
  5330. }
  5331. async function _addToWishlist2(gameId) {
  5332. try {
  5333. var _data$response;
  5334. const logStatus = scripts_echoLog({
  5335. type: 'addingToWishlist',
  5336. text: gameId
  5337. });
  5338. const {
  5339. result,
  5340. data
  5341. } = await tools_httpRequest({
  5342. url: 'https://store.steampowered.com/api/addtowishlist',
  5343. method: 'POST',
  5344. headers: {
  5345. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5346. },
  5347. data: $.param({
  5348. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5349. appid: gameId
  5350. }),
  5351. dataType: 'json'
  5352. });
  5353. 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) {
  5354. logStatus.success();
  5355. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5356. return true;
  5357. }
  5358. const {
  5359. result: resultR,
  5360. statusText: statusTextR,
  5361. status: statusR,
  5362. data: dataR
  5363. } = await tools_httpRequest({
  5364. url: `https://store.steampowered.com/app/${gameId}`,
  5365. method: 'GET'
  5366. });
  5367. if (resultR === 'Success') {
  5368. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5369. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5370. logStatus.warning(i18n('changeAreaNotice'));
  5371. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5372. return false;
  5373. }
  5374. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5375. }
  5376. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5377. logStatus.success();
  5378. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5379. return true;
  5380. } 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"')) {
  5381. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5382. return false;
  5383. }
  5384. logStatus.success();
  5385. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5386. return true;
  5387. }
  5388. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5389. return false;
  5390. }
  5391. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5392. return false;
  5393. } catch (error) {
  5394. throwError(error, 'Steam.addToWishlist');
  5395. return false;
  5396. }
  5397. }
  5398. async function _removeFromWishlist2(gameId) {
  5399. try {
  5400. var _data$response2;
  5401. if (this.whiteList.wishlists.includes(gameId)) {
  5402. scripts_echoLog({
  5403. type: 'whiteList',
  5404. text: 'Steam.removeFromWishlist',
  5405. id: gameId
  5406. });
  5407. return true;
  5408. }
  5409. const logStatus = scripts_echoLog({
  5410. type: 'removingFromWishlist',
  5411. text: gameId
  5412. });
  5413. const {
  5414. result,
  5415. data
  5416. } = await tools_httpRequest({
  5417. url: 'https://store.steampowered.com/api/removefromwishlist',
  5418. method: 'POST',
  5419. headers: {
  5420. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5421. },
  5422. data: $.param({
  5423. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5424. appid: gameId
  5425. }),
  5426. dataType: 'json'
  5427. });
  5428. 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) {
  5429. logStatus.success();
  5430. return true;
  5431. }
  5432. const {
  5433. result: resultR,
  5434. statusText: statusTextR,
  5435. status: statusR,
  5436. data: dataR
  5437. } = await tools_httpRequest({
  5438. url: `https://store.steampowered.com/app/${gameId}`,
  5439. method: 'GET'
  5440. });
  5441. if (resultR === 'Success') {
  5442. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5443. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5444. logStatus.warning(i18n('changeAreaNotice'));
  5445. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5446. if (!result || result === 'CN' || result === 'skip') {
  5447. return false;
  5448. }
  5449. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5450. }
  5451. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5452. logStatus.success();
  5453. return true;
  5454. }
  5455. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5456. return false;
  5457. }
  5458. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5459. return false;
  5460. }
  5461. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5462. return false;
  5463. } catch (error) {
  5464. throwError(error, 'Steam.removeFromWishlist');
  5465. return false;
  5466. }
  5467. }
  5468. async function _toggleFollowGame2(gameId, doTask) {
  5469. try {
  5470. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5471. scripts_echoLog({
  5472. type: 'whiteList',
  5473. text: 'Steam.unfollowGame',
  5474. id: gameId
  5475. });
  5476. return true;
  5477. }
  5478. const logStatus = scripts_echoLog({
  5479. type: `${doTask ? '' : 'un'}followingGame`,
  5480. text: gameId
  5481. });
  5482. const requestData = {
  5483. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5484. appid: gameId
  5485. };
  5486. if (!doTask) {
  5487. requestData.unfollow = '1';
  5488. }
  5489. const {
  5490. result,
  5491. data
  5492. } = await tools_httpRequest({
  5493. url: 'https://store.steampowered.com/explore/followgame/',
  5494. method: 'POST',
  5495. headers: {
  5496. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5497. },
  5498. data: $.param(requestData)
  5499. });
  5500. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5501. logStatus.success();
  5502. return true;
  5503. }
  5504. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5505. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5506. logStatus.warning(i18n('changeAreaNotice'));
  5507. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5508. return false;
  5509. }
  5510. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5511. }
  5512. if (doTask === followed) {
  5513. logStatus.success();
  5514. if (doTask) {
  5515. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5516. }
  5517. return true;
  5518. }
  5519. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5520. return false;
  5521. } catch (error) {
  5522. throwError(error, 'Steam.toggleFollowGame');
  5523. return false;
  5524. }
  5525. }
  5526. async function _isFollowedGame2(gameId) {
  5527. try {
  5528. const {
  5529. result,
  5530. data
  5531. } = await tools_httpRequest({
  5532. url: `https://store.steampowered.com/app/${gameId}`,
  5533. method: 'GET'
  5534. });
  5535. if (result === 'Success') {
  5536. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5537. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5538. return 'areaLocked';
  5539. }
  5540. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5541. return true;
  5542. }
  5543. return false;
  5544. }
  5545. return false;
  5546. }
  5547. return false;
  5548. } catch (error) {
  5549. throwError(error, 'Steam.isFollowedGame');
  5550. return false;
  5551. }
  5552. }
  5553. async function _toggleForum2(gameId) {
  5554. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5555. try {
  5556. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5557. scripts_echoLog({
  5558. type: 'whiteList',
  5559. text: 'Steam.unsubscribeForum',
  5560. id: gameId
  5561. });
  5562. return true;
  5563. }
  5564. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5565. if (!forumId) {
  5566. return false;
  5567. }
  5568. const logStatus = scripts_echoLog({
  5569. type: `${doTask ? '' : 'un'}subscribingForum`,
  5570. text: gameId
  5571. });
  5572. const [ id, feature ] = forumId.split('_');
  5573. const {
  5574. result,
  5575. statusText,
  5576. status,
  5577. data
  5578. } = await tools_httpRequest({
  5579. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5580. method: 'POST',
  5581. responseType: 'json',
  5582. headers: {
  5583. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5584. },
  5585. data: $.param({
  5586. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5587. })
  5588. });
  5589. if (result === 'Success') {
  5590. var _data$response3, _data$response4;
  5591. 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)) {
  5592. if (doTask) {
  5593. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5594. }
  5595. logStatus.success();
  5596. return true;
  5597. }
  5598. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5599. return true;
  5600. }
  5601. logStatus.error(`${result}:${statusText}(${status})`);
  5602. return true;
  5603. } catch (error) {
  5604. throwError(error, 'Steam.toggleForum');
  5605. return true;
  5606. }
  5607. }
  5608. async function _getForumId2(gameId) {
  5609. try {
  5610. const logStatus = scripts_echoLog({
  5611. type: 'gettingForumId',
  5612. text: gameId
  5613. });
  5614. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5615. if (forumId) {
  5616. logStatus.success();
  5617. return forumId;
  5618. }
  5619. const {
  5620. result,
  5621. statusText,
  5622. status,
  5623. data
  5624. } = await tools_httpRequest({
  5625. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5626. method: 'GET'
  5627. });
  5628. if (result === 'Success') {
  5629. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5630. var _data$responseText, _data$responseText$ma8;
  5631. 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];
  5632. if (forumId) {
  5633. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5634. logStatus.success();
  5635. return forumId;
  5636. }
  5637. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5638. return false;
  5639. }
  5640. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5641. return false;
  5642. }
  5643. logStatus.error(`${result}:${statusText}(${status})`);
  5644. return false;
  5645. } catch (error) {
  5646. throwError(error, 'Steam.getForumId');
  5647. return false;
  5648. }
  5649. }
  5650. async function _toggleFavoriteWorkshop2(id) {
  5651. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5652. try {
  5653. if (!doTask && this.whiteList.workshops.includes(id)) {
  5654. scripts_echoLog({
  5655. type: 'whiteList',
  5656. text: 'Steam.unfavoriteWorkshop',
  5657. id: id
  5658. });
  5659. return true;
  5660. }
  5661. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5662. if (!appid) {
  5663. return false;
  5664. }
  5665. const logStatus = scripts_echoLog({
  5666. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5667. text: id
  5668. });
  5669. const {
  5670. result,
  5671. statusText,
  5672. status,
  5673. data
  5674. } = await tools_httpRequest({
  5675. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5676. method: 'POST',
  5677. headers: {
  5678. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5679. },
  5680. data: $.param({
  5681. id: id,
  5682. appid: appid,
  5683. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5684. })
  5685. });
  5686. if (result === 'Success') {
  5687. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5688. if (doTask) {
  5689. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5690. }
  5691. logStatus.success();
  5692. return true;
  5693. }
  5694. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5695. return false;
  5696. }
  5697. logStatus.error(`${result}:${statusText}(${status})`);
  5698. return false;
  5699. } catch (error) {
  5700. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5701. return false;
  5702. }
  5703. }
  5704. async function _getWorkshopAppId2(id) {
  5705. try {
  5706. const logStatus = scripts_echoLog({
  5707. type: 'gettingWorkshopAppId',
  5708. text: id
  5709. });
  5710. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5711. if (appId) {
  5712. logStatus.success();
  5713. return appId;
  5714. }
  5715. const {
  5716. result,
  5717. statusText,
  5718. status,
  5719. data
  5720. } = await tools_httpRequest({
  5721. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5722. method: 'GET'
  5723. });
  5724. if (result === 'Success') {
  5725. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5726. var _data$responseText$ma9;
  5727. 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];
  5728. if (appId) {
  5729. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5730. logStatus.success();
  5731. return appId;
  5732. }
  5733. logStatus.error('Error: getWorkshopAppId failed');
  5734. return false;
  5735. }
  5736. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5737. return false;
  5738. }
  5739. logStatus.error(`${result}:${statusText}(${status})`);
  5740. return false;
  5741. } catch (error) {
  5742. throwError(error, 'Steam.getWorkshopAppId');
  5743. return false;
  5744. }
  5745. }
  5746. async function _voteUpWorkshop2(id) {
  5747. try {
  5748. const logStatus = scripts_echoLog({
  5749. type: 'votingUpWorkshop',
  5750. text: id
  5751. });
  5752. const {
  5753. result,
  5754. statusText,
  5755. status,
  5756. data
  5757. } = await tools_httpRequest({
  5758. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5759. method: 'POST',
  5760. responseType: 'json',
  5761. headers: {
  5762. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5763. },
  5764. data: $.param({
  5765. id: id,
  5766. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5767. })
  5768. });
  5769. if (result === 'Success') {
  5770. var _data$response5;
  5771. 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) {
  5772. logStatus.success();
  5773. return true;
  5774. }
  5775. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5776. return true;
  5777. }
  5778. logStatus.error(`${result}:${statusText}(${status})`);
  5779. return true;
  5780. } catch (error) {
  5781. throwError(error, 'Steam.voteupWorkshop');
  5782. return true;
  5783. }
  5784. }
  5785. async function _toggleCurator2(curatorId) {
  5786. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5787. try {
  5788. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5789. scripts_echoLog({
  5790. type: 'whiteList',
  5791. text: 'Steam.unfollowCurator',
  5792. id: curatorId
  5793. });
  5794. return true;
  5795. }
  5796. const logStatus = scripts_echoLog({
  5797. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5798. text: curatorId
  5799. });
  5800. const {
  5801. result,
  5802. statusText,
  5803. status,
  5804. data
  5805. } = await tools_httpRequest({
  5806. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5807. method: 'POST',
  5808. headers: {
  5809. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5810. },
  5811. data: $.param({
  5812. clanid: curatorId,
  5813. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5814. follow: doTask
  5815. }),
  5816. dataType: 'json'
  5817. });
  5818. if (result === 'Success') {
  5819. var _data$response6, _data$response6$succe, _data$response7;
  5820. 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) {
  5821. logStatus.success();
  5822. return true;
  5823. }
  5824. 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})`);
  5825. return false;
  5826. }
  5827. logStatus.error(`${result}:${statusText}(${status})`);
  5828. return false;
  5829. } catch (error) {
  5830. throwError(error, 'Steam.toggleCurator');
  5831. return false;
  5832. }
  5833. }
  5834. async function _toggleCuratorLike2(link) {
  5835. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5836. try {
  5837. const [ path, name ] = link.split('/');
  5838. if (!(path && name)) {
  5839. scripts_echoLog({
  5840. text: i18n('errorLink', link)
  5841. });
  5842. return false;
  5843. }
  5844. const curatorId = await this.getCuratorId(path, name);
  5845. if (curatorId) {
  5846. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5847. }
  5848. return false;
  5849. } catch (error) {
  5850. throwError(error, 'Steam.toggleCuratorLike');
  5851. return false;
  5852. }
  5853. }
  5854. async function _getAnnouncementParams2(appId, viewId) {
  5855. try {
  5856. const logStatus = scripts_echoLog({
  5857. type: 'gettingAnnouncementParams',
  5858. text: appId,
  5859. id: viewId
  5860. });
  5861. const {
  5862. result,
  5863. statusText,
  5864. status,
  5865. data
  5866. } = await tools_httpRequest({
  5867. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5868. method: 'GET',
  5869. headers: {
  5870. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5871. }
  5872. });
  5873. if (result === 'Success') {
  5874. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5875. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5876. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5877. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5878. 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];
  5879. if (authWgToken && clanId) {
  5880. logStatus.success();
  5881. return {
  5882. authWgToken: authWgToken,
  5883. clanId: clanId,
  5884. gid: gid
  5885. };
  5886. }
  5887. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5888. return {};
  5889. }
  5890. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5891. return {};
  5892. }
  5893. logStatus.error(`${result}:${statusText}(${status})`);
  5894. return {};
  5895. } catch (error) {
  5896. throwError(error, 'Steam.likeAnnouncement');
  5897. return {};
  5898. }
  5899. }
  5900. async function _likeAnnouncement2(id) {
  5901. try {
  5902. const [ appId, viewId ] = id.split('/');
  5903. if (!(appId && viewId)) {
  5904. scripts_echoLog({
  5905. type: 'lost params',
  5906. text: id
  5907. });
  5908. return false;
  5909. }
  5910. const {
  5911. authWgToken,
  5912. clanId,
  5913. gid
  5914. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5915. if (!(authWgToken && clanId)) {
  5916. return false;
  5917. }
  5918. const logStatus = scripts_echoLog({
  5919. type: 'likingAnnouncement',
  5920. text: appId,
  5921. id: viewId
  5922. });
  5923. const {
  5924. result,
  5925. statusText,
  5926. status,
  5927. data
  5928. } = await tools_httpRequest({
  5929. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5930. method: 'POST',
  5931. headers: {
  5932. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5933. Host: 'store.steampowered.com',
  5934. Origin: 'https://store.steampowered.com',
  5935. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5936. },
  5937. data: $.param({
  5938. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5939. wgauthtoken: authWgToken,
  5940. voteup: 1,
  5941. clanid: clanId,
  5942. ajax: 1
  5943. }),
  5944. dataType: 'json'
  5945. });
  5946. if (result === 'Success') {
  5947. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5948. logStatus.success();
  5949. return true;
  5950. }
  5951. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5952. return false;
  5953. }
  5954. logStatus.error(`${result}:${statusText}(${status})`);
  5955. return false;
  5956. } catch (error) {
  5957. throwError(error, 'Steam.likeAnnouncement');
  5958. return false;
  5959. }
  5960. }
  5961. function Steam_setCache2(type, name, id) {
  5962. try {
  5963. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  5964. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  5965. } catch (error) {
  5966. throwError(error, 'Steam.setCache');
  5967. }
  5968. }
  5969. const social_Steam = Steam;
  5970. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  5971. Website_checkPrivateRedeclaration(obj, privateSet);
  5972. privateSet.add(obj);
  5973. }
  5974. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  5975. if (privateCollection.has(obj)) {
  5976. throw new TypeError('Cannot initialize the same private elements twice on an object');
  5977. }
  5978. }
  5979. function Website_defineProperty(obj, key, value) {
  5980. if (key in obj) {
  5981. Object.defineProperty(obj, key, {
  5982. value: value,
  5983. enumerable: true,
  5984. configurable: true,
  5985. writable: true
  5986. });
  5987. } else {
  5988. obj[key] = value;
  5989. }
  5990. return obj;
  5991. }
  5992. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  5993. if (!privateSet.has(receiver)) {
  5994. throw new TypeError('attempted to get private field on non-instance');
  5995. }
  5996. return fn;
  5997. }
  5998. var _bind = new WeakSet();
  5999. class Website {
  6000. constructor() {
  6001. Website_classPrivateMethodInitSpec(this, _bind);
  6002. Website_defineProperty(this, 'undoneTasks', void 0);
  6003. Website_defineProperty(this, 'socialTasks', void 0);
  6004. Website_defineProperty(this, 'giveawayId', void 0);
  6005. Website_defineProperty(this, 'socialInitialized', {
  6006. discord: false,
  6007. instagram: false,
  6008. reddit: false,
  6009. twitch: false,
  6010. twitter: false,
  6011. vk: false,
  6012. youtube: false,
  6013. steam: false
  6014. });
  6015. Website_defineProperty(this, 'initialized', false);
  6016. Website_defineProperty(this, 'social', {});
  6017. }
  6018. async initSocial(action) {
  6019. try {
  6020. const pro = [];
  6021. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6022. if (tasks.discord) {
  6023. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6024. if (hasDiscord && !this.socialInitialized.discord) {
  6025. this.social.discord = new social_Discord();
  6026. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6027. }
  6028. }
  6029. if (tasks.instagram) {
  6030. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6031. if (hasInstagram && !this.socialInitialized.instagram) {
  6032. this.social.instagram = new social_Instagram();
  6033. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6034. }
  6035. }
  6036. if (tasks.reddit) {
  6037. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6038. if (hasReddit && !this.socialInitialized.reddit) {
  6039. this.social.reddit = new social_Reddit();
  6040. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6041. }
  6042. }
  6043. if (tasks.twitch) {
  6044. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6045. if (hasTwitch && !this.socialInitialized.twitch) {
  6046. this.social.twitch = new social_Twitch();
  6047. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6048. }
  6049. }
  6050. if (tasks.twitter) {
  6051. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6052. if (hasTwitter && !this.socialInitialized.twitter) {
  6053. this.social.twitter = new social_Twitter();
  6054. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6055. }
  6056. }
  6057. if (tasks.vk) {
  6058. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6059. if (hasVk && !this.socialInitialized.vk) {
  6060. this.social.vk = new social_Vk();
  6061. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6062. }
  6063. }
  6064. if (tasks.youtube) {
  6065. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6066. if (hasYoutube && !this.socialInitialized.youtube) {
  6067. this.social.youtube = new Youtube();
  6068. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6069. }
  6070. }
  6071. if (tasks.steam) {
  6072. const hasSteam = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6073. if (hasSteam && !this.socialInitialized.steam) {
  6074. this.social.steam = new social_Steam();
  6075. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steam', this.social.steam.init()));
  6076. }
  6077. }
  6078. if (tasks.links && tasks.links.length > 0) {
  6079. this.social.visitLink = visitLink;
  6080. }
  6081. return await Promise.all(pro).then(result => {
  6082. let checked = true;
  6083. for (const data of result) {
  6084. if (data.result) {
  6085. this.socialInitialized[data.name] = data.result;
  6086. } else {
  6087. checked = false;
  6088. }
  6089. }
  6090. return checked;
  6091. });
  6092. } catch (error) {
  6093. throwError(error, 'Website.initSocial');
  6094. return false;
  6095. }
  6096. }
  6097. uniqueTasks(allTasks) {
  6098. const result = {};
  6099. for (const [ social, types ] of Object.entries(allTasks)) {
  6100. result[social] = {};
  6101. for (const [ type, tasks ] of Object.entries(types)) {
  6102. result[social][type] = unique(tasks);
  6103. }
  6104. }
  6105. return result;
  6106. }
  6107. async toggleTask(action) {
  6108. try {
  6109. if (!this.initialized && !this.init()) {
  6110. return false;
  6111. }
  6112. if (!await this.classifyTask(action)) {
  6113. return false;
  6114. }
  6115. if (!await this.initSocial(action)) {
  6116. return false;
  6117. }
  6118. const pro = [];
  6119. const doTask = action === 'do';
  6120. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6121. if (this.social.discord) {
  6122. pro.push(this.social.discord.toggle({
  6123. doTask: doTask,
  6124. ...tasks.discord
  6125. }));
  6126. }
  6127. if (this.social.instagram) {
  6128. pro.push(this.social.instagram.toggle({
  6129. doTask: doTask,
  6130. ...tasks.instagram
  6131. }));
  6132. }
  6133. if (this.social.reddit) {
  6134. pro.push(this.social.reddit.toggle({
  6135. doTask: doTask,
  6136. ...tasks.reddit
  6137. }));
  6138. }
  6139. if (this.social.twitch) {
  6140. pro.push(this.social.twitch.toggle({
  6141. doTask: doTask,
  6142. ...tasks.twitch
  6143. }));
  6144. }
  6145. if (this.social.twitter) {
  6146. pro.push(this.social.twitter.toggle({
  6147. doTask: doTask,
  6148. ...tasks.twitter
  6149. }));
  6150. }
  6151. if (this.social.vk) {
  6152. pro.push(this.social.vk.toggle({
  6153. doTask: doTask,
  6154. ...tasks.vk
  6155. }));
  6156. }
  6157. if (this.social.youtube) {
  6158. pro.push(this.social.youtube.toggle({
  6159. doTask: doTask,
  6160. ...tasks.youtube
  6161. }));
  6162. }
  6163. if (this.social.steam) {
  6164. pro.push(this.social.steam.toggle({
  6165. doTask: doTask,
  6166. ...tasks.steam
  6167. }));
  6168. }
  6169. if (this.social.visitLink && tasks.links && doTask) {
  6170. for (const link of tasks.links) {
  6171. pro.push(this.social.visitLink(link));
  6172. }
  6173. }
  6174. if (doTask && tasks.extra && this.extraDoTask) {
  6175. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6176. if (hasExtra) {
  6177. pro.push(this.extraDoTask(tasks.extra));
  6178. }
  6179. }
  6180. await Promise.all(pro);
  6181. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6182. return true;
  6183. } catch (error) {
  6184. throwError(error, 'Website.toggleTask');
  6185. return false;
  6186. }
  6187. }
  6188. async doTask() {
  6189. try {
  6190. return await this.toggleTask('do');
  6191. } catch (error) {
  6192. throwError(error, 'Website.doTask');
  6193. return false;
  6194. }
  6195. }
  6196. async undoTask() {
  6197. try {
  6198. return await this.toggleTask('undo');
  6199. } catch (error) {
  6200. throwError(error, 'Website.undoTask');
  6201. return false;
  6202. }
  6203. }
  6204. }
  6205. async function _bind2(name, init) {
  6206. try {
  6207. return {
  6208. name: name,
  6209. result: await init
  6210. };
  6211. } catch (error) {
  6212. throwError(error, 'Website.bind');
  6213. return {
  6214. name: name,
  6215. result: false
  6216. };
  6217. }
  6218. }
  6219. const website_Website = Website;
  6220. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6221. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6222. privateSet.add(obj);
  6223. }
  6224. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6225. if (privateCollection.has(obj)) {
  6226. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6227. }
  6228. }
  6229. function FreeAnyWhere_defineProperty(obj, key, value) {
  6230. if (key in obj) {
  6231. Object.defineProperty(obj, key, {
  6232. value: value,
  6233. enumerable: true,
  6234. configurable: true,
  6235. writable: true
  6236. });
  6237. } else {
  6238. obj[key] = value;
  6239. }
  6240. return obj;
  6241. }
  6242. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6243. if (!privateSet.has(receiver)) {
  6244. throw new TypeError('attempted to get private field on non-instance');
  6245. }
  6246. return fn;
  6247. }
  6248. const FreeAnyWhere_defaultTasks = {
  6249. steam: {
  6250. groupLinks: [],
  6251. wishlistLinks: [],
  6252. curatorLinks: [],
  6253. followLinks: []
  6254. },
  6255. vk: {
  6256. nameLinks: []
  6257. }
  6258. };
  6259. var _getGiveawayId = new WeakSet();
  6260. var _verify = new WeakSet();
  6261. class FreeAnyWhere extends website_Website {
  6262. constructor() {
  6263. super(...arguments);
  6264. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6265. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6266. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6267. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6268. FreeAnyWhere_defineProperty(this, 'socialTasks', {
  6269. ...FreeAnyWhere_defaultTasks
  6270. });
  6271. FreeAnyWhere_defineProperty(this, 'undoneTasks', {
  6272. ...FreeAnyWhere_defaultTasks
  6273. });
  6274. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6275. }
  6276. static test() {
  6277. return window.location.host === 'freeanywhere.net';
  6278. }
  6279. init() {
  6280. try {
  6281. const logStatus = scripts_echoLog({
  6282. text: i18n('initing')
  6283. });
  6284. if ($('a[href="#/login"]').length > 0) {
  6285. window.open('/#/login', '_self');
  6286. logStatus.warning(i18n('needLogin'));
  6287. return false;
  6288. }
  6289. if (window.location.href.includes('/login')) {
  6290. logStatus.warning(i18n('needLogin'));
  6291. return false;
  6292. }
  6293. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6294. var _window$location$href;
  6295. 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];
  6296. if (!id) {
  6297. logStatus.error(i18n('getFailed', 'Id'));
  6298. return false;
  6299. }
  6300. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6301. }
  6302. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6303. return false;
  6304. }
  6305. this.initialized = true;
  6306. logStatus.success();
  6307. return true;
  6308. } catch (error) {
  6309. throwError(error, 'Freeanywhere.init');
  6310. return false;
  6311. }
  6312. }
  6313. async classifyTask(action) {
  6314. try {
  6315. const logStatus = scripts_echoLog({
  6316. text: i18n('getTasksInfo')
  6317. });
  6318. if (action === 'undo') {
  6319. var _GM_getValue;
  6320. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  6321. ...FreeAnyWhere_defaultTasks
  6322. };
  6323. }
  6324. const {
  6325. result,
  6326. statusText,
  6327. status,
  6328. data
  6329. } = await tools_httpRequest({
  6330. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6331. method: 'GET',
  6332. headers: {
  6333. authorization: `Token ${window.localStorage.getItem('token')}`,
  6334. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6335. },
  6336. responseType: 'json'
  6337. });
  6338. if (result === 'Success') {
  6339. var _data$response;
  6340. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6341. if (tasks) {
  6342. if (action === 'verify') {
  6343. this.tasks = [];
  6344. }
  6345. for (const task of tasks) {
  6346. const type = task.challenge;
  6347. const social = task.challenge_provider;
  6348. const taskInfo = {
  6349. id: task.id,
  6350. title: task.title
  6351. };
  6352. if (action === 'verify' && !task.is_success) {
  6353. this.tasks.push(taskInfo);
  6354. continue;
  6355. }
  6356. switch (social) {
  6357. case 'steam':
  6358. taskInfo.social = 'steam';
  6359. switch (type) {
  6360. case 'WL':
  6361. if (action === 'undo') {
  6362. this.socialTasks.steam.wishlistLinks.push(task.link);
  6363. }
  6364. if (action === 'do' && !task.is_success) {
  6365. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6366. }
  6367. break;
  6368.  
  6369. case 'JTG':
  6370. if (action === 'undo') {
  6371. this.socialTasks.steam.groupLinks.push(task.link);
  6372. }
  6373. if (action === 'do' && !task.is_success) {
  6374. this.undoneTasks.steam.groupLinks.push(task.link);
  6375. }
  6376. break;
  6377.  
  6378. case 'STC':
  6379. if (action === 'undo') {
  6380. this.socialTasks.steam.curatorLinks.push(task.link);
  6381. }
  6382. if (action === 'do' && !task.is_success) {
  6383. this.undoneTasks.steam.curatorLinks.push(task.link);
  6384. }
  6385. break;
  6386.  
  6387. case 'GF':
  6388. if (action === 'undo') {
  6389. this.socialTasks.steam.followLinks.push(task.link);
  6390. }
  6391. if (action === 'do' && !task.is_success) {
  6392. this.undoneTasks.steam.followLinks.push(task.link);
  6393. }
  6394. break;
  6395. }
  6396. break;
  6397.  
  6398. case 'vk-oauth2':
  6399. if (action === 'undo') {
  6400. this.socialTasks.vk.nameLinks.push(task.link);
  6401. }
  6402. if (action === 'do' && !task.is_success) {
  6403. this.undoneTasks.vk.nameLinks.push(task.link);
  6404. }
  6405. break;
  6406.  
  6407. case 'website':
  6408. break;
  6409.  
  6410. default:
  6411. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6412. break;
  6413. }
  6414. }
  6415. logStatus.success();
  6416. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6417. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6418. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6419. tasks: this.socialTasks,
  6420. time: new Date().getTime()
  6421. });
  6422. return true;
  6423. }
  6424. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6425. console.error(data);
  6426. return false;
  6427. }
  6428. logStatus.error(`${result}:${statusText}(${status})`);
  6429. return false;
  6430. } catch (error) {
  6431. throwError(error, 'Freeanywhere.classifyTask');
  6432. return false;
  6433. }
  6434. }
  6435. async verifyTask() {
  6436. try {
  6437. if (!this.initialized && !this.init()) {
  6438. return false;
  6439. }
  6440. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6441. return false;
  6442. }
  6443. const pro = [];
  6444. for (const task of this.tasks) {
  6445. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6446. await delay(1e3);
  6447. }
  6448. await Promise.all(pro);
  6449. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6450. return !!await this.getKey(true);
  6451. } catch (error) {
  6452. throwError(error, 'Freeanywhere.verifyTask');
  6453. return false;
  6454. }
  6455. }
  6456. async getKey(initialized) {
  6457. try {
  6458. if (!initialized && !this.initialized && !this.init()) {
  6459. return false;
  6460. }
  6461. const logStatus = scripts_echoLog({
  6462. text: i18n('gettingKey')
  6463. });
  6464. const {
  6465. result,
  6466. statusText,
  6467. status,
  6468. data
  6469. } = await tools_httpRequest({
  6470. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6471. method: 'GET',
  6472. dataType: 'json',
  6473. headers: {
  6474. authorization: `Token ${window.localStorage.getItem('token')}`
  6475. }
  6476. });
  6477. if (result === 'Success') {
  6478. var _data$response2;
  6479. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6480. logStatus.success();
  6481. scripts_echoLog({}).success(data.response.reward);
  6482. return data.response.reward;
  6483. }
  6484. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6485. return false;
  6486. }
  6487. logStatus.error(`${result}:${statusText}(${status})`);
  6488. return false;
  6489. } catch (error) {
  6490. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6491. return false;
  6492. }
  6493. }
  6494. }
  6495. function _getGiveawayId2() {
  6496. try {
  6497. var _window$location$href2;
  6498. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6499. if (giveawayId) {
  6500. this.giveawayId = giveawayId;
  6501. return true;
  6502. }
  6503. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6504. return false;
  6505. } catch (error) {
  6506. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6507. }
  6508. }
  6509. async function _verify2(task) {
  6510. try {
  6511. const logStatus = scripts_echoLog({
  6512. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6513. });
  6514. const {
  6515. result,
  6516. statusText,
  6517. status,
  6518. data
  6519. } = await tools_httpRequest({
  6520. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6521. method: 'GET',
  6522. dataType: 'json',
  6523. headers: {
  6524. authorization: `Token ${window.localStorage.getItem('token')}`,
  6525. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6526. }
  6527. });
  6528. if (result === 'Success') {
  6529. var _data$response3;
  6530. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6531. logStatus.success();
  6532. return true;
  6533. }
  6534. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6535. return false;
  6536. }
  6537. logStatus.error(`${result}:${statusText}(${status})`);
  6538. return false;
  6539. } catch (error) {
  6540. throwError(error, 'Freeanywhere.verify');
  6541. return false;
  6542. }
  6543. }
  6544. const website_FreeAnyWhere = FreeAnyWhere;
  6545. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6546. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6547. privateSet.add(obj);
  6548. }
  6549. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6550. if (privateCollection.has(obj)) {
  6551. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6552. }
  6553. }
  6554. function GiveawaySu_defineProperty(obj, key, value) {
  6555. if (key in obj) {
  6556. Object.defineProperty(obj, key, {
  6557. value: value,
  6558. enumerable: true,
  6559. configurable: true,
  6560. writable: true
  6561. });
  6562. } else {
  6563. obj[key] = value;
  6564. }
  6565. return obj;
  6566. }
  6567. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6568. if (!privateSet.has(receiver)) {
  6569. throw new TypeError('attempted to get private field on non-instance');
  6570. }
  6571. return fn;
  6572. }
  6573. const GiveawaySu_defaultTasks = {
  6574. steam: {
  6575. groupLinks: [],
  6576. wishlistLinks: [],
  6577. curatorLinks: [],
  6578. curatorLikeLinks: [],
  6579. followLinks: [],
  6580. forumLinks: [],
  6581. announcementLinks: [],
  6582. workshopVoteLinks: []
  6583. },
  6584. discord: {
  6585. serverLinks: []
  6586. },
  6587. instagram: {
  6588. userLinks: []
  6589. },
  6590. vk: {
  6591. nameLinks: []
  6592. },
  6593. twitch: {
  6594. channelLinks: []
  6595. },
  6596. reddit: {
  6597. redditLinks: []
  6598. },
  6599. youtube: {
  6600. channelLinks: [],
  6601. likeLinks: []
  6602. }
  6603. };
  6604. var _checkLogin = new WeakSet();
  6605. var _checkLeftKey = new WeakSet();
  6606. var GiveawaySu_getGiveawayId = new WeakSet();
  6607. class GiveawaySu extends website_Website {
  6608. constructor() {
  6609. super(...arguments);
  6610. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6611. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6612. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6613. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6614. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6615. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6616. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6617. }
  6618. static test() {
  6619. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6620. }
  6621. async after() {
  6622. try {
  6623. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6624. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6625. }
  6626. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6627. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6628. }
  6629. scripts_echoLog({}).warning(i18n('gsNotice'));
  6630. } catch (error) {
  6631. throwError(error, 'Giveawaysu.after');
  6632. }
  6633. }
  6634. init() {
  6635. try {
  6636. const logStatus = scripts_echoLog({
  6637. text: i18n('initing')
  6638. });
  6639. if ($('a.steam-login').length > 0) {
  6640. window.open('/steam/redirect', '_self');
  6641. logStatus.warning(i18n('needLogin'));
  6642. return false;
  6643. }
  6644. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6645. return false;
  6646. }
  6647. this.initialized = true;
  6648. logStatus.success();
  6649. return true;
  6650. } catch (error) {
  6651. throwError(error, 'Giveawaysu.init');
  6652. return false;
  6653. }
  6654. }
  6655. async classifyTask(action) {
  6656. try {
  6657. const logStatus = scripts_echoLog({
  6658. text: i18n('getTasksInfo')
  6659. });
  6660. if (action === 'undo') {
  6661. var _GM_getValue;
  6662. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6663. return true;
  6664. }
  6665. const pro = [];
  6666. const tasks = $('#actions tr');
  6667. if ($('div.bind-discord').is(':visible')) {
  6668. $('div.bind-discord a')[0].click();
  6669. }
  6670. if ($('div.bind-twitch').is(':visible')) {
  6671. $('div.bind-twitch a')[0].click();
  6672. }
  6673. for (const task of tasks) {
  6674. pro.push(new Promise(resolve => {
  6675. const td = $(task).find('td:not(".hidden")');
  6676. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6677. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6678. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6679. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6680. const taskName = taskDes.text().trim();
  6681. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6682. return resolve(true);
  6683. }
  6684. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6685. if (!taskLink) {
  6686. return resolve(false);
  6687. }
  6688. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6689. this.undoneTasks.steam.groupLinks.push(taskLink);
  6690. } else if (/like.*announcement/gi.test(taskName)) {
  6691. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6692. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6693. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6694. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6695. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6696. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6697. this.undoneTasks.steam.forumLinks.push(taskLink);
  6698. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6699. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6700. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6701. this.undoneTasks.discord.serverLinks.push(taskLink);
  6702. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6703. this.undoneTasks.instagram.userLinks.push(taskLink);
  6704. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6705. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6706. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6707. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6708. } else if (/watch.*art/gim.test(taskName)) {
  6709. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6710. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6711. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6712. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6713. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6714. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6715. this.undoneTasks.vk.nameLinks.push(taskLink);
  6716. } else {
  6717. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6718. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6719. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6720. }
  6721. if (/follow.*button/gim.test(taskName)) {
  6722. this.undoneTasks.steam.followLinks.push(taskLink);
  6723. }
  6724. }
  6725. }
  6726. resolve(true);
  6727. }).catch(error => {
  6728. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6729. return false;
  6730. });
  6731. }));
  6732. }
  6733. await Promise.all(pro);
  6734. logStatus.success();
  6735. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6736. this.socialTasks = this.undoneTasks;
  6737. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6738. tasks: this.socialTasks,
  6739. time: new Date().getTime()
  6740. });
  6741. return true;
  6742. } catch (error) {
  6743. throwError(error, 'Giveawaysu.classifyTask');
  6744. return false;
  6745. }
  6746. }
  6747. }
  6748. function _checkLogin2() {
  6749. try {
  6750. if (!globalOptions.other.checkLogin) {
  6751. return true;
  6752. }
  6753. if ($('a.steam-login').length > 0) {
  6754. window.open('/steam/redirect', '_self');
  6755. }
  6756. return true;
  6757. } catch (error) {
  6758. throwError(error, 'Giveawaysu.checkLogin');
  6759. return false;
  6760. }
  6761. }
  6762. async function _checkLeftKey2() {
  6763. try {
  6764. if (!globalOptions.other.checkLeftKey) {
  6765. return true;
  6766. }
  6767. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  6768. await external_Swal_default().fire({
  6769. icon: 'warning',
  6770. title: i18n('notice'),
  6771. text: i18n('noKeysLeft'),
  6772. confirmButtonText: i18n('confirm'),
  6773. cancelButtonText: i18n('cancel'),
  6774. showCancelButton: true
  6775. }).then(_ref => {
  6776. let {
  6777. value
  6778. } = _ref;
  6779. if (value) {
  6780. window.close();
  6781. }
  6782. });
  6783. }
  6784. return true;
  6785. } catch (error) {
  6786. throwError(error, 'Giveawaysu.checkLeftKey');
  6787. return false;
  6788. }
  6789. }
  6790. function GiveawaySu_getGiveawayId2() {
  6791. var _window$location$href;
  6792. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6793. if (giveawayId) {
  6794. this.giveawayId = giveawayId;
  6795. return true;
  6796. }
  6797. scripts_echoLog({
  6798. text: i18n('getFailed', 'GiveawayId')
  6799. });
  6800. return false;
  6801. }
  6802. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  6803. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  6804. privateSet.add(obj);
  6805. }
  6806. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  6807. if (privateCollection.has(obj)) {
  6808. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6809. }
  6810. }
  6811. function Indiedb_defineProperty(obj, key, value) {
  6812. if (key in obj) {
  6813. Object.defineProperty(obj, key, {
  6814. value: value,
  6815. enumerable: true,
  6816. configurable: true,
  6817. writable: true
  6818. });
  6819. } else {
  6820. obj[key] = value;
  6821. }
  6822. return obj;
  6823. }
  6824. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  6825. if (!privateSet.has(receiver)) {
  6826. throw new TypeError('attempted to get private field on non-instance');
  6827. }
  6828. return fn;
  6829. }
  6830. var _join = new WeakSet();
  6831. var _do = new WeakSet();
  6832. var Indiedb_checkLogin = new WeakSet();
  6833. var Indiedb_checkLeftKey = new WeakSet();
  6834. class Indiedb {
  6835. constructor() {
  6836. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  6837. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  6838. Indiedb_classPrivateMethodInitSpec(this, _do);
  6839. Indiedb_classPrivateMethodInitSpec(this, _join);
  6840. Indiedb_defineProperty(this, 'name', 'Indiedb');
  6841. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  6842. }
  6843. static test() {
  6844. return window.location.host === 'www.indiedb.com';
  6845. }
  6846. async after() {
  6847. try {
  6848. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  6849. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6850. }
  6851. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  6852. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6853. }
  6854. } catch (error) {
  6855. throwError(error, 'Indiedb.after');
  6856. }
  6857. }
  6858. async doTask() {
  6859. try {
  6860. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  6861. return false;
  6862. }
  6863. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  6864. } catch (error) {
  6865. throwError(error, 'Indiedb.doTask');
  6866. return false;
  6867. }
  6868. }
  6869. }
  6870. async function _join2() {
  6871. try {
  6872. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  6873. scripts_echoLog({}).error(i18n('needLogin'));
  6874. return false;
  6875. }
  6876. const currentoption = $('a.buttonenter.buttongiveaway');
  6877. if (/join giveaway/gim.test(currentoption.text())) {
  6878. const logStatus = scripts_echoLog({
  6879. text: `${i18n('joiningGiveaway')}...`
  6880. });
  6881. const {
  6882. result,
  6883. statusText,
  6884. status,
  6885. data
  6886. } = await tools_httpRequest({
  6887. url: currentoption.attr('href'),
  6888. method: 'POST',
  6889. data: 'ajax=t',
  6890. dataType: 'json',
  6891. headers: {
  6892. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6893. accept: 'application/json, text/javascript, */*; q=0.01',
  6894. origin: window.location.origin
  6895. }
  6896. });
  6897. if (result === 'Success') {
  6898. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6899. var _data$response, _data$response4, _data$response5;
  6900. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  6901. var _data$response2, _data$response3;
  6902. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  6903. $('#giveawaysjoined').slideDown();
  6904. $('#giveawaysrecommend').slideDown();
  6905. 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}` : ''}`);
  6906. return true;
  6907. }
  6908. 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}` : ''}`);
  6909. return false;
  6910. }
  6911. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6912. return false;
  6913. }
  6914. logStatus.error(`${result}:${statusText}(${status})`);
  6915. return false;
  6916. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  6917. return true;
  6918. }
  6919. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  6920. return false;
  6921. } catch (error) {
  6922. throwError(error, 'Indiedb.init');
  6923. return false;
  6924. }
  6925. }
  6926. async function _do2() {
  6927. try {
  6928. const id = $('script').map((index, script) => {
  6929. if (/\$\(document\)/gim.test(script.innerHTML)) {
  6930. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  6931. 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] ];
  6932. }
  6933. return null;
  6934. });
  6935. if (id.length === 2) {
  6936. const pro = [];
  6937. const tasks = $('#giveawaysjoined a[class*=promo]');
  6938. for (const task of tasks) {
  6939. const promo = $(task);
  6940. if (!promo.hasClass('buttonentered')) {
  6941. const status = scripts_echoLog({
  6942. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  6943. });
  6944. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  6945. let text = '';
  6946. if (promo.hasClass('facebookpromo')) {
  6947. text = 'facebookpromo';
  6948. } else if (promo.hasClass('twitterpromo')) {
  6949. text = 'twitterpromo';
  6950. } else {
  6951. text = 'visitpromo';
  6952. }
  6953. pro.push(new Promise(resolve => {
  6954. $.ajax({
  6955. type: 'POST',
  6956. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  6957. timeout: 6e4,
  6958. dataType: 'json',
  6959. data: {
  6960. ajax: 't'
  6961. },
  6962. error(response, error, exception) {
  6963. console.log({
  6964. response: response,
  6965. error: error,
  6966. exception: exception
  6967. });
  6968. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6969. resolve(true);
  6970. },
  6971. success(response) {
  6972. console.log(response);
  6973. if (response.success) {
  6974. status.success(`Success:${response.text}`);
  6975. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6976. resolve(true);
  6977. } else {
  6978. status.error(`Error:${response.text}`);
  6979. resolve(true);
  6980. }
  6981. }
  6982. });
  6983. }));
  6984. } else if (promo.hasClass('emailoptinpromo')) {
  6985. pro.push(new Promise(resolve => {
  6986. $.ajax({
  6987. type: 'POST',
  6988. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  6989. timeout: 6e4,
  6990. dataType: 'json',
  6991. data: {
  6992. ajax: 't',
  6993. emailsystoggle: 4
  6994. },
  6995. error(response, error, exception) {
  6996. console.log({
  6997. response: response,
  6998. error: error,
  6999. exception: exception
  7000. });
  7001. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7002. resolve(true);
  7003. },
  7004. success(response) {
  7005. console.log(response);
  7006. if (response.success) {
  7007. status.success(`Success:${response.text}`);
  7008. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7009. resolve(true);
  7010. } else {
  7011. status.error(`Error:${response.text}`);
  7012. resolve(true);
  7013. }
  7014. }
  7015. });
  7016. }));
  7017. } else if (promo.hasClass('watchingpromo')) {
  7018. pro.push(new Promise(resolve => {
  7019. var _promo$attr;
  7020. const data = getUrlQuery(promo.attr('href'));
  7021. data.ajax = 't';
  7022. $.ajax({
  7023. type: 'POST',
  7024. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7025. timeout: 6e4,
  7026. dataType: 'json',
  7027. data: data,
  7028. error(response, error, exception) {
  7029. console.log({
  7030. response: response,
  7031. error: error,
  7032. exception: exception
  7033. });
  7034. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7035. resolve(true);
  7036. },
  7037. success(response) {
  7038. console.log(response);
  7039. if (response.success) {
  7040. status.success(`Success:${response.text}`);
  7041. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7042. resolve(true);
  7043. } else {
  7044. status.error(`Error:${response.text}`);
  7045. resolve(true);
  7046. }
  7047. }
  7048. });
  7049. }));
  7050. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7051. pro.push(new Promise(resolve => {
  7052. $.ajax({
  7053. type: 'POST',
  7054. url: urlPath(promo.attr('href')),
  7055. timeout: 6e4,
  7056. dataType: 'json',
  7057. data: {
  7058. ajax: 't'
  7059. },
  7060. error(response, error, exception) {
  7061. console.log({
  7062. response: response,
  7063. error: error,
  7064. exception: exception
  7065. });
  7066. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7067. resolve(true);
  7068. },
  7069. success(response) {
  7070. console.log(response);
  7071. if (response.success) {
  7072. status.success(`Success:${response.text}`);
  7073. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7074. resolve(true);
  7075. } else {
  7076. status.error(`Error:${response.text}`);
  7077. resolve(true);
  7078. }
  7079. }
  7080. });
  7081. }));
  7082. } else {
  7083. status.error(`Error:${i18n('unKnownTaskType')}`);
  7084. }
  7085. }
  7086. }
  7087. await Promise.all(pro);
  7088. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7089. return true;
  7090. }
  7091. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7092. return false;
  7093. } catch (error) {
  7094. throwError(error, 'Indiedb.classifyTask');
  7095. return false;
  7096. }
  7097. }
  7098. function Indiedb_checkLogin2() {
  7099. try {
  7100. if (!globalOptions.other.checkLogin) {
  7101. return true;
  7102. }
  7103. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7104. window.open('/members/login', '_self');
  7105. }
  7106. return true;
  7107. } catch (error) {
  7108. throwError(error, 'Indiedb.checkLogin');
  7109. return false;
  7110. }
  7111. }
  7112. async function Indiedb_checkLeftKey2() {
  7113. try {
  7114. if (!globalOptions.other.checkLeftKey) {
  7115. return true;
  7116. }
  7117. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7118. await external_Swal_default().fire({
  7119. icon: 'warning',
  7120. title: i18n('notice'),
  7121. text: i18n('giveawayEnded'),
  7122. confirmButtonText: i18n('confirm'),
  7123. cancelButtonText: i18n('cancel'),
  7124. showCancelButton: true
  7125. }).then(_ref => {
  7126. let {
  7127. value
  7128. } = _ref;
  7129. if (value) {
  7130. window.close();
  7131. }
  7132. });
  7133. }
  7134. return true;
  7135. } catch (error) {
  7136. throwError(error, 'Indiedb.checkLeftKey');
  7137. return false;
  7138. }
  7139. }
  7140. const website_Indiedb = Indiedb;
  7141. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7142. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7143. privateSet.add(obj);
  7144. }
  7145. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7146. if (privateCollection.has(obj)) {
  7147. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7148. }
  7149. }
  7150. function Keyhub_defineProperty(obj, key, value) {
  7151. if (key in obj) {
  7152. Object.defineProperty(obj, key, {
  7153. value: value,
  7154. enumerable: true,
  7155. configurable: true,
  7156. writable: true
  7157. });
  7158. } else {
  7159. obj[key] = value;
  7160. }
  7161. return obj;
  7162. }
  7163. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7164. if (!privateSet.has(receiver)) {
  7165. throw new TypeError('attempted to get private field on non-instance');
  7166. }
  7167. return fn;
  7168. }
  7169. const Keyhub_defaultTasks = {
  7170. steam: {
  7171. groupLinks: [],
  7172. wishlistLinks: [],
  7173. curatorLinks: []
  7174. },
  7175. discord: {
  7176. serverLinks: []
  7177. },
  7178. links: []
  7179. };
  7180. var Keyhub_getGiveawayId = new WeakSet();
  7181. var Keyhub_checkLeftKey = new WeakSet();
  7182. var Keyhub_checkLogin = new WeakSet();
  7183. class Keyhub extends website_Website {
  7184. constructor() {
  7185. super(...arguments);
  7186. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7187. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7188. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7189. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7190. Keyhub_defineProperty(this, 'socialTasks', {
  7191. ...Keyhub_defaultTasks
  7192. });
  7193. Keyhub_defineProperty(this, 'undoneTasks', {
  7194. ...Keyhub_defaultTasks
  7195. });
  7196. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7197. }
  7198. static test() {
  7199. return window.location.host === 'key-hub.eu';
  7200. }
  7201. async after() {
  7202. try {
  7203. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7204. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7205. }
  7206. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7207. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7208. }
  7209. } catch (error) {
  7210. throwError(error, 'Keyhub.after');
  7211. }
  7212. }
  7213. init() {
  7214. try {
  7215. const logStatus = scripts_echoLog({
  7216. text: i18n('initing')
  7217. });
  7218. if ($('a[href*="/connect/steam"]').length > 0) {
  7219. window.open('/connect/steam', '_self');
  7220. logStatus.warning(i18n('needLogin'));
  7221. return false;
  7222. }
  7223. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7224. return false;
  7225. }
  7226. $('#VPNoverlay').hide();
  7227. $('#mainArticleSection').show();
  7228. this.initialized = true;
  7229. logStatus.success();
  7230. return true;
  7231. } catch (error) {
  7232. throwError(error, 'Keyhub.init');
  7233. return false;
  7234. }
  7235. }
  7236. async classifyTask(action) {
  7237. try {
  7238. const logStatus = scripts_echoLog({
  7239. text: i18n('getTasksInfo')
  7240. });
  7241. if (action === 'undo') {
  7242. var _GM_getValue;
  7243. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  7244. ...Keyhub_defaultTasks
  7245. };
  7246. }
  7247. const tasks = $('.task a');
  7248. for (const task of tasks) {
  7249. let link = $(task).attr('href');
  7250. const taskDes = $(task).text().trim();
  7251. if (!link) {
  7252. continue;
  7253. }
  7254. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7255. link = await getRedirectLink(link) || link;
  7256. }
  7257. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7258. window.open(link, '_blank');
  7259. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7260. if (action === 'undo') {
  7261. this.socialTasks.steam.groupLinks.push(link);
  7262. }
  7263. if (action === 'do') {
  7264. this.undoneTasks.steam.groupLinks.push(link);
  7265. }
  7266. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7267. if (action === 'undo') {
  7268. this.socialTasks.steam.wishlistLinks.push(link);
  7269. }
  7270. if (action === 'do') {
  7271. this.undoneTasks.steam.wishlistLinks.push(link);
  7272. }
  7273. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7274. if (action === 'undo') {
  7275. this.socialTasks.steam.curatorLinks.push(link);
  7276. }
  7277. if (action === 'do') {
  7278. this.undoneTasks.steam.curatorLinks.push(link);
  7279. }
  7280. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7281. if (action === 'undo') {
  7282. this.socialTasks.discord.serverLinks.push(link);
  7283. }
  7284. if (action === 'do') {
  7285. this.undoneTasks.discord.serverLinks.push(link);
  7286. }
  7287. } else {
  7288. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7289. }
  7290. }
  7291. logStatus.success();
  7292. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7293. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7294. GM_setValue(`khTasks-${this.giveawayId}`, {
  7295. tasks: this.socialTasks,
  7296. time: new Date().getTime()
  7297. });
  7298. return true;
  7299. } catch (error) {
  7300. throwError(error, 'Keyhub.classifyTask');
  7301. return false;
  7302. }
  7303. }
  7304. verifyTask() {
  7305. try {
  7306. scripts_echoLog({
  7307. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7308. });
  7309. $.get(window.location.href, res => {
  7310. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7311. });
  7312. } catch (error) {
  7313. throwError(error, 'keyhub.verifyTask');
  7314. }
  7315. }
  7316. }
  7317. function Keyhub_getGiveawayId2() {
  7318. try {
  7319. var _window$location$href;
  7320. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7321. if (giveawayId) {
  7322. this.giveawayId = giveawayId;
  7323. return true;
  7324. }
  7325. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7326. return false;
  7327. } catch (error) {
  7328. throwError(error, 'Keyhub.getGiveawayId');
  7329. return false;
  7330. }
  7331. }
  7332. async function Keyhub_checkLeftKey2() {
  7333. try {
  7334. if (!globalOptions.other.checkLeftKey) {
  7335. return true;
  7336. }
  7337. const leftKey = $('#keysleft').text().trim();
  7338. if (leftKey === '0') {
  7339. await external_Swal_default().fire({
  7340. icon: 'warning',
  7341. title: i18n('notice'),
  7342. text: i18n('noKeysLeft'),
  7343. confirmButtonText: i18n('confirm'),
  7344. cancelButtonText: i18n('cancel'),
  7345. showCancelButton: true
  7346. }).then(_ref => {
  7347. let {
  7348. value
  7349. } = _ref;
  7350. if (value) {
  7351. window.close();
  7352. }
  7353. });
  7354. }
  7355. return true;
  7356. } catch (error) {
  7357. throwError(error, 'Keyhub.checkLeftKey');
  7358. return false;
  7359. }
  7360. }
  7361. function Keyhub_checkLogin2() {
  7362. try {
  7363. if (!globalOptions.other.checkLogin) {
  7364. return true;
  7365. }
  7366. if ($('a[href*="/connect/steam"]').length > 0) {
  7367. window.open('/connect/steam', '_self');
  7368. }
  7369. return true;
  7370. } catch (error) {
  7371. throwError(error, 'Keyhub.checkLogin');
  7372. return false;
  7373. }
  7374. }
  7375. const website_Keyhub = Keyhub;
  7376. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7377. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7378. privateSet.add(obj);
  7379. }
  7380. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7381. if (privateCollection.has(obj)) {
  7382. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7383. }
  7384. }
  7385. function Givekey_defineProperty(obj, key, value) {
  7386. if (key in obj) {
  7387. Object.defineProperty(obj, key, {
  7388. value: value,
  7389. enumerable: true,
  7390. configurable: true,
  7391. writable: true
  7392. });
  7393. } else {
  7394. obj[key] = value;
  7395. }
  7396. return obj;
  7397. }
  7398. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7399. if (!privateSet.has(receiver)) {
  7400. throw new TypeError('attempted to get private field on non-instance');
  7401. }
  7402. return fn;
  7403. }
  7404. const Givekey_defaultTasks = {
  7405. steam: {
  7406. groupLinks: [],
  7407. wishlistLinks: [],
  7408. curatorLinks: [],
  7409. curatorLikeLinks: []
  7410. },
  7411. twitter: {
  7412. userLinks: []
  7413. },
  7414. vk: {
  7415. nameLinks: []
  7416. },
  7417. discord: {
  7418. serverLinks: []
  7419. }
  7420. };
  7421. var Givekey_verify = new WeakSet();
  7422. var Givekey_getGiveawayId = new WeakSet();
  7423. var Givekey_checkLeftKey = new WeakSet();
  7424. class Givekey extends website_Website {
  7425. constructor() {
  7426. super(...arguments);
  7427. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7428. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7429. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7430. Givekey_defineProperty(this, 'name', 'Givekey');
  7431. Givekey_defineProperty(this, 'tasks', []);
  7432. Givekey_defineProperty(this, 'socialTasks', {
  7433. ...Givekey_defaultTasks
  7434. });
  7435. Givekey_defineProperty(this, 'undoneTasks', {
  7436. ...Givekey_defaultTasks
  7437. });
  7438. Givekey_defineProperty(this, 'userId', void 0);
  7439. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7440. }
  7441. static test() {
  7442. return window.location.host === 'givekey.ru';
  7443. }
  7444. async after() {
  7445. try {
  7446. await new Promise(resolve => {
  7447. const checker = setInterval(() => {
  7448. if ($('#navbarDropdown').length > 0) {
  7449. clearInterval(checker);
  7450. resolve(true);
  7451. }
  7452. });
  7453. });
  7454. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7455. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7456. }
  7457. } catch (error) {
  7458. throwError(error, 'Givekey.after');
  7459. return false;
  7460. }
  7461. }
  7462. init() {
  7463. try {
  7464. const logStatus = scripts_echoLog({
  7465. text: i18n('initing')
  7466. });
  7467. if ($('a[href*="/auth/steam"]').length > 0) {
  7468. window.open('/auth/steam', '_self');
  7469. logStatus.warning(i18n('needLogin'));
  7470. return false;
  7471. }
  7472. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7473. return false;
  7474. }
  7475. const userId = $('meta[name="user-id"]').attr('content');
  7476. if (!userId) {
  7477. logStatus.error(i18n('getFailed', i18n('userId')));
  7478. return false;
  7479. }
  7480. this.userId = userId;
  7481. this.initialized = true;
  7482. logStatus.success();
  7483. return true;
  7484. } catch (error) {
  7485. throwError(error, 'Givekey.init');
  7486. return false;
  7487. }
  7488. }
  7489. async classifyTask(action) {
  7490. try {
  7491. const logStatus = scripts_echoLog({
  7492. text: i18n('getTasksInfo')
  7493. });
  7494. if (action === 'undo') {
  7495. var _GM_getValue;
  7496. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || Givekey_defaultTasks;
  7497. }
  7498. const tasks = $('.card-body:has("button") .row');
  7499. for (const task of tasks) {
  7500. const taskEle = $(task);
  7501. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7502. if (isSuccess && action !== 'undo') {
  7503. continue;
  7504. }
  7505. const checkButton = taskEle.find('#task_check');
  7506. const taskId = checkButton.attr('data-id');
  7507. if (taskId) {
  7508. this.tasks.push(taskId);
  7509. }
  7510. if (action === 'verify') {
  7511. continue;
  7512. }
  7513. let href = taskEle.find('a').attr('href') || null;
  7514. const text = taskEle.find('a').text().trim();
  7515. const icon = taskEle.find('i');
  7516. if (!href || !text) {
  7517. continue;
  7518. }
  7519. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7520. href = await getRedirectLink(href);
  7521. }
  7522. if (!href) {
  7523. continue;
  7524. }
  7525. if (/^https?:\/\/vk\.com\//.test(href)) {
  7526. this.socialTasks.vk.nameLinks.push(href);
  7527. if (action === 'do' && !isSuccess) {
  7528. this.undoneTasks.vk.nameLinks.push(href);
  7529. }
  7530. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7531. this.socialTasks.steam.groupLinks.push(href);
  7532. if (action === 'do' && !isSuccess) {
  7533. this.undoneTasks.steam.groupLinks.push(href);
  7534. }
  7535. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7536. this.socialTasks.steam.wishlistLinks.push(href);
  7537. if (action === 'do' && !isSuccess) {
  7538. this.undoneTasks.steam.wishlistLinks.push(href);
  7539. }
  7540. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7541. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7542. this.socialTasks.steam.curatorLinks.push(href);
  7543. if (action === 'do' && !isSuccess) {
  7544. this.undoneTasks.steam.curatorLinks.push(href);
  7545. }
  7546. } else {
  7547. this.socialTasks.steam.curatorLikeLinks.push(href);
  7548. if (action === 'do' && !isSuccess) {
  7549. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7550. }
  7551. }
  7552. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7553. this.socialTasks.twitter.userLinks.push(href);
  7554. if (action === 'do' && !isSuccess) {
  7555. this.undoneTasks.twitter.userLinks.push(href);
  7556. }
  7557. } else if (icon.hasClass('fa-discord')) {
  7558. this.socialTasks.discord.serverLinks.push(href);
  7559. if (action === 'do' && !isSuccess) {
  7560. this.undoneTasks.discord.serverLinks.push(href);
  7561. }
  7562. } else {
  7563. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7564. }
  7565. }
  7566. logStatus.success();
  7567. this.tasks = unique(this.tasks);
  7568. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7569. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7570. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7571. tasks: this.socialTasks,
  7572. time: new Date().getTime()
  7573. });
  7574. return true;
  7575. } catch (error) {
  7576. throwError(error, 'Givekey.classifyTask');
  7577. return false;
  7578. }
  7579. }
  7580. async verifyTask() {
  7581. try {
  7582. if (!this.initialized && !this.init()) {
  7583. return false;
  7584. }
  7585. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7586. return false;
  7587. }
  7588. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7589. const taskLength = this.tasks.length;
  7590. for (let i = 0; i < taskLength; i++) {
  7591. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7592. if (i < taskLength - 1) {
  7593. await delay(15e3);
  7594. }
  7595. }
  7596. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7597. scripts_echoLog({
  7598. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7599. });
  7600. return true;
  7601. } catch (error) {
  7602. throwError(error, 'Givekey.verifyTask');
  7603. return false;
  7604. }
  7605. }
  7606. }
  7607. async function Givekey_verify2(task) {
  7608. try {
  7609. const logStatus = scripts_echoLog({
  7610. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7611. });
  7612. return await new Promise(resolve => {
  7613. $.ajax({
  7614. url: 'https://givekey.ru/giveaway/task',
  7615. method: 'POST',
  7616. data: `id=${task}&user_id=${this.userId}`,
  7617. dataType: 'json',
  7618. headers: {
  7619. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7620. },
  7621. success: data => {
  7622. if (data.btn) {
  7623. $(`button[data-id=${this.userId}]`).html(data.btn);
  7624. }
  7625. if (data.status === 'ok') {
  7626. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7627. logStatus.success();
  7628. resolve(true);
  7629. } else if (data.status === 'end') {
  7630. logStatus.success();
  7631. scripts_echoLog({}).success(data.key);
  7632. resolve(true);
  7633. } else {
  7634. logStatus.error(`Error:${data.msg}`);
  7635. resolve(false);
  7636. }
  7637. },
  7638. error: xhr => {
  7639. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7640. resolve(false);
  7641. }
  7642. });
  7643. });
  7644. } catch (error) {
  7645. throwError(error, 'Givekey.verify');
  7646. return false;
  7647. }
  7648. }
  7649. function Givekey_getGiveawayId2() {
  7650. try {
  7651. var _window$location$href;
  7652. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7653. if (giveawayId) {
  7654. this.giveawayId = giveawayId;
  7655. return true;
  7656. }
  7657. scripts_echoLog({
  7658. text: i18n('getFailed', 'GiveawayId')
  7659. });
  7660. return false;
  7661. } catch (error) {
  7662. throwError(error, 'Givekey.getGiveawayId');
  7663. return false;
  7664. }
  7665. }
  7666. async function Givekey_checkLeftKey2() {
  7667. try {
  7668. if (!globalOptions.other.checkLeftKey) {
  7669. return true;
  7670. }
  7671. if (!$('#keys_count').text()) {
  7672. await external_Swal_default().fire({
  7673. icon: 'warning',
  7674. title: i18n('notice'),
  7675. text: i18n('noKeysLeft'),
  7676. confirmButtonText: i18n('confirm'),
  7677. cancelButtonText: i18n('cancel'),
  7678. showCancelButton: true
  7679. }).then(_ref => {
  7680. let {
  7681. value
  7682. } = _ref;
  7683. if (value) {
  7684. window.close();
  7685. }
  7686. });
  7687. }
  7688. return true;
  7689. } catch (error) {
  7690. throwError(error, 'Givekey.checkLeftKey');
  7691. return false;
  7692. }
  7693. }
  7694. const website_Givekey = Givekey;
  7695. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7696. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7697. privateSet.add(obj);
  7698. }
  7699. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  7700. if (privateCollection.has(obj)) {
  7701. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7702. }
  7703. }
  7704. function GiveeClub_defineProperty(obj, key, value) {
  7705. if (key in obj) {
  7706. Object.defineProperty(obj, key, {
  7707. value: value,
  7708. enumerable: true,
  7709. configurable: true,
  7710. writable: true
  7711. });
  7712. } else {
  7713. obj[key] = value;
  7714. }
  7715. return obj;
  7716. }
  7717. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  7718. if (!privateSet.has(receiver)) {
  7719. throw new TypeError('attempted to get private field on non-instance');
  7720. }
  7721. return fn;
  7722. }
  7723. var GiveeClub_checkLogin = new WeakSet();
  7724. var GiveeClub_getGiveawayId = new WeakSet();
  7725. var GiveeClub_checkLeftKey = new WeakSet();
  7726. class GiveeClub extends GiveawaySu {
  7727. constructor() {
  7728. super(...arguments);
  7729. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  7730. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  7731. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  7732. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  7733. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7734. }
  7735. static test() {
  7736. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7737. }
  7738. async after() {
  7739. try {
  7740. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7741. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7742. }
  7743. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  7744. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7745. }
  7746. } catch (error) {
  7747. throwError(error, 'GiveeClub.after');
  7748. }
  7749. }
  7750. init() {
  7751. try {
  7752. const logStatus = scripts_echoLog({
  7753. text: i18n('initing')
  7754. });
  7755. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7756. logStatus.warning(i18n('needLogin'));
  7757. return false;
  7758. }
  7759. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  7760. return false;
  7761. }
  7762. this.initialized = true;
  7763. logStatus.success();
  7764. return true;
  7765. } catch (error) {
  7766. throwError(error, 'GiveeClub.init');
  7767. return false;
  7768. }
  7769. }
  7770. async classifyTask(action) {
  7771. try {
  7772. const logStatus = scripts_echoLog({
  7773. text: i18n('getTasksInfo')
  7774. });
  7775. if (action === 'undo') {
  7776. var _GM_getValue;
  7777. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7778. return true;
  7779. }
  7780. const pro = [];
  7781. const tasks = $('.event-actions tr');
  7782. for (const task of tasks) {
  7783. pro.push(new Promise(resolve => {
  7784. const taskDes = $(task).find('.event-action-label a');
  7785. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7786. const taskName = taskDes.text().trim();
  7787. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  7788. return resolve(true);
  7789. }
  7790. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7791. if (!taskLink) {
  7792. return resolve(false);
  7793. }
  7794. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7795. this.undoneTasks.steam.groupLinks.push(taskLink);
  7796. } else if (/like.*announcement/gi.test(taskName)) {
  7797. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7798. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7799. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7800. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  7801. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  7802. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7803. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7804. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7805. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7806. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7807. this.undoneTasks.steam.forumLinks.push(taskLink);
  7808. } else if (taskIcon.includes('discord')) {
  7809. this.undoneTasks.discord.serverLinks.push(taskLink);
  7810. } else if (taskIcon.includes('instagram')) {
  7811. this.undoneTasks.instagram.userLinks.push(taskLink);
  7812. } else if (taskIcon.includes('twitch')) {
  7813. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7814. } else if (taskIcon.includes('reddit')) {
  7815. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7816. } else if (/watch.*art/gim.test(taskName)) {
  7817. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7818. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7819. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7820. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7821. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7822. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7823. this.undoneTasks.vk.nameLinks.push(taskLink);
  7824. } else {
  7825. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7826. if (/follow.*button/gim.test(taskName)) {
  7827. this.undoneTasks.steam.followLinks.push(taskLink);
  7828. }
  7829. }
  7830. }
  7831. resolve(true);
  7832. }).catch(error => {
  7833. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7834. return false;
  7835. });
  7836. }));
  7837. }
  7838. await Promise.all(pro);
  7839. logStatus.success();
  7840. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7841. this.socialTasks = this.undoneTasks;
  7842. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7843. tasks: this.socialTasks,
  7844. time: new Date().getTime()
  7845. });
  7846. return true;
  7847. } catch (error) {
  7848. throwError(error, 'GiveeClub.classifyTask');
  7849. return false;
  7850. }
  7851. }
  7852. }
  7853. function GiveeClub_checkLogin2() {
  7854. try {
  7855. if (!globalOptions.other.checkLogin) {
  7856. return true;
  7857. }
  7858. if ($('a[href*="/account/auth"]').length > 0) {
  7859. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  7860. }
  7861. return true;
  7862. } catch (error) {
  7863. throwError(error, 'GiveeClub.checkLogin');
  7864. return false;
  7865. }
  7866. }
  7867. function GiveeClub_getGiveawayId2() {
  7868. var _window$location$href;
  7869. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7870. if (giveawayId) {
  7871. this.giveawayId = giveawayId;
  7872. return true;
  7873. }
  7874. scripts_echoLog({
  7875. text: i18n('getFailed', 'GiveawayId')
  7876. });
  7877. return false;
  7878. }
  7879. async function GiveeClub_checkLeftKey2() {
  7880. try {
  7881. if (!globalOptions.other.checkLeftKey) {
  7882. return true;
  7883. }
  7884. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  7885. await external_Swal_default().fire({
  7886. icon: 'warning',
  7887. title: i18n('notice'),
  7888. text: i18n('giveawayEnded'),
  7889. confirmButtonText: i18n('confirm'),
  7890. cancelButtonText: i18n('cancel'),
  7891. showCancelButton: true
  7892. }).then(_ref => {
  7893. let {
  7894. value
  7895. } = _ref;
  7896. if (value) {
  7897. window.close();
  7898. }
  7899. });
  7900. }
  7901. return true;
  7902. } catch (error) {
  7903. throwError(error, 'Giveawaysu.checkLeftKey');
  7904. return false;
  7905. }
  7906. }
  7907. const website_GiveeClub = GiveeClub;
  7908. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  7909. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  7910. privateSet.add(obj);
  7911. }
  7912. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  7913. if (privateCollection.has(obj)) {
  7914. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7915. }
  7916. }
  7917. function OpiumPulses_defineProperty(obj, key, value) {
  7918. if (key in obj) {
  7919. Object.defineProperty(obj, key, {
  7920. value: value,
  7921. enumerable: true,
  7922. configurable: true,
  7923. writable: true
  7924. });
  7925. } else {
  7926. obj[key] = value;
  7927. }
  7928. return obj;
  7929. }
  7930. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  7931. if (!privateSet.has(receiver)) {
  7932. throw new TypeError('attempted to get private field on non-instance');
  7933. }
  7934. return fn;
  7935. }
  7936. const defaultOptions = {
  7937. maxPoint: '99999999'
  7938. };
  7939. var _toggleTask = new WeakSet();
  7940. var OpiumPulses_checkLogin = new WeakSet();
  7941. class OpiumPulses {
  7942. constructor() {
  7943. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  7944. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  7945. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  7946. OpiumPulses_defineProperty(this, 'options', {
  7947. ...defaultOptions,
  7948. ...GM_getValue('OpiumPulsesOptions')
  7949. });
  7950. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  7951. OpiumPulses_defineProperty(this, 'myPoints', 0);
  7952. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  7953. }
  7954. static test() {
  7955. return window.location.host === 'www.opiumpulses.com';
  7956. }
  7957. async after() {
  7958. try {
  7959. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  7960. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7961. }
  7962. this.maxPoints = parseInt(this.options.maxPoint, 10);
  7963. } catch (error) {
  7964. throwError(error, 'OpiumPulses.after');
  7965. }
  7966. }
  7967. async doFreeTask() {
  7968. try {
  7969. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  7970. } catch (error) {
  7971. throwError(error, 'OpiumPulses.doFreeTask');
  7972. }
  7973. }
  7974. async doPointTask() {
  7975. try {
  7976. var _$$text$match;
  7977. 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);
  7978. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  7979. } catch (error) {
  7980. throwError(error, 'OpiumPulses.doPointTask');
  7981. }
  7982. }
  7983. init() {
  7984. return true;
  7985. }
  7986. classifyTask() {
  7987. return true;
  7988. }
  7989. }
  7990. async function _toggleTask2(type) {
  7991. try {
  7992. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  7993. for (const item of items) {
  7994. var _$$find$text$match;
  7995. 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);
  7996. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  7997. if (type === 'points' && needPoints > this.myPoints) {
  7998. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  7999. } else if (type === 'points' && !needPoints) {
  8000. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8001. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8002. var _aElement$attr;
  8003. const logStatus = scripts_echoLog({
  8004. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8005. });
  8006. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8007. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8008. var _aElement$attr2, _aElement$attr2$match;
  8009. 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];
  8010. if (giveawayId) {
  8011. checkUser(giveawayId);
  8012. }
  8013. }
  8014. if (!aElement.attr('href')) {
  8015. logStatus.error('Error: No "href".');
  8016. continue;
  8017. }
  8018. const {
  8019. result,
  8020. statusText,
  8021. status,
  8022. data
  8023. } = await tools_httpRequest({
  8024. url: aElement.attr('href'),
  8025. method: 'GET'
  8026. });
  8027. if (result === 'Success') {
  8028. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8029. var _data$responseText$ma;
  8030. logStatus.success();
  8031. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8032. if (type === 'points' && points) {
  8033. this.myPoints = parseInt(points, 10);
  8034. }
  8035. } else {
  8036. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8037. }
  8038. } else {
  8039. logStatus.error(`${result}:${statusText}(${status})`);
  8040. }
  8041. }
  8042. }
  8043. scripts_echoLog({
  8044. text: '-----END-----'
  8045. });
  8046. } catch (error) {
  8047. throwError(error, 'OpiumPulses.toggleTask');
  8048. }
  8049. }
  8050. function OpiumPulses_checkLogin2() {
  8051. try {
  8052. if (!globalOptions.other.checkLogin) {
  8053. return true;
  8054. }
  8055. if ($('a[href*="/site/login"]').length > 1) {
  8056. window.open('/site/login', '_self');
  8057. }
  8058. return true;
  8059. } catch (error) {
  8060. throwError(error, 'OpiumPulses.checkLogin');
  8061. return false;
  8062. }
  8063. }
  8064. const website_OpiumPulses = OpiumPulses;
  8065. const external_dayjs_namespaceObject = dayjs;
  8066. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8067. const leftKeyChecker = {
  8068. async classify(link) {
  8069. try {
  8070. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8071. return await this.giveawaySu(link);
  8072. }
  8073. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8074. return await this.giveeClub(link);
  8075. }
  8076. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8077. return await this.gleam(link);
  8078. }
  8079. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8080. return await this.indieDb(link);
  8081. }
  8082. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8083. return await this.keyhub(link);
  8084. }
  8085. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8086. return await this.opquests(link);
  8087. }
  8088. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8089. return await this.itch(link);
  8090. }
  8091. return false;
  8092. } catch (error) {
  8093. throwError(error, 'leftKeyChecker.classify');
  8094. return false;
  8095. }
  8096. },
  8097. async giveawaySu(link) {
  8098. try {
  8099. const {
  8100. result,
  8101. data
  8102. } = await tools_httpRequest({
  8103. url: link,
  8104. method: 'GET'
  8105. });
  8106. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8107. if (data.responseText.includes('class="steam-login"')) {
  8108. return false;
  8109. }
  8110. if (data.responseText.includes('class="giveaway-ended"')) {
  8111. return 'Ended';
  8112. }
  8113. return 'Active';
  8114. }
  8115. return false;
  8116. } catch (error) {
  8117. throwError(error, 'leftKeyChecker.giveawaySu');
  8118. return false;
  8119. }
  8120. },
  8121. async giveeClub(link) {
  8122. try {
  8123. const {
  8124. result,
  8125. data
  8126. } = await tools_httpRequest({
  8127. url: link,
  8128. method: 'GET'
  8129. });
  8130. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8131. if (data.responseText.includes('class="event-winner"')) {
  8132. return 'Won';
  8133. }
  8134. if (data.responseText.includes('class="event-ended"')) {
  8135. return 'Ended';
  8136. }
  8137. return 'Active';
  8138. }
  8139. return false;
  8140. } catch (error) {
  8141. throwError(error, 'leftKeyChecker.giveeClub');
  8142. return false;
  8143. }
  8144. },
  8145. async gleam(link) {
  8146. try {
  8147. const {
  8148. result,
  8149. data
  8150. } = await tools_httpRequest({
  8151. url: link,
  8152. method: 'GET'
  8153. });
  8154. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8155. var _data$responseText$ma, _$$attr, _$$attr$match;
  8156. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8157. return 'Won';
  8158. }
  8159. 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];
  8160. if (!campaignDiv) {
  8161. return false;
  8162. }
  8163. 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];
  8164. if (!campaignString) {
  8165. return false;
  8166. }
  8167. const {
  8168. campaign
  8169. } = JSON.parse(campaignString);
  8170. if (campaign.banned) {
  8171. return 'Banned';
  8172. }
  8173. if (campaign.finished) {
  8174. return 'Ended';
  8175. }
  8176. if (campaign.paused) {
  8177. return 'Paused';
  8178. }
  8179. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8180. return 'NotStart';
  8181. }
  8182. return 'Active';
  8183. }
  8184. return false;
  8185. } catch (error) {
  8186. throwError(error, 'leftKeyChecker.gleam');
  8187. return false;
  8188. }
  8189. },
  8190. async indieDb(link) {
  8191. try {
  8192. const {
  8193. result,
  8194. data
  8195. } = await tools_httpRequest({
  8196. url: link,
  8197. method: 'GET'
  8198. });
  8199. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8200. if (data.responseText.includes('Congrats you WON')) {
  8201. return 'Won';
  8202. }
  8203. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8204. return 'Ended';
  8205. }
  8206. return 'Active';
  8207. }
  8208. return false;
  8209. } catch (error) {
  8210. throwError(error, 'leftKeyChecker.indieDb');
  8211. return false;
  8212. }
  8213. },
  8214. async keyhub(link) {
  8215. try {
  8216. const {
  8217. result,
  8218. data
  8219. } = await tools_httpRequest({
  8220. url: link,
  8221. method: 'GET'
  8222. });
  8223. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8224. var _data$responseText$ma2;
  8225. 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];
  8226. if (!keysleft) {
  8227. return false;
  8228. }
  8229. if (keysleft === '0') {
  8230. return 'Ended';
  8231. }
  8232. return `Active(${keysleft})`;
  8233. }
  8234. return false;
  8235. } catch (error) {
  8236. throwError(error, 'leftKeyChecker.keyhub');
  8237. return false;
  8238. }
  8239. },
  8240. async opquests(link) {
  8241. try {
  8242. const {
  8243. result,
  8244. data
  8245. } = await tools_httpRequest({
  8246. url: link,
  8247. method: 'GET'
  8248. });
  8249. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8250. var _data$responseText$ma3;
  8251. 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];
  8252. if (!keysleft) {
  8253. return false;
  8254. }
  8255. if (keysleft === '0') {
  8256. return 'Ended';
  8257. }
  8258. return `Active(${keysleft})`;
  8259. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8260. return 'Ended';
  8261. }
  8262. return false;
  8263. } catch (error) {
  8264. throwError(error, 'leftKeyChecker.opquests');
  8265. return false;
  8266. }
  8267. },
  8268. async itch(link) {
  8269. try {
  8270. const {
  8271. result,
  8272. data
  8273. } = await tools_httpRequest({
  8274. url: link,
  8275. method: 'GET'
  8276. });
  8277. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8278. var _data$responseText$ma4;
  8279. 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];
  8280. if (!endDate) {
  8281. return false;
  8282. }
  8283. if (new Date().getTime() > new Date(endDate).getTime()) {
  8284. return 'Ended';
  8285. }
  8286. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8287. }
  8288. return false;
  8289. } catch (error) {
  8290. throwError(error, 'leftKeyChecker.opquests');
  8291. return false;
  8292. }
  8293. }
  8294. };
  8295. const website_leftKeyChecker = leftKeyChecker;
  8296. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8297. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8298. privateSet.add(obj);
  8299. }
  8300. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8301. if (privateCollection.has(obj)) {
  8302. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8303. }
  8304. }
  8305. function Keylol_defineProperty(obj, key, value) {
  8306. if (key in obj) {
  8307. Object.defineProperty(obj, key, {
  8308. value: value,
  8309. enumerable: true,
  8310. configurable: true,
  8311. writable: true
  8312. });
  8313. } else {
  8314. obj[key] = value;
  8315. }
  8316. return obj;
  8317. }
  8318. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8319. if (!privateSet.has(receiver)) {
  8320. throw new TypeError('attempted to get private field on non-instance');
  8321. }
  8322. return fn;
  8323. }
  8324. const Keylol_defaultTasks = {
  8325. steam: {
  8326. groupLinks: [],
  8327. wishlistLinks: [],
  8328. curatorLinks: [],
  8329. curatorLikeLinks: [],
  8330. followLinks: [],
  8331. forumLinks: [],
  8332. announcementLinks: [],
  8333. workshopVoteLinks: []
  8334. },
  8335. discord: {
  8336. serverLinks: []
  8337. },
  8338. instagram: {
  8339. userLinks: []
  8340. },
  8341. vk: {
  8342. nameLinks: []
  8343. },
  8344. twitch: {
  8345. channelLinks: []
  8346. },
  8347. reddit: {
  8348. redditLinks: []
  8349. },
  8350. twitter: {
  8351. userLinks: [],
  8352. retweetLinks: []
  8353. },
  8354. youtube: {
  8355. channelLinks: [],
  8356. likeLinks: []
  8357. }
  8358. };
  8359. var _addBtn = new WeakSet();
  8360. class Keylol extends website_Website {
  8361. constructor() {
  8362. super(...arguments);
  8363. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8364. Keylol_defineProperty(this, 'name', 'Keylol');
  8365. Keylol_defineProperty(this, 'socialTasks', {
  8366. ...Keylol_defaultTasks
  8367. });
  8368. Keylol_defineProperty(this, 'undoneTasks', {
  8369. ...Keylol_defaultTasks
  8370. });
  8371. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8372. }
  8373. static test() {
  8374. var _$$eq$attr;
  8375. 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'));
  8376. }
  8377. init() {
  8378. return true;
  8379. }
  8380. after() {
  8381. try {
  8382. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8383. const mainPost = $(selector);
  8384. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8385. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8386. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8387. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8388. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8389. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8390. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8391. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8392. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8393. if (discordLinks.length > 0) {
  8394. for (const discordLink of discordLinks) {
  8395. const link = $(discordLink).attr('href');
  8396. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8397. continue;
  8398. }
  8399. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8400. }
  8401. }
  8402. if (redditLinks.length > 0) {
  8403. for (const redditLink of redditLinks) {
  8404. const link = $(redditLink).attr('href');
  8405. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8406. continue;
  8407. }
  8408. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8409. }
  8410. }
  8411. if (insLinks.length > 0) {
  8412. for (const insLink of insLinks) {
  8413. const link = $(insLink).attr('href');
  8414. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8415. continue;
  8416. }
  8417. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8418. }
  8419. }
  8420. if (twitterLinks.length > 0) {
  8421. for (const twitterLink of twitterLinks) {
  8422. const link = $(twitterLink).attr('href');
  8423. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8424. continue;
  8425. }
  8426. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8427. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8428. } else {
  8429. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8430. }
  8431. }
  8432. }
  8433. if (twitchLinks.length > 0) {
  8434. for (const twitchLink of twitchLinks) {
  8435. const link = $(twitchLink).attr('href');
  8436. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8437. continue;
  8438. }
  8439. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8440. }
  8441. }
  8442. if (vkLinks.length > 0) {
  8443. for (const vkLink of vkLinks) {
  8444. const link = $(vkLink).attr('href');
  8445. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8446. continue;
  8447. }
  8448. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8449. }
  8450. }
  8451. if (steamStoreLinks.length > 0) {
  8452. for (const steamStoreLink of steamStoreLinks) {
  8453. const link = $(steamStoreLink).attr('href');
  8454. if (!link) {
  8455. continue;
  8456. }
  8457. if (/app\/[\d]+/.test(link)) {
  8458. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8459. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8460. } else if (/curator\/[\d]+/.test(link)) {
  8461. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8462. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8463. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8464. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8465. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8466. }
  8467. }
  8468. }
  8469. if (steamCommunityLinks.length > 0) {
  8470. for (const steamCommunityLink of steamCommunityLinks) {
  8471. const link = $(steamCommunityLink).attr('href');
  8472. if (!link) {
  8473. continue;
  8474. }
  8475. if (/groups\/.+/.test(link)) {
  8476. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8477. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8478. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8479. }
  8480. }
  8481. }
  8482. if (ytbLinks.length > 0) {
  8483. for (const ytbLink of ytbLinks) {
  8484. const link = $(ytbLink).attr('href');
  8485. if (!link) {
  8486. continue;
  8487. }
  8488. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8489. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8490. }
  8491. }
  8492. 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/"]');
  8493. if (giveawayLinks.length > 0) {
  8494. for (const giveawayLink of giveawayLinks) {
  8495. const link = $(giveawayLink).attr('href');
  8496. if (!link) {
  8497. continue;
  8498. }
  8499. website_leftKeyChecker.classify(link).then(status => {
  8500. if (!status) {
  8501. return;
  8502. }
  8503. if (/^Active/.test(status)) {
  8504. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  8505. return;
  8506. }
  8507. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  8508. }).catch(error => {
  8509. throwError(error, 'keylol.after -> leftKeyChecker');
  8510. });
  8511. }
  8512. }
  8513. } catch (error) {
  8514. throwError(error, 'keylol.after');
  8515. }
  8516. }
  8517. classifyTask(action) {
  8518. try {
  8519. this.socialTasks = {
  8520. ...Keylol_defaultTasks
  8521. };
  8522. this.undoneTasks = {
  8523. ...Keylol_defaultTasks
  8524. };
  8525. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8526. for (const btn of selectedBtns) {
  8527. const button = $(btn);
  8528. const social = button.attr('data-social');
  8529. const type = button.attr('data-type');
  8530. const link = button.attr('data-link');
  8531. if (!(social && type && link)) {
  8532. continue;
  8533. }
  8534. if (action === 'do') {
  8535. this.undoneTasks[social][type].push(link);
  8536. }
  8537. if (action === 'undo') {
  8538. this.socialTasks[social][type].push(link);
  8539. }
  8540. }
  8541. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8542. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8543. return true;
  8544. } catch (error) {
  8545. throwError(error, 'Keylol.classifyTask');
  8546. return false;
  8547. }
  8548. }
  8549. selectAll() {
  8550. try {
  8551. $('.auto-task-keylol').attr('selected', 'selected');
  8552. } catch (error) {
  8553. throwError(error, 'Keylol.selectAll');
  8554. }
  8555. }
  8556. selectNone() {
  8557. try {
  8558. $('.auto-task-keylol').removeAttr('selected');
  8559. } catch (error) {
  8560. throwError(error, 'Keylol.selectNone');
  8561. }
  8562. }
  8563. invertSelect() {
  8564. try {
  8565. $('.auto-task-keylol').each((index, element) => {
  8566. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8567. });
  8568. } catch (error) {
  8569. throwError(error, 'Keylol.invertSelect');
  8570. }
  8571. }
  8572. }
  8573. function _addBtn2(before, social, linkType, link) {
  8574. try {
  8575. $(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>`);
  8576. } catch (error) {
  8577. throwError(error, 'keylol.addBtn');
  8578. }
  8579. }
  8580. const website_Keylol = Keylol;
  8581. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8582. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8583. privateSet.add(obj);
  8584. }
  8585. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8586. if (privateCollection.has(obj)) {
  8587. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8588. }
  8589. }
  8590. function Opquests_defineProperty(obj, key, value) {
  8591. if (key in obj) {
  8592. Object.defineProperty(obj, key, {
  8593. value: value,
  8594. enumerable: true,
  8595. configurable: true,
  8596. writable: true
  8597. });
  8598. } else {
  8599. obj[key] = value;
  8600. }
  8601. return obj;
  8602. }
  8603. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8604. if (!privateSet.has(receiver)) {
  8605. throw new TypeError('attempted to get private field on non-instance');
  8606. }
  8607. return fn;
  8608. }
  8609. const Opquests_defaultTasks = {
  8610. steam: {
  8611. groupLinks: [],
  8612. wishlistLinks: [],
  8613. followLinks: [],
  8614. curatorLikeLinks: []
  8615. }
  8616. };
  8617. var Opquests_getGiveawayId = new WeakSet();
  8618. var Opquests_checkLogin = new WeakSet();
  8619. class Opquests extends website_Website {
  8620. constructor() {
  8621. super(...arguments);
  8622. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8623. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8624. Opquests_defineProperty(this, 'name', 'Opquests');
  8625. Opquests_defineProperty(this, 'undoneTasks', {
  8626. ...Opquests_defaultTasks
  8627. });
  8628. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8629. }
  8630. static test() {
  8631. return window.location.host === 'opquests.com';
  8632. }
  8633. async after() {
  8634. try {
  8635. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8636. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8637. }
  8638. } catch (error) {
  8639. throwError(error, 'Opquests.after');
  8640. }
  8641. }
  8642. init() {
  8643. try {
  8644. const logStatus = scripts_echoLog({
  8645. text: i18n('initing')
  8646. });
  8647. if ($('a[href*="/auth/redirect"]').length > 0) {
  8648. window.open('/auth/redirect', '_self');
  8649. logStatus.warning(i18n('needLogin'));
  8650. return false;
  8651. }
  8652. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8653. return false;
  8654. }
  8655. this.initialized = true;
  8656. logStatus.success();
  8657. return true;
  8658. } catch (error) {
  8659. throwError(error, 'Opquests.init');
  8660. return false;
  8661. }
  8662. }
  8663. async classifyTask(action) {
  8664. try {
  8665. if (action === 'undo') {
  8666. scripts_echoLog({
  8667. text: i18n('cannotUndo')
  8668. });
  8669. return false;
  8670. }
  8671. const logStatus = scripts_echoLog({
  8672. text: i18n('getTasksInfo')
  8673. });
  8674. const tasks = $('.w-full:contains("Validate") .items-center');
  8675. for (const task of tasks) {
  8676. const link = $(task).find('a:contains("Open")').attr('href');
  8677. const taskDes = $(task).find('div').eq(1).text().trim();
  8678. if (!link) {
  8679. continue;
  8680. }
  8681. if (/steamcommunity\.com\/groups\//.test(link)) {
  8682. this.undoneTasks.steam.groupLinks.push(link);
  8683. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8684. if (/wishlist/gim.test(taskDes)) {
  8685. this.undoneTasks.steam.wishlistLinks.push(link);
  8686. } else if (/follow/gim.test(taskDes)) {
  8687. this.undoneTasks.steam.followLinks.push(link);
  8688. }
  8689. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  8690. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8691. } else {
  8692. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8693. }
  8694. }
  8695. logStatus.success();
  8696. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8697. return true;
  8698. } catch (error) {
  8699. throwError(error, 'Opquests.classifyTask');
  8700. return false;
  8701. }
  8702. }
  8703. }
  8704. function Opquests_getGiveawayId2() {
  8705. try {
  8706. var _window$location$href;
  8707. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8708. if (giveawayId) {
  8709. this.giveawayId = giveawayId;
  8710. return true;
  8711. }
  8712. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8713. return false;
  8714. } catch (error) {
  8715. throwError(error, 'Opquests.getGiveawayId');
  8716. return false;
  8717. }
  8718. }
  8719. function Opquests_checkLogin2() {
  8720. try {
  8721. if (!globalOptions.other.checkLogin) {
  8722. return true;
  8723. }
  8724. if ($('a[href*="/auth/redirect"]').length > 0) {
  8725. window.open('/auth/redirect', '_self');
  8726. }
  8727. return true;
  8728. } catch (error) {
  8729. throwError(error, 'Opquests.checkLogin');
  8730. return false;
  8731. }
  8732. }
  8733. const website_Opquests = Opquests;
  8734. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  8735. Gleam_checkPrivateRedeclaration(obj, privateSet);
  8736. privateSet.add(obj);
  8737. }
  8738. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  8739. if (privateCollection.has(obj)) {
  8740. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8741. }
  8742. }
  8743. function Gleam_defineProperty(obj, key, value) {
  8744. if (key in obj) {
  8745. Object.defineProperty(obj, key, {
  8746. value: value,
  8747. enumerable: true,
  8748. configurable: true,
  8749. writable: true
  8750. });
  8751. } else {
  8752. obj[key] = value;
  8753. }
  8754. return obj;
  8755. }
  8756. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  8757. if (!privateSet.has(receiver)) {
  8758. throw new TypeError('attempted to get private field on non-instance');
  8759. }
  8760. return fn;
  8761. }
  8762. const Gleam_defaultTasks = {
  8763. steam: {
  8764. groupLinks: [],
  8765. wishlistLinks: [],
  8766. followLinks: [],
  8767. curatorLinks: [],
  8768. curatorLikeLinks: []
  8769. },
  8770. twitter: {
  8771. userLinks: [],
  8772. retweetLinks: []
  8773. },
  8774. twitch: {
  8775. channelLinks: []
  8776. },
  8777. discord: {
  8778. serverLinks: []
  8779. },
  8780. youtube: {
  8781. channelLinks: []
  8782. },
  8783. extra: {
  8784. gleam: []
  8785. }
  8786. };
  8787. const Gleam_defaultOptions = {
  8788. vlootUsername: '',
  8789. gameroundUsername: ''
  8790. };
  8791. var _checkSync = new WeakSet();
  8792. var _doGleamTask = new WeakSet();
  8793. var Gleam_getGiveawayId = new WeakSet();
  8794. var _getGleamLink = new WeakSet();
  8795. var Gleam_checkLeftKey = new WeakSet();
  8796. class Gleam extends website_Website {
  8797. constructor() {
  8798. super(...arguments);
  8799. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  8800. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  8801. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  8802. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  8803. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  8804. Gleam_defineProperty(this, 'name', 'Gleam');
  8805. Gleam_defineProperty(this, 'undoneTasks', {
  8806. ...Gleam_defaultTasks
  8807. });
  8808. Gleam_defineProperty(this, 'socialTasks', {
  8809. ...Gleam_defaultTasks
  8810. });
  8811. Gleam_defineProperty(this, 'options', {
  8812. ...Gleam_defaultOptions,
  8813. ...GM_getValue('GleamOptions')
  8814. });
  8815. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8816. }
  8817. static test() {
  8818. return window.location.host === 'gleam.io';
  8819. }
  8820. async after() {
  8821. try {
  8822. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8823. const checkComplete = setInterval(() => {
  8824. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8825. clearInterval(checkComplete);
  8826. window.close();
  8827. }
  8828. });
  8829. for (const task of $('.entry-content .entry-method')) {
  8830. const taskInfo = $(task).find('.user-links');
  8831. const expandInfo = $(task).find('.expandable');
  8832. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8833. if (aElements.length > 0) {
  8834. for (const element of aElements) {
  8835. const $element = $(element);
  8836. const href = $element.attr('href');
  8837. $element.removeAttr('href')[0].click();
  8838. $element.attr('href', href);
  8839. await delay(1e3);
  8840. }
  8841. }
  8842. taskInfo[0].click();
  8843. await delay(1e3);
  8844. }
  8845. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8846. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  8847. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8848. }
  8849. } catch (error) {
  8850. throwError(error, 'Gleam.after');
  8851. return false;
  8852. }
  8853. }
  8854. init() {
  8855. try {
  8856. const logStatus = scripts_echoLog({
  8857. text: i18n('initing')
  8858. });
  8859. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  8860. return false;
  8861. }
  8862. this.initialized = true;
  8863. logStatus.success();
  8864. return true;
  8865. } catch (error) {
  8866. throwError(error, 'Gleam.init');
  8867. return false;
  8868. }
  8869. }
  8870. async classifyTask(action) {
  8871. try {
  8872. const logStatus = scripts_echoLog({
  8873. text: i18n('getTasksInfo')
  8874. });
  8875. if (action === 'undo') {
  8876. var _GM_getValue;
  8877. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  8878. ...Gleam_defaultTasks
  8879. };
  8880. }
  8881. const tasks = $('.entry-content .entry-method');
  8882. for (const task of tasks) {
  8883. var _socialIcon$attr;
  8884. const $task = $(task);
  8885. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  8886. continue;
  8887. }
  8888. const socialIcon = $task.find('.icon-wrapper i');
  8889. const taskInfo = $task.find('.user-links');
  8890. const taskText = taskInfo.text().trim();
  8891. const expandInfo = $task.find('.expandable');
  8892. const aElements = expandInfo.find('a.btn');
  8893. if (aElements.length > 0) {
  8894. for (const element of aElements) {
  8895. const $element = $(element);
  8896. const href = $element.attr('href');
  8897. $element.removeAttr('href')[0].click();
  8898. $element.attr('href', href);
  8899. }
  8900. }
  8901. if (socialIcon.hasClass('fa-twitter')) {
  8902. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  8903. if (!link) {
  8904. continue;
  8905. }
  8906. if (/follow/gi.test(taskText)) {
  8907. if (action === 'undo') {
  8908. this.socialTasks.twitter.userLinks.push(link);
  8909. }
  8910. if (action === 'do') {
  8911. this.undoneTasks.twitter.userLinks.push(link);
  8912. }
  8913. } else if (/retweet/gim.test(taskText)) {
  8914. if (action === 'undo') {
  8915. this.socialTasks.twitter.retweetLinks.push(link);
  8916. }
  8917. if (action === 'do') {
  8918. this.undoneTasks.twitter.retweetLinks.push(link);
  8919. }
  8920. }
  8921. } else if (socialIcon.hasClass('fa-twitch')) {
  8922. if (/follow/gim.test(taskText)) {
  8923. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  8924. if (!link) {
  8925. continue;
  8926. }
  8927. if (action === 'undo') {
  8928. this.socialTasks.twitch.channelLinks.push(link);
  8929. }
  8930. if (action === 'do') {
  8931. this.undoneTasks.twitch.channelLinks.push(link);
  8932. }
  8933. }
  8934. } else if (socialIcon.hasClass('fa-discord')) {
  8935. if (/join/gim.test(taskText)) {
  8936. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  8937. if (!link) {
  8938. var _$task$find$attr, _$task$find$attr$matc;
  8939. 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];
  8940. if (!ggLink) {
  8941. continue;
  8942. }
  8943. link = `https://discord.com/invite/${ggLink}`;
  8944. }
  8945. if (action === 'undo') {
  8946. this.socialTasks.discord.serverLinks.push(link);
  8947. }
  8948. if (action === 'do') {
  8949. this.undoneTasks.discord.serverLinks.push(link);
  8950. }
  8951. }
  8952. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  8953. continue;
  8954. } else if (socialIcon.hasClass('fa-youtube')) {
  8955. if (/subscribe/gim.test(taskText)) {
  8956. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  8957. if (!link) {
  8958. continue;
  8959. }
  8960. if (action === 'undo') {
  8961. this.socialTasks.youtube.channelLinks.push(link);
  8962. }
  8963. if (action === 'do') {
  8964. this.undoneTasks.youtube.channelLinks.push(link);
  8965. }
  8966. }
  8967. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  8968. if (/join.*group/gi.test(taskText)) {
  8969. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  8970. if (!link) {
  8971. continue;
  8972. }
  8973. if (action === 'undo') {
  8974. this.socialTasks.steam.groupLinks.push(link);
  8975. }
  8976. if (action === 'do') {
  8977. this.undoneTasks.steam.groupLinks.push(link);
  8978. }
  8979. } else if (/follow.*curator/gi.test(taskText)) {
  8980. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  8981. if (!link) {
  8982. continue;
  8983. }
  8984. if (action === 'undo') {
  8985. this.socialTasks.steam.curatorLinks.push(link);
  8986. }
  8987. if (action === 'do') {
  8988. this.undoneTasks.steam.curatorLinks.push(link);
  8989. }
  8990. }
  8991. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  8992. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  8993. for (const button of continueBtn) {
  8994. button.click();
  8995. await delay(500);
  8996. expandInfo.find('input').val(this.options.vlootUsername);
  8997. }
  8998. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  8999. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9000. for (const button of continueBtn) {
  9001. button.click();
  9002. await delay(500);
  9003. expandInfo.find('input').val(this.options.gameroundUsername);
  9004. }
  9005. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9006. if (action !== 'do') {
  9007. continue;
  9008. }
  9009. const link = aElements.attr('href');
  9010. if (!link) {
  9011. continue;
  9012. }
  9013. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9014. if (!gleamLink) {
  9015. continue;
  9016. }
  9017. this.undoneTasks.extra.gleam.push(gleamLink);
  9018. } 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 {
  9019. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9020. }
  9021. }
  9022. logStatus.success();
  9023. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9024. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9025. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9026. tasks: this.socialTasks,
  9027. time: new Date().getTime()
  9028. });
  9029. return true;
  9030. } catch (error) {
  9031. throwError(error, 'Gleam.classifyTask');
  9032. return false;
  9033. }
  9034. }
  9035. async extraDoTask(_ref) {
  9036. let {
  9037. gleam
  9038. } = _ref;
  9039. try {
  9040. const pro = [];
  9041. for (const link of gleam) {
  9042. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9043. }
  9044. return Promise.all(pro).then(() => true);
  9045. } catch (error) {
  9046. throwError(error, 'Gleam.extraDoTask');
  9047. return false;
  9048. }
  9049. }
  9050. async verifyTask() {
  9051. try {
  9052. scripts_echoLog({
  9053. text: `${i18n('verifyingTask')}...`
  9054. });
  9055. const tasks = $('.entry-content .entry-method');
  9056. for (const task of tasks) {
  9057. const $task = $(task);
  9058. if ($task.find('i.fa-question').length === 0) {
  9059. continue;
  9060. }
  9061. const taskInfo = $task.find('.user-links');
  9062. taskInfo[0].click();
  9063. await delay(500);
  9064. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9065. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9066. for (const button of continueBtn) {
  9067. button.click();
  9068. await delay(500);
  9069. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9070. }
  9071. }
  9072. scripts_echoLog({
  9073. text: i18n('verifiedGleamTasks')
  9074. });
  9075. } catch (error) {
  9076. throwError(error, 'Gleam.verifyTask');
  9077. return false;
  9078. }
  9079. }
  9080. }
  9081. async function _checkSync2() {
  9082. try {
  9083. return await new Promise(resolve => {
  9084. const checker = setInterval(() => {
  9085. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9086. clearInterval(checker);
  9087. resolve(true);
  9088. }
  9089. }, 500);
  9090. });
  9091. } catch (error) {
  9092. throwError(error, 'Gleam.checkSync');
  9093. return false;
  9094. }
  9095. }
  9096. async function _doGleamTask2(link) {
  9097. try {
  9098. const logStatus = scripts_echoLog({
  9099. text: i18n('doingGleamTask')
  9100. });
  9101. return await new Promise(resolve => {
  9102. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9103. active: true,
  9104. insert: true,
  9105. setParent: true
  9106. }).onclose = () => {
  9107. logStatus.success();
  9108. resolve(true);
  9109. };
  9110. });
  9111. } catch (error) {
  9112. throwError(error, 'Gleam.doGleamTask');
  9113. return false;
  9114. }
  9115. }
  9116. function Gleam_getGiveawayId2() {
  9117. try {
  9118. const giveawayId = window.location.pathname;
  9119. if (giveawayId) {
  9120. this.giveawayId = giveawayId;
  9121. return true;
  9122. }
  9123. scripts_echoLog({
  9124. text: i18n('getFailed', 'GiveawayId')
  9125. });
  9126. return false;
  9127. } catch (error) {
  9128. throwError(error, 'Gleam.getGiveawayId');
  9129. return false;
  9130. }
  9131. }
  9132. async function _getGleamLink2(link) {
  9133. try {
  9134. const logStatus = scripts_echoLog({
  9135. text: i18n('gettingGleamLink')
  9136. });
  9137. const {
  9138. result,
  9139. statusText,
  9140. status,
  9141. data
  9142. } = await tools_httpRequest({
  9143. url: link,
  9144. method: 'GET'
  9145. });
  9146. if (result === 'Success') {
  9147. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9148. var _data$responseText$ma;
  9149. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9150. if (gleamLink) {
  9151. logStatus.success();
  9152. return gleamLink;
  9153. }
  9154. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9155. return false;
  9156. }
  9157. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9158. return false;
  9159. }
  9160. logStatus.error(`${result}:${statusText}(${status})`);
  9161. return false;
  9162. } catch (error) {
  9163. throwError(error, 'Gleam.getGleamLink');
  9164. return false;
  9165. }
  9166. }
  9167. async function Gleam_checkLeftKey2() {
  9168. try {
  9169. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9170. if (!globalOptions.other.checkLeftKey) {
  9171. return true;
  9172. }
  9173. 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];
  9174. if (!campaignString) {
  9175. return false;
  9176. }
  9177. const {
  9178. campaign,
  9179. incentive
  9180. } = JSON.parse(campaignString);
  9181. 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];
  9182. let ownedKey = false;
  9183. if (controllerString) {
  9184. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9185. 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) {
  9186. ownedKey = true;
  9187. }
  9188. }
  9189. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9190. await external_Swal_default().fire({
  9191. icon: 'warning',
  9192. title: i18n('notice'),
  9193. text: i18n('giveawayNotWork'),
  9194. confirmButtonText: i18n('confirm'),
  9195. cancelButtonText: i18n('cancel'),
  9196. showCancelButton: true
  9197. }).then(_ref2 => {
  9198. let {
  9199. value
  9200. } = _ref2;
  9201. if (value) {
  9202. window.close();
  9203. }
  9204. });
  9205. }
  9206. return true;
  9207. } catch (error) {
  9208. throwError(error, 'Gleam.checkLeftKey');
  9209. return false;
  9210. }
  9211. }
  9212. const website_Gleam = Gleam;
  9213. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9214. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9215. privateSet.add(obj);
  9216. }
  9217. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9218. if (privateCollection.has(obj)) {
  9219. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9220. }
  9221. }
  9222. function SweepWidget_defineProperty(obj, key, value) {
  9223. if (key in obj) {
  9224. Object.defineProperty(obj, key, {
  9225. value: value,
  9226. enumerable: true,
  9227. configurable: true,
  9228. writable: true
  9229. });
  9230. } else {
  9231. obj[key] = value;
  9232. }
  9233. return obj;
  9234. }
  9235. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9236. if (!privateSet.has(receiver)) {
  9237. throw new TypeError('attempted to get private field on non-instance');
  9238. }
  9239. return fn;
  9240. }
  9241. const SweepWidget_defaultOptions = {
  9242. username: '',
  9243. email: ''
  9244. };
  9245. var SweepWidget_checkLogin = new WeakSet();
  9246. var SweepWidget_getGiveawayId = new WeakSet();
  9247. var _checkEnter = new WeakSet();
  9248. var _checkFinish = new WeakSet();
  9249. class SweepWidget extends website_Website {
  9250. constructor() {
  9251. super(...arguments);
  9252. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9253. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9254. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9255. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9256. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9257. SweepWidget_defineProperty(this, 'options', {
  9258. ...SweepWidget_defaultOptions,
  9259. ...GM_getValue('SweepWidgetOptions')
  9260. });
  9261. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9262. }
  9263. static test() {
  9264. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9265. }
  9266. async after() {
  9267. try {
  9268. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9269. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9270. }
  9271. } catch (error) {
  9272. throwError(error, 'SweepWidget.after');
  9273. }
  9274. }
  9275. init() {
  9276. try {
  9277. const logStatus = scripts_echoLog({
  9278. text: i18n('initing')
  9279. });
  9280. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9281. logStatus.warning(i18n('needLogin'));
  9282. return false;
  9283. }
  9284. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9285. return false;
  9286. }
  9287. this.initialized = true;
  9288. logStatus.success();
  9289. return true;
  9290. } catch (error) {
  9291. throwError(error, 'SweepWidget.init');
  9292. return false;
  9293. }
  9294. }
  9295. classifyTask() {
  9296. return true;
  9297. }
  9298. async doTask() {
  9299. try {
  9300. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9301. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9302. $('input[name="sw__login_name"]').val(this.options.username);
  9303. }
  9304. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9305. $('input[name="sw__login_email"]').val(this.options.email);
  9306. }
  9307. if ($('#sw_login_button:visible').length > 0) {
  9308. $('#sw_login_button')[0].click();
  9309. }
  9310. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9311. return false;
  9312. }
  9313. }
  9314. const logStatus = scripts_echoLog({
  9315. text: i18n('SweepWidgetNotice')
  9316. });
  9317. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9318. for (const task of tasks) {
  9319. var _aElement$, _$task$find$removeAtt;
  9320. const $task = $(task);
  9321. if ($task.find('i.fa-check:visible').length > 0) {
  9322. continue;
  9323. }
  9324. const title = $task.find('.sw_text_inner');
  9325. title[0].click();
  9326. const aElement = $task.find('a.sw_link');
  9327. const link = aElement.attr('href');
  9328. aElement.attr('href', '#a').attr('target', '_self');
  9329. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9330. await delay(300);
  9331. aElement.attr('href', link).attr('target', '_blank');
  9332. $task.find('input[type="text"]').val('test');
  9333. const verifyBtn = $task.find('input.sw_verify');
  9334. if (verifyBtn.prop('disabled') === true) {
  9335. title[0].click();
  9336. await delay(300);
  9337. title[0].click();
  9338. await delay(300);
  9339. }
  9340. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9341. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9342. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9343. }
  9344. logStatus.success();
  9345. return true;
  9346. } catch (error) {
  9347. throwError(error, 'SweepWidget.doTask');
  9348. return false;
  9349. }
  9350. }
  9351. }
  9352. function SweepWidget_checkLogin2() {
  9353. try {
  9354. if ($('#twitter_login_button').length > 0) {
  9355. $('#twitter_login_button')[0].click();
  9356. }
  9357. return true;
  9358. } catch (error) {
  9359. throwError(error, 'SweepWidget.checkLogin');
  9360. return false;
  9361. }
  9362. }
  9363. function SweepWidget_getGiveawayId2() {
  9364. try {
  9365. var _window$location$href;
  9366. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9367. if (giveawayId) {
  9368. this.giveawayId = giveawayId;
  9369. return true;
  9370. }
  9371. scripts_echoLog({
  9372. text: i18n('getFailed', 'GiveawayId')
  9373. });
  9374. return false;
  9375. } catch (error) {
  9376. throwError(error, 'SweepWidget.getGiveawayId');
  9377. return false;
  9378. }
  9379. }
  9380. async function _checkEnter2() {
  9381. try {
  9382. return new Promise(resolve => {
  9383. const checker = setInterval(() => {
  9384. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9385. clearInterval(checker);
  9386. resolve(true);
  9387. }
  9388. });
  9389. });
  9390. } catch (error) {
  9391. throwError(error, 'SweepWidget.checkEnter');
  9392. return false;
  9393. }
  9394. }
  9395. async function _checkFinish2($task) {
  9396. try {
  9397. return new Promise(resolve => {
  9398. const checker = setInterval(() => {
  9399. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9400. clearInterval(checker);
  9401. resolve(true);
  9402. }
  9403. });
  9404. });
  9405. } catch (error) {
  9406. throwError(error, 'SweepWidget.checkFinish');
  9407. return false;
  9408. }
  9409. }
  9410. const website_SweepWidget = SweepWidget;
  9411. const defaultWhiteList = {
  9412. discord: {
  9413. servers: []
  9414. },
  9415. instagram: {
  9416. users: []
  9417. },
  9418. twitch: {
  9419. channels: []
  9420. },
  9421. twitter: {
  9422. users: [],
  9423. retweets: [],
  9424. likes: []
  9425. },
  9426. vk: {
  9427. names: []
  9428. },
  9429. youtube: {
  9430. channels: [],
  9431. likes: []
  9432. },
  9433. reddit: {
  9434. reddits: []
  9435. },
  9436. steam: {
  9437. groups: [],
  9438. wishlists: [],
  9439. follows: [],
  9440. forums: [],
  9441. workshops: [],
  9442. curators: [],
  9443. workshopVotes: [],
  9444. curatorLikes: [],
  9445. announcements: []
  9446. }
  9447. };
  9448. const link2id = async function(type) {
  9449. 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;
  9450. try {
  9451. const link = $('#socialLink').val();
  9452. let id = '';
  9453. switch (type) {
  9454. case 'discord.servers':
  9455. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9456. break;
  9457.  
  9458. case 'instagram.users':
  9459. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9460. break;
  9461.  
  9462. case 'twitch.channels':
  9463. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9464. break;
  9465.  
  9466. case 'twitter.users':
  9467. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9468. break;
  9469.  
  9470. case 'twitter.retweets':
  9471. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9472. break;
  9473.  
  9474. case 'vk.names':
  9475. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9476. break;
  9477.  
  9478. case 'youtube.channels':
  9479. 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) || '';
  9480. break;
  9481.  
  9482. case 'youtube.likes':
  9483. 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) || '';
  9484. break;
  9485.  
  9486. case 'reddit.reddits':
  9487. 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]) || '';
  9488. break;
  9489.  
  9490. case 'steam.groups':
  9491. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9492. break;
  9493.  
  9494. case 'steam.wishlists':
  9495. case 'steam.follows':
  9496. case 'steam.forums':
  9497. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9498. break;
  9499.  
  9500. case 'steam.workshops':
  9501. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9502. break;
  9503.  
  9504. case 'steam.curators':
  9505. {
  9506. if (link.includes('curator')) {
  9507. var _link$match12;
  9508. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9509. } else {
  9510. var _link$match13;
  9511. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9512. if (!param || param.length !== 2) {
  9513. break;
  9514. }
  9515. const steam = new social_Steam();
  9516. if (await steam.init()) {
  9517. id = await steam.getCuratorId(param[0], param[1]) || '';
  9518. }
  9519. }
  9520. }
  9521. break;
  9522. }
  9523. return id;
  9524. } catch (error) {
  9525. throwError(error, 'link2id');
  9526. return i18n('getFailed', 'id');
  9527. }
  9528. };
  9529. const disabledType = {
  9530. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9531. twitter: [ 'likes' ]
  9532. };
  9533. const whiteListOptions = function(showType) {
  9534. try {
  9535. const whiteList = {
  9536. ...defaultWhiteList,
  9537. ...GM_getValue('whiteList') || {}
  9538. };
  9539. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9540. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9541. for (const [ social, types ] of Object.entries(whiteList)) {
  9542. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9543. var _disabledType$social;
  9544. 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>`;
  9545. }).join('');
  9546. }
  9547. whiteListOptionsForm += '</tbody></table></form>';
  9548. if (showType === 'swal') {
  9549. external_Swal_default().fire({
  9550. title: i18n('whiteListOptions'),
  9551. html: whiteListOptionsForm,
  9552. showConfirmButton: false,
  9553. showCloseButton: true
  9554. });
  9555. } else {
  9556. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9557. }
  9558. $('.editWhiteList').on('click', function() {
  9559. var _whiteList$social;
  9560. const value = $(this).attr('data-value');
  9561. if (!value) {
  9562. return;
  9563. }
  9564. const [ social, type ] = value.split('.');
  9565. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9566. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9567. return;
  9568. }
  9569. external_Swal_default().fire({
  9570. title: i18n('changeWhiteListOption', value),
  9571. input: 'textarea',
  9572. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9573. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9574. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9575. inputValue: whiteList[social][type].join('\n'),
  9576. showConfirmButton: true,
  9577. confirmButtonText: i18n('save'),
  9578. showCancelButton: true,
  9579. cancelButtonText: i18n('close'),
  9580. showDenyButton: true,
  9581. denyButtonText: i18n('return')
  9582. }).then(_ref => {
  9583. let {
  9584. isDenied,
  9585. isConfirmed,
  9586. value
  9587. } = _ref;
  9588. if (isDenied) {
  9589. if (showType === 'swal') {
  9590. whiteListOptions(showType);
  9591. }
  9592. return;
  9593. } else if (isConfirmed) {
  9594. whiteList[social][type] = value.split('\n');
  9595. GM_setValue('whiteList', whiteList);
  9596. external_Swal_default().fire({
  9597. title: i18n('changeWhiteListSuccess'),
  9598. icon: 'success'
  9599. });
  9600. }
  9601. });
  9602. $('#link2id').on('click', async function() {
  9603. const type = $(this).attr('data-type');
  9604. $('#socialLink').val(await link2id(type));
  9605. });
  9606. });
  9607. } catch (error) {
  9608. throwError(error, 'whiteListOptions');
  9609. }
  9610. };
  9611. const whiteList = whiteListOptions;
  9612. const setGistData = async (token, gistId, fileName, content) => {
  9613. try {
  9614. const logStatus = scripts_echoLog({
  9615. text: i18n('settingData')
  9616. });
  9617. const contentData = JSON.stringify({
  9618. files: {
  9619. [fileName]: {
  9620. content: JSON.stringify(content)
  9621. }
  9622. }
  9623. });
  9624. const {
  9625. result,
  9626. statusText,
  9627. status,
  9628. data
  9629. } = await tools_httpRequest({
  9630. url: `https://api.github.com/gists/${gistId}`,
  9631. headers: {
  9632. Accept: 'application/vnd.github.v3+json',
  9633. Authorization: `token ${token}`
  9634. },
  9635. data: contentData,
  9636. responseType: 'json',
  9637. method: 'POST',
  9638. timeout: 3e4
  9639. });
  9640. if (result === 'Success') {
  9641. var _data$response$files, _data$response$files$;
  9642. 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)) {
  9643. logStatus.success();
  9644. return true;
  9645. }
  9646. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9647. return false;
  9648. }
  9649. logStatus.error(`${result}:${statusText}(${status})`);
  9650. return false;
  9651. } catch (error) {
  9652. throwError(error, 'setGistData');
  9653. return false;
  9654. }
  9655. };
  9656. const getGistData = async (token, gistId, fileName) => {
  9657. try {
  9658. const logStatus = scripts_echoLog({
  9659. text: i18n('gettingData')
  9660. });
  9661. const {
  9662. result,
  9663. statusText,
  9664. status,
  9665. data
  9666. } = await tools_httpRequest({
  9667. url: `https://api.github.com/gists/${gistId}`,
  9668. headers: {
  9669. Accept: 'application/vnd.github.v3+json',
  9670. Authorization: `token ${token}`
  9671. },
  9672. responseType: 'json',
  9673. method: 'GET',
  9674. timeout: 3e4
  9675. });
  9676. if (result === 'Success') {
  9677. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9678. var _data$response, _data$response$files2, _data$response$files3;
  9679. logStatus.success();
  9680. 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);
  9681. }
  9682. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9683. return false;
  9684. }
  9685. logStatus.error(`${result}:${statusText}(${status})`);
  9686. return false;
  9687. } catch (error) {
  9688. throwError(error, 'getGistData');
  9689. return false;
  9690. }
  9691. };
  9692. const syncOptions = () => {
  9693. try {
  9694. const {
  9695. TOKEN,
  9696. GIST_ID,
  9697. FILE_NAME,
  9698. SYNC_HISTORY
  9699. } = GM_getValue('gistOptions') || {
  9700. TOKEN: '',
  9701. GIST_ID: '',
  9702. FILE_NAME: '',
  9703. SYNC_HISTORY: true
  9704. };
  9705. external_Swal_default().fire({
  9706. title: i18n('gistOptions'),
  9707. 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;">
  9708. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9709. ${i18n('downloadFromGist')}</button></p>`,
  9710. focusConfirm: false,
  9711. showLoaderOnConfirm: true,
  9712. 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>`,
  9713. preConfirm: async () => {
  9714. const token = $('#github-token').val();
  9715. const gistId = $('#gist-id').val();
  9716. const fileName = $('#file-name').val();
  9717. const syncHistory = $('#sync-history').prop('checked');
  9718. GM_setValue('gistOptions', {
  9719. TOKEN: token,
  9720. GIST_ID: gistId,
  9721. FILE_NAME: fileName,
  9722. SYNC_HISTORY: syncHistory
  9723. });
  9724. return await getGistData(token, gistId, fileName);
  9725. },
  9726. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9727. confirmButtonText: i18n('saveAndTest'),
  9728. showCancelButton: true,
  9729. cancelButtonText: i18n('close')
  9730. }).then(_ref => {
  9731. let {
  9732. value
  9733. } = _ref;
  9734. if (value) {
  9735. external_Swal_default().fire({
  9736. icon: 'success',
  9737. title: i18n('testSuccess')
  9738. }).then(syncOptions);
  9739. } else if (value !== undefined) {
  9740. external_Swal_default().fire({
  9741. icon: 'error',
  9742. title: i18n('testFailed')
  9743. }).then(syncOptions);
  9744. }
  9745. });
  9746. $('#upload-data').on('click', async () => {
  9747. const {
  9748. TOKEN,
  9749. GIST_ID,
  9750. FILE_NAME
  9751. } = GM_getValue('gistOptions') || {};
  9752. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9753. return external_Swal_default().fire({
  9754. icon: 'error',
  9755. title: i18n('saveAndTestNotice')
  9756. }).then(syncOptions);
  9757. }
  9758. external_Swal_default().fire({
  9759. icon: 'info',
  9760. title: i18n('processingData')
  9761. });
  9762. const data = {};
  9763. const names = GM_listValues();
  9764. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9765. for (const name of names) {
  9766. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9767. continue;
  9768. }
  9769. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9770. continue;
  9771. }
  9772. data[name] = GM_getValue(name);
  9773. }
  9774. external_Swal_default().update({
  9775. icon: 'info',
  9776. title: i18n('updatingData')
  9777. });
  9778. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9779. external_Swal_default().fire({
  9780. icon: 'success',
  9781. title: i18n('syncDataSuccess')
  9782. });
  9783. } else {
  9784. external_Swal_default().fire({
  9785. icon: 'error',
  9786. title: i18n('syncDataFailed')
  9787. });
  9788. }
  9789. });
  9790. $('#download-data').on('click', async () => {
  9791. const {
  9792. TOKEN,
  9793. GIST_ID,
  9794. FILE_NAME
  9795. } = GM_getValue('gistOptions') || {};
  9796. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9797. return external_Swal_default().fire({
  9798. icon: 'error',
  9799. title: i18n('saveAndTestNotice')
  9800. }).then(syncOptions);
  9801. }
  9802. external_Swal_default().fire({
  9803. icon: 'info',
  9804. title: i18n('downloadingData')
  9805. });
  9806. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9807. if (!data) {
  9808. return external_Swal_default().fire({
  9809. icon: 'error',
  9810. title: i18n('checkedNoData')
  9811. }).then(syncOptions);
  9812. }
  9813. external_Swal_default().update({
  9814. icon: 'info',
  9815. title: i18n('savingData')
  9816. });
  9817. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9818. for (const [ name, value ] of Object.entries(data)) {
  9819. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9820. continue;
  9821. }
  9822. GM_setValue(name, value);
  9823. }
  9824. external_Swal_default().fire({
  9825. icon: 'success',
  9826. title: i18n('syncDataSuccess')
  9827. });
  9828. });
  9829. } catch (error) {
  9830. throwError(error, 'syncOptions');
  9831. }
  9832. };
  9833. const dataSync = syncOptions;
  9834. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  9835. Setting_checkPrivateRedeclaration(obj, privateSet);
  9836. privateSet.add(obj);
  9837. }
  9838. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  9839. if (privateCollection.has(obj)) {
  9840. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9841. }
  9842. }
  9843. function Setting_defineProperty(obj, key, value) {
  9844. if (key in obj) {
  9845. Object.defineProperty(obj, key, {
  9846. value: value,
  9847. enumerable: true,
  9848. configurable: true,
  9849. writable: true
  9850. });
  9851. } else {
  9852. obj[key] = value;
  9853. }
  9854. return obj;
  9855. }
  9856. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  9857. if (!privateSet.has(receiver)) {
  9858. throw new TypeError('attempted to get private field on non-instance');
  9859. }
  9860. return fn;
  9861. }
  9862. var Setting_getId = new WeakSet();
  9863. var _environment = new WeakSet();
  9864. class Setting {
  9865. constructor() {
  9866. Setting_classPrivateMethodInitSpec(this, _environment);
  9867. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  9868. Setting_defineProperty(this, 'name', 'Setting');
  9869. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  9870. Setting_defineProperty(this, 'syncData', dataSync);
  9871. }
  9872. tasksHistory() {
  9873. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  9874. }
  9875. static test() {
  9876. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  9877. }
  9878. before() {
  9879. $('body').html('').addClass('auto-task-options');
  9880. }
  9881. after() {
  9882. try {
  9883. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  9884. changeGlobalOptions('page');
  9885. whiteList('page');
  9886. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  9887. $('#getTwitterUserId').on('click', () => {
  9888. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  9889. });
  9890. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  9891. $('#getYoutubeChannelId').on('click', () => {
  9892. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  9893. });
  9894. $('input[name^="position"]').on('input', function() {
  9895. const type = $(this).attr('name').replace('position.', '');
  9896. const xLabel = 'rightleft';
  9897. const yLabel = 'topbottpm';
  9898. switch (type) {
  9899. case 'buttonSideX':
  9900. case 'buttonSideY':
  9901. case 'buttonDistance':
  9902. {
  9903. const distance = $('input[name="position.buttonDistance"]').val();
  9904. const sideX = $('input[name="position.buttonSideX"]').val();
  9905. const sideY = $('input[name="position.buttonSideY"]').val();
  9906. if (![ 'right', 'left' ].includes(sideX)) {
  9907. break;
  9908. }
  9909. if (![ 'top', 'bottom' ].includes(sideY)) {
  9910. break;
  9911. }
  9912. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9913. break;
  9914. }
  9915. const distanceArr = distance.split(',');
  9916. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9917. break;
  9918. }
  9919.  
  9920. case 'showButtonSideX':
  9921. case 'showButtonSideY':
  9922. case 'showButtonDistance':
  9923. {
  9924. const distance = $('input[name="position.showButtonDistance"]').val();
  9925. const sideX = $('input[name="position.showButtonSideX"]').val();
  9926. const sideY = $('input[name="position.showButtonSideY"]').val();
  9927. if (![ 'right', 'left' ].includes(sideX)) {
  9928. break;
  9929. }
  9930. if (![ 'top', 'bottom' ].includes(sideY)) {
  9931. break;
  9932. }
  9933. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9934. break;
  9935. }
  9936. const distanceArr = distance.split(',');
  9937. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9938. break;
  9939. }
  9940.  
  9941. case 'logSideX':
  9942. case 'logSideY':
  9943. case 'logDistance':
  9944. {
  9945. const distance = $('input[name="position.logDistance"]').val();
  9946. const sideX = $('input[name="position.logSideX"]').val();
  9947. const sideY = $('input[name="position.logSideY"]').val();
  9948. if (![ 'right', 'left' ].includes(sideX)) {
  9949. break;
  9950. }
  9951. if (![ 'top', 'bottom' ].includes(sideY)) {
  9952. break;
  9953. }
  9954. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9955. break;
  9956. }
  9957. const distanceArr = distance.split(',');
  9958. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9959. break;
  9960. }
  9961.  
  9962. default:
  9963. break;
  9964. }
  9965. });
  9966. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  9967. let functionKey = '';
  9968. if (event.altKey) {
  9969. functionKey += 'alt + ';
  9970. } else if (event.ctrlKey) {
  9971. functionKey += 'ctrl + ';
  9972. } else if (event.shiftKey) {
  9973. functionKey += 'shift + ';
  9974. }
  9975. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  9976. });
  9977. } catch (error) {
  9978. throwError(error, 'Setting.after');
  9979. }
  9980. }
  9981. saveGlobalOptions() {
  9982. saveData();
  9983. }
  9984. }
  9985. function Setting_getId2(social) {
  9986. try {
  9987. external_Swal_default().fire({
  9988. title: i18n('getId', i18n(social)),
  9989. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9990. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  9991. showCancelButton: true,
  9992. cancelButtonText: i18n('close'),
  9993. showConfirmButton: false
  9994. });
  9995. $('#link2id').on('click', async function() {
  9996. const link = $('#socialLink').val();
  9997. if (!link) {
  9998. return;
  9999. }
  10000. const type = $(this).attr('data-type');
  10001. if (type === 'twitterUser') {
  10002. var _link$match;
  10003. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10004. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10005. } else if (type === 'youtubeChannel') {
  10006. var _link$match2, _await$getInfo, _await$getInfo$params;
  10007. 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;
  10008. $('#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) || '');
  10009. }
  10010. });
  10011. } catch (error) {
  10012. throwError(error, 'Setting.getId');
  10013. }
  10014. }
  10015. function _environment2() {
  10016. try {
  10017. const userAgent = (0, javascript_utils_umd_min.ua)();
  10018. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10019. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10020. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10021. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10022. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10023. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10024. </tbody></table></form>`;
  10025. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10026. } catch (error) {
  10027. throwError(error, 'Setting.environment');
  10028. }
  10029. }
  10030. const website_Setting = Setting;
  10031. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10032. History_checkPrivateRedeclaration(obj, privateSet);
  10033. privateSet.add(obj);
  10034. }
  10035. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10036. if (privateCollection.has(obj)) {
  10037. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10038. }
  10039. }
  10040. function History_defineProperty(obj, key, value) {
  10041. if (key in obj) {
  10042. Object.defineProperty(obj, key, {
  10043. value: value,
  10044. enumerable: true,
  10045. configurable: true,
  10046. writable: true
  10047. });
  10048. } else {
  10049. obj[key] = value;
  10050. }
  10051. return obj;
  10052. }
  10053. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10054. if (!privateSet.has(receiver)) {
  10055. throw new TypeError('attempted to get private field on non-instance');
  10056. }
  10057. return fn;
  10058. }
  10059. var _addItem = new WeakSet();
  10060. class History extends website_Keylol {
  10061. constructor() {
  10062. super(...arguments);
  10063. History_classPrivateMethodInitSpec(this, _addItem);
  10064. History_defineProperty(this, 'name', 'History');
  10065. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10066. }
  10067. static test() {
  10068. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10069. }
  10070. before() {
  10071. try {
  10072. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10073. const data = GM_listValues() || [];
  10074. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10075. for (const item of tasksHistory) {
  10076. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10077. }
  10078. } catch (error) {
  10079. throwError(error, 'History.before');
  10080. }
  10081. }
  10082. clearHistory() {
  10083. try {
  10084. const data = GM_listValues() || [];
  10085. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10086. for (const item of tasksHistory) {
  10087. GM_deleteValue(item);
  10088. }
  10089. external_Swal_default().fire({
  10090. title: i18n('clearHistoryFinished'),
  10091. icon: 'success'
  10092. });
  10093. } catch (error) {
  10094. throwError(error, 'History.after');
  10095. }
  10096. }
  10097. }
  10098. function _addItem2(item) {
  10099. try {
  10100. const tasksData = GM_getValue(item);
  10101. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10102. return;
  10103. }
  10104. let html = '';
  10105. let title = '';
  10106. let link = '';
  10107. const [ website, id ] = item.split('-');
  10108. switch (website) {
  10109. case 'fawTasks':
  10110. title = `Freeanywhere[${id}]`;
  10111. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10112. break;
  10113.  
  10114. case 'gasTasks':
  10115. title = `Giveawaysu[${id}]`;
  10116. link = `https://giveaway.su/giveaway/view/${id}`;
  10117. break;
  10118.  
  10119. case 'gcTasks':
  10120. title = `GiveeClub[${id}]`;
  10121. link = `https://givee.club/event/${id}`;
  10122. break;
  10123.  
  10124. case 'gkTasks':
  10125. title = `Givekey[${id}]`;
  10126. link = `https://givekey.ru/giveaway/${id}`;
  10127. break;
  10128.  
  10129. case 'gleamTasks':
  10130. title = `Gleam[${id}]`;
  10131. link = `https://gleam.io${id}`;
  10132. break;
  10133.  
  10134. case 'khTasks':
  10135. title = `keyhub[${id}]`;
  10136. link = `https://key-hub.eu/giveaway/${id}`;
  10137. break;
  10138.  
  10139. case 'prysTasks':
  10140. title = `Prys[${id}]`;
  10141. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10142. break;
  10143.  
  10144. default:
  10145. return;
  10146. }
  10147. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10148. for (const [ type, tasks ] of Object.entries(types)) {
  10149. for (const task of tasks) {
  10150. 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>`;
  10151. }
  10152. }
  10153. }
  10154. $('.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>`);
  10155. $('span.delete-task').on('click', function() {
  10156. const itemName = $(this).attr('data-name');
  10157. if (itemName) {
  10158. GM_deleteValue(itemName);
  10159. external_Swal_default().fire({
  10160. title: i18n('clearTaskFinished'),
  10161. text: itemName,
  10162. icon: 'success'
  10163. });
  10164. } else {
  10165. external_Swal_default().fire({
  10166. title: i18n('clearTaskFailed'),
  10167. icon: 'error'
  10168. });
  10169. }
  10170. });
  10171. } catch (error) {
  10172. throwError(error, 'History.addItem');
  10173. }
  10174. }
  10175. const website_History = History;
  10176. 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 ];
  10177. const websiteOptions = function(website, options) {
  10178. try {
  10179. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10180. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10181. for (const [ option, value ] of Object.entries(options)) {
  10182. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10183. }
  10184. websiteOptionsForm += '</tbody></table></form>';
  10185. external_Swal_default().fire({
  10186. title: i18n('websiteOptions'),
  10187. html: websiteOptionsForm,
  10188. showConfirmButton: true,
  10189. confirmButtonText: i18n('save'),
  10190. showCancelButton: true,
  10191. cancelButtonText: i18n('close')
  10192. }).then(_ref => {
  10193. let {
  10194. isConfirmed
  10195. } = _ref;
  10196. if (isConfirmed) {
  10197. $('#websiteOptionsForm').serializeArray().map(value => {
  10198. options[value.name] = value.value;
  10199. return value;
  10200. });
  10201. GM_setValue(`${website}Options`, options);
  10202. external_Swal_default().fire({
  10203. title: i18n('changeWebsiteOptionsSuccess'),
  10204. icon: 'success'
  10205. });
  10206. }
  10207. });
  10208. } catch (error) {
  10209. throwError(error, 'websiteOptions');
  10210. }
  10211. };
  10212. const options = websiteOptions;
  10213. const external_keyboardJS_namespaceObject = keyboardJS;
  10214. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10215. const checkUpdate = async (updateLink, auto) => {
  10216. try {
  10217. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10218. const {
  10219. result,
  10220. statusText,
  10221. status,
  10222. data
  10223. } = await tools_httpRequest({
  10224. url: checkUrl,
  10225. responseType: 'json',
  10226. method: 'GET',
  10227. timeout: 3e4
  10228. });
  10229. if (result === 'Success') {
  10230. var _data$response;
  10231. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10232. return data.response;
  10233. }
  10234. if (!auto) {
  10235. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10236. }
  10237. return false;
  10238. }
  10239. if (!auto) {
  10240. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10241. }
  10242. return false;
  10243. } catch (error) {
  10244. throwError(error, 'checkUpdate');
  10245. return false;
  10246. }
  10247. };
  10248. const hasNewVersion = (currentVersion, remoteVersion) => {
  10249. try {
  10250. const [ currentRealVersion ] = currentVersion.split('-');
  10251. const [ remoteRealVersion ] = remoteVersion.split('-');
  10252. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10253. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10254. if (remoteVersion1 > currentVersion1) {
  10255. return true;
  10256. }
  10257. if (remoteVersion1 < currentVersion1) {
  10258. return false;
  10259. }
  10260. if (remoteVersion2 > currentVersion2) {
  10261. return true;
  10262. }
  10263. if (remoteVersion2 < currentVersion2) {
  10264. return false;
  10265. }
  10266. if (remoteVersion3 > currentVersion3) {
  10267. return true;
  10268. }
  10269. return false;
  10270. } catch (error) {
  10271. throwError(error, 'compareVersion');
  10272. return false;
  10273. }
  10274. };
  10275. const updateChecker = async () => {
  10276. try {
  10277. const currentVersion = GM_info.script.version;
  10278. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10279. const updateLinks = {
  10280. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10281. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10282. standby: 'https://auto-task-v4.hclonely.com/'
  10283. };
  10284. let version;
  10285. let updateLink = '';
  10286. let packageData;
  10287. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10288. updateLink = updateLinks[updateSource];
  10289. packageData = await checkUpdate(updateLink, false);
  10290. } else {
  10291. updateLink = updateLinks.github;
  10292. packageData = await checkUpdate(updateLink, true);
  10293. if (!packageData) {
  10294. updateLink = updateLinks.jsdelivr;
  10295. packageData = await checkUpdate(updateLink, true);
  10296. if (!packageData) {
  10297. updateLink = updateLinks.standby;
  10298. packageData = await checkUpdate(updateLink, true);
  10299. }
  10300. }
  10301. }
  10302. if (packageData) {
  10303. version = packageData.version || currentVersion;
  10304. } else {
  10305. version = currentVersion;
  10306. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10307. }
  10308. if (packageData && hasNewVersion(currentVersion, version)) {
  10309. var _packageData$change;
  10310. scripts_echoLog({
  10311. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10312. });
  10313. scripts_echoLog({
  10314. 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>`
  10315. });
  10316. }
  10317. } catch (error) {
  10318. throwError(error, 'updateChecker');
  10319. }
  10320. };
  10321. const scripts_updateChecker = updateChecker;
  10322. if (window.location.hostname === 'discord.com') {
  10323. var _window$localStorage, _window$localStorage$;
  10324. 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, '');
  10325. GM_setValue('discordAuth', {
  10326. auth: discordAuth
  10327. });
  10328. if (discordAuth && window.location.hash === '#auth') {
  10329. window.close();
  10330. external_Swal_default().fire('', i18n('closePageNotice'));
  10331. }
  10332. }
  10333. const loadScript = async () => {
  10334. var _website, _website2, _website3, _website4, _website5, _website6;
  10335. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10336. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10337. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10338. if (isLogin) {
  10339. var _commonOptions, _commonOptions$header;
  10340. GM_setValue('twitchAuth', {
  10341. authToken: authToken,
  10342. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10343. });
  10344. window.close();
  10345. external_Swal_default().fire('', i18n('closePageNotice'));
  10346. } else {
  10347. external_Swal_default().fire('', i18n('needLogin'));
  10348. }
  10349. }
  10350. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10351. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10352. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10353. if (isLogin && ct0) {
  10354. GM_setValue('twitterAuth', {
  10355. ct0: ct0
  10356. });
  10357. window.close();
  10358. external_Swal_default().fire('', i18n('closePageNotice'));
  10359. } else {
  10360. external_Swal_default().fire('', i18n('needLogin'));
  10361. }
  10362. }
  10363. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10364. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10365. if (PAPISID) {
  10366. GM_setValue('youtubeAuth', {
  10367. PAPISID: PAPISID
  10368. });
  10369. window.close();
  10370. external_Swal_default().fire('', i18n('closePageNotice'));
  10371. } else {
  10372. external_Swal_default().fire('', i18n('needLogin'));
  10373. }
  10374. }
  10375. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10376. const betaButton = $('#redesign-beta-optin-btn');
  10377. if (betaButton.length > 0) {
  10378. GM_setValue('redditAuth', '#auth');
  10379. return betaButton[0].click();
  10380. }
  10381. GM_setValue('redditAuth', null);
  10382. window.close();
  10383. external_Swal_default().fire('', i18n('closePageNotice'));
  10384. }
  10385. let website;
  10386. for (const Website of Websites) {
  10387. if (Website.test()) {
  10388. website = new Website();
  10389. break;
  10390. }
  10391. }
  10392. if (!website) {
  10393. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10394. return;
  10395. }
  10396. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10397. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10398. }
  10399. $('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>`);
  10400. $('div.show-button-div').on('click', () => {
  10401. $('#auto-task-buttons').show();
  10402. $('div.show-button-div').hide();
  10403. });
  10404. const toggleLog = () => {
  10405. const $this = $('#toggle-log');
  10406. const status = $this.attr('data-status');
  10407. if (status === 'show') {
  10408. $('#auto-task-info').hide();
  10409. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10410. } else {
  10411. $('#auto-task-info').show();
  10412. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10413. }
  10414. };
  10415. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10416. if (website.doTask) {
  10417. website.doTask();
  10418. }
  10419. });
  10420. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10421. if (website.undoTask) {
  10422. website.doTask();
  10423. }
  10424. });
  10425. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10426. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10427. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10428. }
  10429. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10430. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10431. for (const button of website.buttons) {
  10432. if (website[button]) {
  10433. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10434. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10435. website[button]();
  10436. });
  10437. $('#auto-task-buttons').append(btnElement);
  10438. }
  10439. }
  10440. }
  10441. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10442. ${i18n('hideButton')}</a></p>`);
  10443. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10444. $('#auto-task-buttons').hide();
  10445. $('div.show-button-div').show();
  10446. });
  10447. 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'}">
  10448. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10449. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10450. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10451. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10452. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10453. options(website.name, website.options);
  10454. });
  10455. }
  10456. if (website.name !== 'Setting') {
  10457. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10458. changeGlobalOptions('swal');
  10459. });
  10460. GM_registerMenuCommand(i18n('settingPage'), () => {
  10461. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10462. });
  10463. }
  10464. GM_addStyle(auto_task.Z);
  10465. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10466. if (!GM_getValue('notice')) {
  10467. var _echoLog$font;
  10468. external_Swal_default().fire({
  10469. title: i18n('swalNotice'),
  10470. icon: 'warning'
  10471. }).then(() => {
  10472. window.open(i18n('noticeLink'), '_blank');
  10473. GM_setValue('notice', new Date().getTime());
  10474. });
  10475. (_echoLog$font = scripts_echoLog({
  10476. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10477. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10478. GM_setValue('notice', new Date().getTime());
  10479. });
  10480. }
  10481. scripts_updateChecker();
  10482. };
  10483. if (window.location.hostname === 'opquests.com') {
  10484. loadScript();
  10485. } else {
  10486. $(loadScript);
  10487. }
  10488. }();
  10489. })();