auto-task-v4

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

目前为 2022-06-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.2.13
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12. // @icon https://auto-task-v4.hclonely.com/favicon.ico
  13.  
  14. // @include *://freeanywhere.net/*
  15. // @include *://giveaway.su/giveaway/view/*
  16. // @include *://givee.club/*/event/*
  17. // @include *://givekey.ru/giveaway/*
  18. // @include *://www.indiedb.com/giveaways*
  19. // @include *://key-hub.eu/giveaway/*
  20. // @include *://keylol.com/*
  21. // @include *://www.opiumpulses.com/giveaways
  22. // @include *://prys.revadike.com/giveaway/?id=*
  23. // @include *://opquests.com/quests/*
  24. // @include *://gleam.io/*
  25. // @include *://sweepwidget.com/view/*
  26. // @include *://discord.com/*
  27. // @include *://www.twitch.tv/*
  28. // @include *://www.youtube.com/*
  29. // @include *://*.reddit.com/*
  30. // @include *://twitter.com/settings/account?k*
  31. // @include https://auto-task-v4.hclonely.com/setting.html
  32. // @include https://auto-task-v4.hclonely.com/history.html
  33.  
  34. // @grant GM_setValue
  35. // @grant GM_getValue
  36. // @grant GM_listValues
  37. // @grant GM_deleteValue
  38. // @grant GM_addStyle
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_info
  42. // @grant GM_openInTab
  43. // @grant GM_setClipboard
  44. // @grant GM_getResourceText
  45. // @grant unsafeWindow
  46. // @grant window.close
  47. // @grant window.localStorage
  48.  
  49. // @connect cdn.jsdelivr.net
  50. // @connect store.steampowered.com
  51. // @connect steamcommunity.com
  52. // @connect twitter.com
  53. // @connect api.twitter.com
  54. // @connect youtube.com
  55. // @connect www.youtube.com
  56. // @connect facebook.com
  57. // @connect instagram.com
  58. // @connect vk.com
  59. // @connect twitch.tv
  60. // @connect www.twitch.tv
  61. // @connect gql.twitch.tv
  62. // @connect github.com
  63. // @connect discordapp.com
  64. // @connect discord.gg
  65. // @connect discord.com
  66. // @connect www.reddit.com
  67. // @connect oauth.reddit.com
  68. // @connect raw.githubusercontent.com
  69. // @connect t.me
  70. // @connect bit.ly
  71. // @connect giveaway.su
  72. // @connect google.com
  73. // @connect www.vloot.io
  74. // @connect givee.club
  75. // @connect gleam.io
  76. // @connect www.indiedb.com
  77. // @connect key-hub.eu
  78. // @connect opquests.com
  79. // @connect itch.io
  80. // @connect auto-task-v4.hclonely.com
  81. // @connect *
  82. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  83. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  84. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  85. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  86. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js
  87. // @resource style https://cdn.jsdelivr.net/npm/sweetalert2@11.3.5/dist/sweetalert2.min.css
  88. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  89. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  90.  
  91. // @noframes
  92. // ==/UserScript==
  93.  
  94. console.log('%c%s', 'color:blue', 'Auto-Task[Load]: 脚本开始加载');
  95.  
  96. (function() {
  97. var __webpack_modules__ = {
  98. 514: function(__unused_webpack_module, exports) {
  99. !function(e, n) {
  100. true ? n(exports) : 0;
  101. }(this, function(e) {
  102. 'use strict';
  103. var t = function() {
  104. return (t = Object.assign || function(e) {
  105. for (var n, o = 1, t = arguments.length; o < t; o++) {
  106. for (var r in n = arguments[o]) {
  107. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  108. }
  109. }
  110. return e;
  111. }).apply(this, arguments);
  112. };
  113. function r(e, n, o) {
  114. if (o || 2 === arguments.length) {
  115. for (var t, r = 0, i = n.length; r < i; r++) {
  116. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  117. }
  118. }
  119. return e.concat(t || Array.prototype.slice.call(n));
  120. }
  121. function d(e) {
  122. return '[object Object]' === n(e);
  123. }
  124. function l(e, n) {
  125. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  126. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  127. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  128. });
  129. }
  130. var n = function(e) {
  131. return Object.prototype.toString.call(e);
  132. };
  133. var o = (i.prototype.init = function() {
  134. try {
  135. this.getSystemName(), this.getBrowserName();
  136. } catch (e) {
  137. console.warn('[UA formatter error] '.concat(e));
  138. }
  139. }, i.prototype.getEngine = function() {
  140. var e = this.agent;
  141. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  142. }, i.prototype.getSystemName = function() {
  143. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  144. try {
  145. var o = '';
  146. if (/Windows/i.test(n)) {
  147. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  148. switch (this.info.os = 'Windows', t) {
  149. case '6.3':
  150. o = '8.1';
  151. break;
  152.  
  153. case '6.2':
  154. o = '8';
  155. break;
  156.  
  157. case '6.1':
  158. o = '7';
  159. break;
  160.  
  161. case '5.2':
  162. case '5.1':
  163. o = 'XP';
  164. break;
  165.  
  166. default:
  167. o = t;
  168. }
  169. return this.info.device = 'PC', void (this.info.osVersion = o);
  170. }
  171. if (/^Macintosh/i.test(n)) {
  172. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  173. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  174. }
  175. if (/^iPad/i.test(n)) {
  176. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  177. void (this.info.osVersion = o.replace(/_/g, '.'));
  178. }
  179. if (/^iPhone/i.test(n)) {
  180. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  181. void (this.info.osVersion = o.replace(/_/g, '.'));
  182. }
  183. if (-1 !== n.indexOf('Android')) {
  184. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  185. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  186. }
  187. if (/Linux\s[a-z\d_]+/.test(n)) {
  188. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  189. }
  190. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  191. } catch (e) {
  192. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  193. }
  194. }, i.prototype.getBrowserName = function() {
  195. var e = Object.keys(this.browserNameMap).map(function(e) {
  196. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  197. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  198. return -1 !== e.findIndex(function(e) {
  199. return e.test(n);
  200. });
  201. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  202. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  203. }, i.prototype._formatBrowserVersion = function(e) {
  204. var n, o, t, r;
  205. try {
  206. for (var i = null !== (o = null === (n = e.match(/(?<name>[a-z\d]+)(\/|\s)(?<version>(\d+\.)+\d+)/i)) || void 0 === n ? void 0 : n.groups) && void 0 !== o ? o : {}, s = i.name, a = i.version, c = {}, f = 0, u = Object.entries(this.browserNameMap); f < u.length; f++) {
  207. var d = u[f], l = d[0], h = d[1];
  208. if (new RegExp(l).test(s)) {
  209. c = h;
  210. break;
  211. }
  212. }
  213. var p = {
  214. browserVersion: null != a ? a : 'Unknown',
  215. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  216. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  217. };
  218. return 'Trident' === s && (p.browserVersion = {
  219. '4.0': 8,
  220. '5.0': 9,
  221. '6.0': 10,
  222. '7.0': 11
  223. }[a]), p;
  224. } catch (e) {
  225. return console.warn('[UA formatter error] '.concat(e)), {
  226. browser: 'Unknown',
  227. browserVersion: 'Unknown'
  228. };
  229. }
  230. }, i);
  231. function i(e) {
  232. this.agent = '', this.info = {
  233. browser: '',
  234. browserZH: '',
  235. browserVersion: '',
  236. os: '',
  237. osVersion: '',
  238. device: 'Unknown',
  239. engine: 'WebKit'
  240. }, this.browserNameMap = {
  241. MicroMessenger: {
  242. en: 'MicroMessenger',
  243. zh: '微信'
  244. },
  245. MetaSr: {
  246. en: 'MetaSr',
  247. zh: '搜狗浏览器'
  248. },
  249. 'QQ(Browser)?': {
  250. en: 'QQBrowser',
  251. zh: 'QQ浏览器'
  252. },
  253. UCBrowser: {
  254. en: 'UCBrowser',
  255. zh: 'UC浏览器'
  256. },
  257. '2345Explorer': {
  258. en: '2345Explorer',
  259. zh: '2345极速浏览器'
  260. },
  261. Mb2345Browser: {
  262. en: 'Mb2345Browser',
  263. zh: '2345手机浏览器'
  264. },
  265. Trident: {
  266. en: 'Internet Explorer'
  267. },
  268. 'Edge?': {
  269. en: 'Edge'
  270. },
  271. OPR: {
  272. en: 'Opera'
  273. },
  274. Vivaldi: {
  275. en: 'Vivaldi'
  276. },
  277. Firefox: {
  278. en: 'Firefox'
  279. },
  280. Chrome: {
  281. en: 'Chrome'
  282. },
  283. Safari: {
  284. en: 'Safari'
  285. }
  286. }, this.agent = e, this.init();
  287. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  288. this.info = t(t({}, this.info), {
  289. engine: this.getEngine(),
  290. browserVersion: 'Safari' === o ? n : e
  291. });
  292. }
  293. function s() {
  294. this.cookies = {}, this.init();
  295. }
  296. var a = new (s.prototype.init = function() {
  297. var o = {};
  298. document.cookie.split(/;\s/).forEach(function(e) {
  299. var n = e.split(/=/), e = n[0], n = n[1];
  300. o[e] = n;
  301. }), this.cookies = o;
  302. }, s.prototype.getItem = function(e) {
  303. return this.cookies[e];
  304. }, s.prototype.getAllItems = function() {
  305. return this.cookies;
  306. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  307. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  308. }, s)();
  309. e.countDown = function e(n, o, t, r) {
  310. if (!window) {
  311. throw new Error('window is not defind.');
  312. }
  313. if (0 < n) {
  314. return r && r(), n--, window[o] = window.setTimeout(function() {
  315. e(n, o, t, r);
  316. }, 1e3), function() {
  317. return clearTimeout(window[o]);
  318. };
  319. }
  320. clearTimeout(window[o]), t && t();
  321. }, e.createRandomID = function(e) {
  322. void 0 === e && (e = 12);
  323. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  324. n.push(o[Math.round(Math.random() * t)]);
  325. }
  326. return n.join('');
  327. }, e.dCookie = a, e.debounce = function(o, t, r) {
  328. var i;
  329. void 0 === t && (t = 0);
  330. var s = r = void 0 === r ? !1 : r;
  331. return function() {
  332. var e = this, n = arguments;
  333. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  334. r ? s = !0 : o.apply(e, n);
  335. }, t);
  336. };
  337. }, e.deepCopy = function e(n) {
  338. if (d(n) || Array.isArray(n)) {
  339. var o, t = Array.isArray(n) ? [] : {};
  340. for (o in n) {
  341. t[o] = e(n[o]);
  342. }
  343. return t;
  344. }
  345. return n;
  346. }, e.formatQueryParams = function(e) {
  347. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  348. if (!e) {
  349. return {};
  350. }
  351. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  352. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  353. return t[n] = o, e;
  354. });
  355. }
  356. return t;
  357. }, e.formatThousandth = function(e) {
  358. var n = ''.concat(e).split('.'), e = n[0], n = n[1], n = void 0 === n ? '' : n, e = e.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,');
  359. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  360. }, e.generateTree = function e(n, o, t, r) {
  361. for (var i = [], s = 0; s < n.length; s++) {
  362. var a = n[s];
  363. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  364. }
  365. return i;
  366. }, e.isEmpty = function(e) {
  367. return Array.isArray(e) ? 0 === e.length : d(e) ? 0 === Object.keys(e).length : [ '[object Set]', '[object Map]' ].includes(n(e)) ? 0 === e.size : [ null, void 0, '' ].includes(e);
  368. }, e.isFunction = function(e) {
  369. return '[object Function]' === n(e);
  370. }, e.isImageUrl = function(e) {
  371. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  372. }, e.isObject = d, e.isRegexp = function(e) {
  373. return '[object RegExp]' === n(e);
  374. }, e.objectKeyToCamelCase = function e(n, o, t) {
  375. if (Array.isArray(n)) {
  376. for (var r = [], i = 0; i < n.length; i++) {
  377. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  378. }
  379. } else if (d(n)) {
  380. r = {};
  381. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  382. var f = (u = c[a])[0], u = u[1];
  383. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  384. }
  385. } else {
  386. r = n;
  387. }
  388. return r;
  389. }, e.realType = n, e.searchParams = function(e, n) {
  390. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  391. new URLSearchParams(e).get(n);
  392. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  393. return e.replace(/([A-Z])/g, function(e) {
  394. return '_'.concat(e.toLocaleLowerCase());
  395. });
  396. }, e.ua = function(e) {
  397. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  398. }, Object.defineProperty(e, '__esModule', {
  399. value: !0
  400. });
  401. });
  402. },
  403. 786: function(module, __webpack_exports__, __webpack_require__) {
  404. 'use strict';
  405. __webpack_require__.d(__webpack_exports__, {
  406. Z: function() {
  407. return __WEBPACK_DEFAULT_EXPORT__;
  408. }
  409. });
  410. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(220);
  411. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  412. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400);
  413. var _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = __webpack_require__.n(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  414. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()(_node_modules_pnpm_registry_npmmirror_com_css_loader_6_5_1_webpack_5_60_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default());
  415. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(10px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px rgba(5,190,5,0.4)}body.auto-task-options .auto-task-form table label input:checked~span i{left:84px}body.auto-task-options .auto-task-form table label input:checked~span i::before{background:#05be05;box-shadow:35px 0 0 #05be05}body.auto-task-options .auto-task-form table label input:checked~span i::after{bottom:12px;height:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;background:#05be05}body.auto-task-options .auto-task-form table label span{position:absolute;top:0;left:0;width:100%;height:100%;background:#fe0000;border-radius:80px;transition:.5s;box-shadow:0 15px 25px rgba(254,0,0,0.4)}body.auto-task-options .auto-task-form table label span i{position:absolute;top:4px;left:4px;width:72px;height:72px;background:#fff;border-radius:50%}body.auto-task-options .auto-task-form table label span i::before{content:"";position:absolute;top:22px;left:12px;width:12px;height:12px;border-radius:50%;background:#fe0000;box-shadow:35px 0 0 #fe0000;transition:.5s}body.auto-task-options .auto-task-form table label span i::after{content:"";position:absolute;bottom:15px;left:calc(50% - 15px);width:30px;height:6px;border-radius:6px;background:#fe0000;transition:.5s}body.auto-task-history{font-size:15px;font-weight:400;line-height:1.5}body.auto-task-history .container a{color:#007bff;text-decoration:none;background-color:transparent}body.auto-task-history .container .card{width:80%;max-width:800px;border-radius:10px;background:rgba(118,118,118,0.10196);border-top:1px solid rgba(255,255,255,0.50196);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px rgba(0,0,0,0.10196);margin:20px auto;position:relative;display:flex;flex-direction:column;word-wrap:break-word;-webkit-background-clip:border-box;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}body.auto-task-history .container .card .title{text-align:center;font-size:30px;font-weight:bold;margin:5px 0}body.auto-task-history .container .card .title a:hover{text-decoration:none;background:#93e1ff;border-radius:10px;padding:3px}body.auto-task-history .container .card ul{margin-bottom:25px}body.auto-task-history .container .card ul li{margin-bottom:5px;line-height:20px}body.auto-task-history .container .card ul a:hover{text-decoration:underline}body.auto-task-history .container .card .delete-task{right:10px;width:38px;height:35px;position:absolute;font-size:24px;cursor:pointer;border-radius:10px}body.auto-task-history .container .card .delete-task:hover{background:#fff}body.auto-task-history .container .card .time{right:5px;position:absolute;bottom:0;color:#e83e8c;font-family:\'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace\';font-size:15px}#auto-task-buttons,.show-button-div{position:fixed;top:30px;right:15px;width:170px;z-index:999999999 !important;transform:scale(0.9)}#auto-task-buttons p,.show-button-div p{line-height:30px;height:40px;text-align:center;margin:5px !important}#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn{width:150px;height:40px;line-height:30px;font-size:20px}.show-button-div{width:20px}.auto-task-capitalize{text-transform:capitalize !important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{box-shadow:inset 0px 0px 4px 1px rgba(100,150,200,.5) !important}.swal2-checkbox-custom{align-items:center;justify-content:center;background:#fff;color:inherit;margin:1em auto}.swal2-checkbox-custom input{flex-shrink:0;margin:0 .4em}.giveaway-actions #getKey{display:none !important}.auto-task-giveaway-status{color:#fff;border-radius:10px;padding:0 5px;margin-left:5px}.auto-task-giveaway-status.active{background-color:#5cb85c}.auto-task-giveaway-status.not-active{background-color:#d9534f}.left-keys.lk-green,.left-keys.lk-yellow,.left-keys.lk-red,.left-keys.lk-black{display:none !important}', '' ]);
  416. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  417. },
  418. 400: function(module) {
  419. 'use strict';
  420. module.exports = function(cssWithMappingToString) {
  421. var list = [];
  422. list.toString = function toString() {
  423. return this.map(function(item) {
  424. var content = '';
  425. var needLayer = typeof item[5] !== 'undefined';
  426. if (item[4]) {
  427. content += '@supports ('.concat(item[4], ') {');
  428. }
  429. if (item[2]) {
  430. content += '@media '.concat(item[2], ' {');
  431. }
  432. if (needLayer) {
  433. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  434. }
  435. content += cssWithMappingToString(item);
  436. if (needLayer) {
  437. content += '}';
  438. }
  439. if (item[2]) {
  440. content += '}';
  441. }
  442. if (item[4]) {
  443. content += '}';
  444. }
  445. return content;
  446. }).join('');
  447. };
  448. list.i = function i(modules, media, dedupe, supports, layer) {
  449. if (typeof modules === 'string') {
  450. modules = [ [ null, modules, undefined ] ];
  451. }
  452. var alreadyImportedModules = {};
  453. if (dedupe) {
  454. for (var k = 0; k < this.length; k++) {
  455. var id = this[k][0];
  456. if (id != null) {
  457. alreadyImportedModules[id] = true;
  458. }
  459. }
  460. }
  461. for (var _k = 0; _k < modules.length; _k++) {
  462. var item = [].concat(modules[_k]);
  463. if (dedupe && alreadyImportedModules[item[0]]) {
  464. continue;
  465. }
  466. if (typeof layer !== 'undefined') {
  467. if (typeof item[5] === 'undefined') {
  468. item[5] = layer;
  469. } else {
  470. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  471. item[5] = layer;
  472. }
  473. }
  474. if (media) {
  475. if (!item[2]) {
  476. item[2] = media;
  477. } else {
  478. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  479. item[2] = media;
  480. }
  481. }
  482. if (supports) {
  483. if (!item[4]) {
  484. item[4] = ''.concat(supports);
  485. } else {
  486. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  487. item[4] = supports;
  488. }
  489. }
  490. list.push(item);
  491. }
  492. };
  493. return list;
  494. };
  495. },
  496. 220: function(module) {
  497. 'use strict';
  498. module.exports = function(i) {
  499. return i[1];
  500. };
  501. }
  502. };
  503. var __webpack_module_cache__ = {};
  504. function __webpack_require__(moduleId) {
  505. var cachedModule = __webpack_module_cache__[moduleId];
  506. if (cachedModule !== undefined) {
  507. return cachedModule.exports;
  508. }
  509. var module = __webpack_module_cache__[moduleId] = {
  510. id: moduleId,
  511. exports: {}
  512. };
  513. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  514. return module.exports;
  515. }
  516. !function() {
  517. __webpack_require__.n = function(module) {
  518. var getter = module && module.__esModule ? function() {
  519. return module['default'];
  520. } : function() {
  521. return module;
  522. };
  523. __webpack_require__.d(getter, {
  524. a: getter
  525. });
  526. return getter;
  527. };
  528. }();
  529. !function() {
  530. __webpack_require__.d = function(exports, definition) {
  531. for (var key in definition) {
  532. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  533. Object.defineProperty(exports, key, {
  534. enumerable: true,
  535. get: definition[key]
  536. });
  537. }
  538. }
  539. };
  540. }();
  541. !function() {
  542. __webpack_require__.o = function(obj, prop) {
  543. return Object.prototype.hasOwnProperty.call(obj, prop);
  544. };
  545. }();
  546. var __webpack_exports__ = {};
  547. !function() {
  548. 'use strict';
  549. const external_Swal_namespaceObject = Swal;
  550. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  551. const external_Cookies_namespaceObject = Cookies;
  552. var auto_task = __webpack_require__(786);
  553. var javascript_utils_umd_min = __webpack_require__(514);
  554. const httpRequest = async function(options) {
  555. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  556. if (window.TRACE) {
  557. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  558. }
  559. try {
  560. const result = await new Promise(resolve => {
  561. if (options.dataType) {
  562. options.responseType = options.dataType;
  563. }
  564. const requestObj = {
  565. ...{
  566. timeout: 3e4,
  567. ontimeout(data) {
  568. resolve({
  569. result: 'Error',
  570. statusText: 'Timeout',
  571. status: 601,
  572. data: data,
  573. options: options
  574. });
  575. },
  576. onabort(data) {
  577. resolve({
  578. result: 'Error',
  579. statusText: 'Aborted',
  580. status: 602,
  581. data: data,
  582. options: options
  583. });
  584. },
  585. onerror(data) {
  586. resolve({
  587. result: 'Error',
  588. statusText: 'Error',
  589. status: 603,
  590. data: data,
  591. options: options
  592. });
  593. },
  594. onload(data) {
  595. resolve({
  596. result: 'Success',
  597. statusText: 'Load',
  598. status: 600,
  599. data: data,
  600. options: options
  601. });
  602. }
  603. },
  604. ...options
  605. };
  606. GM_xmlhttpRequest(requestObj);
  607. });
  608. if (window.DEBUG) {
  609. console.log('%cAuto-Task[httpRequest]:', 'color:blue', JSON.stringify(result));
  610. }
  611. if (result.status !== 600 && times < 2) {
  612. return await httpRequest(options, times + 1);
  613. }
  614. return result;
  615. } catch (error) {
  616. console.log('%cAuto-Task[httpRequest]:', 'color:red', JSON.stringify({
  617. errorMsg: error,
  618. options: options
  619. }));
  620. throwError(error, 'httpRequest');
  621. return {
  622. result: 'JsError',
  623. statusText: 'Error',
  624. status: 604,
  625. error: error,
  626. options: options
  627. };
  628. }
  629. };
  630. const tools_httpRequest = httpRequest;
  631. const echoLog = _ref => {
  632. let {
  633. type,
  634. text,
  635. html,
  636. id
  637. } = _ref;
  638. const emptyStatus = {
  639. success: () => emptyStatus,
  640. error: () => emptyStatus,
  641. warning: () => emptyStatus,
  642. info: () => emptyStatus,
  643. view: () => emptyStatus
  644. };
  645. try {
  646. var _ele$;
  647. let ele;
  648. if (type) {
  649. switch (type) {
  650. case 'joiningSteamGroup':
  651. case 'leavingSteamGroup':
  652. case 'gettingSteamGroupId':
  653. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  654. break;
  655.  
  656. case 'joiningSteamOfficialGroup':
  657. case 'leavingSteamOfficialGroup':
  658. case 'gettingSteamOfficialGroupId':
  659. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/games/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  660. break;
  661.  
  662. case 'subscribingForum':
  663. case 'unsubscribingForum':
  664. case 'gettingForumId':
  665. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>]...<font></font></li>`);
  666. break;
  667.  
  668. case 'followingCurator':
  669. case 'unfollowingCurator':
  670. case 'getCuratorId':
  671. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/${text !== null && text !== void 0 && text.includes('/') ? text : `curator/${text}`}" target="_blank">${text}</a>]...<font></font></li>`);
  672. break;
  673.  
  674. case 'addingToWishlist':
  675. case 'removingFromWishlist':
  676. case 'followingGame':
  677. case 'unfollowingGame':
  678. case 'gettingSubid':
  679. case 'addingFreeLicense':
  680. case 'requestingPlayTestAccess':
  681. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  682. break;
  683.  
  684. case 'addingFreeLicenseSubid':
  685. ele = $(`<li>${i18n('addingFreeLicense')}[<a href="https://steamdb.info/sub/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  686. break;
  687.  
  688. case 'favoritingWorkshop':
  689. case 'unfavoritingWorkshop':
  690. case 'gettingWorkshopAppId':
  691. case 'votingUpWorkshop':
  692. ele = $(`<li>${i18n(type)}[<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  693. ${text}</a>]...<font></font></li>`);
  694. break;
  695.  
  696. case 'gettingAnnouncementParams':
  697. case 'likingAnnouncement':
  698. ele = $(`<li>${i18n(type)}[<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  699. ${id}</a>]...<font></font></li>`);
  700. break;
  701.  
  702. case 'joiningDiscordServer':
  703. case 'gettingDiscordGuild':
  704. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  705. break;
  706.  
  707. case 'leavingDiscordServer':
  708. ele = $(`<li>${i18n(type)}[<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  709. break;
  710.  
  711. case 'updateDiscordAuth':
  712. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  713. break;
  714.  
  715. case 'followingTwitchChannel':
  716. case 'unfollowingTwitchChannel':
  717. case 'gettingTwitchChannelId':
  718. ele = $(`<li>${i18n(type)}[<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  719. break;
  720.  
  721. case 'gettingInsUserId':
  722. case 'followingIns':
  723. case 'unfollowingIns':
  724. ele = $(`<li>${i18n(type)}[<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  725. break;
  726.  
  727. case 'gettingTwitterUserId':
  728. case 'followingTwitterUser':
  729. case 'unfollowingTwitterUser':
  730. ele = $(`<li>${i18n(type)}[<a href="https://twitter.com/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  731. break;
  732.  
  733. case 'retweetting':
  734. case 'unretweetting':
  735. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  736. break;
  737.  
  738. case 'joiningReddit':
  739. case 'leavingReddit':
  740. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  741. break;
  742.  
  743. case 'followingRedditUser':
  744. case 'unfollowingRedditUser':
  745. ele = $(`<li>${i18n(type)}[<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  746. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>]...<font></font></li>`);
  747. break;
  748.  
  749. case 'followingYtbChannel':
  750. case 'unfollowingYtbChannel':
  751. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>]...<font></font></li>`);
  752. break;
  753.  
  754. case 'likingYtbVideo':
  755. case 'unlikingYtbVideo':
  756. ele = $(`<li>${i18n(type)}[<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>]...<font></font></li>`);
  757. break;
  758.  
  759. case 'gettingVkId':
  760. case 'joiningVkGroup':
  761. case 'leavingVkGroup':
  762. case 'joiningVkPublic':
  763. case 'leavingVkPublic':
  764. case 'sendingVkWall':
  765. case 'deletingVkWall':
  766. ele = $(`<li>${i18n(type)}[<a href="https://vk.com/${text}/" target="_blank">${text}</a>]...<font></font></li>`);
  767. break;
  768.  
  769. case 'visitingLink':
  770. ele = $(`<li>${i18n('visitingLink')}[<a href="${text}" target="_blank">${text}</a>]...<font></font></li>`);
  771. break;
  772.  
  773. case 'verifyingInsAuth':
  774. case 'text':
  775. ele = $(`<li>${i18n(text)}<font></font></li>`);
  776. break;
  777.  
  778. case 'html':
  779. ele = $(text || html);
  780. break;
  781.  
  782. case 'whiteList':
  783. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  784. break;
  785.  
  786. case 'globalOptionsSkip':
  787. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  788. break;
  789.  
  790. default:
  791. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  792. break;
  793. }
  794. } else if (text) {
  795. ele = $(`<li>${i18n(text)}<font></font></li>`);
  796. } else if (html) {
  797. ele = $(html);
  798. } else {
  799. ele = $('<li><font></font></li>');
  800. }
  801. ele.addClass('card-text');
  802. $('#auto-task-info').append(ele);
  803. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  804. const font = ele.find('font');
  805. const status = {
  806. font: font,
  807. success() {
  808. var _this$font, _this$font2, _this$font3;
  809. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  810. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  811. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  812. html ? (_this$font2 = this.font) === null || _this$font2 === void 0 ? void 0 : _this$font2.html(text) : (_this$font3 = this.font) === null || _this$font3 === void 0 ? void 0 : _this$font3.text(text);
  813. return this;
  814. },
  815. error() {
  816. var _this$font4, _this$font5, _this$font6;
  817. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  818. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  819. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  820. html ? (_this$font5 = this.font) === null || _this$font5 === void 0 ? void 0 : _this$font5.html(text) : (_this$font6 = this.font) === null || _this$font6 === void 0 ? void 0 : _this$font6.text(text);
  821. return this;
  822. },
  823. warning() {
  824. var _this$font7, _this$font8, _this$font9;
  825. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  826. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  827. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  828. html ? (_this$font8 = this.font) === null || _this$font8 === void 0 ? void 0 : _this$font8.html(text) : (_this$font9 = this.font) === null || _this$font9 === void 0 ? void 0 : _this$font9.text(text);
  829. return this;
  830. },
  831. info() {
  832. var _this$font10, _this$font11, _this$font12;
  833. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  834. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  835. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  836. html ? (_this$font11 = this.font) === null || _this$font11 === void 0 ? void 0 : _this$font11.html(text) : (_this$font12 = this.font) === null || _this$font12 === void 0 ? void 0 : _this$font12.text(text);
  837. return this;
  838. },
  839. view() {
  840. var _this$font13;
  841. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  842. return this;
  843. }
  844. };
  845. return status;
  846. } catch (error) {
  847. throwError(error, 'echoLog');
  848. return emptyStatus;
  849. }
  850. };
  851. const scripts_echoLog = echoLog;
  852. const unique = array => {
  853. try {
  854. return [ ...new Set(array) ];
  855. } catch (error) {
  856. throwError(error, 'unique');
  857. return [];
  858. }
  859. };
  860. const delay = function() {
  861. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  862. return new Promise(resolve => {
  863. setTimeout(() => {
  864. resolve(true);
  865. }, time);
  866. });
  867. };
  868. const getRedirectLink = async link => {
  869. try {
  870. if (!link) {
  871. return null;
  872. }
  873. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  874. if (redirectLinksCache[link]) {
  875. redirectLinksCache[link];
  876. }
  877. return await tools_httpRequest({
  878. url: link,
  879. method: 'GET'
  880. }).then(_ref => {
  881. let {
  882. data
  883. } = _ref;
  884. if (data !== null && data !== void 0 && data.finalUrl) {
  885. redirectLinksCache[link] = data.finalUrl;
  886. GM_setValue('redirectLinks', redirectLinksCache);
  887. return data.finalUrl;
  888. }
  889. return null;
  890. });
  891. } catch (error) {
  892. throwError(error, 'getRedirectLink');
  893. return null;
  894. }
  895. };
  896. const visitLink = async (link, options) => {
  897. try {
  898. const logStatus = scripts_echoLog({
  899. type: 'visitLink',
  900. text: link
  901. });
  902. return await tools_httpRequest({
  903. url: link,
  904. method: 'GET',
  905. ...options
  906. }).then(_ref2 => {
  907. let {
  908. result,
  909. statusText,
  910. status
  911. } = _ref2;
  912. if (result === 'Success') {
  913. logStatus.success();
  914. return true;
  915. }
  916. logStatus.error(`${result}:${statusText}(${status})`);
  917. return false;
  918. });
  919. } catch (error) {
  920. throwError(error, 'visitLink');
  921. return false;
  922. }
  923. };
  924. const getUrlQuery = url => {
  925. try {
  926. const query = {};
  927. if (url) {
  928. if (url.includes('?')) {
  929. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  930. query[key] = value;
  931. return str;
  932. });
  933. }
  934. } else {
  935. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  936. query[key] = value;
  937. return str;
  938. });
  939. }
  940. return query;
  941. } catch (error) {
  942. throwError(error, 'getUrlQuery');
  943. return {};
  944. }
  945. };
  946. const getUuid = () => {
  947. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  948. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  949. };
  950. const stringToColour = str => {
  951. try {
  952. let hash = 0;
  953. for (let i = 0; i < str.length; i++) {
  954. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  955. }
  956. let colour = '#';
  957. for (let i = 0; i < 3; i++) {
  958. const value = hash >> i * 8 & 255;
  959. colour += `00${value.toString(16)}`.slice(-2);
  960. }
  961. return colour;
  962. } catch (error) {
  963. throwError(error, 'stringToColour');
  964. return '#fff';
  965. }
  966. };
  967. const defaultGlobalOptions = {
  968. doTask: {
  969. discord: {
  970. servers: true
  971. },
  972. instagram: {
  973. users: true
  974. },
  975. twitch: {
  976. channels: true
  977. },
  978. twitter: {
  979. users: true,
  980. retweets: true
  981. },
  982. vk: {
  983. names: true
  984. },
  985. youtube: {
  986. channels: true,
  987. likes: true
  988. },
  989. reddit: {
  990. reddits: true
  991. },
  992. steam: {
  993. groups: true,
  994. officialGroups: true,
  995. wishlists: true,
  996. follows: true,
  997. forums: true,
  998. workshops: true,
  999. curators: true,
  1000. workshopVotes: true,
  1001. announcements: true,
  1002. licenses: true,
  1003. playtests: true
  1004. }
  1005. },
  1006. undoTask: {
  1007. discord: {
  1008. servers: true
  1009. },
  1010. instagram: {
  1011. users: true
  1012. },
  1013. twitch: {
  1014. channels: true
  1015. },
  1016. twitter: {
  1017. users: true,
  1018. retweets: true
  1019. },
  1020. vk: {
  1021. names: true
  1022. },
  1023. youtube: {
  1024. channels: true,
  1025. likes: true
  1026. },
  1027. reddit: {
  1028. reddits: true
  1029. },
  1030. steam: {
  1031. groups: true,
  1032. officialGroups: true,
  1033. wishlists: true,
  1034. follows: true,
  1035. forums: true,
  1036. workshops: true,
  1037. curators: true
  1038. }
  1039. },
  1040. position: {
  1041. buttonSideX: 'right',
  1042. buttonSideY: 'top',
  1043. buttonDistance: '15,30',
  1044. showButtonSideX: 'right',
  1045. showButtonSideY: 'top',
  1046. showButtonDistance: '15,30',
  1047. logSideX: 'right',
  1048. logSideY: 'bottom',
  1049. logDistance: '10,10'
  1050. },
  1051. hotKey: {
  1052. doTaskKey: 'alt + d',
  1053. undoTaskKey: 'alt + u',
  1054. toggleLogKey: 'alt + l'
  1055. },
  1056. other: {
  1057. twitterVerifyId: '783214',
  1058. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1059. autoUpdateSource: 'jsdelivr',
  1060. language: 'zh',
  1061. checkLogin: true,
  1062. checkLeftKey: true,
  1063. defaultShowButton: true,
  1064. defaultShowLog: true,
  1065. debug: false,
  1066. receivePreview: true
  1067. }
  1068. };
  1069. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1070. const assignObject = (obj1, obj2) => {
  1071. try {
  1072. const newObj = {};
  1073. for (const [ key, value ] of Object.entries(obj1)) {
  1074. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1075. newObj[key] = assignObject(value, obj2[key]);
  1076. } else {
  1077. newObj[key] = obj2[key] ?? value;
  1078. }
  1079. }
  1080. return newObj;
  1081. } catch (error) {
  1082. throwError(error, 'assignObject');
  1083. return defaultGlobalOptions;
  1084. }
  1085. };
  1086. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1087. const saveData = () => {
  1088. try {
  1089. const data = {};
  1090. $('#globalOptionsForm').serializeArray().map(value => {
  1091. data[value.name] = value.value;
  1092. return value;
  1093. });
  1094. $.makeArray($('#globalOptionsForm input')).map(element => {
  1095. const name = $(element).attr('name');
  1096. const keys = name.split('.');
  1097. if (keys.length === 3) {
  1098. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1099. } else if (keys.length === 2) {
  1100. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1101. }
  1102. return element;
  1103. });
  1104. GM_setValue('globalOptions', globalOptions);
  1105. external_Swal_default().fire({
  1106. title: i18n('changeGlobalOptionsSuccess'),
  1107. icon: 'success'
  1108. });
  1109. } catch (error) {
  1110. throwError(error, 'saveData');
  1111. }
  1112. };
  1113. const changeGlobalOptions = showType => {
  1114. try {
  1115. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1116. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1117. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1118. for (const [ option, data2 ] of Object.entries(data1)) {
  1119. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1120. if (typeof data2 === 'boolean') {
  1121. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><label><input type="checkbox" name="${type}.${option}"${data2 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1122. } else {
  1123. globalOptionsForm += `<tr style="background-color: ${stringToColour(type)}44">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).length}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${i18n(option)}</td><td><input class="editOption" type="text" name="${type}.${option}" value="${data2}"/></td></tr>`;
  1124. }
  1125. } else {
  1126. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1127. globalOptionsForm += `<tr style="background-color: ${stringToColour(option)}66">${Object.keys(data1).indexOf(option) === 0 ? `<th rowspan="${Object.keys(data1).map(key => Object.keys(data1[key]).length).reduce((acr, cur) => acr + cur)}" style="background-color: ${stringToColour(type)}66">${i18n(type)}</th>` : ''}<td>${option}.${i18n(socialType)}</td><td><label><input type="checkbox" name="${type}.${option}.${socialType}"${data3 ? ' checked="checked"' : ''}/><span><i></i></span></label></td></tr>`;
  1128. }
  1129. }
  1130. }
  1131. }
  1132. globalOptionsForm += '</tbody></table></form>';
  1133. if (showType === 'swal') {
  1134. external_Swal_default().fire({
  1135. title: i18n('globalOptions'),
  1136. html: globalOptionsForm,
  1137. showConfirmButton: true,
  1138. confirmButtonText: i18n('save'),
  1139. showCancelButton: true,
  1140. cancelButtonText: i18n('close')
  1141. }).then(_ref => {
  1142. let {
  1143. isConfirmed
  1144. } = _ref;
  1145. if (isConfirmed) {
  1146. saveData();
  1147. }
  1148. });
  1149. } else {
  1150. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1151. }
  1152. } catch (error) {
  1153. throwError(error, 'changeGlobalOptions');
  1154. }
  1155. };
  1156. const data = {
  1157. website: '网站',
  1158. type: '类型',
  1159. edit: '编辑',
  1160. whiteList: '白名单',
  1161. skipTask: '跳过撤销任务',
  1162. whiteListOptions: '白名单设置',
  1163. changeWhiteListOption: '设置白名单(%0)',
  1164. whiteListNotFound: '找不到此项白名单: %0',
  1165. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1166. changeWebsiteOptions: '网站设置',
  1167. changeGlobalOptions: '全局设置',
  1168. ok: '是',
  1169. save: '保存',
  1170. close: '关闭',
  1171. return: '返回',
  1172. option: '选项',
  1173. value: '值',
  1174. websiteOptions: '当前网站设置',
  1175. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1176. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1177. needLogin: '请先登录!',
  1178. getTasksInfo: '正在获取并处理任务信息...',
  1179. gettingKey: '正在获取Key...',
  1180. verifyingTask: '正在验证任务',
  1181. notice: '自动任务脚本提醒',
  1182. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1183. giveawayEnded: '此活动已结束,是否关闭?',
  1184. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1185. confirm: '确定',
  1186. cancel: '取消',
  1187. unKnown: '未知',
  1188. unKnownTaskType: '未识别的任务',
  1189. doing: '正在做任务',
  1190. allTasksComplete: '所有任务已完成!',
  1191. getTaskIdFailed: '获取任务Id失败!',
  1192. initSuccess: '%0 初始化成功!',
  1193. initFailed: '%0 初始化失败!',
  1194. errorLink: '链接错误: %0',
  1195. needInit: '请先初始化',
  1196. verifyingAuth: '正在验证%0凭证...',
  1197. updatingAuth: '正在更新%0凭证...',
  1198. initing: '正在初始化...',
  1199. getFailed: '获取%0失败!',
  1200. checkLoginFailed: '检测登录状态失败!',
  1201. checkLeftKeyFailed: '检测剩余Key失败!',
  1202. userId: '用户Id',
  1203. joiningGiveaway: '正在加入赠Key',
  1204. needJoinGiveaway: '需要先加入赠Key',
  1205. cannotUndo: '此网站不支持取消任务',
  1206. verifyAuth: '正在验证 %0 凭证...',
  1207. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1208. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1209. visitingLink: '正在访问链接: ',
  1210. doTask: '做任务',
  1211. undoTask: '撤销任务',
  1212. verifyTask: '验证任务',
  1213. getKey: '获取Key',
  1214. selectAll: '全选',
  1215. selectNone: '全不选',
  1216. invertSelect: '反选',
  1217. doFreeTask: '加入免费赠品',
  1218. doPointTask: '加入点数赠品',
  1219. skipTaskOption: '设置中已配置跳过任务',
  1220. other: '其他',
  1221. globalOptions: '全局设置',
  1222. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1223. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1224. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1225. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1226. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1227. saveGlobalOptions: '保存全局设置',
  1228. settingPage: '设置页面',
  1229. name: '名称',
  1230. version: '版本',
  1231. scriptManager: '脚本管理器',
  1232. script: '脚本',
  1233. environment: '环境',
  1234. os: '系统',
  1235. browser: '浏览器',
  1236. getId: '获取 %0 id',
  1237. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1238. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1239. showButton: '显示按钮',
  1240. hideButton: '隐藏按钮',
  1241. showLog: '显示日志',
  1242. hideLog: '隐藏日志',
  1243. defaultShowButton: '默认显示按钮',
  1244. defaultShowLog: '默认显示日志',
  1245. debug: '输出调试日志,不要开启此选项!',
  1246. receivePreview: '接收预览版更新',
  1247. position: '组件位置',
  1248. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1249. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1250. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1251. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1252. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1253. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1254. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1255. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1256. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1257. hotKey: '快捷键',
  1258. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1259. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1260. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1261. tasksHistory: '任务历史',
  1262. clearHistory: '清空历史',
  1263. clearHistoryFinished: '已清空任务历史!',
  1264. deleteTask: '删除任务',
  1265. lastChangeTime: '最后一次修改时间',
  1266. clearTaskFinished: '删除以下任务完成!',
  1267. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1268. syncData: '数据同步',
  1269. settingData: '正在上传数据...',
  1270. gettingData: '正在获取数据...',
  1271. help: '帮助',
  1272. fileName: '文件名',
  1273. upload2gist: '同步到Gist',
  1274. downloadFromGist: '从Gist同步',
  1275. saveAndTest: '保存配置并测试',
  1276. testSuccess: '测试成功!',
  1277. testFailed: '测试失败!',
  1278. saveAndTestNotice: '请先保存配置并测试!',
  1279. processingData: '正在处理数据...',
  1280. updatingData: '正在上传数据...',
  1281. syncDataSuccess: '同步数据成功!',
  1282. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1283. downloadingData: '正在下载数据...',
  1284. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1285. savingData: '正在保存数据...',
  1286. syncHistory: '同步任务历史',
  1287. checkUpdateFailed: '检测更新失败',
  1288. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1289. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1290. gistOptions: 'Gist 设置',
  1291. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1292. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1293. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1294. toGithub: '前往Github反馈',
  1295. toKeylol: '前往其乐论坛反馈',
  1296. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1297. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1298. updateText: '%0 版本更新内容:',
  1299. Active: '进行中',
  1300. Ended: '已结束',
  1301. Banned: '已封禁',
  1302. Paused: '已暂停',
  1303. notStart: '未开始',
  1304. noRemoteData: '检测到远程无数据',
  1305. errorRemoteDataFormat: '远程数据格式错误',
  1306. updateHistory: '历史更新记录<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">点此查看</a>',
  1307. groups: '组',
  1308. officialGroups: '官方组',
  1309. wishlists: '愿望单',
  1310. follows: '游戏关注',
  1311. forums: '论坛',
  1312. workshops: '创意工坊收藏',
  1313. curators: '鉴赏家',
  1314. workshopVotes: '创意工坊点赞',
  1315. announcements: '社区通知',
  1316. steamCommunity: 'Steam社区',
  1317. steamStore: 'Steam商店',
  1318. licenses: '入库免费游戏',
  1319. playtests: '请求访问权限',
  1320. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1321. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1322. joiningSteamGroup: '正在加入Steam组',
  1323. leavingSteamGroup: '正在退出Steam组',
  1324. gettingSteamGroupId: '正在获取Steam组Id',
  1325. joiningSteamOfficialGroup: '正在加入Steam官方组',
  1326. leavingSteamOfficialGroup: '正在退出Steam官方组',
  1327. gettingSteamOfficialGroupId: '正在获取Steam官方组Id',
  1328. subscribingForum: '正在订阅Steam论坛',
  1329. unsubscribingForum: '正在取消订阅Steam论坛',
  1330. gettingForumId: '正在获取Steam论坛Id',
  1331. followingCurator: '正在关注Steam鉴赏家',
  1332. unfollowingCurator: '正在取关Steam鉴赏家',
  1333. gettingCuratorId: '正在获取Steam鉴赏家Id',
  1334. addingToWishlist: '正在添加游戏到Steam愿望单',
  1335. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1336. followingGame: '正在关注Steam游戏',
  1337. unfollowingGame: '正在取关Steam游戏',
  1338. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1339. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1340. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1341. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1342. gettingAnnouncementParams: '正在获取Steam通知信息',
  1343. likingAnnouncement: '正在点赞Steam通知',
  1344. changingArea: '正在更换Steam地区: %0...',
  1345. notNeededChangeArea: '当前地区不需要更换',
  1346. noAnotherArea: '请检测是否开启正确开启代理',
  1347. gettingAreaInfo: '正在获取Steam地区信息...',
  1348. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1349. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1350. gettingSubid: '正在获取游戏subid',
  1351. addingFreeLicense: '正在入库',
  1352. missParams: '缺少参数',
  1353. gettingLicenses: '正在获取Licenses...',
  1354. requestingPlayTestAccess: '正在请求访问权限',
  1355. tryChangeAreaNotice: '此功能无法检测游戏是否限区,因此会尝试换区后再入库,换区失败也不影响后续入库',
  1356. servers: '服务器',
  1357. joiningDiscordServer: '正在加入Discord服务器',
  1358. leavingDiscordServer: '正在退出Discord服务器',
  1359. gettingDiscordGuild: '正在获取Discord服务器Id',
  1360. getDiscordAuthFailed: '获取Discord凭证失败,请检测Discord帐号是否已登录',
  1361. discordImportantNotice: '重要提醒!!!',
  1362. discordImportantNoticeText: '由于Discord网站后台更新,目前使用此脚本加组后可能会导致Discord帐号被强制退出,且需要两步验证才能正常登录,请谨慎使用!!!',
  1363. continue: '继续',
  1364. skipDiscordTask: '跳过Discord任务',
  1365. continueAndDontRemindAgain: '继续且不再提醒',
  1366. users: '用户',
  1367. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1368. insBanned: '您的Instagram账户已被封禁',
  1369. verifyingInsAuth: '正在验证Instagram凭证...',
  1370. gettingInsUserId: '正在获取Instagram用户Id',
  1371. followingIns: '正在关注Instagram用户',
  1372. unfollowingIns: '正在取关Instagram用户',
  1373. reddits: '社区/用户',
  1374. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1375. changingRedditVersion: '正在切换Reddit为新版页面...',
  1376. joiningReddit: '正在加入Reddit社区',
  1377. leavingReddit: '正在退出Reddit社区',
  1378. followingRedditUser: '正在关注Reddit用户',
  1379. unfollowingRedditUser: '正在取关Reddit用户',
  1380. channels: '频道',
  1381. followingTwitchChannel: '正在关注Twitch频道',
  1382. unfollowingTwitchChannel: '正在取关Twitch频道',
  1383. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1384. twitterUser: '推特用户',
  1385. retweets: '转推',
  1386. gettingTwitterUserId: '正在获取推特用户Id',
  1387. followingTwitterUser: '正在关注推特用户',
  1388. unfollowingTwitterUser: '正在取关推特用户',
  1389. retweetting: '正在转推',
  1390. unretweetting: '正在撤销转推',
  1391. names: '组/社区/动态',
  1392. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1393. gettingVkId: '正在获取Vk任务Id',
  1394. joiningVkGroup: '正在加入Vk组',
  1395. leavingVkGroup: '正在退出Vk组',
  1396. joiningVkPublic: '正在加入Vk社区',
  1397. leavingVkPublic: '正在退出Vk社区',
  1398. sendingVkWall: '正在转发Vk动态',
  1399. deletingVkWall: '正在撤销转发Vk动态',
  1400. youtubeChannel: 'YouTube频道',
  1401. likes: '点赞',
  1402. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1403. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1404. gettingYtbToken: '正在获取YouTube Token...',
  1405. followingYtbChannel: '正在订阅YouTube频道',
  1406. unfollowingYtbChannel: '正在退订YouTube频道',
  1407. likingYtbVideo: '正在点赞YouTube视频',
  1408. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1409. giveKeyNoticeBefore: '每次验证间隔15s',
  1410. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1411. noPoints: '点数不够,跳过抽奖',
  1412. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1413. joiningLottery: '正在加入抽奖',
  1414. doingGleamTask: '正在做Gleam任务...',
  1415. gettingGleamLink: '正在获取Gleam任务链接...',
  1416. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1417. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1418. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1419. giveeClubVerifyNotice: '正在验证任务...',
  1420. giveeClubVerifyFinished: '请等待验证完成后自行加入赠Key',
  1421. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1422. };
  1423. const zh_CN = data;
  1424. const en_US_data = {
  1425. website: 'Website',
  1426. type: 'Type',
  1427. edit: 'Edit',
  1428. whiteList: 'Whitelist',
  1429. skipTask: 'Skip undo task',
  1430. whiteListOptions: 'Whitelist options',
  1431. changeWhiteListOption: 'Whitelist option(%0)',
  1432. whiteListNotFound: 'Cannot find this whitelist: %0',
  1433. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1434. changeWebsiteOptions: 'Website options',
  1435. changeGlobalOptions: 'Global options',
  1436. ok: 'OK',
  1437. save: 'Save',
  1438. close: 'Close',
  1439. return: 'Return',
  1440. option: 'Option',
  1441. value: 'Value',
  1442. websiteOptions: 'Current website settings',
  1443. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1444. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1445. needLogin: 'Please log in first!',
  1446. getTasksInfo: 'Obtaining and processing task information...',
  1447. gettingKey: 'Getting Key...',
  1448. verifyingTask: 'Verifying task',
  1449. notice: 'Automatic task script notice',
  1450. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1451. giveawayEnded: 'This event has ended, do you want to close it?',
  1452. 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?',
  1453. confirm: 'Confirm',
  1454. cancel: 'Cancel',
  1455. unKnown: 'Unknown',
  1456. unKnownTaskType: 'Unrecognized task',
  1457. doing: 'Doing a task',
  1458. allTasksComplete: 'All tasks have been completed!',
  1459. getTaskIdFailed: 'Failed to obtain task Id!',
  1460. initSuccess: '%0 was initialized successfully!',
  1461. initFailed: '%0 initialization failed!',
  1462. errorLink: 'Link error: %0',
  1463. needInit: 'Please initialize first',
  1464. verifyingAuth: 'Verifying %0 token...',
  1465. updatingAuth: 'Update %0 token...',
  1466. initing: 'Initializing...',
  1467. getFailed: 'Failed to get %0!',
  1468. checkLoginFailed: 'Failed to detect login status!',
  1469. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1470. userId: 'User Id',
  1471. joiningGiveaway: 'Joining giveaway',
  1472. needJoinGiveaway: 'Need to join the giveaway first',
  1473. cannotUndo: 'This website does not support canceling tasks',
  1474. verifyAuth: 'Verifying %0 token...',
  1475. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1476. errorReport: 'A script error is detected, do you want to report the BUG?',
  1477. visitingLink: 'Visiting link: ',
  1478. doTask: 'DoTask',
  1479. undoTask: 'UndoTask',
  1480. verifyTask: 'Verify',
  1481. getKey: 'GetKey',
  1482. selectAll: 'SelectAll',
  1483. selectNone: 'SelectNone',
  1484. invertSelect: 'InvertSelect',
  1485. doFreeTask: 'FreeTask',
  1486. doPointTask: 'PointTask',
  1487. skipTaskOption: 'Skip task has been configured in the settings',
  1488. other: 'Other',
  1489. globalOptions: 'Global Options',
  1490. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1491. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1492. 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.',
  1493. 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.',
  1494. 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.',
  1495. saveGlobalOptions: 'SaveSettings',
  1496. settingPage: 'Setting Page',
  1497. name: 'Name',
  1498. version: 'Version',
  1499. scriptManager: 'Script Manager',
  1500. script: 'Script',
  1501. environment: 'Environment',
  1502. os: 'OS',
  1503. browser: 'Browser',
  1504. getId: 'Get %0 id',
  1505. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1506. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1507. showButton: 'ShowButton',
  1508. hideButton: 'HideButton',
  1509. showLog: 'ShowLog',
  1510. hideLog: 'HideLog',
  1511. defaultShowButton: 'Default display button',
  1512. defaultShowLog: 'Display log by default',
  1513. debug: 'Output debug log, do not enable this option!',
  1514. receivePreview: 'Receive preview updates',
  1515. position: 'Component position',
  1516. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1517. 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',
  1518. 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',
  1519. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1520. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1521. 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',
  1522. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1523. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1524. 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',
  1525. hotKey: 'Shortcut key',
  1526. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1527. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1528. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1529. tasksHistory: 'TasksHistory',
  1530. clearHistory: 'Clear history',
  1531. clearHistoryFinished: 'The mission history has been cleared!',
  1532. deleteTask: 'Delete task',
  1533. lastChangeTime: 'Last Change Time',
  1534. clearTaskFinished: 'Delete the following tasks completed!',
  1535. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1536. syncData: 'DataSync',
  1537. settingData: 'Uploading data...',
  1538. gettingData: 'Getting data...',
  1539. help: 'Help',
  1540. fileName: 'Filename',
  1541. upload2gist: 'Sync to Gist',
  1542. downloadFromGist: 'Sync from Gist',
  1543. saveAndTest: 'Save configuration and test',
  1544. testSuccess: 'Test success!',
  1545. testFailed: 'Test failed!',
  1546. saveAndTestNotice: 'Please save the configuration and test first!',
  1547. processingData: 'Processing data...',
  1548. updatingData: 'Uploading data...',
  1549. syncDataSuccess: 'Synchronized data successfully!',
  1550. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1551. downloadingData: 'Downloading data...',
  1552. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1553. savingData: 'Saving data...',
  1554. syncHistory: 'Synchronize tasks history',
  1555. checkUpdateFailed: 'Check update failed',
  1556. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1557. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1558. gistOptions: 'Gist Settings',
  1559. 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!',
  1560. 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!',
  1561. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1562. toGithub: 'Feedback(Github)',
  1563. toKeylol: 'Feedback(Keylol)',
  1564. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1565. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1566. updateText: 'Updates in version %0:',
  1567. Active: 'Active',
  1568. Ended: 'Ended',
  1569. Banned: 'Banned',
  1570. Paused: 'Paused',
  1571. notStart: 'notStart',
  1572. noRemoteData: 'No data remotely',
  1573. errorRemoteDataFormat: 'Remote data has wrong format',
  1574. updateHistory: '<a class="high-light" href="https://auto-task-doc.js.org/logs/" target="_blank">Click here</a>' + ' to view the historical update record.',
  1575. groups: 'Group',
  1576. officialGroups: 'Official Group',
  1577. wishlists: 'Wishlist',
  1578. follows: 'Follow Game',
  1579. forums: 'Forum',
  1580. workshops: 'Favorite Workshop',
  1581. curators: 'Curator',
  1582. workshopVotes: 'Voteup Workshop',
  1583. announcements: 'Announcement',
  1584. steamCommunity: 'Steam Community',
  1585. steamStore: 'Steam Store',
  1586. licenses: 'Add License',
  1587. playtests: 'Playtest Access',
  1588. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1589. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1590. joiningSteamGroup: 'Joining Steam Group',
  1591. leavingSteamGroup: 'Leaving Steam Group',
  1592. gettingSteamGroupId: 'Getting Steam Group Id',
  1593. joiningSteamOfficialGroup: 'Joining Steam Official Group',
  1594. leavingSteamOfficialGroup: 'Leaving Steam Official Group',
  1595. gettingSteamOfficialGroupId: 'Getting Steam Official Group Id',
  1596. subscribingForum: 'Subscribing the Steam Forum',
  1597. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1598. gettingForumId: 'Getting Steam Forum Id',
  1599. followingCurator: 'Following Steam Curator',
  1600. unfollowingCurator: 'Unfollowing Steam Curator',
  1601. gettingCuratorId: 'Getting Steam Curator Id',
  1602. addingToWishlist: 'Adding the game to the Steam wishlist',
  1603. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1604. followingGame: 'Following Steam games',
  1605. unfollowingGame: 'Unfollowing Steam games',
  1606. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1607. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1608. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1609. votingUpWorkshop: 'Liking Steam workshop items',
  1610. gettingAnnouncementParams: 'Getting Steam announcement information',
  1611. likingAnnouncement: 'Liking Steam announcement',
  1612. changingArea: 'Changing Steam area: %0...',
  1613. notNeededChangeArea: 'The current area does not need to be changed',
  1614. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1615. gettingAreaInfo: 'Getting Steam area information...',
  1616. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1617. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1618. gettingSubid: 'Getting subid',
  1619. addingFreeLicense: 'Adding free license',
  1620. missParams: 'Missing parameters',
  1621. gettingLicenses: 'Getting licenses...',
  1622. requestingPlayTestAccess: 'Requesting play test access',
  1623. 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.',
  1624. servers: 'Server',
  1625. joiningDiscordServer: 'Joining Discord Server',
  1626. leavingDiscordServer: 'Leaving Discord Server',
  1627. gettingDiscordGuild: 'Getting Discord server Id',
  1628. getDiscordAuthFailed: 'Failed to get Discord token, please check whether the Discord account is logged in',
  1629. discordImportantNotice: 'Important Reminder! ! !',
  1630. 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! ! !',
  1631. continue: 'Continue',
  1632. skipDiscordTask: 'Skip',
  1633. continueAndDontRemindAgain: 'Continue without Reminders',
  1634. users: 'User',
  1635. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1636. insBanned: 'Your Instagram account has been banned',
  1637. verifyingInsAuth: 'Verifying Instagram token...',
  1638. gettingInsUserId: 'Getting Instagram user Id',
  1639. followingIns: 'Following Instagram user',
  1640. unfollowingIns: 'Unfollowing Instagram user',
  1641. reddits: 'Reddit/User',
  1642. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1643. changingRedditVersion: 'Switching Reddit to a new version page...',
  1644. joiningReddit: 'Joining the Reddit',
  1645. leavingReddit: 'Leaving the Reddit',
  1646. followingRedditUser: 'Following Reddit User',
  1647. unfollowingRedditUser: 'Unfollowing Reddit User',
  1648. channels: 'Channel',
  1649. followingTwitchChannel: 'Following Twitch Channel',
  1650. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1651. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1652. twitterUser: 'Twitter User',
  1653. retweets: 'Retweet',
  1654. gettingTwitterUserId: 'Getting Twitter User Id',
  1655. followingTwitterUser: 'Following Twitter User',
  1656. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1657. retweetting: 'Retweetting',
  1658. unretweetting: 'Unretweetting',
  1659. names: 'Group/Public/Wall',
  1660. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1661. gettingVkId: 'Getting Vk task Id',
  1662. joiningVkGroup: 'Joining Vk Group',
  1663. leavingVkGroup: 'Leaving Vk Group',
  1664. joiningVkPublic: 'Joining Vk Public',
  1665. leavingVkPublic: 'Leaving Vk Public',
  1666. sendingVkWall: 'Sending Vk Wall',
  1667. deletingVkWall: 'Deleting Vk Wall',
  1668. youtubeChannel: 'YouTube Channel',
  1669. likes: 'Like',
  1670. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1671. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1672. gettingYtbToken: 'Getting YouTube Token...',
  1673. followingYtbChannel: 'Subscribing to YouTube channel',
  1674. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1675. likingYtbVideo: 'Liking YouTube video',
  1676. unlikingYtbVideo: 'Unliking YouTube video',
  1677. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1678. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1679. noPoints: 'Not enough points, skip the lottery',
  1680. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1681. joiningLottery: 'Joining the lottery',
  1682. doingGleamTask: 'Doing Gleam Task...',
  1683. gettingGleamLink: 'Getting Gleam task link...',
  1684. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1685. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1686. 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!',
  1687. giveeClubVerifyNotice: 'Verifying task...',
  1688. giveeClubVerifyFinished: 'Wait for the verification to complete and join it by yourself',
  1689. 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...'
  1690. };
  1691. const en_US = en_US_data;
  1692. const languages = {
  1693. zh: zh_CN,
  1694. en: en_US
  1695. };
  1696. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1697. const I18n = function(key) {
  1698. var _languages$language;
  1699. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1700. argvs[_key - 1] = arguments[_key];
  1701. }
  1702. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1703. return key;
  1704. }
  1705. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1706. };
  1707. const i18n = I18n;
  1708. function throwError(error, name) {
  1709. if (window.TRACE) {
  1710. console.trace('%cAuto-Task[Debug]:', 'color:blue');
  1711. }
  1712. external_Swal_default().fire({
  1713. title: i18n('errorReport'),
  1714. icon: 'error',
  1715. showCancelButton: true,
  1716. confirmButtonText: i18n('toGithub'),
  1717. showDenyButton: true,
  1718. denyButtonText: i18n('toKeylol'),
  1719. cancelButtonText: i18n('close')
  1720. }).then(_ref => {
  1721. let {
  1722. isDenied,
  1723. isConfirmed
  1724. } = _ref;
  1725. if (isConfirmed) {
  1726. 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,
  1727. 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');
  1728. } else if (isDenied) {
  1729. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1730.  
  1731. 环境:
  1732.  
  1733. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1734.  
  1735. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1736. 脚本版本: ${GM_info.script.version}
  1737.  
  1738. 报错信息:
  1739. [code]${error.stack}[/code]
  1740.  
  1741. 执行日志:
  1742. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1743. GM_setClipboard(text);
  1744. external_Swal_default().fire({
  1745. title: i18n('copySuccess'),
  1746. icon: 'success',
  1747. confirmButtonText: i18n('ok')
  1748. }).then(() => {
  1749. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1750. });
  1751. }
  1752. });
  1753. console.log('%c%s', 'color:white;background:red', `Auto-Task[Error]: ${name}\n${error.stack}`);
  1754. }
  1755. function _defineProperty(obj, key, value) {
  1756. if (key in obj) {
  1757. Object.defineProperty(obj, key, {
  1758. value: value,
  1759. enumerable: true,
  1760. configurable: true,
  1761. writable: true
  1762. });
  1763. } else {
  1764. obj[key] = value;
  1765. }
  1766. return obj;
  1767. }
  1768. class Social {
  1769. constructor() {
  1770. _defineProperty(this, 'tasks', void 0);
  1771. }
  1772. getRealParams(name, links, doTask, link2param) {
  1773. try {
  1774. let realParams = [];
  1775. if (links.length > 0) {
  1776. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1777. }
  1778. if (!doTask && this.tasks[name].length > 0) {
  1779. realParams = [ ...realParams, ...this.tasks[name] ];
  1780. }
  1781. return unique(realParams);
  1782. } catch (error) {
  1783. throwError(error, 'Social.getRealParams');
  1784. return [];
  1785. }
  1786. }
  1787. }
  1788. const social_Social = Social;
  1789. function _classPrivateMethodInitSpec(obj, privateSet) {
  1790. _checkPrivateRedeclaration(obj, privateSet);
  1791. privateSet.add(obj);
  1792. }
  1793. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1794. _checkPrivateRedeclaration(obj, privateMap);
  1795. privateMap.set(obj, value);
  1796. }
  1797. function _checkPrivateRedeclaration(obj, privateCollection) {
  1798. if (privateCollection.has(obj)) {
  1799. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1800. }
  1801. }
  1802. function Discord_defineProperty(obj, key, value) {
  1803. if (key in obj) {
  1804. Object.defineProperty(obj, key, {
  1805. value: value,
  1806. enumerable: true,
  1807. configurable: true,
  1808. writable: true
  1809. });
  1810. } else {
  1811. obj[key] = value;
  1812. }
  1813. return obj;
  1814. }
  1815. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1816. if (!privateSet.has(receiver)) {
  1817. throw new TypeError('attempted to get private field on non-instance');
  1818. }
  1819. return fn;
  1820. }
  1821. function _classPrivateFieldGet(receiver, privateMap) {
  1822. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1823. return _classApplyDescriptorGet(receiver, descriptor);
  1824. }
  1825. function _classApplyDescriptorGet(receiver, descriptor) {
  1826. if (descriptor.get) {
  1827. return descriptor.get.call(receiver);
  1828. }
  1829. return descriptor.value;
  1830. }
  1831. function _classPrivateFieldSet(receiver, privateMap, value) {
  1832. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1833. _classApplyDescriptorSet(receiver, descriptor, value);
  1834. return value;
  1835. }
  1836. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1837. if (!privateMap.has(receiver)) {
  1838. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1839. }
  1840. return privateMap.get(receiver);
  1841. }
  1842. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1843. if (descriptor.set) {
  1844. descriptor.set.call(receiver, value);
  1845. } else {
  1846. if (!descriptor.writable) {
  1847. throw new TypeError('attempted to set read only private field');
  1848. }
  1849. descriptor.value = value;
  1850. }
  1851. }
  1852. const defaultTasksTemplate = {
  1853. servers: []
  1854. };
  1855. const defaultTasks = JSON.stringify(defaultTasksTemplate);
  1856. var _auth = new WeakMap();
  1857. var _cache = new WeakMap();
  1858. var _initialized = new WeakMap();
  1859. var _verifyAuth = new WeakSet();
  1860. var _updateAuth = new WeakSet();
  1861. var _joinServer = new WeakSet();
  1862. var _leaveServer = new WeakSet();
  1863. var _getGuild = new WeakSet();
  1864. var _setCache = new WeakSet();
  1865. class Discord extends social_Social {
  1866. constructor() {
  1867. var _GM_getValue;
  1868. super(...arguments);
  1869. _classPrivateMethodInitSpec(this, _setCache);
  1870. _classPrivateMethodInitSpec(this, _getGuild);
  1871. _classPrivateMethodInitSpec(this, _leaveServer);
  1872. _classPrivateMethodInitSpec(this, _joinServer);
  1873. _classPrivateMethodInitSpec(this, _updateAuth);
  1874. _classPrivateMethodInitSpec(this, _verifyAuth);
  1875. Discord_defineProperty(this, 'tasks', JSON.parse(defaultTasks));
  1876. Discord_defineProperty(this, 'whiteList', {
  1877. ...JSON.parse(defaultTasks),
  1878. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord
  1879. });
  1880. _classPrivateFieldInitSpec(this, _auth, {
  1881. writable: true,
  1882. value: GM_getValue('discordAuth') || {}
  1883. });
  1884. _classPrivateFieldInitSpec(this, _cache, {
  1885. writable: true,
  1886. value: GM_getValue('discordCache') || {}
  1887. });
  1888. _classPrivateFieldInitSpec(this, _initialized, {
  1889. writable: true,
  1890. value: false
  1891. });
  1892. }
  1893. async init() {
  1894. try {
  1895. if (!GM_getValue('dontRemindDiscordAgain')) {
  1896. const result = await external_Swal_default().fire({
  1897. title: i18n('discordImportantNotice'),
  1898. text: i18n('discordImportantNoticeText'),
  1899. showCancelButton: true,
  1900. showDenyButton: true,
  1901. confirmButtonText: i18n('continue'),
  1902. cancelButtonText: i18n('skipDiscordTask'),
  1903. denyButtonText: i18n('continueAndDontRemindAgain')
  1904. }).then(_ref => {
  1905. let {
  1906. isConfirmed,
  1907. isDenied
  1908. } = _ref;
  1909. if (isConfirmed) {
  1910. return true;
  1911. }
  1912. if (isDenied) {
  1913. GM_setValue('dontRemindDiscordAgain', true);
  1914. return true;
  1915. }
  1916. return false;
  1917. });
  1918. if (!result) {
  1919. _classPrivateFieldSet(this, _initialized, false);
  1920. return 'skip';
  1921. }
  1922. }
  1923. if (_classPrivateFieldGet(this, _initialized)) {
  1924. return true;
  1925. }
  1926. if (!_classPrivateFieldGet(this, _auth).auth) {
  1927. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1928. _classPrivateFieldSet(this, _initialized, true);
  1929. return true;
  1930. }
  1931. return false;
  1932. }
  1933. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1934. if (isVerified) {
  1935. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1936. _classPrivateFieldSet(this, _initialized, true);
  1937. return true;
  1938. }
  1939. GM_setValue('discordAuth', {
  1940. auth: null
  1941. });
  1942. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1943. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1944. _classPrivateFieldSet(this, _initialized, true);
  1945. return true;
  1946. }
  1947. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1948. return false;
  1949. } catch (error) {
  1950. throwError(error, 'Discord.init');
  1951. return false;
  1952. }
  1953. }
  1954. async toggle(_ref2) {
  1955. let {
  1956. doTask = true,
  1957. serverLinks = []
  1958. } = _ref2;
  1959. try {
  1960. if (!_classPrivateFieldGet(this, _initialized)) {
  1961. scripts_echoLog({
  1962. text: i18n('needInit')
  1963. });
  1964. return false;
  1965. }
  1966. const prom = [];
  1967. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1968. scripts_echoLog({
  1969. type: 'globalOptionsSkip',
  1970. text: 'discord.servers'
  1971. });
  1972. } else {
  1973. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1974. var _link$match;
  1975. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1976. });
  1977. if (realServers.length > 0) {
  1978. for (const server of realServers) {
  1979. if (doTask) {
  1980. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1981. } else {
  1982. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1983. }
  1984. await delay(1e3);
  1985. }
  1986. }
  1987. }
  1988. return await Promise.all(prom).then(() => true);
  1989. } catch (error) {
  1990. throwError(error, 'Discord.toggleServers');
  1991. return false;
  1992. }
  1993. }
  1994. }
  1995. async function _verifyAuth2() {
  1996. try {
  1997. const logStatus = scripts_echoLog({
  1998. text: i18n('verifyingAuth', 'Discord')
  1999. });
  2000. const {
  2001. result,
  2002. statusText,
  2003. status,
  2004. data
  2005. } = await tools_httpRequest({
  2006. url: 'https://discord.com/api/v6/users/@me',
  2007. method: 'HEAD',
  2008. headers: {
  2009. authorization: _classPrivateFieldGet(this, _auth).auth
  2010. }
  2011. });
  2012. if (result === 'Success') {
  2013. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2014. logStatus.success();
  2015. return true;
  2016. }
  2017. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2018. return false;
  2019. }
  2020. logStatus.error(`${result}:${statusText}(${status})`);
  2021. return false;
  2022. } catch (error) {
  2023. throwError(error, 'Discord.verifyAuth');
  2024. return false;
  2025. }
  2026. }
  2027. async function _updateAuth2() {
  2028. try {
  2029. const logStatus = scripts_echoLog({
  2030. text: i18n('updatingAuth', 'Discord')
  2031. });
  2032. return await new Promise(resolve => {
  2033. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  2034. active: true,
  2035. insert: true,
  2036. setParent: true
  2037. });
  2038. newTab.onclose = async () => {
  2039. var _GM_getValue2;
  2040. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  2041. if (auth) {
  2042. _classPrivateFieldSet(this, _auth, {
  2043. auth: auth
  2044. });
  2045. logStatus.success();
  2046. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  2047. } else {
  2048. logStatus.error('Error: Update discord auth failed!');
  2049. resolve(false);
  2050. }
  2051. };
  2052. });
  2053. } catch (error) {
  2054. throwError(error, 'Discord.updateAuth');
  2055. return false;
  2056. }
  2057. }
  2058. async function _joinServer2(inviteId) {
  2059. try {
  2060. const logStatus = scripts_echoLog({
  2061. type: 'joiningDiscordServer',
  2062. text: inviteId
  2063. });
  2064. const {
  2065. result,
  2066. statusText,
  2067. status,
  2068. data
  2069. } = await tools_httpRequest({
  2070. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2071. method: 'POST',
  2072. dataType: 'json',
  2073. headers: {
  2074. authorization: _classPrivateFieldGet(this, _auth).auth,
  2075. origin: 'https://discord.com',
  2076. referer: `https://discord.com/invite/${inviteId}`
  2077. }
  2078. });
  2079. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2080. var _data$response, _data$response$guild;
  2081. logStatus.success();
  2082. 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);
  2083. if (guild) {
  2084. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2085. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  2086. }
  2087. return true;
  2088. }
  2089. logStatus.error(`${result}:${statusText}(${status})`);
  2090. return false;
  2091. } catch (error) {
  2092. throwError(error, 'Discord.joinServer');
  2093. return false;
  2094. }
  2095. }
  2096. async function _leaveServer2(inviteId) {
  2097. try {
  2098. if (this.whiteList.servers.includes(inviteId)) {
  2099. scripts_echoLog({
  2100. type: 'whiteList',
  2101. text: 'Discord.leaveServer',
  2102. id: inviteId
  2103. });
  2104. return true;
  2105. }
  2106. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  2107. if (!guild) {
  2108. return false;
  2109. }
  2110. const logStatus = scripts_echoLog({
  2111. type: 'leavingDiscordServer',
  2112. text: guild
  2113. });
  2114. const {
  2115. result,
  2116. statusText,
  2117. status,
  2118. data
  2119. } = await tools_httpRequest({
  2120. url: `https://discord.com/api/v9/users/@me/guilds/${guild}`,
  2121. method: 'DELETE',
  2122. headers: {
  2123. authorization: _classPrivateFieldGet(this, _auth).auth
  2124. }
  2125. });
  2126. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2127. logStatus.success();
  2128. return true;
  2129. }
  2130. logStatus.error(`${result}:${statusText}(${status})`);
  2131. return false;
  2132. } catch (error) {
  2133. throwError(error, 'Discord.leaveServer');
  2134. return false;
  2135. }
  2136. }
  2137. async function _getGuild2(inviteId) {
  2138. try {
  2139. const logStatus = scripts_echoLog({
  2140. type: 'gettingDiscordGuild',
  2141. text: inviteId
  2142. });
  2143. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2144. if (guild) {
  2145. logStatus.success();
  2146. return guild;
  2147. }
  2148. const {
  2149. result,
  2150. statusText,
  2151. status,
  2152. data
  2153. } = await tools_httpRequest({
  2154. url: `https://discord.com/api/v9/invites/${inviteId}`,
  2155. responseType: 'json',
  2156. method: 'GET'
  2157. });
  2158. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2159. var _data$response2, _data$response2$guild;
  2160. 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;
  2161. if (guild) {
  2162. logStatus.success();
  2163. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2164. return guild;
  2165. }
  2166. logStatus.error(`${result}:${statusText}(${status})`);
  2167. return false;
  2168. }
  2169. logStatus.error(`${result}:${statusText}(${status})`);
  2170. return false;
  2171. } catch (error) {
  2172. throwError(error, 'Discord.getGuild');
  2173. return false;
  2174. }
  2175. }
  2176. function _setCache2(inviteId, guild) {
  2177. try {
  2178. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2179. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2180. } catch (error) {
  2181. throwError(error, 'Discord.setCache');
  2182. }
  2183. }
  2184. const social_Discord = Discord;
  2185. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2186. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2187. privateSet.add(obj);
  2188. }
  2189. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2190. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2191. privateMap.set(obj, value);
  2192. }
  2193. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2194. if (privateCollection.has(obj)) {
  2195. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2196. }
  2197. }
  2198. function Instagram_defineProperty(obj, key, value) {
  2199. if (key in obj) {
  2200. Object.defineProperty(obj, key, {
  2201. value: value,
  2202. enumerable: true,
  2203. configurable: true,
  2204. writable: true
  2205. });
  2206. } else {
  2207. obj[key] = value;
  2208. }
  2209. return obj;
  2210. }
  2211. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2212. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2213. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2214. return value;
  2215. }
  2216. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2217. if (descriptor.set) {
  2218. descriptor.set.call(receiver, value);
  2219. } else {
  2220. if (!descriptor.writable) {
  2221. throw new TypeError('attempted to set read only private field');
  2222. }
  2223. descriptor.value = value;
  2224. }
  2225. }
  2226. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2227. if (!privateSet.has(receiver)) {
  2228. throw new TypeError('attempted to get private field on non-instance');
  2229. }
  2230. return fn;
  2231. }
  2232. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2233. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2234. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2235. }
  2236. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2237. if (!privateMap.has(receiver)) {
  2238. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2239. }
  2240. return privateMap.get(receiver);
  2241. }
  2242. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2243. if (descriptor.get) {
  2244. return descriptor.get.call(receiver);
  2245. }
  2246. return descriptor.value;
  2247. }
  2248. const Instagram_defaultTasksTemplate = {
  2249. users: []
  2250. };
  2251. const Instagram_defaultTasks = JSON.stringify(Instagram_defaultTasksTemplate);
  2252. var Instagram_cache = new WeakMap();
  2253. var Instagram_auth = new WeakMap();
  2254. var Instagram_initialized = new WeakMap();
  2255. var _getUserInfo = new WeakSet();
  2256. var _followUser = new WeakSet();
  2257. var _unfollowUser = new WeakSet();
  2258. var Instagram_setCache = new WeakSet();
  2259. class Instagram extends social_Social {
  2260. constructor() {
  2261. var _GM_getValue;
  2262. super(...arguments);
  2263. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2264. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2265. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2266. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2267. Instagram_defineProperty(this, 'tasks', JSON.parse(Instagram_defaultTasks));
  2268. Instagram_defineProperty(this, 'whiteList', {
  2269. ...JSON.parse(Instagram_defaultTasks),
  2270. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram
  2271. });
  2272. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2273. writable: true,
  2274. value: GM_getValue('instagramCache') || {}
  2275. });
  2276. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2277. writable: true,
  2278. value: {}
  2279. });
  2280. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2281. writable: true,
  2282. value: false
  2283. });
  2284. }
  2285. async init() {
  2286. try {
  2287. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2288. return true;
  2289. }
  2290. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2291. if (isVerified) {
  2292. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2293. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2294. return true;
  2295. }
  2296. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2297. return false;
  2298. } catch (error) {
  2299. throwError(error, 'Instagram.init');
  2300. return false;
  2301. }
  2302. }
  2303. async toggle(_ref) {
  2304. let {
  2305. doTask = true,
  2306. userLinks = []
  2307. } = _ref;
  2308. try {
  2309. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2310. scripts_echoLog({
  2311. text: i18n('needInit')
  2312. });
  2313. return false;
  2314. }
  2315. const prom = [];
  2316. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2317. scripts_echoLog({
  2318. type: 'globalOptionsSkip',
  2319. text: 'instagram.users'
  2320. });
  2321. } else {
  2322. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2323. var _link$match;
  2324. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2325. });
  2326. if (realUsers.length > 0) {
  2327. for (const username of realUsers) {
  2328. if (doTask) {
  2329. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2330. } else {
  2331. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2332. }
  2333. await delay(1e3);
  2334. }
  2335. }
  2336. }
  2337. return await Promise.all(prom).then(() => true);
  2338. } catch (error) {
  2339. throwError(error, 'Instagram.toggleUsers');
  2340. return false;
  2341. }
  2342. }
  2343. }
  2344. async function _getUserInfo2() {
  2345. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2346. try {
  2347. const logStatus = scripts_echoLog({
  2348. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2349. text: name
  2350. });
  2351. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2352. if (userId && name !== 'instagram') {
  2353. logStatus.success();
  2354. return userId;
  2355. }
  2356. const {
  2357. result,
  2358. statusText,
  2359. status,
  2360. data
  2361. } = await tools_httpRequest({
  2362. url: `https://www.instagram.com/${name}/`,
  2363. method: 'GET'
  2364. });
  2365. if (result === 'Success') {
  2366. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2367. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2368. return false;
  2369. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2370. logStatus.error(`Error:${i18n('insBanned')}`);
  2371. return false;
  2372. }
  2373. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2374. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2375. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2376. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2377. if (name === 'instagram') {
  2378. if (csrftoken && hash) {
  2379. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2380. csrftoken: csrftoken,
  2381. hash: hash
  2382. });
  2383. return true;
  2384. }
  2385. return false;
  2386. }
  2387. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2388. if (id) {
  2389. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2390. logStatus.success();
  2391. return id;
  2392. }
  2393. logStatus.error('Error: Get ins data error!');
  2394. return false;
  2395. }
  2396. logStatus.error(`${result}:${statusText}(${status})`);
  2397. return false;
  2398. }
  2399. return false;
  2400. } catch (error) {
  2401. throwError(error, 'Instagram.getUserInfo');
  2402. return false;
  2403. }
  2404. }
  2405. async function _followUser2(name) {
  2406. try {
  2407. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2408. if (!id) {
  2409. return false;
  2410. }
  2411. const logStatus = scripts_echoLog({
  2412. type: 'followingIns',
  2413. text: name
  2414. });
  2415. const {
  2416. result,
  2417. statusText,
  2418. status,
  2419. data
  2420. } = await tools_httpRequest({
  2421. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2422. method: 'POST',
  2423. dataType: 'json',
  2424. headers: {
  2425. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2426. origin: 'https://www.instagram.com',
  2427. referer: `https://www.instagram.com/${name}/`,
  2428. 'content-type': 'application/x-www-form-urlencoded',
  2429. 'sec-fetch-site': 'same-origin',
  2430. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2431. }
  2432. });
  2433. if (result === 'Success') {
  2434. var _data$response, _data$response2;
  2435. 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') {
  2436. logStatus.success();
  2437. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2438. return true;
  2439. }
  2440. 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})`}`);
  2441. return false;
  2442. }
  2443. logStatus.error(`${result}:${statusText}(${status})`);
  2444. return false;
  2445. } catch (error) {
  2446. throwError(error, 'Instagram.followUser');
  2447. return false;
  2448. }
  2449. }
  2450. async function _unfollowUser2(name) {
  2451. try {
  2452. if (this.whiteList.users.includes(name)) {
  2453. scripts_echoLog({
  2454. type: 'whiteList',
  2455. text: 'Instagram.unfollowUser',
  2456. id: name
  2457. });
  2458. return true;
  2459. }
  2460. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2461. if (!id) {
  2462. return false;
  2463. }
  2464. const logStatus = scripts_echoLog({
  2465. type: 'unfollowingIns',
  2466. text: name
  2467. });
  2468. const {
  2469. result,
  2470. statusText,
  2471. status,
  2472. data
  2473. } = await tools_httpRequest({
  2474. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2475. method: 'POST',
  2476. dataType: 'json',
  2477. headers: {
  2478. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2479. origin: 'https://www.instagram.com',
  2480. referer: `https://www.instagram.com/${name}/`,
  2481. 'content-type': 'application/x-www-form-urlencoded',
  2482. 'sec-fetch-site': 'same-origin',
  2483. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2484. }
  2485. });
  2486. if (result === 'Success') {
  2487. var _data$response3;
  2488. 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') {
  2489. logStatus.success();
  2490. return true;
  2491. }
  2492. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2493. return false;
  2494. }
  2495. logStatus.error(`${result}:${statusText}(${status})`);
  2496. return false;
  2497. } catch (error) {
  2498. throwError(error, 'Instagram.unfollowUser');
  2499. return false;
  2500. }
  2501. }
  2502. function Instagram_setCache2(name, id) {
  2503. try {
  2504. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2505. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2506. } catch (error) {
  2507. throwError(error, 'Instagram.setCache');
  2508. }
  2509. }
  2510. const social_Instagram = Instagram;
  2511. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2512. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2513. privateSet.add(obj);
  2514. }
  2515. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2516. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2517. privateMap.set(obj, value);
  2518. }
  2519. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2520. if (privateCollection.has(obj)) {
  2521. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2522. }
  2523. }
  2524. function Reddit_defineProperty(obj, key, value) {
  2525. if (key in obj) {
  2526. Object.defineProperty(obj, key, {
  2527. value: value,
  2528. enumerable: true,
  2529. configurable: true,
  2530. writable: true
  2531. });
  2532. } else {
  2533. obj[key] = value;
  2534. }
  2535. return obj;
  2536. }
  2537. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2538. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2539. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2540. return value;
  2541. }
  2542. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2543. if (descriptor.set) {
  2544. descriptor.set.call(receiver, value);
  2545. } else {
  2546. if (!descriptor.writable) {
  2547. throw new TypeError('attempted to set read only private field');
  2548. }
  2549. descriptor.value = value;
  2550. }
  2551. }
  2552. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2553. if (!privateSet.has(receiver)) {
  2554. throw new TypeError('attempted to get private field on non-instance');
  2555. }
  2556. return fn;
  2557. }
  2558. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2559. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2560. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2561. }
  2562. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2563. if (!privateMap.has(receiver)) {
  2564. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2565. }
  2566. return privateMap.get(receiver);
  2567. }
  2568. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2569. if (descriptor.get) {
  2570. return descriptor.get.call(receiver);
  2571. }
  2572. return descriptor.value;
  2573. }
  2574. const Reddit_defaultTasksTemplate = {
  2575. reddits: []
  2576. };
  2577. const Reddit_defaultTasks = JSON.stringify(Reddit_defaultTasksTemplate);
  2578. var Reddit_auth = new WeakMap();
  2579. var Reddit_initialized = new WeakMap();
  2580. var _useBeta = new WeakSet();
  2581. var Reddit_updateAuth = new WeakSet();
  2582. class Reddit extends social_Social {
  2583. constructor() {
  2584. var _GM_getValue;
  2585. super(...arguments);
  2586. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2587. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2588. Reddit_defineProperty(this, 'tasks', JSON.parse(Reddit_defaultTasks));
  2589. Reddit_defineProperty(this, 'whiteList', {
  2590. ...JSON.parse(Reddit_defaultTasks),
  2591. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit
  2592. });
  2593. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2594. writable: true,
  2595. value: void 0
  2596. });
  2597. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2598. writable: true,
  2599. value: false
  2600. });
  2601. }
  2602. async init() {
  2603. try {
  2604. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2605. return true;
  2606. }
  2607. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2608. if (isVerified) {
  2609. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2610. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2611. return true;
  2612. }
  2613. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2614. return false;
  2615. } catch (error) {
  2616. throwError(error, 'Reddit.init');
  2617. return false;
  2618. }
  2619. }
  2620. async toggleTask(_ref) {
  2621. let {
  2622. name,
  2623. doTask = true
  2624. } = _ref;
  2625. try {
  2626. if (!doTask && this.whiteList.reddits.includes(name)) {
  2627. scripts_echoLog({
  2628. type: 'whiteList',
  2629. text: 'Reddit.undoTask',
  2630. id: name
  2631. });
  2632. return true;
  2633. }
  2634. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2635. if (/^u_/.test(name)) {
  2636. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2637. }
  2638. const logStatus = scripts_echoLog({
  2639. type: type,
  2640. text: name
  2641. });
  2642. const {
  2643. result,
  2644. statusText,
  2645. status,
  2646. data
  2647. } = await tools_httpRequest({
  2648. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2649. method: 'POST',
  2650. headers: {
  2651. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2652. 'content-type': 'application/x-www-form-urlencoded'
  2653. },
  2654. data: $.param({
  2655. action: doTask ? 'sub' : 'unsub',
  2656. sr_name: name,
  2657. api_type: 'json'
  2658. })
  2659. });
  2660. if (result === 'Success') {
  2661. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2662. logStatus.success();
  2663. if (doTask) {
  2664. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2665. }
  2666. return true;
  2667. }
  2668. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2669. return false;
  2670. }
  2671. logStatus.error(`${result}:${statusText}(${status})`);
  2672. return false;
  2673. } catch (error) {
  2674. throwError(error, 'Reddit.toggleTask');
  2675. return false;
  2676. }
  2677. }
  2678. async toggle(_ref2) {
  2679. let {
  2680. doTask = true,
  2681. redditLinks = []
  2682. } = _ref2;
  2683. try {
  2684. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2685. scripts_echoLog({
  2686. text: i18n('needInit')
  2687. });
  2688. return false;
  2689. }
  2690. const prom = [];
  2691. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2692. scripts_echoLog({
  2693. type: 'globalOptionsSkip',
  2694. text: 'reddit.reddits'
  2695. });
  2696. } else {
  2697. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2698. var _link$match, _link$match2;
  2699. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2700. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2701. if (userName) {
  2702. return name || userName;
  2703. }
  2704. return name;
  2705. });
  2706. if (realReddits.length > 0) {
  2707. for (const name of realReddits) {
  2708. prom.push(this.toggleTask({
  2709. name: name,
  2710. doTask: doTask
  2711. }));
  2712. await delay(1e3);
  2713. }
  2714. }
  2715. }
  2716. return await Promise.all(prom).then(() => true);
  2717. } catch (error) {
  2718. throwError(error, 'Reddit.toggle');
  2719. return false;
  2720. }
  2721. }
  2722. }
  2723. async function _useBeta2() {
  2724. try {
  2725. const logStatus = scripts_echoLog({
  2726. text: i18n('changingRedditVersion')
  2727. });
  2728. GM_setValue('redditAuth', null);
  2729. return await new Promise(resolve => {
  2730. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2731. active: true,
  2732. insert: true,
  2733. setParent: true
  2734. });
  2735. newTab.onclose = async () => {
  2736. logStatus.success();
  2737. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2738. };
  2739. });
  2740. } catch (error) {
  2741. throwError(error, 'Reddit.useBeta');
  2742. return false;
  2743. }
  2744. }
  2745. async function Reddit_updateAuth2() {
  2746. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2747. try {
  2748. const logStatus = scripts_echoLog({
  2749. text: i18n('updatingAuth', 'Reddit')
  2750. });
  2751. const {
  2752. result,
  2753. statusText,
  2754. status,
  2755. data
  2756. } = await tools_httpRequest({
  2757. url: 'https://www.reddit.com/',
  2758. method: 'GET',
  2759. nochche: true,
  2760. headers: {
  2761. 'Cache-Control': 'no-cache'
  2762. }
  2763. });
  2764. if (result === 'Success') {
  2765. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2766. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2767. return false;
  2768. }
  2769. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2770. var _data$responseText$ma;
  2771. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2772. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2773. }
  2774. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2775. if (accessToken) {
  2776. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2777. token: accessToken
  2778. });
  2779. logStatus.success();
  2780. return true;
  2781. }
  2782. logStatus.error('Error: Parameter "accessToken" not found!');
  2783. return false;
  2784. }
  2785. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2786. return false;
  2787. }
  2788. logStatus.error(`${result}:${statusText}(${status})`);
  2789. return false;
  2790. } catch (error) {
  2791. throwError(error, 'Reddit.updateAuth');
  2792. return false;
  2793. }
  2794. }
  2795. const social_Reddit = Reddit;
  2796. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2797. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2798. privateSet.add(obj);
  2799. }
  2800. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2801. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2802. privateMap.set(obj, value);
  2803. }
  2804. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2805. if (privateCollection.has(obj)) {
  2806. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2807. }
  2808. }
  2809. function Twitch_defineProperty(obj, key, value) {
  2810. if (key in obj) {
  2811. Object.defineProperty(obj, key, {
  2812. value: value,
  2813. enumerable: true,
  2814. configurable: true,
  2815. writable: true
  2816. });
  2817. } else {
  2818. obj[key] = value;
  2819. }
  2820. return obj;
  2821. }
  2822. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2823. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2824. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2825. return value;
  2826. }
  2827. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2828. if (descriptor.set) {
  2829. descriptor.set.call(receiver, value);
  2830. } else {
  2831. if (!descriptor.writable) {
  2832. throw new TypeError('attempted to set read only private field');
  2833. }
  2834. descriptor.value = value;
  2835. }
  2836. }
  2837. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2838. if (!privateSet.has(receiver)) {
  2839. throw new TypeError('attempted to get private field on non-instance');
  2840. }
  2841. return fn;
  2842. }
  2843. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2844. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2845. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2846. }
  2847. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2848. if (!privateMap.has(receiver)) {
  2849. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2850. }
  2851. return privateMap.get(receiver);
  2852. }
  2853. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2854. if (descriptor.get) {
  2855. return descriptor.get.call(receiver);
  2856. }
  2857. return descriptor.value;
  2858. }
  2859. const Twitch_defaultTasksTemplate = {
  2860. channels: []
  2861. };
  2862. const Twitch_defaultTasks = JSON.stringify(Twitch_defaultTasksTemplate);
  2863. var Twitch_auth = new WeakMap();
  2864. var Twitch_cache = new WeakMap();
  2865. var Twitch_initialized = new WeakMap();
  2866. var Twitch_verifyAuth = new WeakSet();
  2867. var Twitch_updateAuth = new WeakSet();
  2868. var _toggleChannel = new WeakSet();
  2869. var _getChannelId = new WeakSet();
  2870. var Twitch_setCache = new WeakSet();
  2871. class Twitch extends social_Social {
  2872. constructor() {
  2873. var _GM_getValue;
  2874. super(...arguments);
  2875. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2876. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2877. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2878. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2879. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2880. Twitch_defineProperty(this, 'tasks', JSON.parse(Twitch_defaultTasks));
  2881. Twitch_defineProperty(this, 'whiteList', {
  2882. ...JSON.parse(Twitch_defaultTasks),
  2883. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch
  2884. });
  2885. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2886. writable: true,
  2887. value: GM_getValue('twitchAuth') || {}
  2888. });
  2889. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2890. writable: true,
  2891. value: GM_getValue('twitchCache') || {}
  2892. });
  2893. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2894. writable: true,
  2895. value: false
  2896. });
  2897. }
  2898. async init() {
  2899. try {
  2900. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2901. return true;
  2902. }
  2903. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2904. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2905. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2906. return true;
  2907. }
  2908. return false;
  2909. }
  2910. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2911. if (isVerified) {
  2912. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2913. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2914. return true;
  2915. }
  2916. GM_setValue('twitchAuth', null);
  2917. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2918. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2919. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2920. return true;
  2921. }
  2922. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2923. return false;
  2924. } catch (error) {
  2925. throwError(error, 'Twitch.init');
  2926. return false;
  2927. }
  2928. }
  2929. async toggle(_ref) {
  2930. let {
  2931. doTask = true,
  2932. channelLinks = []
  2933. } = _ref;
  2934. try {
  2935. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2936. scripts_echoLog({
  2937. text: i18n('needInit')
  2938. });
  2939. return false;
  2940. }
  2941. const prom = [];
  2942. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2943. scripts_echoLog({
  2944. type: 'globalOptionsSkip',
  2945. text: 'twitch.channels'
  2946. });
  2947. } else {
  2948. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2949. var _link$match;
  2950. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2951. });
  2952. if (realChannels.length > 0) {
  2953. for (const channel of realChannels) {
  2954. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2955. name: channel,
  2956. doTask: doTask
  2957. }));
  2958. await delay(1e3);
  2959. }
  2960. }
  2961. }
  2962. return Promise.all(prom).then(() => true);
  2963. } catch (error) {
  2964. throwError(error, 'Twitch.toggle');
  2965. return false;
  2966. }
  2967. }
  2968. }
  2969. async function Twitch_verifyAuth2() {
  2970. try {
  2971. const logStatus = scripts_echoLog({
  2972. text: i18n('verifyingAuth', 'Twitch')
  2973. });
  2974. const {
  2975. result,
  2976. statusText,
  2977. status,
  2978. data
  2979. } = await tools_httpRequest({
  2980. url: 'https://gql.twitch.tv/gql',
  2981. method: 'POST',
  2982. dataType: 'json',
  2983. headers: {
  2984. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2985. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2986. },
  2987. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2988. });
  2989. if (result === 'Success') {
  2990. var _data$response, _data$response$, _data$response$$data;
  2991. 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) {
  2992. logStatus.success();
  2993. return true;
  2994. }
  2995. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2996. return false;
  2997. }
  2998. logStatus.error(`${result}:${statusText}(${status})`);
  2999. return false;
  3000. } catch (error) {
  3001. throwError(error, 'Twitch.verifyAuth');
  3002. return false;
  3003. }
  3004. }
  3005. async function Twitch_updateAuth2() {
  3006. try {
  3007. const logStatus = scripts_echoLog({
  3008. text: i18n('updatingAuth', 'Twitch')
  3009. });
  3010. return await new Promise(resolve => {
  3011. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  3012. active: true,
  3013. insert: true,
  3014. setParent: true
  3015. });
  3016. newTab.onclose = async () => {
  3017. const auth = GM_getValue('twitchAuth');
  3018. if (auth) {
  3019. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  3020. logStatus.success();
  3021. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  3022. } else {
  3023. logStatus.error('Error: Update twitch auth failed!');
  3024. resolve(false);
  3025. }
  3026. };
  3027. });
  3028. } catch (error) {
  3029. throwError(error, 'Twitch.updateAuth');
  3030. return false;
  3031. }
  3032. }
  3033. async function _toggleChannel2(_ref2) {
  3034. let {
  3035. name,
  3036. doTask = true
  3037. } = _ref2;
  3038. try {
  3039. if (!doTask && this.whiteList.channels.includes(name)) {
  3040. scripts_echoLog({
  3041. type: 'whiteList',
  3042. text: 'Twitch.unfollowChannel',
  3043. id: name
  3044. });
  3045. return true;
  3046. }
  3047. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  3048. if (!channelId) {
  3049. return false;
  3050. }
  3051. const logStatus = scripts_echoLog({
  3052. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  3053. text: name
  3054. });
  3055. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  3056. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  3057. const {
  3058. result,
  3059. statusText,
  3060. status,
  3061. data
  3062. } = await tools_httpRequest({
  3063. url: 'https://gql.twitch.tv/gql',
  3064. method: 'POST',
  3065. dataType: 'json',
  3066. headers: {
  3067. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  3068. },
  3069. data: doTask ? followData : unfollowData
  3070. });
  3071. if (result === 'Success') {
  3072. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3073. logStatus.success();
  3074. if (doTask) {
  3075. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  3076. }
  3077. return true;
  3078. }
  3079. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3080. return false;
  3081. }
  3082. logStatus.error(`${result}:${statusText}(${status})`);
  3083. return false;
  3084. } catch (error) {
  3085. throwError(error, 'Twitch.toggleChannel');
  3086. return false;
  3087. }
  3088. }
  3089. async function _getChannelId2(name) {
  3090. try {
  3091. const logStatus = scripts_echoLog({
  3092. type: 'gettingTwitchChannelId',
  3093. text: name
  3094. });
  3095. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  3096. if (channelId) {
  3097. logStatus.success();
  3098. return channelId;
  3099. }
  3100. const {
  3101. result,
  3102. statusText,
  3103. status,
  3104. data
  3105. } = await tools_httpRequest({
  3106. url: 'https://gql.twitch.tv/gql',
  3107. method: 'POST',
  3108. headers: {
  3109. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  3110. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  3111. },
  3112. responseType: 'json',
  3113. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3114. });
  3115. if (result === 'Success') {
  3116. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3117. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3118. const channelId = String((_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$ = _data$response2[0]) === null || _data$response2$ === void 0 ? void 0 : (_data$response2$$data = _data$response2$.data) === null || _data$response2$$data === void 0 ? void 0 : (_data$response2$$data2 = _data$response2$$data.user) === null || _data$response2$$data2 === void 0 ? void 0 : _data$response2$$data2.id);
  3119. if (channelId) {
  3120. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3121. logStatus.success();
  3122. return channelId;
  3123. }
  3124. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3125. return false;
  3126. }
  3127. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3128. return false;
  3129. }
  3130. logStatus.error(`${result}:${statusText}(${status})`);
  3131. return false;
  3132. } catch (error) {
  3133. throwError(error, 'Twitch.getChannelId');
  3134. return false;
  3135. }
  3136. }
  3137. function Twitch_setCache2(name, id) {
  3138. try {
  3139. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3140. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3141. } catch (error) {
  3142. throwError(error, 'Twitch.setCache');
  3143. }
  3144. }
  3145. const social_Twitch = Twitch;
  3146. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3147. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3148. privateSet.add(obj);
  3149. }
  3150. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3151. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3152. privateMap.set(obj, value);
  3153. }
  3154. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3155. if (privateCollection.has(obj)) {
  3156. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3157. }
  3158. }
  3159. function Twitter_defineProperty(obj, key, value) {
  3160. if (key in obj) {
  3161. Object.defineProperty(obj, key, {
  3162. value: value,
  3163. enumerable: true,
  3164. configurable: true,
  3165. writable: true
  3166. });
  3167. } else {
  3168. obj[key] = value;
  3169. }
  3170. return obj;
  3171. }
  3172. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3173. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3174. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3175. return value;
  3176. }
  3177. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3178. if (descriptor.set) {
  3179. descriptor.set.call(receiver, value);
  3180. } else {
  3181. if (!descriptor.writable) {
  3182. throw new TypeError('attempted to set read only private field');
  3183. }
  3184. descriptor.value = value;
  3185. }
  3186. }
  3187. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3188. if (!privateSet.has(receiver)) {
  3189. throw new TypeError('attempted to get private field on non-instance');
  3190. }
  3191. return fn;
  3192. }
  3193. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3194. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3195. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3196. }
  3197. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3198. if (!privateMap.has(receiver)) {
  3199. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3200. }
  3201. return privateMap.get(receiver);
  3202. }
  3203. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3204. if (descriptor.get) {
  3205. return descriptor.get.call(receiver);
  3206. }
  3207. return descriptor.value;
  3208. }
  3209. const Twitter_defaultTasksTemplate = {
  3210. users: [],
  3211. retweets: [],
  3212. likes: []
  3213. };
  3214. const Twitter_defaultTasks = JSON.stringify(Twitter_defaultTasksTemplate);
  3215. var _verifyId = new WeakMap();
  3216. var Twitter_auth = new WeakMap();
  3217. var Twitter_cache = new WeakMap();
  3218. var Twitter_initialized = new WeakMap();
  3219. var Twitter_verifyAuth = new WeakSet();
  3220. var Twitter_updateAuth = new WeakSet();
  3221. var _toggleUser = new WeakSet();
  3222. var _toggleRetweet = new WeakSet();
  3223. var Twitter_setCache = new WeakSet();
  3224. class Twitter extends social_Social {
  3225. constructor() {
  3226. var _GM_getValue;
  3227. super(...arguments);
  3228. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3229. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3230. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3231. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3232. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3233. Twitter_defineProperty(this, 'tasks', JSON.parse(Twitter_defaultTasks));
  3234. Twitter_defineProperty(this, 'whiteList', {
  3235. ...JSON.parse(Twitter_defaultTasks),
  3236. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter
  3237. });
  3238. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3239. writable: true,
  3240. value: globalOptions.other.twitterVerifyId
  3241. });
  3242. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3243. writable: true,
  3244. value: GM_getValue('twitterAuth') || {}
  3245. });
  3246. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3247. writable: true,
  3248. value: GM_getValue('twitterCache') || {}
  3249. });
  3250. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3251. writable: true,
  3252. value: false
  3253. });
  3254. }
  3255. async init() {
  3256. try {
  3257. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3258. return true;
  3259. }
  3260. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3261. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3262. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3263. return true;
  3264. }
  3265. return false;
  3266. }
  3267. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3268. if (isVerified) {
  3269. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3270. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3271. return true;
  3272. }
  3273. GM_setValue('twitterAuth', null);
  3274. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3275. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3276. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3277. return true;
  3278. }
  3279. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3280. return false;
  3281. } catch (error) {
  3282. throwError(error, 'Twitter.init');
  3283. return false;
  3284. }
  3285. }
  3286. async userName2id(name) {
  3287. try {
  3288. const logStatus = scripts_echoLog({
  3289. type: 'gettingTwitterUserId',
  3290. text: name
  3291. });
  3292. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3293. if (userId) {
  3294. logStatus.success();
  3295. return userId;
  3296. }
  3297. const {
  3298. result,
  3299. statusText,
  3300. status,
  3301. data
  3302. } = await tools_httpRequest({
  3303. 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`,
  3304. method: 'GET',
  3305. headers: {
  3306. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3307. 'content-type': 'application/json',
  3308. referer: `https://twitter.com/${name}`,
  3309. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3310. },
  3311. responseType: 'json'
  3312. });
  3313. if (result === 'Success') {
  3314. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3315. var _response, _response$data, _response$data$user, _response$data$user$r;
  3316. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3317. if (!response) {
  3318. try {
  3319. response = JSON.parse(data.responseText);
  3320. } catch (error) {
  3321. response = null;
  3322. }
  3323. }
  3324. 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);
  3325. if (userId) {
  3326. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3327. logStatus.success();
  3328. return userId;
  3329. }
  3330. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3331. return false;
  3332. }
  3333. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3334. return false;
  3335. }
  3336. logStatus.error(`${result}:${statusText}(${status})`);
  3337. return false;
  3338. } catch (error) {
  3339. throwError(error, 'Twitter.getUserId');
  3340. return false;
  3341. }
  3342. }
  3343. async toggle(_ref) {
  3344. let {
  3345. doTask = true,
  3346. userLinks = [],
  3347. retweetLinks = []
  3348. } = _ref;
  3349. try {
  3350. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3351. scripts_echoLog({
  3352. text: i18n('needInit')
  3353. });
  3354. return false;
  3355. }
  3356. const prom = [];
  3357. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3358. scripts_echoLog({
  3359. type: 'globalOptionsSkip',
  3360. text: 'twitter.users'
  3361. });
  3362. } else {
  3363. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3364. var _link$match;
  3365. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3366. });
  3367. if (realUsers.length > 0) {
  3368. for (const user of realUsers) {
  3369. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3370. name: user,
  3371. doTask: doTask
  3372. }));
  3373. await delay(1e3);
  3374. }
  3375. }
  3376. }
  3377. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3378. scripts_echoLog({
  3379. type: 'globalOptionsSkip',
  3380. text: 'twitter.retweets'
  3381. });
  3382. } else {
  3383. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3384. var _link$match2;
  3385. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3386. });
  3387. if (realRetweets.length > 0) {
  3388. for (const retweet of realRetweets) {
  3389. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3390. retweetId: retweet,
  3391. doTask: doTask
  3392. }));
  3393. await delay(1e3);
  3394. }
  3395. }
  3396. }
  3397. return Promise.all(prom).then(() => true);
  3398. } catch (error) {
  3399. throwError(error, 'Twitter.toggle');
  3400. return false;
  3401. }
  3402. }
  3403. }
  3404. async function Twitter_verifyAuth2() {
  3405. try {
  3406. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3407. name: 'verify',
  3408. doTask: true,
  3409. verify: true
  3410. });
  3411. } catch (error) {
  3412. throwError(error, 'Twitter.verifyAuth');
  3413. return false;
  3414. }
  3415. }
  3416. async function Twitter_updateAuth2() {
  3417. try {
  3418. const logStatus = scripts_echoLog({
  3419. text: i18n('updatingAuth', 'Twitter')
  3420. });
  3421. return await new Promise(resolve => {
  3422. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3423. active: true,
  3424. insert: true,
  3425. setParent: true
  3426. });
  3427. newTab.onclose = async () => {
  3428. const auth = GM_getValue('twitterAuth');
  3429. if (auth) {
  3430. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3431. logStatus.success();
  3432. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3433. } else {
  3434. logStatus.error('Error: Update twitter auth failed!');
  3435. resolve(false);
  3436. }
  3437. };
  3438. });
  3439. } catch (error) {
  3440. throwError(error, 'Twitter.updateToken');
  3441. return false;
  3442. }
  3443. }
  3444. async function _toggleUser2(_ref2) {
  3445. let {
  3446. name,
  3447. doTask = true,
  3448. verify = false
  3449. } = _ref2;
  3450. try {
  3451. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3452. scripts_echoLog({
  3453. type: 'whiteList',
  3454. text: 'Twitter.unfollowUser',
  3455. id: name
  3456. });
  3457. return true;
  3458. }
  3459. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3460. if (!userId) {
  3461. return false;
  3462. }
  3463. const logStatus = verify ? scripts_echoLog({
  3464. text: i18n('verifyingAuth', 'Twitter')
  3465. }) : scripts_echoLog({
  3466. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3467. text: name
  3468. });
  3469. const {
  3470. result,
  3471. statusText,
  3472. status,
  3473. data
  3474. } = await tools_httpRequest({
  3475. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3476. method: 'POST',
  3477. headers: {
  3478. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3479. 'Content-Type': 'application/x-www-form-urlencoded',
  3480. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3481. },
  3482. responseType: 'json',
  3483. data: $.param({
  3484. include_profile_interstitial_type: 1,
  3485. include_blocking: 1,
  3486. include_blocked_by: 1,
  3487. include_followed_by: 1,
  3488. include_want_retweets: 1,
  3489. include_mute_edge: 1,
  3490. include_can_dm: 1,
  3491. include_can_media_tag: 1,
  3492. skip_status: 1,
  3493. id: userId
  3494. })
  3495. });
  3496. if (result === 'Success') {
  3497. var _data$response, _data$response$errors, _data$response$errors2;
  3498. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3499. logStatus.success();
  3500. if (doTask && !verify) {
  3501. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3502. }
  3503. return true;
  3504. }
  3505. 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) {
  3506. logStatus.success();
  3507. return true;
  3508. }
  3509. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3510. return false;
  3511. }
  3512. logStatus.error(`${result}:${statusText}(${status})`);
  3513. return false;
  3514. } catch (error) {
  3515. throwError(error, 'Twitter.toggleUser');
  3516. return false;
  3517. }
  3518. }
  3519. async function _toggleRetweet2(_ref3) {
  3520. let {
  3521. retweetId,
  3522. doTask = true
  3523. } = _ref3;
  3524. try {
  3525. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3526. scripts_echoLog({
  3527. type: 'whiteList',
  3528. text: 'Twitter.unretweet',
  3529. id: retweetId
  3530. });
  3531. return true;
  3532. }
  3533. const logStatus = scripts_echoLog({
  3534. type: `${doTask ? '' : 'un'}retweetting`,
  3535. text: retweetId
  3536. });
  3537. const {
  3538. result,
  3539. statusText,
  3540. status,
  3541. data
  3542. } = await tools_httpRequest({
  3543. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3544. method: 'POST',
  3545. headers: {
  3546. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3547. 'Content-Type': 'application/x-www-form-urlencoded',
  3548. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3549. },
  3550. data: $.param({
  3551. tweet_mode: 'extended',
  3552. id: retweetId
  3553. }),
  3554. responseType: 'json'
  3555. });
  3556. if (result === 'Success') {
  3557. var _data$response2, _data$response2$error, _data$response2$error2;
  3558. 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) {
  3559. logStatus.success();
  3560. if (doTask) {
  3561. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3562. }
  3563. return true;
  3564. }
  3565. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3566. return false;
  3567. }
  3568. logStatus.error(`${result}:${statusText}(${status})`);
  3569. return false;
  3570. } catch (error) {
  3571. throwError(error, 'Twitter.toggleRetweet');
  3572. return false;
  3573. }
  3574. }
  3575. function Twitter_setCache2(name, id) {
  3576. try {
  3577. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3578. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3579. } catch (error) {
  3580. throwError(error, 'Twitter.setCache');
  3581. }
  3582. }
  3583. const social_Twitter = Twitter;
  3584. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3585. Vk_checkPrivateRedeclaration(obj, privateSet);
  3586. privateSet.add(obj);
  3587. }
  3588. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3589. Vk_checkPrivateRedeclaration(obj, privateMap);
  3590. privateMap.set(obj, value);
  3591. }
  3592. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3593. if (privateCollection.has(obj)) {
  3594. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3595. }
  3596. }
  3597. function Vk_defineProperty(obj, key, value) {
  3598. if (key in obj) {
  3599. Object.defineProperty(obj, key, {
  3600. value: value,
  3601. enumerable: true,
  3602. configurable: true,
  3603. writable: true
  3604. });
  3605. } else {
  3606. obj[key] = value;
  3607. }
  3608. return obj;
  3609. }
  3610. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3611. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3612. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3613. return value;
  3614. }
  3615. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3616. if (descriptor.set) {
  3617. descriptor.set.call(receiver, value);
  3618. } else {
  3619. if (!descriptor.writable) {
  3620. throw new TypeError('attempted to set read only private field');
  3621. }
  3622. descriptor.value = value;
  3623. }
  3624. }
  3625. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3626. if (!privateSet.has(receiver)) {
  3627. throw new TypeError('attempted to get private field on non-instance');
  3628. }
  3629. return fn;
  3630. }
  3631. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3632. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3633. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3634. }
  3635. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3636. if (!privateMap.has(receiver)) {
  3637. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3638. }
  3639. return privateMap.get(receiver);
  3640. }
  3641. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3642. if (descriptor.get) {
  3643. return descriptor.get.call(receiver);
  3644. }
  3645. return descriptor.value;
  3646. }
  3647. const Vk_defaultTasksTemplate = {
  3648. names: []
  3649. };
  3650. const Vk_defaultTasks = JSON.stringify(Vk_defaultTasksTemplate);
  3651. var _username = new WeakMap();
  3652. var Vk_cache = new WeakMap();
  3653. var Vk_initialized = new WeakMap();
  3654. var Vk_verifyAuth = new WeakSet();
  3655. var _toggleGroup = new WeakSet();
  3656. var _togglePublic = new WeakSet();
  3657. var _sendWall = new WeakSet();
  3658. var _deleteWall = new WeakSet();
  3659. var _getId = new WeakSet();
  3660. var _toggleVk = new WeakSet();
  3661. var Vk_setCache = new WeakSet();
  3662. class Vk extends social_Social {
  3663. constructor() {
  3664. var _GM_getValue;
  3665. super(...arguments);
  3666. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3667. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3668. Vk_classPrivateMethodInitSpec(this, _getId);
  3669. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3670. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3671. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3672. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3673. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3674. Vk_defineProperty(this, 'tasks', JSON.parse(Vk_defaultTasks));
  3675. Vk_defineProperty(this, 'whiteList', {
  3676. ...JSON.parse(Vk_defaultTasks),
  3677. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk
  3678. });
  3679. Vk_classPrivateFieldInitSpec(this, _username, {
  3680. writable: true,
  3681. value: ''
  3682. });
  3683. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3684. writable: true,
  3685. value: GM_getValue('vkCache') || {}
  3686. });
  3687. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3688. writable: true,
  3689. value: false
  3690. });
  3691. }
  3692. async init() {
  3693. try {
  3694. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3695. return true;
  3696. }
  3697. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3698. if (isVerified) {
  3699. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3700. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3701. return true;
  3702. }
  3703. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3704. return false;
  3705. } catch (error) {
  3706. throwError(error, 'Vk.init');
  3707. return false;
  3708. }
  3709. }
  3710. async toggle(_ref) {
  3711. let {
  3712. doTask = true,
  3713. nameLinks = []
  3714. } = _ref;
  3715. try {
  3716. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3717. scripts_echoLog({
  3718. text: i18n('needInit')
  3719. });
  3720. return false;
  3721. }
  3722. const prom = [];
  3723. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3724. scripts_echoLog({
  3725. type: 'globalOptionsSkip',
  3726. text: 'vk.names'
  3727. });
  3728. } else {
  3729. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3730. var _link$match;
  3731. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3732. });
  3733. if (realNames.length > 0) {
  3734. for (const name of realNames) {
  3735. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3736. name: name,
  3737. doTask: doTask
  3738. }));
  3739. await delay(1e3);
  3740. }
  3741. }
  3742. }
  3743. return Promise.all(prom).then(() => true);
  3744. } catch (error) {
  3745. throwError(error, 'Vk.toggle');
  3746. return false;
  3747. }
  3748. }
  3749. }
  3750. async function Vk_verifyAuth2() {
  3751. try {
  3752. const logStatus = scripts_echoLog({
  3753. text: i18n('verifyAuth', 'Vk')
  3754. });
  3755. const {
  3756. result,
  3757. statusText,
  3758. status,
  3759. data
  3760. } = await tools_httpRequest({
  3761. url: 'https://vk.com/im',
  3762. method: 'GET'
  3763. });
  3764. if (result === 'Success') {
  3765. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3766. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3767. return false;
  3768. }
  3769. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3770. var _data$responseText$ma;
  3771. Vk_classPrivateFieldSet(this, _username, ((_data$responseText$ma = data.responseText.match(/TopNavBtn__profileLink" href="\/(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1]) || '');
  3772. logStatus.success();
  3773. return true;
  3774. }
  3775. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3776. return false;
  3777. }
  3778. logStatus.error(`${result}:${statusText}(${status})`);
  3779. return false;
  3780. } catch (error) {
  3781. throwError(error, 'Vk.verifyAuth');
  3782. return false;
  3783. }
  3784. }
  3785. async function _toggleGroup2(name, dataParam) {
  3786. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3787. try {
  3788. const logStatus = scripts_echoLog({
  3789. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3790. text: name
  3791. });
  3792. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3793. logStatus.success();
  3794. return true;
  3795. }
  3796. const reqData = {
  3797. act: doTask ? 'enter' : 'leave',
  3798. al: 1,
  3799. gid: dataParam.groupId,
  3800. hash: dataParam.groupHash
  3801. };
  3802. if (doTask) {
  3803. reqData.context = '_';
  3804. }
  3805. const {
  3806. result,
  3807. statusText,
  3808. status,
  3809. data
  3810. } = await tools_httpRequest({
  3811. url: 'https://vk.com/al_groups.php',
  3812. method: 'POST',
  3813. headers: {
  3814. origin: 'https://vk.com',
  3815. referer: `https://vk.com/${name}`,
  3816. 'content-type': 'application/x-www-form-urlencoded'
  3817. },
  3818. data: $.param(reqData)
  3819. });
  3820. if (result === 'Success') {
  3821. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3822. logStatus.success();
  3823. if (doTask) {
  3824. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3825. }
  3826. return true;
  3827. }
  3828. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3829. return false;
  3830. }
  3831. logStatus.error(`${result}:${statusText}(${status})`);
  3832. return false;
  3833. } catch (error) {
  3834. throwError(error, 'Vk.toggleGroup');
  3835. return false;
  3836. }
  3837. }
  3838. async function _togglePublic2(name, dataParam) {
  3839. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3840. try {
  3841. const logStatus = scripts_echoLog({
  3842. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3843. text: name
  3844. });
  3845. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3846. logStatus.success();
  3847. return true;
  3848. }
  3849. const {
  3850. result,
  3851. statusText,
  3852. status,
  3853. data
  3854. } = await tools_httpRequest({
  3855. url: 'https://vk.com/al_public.php',
  3856. method: 'POST',
  3857. headers: {
  3858. origin: 'https://vk.com',
  3859. referer: `https://vk.com/${name}`,
  3860. 'content-type': 'application/x-www-form-urlencoded'
  3861. },
  3862. data: $.param({
  3863. act: doTask ? 'a_enter' : 'a_leave',
  3864. al: 1,
  3865. pid: dataParam.publicPid,
  3866. hash: dataParam.publicHash
  3867. })
  3868. });
  3869. if (result === 'Success') {
  3870. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3871. logStatus.success();
  3872. if (doTask) {
  3873. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3874. }
  3875. return true;
  3876. }
  3877. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3878. return false;
  3879. }
  3880. logStatus.error(`${result}:${statusText}(${status})`);
  3881. return false;
  3882. } catch (error) {
  3883. throwError(error, 'Vk.togglePublic');
  3884. return false;
  3885. }
  3886. }
  3887. async function _sendWall2(name) {
  3888. try {
  3889. const logStatus = scripts_echoLog({
  3890. type: 'sendingVkWall',
  3891. text: name
  3892. });
  3893. const {
  3894. result,
  3895. statusText,
  3896. status,
  3897. data
  3898. } = await tools_httpRequest({
  3899. url: 'https://vk.com/like.php',
  3900. method: 'POST',
  3901. headers: {
  3902. origin: 'https://vk.com',
  3903. referer: `https://vk.com/${name}`,
  3904. 'content-type': 'application/x-www-form-urlencoded'
  3905. },
  3906. data: $.param({
  3907. act: 'publish_box',
  3908. al: 1,
  3909. object: name
  3910. })
  3911. });
  3912. if (result === 'Success') {
  3913. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3914. var _data$responseText$ma2;
  3915. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3916. if (hash) {
  3917. const {
  3918. result: resultR,
  3919. statusText: statusTextR,
  3920. status: statusR,
  3921. data: dataR
  3922. } = await tools_httpRequest({
  3923. url: 'https://vk.com/like.php',
  3924. method: 'POST',
  3925. headers: {
  3926. origin: 'https://vk.com',
  3927. referer: `https://vk.com/${name}`,
  3928. 'content-type': 'application/x-www-form-urlencoded'
  3929. },
  3930. data: $.param({
  3931. Message: '',
  3932. act: 'a_do_publish',
  3933. al: 1,
  3934. close_comments: 0,
  3935. friends_only: 0,
  3936. from: 'box',
  3937. hash: hash,
  3938. list: '',
  3939. mark_as_ads: 0,
  3940. mute_notifications: 0,
  3941. object: name,
  3942. ret_data: 1,
  3943. to: 0
  3944. })
  3945. });
  3946. if (resultR === 'Success') {
  3947. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3948. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3949. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3950. 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) {
  3951. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3952. logStatus.success();
  3953. 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);
  3954. 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);
  3955. if (postId && ownerId) {
  3956. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3957. }
  3958. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3959. return true;
  3960. }
  3961. }
  3962. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3963. return false;
  3964. }
  3965. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3966. return false;
  3967. }
  3968. logStatus.error('Error: Get "hash" failed');
  3969. return false;
  3970. }
  3971. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3972. return false;
  3973. }
  3974. logStatus.error(`${result}:${statusText}(${status})`);
  3975. return false;
  3976. } catch (error) {
  3977. throwError(error, 'Vk.sendWall');
  3978. return false;
  3979. }
  3980. }
  3981. async function _deleteWall2(name, dataParams) {
  3982. try {
  3983. const logStatus = scripts_echoLog({
  3984. type: 'deletingVkWall',
  3985. text: name
  3986. });
  3987. const {
  3988. result,
  3989. statusText,
  3990. status,
  3991. data
  3992. } = await tools_httpRequest({
  3993. url: 'https://vk.com/al_wall.php?act=delete',
  3994. method: 'POST',
  3995. headers: {
  3996. origin: 'https://vk.com',
  3997. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3998. 'content-type': 'application/x-www-form-urlencoded'
  3999. },
  4000. data: $.param({
  4001. act: 'delete',
  4002. al: 1,
  4003. confirm: 0,
  4004. from: 'wkview',
  4005. hash: dataParams.wallHash,
  4006. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  4007. })
  4008. });
  4009. if (result === 'Success') {
  4010. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4011. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  4012. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  4013. 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]) {
  4014. logStatus.success();
  4015. return true;
  4016. }
  4017. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4018. return false;
  4019. }
  4020. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4021. return false;
  4022. }
  4023. logStatus.error(`${result}:${statusText}(${status})`);
  4024. return false;
  4025. } catch (error) {
  4026. throwError(error, 'Vk.deleteWall');
  4027. return false;
  4028. }
  4029. }
  4030. async function _getId2(name, doTask) {
  4031. try {
  4032. let url = `https://vk.com/${name}`;
  4033. if (/^wall-/.test(name)) {
  4034. if (doTask) {
  4035. return {
  4036. type: 'sendWall'
  4037. };
  4038. }
  4039. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  4040. return {
  4041. type: 'unSupport'
  4042. };
  4043. }
  4044. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  4045. }
  4046. const logStatus = scripts_echoLog({
  4047. type: 'gettingVkId',
  4048. text: name
  4049. });
  4050. const {
  4051. result,
  4052. statusText,
  4053. status,
  4054. data
  4055. } = await tools_httpRequest({
  4056. url: url,
  4057. method: 'GET'
  4058. });
  4059. if (result === 'Success') {
  4060. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4061. var _data$responseText$ma3, _data$responseText$ma4;
  4062. const [ , groupAct, groupId, , groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), (&#39;|')(.*?)(&#39;|')/) || [];
  4063. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4064. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4065. const publicJoined = !data.responseText.includes('Public.subscribe');
  4066. if (groupAct && groupId && groupHash) {
  4067. logStatus.success();
  4068. return {
  4069. groupAct: groupAct,
  4070. groupId: groupId,
  4071. groupHash: groupHash,
  4072. type: 'group'
  4073. };
  4074. } else if (publicHash && publicPid) {
  4075. logStatus.success();
  4076. return {
  4077. publicHash: publicHash,
  4078. publicPid: publicPid,
  4079. publicJoined: publicJoined,
  4080. type: 'public'
  4081. };
  4082. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  4083. var _data$responseText$ma5;
  4084. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  4085. if (wallHash) {
  4086. logStatus.success();
  4087. return {
  4088. type: 'deleteWall',
  4089. wallHash: wallHash
  4090. };
  4091. }
  4092. } else if (name.includes('wall') && doTask) {
  4093. logStatus.success();
  4094. return {
  4095. type: 'sendWall'
  4096. };
  4097. }
  4098. logStatus.error('Error: Parameters not found!');
  4099. return false;
  4100. }
  4101. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4102. return false;
  4103. }
  4104. logStatus.error(`${result}:${statusText}(${status})`);
  4105. return false;
  4106. } catch (error) {
  4107. throwError(error, 'Vk.getId');
  4108. return false;
  4109. }
  4110. }
  4111. async function _toggleVk2(_ref2) {
  4112. let {
  4113. name,
  4114. doTask = true
  4115. } = _ref2;
  4116. try {
  4117. if (!doTask && this.whiteList.names.includes(name)) {
  4118. scripts_echoLog({
  4119. type: 'whiteList',
  4120. text: 'Vk.undoTask',
  4121. id: name
  4122. });
  4123. return true;
  4124. }
  4125. const formatName = name.replace(/\/$/, '');
  4126. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4127. if (!data) {
  4128. return false;
  4129. }
  4130. switch (data.type) {
  4131. case 'group':
  4132. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4133.  
  4134. case 'public':
  4135. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4136.  
  4137. case 'sendWall':
  4138. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4139.  
  4140. case 'deleteWall':
  4141. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4142.  
  4143. default:
  4144. return false;
  4145. }
  4146. } catch (error) {
  4147. throwError(error, 'Vk.toggleVk');
  4148. return false;
  4149. }
  4150. }
  4151. function Vk_setCache2(name, postId) {
  4152. try {
  4153. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4154. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4155. } catch (error) {
  4156. throwError(error, 'Vk.setCache');
  4157. }
  4158. }
  4159. const social_Vk = Vk;
  4160. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4161. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4162. privateSet.add(obj);
  4163. }
  4164. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4165. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4166. privateMap.set(obj, value);
  4167. }
  4168. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4169. if (privateCollection.has(obj)) {
  4170. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4171. }
  4172. }
  4173. function Youtube_defineProperty(obj, key, value) {
  4174. if (key in obj) {
  4175. Object.defineProperty(obj, key, {
  4176. value: value,
  4177. enumerable: true,
  4178. configurable: true,
  4179. writable: true
  4180. });
  4181. } else {
  4182. obj[key] = value;
  4183. }
  4184. return obj;
  4185. }
  4186. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4187. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4188. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4189. return value;
  4190. }
  4191. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4192. if (descriptor.set) {
  4193. descriptor.set.call(receiver, value);
  4194. } else {
  4195. if (!descriptor.writable) {
  4196. throw new TypeError('attempted to set read only private field');
  4197. }
  4198. descriptor.value = value;
  4199. }
  4200. }
  4201. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4202. if (!privateSet.has(receiver)) {
  4203. throw new TypeError('attempted to get private field on non-instance');
  4204. }
  4205. return fn;
  4206. }
  4207. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4208. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4209. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4210. }
  4211. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4212. if (!privateMap.has(receiver)) {
  4213. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4214. }
  4215. return privateMap.get(receiver);
  4216. }
  4217. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4218. if (descriptor.get) {
  4219. return descriptor.get.call(receiver);
  4220. }
  4221. return descriptor.value;
  4222. }
  4223. const Youtube_defaultTasksTemplate = {
  4224. channels: [],
  4225. likes: []
  4226. };
  4227. const Youtube_defaultTasks = JSON.stringify(Youtube_defaultTasksTemplate);
  4228. const getInfo = async function(link, type) {
  4229. try {
  4230. const logStatus = scripts_echoLog({
  4231. text: i18n('gettingYtbToken')
  4232. });
  4233. const {
  4234. result,
  4235. statusText,
  4236. status,
  4237. data
  4238. } = await tools_httpRequest({
  4239. url: link,
  4240. method: 'GET'
  4241. });
  4242. if (result === 'Success') {
  4243. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4244. var _data$responseText$ma, _ref;
  4245. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4246. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4247. return {
  4248. needLogin: true
  4249. };
  4250. }
  4251. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4252. 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]) || '{}';
  4253. const {
  4254. client,
  4255. request
  4256. } = JSON.parse(context);
  4257. if (apiKey && client && request) {
  4258. client.hl = 'en';
  4259. if (type === 'channel') {
  4260. var _data$responseText$ma2;
  4261. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4262. if (channelId) {
  4263. logStatus.success();
  4264. return {
  4265. params: {
  4266. apiKey: apiKey,
  4267. client: client,
  4268. request: request,
  4269. channelId: channelId
  4270. }
  4271. };
  4272. }
  4273. logStatus.error('Error: Get "channelId" failed!');
  4274. return {};
  4275. } else if (type === 'likeVideo') {
  4276. var _data$responseText$ma3, _data$responseText$ma4;
  4277. 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];
  4278. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4279. if (videoId) {
  4280. logStatus.success();
  4281. return {
  4282. params: {
  4283. apiKey: apiKey,
  4284. client: client,
  4285. request: request,
  4286. videoId: videoId,
  4287. likeParams: likeParams
  4288. }
  4289. };
  4290. }
  4291. logStatus.error('Error: Get "videoId" failed!');
  4292. return {};
  4293. }
  4294. logStatus.error('Error: Unknown type');
  4295. return {};
  4296. }
  4297. logStatus.error('Error: Parameter "apiKey" not found!');
  4298. return {};
  4299. }
  4300. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4301. return {};
  4302. }
  4303. logStatus.error(`${result}:${statusText}(${status})`);
  4304. return {};
  4305. } catch (error) {
  4306. throwError(error, 'Youtube.getInfo');
  4307. return {};
  4308. }
  4309. };
  4310. var Youtube_auth = new WeakMap();
  4311. var Youtube_initialized = new WeakMap();
  4312. var _verifyChannel = new WeakMap();
  4313. var Youtube_verifyAuth = new WeakSet();
  4314. var Youtube_updateAuth = new WeakSet();
  4315. var _getInfo = new WeakSet();
  4316. var Youtube_toggleChannel = new WeakSet();
  4317. var _toggleLikeVideo = new WeakSet();
  4318. class Youtube extends social_Social {
  4319. constructor() {
  4320. var _GM_getValue;
  4321. super(...arguments);
  4322. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4323. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4324. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4325. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4326. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4327. Youtube_defineProperty(this, 'tasks', JSON.parse(Youtube_defaultTasks));
  4328. Youtube_defineProperty(this, 'whiteList', {
  4329. ...JSON.parse(Youtube_defaultTasks),
  4330. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube
  4331. });
  4332. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4333. writable: true,
  4334. value: GM_getValue('youtubeAuth') || {}
  4335. });
  4336. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4337. writable: true,
  4338. value: false
  4339. });
  4340. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4341. writable: true,
  4342. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4343. });
  4344. }
  4345. async init() {
  4346. try {
  4347. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4348. return true;
  4349. }
  4350. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4351. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4352. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4353. return true;
  4354. }
  4355. return false;
  4356. }
  4357. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4358. if (isVerified) {
  4359. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4360. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4361. return true;
  4362. }
  4363. GM_setValue('youtubeAuth', null);
  4364. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4365. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4366. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4367. return true;
  4368. }
  4369. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4370. return false;
  4371. } catch (error) {
  4372. throwError(error, 'Youtube.init');
  4373. return false;
  4374. }
  4375. }
  4376. async toggle(_ref2) {
  4377. let {
  4378. doTask = true,
  4379. channelLinks = [],
  4380. videoLinks = []
  4381. } = _ref2;
  4382. try {
  4383. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4384. scripts_echoLog({
  4385. text: i18n('needInit')
  4386. });
  4387. return false;
  4388. }
  4389. const prom = [];
  4390. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4391. scripts_echoLog({
  4392. type: 'globalOptionsSkip',
  4393. text: 'youtube.channels'
  4394. });
  4395. } else {
  4396. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4397. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4398. var _link$match;
  4399. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4400. }
  4401. return link;
  4402. });
  4403. if (realChannels.length > 0) {
  4404. for (const channel of realChannels) {
  4405. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4406. link: channel,
  4407. doTask: doTask
  4408. }));
  4409. await delay(1e3);
  4410. }
  4411. }
  4412. }
  4413. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4414. scripts_echoLog({
  4415. type: 'globalOptionsSkip',
  4416. text: 'youtube.likes'
  4417. });
  4418. } else {
  4419. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4420. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4421. var _link$match2;
  4422. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4423. }
  4424. return link;
  4425. });
  4426. if (realLikes.length > 0) {
  4427. for (const video of realLikes) {
  4428. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4429. link: video,
  4430. doTask: doTask
  4431. }));
  4432. await delay(1e3);
  4433. }
  4434. }
  4435. }
  4436. return Promise.all(prom).then(() => true);
  4437. } catch (error) {
  4438. throwError(error, 'Youtube.toggle');
  4439. return false;
  4440. }
  4441. }
  4442. }
  4443. async function Youtube_verifyAuth2() {
  4444. try {
  4445. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4446. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4447. doTask: true,
  4448. verify: true
  4449. });
  4450. } catch (error) {
  4451. throwError(error, 'Youtube.verifyAuth');
  4452. return false;
  4453. }
  4454. }
  4455. async function Youtube_updateAuth2() {
  4456. try {
  4457. const logStatus = scripts_echoLog({
  4458. text: i18n('updatingAuth', 'Youtube')
  4459. });
  4460. return await new Promise(resolve => {
  4461. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4462. active: true,
  4463. insert: true,
  4464. setParent: true
  4465. });
  4466. newTab.onclose = async () => {
  4467. const auth = GM_getValue('youtubeAuth');
  4468. if (auth) {
  4469. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4470. logStatus.success();
  4471. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4472. resolve(result);
  4473. });
  4474. } else {
  4475. logStatus.error('Error: Update youtube auth failed!');
  4476. resolve(false);
  4477. }
  4478. };
  4479. });
  4480. } catch (error) {
  4481. throwError(error, 'Discord.updateAuth');
  4482. return false;
  4483. }
  4484. }
  4485. function _getInfo2(link, type) {
  4486. return getInfo(link, type);
  4487. }
  4488. async function Youtube_toggleChannel2(_ref3) {
  4489. let {
  4490. link,
  4491. doTask = true,
  4492. verify = false
  4493. } = _ref3;
  4494. try {
  4495. const {
  4496. params,
  4497. needLogin
  4498. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4499. const {
  4500. apiKey,
  4501. client,
  4502. request,
  4503. channelId
  4504. } = params || {};
  4505. if (needLogin) {
  4506. scripts_echoLog({
  4507. html: i18n('loginYtb')
  4508. });
  4509. return false;
  4510. }
  4511. if (!(apiKey && client && request && channelId)) {
  4512. scripts_echoLog({
  4513. text: '"getYtbToken" failed'
  4514. });
  4515. return false;
  4516. }
  4517. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4518. scripts_echoLog({
  4519. type: 'whiteList',
  4520. text: 'Youtube.unfollowChannel',
  4521. id: channelId
  4522. });
  4523. return true;
  4524. }
  4525. const logStatus = verify ? scripts_echoLog({
  4526. text: i18n('verifyingAuth', 'Youtube')
  4527. }) : scripts_echoLog({
  4528. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4529. text: channelId
  4530. });
  4531. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4532. const {
  4533. result,
  4534. statusText,
  4535. status,
  4536. data
  4537. } = await tools_httpRequest({
  4538. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4539. method: 'POST',
  4540. headers: {
  4541. origin: 'https://www.youtube.com',
  4542. referer: `https://www.youtube.com/channel/${channelId}`,
  4543. 'content-type': 'application/json',
  4544. 'x-goog-authuser': '0',
  4545. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4546. 'x-origin': 'https://www.youtube.com',
  4547. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4548. },
  4549. data: JSON.stringify({
  4550. context: {
  4551. client: client,
  4552. request: {
  4553. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4554. internalExperimentFlags: [],
  4555. consistencyTokenJars: []
  4556. },
  4557. user: {}
  4558. },
  4559. channelIds: [ channelId ],
  4560. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4561. })
  4562. });
  4563. if (result === 'Success') {
  4564. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4565. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4566. logStatus.success();
  4567. if (doTask && !verify) {
  4568. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4569. }
  4570. return true;
  4571. }
  4572. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4573. logStatus.success();
  4574. return true;
  4575. }
  4576. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4577. return false;
  4578. }
  4579. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4580. return false;
  4581. }
  4582. logStatus.error(`${result}:${statusText}(${status})`);
  4583. return false;
  4584. } catch (error) {
  4585. throwError(error, 'Youtube.toggleChannel');
  4586. return false;
  4587. }
  4588. }
  4589. async function _toggleLikeVideo2(_ref4) {
  4590. let {
  4591. link,
  4592. doTask = true
  4593. } = _ref4;
  4594. try {
  4595. const {
  4596. params,
  4597. needLogin
  4598. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4599. const {
  4600. apiKey,
  4601. client,
  4602. request,
  4603. videoId,
  4604. likeParams
  4605. } = params || {};
  4606. if (needLogin) {
  4607. scripts_echoLog({
  4608. html: `${i18n('loginYtb')}`
  4609. });
  4610. return false;
  4611. }
  4612. if (!(apiKey && client && request && videoId && likeParams)) {
  4613. scripts_echoLog({
  4614. text: '"getYtbToken" failed'
  4615. });
  4616. return false;
  4617. }
  4618. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4619. scripts_echoLog({
  4620. type: 'whiteList',
  4621. text: 'Youtube.unlikeVideo',
  4622. id: videoId
  4623. });
  4624. return true;
  4625. }
  4626. const logStatus = scripts_echoLog({
  4627. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4628. text: videoId
  4629. });
  4630. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4631. const likeVideoData = {
  4632. context: {
  4633. client: client,
  4634. request: {
  4635. sessionId: request.sessionId,
  4636. internalExperimentFlags: [],
  4637. consistencyTokenJars: []
  4638. },
  4639. user: {}
  4640. },
  4641. target: {
  4642. videoId: videoId
  4643. }
  4644. };
  4645. if (doTask) {
  4646. if (likeParams) {
  4647. likeVideoData.params = likeParams;
  4648. } else {
  4649. logStatus.error('Empty likeParams');
  4650. return false;
  4651. }
  4652. }
  4653. const {
  4654. result,
  4655. statusText,
  4656. status,
  4657. data
  4658. } = await tools_httpRequest({
  4659. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4660. method: 'POST',
  4661. headers: {
  4662. origin: 'https://www.youtube.com',
  4663. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4664. 'content-type': 'application/json',
  4665. 'x-goog-authuser': '0',
  4666. 'x-goog-visitor-id': client.visitorData,
  4667. 'x-origin': 'https://www.youtube.com',
  4668. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4669. },
  4670. data: JSON.stringify(likeVideoData)
  4671. });
  4672. if (result === 'Success') {
  4673. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4674. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4675. logStatus.success();
  4676. if (doTask) {
  4677. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4678. }
  4679. return true;
  4680. }
  4681. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4682. return false;
  4683. }
  4684. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4685. return false;
  4686. }
  4687. logStatus.error(`${result}:${statusText}(${status})`);
  4688. return false;
  4689. } catch (error) {
  4690. throwError(error, 'Youtube.toggleLikeVideo');
  4691. return false;
  4692. }
  4693. }
  4694. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4695. Steam_checkPrivateRedeclaration(obj, privateSet);
  4696. privateSet.add(obj);
  4697. }
  4698. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4699. Steam_checkPrivateRedeclaration(obj, privateMap);
  4700. privateMap.set(obj, value);
  4701. }
  4702. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4703. if (privateCollection.has(obj)) {
  4704. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4705. }
  4706. }
  4707. function Steam_defineProperty(obj, key, value) {
  4708. if (key in obj) {
  4709. Object.defineProperty(obj, key, {
  4710. value: value,
  4711. enumerable: true,
  4712. configurable: true,
  4713. writable: true
  4714. });
  4715. } else {
  4716. obj[key] = value;
  4717. }
  4718. return obj;
  4719. }
  4720. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4721. if (!privateSet.has(receiver)) {
  4722. throw new TypeError('attempted to get private field on non-instance');
  4723. }
  4724. return fn;
  4725. }
  4726. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4727. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4728. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4729. return value;
  4730. }
  4731. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4732. if (descriptor.set) {
  4733. descriptor.set.call(receiver, value);
  4734. } else {
  4735. if (!descriptor.writable) {
  4736. throw new TypeError('attempted to set read only private field');
  4737. }
  4738. descriptor.value = value;
  4739. }
  4740. }
  4741. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4742. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4743. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4744. }
  4745. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4746. if (!privateMap.has(receiver)) {
  4747. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4748. }
  4749. return privateMap.get(receiver);
  4750. }
  4751. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4752. if (descriptor.get) {
  4753. return descriptor.get.call(receiver);
  4754. }
  4755. return descriptor.value;
  4756. }
  4757. const Steam_defaultTasksTemplate = {
  4758. groups: [],
  4759. officialGroups: [],
  4760. wishlists: [],
  4761. follows: [],
  4762. forums: [],
  4763. workshops: [],
  4764. workshopVotes: [],
  4765. curators: [],
  4766. curatorLikes: [],
  4767. announcements: [],
  4768. licenses: [],
  4769. playtests: []
  4770. };
  4771. const Steam_defaultTasks = JSON.stringify(Steam_defaultTasksTemplate);
  4772. var Steam_cache = new WeakMap();
  4773. var Steam_auth = new WeakMap();
  4774. var _storeInitialized = new WeakMap();
  4775. var _communityInitialized = new WeakMap();
  4776. var _area = new WeakMap();
  4777. var _areaStatus = new WeakMap();
  4778. var _updateStoreAuth = new WeakSet();
  4779. var _updateCommunityAuth = new WeakSet();
  4780. var _getAreaInfo = new WeakSet();
  4781. var _changeArea = new WeakSet();
  4782. var _joinGroup = new WeakSet();
  4783. var _leaveGroup = new WeakSet();
  4784. var _getGroupId = new WeakSet();
  4785. var _joinOfficialGroup = new WeakSet();
  4786. var _leaveOfficialGroup = new WeakSet();
  4787. var _getOfficialGroupId = new WeakSet();
  4788. var _addToWishlist = new WeakSet();
  4789. var _removeFromWishlist = new WeakSet();
  4790. var _toggleFollowGame = new WeakSet();
  4791. var _isFollowedGame = new WeakSet();
  4792. var _toggleForum = new WeakSet();
  4793. var _getForumId = new WeakSet();
  4794. var _toggleFavoriteWorkshop = new WeakSet();
  4795. var _getWorkshopAppId = new WeakSet();
  4796. var _voteUpWorkshop = new WeakSet();
  4797. var _toggleCurator = new WeakSet();
  4798. var _toggleCuratorLike = new WeakSet();
  4799. var _getAnnouncementParams = new WeakSet();
  4800. var _likeAnnouncement = new WeakSet();
  4801. var _appid2subid = new WeakSet();
  4802. var _getLicenses = new WeakSet();
  4803. var _addLicense = new WeakSet();
  4804. var _addFreeLicense = new WeakSet();
  4805. var _requestPlayTestAccess = new WeakSet();
  4806. var Steam_setCache = new WeakSet();
  4807. class Steam extends social_Social {
  4808. constructor() {
  4809. var _GM_getValue;
  4810. super(...arguments);
  4811. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4812. Steam_classPrivateMethodInitSpec(this, _requestPlayTestAccess);
  4813. Steam_classPrivateMethodInitSpec(this, _addFreeLicense);
  4814. Steam_classPrivateMethodInitSpec(this, _addLicense);
  4815. Steam_classPrivateMethodInitSpec(this, _getLicenses);
  4816. Steam_classPrivateMethodInitSpec(this, _appid2subid);
  4817. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4818. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4819. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4820. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4821. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4822. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4823. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4824. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4825. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4826. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4827. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4828. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4829. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4830. Steam_classPrivateMethodInitSpec(this, _getOfficialGroupId);
  4831. Steam_classPrivateMethodInitSpec(this, _leaveOfficialGroup);
  4832. Steam_classPrivateMethodInitSpec(this, _joinOfficialGroup);
  4833. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4834. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4835. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4836. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4837. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4838. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4839. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4840. Steam_defineProperty(this, 'tasks', JSON.parse(Steam_defaultTasks));
  4841. Steam_defineProperty(this, 'whiteList', {
  4842. ...JSON.parse(Steam_defaultTasks),
  4843. ...(_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam
  4844. });
  4845. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4846. writable: true,
  4847. value: {
  4848. ...{
  4849. group: {},
  4850. officialGroup: {},
  4851. forum: {},
  4852. workshop: {},
  4853. curator: {}
  4854. },
  4855. ...GM_getValue('steamCache')
  4856. }
  4857. });
  4858. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4859. writable: true,
  4860. value: {}
  4861. });
  4862. Steam_classPrivateFieldInitSpec(this, _storeInitialized, {
  4863. writable: true,
  4864. value: false
  4865. });
  4866. Steam_classPrivateFieldInitSpec(this, _communityInitialized, {
  4867. writable: true,
  4868. value: false
  4869. });
  4870. Steam_classPrivateFieldInitSpec(this, _area, {
  4871. writable: true,
  4872. value: 'CN'
  4873. });
  4874. Steam_classPrivateFieldInitSpec(this, _areaStatus, {
  4875. writable: true,
  4876. value: 'end'
  4877. });
  4878. }
  4879. async init() {
  4880. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
  4881. try {
  4882. if (type === 'store') {
  4883. if (Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4884. return true;
  4885. }
  4886. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4887. if (!Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4888. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4889. return false;
  4890. }
  4891. scripts_echoLog({}).success(i18n('initSuccess', 'SteamStore'));
  4892. return true;
  4893. }
  4894. if (type === 'community') {
  4895. if (Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4896. return true;
  4897. }
  4898. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4899. if (!Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4900. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4901. return false;
  4902. }
  4903. scripts_echoLog({}).success(i18n('initSuccess', 'SteamCommunity'));
  4904. return true;
  4905. }
  4906. Steam_classPrivateFieldSet(this, _storeInitialized, await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this));
  4907. Steam_classPrivateFieldSet(this, _communityInitialized, await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this));
  4908. if (Steam_classPrivateFieldGet(this, _storeInitialized) && Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4909. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4910. return true;
  4911. }
  4912. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4913. return false;
  4914. } catch (error) {
  4915. throwError(error, 'Steam.init');
  4916. return false;
  4917. }
  4918. }
  4919. async getCuratorId(path, name) {
  4920. try {
  4921. const logStatus = scripts_echoLog({
  4922. type: 'gettingCuratorId',
  4923. text: `${path}/${name}`
  4924. });
  4925. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4926. if (curatorId) {
  4927. logStatus.success();
  4928. return curatorId;
  4929. }
  4930. const {
  4931. result,
  4932. statusText,
  4933. status,
  4934. data
  4935. } = await tools_httpRequest({
  4936. url: `https://store.steampowered.com/${path}/${name}`,
  4937. method: 'GET',
  4938. headers: {
  4939. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4940. }
  4941. });
  4942. if (result === 'Success') {
  4943. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4944. var _data$responseText$ma;
  4945. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4946. if (curatorId) {
  4947. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4948. logStatus.success();
  4949. return curatorId;
  4950. }
  4951. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4952. return false;
  4953. }
  4954. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4955. return false;
  4956. }
  4957. logStatus.error(`${result}:${statusText}(${status})`);
  4958. return false;
  4959. } catch (error) {
  4960. throwError(error, 'Steam.getCuratorID');
  4961. return false;
  4962. }
  4963. }
  4964. async toggle(_ref) {
  4965. let {
  4966. doTask = true,
  4967. groupLinks = [],
  4968. officialGroupLinks = [],
  4969. wishlistLinks = [],
  4970. followLinks = [],
  4971. forumLinks = [],
  4972. workshopLinks = [],
  4973. workshopVoteLinks = [],
  4974. curatorLinks = [],
  4975. curatorLikeLinks = [],
  4976. announcementLinks = [],
  4977. licenseLinks = [],
  4978. playtestLinks = []
  4979. } = _ref;
  4980. try {
  4981. if ([ ...groupLinks, ...officialGroupLinks, ...forumLinks, ...workshopLinks, ...workshopVoteLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _communityInitialized)) {
  4982. scripts_echoLog({
  4983. text: i18n('needInit')
  4984. });
  4985. return false;
  4986. }
  4987. if ([ ...wishlistLinks, ...followLinks, ...curatorLinks, ...curatorLikeLinks, ...announcementLinks, ...licenseLinks, ...playtestLinks ].length > 0 && !Steam_classPrivateFieldGet(this, _storeInitialized)) {
  4988. scripts_echoLog({
  4989. text: i18n('needInit')
  4990. });
  4991. return false;
  4992. }
  4993. const prom = [];
  4994. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4995. scripts_echoLog({
  4996. type: 'globalOptionsSkip',
  4997. text: 'steam.groups'
  4998. });
  4999. } else {
  5000. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  5001. var _link$match;
  5002. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  5003. });
  5004. if (realGroups.length > 0) {
  5005. for (const group of realGroups) {
  5006. if (doTask) {
  5007. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  5008. } else {
  5009. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  5010. }
  5011. await delay(1e3);
  5012. }
  5013. }
  5014. }
  5015. if (doTask && !globalOptions.doTask.steam.officialGroups || !doTask && !globalOptions.undoTask.steam.officialGroups) {
  5016. scripts_echoLog({
  5017. type: 'globalOptionsSkip',
  5018. text: 'steam.officialGroups'
  5019. });
  5020. } else {
  5021. const realOfficialGroups = this.getRealParams('officialGroups', officialGroupLinks, doTask, link => {
  5022. var _link$match2;
  5023. return (_link$match2 = link.match(/games\/(.+)\/?/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  5024. });
  5025. if (realOfficialGroups.length > 0) {
  5026. for (const officialGroup of realOfficialGroups) {
  5027. if (doTask) {
  5028. prom.push(Steam_classPrivateMethodGet(this, _joinOfficialGroup, _joinOfficialGroup2).call(this, officialGroup));
  5029. } else {
  5030. prom.push(Steam_classPrivateMethodGet(this, _leaveOfficialGroup, _leaveOfficialGroup2).call(this, officialGroup));
  5031. }
  5032. await delay(1e3);
  5033. }
  5034. }
  5035. }
  5036. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  5037. scripts_echoLog({
  5038. type: 'globalOptionsSkip',
  5039. text: 'steam.wishlists'
  5040. });
  5041. } else {
  5042. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  5043. var _link$match3;
  5044. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  5045. });
  5046. if (realWishlists.length > 0) {
  5047. for (const game of realWishlists) {
  5048. if (doTask) {
  5049. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  5050. } else {
  5051. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  5052. }
  5053. await delay(1e3);
  5054. }
  5055. }
  5056. }
  5057. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  5058. scripts_echoLog({
  5059. type: 'globalOptionsSkip',
  5060. text: 'steam.follows'
  5061. });
  5062. } else {
  5063. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  5064. var _link$match4;
  5065. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  5066. });
  5067. if (realFollows.length > 0) {
  5068. for (const game of realFollows) {
  5069. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  5070. await delay(1e3);
  5071. }
  5072. }
  5073. }
  5074. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  5075. scripts_echoLog({
  5076. type: 'globalOptionsSkip',
  5077. text: 'steam.forums'
  5078. });
  5079. } else {
  5080. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  5081. var _link$match5;
  5082. return (_link$match5 = link.match(/app\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  5083. });
  5084. if (realForums.length > 0) {
  5085. for (const forum of realForums) {
  5086. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  5087. await delay(1e3);
  5088. }
  5089. }
  5090. }
  5091. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  5092. scripts_echoLog({
  5093. type: 'globalOptionsSkip',
  5094. text: 'steam.workshops'
  5095. });
  5096. } else {
  5097. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  5098. var _link$match6;
  5099. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  5100. });
  5101. if (realWorkshops.length > 0) {
  5102. for (const workshop of realWorkshops) {
  5103. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  5104. await delay(1e3);
  5105. }
  5106. }
  5107. }
  5108. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  5109. scripts_echoLog({
  5110. type: 'globalOptionsSkip',
  5111. text: 'steam.workshopVotes'
  5112. });
  5113. } else {
  5114. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  5115. var _link$match7;
  5116. return (_link$match7 = link.match(/\?id=([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  5117. });
  5118. if (doTask && realworkshopVotes.length > 0) {
  5119. for (const workshop of realworkshopVotes) {
  5120. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  5121. await delay(1e3);
  5122. }
  5123. }
  5124. }
  5125. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  5126. scripts_echoLog({
  5127. type: 'globalOptionsSkip',
  5128. text: 'steam.curators'
  5129. });
  5130. } else {
  5131. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  5132. var _link$match8;
  5133. return (_link$match8 = link.match(/curator\/([\d]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8[1];
  5134. });
  5135. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  5136. var _link$match9;
  5137. return (_link$match9 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  5138. });
  5139. if (realCurators.length > 0) {
  5140. for (const curator of realCurators) {
  5141. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  5142. await delay(1e3);
  5143. }
  5144. }
  5145. if (realCuratorLikes.length > 0) {
  5146. for (const curatorLike of realCuratorLikes) {
  5147. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  5148. await delay(1e3);
  5149. }
  5150. }
  5151. }
  5152. if (doTask && !globalOptions.doTask.steam.announcements) {
  5153. scripts_echoLog({
  5154. type: 'globalOptionsSkip',
  5155. text: 'steam.announcements'
  5156. });
  5157. } else {
  5158. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  5159. var _link$match11;
  5160. if (link.includes('store.steampowered.com')) {
  5161. var _link$match10;
  5162. 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('/');
  5163. }
  5164. 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('/');
  5165. });
  5166. if (doTask && realAnnouncements.length > 0) {
  5167. for (const id of realAnnouncements) {
  5168. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  5169. await delay(1e3);
  5170. }
  5171. }
  5172. }
  5173. if (doTask && !globalOptions.doTask.steam.licenses) {
  5174. scripts_echoLog({
  5175. type: 'globalOptionsSkip',
  5176. text: 'steam.licenses'
  5177. });
  5178. } else if (doTask && globalOptions.doTask.steam.licenses && licenseLinks.length > 0) {
  5179. for (const id of licenseLinks) {
  5180. prom.push(Steam_classPrivateMethodGet(this, _addLicense, _addLicense2).call(this, id));
  5181. await delay(1e3);
  5182. }
  5183. }
  5184. if (doTask && !globalOptions.doTask.steam.playtests) {
  5185. scripts_echoLog({
  5186. type: 'globalOptionsSkip',
  5187. text: 'steam.playtests'
  5188. });
  5189. } else {
  5190. const realPlaytests = this.getRealParams('playtests', playtestLinks, doTask, link => {
  5191. var _link$match12;
  5192. return (_link$match12 = link.match(/app\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1];
  5193. });
  5194. if (doTask && globalOptions.doTask.steam.playtests && realPlaytests.length > 0) {
  5195. for (const id of realPlaytests) {
  5196. prom.push(Steam_classPrivateMethodGet(this, _requestPlayTestAccess, _requestPlayTestAccess2).call(this, id));
  5197. await delay(1e3);
  5198. }
  5199. }
  5200. }
  5201. return Promise.all(prom).then(async () => {
  5202. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5203. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  5204. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  5205. }
  5206. return true;
  5207. });
  5208. } catch (error) {
  5209. throwError(error, 'Steam.toggle');
  5210. return false;
  5211. }
  5212. }
  5213. }
  5214. async function _updateStoreAuth2() {
  5215. try {
  5216. const logStatus = scripts_echoLog({
  5217. text: i18n('updatingAuth', i18n('steamStore'))
  5218. });
  5219. const {
  5220. result,
  5221. statusText,
  5222. status,
  5223. data
  5224. } = await tools_httpRequest({
  5225. url: 'https://store.steampowered.com/stats/',
  5226. method: 'GET'
  5227. });
  5228. if (result === 'Success') {
  5229. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5230. var _data$responseText$ma2;
  5231. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5232. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5233. return false;
  5234. }
  5235. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5236. if (storeSessionID) {
  5237. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5238. logStatus.success();
  5239. return true;
  5240. }
  5241. logStatus.error('Error: Get "sessionID" failed');
  5242. return false;
  5243. }
  5244. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5245. return false;
  5246. }
  5247. logStatus.error(`${result}:${statusText}(${status})`);
  5248. return false;
  5249. } catch (error) {
  5250. throwError(error, 'Steam.updateStoreAuth');
  5251. return false;
  5252. }
  5253. }
  5254. async function _updateCommunityAuth2() {
  5255. try {
  5256. const logStatus = scripts_echoLog({
  5257. text: i18n('updatingAuth', i18n('steamCommunity'))
  5258. });
  5259. const {
  5260. result,
  5261. statusText,
  5262. status,
  5263. data
  5264. } = await tools_httpRequest({
  5265. url: 'https://steamcommunity.com/my',
  5266. method: 'GET'
  5267. });
  5268. if (result === 'Success') {
  5269. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5270. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5271. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5272. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5273. return false;
  5274. }
  5275. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5276. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5277. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5278. if (steam64Id) {
  5279. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5280. }
  5281. if (userName) {
  5282. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5283. }
  5284. if (communitySessionID) {
  5285. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5286. logStatus.success();
  5287. return true;
  5288. }
  5289. logStatus.error('Error: Get "sessionID" failed');
  5290. return false;
  5291. }
  5292. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5293. return false;
  5294. }
  5295. logStatus.error(`${result}:${statusText}(${status})`);
  5296. return false;
  5297. } catch (error) {
  5298. throwError(error, 'Steam.updateCommunityAuth');
  5299. return false;
  5300. }
  5301. }
  5302. async function _getAreaInfo2() {
  5303. try {
  5304. const logStatus = scripts_echoLog({
  5305. text: i18n('gettingAreaInfo')
  5306. });
  5307. const {
  5308. result,
  5309. statusText,
  5310. status,
  5311. data
  5312. } = await tools_httpRequest({
  5313. url: 'https://store.steampowered.com/cart/',
  5314. method: 'GET'
  5315. });
  5316. if (result === 'Success') {
  5317. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5318. var _data$responseText$ma6;
  5319. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5320. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5321. if (currentArea && areas.length > 0) {
  5322. Steam_classPrivateFieldSet(this, _area, currentArea);
  5323. logStatus.success();
  5324. return {
  5325. currentArea: currentArea,
  5326. areas: areas
  5327. };
  5328. }
  5329. logStatus.error('Error: get country info filed');
  5330. return {};
  5331. }
  5332. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5333. return {};
  5334. }
  5335. logStatus.error(`${result}:${statusText}(${status})`);
  5336. return {};
  5337. } catch (error) {
  5338. throwError(error, 'Steam.getAreaInfo');
  5339. return {};
  5340. }
  5341. }
  5342. async function _changeArea2(area) {
  5343. try {
  5344. if (Steam_classPrivateFieldGet(this, _areaStatus) === 'waiting') {
  5345. await new Promise(resolve => {
  5346. const checker = setInterval(() => {
  5347. if (Steam_classPrivateFieldGet(this, _areaStatus) !== 'waiting') {
  5348. clearInterval(checker);
  5349. resolve(true);
  5350. }
  5351. });
  5352. });
  5353. }
  5354. if (Steam_classPrivateFieldGet(this, _area) === area || !area && Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  5355. return true;
  5356. }
  5357. Steam_classPrivateFieldSet(this, _areaStatus, 'waiting');
  5358. let aimedArea = area;
  5359. if (!aimedArea) {
  5360. const {
  5361. currentArea,
  5362. areas
  5363. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5364. if (!currentArea || !areas) {
  5365. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5366. return false;
  5367. }
  5368. if (currentArea !== 'CN') {
  5369. Steam_classPrivateFieldSet(this, _areaStatus, 'skip');
  5370. scripts_echoLog({
  5371. text: 'notNeededChangeArea'
  5372. });
  5373. return 'skip';
  5374. }
  5375. const anotherArea = areas.filter(area => area && area !== 'CN');
  5376. if (!anotherArea || anotherArea.length === 0) {
  5377. Steam_classPrivateFieldSet(this, _areaStatus, 'noAnotherArea');
  5378. scripts_echoLog({
  5379. text: 'noAnotherArea'
  5380. });
  5381. return false;
  5382. }
  5383. [ aimedArea ] = anotherArea;
  5384. }
  5385. const logStatus = scripts_echoLog({
  5386. text: i18n('changingArea', aimedArea)
  5387. });
  5388. const {
  5389. result,
  5390. statusText,
  5391. status,
  5392. data
  5393. } = await tools_httpRequest({
  5394. url: 'https://store.steampowered.com/account/setcountry',
  5395. method: 'POST',
  5396. headers: {
  5397. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5398. },
  5399. data: $.param({
  5400. cc: aimedArea,
  5401. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5402. })
  5403. });
  5404. if (result === 'Success') {
  5405. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5406. const {
  5407. currentArea
  5408. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5409. if (currentArea === aimedArea) {
  5410. Steam_classPrivateFieldSet(this, _areaStatus, 'success');
  5411. logStatus.success();
  5412. return currentArea;
  5413. }
  5414. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5415. logStatus.error('Error: change country filed');
  5416. return 'CN';
  5417. }
  5418. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5419. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5420. return 'CN';
  5421. }
  5422. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5423. logStatus.error(`${result}:${statusText}(${status})`);
  5424. return 'CN';
  5425. } catch (error) {
  5426. Steam_classPrivateFieldSet(this, _areaStatus, 'error');
  5427. throwError(error, 'Steam.changeArea');
  5428. return false;
  5429. }
  5430. }
  5431. async function _joinGroup2(groupName) {
  5432. try {
  5433. const logStatus = scripts_echoLog({
  5434. type: 'joiningSteamGroup',
  5435. text: groupName
  5436. });
  5437. const {
  5438. result,
  5439. statusText,
  5440. status,
  5441. data
  5442. } = await tools_httpRequest({
  5443. url: `https://steamcommunity.com/groups/${groupName}`,
  5444. method: 'POST',
  5445. headers: {
  5446. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5447. },
  5448. data: $.param({
  5449. action: 'join',
  5450. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5451. })
  5452. });
  5453. if (result === 'Success') {
  5454. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5455. logStatus.success();
  5456. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5457. return true;
  5458. }
  5459. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5460. return false;
  5461. }
  5462. logStatus.error(`${result}:${statusText}(${status})`);
  5463. return false;
  5464. } catch (error) {
  5465. throwError(error, 'Steam.joinGroup');
  5466. return false;
  5467. }
  5468. }
  5469. async function _leaveGroup2(groupName) {
  5470. try {
  5471. if (this.whiteList.groups.includes(groupName)) {
  5472. scripts_echoLog({
  5473. type: 'whiteList',
  5474. text: 'Steam.leaveGroup',
  5475. id: groupName
  5476. });
  5477. return true;
  5478. }
  5479. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5480. if (!groupId) {
  5481. return false;
  5482. }
  5483. const logStatus = scripts_echoLog({
  5484. type: 'leavingSteamGroup',
  5485. text: groupName
  5486. });
  5487. const {
  5488. result,
  5489. statusText,
  5490. status,
  5491. data
  5492. } = await tools_httpRequest({
  5493. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5494. method: 'POST',
  5495. headers: {
  5496. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5497. },
  5498. data: $.param({
  5499. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5500. action: 'leaveGroup',
  5501. groupId: groupId
  5502. })
  5503. });
  5504. if (result === 'Success') {
  5505. 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) {
  5506. logStatus.success();
  5507. return true;
  5508. }
  5509. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5510. return false;
  5511. }
  5512. logStatus.error(`${result}:${statusText}(${status})`);
  5513. return false;
  5514. } catch (error) {
  5515. throwError(error, 'Steam.leaveGroup');
  5516. return false;
  5517. }
  5518. }
  5519. async function _getGroupId2(groupName) {
  5520. try {
  5521. const logStatus = scripts_echoLog({
  5522. type: 'gettingSteamGroupId',
  5523. text: groupName
  5524. });
  5525. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5526. if (groupId) {
  5527. logStatus.success();
  5528. return groupId;
  5529. }
  5530. const {
  5531. result,
  5532. statusText,
  5533. status,
  5534. data
  5535. } = await tools_httpRequest({
  5536. url: `https://steamcommunity.com/groups/${groupName}`,
  5537. method: 'GET',
  5538. headers: {
  5539. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5540. }
  5541. });
  5542. if (result === 'Success') {
  5543. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5544. var _data$responseText$ma7;
  5545. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5546. if (groupId) {
  5547. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5548. logStatus.success();
  5549. return groupId;
  5550. }
  5551. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5552. return false;
  5553. }
  5554. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5555. return false;
  5556. }
  5557. logStatus.error(`${result}:${statusText}(${status})`);
  5558. return false;
  5559. } catch (error) {
  5560. throwError(error, 'Steam.getGroupID');
  5561. return false;
  5562. }
  5563. }
  5564. async function _joinOfficialGroup2(gameId) {
  5565. try {
  5566. const logStatus = scripts_echoLog({
  5567. type: 'joiningSteamOfficialGroup',
  5568. text: gameId
  5569. });
  5570. const {
  5571. result,
  5572. statusText,
  5573. status,
  5574. data
  5575. } = await tools_httpRequest({
  5576. url: `https://steamcommunity.com/games/${gameId}?action=join&sessionID=${Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID}`,
  5577. method: 'GET',
  5578. headers: {
  5579. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5580. }
  5581. });
  5582. if (result === 'Success') {
  5583. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('id="publicGroupJoin"')) {
  5584. var _data$responseText$ma8;
  5585. logStatus.success();
  5586. this.tasks.officialGroups = unique([ ...this.tasks.officialGroups, gameId ]);
  5587. 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];
  5588. if (groupId) {
  5589. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5590. }
  5591. return true;
  5592. }
  5593. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5594. return false;
  5595. }
  5596. logStatus.error(`${result}:${statusText}(${status})`);
  5597. return false;
  5598. } catch (error) {
  5599. throwError(error, 'Steam.joinOfficialGroup');
  5600. return false;
  5601. }
  5602. }
  5603. async function _leaveOfficialGroup2(gameId) {
  5604. try {
  5605. if (this.whiteList.officialGroups.includes(gameId)) {
  5606. scripts_echoLog({
  5607. type: 'whiteList',
  5608. text: 'Steam.leaveOfficialGroup',
  5609. id: gameId
  5610. });
  5611. return true;
  5612. }
  5613. const groupId = await Steam_classPrivateMethodGet(this, _getOfficialGroupId, _getOfficialGroupId2).call(this, gameId);
  5614. if (!groupId) {
  5615. return false;
  5616. }
  5617. const logStatus = scripts_echoLog({
  5618. type: 'leavingSteamOfficialGroup',
  5619. text: gameId
  5620. });
  5621. const {
  5622. result,
  5623. statusText,
  5624. status,
  5625. data
  5626. } = await tools_httpRequest({
  5627. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5628. method: 'POST',
  5629. headers: {
  5630. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5631. },
  5632. data: $.param({
  5633. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5634. action: 'leaveGroup',
  5635. groupId: groupId
  5636. })
  5637. });
  5638. if (result === 'Success') {
  5639. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5640. const {
  5641. result: resultR,
  5642. statusText: statusTextR,
  5643. status: statusR,
  5644. data: dataR
  5645. } = await tools_httpRequest({
  5646. url: `https://steamcommunity.com/games/${gameId}`,
  5647. method: 'GET',
  5648. headers: {
  5649. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5650. }
  5651. });
  5652. if (resultR === 'Success') {
  5653. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200 && dataR.responseText.includes('id="publicGroupJoin"')) {
  5654. logStatus.success();
  5655. return true;
  5656. }
  5657. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5658. return false;
  5659. }
  5660. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5661. return false;
  5662. }
  5663. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5664. return false;
  5665. }
  5666. logStatus.error(`${result}:${statusText}(${status})`);
  5667. return false;
  5668. } catch (error) {
  5669. throwError(error, 'Steam.leaveOfficialGroup');
  5670. return false;
  5671. }
  5672. }
  5673. async function _getOfficialGroupId2(gameId) {
  5674. try {
  5675. const logStatus = scripts_echoLog({
  5676. type: 'gettingSteamOfficialGroupId',
  5677. text: gameId
  5678. });
  5679. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).officialGroup[gameId];
  5680. if (groupId) {
  5681. logStatus.success();
  5682. return groupId;
  5683. }
  5684. const {
  5685. result,
  5686. statusText,
  5687. status,
  5688. data
  5689. } = await tools_httpRequest({
  5690. url: `https://steamcommunity.com/games/${gameId}`,
  5691. method: 'GET',
  5692. headers: {
  5693. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5694. }
  5695. });
  5696. if (result === 'Success') {
  5697. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5698. var _data$responseText$ma9;
  5699. const groupId = (_data$responseText$ma9 = data.responseText.match(/steam:\/\/friends\/joinchat\/([0-9]+)/)) === null || _data$responseText$ma9 === void 0 ? void 0 : _data$responseText$ma9[1];
  5700. if (groupId) {
  5701. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'officialGroup', gameId, groupId);
  5702. logStatus.success();
  5703. return groupId;
  5704. }
  5705. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5706. return false;
  5707. }
  5708. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5709. return false;
  5710. }
  5711. logStatus.error(`${result}:${statusText}(${status})`);
  5712. return false;
  5713. } catch (error) {
  5714. throwError(error, 'Steam.getGroupID');
  5715. return false;
  5716. }
  5717. }
  5718. async function _addToWishlist2(gameId) {
  5719. try {
  5720. var _data$response;
  5721. const logStatus = scripts_echoLog({
  5722. type: 'addingToWishlist',
  5723. text: gameId
  5724. });
  5725. const {
  5726. result,
  5727. data
  5728. } = await tools_httpRequest({
  5729. url: 'https://store.steampowered.com/api/addtowishlist',
  5730. method: 'POST',
  5731. headers: {
  5732. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5733. },
  5734. data: $.param({
  5735. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5736. appid: gameId
  5737. }),
  5738. dataType: 'json'
  5739. });
  5740. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.success) === true) {
  5741. logStatus.success();
  5742. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5743. return true;
  5744. }
  5745. const {
  5746. result: resultR,
  5747. statusText: statusTextR,
  5748. status: statusR,
  5749. data: dataR
  5750. } = await tools_httpRequest({
  5751. url: `https://store.steampowered.com/app/${gameId}`,
  5752. method: 'GET'
  5753. });
  5754. if (resultR === 'Success') {
  5755. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5756. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5757. logStatus.warning(i18n('changeAreaNotice'));
  5758. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5759. return false;
  5760. }
  5761. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5762. }
  5763. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5764. logStatus.success();
  5765. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5766. return true;
  5767. } 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"')) {
  5768. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5769. return false;
  5770. }
  5771. logStatus.success();
  5772. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5773. return true;
  5774. }
  5775. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5776. return false;
  5777. }
  5778. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5779. return false;
  5780. } catch (error) {
  5781. throwError(error, 'Steam.addToWishlist');
  5782. return false;
  5783. }
  5784. }
  5785. async function _removeFromWishlist2(gameId) {
  5786. try {
  5787. var _data$response2;
  5788. if (this.whiteList.wishlists.includes(gameId)) {
  5789. scripts_echoLog({
  5790. type: 'whiteList',
  5791. text: 'Steam.removeFromWishlist',
  5792. id: gameId
  5793. });
  5794. return true;
  5795. }
  5796. const logStatus = scripts_echoLog({
  5797. type: 'removingFromWishlist',
  5798. text: gameId
  5799. });
  5800. const {
  5801. result,
  5802. data
  5803. } = await tools_httpRequest({
  5804. url: 'https://store.steampowered.com/api/removefromwishlist',
  5805. method: 'POST',
  5806. headers: {
  5807. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5808. },
  5809. data: $.param({
  5810. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5811. appid: gameId
  5812. }),
  5813. dataType: 'json'
  5814. });
  5815. 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) {
  5816. logStatus.success();
  5817. return true;
  5818. }
  5819. const {
  5820. result: resultR,
  5821. statusText: statusTextR,
  5822. status: statusR,
  5823. data: dataR
  5824. } = await tools_httpRequest({
  5825. url: `https://store.steampowered.com/app/${gameId}`,
  5826. method: 'GET'
  5827. });
  5828. if (resultR === 'Success') {
  5829. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5830. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5831. logStatus.warning(i18n('changeAreaNotice'));
  5832. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5833. if (!result || result === 'CN' || result === 'skip') {
  5834. return false;
  5835. }
  5836. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5837. }
  5838. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5839. logStatus.success();
  5840. return true;
  5841. }
  5842. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5843. return false;
  5844. }
  5845. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5846. return false;
  5847. }
  5848. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5849. return false;
  5850. } catch (error) {
  5851. throwError(error, 'Steam.removeFromWishlist');
  5852. return false;
  5853. }
  5854. }
  5855. async function _toggleFollowGame2(gameId, doTask) {
  5856. try {
  5857. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5858. scripts_echoLog({
  5859. type: 'whiteList',
  5860. text: 'Steam.unfollowGame',
  5861. id: gameId
  5862. });
  5863. return true;
  5864. }
  5865. const logStatus = scripts_echoLog({
  5866. type: `${doTask ? '' : 'un'}followingGame`,
  5867. text: gameId
  5868. });
  5869. const requestData = {
  5870. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5871. appid: gameId
  5872. };
  5873. if (!doTask) {
  5874. requestData.unfollow = '1';
  5875. }
  5876. const {
  5877. result,
  5878. data
  5879. } = await tools_httpRequest({
  5880. url: 'https://store.steampowered.com/explore/followgame/',
  5881. method: 'POST',
  5882. headers: {
  5883. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5884. },
  5885. data: $.param(requestData)
  5886. });
  5887. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5888. logStatus.success();
  5889. return true;
  5890. }
  5891. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5892. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5893. logStatus.warning(i18n('changeAreaNotice'));
  5894. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5895. return false;
  5896. }
  5897. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5898. }
  5899. if (doTask === followed) {
  5900. logStatus.success();
  5901. if (doTask) {
  5902. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5903. }
  5904. return true;
  5905. }
  5906. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5907. return false;
  5908. } catch (error) {
  5909. throwError(error, 'Steam.toggleFollowGame');
  5910. return false;
  5911. }
  5912. }
  5913. async function _isFollowedGame2(gameId) {
  5914. try {
  5915. const {
  5916. result,
  5917. data
  5918. } = await tools_httpRequest({
  5919. url: `https://store.steampowered.com/app/${gameId}`,
  5920. method: 'GET'
  5921. });
  5922. if (result === 'Success') {
  5923. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5924. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5925. return 'areaLocked';
  5926. }
  5927. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5928. return true;
  5929. }
  5930. return false;
  5931. }
  5932. return false;
  5933. }
  5934. return false;
  5935. } catch (error) {
  5936. throwError(error, 'Steam.isFollowedGame');
  5937. return false;
  5938. }
  5939. }
  5940. async function _toggleForum2(gameId) {
  5941. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5942. try {
  5943. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5944. scripts_echoLog({
  5945. type: 'whiteList',
  5946. text: 'Steam.unsubscribeForum',
  5947. id: gameId
  5948. });
  5949. return true;
  5950. }
  5951. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5952. if (!forumId) {
  5953. return false;
  5954. }
  5955. const logStatus = scripts_echoLog({
  5956. type: `${doTask ? '' : 'un'}subscribingForum`,
  5957. text: gameId
  5958. });
  5959. const [ id, feature ] = forumId.split('_');
  5960. const {
  5961. result,
  5962. statusText,
  5963. status,
  5964. data
  5965. } = await tools_httpRequest({
  5966. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5967. method: 'POST',
  5968. responseType: 'json',
  5969. headers: {
  5970. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5971. },
  5972. data: $.param({
  5973. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5974. })
  5975. });
  5976. if (result === 'Success') {
  5977. var _data$response3, _data$response4;
  5978. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && (((_data$response3 = data.response) === null || _data$response3 === void 0 ? void 0 : _data$response3.success) === 1 || ((_data$response4 = data.response) === null || _data$response4 === void 0 ? void 0 : _data$response4.success) === 29)) {
  5979. if (doTask) {
  5980. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5981. }
  5982. logStatus.success();
  5983. return true;
  5984. }
  5985. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5986. return true;
  5987. }
  5988. logStatus.error(`${result}:${statusText}(${status})`);
  5989. return true;
  5990. } catch (error) {
  5991. throwError(error, 'Steam.toggleForum');
  5992. return true;
  5993. }
  5994. }
  5995. async function _getForumId2(gameId) {
  5996. try {
  5997. const logStatus = scripts_echoLog({
  5998. type: 'gettingForumId',
  5999. text: gameId
  6000. });
  6001. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  6002. if (forumId) {
  6003. logStatus.success();
  6004. return forumId;
  6005. }
  6006. const {
  6007. result,
  6008. statusText,
  6009. status,
  6010. data
  6011. } = await tools_httpRequest({
  6012. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  6013. method: 'GET'
  6014. });
  6015. if (result === 'Success') {
  6016. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6017. var _data$responseText, _data$responseText$ma10;
  6018. const forumId = (_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : (_data$responseText$ma10 = _data$responseText.match(/General_([\d]+(_[\d]+)?)/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  6019. if (forumId) {
  6020. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  6021. logStatus.success();
  6022. return forumId;
  6023. }
  6024. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6025. return false;
  6026. }
  6027. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6028. return false;
  6029. }
  6030. logStatus.error(`${result}:${statusText}(${status})`);
  6031. return false;
  6032. } catch (error) {
  6033. throwError(error, 'Steam.getForumId');
  6034. return false;
  6035. }
  6036. }
  6037. async function _toggleFavoriteWorkshop2(id) {
  6038. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6039. try {
  6040. if (!doTask && this.whiteList.workshops.includes(id)) {
  6041. scripts_echoLog({
  6042. type: 'whiteList',
  6043. text: 'Steam.unfavoriteWorkshop',
  6044. id: id
  6045. });
  6046. return true;
  6047. }
  6048. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  6049. if (!appid) {
  6050. return false;
  6051. }
  6052. const logStatus = scripts_echoLog({
  6053. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  6054. text: id
  6055. });
  6056. const {
  6057. result,
  6058. statusText,
  6059. status,
  6060. data
  6061. } = await tools_httpRequest({
  6062. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  6063. method: 'POST',
  6064. headers: {
  6065. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6066. },
  6067. data: $.param({
  6068. id: id,
  6069. appid: appid,
  6070. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6071. })
  6072. });
  6073. if (result === 'Success') {
  6074. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  6075. if (doTask) {
  6076. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  6077. }
  6078. logStatus.success();
  6079. return true;
  6080. }
  6081. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6082. return false;
  6083. }
  6084. logStatus.error(`${result}:${statusText}(${status})`);
  6085. return false;
  6086. } catch (error) {
  6087. throwError(error, 'Steam.toggleFavoriteWorkshop');
  6088. return false;
  6089. }
  6090. }
  6091. async function _getWorkshopAppId2(id) {
  6092. try {
  6093. const logStatus = scripts_echoLog({
  6094. type: 'gettingWorkshopAppId',
  6095. text: id
  6096. });
  6097. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  6098. if (appId) {
  6099. logStatus.success();
  6100. return appId;
  6101. }
  6102. const {
  6103. result,
  6104. statusText,
  6105. status,
  6106. data
  6107. } = await tools_httpRequest({
  6108. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  6109. method: 'GET'
  6110. });
  6111. if (result === 'Success') {
  6112. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6113. var _data$responseText$ma11;
  6114. const appId = (_data$responseText$ma11 = data.responseText.match(/<input type="hidden" name="appid" value="([\d]+?)" \/>/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  6115. if (appId) {
  6116. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  6117. logStatus.success();
  6118. return appId;
  6119. }
  6120. logStatus.error('Error: getWorkshopAppId failed');
  6121. return false;
  6122. }
  6123. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6124. return false;
  6125. }
  6126. logStatus.error(`${result}:${statusText}(${status})`);
  6127. return false;
  6128. } catch (error) {
  6129. throwError(error, 'Steam.getWorkshopAppId');
  6130. return false;
  6131. }
  6132. }
  6133. async function _voteUpWorkshop2(id) {
  6134. try {
  6135. const logStatus = scripts_echoLog({
  6136. type: 'votingUpWorkshop',
  6137. text: id
  6138. });
  6139. const {
  6140. result,
  6141. statusText,
  6142. status,
  6143. data
  6144. } = await tools_httpRequest({
  6145. url: 'https://steamcommunity.com/sharedfiles/voteup',
  6146. method: 'POST',
  6147. responseType: 'json',
  6148. headers: {
  6149. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6150. },
  6151. data: $.param({
  6152. id: id,
  6153. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  6154. })
  6155. });
  6156. if (result === 'Success') {
  6157. var _data$response5;
  6158. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response5 = data.response) === null || _data$response5 === void 0 ? void 0 : _data$response5.success) === 1) {
  6159. logStatus.success();
  6160. return true;
  6161. }
  6162. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6163. return true;
  6164. }
  6165. logStatus.error(`${result}:${statusText}(${status})`);
  6166. return true;
  6167. } catch (error) {
  6168. throwError(error, 'Steam.voteupWorkshop');
  6169. return true;
  6170. }
  6171. }
  6172. async function _toggleCurator2(curatorId) {
  6173. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6174. try {
  6175. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  6176. scripts_echoLog({
  6177. type: 'whiteList',
  6178. text: 'Steam.unfollowCurator',
  6179. id: curatorId
  6180. });
  6181. return true;
  6182. }
  6183. const logStatus = scripts_echoLog({
  6184. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  6185. text: curatorId
  6186. });
  6187. const {
  6188. result,
  6189. statusText,
  6190. status,
  6191. data
  6192. } = await tools_httpRequest({
  6193. url: 'https://store.steampowered.com/curators/ajaxfollow',
  6194. method: 'POST',
  6195. headers: {
  6196. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6197. },
  6198. data: $.param({
  6199. clanid: curatorId,
  6200. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6201. follow: doTask
  6202. }),
  6203. dataType: 'json'
  6204. });
  6205. if (result === 'Success') {
  6206. var _data$response6, _data$response6$succe, _data$response7;
  6207. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && ((_data$response6 = data.response) === null || _data$response6 === void 0 ? void 0 : (_data$response6$succe = _data$response6.success) === null || _data$response6$succe === void 0 ? void 0 : _data$response6$succe.success) === 1) {
  6208. logStatus.success();
  6209. return true;
  6210. }
  6211. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : (_data$response7 = data.response) === null || _data$response7 === void 0 ? void 0 : _data$response7.success}` || `${data === null || data === void 0 ? void 0 : data.status})`);
  6212. return false;
  6213. }
  6214. logStatus.error(`${result}:${statusText}(${status})`);
  6215. return false;
  6216. } catch (error) {
  6217. throwError(error, 'Steam.toggleCurator');
  6218. return false;
  6219. }
  6220. }
  6221. async function _toggleCuratorLike2(link) {
  6222. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6223. try {
  6224. const [ path, name ] = link.split('/');
  6225. if (!(path && name)) {
  6226. scripts_echoLog({
  6227. text: i18n('errorLink', link)
  6228. });
  6229. return false;
  6230. }
  6231. const curatorId = await this.getCuratorId(path, name);
  6232. if (curatorId) {
  6233. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  6234. }
  6235. return false;
  6236. } catch (error) {
  6237. throwError(error, 'Steam.toggleCuratorLike');
  6238. return false;
  6239. }
  6240. }
  6241. async function _getAnnouncementParams2(appId, viewId) {
  6242. try {
  6243. const logStatus = scripts_echoLog({
  6244. type: 'gettingAnnouncementParams',
  6245. text: appId,
  6246. id: viewId
  6247. });
  6248. const {
  6249. result,
  6250. statusText,
  6251. status,
  6252. data
  6253. } = await tools_httpRequest({
  6254. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  6255. method: 'GET',
  6256. headers: {
  6257. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6258. }
  6259. });
  6260. if (result === 'Success') {
  6261. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6262. var _data$responseText$ma12, _data$responseText$ma13, _data$responseText$ma14;
  6263. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6264. logStatus.warning(i18n('changeAreaNotice'));
  6265. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  6266. return {};
  6267. }
  6268. return await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6269. }
  6270. const authWgToken = (_data$responseText$ma12 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  6271. const clanId = (_data$responseText$ma13 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma13 === void 0 ? void 0 : _data$responseText$ma13[1];
  6272. const gid = (_data$responseText$ma14 = data.responseText.match(/announcementGID&quot;:&quot;([\d]+?)&quot;/)) === null || _data$responseText$ma14 === void 0 ? void 0 : _data$responseText$ma14[1];
  6273. if (authWgToken && clanId) {
  6274. logStatus.success();
  6275. return {
  6276. authWgToken: authWgToken,
  6277. clanId: clanId,
  6278. gid: gid
  6279. };
  6280. }
  6281. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6282. return {};
  6283. }
  6284. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6285. return {};
  6286. }
  6287. logStatus.error(`${result}:${statusText}(${status})`);
  6288. return {};
  6289. } catch (error) {
  6290. throwError(error, 'Steam.likeAnnouncement');
  6291. return {};
  6292. }
  6293. }
  6294. async function _likeAnnouncement2(id) {
  6295. try {
  6296. const [ appId, viewId ] = id.split('/');
  6297. if (!(appId && viewId)) {
  6298. scripts_echoLog({}).error(`${i18n('missParams')}(id)`);
  6299. return false;
  6300. }
  6301. const {
  6302. authWgToken,
  6303. clanId,
  6304. gid
  6305. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  6306. if (!(authWgToken && clanId)) {
  6307. return false;
  6308. }
  6309. const logStatus = scripts_echoLog({
  6310. type: 'likingAnnouncement',
  6311. text: appId,
  6312. id: viewId
  6313. });
  6314. const {
  6315. result,
  6316. statusText,
  6317. status,
  6318. data
  6319. } = await tools_httpRequest({
  6320. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  6321. method: 'POST',
  6322. headers: {
  6323. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6324. Host: 'store.steampowered.com',
  6325. Origin: 'https://store.steampowered.com',
  6326. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  6327. },
  6328. data: $.param({
  6329. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6330. wgauthtoken: authWgToken,
  6331. voteup: 1,
  6332. clanid: clanId,
  6333. ajax: 1
  6334. }),
  6335. dataType: 'json'
  6336. });
  6337. if (result === 'Success') {
  6338. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  6339. logStatus.success();
  6340. return true;
  6341. }
  6342. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6343. return false;
  6344. }
  6345. logStatus.error(`${result}:${statusText}(${status})`);
  6346. return false;
  6347. } catch (error) {
  6348. throwError(error, 'Steam.likeAnnouncement');
  6349. return false;
  6350. }
  6351. }
  6352. async function _appid2subid2(id) {
  6353. try {
  6354. const logStatus = scripts_echoLog({
  6355. type: 'gettingSubid',
  6356. text: id
  6357. });
  6358. const {
  6359. result,
  6360. statusText,
  6361. status,
  6362. data
  6363. } = await tools_httpRequest({
  6364. url: `https://store.steampowered.com/app/${id}`,
  6365. method: 'GET',
  6366. headers: {
  6367. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  6368. }
  6369. });
  6370. if (result === 'Success') {
  6371. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6372. var _data$responseText$ma15;
  6373. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6374. logStatus.warning(i18n('changeAreaNotice'));
  6375. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6376. if (!result || result === 'CN' || result === 'skip') {
  6377. return false;
  6378. }
  6379. return await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, id);
  6380. }
  6381. const subid = (_data$responseText$ma15 = data.responseText.match(/name="subid" value="([\d]+?)"/)) === null || _data$responseText$ma15 === void 0 ? void 0 : _data$responseText$ma15[1];
  6382. if (subid) {
  6383. logStatus.success();
  6384. return subid;
  6385. }
  6386. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6387. return false;
  6388. }
  6389. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6390. return false;
  6391. }
  6392. logStatus.error(`${result}:${statusText}(${status})`);
  6393. return false;
  6394. } catch (error) {
  6395. throwError(error, 'Steam.appid2subid');
  6396. return false;
  6397. }
  6398. }
  6399. async function _getLicenses2() {
  6400. try {
  6401. const logStatus = scripts_echoLog({
  6402. text: i18n('gettingLicenses')
  6403. });
  6404. const {
  6405. result,
  6406. statusText,
  6407. status,
  6408. data
  6409. } = await tools_httpRequest({
  6410. url: `https://store.steampowered.com/dynamicstore/userdata/?t=${new Date().getTime()}`,
  6411. method: 'GET',
  6412. responseType: 'json'
  6413. });
  6414. if (result === 'Success') {
  6415. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6416. var _data$response8;
  6417. logStatus.success();
  6418. return (_data$response8 = data.response) === null || _data$response8 === void 0 ? void 0 : _data$response8.rgOwnedPackages;
  6419. }
  6420. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6421. return false;
  6422. }
  6423. logStatus.error(`${result}:${statusText}(${status})`);
  6424. return false;
  6425. } catch (error) {
  6426. throwError(error, 'Steam.getLicenses');
  6427. return false;
  6428. }
  6429. }
  6430. async function _addLicense2(id) {
  6431. try {
  6432. const [ type, ids ] = id.split('-');
  6433. if (type === 'appid') {
  6434. const subid = await Steam_classPrivateMethodGet(this, _appid2subid, _appid2subid2).call(this, ids);
  6435. if (!subid) {
  6436. return false;
  6437. }
  6438. const logStatus = scripts_echoLog({
  6439. type: 'addingFreeLicense',
  6440. text: ids
  6441. });
  6442. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6443. return false;
  6444. }
  6445. const {
  6446. result,
  6447. statusText,
  6448. status,
  6449. data
  6450. } = await tools_httpRequest({
  6451. url: `https://store.steampowered.com/app/${ids}`,
  6452. method: 'GET'
  6453. });
  6454. if (result === 'Success') {
  6455. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6456. if (data.responseText.includes('ds_owned_flag ds_flag') || data.responseText.includes('class="already_in_library"')) {
  6457. logStatus.success();
  6458. return true;
  6459. }
  6460. logStatus.error(`Error:${data.statusText}(${data.status})`);
  6461. return false;
  6462. }
  6463. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6464. return false;
  6465. }
  6466. logStatus.error(`${result}:${statusText}(${status})`);
  6467. return false;
  6468. } else if (type === 'subid') {
  6469. if (Steam_classPrivateFieldGet(this, _area) === 'CN') {
  6470. scripts_echoLog({}).success(i18n('tryChangeAreaNotice'));
  6471. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6472. }
  6473. const logStatusArr = {};
  6474. const idsArr = ids.split(',');
  6475. for (const subid of idsArr) {
  6476. const logStatus = scripts_echoLog({
  6477. type: 'addingFreeLicenseSubid',
  6478. text: subid
  6479. });
  6480. if (!await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, subid, logStatus)) {
  6481. return false;
  6482. }
  6483. logStatusArr[subid] = logStatus;
  6484. }
  6485. const licenses = await Steam_classPrivateMethodGet(this, _getLicenses, _getLicenses2).call(this);
  6486. if (!licenses) {
  6487. return false;
  6488. }
  6489. for (const subid of idsArr) {
  6490. if (licenses.includes(parseInt(subid, 10))) {
  6491. logStatusArr[subid].success();
  6492. } else {
  6493. logStatusArr[subid].error();
  6494. }
  6495. }
  6496. return true;
  6497. }
  6498. return false;
  6499. } catch (error) {
  6500. throwError(error, 'Steam.addLicense');
  6501. return false;
  6502. }
  6503. }
  6504. async function _addFreeLicense2(id, logStatusPre) {
  6505. try {
  6506. const logStatus = logStatusPre || scripts_echoLog({
  6507. type: 'addingFreeLicenseSubid',
  6508. text: id
  6509. });
  6510. const {
  6511. result,
  6512. statusText,
  6513. status,
  6514. data
  6515. } = await tools_httpRequest({
  6516. url: 'https://store.steampowered.com/checkout/addfreelicense',
  6517. method: 'POST',
  6518. headers: {
  6519. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6520. Host: 'store.steampowered.com',
  6521. Origin: 'https://store.steampowered.com',
  6522. Referer: 'https://store.steampowered.com/account/licenses/'
  6523. },
  6524. data: $.param({
  6525. action: 'add_to_cart',
  6526. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  6527. subid: id
  6528. }),
  6529. dataType: 'json'
  6530. });
  6531. if (result === 'Success') {
  6532. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6533. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  6534. logStatus.warning(i18n('changeAreaNotice'));
  6535. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  6536. if (!result || result === 'CN') {
  6537. return false;
  6538. }
  6539. return await Steam_classPrivateMethodGet(this, _addFreeLicense, _addFreeLicense2).call(this, id);
  6540. }
  6541. logStatus.success();
  6542. return true;
  6543. }
  6544. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6545. return false;
  6546. }
  6547. logStatus.error(`${result}:${statusText}(${status})`);
  6548. return false;
  6549. } catch (error) {
  6550. throwError(error, 'Steam.addFreeLicense');
  6551. return false;
  6552. }
  6553. }
  6554. async function _requestPlayTestAccess2(id) {
  6555. try {
  6556. const logStatus = scripts_echoLog({
  6557. type: 'requestingPlayTestAccess',
  6558. text: id
  6559. });
  6560. const {
  6561. result,
  6562. statusText,
  6563. status,
  6564. data
  6565. } = await tools_httpRequest({
  6566. url: `https://store.steampowered.com/ajaxrequestplaytestaccess/${id}`,
  6567. method: 'POST',
  6568. headers: {
  6569. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6570. Host: 'store.steampowered.com',
  6571. Origin: 'https://store.steampowered.com',
  6572. Referer: `https://store.steampowered.com/app/${id}`
  6573. },
  6574. data: $.param({
  6575. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  6576. }),
  6577. dataType: 'json'
  6578. });
  6579. if (result === 'Success') {
  6580. var _data$response9;
  6581. 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) {
  6582. logStatus.success();
  6583. return true;
  6584. }
  6585. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6586. return false;
  6587. }
  6588. logStatus.error(`${result}:${statusText}(${status})`);
  6589. return false;
  6590. } catch (error) {
  6591. throwError(error, 'Steam.requestPlayTestAccess');
  6592. return false;
  6593. }
  6594. }
  6595. function Steam_setCache2(type, name, id) {
  6596. try {
  6597. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  6598. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  6599. } catch (error) {
  6600. throwError(error, 'Steam.setCache');
  6601. }
  6602. }
  6603. const social_Steam = Steam;
  6604. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  6605. Website_checkPrivateRedeclaration(obj, privateSet);
  6606. privateSet.add(obj);
  6607. }
  6608. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  6609. if (privateCollection.has(obj)) {
  6610. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6611. }
  6612. }
  6613. function Website_defineProperty(obj, key, value) {
  6614. if (key in obj) {
  6615. Object.defineProperty(obj, key, {
  6616. value: value,
  6617. enumerable: true,
  6618. configurable: true,
  6619. writable: true
  6620. });
  6621. } else {
  6622. obj[key] = value;
  6623. }
  6624. return obj;
  6625. }
  6626. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  6627. if (!privateSet.has(receiver)) {
  6628. throw new TypeError('attempted to get private field on non-instance');
  6629. }
  6630. return fn;
  6631. }
  6632. var _bind = new WeakSet();
  6633. class Website {
  6634. constructor() {
  6635. Website_classPrivateMethodInitSpec(this, _bind);
  6636. Website_defineProperty(this, 'undoneTasks', void 0);
  6637. Website_defineProperty(this, 'socialTasks', void 0);
  6638. Website_defineProperty(this, 'giveawayId', void 0);
  6639. Website_defineProperty(this, 'socialInitialized', {
  6640. discord: false,
  6641. instagram: false,
  6642. reddit: false,
  6643. twitch: false,
  6644. twitter: false,
  6645. vk: false,
  6646. youtube: false,
  6647. steamStore: false,
  6648. steamCommunity: false
  6649. });
  6650. Website_defineProperty(this, 'initialized', false);
  6651. Website_defineProperty(this, 'social', {});
  6652. }
  6653. async initSocial(action) {
  6654. try {
  6655. const pro = [];
  6656. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6657. if (tasks.discord) {
  6658. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6659. if (hasDiscord && (!this.socialInitialized.discord || !this.social.discord)) {
  6660. this.social.discord = new social_Discord();
  6661. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6662. }
  6663. }
  6664. if (tasks.instagram) {
  6665. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6666. if (hasInstagram && (!this.socialInitialized.instagram || !this.social.instagram)) {
  6667. this.social.instagram = new social_Instagram();
  6668. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6669. }
  6670. }
  6671. if (tasks.reddit) {
  6672. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6673. if (hasReddit && (!this.socialInitialized.reddit || !this.social.reddit)) {
  6674. this.social.reddit = new social_Reddit();
  6675. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6676. }
  6677. }
  6678. if (tasks.twitch) {
  6679. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6680. if (hasTwitch && (!this.socialInitialized.twitch || !this.social.twitch)) {
  6681. this.social.twitch = new social_Twitch();
  6682. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6683. }
  6684. }
  6685. if (tasks.twitter) {
  6686. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6687. if (hasTwitter && (!this.socialInitialized.twitter || !this.social.twitter)) {
  6688. this.social.twitter = new social_Twitter();
  6689. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6690. }
  6691. }
  6692. if (tasks.vk) {
  6693. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6694. if (hasVk && (!this.socialInitialized.vk || !this.social.vk)) {
  6695. this.social.vk = new social_Vk();
  6696. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6697. }
  6698. }
  6699. if (tasks.youtube) {
  6700. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6701. if (hasYoutube && (!this.socialInitialized.youtube || !this.social.youtube)) {
  6702. this.social.youtube = new Youtube();
  6703. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6704. }
  6705. }
  6706. if (tasks.steam) {
  6707. const steamLength = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length;
  6708. if (steamLength > 0) {
  6709. if (!this.social.steam) {
  6710. this.social.steam = new social_Steam();
  6711. }
  6712. const steamCommunityLength = Object.keys(tasks.steam).map(type => {
  6713. var _tasks$steam, _tasks$steam$type;
  6714. 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;
  6715. }).reduce((total, number) => total + number, 0);
  6716. if (steamLength - steamCommunityLength > 0 && !this.socialInitialized.steamStore) {
  6717. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamStore', this.social.steam.init('store')));
  6718. }
  6719. if (steamCommunityLength > 0 && !this.socialInitialized.steamCommunity) {
  6720. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steamCommunity', this.social.steam.init('community')));
  6721. }
  6722. }
  6723. }
  6724. if (tasks.links && tasks.links.length > 0) {
  6725. this.social.visitLink = visitLink;
  6726. }
  6727. return await Promise.all(pro).then(result => {
  6728. let checked = true;
  6729. for (const data of result) {
  6730. if (data.result) {
  6731. this.socialInitialized[data.name] = data.result;
  6732. } else {
  6733. checked = false;
  6734. }
  6735. }
  6736. return checked;
  6737. });
  6738. } catch (error) {
  6739. throwError(error, 'Website.initSocial');
  6740. return false;
  6741. }
  6742. }
  6743. uniqueTasks(allTasks) {
  6744. const result = {};
  6745. for (const [ social, types ] of Object.entries(allTasks)) {
  6746. result[social] = {};
  6747. for (const [ type, tasks ] of Object.entries(types)) {
  6748. result[social][type] = unique(tasks);
  6749. }
  6750. }
  6751. return result;
  6752. }
  6753. async toggleTask(action) {
  6754. try {
  6755. if (!this.initialized && !this.init()) {
  6756. return false;
  6757. }
  6758. if (!await this.classifyTask(action)) {
  6759. return false;
  6760. }
  6761. if (!await this.initSocial(action)) {
  6762. return false;
  6763. }
  6764. const pro = [];
  6765. const doTask = action === 'do';
  6766. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6767. if (this.socialInitialized.discord !== 'skip' && this.social.discord) {
  6768. pro.push(this.social.discord.toggle({
  6769. doTask: doTask,
  6770. ...tasks.discord
  6771. }));
  6772. }
  6773. if (this.social.instagram) {
  6774. pro.push(this.social.instagram.toggle({
  6775. doTask: doTask,
  6776. ...tasks.instagram
  6777. }));
  6778. }
  6779. if (this.social.reddit) {
  6780. pro.push(this.social.reddit.toggle({
  6781. doTask: doTask,
  6782. ...tasks.reddit
  6783. }));
  6784. }
  6785. if (this.social.twitch) {
  6786. pro.push(this.social.twitch.toggle({
  6787. doTask: doTask,
  6788. ...tasks.twitch
  6789. }));
  6790. }
  6791. if (this.social.twitter) {
  6792. pro.push(this.social.twitter.toggle({
  6793. doTask: doTask,
  6794. ...tasks.twitter
  6795. }));
  6796. }
  6797. if (this.social.vk) {
  6798. pro.push(this.social.vk.toggle({
  6799. doTask: doTask,
  6800. ...tasks.vk
  6801. }));
  6802. }
  6803. if (this.social.youtube) {
  6804. pro.push(this.social.youtube.toggle({
  6805. doTask: doTask,
  6806. ...tasks.youtube
  6807. }));
  6808. }
  6809. if (this.social.steam) {
  6810. pro.push(this.social.steam.toggle({
  6811. doTask: doTask,
  6812. ...tasks.steam
  6813. }));
  6814. }
  6815. if (this.social.visitLink && tasks.links && doTask) {
  6816. for (const link of tasks.links) {
  6817. pro.push(this.social.visitLink(link));
  6818. }
  6819. }
  6820. if (doTask && tasks.extra && this.extraDoTask) {
  6821. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6822. if (hasExtra) {
  6823. pro.push(this.extraDoTask(tasks.extra));
  6824. }
  6825. }
  6826. await Promise.all(pro);
  6827. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6828. return true;
  6829. } catch (error) {
  6830. throwError(error, 'Website.toggleTask');
  6831. return false;
  6832. }
  6833. }
  6834. async doTask() {
  6835. try {
  6836. return await this.toggleTask('do');
  6837. } catch (error) {
  6838. throwError(error, 'Website.doTask');
  6839. return false;
  6840. }
  6841. }
  6842. async undoTask() {
  6843. try {
  6844. return await this.toggleTask('undo');
  6845. } catch (error) {
  6846. throwError(error, 'Website.undoTask');
  6847. return false;
  6848. }
  6849. }
  6850. }
  6851. async function _bind2(name, init) {
  6852. try {
  6853. return {
  6854. name: name,
  6855. result: await init
  6856. };
  6857. } catch (error) {
  6858. throwError(error, 'Website.bind');
  6859. return {
  6860. name: name,
  6861. result: false
  6862. };
  6863. }
  6864. }
  6865. const website_Website = Website;
  6866. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6867. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6868. privateSet.add(obj);
  6869. }
  6870. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6871. if (privateCollection.has(obj)) {
  6872. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6873. }
  6874. }
  6875. function FreeAnyWhere_defineProperty(obj, key, value) {
  6876. if (key in obj) {
  6877. Object.defineProperty(obj, key, {
  6878. value: value,
  6879. enumerable: true,
  6880. configurable: true,
  6881. writable: true
  6882. });
  6883. } else {
  6884. obj[key] = value;
  6885. }
  6886. return obj;
  6887. }
  6888. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6889. if (!privateSet.has(receiver)) {
  6890. throw new TypeError('attempted to get private field on non-instance');
  6891. }
  6892. return fn;
  6893. }
  6894. const FreeAnyWhere_defaultTasksTemplate = {
  6895. steam: {
  6896. groupLinks: [],
  6897. wishlistLinks: [],
  6898. curatorLinks: [],
  6899. followLinks: []
  6900. },
  6901. vk: {
  6902. nameLinks: []
  6903. }
  6904. };
  6905. const FreeAnyWhere_defaultTasks = JSON.stringify(FreeAnyWhere_defaultTasksTemplate);
  6906. var _getGiveawayId = new WeakSet();
  6907. var _verify = new WeakSet();
  6908. class FreeAnyWhere extends website_Website {
  6909. constructor() {
  6910. super(...arguments);
  6911. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6912. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6913. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6914. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6915. FreeAnyWhere_defineProperty(this, 'socialTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6916. FreeAnyWhere_defineProperty(this, 'undoneTasks', JSON.parse(FreeAnyWhere_defaultTasks));
  6917. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6918. }
  6919. static test() {
  6920. return window.location.host === 'freeanywhere.net';
  6921. }
  6922. init() {
  6923. try {
  6924. const logStatus = scripts_echoLog({
  6925. text: i18n('initing')
  6926. });
  6927. if ($('a[href="#/login"]').length > 0) {
  6928. window.open('/#/login', '_self');
  6929. logStatus.warning(i18n('needLogin'));
  6930. return false;
  6931. }
  6932. if (window.location.href.includes('/login')) {
  6933. logStatus.warning(i18n('needLogin'));
  6934. return false;
  6935. }
  6936. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6937. var _window$location$href;
  6938. 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];
  6939. if (!id) {
  6940. logStatus.error(i18n('getFailed', 'Id'));
  6941. return false;
  6942. }
  6943. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6944. }
  6945. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6946. return false;
  6947. }
  6948. this.initialized = true;
  6949. logStatus.success();
  6950. return true;
  6951. } catch (error) {
  6952. throwError(error, 'Freeanywhere.init');
  6953. return false;
  6954. }
  6955. }
  6956. async classifyTask(action) {
  6957. try {
  6958. const logStatus = scripts_echoLog({
  6959. text: i18n('getTasksInfo')
  6960. });
  6961. if (action === 'undo') {
  6962. var _GM_getValue;
  6963. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(FreeAnyWhere_defaultTasks);
  6964. }
  6965. const {
  6966. result,
  6967. statusText,
  6968. status,
  6969. data
  6970. } = await tools_httpRequest({
  6971. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6972. method: 'GET',
  6973. headers: {
  6974. authorization: `Token ${window.localStorage.getItem('token')}`,
  6975. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6976. },
  6977. responseType: 'json'
  6978. });
  6979. if (result === 'Success') {
  6980. var _data$response;
  6981. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6982. if (tasks) {
  6983. if (action === 'verify') {
  6984. this.tasks = [];
  6985. }
  6986. for (const task of tasks) {
  6987. const type = task.challenge;
  6988. const social = task.challenge_provider;
  6989. const taskInfo = {
  6990. id: task.id,
  6991. title: task.title
  6992. };
  6993. if (action === 'verify' && !task.is_success) {
  6994. this.tasks.push(taskInfo);
  6995. continue;
  6996. }
  6997. switch (social) {
  6998. case 'steam':
  6999. taskInfo.social = 'steam';
  7000. switch (type) {
  7001. case 'WL':
  7002. if (action === 'undo') {
  7003. this.socialTasks.steam.wishlistLinks.push(task.link);
  7004. }
  7005. if (action === 'do' && !task.is_success) {
  7006. this.undoneTasks.steam.wishlistLinks.push(task.link);
  7007. }
  7008. break;
  7009.  
  7010. case 'JTG':
  7011. if (action === 'undo') {
  7012. this.socialTasks.steam.groupLinks.push(task.link);
  7013. }
  7014. if (action === 'do' && !task.is_success) {
  7015. this.undoneTasks.steam.groupLinks.push(task.link);
  7016. }
  7017. break;
  7018.  
  7019. case 'STC':
  7020. if (action === 'undo') {
  7021. this.socialTasks.steam.curatorLinks.push(task.link);
  7022. }
  7023. if (action === 'do' && !task.is_success) {
  7024. this.undoneTasks.steam.curatorLinks.push(task.link);
  7025. }
  7026. break;
  7027.  
  7028. case 'GF':
  7029. if (action === 'undo') {
  7030. this.socialTasks.steam.followLinks.push(task.link);
  7031. }
  7032. if (action === 'do' && !task.is_success) {
  7033. this.undoneTasks.steam.followLinks.push(task.link);
  7034. }
  7035. break;
  7036. }
  7037. break;
  7038.  
  7039. case 'vk-oauth2':
  7040. if (action === 'undo') {
  7041. this.socialTasks.vk.nameLinks.push(task.link);
  7042. }
  7043. if (action === 'do' && !task.is_success) {
  7044. this.undoneTasks.vk.nameLinks.push(task.link);
  7045. }
  7046. break;
  7047.  
  7048. case 'website':
  7049. break;
  7050.  
  7051. default:
  7052. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  7053. break;
  7054. }
  7055. }
  7056. logStatus.success();
  7057. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7058. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7059. if (window.DEBUG) {
  7060. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7061. }
  7062. GM_setValue(`fawTasks-${this.giveawayId}`, {
  7063. tasks: this.socialTasks,
  7064. time: new Date().getTime()
  7065. });
  7066. return true;
  7067. }
  7068. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7069. return false;
  7070. }
  7071. logStatus.error(`${result}:${statusText}(${status})`);
  7072. return false;
  7073. } catch (error) {
  7074. throwError(error, 'Freeanywhere.classifyTask');
  7075. return false;
  7076. }
  7077. }
  7078. async verifyTask() {
  7079. try {
  7080. if (!this.initialized && !this.init()) {
  7081. return false;
  7082. }
  7083. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7084. return false;
  7085. }
  7086. const pro = [];
  7087. for (const task of this.tasks) {
  7088. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  7089. await delay(1e3);
  7090. }
  7091. await Promise.all(pro);
  7092. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7093. return !!await this.getKey(true);
  7094. } catch (error) {
  7095. throwError(error, 'Freeanywhere.verifyTask');
  7096. return false;
  7097. }
  7098. }
  7099. async getKey(initialized) {
  7100. try {
  7101. if (!initialized && !this.initialized && !this.init()) {
  7102. return false;
  7103. }
  7104. const logStatus = scripts_echoLog({
  7105. text: i18n('gettingKey')
  7106. });
  7107. const {
  7108. result,
  7109. statusText,
  7110. status,
  7111. data
  7112. } = await tools_httpRequest({
  7113. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  7114. method: 'GET',
  7115. dataType: 'json',
  7116. headers: {
  7117. authorization: `Token ${window.localStorage.getItem('token')}`
  7118. }
  7119. });
  7120. if (result === 'Success') {
  7121. var _data$response2;
  7122. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  7123. logStatus.success();
  7124. scripts_echoLog({}).success(data.response.reward);
  7125. return data.response.reward;
  7126. }
  7127. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7128. return false;
  7129. }
  7130. logStatus.error(`${result}:${statusText}(${status})`);
  7131. return false;
  7132. } catch (error) {
  7133. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7134. return false;
  7135. }
  7136. }
  7137. }
  7138. function _getGiveawayId2() {
  7139. try {
  7140. var _window$location$href2;
  7141. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  7142. if (giveawayId) {
  7143. this.giveawayId = giveawayId;
  7144. return true;
  7145. }
  7146. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7147. return false;
  7148. } catch (error) {
  7149. throwError(error, 'FreeAnyWhere.getGiveawayId');
  7150. }
  7151. }
  7152. async function _verify2(task) {
  7153. try {
  7154. const logStatus = scripts_echoLog({
  7155. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  7156. });
  7157. const {
  7158. result,
  7159. statusText,
  7160. status,
  7161. data
  7162. } = await tools_httpRequest({
  7163. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  7164. method: 'GET',
  7165. dataType: 'json',
  7166. headers: {
  7167. authorization: `Token ${window.localStorage.getItem('token')}`,
  7168. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  7169. }
  7170. });
  7171. if (result === 'Success') {
  7172. var _data$response3;
  7173. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  7174. logStatus.success();
  7175. return true;
  7176. }
  7177. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7178. return false;
  7179. }
  7180. logStatus.error(`${result}:${statusText}(${status})`);
  7181. return false;
  7182. } catch (error) {
  7183. throwError(error, 'Freeanywhere.verify');
  7184. return false;
  7185. }
  7186. }
  7187. const website_FreeAnyWhere = FreeAnyWhere;
  7188. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  7189. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  7190. privateSet.add(obj);
  7191. }
  7192. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  7193. if (privateCollection.has(obj)) {
  7194. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7195. }
  7196. }
  7197. function GiveawaySu_defineProperty(obj, key, value) {
  7198. if (key in obj) {
  7199. Object.defineProperty(obj, key, {
  7200. value: value,
  7201. enumerable: true,
  7202. configurable: true,
  7203. writable: true
  7204. });
  7205. } else {
  7206. obj[key] = value;
  7207. }
  7208. return obj;
  7209. }
  7210. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  7211. if (!privateSet.has(receiver)) {
  7212. throw new TypeError('attempted to get private field on non-instance');
  7213. }
  7214. return fn;
  7215. }
  7216. const GiveawaySu_defaultTasks = {
  7217. steam: {
  7218. groupLinks: [],
  7219. wishlistLinks: [],
  7220. curatorLinks: [],
  7221. curatorLikeLinks: [],
  7222. followLinks: [],
  7223. forumLinks: [],
  7224. announcementLinks: [],
  7225. workshopVoteLinks: [],
  7226. playtestLinks: []
  7227. },
  7228. discord: {
  7229. serverLinks: []
  7230. },
  7231. instagram: {
  7232. userLinks: []
  7233. },
  7234. vk: {
  7235. nameLinks: []
  7236. },
  7237. twitch: {
  7238. channelLinks: []
  7239. },
  7240. reddit: {
  7241. redditLinks: []
  7242. },
  7243. youtube: {
  7244. channelLinks: [],
  7245. likeLinks: []
  7246. }
  7247. };
  7248. var _checkLogin = new WeakSet();
  7249. var _checkLeftKey = new WeakSet();
  7250. var GiveawaySu_getGiveawayId = new WeakSet();
  7251. class GiveawaySu extends website_Website {
  7252. constructor() {
  7253. super(...arguments);
  7254. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  7255. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  7256. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  7257. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  7258. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  7259. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  7260. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7261. }
  7262. static test() {
  7263. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  7264. }
  7265. async after() {
  7266. try {
  7267. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  7268. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7269. }
  7270. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  7271. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7272. }
  7273. scripts_echoLog({}).warning(i18n('gsNotice'));
  7274. } catch (error) {
  7275. throwError(error, 'Giveawaysu.after');
  7276. }
  7277. }
  7278. init() {
  7279. try {
  7280. const logStatus = scripts_echoLog({
  7281. text: i18n('initing')
  7282. });
  7283. if ($('a.steam-login').length > 0) {
  7284. window.open('/steam/redirect', '_self');
  7285. logStatus.warning(i18n('needLogin'));
  7286. return false;
  7287. }
  7288. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  7289. return false;
  7290. }
  7291. this.initialized = true;
  7292. logStatus.success();
  7293. return true;
  7294. } catch (error) {
  7295. throwError(error, 'Giveawaysu.init');
  7296. return false;
  7297. }
  7298. }
  7299. async classifyTask(action) {
  7300. try {
  7301. const logStatus = scripts_echoLog({
  7302. text: i18n('getTasksInfo')
  7303. });
  7304. if (action === 'undo') {
  7305. var _GM_getValue;
  7306. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7307. return true;
  7308. }
  7309. const pro = [];
  7310. const tasks = $('#actions tr');
  7311. if ($('div.bind-discord').is(':visible')) {
  7312. $('div.bind-discord a')[0].click();
  7313. }
  7314. if ($('div.bind-twitch').is(':visible')) {
  7315. $('div.bind-twitch a')[0].click();
  7316. }
  7317. for (const task of tasks) {
  7318. pro.push(new Promise(resolve => {
  7319. const td = $(task).find('td:not(".hidden")');
  7320. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  7321. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  7322. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  7323. const taskIcon = td.eq(0).find('i').attr('class') || '';
  7324. const taskName = taskDes.text().trim();
  7325. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  7326. return resolve(true);
  7327. }
  7328. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7329. if (!taskLink) {
  7330. return resolve(false);
  7331. }
  7332. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  7333. this.undoneTasks.steam.groupLinks.push(taskLink);
  7334. } else if (/like.*announcement/gi.test(taskName)) {
  7335. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7336. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7337. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7338. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7339. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7340. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7341. this.undoneTasks.steam.forumLinks.push(taskLink);
  7342. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  7343. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7344. } else if (taskIcon.includes('plus') && /request.*playtest/gim.test(taskName)) {
  7345. this.undoneTasks.steam.playtestLinks.push(taskLink);
  7346. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  7347. this.undoneTasks.discord.serverLinks.push(taskLink);
  7348. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  7349. this.undoneTasks.instagram.userLinks.push(taskLink);
  7350. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  7351. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7352. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  7353. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7354. } else if (/watch.*art/gim.test(taskName)) {
  7355. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7356. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7357. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7358. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7359. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7360. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7361. this.undoneTasks.vk.nameLinks.push(taskLink);
  7362. } else {
  7363. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7364. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  7365. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7366. }
  7367. if (/follow.*button/gim.test(taskName)) {
  7368. this.undoneTasks.steam.followLinks.push(taskLink);
  7369. }
  7370. }
  7371. }
  7372. resolve(true);
  7373. }).catch(error => {
  7374. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  7375. return false;
  7376. });
  7377. }));
  7378. }
  7379. await Promise.all(pro);
  7380. logStatus.success();
  7381. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7382. this.socialTasks = this.undoneTasks;
  7383. if (window.DEBUG) {
  7384. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7385. }
  7386. GM_setValue(`gasTasks-${this.giveawayId}`, {
  7387. tasks: this.socialTasks,
  7388. time: new Date().getTime()
  7389. });
  7390. return true;
  7391. } catch (error) {
  7392. throwError(error, 'Giveawaysu.classifyTask');
  7393. return false;
  7394. }
  7395. }
  7396. }
  7397. function _checkLogin2() {
  7398. try {
  7399. if (!globalOptions.other.checkLogin) {
  7400. return true;
  7401. }
  7402. if ($('a.steam-login').length > 0) {
  7403. window.open('/steam/redirect', '_self');
  7404. }
  7405. return true;
  7406. } catch (error) {
  7407. throwError(error, 'Giveawaysu.checkLogin');
  7408. return false;
  7409. }
  7410. }
  7411. async function _checkLeftKey2() {
  7412. try {
  7413. if (!globalOptions.other.checkLeftKey) {
  7414. return true;
  7415. }
  7416. if ($('.giveaway-ended').length > 0 && $('.giveaway-key').length === 0) {
  7417. await external_Swal_default().fire({
  7418. icon: 'warning',
  7419. title: i18n('notice'),
  7420. text: i18n('noKeysLeft'),
  7421. confirmButtonText: i18n('confirm'),
  7422. cancelButtonText: i18n('cancel'),
  7423. showCancelButton: true
  7424. }).then(_ref => {
  7425. let {
  7426. value
  7427. } = _ref;
  7428. if (value) {
  7429. window.close();
  7430. }
  7431. });
  7432. }
  7433. return true;
  7434. } catch (error) {
  7435. throwError(error, 'Giveawaysu.checkLeftKey');
  7436. return false;
  7437. }
  7438. }
  7439. function GiveawaySu_getGiveawayId2() {
  7440. var _window$location$href;
  7441. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7442. if (giveawayId) {
  7443. this.giveawayId = giveawayId;
  7444. return true;
  7445. }
  7446. scripts_echoLog({
  7447. text: i18n('getFailed', 'GiveawayId')
  7448. });
  7449. return false;
  7450. }
  7451. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  7452. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  7453. privateSet.add(obj);
  7454. }
  7455. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  7456. if (privateCollection.has(obj)) {
  7457. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7458. }
  7459. }
  7460. function Indiedb_defineProperty(obj, key, value) {
  7461. if (key in obj) {
  7462. Object.defineProperty(obj, key, {
  7463. value: value,
  7464. enumerable: true,
  7465. configurable: true,
  7466. writable: true
  7467. });
  7468. } else {
  7469. obj[key] = value;
  7470. }
  7471. return obj;
  7472. }
  7473. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  7474. if (!privateSet.has(receiver)) {
  7475. throw new TypeError('attempted to get private field on non-instance');
  7476. }
  7477. return fn;
  7478. }
  7479. var _join = new WeakSet();
  7480. var _do = new WeakSet();
  7481. var Indiedb_checkLogin = new WeakSet();
  7482. var Indiedb_checkLeftKey = new WeakSet();
  7483. class Indiedb {
  7484. constructor() {
  7485. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  7486. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  7487. Indiedb_classPrivateMethodInitSpec(this, _do);
  7488. Indiedb_classPrivateMethodInitSpec(this, _join);
  7489. Indiedb_defineProperty(this, 'name', 'Indiedb');
  7490. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  7491. }
  7492. static test() {
  7493. return window.location.host === 'www.indiedb.com';
  7494. }
  7495. async after() {
  7496. try {
  7497. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  7498. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7499. }
  7500. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  7501. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7502. }
  7503. } catch (error) {
  7504. throwError(error, 'Indiedb.after');
  7505. }
  7506. }
  7507. async doTask() {
  7508. try {
  7509. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  7510. return false;
  7511. }
  7512. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  7513. } catch (error) {
  7514. throwError(error, 'Indiedb.doTask');
  7515. return false;
  7516. }
  7517. }
  7518. }
  7519. async function _join2() {
  7520. try {
  7521. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7522. scripts_echoLog({}).error(i18n('needLogin'));
  7523. return false;
  7524. }
  7525. const currentoption = $('a.buttonenter.buttongiveaway');
  7526. if (/join giveaway/gim.test(currentoption.text())) {
  7527. const logStatus = scripts_echoLog({
  7528. text: `${i18n('joiningGiveaway')}...`
  7529. });
  7530. const {
  7531. result,
  7532. statusText,
  7533. status,
  7534. data
  7535. } = await tools_httpRequest({
  7536. url: currentoption.attr('href'),
  7537. method: 'POST',
  7538. data: 'ajax=t',
  7539. dataType: 'json',
  7540. headers: {
  7541. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  7542. accept: 'application/json, text/javascript, */*; q=0.01',
  7543. origin: window.location.origin
  7544. }
  7545. });
  7546. if (result === 'Success') {
  7547. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  7548. var _data$response, _data$response4, _data$response5;
  7549. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  7550. var _data$response2, _data$response3;
  7551. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  7552. $('#giveawaysjoined').slideDown();
  7553. $('#giveawaysrecommend').slideDown();
  7554. 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}` : ''}`);
  7555. return true;
  7556. }
  7557. 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}` : ''}`);
  7558. return false;
  7559. }
  7560. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  7561. return false;
  7562. }
  7563. logStatus.error(`${result}:${statusText}(${status})`);
  7564. return false;
  7565. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  7566. return true;
  7567. }
  7568. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  7569. return false;
  7570. } catch (error) {
  7571. throwError(error, 'Indiedb.init');
  7572. return false;
  7573. }
  7574. }
  7575. async function _do2() {
  7576. try {
  7577. const id = $('script').map((index, script) => {
  7578. if (/\$\(document\)/gim.test(script.innerHTML)) {
  7579. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  7580. 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] ];
  7581. }
  7582. return null;
  7583. });
  7584. if (id.length === 2) {
  7585. const pro = [];
  7586. const tasks = $('#giveawaysjoined a[class*=promo]');
  7587. for (const task of tasks) {
  7588. const promo = $(task);
  7589. if (!promo.hasClass('buttonentered')) {
  7590. const status = scripts_echoLog({
  7591. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  7592. });
  7593. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  7594. let text = '';
  7595. if (promo.hasClass('facebookpromo')) {
  7596. text = 'facebookpromo';
  7597. } else if (promo.hasClass('twitterpromo')) {
  7598. text = 'twitterpromo';
  7599. } else {
  7600. text = 'visitpromo';
  7601. }
  7602. pro.push(new Promise(resolve => {
  7603. $.ajax({
  7604. type: 'POST',
  7605. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  7606. timeout: 6e4,
  7607. dataType: 'json',
  7608. data: {
  7609. ajax: 't'
  7610. },
  7611. error(response, error, exception) {
  7612. if (window.DEBUG) {
  7613. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7614. response: response,
  7615. error: error,
  7616. exception: exception
  7617. });
  7618. }
  7619. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7620. resolve(true);
  7621. },
  7622. success(response) {
  7623. if (response.success) {
  7624. status.success(`Success:${response.text}`);
  7625. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7626. resolve(true);
  7627. } else {
  7628. status.error(`Error:${response.text}`);
  7629. resolve(true);
  7630. }
  7631. }
  7632. });
  7633. }));
  7634. } else if (promo.hasClass('emailoptinpromo')) {
  7635. pro.push(new Promise(resolve => {
  7636. $.ajax({
  7637. type: 'POST',
  7638. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  7639. timeout: 6e4,
  7640. dataType: 'json',
  7641. data: {
  7642. ajax: 't',
  7643. emailsystoggle: 4
  7644. },
  7645. error(response, error, exception) {
  7646. if (window.DEBUG) {
  7647. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7648. response: response,
  7649. error: error,
  7650. exception: exception
  7651. });
  7652. }
  7653. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7654. resolve(true);
  7655. },
  7656. success(response) {
  7657. if (response.success) {
  7658. status.success(`Success:${response.text}`);
  7659. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7660. resolve(true);
  7661. } else {
  7662. status.error(`Error:${response.text}`);
  7663. resolve(true);
  7664. }
  7665. }
  7666. });
  7667. }));
  7668. } else if (promo.hasClass('watchingpromo')) {
  7669. pro.push(new Promise(resolve => {
  7670. var _promo$attr;
  7671. const data = getUrlQuery(promo.attr('href'));
  7672. data.ajax = 't';
  7673. $.ajax({
  7674. type: 'POST',
  7675. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7676. timeout: 6e4,
  7677. dataType: 'json',
  7678. data: data,
  7679. error(response, error, exception) {
  7680. if (window.DEBUG) {
  7681. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7682. response: response,
  7683. error: error,
  7684. exception: exception
  7685. });
  7686. }
  7687. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7688. resolve(true);
  7689. },
  7690. success(response) {
  7691. if (response.success) {
  7692. status.success(`Success:${response.text}`);
  7693. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7694. resolve(true);
  7695. } else {
  7696. status.error(`Error:${response.text}`);
  7697. resolve(true);
  7698. }
  7699. }
  7700. });
  7701. }));
  7702. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7703. pro.push(new Promise(resolve => {
  7704. $.ajax({
  7705. type: 'POST',
  7706. url: urlPath(promo.attr('href')),
  7707. timeout: 6e4,
  7708. dataType: 'json',
  7709. data: {
  7710. ajax: 't'
  7711. },
  7712. error(response, error, exception) {
  7713. if (window.DEBUG) {
  7714. console.log('%cAuto-Task[Debug]:', 'color:red', {
  7715. response: response,
  7716. error: error,
  7717. exception: exception
  7718. });
  7719. }
  7720. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7721. resolve(true);
  7722. },
  7723. success(response) {
  7724. if (response.success) {
  7725. status.success(`Success:${response.text}`);
  7726. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7727. resolve(true);
  7728. } else {
  7729. status.error(`Error:${response.text}`);
  7730. resolve(true);
  7731. }
  7732. }
  7733. });
  7734. }));
  7735. } else {
  7736. status.error(`Error:${i18n('unKnownTaskType')}`);
  7737. }
  7738. }
  7739. }
  7740. await Promise.all(pro);
  7741. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7742. return true;
  7743. }
  7744. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7745. return false;
  7746. } catch (error) {
  7747. throwError(error, 'Indiedb.classifyTask');
  7748. return false;
  7749. }
  7750. }
  7751. function Indiedb_checkLogin2() {
  7752. try {
  7753. if (!globalOptions.other.checkLogin) {
  7754. return true;
  7755. }
  7756. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7757. window.open('/members/login', '_self');
  7758. }
  7759. return true;
  7760. } catch (error) {
  7761. throwError(error, 'Indiedb.checkLogin');
  7762. return false;
  7763. }
  7764. }
  7765. async function Indiedb_checkLeftKey2() {
  7766. try {
  7767. if (!globalOptions.other.checkLeftKey) {
  7768. return true;
  7769. }
  7770. if ($('a.buttonenter:contains("next time"),a.buttonenter:contains("Giveaway is closed")').length > 0) {
  7771. await external_Swal_default().fire({
  7772. icon: 'warning',
  7773. title: i18n('notice'),
  7774. text: i18n('giveawayEnded'),
  7775. confirmButtonText: i18n('confirm'),
  7776. cancelButtonText: i18n('cancel'),
  7777. showCancelButton: true
  7778. }).then(_ref => {
  7779. let {
  7780. value
  7781. } = _ref;
  7782. if (value) {
  7783. window.close();
  7784. }
  7785. });
  7786. }
  7787. return true;
  7788. } catch (error) {
  7789. throwError(error, 'Indiedb.checkLeftKey');
  7790. return false;
  7791. }
  7792. }
  7793. const website_Indiedb = Indiedb;
  7794. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7795. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7796. privateSet.add(obj);
  7797. }
  7798. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7799. if (privateCollection.has(obj)) {
  7800. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7801. }
  7802. }
  7803. function Keyhub_defineProperty(obj, key, value) {
  7804. if (key in obj) {
  7805. Object.defineProperty(obj, key, {
  7806. value: value,
  7807. enumerable: true,
  7808. configurable: true,
  7809. writable: true
  7810. });
  7811. } else {
  7812. obj[key] = value;
  7813. }
  7814. return obj;
  7815. }
  7816. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7817. if (!privateSet.has(receiver)) {
  7818. throw new TypeError('attempted to get private field on non-instance');
  7819. }
  7820. return fn;
  7821. }
  7822. const Keyhub_defaultTasksTemplate = {
  7823. steam: {
  7824. groupLinks: [],
  7825. officialGroupLinks: [],
  7826. wishlistLinks: [],
  7827. curatorLinks: []
  7828. },
  7829. discord: {
  7830. serverLinks: []
  7831. },
  7832. links: []
  7833. };
  7834. const Keyhub_defaultTasks = JSON.stringify(Keyhub_defaultTasksTemplate);
  7835. var Keyhub_getGiveawayId = new WeakSet();
  7836. var Keyhub_checkLeftKey = new WeakSet();
  7837. var Keyhub_checkLogin = new WeakSet();
  7838. class Keyhub extends website_Website {
  7839. constructor() {
  7840. super(...arguments);
  7841. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7842. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7843. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7844. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7845. Keyhub_defineProperty(this, 'socialTasks', JSON.parse(Keyhub_defaultTasks));
  7846. Keyhub_defineProperty(this, 'undoneTasks', JSON.parse(Keyhub_defaultTasks));
  7847. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7848. }
  7849. static test() {
  7850. return window.location.host === 'key-hub.eu';
  7851. }
  7852. async after() {
  7853. try {
  7854. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7855. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7856. }
  7857. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7858. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7859. }
  7860. $('.NSFW').hide();
  7861. } catch (error) {
  7862. throwError(error, 'Keyhub.after');
  7863. }
  7864. }
  7865. init() {
  7866. try {
  7867. const logStatus = scripts_echoLog({
  7868. text: i18n('initing')
  7869. });
  7870. if ($('a[href*="/connect/steam"]').length > 0) {
  7871. window.open('/connect/steam', '_self');
  7872. logStatus.warning(i18n('needLogin'));
  7873. return false;
  7874. }
  7875. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7876. return false;
  7877. }
  7878. $('#VPNoverlay').hide();
  7879. $('#mainArticleSection').show();
  7880. this.initialized = true;
  7881. logStatus.success();
  7882. return true;
  7883. } catch (error) {
  7884. throwError(error, 'Keyhub.init');
  7885. return false;
  7886. }
  7887. }
  7888. async classifyTask(action) {
  7889. try {
  7890. const logStatus = scripts_echoLog({
  7891. text: i18n('getTasksInfo')
  7892. });
  7893. if (action === 'undo') {
  7894. var _GM_getValue;
  7895. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Keyhub_defaultTasks);
  7896. }
  7897. const tasks = $('.task:not(".googleads")').filter((index, element) => action === 'do' ? $(element).find('i.fa-check-circle:visible').length === 0 : true).find('a');
  7898. for (const task of tasks) {
  7899. let link = $(task).attr('href');
  7900. const taskDes = $(task).text().trim();
  7901. if (!link) {
  7902. continue;
  7903. }
  7904. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7905. link = await getRedirectLink(link) || link;
  7906. }
  7907. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7908. window.open(link, '_blank');
  7909. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7910. if (action === 'undo') {
  7911. this.socialTasks.steam.groupLinks.push(link);
  7912. }
  7913. if (action === 'do') {
  7914. this.undoneTasks.steam.groupLinks.push(link);
  7915. }
  7916. } else if (/steamcommunity\.com\/games\/[\d]+/.test(link)) {
  7917. if (action === 'undo') {
  7918. this.socialTasks.steam.officialGroupLinks.push(link);
  7919. }
  7920. if (action === 'do') {
  7921. this.undoneTasks.steam.officialGroupLinks.push(link);
  7922. }
  7923. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7924. if (action === 'undo') {
  7925. this.socialTasks.steam.wishlistLinks.push(link);
  7926. }
  7927. if (action === 'do') {
  7928. this.undoneTasks.steam.wishlistLinks.push(link);
  7929. }
  7930. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7931. if (action === 'undo') {
  7932. this.socialTasks.steam.curatorLinks.push(link);
  7933. }
  7934. if (action === 'do') {
  7935. this.undoneTasks.steam.curatorLinks.push(link);
  7936. }
  7937. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7938. if (action === 'undo') {
  7939. this.socialTasks.discord.serverLinks.push(link);
  7940. }
  7941. if (action === 'do') {
  7942. this.undoneTasks.discord.serverLinks.push(link);
  7943. }
  7944. } else if (/^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)) {} else {
  7945. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7946. }
  7947. }
  7948. logStatus.success();
  7949. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7950. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7951. if (window.DEBUG) {
  7952. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  7953. }
  7954. GM_setValue(`khTasks-${this.giveawayId}`, {
  7955. tasks: this.socialTasks,
  7956. time: new Date().getTime()
  7957. });
  7958. return true;
  7959. } catch (error) {
  7960. throwError(error, 'Keyhub.classifyTask');
  7961. return false;
  7962. }
  7963. }
  7964. }
  7965. function Keyhub_getGiveawayId2() {
  7966. try {
  7967. var _window$location$href;
  7968. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7969. if (giveawayId) {
  7970. this.giveawayId = giveawayId;
  7971. return true;
  7972. }
  7973. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7974. return false;
  7975. } catch (error) {
  7976. throwError(error, 'Keyhub.getGiveawayId');
  7977. return false;
  7978. }
  7979. }
  7980. async function Keyhub_checkLeftKey2() {
  7981. try {
  7982. if (!globalOptions.other.checkLeftKey) {
  7983. return true;
  7984. }
  7985. const leftKey = $('#keysleft').text().trim();
  7986. if (leftKey === '0') {
  7987. await external_Swal_default().fire({
  7988. icon: 'warning',
  7989. title: i18n('notice'),
  7990. text: i18n('noKeysLeft'),
  7991. confirmButtonText: i18n('confirm'),
  7992. cancelButtonText: i18n('cancel'),
  7993. showCancelButton: true
  7994. }).then(_ref => {
  7995. let {
  7996. value
  7997. } = _ref;
  7998. if (value) {
  7999. window.close();
  8000. }
  8001. });
  8002. }
  8003. return true;
  8004. } catch (error) {
  8005. throwError(error, 'Keyhub.checkLeftKey');
  8006. return false;
  8007. }
  8008. }
  8009. function Keyhub_checkLogin2() {
  8010. try {
  8011. if (!globalOptions.other.checkLogin) {
  8012. return true;
  8013. }
  8014. if ($('a[href*="/connect/steam"]').length > 0) {
  8015. window.open('/connect/steam', '_self');
  8016. }
  8017. return true;
  8018. } catch (error) {
  8019. throwError(error, 'Keyhub.checkLogin');
  8020. return false;
  8021. }
  8022. }
  8023. const website_Keyhub = Keyhub;
  8024. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  8025. Givekey_checkPrivateRedeclaration(obj, privateSet);
  8026. privateSet.add(obj);
  8027. }
  8028. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  8029. if (privateCollection.has(obj)) {
  8030. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8031. }
  8032. }
  8033. function Givekey_defineProperty(obj, key, value) {
  8034. if (key in obj) {
  8035. Object.defineProperty(obj, key, {
  8036. value: value,
  8037. enumerable: true,
  8038. configurable: true,
  8039. writable: true
  8040. });
  8041. } else {
  8042. obj[key] = value;
  8043. }
  8044. return obj;
  8045. }
  8046. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  8047. if (!privateSet.has(receiver)) {
  8048. throw new TypeError('attempted to get private field on non-instance');
  8049. }
  8050. return fn;
  8051. }
  8052. const Givekey_defaultTasksTemplate = {
  8053. steam: {
  8054. groupLinks: [],
  8055. wishlistLinks: [],
  8056. curatorLinks: [],
  8057. curatorLikeLinks: []
  8058. },
  8059. twitter: {
  8060. userLinks: []
  8061. },
  8062. vk: {
  8063. nameLinks: []
  8064. },
  8065. discord: {
  8066. serverLinks: []
  8067. }
  8068. };
  8069. const Givekey_defaultTasks = JSON.stringify(Givekey_defaultTasksTemplate);
  8070. var Givekey_verify = new WeakSet();
  8071. var Givekey_getGiveawayId = new WeakSet();
  8072. var Givekey_checkLeftKey = new WeakSet();
  8073. class Givekey extends website_Website {
  8074. constructor() {
  8075. super(...arguments);
  8076. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  8077. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  8078. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  8079. Givekey_defineProperty(this, 'name', 'Givekey');
  8080. Givekey_defineProperty(this, 'tasks', []);
  8081. Givekey_defineProperty(this, 'socialTasks', JSON.parse(Givekey_defaultTasks));
  8082. Givekey_defineProperty(this, 'undoneTasks', JSON.parse(Givekey_defaultTasks));
  8083. Givekey_defineProperty(this, 'userId', void 0);
  8084. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8085. }
  8086. static test() {
  8087. return window.location.host === 'givekey.ru';
  8088. }
  8089. async after() {
  8090. try {
  8091. await new Promise(resolve => {
  8092. const checker = setInterval(() => {
  8093. if ($('#navbarDropdown').length > 0) {
  8094. clearInterval(checker);
  8095. resolve(true);
  8096. }
  8097. });
  8098. });
  8099. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  8100. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8101. }
  8102. } catch (error) {
  8103. throwError(error, 'Givekey.after');
  8104. return false;
  8105. }
  8106. }
  8107. init() {
  8108. try {
  8109. const logStatus = scripts_echoLog({
  8110. text: i18n('initing')
  8111. });
  8112. if ($('a[href*="/auth/steam"]').length > 0) {
  8113. window.open('/auth/steam', '_self');
  8114. logStatus.warning(i18n('needLogin'));
  8115. return false;
  8116. }
  8117. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  8118. return false;
  8119. }
  8120. const userId = $('meta[name="user-id"]').attr('content');
  8121. if (!userId) {
  8122. logStatus.error(i18n('getFailed', i18n('userId')));
  8123. return false;
  8124. }
  8125. this.userId = userId;
  8126. this.initialized = true;
  8127. logStatus.success();
  8128. return true;
  8129. } catch (error) {
  8130. throwError(error, 'Givekey.init');
  8131. return false;
  8132. }
  8133. }
  8134. async classifyTask(action) {
  8135. try {
  8136. const logStatus = scripts_echoLog({
  8137. text: i18n('getTasksInfo')
  8138. });
  8139. if (action === 'undo') {
  8140. var _GM_getValue;
  8141. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Givekey_defaultTasks);
  8142. }
  8143. const tasks = $('.card-body:has("button") .row');
  8144. for (const task of tasks) {
  8145. const taskEle = $(task);
  8146. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  8147. if (isSuccess && action !== 'undo') {
  8148. continue;
  8149. }
  8150. const checkButton = taskEle.find('#task_check');
  8151. const taskId = checkButton.attr('data-id');
  8152. if (taskId) {
  8153. this.tasks.push(taskId);
  8154. }
  8155. if (action === 'verify') {
  8156. continue;
  8157. }
  8158. let href = taskEle.find('a').attr('href') || null;
  8159. const text = taskEle.find('a').text().trim();
  8160. const icon = taskEle.find('i');
  8161. if (!href || !text) {
  8162. continue;
  8163. }
  8164. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  8165. href = await getRedirectLink(href);
  8166. }
  8167. if (!href) {
  8168. continue;
  8169. }
  8170. if (/^https?:\/\/vk\.com\//.test(href)) {
  8171. this.socialTasks.vk.nameLinks.push(href);
  8172. if (action === 'do' && !isSuccess) {
  8173. this.undoneTasks.vk.nameLinks.push(href);
  8174. }
  8175. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  8176. this.socialTasks.steam.groupLinks.push(href);
  8177. if (action === 'do' && !isSuccess) {
  8178. this.undoneTasks.steam.groupLinks.push(href);
  8179. }
  8180. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  8181. this.socialTasks.steam.wishlistLinks.push(href);
  8182. if (action === 'do' && !isSuccess) {
  8183. this.undoneTasks.steam.wishlistLinks.push(href);
  8184. }
  8185. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  8186. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  8187. this.socialTasks.steam.curatorLinks.push(href);
  8188. if (action === 'do' && !isSuccess) {
  8189. this.undoneTasks.steam.curatorLinks.push(href);
  8190. }
  8191. } else {
  8192. this.socialTasks.steam.curatorLikeLinks.push(href);
  8193. if (action === 'do' && !isSuccess) {
  8194. this.undoneTasks.steam.curatorLikeLinks.push(href);
  8195. }
  8196. }
  8197. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  8198. this.socialTasks.twitter.userLinks.push(href);
  8199. if (action === 'do' && !isSuccess) {
  8200. this.undoneTasks.twitter.userLinks.push(href);
  8201. }
  8202. } else if (icon.hasClass('fa-discord') || /^https?:\/\/discord\.com\/invite\//.test(href)) {
  8203. this.socialTasks.discord.serverLinks.push(href);
  8204. if (action === 'do' && !isSuccess) {
  8205. this.undoneTasks.discord.serverLinks.push(href);
  8206. }
  8207. } else {
  8208. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  8209. }
  8210. }
  8211. logStatus.success();
  8212. this.tasks = unique(this.tasks);
  8213. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8214. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8215. if (window.DEBUG) {
  8216. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8217. }
  8218. GM_setValue(`gkTasks-${this.giveawayId}`, {
  8219. tasks: this.socialTasks,
  8220. time: new Date().getTime()
  8221. });
  8222. return true;
  8223. } catch (error) {
  8224. throwError(error, 'Givekey.classifyTask');
  8225. return false;
  8226. }
  8227. }
  8228. async verifyTask() {
  8229. try {
  8230. if (!this.initialized && !this.init()) {
  8231. return false;
  8232. }
  8233. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  8234. return false;
  8235. }
  8236. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  8237. const taskLength = this.tasks.length;
  8238. for (let i = 0; i < taskLength; i++) {
  8239. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  8240. if (i < taskLength - 1) {
  8241. await delay(15e3);
  8242. }
  8243. }
  8244. scripts_echoLog({}).success(i18n('allTasksComplete'));
  8245. scripts_echoLog({
  8246. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  8247. });
  8248. return true;
  8249. } catch (error) {
  8250. throwError(error, 'Givekey.verifyTask');
  8251. return false;
  8252. }
  8253. }
  8254. }
  8255. async function Givekey_verify2(task) {
  8256. try {
  8257. const logStatus = scripts_echoLog({
  8258. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  8259. });
  8260. return await new Promise(resolve => {
  8261. $.ajax({
  8262. url: 'https://givekey.ru/giveaway/task',
  8263. method: 'POST',
  8264. data: `id=${task}&user_id=${this.userId}`,
  8265. dataType: 'json',
  8266. headers: {
  8267. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  8268. },
  8269. success: data => {
  8270. if (data.btn) {
  8271. $(`button[data-id=${this.userId}]`).html(data.btn);
  8272. }
  8273. if (data.status === 'ok') {
  8274. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  8275. logStatus.success();
  8276. resolve(true);
  8277. } else if (data.status === 'end') {
  8278. logStatus.success();
  8279. scripts_echoLog({}).success(data.key);
  8280. resolve(true);
  8281. } else {
  8282. logStatus.error(`Error:${data.msg}`);
  8283. resolve(false);
  8284. }
  8285. },
  8286. error: xhr => {
  8287. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  8288. resolve(false);
  8289. }
  8290. });
  8291. });
  8292. } catch (error) {
  8293. throwError(error, 'Givekey.verify');
  8294. return false;
  8295. }
  8296. }
  8297. function Givekey_getGiveawayId2() {
  8298. try {
  8299. var _window$location$href;
  8300. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8301. if (giveawayId) {
  8302. this.giveawayId = giveawayId;
  8303. return true;
  8304. }
  8305. scripts_echoLog({
  8306. text: i18n('getFailed', 'GiveawayId')
  8307. });
  8308. return false;
  8309. } catch (error) {
  8310. throwError(error, 'Givekey.getGiveawayId');
  8311. return false;
  8312. }
  8313. }
  8314. async function Givekey_checkLeftKey2() {
  8315. try {
  8316. if (!globalOptions.other.checkLeftKey) {
  8317. return true;
  8318. }
  8319. if (!$('#keys_count').text()) {
  8320. await external_Swal_default().fire({
  8321. icon: 'warning',
  8322. title: i18n('notice'),
  8323. text: i18n('noKeysLeft'),
  8324. confirmButtonText: i18n('confirm'),
  8325. cancelButtonText: i18n('cancel'),
  8326. showCancelButton: true
  8327. }).then(_ref => {
  8328. let {
  8329. value
  8330. } = _ref;
  8331. if (value) {
  8332. window.close();
  8333. }
  8334. });
  8335. }
  8336. return true;
  8337. } catch (error) {
  8338. throwError(error, 'Givekey.checkLeftKey');
  8339. return false;
  8340. }
  8341. }
  8342. const website_Givekey = Givekey;
  8343. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  8344. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  8345. privateSet.add(obj);
  8346. }
  8347. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  8348. if (privateCollection.has(obj)) {
  8349. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8350. }
  8351. }
  8352. function GiveeClub_defineProperty(obj, key, value) {
  8353. if (key in obj) {
  8354. Object.defineProperty(obj, key, {
  8355. value: value,
  8356. enumerable: true,
  8357. configurable: true,
  8358. writable: true
  8359. });
  8360. } else {
  8361. obj[key] = value;
  8362. }
  8363. return obj;
  8364. }
  8365. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  8366. if (!privateSet.has(receiver)) {
  8367. throw new TypeError('attempted to get private field on non-instance');
  8368. }
  8369. return fn;
  8370. }
  8371. var GiveeClub_checkLogin = new WeakSet();
  8372. var GiveeClub_getGiveawayId = new WeakSet();
  8373. var GiveeClub_checkLeftKey = new WeakSet();
  8374. class GiveeClub extends GiveawaySu {
  8375. constructor() {
  8376. super(...arguments);
  8377. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  8378. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  8379. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  8380. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  8381. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8382. }
  8383. static test() {
  8384. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  8385. }
  8386. async after() {
  8387. try {
  8388. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8389. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8390. }
  8391. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  8392. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8393. }
  8394. } catch (error) {
  8395. throwError(error, 'GiveeClub.after');
  8396. }
  8397. }
  8398. init() {
  8399. try {
  8400. const logStatus = scripts_echoLog({
  8401. text: i18n('initing')
  8402. });
  8403. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  8404. logStatus.warning(i18n('needLogin'));
  8405. return false;
  8406. }
  8407. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  8408. return false;
  8409. }
  8410. this.initialized = true;
  8411. logStatus.success();
  8412. return true;
  8413. } catch (error) {
  8414. throwError(error, 'GiveeClub.init');
  8415. return false;
  8416. }
  8417. }
  8418. async classifyTask(action) {
  8419. try {
  8420. const logStatus = scripts_echoLog({
  8421. text: i18n('getTasksInfo')
  8422. });
  8423. if (action === 'undo') {
  8424. var _GM_getValue;
  8425. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  8426. return true;
  8427. }
  8428. const pro = [];
  8429. const tasks = $('.event-actions tr');
  8430. for (const task of tasks) {
  8431. pro.push(new Promise(resolve => {
  8432. const taskDes = $(task).find('.event-action-label a');
  8433. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  8434. const taskName = taskDes.text().trim();
  8435. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  8436. return resolve(true);
  8437. }
  8438. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  8439. if (!taskLink) {
  8440. return resolve(false);
  8441. }
  8442. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  8443. this.undoneTasks.steam.groupLinks.push(taskLink);
  8444. } else if (/like.*announcement/gi.test(taskName)) {
  8445. this.undoneTasks.steam.announcementLinks.push(taskLink);
  8446. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  8447. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  8448. } else if (taskIcon.includes('plus') && taskDes.attr('data-steam-wishlist-appid')) {
  8449. this.undoneTasks.steam.wishlistLinks.push(`https://store.steampowered.com/app/${taskDes.attr('data-steam-wishlist-appid')}`);
  8450. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  8451. this.undoneTasks.steam.curatorLinks.push(taskLink);
  8452. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  8453. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  8454. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  8455. this.undoneTasks.steam.forumLinks.push(taskLink);
  8456. } else if (taskIcon.includes('discord')) {
  8457. this.undoneTasks.discord.serverLinks.push(taskLink);
  8458. } else if (taskIcon.includes('instagram')) {
  8459. this.undoneTasks.instagram.userLinks.push(taskLink);
  8460. } else if (taskIcon.includes('twitch')) {
  8461. this.undoneTasks.twitch.channelLinks.push(taskLink);
  8462. } else if (taskIcon.includes('reddit')) {
  8463. this.undoneTasks.reddit.redditLinks.push(taskLink);
  8464. } else if (/watch.*art/gim.test(taskName)) {
  8465. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  8466. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  8467. this.undoneTasks.youtube.channelLinks.push(taskLink);
  8468. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  8469. this.undoneTasks.youtube.likeLinks.push(taskLink);
  8470. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  8471. this.undoneTasks.vk.nameLinks.push(taskLink);
  8472. } else {
  8473. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  8474. if (/follow.*button/gim.test(taskName)) {
  8475. this.undoneTasks.steam.followLinks.push(taskLink);
  8476. }
  8477. }
  8478. }
  8479. resolve(true);
  8480. }).catch(error => {
  8481. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  8482. return false;
  8483. });
  8484. }));
  8485. }
  8486. await Promise.all(pro);
  8487. logStatus.success();
  8488. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8489. this.socialTasks = this.undoneTasks;
  8490. if (window.DEBUG) {
  8491. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  8492. }
  8493. GM_setValue(`gcTasks-${this.giveawayId}`, {
  8494. tasks: this.socialTasks,
  8495. time: new Date().getTime()
  8496. });
  8497. return true;
  8498. } catch (error) {
  8499. throwError(error, 'GiveeClub.classifyTask');
  8500. return false;
  8501. }
  8502. }
  8503. async verifyTask() {
  8504. try {
  8505. const logStatus = scripts_echoLog({
  8506. text: i18n('giveeClubVerifyNotice')
  8507. });
  8508. const taskButtons = $('.event-actions tr button').has('i.glyphicon-refresh').not('[data-type="user.adblock"]');
  8509. for (const button of taskButtons) {
  8510. button.click();
  8511. if ($(button).attr('data-type') !== 'steam.game.wishlist') {
  8512. await delay(1e3);
  8513. }
  8514. }
  8515. logStatus.warning(i18n('giveeClubVerifyFinished'));
  8516. return true;
  8517. } catch (error) {
  8518. throwError(error, 'Givekey.verifyTask');
  8519. return false;
  8520. }
  8521. }
  8522. }
  8523. function GiveeClub_checkLogin2() {
  8524. try {
  8525. if (!globalOptions.other.checkLogin) {
  8526. return true;
  8527. }
  8528. if ($('a[href*="/account/auth"]').length > 0) {
  8529. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  8530. }
  8531. return true;
  8532. } catch (error) {
  8533. throwError(error, 'GiveeClub.checkLogin');
  8534. return false;
  8535. }
  8536. }
  8537. function GiveeClub_getGiveawayId2() {
  8538. var _window$location$href;
  8539. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8540. if (giveawayId) {
  8541. this.giveawayId = giveawayId;
  8542. return true;
  8543. }
  8544. scripts_echoLog({
  8545. text: i18n('getFailed', 'GiveawayId')
  8546. });
  8547. return false;
  8548. }
  8549. async function GiveeClub_checkLeftKey2() {
  8550. try {
  8551. if (!globalOptions.other.checkLeftKey) {
  8552. return true;
  8553. }
  8554. if ($('.event-ended').length > 0 && $('.event-winner').length === 0) {
  8555. await external_Swal_default().fire({
  8556. icon: 'warning',
  8557. title: i18n('notice'),
  8558. text: i18n('giveawayEnded'),
  8559. confirmButtonText: i18n('confirm'),
  8560. cancelButtonText: i18n('cancel'),
  8561. showCancelButton: true
  8562. }).then(_ref => {
  8563. let {
  8564. value
  8565. } = _ref;
  8566. if (value) {
  8567. window.close();
  8568. }
  8569. });
  8570. }
  8571. return true;
  8572. } catch (error) {
  8573. throwError(error, 'Giveawaysu.checkLeftKey');
  8574. return false;
  8575. }
  8576. }
  8577. const website_GiveeClub = GiveeClub;
  8578. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  8579. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  8580. privateSet.add(obj);
  8581. }
  8582. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  8583. if (privateCollection.has(obj)) {
  8584. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8585. }
  8586. }
  8587. function OpiumPulses_defineProperty(obj, key, value) {
  8588. if (key in obj) {
  8589. Object.defineProperty(obj, key, {
  8590. value: value,
  8591. enumerable: true,
  8592. configurable: true,
  8593. writable: true
  8594. });
  8595. } else {
  8596. obj[key] = value;
  8597. }
  8598. return obj;
  8599. }
  8600. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  8601. if (!privateSet.has(receiver)) {
  8602. throw new TypeError('attempted to get private field on non-instance');
  8603. }
  8604. return fn;
  8605. }
  8606. const defaultOptions = {
  8607. maxPoint: '99999999'
  8608. };
  8609. var _toggleTask = new WeakSet();
  8610. var OpiumPulses_checkLogin = new WeakSet();
  8611. class OpiumPulses {
  8612. constructor() {
  8613. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  8614. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  8615. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  8616. OpiumPulses_defineProperty(this, 'options', {
  8617. ...defaultOptions,
  8618. ...GM_getValue('OpiumPulsesOptions')
  8619. });
  8620. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  8621. OpiumPulses_defineProperty(this, 'myPoints', 0);
  8622. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  8623. }
  8624. static test() {
  8625. return window.location.host === 'www.opiumpulses.com';
  8626. }
  8627. async after() {
  8628. try {
  8629. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  8630. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8631. }
  8632. this.maxPoints = parseInt(this.options.maxPoint, 10);
  8633. } catch (error) {
  8634. throwError(error, 'OpiumPulses.after');
  8635. }
  8636. }
  8637. async doFreeTask() {
  8638. try {
  8639. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  8640. } catch (error) {
  8641. throwError(error, 'OpiumPulses.doFreeTask');
  8642. }
  8643. }
  8644. async doPointTask() {
  8645. try {
  8646. var _$$text$match;
  8647. 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);
  8648. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  8649. } catch (error) {
  8650. throwError(error, 'OpiumPulses.doPointTask');
  8651. }
  8652. }
  8653. init() {
  8654. return true;
  8655. }
  8656. classifyTask() {
  8657. return true;
  8658. }
  8659. }
  8660. async function _toggleTask2(type) {
  8661. try {
  8662. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  8663. for (const item of items) {
  8664. var _$$find$text$match;
  8665. 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);
  8666. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  8667. if (type === 'points' && needPoints > this.myPoints) {
  8668. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  8669. } else if (type === 'points' && !needPoints) {
  8670. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  8671. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  8672. var _aElement$attr;
  8673. const logStatus = scripts_echoLog({
  8674. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  8675. });
  8676. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  8677. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  8678. var _aElement$attr2, _aElement$attr2$match;
  8679. 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];
  8680. if (giveawayId) {
  8681. checkUser(giveawayId);
  8682. }
  8683. }
  8684. if (!aElement.attr('href')) {
  8685. logStatus.error('Error: No "href".');
  8686. continue;
  8687. }
  8688. const {
  8689. result,
  8690. statusText,
  8691. status,
  8692. data
  8693. } = await tools_httpRequest({
  8694. url: aElement.attr('href'),
  8695. method: 'GET'
  8696. });
  8697. if (result === 'Success') {
  8698. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8699. var _data$responseText$ma;
  8700. logStatus.success();
  8701. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8702. if (type === 'points' && points) {
  8703. this.myPoints = parseInt(points, 10);
  8704. }
  8705. } else {
  8706. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8707. }
  8708. } else {
  8709. logStatus.error(`${result}:${statusText}(${status})`);
  8710. }
  8711. }
  8712. }
  8713. scripts_echoLog({
  8714. text: '-----END-----'
  8715. });
  8716. } catch (error) {
  8717. throwError(error, 'OpiumPulses.toggleTask');
  8718. }
  8719. }
  8720. function OpiumPulses_checkLogin2() {
  8721. try {
  8722. if (!globalOptions.other.checkLogin) {
  8723. return true;
  8724. }
  8725. if ($('a[href*="/site/login"]').length > 1) {
  8726. window.open('/site/login', '_self');
  8727. }
  8728. return true;
  8729. } catch (error) {
  8730. throwError(error, 'OpiumPulses.checkLogin');
  8731. return false;
  8732. }
  8733. }
  8734. const website_OpiumPulses = OpiumPulses;
  8735. const external_dayjs_namespaceObject = dayjs;
  8736. var external_dayjs_default = __webpack_require__.n(external_dayjs_namespaceObject);
  8737. const leftKeyChecker = {
  8738. async classify(link) {
  8739. try {
  8740. if (/^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(link)) {
  8741. return await this.giveawaySu(link);
  8742. }
  8743. if (/^https?:\/\/givee\.club\/[\w]+?\/event\/[\d]+/.test(link)) {
  8744. return await this.giveeClub(link);
  8745. }
  8746. if (/^https?:\/\/gleam\.io\/.+?\/.+/.test(link)) {
  8747. return await this.gleam(link);
  8748. }
  8749. if (/^https?:\/\/www\.indiedb\.com\/giveaways\/.+/.test(link)) {
  8750. return await this.indieDb(link);
  8751. }
  8752. if (/^https?:\/\/key-hub\.eu\/giveaway\/[\d]+/.test(link)) {
  8753. return await this.keyhub(link);
  8754. }
  8755. if (/^https?:\/\/opquests\.com\/quests\/[\d]+/.test(link)) {
  8756. return await this.opquests(link);
  8757. }
  8758. if (/^https?:\/\/itch\.io\/s\/[\d]+?\/.*/.test(link)) {
  8759. return await this.itch(link);
  8760. }
  8761. return false;
  8762. } catch (error) {
  8763. throwError(error, 'leftKeyChecker.classify');
  8764. return false;
  8765. }
  8766. },
  8767. async giveawaySu(link) {
  8768. try {
  8769. const {
  8770. result,
  8771. data
  8772. } = await tools_httpRequest({
  8773. url: link,
  8774. method: 'GET'
  8775. });
  8776. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8777. if (data.responseText.includes('class="steam-login"')) {
  8778. return false;
  8779. }
  8780. if (data.responseText.includes('class="giveaway-ended"')) {
  8781. return 'Ended';
  8782. }
  8783. return 'Active';
  8784. }
  8785. return false;
  8786. } catch (error) {
  8787. throwError(error, 'leftKeyChecker.giveawaySu');
  8788. return false;
  8789. }
  8790. },
  8791. async giveeClub(link) {
  8792. try {
  8793. const {
  8794. result,
  8795. data
  8796. } = await tools_httpRequest({
  8797. url: link,
  8798. method: 'GET'
  8799. });
  8800. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8801. if (data.responseText.includes('class="event-winner"')) {
  8802. return 'Won';
  8803. }
  8804. if (data.responseText.includes('class="event-ended"')) {
  8805. return 'Ended';
  8806. }
  8807. return 'Active';
  8808. }
  8809. return false;
  8810. } catch (error) {
  8811. throwError(error, 'leftKeyChecker.giveeClub');
  8812. return false;
  8813. }
  8814. },
  8815. async gleam(link) {
  8816. try {
  8817. const {
  8818. result,
  8819. data
  8820. } = await tools_httpRequest({
  8821. url: link,
  8822. method: 'GET'
  8823. });
  8824. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8825. var _data$responseText$ma, _$$attr, _$$attr$match;
  8826. if (/incentives&quot;:{&quot;[\d]+?&quot;:\[&quot;.+?&quot;\]/.test(data.responseText)) {
  8827. return 'Won';
  8828. }
  8829. 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];
  8830. if (!campaignDiv) {
  8831. return false;
  8832. }
  8833. 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];
  8834. if (!campaignString) {
  8835. return false;
  8836. }
  8837. const {
  8838. campaign
  8839. } = JSON.parse(campaignString);
  8840. if (campaign.banned) {
  8841. return 'Banned';
  8842. }
  8843. if (campaign.finished) {
  8844. return 'Ended';
  8845. }
  8846. if (campaign.paused) {
  8847. return 'Paused';
  8848. }
  8849. if (new Date().getTime() < campaign.starts_at * 1e3) {
  8850. return 'NotStart';
  8851. }
  8852. return 'Active';
  8853. }
  8854. return false;
  8855. } catch (error) {
  8856. throwError(error, 'leftKeyChecker.gleam');
  8857. return false;
  8858. }
  8859. },
  8860. async indieDb(link) {
  8861. try {
  8862. const {
  8863. result,
  8864. data
  8865. } = await tools_httpRequest({
  8866. url: link,
  8867. method: 'GET'
  8868. });
  8869. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8870. if (data.responseText.includes('Congrats you WON')) {
  8871. return 'Won';
  8872. }
  8873. if (data.responseText.includes('Giveaway is closed') || data.responseText.includes('next time')) {
  8874. return 'Ended';
  8875. }
  8876. return 'Active';
  8877. }
  8878. return false;
  8879. } catch (error) {
  8880. throwError(error, 'leftKeyChecker.indieDb');
  8881. return false;
  8882. }
  8883. },
  8884. async keyhub(link) {
  8885. try {
  8886. const {
  8887. result,
  8888. data
  8889. } = await tools_httpRequest({
  8890. url: link,
  8891. method: 'GET'
  8892. });
  8893. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8894. var _data$responseText$ma2;
  8895. 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];
  8896. if (!keysleft) {
  8897. return false;
  8898. }
  8899. if (keysleft === '0') {
  8900. return 'Ended';
  8901. }
  8902. return `Active(${keysleft})`;
  8903. }
  8904. return false;
  8905. } catch (error) {
  8906. throwError(error, 'leftKeyChecker.keyhub');
  8907. return false;
  8908. }
  8909. },
  8910. async opquests(link) {
  8911. try {
  8912. const {
  8913. result,
  8914. data
  8915. } = await tools_httpRequest({
  8916. url: link,
  8917. method: 'GET'
  8918. });
  8919. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8920. var _data$responseText$ma3;
  8921. 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];
  8922. if (!keysleft) {
  8923. return false;
  8924. }
  8925. if (keysleft === '0') {
  8926. return 'Ended';
  8927. }
  8928. return `Active(${keysleft})`;
  8929. } else if ((data === null || data === void 0 ? void 0 : data.status) === 404) {
  8930. return 'Ended';
  8931. }
  8932. return false;
  8933. } catch (error) {
  8934. throwError(error, 'leftKeyChecker.opquests');
  8935. return false;
  8936. }
  8937. },
  8938. async itch(link) {
  8939. try {
  8940. const {
  8941. result,
  8942. data
  8943. } = await tools_httpRequest({
  8944. url: link,
  8945. method: 'GET'
  8946. });
  8947. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  8948. var _data$responseText$ma4;
  8949. 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];
  8950. if (!endDate) {
  8951. return false;
  8952. }
  8953. if (new Date().getTime() > new Date(endDate).getTime()) {
  8954. return 'Ended';
  8955. }
  8956. return `Active(${external_dayjs_default()(endDate).format('YYYY-MM-DD HH:mm:ss')})`;
  8957. }
  8958. return false;
  8959. } catch (error) {
  8960. throwError(error, 'leftKeyChecker.opquests');
  8961. return false;
  8962. }
  8963. }
  8964. };
  8965. const website_leftKeyChecker = leftKeyChecker;
  8966. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8967. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8968. privateSet.add(obj);
  8969. }
  8970. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8971. if (privateCollection.has(obj)) {
  8972. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8973. }
  8974. }
  8975. function Keylol_defineProperty(obj, key, value) {
  8976. if (key in obj) {
  8977. Object.defineProperty(obj, key, {
  8978. value: value,
  8979. enumerable: true,
  8980. configurable: true,
  8981. writable: true
  8982. });
  8983. } else {
  8984. obj[key] = value;
  8985. }
  8986. return obj;
  8987. }
  8988. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8989. if (!privateSet.has(receiver)) {
  8990. throw new TypeError('attempted to get private field on non-instance');
  8991. }
  8992. return fn;
  8993. }
  8994. const Keylol_defaultTasksTemplate = {
  8995. steam: {
  8996. groupLinks: [],
  8997. wishlistLinks: [],
  8998. curatorLinks: [],
  8999. curatorLikeLinks: [],
  9000. followLinks: [],
  9001. forumLinks: [],
  9002. announcementLinks: [],
  9003. workshopVoteLinks: [],
  9004. licenseLinks: []
  9005. },
  9006. discord: {
  9007. serverLinks: []
  9008. },
  9009. instagram: {
  9010. userLinks: []
  9011. },
  9012. vk: {
  9013. nameLinks: []
  9014. },
  9015. twitch: {
  9016. channelLinks: []
  9017. },
  9018. reddit: {
  9019. redditLinks: []
  9020. },
  9021. twitter: {
  9022. userLinks: [],
  9023. retweetLinks: []
  9024. },
  9025. youtube: {
  9026. channelLinks: [],
  9027. likeLinks: []
  9028. }
  9029. };
  9030. const Keylol_defaultTasks = JSON.stringify(Keylol_defaultTasksTemplate);
  9031. var _addBtn = new WeakSet();
  9032. class Keylol extends website_Website {
  9033. constructor() {
  9034. super(...arguments);
  9035. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  9036. Keylol_defineProperty(this, 'name', 'Keylol');
  9037. Keylol_defineProperty(this, 'socialTasks', JSON.parse(Keylol_defaultTasks));
  9038. Keylol_defineProperty(this, 'undoneTasks', JSON.parse(Keylol_defaultTasks));
  9039. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  9040. }
  9041. static test() {
  9042. var _$$eq$attr, _$$eq$attr2;
  9043. 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')));
  9044. }
  9045. init() {
  9046. return true;
  9047. }
  9048. after() {
  9049. try {
  9050. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  9051. const mainPost = $(selector);
  9052. const discordLinks = mainPost.find('a[href*="discord.com"]:visible');
  9053. const redditLinks = mainPost.find('a[href*="reddit.com"]:visible');
  9054. const insLinks = mainPost.find('a[href*="instagram.com"]:visible');
  9055. const twitterLinks = mainPost.find('a[href*="twitter.com"]:visible');
  9056. const twitchLinks = mainPost.find('a[href*="twitch.tv"]:visible');
  9057. const vkLinks = mainPost.find('a[href*="vk.com"]:visible');
  9058. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]:visible');
  9059. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]:visible');
  9060. const ytbLinks = mainPost.find('a[href*="youtube.com"]:visible');
  9061. if (discordLinks.length > 0) {
  9062. for (const discordLink of discordLinks) {
  9063. const link = $(discordLink).attr('href');
  9064. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  9065. continue;
  9066. }
  9067. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  9068. }
  9069. }
  9070. if (redditLinks.length > 0) {
  9071. for (const redditLink of redditLinks) {
  9072. const link = $(redditLink).attr('href');
  9073. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  9074. continue;
  9075. }
  9076. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  9077. }
  9078. }
  9079. if (insLinks.length > 0) {
  9080. for (const insLink of insLinks) {
  9081. const link = $(insLink).attr('href');
  9082. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  9083. continue;
  9084. }
  9085. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  9086. }
  9087. }
  9088. if (twitterLinks.length > 0) {
  9089. for (const twitterLink of twitterLinks) {
  9090. const link = $(twitterLink).attr('href');
  9091. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  9092. continue;
  9093. }
  9094. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  9095. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  9096. } else {
  9097. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  9098. }
  9099. }
  9100. }
  9101. if (twitchLinks.length > 0) {
  9102. for (const twitchLink of twitchLinks) {
  9103. const link = $(twitchLink).attr('href');
  9104. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  9105. continue;
  9106. }
  9107. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  9108. }
  9109. }
  9110. if (vkLinks.length > 0) {
  9111. for (const vkLink of vkLinks) {
  9112. const link = $(vkLink).attr('href');
  9113. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  9114. continue;
  9115. }
  9116. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  9117. }
  9118. }
  9119. if (steamStoreLinks.length > 0) {
  9120. for (const steamStoreLink of steamStoreLinks) {
  9121. const link = $(steamStoreLink).attr('href');
  9122. if (!link) {
  9123. continue;
  9124. }
  9125. if (/curator\/[\d]+/.test(link)) {
  9126. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  9127. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  9128. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  9129. } else if (/news(hub)?\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  9130. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  9131. } else if (/app\/[\d]+/.test(link)) {
  9132. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  9133. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  9134. }
  9135. }
  9136. }
  9137. if (steamCommunityLinks.length > 0) {
  9138. for (const steamCommunityLink of steamCommunityLinks) {
  9139. const link = $(steamCommunityLink).attr('href');
  9140. if (!link) {
  9141. continue;
  9142. }
  9143. if (/groups\/.+/.test(link)) {
  9144. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  9145. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  9146. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  9147. }
  9148. }
  9149. }
  9150. if (ytbLinks.length > 0) {
  9151. for (const ytbLink of ytbLinks) {
  9152. const link = $(ytbLink).attr('href');
  9153. if (!link) {
  9154. continue;
  9155. }
  9156. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  9157. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'likeLinks', link);
  9158. }
  9159. }
  9160. 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');
  9161. if (giveawayLinks.length > 0) {
  9162. for (const giveawayLink of giveawayLinks) {
  9163. const link = $(giveawayLink).attr('href');
  9164. if (!link) {
  9165. continue;
  9166. }
  9167. website_leftKeyChecker.classify(link).then(status => {
  9168. if (!status) {
  9169. return;
  9170. }
  9171. if (/^Active/.test(status)) {
  9172. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status active" title="${i18n('Active')}">${status}</font>`);
  9173. return;
  9174. }
  9175. $(`a[href="${link}"]`).after(`<font class="auto-task-giveaway-status not-active" title="${i18n(status)}">${status}</font>`);
  9176. }).catch(error => {
  9177. throwError(error, 'keylol.after -> leftKeyChecker');
  9178. });
  9179. }
  9180. }
  9181. if (this.name === 'Keylol') {
  9182. const asfLinks = mainPost.find('a[href^="#asf"]:visible');
  9183. if (asfLinks.length > 0) {
  9184. for (const asfLink of asfLinks) {
  9185. const link = $(asfLink).attr('href');
  9186. if (!link) {
  9187. continue;
  9188. }
  9189. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(`a[href="${link}"]`).after('<span style="color: #ccc; margin: 0 -5px 0 5px"> | </span>').next()[0], 'steam', 'licenseLinks', `appid-${link.replace('#asf', '')}`);
  9190. }
  9191. }
  9192. const subLinks = mainPost.find('a[href*="steamdb.info/sub/"]:visible');
  9193. if (subLinks.length > 0) {
  9194. for (const subLink of subLinks) {
  9195. var _link$match;
  9196. const link = $(subLink).attr('href');
  9197. if (!link) {
  9198. continue;
  9199. }
  9200. const subid = (_link$match = link.match(/^https:\/\/steamdb\.info\/sub\/([\d]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  9201. if (!subid) {
  9202. continue;
  9203. }
  9204. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, subLink, 'steam', 'licenseLinks', `subid-${subid}`);
  9205. }
  9206. }
  9207. const asfLinks2 = mainPost.find('.blockcode:contains("addlicense"):visible');
  9208. if (asfLinks2.length > 0) {
  9209. for (const asfLink of asfLinks2) {
  9210. const subid = asfLink.innerText.match(/[\d]+/g);
  9211. if (!subid || subid.length === 0) {
  9212. continue;
  9213. }
  9214. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, $(asfLink).children('em')[0], 'steam', 'licenseLinks', `subid-${subid.join(',')}`);
  9215. }
  9216. }
  9217. }
  9218. } catch (error) {
  9219. throwError(error, 'keylol.after');
  9220. }
  9221. }
  9222. classifyTask(action) {
  9223. try {
  9224. this.socialTasks = JSON.parse(Keylol_defaultTasks);
  9225. this.undoneTasks = JSON.parse(Keylol_defaultTasks);
  9226. const selectedBtns = $('.auto-task-keylol[selected="selected"]:visible');
  9227. for (const btn of selectedBtns) {
  9228. const button = $(btn);
  9229. const social = button.attr('data-social');
  9230. const type = button.attr('data-type');
  9231. const link = button.attr('data-link');
  9232. if (!(social && type && link)) {
  9233. continue;
  9234. }
  9235. if (action === 'do') {
  9236. this.undoneTasks[social][type].push(link);
  9237. }
  9238. if (action === 'undo') {
  9239. this.socialTasks[social][type].push(link);
  9240. }
  9241. }
  9242. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9243. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9244. if (window.DEBUG) {
  9245. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9246. }
  9247. return true;
  9248. } catch (error) {
  9249. throwError(error, 'Keylol.classifyTask');
  9250. return false;
  9251. }
  9252. }
  9253. selectAll() {
  9254. try {
  9255. $('.auto-task-keylol:visible').attr('selected', 'selected');
  9256. } catch (error) {
  9257. throwError(error, 'Keylol.selectAll');
  9258. }
  9259. }
  9260. selectNone() {
  9261. try {
  9262. $('.auto-task-keylol:visible').removeAttr('selected');
  9263. } catch (error) {
  9264. throwError(error, 'Keylol.selectNone');
  9265. }
  9266. }
  9267. invertSelect() {
  9268. try {
  9269. $('.auto-task-keylol:visible').each((index, element) => {
  9270. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  9271. });
  9272. } catch (error) {
  9273. throwError(error, 'Keylol.invertSelect');
  9274. }
  9275. }
  9276. }
  9277. function _addBtn2(before, social, linkType, link) {
  9278. try {
  9279. $(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>`);
  9280. } catch (error) {
  9281. throwError(error, 'keylol.addBtn');
  9282. }
  9283. }
  9284. const website_Keylol = Keylol;
  9285. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  9286. Opquests_checkPrivateRedeclaration(obj, privateSet);
  9287. privateSet.add(obj);
  9288. }
  9289. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  9290. if (privateCollection.has(obj)) {
  9291. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9292. }
  9293. }
  9294. function Opquests_defineProperty(obj, key, value) {
  9295. if (key in obj) {
  9296. Object.defineProperty(obj, key, {
  9297. value: value,
  9298. enumerable: true,
  9299. configurable: true,
  9300. writable: true
  9301. });
  9302. } else {
  9303. obj[key] = value;
  9304. }
  9305. return obj;
  9306. }
  9307. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  9308. if (!privateSet.has(receiver)) {
  9309. throw new TypeError('attempted to get private field on non-instance');
  9310. }
  9311. return fn;
  9312. }
  9313. const Opquests_defaultTasks = {
  9314. steam: {
  9315. groupLinks: [],
  9316. wishlistLinks: [],
  9317. followLinks: [],
  9318. curatorLikeLinks: []
  9319. }
  9320. };
  9321. var Opquests_getGiveawayId = new WeakSet();
  9322. var Opquests_checkLogin = new WeakSet();
  9323. class Opquests extends website_Website {
  9324. constructor() {
  9325. super(...arguments);
  9326. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  9327. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  9328. Opquests_defineProperty(this, 'name', 'Opquests');
  9329. Opquests_defineProperty(this, 'undoneTasks', {
  9330. ...Opquests_defaultTasks
  9331. });
  9332. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  9333. }
  9334. static test() {
  9335. return window.location.host === 'opquests.com';
  9336. }
  9337. async after() {
  9338. try {
  9339. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  9340. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9341. }
  9342. } catch (error) {
  9343. throwError(error, 'Opquests.after');
  9344. }
  9345. }
  9346. init() {
  9347. try {
  9348. const logStatus = scripts_echoLog({
  9349. text: i18n('initing')
  9350. });
  9351. if ($('a[href*="/auth/redirect"]').length > 0) {
  9352. window.open('/auth/redirect', '_self');
  9353. logStatus.warning(i18n('needLogin'));
  9354. return false;
  9355. }
  9356. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  9357. return false;
  9358. }
  9359. this.initialized = true;
  9360. logStatus.success();
  9361. return true;
  9362. } catch (error) {
  9363. throwError(error, 'Opquests.init');
  9364. return false;
  9365. }
  9366. }
  9367. async classifyTask(action) {
  9368. try {
  9369. if (action === 'undo') {
  9370. scripts_echoLog({
  9371. text: i18n('cannotUndo')
  9372. });
  9373. return false;
  9374. }
  9375. const logStatus = scripts_echoLog({
  9376. text: i18n('getTasksInfo')
  9377. });
  9378. const tasks = $('.w-full:contains("Validate") .items-center');
  9379. for (const task of tasks) {
  9380. const link = $(task).find('a:contains("Open")').attr('href');
  9381. const taskDes = $(task).find('div').eq(1).text().trim();
  9382. if (!link) {
  9383. continue;
  9384. }
  9385. if (/steamcommunity\.com\/groups\//.test(link)) {
  9386. this.undoneTasks.steam.groupLinks.push(link);
  9387. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  9388. if (/wishlist/gim.test(taskDes)) {
  9389. this.undoneTasks.steam.wishlistLinks.push(link);
  9390. } else if (/follow/gim.test(taskDes)) {
  9391. this.undoneTasks.steam.followLinks.push(link);
  9392. }
  9393. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  9394. this.undoneTasks.steam.curatorLikeLinks.push(link);
  9395. } else {
  9396. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  9397. }
  9398. }
  9399. logStatus.success();
  9400. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9401. if (window.DEBUG) {
  9402. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9403. }
  9404. return true;
  9405. } catch (error) {
  9406. throwError(error, 'Opquests.classifyTask');
  9407. return false;
  9408. }
  9409. }
  9410. }
  9411. function Opquests_getGiveawayId2() {
  9412. try {
  9413. var _window$location$href;
  9414. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9415. if (giveawayId) {
  9416. this.giveawayId = giveawayId;
  9417. return true;
  9418. }
  9419. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  9420. return false;
  9421. } catch (error) {
  9422. throwError(error, 'Opquests.getGiveawayId');
  9423. return false;
  9424. }
  9425. }
  9426. function Opquests_checkLogin2() {
  9427. try {
  9428. if (!globalOptions.other.checkLogin) {
  9429. return true;
  9430. }
  9431. if ($('a[href*="/auth/redirect"]').length > 0) {
  9432. window.open('/auth/redirect', '_self');
  9433. }
  9434. return true;
  9435. } catch (error) {
  9436. throwError(error, 'Opquests.checkLogin');
  9437. return false;
  9438. }
  9439. }
  9440. const website_Opquests = Opquests;
  9441. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  9442. Gleam_checkPrivateRedeclaration(obj, privateSet);
  9443. privateSet.add(obj);
  9444. }
  9445. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  9446. if (privateCollection.has(obj)) {
  9447. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9448. }
  9449. }
  9450. function Gleam_defineProperty(obj, key, value) {
  9451. if (key in obj) {
  9452. Object.defineProperty(obj, key, {
  9453. value: value,
  9454. enumerable: true,
  9455. configurable: true,
  9456. writable: true
  9457. });
  9458. } else {
  9459. obj[key] = value;
  9460. }
  9461. return obj;
  9462. }
  9463. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  9464. if (!privateSet.has(receiver)) {
  9465. throw new TypeError('attempted to get private field on non-instance');
  9466. }
  9467. return fn;
  9468. }
  9469. const Gleam_defaultTasksTemplate = {
  9470. steam: {
  9471. groupLinks: [],
  9472. wishlistLinks: [],
  9473. followLinks: [],
  9474. curatorLinks: [],
  9475. curatorLikeLinks: []
  9476. },
  9477. twitter: {
  9478. userLinks: [],
  9479. retweetLinks: []
  9480. },
  9481. twitch: {
  9482. channelLinks: []
  9483. },
  9484. discord: {
  9485. serverLinks: []
  9486. },
  9487. youtube: {
  9488. channelLinks: []
  9489. },
  9490. extra: {
  9491. gleam: []
  9492. }
  9493. };
  9494. const Gleam_defaultTasks = JSON.stringify(Gleam_defaultTasksTemplate);
  9495. const Gleam_defaultOptions = {
  9496. vlootUsername: '',
  9497. gameroundUsername: ''
  9498. };
  9499. var _checkSync = new WeakSet();
  9500. var _doGleamTask = new WeakSet();
  9501. var Gleam_getGiveawayId = new WeakSet();
  9502. var _getGleamLink = new WeakSet();
  9503. var Gleam_checkLeftKey = new WeakSet();
  9504. class Gleam extends website_Website {
  9505. constructor() {
  9506. super(...arguments);
  9507. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  9508. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  9509. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  9510. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  9511. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  9512. Gleam_defineProperty(this, 'name', 'Gleam');
  9513. Gleam_defineProperty(this, 'undoneTasks', JSON.parse(Gleam_defaultTasks));
  9514. Gleam_defineProperty(this, 'socialTasks', JSON.parse(Gleam_defaultTasks));
  9515. Gleam_defineProperty(this, 'options', {
  9516. ...Gleam_defaultOptions,
  9517. ...GM_getValue('GleamOptions')
  9518. });
  9519. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  9520. }
  9521. static test() {
  9522. return window.location.host === 'gleam.io';
  9523. }
  9524. async after() {
  9525. try {
  9526. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  9527. const checkComplete = setInterval(() => {
  9528. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  9529. clearInterval(checkComplete);
  9530. window.close();
  9531. }
  9532. });
  9533. for (const task of $('.entry-content .entry-method')) {
  9534. const taskInfo = $(task).find('.user-links');
  9535. const expandInfo = $(task).find('.expandable');
  9536. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  9537. if (aElements.length > 0) {
  9538. for (const element of aElements) {
  9539. const $element = $(element);
  9540. const href = $element.attr('href');
  9541. $element.removeAttr('href')[0].click();
  9542. $element.attr('href', href);
  9543. await delay(1e3);
  9544. }
  9545. }
  9546. taskInfo[0].click();
  9547. await delay(1e3);
  9548. }
  9549. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  9550. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  9551. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  9552. }
  9553. } catch (error) {
  9554. throwError(error, 'Gleam.after');
  9555. return false;
  9556. }
  9557. }
  9558. init() {
  9559. try {
  9560. const logStatus = scripts_echoLog({
  9561. text: i18n('initing')
  9562. });
  9563. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  9564. return false;
  9565. }
  9566. this.initialized = true;
  9567. logStatus.success();
  9568. return true;
  9569. } catch (error) {
  9570. throwError(error, 'Gleam.init');
  9571. return false;
  9572. }
  9573. }
  9574. async classifyTask(action) {
  9575. try {
  9576. const logStatus = scripts_echoLog({
  9577. text: i18n('getTasksInfo')
  9578. });
  9579. if (action === 'undo') {
  9580. var _GM_getValue;
  9581. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || JSON.parse(Gleam_defaultTasks);
  9582. }
  9583. const tasks = $('.entry-content .entry-method');
  9584. for (const task of tasks) {
  9585. var _socialIcon$attr;
  9586. const $task = $(task);
  9587. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  9588. continue;
  9589. }
  9590. const socialIcon = $task.find('.icon-wrapper i');
  9591. const taskInfo = $task.find('.user-links');
  9592. const taskText = taskInfo.text().trim();
  9593. const expandInfo = $task.find('.expandable');
  9594. const aElements = expandInfo.find('a.btn');
  9595. if (aElements.length > 0) {
  9596. for (const element of aElements) {
  9597. const $element = $(element);
  9598. const href = $element.attr('href');
  9599. $element.removeAttr('href')[0].click();
  9600. $element.attr('href', href);
  9601. }
  9602. }
  9603. if (socialIcon.hasClass('fa-twitter')) {
  9604. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  9605. if (!link) {
  9606. continue;
  9607. }
  9608. if (/follow/gi.test(taskText)) {
  9609. if (action === 'undo') {
  9610. this.socialTasks.twitter.userLinks.push(link);
  9611. }
  9612. if (action === 'do') {
  9613. this.undoneTasks.twitter.userLinks.push(link);
  9614. }
  9615. } else if (/retweet/gim.test(taskText)) {
  9616. if (action === 'undo') {
  9617. this.socialTasks.twitter.retweetLinks.push(link);
  9618. }
  9619. if (action === 'do') {
  9620. this.undoneTasks.twitter.retweetLinks.push(link);
  9621. }
  9622. }
  9623. } else if (socialIcon.hasClass('fa-twitch')) {
  9624. if (/follow/gim.test(taskText)) {
  9625. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  9626. if (!link) {
  9627. continue;
  9628. }
  9629. if (action === 'undo') {
  9630. this.socialTasks.twitch.channelLinks.push(link);
  9631. }
  9632. if (action === 'do') {
  9633. this.undoneTasks.twitch.channelLinks.push(link);
  9634. }
  9635. }
  9636. } else if (socialIcon.hasClass('fa-discord')) {
  9637. if (/join/gim.test(taskText)) {
  9638. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  9639. if (!link) {
  9640. var _$task$find$attr, _$task$find$attr$matc;
  9641. 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];
  9642. if (!ggLink) {
  9643. continue;
  9644. }
  9645. link = `https://discord.com/invite/${ggLink}`;
  9646. }
  9647. if (action === 'undo') {
  9648. this.socialTasks.discord.serverLinks.push(link);
  9649. }
  9650. if (action === 'do') {
  9651. this.undoneTasks.discord.serverLinks.push(link);
  9652. }
  9653. }
  9654. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  9655. continue;
  9656. } else if (socialIcon.hasClass('fa-youtube')) {
  9657. if (/subscribe/gim.test(taskText)) {
  9658. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  9659. if (!link) {
  9660. continue;
  9661. }
  9662. if (action === 'undo') {
  9663. this.socialTasks.youtube.channelLinks.push(link);
  9664. }
  9665. if (action === 'do') {
  9666. this.undoneTasks.youtube.channelLinks.push(link);
  9667. }
  9668. }
  9669. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  9670. if (/join.*group/gi.test(taskText)) {
  9671. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  9672. if (!link) {
  9673. continue;
  9674. }
  9675. if (action === 'undo') {
  9676. this.socialTasks.steam.groupLinks.push(link);
  9677. }
  9678. if (action === 'do') {
  9679. this.undoneTasks.steam.groupLinks.push(link);
  9680. }
  9681. } else if (/follow.*curator/gi.test(taskText)) {
  9682. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  9683. if (!link) {
  9684. continue;
  9685. }
  9686. if (action === 'undo') {
  9687. this.socialTasks.steam.curatorLinks.push(link);
  9688. }
  9689. if (action === 'do') {
  9690. this.undoneTasks.steam.curatorLinks.push(link);
  9691. }
  9692. }
  9693. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  9694. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9695. for (const button of continueBtn) {
  9696. button.click();
  9697. await delay(500);
  9698. expandInfo.find('input').val(this.options.vlootUsername);
  9699. }
  9700. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  9701. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  9702. for (const button of continueBtn) {
  9703. button.click();
  9704. await delay(500);
  9705. expandInfo.find('input').val(this.options.gameroundUsername);
  9706. }
  9707. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  9708. if (action !== 'do') {
  9709. continue;
  9710. }
  9711. const link = aElements.attr('href');
  9712. if (!link) {
  9713. continue;
  9714. }
  9715. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  9716. if (!gleamLink) {
  9717. continue;
  9718. }
  9719. this.undoneTasks.extra.gleam.push(gleamLink);
  9720. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-instagram') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-telegram-plane') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  9721. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  9722. }
  9723. }
  9724. logStatus.success();
  9725. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  9726. this.socialTasks = this.uniqueTasks(this.socialTasks);
  9727. if (window.DEBUG) {
  9728. console.log('%cAuto-Task[Debug]:', 'color:blue', JSON.stringify(this));
  9729. }
  9730. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  9731. tasks: this.socialTasks,
  9732. time: new Date().getTime()
  9733. });
  9734. return true;
  9735. } catch (error) {
  9736. throwError(error, 'Gleam.classifyTask');
  9737. return false;
  9738. }
  9739. }
  9740. async extraDoTask(_ref) {
  9741. let {
  9742. gleam
  9743. } = _ref;
  9744. try {
  9745. const pro = [];
  9746. for (const link of gleam) {
  9747. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  9748. }
  9749. return Promise.all(pro).then(() => true);
  9750. } catch (error) {
  9751. throwError(error, 'Gleam.extraDoTask');
  9752. return false;
  9753. }
  9754. }
  9755. async verifyTask() {
  9756. try {
  9757. scripts_echoLog({
  9758. text: `${i18n('verifyingTask')}...`
  9759. });
  9760. const tasks = $('.entry-content .entry-method');
  9761. for (const task of tasks) {
  9762. const $task = $(task);
  9763. if ($task.find('i.fa-question').length === 0) {
  9764. continue;
  9765. }
  9766. const taskInfo = $task.find('.user-links');
  9767. taskInfo[0].click();
  9768. await delay(500);
  9769. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9770. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  9771. for (const button of continueBtn) {
  9772. button.click();
  9773. await delay(500);
  9774. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  9775. }
  9776. }
  9777. scripts_echoLog({
  9778. text: i18n('verifiedGleamTasks')
  9779. });
  9780. } catch (error) {
  9781. throwError(error, 'Gleam.verifyTask');
  9782. return false;
  9783. }
  9784. }
  9785. }
  9786. async function _checkSync2() {
  9787. try {
  9788. return await new Promise(resolve => {
  9789. const checker = setInterval(() => {
  9790. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  9791. clearInterval(checker);
  9792. resolve(true);
  9793. }
  9794. }, 500);
  9795. });
  9796. } catch (error) {
  9797. throwError(error, 'Gleam.checkSync');
  9798. return false;
  9799. }
  9800. }
  9801. async function _doGleamTask2(link) {
  9802. try {
  9803. const logStatus = scripts_echoLog({
  9804. text: i18n('doingGleamTask')
  9805. });
  9806. return await new Promise(resolve => {
  9807. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  9808. active: true,
  9809. insert: true,
  9810. setParent: true
  9811. }).onclose = () => {
  9812. logStatus.success();
  9813. resolve(true);
  9814. };
  9815. });
  9816. } catch (error) {
  9817. throwError(error, 'Gleam.doGleamTask');
  9818. return false;
  9819. }
  9820. }
  9821. function Gleam_getGiveawayId2() {
  9822. try {
  9823. const giveawayId = window.location.pathname;
  9824. if (giveawayId) {
  9825. this.giveawayId = giveawayId;
  9826. return true;
  9827. }
  9828. scripts_echoLog({
  9829. text: i18n('getFailed', 'GiveawayId')
  9830. });
  9831. return false;
  9832. } catch (error) {
  9833. throwError(error, 'Gleam.getGiveawayId');
  9834. return false;
  9835. }
  9836. }
  9837. async function _getGleamLink2(link) {
  9838. try {
  9839. const logStatus = scripts_echoLog({
  9840. text: i18n('gettingGleamLink')
  9841. });
  9842. const {
  9843. result,
  9844. statusText,
  9845. status,
  9846. data
  9847. } = await tools_httpRequest({
  9848. url: link,
  9849. method: 'GET'
  9850. });
  9851. if (result === 'Success') {
  9852. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9853. var _data$responseText$ma;
  9854. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  9855. if (gleamLink) {
  9856. logStatus.success();
  9857. return gleamLink;
  9858. }
  9859. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  9860. return false;
  9861. }
  9862. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9863. return false;
  9864. }
  9865. logStatus.error(`${result}:${statusText}(${status})`);
  9866. return false;
  9867. } catch (error) {
  9868. throwError(error, 'Gleam.getGleamLink');
  9869. return false;
  9870. }
  9871. }
  9872. async function Gleam_checkLeftKey2() {
  9873. try {
  9874. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  9875. if (!globalOptions.other.checkLeftKey) {
  9876. return true;
  9877. }
  9878. 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];
  9879. if (!campaignString) {
  9880. return false;
  9881. }
  9882. const {
  9883. campaign,
  9884. incentive
  9885. } = JSON.parse(campaignString);
  9886. 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];
  9887. let ownedKey = false;
  9888. if (controllerString) {
  9889. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  9890. 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) {
  9891. ownedKey = true;
  9892. }
  9893. }
  9894. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  9895. await external_Swal_default().fire({
  9896. icon: 'warning',
  9897. title: i18n('notice'),
  9898. text: i18n('giveawayNotWork'),
  9899. confirmButtonText: i18n('confirm'),
  9900. cancelButtonText: i18n('cancel'),
  9901. showCancelButton: true
  9902. }).then(_ref2 => {
  9903. let {
  9904. value
  9905. } = _ref2;
  9906. if (value) {
  9907. window.close();
  9908. }
  9909. });
  9910. }
  9911. return true;
  9912. } catch (error) {
  9913. throwError(error, 'Gleam.checkLeftKey');
  9914. return false;
  9915. }
  9916. }
  9917. const website_Gleam = Gleam;
  9918. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  9919. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  9920. privateSet.add(obj);
  9921. }
  9922. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  9923. if (privateCollection.has(obj)) {
  9924. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9925. }
  9926. }
  9927. function SweepWidget_defineProperty(obj, key, value) {
  9928. if (key in obj) {
  9929. Object.defineProperty(obj, key, {
  9930. value: value,
  9931. enumerable: true,
  9932. configurable: true,
  9933. writable: true
  9934. });
  9935. } else {
  9936. obj[key] = value;
  9937. }
  9938. return obj;
  9939. }
  9940. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  9941. if (!privateSet.has(receiver)) {
  9942. throw new TypeError('attempted to get private field on non-instance');
  9943. }
  9944. return fn;
  9945. }
  9946. const SweepWidget_defaultOptions = {
  9947. username: '',
  9948. email: ''
  9949. };
  9950. var SweepWidget_checkLogin = new WeakSet();
  9951. var SweepWidget_getGiveawayId = new WeakSet();
  9952. var _checkEnter = new WeakSet();
  9953. var _checkFinish = new WeakSet();
  9954. class SweepWidget extends website_Website {
  9955. constructor() {
  9956. super(...arguments);
  9957. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  9958. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  9959. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  9960. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  9961. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  9962. SweepWidget_defineProperty(this, 'options', {
  9963. ...SweepWidget_defaultOptions,
  9964. ...GM_getValue('SweepWidgetOptions')
  9965. });
  9966. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  9967. }
  9968. static test() {
  9969. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  9970. }
  9971. async after() {
  9972. try {
  9973. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9974. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9975. }
  9976. } catch (error) {
  9977. throwError(error, 'SweepWidget.after');
  9978. }
  9979. }
  9980. init() {
  9981. try {
  9982. const logStatus = scripts_echoLog({
  9983. text: i18n('initing')
  9984. });
  9985. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9986. logStatus.warning(i18n('needLogin'));
  9987. return false;
  9988. }
  9989. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9990. return false;
  9991. }
  9992. this.initialized = true;
  9993. logStatus.success();
  9994. return true;
  9995. } catch (error) {
  9996. throwError(error, 'SweepWidget.init');
  9997. return false;
  9998. }
  9999. }
  10000. classifyTask() {
  10001. return true;
  10002. }
  10003. async doTask() {
  10004. try {
  10005. if ($('#unlock_rewards_main_wrapper').length === 0) {
  10006. if ($('input[name="sw__login_name"]:visible').length > 0) {
  10007. $('input[name="sw__login_name"]').val(this.options.username);
  10008. }
  10009. if ($('input[name="sw__login_email"]:visible').length > 0) {
  10010. $('input[name="sw__login_email"]').val(this.options.email);
  10011. }
  10012. if ($('#sw_login_button:visible').length > 0) {
  10013. $('#sw_login_button')[0].click();
  10014. }
  10015. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  10016. return false;
  10017. }
  10018. }
  10019. const logStatus = scripts_echoLog({
  10020. text: i18n('SweepWidgetNotice')
  10021. });
  10022. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  10023. for (const task of tasks) {
  10024. var _aElement$, _$task$find$removeAtt;
  10025. const $task = $(task);
  10026. if ($task.find('i.fa-check:visible').length > 0) {
  10027. continue;
  10028. }
  10029. const title = $task.find('.sw_text_inner');
  10030. title[0].click();
  10031. const aElement = $task.find('a.sw_link');
  10032. const link = aElement.attr('href');
  10033. aElement.attr('href', '#a').attr('target', '_self');
  10034. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  10035. await delay(300);
  10036. aElement.attr('href', link).attr('target', '_blank');
  10037. $task.find('input[type="text"]').val('test');
  10038. const verifyBtn = $task.find('input.sw_verify');
  10039. if (verifyBtn.prop('disabled') === true) {
  10040. title[0].click();
  10041. await delay(300);
  10042. title[0].click();
  10043. await delay(300);
  10044. }
  10045. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  10046. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  10047. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  10048. }
  10049. logStatus.success();
  10050. return true;
  10051. } catch (error) {
  10052. throwError(error, 'SweepWidget.doTask');
  10053. return false;
  10054. }
  10055. }
  10056. }
  10057. function SweepWidget_checkLogin2() {
  10058. try {
  10059. if ($('#twitter_login_button').length > 0) {
  10060. $('#twitter_login_button')[0].click();
  10061. }
  10062. return true;
  10063. } catch (error) {
  10064. throwError(error, 'SweepWidget.checkLogin');
  10065. return false;
  10066. }
  10067. }
  10068. function SweepWidget_getGiveawayId2() {
  10069. try {
  10070. var _window$location$href;
  10071. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  10072. if (giveawayId) {
  10073. this.giveawayId = giveawayId;
  10074. return true;
  10075. }
  10076. scripts_echoLog({
  10077. text: i18n('getFailed', 'GiveawayId')
  10078. });
  10079. return false;
  10080. } catch (error) {
  10081. throwError(error, 'SweepWidget.getGiveawayId');
  10082. return false;
  10083. }
  10084. }
  10085. async function _checkEnter2() {
  10086. try {
  10087. return new Promise(resolve => {
  10088. const checker = setInterval(() => {
  10089. if ($('#unlock_rewards_main_wrapper').length > 0) {
  10090. clearInterval(checker);
  10091. resolve(true);
  10092. }
  10093. });
  10094. });
  10095. } catch (error) {
  10096. throwError(error, 'SweepWidget.checkEnter');
  10097. return false;
  10098. }
  10099. }
  10100. async function _checkFinish2($task) {
  10101. try {
  10102. return new Promise(resolve => {
  10103. const checker = setInterval(() => {
  10104. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  10105. clearInterval(checker);
  10106. resolve(true);
  10107. }
  10108. });
  10109. });
  10110. } catch (error) {
  10111. throwError(error, 'SweepWidget.checkFinish');
  10112. return false;
  10113. }
  10114. }
  10115. const website_SweepWidget = SweepWidget;
  10116. const defaultWhiteList = {
  10117. discord: {
  10118. servers: []
  10119. },
  10120. instagram: {
  10121. users: []
  10122. },
  10123. twitch: {
  10124. channels: []
  10125. },
  10126. twitter: {
  10127. users: [],
  10128. retweets: [],
  10129. likes: []
  10130. },
  10131. vk: {
  10132. names: []
  10133. },
  10134. youtube: {
  10135. channels: [],
  10136. likes: []
  10137. },
  10138. reddit: {
  10139. reddits: []
  10140. },
  10141. steam: {
  10142. groups: [],
  10143. officialGroups: [],
  10144. wishlists: [],
  10145. follows: [],
  10146. forums: [],
  10147. workshops: [],
  10148. curators: [],
  10149. workshopVotes: [],
  10150. curatorLikes: [],
  10151. announcements: [],
  10152. licenses: [],
  10153. playtests: []
  10154. }
  10155. };
  10156. const link2id = async function(type) {
  10157. 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;
  10158. try {
  10159. const link = $('#socialLink').val();
  10160. let id = '';
  10161. switch (type) {
  10162. case 'discord.servers':
  10163. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  10164. break;
  10165.  
  10166. case 'instagram.users':
  10167. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  10168. break;
  10169.  
  10170. case 'twitch.channels':
  10171. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  10172. break;
  10173.  
  10174. case 'twitter.users':
  10175. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  10176. break;
  10177.  
  10178. case 'twitter.retweets':
  10179. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  10180. break;
  10181.  
  10182. case 'vk.names':
  10183. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  10184. break;
  10185.  
  10186. case 'youtube.channels':
  10187. 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) || '';
  10188. break;
  10189.  
  10190. case 'youtube.likes':
  10191. 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) || '';
  10192. break;
  10193.  
  10194. case 'reddit.reddits':
  10195. 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]) || '';
  10196. break;
  10197.  
  10198. case 'steam.groups':
  10199. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  10200. break;
  10201.  
  10202. case 'steam.wishlists':
  10203. case 'steam.follows':
  10204. case 'steam.forums':
  10205. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  10206. break;
  10207.  
  10208. case 'steam.workshops':
  10209. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  10210. break;
  10211.  
  10212. case 'steam.curators':
  10213. {
  10214. if (link.includes('curator')) {
  10215. var _link$match12;
  10216. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  10217. } else {
  10218. var _link$match13;
  10219. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  10220. if (!param || param.length !== 2) {
  10221. break;
  10222. }
  10223. const steam = new social_Steam();
  10224. if (await steam.init()) {
  10225. id = await steam.getCuratorId(param[0], param[1]) || '';
  10226. }
  10227. }
  10228. }
  10229. break;
  10230. }
  10231. return id;
  10232. } catch (error) {
  10233. throwError(error, 'link2id');
  10234. return i18n('getFailed', 'id');
  10235. }
  10236. };
  10237. const disabledType = {
  10238. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  10239. twitter: [ 'likes' ]
  10240. };
  10241. const assignWhiteList = whiteList => {
  10242. try {
  10243. const newWhiteList = {};
  10244. for (const [ key, value ] of Object.entries(defaultWhiteList)) {
  10245. newWhiteList[key] = {
  10246. ...value,
  10247. ...whiteList[key]
  10248. };
  10249. }
  10250. return newWhiteList;
  10251. } catch (error) {
  10252. throwError(error, 'assignWhiteList');
  10253. return defaultWhiteList;
  10254. }
  10255. };
  10256. const whiteListOptions = function(showType) {
  10257. try {
  10258. const whiteList = assignWhiteList(GM_getValue('whiteList') || {});
  10259. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  10260. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  10261. for (const [ social, types ] of Object.entries(whiteList)) {
  10262. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  10263. var _disabledType$social;
  10264. 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>`;
  10265. }).join('');
  10266. }
  10267. whiteListOptionsForm += '</tbody></table></form>';
  10268. if (showType === 'swal') {
  10269. external_Swal_default().fire({
  10270. title: i18n('whiteListOptions'),
  10271. html: whiteListOptionsForm,
  10272. showConfirmButton: false,
  10273. showCloseButton: true
  10274. });
  10275. } else {
  10276. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  10277. }
  10278. $('.editWhiteList').on('click', function() {
  10279. var _whiteList$social;
  10280. const value = $(this).attr('data-value');
  10281. if (!value) {
  10282. return;
  10283. }
  10284. const [ social, type ] = value.split('.');
  10285. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  10286. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  10287. return;
  10288. }
  10289. external_Swal_default().fire({
  10290. title: i18n('changeWhiteListOption', value),
  10291. input: 'textarea',
  10292. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10293. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  10294. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  10295. inputValue: whiteList[social][type].join('\n'),
  10296. showConfirmButton: true,
  10297. confirmButtonText: i18n('save'),
  10298. showCancelButton: true,
  10299. cancelButtonText: i18n('close'),
  10300. showDenyButton: true,
  10301. denyButtonText: i18n('return')
  10302. }).then(_ref => {
  10303. let {
  10304. isDenied,
  10305. isConfirmed,
  10306. value
  10307. } = _ref;
  10308. if (isDenied) {
  10309. if (showType === 'swal') {
  10310. whiteListOptions(showType);
  10311. }
  10312. return;
  10313. } else if (isConfirmed) {
  10314. whiteList[social][type] = value.split('\n');
  10315. GM_setValue('whiteList', whiteList);
  10316. external_Swal_default().fire({
  10317. title: i18n('changeWhiteListSuccess'),
  10318. icon: 'success'
  10319. });
  10320. }
  10321. });
  10322. $('#link2id').on('click', async function() {
  10323. const type = $(this).attr('data-type');
  10324. $('#socialLink').val(await link2id(type));
  10325. });
  10326. });
  10327. } catch (error) {
  10328. throwError(error, 'whiteListOptions');
  10329. }
  10330. };
  10331. const whiteList = whiteListOptions;
  10332. const setGistData = async (token, gistId, fileName, content) => {
  10333. try {
  10334. const logStatus = scripts_echoLog({
  10335. text: i18n('settingData')
  10336. });
  10337. const contentData = JSON.stringify({
  10338. files: {
  10339. [fileName]: {
  10340. content: JSON.stringify(content)
  10341. }
  10342. }
  10343. });
  10344. const {
  10345. result,
  10346. statusText,
  10347. status,
  10348. data
  10349. } = await tools_httpRequest({
  10350. url: `https://api.github.com/gists/${gistId}`,
  10351. headers: {
  10352. Accept: 'application/vnd.github.v3+json',
  10353. Authorization: `token ${token}`
  10354. },
  10355. data: contentData,
  10356. responseType: 'json',
  10357. method: 'POST',
  10358. timeout: 3e4
  10359. });
  10360. if (result === 'Success') {
  10361. var _data$response$files, _data$response$files$;
  10362. 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)) {
  10363. logStatus.success();
  10364. return true;
  10365. }
  10366. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10367. return false;
  10368. }
  10369. logStatus.error(`${result}:${statusText}(${status})`);
  10370. return false;
  10371. } catch (error) {
  10372. throwError(error, 'setGistData');
  10373. return false;
  10374. }
  10375. };
  10376. const getGistData = async function(token, gistId, fileName) {
  10377. let test = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10378. try {
  10379. const logStatus = scripts_echoLog({
  10380. text: i18n('gettingData')
  10381. });
  10382. const {
  10383. result,
  10384. statusText,
  10385. status,
  10386. data
  10387. } = await tools_httpRequest({
  10388. url: `https://api.github.com/gists/${gistId}`,
  10389. headers: {
  10390. Accept: 'application/vnd.github.v3+json',
  10391. Authorization: `token ${token}`
  10392. },
  10393. responseType: 'json',
  10394. method: 'GET',
  10395. timeout: 3e4
  10396. });
  10397. if (result === 'Success') {
  10398. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  10399. var _data$response, _data$response$files2, _data$response$files3;
  10400. 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;
  10401. let formatedContent;
  10402. if (!content) {
  10403. logStatus.error(`Error:${i18n('noRemoteData')}`);
  10404. return false;
  10405. }
  10406. if (test) {
  10407. logStatus.success();
  10408. return true;
  10409. }
  10410. try {
  10411. formatedContent = JSON.parse(content);
  10412. } catch (error) {
  10413. logStatus.error(`Error:${i18n('errorRemoteDataFormat')}`);
  10414. return false;
  10415. }
  10416. logStatus.success();
  10417. return formatedContent;
  10418. }
  10419. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  10420. return false;
  10421. }
  10422. logStatus.error(`${result}:${statusText}(${status})`);
  10423. return false;
  10424. } catch (error) {
  10425. throwError(error, 'getGistData');
  10426. return false;
  10427. }
  10428. };
  10429. const syncOptions = () => {
  10430. try {
  10431. const {
  10432. TOKEN,
  10433. GIST_ID,
  10434. FILE_NAME,
  10435. SYNC_HISTORY
  10436. } = GM_getValue('gistOptions') || {
  10437. TOKEN: '',
  10438. GIST_ID: '',
  10439. FILE_NAME: '',
  10440. SYNC_HISTORY: true
  10441. };
  10442. external_Swal_default().fire({
  10443. title: i18n('gistOptions'),
  10444. 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;">
  10445. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  10446. ${i18n('downloadFromGist')}</button></p>`,
  10447. focusConfirm: false,
  10448. showLoaderOnConfirm: true,
  10449. 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>`,
  10450. preConfirm: async () => {
  10451. const token = $('#github-token').val();
  10452. const gistId = $('#gist-id').val();
  10453. const fileName = $('#file-name').val();
  10454. const syncHistory = $('#sync-history').prop('checked');
  10455. GM_setValue('gistOptions', {
  10456. TOKEN: token,
  10457. GIST_ID: gistId,
  10458. FILE_NAME: fileName,
  10459. SYNC_HISTORY: syncHistory
  10460. });
  10461. return await getGistData(token, gistId, fileName, true);
  10462. },
  10463. allowOutsideClick: () => !external_Swal_default().isLoading(),
  10464. confirmButtonText: i18n('saveAndTest'),
  10465. showCancelButton: true,
  10466. cancelButtonText: i18n('close')
  10467. }).then(_ref => {
  10468. let {
  10469. value
  10470. } = _ref;
  10471. if (value) {
  10472. external_Swal_default().fire({
  10473. icon: 'success',
  10474. title: i18n('testSuccess')
  10475. }).then(syncOptions);
  10476. } else if (value !== undefined) {
  10477. external_Swal_default().fire({
  10478. icon: 'error',
  10479. title: i18n('testFailed')
  10480. }).then(syncOptions);
  10481. }
  10482. });
  10483. $('#upload-data').on('click', async () => {
  10484. const {
  10485. TOKEN,
  10486. GIST_ID,
  10487. FILE_NAME
  10488. } = GM_getValue('gistOptions') || {};
  10489. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10490. return external_Swal_default().fire({
  10491. icon: 'error',
  10492. title: i18n('saveAndTestNotice')
  10493. }).then(syncOptions);
  10494. }
  10495. external_Swal_default().fire({
  10496. icon: 'info',
  10497. title: i18n('processingData')
  10498. });
  10499. const data = {};
  10500. const names = GM_listValues();
  10501. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10502. for (const name of names) {
  10503. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  10504. continue;
  10505. }
  10506. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10507. continue;
  10508. }
  10509. data[name] = GM_getValue(name);
  10510. }
  10511. external_Swal_default().update({
  10512. icon: 'info',
  10513. title: i18n('updatingData')
  10514. });
  10515. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  10516. external_Swal_default().fire({
  10517. icon: 'success',
  10518. title: i18n('syncDataSuccess')
  10519. });
  10520. } else {
  10521. external_Swal_default().fire({
  10522. icon: 'error',
  10523. title: i18n('syncDataFailed')
  10524. });
  10525. }
  10526. });
  10527. $('#download-data').on('click', async () => {
  10528. const {
  10529. TOKEN,
  10530. GIST_ID,
  10531. FILE_NAME
  10532. } = GM_getValue('gistOptions') || {};
  10533. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  10534. return external_Swal_default().fire({
  10535. icon: 'error',
  10536. title: i18n('saveAndTestNotice')
  10537. }).then(syncOptions);
  10538. }
  10539. external_Swal_default().fire({
  10540. icon: 'info',
  10541. title: i18n('downloadingData')
  10542. });
  10543. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  10544. if (!data) {
  10545. return external_Swal_default().fire({
  10546. icon: 'error',
  10547. title: i18n('checkedNoData')
  10548. }).then(syncOptions);
  10549. }
  10550. external_Swal_default().update({
  10551. icon: 'info',
  10552. title: i18n('savingData')
  10553. });
  10554. const SYNC_HISTORY = $('#sync-history').prop('checked');
  10555. for (const [ name, value ] of Object.entries(data)) {
  10556. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  10557. continue;
  10558. }
  10559. GM_setValue(name, value);
  10560. }
  10561. external_Swal_default().fire({
  10562. icon: 'success',
  10563. title: i18n('syncDataSuccess')
  10564. });
  10565. });
  10566. } catch (error) {
  10567. throwError(error, 'syncOptions');
  10568. }
  10569. };
  10570. const dataSync = syncOptions;
  10571. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  10572. Setting_checkPrivateRedeclaration(obj, privateSet);
  10573. privateSet.add(obj);
  10574. }
  10575. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  10576. if (privateCollection.has(obj)) {
  10577. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10578. }
  10579. }
  10580. function Setting_defineProperty(obj, key, value) {
  10581. if (key in obj) {
  10582. Object.defineProperty(obj, key, {
  10583. value: value,
  10584. enumerable: true,
  10585. configurable: true,
  10586. writable: true
  10587. });
  10588. } else {
  10589. obj[key] = value;
  10590. }
  10591. return obj;
  10592. }
  10593. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  10594. if (!privateSet.has(receiver)) {
  10595. throw new TypeError('attempted to get private field on non-instance');
  10596. }
  10597. return fn;
  10598. }
  10599. var Setting_getId = new WeakSet();
  10600. var _environment = new WeakSet();
  10601. class Setting {
  10602. constructor() {
  10603. Setting_classPrivateMethodInitSpec(this, _environment);
  10604. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  10605. Setting_defineProperty(this, 'name', 'Setting');
  10606. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  10607. Setting_defineProperty(this, 'syncData', dataSync);
  10608. }
  10609. tasksHistory() {
  10610. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  10611. }
  10612. static test() {
  10613. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  10614. }
  10615. before() {
  10616. $('body').html('').addClass('auto-task-options');
  10617. }
  10618. after() {
  10619. try {
  10620. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  10621. changeGlobalOptions('page');
  10622. whiteList('page');
  10623. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  10624. $('#getTwitterUserId').on('click', () => {
  10625. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  10626. });
  10627. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  10628. $('#getYoutubeChannelId').on('click', () => {
  10629. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  10630. });
  10631. $('input[name^="position"]').on('input', function() {
  10632. const type = $(this).attr('name').replace('position.', '');
  10633. const xLabel = 'rightleft';
  10634. const yLabel = 'topbottpm';
  10635. switch (type) {
  10636. case 'buttonSideX':
  10637. case 'buttonSideY':
  10638. case 'buttonDistance':
  10639. {
  10640. const distance = $('input[name="position.buttonDistance"]').val();
  10641. const sideX = $('input[name="position.buttonSideX"]').val();
  10642. const sideY = $('input[name="position.buttonSideY"]').val();
  10643. if (![ 'right', 'left' ].includes(sideX)) {
  10644. break;
  10645. }
  10646. if (![ 'top', 'bottom' ].includes(sideY)) {
  10647. break;
  10648. }
  10649. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10650. break;
  10651. }
  10652. const distanceArr = distance.split(',');
  10653. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10654. break;
  10655. }
  10656.  
  10657. case 'showButtonSideX':
  10658. case 'showButtonSideY':
  10659. case 'showButtonDistance':
  10660. {
  10661. const distance = $('input[name="position.showButtonDistance"]').val();
  10662. const sideX = $('input[name="position.showButtonSideX"]').val();
  10663. const sideY = $('input[name="position.showButtonSideY"]').val();
  10664. if (![ 'right', 'left' ].includes(sideX)) {
  10665. break;
  10666. }
  10667. if (![ 'top', 'bottom' ].includes(sideY)) {
  10668. break;
  10669. }
  10670. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10671. break;
  10672. }
  10673. const distanceArr = distance.split(',');
  10674. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10675. break;
  10676. }
  10677.  
  10678. case 'logSideX':
  10679. case 'logSideY':
  10680. case 'logDistance':
  10681. {
  10682. const distance = $('input[name="position.logDistance"]').val();
  10683. const sideX = $('input[name="position.logSideX"]').val();
  10684. const sideY = $('input[name="position.logSideY"]').val();
  10685. if (![ 'right', 'left' ].includes(sideX)) {
  10686. break;
  10687. }
  10688. if (![ 'top', 'bottom' ].includes(sideY)) {
  10689. break;
  10690. }
  10691. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  10692. break;
  10693. }
  10694. const distanceArr = distance.split(',');
  10695. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  10696. break;
  10697. }
  10698.  
  10699. default:
  10700. break;
  10701. }
  10702. });
  10703. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  10704. let functionKey = '';
  10705. if (event.altKey) {
  10706. functionKey += 'alt + ';
  10707. } else if (event.ctrlKey) {
  10708. functionKey += 'ctrl + ';
  10709. } else if (event.shiftKey) {
  10710. functionKey += 'shift + ';
  10711. }
  10712. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  10713. });
  10714. } catch (error) {
  10715. throwError(error, 'Setting.after');
  10716. }
  10717. }
  10718. saveGlobalOptions() {
  10719. saveData();
  10720. }
  10721. }
  10722. function Setting_getId2(social) {
  10723. try {
  10724. external_Swal_default().fire({
  10725. title: i18n('getId', i18n(social)),
  10726. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  10727. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  10728. showCancelButton: true,
  10729. cancelButtonText: i18n('close'),
  10730. showConfirmButton: false
  10731. });
  10732. $('#link2id').on('click', async function() {
  10733. const link = $('#socialLink').val();
  10734. if (!link) {
  10735. return;
  10736. }
  10737. const type = $(this).attr('data-type');
  10738. if (type === 'twitterUser') {
  10739. var _link$match;
  10740. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  10741. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  10742. } else if (type === 'youtubeChannel') {
  10743. var _link$match2, _await$getInfo, _await$getInfo$params;
  10744. 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;
  10745. $('#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) || '');
  10746. }
  10747. });
  10748. } catch (error) {
  10749. throwError(error, 'Setting.getId');
  10750. }
  10751. }
  10752. function _environment2() {
  10753. try {
  10754. const userAgent = (0, javascript_utils_umd_min.ua)();
  10755. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  10756. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  10757. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  10758. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  10759. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  10760. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  10761. </tbody></table></form>`;
  10762. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  10763. } catch (error) {
  10764. throwError(error, 'Setting.environment');
  10765. }
  10766. }
  10767. const website_Setting = Setting;
  10768. function History_classPrivateMethodInitSpec(obj, privateSet) {
  10769. History_checkPrivateRedeclaration(obj, privateSet);
  10770. privateSet.add(obj);
  10771. }
  10772. function History_checkPrivateRedeclaration(obj, privateCollection) {
  10773. if (privateCollection.has(obj)) {
  10774. throw new TypeError('Cannot initialize the same private elements twice on an object');
  10775. }
  10776. }
  10777. function History_defineProperty(obj, key, value) {
  10778. if (key in obj) {
  10779. Object.defineProperty(obj, key, {
  10780. value: value,
  10781. enumerable: true,
  10782. configurable: true,
  10783. writable: true
  10784. });
  10785. } else {
  10786. obj[key] = value;
  10787. }
  10788. return obj;
  10789. }
  10790. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  10791. if (!privateSet.has(receiver)) {
  10792. throw new TypeError('attempted to get private field on non-instance');
  10793. }
  10794. return fn;
  10795. }
  10796. var _addItem = new WeakSet();
  10797. class History extends website_Keylol {
  10798. constructor() {
  10799. super(...arguments);
  10800. History_classPrivateMethodInitSpec(this, _addItem);
  10801. History_defineProperty(this, 'name', 'History');
  10802. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  10803. }
  10804. static test() {
  10805. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  10806. }
  10807. before() {
  10808. try {
  10809. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  10810. const data = GM_listValues() || [];
  10811. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10812. for (const item of tasksHistory) {
  10813. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  10814. }
  10815. } catch (error) {
  10816. throwError(error, 'History.before');
  10817. }
  10818. }
  10819. clearHistory() {
  10820. try {
  10821. const data = GM_listValues() || [];
  10822. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  10823. for (const item of tasksHistory) {
  10824. GM_deleteValue(item);
  10825. }
  10826. external_Swal_default().fire({
  10827. title: i18n('clearHistoryFinished'),
  10828. icon: 'success'
  10829. });
  10830. } catch (error) {
  10831. throwError(error, 'History.after');
  10832. }
  10833. }
  10834. }
  10835. function _addItem2(item) {
  10836. try {
  10837. const tasksData = GM_getValue(item);
  10838. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  10839. return;
  10840. }
  10841. let html = '';
  10842. let title = '';
  10843. let link = '';
  10844. const [ website, id ] = item.split('-');
  10845. switch (website) {
  10846. case 'fawTasks':
  10847. title = `Freeanywhere[${id}]`;
  10848. link = `https://freeanywhere.net/#/giveaway/${id}`;
  10849. break;
  10850.  
  10851. case 'gasTasks':
  10852. title = `Giveawaysu[${id}]`;
  10853. link = `https://giveaway.su/giveaway/view/${id}`;
  10854. break;
  10855.  
  10856. case 'gcTasks':
  10857. title = `GiveeClub[${id}]`;
  10858. link = `https://givee.club/event/${id}`;
  10859. break;
  10860.  
  10861. case 'gkTasks':
  10862. title = `Givekey[${id}]`;
  10863. link = `https://givekey.ru/giveaway/${id}`;
  10864. break;
  10865.  
  10866. case 'gleamTasks':
  10867. title = `Gleam[${id}]`;
  10868. link = `https://gleam.io${id}`;
  10869. break;
  10870.  
  10871. case 'khTasks':
  10872. title = `keyhub[${id}]`;
  10873. link = `https://key-hub.eu/giveaway/${id}`;
  10874. break;
  10875.  
  10876. case 'prysTasks':
  10877. title = `Prys[${id}]`;
  10878. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  10879. break;
  10880.  
  10881. default:
  10882. return;
  10883. }
  10884. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  10885. for (const [ type, tasks ] of Object.entries(types)) {
  10886. for (const task of tasks) {
  10887. 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>`;
  10888. }
  10889. }
  10890. }
  10891. $('.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>`);
  10892. $('span.delete-task').on('click', function() {
  10893. const itemName = $(this).attr('data-name');
  10894. if (itemName) {
  10895. GM_deleteValue(itemName);
  10896. $(`div.card[data-name="${itemName}"]`).remove();
  10897. external_Swal_default().fire({
  10898. title: i18n('clearTaskFinished'),
  10899. text: itemName,
  10900. icon: 'success'
  10901. });
  10902. } else {
  10903. external_Swal_default().fire({
  10904. title: i18n('clearTaskFailed'),
  10905. icon: 'error'
  10906. });
  10907. }
  10908. });
  10909. } catch (error) {
  10910. throwError(error, 'History.addItem');
  10911. }
  10912. }
  10913. const website_History = History;
  10914. 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 ];
  10915. const websiteOptions = function(website, options) {
  10916. try {
  10917. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  10918. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  10919. for (const [ option, value ] of Object.entries(options)) {
  10920. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  10921. }
  10922. websiteOptionsForm += '</tbody></table></form>';
  10923. external_Swal_default().fire({
  10924. title: i18n('websiteOptions'),
  10925. html: websiteOptionsForm,
  10926. showConfirmButton: true,
  10927. confirmButtonText: i18n('save'),
  10928. showCancelButton: true,
  10929. cancelButtonText: i18n('close')
  10930. }).then(_ref => {
  10931. let {
  10932. isConfirmed
  10933. } = _ref;
  10934. if (isConfirmed) {
  10935. $('#websiteOptionsForm').serializeArray().map(value => {
  10936. options[value.name] = value.value;
  10937. return value;
  10938. });
  10939. GM_setValue(`${website}Options`, options);
  10940. external_Swal_default().fire({
  10941. title: i18n('changeWebsiteOptionsSuccess'),
  10942. icon: 'success'
  10943. });
  10944. }
  10945. });
  10946. } catch (error) {
  10947. throwError(error, 'websiteOptions');
  10948. }
  10949. };
  10950. const options = websiteOptions;
  10951. const external_keyboardJS_namespaceObject = keyboardJS;
  10952. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  10953. const checkUpdate = async (updateLink, auto) => {
  10954. try {
  10955. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  10956. const {
  10957. result,
  10958. statusText,
  10959. status,
  10960. data
  10961. } = await tools_httpRequest({
  10962. url: checkUrl,
  10963. responseType: 'json',
  10964. method: 'GET',
  10965. timeout: 3e4
  10966. });
  10967. if (result === 'Success') {
  10968. var _data$response;
  10969. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  10970. return data.response;
  10971. }
  10972. if (!auto) {
  10973. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  10974. }
  10975. return false;
  10976. }
  10977. if (!auto) {
  10978. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  10979. }
  10980. return false;
  10981. } catch (error) {
  10982. throwError(error, 'checkUpdate');
  10983. return false;
  10984. }
  10985. };
  10986. const hasNewVersion = (currentVersion, remoteVersion) => {
  10987. try {
  10988. const [ currentRealVersion ] = currentVersion.split('-');
  10989. const [ remoteRealVersion, isPreview ] = remoteVersion.split('-');
  10990. if (isPreview && !globalOptions.other.receivePreview) {
  10991. return false;
  10992. }
  10993. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  10994. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  10995. if (remoteVersion1 > currentVersion1) {
  10996. return true;
  10997. }
  10998. if (remoteVersion1 < currentVersion1) {
  10999. return false;
  11000. }
  11001. if (remoteVersion2 > currentVersion2) {
  11002. return true;
  11003. }
  11004. if (remoteVersion2 < currentVersion2) {
  11005. return false;
  11006. }
  11007. if (remoteVersion3 > currentVersion3) {
  11008. return true;
  11009. }
  11010. return false;
  11011. } catch (error) {
  11012. throwError(error, 'compareVersion');
  11013. return false;
  11014. }
  11015. };
  11016. const updateChecker = async () => {
  11017. try {
  11018. const currentVersion = GM_info.script.version;
  11019. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  11020. const updateLinks = {
  11021. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  11022. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  11023. standby: 'https://auto-task-v4.hclonely.com/'
  11024. };
  11025. let version;
  11026. let updateLink = '';
  11027. let packageData;
  11028. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  11029. updateLink = updateLinks[updateSource];
  11030. packageData = await checkUpdate(updateLink, false);
  11031. } else {
  11032. updateLink = updateLinks.github;
  11033. packageData = await checkUpdate(updateLink, true);
  11034. if (!packageData) {
  11035. updateLink = updateLinks.jsdelivr;
  11036. packageData = await checkUpdate(updateLink, true);
  11037. if (!packageData) {
  11038. updateLink = updateLinks.standby;
  11039. packageData = await checkUpdate(updateLink, true);
  11040. }
  11041. }
  11042. }
  11043. if (packageData) {
  11044. version = packageData.version || currentVersion;
  11045. } else {
  11046. version = currentVersion;
  11047. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  11048. }
  11049. if (packageData && hasNewVersion(currentVersion, version)) {
  11050. var _packageData$change;
  11051. scripts_echoLog({
  11052. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  11053. });
  11054. scripts_echoLog({
  11055. 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>`
  11056. });
  11057. }
  11058. } catch (error) {
  11059. throwError(error, 'updateChecker');
  11060. }
  11061. };
  11062. const scripts_updateChecker = updateChecker;
  11063. var _globalOptions$other, _globalOptions$other2;
  11064. window.STYLE = GM_addStyle(auto_task.Z + GM_getResourceText('style'));
  11065. window.DEBUG = !!((_globalOptions$other = globalOptions.other) !== null && _globalOptions$other !== void 0 && _globalOptions$other.debug);
  11066. window.TRACE = !!((_globalOptions$other2 = globalOptions.other) !== null && _globalOptions$other2 !== void 0 && _globalOptions$other2.debug) && typeof console.trace === 'function';
  11067. const loadScript = async () => {
  11068. var _website, _website2, _website3, _website4, _website5, _website6;
  11069. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  11070. const authToken = external_Cookies_namespaceObject.get('auth-token');
  11071. const isLogin = !!external_Cookies_namespaceObject.get('login');
  11072. if (isLogin) {
  11073. var _commonOptions, _commonOptions$header;
  11074. GM_setValue('twitchAuth', {
  11075. authToken: authToken,
  11076. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  11077. });
  11078. window.close();
  11079. external_Swal_default().fire('', i18n('closePageNotice'));
  11080. } else {
  11081. external_Swal_default().fire('', i18n('needLogin'));
  11082. }
  11083. return;
  11084. }
  11085. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  11086. const ct0 = external_Cookies_namespaceObject.get('ct0');
  11087. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  11088. if (isLogin && ct0) {
  11089. GM_setValue('twitterAuth', {
  11090. ct0: ct0
  11091. });
  11092. window.close();
  11093. external_Swal_default().fire('', i18n('closePageNotice'));
  11094. } else {
  11095. external_Swal_default().fire('', i18n('needLogin'));
  11096. }
  11097. return;
  11098. }
  11099. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  11100. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  11101. if (PAPISID) {
  11102. GM_setValue('youtubeAuth', {
  11103. PAPISID: PAPISID
  11104. });
  11105. window.close();
  11106. external_Swal_default().fire('', i18n('closePageNotice'));
  11107. } else {
  11108. external_Swal_default().fire('', i18n('needLogin'));
  11109. }
  11110. return;
  11111. }
  11112. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  11113. const betaButton = $('#redesign-beta-optin-btn');
  11114. if (betaButton.length > 0) {
  11115. GM_setValue('redditAuth', '#auth');
  11116. return betaButton[0].click();
  11117. }
  11118. GM_setValue('redditAuth', null);
  11119. window.close();
  11120. external_Swal_default().fire('', i18n('closePageNotice'));
  11121. return;
  11122. }
  11123. let website;
  11124. for (const Website of Websites) {
  11125. if (Website.test()) {
  11126. website = new Website();
  11127. break;
  11128. }
  11129. }
  11130. if (!website) {
  11131. console.log('%c%s', 'color:#ff0000', 'Auto-Task[Warning]: 脚本停止加载,当前网站不支持!');
  11132. return;
  11133. }
  11134. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  11135. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  11136. }
  11137. $('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>`);
  11138. $('div.show-button-div').on('click', () => {
  11139. $('#auto-task-buttons').show();
  11140. $('div.show-button-div').hide();
  11141. });
  11142. const toggleLog = () => {
  11143. const $this = $('#toggle-log');
  11144. const status = $this.attr('data-status');
  11145. if (status === 'show') {
  11146. $('#auto-task-info').hide();
  11147. $this.attr('data-status', 'hide').text(i18n('showLog'));
  11148. } else {
  11149. $('#auto-task-info').show();
  11150. $this.attr('data-status', 'show').text(i18n('hideLog'));
  11151. }
  11152. };
  11153. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  11154. if (website.doTask) {
  11155. website.doTask();
  11156. }
  11157. });
  11158. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  11159. if (website.undoTask) {
  11160. website.doTask();
  11161. }
  11162. });
  11163. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  11164. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  11165. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  11166. }
  11167. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  11168. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  11169. for (const button of website.buttons) {
  11170. if (website[button]) {
  11171. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  11172. btnElement.find('a.auto-task-website-btn').on('click', () => {
  11173. website[button]();
  11174. });
  11175. $('#auto-task-buttons').append(btnElement);
  11176. }
  11177. }
  11178. }
  11179. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  11180. ${i18n('hideButton')}</a></p>`);
  11181. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  11182. $('#auto-task-buttons').hide();
  11183. $('div.show-button-div').show();
  11184. });
  11185. 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'}">
  11186. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  11187. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  11188. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  11189. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  11190. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  11191. options(website.name, website.options);
  11192. });
  11193. }
  11194. if (website.name !== 'Setting') {
  11195. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  11196. changeGlobalOptions('swal');
  11197. });
  11198. GM_registerMenuCommand(i18n('settingPage'), () => {
  11199. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  11200. });
  11201. }
  11202. console.log('%c%s', 'color:#1bbe1a', 'Auto-Task[Load]: 脚本加载完成');
  11203. if (!GM_getValue('notice')) {
  11204. var _echoLog$font;
  11205. external_Swal_default().fire({
  11206. title: i18n('swalNotice'),
  11207. icon: 'warning'
  11208. }).then(() => {
  11209. window.open(i18n('noticeLink'), '_blank');
  11210. GM_setValue('notice', new Date().getTime());
  11211. });
  11212. (_echoLog$font = scripts_echoLog({
  11213. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  11214. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  11215. GM_setValue('notice', new Date().getTime());
  11216. });
  11217. }
  11218. scripts_updateChecker();
  11219. };
  11220. if (window.location.hostname === 'discord.com') {
  11221. const LocalStorage = window.localStorage;
  11222. if (window.location.hash === '#auth') {
  11223. var _LocalStorage$getItem;
  11224. window.localStorage.removeItem = () => true;
  11225. 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, '');
  11226. if (discordAuth && discordAuth.length > 0) {
  11227. GM_setValue('discordAuth', {
  11228. auth: discordAuth
  11229. });
  11230. window.close();
  11231. external_Swal_default().fire('', i18n('closePageNotice'));
  11232. } else {
  11233. external_Swal_default().fire({
  11234. text: i18n('getDiscordAuthFailed'),
  11235. icon: 'error'
  11236. });
  11237. }
  11238. } else {
  11239. var _LocalStorage$getItem2;
  11240. 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, '');
  11241. if (discordAuth && discordAuth.length > 0) {
  11242. GM_setValue('discordAuth', {
  11243. auth: discordAuth
  11244. });
  11245. }
  11246. }
  11247. } else if (window.location.hostname === 'opquests.com') {
  11248. loadScript();
  11249. } else {
  11250. $(loadScript);
  11251. }
  11252. }();
  11253. })();