auto-task-v4

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

目前为 2023-01-08 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.29
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12. // @icon https://auto-task-v4.hclonely.com/favicon.ico
  13.  
  14. // @include *://freeanywhere.net/*
  15. // @include *://giveaway.su/giveaway/view/*
  16. // @include *://givee.club/*/event/*
  17. // @include *://givekey.ru/giveaway/*
  18. // @include *://www.indiedb.com/giveaways*
  19. // @include *://key-hub.eu/giveaway/*
  20. // @include *://keylol.com/*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://prys.revadike.com/giveaway/?id=*
  23. // @include *://opquests.com/quests/*
  24. // @include *://gleam.io/*
  25. // @include *://sweepwidget.com/view/*
  26. // @include *://discord.com/*
  27. // @include *://www.twitch.tv/*
  28. // @include *://www.youtube.com/*
  29. // @include *://*.reddit.com/*
  30. // @include *://twitter.com/settings/account?k*
  31. // @include https://auto-task-v4.hclonely.com/setting.html
  32. // @include https://auto-task-v4.hclonely.com/history.html
  33.  
  34. // @grant GM_setValue
  35. // @grant GM_getValue
  36. // @grant GM_listValues
  37. // @grant GM_deleteValue
  38. // @grant GM_addStyle
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_info
  42. // @grant GM_openInTab
  43. // @grant GM_setClipboard
  44. // @grant GM_getResourceText
  45. // @grant unsafeWindow
  46. // @grant window.close
  47. // @grant window.localStorage
  48.  
  49. // @connect cdn.jsdelivr.net
  50. // @connect store.steampowered.com
  51. // @connect steamcommunity.com
  52. // @connect login.steampowered.com
  53. // @connect twitter.com
  54. // @connect api.twitter.com
  55. // @connect youtube.com
  56. // @connect www.youtube.com
  57. // @connect facebook.com
  58. // @connect instagram.com
  59. // @connect vk.com
  60. // @connect twitch.tv
  61. // @connect www.twitch.tv
  62. // @connect gql.twitch.tv
  63. // @connect github.com
  64. // @connect discordapp.com
  65. // @connect discord.gg
  66. // @connect discord.com
  67. // @connect www.reddit.com
  68. // @connect oauth.reddit.com
  69. // @connect raw.githubusercontent.com
  70. // @connect t.me
  71. // @connect bit.ly
  72. // @connect giveaway.su
  73. // @connect google.com
  74. // @connect www.vloot.io
  75. // @connect givee.club
  76. // @connect gleam.io
  77. // @connect www.indiedb.com
  78. // @connect key-hub.eu
  79. // @connect opquests.com
  80. // @connect itch.io
  81. // @connect auto-task-v4.hclonely.com
  82. // @connect *
  83. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  84. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  85. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  86. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  87. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  88. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  89. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  90. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  91.  
  92. // @noframes
  93. // ==/UserScript==
  94.  
  95. console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
  96.  
  97. (function() {
  98. var __webpack_modules__ = {
  99. 588: function(__unused_webpack_module, exports) {
  100. !function(e, n) {
  101. true ? n(exports) : 0;
  102. }(this, function(e) {
  103. 'use strict';
  104. var t = function() {
  105. return (t = Object.assign || function(e) {
  106. for (var n, o = 1, t = arguments.length; o < t; o++) {
  107. for (var r in n = arguments[o]) {
  108. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  109. }
  110. }
  111. return e;
  112. }).apply(this, arguments);
  113. };
  114. function r(e, n, o) {
  115. if (o || 2 === arguments.length) {
  116. for (var t, r = 0, i = n.length; r < i; r++) {
  117. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  118. }
  119. }
  120. return e.concat(t || Array.prototype.slice.call(n));
  121. }
  122. function d(e) {
  123. return '[object Object]' === n(e);
  124. }
  125. function l(e, n) {
  126. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  127. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  128. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  129. });
  130. }
  131. var n = function(e) {
  132. return Object.prototype.toString.call(e);
  133. };
  134. var o = (i.prototype.init = function() {
  135. try {
  136. this.getSystemName(), this.getBrowserName();
  137. } catch (e) {
  138. console.warn('[UA formatter error] '.concat(e));
  139. }
  140. }, i.prototype.getEngine = function() {
  141. var e = this.agent;
  142. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  143. }, i.prototype.getSystemName = function() {
  144. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  145. try {
  146. var o = '';
  147. if (/Windows/i.test(n)) {
  148. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  149. switch (this.info.os = 'Windows', t) {
  150. case '6.3':
  151. o = '8.1';
  152. break;
  153.  
  154. case '6.2':
  155. o = '8';
  156. break;
  157.  
  158. case '6.1':
  159. o = '7';
  160. break;
  161.  
  162. case '5.2':
  163. case '5.1':
  164. o = 'XP';
  165. break;
  166.  
  167. default:
  168. o = t;
  169. }
  170. return this.info.device = 'PC', void (this.info.osVersion = o);
  171. }
  172. if (/^Macintosh/i.test(n)) {
  173. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  174. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  175. }
  176. if (/^iPad/i.test(n)) {
  177. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  178. void (this.info.osVersion = o.replace(/_/g, '.'));
  179. }
  180. if (/^iPhone/i.test(n)) {
  181. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  182. void (this.info.osVersion = o.replace(/_/g, '.'));
  183. }
  184. if (-1 !== n.indexOf('Android')) {
  185. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  186. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  187. }
  188. if (/Linux\s[a-z\d_]+/.test(n)) {
  189. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  190. }
  191. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  192. } catch (e) {
  193. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  194. }
  195. }, i.prototype.getBrowserName = function() {
  196. var e = Object.keys(this.browserNameMap).map(function(e) {
  197. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  198. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  199. return -1 !== e.findIndex(function(e) {
  200. return e.test(n);
  201. });
  202. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  203. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  204. }, i.prototype._formatBrowserVersion = function(e) {
  205. var n, o, t, r;
  206. try {
  207. 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++) {
  208. var d = u[f], l = d[0], h = d[1];
  209. if (new RegExp(l).test(s)) {
  210. c = h;
  211. break;
  212. }
  213. }
  214. var p = {
  215. browserVersion: null != a ? a : 'Unknown',
  216. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  217. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  218. };
  219. return 'Trident' === s && (p.browserVersion = {
  220. '4.0': 8,
  221. '5.0': 9,
  222. '6.0': 10,
  223. '7.0': 11
  224. }[a]), p;
  225. } catch (e) {
  226. return console.warn('[UA formatter error] '.concat(e)), {
  227. browser: 'Unknown',
  228. browserVersion: 'Unknown'
  229. };
  230. }
  231. }, i);
  232. function i(e) {
  233. this.agent = '', this.info = {
  234. browser: '',
  235. browserZH: '',
  236. browserVersion: '',
  237. os: '',
  238. osVersion: '',
  239. device: 'Unknown',
  240. engine: 'WebKit'
  241. }, this.browserNameMap = {
  242. MicroMessenger: {
  243. en: 'MicroMessenger',
  244. zh: '微信'
  245. },
  246. MetaSr: {
  247. en: 'MetaSr',
  248. zh: '搜狗浏览器'
  249. },
  250. 'QQ(Browser)?': {
  251. en: 'QQBrowser',
  252. zh: 'QQ浏览器'
  253. },
  254. UCBrowser: {
  255. en: 'UCBrowser',
  256. zh: 'UC浏览器'
  257. },
  258. '2345Explorer': {
  259. en: '2345Explorer',
  260. zh: '2345极速浏览器'
  261. },
  262. Mb2345Browser: {
  263. en: 'Mb2345Browser',
  264. zh: '2345手机浏览器'
  265. },
  266. Trident: {
  267. en: 'Internet Explorer'
  268. },
  269. 'Edge?': {
  270. en: 'Edge'
  271. },
  272. OPR: {
  273. en: 'Opera'
  274. },
  275. Vivaldi: {
  276. en: 'Vivaldi'
  277. },
  278. Firefox: {
  279. en: 'Firefox'
  280. },
  281. Chrome: {
  282. en: 'Chrome'
  283. },
  284. Safari: {
  285. en: 'Safari'
  286. }
  287. }, this.agent = e, this.init();
  288. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  289. this.info = t(t({}, this.info), {
  290. engine: this.getEngine(),
  291. browserVersion: 'Safari' === o ? n : e
  292. });
  293. }
  294. function s() {
  295. this.cookies = {}, this.init();
  296. }
  297. var a = new (s.prototype.init = function() {
  298. var o = {};
  299. document.cookie.split(/;\s/).forEach(function(e) {
  300. var n = e.split(/=/), e = n[0], n = n[1];
  301. o[e] = n;
  302. }), this.cookies = o;
  303. }, s.prototype.getItem = function(e) {
  304. return this.cookies[e];
  305. }, s.prototype.getAllItems = function() {
  306. return this.cookies;
  307. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  308. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  309. }, s)();
  310. e.countDown = function e(n, o, t, r) {
  311. if (!window) {
  312. throw new Error('window is not defind.');
  313. }
  314. if (0 < n) {
  315. return r && r(), n--, window[o] = window.setTimeout(function() {
  316. e(n, o, t, r);
  317. }, 1e3), function() {
  318. return clearTimeout(window[o]);
  319. };
  320. }
  321. clearTimeout(window[o]), t && t();
  322. }, e.createRandomID = function(e) {
  323. void 0 === e && (e = 12);
  324. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  325. n.push(o[Math.round(Math.random() * t)]);
  326. }
  327. return n.join('');
  328. }, e.dCookie = a, e.debounce = function(o, t, r) {
  329. var i;
  330. void 0 === t && (t = 0);
  331. var s = r = void 0 === r ? !1 : r;
  332. return function() {
  333. var e = this, n = arguments;
  334. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  335. r ? s = !0 : o.apply(e, n);
  336. }, t);
  337. };
  338. }, e.deepCopy = function e(n) {
  339. if (d(n) || Array.isArray(n)) {
  340. var o, t = Array.isArray(n) ? [] : {};
  341. for (o in n) {
  342. t[o] = e(n[o]);
  343. }
  344. return t;
  345. }
  346. return n;
  347. }, e.formatQueryParams = function(e) {
  348. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  349. if (!e) {
  350. return {};
  351. }
  352. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  353. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  354. return t[n] = o, e;
  355. });
  356. }
  357. return t;
  358. }, e.formatThousandth = function(e) {
  359. 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, '$&,');
  360. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  361. }, e.generateTree = function e(n, o, t, r) {
  362. for (var i = [], s = 0; s < n.length; s++) {
  363. var a = n[s];
  364. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  365. }
  366. return i;
  367. }, e.isEmpty = function(e) {
  368. 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);
  369. }, e.isFunction = function(e) {
  370. return '[object Function]' === n(e);
  371. }, e.isImageUrl = function(e) {
  372. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  373. }, e.isObject = d, e.isRegexp = function(e) {
  374. return '[object RegExp]' === n(e);
  375. }, e.objectKeyToCamelCase = function e(n, o, t) {
  376. if (Array.isArray(n)) {
  377. for (var r = [], i = 0; i < n.length; i++) {
  378. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  379. }
  380. } else if (d(n)) {
  381. r = {};
  382. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  383. var f = (u = c[a])[0], u = u[1];
  384. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  385. }
  386. } else {
  387. r = n;
  388. }
  389. return r;
  390. }, e.realType = n, e.searchParams = function(e, n) {
  391. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  392. new URLSearchParams(e).get(n);
  393. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  394. return e.replace(/([A-Z])/g, function(e) {
  395. return '_'.concat(e.toLocaleLowerCase());
  396. });
  397. }, e.ua = function(e) {
  398. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  399. }, Object.defineProperty(e, '__esModule', {
  400. value: !0
  401. });
  402. });
  403. },
  404. 301: function(module, __webpack_exports__, __webpack_require__) {
  405. 'use strict';
  406. __webpack_require__.d(__webpack_exports__, {
  407. Z: function() {
  408. return __WEBPACK_DEFAULT_EXPORT__;
  409. }
  410. });
  411. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  412. 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__);
  413. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  414. 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__);
  415. 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());
  416. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(10px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px #05be0566}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 #fe000066}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:#7676761a;border-top:1px solid #ffffff80;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px #0000001a;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}', '' ]);
  417. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  418. },
  419. 400: function(module) {
  420. 'use strict';
  421. module.exports = function(cssWithMappingToString) {
  422. var list = [];
  423. list.toString = function toString() {
  424. return this.map(function(item) {
  425. var content = '';
  426. var needLayer = typeof item[5] !== 'undefined';
  427. if (item[4]) {
  428. content += '@supports ('.concat(item[4], ') {');
  429. }
  430. if (item[2]) {
  431. content += '@media '.concat(item[2], ' {');
  432. }
  433. if (needLayer) {
  434. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  435. }
  436. content += cssWithMappingToString(item);
  437. if (needLayer) {
  438. content += '}';
  439. }
  440. if (item[2]) {
  441. content += '}';
  442. }
  443. if (item[4]) {
  444. content += '}';
  445. }
  446. return content;
  447. }).join('');
  448. };
  449. list.i = function i(modules, media, dedupe, supports, layer) {
  450. if (typeof modules === 'string') {
  451. modules = [ [ null, modules, undefined ] ];
  452. }
  453. var alreadyImportedModules = {};
  454. if (dedupe) {
  455. for (var k = 0; k < this.length; k++) {
  456. var id = this[k][0];
  457. if (id != null) {
  458. alreadyImportedModules[id] = true;
  459. }
  460. }
  461. }
  462. for (var _k = 0; _k < modules.length; _k++) {
  463. var item = [].concat(modules[_k]);
  464. if (dedupe && alreadyImportedModules[item[0]]) {
  465. continue;
  466. }
  467. if (typeof layer !== 'undefined') {
  468. if (typeof item[5] === 'undefined') {
  469. item[5] = layer;
  470. } else {
  471. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  472. item[5] = layer;
  473. }
  474. }
  475. if (media) {
  476. if (!item[2]) {
  477. item[2] = media;
  478. } else {
  479. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  480. item[2] = media;
  481. }
  482. }
  483. if (supports) {
  484. if (!item[4]) {
  485. item[4] = ''.concat(supports);
  486. } else {
  487. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  488. item[4] = supports;
  489. }
  490. }
  491. list.push(item);
  492. }
  493. };
  494. return list;
  495. };
  496. },
  497. 220: function(module) {
  498. 'use strict';
  499. module.exports = function(i) {
  500. return i[1];
  501. };
  502. }
  503. };
  504. var __webpack_module_cache__ = {};
  505. function __webpack_require__(moduleId) {
  506. var cachedModule = __webpack_module_cache__[moduleId];
  507. if (cachedModule !== undefined) {
  508. return cachedModule.exports;
  509. }
  510. var module = __webpack_module_cache__[moduleId] = {
  511. id: moduleId,
  512. exports: {}
  513. };
  514. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  515. return module.exports;
  516. }
  517. !function() {
  518. __webpack_require__.n = function(module) {
  519. var getter = module && module.__esModule ? function() {
  520. return module['default'];
  521. } : function() {
  522. return module;
  523. };
  524. __webpack_require__.d(getter, {
  525. a: getter
  526. });
  527. return getter;
  528. };
  529. }();
  530. !function() {
  531. __webpack_require__.d = function(exports, definition) {
  532. for (var key in definition) {
  533. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  534. Object.defineProperty(exports, key, {
  535. enumerable: true,
  536. get: definition[key]
  537. });
  538. }
  539. }
  540. };
  541. }();
  542. !function() {
  543. __webpack_require__.o = function(obj, prop) {
  544. return Object.prototype.hasOwnProperty.call(obj, prop);
  545. };
  546. }();
  547. var __webpack_exports__ = {};
  548. !function() {
  549. 'use strict';
  550. const external_Swal_namespaceObject = Swal;
  551. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  552. const external_Cookies_namespaceObject = Cookies;
  553. var auto_task = __webpack_require__(301);
  554. var javascript_utils_umd_min = __webpack_require__(588);
  555. const httpRequest = async function(options) {
  556. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  557. if (window.TRACE) {
  558. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  559. }
  560. try {
  561. const result = await new Promise(resolve => {
  562. if (options.dataType) {
  563. options.responseType = options.dataType;
  564. }
  565. const requestObj = {
  566. ...{
  567. timeout: 3e4,
  568. ontimeout(data) {
  569. resolve({
  570. result: 'Error',
  571. statusText: 'Timeout',
  572. status: 601,
  573. data: data,
  574. options: options
  575. });
  576. },
  577. onabort(data) {
  578. resolve({
  579. result: 'Error',
  580. statusText: 'Aborted',
  581. status: 602,
  582. data: data,
  583. options: options
  584. });
  585. },
  586. onerror(data) {
  587. resolve({
  588. result: 'Error',
  589. statusText: 'Error',
  590. status: 603,
  591. data: data,
  592. options: options
  593. });
  594. },
  595. onload(data) {
  596. resolve({
  597. result: 'Success',
  598. statusText: 'Load',
  599. status: 600,
  600. data: data,
  601. options: options
  602. });
  603. }
  604. },
  605. ...options
  606. };
  607. GM_xmlhttpRequest(requestObj);
  608. });
  609. if (window.DEBUG) {
  610. console.log('%cAuto-Task[httpRequest]:', 'color:blue', JSON.stringify(result));
  611. }
  612. if (result.status !== 600 && times < 2) {
  613. return await httpRequest(options, times + 1);
  614. }
  615. return result;
  616. } catch (error) {
  617. console.log('%cAuto-Task[httpRequest]:', 'color:red', JSON.stringify({
  618. errorMsg: error,
  619. options: options
  620. }));
  621. throwError(error, 'httpRequest');
  622. return {
  623. result: 'JsError',
  624. statusText: 'Error',
  625. status: 604,
  626. error: error,
  627. options: options
  628. };
  629. }
  630. };
  631. const tools_httpRequest = httpRequest;
  632. const echoLog = _ref => {
  633. let {
  634. type,
  635. text,
  636. html,
  637. id
  638. } = _ref;
  639. const emptyStatus = {
  640. success: () => emptyStatus,
  641. error: () => emptyStatus,
  642. warning: () => emptyStatus,
  643. info: () => emptyStatus,
  644. view: () => emptyStatus
  645. };
  646. try {
  647. var _ele$;
  648. let ele;
  649. if (type) {
  650. switch (type) {
  651. case 'joiningSteamGroup':
  652. case 'leavingSteamGroup':
  653. case 'gettingSteamGroupId':
  654. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  655. break;
  656.  
  657. case 'joiningSteamOfficialGroup':
  658. case 'leavingSteamOfficialGroup':
  659. case 'gettingSteamOfficialGroupId':
  660. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/games/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  661. break;
  662.  
  663. case 'subscribingForum':
  664. case 'unsubscribingForum':
  665. case 'gettingForumId':
  666. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>]...<font></font></li>`);
  667. break;
  668.  
  669. case 'followingCurator':
  670. case 'unfollowingCurator':
  671. case 'gettingCuratorId':
  672. 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>`);
  673. break;
  674.  
  675. case 'addingToWishlist':
  676. case 'removingFromWishlist':
  677. case 'followingGame':
  678. case 'unfollowingGame':
  679. case 'gettingSubid':
  680. case 'addingFreeLicense':
  681. case 'requestingPlayTestAccess':
  682. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  683. break;
  684.  
  685. case 'addingFreeLicenseSubid':
  686. ele = $(`<li>${i18n('addingFreeLicense')}[<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  687. break;
  688.  
  689. case 'favoritingWorkshop':
  690. case 'unfavoritingWorkshop':
  691. case 'gettingWorkshopAppId':
  692. case 'votingUpWorkshop':
  693. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  694. ${text}</a>]...<font></font></li>`);
  695. break;
  696.  
  697. case 'gettingAnnouncementParams':
  698. case 'likingAnnouncement':
  699. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  700. ${id}</a>]...<font></font></li>`);
  701. break;
  702.  
  703. case 'joiningDiscordServer':
  704. case 'gettingDiscordGuild':
  705. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  706. break;
  707.  
  708. case 'leavingDiscordServer':
  709. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  710. break;
  711.  
  712. case 'updateDiscordAuth':
  713. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  714. break;
  715.  
  716. case 'followingTwitchChannel':
  717. case 'unfollowingTwitchChannel':
  718. case 'gettingTwitchChannelId':
  719. ele = $(`<li>${i18n(type)}[<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  720. break;
  721.  
  722. case 'gettingInsUserId':
  723. case 'followingIns':
  724. case 'unfollowingIns':
  725. ele = $(`<li>${i18n(type)}[<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  726. break;
  727.  
  728. case 'gettingTwitterUserId':
  729. case 'followingTwitterUser':
  730. case 'unfollowingTwitterUser':
  731. ele = $(`<li>${i18n(type)}[<a href="https://twitter.com/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  732. break;
  733.  
  734. case 'retweetting':
  735. case 'unretweetting':
  736. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  737. break;
  738.  
  739. case 'joiningReddit':
  740. case 'leavingReddit':
  741. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  742. break;
  743.  
  744. case 'followingRedditUser':
  745. case 'unfollowingRedditUser':
  746. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  747. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>]...<font></font></li>`);
  748. break;
  749.  
  750. case 'followingYtbChannel':
  751. case 'unfollowingYtbChannel':
  752. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  753. break;
  754.  
  755. case 'likingYtbVideo':
  756. case 'unlikingYtbVideo':
  757. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>]...<font></font></li>`);
  758. break;
  759.  
  760. case 'gettingVkId':
  761. case 'joiningVkGroup':
  762. case 'leavingVkGroup':
  763. case 'joiningVkPublic':
  764. case 'leavingVkPublic':
  765. case 'sendingVkWall':
  766. case 'deletingVkWall':
  767. ele = $(`<li>${i18n(type)}[<a href="https://vk.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  768. break;
  769.  
  770. case 'visitingLink':
  771. ele = $(`<li>${i18n('visitingLink')}[<a href="${text}" target="_blank">${text}</a>]...<font></font></li>`);
  772. break;
  773.  
  774. case 'verifyingInsAuth':
  775. case 'text':
  776. ele = $(`<li>${i18n(text)}<font></font></li>`);
  777. break;
  778.  
  779. case 'html':
  780. ele = $(text || html);
  781. break;
  782.  
  783. case 'whiteList':
  784. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  785. break;
  786.  
  787. case 'globalOptionsSkip':
  788. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  789. break;
  790.  
  791. default:
  792. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  793. break;
  794. }
  795. } else if (text) {
  796. ele = $(`<li>${i18n(text)}<font></font></li>`);
  797. } else if (html) {
  798. ele = $(html);
  799. } else {
  800. ele = $('<li><font></font></li>');
  801. }
  802. ele.addClass('card-text');
  803. $('#auto-task-info').append(ele);
  804. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  805. const font = ele.find('font');
  806. const status = {
  807. font: font,
  808. success() {
  809. var _this$font, _this$font2, _this$font3;
  810. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  811. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  812. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  813. 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);
  814. return this;
  815. },
  816. error() {
  817. var _this$font4, _this$font5, _this$font6;
  818. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  819. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  820. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  821. 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);
  822. return this;
  823. },
  824. warning() {
  825. var _this$font7, _this$font8, _this$font9;
  826. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  827. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  828. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  829. 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);
  830. return this;
  831. },
  832. info() {
  833. var _this$font10, _this$font11, _this$font12;
  834. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  835. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  836. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  837. 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);
  838. return this;
  839. },
  840. view() {
  841. var _this$font13;
  842. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  843. return this;
  844. }
  845. };
  846. return status;
  847. } catch (error) {
  848. throwError(error, 'echoLog');
  849. return emptyStatus;
  850. }
  851. };
  852. const scripts_echoLog = echoLog;
  853. const unique = array => {
  854. try {
  855. return [ ...new Set(array) ];
  856. } catch (error) {
  857. throwError(error, 'unique');
  858. return [];
  859. }
  860. };
  861. const delay = function() {
  862. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  863. return new Promise(resolve => {
  864. setTimeout(() => {
  865. resolve(true);
  866. }, time);
  867. });
  868. };
  869. const getRedirectLink = async link => {
  870. try {
  871. if (!link) {
  872. return null;
  873. }
  874. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  875. if (redirectLinksCache[link]) {
  876. redirectLinksCache[link];
  877. }
  878. return await tools_httpRequest({
  879. url: link,
  880. method: 'GET'
  881. }).then(_ref => {
  882. let {
  883. data
  884. } = _ref;
  885. if (data !== null && data !== void 0 && data.finalUrl) {
  886. redirectLinksCache[link] = data.finalUrl;
  887. GM_setValue('redirectLinks', redirectLinksCache);
  888. return data.finalUrl;
  889. }
  890. return null;
  891. });
  892. } catch (error) {
  893. throwError(error, 'getRedirectLink');
  894. return null;
  895. }
  896. };
  897. const visitLink = async (link, options) => {
  898. try {
  899. const logStatus = scripts_echoLog({
  900. type: 'visitLink',
  901. text: link
  902. });
  903. return await tools_httpRequest({
  904. url: link,
  905. method: 'GET',
  906. ...options
  907. }).then(_ref2 => {
  908. let {
  909. result,
  910. statusText,
  911. status
  912. } = _ref2;
  913. if (result === 'Success') {
  914. logStatus.success();
  915. return true;
  916. }
  917. logStatus.error(`${result}:${statusText}(${status})`);
  918. return false;
  919. });
  920. } catch (error) {
  921. throwError(error, 'visitLink');
  922. return false;
  923. }
  924. };
  925. const getUrlQuery = url => {
  926. try {
  927. const query = {};
  928. if (url) {
  929. if (url.includes('?')) {
  930. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  931. query[key] = value;
  932. return str;
  933. });
  934. }
  935. } else {
  936. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  937. query[key] = value;
  938. return str;
  939. });
  940. }
  941. return query;
  942. } catch (error) {
  943. throwError(error, 'getUrlQuery');
  944. return {};
  945. }
  946. };
  947. const getUuid = () => {
  948. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  949. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  950. };
  951. const stringToColour = str => {
  952. try {
  953. let hash = 0;
  954. for (let i = 0; i < str.length; i++) {
  955. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  956. }
  957. let colour = '#';
  958. for (let i = 0; i < 3; i++) {
  959. const value = hash >> i * 8 & 255;
  960. colour += `00${value.toString(16)}`.slice(-2);
  961. }
  962. return colour;
  963. } catch (error) {
  964. throwError(error, 'stringToColour');
  965. return '#fff';
  966. }
  967. };
  968. const defaultGlobalOptions = {
  969. doTask: {
  970. discord: {
  971. servers: true
  972. },
  973. instagram: {
  974. users: true
  975. },
  976. twitch: {
  977. channels: true
  978. },
  979. twitter: {
  980. users: true,
  981. retweets: true
  982. },
  983. vk: {
  984. names: true
  985. },
  986. youtube: {
  987. channels: true,
  988. likes: true
  989. },
  990. reddit: {
  991. reddits: true
  992. },
  993. steam: {
  994. groups: true,
  995. officialGroups: true,
  996. wishlists: true,
  997. follows: true,
  998. forums: true,
  999. workshops: true,
  1000. curators: true,
  1001. workshopVotes: true,
  1002. announcements: true,
  1003. licenses: true,
  1004. playtests: true
  1005. }
  1006. },
  1007. undoTask: {
  1008. discord: {
  1009. servers: true
  1010. },
  1011. instagram: {
  1012. users: true
  1013. },
  1014. twitch: {
  1015. channels: true
  1016. },
  1017. twitter: {
  1018. users: true,
  1019. retweets: true
  1020. },
  1021. vk: {
  1022. names: true
  1023. },
  1024. youtube: {
  1025. channels: true,
  1026. likes: true
  1027. },
  1028. reddit: {
  1029. reddits: true
  1030. },
  1031. steam: {
  1032. groups: true,
  1033. officialGroups: true,
  1034. wishlists: true,
  1035. follows: true,
  1036. forums: true,
  1037. workshops: true,
  1038. curators: true
  1039. }
  1040. },
  1041. position: {
  1042. buttonSideX: 'right',
  1043. buttonSideY: 'top',
  1044. buttonDistance: '15,30',
  1045. showButtonSideX: 'right',
  1046. showButtonSideY: 'top',
  1047. showButtonDistance: '15,30',
  1048. logSideX: 'right',
  1049. logSideY: 'bottom',
  1050. logDistance: '10,10'
  1051. },
  1052. hotKey: {
  1053. doTaskKey: 'alt + d',
  1054. undoTaskKey: 'alt + u',
  1055. toggleLogKey: 'alt + l'
  1056. },
  1057. other: {
  1058. twitterVerifyId: '783214',
  1059. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1060. autoUpdateSource: 'jsdelivr',
  1061. language: 'zh',
  1062. checkLogin: true,
  1063. checkLeftKey: true,
  1064. defaultShowButton: true,
  1065. defaultShowLog: true,
  1066. debug: false,
  1067. receivePreview: true
  1068. }
  1069. };
  1070. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1071. const assignObject = (obj1, obj2) => {
  1072. try {
  1073. const newObj = {};
  1074. for (const [ key, value ] of Object.entries(obj1)) {
  1075. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1076. newObj[key] = assignObject(value, obj2[key]);
  1077. } else {
  1078. newObj[key] = obj2[key] ?? value;
  1079. }
  1080. }
  1081. return newObj;
  1082. } catch (error) {
  1083. throwError(error, 'assignObject');
  1084. return defaultGlobalOptions;
  1085. }
  1086. };
  1087. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1088. const saveData = () => {
  1089. try {
  1090. const data = {};
  1091. $('#globalOptionsForm').serializeArray().map(value => {
  1092. data[value.name] = value.value;
  1093. return value;
  1094. });
  1095. $.makeArray($('#globalOptionsForm input')).map(element => {
  1096. const name = $(element).attr('name');
  1097. const keys = name.split('.');
  1098. if (keys.length === 3) {
  1099. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1100. } else if (keys.length === 2) {
  1101. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1102. }
  1103. return element;
  1104. });
  1105. GM_setValue('globalOptions', globalOptions);
  1106. external_Swal_default().fire({
  1107. title: i18n('changeGlobalOptionsSuccess'),
  1108. icon: 'success'
  1109. });
  1110. } catch (error) {
  1111. throwError(error, 'saveData');
  1112. }
  1113. };
  1114. const changeGlobalOptions = showType => {
  1115. try {
  1116. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1117. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1118. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1119. for (const [ option, data2 ] of Object.entries(data1)) {
  1120. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1121. if (typeof data2 === 'boolean') {
  1122. 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>`;
  1123. } else {
  1124. 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>`;
  1125. }
  1126. } else {
  1127. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1128. 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>`;
  1129. }
  1130. }
  1131. }
  1132. }
  1133. globalOptionsForm += '</tbody></table></form>';
  1134. if (showType === 'swal') {
  1135. external_Swal_default().fire({
  1136. title: i18n('globalOptions'),
  1137. html: globalOptionsForm,
  1138. showConfirmButton: true,
  1139. confirmButtonText: i18n('save'),
  1140. showCancelButton: true,
  1141. cancelButtonText: i18n('close')
  1142. }).then(_ref => {
  1143. let {
  1144. isConfirmed
  1145. } = _ref;
  1146. if (isConfirmed) {
  1147. saveData();
  1148. }
  1149. });
  1150. } else {
  1151. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1152. }
  1153. } catch (error) {
  1154. throwError(error, 'changeGlobalOptions');
  1155. }
  1156. };
  1157. const data = {
  1158. website: '网站',
  1159. type: '类型',
  1160. edit: '编辑',
  1161. whiteList: '白名单',
  1162. skipTask: '跳过撤销任务',
  1163. whiteListOptions: '白名单设置',
  1164. changeWhiteListOption: '设置白名单(%0)',
  1165. whiteListNotFound: '找不到此项白名单: %0',
  1166. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1167. changeWebsiteOptions: '网站设置',
  1168. changeGlobalOptions: '全局设置',
  1169. ok: '是',
  1170. save: '保存',
  1171. close: '关闭',
  1172. return: '返回',
  1173. option: '选项',
  1174. value: '值',
  1175. websiteOptions: '当前网站设置',
  1176. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1177. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1178. needLogin: '请先登录!',
  1179. getTasksInfo: '正在获取并处理任务信息...',
  1180. gettingKey: '正在获取Key...',
  1181. verifyingTask: '正在验证任务',
  1182. notice: '自动任务脚本提醒',
  1183. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1184. giveawayEnded: '此活动已结束,是否关闭?',
  1185. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1186. confirm: '确定',
  1187. cancel: '取消',
  1188. unKnown: '未知',
  1189. unKnownTaskType: '未识别的任务',
  1190. doing: '正在做任务',
  1191. allTasksComplete: '所有任务已完成!',
  1192. getTaskIdFailed: '获取任务Id失败!',
  1193. initSuccess: '%0 初始化成功!',
  1194. initFailed: '%0 初始化失败!',
  1195. errorLink: '链接错误: %0',
  1196. needInit: '请先初始化',
  1197. verifyingAuth: '正在验证%0凭证...',
  1198. updatingAuth: '正在更新%0凭证...',
  1199. refreshingToken: '正在刷新%0凭证...',
  1200. settingToken: '正在设置%0凭证...',
  1201. initing: '正在初始化...',
  1202. getFailed: '获取%0失败!',
  1203. checkLoginFailed: '检测登录状态失败!',
  1204. checkLeftKeyFailed: '检测剩余Key失败!',
  1205. userId: '用户Id',
  1206. joiningGiveaway: '正在加入赠Key',
  1207. needJoinGiveaway: '需要先加入赠Key',
  1208. cannotUndo: '此网站不支持取消任务',
  1209. verifyAuth: '正在验证 %0 凭证...',
  1210. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1211. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1212. visitingLink: '正在访问链接: ',
  1213. doTask: '做任务',
  1214. undoTask: '撤销任务',
  1215. verifyTask: '验证任务',
  1216. getKey: '获取Key',
  1217. selectAll: '全选',
  1218. selectNone: '全不选',
  1219. invertSelect: '反选',
  1220. doFreeTask: '加入免费赠品',
  1221. doPointTask: '加入点数赠品',
  1222. skipTaskOption: '设置中已配置跳过任务',
  1223. other: '其他',
  1224. globalOptions: '全局设置',
  1225. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1226. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1227. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1228. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1229. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1230. saveGlobalOptions: '保存全局设置',
  1231. settingPage: '设置页面',
  1232. name: '名称',
  1233. version: '版本',
  1234. scriptManager: '脚本管理器',
  1235. script: '脚本',
  1236. environment: '环境',
  1237. os: '系统',
  1238. browser: '浏览器',
  1239. getId: '获取 %0 id',
  1240. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1241. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1242. showButton: '显示按钮',
  1243. hideButton: '隐藏按钮',
  1244. showLog: '显示日志',
  1245. hideLog: '隐藏日志',
  1246. defaultShowButton: '默认显示按钮',
  1247. defaultShowLog: '默认显示日志',
  1248. debug: '输出调试日志,不要开启此选项!',
  1249. receivePreview: '接收预览版更新',
  1250. position: '组件位置',
  1251. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1252. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1253. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1254. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1255. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1256. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1257. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1258. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1259. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1260. hotKey: '快捷键',
  1261. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1262. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1263. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1264. tasksHistory: '任务历史',
  1265. clearHistory: '清空历史',
  1266. clearHistoryFinished: '已清空任务历史!',
  1267. deleteTask: '删除任务',
  1268. lastChangeTime: '最后一次修改时间',
  1269. clearTaskFinished: '删除以下任务完成!',
  1270. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1271. syncData: '数据同步',
  1272. settingData: '正在上传数据...',
  1273. gettingData: '正在获取数据...',
  1274. help: '帮助',
  1275. fileName: '文件名',
  1276. upload2gist: '同步到Gist',
  1277. downloadFromGist: '从Gist同步',
  1278. saveAndTest: '保存配置并测试',
  1279. testSuccess: '测试成功!',
  1280. testFailed: '测试失败!',
  1281. saveAndTestNotice: '请先保存配置并测试!',
  1282. processingData: '正在处理数据...',
  1283. updatingData: '正在上传数据...',
  1284. syncDataSuccess: '同步数据成功!',
  1285. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1286. downloadingData: '正在下载数据...',
  1287. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1288. savingData: '正在保存数据...',
  1289. syncHistory: '同步任务历史',
  1290. checkUpdateFailed: '检测更新失败',
  1291. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1292. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1293. gistOptions: 'Gist 设置',
  1294. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1295. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1296. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1297. toGithub: '前往Github反馈',
  1298. toKeylol: '前往其乐论坛反馈',
  1299. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1300. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1301. updateText: '%0 版本更新内容:',
  1302. Active: '进行中',
  1303. Ended: '已结束',
  1304. Banned: '已封禁',
  1305. Paused: '已暂停',
  1306. notStart: '未开始',
  1307. noRemoteData: '检测到远程无数据',
  1308. errorRemoteDataFormat: '远程数据格式错误',
  1309. updateHistory: '历史更新记录<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">点此查看</a>',
  1310. groups: '组',
  1311. officialGroups: '官方组',
  1312. wishlists: '愿望单',
  1313. follows: '游戏关注',
  1314. forums: '论坛',
  1315. workshops: '创意工坊收藏',
  1316. curators: '鉴赏家',
  1317. workshopVotes: '创意工坊点赞',
  1318. announcements: '社区通知',
  1319. steamCommunity: 'Steam社区',
  1320. steamStore: 'Steam商店',
  1321. licenses: '入库免费游戏',
  1322. playtests: '请求访问权限',
  1323. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1324. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1325. joiningSteamGroup: '正在加入Steam组',
  1326. leavingSteamGroup: '正在退出Steam组',
  1327. gettingSteamGroupId: '正在获取Steam组Id',
  1328. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1329. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1330. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1331. subscribingForum: '正在订阅Steam论坛',
  1332. unsubscribingForum: '正在取消订阅Steam论坛',
  1333. gettingForumId: '正在获取Steam论坛Id',
  1334. followingCurator: '正在关注Steam鉴赏家',
  1335. unfollowingCurator: '正在取关Steam鉴赏家',
  1336. gettingCuratorId: '正在获取Steam鉴赏家Id',
  1337. addingToWishlist: '正在添加游戏到Steam愿望单',
  1338. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1339. followingGame: '正在关注Steam游戏',
  1340. unfollowingGame: '正在取关Steam游戏',
  1341. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1342. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1343. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1344. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1345. gettingAnnouncementParams: '正在获取Steam通知信息',
  1346. likingAnnouncement: '正在点赞Steam通知',
  1347. changingArea: '正在更换Steam地区: %0...',
  1348. notNeededChangeArea: '当前地区不需要更换',
  1349. noAnotherArea: '请检测是否开启正确开启代理',
  1350. gettingAreaInfo: '正在获取Steam地区信息...',
  1351. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1352. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1353. gettingSubid: '正在获取游戏subid',
  1354. addingFreeLicense: '正在入库',
  1355. missParams: '缺少参数',
  1356. gettingLicenses: '正在获取Licenses...',
  1357. requestingPlayTestAccess: '正在请求访问权限',
  1358. tryChangeAreaNotice: '此功能无法检测游戏是否限区,因此会尝试换区后再入库,换区失败也不影响后续入库',
  1359. servers: '服务器',
  1360. joiningDiscordServer: '正在加入Discord服务器',
  1361. leavingDiscordServer: '正在退出Discord服务器',
  1362. gettingDiscordGuild: '正在获取Discord服务器Id',
  1363. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1364. discordImportantNotice: '重要提醒!!!',
  1365. discordImportantNoticeText: '由于Discord网站后台更新,目前使用此脚本加组后可能会导致Discord帐号被强制退出,且需要两步验证才能正常登录,请谨慎使用!!!',
  1366. continue: '继续',
  1367. skipDiscordTask: '跳过Discord任务',
  1368. continueAndDontRemindAgain: '继续且不再提醒',
  1369. users: '用户',
  1370. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1371. insBanned: '您的Instagram账户已被封禁',
  1372. verifyingInsAuth: '正在验证Instagram凭证...',
  1373. gettingInsUserId: '正在获取Instagram用户Id',
  1374. followingIns: '正在关注Instagram用户',
  1375. unfollowingIns: '正在取关Instagram用户',
  1376. reddits: '社区/用户',
  1377. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1378. changingRedditVersion: '正在切换Reddit为新版页面...',
  1379. joiningReddit: '正在加入Reddit社区',
  1380. leavingReddit: '正在退出Reddit社区',
  1381. followingRedditUser: '正在关注Reddit用户',
  1382. unfollowingRedditUser: '正在取关Reddit用户',
  1383. channels: '频道',
  1384. followingTwitchChannel: '正在关注Twitch频道',
  1385. unfollowingTwitchChannel: '正在取关Twitch频道',
  1386. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1387. checkingTwitchIntegrity: '正在检查Twitch完整性...',
  1388. twitterUser: '推特用户',
  1389. retweets: '转推',
  1390. gettingTwitterUserId: '正在获取推特用户Id',
  1391. followingTwitterUser: '正在关注推特用户',
  1392. unfollowingTwitterUser: '正在取关推特用户',
  1393. retweetting: '正在转推',
  1394. unretweetting: '正在撤销转推',
  1395. names: '组/社区/动态',
  1396. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1397. gettingVkId: '正在获取Vk任务Id',
  1398. joiningVkGroup: '正在加入Vk组',
  1399. leavingVkGroup: '正在退出Vk组',
  1400. joiningVkPublic: '正在加入Vk社区',
  1401. leavingVkPublic: '正在退出Vk社区',
  1402. sendingVkWall: '正在转发Vk动态',
  1403. deletingVkWall: '正在撤销转发Vk动态',
  1404. youtubeChannel: 'YouTube频道',
  1405. likes: '点赞',
  1406. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1407. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1408. gettingYtbToken: '正在获取YouTube Token...',
  1409. followingYtbChannel: '正在订阅YouTube频道',
  1410. unfollowingYtbChannel: '正在退订YouTube频道',
  1411. likingYtbVideo: '正在点赞YouTube视频',
  1412. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1413. giveKeyNoticeBefore: '每次验证间隔15s',
  1414. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1415. noPoints: '点数不够,跳过抽奖',
  1416. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1417. joiningLottery: '正在加入抽奖',
  1418. doingGleamTask: '正在做Gleam任务...',
  1419. gettingGleamLink: '正在获取Gleam任务链接...',
  1420. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1421. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1422. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1423. giveeClubVerifyNotice: '正在验证任务...',
  1424. giveeClubVerifyFinished: '请等待验证完成后自行加入赠Key',
  1425. doingKeyhubTask: '正在做Keyhub任务...',
  1426. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1427. };
  1428. const zh_CN = data;
  1429. const en_US_data = {
  1430. website: 'Website',
  1431. type: 'Type',
  1432. edit: 'Edit',
  1433. whiteList: 'Whitelist',
  1434. skipTask: 'Skip undo task',
  1435. whiteListOptions: 'Whitelist options',
  1436. changeWhiteListOption: 'Whitelist option(%0)',
  1437. whiteListNotFound: 'Cannot find this whitelist: %0',
  1438. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1439. changeWebsiteOptions: 'Website options',
  1440. changeGlobalOptions: 'Global options',
  1441. ok: 'OK',
  1442. save: 'Save',
  1443. close: 'Close',
  1444. return: 'Return',
  1445. option: 'Option',
  1446. value: 'Value',
  1447. websiteOptions: 'Current website settings',
  1448. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1449. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1450. needLogin: 'Please log in first!',
  1451. getTasksInfo: 'Obtaining and processing task information...',
  1452. gettingKey: 'Getting Key...',
  1453. verifyingTask: 'Verifying task',
  1454. notice: 'Automatic task script notice',
  1455. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1456. giveawayEnded: 'This event has ended, do you want to close it?',
  1457. 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?',
  1458. confirm: 'Confirm',
  1459. cancel: 'Cancel',
  1460. unKnown: 'Unknown',
  1461. unKnownTaskType: 'Unrecognized task',
  1462. doing: 'Doing a task',
  1463. allTasksComplete: 'All tasks have been completed!',
  1464. getTaskIdFailed: 'Failed to obtain task Id!',
  1465. initSuccess: '%0 was initialized successfully!',
  1466. initFailed: '%0 initialization failed!',
  1467. errorLink: 'Link error: %0',
  1468. needInit: 'Please initialize first',
  1469. verifyingAuth: 'Verifying %0 token...',
  1470. updatingAuth: 'Update %0 token...',
  1471. initing: 'Initializing...',
  1472. getFailed: 'Failed to get %0!',
  1473. checkLoginFailed: 'Failed to detect login status!',
  1474. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1475. userId: 'User Id',
  1476. joiningGiveaway: 'Joining giveaway',
  1477. needJoinGiveaway: 'Need to join the giveaway first',
  1478. cannotUndo: 'This website does not support canceling tasks',
  1479. verifyAuth: 'Verifying %0 token...',
  1480. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1481. errorReport: 'A script error is detected, do you want to report the BUG?',
  1482. visitingLink: 'Visiting link: ',
  1483. doTask: 'DoTask',
  1484. undoTask: 'UndoTask',
  1485. verifyTask: 'Verify',
  1486. getKey: 'GetKey',
  1487. selectAll: 'SelectAll',
  1488. selectNone: 'SelectNone',
  1489. invertSelect: 'InvertSelect',
  1490. doFreeTask: 'FreeTask',
  1491. doPointTask: 'PointTask',
  1492. skipTaskOption: 'Skip task has been configured in the settings',
  1493. other: 'Other',
  1494. globalOptions: 'Global Options',
  1495. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1496. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1497. 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.',
  1498. 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.',
  1499. 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.',
  1500. saveGlobalOptions: 'SaveSettings',
  1501. settingPage: 'Setting Page',
  1502. name: 'Name',
  1503. version: 'Version',
  1504. scriptManager: 'Script Manager',
  1505. script: 'Script',
  1506. environment: 'Environment',
  1507. os: 'OS',
  1508. browser: 'Browser',
  1509. getId: 'Get %0 id',
  1510. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1511. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1512. showButton: 'ShowButton',
  1513. hideButton: 'HideButton',
  1514. showLog: 'ShowLog',
  1515. hideLog: 'HideLog',
  1516. defaultShowButton: 'Default display button',
  1517. defaultShowLog: 'Display log by default',
  1518. debug: 'Output debug log, do not enable this option!',
  1519. receivePreview: 'Receive preview updates',
  1520. position: 'Component position',
  1521. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1522. 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',
  1523. 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',
  1524. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1525. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1526. 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',
  1527. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1528. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1529. 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',
  1530. hotKey: 'Shortcut key',
  1531. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1532. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1533. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1534. tasksHistory: 'TasksHistory',
  1535. clearHistory: 'Clear history',
  1536. clearHistoryFinished: 'The mission history has been cleared!',
  1537. deleteTask: 'Delete task',
  1538. lastChangeTime: 'Last Change Time',
  1539. clearTaskFinished: 'Delete the following tasks completed!',
  1540. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1541. syncData: 'DataSync',
  1542. settingData: 'Uploading data...',
  1543. gettingData: 'Getting data...',
  1544. help: 'Help',
  1545. fileName: 'Filename',
  1546. upload2gist: 'Sync to Gist',
  1547. downloadFromGist: 'Sync from Gist',
  1548. saveAndTest: 'Save configuration and test',
  1549. testSuccess: 'Test success!',
  1550. testFailed: 'Test failed!',
  1551. saveAndTestNotice: 'Please save the configuration and test first!',
  1552. processingData: 'Processing data...',
  1553. updatingData: 'Uploading data...',
  1554. syncDataSuccess: 'Synchronized data successfully!',
  1555. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1556. downloadingData: 'Downloading data...',
  1557. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1558. savingData: 'Saving data...',
  1559. syncHistory: 'Synchronize tasks history',
  1560. checkUpdateFailed: 'Check update failed',
  1561. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1562. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1563. gistOptions: 'Gist Settings',
  1564. 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!',
  1565. 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!',
  1566. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1567. toGithub: 'Feedback(Github)',
  1568. toKeylol: 'Feedback(Keylol)',
  1569. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1570. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1571. updateText: 'Updates in version %0:',
  1572. Active: 'Active',
  1573. Ended: 'Ended',
  1574. Banned: 'Banned',
  1575. Paused: 'Paused',
  1576. notStart: 'notStart',
  1577. noRemoteData: 'No data remotely',
  1578. errorRemoteDataFormat: 'Remote data has wrong format',
  1579. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1580. groups: 'Group',
  1581. officialGroups: 'Official Group',
  1582. wishlists: 'Wishlist',
  1583. follows: 'Follow Game',
  1584. forums: 'Forum',
  1585. workshops: 'Favorite Workshop',
  1586. curators: 'Curator',
  1587. workshopVotes: 'Voteup Workshop',
  1588. announcements: 'Announcement',
  1589. steamCommunity: 'Steam Community',
  1590. steamStore: 'Steam Store',
  1591. licenses: 'Add License',
  1592. playtests: 'Playtest Access',
  1593. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1594. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1595. joiningSteamGroup: 'Joining Steam Group',
  1596. leavingSteamGroup: 'Leaving Steam Group',
  1597. gettingSteamGroupId: 'Getting Steam Group Id',
  1598. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1599. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1600. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1601. subscribingForum: 'Subscribing the Steam Forum',
  1602. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1603. gettingForumId: 'Getting Steam Forum Id',
  1604. followingCurator: 'Following Steam Curator',
  1605. unfollowingCurator: 'Unfollowing Steam Curator',
  1606. gettingCuratorId: 'Getting Steam Curator Id',
  1607. addingToWishlist: 'Adding the game to the Steam wishlist',
  1608. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1609. followingGame: 'Following Steam games',
  1610. unfollowingGame: 'Unfollowing Steam games',
  1611. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1612. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1613. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1614. votingUpWorkshop: 'Liking Steam workshop items',
  1615. gettingAnnouncementParams: 'Getting Steam announcement information',
  1616. likingAnnouncement: 'Liking Steam announcement',
  1617. changingArea: 'Changing Steam area: %0...',
  1618. notNeededChangeArea: 'The current area does not need to be changed',
  1619. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1620. gettingAreaInfo: 'Getting Steam area information...',
  1621. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1622. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1623. gettingSubid: 'Getting subid',
  1624. addingFreeLicense: 'Adding free license',
  1625. missParams: 'Missing parameters',
  1626. gettingLicenses: 'Getting licenses...',
  1627. requestingPlayTestAccess: 'Requesting play test access',
  1628. tryChangeAreaNotice: 'This function cannot detect whether the game is limited, so it will try to change the area before entering the library' + '. Failure to change the area will not affect the subsequent storage.',
  1629. servers: 'Server',
  1630. joiningDiscordServer: 'Joining Discord Server',
  1631. leavingDiscordServer: 'Leaving Discord Server',
  1632. gettingDiscordGuild: 'Getting Discord server Id',
  1633. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1634. discordImportantNotice: 'Important Reminder! ! !',
  1635. discordImportantNoticeText: 'Due to the background update of the Discord website, currently using this script to join a group may cause the Discord account to be forcibly logged out, and two-step verification is required to log in normally, please use it with caution! ! !',
  1636. continue: 'Continue',
  1637. skipDiscordTask: 'Skip',
  1638. continueAndDontRemindAgain: 'Continue without Reminders',
  1639. users: 'User',
  1640. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1641. insBanned: 'Your Instagram account has been banned',
  1642. verifyingInsAuth: 'Verifying Instagram token...',
  1643. gettingInsUserId: 'Getting Instagram user Id',
  1644. followingIns: 'Following Instagram user',
  1645. unfollowingIns: 'Unfollowing Instagram user',
  1646. reddits: 'Reddit/User',
  1647. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1648. changingRedditVersion: 'Switching Reddit to a new version page...',
  1649. joiningReddit: 'Joining the Reddit',
  1650. leavingReddit: 'Leaving the Reddit',
  1651. followingRedditUser: 'Following Reddit User',
  1652. unfollowingRedditUser: 'Unfollowing Reddit User',
  1653. channels: 'Channel',
  1654. followingTwitchChannel: 'Following Twitch Channel',
  1655. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1656. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1657. checkingTwitchIntegrity: 'Checking Twitch integrity...',
  1658. twitterUser: 'Twitter User',
  1659. retweets: 'Retweet',
  1660. gettingTwitterUserId: 'Getting Twitter User Id',
  1661. followingTwitterUser: 'Following Twitter User',
  1662. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1663. retweetting: 'Retweetting',
  1664. unretweetting: 'Unretweetting',
  1665. names: 'Group/Public/Wall',
  1666. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1667. gettingVkId: 'Getting Vk task Id',
  1668. joiningVkGroup: 'Joining Vk Group',
  1669. leavingVkGroup: 'Leaving Vk Group',
  1670. joiningVkPublic: 'Joining Vk Public',
  1671. leavingVkPublic: 'Leaving Vk Public',
  1672. sendingVkWall: 'Sending Vk Wall',
  1673. deletingVkWall: 'Deleting Vk Wall',
  1674. youtubeChannel: 'YouTube Channel',
  1675. likes: 'Like',
  1676. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1677. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1678. gettingYtbToken: 'Getting YouTube Token...',
  1679. followingYtbChannel: 'Subscribing to YouTube channel',
  1680. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1681. likingYtbVideo: 'Liking YouTube video',
  1682. unlikingYtbVideo: 'Unliking YouTube video',
  1683. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1684. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1685. noPoints: 'Not enough points, skip the lottery',
  1686. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1687. joiningLottery: 'Joining the lottery',
  1688. doingGleamTask: 'Doing Gleam Task...',
  1689. gettingGleamLink: 'Getting Gleam task link...',
  1690. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1691. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1692. 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!',
  1693. giveeClubVerifyNotice: 'Verifying task...',
  1694. giveeClubVerifyFinished: 'Wait for the verification to complete and join it by yourself',
  1695. doingKeyhubTask: 'Doing Keyhub Task...',
  1696. 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...'
  1697. };
  1698. const en_US = en_US_data;
  1699. const languages = {
  1700. zh: zh_CN,
  1701. en: en_US
  1702. };
  1703. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1704. const I18n = function(key) {
  1705. var _languages$language;
  1706. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1707. argvs[_key - 1] = arguments[_key];
  1708. }
  1709. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1710. return key;
  1711. }
  1712. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1713. };
  1714. const i18n = I18n;
  1715. function throwError(error, name) {
  1716. if (window.TRACE) {
  1717. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1718. }
  1719. external_Swal_default().fire({
  1720. title: i18n('errorReport'),
  1721. icon: 'error',
  1722. showCancelButton: true,
  1723. confirmButtonText: i18n('toGithub'),
  1724. showDenyButton: true,
  1725. denyButtonText: i18n('toKeylol'),
  1726. cancelButtonText: i18n('close')
  1727. }).then(_ref => {
  1728. let {
  1729. isDenied,
  1730. isConfirmed
  1731. } = _ref;
  1732. if (isConfirmed) {
  1733. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`[BUG] 脚本报错: ${name}`)}&labels=bug&template=bug_report.yml&website=${encodeURIComponent(window.location.href)}&browser=${encodeURIComponent(JSON.stringify((0,
  1734. javascript_utils_umd_min.ua)(), null, 4))}&manager=${encodeURIComponent(`${GM_info.scriptHandler} ${GM_info.version}`)}&user-script=${encodeURIComponent(GM_info.script.version)}&logs=${encodeURIComponent(error.stack || 'null')}&run-logs=${encodeURIComponent($.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n'))}`, '_blank');
  1735. } else if (isDenied) {
  1736. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1737.  
  1738. 环境:
  1739.  
  1740. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1741.  
  1742. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1743. 脚本版本: ${GM_info.script.version}
  1744.  
  1745. 报错信息:
  1746. [code]${error.stack}[/code]
  1747.  
  1748. 执行日志:
  1749. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1750. GM_setClipboard(text);
  1751. external_Swal_default().fire({
  1752. title: i18n('copySuccess'),
  1753. icon: 'success',
  1754. confirmButtonText: i18n('ok')
  1755. }).then(() => {
  1756. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1757. });
  1758. }
  1759. });
  1760. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1761. }
  1762. class Social {
  1763. tasks;
  1764. getRealParams(name, links, doTask, link2param) {
  1765. try {
  1766. let realParams = [];
  1767. if (links.length > 0) {
  1768. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1769. }
  1770. if (!doTask && this.tasks[name].length > 0) {
  1771. realParams = [ ...realParams, ...this.tasks[name] ];
  1772. }
  1773. return unique(realParams);
  1774. } catch (error) {
  1775. throwError(error, 'Social.getRealParams');
  1776. return [];
  1777. }
  1778. }
  1779. }
  1780. const social_Social = Social;
  1781. var _GM_getValue;
  1782. const defaultTasksTemplate = {
  1783. servers: []
  1784. };
  1785. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1786. class Discord extends social_Social {
  1787. tasks = JSON.parse(defaultTasks);
  1788. whiteList = {
  1789. ...JSON.parse(defaultTasks),
  1790. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1791. };
  1792. #auth = GM_getValue('discordAuth') || {};
  1793. #cache = GM_getValue('discordCache') || {};
  1794. #initialized = false;
  1795. async init() {
  1796. try {
  1797. if (!GM_getValue('dontRemindDiscordAgain')) {
  1798. const result = await external_Swal_default().fire({
  1799. title: i18n('discordImportantNotice'),
  1800. text: i18n('discordImportantNoticeText'),
  1801. showCancelButton: true,
  1802. showDenyButton: true,
  1803. confirmButtonText: i18n('continue'),
  1804. cancelButtonText: i18n('skipDiscordTask'),
  1805. denyButtonText: i18n('continueAndDontRemindAgain')
  1806. }).then(_ref => {
  1807. let {
  1808. isConfirmed,
  1809. isDenied
  1810. } = _ref;
  1811. if (isConfirmed) {
  1812. return true;
  1813. }
  1814. if (isDenied) {
  1815. GM_setValue('dontRemindDiscordAgain', true);
  1816. return true;
  1817. }
  1818. return false;
  1819. });
  1820. if (!result) {
  1821. this.#initialized = false;
  1822. return 'skip';
  1823. }
  1824. }
  1825. if (this.#initialized) {
  1826. return true;
  1827. }
  1828. if (!this.#auth.auth) {
  1829. if (await this.#updateAuth()) {
  1830. this.#initialized = true;
  1831. return true;
  1832. }
  1833. return false;
  1834. }
  1835. const isVerified = await this.#verifyAuth();
  1836. if (isVerified) {
  1837. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1838. this.#initialized = true;
  1839. return true;
  1840. }
  1841. GM_setValue('discordAuth', {
  1842. auth: null
  1843. });
  1844. if (await this.#updateAuth()) {
  1845. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1846. this.#initialized = true;
  1847. return true;
  1848. }
  1849. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1850. return false;
  1851. } catch (error) {
  1852. throwError(error, 'Discord.init');
  1853. return false;
  1854. }
  1855. }
  1856. async #verifyAuth() {
  1857. try {
  1858. const logStatus = scripts_echoLog({
  1859. text: i18n('verifyingAuth', 'Discord')
  1860. });
  1861. const {
  1862. result,
  1863. statusText,
  1864. status,
  1865. data
  1866. } = await tools_httpRequest({
  1867. url: 'https://discord.com/api/v6/users/@me',
  1868. method: 'HEAD',
  1869. headers: {
  1870. authorization: this.#auth.auth
  1871. }
  1872. });
  1873. if (result === 'Success') {
  1874. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1875. logStatus.success();
  1876. return true;
  1877. }
  1878. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1879. return false;
  1880. }
  1881. logStatus.error(`${result}:${statusText}(${status})`);
  1882. return false;
  1883. } catch (error) {
  1884. throwError(error, 'Discord.verifyAuth');
  1885. return false;
  1886. }
  1887. }
  1888. async #updateAuth() {
  1889. try {
  1890. const logStatus = scripts_echoLog({
  1891. text: i18n('updatingAuth', 'Discord')
  1892. });
  1893. return await new Promise(resolve => {
  1894. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1895. active: true,
  1896. insert: true,
  1897. setParent: true
  1898. });
  1899. newTab.onclose = async () => {
  1900. var _GM_getValue2;
  1901. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1902. if (auth) {
  1903. this.#auth = {
  1904. auth: auth
  1905. };
  1906. logStatus.success();
  1907. resolve(await this.#verifyAuth());
  1908. } else {
  1909. logStatus.error('Error: Update discord auth failed!');
  1910. resolve(false);
  1911. }
  1912. };
  1913. });
  1914. } catch (error) {
  1915. throwError(error, 'Discord.updateAuth');
  1916. return false;
  1917. }
  1918. }
  1919. async #joinServer(inviteId) {
  1920. try {
  1921. const logStatus = scripts_echoLog({
  1922. type: 'joiningDiscordServer',
  1923. text: inviteId
  1924. });
  1925. const {
  1926. result,
  1927. statusText,
  1928. status,
  1929. data
  1930. } = await tools_httpRequest({
  1931. url: `https://discord.com/api/v9/invites/${inviteId}`,
  1932. method: 'POST',
  1933. dataType: 'json',
  1934. headers: {
  1935. authorization: this.#auth.auth,
  1936. origin: 'https://discord.com',
  1937. referer: `https://discord.com/invite/${inviteId}`
  1938. }
  1939. });
  1940. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1941. var _data$response, _data$response$guild;
  1942. logStatus.success();
  1943. 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);
  1944. if (guild) {
  1945. this.#setCache(inviteId, guild);
  1946. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1947. }
  1948. return true;
  1949. }
  1950. logStatus.error(`${result}:${statusText}(${status})`);
  1951. return false;
  1952. } catch (error) {
  1953. throwError(error, 'Discord.joinServer');
  1954. return false;
  1955. }
  1956. }
  1957. async #leaveServer(inviteId) {
  1958. try {
  1959. if (this.whiteList.servers.includes(inviteId)) {
  1960. scripts_echoLog({
  1961. type: 'whiteList',
  1962. text: 'Discord.leaveServer',
  1963. id: inviteId
  1964. });
  1965. return true;
  1966. }
  1967. const guild = await this.#getGuild(inviteId);
  1968. if (!guild) {
  1969. return false;
  1970. }
  1971. const logStatus = scripts_echoLog({
  1972. type: 'leavingDiscordServer',
  1973. text: guild
  1974. });
  1975. const {
  1976. result,
  1977. statusText,
  1978. status,
  1979. data
  1980. } = await tools_httpRequest({
  1981. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  1982. method: 'DELETE',
  1983. headers: {
  1984. authorization: this.#auth.auth
  1985. }
  1986. });
  1987. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  1988. logStatus.success();
  1989. return true;
  1990. }
  1991. logStatus.error(`${result}:${statusText}(${status})`);
  1992. return false;
  1993. } catch (error) {
  1994. throwError(error, 'Discord.leaveServer');
  1995. return false;
  1996. }
  1997. }
  1998. async #getGuild(inviteId) {
  1999. try {
  2000. const logStatus = scripts_echoLog({
  2001. type: 'gettingDiscordGuild',
  2002. text: inviteId
  2003. });
  2004. const guild = this.#cache[inviteId];
  2005. if (guild) {
  2006. logStatus.success();
  2007. return guild;
  2008. }
  2009. const {
  2010. result,
  2011. statusText,
  2012. status,
  2013. data
  2014. } = await tools_httpRequest({
  2015. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2016. responseType: 'json',
  2017. method: 'GET'
  2018. });
  2019. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2020. var _data$response2, _data$response2$guild;
  2021. const guild = (_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$guild = _data$response2.guild) === null || _data$response2$guild === void 0 ? void 0 : _data$response2$guild.id;
  2022. if (guild) {
  2023. logStatus.success();
  2024. this.#setCache(inviteId, guild);
  2025. return guild;
  2026. }
  2027. logStatus.error(`${result}:${statusText}(${status})`);
  2028. return false;
  2029. }
  2030. logStatus.error(`${result}:${statusText}(${status})`);
  2031. return false;
  2032. } catch (error) {
  2033. throwError(error, 'Discord.getGuild');
  2034. return false;
  2035. }
  2036. }
  2037. async toggle(_ref2) {
  2038. let {
  2039. doTask = true,
  2040. serverLinks = []
  2041. } = _ref2;
  2042. try {
  2043. if (!this.#initialized) {
  2044. scripts_echoLog({
  2045. text: i18n('needInit')
  2046. });
  2047. return false;
  2048. }
  2049. const prom = [];
  2050. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  2051. scripts_echoLog({
  2052. type: 'globalOptionsSkip',
  2053. text: 'discord.servers'
  2054. });
  2055. } else {
  2056. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  2057. var _link$match;
  2058. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2059. });
  2060. if (realServers.length > 0) {
  2061. for (const server of realServers) {
  2062. if (doTask) {
  2063. prom.push(this.#joinServer(server));
  2064. } else {
  2065. prom.push(this.#leaveServer(server));
  2066. }
  2067. await delay(1e3);
  2068. }
  2069. }
  2070. }
  2071. return await Promise.all(prom).then(() => true);
  2072. } catch (error) {
  2073. throwError(error, 'Discord.toggleServers');
  2074. return false;
  2075. }
  2076. }
  2077. #setCache(inviteId, guild) {
  2078. try {
  2079. this.#cache[inviteId] = guild;
  2080. GM_setValue('discordCache', this.#cache);
  2081. } catch (error) {
  2082. throwError(error, 'Discord.setCache');
  2083. }
  2084. }
  2085. }
  2086. const social_Discord = Discord;
  2087. var Instagram_GM_getValue;
  2088. const Instagram_defaultTasksTemplate = {
  2089. users: []
  2090. };
  2091. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2092. class Instagram extends social_Social {
  2093. tasks = JSON.parse(Instagram_defaultTasks);
  2094. whiteList = {
  2095. ...JSON.parse(Instagram_defaultTasks),
  2096. ...(Instagram_GM_getValue = GM_getValue('whiteList')) === null || Instagram_GM_getValue === void 0 ? void 0 : Instagram_GM_getValue.instagram
  2097. };
  2098. #cache = GM_getValue('instagramCache') || {};
  2099. #auth = {};
  2100. #initialized = false;
  2101. async init() {
  2102. try {
  2103. if (this.#initialized) {
  2104. return true;
  2105. }
  2106. const isVerified = await this.#getUserInfo();
  2107. if (isVerified) {
  2108. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2109. this.#initialized = true;
  2110. return true;
  2111. }
  2112. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2113. return false;
  2114. } catch (error) {
  2115. throwError(error, 'Instagram.init');
  2116. return false;
  2117. }
  2118. }
  2119. async #getUserInfo() {
  2120. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2121. try {
  2122. const logStatus = scripts_echoLog({
  2123. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2124. text: name
  2125. });
  2126. const userId = this.#cache[name];
  2127. if (userId && name !== 'instagram') {
  2128. logStatus.success();
  2129. return userId;
  2130. }
  2131. const {
  2132. result,
  2133. statusText,
  2134. status,
  2135. data
  2136. } = await tools_httpRequest({
  2137. url: `https://www.instagram.com/${name}/`,
  2138. method: 'GET'
  2139. });
  2140. if (result === 'Success') {
  2141. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2142. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2143. return false;
  2144. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2145. logStatus.error(`Error:${i18n('insBanned')}`);
  2146. return false;
  2147. }
  2148. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2149. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2150. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2151. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2152. if (name === 'instagram') {
  2153. if (csrftoken && hash) {
  2154. this.#auth = {
  2155. csrftoken: csrftoken,
  2156. hash: hash
  2157. };
  2158. return true;
  2159. }
  2160. return false;
  2161. }
  2162. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2163. if (id) {
  2164. this.#setCache(name, id);
  2165. logStatus.success();
  2166. return id;
  2167. }
  2168. logStatus.error('Error: Get ins data error!');
  2169. return false;
  2170. }
  2171. logStatus.error(`${result}:${statusText}(${status})`);
  2172. return false;
  2173. }
  2174. return false;
  2175. } catch (error) {
  2176. throwError(error, 'Instagram.getUserInfo');
  2177. return false;
  2178. }
  2179. }
  2180. async #followUser(name) {
  2181. try {
  2182. const id = await this.#getUserInfo(name);
  2183. if (!id) {
  2184. return false;
  2185. }
  2186. const logStatus = scripts_echoLog({
  2187. type: 'followingIns',
  2188. text: name
  2189. });
  2190. const {
  2191. result,
  2192. statusText,
  2193. status,
  2194. data
  2195. } = await tools_httpRequest({
  2196. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2197. method: 'POST',
  2198. dataType: 'json',
  2199. headers: {
  2200. 'x-csrftoken': this.#auth.csrftoken,
  2201. origin: 'https://www.instagram.com',
  2202. referer: `https://www.instagram.com/${name}/`,
  2203. 'content-type': 'application/x-www-form-urlencoded',
  2204. 'sec-fetch-site': 'same-origin',
  2205. 'x-instagram-ajax': this.#auth.hash
  2206. }
  2207. });
  2208. if (result === 'Success') {
  2209. var _data$response, _data$response2;
  2210. 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') {
  2211. logStatus.success();
  2212. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2213. return true;
  2214. }
  2215. 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})`}`);
  2216. return false;
  2217. }
  2218. logStatus.error(`${result}:${statusText}(${status})`);
  2219. return false;
  2220. } catch (error) {
  2221. throwError(error, 'Instagram.followUser');
  2222. return false;
  2223. }
  2224. }
  2225. async #unfollowUser(name) {
  2226. try {
  2227. if (this.whiteList.users.includes(name)) {
  2228. scripts_echoLog({
  2229. type: 'whiteList',
  2230. text: 'Instagram.unfollowUser',
  2231. id: name
  2232. });
  2233. return true;
  2234. }
  2235. const id = await this.#getUserInfo(name);
  2236. if (!id) {
  2237. return false;
  2238. }
  2239. const logStatus = scripts_echoLog({
  2240. type: 'unfollowingIns',
  2241. text: name
  2242. });
  2243. const {
  2244. result,
  2245. statusText,
  2246. status,
  2247. data
  2248. } = await tools_httpRequest({
  2249. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2250. method: 'POST',
  2251. dataType: 'json',
  2252. headers: {
  2253. 'x-csrftoken': this.#auth.csrftoken,
  2254. origin: 'https://www.instagram.com',
  2255. referer: `https://www.instagram.com/${name}/`,
  2256. 'content-type': 'application/x-www-form-urlencoded',
  2257. 'sec-fetch-site': 'same-origin',
  2258. 'x-instagram-ajax': this.#auth.hash
  2259. }
  2260. });
  2261. if (result === 'Success') {
  2262. var _data$response3;
  2263. 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') {
  2264. logStatus.success();
  2265. return true;
  2266. }
  2267. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2268. return false;
  2269. }
  2270. logStatus.error(`${result}:${statusText}(${status})`);
  2271. return false;
  2272. } catch (error) {
  2273. throwError(error, 'Instagram.unfollowUser');
  2274. return false;
  2275. }
  2276. }
  2277. async toggle(_ref) {
  2278. let {
  2279. doTask = true,
  2280. userLinks = []
  2281. } = _ref;
  2282. try {
  2283. if (!this.#initialized) {
  2284. scripts_echoLog({
  2285. text: i18n('needInit')
  2286. });
  2287. return false;
  2288. }
  2289. const prom = [];
  2290. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2291. scripts_echoLog({
  2292. type: 'globalOptionsSkip',
  2293. text: 'instagram.users'
  2294. });
  2295. } else {
  2296. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2297. var _link$match;
  2298. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2299. });
  2300. if (realUsers.length > 0) {
  2301. for (const username of realUsers) {
  2302. if (doTask) {
  2303. prom.push(this.#followUser(username));
  2304. } else {
  2305. prom.push(this.#unfollowUser(username));
  2306. }
  2307. await delay(1e3);
  2308. }
  2309. }
  2310. }
  2311. return await Promise.all(prom).then(() => true);
  2312. } catch (error) {
  2313. throwError(error, 'Instagram.toggleUsers');
  2314. return false;
  2315. }
  2316. }
  2317. #setCache(name, id) {
  2318. try {
  2319. this.#cache[name] = id;
  2320. GM_setValue('instagramCache', this.#cache);
  2321. } catch (error) {
  2322. throwError(error, 'Instagram.setCache');
  2323. }
  2324. }
  2325. }
  2326. const social_Instagram = Instagram;
  2327. var Reddit_GM_getValue;
  2328. const Reddit_defaultTasksTemplate = {
  2329. reddits: []
  2330. };
  2331. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2332. class Reddit extends social_Social {
  2333. tasks = JSON.parse(Reddit_defaultTasks);
  2334. whiteList = {
  2335. ...JSON.parse(Reddit_defaultTasks),
  2336. ...(Reddit_GM_getValue = GM_getValue('whiteList')) === null || Reddit_GM_getValue === void 0 ? void 0 : Reddit_GM_getValue.reddit
  2337. };
  2338. #auth;
  2339. #initialized = false;
  2340. async init() {
  2341. try {
  2342. if (this.#initialized) {
  2343. return true;
  2344. }
  2345. const isVerified = await this.#updateAuth();
  2346. if (isVerified) {
  2347. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2348. this.#initialized = true;
  2349. return true;
  2350. }
  2351. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2352. return false;
  2353. } catch (error) {
  2354. throwError(error, 'Reddit.init');
  2355. return false;
  2356. }
  2357. }
  2358. async #useBeta() {
  2359. try {
  2360. const logStatus = scripts_echoLog({
  2361. text: i18n('changingRedditVersion')
  2362. });
  2363. GM_setValue('redditAuth', null);
  2364. return await new Promise(resolve => {
  2365. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2366. active: true,
  2367. insert: true,
  2368. setParent: true
  2369. });
  2370. newTab.onclose = async () => {
  2371. logStatus.success();
  2372. resolve(await this.#updateAuth(true));
  2373. };
  2374. });
  2375. } catch (error) {
  2376. throwError(error, 'Reddit.useBeta');
  2377. return false;
  2378. }
  2379. }
  2380. async #updateAuth() {
  2381. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2382. try {
  2383. const logStatus = scripts_echoLog({
  2384. text: i18n('updatingAuth', 'Reddit')
  2385. });
  2386. const {
  2387. result,
  2388. statusText,
  2389. status,
  2390. data
  2391. } = await tools_httpRequest({
  2392. url: 'https://www.reddit.com/',
  2393. method: 'GET',
  2394. nochche: true,
  2395. headers: {
  2396. 'Cache-Control': 'no-cache'
  2397. }
  2398. });
  2399. if (result === 'Success') {
  2400. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2401. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2402. return false;
  2403. }
  2404. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2405. var _data$responseText$ma;
  2406. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2407. return await this.#useBeta();
  2408. }
  2409. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2410. if (accessToken) {
  2411. this.#auth = {
  2412. token: accessToken
  2413. };
  2414. logStatus.success();
  2415. return true;
  2416. }
  2417. logStatus.error('Error: Parameter "accessToken" not found!');
  2418. return false;
  2419. }
  2420. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2421. return false;
  2422. }
  2423. logStatus.error(`${result}:${statusText}(${status})`);
  2424. return false;
  2425. } catch (error) {
  2426. throwError(error, 'Reddit.updateAuth');
  2427. return false;
  2428. }
  2429. }
  2430. async toggleTask(_ref) {
  2431. let {
  2432. name,
  2433. doTask = true
  2434. } = _ref;
  2435. try {
  2436. if (!doTask && this.whiteList.reddits.includes(name)) {
  2437. scripts_echoLog({
  2438. type: 'whiteList',
  2439. text: 'Reddit.undoTask',
  2440. id: name
  2441. });
  2442. return true;
  2443. }
  2444. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2445. if (/^u_/.test(name)) {
  2446. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2447. }
  2448. const logStatus = scripts_echoLog({
  2449. type: type,
  2450. text: name
  2451. });
  2452. const {
  2453. result,
  2454. statusText,
  2455. status,
  2456. data
  2457. } = await tools_httpRequest({
  2458. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2459. method: 'POST',
  2460. headers: {
  2461. authorization: `Bearer ${this.#auth.token}`,
  2462. 'content-type': 'application/x-www-form-urlencoded'
  2463. },
  2464. data: $.param({
  2465. action: doTask ? 'sub' : 'unsub',
  2466. sr_name: name,
  2467. api_type: 'json'
  2468. })
  2469. });
  2470. if (result === 'Success') {
  2471. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2472. logStatus.success();
  2473. if (doTask) {
  2474. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2475. }
  2476. return true;
  2477. }
  2478. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2479. return false;
  2480. }
  2481. logStatus.error(`${result}:${statusText}(${status})`);
  2482. return false;
  2483. } catch (error) {
  2484. throwError(error, 'Reddit.toggleTask');
  2485. return false;
  2486. }
  2487. }
  2488. async toggle(_ref2) {
  2489. let {
  2490. doTask = true,
  2491. redditLinks = []
  2492. } = _ref2;
  2493. try {
  2494. if (!this.#initialized) {
  2495. scripts_echoLog({
  2496. text: i18n('needInit')
  2497. });
  2498. return false;
  2499. }
  2500. const prom = [];
  2501. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2502. scripts_echoLog({
  2503. type: 'globalOptionsSkip',
  2504. text: 'reddit.reddits'
  2505. });
  2506. } else {
  2507. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2508. var _link$match, _link$match2;
  2509. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2510. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2511. if (userName) {
  2512. return name || userName;
  2513. }
  2514. return name;
  2515. });
  2516. if (realReddits.length > 0) {
  2517. for (const name of realReddits) {
  2518. prom.push(this.toggleTask({
  2519. name: name,
  2520. doTask: doTask
  2521. }));
  2522. await delay(1e3);
  2523. }
  2524. }
  2525. }
  2526. return await Promise.all(prom).then(() => true);
  2527. } catch (error) {
  2528. throwError(error, 'Reddit.toggle');
  2529. return false;
  2530. }
  2531. }
  2532. }
  2533. const social_Reddit = Reddit;
  2534. var Twitch_GM_getValue;
  2535. const Twitch_defaultTasksTemplate = {
  2536. channels: []
  2537. };
  2538. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2539. class Twitch extends social_Social {
  2540. tasks = JSON.parse(Twitch_defaultTasks);
  2541. whiteList = {
  2542. ...JSON.parse(Twitch_defaultTasks),
  2543. ...(Twitch_GM_getValue = GM_getValue('whiteList')) === null || Twitch_GM_getValue === void 0 ? void 0 : Twitch_GM_getValue.twitch
  2544. };
  2545. #auth = GM_getValue('twitchAuth') || {};
  2546. #cache = GM_getValue('twitchCache') || {};
  2547. #initialized = false;
  2548. #integrityToken;
  2549. async init() {
  2550. try {
  2551. if (this.#initialized) {
  2552. return true;
  2553. }
  2554. if (!this.#auth.authToken || !this.#auth.clientId || !this.#auth.clientVersion || !this.#auth.deviceId || !this.#auth.clientSessionId) {
  2555. if (await this.#updateAuth()) {
  2556. this.#initialized = true;
  2557. return true;
  2558. }
  2559. return false;
  2560. }
  2561. const isVerified = await this.#verifyAuth();
  2562. if (isVerified) {
  2563. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2564. this.#initialized = true;
  2565. return true;
  2566. }
  2567. GM_setValue('twitchAuth', null);
  2568. if (await this.#updateAuth()) {
  2569. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2570. this.#initialized = true;
  2571. return true;
  2572. }
  2573. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2574. return false;
  2575. } catch (error) {
  2576. throwError(error, 'Twitch.init');
  2577. return false;
  2578. }
  2579. }
  2580. async #verifyAuth() {
  2581. try {
  2582. const logStatus = scripts_echoLog({
  2583. text: i18n('verifyingAuth', 'Twitch')
  2584. });
  2585. const {
  2586. result,
  2587. statusText,
  2588. status,
  2589. data
  2590. } = await tools_httpRequest({
  2591. url: 'https://gql.twitch.tv/gql',
  2592. method: 'POST',
  2593. dataType: 'json',
  2594. headers: {
  2595. Authorization: `OAuth ${this.#auth.authToken}`,
  2596. 'Client-Id': this.#auth.clientId
  2597. },
  2598. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2599. });
  2600. if (result === 'Success') {
  2601. var _data$response, _data$response$, _data$response$$data;
  2602. 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) {
  2603. await this.#integrity();
  2604. logStatus.success();
  2605. return true;
  2606. }
  2607. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2608. return false;
  2609. }
  2610. logStatus.error(`${result}:${statusText}(${status})`);
  2611. return false;
  2612. } catch (error) {
  2613. throwError(error, 'Twitch.verifyAuth');
  2614. return false;
  2615. }
  2616. }
  2617. async #integrity() {
  2618. let ct = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  2619. try {
  2620. const logStatus = scripts_echoLog({
  2621. text: i18n('checkingTwitchIntegrity')
  2622. });
  2623. const {
  2624. result,
  2625. statusText,
  2626. status,
  2627. data
  2628. } = await tools_httpRequest({
  2629. url: 'https://gql.twitch.tv/integrity',
  2630. method: 'POST',
  2631. dataType: 'json',
  2632. anonymous: true,
  2633. headers: {
  2634. Origin: 'https://www.twitch.tv',
  2635. Referer: 'https://www.twitch.tv/',
  2636. Authorization: `OAuth ${this.#auth.authToken}`,
  2637. 'Client-Id': this.#auth.clientId,
  2638. 'Client-Version': this.#auth.clientVersion,
  2639. 'X-Device-Id': this.#auth.deviceId,
  2640. 'Client-Session-Id': this.#auth.clientSessionId,
  2641. 'x-kpsdk-ct': ct
  2642. }
  2643. });
  2644. if (result === 'Success') {
  2645. var _data$responseHeaders, _data$response2;
  2646. if (!ct && data !== null && data !== void 0 && (_data$responseHeaders = data.responseHeaders) !== null && _data$responseHeaders !== void 0 && _data$responseHeaders['x-kpsdk-ct']) {
  2647. return await this.#integrity(data.responseHeaders['x-kpsdk-ct']);
  2648. }
  2649. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.token) {
  2650. this.#integrityToken = data.response.token;
  2651. logStatus.success();
  2652. return true;
  2653. }
  2654. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2655. return false;
  2656. }
  2657. logStatus.error(`${result}:${statusText}(${status})`);
  2658. return false;
  2659. } catch (error) {
  2660. throwError(error, 'Twitch.integrity');
  2661. return false;
  2662. }
  2663. }
  2664. async #updateAuth() {
  2665. try {
  2666. const logStatus = scripts_echoLog({
  2667. text: i18n('updatingAuth', 'Twitch')
  2668. });
  2669. return await new Promise(resolve => {
  2670. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2671. active: true,
  2672. insert: true,
  2673. setParent: true
  2674. });
  2675. newTab.onclose = async () => {
  2676. const auth = GM_getValue('twitchAuth');
  2677. if (auth) {
  2678. this.#auth = auth;
  2679. logStatus.success();
  2680. resolve(await this.#verifyAuth());
  2681. } else {
  2682. logStatus.error('Error: Update twitch auth failed!');
  2683. resolve(false);
  2684. }
  2685. };
  2686. });
  2687. } catch (error) {
  2688. throwError(error, 'Twitch.updateAuth');
  2689. return false;
  2690. }
  2691. }
  2692. async #toggleChannel(_ref) {
  2693. let {
  2694. name,
  2695. doTask = true
  2696. } = _ref;
  2697. try {
  2698. if (!doTask && this.whiteList.channels.includes(name)) {
  2699. scripts_echoLog({
  2700. type: 'whiteList',
  2701. text: 'Twitch.unfollowChannel',
  2702. id: name
  2703. });
  2704. return true;
  2705. }
  2706. const channelId = await this.#getChannelId(name);
  2707. if (!channelId) {
  2708. return false;
  2709. }
  2710. const logStatus = scripts_echoLog({
  2711. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2712. text: name
  2713. });
  2714. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"800e7346bdf7e5278a3c1d3f21b2b56e2639928f86815677a7126b093b2fdd08"}}}]';
  2715. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"f7dae976ebf41c755ae2d758546bfd176b4eeb856656098bb40e0a672ca0d880"}}}]';
  2716. const {
  2717. result,
  2718. statusText,
  2719. status,
  2720. data
  2721. } = await tools_httpRequest({
  2722. url: 'https://gql.twitch.tv/gql',
  2723. method: 'POST',
  2724. dataType: 'json',
  2725. anonymous: true,
  2726. headers: {
  2727. Origin: 'https://www.twitch.tv',
  2728. Referer: 'https://www.twitch.tv/',
  2729. Authorization: `OAuth ${this.#auth.authToken}`,
  2730. 'Client-Id': this.#auth.clientId,
  2731. 'Client-Version': this.#auth.clientVersion,
  2732. 'X-Device-Id': this.#auth.deviceId,
  2733. 'Client-Session-Id': this.#auth.clientSessionId,
  2734. 'Client-Integrity': this.#integrityToken
  2735. },
  2736. data: doTask ? followData : unfollowData
  2737. });
  2738. if (result === 'Success') {
  2739. var _data$response3, _data$response4, _data$response4$0$err, _data$response4$0$err2;
  2740. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3[0] && !data.response[0].errors) {
  2741. logStatus.success();
  2742. if (doTask) {
  2743. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2744. }
  2745. return true;
  2746. }
  2747. logStatus.error(`Error:${(data === null || data === void 0 ? void 0 : (_data$response4 = data.response) === null || _data$response4 === void 0 ? void 0 : (_data$response4$0$err = _data$response4[0].errors) === null || _data$response4$0$err === void 0 ? void 0 : (_data$response4$0$err2 = _data$response4$0$err[0]) === null || _data$response4$0$err2 === void 0 ? void 0 : _data$response4$0$err2.message) || `${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`}`);
  2748. return false;
  2749. }
  2750. logStatus.error(`${result}:${statusText}(${status})`);
  2751. return false;
  2752. } catch (error) {
  2753. throwError(error, 'Twitch.toggleChannel');
  2754. return false;
  2755. }
  2756. }
  2757. async #getChannelId(name) {
  2758. try {
  2759. const logStatus = scripts_echoLog({
  2760. type: 'gettingTwitchChannelId',
  2761. text: name
  2762. });
  2763. const channelId = this.#cache[name];
  2764. if (channelId) {
  2765. logStatus.success();
  2766. return channelId;
  2767. }
  2768. const {
  2769. result,
  2770. statusText,
  2771. status,
  2772. data
  2773. } = await tools_httpRequest({
  2774. url: 'https://gql.twitch.tv/gql',
  2775. method: 'POST',
  2776. headers: {
  2777. Authorization: `OAuth ${this.#auth.authToken}`,
  2778. 'Client-Id': this.#auth.clientId
  2779. },
  2780. responseType: 'json',
  2781. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  2782. });
  2783. if (result === 'Success') {
  2784. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2785. var _data$response5, _data$response5$, _data$response5$$data, _data$response5$$data2;
  2786. const channelId = (_data$response5 = data.response) === null || _data$response5 === void 0 ? void 0 : (_data$response5$ = _data$response5[0]) === null || _data$response5$ === void 0 ? void 0 : (_data$response5$$data = _data$response5$.data) === null || _data$response5$$data === void 0 ? void 0 : (_data$response5$$data2 = _data$response5$$data.user) === null || _data$response5$$data2 === void 0 ? void 0 : _data$response5$$data2.id;
  2787. if (channelId) {
  2788. this.#setCache(name, String(channelId));
  2789. logStatus.success();
  2790. return channelId;
  2791. }
  2792. logStatus.error(`Error:${data.statusText}(${data.status})`);
  2793. return false;
  2794. }
  2795. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2796. return false;
  2797. }
  2798. logStatus.error(`${result}:${statusText}(${status})`);
  2799. return false;
  2800. } catch (error) {
  2801. throwError(error, 'Twitch.getChannelId');
  2802. return false;
  2803. }
  2804. }
  2805. async toggle(_ref2) {
  2806. let {
  2807. doTask = true,
  2808. channelLinks = []
  2809. } = _ref2;
  2810. try {
  2811. if (!this.#initialized) {
  2812. scripts_echoLog({
  2813. text: i18n('needInit')
  2814. });
  2815. return false;
  2816. }
  2817. const prom = [];
  2818. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2819. scripts_echoLog({
  2820. type: 'globalOptionsSkip',
  2821. text: 'twitch.channels'
  2822. });
  2823. } else {
  2824. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2825. var _link$match;
  2826. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2827. });
  2828. if (realChannels.length > 0) {
  2829. for (const channel of realChannels) {
  2830. prom.push(this.#toggleChannel({
  2831. name: channel,
  2832. doTask: doTask
  2833. }));
  2834. await delay(1e3);
  2835. }
  2836. }
  2837. }
  2838. return Promise.all(prom).then(() => true);
  2839. } catch (error) {
  2840. throwError(error, 'Twitch.toggle');
  2841. return false;
  2842. }
  2843. }
  2844. #setCache(name, id) {
  2845. try {
  2846. this.#cache[name] = id;
  2847. GM_setValue('twitchCache', this.#cache);
  2848. } catch (error) {
  2849. throwError(error, 'Twitch.setCache');
  2850. }
  2851. }
  2852. }
  2853. const social_Twitch = Twitch;
  2854. var Twitter_GM_getValue;
  2855. const Twitter_defaultTasksTemplate = {
  2856. users: [],
  2857. retweets: [],
  2858. likes: []
  2859. };
  2860. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  2861. class Twitter extends social_Social {
  2862. tasks = JSON.parse(Twitter_defaultTasks);
  2863. whiteList = {
  2864. ...JSON.parse(Twitter_defaultTasks),
  2865. ...(Twitter_GM_getValue = GM_getValue('whiteList')) === null || Twitter_GM_getValue === void 0 ? void 0 : Twitter_GM_getValue.twitter
  2866. };
  2867. #verifyId = globalOptions.other.twitterVerifyId;
  2868. #auth = GM_getValue('twitterAuth') || {};
  2869. #cache = GM_getValue('twitterCache') || {};
  2870. #initialized = false;
  2871. async init() {
  2872. try {
  2873. if (this.#initialized) {
  2874. return true;
  2875. }
  2876. if (!this.#auth.ct0) {
  2877. if (await this.#updateAuth()) {
  2878. this.#initialized = true;
  2879. return true;
  2880. }
  2881. return false;
  2882. }
  2883. const isVerified = await this.#verifyAuth();
  2884. if (isVerified) {
  2885. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  2886. this.#initialized = true;
  2887. return true;
  2888. }
  2889. GM_setValue('twitterAuth', null);
  2890. if (await this.#updateAuth()) {
  2891. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  2892. this.#initialized = true;
  2893. return true;
  2894. }
  2895. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  2896. return false;
  2897. } catch (error) {
  2898. throwError(error, 'Twitter.init');
  2899. return false;
  2900. }
  2901. }
  2902. async #verifyAuth() {
  2903. try {
  2904. return await this.#toggleUser({
  2905. name: 'verify',
  2906. doTask: true,
  2907. verify: true
  2908. });
  2909. } catch (error) {
  2910. throwError(error, 'Twitter.verifyAuth');
  2911. return false;
  2912. }
  2913. }
  2914. async #updateAuth() {
  2915. try {
  2916. const logStatus = scripts_echoLog({
  2917. text: i18n('updatingAuth', 'Twitter')
  2918. });
  2919. return await new Promise(resolve => {
  2920. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  2921. active: true,
  2922. insert: true,
  2923. setParent: true
  2924. });
  2925. newTab.onclose = async () => {
  2926. const auth = GM_getValue('twitterAuth');
  2927. if (auth) {
  2928. this.#auth = auth;
  2929. logStatus.success();
  2930. resolve(await this.#verifyAuth());
  2931. } else {
  2932. logStatus.error('Error: Update twitter auth failed!');
  2933. resolve(false);
  2934. }
  2935. };
  2936. });
  2937. } catch (error) {
  2938. throwError(error, 'Twitter.updateToken');
  2939. return false;
  2940. }
  2941. }
  2942. async #toggleUser(_ref) {
  2943. let {
  2944. name,
  2945. doTask = true,
  2946. verify = false
  2947. } = _ref;
  2948. try {
  2949. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  2950. scripts_echoLog({
  2951. type: 'whiteList',
  2952. text: 'Twitter.unfollowUser',
  2953. id: name
  2954. });
  2955. return true;
  2956. }
  2957. const userId = verify ? this.#verifyId : await this.userName2id(name);
  2958. if (!userId) {
  2959. return false;
  2960. }
  2961. const logStatus = verify ? scripts_echoLog({
  2962. text: i18n('verifyingAuth', 'Twitter')
  2963. }) : scripts_echoLog({
  2964. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  2965. text: name
  2966. });
  2967. const {
  2968. result,
  2969. statusText,
  2970. status,
  2971. data
  2972. } = await tools_httpRequest({
  2973. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  2974. method: 'POST',
  2975. headers: {
  2976. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  2977. 'Content-Type': 'application/x-www-form-urlencoded',
  2978. 'x-csrf-token': this.#auth.ct0
  2979. },
  2980. responseType: 'json',
  2981. data: $.param({
  2982. include_profile_interstitial_type: 1,
  2983. include_blocking: 1,
  2984. include_blocked_by: 1,
  2985. include_followed_by: 1,
  2986. include_want_retweets: 1,
  2987. include_mute_edge: 1,
  2988. include_can_dm: 1,
  2989. include_can_media_tag: 1,
  2990. skip_status: 1,
  2991. id: userId
  2992. })
  2993. });
  2994. if (result === 'Success') {
  2995. var _data$response, _data$response$errors, _data$response$errors2;
  2996. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2997. logStatus.success();
  2998. if (doTask && !verify) {
  2999. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3000. }
  3001. return true;
  3002. }
  3003. 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) {
  3004. logStatus.success();
  3005. return true;
  3006. }
  3007. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3008. return false;
  3009. }
  3010. logStatus.error(`${result}:${statusText}(${status})`);
  3011. return false;
  3012. } catch (error) {
  3013. throwError(error, 'Twitter.toggleUser');
  3014. return false;
  3015. }
  3016. }
  3017. async userName2id(name) {
  3018. try {
  3019. const logStatus = scripts_echoLog({
  3020. type: 'gettingTwitterUserId',
  3021. text: name
  3022. });
  3023. const userId = this.#cache[name];
  3024. if (userId) {
  3025. logStatus.success();
  3026. return userId;
  3027. }
  3028. const {
  3029. result,
  3030. statusText,
  3031. status,
  3032. data
  3033. } = await tools_httpRequest({
  3034. url: 'https://api.twitter.com/graphql/mCbpQvZAw6zu_4PvuAUVVQ/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D`,
  3035. method: 'GET',
  3036. headers: {
  3037. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3038. 'content-type': 'application/json',
  3039. referer: `https://twitter.com/${name}`,
  3040. 'x-csrf-token': this.#auth.ct0
  3041. },
  3042. responseType: 'json'
  3043. });
  3044. if (result === 'Success') {
  3045. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3046. var _response, _response$data, _response$data$user, _response$data$user$r;
  3047. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3048. if (!response) {
  3049. try {
  3050. response = JSON.parse(data.responseText);
  3051. } catch (error) {
  3052. response = null;
  3053. }
  3054. }
  3055. 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$r = _response$data$user.result) === null || _response$data$user$r === void 0 ? void 0 : _response$data$user$r.rest_id);
  3056. if (userId) {
  3057. this.#setCache(name, userId);
  3058. logStatus.success();
  3059. return userId;
  3060. }
  3061. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3062. return false;
  3063. }
  3064. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3065. return false;
  3066. }
  3067. logStatus.error(`${result}:${statusText}(${status})`);
  3068. return false;
  3069. } catch (error) {
  3070. throwError(error, 'Twitter.getUserId');
  3071. return false;
  3072. }
  3073. }
  3074. async #toggleRetweet(_ref2) {
  3075. let {
  3076. retweetId,
  3077. doTask = true
  3078. } = _ref2;
  3079. try {
  3080. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3081. scripts_echoLog({
  3082. type: 'whiteList',
  3083. text: 'Twitter.unretweet',
  3084. id: retweetId
  3085. });
  3086. return true;
  3087. }
  3088. const logStatus = scripts_echoLog({
  3089. type: `${doTask ? '' : 'un'}retweetting`,
  3090. text: retweetId
  3091. });
  3092. const {
  3093. result,
  3094. statusText,
  3095. status,
  3096. data
  3097. } = await tools_httpRequest({
  3098. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3099. method: 'POST',
  3100. headers: {
  3101. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3102. 'Content-Type': 'application/x-www-form-urlencoded',
  3103. 'x-csrf-token': this.#auth.ct0
  3104. },
  3105. data: $.param({
  3106. tweet_mode: 'extended',
  3107. id: retweetId
  3108. }),
  3109. responseType: 'json'
  3110. });
  3111. if (result === 'Success') {
  3112. var _data$response2, _data$response2$error, _data$response2$error2;
  3113. 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) {
  3114. logStatus.success();
  3115. if (doTask) {
  3116. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3117. }
  3118. return true;
  3119. }
  3120. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3121. return false;
  3122. }
  3123. logStatus.error(`${result}:${statusText}(${status})`);
  3124. return false;
  3125. } catch (error) {
  3126. throwError(error, 'Twitter.toggleRetweet');
  3127. return false;
  3128. }
  3129. }
  3130. async toggle(_ref3) {
  3131. let {
  3132. doTask = true,
  3133. userLinks = [],
  3134. retweetLinks = []
  3135. } = _ref3;
  3136. try {
  3137. if (!this.#initialized) {
  3138. scripts_echoLog({
  3139. text: i18n('needInit')
  3140. });
  3141. return false;
  3142. }
  3143. const prom = [];
  3144. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3145. scripts_echoLog({
  3146. type: 'globalOptionsSkip',
  3147. text: 'twitter.users'
  3148. });
  3149. } else {
  3150. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3151. var _link$match;
  3152. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3153. });
  3154. if (realUsers.length > 0) {
  3155. for (const user of realUsers) {
  3156. prom.push(this.#toggleUser({
  3157. name: user,
  3158. doTask: doTask
  3159. }));
  3160. await delay(1e3);
  3161. }
  3162. }
  3163. }
  3164. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3165. scripts_echoLog({
  3166. type: 'globalOptionsSkip',
  3167. text: 'twitter.retweets'
  3168. });
  3169. } else {
  3170. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3171. var _link$match2;
  3172. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3173. });
  3174. if (realRetweets.length > 0) {
  3175. for (const retweet of realRetweets) {
  3176. prom.push(this.#toggleRetweet({
  3177. retweetId: retweet,
  3178. doTask: doTask
  3179. }));
  3180. await delay(1e3);
  3181. }
  3182. }
  3183. }
  3184. return Promise.all(prom).then(() => true);
  3185. } catch (error) {
  3186. throwError(error, 'Twitter.toggle');
  3187. return false;
  3188. }
  3189. }
  3190. #setCache(name, id) {
  3191. try {
  3192. this.#cache[name] = id;
  3193. GM_setValue('twitterCache', this.#cache);
  3194. } catch (error) {
  3195. throwError(error, 'Twitter.setCache');
  3196. }
  3197. }
  3198. }
  3199. const social_Twitter = Twitter;
  3200. var Vk_GM_getValue;
  3201. const Vk_defaultTasksTemplate = {
  3202. names: []
  3203. };
  3204. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3205. class Vk extends social_Social {
  3206. tasks = JSON.parse(Vk_defaultTasks);
  3207. whiteList = {
  3208. ...JSON.parse(Vk_defaultTasks),
  3209. ...(Vk_GM_getValue = GM_getValue('whiteList')) === null || Vk_GM_getValue === void 0 ? void 0 : Vk_GM_getValue.vk
  3210. };
  3211. #username = '';
  3212. #cache = GM_getValue('vkCache') || {};
  3213. #initialized = false;
  3214. async init() {
  3215. try {
  3216. if (this.#initialized) {
  3217. return true;
  3218. }
  3219. const isVerified = await this.#verifyAuth();
  3220. if (isVerified) {
  3221. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3222. this.#initialized = true;
  3223. return true;
  3224. }
  3225. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3226. return false;
  3227. } catch (error) {
  3228. throwError(error, 'Vk.init');
  3229. return false;
  3230. }
  3231. }
  3232. async #verifyAuth() {
  3233. try {
  3234. const logStatus = scripts_echoLog({
  3235. text: i18n('verifyAuth', 'Vk')
  3236. });
  3237. const {
  3238. result,
  3239. statusText,
  3240. status,
  3241. data
  3242. } = await tools_httpRequest({
  3243. url: 'https://vk.com/im',
  3244. method: 'GET'
  3245. });
  3246. if (result === 'Success') {
  3247. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3248. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3249. return false;
  3250. }
  3251. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3252. var _data$responseText$ma;
  3253. this.#username = ((_data$responseText$ma = data.responseText.match(/TopNavBtn__profileLink" href="\/(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1]) || '';
  3254. logStatus.success();
  3255. return true;
  3256. }
  3257. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3258. return false;
  3259. }
  3260. logStatus.error(`${result}:${statusText}(${status})`);
  3261. return false;
  3262. } catch (error) {
  3263. throwError(error, 'Vk.verifyAuth');
  3264. return false;
  3265. }
  3266. }
  3267. async #toggleGroup(name, dataParam) {
  3268. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3269. try {
  3270. const logStatus = scripts_echoLog({
  3271. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3272. text: name
  3273. });
  3274. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3275. logStatus.success();
  3276. return true;
  3277. }
  3278. const reqData = {
  3279. act: doTask ? 'enter' : 'leave',
  3280. al: 1,
  3281. gid: dataParam.groupId,
  3282. hash: dataParam.groupHash
  3283. };
  3284. if (doTask) {
  3285. reqData.context = '_';
  3286. }
  3287. const {
  3288. result,
  3289. statusText,
  3290. status,
  3291. data
  3292. } = await tools_httpRequest({
  3293. url: 'https://vk.com/al_groups.php',
  3294. method: 'POST',
  3295. headers: {
  3296. origin: 'https://vk.com',
  3297. referer: `https://vk.com/${name}`,
  3298. 'content-type': 'application/x-www-form-urlencoded'
  3299. },
  3300. data: $.param(reqData)
  3301. });
  3302. if (result === 'Success') {
  3303. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3304. logStatus.success();
  3305. if (doTask) {
  3306. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3307. }
  3308. return true;
  3309. }
  3310. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3311. return false;
  3312. }
  3313. logStatus.error(`${result}:${statusText}(${status})`);
  3314. return false;
  3315. } catch (error) {
  3316. throwError(error, 'Vk.toggleGroup');
  3317. return false;
  3318. }
  3319. }
  3320. async #togglePublic(name, dataParam) {
  3321. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3322. try {
  3323. const logStatus = scripts_echoLog({
  3324. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3325. text: name
  3326. });
  3327. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3328. logStatus.success();
  3329. return true;
  3330. }
  3331. const {
  3332. result,
  3333. statusText,
  3334. status,
  3335. data
  3336. } = await tools_httpRequest({
  3337. url: 'https://vk.com/al_public.php',
  3338. method: 'POST',
  3339. headers: {
  3340. origin: 'https://vk.com',
  3341. referer: `https://vk.com/${name}`,
  3342. 'content-type': 'application/x-www-form-urlencoded'
  3343. },
  3344. data: $.param({
  3345. act: doTask ? 'a_enter' : 'a_leave',
  3346. al: 1,
  3347. pid: dataParam.publicPid,
  3348. hash: dataParam.publicHash
  3349. })
  3350. });
  3351. if (result === 'Success') {
  3352. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3353. logStatus.success();
  3354. if (doTask) {
  3355. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3356. }
  3357. return true;
  3358. }
  3359. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3360. return false;
  3361. }
  3362. logStatus.error(`${result}:${statusText}(${status})`);
  3363. return false;
  3364. } catch (error) {
  3365. throwError(error, 'Vk.togglePublic');
  3366. return false;
  3367. }
  3368. }
  3369. async #sendWall(name) {
  3370. try {
  3371. const logStatus = scripts_echoLog({
  3372. type: 'sendingVkWall',
  3373. text: name
  3374. });
  3375. const {
  3376. result,
  3377. statusText,
  3378. status,
  3379. data
  3380. } = await tools_httpRequest({
  3381. url: 'https://vk.com/like.php',
  3382. method: 'POST',
  3383. headers: {
  3384. origin: 'https://vk.com',
  3385. referer: `https://vk.com/${name}`,
  3386. 'content-type': 'application/x-www-form-urlencoded'
  3387. },
  3388. data: $.param({
  3389. act: 'publish_box',
  3390. al: 1,
  3391. object: name
  3392. })
  3393. });
  3394. if (result === 'Success') {
  3395. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3396. var _data$responseText$ma2;
  3397. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3398. if (hash) {
  3399. const {
  3400. result: resultR,
  3401. statusText: statusTextR,
  3402. status: statusR,
  3403. data: dataR
  3404. } = await tools_httpRequest({
  3405. url: 'https://vk.com/like.php',
  3406. method: 'POST',
  3407. headers: {
  3408. origin: 'https://vk.com',
  3409. referer: `https://vk.com/${name}`,
  3410. 'content-type': 'application/x-www-form-urlencoded'
  3411. },
  3412. data: $.param({
  3413. Message: '',
  3414. act: 'a_do_publish',
  3415. al: 1,
  3416. close_comments: 0,
  3417. friends_only: 0,
  3418. from: 'box',
  3419. hash: hash,
  3420. list: '',
  3421. mark_as_ads: 0,
  3422. mute_notifications: 0,
  3423. object: name,
  3424. ret_data: 1,
  3425. to: 0
  3426. })
  3427. });
  3428. if (resultR === 'Success') {
  3429. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3430. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3431. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3432. 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) {
  3433. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3434. logStatus.success();
  3435. 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);
  3436. 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);
  3437. if (postId && ownerId) {
  3438. this.#setCache(name, `${ownerId}_${postId}`);
  3439. }
  3440. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3441. return true;
  3442. }
  3443. }
  3444. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3445. return false;
  3446. }
  3447. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3448. return false;
  3449. }
  3450. logStatus.error('Error: Get "hash" failed');
  3451. return false;
  3452. }
  3453. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3454. return false;
  3455. }
  3456. logStatus.error(`${result}:${statusText}(${status})`);
  3457. return false;
  3458. } catch (error) {
  3459. throwError(error, 'Vk.sendWall');
  3460. return false;
  3461. }
  3462. }
  3463. async #deleteWall(name, dataParams) {
  3464. try {
  3465. const logStatus = scripts_echoLog({
  3466. type: 'deletingVkWall',
  3467. text: name
  3468. });
  3469. const {
  3470. result,
  3471. statusText,
  3472. status,
  3473. data
  3474. } = await tools_httpRequest({
  3475. url: 'https://vk.com/al_wall.php?act=delete',
  3476. method: 'POST',
  3477. headers: {
  3478. origin: 'https://vk.com',
  3479. referer: `https://vk.com/${this.#username}?w=wall${this.#cache[name]}%2Fall`,
  3480. 'content-type': 'application/x-www-form-urlencoded'
  3481. },
  3482. data: $.param({
  3483. act: 'delete',
  3484. al: 1,
  3485. confirm: 0,
  3486. from: 'wkview',
  3487. hash: dataParams.wallHash,
  3488. post: this.#cache[name]
  3489. })
  3490. });
  3491. if (result === 'Success') {
  3492. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3493. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3494. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3495. 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]) {
  3496. logStatus.success();
  3497. return true;
  3498. }
  3499. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3500. return false;
  3501. }
  3502. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3503. return false;
  3504. }
  3505. logStatus.error(`${result}:${statusText}(${status})`);
  3506. return false;
  3507. } catch (error) {
  3508. throwError(error, 'Vk.deleteWall');
  3509. return false;
  3510. }
  3511. }
  3512. async #getId(name, doTask) {
  3513. try {
  3514. let url = `https://vk.com/${name}`;
  3515. if (/^wall-/.test(name)) {
  3516. if (doTask) {
  3517. return {
  3518. type: 'sendWall'
  3519. };
  3520. }
  3521. if (!this.#cache[name]) {
  3522. return {
  3523. type: 'unSupport'
  3524. };
  3525. }
  3526. url = `https://vk.com/${this.#username}?w=wall${this.#cache[name]}`;
  3527. }
  3528. const logStatus = scripts_echoLog({
  3529. type: 'gettingVkId',
  3530. text: name
  3531. });
  3532. const {
  3533. result,
  3534. statusText,
  3535. status,
  3536. data
  3537. } = await tools_httpRequest({
  3538. url: url,
  3539. method: 'GET'
  3540. });
  3541. if (result === 'Success') {
  3542. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3543. var _data$responseText$ma3, _data$responseText$ma4;
  3544. const [ , groupAct, groupId, , groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), (&#39;|')(.*?)(&#39;|')/) || [];
  3545. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3546. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3547. const publicJoined = !data.responseText.includes('Public.subscribe');
  3548. if (groupAct && groupId && groupHash) {
  3549. logStatus.success();
  3550. return {
  3551. groupAct: groupAct,
  3552. groupId: groupId,
  3553. groupHash: groupHash,
  3554. type: 'group'
  3555. };
  3556. } else if (publicHash && publicPid) {
  3557. logStatus.success();
  3558. return {
  3559. publicHash: publicHash,
  3560. publicPid: publicPid,
  3561. publicJoined: publicJoined,
  3562. type: 'public'
  3563. };
  3564. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3565. var _data$responseText$ma5;
  3566. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3567. if (wallHash) {
  3568. logStatus.success();
  3569. return {
  3570. type: 'deleteWall',
  3571. wallHash: wallHash
  3572. };
  3573. }
  3574. } else if (name.includes('wall') && doTask) {
  3575. logStatus.success();
  3576. return {
  3577. type: 'sendWall'
  3578. };
  3579. }
  3580. logStatus.error('Error: Parameters not found!');
  3581. return false;
  3582. }
  3583. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3584. return false;
  3585. }
  3586. logStatus.error(`${result}:${statusText}(${status})`);
  3587. return false;
  3588. } catch (error) {
  3589. throwError(error, 'Vk.getId');
  3590. return false;
  3591. }
  3592. }
  3593. async #toggleVk(_ref) {
  3594. let {
  3595. name,
  3596. doTask = true
  3597. } = _ref;
  3598. try {
  3599. if (!doTask && this.whiteList.names.includes(name)) {
  3600. scripts_echoLog({
  3601. type: 'whiteList',
  3602. text: 'Vk.undoTask',
  3603. id: name
  3604. });
  3605. return true;
  3606. }
  3607. const formatName = name.replace(/\/$/, '');
  3608. const data = await this.#getId(formatName, doTask);
  3609. if (!data) {
  3610. return false;
  3611. }
  3612. switch (data.type) {
  3613. case 'group':
  3614. return await this.#toggleGroup(formatName, data, doTask);
  3615.  
  3616. case 'public':
  3617. return await this.#togglePublic(formatName, data, doTask);
  3618.  
  3619. case 'sendWall':
  3620. return doTask ? await this.#sendWall(formatName) : true;
  3621.  
  3622. case 'deleteWall':
  3623. return doTask ? true : await this.#deleteWall(formatName, data);
  3624.  
  3625. default:
  3626. return false;
  3627. }
  3628. } catch (error) {
  3629. throwError(error, 'Vk.toggleVk');
  3630. return false;
  3631. }
  3632. }
  3633. async toggle(_ref2) {
  3634. let {
  3635. doTask = true,
  3636. nameLinks = []
  3637. } = _ref2;
  3638. try {
  3639. if (!this.#initialized) {
  3640. scripts_echoLog({
  3641. text: i18n('needInit')
  3642. });
  3643. return false;
  3644. }
  3645. const prom = [];
  3646. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3647. scripts_echoLog({
  3648. type: 'globalOptionsSkip',
  3649. text: 'vk.names'
  3650. });
  3651. } else {
  3652. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3653. var _link$match;
  3654. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3655. });
  3656. if (realNames.length > 0) {
  3657. for (const name of realNames) {
  3658. prom.push(this.#toggleVk({
  3659. name: name,
  3660. doTask: doTask
  3661. }));
  3662. await delay(1e3);
  3663. }
  3664. }
  3665. }
  3666. return Promise.all(prom).then(() => true);
  3667. } catch (error) {
  3668. throwError(error, 'Vk.toggle');
  3669. return false;
  3670. }
  3671. }
  3672. #setCache(name, postId) {
  3673. try {
  3674. this.#cache[name] = postId;
  3675. GM_setValue('vkCache', this.#cache);
  3676. } catch (error) {
  3677. throwError(error, 'Vk.setCache');
  3678. }
  3679. }
  3680. }
  3681. const social_Vk = Vk;
  3682. var Youtube_GM_getValue;
  3683. const Youtube_defaultTasksTemplate = {
  3684. channels: [],
  3685. likes: []
  3686. };
  3687. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  3688. const getInfo = async function(link, type) {
  3689. try {
  3690. const logStatus = scripts_echoLog({
  3691. text: i18n('gettingYtbToken')
  3692. });
  3693. const {
  3694. result,
  3695. statusText,
  3696. status,
  3697. data
  3698. } = await tools_httpRequest({
  3699. url: link,
  3700. method: 'GET'
  3701. });
  3702. if (result === 'Success') {
  3703. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3704. var _data$responseText$ma, _ref;
  3705. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  3706. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  3707. return {
  3708. needLogin: true
  3709. };
  3710. }
  3711. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  3712. 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]) || '{}';
  3713. const {
  3714. client,
  3715. request
  3716. } = JSON.parse(context);
  3717. if (apiKey && client && request) {
  3718. client.hl = 'en';
  3719. if (type === 'channel') {
  3720. var _data$responseText$ma2;
  3721. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3722. if (channelId) {
  3723. logStatus.success();
  3724. return {
  3725. params: {
  3726. apiKey: apiKey,
  3727. client: client,
  3728. request: request,
  3729. channelId: channelId
  3730. }
  3731. };
  3732. }
  3733. logStatus.error('Error: Get "channelId" failed!');
  3734. return {};
  3735. } else if (type === 'likeVideo') {
  3736. var _data$responseText$ma3, _data$responseText$ma4;
  3737. 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];
  3738. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3739. if (videoId) {
  3740. logStatus.success();
  3741. return {
  3742. params: {
  3743. apiKey: apiKey,
  3744. client: client,
  3745. request: request,
  3746. videoId: videoId,
  3747. likeParams: likeParams
  3748. }
  3749. };
  3750. }
  3751. logStatus.error('Error: Get "videoId" failed!');
  3752. return {};
  3753. }
  3754. logStatus.error('Error: Unknown type');
  3755. return {};
  3756. }
  3757. logStatus.error('Error: Parameter "apiKey" not found!');
  3758. return {};
  3759. }
  3760. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3761. return {};
  3762. }
  3763. logStatus.error(`${result}:${statusText}(${status})`);
  3764. return {};
  3765. } catch (error) {
  3766. throwError(error, 'Youtube.getInfo');
  3767. return {};
  3768. }
  3769. };
  3770. class Youtube extends social_Social {
  3771. tasks = JSON.parse(Youtube_defaultTasks);
  3772. whiteList = {
  3773. ...JSON.parse(Youtube_defaultTasks),
  3774. ...(Youtube_GM_getValue = GM_getValue('whiteList')) === null || Youtube_GM_getValue === void 0 ? void 0 : Youtube_GM_getValue.youtube
  3775. };
  3776. #auth = GM_getValue('youtubeAuth') || {};
  3777. #initialized = false;
  3778. #verifyChannel = `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`;
  3779. async init() {
  3780. try {
  3781. if (this.#initialized) {
  3782. return true;
  3783. }
  3784. if (!this.#auth.PAPISID) {
  3785. if (await this.#updateAuth()) {
  3786. this.#initialized = true;
  3787. return true;
  3788. }
  3789. return false;
  3790. }
  3791. const isVerified = await this.#verifyAuth();
  3792. if (isVerified) {
  3793. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  3794. this.#initialized = true;
  3795. return true;
  3796. }
  3797. GM_setValue('youtubeAuth', null);
  3798. if (await this.#updateAuth()) {
  3799. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  3800. this.#initialized = true;
  3801. return true;
  3802. }
  3803. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  3804. return false;
  3805. } catch (error) {
  3806. throwError(error, 'Youtube.init');
  3807. return false;
  3808. }
  3809. }
  3810. async #verifyAuth() {
  3811. try {
  3812. return await this.#toggleChannel({
  3813. link: this.#verifyChannel,
  3814. doTask: true,
  3815. verify: true
  3816. });
  3817. } catch (error) {
  3818. throwError(error, 'Youtube.verifyAuth');
  3819. return false;
  3820. }
  3821. }
  3822. async #updateAuth() {
  3823. try {
  3824. const logStatus = scripts_echoLog({
  3825. text: i18n('updatingAuth', 'Youtube')
  3826. });
  3827. return await new Promise(resolve => {
  3828. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  3829. active: true,
  3830. insert: true,
  3831. setParent: true
  3832. });
  3833. newTab.onclose = async () => {
  3834. const auth = GM_getValue('youtubeAuth');
  3835. if (auth) {
  3836. this.#auth = auth;
  3837. logStatus.success();
  3838. this.#verifyAuth().then(result => {
  3839. resolve(result);
  3840. });
  3841. } else {
  3842. logStatus.error('Error: Update youtube auth failed!');
  3843. resolve(false);
  3844. }
  3845. };
  3846. });
  3847. } catch (error) {
  3848. throwError(error, 'Discord.updateAuth');
  3849. return false;
  3850. }
  3851. }
  3852. #getInfo(link, type) {
  3853. return getInfo(link, type);
  3854. }
  3855. async #toggleChannel(_ref2) {
  3856. let {
  3857. link,
  3858. doTask = true,
  3859. verify = false
  3860. } = _ref2;
  3861. try {
  3862. const {
  3863. params,
  3864. needLogin
  3865. } = await this.#getInfo(link, 'channel');
  3866. const {
  3867. apiKey,
  3868. client,
  3869. request,
  3870. channelId
  3871. } = params || {};
  3872. if (needLogin) {
  3873. scripts_echoLog({
  3874. html: i18n('loginYtb')
  3875. });
  3876. return false;
  3877. }
  3878. if (!(apiKey && client && request && channelId)) {
  3879. scripts_echoLog({
  3880. text: '"getYtbToken" failed'
  3881. });
  3882. return false;
  3883. }
  3884. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  3885. scripts_echoLog({
  3886. type: 'whiteList',
  3887. text: 'Youtube.unfollowChannel',
  3888. id: channelId
  3889. });
  3890. return true;
  3891. }
  3892. const logStatus = verify ? scripts_echoLog({
  3893. text: i18n('verifyingAuth', 'Youtube')
  3894. }) : scripts_echoLog({
  3895. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  3896. text: channelId
  3897. });
  3898. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  3899. const {
  3900. result,
  3901. statusText,
  3902. status,
  3903. data
  3904. } = await tools_httpRequest({
  3905. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  3906. method: 'POST',
  3907. headers: {
  3908. origin: 'https://www.youtube.com',
  3909. referer: `https://www.youtube.com/channel/${channelId}`,
  3910. 'content-type': 'application/json',
  3911. 'x-goog-authuser': '0',
  3912. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  3913. 'x-origin': 'https://www.youtube.com',
  3914. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${this.#auth.PAPISID} https://www.youtube.com`)}`
  3915. },
  3916. data: JSON.stringify({
  3917. context: {
  3918. client: client,
  3919. request: {
  3920. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  3921. internalExperimentFlags: [],
  3922. consistencyTokenJars: []
  3923. },
  3924. user: {}
  3925. },
  3926. channelIds: [ channelId ],
  3927. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  3928. })
  3929. });
  3930. if (result === 'Success') {
  3931. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3932. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  3933. logStatus.success();
  3934. if (doTask && !verify) {
  3935. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  3936. }
  3937. return true;
  3938. }
  3939. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  3940. logStatus.success();
  3941. return true;
  3942. }
  3943. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  3944. return false;
  3945. }
  3946. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3947. return false;
  3948. }
  3949. logStatus.error(`${result}:${statusText}(${status})`);
  3950. return false;
  3951. } catch (error) {
  3952. throwError(error, 'Youtube.toggleChannel');
  3953. return false;
  3954. }
  3955. }
  3956. async #toggleLikeVideo(_ref3) {
  3957. let {
  3958. link,
  3959. doTask = true
  3960. } = _ref3;
  3961. try {
  3962. const {
  3963. params,
  3964. needLogin
  3965. } = await this.#getInfo(link, 'likeVideo');
  3966. const {
  3967. apiKey,
  3968. client,
  3969. request,
  3970. videoId,
  3971. likeParams
  3972. } = params || {};
  3973. if (needLogin) {
  3974. scripts_echoLog({
  3975. html: `${i18n('loginYtb')}`
  3976. });
  3977. return false;
  3978. }
  3979. if (!(apiKey && client && request && videoId && likeParams)) {
  3980. scripts_echoLog({
  3981. text: '"getYtbToken" failed'
  3982. });
  3983. return false;
  3984. }
  3985. if (!doTask && this.whiteList.likes.includes(videoId)) {
  3986. scripts_echoLog({
  3987. type: 'whiteList',
  3988. text: 'Youtube.unlikeVideo',
  3989. id: videoId
  3990. });
  3991. return true;
  3992. }
  3993. const logStatus = scripts_echoLog({
  3994. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  3995. text: videoId
  3996. });
  3997. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  3998. const likeVideoData = {
  3999. context: {
  4000. client: client,
  4001. request: {
  4002. sessionId: request.sessionId,
  4003. internalExperimentFlags: [],
  4004. consistencyTokenJars: []
  4005. },
  4006. user: {}
  4007. },
  4008. target: {
  4009. videoId: videoId
  4010. }
  4011. };
  4012. if (doTask) {
  4013. if (likeParams) {
  4014. likeVideoData.params = likeParams;
  4015. } else {
  4016. logStatus.error('Empty likeParams');
  4017. return false;
  4018. }
  4019. }
  4020. const {
  4021. result,
  4022. statusText,
  4023. status,
  4024. data
  4025. } = await tools_httpRequest({
  4026. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4027. method: 'POST',
  4028. headers: {
  4029. origin: 'https://www.youtube.com',
  4030. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4031. 'content-type': 'application/json',
  4032. 'x-goog-authuser': '0',
  4033. 'x-goog-visitor-id': client.visitorData,
  4034. 'x-origin': 'https://www.youtube.com',
  4035. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${this.#auth.PAPISID} https://www.youtube.com`)}`
  4036. },
  4037. data: JSON.stringify(likeVideoData)
  4038. });
  4039. if (result === 'Success') {
  4040. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4041. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4042. logStatus.success();
  4043. if (doTask) {
  4044. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4045. }
  4046. return true;
  4047. }
  4048. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4049. return false;
  4050. }
  4051. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4052. return false;
  4053. }
  4054. logStatus.error(`${result}:${statusText}(${status})`);
  4055. return false;
  4056. } catch (error) {
  4057. throwError(error, 'Youtube.toggleLikeVideo');
  4058. return false;
  4059. }
  4060. }
  4061. async toggle(_ref4) {
  4062. let {
  4063. doTask = true,
  4064. channelLinks = [],
  4065. videoLinks = []
  4066. } = _ref4;
  4067. try {
  4068. if (!this.#initialized) {
  4069. scripts_echoLog({
  4070. text: i18n('needInit')
  4071. });
  4072. return false;
  4073. }
  4074. const prom = [];
  4075. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4076. scripts_echoLog({
  4077. type: 'globalOptionsSkip',
  4078. text: 'youtube.channels'
  4079. });
  4080. } else {
  4081. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4082. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4083. var _link$match;
  4084. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4085. }
  4086. return link;
  4087. });
  4088. if (realChannels.length > 0) {
  4089. for (const channel of realChannels) {
  4090. prom.push(this.#toggleChannel({
  4091. link: channel,
  4092. doTask: doTask
  4093. }));
  4094. await delay(1e3);
  4095. }
  4096. }
  4097. }
  4098. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4099. scripts_echoLog({
  4100. type: 'globalOptionsSkip',
  4101. text: 'youtube.likes'
  4102. });
  4103. } else {
  4104. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4105. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4106. var _link$match2;
  4107. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4108. }
  4109. return link;
  4110. });
  4111. if (realLikes.length > 0) {
  4112. for (const video of realLikes) {
  4113. prom.push(this.#toggleLikeVideo({
  4114. link: video,
  4115. doTask: doTask
  4116. }));
  4117. await delay(1e3);
  4118. }
  4119. }
  4120. }
  4121. return Promise.all(prom).then(() => true);
  4122. } catch (error) {
  4123. throwError(error, 'Youtube.toggle');
  4124. return false;
  4125. }
  4126. }
  4127. }
  4128. var Steam_GM_getValue;
  4129. const Steam_defaultTasksTemplate = {
  4130. groups: [],
  4131. officialGroups: [],
  4132. wishlists: [],
  4133. follows: [],
  4134. forums: [],
  4135. workshops: [],
  4136. workshopVotes: [],
  4137. curators: [],
  4138. curatorLikes: [],
  4139. announcements: [],
  4140. licenses: [],
  4141. playtests: []
  4142. };
  4143. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4144. class Steam extends social_Social {
  4145. tasks = JSON.parse(Steam_defaultTasks);
  4146. whiteList = {
  4147. ...JSON.parse(Steam_defaultTasks),
  4148. ...(Steam_GM_getValue = GM_getValue('whiteList')) === null || Steam_GM_getValue === void 0 ? void 0 : Steam_GM_getValue.steam
  4149. };
  4150. #cache = {
  4151. ...{
  4152. group: {},
  4153. officialGroup: {},
  4154. forum: {},
  4155. workshop: {},
  4156. curator: {}
  4157. },
  4158. ...GM_getValue('steamCache')
  4159. };
  4160. #auth = {};
  4161. #storeInitialized = false;
  4162. #communityInitialized = false;
  4163. #area = 'CN';
  4164. #areaStatus = 'end';
  4165. async init() {
  4166. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4167. try {
  4168. if (type === 'store') {
  4169. if (this.#storeInitialized) {
  4170. return true;
  4171. }
  4172. this.#storeInitialized = await this.#updateStoreAuth();
  4173. if (!this.#storeInitialized) {
  4174. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4175. return false;
  4176. }
  4177. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4178. return true;
  4179. }
  4180. if (type === 'community') {
  4181. if (this.#communityInitialized) {
  4182. return true;
  4183. }
  4184. this.#communityInitialized = await this.#updateCommunityAuth();
  4185. if (!this.#communityInitialized) {
  4186. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4187. return false;
  4188. }
  4189. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4190. return true;
  4191. }
  4192. this.#storeInitialized = await this.#updateStoreAuth();
  4193. this.#communityInitialized = await this.#updateCommunityAuth();
  4194. if (this.#storeInitialized && this.#communityInitialized) {
  4195. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4196. return true;
  4197. }
  4198. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4199. return false;
  4200. } catch (error) {
  4201. throwError(error, 'Steam.init');
  4202. return false;
  4203. }
  4204. }
  4205. async #refreshStoreToken() {
  4206. try {
  4207. const logStatus = scripts_echoLog({
  4208. text: i18n('refreshingToken', i18n('steamStore'))
  4209. });
  4210. const formData = new FormData();
  4211. formData.append('redir', 'https://store.steampowered.com/');
  4212. const {
  4213. result,
  4214. statusText,
  4215. status,
  4216. data
  4217. } = await tools_httpRequest({
  4218. url: 'https://login.steampowered.com/jwt/ajaxrefresh',
  4219. method: 'POST',
  4220. responseType: 'json',
  4221. headers: {
  4222. Host: 'login.steampowered.com',
  4223. Origin: 'https://store.steampowered.com',
  4224. Referer: 'https://store.steampowered.com/'
  4225. },
  4226. data: formData
  4227. });
  4228. if (result === 'Success') {
  4229. var _data$response;
  4230. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  4231. if (await this.#setStoreToken(data.response)) {
  4232. logStatus.success();
  4233. return true;
  4234. }
  4235. logStatus.error('Error');
  4236. return false;
  4237. }
  4238. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4239. return false;
  4240. }
  4241. logStatus.error(`${result}:${statusText}(${status})`);
  4242. return false;
  4243. } catch (error) {
  4244. throwError(error, 'Steam.refreshStoreToken');
  4245. return false;
  4246. }
  4247. }
  4248. async #setStoreToken(param) {
  4249. try {
  4250. const logStatus = scripts_echoLog({
  4251. text: i18n('settingToken', i18n('steamStore'))
  4252. });
  4253. const formData = new FormData();
  4254. formData.append('steamID', param.steamID);
  4255. formData.append('nonce', param.nonce);
  4256. formData.append('redir', param.redir);
  4257. formData.append('auth', param.auth);
  4258. const {
  4259. result,
  4260. statusText,
  4261. status,
  4262. data
  4263. } = await tools_httpRequest({
  4264. url: 'https://store.steampowered.com/login/settoken',
  4265. method: 'POST',
  4266. headers: {
  4267. Accept: 'application/json, text/plain, */*',
  4268. Host: 'store.steampowered.com',
  4269. Origin: 'https://store.steampowered.com',
  4270. Referer: 'https://store.steampowered.com/login'
  4271. },
  4272. data: formData
  4273. });
  4274. if (result === 'Success') {
  4275. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4276. logStatus.success();
  4277. return true;
  4278. }
  4279. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4280. return false;
  4281. }
  4282. logStatus.error(`${result}:${statusText}(${status})`);
  4283. return false;
  4284. } catch (error) {
  4285. throwError(error, 'Steam.setStoreToken');
  4286. return false;
  4287. }
  4288. }
  4289. async #updateStoreAuth() {
  4290. try {
  4291. const logStatus = scripts_echoLog({
  4292. text: i18n('updatingAuth', i18n('steamStore'))
  4293. });
  4294. const {
  4295. result,
  4296. statusText,
  4297. status,
  4298. data
  4299. } = await tools_httpRequest({
  4300. url: 'https://store.steampowered.com/',
  4301. method: 'GET',
  4302. headers: {
  4303. Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  4304. 'Cache-Control': 'max-age=0',
  4305. 'Sec-Fetch-Dest': 'document',
  4306. 'Sec-Fetch-Mode': 'navigate',
  4307. 'Upgrade-Insecure-Requests': '1'
  4308. }
  4309. });
  4310. if (result === 'Success') {
  4311. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4312. var _data$responseText$ma;
  4313. if (!data.responseText.includes('data-miniprofile=')) {
  4314. await this.#refreshStoreToken();
  4315. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  4316. return false;
  4317. }
  4318. const storeSessionID = (_data$responseText$ma = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4319. if (storeSessionID) {
  4320. this.#auth.storeSessionID = storeSessionID;
  4321. logStatus.success();
  4322. return true;
  4323. }
  4324. logStatus.error('Error: Get "sessionID" failed');
  4325. return false;
  4326. }
  4327. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4328. return false;
  4329. }
  4330. logStatus.error(`${result}:${statusText}(${status})`);
  4331. return false;
  4332. } catch (error) {
  4333. throwError(error, 'Steam.updateStoreAuth');
  4334. return false;
  4335. }
  4336. }
  4337. async #updateCommunityAuth() {
  4338. try {
  4339. const logStatus = scripts_echoLog({
  4340. text: i18n('updatingAuth', i18n('steamCommunity'))
  4341. });
  4342. const {
  4343. result,
  4344. statusText,
  4345. status,
  4346. data
  4347. } = await tools_httpRequest({
  4348. url: 'https://steamcommunity.com/my',
  4349. method: 'GET',
  4350. headers: {
  4351. Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  4352. 'Cache-Control': 'max-age=0',
  4353. 'Sec-Fetch-Dest': 'document',
  4354. 'Sec-Fetch-Mode': 'navigate',
  4355. 'Upgrade-Insecure-Requests': '1'
  4356. }
  4357. });
  4358. if (result === 'Success') {
  4359. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4360. var _data$responseText$ma2, _data$responseText$ma3, _data$responseText$ma4;
  4361. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  4362. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  4363. return false;
  4364. }
  4365. const steam64Id = (_data$responseText$ma2 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4366. const communitySessionID = (_data$responseText$ma3 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4367. const userName = (_data$responseText$ma4 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4368. if (steam64Id) {
  4369. this.#auth.steam64Id = steam64Id;
  4370. }
  4371. if (userName) {
  4372. this.#auth.userName = userName;
  4373. }
  4374. if (communitySessionID) {
  4375. this.#auth.communitySessionID = communitySessionID;
  4376. logStatus.success();
  4377. return true;
  4378. }
  4379. logStatus.error('Error: Get "sessionID" failed');
  4380. return false;
  4381. }
  4382. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4383. return false;
  4384. }
  4385. logStatus.error(`${result}:${statusText}(${status})`);
  4386. return false;
  4387. } catch (error) {
  4388. throwError(error, 'Steam.updateCommunityAuth');
  4389. return false;
  4390. }
  4391. }
  4392. async #getAreaInfo() {
  4393. try {
  4394. const logStatus = scripts_echoLog({
  4395. text: i18n('gettingAreaInfo')
  4396. });
  4397. const {
  4398. result,
  4399. statusText,
  4400. status,
  4401. data
  4402. } = await tools_httpRequest({
  4403. url: 'https://store.steampowered.com/cart/',
  4404. method: 'GET'
  4405. });
  4406. if (result === 'Success') {
  4407. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4408. var _data$responseText$ma5;
  4409. const currentArea = (_data$responseText$ma5 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4410. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  4411. if (currentArea && areas.length > 0) {
  4412. this.#area = currentArea;
  4413. logStatus.success();
  4414. return {
  4415. currentArea: currentArea,
  4416. areas: areas
  4417. };
  4418. }
  4419. logStatus.error('Error: get country info filed');
  4420. return {};
  4421. }
  4422. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4423. return {};
  4424. }
  4425. logStatus.error(`${result}:${statusText}(${status})`);
  4426. return {};
  4427. } catch (error) {
  4428. throwError(error, 'Steam.getAreaInfo');
  4429. return {};
  4430. }
  4431. }
  4432. async #changeArea(area) {
  4433. try {
  4434. if (this.#areaStatus === 'waiting') {
  4435. await new Promise(resolve => {
  4436. const checker = setInterval(() => {
  4437. if (this.#areaStatus !== 'waiting') {
  4438. clearInterval(checker);
  4439. resolve(true);
  4440. }
  4441. });
  4442. });
  4443. }
  4444. if (this.#area === area || !area && this.#area !== 'CN') {
  4445. return true;
  4446. }
  4447. this.#areaStatus = 'waiting';
  4448. let aimedArea = area;
  4449. if (!aimedArea) {
  4450. const {
  4451. currentArea,
  4452. areas
  4453. } = await this.#getAreaInfo();
  4454. if (!currentArea || !areas) {
  4455. this.#areaStatus = 'error';
  4456. return false;
  4457. }
  4458. if (currentArea !== 'CN') {
  4459. this.#areaStatus = 'skip';
  4460. scripts_echoLog({
  4461. text: 'notNeededChangeArea'
  4462. });
  4463. return 'skip';
  4464. }
  4465. const anotherArea = areas.filter(area => area && area !== 'CN');
  4466. if (!anotherArea || anotherArea.length === 0) {
  4467. this.#areaStatus = 'noAnotherArea';
  4468. scripts_echoLog({
  4469. text: 'noAnotherArea'
  4470. });
  4471. return false;
  4472. }
  4473. [ aimedArea ] = anotherArea;
  4474. }
  4475. const logStatus = scripts_echoLog({
  4476. text: i18n('changingArea', aimedArea)
  4477. });
  4478. const {
  4479. result,
  4480. statusText,
  4481. status,
  4482. data
  4483. } = await tools_httpRequest({
  4484. url: 'https://store.steampowered.com/account/setcountry',
  4485. method: 'POST',
  4486. headers: {
  4487. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4488. },
  4489. data: $.param({
  4490. cc: aimedArea,
  4491. sessionid: this.#auth.storeSessionID
  4492. })
  4493. });
  4494. if (result === 'Success') {
  4495. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  4496. const {
  4497. currentArea
  4498. } = await this.#getAreaInfo();
  4499. if (currentArea === aimedArea) {
  4500. this.#areaStatus = 'success';
  4501. logStatus.success();
  4502. return currentArea;
  4503. }
  4504. this.#areaStatus = 'error';
  4505. logStatus.error('Error: change country filed');
  4506. return 'CN';
  4507. }
  4508. this.#areaStatus = 'error';
  4509. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4510. return 'CN';
  4511. }
  4512. this.#areaStatus = 'error';
  4513. logStatus.error(`${result}:${statusText}(${status})`);
  4514. return 'CN';
  4515. } catch (error) {
  4516. this.#areaStatus = 'error';
  4517. throwError(error, 'Steam.changeArea');
  4518. return false;
  4519. }
  4520. }
  4521. async #joinGroup(groupName) {
  4522. try {
  4523. const logStatus = scripts_echoLog({
  4524. type: 'joiningSteamGroup',
  4525. text: groupName
  4526. });
  4527. const {
  4528. result,
  4529. statusText,
  4530. status,
  4531. data
  4532. } = await tools_httpRequest({
  4533. url: `https://steamcommunity.com/groups/${groupName}`,
  4534. method: 'POST',
  4535. headers: {
  4536. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4537. },
  4538. data: $.param({
  4539. action: 'join',
  4540. sessionID: this.#auth.communitySessionID
  4541. })
  4542. });
  4543. if (result === 'Success') {
  4544. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  4545. logStatus.success();
  4546. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  4547. return true;
  4548. }
  4549. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4550. return false;
  4551. }
  4552. logStatus.error(`${result}:${statusText}(${status})`);
  4553. return false;
  4554. } catch (error) {
  4555. throwError(error, 'Steam.joinGroup');
  4556. return false;
  4557. }
  4558. }
  4559. async #leaveGroup(groupName) {
  4560. try {
  4561. if (this.whiteList.groups.includes(groupName)) {
  4562. scripts_echoLog({
  4563. type: 'whiteList',
  4564. text: 'Steam.leaveGroup',
  4565. id: groupName
  4566. });
  4567. return true;
  4568. }
  4569. const groupId = await this.#getGroupId(groupName);
  4570. if (!groupId) {
  4571. return false;
  4572. }
  4573. const logStatus = scripts_echoLog({
  4574. type: 'leavingSteamGroup',
  4575. text: groupName
  4576. });
  4577. const {
  4578. result,
  4579. statusText,
  4580. status,
  4581. data
  4582. } = await tools_httpRequest({
  4583. url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
  4584. method: 'POST',
  4585. headers: {
  4586. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4587. },
  4588. data: $.param({
  4589. sessionID: this.#auth.communitySessionID,
  4590. action: 'leaveGroup',
  4591. groupId: groupId
  4592. })
  4593. });
  4594. if (result === 'Success') {
  4595. 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) {
  4596. logStatus.success();
  4597. return true;
  4598. }
  4599. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4600. return false;
  4601. }
  4602. logStatus.error(`${result}:${statusText}(${status})`);
  4603. return false;
  4604. } catch (error) {
  4605. throwError(error, 'Steam.leaveGroup');
  4606. return false;
  4607. }
  4608. }
  4609. async #getGroupId(groupName) {
  4610. try {
  4611. const logStatus = scripts_echoLog({
  4612. type: 'gettingSteamGroupId',
  4613. text: groupName
  4614. });
  4615. const groupId = this.#cache.group[groupName];
  4616. if (groupId) {
  4617. logStatus.success();
  4618. return groupId;
  4619. }
  4620. const {
  4621. result,
  4622. statusText,
  4623. status,
  4624. data
  4625. } = await tools_httpRequest({
  4626. url: `https://steamcommunity.com/groups/${groupName}`,
  4627. method: 'GET',
  4628. headers: {
  4629. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4630. }
  4631. });
  4632. if (result === 'Success') {
  4633. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4634. var _data$responseText$ma6;
  4635. const groupId = (_data$responseText$ma6 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  4636. if (groupId) {
  4637. this.#setCache('group', groupName, groupId);
  4638. logStatus.success();
  4639. return groupId;
  4640. }
  4641. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4642. return false;
  4643. }
  4644. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4645. return false;
  4646. }
  4647. logStatus.error(`${result}:${statusText}(${status})`);
  4648. return false;
  4649. } catch (error) {
  4650. throwError(error, 'Steam.getGroupID');
  4651. return false;
  4652. }
  4653. }
  4654. async #joinOfficialGroup(gameId) {
  4655. try {
  4656. const logStatus = scripts_echoLog({
  4657. type: 'joiningSteamOfficialGroup',
  4658. text: gameId
  4659. });
  4660. const {
  4661. result,
  4662. statusText,
  4663. status,
  4664. data
  4665. } = await tools_httpRequest({
  4666. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${this.#auth.communitySessionID}`,
  4667. method: 'GET',
  4668. headers: {
  4669. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4670. }
  4671. });
  4672. if (result === 'Success') {
  4673. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  4674. var _data$responseText$ma7;
  4675. logStatus.success();
  4676. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  4677. const groupId = (_data$responseText$ma7 = data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  4678. if (groupId) {
  4679. this.#setCache('officialGroup', gameId, groupId);
  4680. }
  4681. return true;
  4682. }
  4683. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4684. return false;
  4685. }
  4686. logStatus.error(`${result}:${statusText}(${status})`);
  4687. return false;
  4688. } catch (error) {
  4689. throwError(error, 'Steam.joinOfficialGroup');
  4690. return false;
  4691. }
  4692. }
  4693. async #leaveOfficialGroup(gameId) {
  4694. try {
  4695. if (this.whiteList.officialGroups.includes(gameId)) {
  4696. scripts_echoLog({
  4697. type: 'whiteList',
  4698. text: 'Steam.leaveOfficialGroup',
  4699. id: gameId
  4700. });
  4701. return true;
  4702. }
  4703. const groupId = await this.#getOfficialGroupId(gameId);
  4704. if (!groupId) {
  4705. return false;
  4706. }
  4707. const logStatus = scripts_echoLog({
  4708. type: 'leavingSteamOfficialGroup',
  4709. text: gameId
  4710. });
  4711. const {
  4712. result,
  4713. statusText,
  4714. status,
  4715. data
  4716. } = await tools_httpRequest({
  4717. url: `https://steamcommunity.com/id/${this.#auth.userName}/home_process`,
  4718. method: 'POST',
  4719. headers: {
  4720. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4721. },
  4722. data: $.param({
  4723. sessionID: this.#auth.communitySessionID,
  4724. action: 'leaveGroup',
  4725. groupId: groupId
  4726. })
  4727. });
  4728. if (result === 'Success') {
  4729. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4730. const {
  4731. result: resultR,
  4732. statusText: statusTextR,
  4733. status: statusR,
  4734. data: dataR
  4735. } = await tools_httpRequest({
  4736. url: `https://steamcommunity.com/games/${gameId}`,
  4737. method: 'GET',
  4738. headers: {
  4739. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4740. }
  4741. });
  4742. if (resultR === 'Success') {
  4743. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  4744. logStatus.success();
  4745. return true;
  4746. }
  4747. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4748. return false;
  4749. }
  4750. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4751. return false;
  4752. }
  4753. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4754. return false;
  4755. }
  4756. logStatus.error(`${result}:${statusText}(${status})`);
  4757. return false;
  4758. } catch (error) {
  4759. throwError(error, 'Steam.leaveOfficialGroup');
  4760. return false;
  4761. }
  4762. }
  4763. async #getOfficialGroupId(gameId) {
  4764. try {
  4765. const logStatus = scripts_echoLog({
  4766. type: 'gettingSteamOfficialGroupId',
  4767. text: gameId
  4768. });
  4769. const groupId = this.#cache.officialGroup[gameId];
  4770. if (groupId) {
  4771. logStatus.success();
  4772. return groupId;
  4773. }
  4774. const {
  4775. result,
  4776. statusText,
  4777. status,
  4778. data
  4779. } = await tools_httpRequest({
  4780. url: `https://steamcommunity.com/games/${gameId}`,
  4781. method: 'GET',
  4782. headers: {
  4783. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4784. }
  4785. });
  4786. if (result === 'Success') {
  4787. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4788. var _data$responseText$ma8;
  4789. const groupId = (_data$responseText$ma8 = data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)) === null || _data$responseText$ma8 === void 0 ? void 0 : _data$responseText$ma8[1];
  4790. if (groupId) {
  4791. this.#setCache('officialGroup', gameId, groupId);
  4792. logStatus.success();
  4793. return groupId;
  4794. }
  4795. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4796. return false;
  4797. }
  4798. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4799. return false;
  4800. }
  4801. logStatus.error(`${result}:${statusText}(${status})`);
  4802. return false;
  4803. } catch (error) {
  4804. throwError(error, 'Steam.getGroupID');
  4805. return false;
  4806. }
  4807. }
  4808. async #addToWishlist(gameId) {
  4809. try {
  4810. var _data$response2;
  4811. const logStatus = scripts_echoLog({
  4812. type: 'addingToWishlist',
  4813. text: gameId
  4814. });
  4815. const {
  4816. result,
  4817. data
  4818. } = await tools_httpRequest({
  4819. url: 'https://store.steampowered.com/api/addtowishlist',
  4820. method: 'POST',
  4821. headers: {
  4822. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4823. },
  4824. data: $.param({
  4825. sessionid: this.#auth.storeSessionID,
  4826. appid: gameId
  4827. }),
  4828. dataType: 'json'
  4829. });
  4830. 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) {
  4831. logStatus.success();
  4832. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  4833. return true;
  4834. }
  4835. const {
  4836. result: resultR,
  4837. statusText: statusTextR,
  4838. status: statusR,
  4839. data: dataR
  4840. } = await tools_httpRequest({
  4841. url: `https://store.steampowered.com/app/${gameId}`,
  4842. method: 'GET'
  4843. });
  4844. if (resultR === 'Success') {
  4845. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  4846. if (this.#area === 'CN' && dataR.responseText.includes('id="error_box"')) {
  4847. logStatus.warning(i18n('changeAreaNotice'));
  4848. if (!await this.#changeArea()) {
  4849. return false;
  4850. }
  4851. return await this.#addToWishlist(gameId);
  4852. }
  4853. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  4854. logStatus.success();
  4855. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  4856. return true;
  4857. } 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"')) {
  4858. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  4859. return false;
  4860. }
  4861. logStatus.success();
  4862. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  4863. return true;
  4864. }
  4865. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4866. return false;
  4867. }
  4868. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4869. return false;
  4870. } catch (error) {
  4871. throwError(error, 'Steam.addToWishlist');
  4872. return false;
  4873. }
  4874. }
  4875. async #removeFromWishlist(gameId) {
  4876. try {
  4877. var _data$response3;
  4878. if (this.whiteList.wishlists.includes(gameId)) {
  4879. scripts_echoLog({
  4880. type: 'whiteList',
  4881. text: 'Steam.removeFromWishlist',
  4882. id: gameId
  4883. });
  4884. return true;
  4885. }
  4886. const logStatus = scripts_echoLog({
  4887. type: 'removingFromWishlist',
  4888. text: gameId
  4889. });
  4890. const {
  4891. result,
  4892. data
  4893. } = await tools_httpRequest({
  4894. url: 'https://store.steampowered.com/api/removefromwishlist',
  4895. method: 'POST',
  4896. headers: {
  4897. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4898. },
  4899. data: $.param({
  4900. sessionid: this.#auth.storeSessionID,
  4901. appid: gameId
  4902. }),
  4903. dataType: 'json'
  4904. });
  4905. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response3 = data.response) === null || _data$response3 === void 0 ? void 0 : _data$response3.success) === true) {
  4906. logStatus.success();
  4907. return true;
  4908. }
  4909. const {
  4910. result: resultR,
  4911. statusText: statusTextR,
  4912. status: statusR,
  4913. data: dataR
  4914. } = await tools_httpRequest({
  4915. url: `https://store.steampowered.com/app/${gameId}`,
  4916. method: 'GET'
  4917. });
  4918. if (resultR === 'Success') {
  4919. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  4920. if (this.#area === 'CN' && dataR.responseText.includes('id="error_box"')) {
  4921. logStatus.warning(i18n('changeAreaNotice'));
  4922. const result = await this.#changeArea();
  4923. if (!result || result === 'CN' || result === 'skip') {
  4924. return false;
  4925. }
  4926. return await this.#removeFromWishlist(gameId);
  4927. }
  4928. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  4929. logStatus.success();
  4930. return true;
  4931. }
  4932. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  4933. return false;
  4934. }
  4935. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  4936. return false;
  4937. }
  4938. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  4939. return false;
  4940. } catch (error) {
  4941. throwError(error, 'Steam.removeFromWishlist');
  4942. return false;
  4943. }
  4944. }
  4945. async #toggleFollowGame(gameId, doTask) {
  4946. try {
  4947. if (!doTask && this.whiteList.follows.includes(gameId)) {
  4948. scripts_echoLog({
  4949. type: 'whiteList',
  4950. text: 'Steam.unfollowGame',
  4951. id: gameId
  4952. });
  4953. return true;
  4954. }
  4955. const logStatus = scripts_echoLog({
  4956. type: `${doTask ? '' : 'un'}followingGame`,
  4957. text: gameId
  4958. });
  4959. const requestData = {
  4960. sessionid: this.#auth.storeSessionID,
  4961. appid: gameId
  4962. };
  4963. if (!doTask) {
  4964. requestData.unfollow = '1';
  4965. }
  4966. const {
  4967. result,
  4968. data
  4969. } = await tools_httpRequest({
  4970. url: 'https://store.steampowered.com/explore/followgame/',
  4971. method: 'POST',
  4972. headers: {
  4973. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4974. },
  4975. data: $.param(requestData)
  4976. });
  4977. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  4978. logStatus.success();
  4979. return true;
  4980. }
  4981. const followed = await this.#isFollowedGame(gameId);
  4982. if (this.#area === 'CN' && followed === 'areaLocked') {
  4983. logStatus.warning(i18n('changeAreaNotice'));
  4984. if (!await this.#changeArea()) {
  4985. return false;
  4986. }
  4987. return await this.#removeFromWishlist(gameId);
  4988. }
  4989. if (doTask === followed) {
  4990. logStatus.success();
  4991. if (doTask) {
  4992. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  4993. }
  4994. return true;
  4995. }
  4996. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4997. return false;
  4998. } catch (error) {
  4999. throwError(error, 'Steam.toggleFollowGame');
  5000. return false;
  5001. }
  5002. }
  5003. async #isFollowedGame(gameId) {
  5004. try {
  5005. const {
  5006. result,
  5007. data
  5008. } = await tools_httpRequest({
  5009. url: `https://store.steampowered.com/app/${gameId}`,
  5010. method: 'GET'
  5011. });
  5012. if (result === 'Success') {
  5013. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5014. if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
  5015. return 'areaLocked';
  5016. }
  5017. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5018. return true;
  5019. }
  5020. return false;
  5021. }
  5022. return false;
  5023. }
  5024. return false;
  5025. } catch (error) {
  5026. throwError(error, 'Steam.isFollowedGame');
  5027. return false;
  5028. }
  5029. }
  5030. async #toggleForum(gameId) {
  5031. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5032. try {
  5033. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5034. scripts_echoLog({
  5035. type: 'whiteList',
  5036. text: 'Steam.unsubscribeForum',
  5037. id: gameId
  5038. });
  5039. return true;
  5040. }
  5041. const forumId = await this.#getForumId(gameId);
  5042. if (!forumId) {
  5043. return false;
  5044. }
  5045. const logStatus = scripts_echoLog({
  5046. type: `${doTask ? '' : 'un'}subscribingForum`,
  5047. text: gameId
  5048. });
  5049. const [ id, feature ] = forumId.split('_');
  5050. const {
  5051. result,
  5052. statusText,
  5053. status,
  5054. data
  5055. } = await tools_httpRequest({
  5056. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5057. method: 'POST',
  5058. responseType: 'json',
  5059. headers: {
  5060. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5061. },
  5062. data: $.param({
  5063. sessionid: this.#auth.communitySessionID
  5064. })
  5065. });
  5066. if (result === 'Success') {
  5067. var _data$response4, _data$response5;
  5068. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (((_data$response4 = data.response) === null || _data$response4 === void 0 ? void 0 : _data$response4.success) === 1 || ((_data$response5 = data.response) === null || _data$response5 === void 0 ? void 0 : _data$response5.success) === 29)) {
  5069. if (doTask) {
  5070. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5071. }
  5072. logStatus.success();
  5073. return true;
  5074. }
  5075. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5076. return true;
  5077. }
  5078. logStatus.error(`${result}:${statusText}(${status})`);
  5079. return true;
  5080. } catch (error) {
  5081. throwError(error, 'Steam.toggleForum');
  5082. return true;
  5083. }
  5084. }
  5085. async #getForumId(gameId) {
  5086. try {
  5087. const logStatus = scripts_echoLog({
  5088. type: 'gettingForumId',
  5089. text: gameId
  5090. });
  5091. const forumId = this.#cache.forum[gameId];
  5092. if (forumId) {
  5093. logStatus.success();
  5094. return forumId;
  5095. }
  5096. const {
  5097. result,
  5098. statusText,
  5099. status,
  5100. data
  5101. } = await tools_httpRequest({
  5102. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5103. method: 'GET'
  5104. });
  5105. if (result === 'Success') {
  5106. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5107. var _data$responseText, _data$responseText$ma9;
  5108. const forumId = (_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : (_data$responseText$ma9 = _data$responseText.match(/General_([\d]+(_[\d]+)?)/)) === null || _data$responseText$ma9 === void 0 ? void 0 : _data$responseText$ma9[1];
  5109. if (forumId) {
  5110. this.#setCache('forum', gameId, forumId);
  5111. logStatus.success();
  5112. return forumId;
  5113. }
  5114. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5115. return false;
  5116. }
  5117. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5118. return false;
  5119. }
  5120. logStatus.error(`${result}:${statusText}(${status})`);
  5121. return false;
  5122. } catch (error) {
  5123. throwError(error, 'Steam.getForumId');
  5124. return false;
  5125. }
  5126. }
  5127. async #toggleFavoriteWorkshop(id) {
  5128. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5129. try {
  5130. if (!doTask && this.whiteList.workshops.includes(id)) {
  5131. scripts_echoLog({
  5132. type: 'whiteList',
  5133. text: 'Steam.unfavoriteWorkshop',
  5134. id: id
  5135. });
  5136. return true;
  5137. }
  5138. const appid = await this.#getWorkshopAppId(id);
  5139. if (!appid) {
  5140. return false;
  5141. }
  5142. const logStatus = scripts_echoLog({
  5143. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5144. text: id
  5145. });
  5146. const {
  5147. result,
  5148. statusText,
  5149. status,
  5150. data
  5151. } = await tools_httpRequest({
  5152. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5153. method: 'POST',
  5154. headers: {
  5155. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5156. },
  5157. data: $.param({
  5158. id: id,
  5159. appid: appid,
  5160. sessionid: this.#auth.communitySessionID
  5161. })
  5162. });
  5163. if (result === 'Success') {
  5164. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5165. if (doTask) {
  5166. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5167. }
  5168. logStatus.success();
  5169. return true;
  5170. }
  5171. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5172. return false;
  5173. }
  5174. logStatus.error(`${result}:${statusText}(${status})`);
  5175. return false;
  5176. } catch (error) {
  5177. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5178. return false;
  5179. }
  5180. }
  5181. async #getWorkshopAppId(id) {
  5182. try {
  5183. const logStatus = scripts_echoLog({
  5184. type: 'gettingWorkshopAppId',
  5185. text: id
  5186. });
  5187. const appId = this.#cache.workshop[id];
  5188. if (appId) {
  5189. logStatus.success();
  5190. return appId;
  5191. }
  5192. const {
  5193. result,
  5194. statusText,
  5195. status,
  5196. data
  5197. } = await tools_httpRequest({
  5198. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5199. method: 'GET'
  5200. });
  5201. if (result === 'Success') {
  5202. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5203. var _data$responseText$ma10;
  5204. const appId = (_data$responseText$ma10 = data.responseText.match(/<input type="hidden" name="appid" value="([\d]+?)" \/>/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5205. if (appId) {
  5206. this.#setCache('workshop', id, appId);
  5207. logStatus.success();
  5208. return appId;
  5209. }
  5210. logStatus.error('Error: getWorkshopAppId failed');
  5211. return false;
  5212. }
  5213. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5214. return false;
  5215. }
  5216. logStatus.error(`${result}:${statusText}(${status})`);
  5217. return false;
  5218. } catch (error) {
  5219. throwError(error, 'Steam.getWorkshopAppId');
  5220. return false;
  5221. }
  5222. }
  5223. async #voteUpWorkshop(id) {
  5224. try {
  5225. const logStatus = scripts_echoLog({
  5226. type: 'votingUpWorkshop',
  5227. text: id
  5228. });
  5229. const {
  5230. result,
  5231. statusText,
  5232. status,
  5233. data
  5234. } = await tools_httpRequest({
  5235. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5236. method: 'POST',
  5237. responseType: 'json',
  5238. headers: {
  5239. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5240. },
  5241. data: $.param({
  5242. id: id,
  5243. sessionid: this.#auth.communitySessionID
  5244. })
  5245. });
  5246. if (result === 'Success') {
  5247. var _data$response6;
  5248. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response6 = data.response) === null || _data$response6 === void 0 ? void 0 : _data$response6.success) === 1) {
  5249. logStatus.success();
  5250. return true;
  5251. }
  5252. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5253. return true;
  5254. }
  5255. logStatus.error(`${result}:${statusText}(${status})`);
  5256. return true;
  5257. } catch (error) {
  5258. throwError(error, 'Steam.voteupWorkshop');
  5259. return true;
  5260. }
  5261. }
  5262. async #toggleCurator(curatorId) {
  5263. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5264. try {
  5265. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5266. scripts_echoLog({
  5267. type: 'whiteList',
  5268. text: 'Steam.unfollowCurator',
  5269. id: curatorId
  5270. });
  5271. return true;
  5272. }
  5273. const logStatus = scripts_echoLog({
  5274. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5275. text: curatorId
  5276. });
  5277. const {
  5278. result,
  5279. statusText,
  5280. status,
  5281. data
  5282. } = await tools_httpRequest({
  5283. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5284. method: 'POST',
  5285. headers: {
  5286. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5287. },
  5288. data: $.param({
  5289. clanid: curatorId,
  5290. sessionid: this.#auth.storeSessionID,
  5291. follow: doTask
  5292. }),
  5293. dataType: 'json'
  5294. });
  5295. if (result === 'Success') {
  5296. var _data$response7, _data$response7$succe, _data$response8;
  5297. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response7 = data.response) === null || _data$response7 === void 0 ? void 0 : (_data$response7$succe = _data$response7.success) === null || _data$response7$succe === void 0 ? void 0 : _data$response7$succe.success) === 1) {
  5298. logStatus.success();
  5299. return true;
  5300. }
  5301. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.success}` || `${data === null || data === void 0 ? void 0 : data.status})`);
  5302. return false;
  5303. }
  5304. logStatus.error(`${result}:${statusText}(${status})`);
  5305. return false;
  5306. } catch (error) {
  5307. throwError(error, 'Steam.toggleCurator');
  5308. return false;
  5309. }
  5310. }
  5311. async getCuratorId(path, name) {
  5312. try {
  5313. const logStatus = scripts_echoLog({
  5314. type: 'gettingCuratorId',
  5315. text: `${path}/${name}`
  5316. });
  5317. const curatorId = this.#cache.curator[`${path}/${name}`];
  5318. if (curatorId) {
  5319. logStatus.success();
  5320. return curatorId;
  5321. }
  5322. const {
  5323. result,
  5324. statusText,
  5325. status,
  5326. data
  5327. } = await tools_httpRequest({
  5328. url: `https://store.steampowered.com/${path}/${name}`,
  5329. method: 'GET',
  5330. headers: {
  5331. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5332. }
  5333. });
  5334. if (result === 'Success') {
  5335. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5336. var _data$responseText$ma11;
  5337. const curatorId = (_data$responseText$ma11 = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5338. if (curatorId) {
  5339. this.#setCache('curator', `${path}/${name}`, curatorId);
  5340. logStatus.success();
  5341. return curatorId;
  5342. }
  5343. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5344. return false;
  5345. }
  5346. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5347. return false;
  5348. }
  5349. logStatus.error(`${result}:${statusText}(${status})`);
  5350. return false;
  5351. } catch (error) {
  5352. throwError(error, 'Steam.getCuratorID');
  5353. return false;
  5354. }
  5355. }
  5356. async #toggleCuratorLike(link) {
  5357. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5358. try {
  5359. const [ path, name ] = link.split('/');
  5360. if (!(path && name)) {
  5361. scripts_echoLog({
  5362. text: i18n('errorLink', link)
  5363. });
  5364. return false;
  5365. }
  5366. const curatorId = await this.getCuratorId(path, name);
  5367. if (curatorId) {
  5368. return await this.#toggleCurator(curatorId, doTask);
  5369. }
  5370. return false;
  5371. } catch (error) {
  5372. throwError(error, 'Steam.toggleCuratorLike');
  5373. return false;
  5374. }
  5375. }
  5376. async #getAnnouncementParams(appId, viewId) {
  5377. try {
  5378. const logStatus = scripts_echoLog({
  5379. type: 'gettingAnnouncementParams',
  5380. text: appId,
  5381. id: viewId
  5382. });
  5383. const {
  5384. result,
  5385. statusText,
  5386. status,
  5387. data
  5388. } = await tools_httpRequest({
  5389. url: `https://store.steampowered.com/events/ajaxgetpartnerevent?appid=${appId}&announcement_gid=${viewId}&lang_list=6_0&last_modified_time=0&origin=https:%2F%2Fstore.steampowered.com&for_edit=false`,
  5390. method: 'GET',
  5391. responseType: 'json',
  5392. headers: {
  5393. Host: 'store.steampowered.com',
  5394. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5395. }
  5396. });
  5397. if (result === 'Success') {
  5398. var _data$response9;
  5399. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response9 = data.response) === null || _data$response9 === void 0 ? void 0 : _data$response9.success) === 1) {
  5400. var _data$response$event;
  5401. const {
  5402. clanid,
  5403. gid
  5404. } = ((_data$response$event = data.response.event) === null || _data$response$event === void 0 ? void 0 : _data$response$event.announcement_body) || {};
  5405. if (clanid) {
  5406. logStatus.success();
  5407. return {
  5408. clanId: clanid,
  5409. gid: gid
  5410. };
  5411. }
  5412. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5413. return {};
  5414. }
  5415. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5416. return {};
  5417. }
  5418. logStatus.error(`${result}:${statusText}(${status})`);
  5419. return {};
  5420. } catch (error) {
  5421. throwError(error, 'Steam.likeAnnouncement');
  5422. return {};
  5423. }
  5424. }
  5425. async #likeAnnouncement(id) {
  5426. try {
  5427. const [ appId, viewId ] = id.split('/');
  5428. if (!(appId && viewId)) {
  5429. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  5430. return false;
  5431. }
  5432. const {
  5433. clanId,
  5434. gid
  5435. } = await this.#getAnnouncementParams(appId, viewId);
  5436. if (!clanId) {
  5437. return false;
  5438. }
  5439. const logStatus = scripts_echoLog({
  5440. type: 'likingAnnouncement',
  5441. text: appId,
  5442. id: viewId
  5443. });
  5444. const {
  5445. result,
  5446. statusText,
  5447. status,
  5448. data
  5449. } = await tools_httpRequest({
  5450. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5451. method: 'POST',
  5452. headers: {
  5453. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5454. Host: 'store.steampowered.com',
  5455. Origin: 'https://store.steampowered.com',
  5456. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5457. },
  5458. data: $.param({
  5459. sessionid: this.#auth.storeSessionID,
  5460. voteup: 1,
  5461. clanid: clanId,
  5462. ajax: 1
  5463. }),
  5464. dataType: 'json'
  5465. });
  5466. if (result === 'Success') {
  5467. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5468. logStatus.success();
  5469. return true;
  5470. }
  5471. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5472. return false;
  5473. }
  5474. logStatus.error(`${result}:${statusText}(${status})`);
  5475. return false;
  5476. } catch (error) {
  5477. throwError(error, 'Steam.likeAnnouncement');
  5478. return false;
  5479. }
  5480. }
  5481. async #appid2subid(id) {
  5482. try {
  5483. const logStatus = scripts_echoLog({
  5484. type: 'gettingSubid',
  5485. text: id
  5486. });
  5487. const {
  5488. result,
  5489. statusText,
  5490. status,
  5491. data
  5492. } = await tools_httpRequest({
  5493. url: `https://store.steampowered.com/app/${id}`,
  5494. method: 'GET',
  5495. headers: {
  5496. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5497. }
  5498. });
  5499. if (result === 'Success') {
  5500. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5501. var _data$responseText$ma12;
  5502. if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
  5503. logStatus.warning(i18n('changeAreaNotice'));
  5504. const result = await this.#changeArea();
  5505. if (!result || result === 'CN' || result === 'skip') {
  5506. return false;
  5507. }
  5508. return await this.#appid2subid(id);
  5509. }
  5510. const subid = (_data$responseText$ma12 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  5511. if (subid) {
  5512. logStatus.success();
  5513. return subid;
  5514. }
  5515. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5516. return false;
  5517. }
  5518. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5519. return false;
  5520. }
  5521. logStatus.error(`${result}:${statusText}(${status})`);
  5522. return false;
  5523. } catch (error) {
  5524. throwError(error, 'Steam.appid2subid');
  5525. return false;
  5526. }
  5527. }
  5528. async #getLicenses() {
  5529. try {
  5530. const logStatus = scripts_echoLog({
  5531. text: i18n('gettingLicenses')
  5532. });
  5533. const {
  5534. result,
  5535. statusText,
  5536. status,
  5537. data
  5538. } = await tools_httpRequest({
  5539. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  5540. method: 'GET',
  5541. responseType: 'json'
  5542. });
  5543. if (result === 'Success') {
  5544. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5545. var _data$response10;
  5546. logStatus.success();
  5547. return (_data$response10 = data.response) === null || _data$response10 === void 0 ? void 0 : _data$response10.rgOwnedPackages;
  5548. }
  5549. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5550. return false;
  5551. }
  5552. logStatus.error(`${result}:${statusText}(${status})`);
  5553. return false;
  5554. } catch (error) {
  5555. throwError(error, 'Steam.getLicenses');
  5556. return false;
  5557. }
  5558. }
  5559. async #addLicense(id) {
  5560. try {
  5561. const [ type, ids ] = id.split('-');
  5562. if (type === 'appid') {
  5563. const subid = await this.#appid2subid(ids);
  5564. if (!subid) {
  5565. return false;
  5566. }
  5567. const logStatus = scripts_echoLog({
  5568. type: 'addingFreeLicense',
  5569. text: ids
  5570. });
  5571. if (!await this.#addFreeLicense(subid, logStatus)) {
  5572. return false;
  5573. }
  5574. const {
  5575. result,
  5576. statusText,
  5577. status,
  5578. data
  5579. } = await tools_httpRequest({
  5580. url: `https://store.steampowered.com/app/${ids}`,
  5581. method: 'GET'
  5582. });
  5583. if (result === 'Success') {
  5584. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5585. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  5586. logStatus.success();
  5587. return true;
  5588. }
  5589. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5590. return false;
  5591. }
  5592. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5593. return false;
  5594. }
  5595. logStatus.error(`${result}:${statusText}(${status})`);
  5596. return false;
  5597. } else if (type === 'subid') {
  5598. if (this.#area === 'CN') {
  5599. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  5600. await this.#changeArea();
  5601. }
  5602. const logStatusArr = {};
  5603. const idsArr = ids.split(',');
  5604. for (const subid of idsArr) {
  5605. const logStatus = scripts_echoLog({
  5606. type: 'addingFreeLicenseSubid',
  5607. text: subid
  5608. });
  5609. if (!await this.#addFreeLicense(subid, logStatus)) {
  5610. return false;
  5611. }
  5612. logStatusArr[subid] = logStatus;
  5613. }
  5614. const licenses = await this.#getLicenses();
  5615. if (!licenses) {
  5616. return false;
  5617. }
  5618. for (const subid of idsArr) {
  5619. if (licenses.includes(parseInt(subid, 10))) {
  5620. logStatusArr[subid].success();
  5621. } else {
  5622. logStatusArr[subid].error();
  5623. }
  5624. }
  5625. return true;
  5626. }
  5627. return false;
  5628. } catch (error) {
  5629. throwError(error, 'Steam.addLicense');
  5630. return false;
  5631. }
  5632. }
  5633. async #addFreeLicense(id, logStatusPre) {
  5634. try {
  5635. const logStatus = logStatusPre || scripts_echoLog({
  5636. type: 'addingFreeLicenseSubid',
  5637. text: id
  5638. });
  5639. const {
  5640. result,
  5641. statusText,
  5642. status,
  5643. data
  5644. } = await tools_httpRequest({
  5645. url: 'https://store.steampowered.com/checkout/addfreelicense',
  5646. method: 'POST',
  5647. headers: {
  5648. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5649. Host: 'store.steampowered.com',
  5650. Origin: 'https://store.steampowered.com',
  5651. Referer: 'https://store.steampowered.com/account/licenses/'
  5652. },
  5653. data: $.param({
  5654. action: 'add_to_cart',
  5655. sessionid: this.#auth.storeSessionID,
  5656. subid: id
  5657. }),
  5658. dataType: 'json'
  5659. });
  5660. if (result === 'Success') {
  5661. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5662. if (this.#area === 'CN' && data.responseText.includes('id="error_box"')) {
  5663. logStatus.warning(i18n('changeAreaNotice'));
  5664. const result = await this.#changeArea();
  5665. if (!result || result === 'CN') {
  5666. return false;
  5667. }
  5668. return await this.#addFreeLicense(id);
  5669. }
  5670. logStatus.success();
  5671. return true;
  5672. }
  5673. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5674. return false;
  5675. }
  5676. logStatus.error(`${result}:${statusText}(${status})`);
  5677. return false;
  5678. } catch (error) {
  5679. throwError(error, 'Steam.addFreeLicense');
  5680. return false;
  5681. }
  5682. }
  5683. async #requestPlayTestAccess(id) {
  5684. try {
  5685. const logStatus = scripts_echoLog({
  5686. type: 'requestingPlayTestAccess',
  5687. text: id
  5688. });
  5689. const {
  5690. result,
  5691. statusText,
  5692. status,
  5693. data
  5694. } = await tools_httpRequest({
  5695. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  5696. method: 'POST',
  5697. headers: {
  5698. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5699. Host: 'store.steampowered.com',
  5700. Origin: 'https://store.steampowered.com',
  5701. Referer: `https://store.steampowered.com/app/${id}`
  5702. },
  5703. data: $.param({
  5704. sessionid: this.#auth.storeSessionID
  5705. }),
  5706. dataType: 'json'
  5707. });
  5708. if (result === 'Success') {
  5709. var _data$response11;
  5710. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response11 = data.response) === null || _data$response11 === void 0 ? void 0 : _data$response11.success) === 1) {
  5711. logStatus.success();
  5712. return true;
  5713. }
  5714. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5715. return false;
  5716. }
  5717. logStatus.error(`${result}:${statusText}(${status})`);
  5718. return false;
  5719. } catch (error) {
  5720. throwError(error, 'Steam.requestPlayTestAccess');
  5721. return false;
  5722. }
  5723. }
  5724. async toggle(_ref) {
  5725. let {
  5726. doTask = true,
  5727. groupLinks = [],
  5728. officialGroupLinks = [],
  5729. wishlistLinks = [],
  5730. followLinks = [],
  5731. forumLinks = [],
  5732. workshopLinks = [],
  5733. workshopVoteLinks = [],
  5734. curatorLinks = [],
  5735. curatorLikeLinks = [],
  5736. announcementLinks = [],
  5737. licenseLinks = [],
  5738. playtestLinks = []
  5739. } = _ref;
  5740. try {
  5741. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !this.#communityInitialized) {
  5742. scripts_echoLog({
  5743. text: i18n('needInit')
  5744. });
  5745. return false;
  5746. }
  5747. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !this.#storeInitialized) {
  5748. scripts_echoLog({
  5749. text: i18n('needInit')
  5750. });
  5751. return false;
  5752. }
  5753. const prom = [];
  5754. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  5755. scripts_echoLog({
  5756. type: 'globalOptionsSkip',
  5757. text: 'steam.groups'
  5758. });
  5759. } else {
  5760. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  5761. var _link$match;
  5762. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  5763. });
  5764. if (realGroups.length > 0) {
  5765. for (const group of realGroups) {
  5766. if (doTask) {
  5767. prom.push(this.#joinGroup(group));
  5768. } else {
  5769. prom.push(this.#leaveGroup(group));
  5770. }
  5771. await delay(1e3);
  5772. }
  5773. }
  5774. }
  5775. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  5776. scripts_echoLog({
  5777. type: 'globalOptionsSkip',
  5778. text: 'steam.officialGroups'
  5779. });
  5780. } else {
  5781. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  5782. var _link$match2;
  5783. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  5784. });
  5785. if (realOfficialGroups.length > 0) {
  5786. for (const officialGroup of realOfficialGroups) {
  5787. if (doTask) {
  5788. prom.push(this.#joinOfficialGroup(officialGroup));
  5789. } else {
  5790. prom.push(this.#leaveOfficialGroup(officialGroup));
  5791. }
  5792. await delay(1e3);
  5793. }
  5794. }
  5795. }
  5796. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  5797. scripts_echoLog({
  5798. type: 'globalOptionsSkip',
  5799. text: 'steam.wishlists'
  5800. });
  5801. } else {
  5802. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  5803. var _link$match3;
  5804. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5805. });
  5806. if (realWishlists.length > 0) {
  5807. for (const game of realWishlists) {
  5808. if (doTask) {
  5809. prom.push(this.#addToWishlist(game));
  5810. } else {
  5811. prom.push(this.#removeFromWishlist(game));
  5812. }
  5813. await delay(1e3);
  5814. }
  5815. }
  5816. }
  5817. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5818. scripts_echoLog({
  5819. type: 'globalOptionsSkip',
  5820. text: 'steam.follows'
  5821. });
  5822. } else {
  5823. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5824. var _link$match4;
  5825. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5826. });
  5827. if (realFollows.length > 0) {
  5828. for (const game of realFollows) {
  5829. prom.push(this.#toggleFollowGame(game, doTask));
  5830. await delay(1e3);
  5831. }
  5832. }
  5833. }
  5834. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5835. scripts_echoLog({
  5836. type: 'globalOptionsSkip',
  5837. text: 'steam.forums'
  5838. });
  5839. } else {
  5840. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5841. var _link$match5;
  5842. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5843. });
  5844. if (realForums.length > 0) {
  5845. for (const forum of realForums) {
  5846. prom.push(this.#toggleForum(forum, doTask));
  5847. await delay(1e3);
  5848. }
  5849. }
  5850. }
  5851. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5852. scripts_echoLog({
  5853. type: 'globalOptionsSkip',
  5854. text: 'steam.workshops'
  5855. });
  5856. } else {
  5857. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5858. var _link$match6;
  5859. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5860. });
  5861. if (realWorkshops.length > 0) {
  5862. for (const workshop of realWorkshops) {
  5863. prom.push(this.#toggleFavoriteWorkshop(workshop, doTask));
  5864. await delay(1e3);
  5865. }
  5866. }
  5867. }
  5868. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5869. scripts_echoLog({
  5870. type: 'globalOptionsSkip',
  5871. text: 'steam.workshopVotes'
  5872. });
  5873. } else {
  5874. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5875. var _link$match7;
  5876. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5877. });
  5878. if (doTask && realworkshopVotes.length > 0) {
  5879. for (const workshop of realworkshopVotes) {
  5880. prom.push(this.#voteUpWorkshop(workshop));
  5881. await delay(1e3);
  5882. }
  5883. }
  5884. }
  5885. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5886. scripts_echoLog({
  5887. type: 'globalOptionsSkip',
  5888. text: 'steam.curators'
  5889. });
  5890. } else {
  5891. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5892. var _link$match8;
  5893. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5894. });
  5895. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5896. var _link$match9;
  5897. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5898. });
  5899. if (realCurators.length > 0) {
  5900. for (const curator of realCurators) {
  5901. prom.push(this.#toggleCurator(curator, doTask));
  5902. await delay(1e3);
  5903. }
  5904. }
  5905. if (realCuratorLikes.length > 0) {
  5906. for (const curatorLike of realCuratorLikes) {
  5907. prom.push(this.#toggleCuratorLike(curatorLike, doTask));
  5908. await delay(1e3);
  5909. }
  5910. }
  5911. }
  5912. if (doTask && !globalOptions.doTask.steam.announcements) {
  5913. scripts_echoLog({
  5914. type: 'globalOptionsSkip',
  5915. text: 'steam.announcements'
  5916. });
  5917. } else {
  5918. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5919. var _link$match11;
  5920. if (link.includes('store.steampowered.com')) {
  5921. var _link$match10;
  5922. return (_link$match10 = link.match(/store\.steampowered\.com\/news\/app\/([\d]+)\/view\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10.slice(1, 3).join('/');
  5923. }
  5924. return (_link$match11 = link.match(/steamcommunity\.com\/games\/([\d]+)\/announcements\/detail\/([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11.slice(1, 3).join('/');
  5925. });
  5926. if (doTask && realAnnouncements.length > 0) {
  5927. for (const id of realAnnouncements) {
  5928. prom.push(this.#likeAnnouncement(id));
  5929. await delay(1e3);
  5930. }
  5931. }
  5932. }
  5933. if (doTask && !globalOptions.doTask.steam.licenses) {
  5934. scripts_echoLog({
  5935. type: 'globalOptionsSkip',
  5936. text: 'steam.licenses'
  5937. });
  5938. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5939. for (const id of licenseLinks) {
  5940. prom.push(this.#addLicense(id));
  5941. await delay(1e3);
  5942. }
  5943. }
  5944. if (doTask && !globalOptions.doTask.steam.playtests) {
  5945. scripts_echoLog({
  5946. type: 'globalOptionsSkip',
  5947. text: 'steam.playtests'
  5948. });
  5949. } else {
  5950. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5951. var _link$match12;
  5952. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5953. });
  5954. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5955. for (const id of realPlaytests) {
  5956. prom.push(this.#requestPlayTestAccess(id));
  5957. await delay(1e3);
  5958. }
  5959. }
  5960. }
  5961. return Promise.all(prom).then(async () => {
  5962. if (this.#area !== 'CN') {
  5963. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5964. await this.#changeArea('CN');
  5965. }
  5966. return true;
  5967. });
  5968. } catch (error) {
  5969. throwError(error, 'Steam.toggle');
  5970. return false;
  5971. }
  5972. }
  5973. #setCache(type, name, id) {
  5974. try {
  5975. this.#cache[type][name] = id;
  5976. GM_setValue('steamCache', this.#cache);
  5977. } catch (error) {
  5978. throwError(error, 'Steam.setCache');
  5979. }
  5980. }
  5981. }
  5982. const social_Steam = Steam;
  5983. class Website {
  5984. undoneTasks;
  5985. socialTasks;
  5986. giveawayId;
  5987. socialInitialized = {
  5988. discord: false,
  5989. instagram: false,
  5990. reddit: false,
  5991. twitch: false,
  5992. twitter: false,
  5993. vk: false,
  5994. youtube: false,
  5995. steamStore: false,
  5996. steamCommunity: false
  5997. };
  5998. initialized = false;
  5999. social = {};
  6000. async #bind(name, init) {
  6001. try {
  6002. return {
  6003. name: name,
  6004. result: await init
  6005. };
  6006. } catch (error) {
  6007. throwError(error, 'Website.bind');
  6008. return {
  6009. name: name,
  6010. result: false
  6011. };
  6012. }
  6013. }
  6014. async initSocial(action) {
  6015. try {
  6016. const pro = [];
  6017. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6018. if (tasks.discord) {
  6019. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6020. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6021. this.social.discord = new social_Discord();
  6022. pro.push(this.#bind('discord', this.social.discord.init()));
  6023. }
  6024. }
  6025. if (tasks.instagram) {
  6026. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6027. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6028. this.social.instagram = new social_Instagram();
  6029. pro.push(this.#bind('instagram', this.social.instagram.init()));
  6030. }
  6031. }
  6032. if (tasks.reddit) {
  6033. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6034. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6035. this.social.reddit = new social_Reddit();
  6036. pro.push(this.#bind('reddit', this.social.reddit.init()));
  6037. }
  6038. }
  6039. if (tasks.twitch) {
  6040. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6041. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6042. this.social.twitch = new social_Twitch();
  6043. pro.push(this.#bind('twitch', this.social.twitch.init()));
  6044. }
  6045. }
  6046. if (tasks.twitter) {
  6047. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6048. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6049. this.social.twitter = new social_Twitter();
  6050. pro.push(this.#bind('twitter', this.social.twitter.init()));
  6051. }
  6052. }
  6053. if (tasks.vk) {
  6054. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6055. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6056. this.social.vk = new social_Vk();
  6057. pro.push(this.#bind('vk', this.social.vk.init()));
  6058. }
  6059. }
  6060. if (tasks.youtube) {
  6061. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6062. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6063. this.social.youtube = new Youtube();
  6064. pro.push(this.#bind('youtube', this.social.youtube.init()));
  6065. }
  6066. }
  6067. if (tasks.steam) {
  6068. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6069. if (steamLength > 0) {
  6070. if (!this.social.steam) {
  6071. this.social.steam = new social_Steam();
  6072. }
  6073. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6074. var _tasks$steam, _tasks$steam$type;
  6075. return [ 'groupLinks', 'officialGroupLinks', 'forumLinks', 'workshopLinks', 'workshopVoteLinks' ].includes(type) ? ((_tasks$steam = tasks.steam) === null || _tasks$steam === void 0 ? void 0 : (_tasks$steam$type = _tasks$steam[type]) === null || _tasks$steam$type === void 0 ? void 0 : _tasks$steam$type.length) || 0 : 0;
  6076. }).reduce((total, number) => total + number, 0);
  6077. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6078. pro.push(this.#bind('steamStore', this.social.steam.init('store')));
  6079. }
  6080. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6081. pro.push(this.#bind('steamCommunity', this.social.steam.init('community')));
  6082. }
  6083. }
  6084. }
  6085. if (tasks.links && tasks.links.length > 0) {
  6086. this.social.visitLink = visitLink;
  6087. }
  6088. return await Promise.all(pro).then(result => {
  6089. let checked = true;
  6090. for (const data of result) {
  6091. if (data.result) {
  6092. this.socialInitialized[data.name] = data.result;
  6093. } else {
  6094. checked = false;
  6095. }
  6096. }
  6097. return checked;
  6098. });
  6099. } catch (error) {
  6100. throwError(error, 'Website.initSocial');
  6101. return false;
  6102. }
  6103. }
  6104. uniqueTasks(allTasks) {
  6105. const result = {};
  6106. for (const [ social, types ] of Object.entries(allTasks)) {
  6107. result[social] = {};
  6108. for (const [ type, tasks ] of Object.entries(types)) {
  6109. result[social][type] = unique(tasks);
  6110. }
  6111. }
  6112. return result;
  6113. }
  6114. async toggleTask(action) {
  6115. try {
  6116. if (!this.initialized && !this.init()) {
  6117. return false;
  6118. }
  6119. if (!await this.classifyTask(action)) {
  6120. return false;
  6121. }
  6122. if (!await this.initSocial(action)) {
  6123. return false;
  6124. }
  6125. const pro = [];
  6126. const doTask = action === 'do';
  6127. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6128. if (this.socialInitialized.discord !== 'skip' && this.social.discord) {
  6129. pro.push(this.social.discord.toggle({
  6130. doTask: doTask,
  6131. ...tasks.discord
  6132. }));
  6133. }
  6134. if (this.social.instagram) {
  6135. pro.push(this.social.instagram.toggle({
  6136. doTask: doTask,
  6137. ...tasks.instagram
  6138. }));
  6139. }
  6140. if (this.social.reddit) {
  6141. pro.push(this.social.reddit.toggle({
  6142. doTask: doTask,
  6143. ...tasks.reddit
  6144. }));
  6145. }
  6146. if (this.social.twitch) {
  6147. pro.push(this.social.twitch.toggle({
  6148. doTask: doTask,
  6149. ...tasks.twitch
  6150. }));
  6151. }
  6152. if (this.social.twitter) {
  6153. pro.push(this.social.twitter.toggle({
  6154. doTask: doTask,
  6155. ...tasks.twitter
  6156. }));
  6157. }
  6158. if (this.social.vk) {
  6159. pro.push(this.social.vk.toggle({
  6160. doTask: doTask,
  6161. ...tasks.vk
  6162. }));
  6163. }
  6164. if (this.social.youtube) {
  6165. pro.push(this.social.youtube.toggle({
  6166. doTask: doTask,
  6167. ...tasks.youtube
  6168. }));
  6169. }
  6170. if (this.social.steam) {
  6171. pro.push(this.social.steam.toggle({
  6172. doTask: doTask,
  6173. ...tasks.steam
  6174. }));
  6175. }
  6176. if (this.social.visitLink && tasks.links && doTask) {
  6177. for (const link of tasks.links) {
  6178. pro.push(this.social.visitLink(link));
  6179. }
  6180. }
  6181. if (doTask && tasks.extra && this.extraDoTask) {
  6182. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6183. if (hasExtra) {
  6184. pro.push(this.extraDoTask(tasks.extra));
  6185. }
  6186. }
  6187. await Promise.all(pro);
  6188. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6189. return true;
  6190. } catch (error) {
  6191. throwError(error, 'Website.toggleTask');
  6192. return false;
  6193. }
  6194. }
  6195. async doTask() {
  6196. try {
  6197. return await this.toggleTask('do');
  6198. } catch (error) {
  6199. throwError(error, 'Website.doTask');
  6200. return false;
  6201. }
  6202. }
  6203. async undoTask() {
  6204. try {
  6205. return await this.toggleTask('undo');
  6206. } catch (error) {
  6207. throwError(error, 'Website.undoTask');
  6208. return false;
  6209. }
  6210. }
  6211. }
  6212. const website_Website = Website;
  6213. const FreeAnyWhere_defaultTasksTemplate = {
  6214. steam: {
  6215. groupLinks: [],
  6216. wishlistLinks: [],
  6217. curatorLinks: [],
  6218. followLinks: []
  6219. },
  6220. vk: {
  6221. nameLinks: []
  6222. }
  6223. };
  6224. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6225. class FreeAnyWhere extends website_Website {
  6226. name = 'FreeAnyWhere';
  6227. tasks = [];
  6228. socialTasks = JSON.parse(FreeAnyWhere_defaultTasks);
  6229. undoneTasks = JSON.parse(FreeAnyWhere_defaultTasks);
  6230. buttons = [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ];
  6231. static test() {
  6232. return window.location.host === 'freeanywhere.net';
  6233. }
  6234. async init() {
  6235. try {
  6236. const logStatus = scripts_echoLog({
  6237. text: i18n('initing')
  6238. });
  6239. if ($('a[href="#/login"]').length > 0) {
  6240. window.open('/#/login', '_self');
  6241. logStatus.warning(i18n('needLogin'));
  6242. return false;
  6243. }
  6244. if (window.location.href.includes('/login')) {
  6245. logStatus.warning(i18n('needLogin'));
  6246. return false;
  6247. }
  6248. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6249. var _window$location$href;
  6250. 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];
  6251. if (!id) {
  6252. logStatus.error(i18n('getFailed', 'Id'));
  6253. return false;
  6254. }
  6255. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6256. }
  6257. if (!this.#getGiveawayId()) {
  6258. return false;
  6259. }
  6260. if (!await this.#checkLeftKey()) {
  6261. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6262. }
  6263. this.initialized = true;
  6264. logStatus.success();
  6265. return true;
  6266. } catch (error) {
  6267. throwError(error, 'Freeanywhere.init');
  6268. return false;
  6269. }
  6270. }
  6271. async classifyTask(action) {
  6272. try {
  6273. const logStatus = scripts_echoLog({
  6274. text: i18n('getTasksInfo')
  6275. });
  6276. if (action === 'undo') {
  6277. var _GM_getValue;
  6278. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6279. }
  6280. const {
  6281. result,
  6282. statusText,
  6283. status,
  6284. data
  6285. } = await tools_httpRequest({
  6286. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6287. method: 'GET',
  6288. headers: {
  6289. authorization: `Token ${window.localStorage.getItem('token')}`,
  6290. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6291. },
  6292. responseType: 'json'
  6293. });
  6294. if (result === 'Success') {
  6295. var _data$response;
  6296. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6297. if (tasks) {
  6298. if (action === 'verify') {
  6299. this.tasks = [];
  6300. }
  6301. for (const task of tasks) {
  6302. const type = task.challenge;
  6303. const social = task.challenge_provider;
  6304. const taskInfo = {
  6305. id: task.id,
  6306. title: task.title
  6307. };
  6308. if (action === 'verify' && !task.is_success) {
  6309. this.tasks.push(taskInfo);
  6310. continue;
  6311. }
  6312. switch (social) {
  6313. case 'steam':
  6314. taskInfo.social = 'steam';
  6315. switch (type) {
  6316. case 'WL':
  6317. if (action === 'undo') {
  6318. this.socialTasks.steam.wishlistLinks.push(task.link);
  6319. }
  6320. if (action === 'do' && !task.is_success) {
  6321. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6322. }
  6323. break;
  6324.  
  6325. case 'JTG':
  6326. if (action === 'undo') {
  6327. this.socialTasks.steam.groupLinks.push(task.link);
  6328. }
  6329. if (action === 'do' && !task.is_success) {
  6330. this.undoneTasks.steam.groupLinks.push(task.link);
  6331. }
  6332. break;
  6333.  
  6334. case 'STC':
  6335. if (action === 'undo') {
  6336. this.socialTasks.steam.curatorLinks.push(task.link);
  6337. }
  6338. if (action === 'do' && !task.is_success) {
  6339. this.undoneTasks.steam.curatorLinks.push(task.link);
  6340. }
  6341. break;
  6342.  
  6343. case 'GF':
  6344. if (action === 'undo') {
  6345. this.socialTasks.steam.followLinks.push(task.link);
  6346. }
  6347. if (action === 'do' && !task.is_success) {
  6348. this.undoneTasks.steam.followLinks.push(task.link);
  6349. }
  6350. break;
  6351. }
  6352. break;
  6353.  
  6354. case 'vk-oauth2':
  6355. if (action === 'undo') {
  6356. this.socialTasks.vk.nameLinks.push(task.link);
  6357. }
  6358. if (action === 'do' && !task.is_success) {
  6359. this.undoneTasks.vk.nameLinks.push(task.link);
  6360. }
  6361. break;
  6362.  
  6363. case 'website':
  6364. break;
  6365.  
  6366. default:
  6367. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6368. break;
  6369. }
  6370. }
  6371. logStatus.success();
  6372. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6373. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6374. if (window.DEBUG) {
  6375. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  6376. }
  6377. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6378. tasks: this.socialTasks,
  6379. time: new Date().getTime()
  6380. });
  6381. return true;
  6382. }
  6383. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6384. return false;
  6385. }
  6386. logStatus.error(`${result}:${statusText}(${status})`);
  6387. return false;
  6388. } catch (error) {
  6389. throwError(error, 'Freeanywhere.classifyTask');
  6390. return false;
  6391. }
  6392. }
  6393. async verifyTask() {
  6394. try {
  6395. if (!this.initialized && !this.init()) {
  6396. return false;
  6397. }
  6398. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6399. return false;
  6400. }
  6401. const pro = [];
  6402. for (const task of this.tasks) {
  6403. pro.push(this.#verify(task));
  6404. await delay(1e3);
  6405. }
  6406. await Promise.all(pro);
  6407. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6408. return !!await this.getKey(true);
  6409. } catch (error) {
  6410. throwError(error, 'Freeanywhere.verifyTask');
  6411. return false;
  6412. }
  6413. }
  6414. async getKey(initialized) {
  6415. try {
  6416. if (!initialized && !this.initialized && !this.init()) {
  6417. return false;
  6418. }
  6419. const logStatus = scripts_echoLog({
  6420. text: i18n('gettingKey')
  6421. });
  6422. const {
  6423. result,
  6424. statusText,
  6425. status,
  6426. data
  6427. } = await tools_httpRequest({
  6428. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6429. method: 'GET',
  6430. dataType: 'json',
  6431. headers: {
  6432. authorization: `Token ${window.localStorage.getItem('token')}`
  6433. }
  6434. });
  6435. if (result === 'Success') {
  6436. var _data$response2;
  6437. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6438. logStatus.success();
  6439. scripts_echoLog({}).success(data.response.reward);
  6440. return data.response.reward;
  6441. }
  6442. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6443. return false;
  6444. }
  6445. logStatus.error(`${result}:${statusText}(${status})`);
  6446. return false;
  6447. } catch (error) {
  6448. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6449. return false;
  6450. }
  6451. }
  6452. #getGiveawayId() {
  6453. try {
  6454. var _window$location$href2;
  6455. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6456. if (giveawayId) {
  6457. this.giveawayId = giveawayId;
  6458. return true;
  6459. }
  6460. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6461. return false;
  6462. } catch (error) {
  6463. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6464. }
  6465. }
  6466. async #verify(task) {
  6467. try {
  6468. const logStatus = scripts_echoLog({
  6469. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6470. });
  6471. const {
  6472. result,
  6473. statusText,
  6474. status,
  6475. data
  6476. } = await tools_httpRequest({
  6477. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6478. method: 'GET',
  6479. dataType: 'json',
  6480. headers: {
  6481. authorization: `Token ${window.localStorage.getItem('token')}`,
  6482. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6483. }
  6484. });
  6485. if (result === 'Success') {
  6486. var _data$response3;
  6487. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6488. logStatus.success();
  6489. return true;
  6490. }
  6491. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6492. return false;
  6493. }
  6494. logStatus.error(`${result}:${statusText}(${status})`);
  6495. return false;
  6496. } catch (error) {
  6497. throwError(error, 'Freeanywhere.verify');
  6498. return false;
  6499. }
  6500. }
  6501. async #checkLeftKey() {
  6502. try {
  6503. var _data$response4;
  6504. if (!globalOptions.other.checkLeftKey) {
  6505. return true;
  6506. }
  6507. const {
  6508. data
  6509. } = await tools_httpRequest({
  6510. url: 'https://freeanywhere.net/api/v1/widget/?format=json',
  6511. method: 'GET',
  6512. dataType: 'json',
  6513. headers: {
  6514. authorization: `Token ${window.localStorage.getItem('token')}`
  6515. }
  6516. });
  6517. if (data !== null && data !== void 0 && (_data$response4 = data.response) !== null && _data$response4 !== void 0 && _data$response4.giveaways.find(giveaway => `${giveaway === null || giveaway === void 0 ? void 0 : giveaway.id}` === this.giveawayId)) {
  6518. return true;
  6519. }
  6520. await external_Swal_default().fire({
  6521. icon: 'warning',
  6522. title: i18n('notice'),
  6523. text: i18n('noKeysLeft'),
  6524. confirmButtonText: i18n('confirm'),
  6525. cancelButtonText: i18n('cancel'),
  6526. showCancelButton: true
  6527. }).then(_ref => {
  6528. let {
  6529. value
  6530. } = _ref;
  6531. if (value) {
  6532. window.close();
  6533. }
  6534. });
  6535. return true;
  6536. } catch (error) {
  6537. throwError(error, 'Giveawaysu.checkLeftKey');
  6538. return false;
  6539. }
  6540. }
  6541. }
  6542. const website_FreeAnyWhere = FreeAnyWhere;
  6543. const GiveawaySu_defaultTasks = {
  6544. steam: {
  6545. groupLinks: [],
  6546. wishlistLinks: [],
  6547. curatorLinks: [],
  6548. curatorLikeLinks: [],
  6549. followLinks: [],
  6550. forumLinks: [],
  6551. announcementLinks: [],
  6552. workshopVoteLinks: [],
  6553. playtestLinks: []
  6554. },
  6555. discord: {
  6556. serverLinks: []
  6557. },
  6558. instagram: {
  6559. userLinks: []
  6560. },
  6561. vk: {
  6562. nameLinks: []
  6563. },
  6564. twitch: {
  6565. channelLinks: []
  6566. },
  6567. reddit: {
  6568. redditLinks: []
  6569. },
  6570. youtube: {
  6571. channelLinks: [],
  6572. likeLinks: []
  6573. },
  6574. twitter: {
  6575. userLinks: [],
  6576. retweetLinks: []
  6577. }
  6578. };
  6579. class GiveawaySu extends website_Website {
  6580. name = 'GiveawaySu';
  6581. socialTasks = GiveawaySu_defaultTasks;
  6582. undoneTasks = GiveawaySu_defaultTasks;
  6583. buttons = [ 'doTask', 'undoTask' ];
  6584. static test() {
  6585. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6586. }
  6587. async after() {
  6588. try {
  6589. if (!this.#checkLogin()) {
  6590. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6591. }
  6592. if (!await this.#checkLeftKey()) {
  6593. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6594. }
  6595. scripts_echoLog({}).warning(i18n('gsNotice'));
  6596. } catch (error) {
  6597. throwError(error, 'Giveawaysu.after');
  6598. }
  6599. }
  6600. init() {
  6601. try {
  6602. const logStatus = scripts_echoLog({
  6603. text: i18n('initing')
  6604. });
  6605. if ($('a.steam-login').length > 0) {
  6606. window.open('/steam/redirect', '_self');
  6607. logStatus.warning(i18n('needLogin'));
  6608. return false;
  6609. }
  6610. if (!this.#getGiveawayId()) {
  6611. return false;
  6612. }
  6613. this.initialized = true;
  6614. logStatus.success();
  6615. return true;
  6616. } catch (error) {
  6617. throwError(error, 'Giveawaysu.init');
  6618. return false;
  6619. }
  6620. }
  6621. async classifyTask(action) {
  6622. try {
  6623. const logStatus = scripts_echoLog({
  6624. text: i18n('getTasksInfo')
  6625. });
  6626. if (action === 'undo') {
  6627. var _GM_getValue;
  6628. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6629. return true;
  6630. }
  6631. const pro = [];
  6632. const tasks = $('#actions tr');
  6633. if ($('div.bind-discord').is(':visible')) {
  6634. $('div.bind-discord a')[0].click();
  6635. }
  6636. if ($('div.bind-twitch').is(':visible')) {
  6637. $('div.bind-twitch a')[0].click();
  6638. }
  6639. for (const task of tasks) {
  6640. pro.push(new Promise(resolve => {
  6641. const td = $(task).find('td:not(".hidden")');
  6642. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6643. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6644. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6645. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6646. const taskName = taskDes.text().trim();
  6647. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6648. return resolve(true);
  6649. }
  6650. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6651. if (!taskLink) {
  6652. return resolve(false);
  6653. }
  6654. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6655. this.undoneTasks.steam.groupLinks.push(taskLink);
  6656. } else if (/like.*announcement/gi.test(taskName)) {
  6657. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6658. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6659. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6660. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6661. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6662. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6663. this.undoneTasks.steam.forumLinks.push(taskLink);
  6664. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6665. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6666. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  6667. this.undoneTasks.steam.playtestLinks.push(taskLink);
  6668. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6669. this.undoneTasks.discord.serverLinks.push(taskLink);
  6670. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6671. this.undoneTasks.instagram.userLinks.push(taskLink);
  6672. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6673. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6674. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6675. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6676. } else if (/watch.*art/gim.test(taskName)) {
  6677. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6678. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6679. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6680. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6681. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6682. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6683. this.undoneTasks.vk.nameLinks.push(taskLink);
  6684. } else {
  6685. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6686. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6687. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6688. }
  6689. if (/follow.*button/gim.test(taskName)) {
  6690. this.undoneTasks.steam.followLinks.push(taskLink);
  6691. }
  6692. }
  6693. }
  6694. resolve(true);
  6695. }).catch(error => {
  6696. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6697. return false;
  6698. });
  6699. }));
  6700. }
  6701. await Promise.all(pro);
  6702. logStatus.success();
  6703. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6704. this.socialTasks = this.undoneTasks;
  6705. if (window.DEBUG) {
  6706. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  6707. }
  6708. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6709. tasks: this.socialTasks,
  6710. time: new Date().getTime()
  6711. });
  6712. return true;
  6713. } catch (error) {
  6714. throwError(error, 'Giveawaysu.classifyTask');
  6715. return false;
  6716. }
  6717. }
  6718. #checkLogin() {
  6719. try {
  6720. if (!globalOptions.other.checkLogin) {
  6721. return true;
  6722. }
  6723. if ($('a.steam-login').length > 0) {
  6724. window.open('/steam/redirect', '_self');
  6725. }
  6726. return true;
  6727. } catch (error) {
  6728. throwError(error, 'Giveawaysu.checkLogin');
  6729. return false;
  6730. }
  6731. }
  6732. async #checkLeftKey() {
  6733. try {
  6734. if (!globalOptions.other.checkLeftKey) {
  6735. return true;
  6736. }
  6737. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  6738. await external_Swal_default().fire({
  6739. icon: 'warning',
  6740. title: i18n('notice'),
  6741. text: i18n('noKeysLeft'),
  6742. confirmButtonText: i18n('confirm'),
  6743. cancelButtonText: i18n('cancel'),
  6744. showCancelButton: true
  6745. }).then(_ref => {
  6746. let {
  6747. value
  6748. } = _ref;
  6749. if (value) {
  6750. window.close();
  6751. }
  6752. });
  6753. }
  6754. return true;
  6755. } catch (error) {
  6756. throwError(error, 'Giveawaysu.checkLeftKey');
  6757. return false;
  6758. }
  6759. }
  6760. #getGiveawayId() {
  6761. var _window$location$href;
  6762. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6763. if (giveawayId) {
  6764. this.giveawayId = giveawayId;
  6765. return true;
  6766. }
  6767. scripts_echoLog({
  6768. text: i18n('getFailed', 'GiveawayId')
  6769. });
  6770. return false;
  6771. }
  6772. }
  6773. class Indiedb {
  6774. name = 'Indiedb';
  6775. buttons = [ 'doTask' ];
  6776. static test() {
  6777. return window.location.host === 'www.indiedb.com';
  6778. }
  6779. async after() {
  6780. try {
  6781. if (!this.#checkLogin()) {
  6782. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6783. }
  6784. if (!await this.#checkLeftKey()) {
  6785. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6786. }
  6787. } catch (error) {
  6788. throwError(error, 'Indiedb.after');
  6789. }
  6790. }
  6791. async doTask() {
  6792. try {
  6793. if (!await this.#join()) {
  6794. return false;
  6795. }
  6796. return await this.#do();
  6797. } catch (error) {
  6798. throwError(error, 'Indiedb.doTask');
  6799. return false;
  6800. }
  6801. }
  6802. async #join() {
  6803. try {
  6804. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  6805. scripts_echoLog({}).error(i18n('needLogin'));
  6806. return false;
  6807. }
  6808. const currentoption = $('a.buttonenter.buttongiveaway');
  6809. if (/join giveaway/gim.test(currentoption.text())) {
  6810. const logStatus = scripts_echoLog({
  6811. text: `${i18n('joiningGiveaway')}...`
  6812. });
  6813. const {
  6814. result,
  6815. statusText,
  6816. status,
  6817. data
  6818. } = await tools_httpRequest({
  6819. url: currentoption.attr('href'),
  6820. method: 'POST',
  6821. data: 'ajax=t',
  6822. dataType: 'json',
  6823. headers: {
  6824. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6825. accept: 'application/json, text/javascript, */*; q=0.01',
  6826. origin: window.location.origin
  6827. }
  6828. });
  6829. if (result === 'Success') {
  6830. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6831. var _data$response, _data$response4, _data$response5;
  6832. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  6833. var _data$response2, _data$response3;
  6834. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  6835. $('#giveawaysjoined').slideDown();
  6836. $('#giveawaysrecommend').slideDown();
  6837. 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}` : ''}`);
  6838. return true;
  6839. }
  6840. 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}` : ''}`);
  6841. return false;
  6842. }
  6843. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6844. return false;
  6845. }
  6846. logStatus.error(`${result}:${statusText}(${status})`);
  6847. return false;
  6848. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  6849. return true;
  6850. }
  6851. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  6852. return false;
  6853. } catch (error) {
  6854. throwError(error, 'Indiedb.init');
  6855. return false;
  6856. }
  6857. }
  6858. async #do() {
  6859. try {
  6860. const id = $('script').map((index, script) => {
  6861. if (/\$\(document\)/gim.test(script.innerHTML)) {
  6862. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  6863. 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] ];
  6864. }
  6865. return null;
  6866. });
  6867. if (id.length === 2) {
  6868. const pro = [];
  6869. const tasks = $('#giveawaysjoined a[class*=promo]');
  6870. for (const task of tasks) {
  6871. const promo = $(task);
  6872. if (!promo.hasClass('buttonentered')) {
  6873. const status = scripts_echoLog({
  6874. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  6875. });
  6876. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  6877. let text = '';
  6878. if (promo.hasClass('facebookpromo')) {
  6879. text = 'facebookpromo';
  6880. } else if (promo.hasClass('twitterpromo')) {
  6881. text = 'twitterpromo';
  6882. } else {
  6883. text = 'visitpromo';
  6884. }
  6885. pro.push(new Promise(resolve => {
  6886. $.ajax({
  6887. type: 'POST',
  6888. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  6889. timeout: 6e4,
  6890. dataType: 'json',
  6891. data: {
  6892. ajax: 't'
  6893. },
  6894. error(response, error, exception) {
  6895. if (window.DEBUG) {
  6896. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6897. response: response,
  6898. error: error,
  6899. exception: exception
  6900. });
  6901. }
  6902. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6903. resolve(true);
  6904. },
  6905. success(response) {
  6906. if (response.success) {
  6907. status.success(`Success:${response.text}`);
  6908. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6909. resolve(true);
  6910. } else {
  6911. status.error(`Error:${response.text}`);
  6912. resolve(true);
  6913. }
  6914. }
  6915. });
  6916. }));
  6917. } else if (promo.hasClass('emailoptinpromo')) {
  6918. pro.push(new Promise(resolve => {
  6919. $.ajax({
  6920. type: 'POST',
  6921. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  6922. timeout: 6e4,
  6923. dataType: 'json',
  6924. data: {
  6925. ajax: 't',
  6926. emailsystoggle: 4
  6927. },
  6928. error(response, error, exception) {
  6929. if (window.DEBUG) {
  6930. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6931. response: response,
  6932. error: error,
  6933. exception: exception
  6934. });
  6935. }
  6936. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6937. resolve(true);
  6938. },
  6939. success(response) {
  6940. if (response.success) {
  6941. status.success(`Success:${response.text}`);
  6942. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6943. resolve(true);
  6944. } else {
  6945. status.error(`Error:${response.text}`);
  6946. resolve(true);
  6947. }
  6948. }
  6949. });
  6950. }));
  6951. } else if (promo.hasClass('watchingpromo')) {
  6952. pro.push(new Promise(resolve => {
  6953. var _promo$attr;
  6954. const data = getUrlQuery(promo.attr('href'));
  6955. data.ajax = 't';
  6956. $.ajax({
  6957. type: 'POST',
  6958. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  6959. timeout: 6e4,
  6960. dataType: 'json',
  6961. data: data,
  6962. error(response, error, exception) {
  6963. if (window.DEBUG) {
  6964. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6965. response: response,
  6966. error: error,
  6967. exception: exception
  6968. });
  6969. }
  6970. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6971. resolve(true);
  6972. },
  6973. success(response) {
  6974. if (response.success) {
  6975. status.success(`Success:${response.text}`);
  6976. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6977. resolve(true);
  6978. } else {
  6979. status.error(`Error:${response.text}`);
  6980. resolve(true);
  6981. }
  6982. }
  6983. });
  6984. }));
  6985. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  6986. pro.push(new Promise(resolve => {
  6987. $.ajax({
  6988. type: 'POST',
  6989. url: urlPath(promo.attr('href')),
  6990. timeout: 6e4,
  6991. dataType: 'json',
  6992. data: {
  6993. ajax: 't'
  6994. },
  6995. error(response, error, exception) {
  6996. if (window.DEBUG) {
  6997. console.log('%cAuto-Task[Debug]:', 'color:red', {
  6998. response: response,
  6999. error: error,
  7000. exception: exception
  7001. });
  7002. }
  7003. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7004. resolve(true);
  7005. },
  7006. success(response) {
  7007. if (response.success) {
  7008. status.success(`Success:${response.text}`);
  7009. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7010. resolve(true);
  7011. } else {
  7012. status.error(`Error:${response.text}`);
  7013. resolve(true);
  7014. }
  7015. }
  7016. });
  7017. }));
  7018. } else {
  7019. status.error(`Error:${i18n('unKnownTaskType')}`);
  7020. }
  7021. }
  7022. }
  7023. await Promise.all(pro);
  7024. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7025. return true;
  7026. }
  7027. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7028. return false;
  7029. } catch (error) {
  7030. throwError(error, 'Indiedb.classifyTask');
  7031. return false;
  7032. }
  7033. }
  7034. #checkLogin() {
  7035. try {
  7036. if (!globalOptions.other.checkLogin) {
  7037. return true;
  7038. }
  7039. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7040. window.open('/members/login', '_self');
  7041. }
  7042. return true;
  7043. } catch (error) {
  7044. throwError(error, 'Indiedb.checkLogin');
  7045. return false;
  7046. }
  7047. }
  7048. async #checkLeftKey() {
  7049. try {
  7050. if (!globalOptions.other.checkLeftKey) {
  7051. return true;
  7052. }
  7053. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7054. await external_Swal_default().fire({
  7055. icon: 'warning',
  7056. title: i18n('notice'),
  7057. text: i18n('giveawayEnded'),
  7058. confirmButtonText: i18n('confirm'),
  7059. cancelButtonText: i18n('cancel'),
  7060. showCancelButton: true
  7061. }).then(_ref => {
  7062. let {
  7063. value
  7064. } = _ref;
  7065. if (value) {
  7066. window.close();
  7067. }
  7068. });
  7069. }
  7070. return true;
  7071. } catch (error) {
  7072. throwError(error, 'Indiedb.checkLeftKey');
  7073. return false;
  7074. }
  7075. }
  7076. }
  7077. const website_Indiedb = Indiedb;
  7078. const Keyhub_defaultTasksTemplate = {
  7079. steam: {
  7080. groupLinks: [],
  7081. officialGroupLinks: [],
  7082. wishlistLinks: [],
  7083. curatorLinks: []
  7084. },
  7085. discord: {
  7086. serverLinks: []
  7087. },
  7088. extra: {
  7089. videoTasks: []
  7090. },
  7091. links: []
  7092. };
  7093. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7094. class Keyhub extends website_Website {
  7095. name = 'Keyhub';
  7096. socialTasks = JSON.parse(Keyhub_defaultTasks);
  7097. undoneTasks = JSON.parse(Keyhub_defaultTasks);
  7098. buttons = [ 'doTask', 'undoTask' ];
  7099. static test() {
  7100. return window.location.host === 'key-hub.eu';
  7101. }
  7102. async after() {
  7103. try {
  7104. if (!this.#checkLogin()) {
  7105. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7106. }
  7107. if (!await this.#checkLeftKey()) {
  7108. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7109. }
  7110. $('.NSFW').hide();
  7111. } catch (error) {
  7112. throwError(error, 'Keyhub.after');
  7113. }
  7114. }
  7115. init() {
  7116. try {
  7117. const logStatus = scripts_echoLog({
  7118. text: i18n('initing')
  7119. });
  7120. if ($('a[href*="/connect/steam"]').length > 0) {
  7121. window.open('/connect/steam', '_self');
  7122. logStatus.warning(i18n('needLogin'));
  7123. return false;
  7124. }
  7125. if (!this.#getGiveawayId()) {
  7126. return false;
  7127. }
  7128. $('#VPNoverlay').hide();
  7129. $('#mainArticleSection').show();
  7130. this.initialized = true;
  7131. logStatus.success();
  7132. return true;
  7133. } catch (error) {
  7134. throwError(error, 'Keyhub.init');
  7135. return false;
  7136. }
  7137. }
  7138. async classifyTask(action) {
  7139. try {
  7140. const logStatus = scripts_echoLog({
  7141. text: i18n('getTasksInfo')
  7142. });
  7143. if (action === 'undo') {
  7144. var _GM_getValue;
  7145. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7146. }
  7147. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7148. for (const task of tasks) {
  7149. let link = $(task).attr('href');
  7150. const taskDes = $(task).text().trim();
  7151. if (!link) {
  7152. continue;
  7153. }
  7154. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7155. link = await getRedirectLink(link) || link;
  7156. }
  7157. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7158. window.open(link, '_blank');
  7159. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7160. if (action === 'undo') {
  7161. this.socialTasks.steam.groupLinks.push(link);
  7162. }
  7163. if (action === 'do') {
  7164. this.undoneTasks.steam.groupLinks.push(link);
  7165. }
  7166. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7167. if (action === 'undo') {
  7168. this.socialTasks.steam.officialGroupLinks.push(link);
  7169. }
  7170. if (action === 'do') {
  7171. this.undoneTasks.steam.officialGroupLinks.push(link);
  7172. }
  7173. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7174. if (action === 'undo') {
  7175. this.socialTasks.steam.wishlistLinks.push(link);
  7176. }
  7177. if (action === 'do') {
  7178. this.undoneTasks.steam.wishlistLinks.push(link);
  7179. }
  7180. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7181. if (action === 'undo') {
  7182. this.socialTasks.steam.curatorLinks.push(link);
  7183. }
  7184. if (action === 'do') {
  7185. this.undoneTasks.steam.curatorLinks.push(link);
  7186. }
  7187. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7188. if (action === 'undo') {
  7189. this.socialTasks.discord.serverLinks.push(link);
  7190. }
  7191. if (action === 'do') {
  7192. this.undoneTasks.discord.serverLinks.push(link);
  7193. }
  7194. } else if (/^javascript:videoTask.+/.test(link)) {
  7195. if (action === 'do') {
  7196. var _link$match;
  7197. const taskData = (_link$match = link.match(/javascript:videoTask\('.+?','(.+?)'/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  7198. if (taskData) {
  7199. this.undoneTasks.extra.videoTasks.push(taskData);
  7200. }
  7201. }
  7202. } else if (/^https?:\/\/www\.instagram\.com\/.*/.test(link) || /^https?:\/\/twitter\.com\/.*/.test(link) || /^https?:\/\/www\.twitch\.tv\/.*/.test(link) || /^https?:\/\/www\.facebook\.com\/.*/.test(link) || /^https?:\/\/www\.youtube\.com\/.*/.test(link) || /^https?:\/\/store\.steampowered\.com\/developer\//.test(link) || /^https?:\/\/.*?\.itch\.io\/.*/.test(link) || /^https?:\/\/key-hub\.eu.*/.test(link) || /^https?:\/\/store\.steampowered\.com\/app\/.*/.test(link) || /^https?:\/\/qr\.streamelements\.com\/.*/.test(link) || /^https?:\/\/store\.steampowered\.com\/news\/app\/.*/.test(link)) {} else {
  7203. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7204. }
  7205. }
  7206. logStatus.success();
  7207. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7208. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7209. if (window.DEBUG) {
  7210. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7211. }
  7212. GM_setValue(`khTasks-${this.giveawayId}`, {
  7213. tasks: this.socialTasks,
  7214. time: new Date().getTime()
  7215. });
  7216. return true;
  7217. } catch (error) {
  7218. throwError(error, 'Keyhub.classifyTask');
  7219. return false;
  7220. }
  7221. }
  7222. async #doScriptTask(data) {
  7223. try {
  7224. const logStatus = scripts_echoLog({
  7225. text: i18n('doingKeyhubTask')
  7226. });
  7227. const {
  7228. result,
  7229. statusText,
  7230. status,
  7231. data: response
  7232. } = await tools_httpRequest({
  7233. url: `/away?data=${data}`,
  7234. method: 'GET',
  7235. headers: {
  7236. origin: 'https://key-hub.eu',
  7237. referer: 'https://key-hub.eu/'
  7238. }
  7239. });
  7240. if (result === 'Success') {
  7241. if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
  7242. logStatus.success();
  7243. return true;
  7244. }
  7245. logStatus.error(`Error:${response === null || response === void 0 ? void 0 : response.statusText}(${response === null || response === void 0 ? void 0 : response.status})`);
  7246. return false;
  7247. }
  7248. logStatus.error(`${result}:${statusText}(${status})`);
  7249. return false;
  7250. } catch (error) {
  7251. throwError(error, 'Keyhub.doScriptTask');
  7252. return false;
  7253. }
  7254. }
  7255. async extraDoTask(_ref) {
  7256. let {
  7257. videoTasks
  7258. } = _ref;
  7259. try {
  7260. const pro = [];
  7261. for (const data of videoTasks) {
  7262. pro.push(this.#doScriptTask(data));
  7263. }
  7264. return Promise.all(pro).then(() => true);
  7265. } catch (error) {
  7266. throwError(error, 'Keyhub.extraDoTask');
  7267. return false;
  7268. }
  7269. }
  7270. #getGiveawayId() {
  7271. try {
  7272. var _window$location$href;
  7273. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7274. if (giveawayId) {
  7275. this.giveawayId = giveawayId;
  7276. return true;
  7277. }
  7278. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7279. return false;
  7280. } catch (error) {
  7281. throwError(error, 'Keyhub.getGiveawayId');
  7282. return false;
  7283. }
  7284. }
  7285. async #checkLeftKey() {
  7286. try {
  7287. if (!globalOptions.other.checkLeftKey) {
  7288. return true;
  7289. }
  7290. const leftKey = $('#keysleft').text().trim();
  7291. if (leftKey === '0') {
  7292. await external_Swal_default().fire({
  7293. icon: 'warning',
  7294. title: i18n('notice'),
  7295. text: i18n('noKeysLeft'),
  7296. confirmButtonText: i18n('confirm'),
  7297. cancelButtonText: i18n('cancel'),
  7298. showCancelButton: true
  7299. }).then(_ref2 => {
  7300. let {
  7301. value
  7302. } = _ref2;
  7303. if (value) {
  7304. window.close();
  7305. }
  7306. });
  7307. }
  7308. return true;
  7309. } catch (error) {
  7310. throwError(error, 'Keyhub.checkLeftKey');
  7311. return false;
  7312. }
  7313. }
  7314. #checkLogin() {
  7315. try {
  7316. if (!globalOptions.other.checkLogin) {
  7317. return true;
  7318. }
  7319. if ($('a[href*="/connect/steam"]').length > 0) {
  7320. window.open('/connect/steam', '_self');
  7321. }
  7322. return true;
  7323. } catch (error) {
  7324. throwError(error, 'Keyhub.checkLogin');
  7325. return false;
  7326. }
  7327. }
  7328. }
  7329. const website_Keyhub = Keyhub;
  7330. const Givekey_defaultTasksTemplate = {
  7331. steam: {
  7332. groupLinks: [],
  7333. wishlistLinks: [],
  7334. curatorLinks: [],
  7335. curatorLikeLinks: []
  7336. },
  7337. twitter: {
  7338. userLinks: []
  7339. },
  7340. vk: {
  7341. nameLinks: []
  7342. },
  7343. discord: {
  7344. serverLinks: []
  7345. }
  7346. };
  7347. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  7348. class Givekey extends website_Website {
  7349. name = 'Givekey';
  7350. tasks = [];
  7351. socialTasks = JSON.parse(Givekey_defaultTasks);
  7352. undoneTasks = JSON.parse(Givekey_defaultTasks);
  7353. userId;
  7354. buttons = [ 'doTask', 'undoTask', 'verifyTask' ];
  7355. static test() {
  7356. return window.location.host === 'givekey.ru';
  7357. }
  7358. async after() {
  7359. try {
  7360. await new Promise(resolve => {
  7361. const checker = setInterval(() => {
  7362. if ($('#navbarDropdown').length > 0) {
  7363. clearInterval(checker);
  7364. resolve(true);
  7365. }
  7366. });
  7367. });
  7368. if (!await this.#checkLeftKey()) {
  7369. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7370. }
  7371. } catch (error) {
  7372. throwError(error, 'Givekey.after');
  7373. return false;
  7374. }
  7375. }
  7376. init() {
  7377. try {
  7378. const logStatus = scripts_echoLog({
  7379. text: i18n('initing')
  7380. });
  7381. if ($('a[href*="/auth/steam"]').length > 0) {
  7382. window.open('/auth/steam', '_self');
  7383. logStatus.warning(i18n('needLogin'));
  7384. return false;
  7385. }
  7386. if (!this.#getGiveawayId()) {
  7387. return false;
  7388. }
  7389. const userId = $('meta[name="user-id"]').attr('content');
  7390. if (!userId) {
  7391. logStatus.error(i18n('getFailed', i18n('userId')));
  7392. return false;
  7393. }
  7394. this.userId = userId;
  7395. this.initialized = true;
  7396. logStatus.success();
  7397. return true;
  7398. } catch (error) {
  7399. throwError(error, 'Givekey.init');
  7400. return false;
  7401. }
  7402. }
  7403. async classifyTask(action) {
  7404. try {
  7405. const logStatus = scripts_echoLog({
  7406. text: i18n('getTasksInfo')
  7407. });
  7408. if (action === 'undo') {
  7409. var _GM_getValue;
  7410. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  7411. }
  7412. const tasks = $('.card-body:has("button") .row');
  7413. for (const task of tasks) {
  7414. const taskEle = $(task);
  7415. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7416. if (isSuccess && action !== 'undo') {
  7417. continue;
  7418. }
  7419. const checkButton = taskEle.find('#task_check');
  7420. const taskId = checkButton.attr('data-id');
  7421. if (taskId) {
  7422. this.tasks.push(taskId);
  7423. }
  7424. if (action === 'verify') {
  7425. continue;
  7426. }
  7427. let href = taskEle.find('a').attr('href') || null;
  7428. const text = taskEle.find('a').text().trim();
  7429. const icon = taskEle.find('i');
  7430. if (!href || !text) {
  7431. continue;
  7432. }
  7433. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7434. href = await getRedirectLink(href);
  7435. }
  7436. if (!href) {
  7437. continue;
  7438. }
  7439. if (/^https?:\/\/vk\.com\//.test(href)) {
  7440. this.socialTasks.vk.nameLinks.push(href);
  7441. if (action === 'do' && !isSuccess) {
  7442. this.undoneTasks.vk.nameLinks.push(href);
  7443. }
  7444. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7445. this.socialTasks.steam.groupLinks.push(href);
  7446. if (action === 'do' && !isSuccess) {
  7447. this.undoneTasks.steam.groupLinks.push(href);
  7448. }
  7449. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7450. this.socialTasks.steam.wishlistLinks.push(href);
  7451. if (action === 'do' && !isSuccess) {
  7452. this.undoneTasks.steam.wishlistLinks.push(href);
  7453. }
  7454. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7455. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7456. this.socialTasks.steam.curatorLinks.push(href);
  7457. if (action === 'do' && !isSuccess) {
  7458. this.undoneTasks.steam.curatorLinks.push(href);
  7459. }
  7460. } else {
  7461. this.socialTasks.steam.curatorLikeLinks.push(href);
  7462. if (action === 'do' && !isSuccess) {
  7463. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7464. }
  7465. }
  7466. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7467. this.socialTasks.twitter.userLinks.push(href);
  7468. if (action === 'do' && !isSuccess) {
  7469. this.undoneTasks.twitter.userLinks.push(href);
  7470. }
  7471. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  7472. this.socialTasks.discord.serverLinks.push(href);
  7473. if (action === 'do' && !isSuccess) {
  7474. this.undoneTasks.discord.serverLinks.push(href);
  7475. }
  7476. } else {
  7477. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7478. }
  7479. }
  7480. logStatus.success();
  7481. this.tasks = unique(this.tasks);
  7482. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7483. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7484. if (window.DEBUG) {
  7485. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7486. }
  7487. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7488. tasks: this.socialTasks,
  7489. time: new Date().getTime()
  7490. });
  7491. return true;
  7492. } catch (error) {
  7493. throwError(error, 'Givekey.classifyTask');
  7494. return false;
  7495. }
  7496. }
  7497. async verifyTask() {
  7498. try {
  7499. if (!this.initialized && !this.init()) {
  7500. return false;
  7501. }
  7502. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7503. return false;
  7504. }
  7505. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7506. const taskLength = this.tasks.length;
  7507. for (let i = 0; i < taskLength; i++) {
  7508. await this.#verify(this.tasks[i]);
  7509. if (i < taskLength - 1) {
  7510. await delay(15e3);
  7511. }
  7512. }
  7513. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7514. scripts_echoLog({
  7515. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7516. });
  7517. return true;
  7518. } catch (error) {
  7519. throwError(error, 'Givekey.verifyTask');
  7520. return false;
  7521. }
  7522. }
  7523. async #verify(task) {
  7524. try {
  7525. const logStatus = scripts_echoLog({
  7526. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7527. });
  7528. return await new Promise(resolve => {
  7529. $.ajax({
  7530. url: 'https://givekey.ru/giveaway/task',
  7531. method: 'POST',
  7532. data: `id=${task}&user_id=${this.userId}`,
  7533. dataType: 'json',
  7534. headers: {
  7535. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7536. },
  7537. success: data => {
  7538. if (data.btn) {
  7539. $(`button[data-id=${this.userId}]`).html(data.btn);
  7540. }
  7541. if (data.status === 'ok') {
  7542. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7543. logStatus.success();
  7544. resolve(true);
  7545. } else if (data.status === 'end') {
  7546. logStatus.success();
  7547. scripts_echoLog({}).success(data.key);
  7548. resolve(true);
  7549. } else {
  7550. logStatus.error(`Error:${data.msg}`);
  7551. resolve(false);
  7552. }
  7553. },
  7554. error: xhr => {
  7555. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7556. resolve(false);
  7557. }
  7558. });
  7559. });
  7560. } catch (error) {
  7561. throwError(error, 'Givekey.verify');
  7562. return false;
  7563. }
  7564. }
  7565. #getGiveawayId() {
  7566. try {
  7567. var _window$location$href;
  7568. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7569. if (giveawayId) {
  7570. this.giveawayId = giveawayId;
  7571. return true;
  7572. }
  7573. scripts_echoLog({
  7574. text: i18n('getFailed', 'GiveawayId')
  7575. });
  7576. return false;
  7577. } catch (error) {
  7578. throwError(error, 'Givekey.getGiveawayId');
  7579. return false;
  7580. }
  7581. }
  7582. async #checkLeftKey() {
  7583. try {
  7584. if (!globalOptions.other.checkLeftKey) {
  7585. return true;
  7586. }
  7587. if (!$('#keys_count').text()) {
  7588. await external_Swal_default().fire({
  7589. icon: 'warning',
  7590. title: i18n('notice'),
  7591. text: i18n('noKeysLeft'),
  7592. confirmButtonText: i18n('confirm'),
  7593. cancelButtonText: i18n('cancel'),
  7594. showCancelButton: true
  7595. }).then(_ref => {
  7596. let {
  7597. value
  7598. } = _ref;
  7599. if (value) {
  7600. window.close();
  7601. }
  7602. });
  7603. }
  7604. return true;
  7605. } catch (error) {
  7606. throwError(error, 'Givekey.checkLeftKey');
  7607. return false;
  7608. }
  7609. }
  7610. }
  7611. const website_Givekey = Givekey;
  7612. class GiveeClub extends GiveawaySu {
  7613. name = 'GiveeClub';
  7614. buttons = [ 'doTask', 'undoTask', 'verifyTask' ];
  7615. static test() {
  7616. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7617. }
  7618. async after() {
  7619. try {
  7620. if (!this.#checkLogin()) {
  7621. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7622. }
  7623. if (!await this.#checkLeftKey()) {
  7624. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7625. }
  7626. } catch (error) {
  7627. throwError(error, 'GiveeClub.after');
  7628. }
  7629. }
  7630. init() {
  7631. try {
  7632. const logStatus = scripts_echoLog({
  7633. text: i18n('initing')
  7634. });
  7635. if (!this.#checkLogin()) {
  7636. logStatus.warning(i18n('needLogin'));
  7637. return false;
  7638. }
  7639. if (!this.#getGiveawayId()) {
  7640. return false;
  7641. }
  7642. this.initialized = true;
  7643. logStatus.success();
  7644. return true;
  7645. } catch (error) {
  7646. throwError(error, 'GiveeClub.init');
  7647. return false;
  7648. }
  7649. }
  7650. async classifyTask(action) {
  7651. try {
  7652. const logStatus = scripts_echoLog({
  7653. text: i18n('getTasksInfo')
  7654. });
  7655. if (action === 'undo') {
  7656. var _GM_getValue;
  7657. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7658. return true;
  7659. }
  7660. const pro = [];
  7661. const tasks = $('.event-actions tr');
  7662. for (const task of tasks) {
  7663. pro.push(new Promise(resolve => {
  7664. var _$$find, _$$find2;
  7665. const taskDes = $(task).find('.event-action-label a');
  7666. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7667. const taskName = taskDes.text().trim();
  7668. const taskType = (_$$find = $(task).find('button[data-type]')) === null || _$$find === void 0 ? void 0 : _$$find.attr('data-type');
  7669. const taskFinished = (_$$find2 = $(task).find('.event-action-buttons .btn-success')) === null || _$$find2 === void 0 ? void 0 : _$$find2.length;
  7670. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope') || taskFinished) {
  7671. return resolve(true);
  7672. }
  7673. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7674. if (!taskLink) {
  7675. return resolve(false);
  7676. }
  7677. if (taskType === 'steam.group.join' && /^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7678. this.undoneTasks.steam.groupLinks.push(taskLink);
  7679. } else if (/like.*announcement/gi.test(taskName)) {
  7680. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7681. } else if (taskType === 'steam.game.wishlist' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7682. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7683. } else if (taskType === 'steam.game.wishlist' && taskDes.attr('data-steam-wishlist-appid')) {
  7684. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  7685. } else if (taskType === 'steam.game.follow' && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7686. this.undoneTasks.steam.followLinks.push(taskLink);
  7687. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7688. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7689. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7690. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7691. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7692. this.undoneTasks.steam.forumLinks.push(taskLink);
  7693. } else if (taskIcon.includes('discord')) {
  7694. this.undoneTasks.discord.serverLinks.push(taskLink);
  7695. } else if (taskIcon.includes('instagram')) {
  7696. this.undoneTasks.instagram.userLinks.push(taskLink);
  7697. } else if (taskIcon.includes('twitch')) {
  7698. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7699. } else if (taskIcon.includes('reddit')) {
  7700. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7701. } else if (/watch.*art/gim.test(taskName)) {
  7702. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7703. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7704. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7705. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7706. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7707. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7708. this.undoneTasks.vk.nameLinks.push(taskLink);
  7709. } else if (taskIcon.includes('twitter')) {
  7710. if (/https?:\/\/twitter\.com\/[^/]+\/?$/gim.test(taskLink)) {
  7711. this.undoneTasks.twitter.userLinks.push(taskLink);
  7712. } else if (/https?:\/\/twitter\.com\/[^/]+?\/status\/[\d]+/gim.test(taskLink)) {
  7713. this.undoneTasks.twitter.retweetLinks.push(taskLink);
  7714. }
  7715. } else {
  7716. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7717. if (/follow.*button/gim.test(taskName)) {
  7718. this.undoneTasks.steam.followLinks.push(taskLink);
  7719. }
  7720. }
  7721. }
  7722. resolve(true);
  7723. }).catch(error => {
  7724. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7725. return false;
  7726. });
  7727. }));
  7728. }
  7729. await Promise.all(pro);
  7730. logStatus.success();
  7731. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7732. this.socialTasks = this.undoneTasks;
  7733. if (window.DEBUG) {
  7734. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7735. }
  7736. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7737. tasks: this.socialTasks,
  7738. time: new Date().getTime()
  7739. });
  7740. return true;
  7741. } catch (error) {
  7742. throwError(error, 'GiveeClub.classifyTask');
  7743. return false;
  7744. }
  7745. }
  7746. async verifyTask() {
  7747. try {
  7748. const logStatus = scripts_echoLog({
  7749. text: i18n('giveeClubVerifyNotice')
  7750. });
  7751. const taskButtons = $('.event-actions tr button').has('i.glyphicon-refresh').not('[data-type="user.adblock"]');
  7752. for (const button of taskButtons) {
  7753. button.click();
  7754. if ($(button).attr('data-type') !== 'steam.game.wishlist') {
  7755. await delay(1e3);
  7756. }
  7757. }
  7758. logStatus.warning(i18n('giveeClubVerifyFinished'));
  7759. return true;
  7760. } catch (error) {
  7761. throwError(error, 'Givekey.verifyTask');
  7762. return false;
  7763. }
  7764. }
  7765. #checkLogin() {
  7766. try {
  7767. if (!globalOptions.other.checkLogin) {
  7768. return true;
  7769. }
  7770. if ($('a[href*="/account/auth"]').length > 0) {
  7771. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  7772. }
  7773. return true;
  7774. } catch (error) {
  7775. throwError(error, 'GiveeClub.checkLogin');
  7776. return false;
  7777. }
  7778. }
  7779. #getGiveawayId() {
  7780. var _window$location$href;
  7781. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7782. if (giveawayId) {
  7783. this.giveawayId = giveawayId;
  7784. return true;
  7785. }
  7786. scripts_echoLog({
  7787. text: i18n('getFailed', 'GiveawayId')
  7788. });
  7789. return false;
  7790. }
  7791. async #checkLeftKey() {
  7792. try {
  7793. if (!globalOptions.other.checkLeftKey) {
  7794. return true;
  7795. }
  7796. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  7797. await external_Swal_default().fire({
  7798. icon: 'warning',
  7799. title: i18n('notice'),
  7800. text: i18n('giveawayEnded'),
  7801. confirmButtonText: i18n('confirm'),
  7802. cancelButtonText: i18n('cancel'),
  7803. showCancelButton: true
  7804. }).then(_ref => {
  7805. let {
  7806. value
  7807. } = _ref;
  7808. if (value) {
  7809. window.close();
  7810. }
  7811. });
  7812. }
  7813. return true;
  7814. } catch (error) {
  7815. throwError(error, 'Giveawaysu.checkLeftKey');
  7816. return false;
  7817. }
  7818. }
  7819. }
  7820. const website_GiveeClub = GiveeClub;
  7821. const defaultOptions = {
  7822. maxPoint: '99999999'
  7823. };
  7824. class OpiumPulses {
  7825. name = 'OpiumPulses';
  7826. options = {
  7827. ...defaultOptions,
  7828. ...GM_getValue('OpiumPulsesOptions')
  7829. };
  7830. maxPoints = 99999999;
  7831. myPoints = 0;
  7832. buttons = [ 'doFreeTask', 'doPointTask' ];
  7833. static test() {
  7834. return window.location.host === 'www.opiumpulses.com';
  7835. }
  7836. async after() {
  7837. try {
  7838. if (!this.#checkLogin()) {
  7839. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7840. }
  7841. this.maxPoints = parseInt(this.options.maxPoint, 10);
  7842. } catch (error) {
  7843. throwError(error, 'OpiumPulses.after');
  7844. }
  7845. }
  7846. async doFreeTask() {
  7847. try {
  7848. this.#toggleTask('FREE');
  7849. } catch (error) {
  7850. throwError(error, 'OpiumPulses.doFreeTask');
  7851. }
  7852. }
  7853. async doPointTask() {
  7854. try {
  7855. var _$$text$match;
  7856. 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);
  7857. this.#toggleTask('points');
  7858. } catch (error) {
  7859. throwError(error, 'OpiumPulses.doPointTask');
  7860. }
  7861. }
  7862. async #toggleTask(type) {
  7863. try {
  7864. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  7865. for (const item of items) {
  7866. var _$$find$text$match;
  7867. 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);
  7868. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  7869. if (type === 'points' && needPoints > this.myPoints) {
  7870. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  7871. } else if (type === 'points' && !needPoints) {
  7872. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  7873. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  7874. var _aElement$attr;
  7875. const logStatus = scripts_echoLog({
  7876. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  7877. });
  7878. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  7879. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  7880. var _aElement$attr2, _aElement$attr2$match;
  7881. 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];
  7882. if (giveawayId) {
  7883. checkUser(giveawayId);
  7884. }
  7885. }
  7886. if (!aElement.attr('href')) {
  7887. logStatus.error('Error: No "href".');
  7888. continue;
  7889. }
  7890. const {
  7891. result,
  7892. statusText,
  7893. status,
  7894. data
  7895. } = await tools_httpRequest({
  7896. url: aElement.attr('href'),
  7897. method: 'GET'
  7898. });
  7899. if (result === 'Success') {
  7900. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  7901. var _data$responseText$ma;
  7902. logStatus.success();
  7903. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  7904. if (type === 'points' && points) {
  7905. this.myPoints = parseInt(points, 10);
  7906. }
  7907. } else {
  7908. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7909. }
  7910. } else {
  7911. logStatus.error(`${result}:${statusText}(${status})`);
  7912. }
  7913. }
  7914. }
  7915. scripts_echoLog({
  7916. text: '-----END-----'
  7917. });
  7918. } catch (error) {
  7919. throwError(error, 'OpiumPulses.toggleTask');
  7920. }
  7921. }
  7922. init() {
  7923. return true;
  7924. }
  7925. classifyTask() {
  7926. return true;
  7927. }
  7928. #checkLogin() {
  7929. try {
  7930. if (!globalOptions.other.checkLogin) {
  7931. return true;
  7932. }
  7933. if ($('a[href*="/site/login"]').length > 1) {
  7934. window.open('/site/login', '_self');
  7935. }
  7936. return true;
  7937. } catch (error) {
  7938. throwError(error, 'OpiumPulses.checkLogin');
  7939. return false;
  7940. }
  7941. }
  7942. }
  7943. const website_OpiumPulses = OpiumPulses;
  7944. const external_dayjs_namespaceObject = dayjs;
  7945. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  7946. const leftKeyChecker = {
  7947. async classify(link) {
  7948. try {
  7949. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  7950. return await this.giveawaySu(link);
  7951. }
  7952. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  7953. return await this.giveeClub(link);
  7954. }
  7955. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  7956. return await this.gleam(link);
  7957. }
  7958. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  7959. return await this.indieDb(link);
  7960. }
  7961. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  7962. return await this.keyhub(link);
  7963. }
  7964. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  7965. return await this.opquests(link);
  7966. }
  7967. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  7968. return await this.itch(link);
  7969. }
  7970. return false;
  7971. } catch (error) {
  7972. throwError(error, 'leftKeyChecker.classify');
  7973. return false;
  7974. }
  7975. },
  7976. async giveawaySu(link) {
  7977. try {
  7978. const {
  7979. result,
  7980. data
  7981. } = await tools_httpRequest({
  7982. url: link,
  7983. method: 'GET'
  7984. });
  7985. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  7986. if (data.responseText.includes('class="steam-login"')) {
  7987. return false;
  7988. }
  7989. if (data.responseText.includes('class="giveaway-ended"')) {
  7990. return 'Ended';
  7991. }
  7992. return 'Active';
  7993. }
  7994. return false;
  7995. } catch (error) {
  7996. throwError(error, 'leftKeyChecker.giveawaySu');
  7997. return false;
  7998. }
  7999. },
  8000. async giveeClub(link) {
  8001. try {
  8002. const {
  8003. result,
  8004. data
  8005. } = await tools_httpRequest({
  8006. url: link,
  8007. method: 'GET'
  8008. });
  8009. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8010. if (data.responseText.includes('class="event-winner"')) {
  8011. return 'Won';
  8012. }
  8013. if (data.responseText.includes('class="event-ended"')) {
  8014. return 'Ended';
  8015. }
  8016. return 'Active';
  8017. }
  8018. return false;
  8019. } catch (error) {
  8020. throwError(error, 'leftKeyChecker.giveeClub');
  8021. return false;
  8022. }
  8023. },
  8024. async gleam(link) {
  8025. try {
  8026. const {
  8027. result,
  8028. data
  8029. } = await tools_httpRequest({
  8030. url: link,
  8031. method: 'GET'
  8032. });
  8033. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8034. var _data$responseText$ma, _$$attr, _$$attr$match;
  8035. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8036. return 'Won';
  8037. }
  8038. 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];
  8039. if (!campaignDiv) {
  8040. return false;
  8041. }
  8042. 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];
  8043. if (!campaignString) {
  8044. return false;
  8045. }
  8046. const {
  8047. campaign
  8048. } = JSON.parse(campaignString);
  8049. if (campaign.banned) {
  8050. return 'Banned';
  8051. }
  8052. if (campaign.finished) {
  8053. return 'Ended';
  8054. }
  8055. if (campaign.paused) {
  8056. return 'Paused';
  8057. }
  8058. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8059. return 'NotStart';
  8060. }
  8061. return 'Active';
  8062. }
  8063. return false;
  8064. } catch (error) {
  8065. throwError(error, 'leftKeyChecker.gleam');
  8066. return false;
  8067. }
  8068. },
  8069. async indieDb(link) {
  8070. try {
  8071. const {
  8072. result,
  8073. data
  8074. } = await tools_httpRequest({
  8075. url: link,
  8076. method: 'GET'
  8077. });
  8078. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8079. if (data.responseText.includes('Congrats you WON')) {
  8080. return 'Won';
  8081. }
  8082. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8083. return 'Ended';
  8084. }
  8085. return 'Active';
  8086. }
  8087. return false;
  8088. } catch (error) {
  8089. throwError(error, 'leftKeyChecker.indieDb');
  8090. return false;
  8091. }
  8092. },
  8093. async keyhub(link) {
  8094. try {
  8095. const {
  8096. result,
  8097. data
  8098. } = await tools_httpRequest({
  8099. url: link,
  8100. method: 'GET'
  8101. });
  8102. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8103. var _data$responseText$ma2;
  8104. 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];
  8105. if (!keysleft) {
  8106. return false;
  8107. }
  8108. if (keysleft === '0') {
  8109. return 'Ended';
  8110. }
  8111. return `Active(${keysleft})`;
  8112. }
  8113. return false;
  8114. } catch (error) {
  8115. throwError(error, 'leftKeyChecker.keyhub');
  8116. return false;
  8117. }
  8118. },
  8119. async opquests(link) {
  8120. try {
  8121. const {
  8122. result,
  8123. data
  8124. } = await tools_httpRequest({
  8125. url: link,
  8126. method: 'GET'
  8127. });
  8128. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8129. var _data$responseText$ma3;
  8130. 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];
  8131. if (!keysleft) {
  8132. return false;
  8133. }
  8134. if (keysleft === '0') {
  8135. return 'Ended';
  8136. }
  8137. return `Active(${keysleft})`;
  8138. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8139. return 'Ended';
  8140. }
  8141. return false;
  8142. } catch (error) {
  8143. throwError(error, 'leftKeyChecker.opquests');
  8144. return false;
  8145. }
  8146. },
  8147. async itch(link) {
  8148. try {
  8149. const {
  8150. result,
  8151. data
  8152. } = await tools_httpRequest({
  8153. url: link,
  8154. method: 'GET'
  8155. });
  8156. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8157. var _data$responseText$ma4;
  8158. 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];
  8159. if (!endDate) {
  8160. return false;
  8161. }
  8162. if (new Date().getTime() > new Date(endDate).getTime()) {
  8163. return 'Ended';
  8164. }
  8165. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8166. }
  8167. return false;
  8168. } catch (error) {
  8169. throwError(error, 'leftKeyChecker.opquests');
  8170. return false;
  8171. }
  8172. }
  8173. };
  8174. const website_leftKeyChecker = leftKeyChecker;
  8175. const Keylol_defaultTasksTemplate = {
  8176. steam: {
  8177. groupLinks: [],
  8178. wishlistLinks: [],
  8179. curatorLinks: [],
  8180. curatorLikeLinks: [],
  8181. followLinks: [],
  8182. forumLinks: [],
  8183. announcementLinks: [],
  8184. workshopVoteLinks: [],
  8185. licenseLinks: []
  8186. },
  8187. discord: {
  8188. serverLinks: []
  8189. },
  8190. instagram: {
  8191. userLinks: []
  8192. },
  8193. vk: {
  8194. nameLinks: []
  8195. },
  8196. twitch: {
  8197. channelLinks: []
  8198. },
  8199. reddit: {
  8200. redditLinks: []
  8201. },
  8202. twitter: {
  8203. userLinks: [],
  8204. retweetLinks: []
  8205. },
  8206. youtube: {
  8207. channelLinks: [],
  8208. likeLinks: []
  8209. }
  8210. };
  8211. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  8212. class Keylol extends website_Website {
  8213. name = 'Keylol';
  8214. socialTasks = JSON.parse(Keylol_defaultTasks);
  8215. undoneTasks = JSON.parse(Keylol_defaultTasks);
  8216. buttons = [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ];
  8217. static test() {
  8218. var _$$eq$attr, _$$eq$attr2;
  8219. return window.location.host === 'keylol.com' && (!!((_$$eq$attr = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr !== void 0 && _$$eq$attr.includes('319')) || !!((_$$eq$attr2 = $('.subforum_left_title_left_up a').eq(3).attr('href')) !== null && _$$eq$attr2 !== void 0 && _$$eq$attr2.includes('234')));
  8220. }
  8221. init() {
  8222. return true;
  8223. }
  8224. after() {
  8225. try {
  8226. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8227. const mainPost = $(selector);
  8228. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  8229. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  8230. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  8231. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  8232. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  8233. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  8234. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  8235. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  8236. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  8237. if (discordLinks.length > 0) {
  8238. for (const discordLink of discordLinks) {
  8239. const link = $(discordLink).attr('href');
  8240. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8241. continue;
  8242. }
  8243. this.#addBtn(discordLink, 'discord', 'serverLinks', link);
  8244. }
  8245. }
  8246. if (redditLinks.length > 0) {
  8247. for (const redditLink of redditLinks) {
  8248. const link = $(redditLink).attr('href');
  8249. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8250. continue;
  8251. }
  8252. this.#addBtn(redditLink, 'reddit', 'redditLinks', link);
  8253. }
  8254. }
  8255. if (insLinks.length > 0) {
  8256. for (const insLink of insLinks) {
  8257. const link = $(insLink).attr('href');
  8258. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8259. continue;
  8260. }
  8261. this.#addBtn(insLink, 'instagram', 'userLinks', link);
  8262. }
  8263. }
  8264. if (twitterLinks.length > 0) {
  8265. for (const twitterLink of twitterLinks) {
  8266. const link = $(twitterLink).attr('href');
  8267. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8268. continue;
  8269. }
  8270. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8271. this.#addBtn(twitterLink, 'twitter', 'retweetLinks', link);
  8272. } else {
  8273. this.#addBtn(twitterLink, 'twitter', 'userLinks', link);
  8274. }
  8275. }
  8276. }
  8277. if (twitchLinks.length > 0) {
  8278. for (const twitchLink of twitchLinks) {
  8279. const link = $(twitchLink).attr('href');
  8280. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8281. continue;
  8282. }
  8283. this.#addBtn(twitchLink, 'twitch', 'channelLinks', link);
  8284. }
  8285. }
  8286. if (vkLinks.length > 0) {
  8287. for (const vkLink of vkLinks) {
  8288. const link = $(vkLink).attr('href');
  8289. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8290. continue;
  8291. }
  8292. this.#addBtn(vkLink, 'vk', 'nameLinks', link);
  8293. }
  8294. }
  8295. if (steamStoreLinks.length > 0) {
  8296. for (const steamStoreLink of steamStoreLinks) {
  8297. const link = $(steamStoreLink).attr('href');
  8298. if (!link) {
  8299. continue;
  8300. }
  8301. if (/curator\/[\d]+/.test(link)) {
  8302. this.#addBtn(steamStoreLink, 'steam', 'curatorLinks', link);
  8303. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8304. this.#addBtn(steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8305. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8306. this.#addBtn(steamStoreLink, 'steam', 'announcementLinks', link);
  8307. } else if (/app\/[\d]+/.test(link)) {
  8308. this.#addBtn(steamStoreLink, 'steam', 'followLinks', link);
  8309. this.#addBtn(steamStoreLink, 'steam', 'wishlistLinks', link);
  8310. }
  8311. }
  8312. }
  8313. if (steamCommunityLinks.length > 0) {
  8314. for (const steamCommunityLink of steamCommunityLinks) {
  8315. const link = $(steamCommunityLink).attr('href');
  8316. if (!link) {
  8317. continue;
  8318. }
  8319. if (/groups\/.+/.test(link)) {
  8320. this.#addBtn(steamCommunityLink, 'steam', 'groupLinks', link);
  8321. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8322. this.#addBtn(steamCommunityLink, 'steam', 'announcementLinks', link);
  8323. }
  8324. }
  8325. }
  8326. if (ytbLinks.length > 0) {
  8327. for (const ytbLink of ytbLinks) {
  8328. const link = $(ytbLink).attr('href');
  8329. if (!link) {
  8330. continue;
  8331. }
  8332. this.#addBtn(ytbLink, 'youtube', 'channelLinks', link);
  8333. this.#addBtn(ytbLink, 'youtube', 'likeLinks', link);
  8334. }
  8335. }
  8336. const giveawayLinks = mainPost.find('a[href*="giveaway.su/giveaway/view/"]:visible,a[href*="givee.club/"]:visible,a[href*="gleam.io/"]:visible,a[href*="www.indiedb.com/giveaways/"]:visible,a[href*="key-hub.eu/giveaway/"]:visible,a[href*="opquests.com/quests/"]:visible,a[href*="itch.io/s/"]:visible');
  8337. if (giveawayLinks.length > 0) {
  8338. for (const giveawayLink of giveawayLinks) {
  8339. const link = $(giveawayLink).attr('href');
  8340. if (!link) {
  8341. continue;
  8342. }
  8343. website_leftKeyChecker.classify(link).then(status => {
  8344. if (!status) {
  8345. return;
  8346. }
  8347. if (/^Active/.test(status)) {
  8348. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  8349. return;
  8350. }
  8351. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  8352. }).catch(error => {
  8353. throwError(error, 'keylol.after -> leftKeyChecker');
  8354. });
  8355. }
  8356. }
  8357. if (this.name === 'Keylol') {
  8358. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  8359. if (asfLinks.length > 0) {
  8360. for (const asfLink of asfLinks) {
  8361. const link = $(asfLink).attr('href');
  8362. if (!link) {
  8363. continue;
  8364. }
  8365. this.#addBtn($(`a[href="${link}"]`).after('<span style="color: #ccc; margin: 0 -5px 0 5px"> | </span>').next()[0], 'steam', 'licenseLinks', `appid-${link.replace('#asf', '')}`);
  8366. }
  8367. }
  8368. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  8369. if (subLinks.length > 0) {
  8370. for (const subLink of subLinks) {
  8371. var _link$match;
  8372. const link = $(subLink).attr('href');
  8373. if (!link) {
  8374. continue;
  8375. }
  8376. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  8377. if (!subid) {
  8378. continue;
  8379. }
  8380. this.#addBtn(subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  8381. }
  8382. }
  8383. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  8384. if (asfLinks2.length > 0) {
  8385. for (const asfLink of asfLinks2) {
  8386. const subid = asfLink.innerText.match(/[\d]+/g);
  8387. if (!subid || subid.length === 0) {
  8388. continue;
  8389. }
  8390. this.#addBtn($(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  8391. }
  8392. }
  8393. }
  8394. } catch (error) {
  8395. throwError(error, 'keylol.after');
  8396. }
  8397. }
  8398. classifyTask(action) {
  8399. try {
  8400. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  8401. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  8402. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  8403. for (const btn of selectedBtns) {
  8404. const button = $(btn);
  8405. const social = button.attr('data-social');
  8406. const type = button.attr('data-type');
  8407. const link = button.attr('data-link');
  8408. if (!(social && type && link)) {
  8409. continue;
  8410. }
  8411. if (action === 'do') {
  8412. this.undoneTasks[social][type].push(link);
  8413. }
  8414. if (action === 'undo') {
  8415. this.socialTasks[social][type].push(link);
  8416. }
  8417. }
  8418. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8419. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8420. if (window.DEBUG) {
  8421. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8422. }
  8423. return true;
  8424. } catch (error) {
  8425. throwError(error, 'Keylol.classifyTask');
  8426. return false;
  8427. }
  8428. }
  8429. selectAll() {
  8430. try {
  8431. $('.auto-task-keylol:visible').attr('selected', 'selected');
  8432. } catch (error) {
  8433. throwError(error, 'Keylol.selectAll');
  8434. }
  8435. }
  8436. selectNone() {
  8437. try {
  8438. $('.auto-task-keylol:visible').removeAttr('selected');
  8439. } catch (error) {
  8440. throwError(error, 'Keylol.selectNone');
  8441. }
  8442. }
  8443. invertSelect() {
  8444. try {
  8445. $('.auto-task-keylol:visible').each((index, element) => {
  8446. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8447. });
  8448. } catch (error) {
  8449. throwError(error, 'Keylol.invertSelect');
  8450. }
  8451. }
  8452. #addBtn(before, social, linkType, link) {
  8453. try {
  8454. $(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>`);
  8455. } catch (error) {
  8456. throwError(error, 'keylol.addBtn');
  8457. }
  8458. }
  8459. }
  8460. const website_Keylol = Keylol;
  8461. const Opquests_defaultTasks = {
  8462. steam: {
  8463. groupLinks: [],
  8464. wishlistLinks: [],
  8465. followLinks: [],
  8466. curatorLikeLinks: []
  8467. }
  8468. };
  8469. class Opquests extends website_Website {
  8470. name = 'Opquests';
  8471. undoneTasks = {
  8472. ...Opquests_defaultTasks
  8473. };
  8474. buttons = [ 'doTask', 'verifyTask', 'getKey' ];
  8475. static test() {
  8476. return window.location.host === 'opquests.com';
  8477. }
  8478. async after() {
  8479. try {
  8480. if (!this.#checkLogin()) {
  8481. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8482. }
  8483. } catch (error) {
  8484. throwError(error, 'Opquests.after');
  8485. }
  8486. }
  8487. init() {
  8488. try {
  8489. const logStatus = scripts_echoLog({
  8490. text: i18n('initing')
  8491. });
  8492. if ($('a[href*="/auth/redirect"]').length > 0) {
  8493. window.open('/auth/redirect', '_self');
  8494. logStatus.warning(i18n('needLogin'));
  8495. return false;
  8496. }
  8497. if (!this.#getGiveawayId()) {
  8498. return false;
  8499. }
  8500. this.initialized = true;
  8501. logStatus.success();
  8502. return true;
  8503. } catch (error) {
  8504. throwError(error, 'Opquests.init');
  8505. return false;
  8506. }
  8507. }
  8508. async classifyTask(action) {
  8509. try {
  8510. if (action === 'undo') {
  8511. scripts_echoLog({
  8512. text: i18n('cannotUndo')
  8513. });
  8514. return false;
  8515. }
  8516. const logStatus = scripts_echoLog({
  8517. text: i18n('getTasksInfo')
  8518. });
  8519. const tasks = $('.w-full:contains("Validate") .items-center');
  8520. for (const task of tasks) {
  8521. const link = $(task).find('a:contains("Open")').attr('href');
  8522. const taskDes = $(task).find('div').eq(1).text().trim();
  8523. if (!link) {
  8524. continue;
  8525. }
  8526. if (/steamcommunity\.com\/groups\//.test(link)) {
  8527. this.undoneTasks.steam.groupLinks.push(link);
  8528. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8529. if (/wishlist/gim.test(taskDes)) {
  8530. this.undoneTasks.steam.wishlistLinks.push(link);
  8531. } else if (/follow/gim.test(taskDes)) {
  8532. this.undoneTasks.steam.followLinks.push(link);
  8533. }
  8534. } else if (/store\.steampowered\.com\/(publisher|developer|curator)\//.test(link) && /follow/gim.test(taskDes)) {
  8535. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8536. } else {
  8537. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8538. }
  8539. }
  8540. logStatus.success();
  8541. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8542. if (window.DEBUG) {
  8543. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8544. }
  8545. return true;
  8546. } catch (error) {
  8547. throwError(error, 'Opquests.classifyTask');
  8548. return false;
  8549. }
  8550. }
  8551. async verifyTask() {
  8552. try {
  8553. const tasks = $.makeArray($('div.w-full').find('.items-center').has('button.submit-loader')).map(ele => ({
  8554. token: $(ele).find('input[name="_token"]').val(),
  8555. taskId: $(ele).find('input[name="task_id"]').val(),
  8556. title: $(ele).find('span.text-sm').text().trim()
  8557. }));
  8558. const pro = [];
  8559. for (const task of tasks) {
  8560. pro.push(this.#verify(task));
  8561. await delay(1e3);
  8562. }
  8563. await Promise.all(pro);
  8564. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8565. if (await this.getKey()) {
  8566. return true;
  8567. }
  8568. window.location.reload();
  8569. return false;
  8570. } catch (error) {
  8571. throwError(error, 'Opquests.verifyTask');
  8572. return false;
  8573. }
  8574. }
  8575. async #verify(task) {
  8576. try {
  8577. const logStatus = scripts_echoLog({
  8578. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  8579. });
  8580. const {
  8581. result,
  8582. statusText,
  8583. status,
  8584. data
  8585. } = await tools_httpRequest({
  8586. url: 'https://opquests.com/entries',
  8587. method: 'POST',
  8588. dataType: 'json',
  8589. nochche: true,
  8590. headers: {
  8591. origin: 'https://opquests.com',
  8592. pragma: 'no-cache',
  8593. referer: window.location.href,
  8594. 'content-type': 'application/x-www-form-urlencoded'
  8595. },
  8596. data: `_token=${task.token}&task_id=${task.taskId}`
  8597. });
  8598. if (result === 'Success') {
  8599. var _data$responseText, _data$responseText2, _$$find$attr;
  8600. if (data !== null && data !== void 0 && (_data$responseText = data.responseText) !== null && _data$responseText !== void 0 && _data$responseText.includes('Successfully completed task') || data !== null && data !== void 0 && (_data$responseText2 = data.responseText) !== null && _data$responseText2 !== void 0 && _data$responseText2.includes('unlocked the key')) {
  8601. logStatus.success();
  8602. return true;
  8603. }
  8604. const key = (_$$find$attr = $((data === null || data === void 0 ? void 0 : data.responseText) || '').find('button[data-clipboard-text]:contains("Copy")').attr('data-clipboard-text')) === null || _$$find$attr === void 0 ? void 0 : _$$find$attr.trim();
  8605. if (key) {
  8606. logStatus.success();
  8607. scripts_echoLog({}).success(key);
  8608. return true;
  8609. }
  8610. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8611. return false;
  8612. }
  8613. logStatus.error(`${result}:${statusText}(${status})`);
  8614. return false;
  8615. } catch (error) {
  8616. throwError(error, 'Opquests.verify');
  8617. return false;
  8618. }
  8619. }
  8620. async getKey(isButton) {
  8621. try {
  8622. const logStatus = scripts_echoLog({
  8623. text: i18n('gettingKey')
  8624. });
  8625. const {
  8626. result,
  8627. statusText,
  8628. status,
  8629. data
  8630. } = await tools_httpRequest({
  8631. url: 'https://opquests.com/keys',
  8632. method: 'GET'
  8633. });
  8634. if (result === 'Success') {
  8635. if (data !== null && data !== void 0 && data.responseText) {
  8636. const key = $(data === null || data === void 0 ? void 0 : data.responseText).find(`div.items-center:contains("${$('h1.font-bold').text().trim().replace(' Quest', '')}")`).find('div.font-bold').next().text();
  8637. if (!key) {
  8638. logStatus.error('Error: Key was not found');
  8639. if (isButton) {
  8640. window.open('https://opquests.com/keys', '_self');
  8641. }
  8642. return false;
  8643. }
  8644. logStatus.success();
  8645. scripts_echoLog({}).success(key);
  8646. return true;
  8647. }
  8648. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8649. return false;
  8650. }
  8651. logStatus.error(`${result}:${statusText}(${status})`);
  8652. return false;
  8653. } catch (error) {
  8654. throwError(error, 'Opquests.getGiveawayId');
  8655. return false;
  8656. }
  8657. }
  8658. #getGiveawayId() {
  8659. try {
  8660. var _window$location$href;
  8661. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8662. if (giveawayId) {
  8663. this.giveawayId = giveawayId;
  8664. return true;
  8665. }
  8666. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8667. return false;
  8668. } catch (error) {
  8669. throwError(error, 'Opquests.getGiveawayId');
  8670. return false;
  8671. }
  8672. }
  8673. #checkLogin() {
  8674. try {
  8675. if (!globalOptions.other.checkLogin) {
  8676. return true;
  8677. }
  8678. if ($('a[href*="/auth/redirect"]').length > 0) {
  8679. window.open('/auth/redirect', '_self');
  8680. }
  8681. return true;
  8682. } catch (error) {
  8683. throwError(error, 'Opquests.checkLogin');
  8684. return false;
  8685. }
  8686. }
  8687. }
  8688. const website_Opquests = Opquests;
  8689. const Gleam_defaultTasksTemplate = {
  8690. steam: {
  8691. groupLinks: [],
  8692. wishlistLinks: [],
  8693. followLinks: [],
  8694. curatorLinks: [],
  8695. curatorLikeLinks: []
  8696. },
  8697. twitter: {
  8698. userLinks: [],
  8699. retweetLinks: []
  8700. },
  8701. twitch: {
  8702. channelLinks: []
  8703. },
  8704. discord: {
  8705. serverLinks: []
  8706. },
  8707. youtube: {
  8708. channelLinks: []
  8709. },
  8710. extra: {
  8711. gleam: []
  8712. }
  8713. };
  8714. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  8715. const Gleam_defaultOptions = {
  8716. vlootUsername: '',
  8717. gameroundUsername: ''
  8718. };
  8719. class Gleam extends website_Website {
  8720. name = 'Gleam';
  8721. undoneTasks = JSON.parse(Gleam_defaultTasks);
  8722. socialTasks = JSON.parse(Gleam_defaultTasks);
  8723. options = {
  8724. ...Gleam_defaultOptions,
  8725. ...GM_getValue('GleamOptions')
  8726. };
  8727. buttons = [ 'doTask', 'undoTask', 'verifyTask' ];
  8728. static test() {
  8729. return window.location.host === 'gleam.io';
  8730. }
  8731. async after() {
  8732. try {
  8733. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8734. const checkComplete = setInterval(() => {
  8735. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8736. clearInterval(checkComplete);
  8737. window.close();
  8738. }
  8739. });
  8740. for (const task of $('.entry-content .entry-method')) {
  8741. const taskInfo = $(task).find('.user-links');
  8742. const expandInfo = $(task).find('.expandable');
  8743. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8744. if (aElements.length > 0) {
  8745. for (const element of aElements) {
  8746. const $element = $(element);
  8747. const href = $element.attr('href');
  8748. $element.removeAttr('href')[0].click();
  8749. $element.attr('href', href);
  8750. await delay(1e3);
  8751. }
  8752. }
  8753. taskInfo[0].click();
  8754. await delay(1e3);
  8755. }
  8756. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8757. } else if (!await this.#checkLeftKey()) {
  8758. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8759. }
  8760. } catch (error) {
  8761. throwError(error, 'Gleam.after');
  8762. return false;
  8763. }
  8764. }
  8765. init() {
  8766. try {
  8767. const logStatus = scripts_echoLog({
  8768. text: i18n('initing')
  8769. });
  8770. if (!this.#getGiveawayId()) {
  8771. return false;
  8772. }
  8773. this.initialized = true;
  8774. logStatus.success();
  8775. return true;
  8776. } catch (error) {
  8777. throwError(error, 'Gleam.init');
  8778. return false;
  8779. }
  8780. }
  8781. async classifyTask(action) {
  8782. try {
  8783. const logStatus = scripts_echoLog({
  8784. text: i18n('getTasksInfo')
  8785. });
  8786. if (action === 'undo') {
  8787. var _GM_getValue;
  8788. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  8789. }
  8790. const tasks = $('.entry-content .entry-method');
  8791. for (const task of tasks) {
  8792. var _socialIcon$attr;
  8793. const $task = $(task);
  8794. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  8795. continue;
  8796. }
  8797. const socialIcon = $task.find('.icon-wrapper i');
  8798. const taskInfo = $task.find('.user-links');
  8799. const taskText = taskInfo.text().trim();
  8800. const expandInfo = $task.find('.expandable');
  8801. const aElements = expandInfo.find('a.btn');
  8802. if (aElements.length > 0) {
  8803. for (const element of aElements) {
  8804. const $element = $(element);
  8805. const href = $element.attr('href');
  8806. $element.removeAttr('href')[0].click();
  8807. $element.attr('href', href);
  8808. }
  8809. }
  8810. if (socialIcon.hasClass('fa-twitter')) {
  8811. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  8812. if (!link) {
  8813. continue;
  8814. }
  8815. if (/follow/gi.test(taskText)) {
  8816. if (action === 'undo') {
  8817. this.socialTasks.twitter.userLinks.push(link);
  8818. }
  8819. if (action === 'do') {
  8820. this.undoneTasks.twitter.userLinks.push(link);
  8821. }
  8822. } else if (/retweet/gim.test(taskText)) {
  8823. if (action === 'undo') {
  8824. this.socialTasks.twitter.retweetLinks.push(link);
  8825. }
  8826. if (action === 'do') {
  8827. this.undoneTasks.twitter.retweetLinks.push(link);
  8828. }
  8829. }
  8830. } else if (socialIcon.hasClass('fa-twitch')) {
  8831. if (/follow/gim.test(taskText)) {
  8832. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  8833. if (!link) {
  8834. continue;
  8835. }
  8836. if (action === 'undo') {
  8837. this.socialTasks.twitch.channelLinks.push(link);
  8838. }
  8839. if (action === 'do') {
  8840. this.undoneTasks.twitch.channelLinks.push(link);
  8841. }
  8842. }
  8843. } else if (socialIcon.hasClass('fa-discord')) {
  8844. if (/join/gim.test(taskText)) {
  8845. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  8846. if (!link) {
  8847. var _$task$find$attr, _$task$find$attr$matc;
  8848. 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];
  8849. if (!ggLink) {
  8850. continue;
  8851. }
  8852. link = `https://discord.com/invite/${ggLink}`;
  8853. }
  8854. if (action === 'undo') {
  8855. this.socialTasks.discord.serverLinks.push(link);
  8856. }
  8857. if (action === 'do') {
  8858. this.undoneTasks.discord.serverLinks.push(link);
  8859. }
  8860. }
  8861. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  8862. continue;
  8863. } else if (socialIcon.hasClass('fa-youtube')) {
  8864. if (/subscribe/gim.test(taskText)) {
  8865. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  8866. if (!link) {
  8867. continue;
  8868. }
  8869. if (action === 'undo') {
  8870. this.socialTasks.youtube.channelLinks.push(link);
  8871. }
  8872. if (action === 'do') {
  8873. this.undoneTasks.youtube.channelLinks.push(link);
  8874. }
  8875. }
  8876. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  8877. if (/join.*group/gi.test(taskText)) {
  8878. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  8879. if (!link) {
  8880. continue;
  8881. }
  8882. if (action === 'undo') {
  8883. this.socialTasks.steam.groupLinks.push(link);
  8884. }
  8885. if (action === 'do') {
  8886. this.undoneTasks.steam.groupLinks.push(link);
  8887. }
  8888. } else if (/follow.*curator/gi.test(taskText)) {
  8889. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  8890. if (!link) {
  8891. continue;
  8892. }
  8893. if (action === 'undo') {
  8894. this.socialTasks.steam.curatorLinks.push(link);
  8895. }
  8896. if (action === 'do') {
  8897. this.undoneTasks.steam.curatorLinks.push(link);
  8898. }
  8899. }
  8900. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('vloot.io') || socialIcon.hasClass('fa-tiktok')) {
  8901. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  8902. for (const button of continueBtn) {
  8903. button.click();
  8904. await delay(500);
  8905. expandInfo.find('input').val(this.options.vlootUsername);
  8906. }
  8907. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  8908. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  8909. for (const button of continueBtn) {
  8910. button.click();
  8911. await delay(500);
  8912. expandInfo.find('input').val(this.options.gameroundUsername);
  8913. }
  8914. } else if (socialIcon.hasClass('fa-bullhorn') && /Complete/gi.test(taskText)) {
  8915. if (action !== 'do') {
  8916. continue;
  8917. }
  8918. const gleamLink = await this.#getGleamLink(taskText);
  8919. if (!gleamLink) {
  8920. continue;
  8921. }
  8922. this.undoneTasks.extra.gleam.push(gleamLink);
  8923. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-instagram') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-telegram-plane') || socialIcon.hasClass('fa-envelope') || socialIcon.hasClass('fa-gift') || socialIcon.hasClass('fa-shield') && taskText.includes('one of our giveaways') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  8924. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  8925. }
  8926. }
  8927. logStatus.success();
  8928. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8929. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8930. if (window.DEBUG) {
  8931. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8932. }
  8933. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  8934. tasks: this.socialTasks,
  8935. time: new Date().getTime()
  8936. });
  8937. return true;
  8938. } catch (error) {
  8939. throwError(error, 'Gleam.classifyTask');
  8940. return false;
  8941. }
  8942. }
  8943. async extraDoTask(_ref) {
  8944. let {
  8945. gleam
  8946. } = _ref;
  8947. try {
  8948. const pro = [];
  8949. for (const link of gleam) {
  8950. pro.push(this.#doGleamTask(link));
  8951. }
  8952. return Promise.all(pro).then(() => true);
  8953. } catch (error) {
  8954. throwError(error, 'Gleam.extraDoTask');
  8955. return false;
  8956. }
  8957. }
  8958. async verifyTask() {
  8959. try {
  8960. scripts_echoLog({
  8961. text: `${i18n('verifyingTask')}...`
  8962. });
  8963. const tasks = $('.entry-content .entry-method');
  8964. for (const task of tasks) {
  8965. const $task = $(task);
  8966. if ($task.find('i.fa-question').length === 0) {
  8967. continue;
  8968. }
  8969. const taskInfo = $task.find('.user-links');
  8970. taskInfo[0].click();
  8971. await delay(500);
  8972. await this.#checkSync();
  8973. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  8974. for (const button of continueBtn) {
  8975. button.click();
  8976. await delay(500);
  8977. await this.#checkSync();
  8978. }
  8979. }
  8980. scripts_echoLog({
  8981. text: i18n('verifiedGleamTasks')
  8982. });
  8983. } catch (error) {
  8984. throwError(error, 'Gleam.verifyTask');
  8985. return false;
  8986. }
  8987. }
  8988. async #checkSync() {
  8989. try {
  8990. return await new Promise(resolve => {
  8991. const checker = setInterval(() => {
  8992. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  8993. clearInterval(checker);
  8994. resolve(true);
  8995. }
  8996. }, 500);
  8997. });
  8998. } catch (error) {
  8999. throwError(error, 'Gleam.checkSync');
  9000. return false;
  9001. }
  9002. }
  9003. async #doGleamTask(link) {
  9004. try {
  9005. const logStatus = scripts_echoLog({
  9006. text: i18n('doingGleamTask')
  9007. });
  9008. return await new Promise(resolve => {
  9009. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9010. active: true,
  9011. insert: true,
  9012. setParent: true
  9013. }).onclose = () => {
  9014. logStatus.success();
  9015. resolve(true);
  9016. };
  9017. });
  9018. } catch (error) {
  9019. throwError(error, 'Gleam.doGleamTask');
  9020. return false;
  9021. }
  9022. }
  9023. #getGiveawayId() {
  9024. try {
  9025. const giveawayId = window.location.pathname;
  9026. if (giveawayId) {
  9027. this.giveawayId = giveawayId;
  9028. return true;
  9029. }
  9030. scripts_echoLog({
  9031. text: i18n('getFailed', 'GiveawayId')
  9032. });
  9033. return false;
  9034. } catch (error) {
  9035. throwError(error, 'Gleam.getGiveawayId');
  9036. return false;
  9037. }
  9038. }
  9039. async #getGleamLink(title) {
  9040. try {
  9041. const logStatus = scripts_echoLog({
  9042. text: i18n('gettingGleamLink')
  9043. });
  9044. const {
  9045. result,
  9046. statusText,
  9047. status,
  9048. data
  9049. } = await tools_httpRequest({
  9050. url: 'https://www.vloot.io/api/v1/giveaways',
  9051. method: 'GET',
  9052. responseType: 'json'
  9053. });
  9054. if (result === 'Success') {
  9055. var _data$response, _data$response2;
  9056. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.Success) === true && data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.Data) {
  9057. const {
  9058. link
  9059. } = data.response.Data.find(giveaway => title.replace(/[\s]/g, '').toLowerCase().includes(giveaway.title.replace(/[\s]/g, '').toLowerCase())) || {};
  9060. if (link) {
  9061. logStatus.success();
  9062. return link;
  9063. }
  9064. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9065. return false;
  9066. }
  9067. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9068. return false;
  9069. }
  9070. logStatus.error(`${result}:${statusText}(${status})`);
  9071. return false;
  9072. } catch (error) {
  9073. throwError(error, 'Gleam.getGleamLink');
  9074. return false;
  9075. }
  9076. }
  9077. async #checkLeftKey() {
  9078. try {
  9079. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9080. if (!globalOptions.other.checkLeftKey) {
  9081. return true;
  9082. }
  9083. 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];
  9084. if (!campaignString) {
  9085. return false;
  9086. }
  9087. const {
  9088. campaign,
  9089. incentive
  9090. } = JSON.parse(campaignString);
  9091. 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];
  9092. let ownedKey = false;
  9093. if (controllerString) {
  9094. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9095. 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) {
  9096. ownedKey = true;
  9097. }
  9098. }
  9099. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9100. await external_Swal_default().fire({
  9101. icon: 'warning',
  9102. title: i18n('notice'),
  9103. text: i18n('giveawayNotWork'),
  9104. confirmButtonText: i18n('confirm'),
  9105. cancelButtonText: i18n('cancel'),
  9106. showCancelButton: true
  9107. }).then(_ref2 => {
  9108. let {
  9109. value
  9110. } = _ref2;
  9111. if (value) {
  9112. window.close();
  9113. }
  9114. });
  9115. }
  9116. return true;
  9117. } catch (error) {
  9118. throwError(error, 'Gleam.checkLeftKey');
  9119. return false;
  9120. }
  9121. }
  9122. }
  9123. const website_Gleam = Gleam;
  9124. const SweepWidget_defaultOptions = {
  9125. username: '',
  9126. email: ''
  9127. };
  9128. class SweepWidget extends website_Website {
  9129. name = 'SweepWidget';
  9130. options = {
  9131. ...SweepWidget_defaultOptions,
  9132. ...GM_getValue('SweepWidgetOptions')
  9133. };
  9134. buttons = [ 'doTask' ];
  9135. static test() {
  9136. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9137. }
  9138. async after() {
  9139. try {
  9140. if (!this.#checkLogin()) {
  9141. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9142. }
  9143. } catch (error) {
  9144. throwError(error, 'SweepWidget.after');
  9145. }
  9146. }
  9147. init() {
  9148. try {
  9149. const logStatus = scripts_echoLog({
  9150. text: i18n('initing')
  9151. });
  9152. if (!this.#checkLogin()) {
  9153. logStatus.warning(i18n('needLogin'));
  9154. return false;
  9155. }
  9156. if (!this.#getGiveawayId()) {
  9157. return false;
  9158. }
  9159. this.initialized = true;
  9160. logStatus.success();
  9161. return true;
  9162. } catch (error) {
  9163. throwError(error, 'SweepWidget.init');
  9164. return false;
  9165. }
  9166. }
  9167. classifyTask() {
  9168. return true;
  9169. }
  9170. async doTask() {
  9171. try {
  9172. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9173. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9174. $('input[name="sw__login_name"]').val(this.options.username);
  9175. }
  9176. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9177. $('input[name="sw__login_email"]').val(this.options.email);
  9178. }
  9179. if ($('#sw_login_button:visible').length > 0) {
  9180. $('#sw_login_button')[0].click();
  9181. }
  9182. if (!await this.#checkEnter()) {
  9183. return false;
  9184. }
  9185. }
  9186. const logStatus = scripts_echoLog({
  9187. text: i18n('SweepWidgetNotice')
  9188. });
  9189. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9190. for (const task of tasks) {
  9191. var _aElement$, _$task$find$removeAtt;
  9192. const $task = $(task);
  9193. if ($task.find('i.fa-check:visible').length > 0) {
  9194. continue;
  9195. }
  9196. const title = $task.find('.sw_text_inner');
  9197. title[0].click();
  9198. const aElement = $task.find('a.sw_link');
  9199. const link = aElement.attr('href');
  9200. aElement.attr('href', '#a').attr('target', '_self');
  9201. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9202. await delay(300);
  9203. aElement.attr('href', link).attr('target', '_blank');
  9204. $task.find('input[type="text"]').val('test');
  9205. const verifyBtn = $task.find('input.sw_verify');
  9206. if (verifyBtn.prop('disabled') === true) {
  9207. title[0].click();
  9208. await delay(300);
  9209. title[0].click();
  9210. await delay(300);
  9211. }
  9212. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9213. await this.#checkFinish($task);
  9214. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9215. }
  9216. logStatus.success();
  9217. return true;
  9218. } catch (error) {
  9219. throwError(error, 'SweepWidget.doTask');
  9220. return false;
  9221. }
  9222. }
  9223. #checkLogin() {
  9224. try {
  9225. if ($('#twitter_login_button').length > 0) {
  9226. $('#twitter_login_button')[0].click();
  9227. }
  9228. return true;
  9229. } catch (error) {
  9230. throwError(error, 'SweepWidget.checkLogin');
  9231. return false;
  9232. }
  9233. }
  9234. #getGiveawayId() {
  9235. try {
  9236. var _window$location$href;
  9237. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9238. if (giveawayId) {
  9239. this.giveawayId = giveawayId;
  9240. return true;
  9241. }
  9242. scripts_echoLog({
  9243. text: i18n('getFailed', 'GiveawayId')
  9244. });
  9245. return false;
  9246. } catch (error) {
  9247. throwError(error, 'SweepWidget.getGiveawayId');
  9248. return false;
  9249. }
  9250. }
  9251. async #checkEnter() {
  9252. try {
  9253. return new Promise(resolve => {
  9254. const checker = setInterval(() => {
  9255. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9256. clearInterval(checker);
  9257. resolve(true);
  9258. }
  9259. });
  9260. });
  9261. } catch (error) {
  9262. throwError(error, 'SweepWidget.checkEnter');
  9263. return false;
  9264. }
  9265. }
  9266. async #checkFinish($task) {
  9267. try {
  9268. return new Promise(resolve => {
  9269. const checker = setInterval(() => {
  9270. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9271. clearInterval(checker);
  9272. resolve(true);
  9273. }
  9274. });
  9275. });
  9276. } catch (error) {
  9277. throwError(error, 'SweepWidget.checkFinish');
  9278. return false;
  9279. }
  9280. }
  9281. }
  9282. const website_SweepWidget = SweepWidget;
  9283. const defaultWhiteList = {
  9284. discord: {
  9285. servers: []
  9286. },
  9287. instagram: {
  9288. users: []
  9289. },
  9290. twitch: {
  9291. channels: []
  9292. },
  9293. twitter: {
  9294. users: [],
  9295. retweets: [],
  9296. likes: []
  9297. },
  9298. vk: {
  9299. names: []
  9300. },
  9301. youtube: {
  9302. channels: [],
  9303. likes: []
  9304. },
  9305. reddit: {
  9306. reddits: []
  9307. },
  9308. steam: {
  9309. groups: [],
  9310. officialGroups: [],
  9311. wishlists: [],
  9312. follows: [],
  9313. forums: [],
  9314. workshops: [],
  9315. curators: [],
  9316. workshopVotes: [],
  9317. curatorLikes: [],
  9318. announcements: [],
  9319. licenses: [],
  9320. playtests: []
  9321. }
  9322. };
  9323. const link2id = async function(type) {
  9324. 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;
  9325. try {
  9326. const link = $('#socialLink').val();
  9327. let id = '';
  9328. switch (type) {
  9329. case 'discord.servers':
  9330. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9331. break;
  9332.  
  9333. case 'instagram.users':
  9334. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9335. break;
  9336.  
  9337. case 'twitch.channels':
  9338. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9339. break;
  9340.  
  9341. case 'twitter.users':
  9342. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9343. break;
  9344.  
  9345. case 'twitter.retweets':
  9346. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9347. break;
  9348.  
  9349. case 'vk.names':
  9350. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9351. break;
  9352.  
  9353. case 'youtube.channels':
  9354. 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) || '';
  9355. break;
  9356.  
  9357. case 'youtube.likes':
  9358. 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) || '';
  9359. break;
  9360.  
  9361. case 'reddit.reddits':
  9362. 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]) || '';
  9363. break;
  9364.  
  9365. case 'steam.groups':
  9366. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9367. break;
  9368.  
  9369. case 'steam.wishlists':
  9370. case 'steam.follows':
  9371. case 'steam.forums':
  9372. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9373. break;
  9374.  
  9375. case 'steam.workshops':
  9376. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9377. break;
  9378.  
  9379. case 'steam.curators':
  9380. {
  9381. if (link.includes('curator')) {
  9382. var _link$match12;
  9383. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9384. } else {
  9385. var _link$match13;
  9386. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9387. if (!param || param.length !== 2) {
  9388. break;
  9389. }
  9390. const steam = new social_Steam();
  9391. if (await steam.init()) {
  9392. id = await steam.getCuratorId(param[0], param[1]) || '';
  9393. }
  9394. }
  9395. }
  9396. break;
  9397. }
  9398. return id;
  9399. } catch (error) {
  9400. throwError(error, 'link2id');
  9401. return i18n('getFailed', 'id');
  9402. }
  9403. };
  9404. const disabledType = {
  9405. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9406. twitter: [ 'likes' ]
  9407. };
  9408. const assignWhiteList = whiteList => {
  9409. try {
  9410. const newWhiteList = {};
  9411. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  9412. newWhiteList[key] = {
  9413. ...value,
  9414. ...whiteList[key]
  9415. };
  9416. }
  9417. return newWhiteList;
  9418. } catch (error) {
  9419. throwError(error, 'assignWhiteList');
  9420. return defaultWhiteList;
  9421. }
  9422. };
  9423. const whiteListOptions = function(showType) {
  9424. try {
  9425. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  9426. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9427. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9428. for (const [ social, types ] of Object.entries(whiteList)) {
  9429. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9430. var _disabledType$social;
  9431. 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>`;
  9432. }).join('');
  9433. }
  9434. whiteListOptionsForm += '</tbody></table></form>';
  9435. if (showType === 'swal') {
  9436. external_Swal_default().fire({
  9437. title: i18n('whiteListOptions'),
  9438. html: whiteListOptionsForm,
  9439. showConfirmButton: false,
  9440. showCloseButton: true
  9441. });
  9442. } else {
  9443. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9444. }
  9445. $('.editWhiteList').on('click', function() {
  9446. var _whiteList$social;
  9447. const value = $(this).attr('data-value');
  9448. if (!value) {
  9449. return;
  9450. }
  9451. const [ social, type ] = value.split('.');
  9452. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9453. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9454. return;
  9455. }
  9456. external_Swal_default().fire({
  9457. title: i18n('changeWhiteListOption', value),
  9458. input: 'textarea',
  9459. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9460. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9461. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9462. inputValue: whiteList[social][type].join('\n'),
  9463. showConfirmButton: true,
  9464. confirmButtonText: i18n('save'),
  9465. showCancelButton: true,
  9466. cancelButtonText: i18n('close'),
  9467. showDenyButton: true,
  9468. denyButtonText: i18n('return')
  9469. }).then(_ref => {
  9470. let {
  9471. isDenied,
  9472. isConfirmed,
  9473. value
  9474. } = _ref;
  9475. if (isDenied) {
  9476. if (showType === 'swal') {
  9477. whiteListOptions(showType);
  9478. }
  9479. return;
  9480. } else if (isConfirmed) {
  9481. whiteList[social][type] = value.split('\n');
  9482. GM_setValue('whiteList', whiteList);
  9483. external_Swal_default().fire({
  9484. title: i18n('changeWhiteListSuccess'),
  9485. icon: 'success'
  9486. });
  9487. }
  9488. });
  9489. $('#link2id').on('click', async function() {
  9490. const type = $(this).attr('data-type');
  9491. $('#socialLink').val(await link2id(type));
  9492. });
  9493. });
  9494. } catch (error) {
  9495. throwError(error, 'whiteListOptions');
  9496. }
  9497. };
  9498. const whiteList = whiteListOptions;
  9499. const setGistData = async (token, gistId, fileName, content) => {
  9500. try {
  9501. const logStatus = scripts_echoLog({
  9502. text: i18n('settingData')
  9503. });
  9504. const contentData = JSON.stringify({
  9505. files: {
  9506. [fileName]: {
  9507. content: JSON.stringify(content)
  9508. }
  9509. }
  9510. });
  9511. const {
  9512. result,
  9513. statusText,
  9514. status,
  9515. data
  9516. } = await tools_httpRequest({
  9517. url: `https://api.github.com/gists/${gistId}`,
  9518. headers: {
  9519. Accept: 'application/vnd.github.v3+json',
  9520. Authorization: `token ${token}`
  9521. },
  9522. data: contentData,
  9523. responseType: 'json',
  9524. method: 'POST',
  9525. timeout: 3e4
  9526. });
  9527. if (result === 'Success') {
  9528. var _data$response$files, _data$response$files$;
  9529. 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)) {
  9530. logStatus.success();
  9531. return true;
  9532. }
  9533. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9534. return false;
  9535. }
  9536. logStatus.error(`${result}:${statusText}(${status})`);
  9537. return false;
  9538. } catch (error) {
  9539. throwError(error, 'setGistData');
  9540. return false;
  9541. }
  9542. };
  9543. const getGistData = async function(token, gistId, fileName) {
  9544. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9545. try {
  9546. const logStatus = scripts_echoLog({
  9547. text: i18n('gettingData')
  9548. });
  9549. const {
  9550. result,
  9551. statusText,
  9552. status,
  9553. data
  9554. } = await tools_httpRequest({
  9555. url: `https://api.github.com/gists/${gistId}`,
  9556. headers: {
  9557. Accept: 'application/vnd.github.v3+json',
  9558. Authorization: `token ${token}`
  9559. },
  9560. responseType: 'json',
  9561. method: 'GET',
  9562. timeout: 3e4
  9563. });
  9564. if (result === 'Success') {
  9565. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9566. var _data$response, _data$response$files2, _data$response$files3;
  9567. const content = (_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$files2 = _data$response.files) === null || _data$response$files2 === void 0 ? void 0 : (_data$response$files3 = _data$response$files2[fileName]) === null || _data$response$files3 === void 0 ? void 0 : _data$response$files3.content;
  9568. let formatedContent;
  9569. if (!content) {
  9570. logStatus.error(`Error:${i18n('noRemoteData')}`);
  9571. return false;
  9572. }
  9573. if (test) {
  9574. logStatus.success();
  9575. return true;
  9576. }
  9577. try {
  9578. formatedContent = JSON.parse(content);
  9579. } catch (error) {
  9580. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  9581. return false;
  9582. }
  9583. logStatus.success();
  9584. return formatedContent;
  9585. }
  9586. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9587. return false;
  9588. }
  9589. logStatus.error(`${result}:${statusText}(${status})`);
  9590. return false;
  9591. } catch (error) {
  9592. throwError(error, 'getGistData');
  9593. return false;
  9594. }
  9595. };
  9596. const syncOptions = () => {
  9597. try {
  9598. const {
  9599. TOKEN,
  9600. GIST_ID,
  9601. FILE_NAME,
  9602. SYNC_HISTORY
  9603. } = GM_getValue('gistOptions') || {
  9604. TOKEN: '',
  9605. GIST_ID: '',
  9606. FILE_NAME: '',
  9607. SYNC_HISTORY: true
  9608. };
  9609. external_Swal_default().fire({
  9610. title: i18n('gistOptions'),
  9611. 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;">
  9612. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9613. ${i18n('downloadFromGist')}</button></p>`,
  9614. focusConfirm: false,
  9615. showLoaderOnConfirm: true,
  9616. 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>`,
  9617. preConfirm: async () => {
  9618. const token = $('#github-token').val();
  9619. const gistId = $('#gist-id').val();
  9620. const fileName = $('#file-name').val();
  9621. const syncHistory = $('#sync-history').prop('checked');
  9622. GM_setValue('gistOptions', {
  9623. TOKEN: token,
  9624. GIST_ID: gistId,
  9625. FILE_NAME: fileName,
  9626. SYNC_HISTORY: syncHistory
  9627. });
  9628. return await getGistData(token, gistId, fileName, true);
  9629. },
  9630. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9631. confirmButtonText: i18n('saveAndTest'),
  9632. showCancelButton: true,
  9633. cancelButtonText: i18n('close')
  9634. }).then(_ref => {
  9635. let {
  9636. value
  9637. } = _ref;
  9638. if (value) {
  9639. external_Swal_default().fire({
  9640. icon: 'success',
  9641. title: i18n('testSuccess')
  9642. }).then(syncOptions);
  9643. } else if (value !== undefined) {
  9644. external_Swal_default().fire({
  9645. icon: 'error',
  9646. title: i18n('testFailed')
  9647. }).then(syncOptions);
  9648. }
  9649. });
  9650. $('#upload-data').on('click', async () => {
  9651. const {
  9652. TOKEN,
  9653. GIST_ID,
  9654. FILE_NAME
  9655. } = GM_getValue('gistOptions') || {};
  9656. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9657. return external_Swal_default().fire({
  9658. icon: 'error',
  9659. title: i18n('saveAndTestNotice')
  9660. }).then(syncOptions);
  9661. }
  9662. external_Swal_default().fire({
  9663. icon: 'info',
  9664. title: i18n('processingData')
  9665. });
  9666. const data = {};
  9667. const names = GM_listValues();
  9668. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9669. for (const name of names) {
  9670. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9671. continue;
  9672. }
  9673. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9674. continue;
  9675. }
  9676. data[name] = GM_getValue(name);
  9677. }
  9678. external_Swal_default().update({
  9679. icon: 'info',
  9680. title: i18n('updatingData')
  9681. });
  9682. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9683. external_Swal_default().fire({
  9684. icon: 'success',
  9685. title: i18n('syncDataSuccess')
  9686. });
  9687. } else {
  9688. external_Swal_default().fire({
  9689. icon: 'error',
  9690. title: i18n('syncDataFailed')
  9691. });
  9692. }
  9693. });
  9694. $('#download-data').on('click', async () => {
  9695. const {
  9696. TOKEN,
  9697. GIST_ID,
  9698. FILE_NAME
  9699. } = GM_getValue('gistOptions') || {};
  9700. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9701. return external_Swal_default().fire({
  9702. icon: 'error',
  9703. title: i18n('saveAndTestNotice')
  9704. }).then(syncOptions);
  9705. }
  9706. external_Swal_default().fire({
  9707. icon: 'info',
  9708. title: i18n('downloadingData')
  9709. });
  9710. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9711. if (!data) {
  9712. return external_Swal_default().fire({
  9713. icon: 'error',
  9714. title: i18n('checkedNoData')
  9715. }).then(syncOptions);
  9716. }
  9717. external_Swal_default().update({
  9718. icon: 'info',
  9719. title: i18n('savingData')
  9720. });
  9721. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9722. for (const [ name, value ] of Object.entries(data)) {
  9723. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9724. continue;
  9725. }
  9726. GM_setValue(name, value);
  9727. }
  9728. external_Swal_default().fire({
  9729. icon: 'success',
  9730. title: i18n('syncDataSuccess')
  9731. });
  9732. });
  9733. } catch (error) {
  9734. throwError(error, 'syncOptions');
  9735. }
  9736. };
  9737. const dataSync = syncOptions;
  9738. class Setting {
  9739. name = 'Setting';
  9740. buttons = [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ];
  9741. syncData = dataSync;
  9742. tasksHistory() {
  9743. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  9744. }
  9745. static test() {
  9746. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  9747. }
  9748. before() {
  9749. $('body').html('').addClass('auto-task-options');
  9750. }
  9751. after() {
  9752. try {
  9753. this.#environment();
  9754. changeGlobalOptions('page');
  9755. whiteList('page');
  9756. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  9757. $('#getTwitterUserId').on('click', () => {
  9758. this.#getId('twitterUser');
  9759. });
  9760. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  9761. $('#getYoutubeChannelId').on('click', () => {
  9762. this.#getId('youtubeChannel');
  9763. });
  9764. $('input[name^="position"]').on('input', function() {
  9765. const type = $(this).attr('name').replace('position.', '');
  9766. const xLabel = 'rightleft';
  9767. const yLabel = 'topbottpm';
  9768. switch (type) {
  9769. case 'buttonSideX':
  9770. case 'buttonSideY':
  9771. case 'buttonDistance':
  9772. {
  9773. const distance = $('input[name="position.buttonDistance"]').val();
  9774. const sideX = $('input[name="position.buttonSideX"]').val();
  9775. const sideY = $('input[name="position.buttonSideY"]').val();
  9776. if (![ 'right', 'left' ].includes(sideX)) {
  9777. break;
  9778. }
  9779. if (![ 'top', 'bottom' ].includes(sideY)) {
  9780. break;
  9781. }
  9782. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9783. break;
  9784. }
  9785. const distanceArr = distance.split(',');
  9786. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9787. break;
  9788. }
  9789.  
  9790. case 'showButtonSideX':
  9791. case 'showButtonSideY':
  9792. case 'showButtonDistance':
  9793. {
  9794. const distance = $('input[name="position.showButtonDistance"]').val();
  9795. const sideX = $('input[name="position.showButtonSideX"]').val();
  9796. const sideY = $('input[name="position.showButtonSideY"]').val();
  9797. if (![ 'right', 'left' ].includes(sideX)) {
  9798. break;
  9799. }
  9800. if (![ 'top', 'bottom' ].includes(sideY)) {
  9801. break;
  9802. }
  9803. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9804. break;
  9805. }
  9806. const distanceArr = distance.split(',');
  9807. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9808. break;
  9809. }
  9810.  
  9811. case 'logSideX':
  9812. case 'logSideY':
  9813. case 'logDistance':
  9814. {
  9815. const distance = $('input[name="position.logDistance"]').val();
  9816. const sideX = $('input[name="position.logSideX"]').val();
  9817. const sideY = $('input[name="position.logSideY"]').val();
  9818. if (![ 'right', 'left' ].includes(sideX)) {
  9819. break;
  9820. }
  9821. if (![ 'top', 'bottom' ].includes(sideY)) {
  9822. break;
  9823. }
  9824. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9825. break;
  9826. }
  9827. const distanceArr = distance.split(',');
  9828. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9829. break;
  9830. }
  9831.  
  9832. default:
  9833. break;
  9834. }
  9835. });
  9836. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  9837. let functionKey = '';
  9838. if (event.altKey) {
  9839. functionKey += 'alt + ';
  9840. } else if (event.ctrlKey) {
  9841. functionKey += 'ctrl + ';
  9842. } else if (event.shiftKey) {
  9843. functionKey += 'shift + ';
  9844. }
  9845. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  9846. });
  9847. } catch (error) {
  9848. throwError(error, 'Setting.after');
  9849. }
  9850. }
  9851. saveGlobalOptions() {
  9852. saveData();
  9853. }
  9854. #getId(social) {
  9855. try {
  9856. external_Swal_default().fire({
  9857. title: i18n('getId', i18n(social)),
  9858. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9859. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  9860. showCancelButton: true,
  9861. cancelButtonText: i18n('close'),
  9862. showConfirmButton: false
  9863. });
  9864. $('#link2id').on('click', async function() {
  9865. const link = $('#socialLink').val();
  9866. if (!link) {
  9867. return;
  9868. }
  9869. const type = $(this).attr('data-type');
  9870. if (type === 'twitterUser') {
  9871. var _link$match;
  9872. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  9873. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  9874. } else if (type === 'youtubeChannel') {
  9875. var _link$match2, _await$getInfo, _await$getInfo$params;
  9876. 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;
  9877. $('#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) || '');
  9878. }
  9879. });
  9880. } catch (error) {
  9881. throwError(error, 'Setting.getId');
  9882. }
  9883. }
  9884. #environment() {
  9885. try {
  9886. const userAgent = (0, javascript_utils_umd_min.ua)();
  9887. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  9888. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  9889. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  9890. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  9891. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  9892. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  9893. </tbody></table></form>`;
  9894. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  9895. } catch (error) {
  9896. throwError(error, 'Setting.environment');
  9897. }
  9898. }
  9899. }
  9900. const website_Setting = Setting;
  9901. class History extends website_Keylol {
  9902. name = 'History';
  9903. buttons = [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ];
  9904. static test() {
  9905. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  9906. }
  9907. before() {
  9908. try {
  9909. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  9910. const data = GM_listValues() || [];
  9911. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9912. for (const item of tasksHistory) {
  9913. this.#addItem(item);
  9914. }
  9915. } catch (error) {
  9916. throwError(error, 'History.before');
  9917. }
  9918. }
  9919. clearHistory() {
  9920. try {
  9921. const data = GM_listValues() || [];
  9922. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9923. for (const item of tasksHistory) {
  9924. GM_deleteValue(item);
  9925. }
  9926. external_Swal_default().fire({
  9927. title: i18n('clearHistoryFinished'),
  9928. icon: 'success'
  9929. });
  9930. } catch (error) {
  9931. throwError(error, 'History.after');
  9932. }
  9933. }
  9934. #addItem(item) {
  9935. try {
  9936. const tasksData = GM_getValue(item);
  9937. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  9938. return;
  9939. }
  9940. let html = '';
  9941. let title = '';
  9942. let link = '';
  9943. const [ website, id ] = item.split('-');
  9944. switch (website) {
  9945. case 'fawTasks':
  9946. title = `Freeanywhere[${id}]`;
  9947. link = `https://freeanywhere.net/#/giveaway/${id}`;
  9948. break;
  9949.  
  9950. case 'gasTasks':
  9951. title = `Giveawaysu[${id}]`;
  9952. link = `https://giveaway.su/giveaway/view/${id}`;
  9953. break;
  9954.  
  9955. case 'gcTasks':
  9956. title = `GiveeClub[${id}]`;
  9957. link = `https://givee.club/event/${id}`;
  9958. break;
  9959.  
  9960. case 'gkTasks':
  9961. title = `Givekey[${id}]`;
  9962. link = `https://givekey.ru/giveaway/${id}`;
  9963. break;
  9964.  
  9965. case 'gleamTasks':
  9966. title = `Gleam[${id}]`;
  9967. link = `https://gleam.io${id}`;
  9968. break;
  9969.  
  9970. case 'khTasks':
  9971. title = `keyhub[${id}]`;
  9972. link = `https://key-hub.eu/giveaway/${id}`;
  9973. break;
  9974.  
  9975. case 'prysTasks':
  9976. title = `Prys[${id}]`;
  9977. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  9978. break;
  9979.  
  9980. default:
  9981. return;
  9982. }
  9983. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  9984. for (const [ type, tasks ] of Object.entries(types)) {
  9985. for (const task of tasks) {
  9986. 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>`;
  9987. }
  9988. }
  9989. }
  9990. $('.container').append(`<div class="card" data-name="${item}"><div class="title"><a href="${link}" target="_blank">${title}</a><span class="delete-task" data-name="${item}" title="${i18n('deleteTask')}"><svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2734" width="32" height="32"><path d="M607.897867 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L575.903242 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 351.94087C639.892491 753.593818 625.61532 768.043004 607.897867 768.043004z" p-id="2735" fill="#d81e06"></path><path d="M415.930119 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L383.935495 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625 17.717453 0 31.994625 14.277171 31.994625 31.994625l0 351.94087C447.924744 753.593818 433.647573 768.043004 415.930119 768.043004z" p-id="2736" fill="#d81e06"></path><path d="M928.016126 223.962372l-159.973123 0L768.043004 159.973123c0-52.980346-42.659499-95.983874-95.295817-95.983874L351.94087 63.989249c-52.980346 0-95.983874 43.003528-95.983874 95.983874l0 63.989249-159.973123 0c-17.717453 0-31.994625 14.277171-31.994625 31.994625s14.277171 31.994625 31.994625 31.994625l832.032253 0c17.717453 0 31.994625-14.277171 31.994625-31.994625S945.73358 223.962372 928.016126 223.962372zM319.946246 159.973123c0-17.545439 14.449185-31.994625 31.994625-31.994625l320.806316 0c17.545439 0 31.306568 14.105157 31.306568 31.994625l0 63.989249L319.946246 223.962372 319.946246 159.973123 319.946246 159.973123z" p-id="2737" fill="#d81e06"></path><path d="M736.048379 960.010751 288.123635 960.010751c-52.980346 0-95.983874-43.003528-95.983874-95.983874L192.139761 383.591466c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 480.435411c0 17.717453 14.449185 31.994625 31.994625 31.994625l448.096758 0c17.717453 0 31.994625-14.277171 31.994625-31.994625L768.215018 384.795565c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 479.231312C832.032253 916.835209 789.028725 960.010751 736.048379 960.010751z" p-id="2738" fill="#d81e06"></path></svg></span></div><ul>${html}</ul><span class="time">${i18n('lastChangeTime')}: ${external_dayjs_namespaceObject(tasksData.time).format('YYYY-MM-DD HH:mm:ss')}</span></div>`);
  9991. $('span.delete-task').on('click', function() {
  9992. const itemName = $(this).attr('data-name');
  9993. if (itemName) {
  9994. GM_deleteValue(itemName);
  9995. $(`div.card[data-name="${itemName}"]`).remove();
  9996. external_Swal_default().fire({
  9997. title: i18n('clearTaskFinished'),
  9998. text: itemName,
  9999. icon: 'success'
  10000. });
  10001. } else {
  10002. external_Swal_default().fire({
  10003. title: i18n('clearTaskFailed'),
  10004. icon: 'error'
  10005. });
  10006. }
  10007. });
  10008. } catch (error) {
  10009. throwError(error, 'History.addItem');
  10010. }
  10011. }
  10012. }
  10013. const website_History = History;
  10014. 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 ];
  10015. const websiteOptions = function(website, options) {
  10016. try {
  10017. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10018. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10019. for (const [ option, value ] of Object.entries(options)) {
  10020. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10021. }
  10022. websiteOptionsForm += '</tbody></table></form>';
  10023. external_Swal_default().fire({
  10024. title: i18n('websiteOptions'),
  10025. html: websiteOptionsForm,
  10026. showConfirmButton: true,
  10027. confirmButtonText: i18n('save'),
  10028. showCancelButton: true,
  10029. cancelButtonText: i18n('close')
  10030. }).then(_ref => {
  10031. let {
  10032. isConfirmed
  10033. } = _ref;
  10034. if (isConfirmed) {
  10035. $('#websiteOptionsForm').serializeArray().map(value => {
  10036. options[value.name] = value.value;
  10037. return value;
  10038. });
  10039. GM_setValue(`${website}Options`, options);
  10040. external_Swal_default().fire({
  10041. title: i18n('changeWebsiteOptionsSuccess'),
  10042. icon: 'success'
  10043. });
  10044. }
  10045. });
  10046. } catch (error) {
  10047. throwError(error, 'websiteOptions');
  10048. }
  10049. };
  10050. const options = websiteOptions;
  10051. const external_keyboardJS_namespaceObject = keyboardJS;
  10052. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10053. const checkUpdate = async (updateLink, auto) => {
  10054. try {
  10055. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10056. const {
  10057. result,
  10058. statusText,
  10059. status,
  10060. data
  10061. } = await tools_httpRequest({
  10062. url: checkUrl,
  10063. responseType: 'json',
  10064. method: 'GET',
  10065. timeout: 3e4
  10066. });
  10067. if (result === 'Success') {
  10068. var _data$response;
  10069. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10070. return data.response;
  10071. }
  10072. if (!auto) {
  10073. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10074. }
  10075. return false;
  10076. }
  10077. if (!auto) {
  10078. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10079. }
  10080. return false;
  10081. } catch (error) {
  10082. throwError(error, 'checkUpdate');
  10083. return false;
  10084. }
  10085. };
  10086. const hasNewVersion = (currentVersion, remoteVersion) => {
  10087. try {
  10088. const [ currentRealVersion ] = currentVersion.split('-');
  10089. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  10090. if (isPreview && !globalOptions.other.receivePreview) {
  10091. return false;
  10092. }
  10093. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10094. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10095. if (remoteVersion1 > currentVersion1) {
  10096. return true;
  10097. }
  10098. if (remoteVersion1 < currentVersion1) {
  10099. return false;
  10100. }
  10101. if (remoteVersion2 > currentVersion2) {
  10102. return true;
  10103. }
  10104. if (remoteVersion2 < currentVersion2) {
  10105. return false;
  10106. }
  10107. if (remoteVersion3 > currentVersion3) {
  10108. return true;
  10109. }
  10110. return false;
  10111. } catch (error) {
  10112. throwError(error, 'compareVersion');
  10113. return false;
  10114. }
  10115. };
  10116. const updateChecker = async () => {
  10117. try {
  10118. const currentVersion = GM_info.script.version;
  10119. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10120. const updateLinks = {
  10121. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10122. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10123. standby: 'https://auto-task-v4.hclonely.com/'
  10124. };
  10125. let version;
  10126. let updateLink = '';
  10127. let packageData;
  10128. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10129. updateLink = updateLinks[updateSource];
  10130. packageData = await checkUpdate(updateLink, false);
  10131. } else {
  10132. updateLink = updateLinks.github;
  10133. packageData = await checkUpdate(updateLink, true);
  10134. if (!packageData) {
  10135. updateLink = updateLinks.jsdelivr;
  10136. packageData = await checkUpdate(updateLink, true);
  10137. if (!packageData) {
  10138. updateLink = updateLinks.standby;
  10139. packageData = await checkUpdate(updateLink, true);
  10140. }
  10141. }
  10142. }
  10143. if (packageData) {
  10144. version = packageData.version || currentVersion;
  10145. } else {
  10146. version = currentVersion;
  10147. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10148. }
  10149. if (packageData && hasNewVersion(currentVersion, version)) {
  10150. var _packageData$change;
  10151. scripts_echoLog({
  10152. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10153. });
  10154. scripts_echoLog({
  10155. html: `<li>${i18n('updateText', version)}</li><ol class="update-text">${(_packageData$change = packageData.change) === null || _packageData$change === void 0 ? void 0 : _packageData$change.map(change => `<li>${change}</li>`).join('')}<li>${i18n('updateHistory')}</li></ol>`
  10156. });
  10157. }
  10158. } catch (error) {
  10159. throwError(error, 'updateChecker');
  10160. }
  10161. };
  10162. const scripts_updateChecker = updateChecker;
  10163. var _globalOptions$other, _globalOptions$other2;
  10164. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  10165. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  10166. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  10167. const loadScript = async () => {
  10168. var _website, _website2, _website3, _website4, _website5, _website6;
  10169. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10170. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10171. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10172. if (isLogin) {
  10173. var _commonOptions, _commonOptions$header, _commonOptions2, _commonOptions2$heade;
  10174. GM_setValue('twitchAuth', {
  10175. authToken: authToken,
  10176. clientVersion: __twilightBuildID,
  10177. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID'],
  10178. deviceId: (_commonOptions2 = commonOptions) === null || _commonOptions2 === void 0 ? void 0 : (_commonOptions2$heade = _commonOptions2.headers) === null || _commonOptions2$heade === void 0 ? void 0 : _commonOptions2$heade['Device-ID'],
  10179. clientSessionId: window.localStorage.local_storage_app_session_id.replace(/"/g, '')
  10180. });
  10181. window.close();
  10182. external_Swal_default().fire('', i18n('closePageNotice'));
  10183. } else {
  10184. external_Swal_default().fire('', i18n('needLogin'));
  10185. }
  10186. return;
  10187. }
  10188. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10189. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10190. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10191. if (isLogin && ct0) {
  10192. GM_setValue('twitterAuth', {
  10193. ct0: ct0
  10194. });
  10195. window.close();
  10196. external_Swal_default().fire('', i18n('closePageNotice'));
  10197. } else {
  10198. external_Swal_default().fire('', i18n('needLogin'));
  10199. }
  10200. return;
  10201. }
  10202. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10203. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10204. if (PAPISID) {
  10205. GM_setValue('youtubeAuth', {
  10206. PAPISID: PAPISID
  10207. });
  10208. window.close();
  10209. external_Swal_default().fire('', i18n('closePageNotice'));
  10210. } else {
  10211. external_Swal_default().fire('', i18n('needLogin'));
  10212. }
  10213. return;
  10214. }
  10215. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10216. const betaButton = $('#redesign-beta-optin-btn');
  10217. if (betaButton.length > 0) {
  10218. GM_setValue('redditAuth', '#auth');
  10219. return betaButton[0].click();
  10220. }
  10221. GM_setValue('redditAuth', null);
  10222. window.close();
  10223. external_Swal_default().fire('', i18n('closePageNotice'));
  10224. return;
  10225. }
  10226. let website;
  10227. for (const Website of Websites) {
  10228. if (Website.test()) {
  10229. website = new Website();
  10230. break;
  10231. }
  10232. }
  10233. if (!website) {
  10234. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  10235. return;
  10236. }
  10237. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10238. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10239. }
  10240. $('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>`);
  10241. $('div.show-button-div').on('click', () => {
  10242. $('#auto-task-buttons').show();
  10243. $('div.show-button-div').hide();
  10244. });
  10245. const toggleLog = () => {
  10246. const $this = $('#toggle-log');
  10247. const status = $this.attr('data-status');
  10248. if (status === 'show') {
  10249. $('#auto-task-info').hide();
  10250. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10251. } else {
  10252. $('#auto-task-info').show();
  10253. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10254. }
  10255. };
  10256. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10257. if (website.doTask) {
  10258. website.doTask();
  10259. }
  10260. });
  10261. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10262. if (website.undoTask) {
  10263. website.doTask();
  10264. }
  10265. });
  10266. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10267. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10268. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10269. }
  10270. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10271. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10272. for (const button of website.buttons) {
  10273. if (website[button]) {
  10274. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10275. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10276. website[button]();
  10277. });
  10278. $('#auto-task-buttons').append(btnElement);
  10279. }
  10280. }
  10281. }
  10282. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10283. ${i18n('hideButton')}</a></p>`);
  10284. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10285. $('#auto-task-buttons').hide();
  10286. $('div.show-button-div').show();
  10287. });
  10288. 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'}">
  10289. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10290. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10291. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10292. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10293. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10294. options(website.name, website.options);
  10295. });
  10296. }
  10297. if (website.name !== 'Setting') {
  10298. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10299. changeGlobalOptions('swal');
  10300. });
  10301. GM_registerMenuCommand(i18n('settingPage'), () => {
  10302. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10303. });
  10304. }
  10305. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  10306. if (!GM_getValue('notice')) {
  10307. var _echoLog$font;
  10308. external_Swal_default().fire({
  10309. title: i18n('swalNotice'),
  10310. icon: 'warning'
  10311. }).then(() => {
  10312. window.open(i18n('noticeLink'), '_blank');
  10313. GM_setValue('notice', new Date().getTime());
  10314. });
  10315. (_echoLog$font = scripts_echoLog({
  10316. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10317. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10318. GM_setValue('notice', new Date().getTime());
  10319. });
  10320. }
  10321. scripts_updateChecker();
  10322. };
  10323. if (window.location.hostname === 'discord.com') {
  10324. const LocalStorage = window.localStorage;
  10325. if (window.location.hash === '#auth') {
  10326. var _LocalStorage$getItem;
  10327. window.localStorage.removeItem = () => true;
  10328. const discordAuth = LocalStorage === null || LocalStorage === void 0 ? void 0 : (_LocalStorage$getItem = LocalStorage.getItem('token')) === null || _LocalStorage$getItem === void 0 ? void 0 : _LocalStorage$getItem.replace(/^"|"$/g, '');
  10329. if (discordAuth && discordAuth.length > 0) {
  10330. GM_setValue('discordAuth', {
  10331. auth: discordAuth
  10332. });
  10333. window.close();
  10334. external_Swal_default().fire('', i18n('closePageNotice'));
  10335. } else {
  10336. external_Swal_default().fire({
  10337. text: i18n('getDiscordAuthFailed'),
  10338. icon: 'error'
  10339. });
  10340. }
  10341. } else {
  10342. var _LocalStorage$getItem2;
  10343. const discordAuth = LocalStorage === null || LocalStorage === void 0 ? void 0 : (_LocalStorage$getItem2 = LocalStorage.getItem('token')) === null || _LocalStorage$getItem2 === void 0 ? void 0 : _LocalStorage$getItem2.replace(/^"|"$/g, '');
  10344. if (discordAuth && discordAuth.length > 0) {
  10345. GM_setValue('discordAuth', {
  10346. auth: discordAuth
  10347. });
  10348. }
  10349. }
  10350. } else if (window.location.hostname === 'opquests.com') {
  10351. loadScript();
  10352. } else {
  10353. if (window.location.hostname === 'key-hub.eu') {
  10354. unsafeWindow.keyhubtracker = 1;
  10355. unsafeWindow.gaData = {};
  10356. }
  10357. $(loadScript);
  10358. }
  10359. }();
  10360. })();