auto-task-v4

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

目前為 2022-01-08 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name auto-task-v4
  3. // @namespace auto-task-v4
  4. // @version 4.1.8-Beta
  5. // @description 自动完成 Freeanywhere,Giveawaysu,GiveeClub,Givekey,Gleam,Indiedb,keyhub,OpiumPulses,Opquests,SweepWidget 等网站的任务。
  6. // @description:en Automatically complete the tasks of FreeAnyWhere, GiveawaySu, GiveeClub, Givekey, Gleam, Indiedb, keyhub, OpiumPulses, Opquests, SweepWidget websites.
  7. // @author HCLonely
  8. // @license MIT
  9. // @run-at document-start
  10. // @homepage https://auto-task-doc.js.org/
  11. // @supportURL https://github.com/HCLonely/auto-task-v4/issues
  12.  
  13. // @include *://freeanywhere.net/*
  14. // @include *://giveaway.su/giveaway/view/*
  15. // @include *://givee.club/*/event/*
  16. // @include *://givekey.ru/giveaway/*
  17. // @include *://www.indiedb.com/giveaways*
  18. // @include *://key-hub.eu/giveaway/*
  19. // @include *://keylol.com/*
  20. // @include *://www.opiumpulses.com/giveaways
  21. // @include *://prys.revadike.com/giveaway/?id=*
  22. // @include *://opquests.com/quests/*
  23. // @include *://gleam.io/*
  24. // @include *://sweepwidget.com/view/*
  25. // @include *://discord.com/*
  26. // @include *://www.twitch.tv/*
  27. // @include *://www.youtube.com/*
  28. // @include *://*.reddit.com/*
  29. // @include *://twitter.com/settings/account?k*
  30. // @include https://auto-task-v4.hclonely.com/setting.html
  31. // @include https://auto-task-v4.hclonely.com/history.html
  32.  
  33. // @grant GM_setValue
  34. // @grant GM_getValue
  35. // @grant GM_listValues
  36. // @grant GM_deleteValue
  37. // @grant GM_addStyle
  38. // @grant GM_xmlhttpRequest
  39. // @grant GM_registerMenuCommand
  40. // @grant GM_info
  41. // @grant GM_openInTab
  42. // @grant GM_setClipboard
  43. // @grant unsafeWindow
  44. // @grant window.close
  45. // @grant window.localStorage
  46.  
  47. // @connect cdn.jsdelivr.net
  48. // @connect store.steampowered.com
  49. // @connect steamcommunity.com
  50. // @connect twitter.com
  51. // @connect api.twitter.com
  52. // @connect youtube.com
  53. // @connect www.youtube.com
  54. // @connect facebook.com
  55. // @connect instagram.com
  56. // @connect vk.com
  57. // @connect twitch.tv
  58. // @connect www.twitch.tv
  59. // @connect gql.twitch.tv
  60. // @connect github.com
  61. // @connect discordapp.com
  62. // @connect discord.gg
  63. // @connect discord.com
  64. // @connect www.reddit.com
  65. // @connect oauth.reddit.com
  66. // @connect raw.githubusercontent.com
  67. // @connect t.me
  68. // @connect bit.ly
  69. // @connect giveaway.su
  70. // @connect google.com
  71. // @connect www.vloot.io
  72. // @connect givee.club
  73. // @connect auto-task-v4.hclonely.com
  74. // @connect *
  75. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  76. // @require https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js
  77. // @require https://cdn.jsdelivr.net/npm/regenerator-runtime@0.13.5/runtime.min.js
  78. // @require https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js
  79. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11
  80. // @require https://cdn.jsdelivr.net/npm/keyboardjs@2.6.4/dist/keyboard.min.js
  81. // @require https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js
  82.  
  83. // @compatible Tampermonkey Only
  84. // @noframes
  85. // ==/UserScript==
  86.  
  87. console.log('%c%s', 'color:blue', 'Auto Task脚本开始加载');
  88.  
  89. (function() {
  90. var __webpack_modules__ = {
  91. 514: function(__unused_webpack_module, exports) {
  92. !function(e, n) {
  93. true ? n(exports) : 0;
  94. }(this, function(e) {
  95. 'use strict';
  96. var t = function() {
  97. return (t = Object.assign || function(e) {
  98. for (var n, o = 1, t = arguments.length; o < t; o++) {
  99. for (var r in n = arguments[o]) {
  100. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  101. }
  102. }
  103. return e;
  104. }).apply(this, arguments);
  105. };
  106. function r(e, n, o) {
  107. if (o || 2 === arguments.length) {
  108. for (var t, r = 0, i = n.length; r < i; r++) {
  109. !t && r in n || ((t = t || Array.prototype.slice.call(n, 0, r))[r] = n[r]);
  110. }
  111. }
  112. return e.concat(t || Array.prototype.slice.call(n));
  113. }
  114. function d(e) {
  115. return '[object Object]' === n(e);
  116. }
  117. function l(e, n) {
  118. var o = r(r([], n || [], !0), [ '_' ], !1).join('|');
  119. return e.replace(new RegExp('(('.concat(o, ')[a-z])+'), 'g'), function(e, n) {
  120. return n.replace(new RegExp(o), '').toLocaleUpperCase();
  121. });
  122. }
  123. var n = function(e) {
  124. return Object.prototype.toString.call(e);
  125. };
  126. var o = (i.prototype.init = function() {
  127. try {
  128. this.getSystemName(), this.getBrowserName();
  129. } catch (e) {
  130. console.warn('[UA formatter error] '.concat(e));
  131. }
  132. }, i.prototype.getEngine = function() {
  133. var e = this.agent;
  134. return -1 !== e.indexOf('Trident') ? 'Trident' : -1 !== e.indexOf('Firefox') ? 'Gecko' : -1 !== e.indexOf('Presto') ? 'Presto' : 'WebKit';
  135. }, i.prototype.getSystemName = function() {
  136. var e, n = (this.agent.match(/^[a-z]+\/\d+\.\d+\s?\(([a-z\d\s:;./_-]+)\)/i) || [])[1];
  137. try {
  138. var o = '';
  139. if (/Windows/i.test(n)) {
  140. var t = (n.match(/NT\s(\d+\.\d+)/) || [])[1];
  141. switch (this.info.os = 'Windows', t) {
  142. case '6.3':
  143. o = '8.1';
  144. break;
  145.  
  146. case '6.2':
  147. o = '8';
  148. break;
  149.  
  150. case '6.1':
  151. o = '7';
  152. break;
  153.  
  154. case '5.2':
  155. case '5.1':
  156. o = 'XP';
  157. break;
  158.  
  159. default:
  160. o = t;
  161. }
  162. return this.info.device = 'PC', void (this.info.osVersion = o);
  163. }
  164. if (/^Macintosh/i.test(n)) {
  165. return o = (n.match(/X\s((\d+(_|\.))+\d+)/) || [])[1], this.info.os = 'Macintosh',
  166. this.info.device = 'PC', void (this.info.osVersion = null !== (e = null == o ? void 0 : o.replace(/_/g, '.')) && void 0 !== e ? e : 'Unknown');
  167. }
  168. if (/^iPad/i.test(n)) {
  169. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPad', this.info.device = 'Tablet',
  170. void (this.info.osVersion = o.replace(/_/g, '.'));
  171. }
  172. if (/^iPhone/i.test(n)) {
  173. return o = (n.match(/((\d+_)+\d+)/) || [])[1], this.info.os = 'iPhone', this.info.device = 'Mobile',
  174. void (this.info.osVersion = o.replace(/_/g, '.'));
  175. }
  176. if (-1 !== n.indexOf('Android')) {
  177. var r = (n.match(/Android\s((\d+\.?)+\d?)/) || [])[1];
  178. return this.info.device = 'Mobile', this.info.os = 'Android', void (this.info.osVersion = r);
  179. }
  180. if (/Linux\s[a-z\d_]+/.test(n)) {
  181. return this.info.os = 'Linux', void (this.info.osVersion = 'Unknown');
  182. }
  183. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  184. } catch (e) {
  185. this.info.os = 'Unknown', this.info.osVersion = 'Unknown';
  186. }
  187. }, i.prototype.getBrowserName = function() {
  188. var e = Object.keys(this.browserNameMap).map(function(e) {
  189. return new RegExp(''.concat(e, '(\\/|\\s)(\\d+\\.)+\\d+'));
  190. }), n = 1 < (n = (this.agent.match(/[a-z\d]+(\/|\s)(\d+\.)+\d+/gi) || []).filter(function(n) {
  191. return -1 !== e.findIndex(function(e) {
  192. return e.test(n);
  193. });
  194. })).length && !/^Safari/.test(n[n.length - 1]) ? n.reverse() : n;
  195. this.info = t(t({}, this.info), this._formatBrowserVersion(n[0]));
  196. }, i.prototype._formatBrowserVersion = function(e) {
  197. var n, o, t, r;
  198. try {
  199. 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++) {
  200. var d = u[f], l = d[0], h = d[1];
  201. if (new RegExp(l).test(s)) {
  202. c = h;
  203. break;
  204. }
  205. }
  206. var p = {
  207. browserVersion: null != a ? a : 'Unknown',
  208. browser: null !== (t = c.en) && void 0 !== t ? t : 'Unknown',
  209. browserZH: null !== (r = (null == c ? void 0 : c.zh) || c.en) && void 0 !== r ? r : 'Unknown'
  210. };
  211. return 'Trident' === s && (p.browserVersion = {
  212. '4.0': 8,
  213. '5.0': 9,
  214. '6.0': 10,
  215. '7.0': 11
  216. }[a]), p;
  217. } catch (e) {
  218. return console.warn('[UA formatter error] '.concat(e)), {
  219. browser: 'Unknown',
  220. browserVersion: 'Unknown'
  221. };
  222. }
  223. }, i);
  224. function i(e) {
  225. this.agent = '', this.info = {
  226. browser: '',
  227. browserZH: '',
  228. browserVersion: '',
  229. os: '',
  230. osVersion: '',
  231. device: 'Unknown',
  232. engine: 'WebKit'
  233. }, this.browserNameMap = {
  234. MicroMessenger: {
  235. en: 'MicroMessenger',
  236. zh: '微信'
  237. },
  238. MetaSr: {
  239. en: 'MetaSr',
  240. zh: '搜狗浏览器'
  241. },
  242. 'QQ(Browser)?': {
  243. en: 'QQBrowser',
  244. zh: 'QQ浏览器'
  245. },
  246. UCBrowser: {
  247. en: 'UCBrowser',
  248. zh: 'UC浏览器'
  249. },
  250. '2345Explorer': {
  251. en: '2345Explorer',
  252. zh: '2345极速浏览器'
  253. },
  254. Mb2345Browser: {
  255. en: 'Mb2345Browser',
  256. zh: '2345手机浏览器'
  257. },
  258. Trident: {
  259. en: 'Internet Explorer'
  260. },
  261. 'Edge?': {
  262. en: 'Edge'
  263. },
  264. OPR: {
  265. en: 'Opera'
  266. },
  267. Vivaldi: {
  268. en: 'Vivaldi'
  269. },
  270. Firefox: {
  271. en: 'Firefox'
  272. },
  273. Chrome: {
  274. en: 'Chrome'
  275. },
  276. Safari: {
  277. en: 'Safari'
  278. }
  279. }, this.agent = e, this.init();
  280. var n = this.info, o = n.browser, e = n.browserVersion, n = n.osVersion;
  281. this.info = t(t({}, this.info), {
  282. engine: this.getEngine(),
  283. browserVersion: 'Safari' === o ? n : e
  284. });
  285. }
  286. function s() {
  287. this.cookies = {}, this.init();
  288. }
  289. var a = new (s.prototype.init = function() {
  290. var o = {};
  291. document.cookie.split(/;\s/).forEach(function(e) {
  292. var n = e.split(/=/), e = n[0], n = n[1];
  293. o[e] = n;
  294. }), this.cookies = o;
  295. }, s.prototype.getItem = function(e) {
  296. return this.cookies[e];
  297. }, s.prototype.getAllItems = function() {
  298. return this.cookies;
  299. }, s.prototype.setItem = function(e, n, o, t, r, i) {
  300. document.cookie = ''.concat(e, '=').concat(n).concat(o ? '; expires='.concat(o) : '').concat(t ? '; path='.concat(t) : '').concat(r ? '; domain='.concat(r) : '').concat(i ? '; secure' : '');
  301. }, s)();
  302. e.countDown = function e(n, o, t, r) {
  303. if (!window) {
  304. throw new Error('window is not defind.');
  305. }
  306. if (0 < n) {
  307. return r && r(), n--, window[o] = window.setTimeout(function() {
  308. e(n, o, t, r);
  309. }, 1e3), function() {
  310. return clearTimeout(window[o]);
  311. };
  312. }
  313. clearTimeout(window[o]), t && t();
  314. }, e.createRandomID = function(e) {
  315. void 0 === e && (e = 12);
  316. for (var n = [], o = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), t = o.length, r = 0; r < e; r++) {
  317. n.push(o[Math.round(Math.random() * t)]);
  318. }
  319. return n.join('');
  320. }, e.dCookie = a, e.debounce = function(o, t, r) {
  321. var i;
  322. void 0 === t && (t = 0);
  323. var s = r = void 0 === r ? !1 : r;
  324. return function() {
  325. var e = this, n = arguments;
  326. s && (o.apply(this, arguments), s = !1), clearTimeout(i), i = setTimeout(function() {
  327. r ? s = !0 : o.apply(e, n);
  328. }, t);
  329. };
  330. }, e.deepCopy = function e(n) {
  331. if (d(n) || Array.isArray(n)) {
  332. var o, t = Array.isArray(n) ? [] : {};
  333. for (o in n) {
  334. t[o] = e(n[o]);
  335. }
  336. return t;
  337. }
  338. return n;
  339. }, e.formatQueryParams = function(e) {
  340. e = null === (e = /\?(?<params>(.*)=.+)/.exec(decodeURIComponent(e))) || void 0 === e ? void 0 : e.groups;
  341. if (!e) {
  342. return {};
  343. }
  344. for (var n = e.params.split('&'), t = {}, o = 0; o < n.length; o++) {
  345. n[o].replace(/([^?&]*)=([^?&]*)/, function(e, n, o) {
  346. return t[n] = o, e;
  347. });
  348. }
  349. return t;
  350. }, e.formatThousandth = function(e) {
  351. 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, '$&,');
  352. return ''.concat(e).concat(n ? '.'.concat(n) : '');
  353. }, e.generateTree = function e(n, o, t, r) {
  354. for (var i = [], s = 0; s < n.length; s++) {
  355. var a = n[s];
  356. a[t] === o && (i.push(a), a.children = e(n, a[null != r ? r : 'id'], t, r));
  357. }
  358. return i;
  359. }, e.isEmpty = function(e) {
  360. 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);
  361. }, e.isFunction = function(e) {
  362. return '[object Function]' === n(e);
  363. }, e.isImageUrl = function(e) {
  364. return /\.((png)|(jpe?g)|(gif)|(svg)|(webp))$/gi.test(e);
  365. }, e.isObject = d, e.isRegexp = function(e) {
  366. return '[object RegExp]' === n(e);
  367. }, e.objectKeyToCamelCase = function e(n, o, t) {
  368. if (Array.isArray(n)) {
  369. for (var r = [], i = 0; i < n.length; i++) {
  370. r[i] = e(o && n[i][o] ? n[i][o] : n[i], o, t);
  371. }
  372. } else if (d(n)) {
  373. r = {};
  374. for (var s = o && n[o] ? n[o] : n, a = 0, c = Object.entries(s); a < c.length; a++) {
  375. var f = (u = c[a])[0], u = u[1];
  376. Array.isArray(u) || d(s) ? r[l(f, t)] = e(u, o, t) : r[l(f, t)] = u;
  377. }
  378. } else {
  379. r = n;
  380. }
  381. return r;
  382. }, e.realType = n, e.searchParams = function(e, n) {
  383. return void 0 === e && (e = null === location || void 0 === location ? void 0 : location.search),
  384. new URLSearchParams(e).get(n);
  385. }, e.toLowerCamelCase = l, e.toUnderline = function(e) {
  386. return e.replace(/([A-Z])/g, function(e) {
  387. return '_'.concat(e.toLocaleLowerCase());
  388. });
  389. }, e.ua = function(e) {
  390. return void 0 === e && (e = navigator.userAgent), new o(e).info;
  391. }, Object.defineProperty(e, '__esModule', {
  392. value: !0
  393. });
  394. });
  395. },
  396. 786: function(module, __webpack_exports__, __webpack_require__) {
  397. 'use strict';
  398. __webpack_require__.d(__webpack_exports__, {
  399. Z: function() {
  400. return __WEBPACK_DEFAULT_EXPORT__;
  401. }
  402. });
  403. 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);
  404. 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__);
  405. 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);
  406. 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__);
  407. 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());
  408. ___CSS_LOADER_EXPORT___.push([ module.id, '.colorful-button,#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn,body.auto-task-options .auto-task-form table button{position:relative;padding:5px 10px;text-align:center;color:#fff;text-decoration:none;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:30px;background-size:400%;text-transform:capitalize}.colorful-button:hover,#auto-task-buttons a.auto-task-website-btn:hover,.show-button-div a.auto-task-website-btn:hover,body.auto-task-options .auto-task-form table button:hover{animation:animate 8s linear infinite;cursor:pointer}.colorful-button:hover::before,#auto-task-buttons a.auto-task-website-btn:hover::before,.show-button-div a.auto-task-website-btn:hover::before,body.auto-task-options .auto-task-form table button:hover::before{filter:blur(20px);opacity:1}.colorful-button::before,#auto-task-buttons a.auto-task-website-btn::before,.show-button-div a.auto-task-website-btn::before,body.auto-task-options .auto-task-form table button::before{content:"";position:absolute;top:-5px;left:-5px;right:-5px;bottom:-5px;z-index:-1;background:linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);border-radius:40px;background-size:400%;opacity:-1;transition:.5s}@keyframes animate{0%{background-position:0%}100%{background-position:100%}}#auto-task-info{position:fixed;bottom:10px;right:10px;width:60%;max-width:500px;max-height:60%;overflow-y:auto;color:#000;background-color:#fff;padding-left:5px;z-index:999999999 !important;border:solid 2px #add8e6;border-radius:10px}#auto-task-info li{text-align:left}#auto-task-info li a.high-light{color:#00aeff;font-weight:bold}#auto-task-info .success{color:green}#auto-task-info .error{color:red}#auto-task-info .warning{color:blue}#auto-task-info .info{color:#ff0}#auto-task-info .update-text{color:green;border:solid 2px #8dcb69;margin:5px 10px 5px 20px;border-radius:10px;padding:5px 20px}.auto-task-keylol{display:inline-block;text-transform:capitalize;margin-left:10px;text-decoration:none !important;border:solid 1px;border-radius:5px;padding:0 2px}.auto-task-keylol[selected=selected]{background-color:blue !important;color:#fff !important}.auto-task-form table{font-family:verdana,arial,sans-serif;font-size:11px;color:#333;border-width:1px;border-color:#999;border-collapse:collapse;width:100%}.auto-task-form table thead td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;font-weight:bold;background-color:#fff}.auto-task-form table tbody tr{background-color:#d4e3e5}.auto-task-form table tbody tr:hover{background-color:#ff6 !important}.auto-task-form table tbody tr th{background-color:#c3dde0;border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9;text-transform:capitalize}.auto-task-form table tbody tr td{border-width:1px;padding:8px;border-style:solid;border-color:#a9c6c9}.swal2-modal{width:70% !important;max-width:1000px !important}body.auto-task-options{padding-top:10px;text-align:center}body.auto-task-options .auto-task-form{width:80%;max-width:1000px;margin:0 auto;padding-bottom:20px}body.auto-task-options .auto-task-form table input.editOption{width:80%}body.auto-task-options .auto-task-form table #getTwitterUserId,body.auto-task-options .auto-task-form table #getYoutubeChannelId{margin-top:5px}body.auto-task-options .auto-task-form table button{z-index:1}body.auto-task-options .auto-task-form table input[type=text]{outline-style:none;border:1px solid #ccc;border-radius:3px;padding:5px 10px;font-size:14px}body.auto-task-options .auto-task-form table input[type=text]:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}body.auto-task-options .auto-task-form table label{position:relative;width:160px;height:80px;cursor:pointer;transform:scale(0.25);margin:-25% 0;top:-30px;display:inline-block}body.auto-task-options .auto-task-form table label input{position:relative;z-index:1;-webkit-appearance:none;appearance:none}body.auto-task-options .auto-task-form table label input:checked~span{background:#05be05;box-shadow:0 15px 25px rgba(5,190,5,0.4)}body.auto-task-options .auto-task-form table label input:checked~span i{left:84px}body.auto-task-options .auto-task-form table label input:checked~span i::before{background:#05be05;box-shadow:35px 0 0 #05be05}body.auto-task-options .auto-task-form table label input:checked~span i::after{bottom:12px;height:15px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;background:#05be05}body.auto-task-options .auto-task-form table label span{position:absolute;top:0;left:0;width:100%;height:100%;background:#fe0000;border-radius:80px;transition:.5s;box-shadow:0 15px 25px rgba(254,0,0,0.4)}body.auto-task-options .auto-task-form table label span i{position:absolute;top:4px;left:4px;width:72px;height:72px;background:#fff;border-radius:50%}body.auto-task-options .auto-task-form table label span i::before{content:"";position:absolute;top:22px;left:12px;width:12px;height:12px;border-radius:50%;background:#fe0000;box-shadow:35px 0 0 #fe0000;transition:.5s}body.auto-task-options .auto-task-form table label span i::after{content:"";position:absolute;bottom:15px;left:calc(50% - 15px);width:30px;height:6px;border-radius:6px;background:#fe0000;transition:.5s}body.auto-task-history{font-size:15px;font-weight:400;line-height:1.5}body.auto-task-history .container a{color:#007bff;text-decoration:none;background-color:transparent}body.auto-task-history .container .card{width:80%;max-width:800px;border-radius:10px;background:rgba(118,118,118,0.10196);border-top:1px solid rgba(255,255,255,0.50196);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);box-shadow:0 15px 25px rgba(0,0,0,0.10196);margin:20px auto;position:relative;display:flex;flex-direction:column;word-wrap:break-word;-webkit-background-clip:border-box;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}body.auto-task-history .container .card .title{text-align:center;font-size:30px;font-weight:bold;margin:5px 0}body.auto-task-history .container .card .title a:hover{text-decoration:none;background:#93e1ff;border-radius:10px;padding:3px}body.auto-task-history .container .card ul{margin-bottom:25px}body.auto-task-history .container .card ul li{margin-bottom:5px;line-height:20px}body.auto-task-history .container .card ul a:hover{text-decoration:underline}body.auto-task-history .container .card .delete-task{right:10px;width:38px;height:35px;position:absolute;font-size:24px;cursor:pointer;border-radius:10px}body.auto-task-history .container .card .delete-task:hover{background:#fff}body.auto-task-history .container .card .time{right:5px;position:absolute;bottom:0;color:#e83e8c;font-family:\'SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace\';font-size:15px}#auto-task-buttons,.show-button-div{position:fixed;top:30px;right:15px;width:170px;z-index:999999999 !important;transform:scale(0.9)}#auto-task-buttons p,.show-button-div p{line-height:30px;height:40px;text-align:center;margin:5px !important}#auto-task-buttons a.auto-task-website-btn,.show-button-div a.auto-task-website-btn{width:150px;height:40px;line-height:30px;font-size:20px}.show-button-div{width:20px}.auto-task-capitalize{text-transform:capitalize !important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{box-shadow:inset 0px 0px 4px 1px rgba(100,150,200,.5) !important}.swal2-checkbox-custom{align-items:center;justify-content:center;background:#fff;color:inherit;margin:1em auto}.swal2-checkbox-custom input{flex-shrink:0;margin:0 .4em}.giveaway-actions #getKey{display:none !important}', '' ]);
  409. const __WEBPACK_DEFAULT_EXPORT__ = ___CSS_LOADER_EXPORT___.toString();
  410. },
  411. 400: function(module) {
  412. 'use strict';
  413. module.exports = function(cssWithMappingToString) {
  414. var list = [];
  415. list.toString = function toString() {
  416. return this.map(function(item) {
  417. var content = '';
  418. var needLayer = typeof item[5] !== 'undefined';
  419. if (item[4]) {
  420. content += '@supports ('.concat(item[4], ') {');
  421. }
  422. if (item[2]) {
  423. content += '@media '.concat(item[2], ' {');
  424. }
  425. if (needLayer) {
  426. content += '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {');
  427. }
  428. content += cssWithMappingToString(item);
  429. if (needLayer) {
  430. content += '}';
  431. }
  432. if (item[2]) {
  433. content += '}';
  434. }
  435. if (item[4]) {
  436. content += '}';
  437. }
  438. return content;
  439. }).join('');
  440. };
  441. list.i = function i(modules, media, dedupe, supports, layer) {
  442. if (typeof modules === 'string') {
  443. modules = [ [ null, modules, undefined ] ];
  444. }
  445. var alreadyImportedModules = {};
  446. if (dedupe) {
  447. for (var k = 0; k < this.length; k++) {
  448. var id = this[k][0];
  449. if (id != null) {
  450. alreadyImportedModules[id] = true;
  451. }
  452. }
  453. }
  454. for (var _k = 0; _k < modules.length; _k++) {
  455. var item = [].concat(modules[_k]);
  456. if (dedupe && alreadyImportedModules[item[0]]) {
  457. continue;
  458. }
  459. if (typeof layer !== 'undefined') {
  460. if (typeof item[5] === 'undefined') {
  461. item[5] = layer;
  462. } else {
  463. item[1] = '@layer'.concat(item[5].length > 0 ? ' '.concat(item[5]) : '', ' {').concat(item[1], '}');
  464. item[5] = layer;
  465. }
  466. }
  467. if (media) {
  468. if (!item[2]) {
  469. item[2] = media;
  470. } else {
  471. item[1] = '@media '.concat(item[2], ' {').concat(item[1], '}');
  472. item[2] = media;
  473. }
  474. }
  475. if (supports) {
  476. if (!item[4]) {
  477. item[4] = ''.concat(supports);
  478. } else {
  479. item[1] = '@supports ('.concat(item[4], ') {').concat(item[1], '}');
  480. item[4] = supports;
  481. }
  482. }
  483. list.push(item);
  484. }
  485. };
  486. return list;
  487. };
  488. },
  489. 220: function(module) {
  490. 'use strict';
  491. module.exports = function(i) {
  492. return i[1];
  493. };
  494. }
  495. };
  496. var __webpack_module_cache__ = {};
  497. function __webpack_require__(moduleId) {
  498. var cachedModule = __webpack_module_cache__[moduleId];
  499. if (cachedModule !== undefined) {
  500. return cachedModule.exports;
  501. }
  502. var module = __webpack_module_cache__[moduleId] = {
  503. id: moduleId,
  504. exports: {}
  505. };
  506. __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  507. return module.exports;
  508. }
  509. !function() {
  510. __webpack_require__.n = function(module) {
  511. var getter = module && module.__esModule ? function() {
  512. return module['default'];
  513. } : function() {
  514. return module;
  515. };
  516. __webpack_require__.d(getter, {
  517. a: getter
  518. });
  519. return getter;
  520. };
  521. }();
  522. !function() {
  523. __webpack_require__.d = function(exports, definition) {
  524. for (var key in definition) {
  525. if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  526. Object.defineProperty(exports, key, {
  527. enumerable: true,
  528. get: definition[key]
  529. });
  530. }
  531. }
  532. };
  533. }();
  534. !function() {
  535. __webpack_require__.o = function(obj, prop) {
  536. return Object.prototype.hasOwnProperty.call(obj, prop);
  537. };
  538. }();
  539. var __webpack_exports__ = {};
  540. !function() {
  541. 'use strict';
  542. const external_Swal_namespaceObject = Swal;
  543. var external_Swal_default = __webpack_require__.n(external_Swal_namespaceObject);
  544. const external_Cookies_namespaceObject = Cookies;
  545. var auto_task = __webpack_require__(786);
  546. var javascript_utils_umd_min = __webpack_require__(514);
  547. const httpRequest = async function(options) {
  548. let times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  549. try {
  550. const result = await new Promise(resolve => {
  551. if (options.dataType) {
  552. options.responseType = options.dataType;
  553. }
  554. const requestObj = {
  555. ...{
  556. timeout: 3e4,
  557. ontimeout(data) {
  558. resolve({
  559. result: 'Error',
  560. statusText: 'Timeout',
  561. status: 601,
  562. data: data,
  563. options: options
  564. });
  565. },
  566. onabort(data) {
  567. resolve({
  568. result: 'Error',
  569. statusText: 'Aborted',
  570. status: 602,
  571. data: data,
  572. options: options
  573. });
  574. },
  575. onerror(data) {
  576. resolve({
  577. result: 'Error',
  578. statusText: 'Error',
  579. status: 603,
  580. data: data,
  581. options: options
  582. });
  583. },
  584. onload(data) {
  585. resolve({
  586. result: 'Success',
  587. statusText: 'Load',
  588. status: 600,
  589. data: data,
  590. options: options
  591. });
  592. }
  593. },
  594. ...options
  595. };
  596. GM_xmlhttpRequest(requestObj);
  597. });
  598. console.log('发送请求:', result);
  599. if (result.status !== 600 && times < 2) {
  600. return await httpRequest(options, times + 1);
  601. }
  602. return result;
  603. } catch (error) {
  604. throwError(error, 'httpRequest');
  605. console.log('发送请求:', {
  606. errorMsg: error,
  607. options: options
  608. });
  609. return {
  610. result: 'JsError',
  611. statusText: 'Error',
  612. status: 604,
  613. error: error,
  614. options: options
  615. };
  616. }
  617. };
  618. const tools_httpRequest = httpRequest;
  619. const echoLog = _ref => {
  620. let {
  621. type,
  622. text,
  623. html,
  624. id
  625. } = _ref;
  626. const emptyStatus = {
  627. success: () => emptyStatus,
  628. error: () => emptyStatus,
  629. warning: () => emptyStatus,
  630. info: () => emptyStatus,
  631. view: () => emptyStatus
  632. };
  633. try {
  634. var _ele$;
  635. let ele;
  636. if (type) {
  637. switch (type) {
  638. case 'joiningSteamGroup':
  639. case 'leavingSteamGroup':
  640. case 'gettingSteamGroupId':
  641. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/groups/${text}" target="_blank">${text}</a>...<font></font></li>`);
  642. break;
  643.  
  644. case 'subscribingForum':
  645. case 'unsubscribingForum':
  646. case 'gettingForumId':
  647. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/app/${text}/discussions/" target="_blank">${text}</a>...<font></font></li>`);
  648. break;
  649.  
  650. case 'followingCurator':
  651. case 'unfollowingCurator':
  652. case 'getCuratorId':
  653. 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>`);
  654. break;
  655.  
  656. case 'addingToWishlist':
  657. case 'removingFromWishlist':
  658. case 'followingGame':
  659. case 'unfollowingGame':
  660. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/app/${text}" target="_blank">${text}</a>...<font></font></li>`);
  661. break;
  662.  
  663. case 'favoritingWorkshop':
  664. case 'unfavoritingWorkshop':
  665. case 'gettingWorkshopAppId':
  666. case 'votingUpWorkshop':
  667. ele = $(`<li>${i18n(type)}<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=${text}" target="_blank">
  668. ${text}</a>...<font></font></li>`);
  669. break;
  670.  
  671. case 'gettingAnnouncementParams':
  672. case 'likingAnnouncement':
  673. ele = $(`<li>${i18n(type)}<a href="https://store.steampowered.com/news/app/${text}/view/${id}" target="_blank">
  674. ${id}</a>...<font></font></li>`);
  675. break;
  676.  
  677. case 'joiningDiscordServer':
  678. case 'gettingDiscordGuild':
  679. ele = $(`<li>${i18n(type)}<a href="https://discord.com/invite/${text}" target="_blank">${text}</a>...<font></font></li>`);
  680. break;
  681.  
  682. case 'leavingDiscordServer':
  683. ele = $(`<li>${i18n(type)}<a href="https://discord.com/channels/@me/${text}" target="_blank">${text}</a>...<font></font></li>`);
  684. break;
  685.  
  686. case 'updateDiscordAuth':
  687. ele = $(`<li style="color:red;">${i18n('updateDiscordAuth')}</li>`);
  688. break;
  689.  
  690. case 'followingTwitchChannel':
  691. case 'unfollowingTwitchChannel':
  692. case 'gettingTwitchChannelId':
  693. ele = $(`<li>${i18n(type)}<a href="https://www.twitch.tv/${text}" target="_blank">${text}</a>...<font></font></li>`);
  694. break;
  695.  
  696. case 'gettingInsUserId':
  697. case 'followingIns':
  698. case 'unfollowingIns':
  699. ele = $(`<li>${i18n(type)}<a href="https://www.instagram.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  700. break;
  701.  
  702. case 'gettingTwitterUserId':
  703. case 'followingTwitterUser':
  704. case 'unfollowingTwitterUser':
  705. ele = $(`<li>${i18n(type)}<a href="https://twitter.com/${text}" target="_blank">${text}</a>...<font></font></li>`);
  706. break;
  707.  
  708. case 'retweetting':
  709. case 'unretweetting':
  710. ele = $(`<li>${i18n(type)}${text}...<font></font></li>`);
  711. break;
  712.  
  713. case 'joiningReddit':
  714. case 'leavingReddit':
  715. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/r/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  716. break;
  717.  
  718. case 'followingRedditUser':
  719. case 'unfollowingRedditUser':
  720. ele = $(`<li>${i18n(type)}<a href="https://www.reddit.com/user/${text === null || text === void 0 ? void 0 : text.replace('u_', '')}" target="_blank">
  721. ${text === null || text === void 0 ? void 0 : text.replace('u_', '')}</a>...<font></font></li>`);
  722. break;
  723.  
  724. case 'followingYtbChannel':
  725. case 'unfollowingYtbChannel':
  726. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/channel/${text}" target="_blank">${text}</a>...<font></font></li>`);
  727. break;
  728.  
  729. case 'likingYtbVideo':
  730. case 'unlikingYtbVideo':
  731. ele = $(`<li>${i18n(type)}<a href="https://www.youtube.com/watch?v=${text}" target="_blank">${text}</a>...<font></font></li>`);
  732. break;
  733.  
  734. case 'gettingVkId':
  735. case 'joiningVkGroup':
  736. case 'leavingVkGroup':
  737. case 'joiningVkPublic':
  738. case 'leavingVkPublic':
  739. case 'sendingVkWall':
  740. case 'deletingVkWall':
  741. ele = $(`<li>${i18n(type)}<a href="https://vk.com/${text}/" target="_blank">${text}</a>...<font></font></li>`);
  742. break;
  743.  
  744. case 'visitingLink':
  745. ele = $(`<li>${i18n('visitingLink')}<a href="${text}" target="_blank">${text}</a>...<font></font></li>`);
  746. break;
  747.  
  748. case 'verifyingInsAuth':
  749. case 'text':
  750. ele = $(`<li>${i18n(text)}<font></font></li>`);
  751. break;
  752.  
  753. case 'html':
  754. ele = $(text || html);
  755. break;
  756.  
  757. case 'whiteList':
  758. ele = $(`<li><font class="warning">${i18n('skipTask')}[${text}(${id})](${i18n('whiteList')})</font></li>`);
  759. break;
  760.  
  761. case 'globalOptionsSkip':
  762. ele = $(`<li>${i18n('skipTaskOption')}<font class="warning">${text}</font></li>`);
  763. break;
  764.  
  765. default:
  766. ele = $(`<li>${i18n('unKnown')}:${type}(${text})...<font></font></li>`);
  767. break;
  768. }
  769. } else if (text) {
  770. ele = $(`<li>${i18n(text)}<font></font></li>`);
  771. } else if (html) {
  772. ele = $(html);
  773. } else {
  774. ele = $('<li><font></font></li>');
  775. }
  776. ele.addClass('card-text');
  777. $('#auto-task-info').append(ele);
  778. (_ele$ = ele[0]) === null || _ele$ === void 0 ? void 0 : _ele$.scrollIntoView();
  779. const font = ele.find('font');
  780. const status = {
  781. font: font,
  782. success() {
  783. var _this$font, _this$font2, _this$font3;
  784. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Success';
  785. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  786. (_this$font = this.font) === null || _this$font === void 0 ? void 0 : _this$font.attr('class', '').addClass('success');
  787. 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);
  788. return this;
  789. },
  790. error() {
  791. var _this$font4, _this$font5, _this$font6;
  792. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error';
  793. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  794. (_this$font4 = this.font) === null || _this$font4 === void 0 ? void 0 : _this$font4.attr('class', '').addClass('error');
  795. 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);
  796. return this;
  797. },
  798. warning() {
  799. var _this$font7, _this$font8, _this$font9;
  800. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Warning';
  801. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  802. (_this$font7 = this.font) === null || _this$font7 === void 0 ? void 0 : _this$font7.attr('class', '').addClass('warning');
  803. 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);
  804. return this;
  805. },
  806. info() {
  807. var _this$font10, _this$font11, _this$font12;
  808. let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Info';
  809. let html = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  810. (_this$font10 = this.font) === null || _this$font10 === void 0 ? void 0 : _this$font10.attr('class', '').addClass('info');
  811. 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);
  812. return this;
  813. },
  814. view() {
  815. var _this$font13;
  816. (_this$font13 = this.font) === null || _this$font13 === void 0 ? void 0 : _this$font13[0].scrollIntoView();
  817. return this;
  818. }
  819. };
  820. return status;
  821. } catch (error) {
  822. throwError(error, 'echoLog');
  823. return emptyStatus;
  824. }
  825. };
  826. const scripts_echoLog = echoLog;
  827. const unique = array => {
  828. try {
  829. return [ ...new Set(array) ];
  830. } catch (error) {
  831. throwError(error, 'unique');
  832. return [];
  833. }
  834. };
  835. const delay = function() {
  836. let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e3;
  837. return new Promise(resolve => {
  838. setTimeout(() => {
  839. resolve(true);
  840. }, time);
  841. });
  842. };
  843. const getRedirectLink = async link => {
  844. try {
  845. if (!link) {
  846. return null;
  847. }
  848. const redirectLinksCache = GM_getValue('redirectLinks') || {};
  849. if (redirectLinksCache[link]) {
  850. redirectLinksCache[link];
  851. }
  852. return await tools_httpRequest({
  853. url: link,
  854. method: 'GET'
  855. }).then(_ref => {
  856. let {
  857. data
  858. } = _ref;
  859. if (data !== null && data !== void 0 && data.finalUrl) {
  860. redirectLinksCache[link] = data.finalUrl;
  861. GM_setValue('redirectLinks', redirectLinksCache);
  862. return data.finalUrl;
  863. }
  864. return null;
  865. });
  866. } catch (error) {
  867. throwError(error, 'getRedirectLink');
  868. return null;
  869. }
  870. };
  871. const visitLink = async (link, options) => {
  872. try {
  873. const logStatus = scripts_echoLog({
  874. type: 'visitLink',
  875. text: link
  876. });
  877. return await tools_httpRequest({
  878. url: link,
  879. method: 'GET',
  880. ...options
  881. }).then(_ref2 => {
  882. let {
  883. result,
  884. statusText,
  885. status
  886. } = _ref2;
  887. if (result === 'Success') {
  888. logStatus.success();
  889. return true;
  890. }
  891. logStatus.error(`${result}:${statusText}(${status})`);
  892. return false;
  893. });
  894. } catch (error) {
  895. throwError(error, 'visitLink');
  896. return false;
  897. }
  898. };
  899. const getUrlQuery = url => {
  900. try {
  901. const query = {};
  902. if (url) {
  903. if (url.includes('?')) {
  904. url.split('?')[1].replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  905. query[key] = value;
  906. return str;
  907. });
  908. }
  909. } else {
  910. window.location.search.replace(/([^?&=]+)=([^&]+)/g, (str, key, value) => {
  911. query[key] = value;
  912. return str;
  913. });
  914. }
  915. return query;
  916. } catch (error) {
  917. throwError(error, 'getUrlQuery');
  918. return {};
  919. }
  920. };
  921. const getUuid = () => {
  922. const uuidUrl = URL.createObjectURL(new Blob()).toString();
  923. return uuidUrl.slice(uuidUrl.lastIndexOf('/') + 1);
  924. };
  925. const stringToColour = str => {
  926. try {
  927. let hash = 0;
  928. for (let i = 0; i < str.length; i++) {
  929. hash = str.charCodeAt(i) + ((hash << 5) - hash);
  930. }
  931. let colour = '#';
  932. for (let i = 0; i < 3; i++) {
  933. const value = hash >> i * 8 & 255;
  934. colour += `00${value.toString(16)}`.slice(-2);
  935. }
  936. return colour;
  937. } catch (error) {
  938. throwError(error, 'stringToColour');
  939. return '#fff';
  940. }
  941. };
  942. const defaultGlobalOptions = {
  943. doTask: {
  944. discord: {
  945. servers: true
  946. },
  947. instagram: {
  948. users: true
  949. },
  950. twitch: {
  951. channels: true
  952. },
  953. twitter: {
  954. users: true,
  955. retweets: true
  956. },
  957. vk: {
  958. names: true
  959. },
  960. youtube: {
  961. channels: true,
  962. likes: true
  963. },
  964. reddit: {
  965. reddits: true
  966. },
  967. steam: {
  968. groups: true,
  969. wishlists: true,
  970. follows: true,
  971. forums: true,
  972. workshops: true,
  973. curators: true,
  974. workshopVotes: true,
  975. announcements: true
  976. }
  977. },
  978. undoTask: {
  979. discord: {
  980. servers: true
  981. },
  982. instagram: {
  983. users: true
  984. },
  985. twitch: {
  986. channels: true
  987. },
  988. twitter: {
  989. users: true,
  990. retweets: true
  991. },
  992. vk: {
  993. names: true
  994. },
  995. youtube: {
  996. channels: true,
  997. likes: true
  998. },
  999. reddit: {
  1000. reddits: true
  1001. },
  1002. steam: {
  1003. groups: true,
  1004. wishlists: true,
  1005. follows: true,
  1006. forums: true,
  1007. workshops: true,
  1008. curators: true
  1009. }
  1010. },
  1011. position: {
  1012. buttonSideX: 'right',
  1013. buttonSideY: 'top',
  1014. buttonDistance: '15,30',
  1015. showButtonSideX: 'right',
  1016. showButtonSideY: 'top',
  1017. showButtonDistance: '15,30',
  1018. logSideX: 'right',
  1019. logSideY: 'bottom',
  1020. logDistance: '10,10'
  1021. },
  1022. hotKey: {
  1023. doTaskKey: 'alt + d',
  1024. undoTaskKey: 'alt + u',
  1025. toggleLogKey: 'alt + l'
  1026. },
  1027. other: {
  1028. twitterVerifyId: '783214',
  1029. youtubeVerifyChannel: 'UCrXUsMBcfTVqwAS7DKg9C0Q',
  1030. autoUpdateSource: 'jsdelivr',
  1031. language: 'zh',
  1032. checkLogin: true,
  1033. checkLeftKey: true,
  1034. defaultShowButton: true,
  1035. defaultShowLog: true
  1036. }
  1037. };
  1038. const userDefinedGlobalOptions = GM_getValue('globalOptions') || {};
  1039. const assignObject = (obj1, obj2) => {
  1040. try {
  1041. const newObj = {};
  1042. for (const [ key, value ] of Object.entries(obj1)) {
  1043. if (Object.prototype.toString.call(value) === '[object Object]' && Object.prototype.toString.call(obj2[key]) === '[object Object]') {
  1044. newObj[key] = assignObject(value, obj2[key]);
  1045. } else {
  1046. newObj[key] = obj2[key] ?? value;
  1047. }
  1048. }
  1049. return newObj;
  1050. } catch (error) {
  1051. throwError(error, 'assignObject');
  1052. return defaultGlobalOptions;
  1053. }
  1054. };
  1055. const globalOptions = assignObject(defaultGlobalOptions, userDefinedGlobalOptions);
  1056. const saveData = () => {
  1057. try {
  1058. const data = {};
  1059. $('#globalOptionsForm').serializeArray().map(value => {
  1060. data[value.name] = value.value;
  1061. return value;
  1062. });
  1063. $.makeArray($('#globalOptionsForm input')).map(element => {
  1064. const name = $(element).attr('name');
  1065. const keys = name.split('.');
  1066. if (keys.length === 3) {
  1067. globalOptions[keys[0]][keys[1]][keys[2]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1068. } else if (keys.length === 2) {
  1069. globalOptions[keys[0]][keys[1]] = data[name] ? data[name] === 'on' ? true : data[name] : false;
  1070. }
  1071. return element;
  1072. });
  1073. GM_setValue('globalOptions', globalOptions);
  1074. external_Swal_default().fire({
  1075. title: i18n('changeGlobalOptionsSuccess'),
  1076. icon: 'success'
  1077. });
  1078. } catch (error) {
  1079. throwError(error, 'saveData');
  1080. }
  1081. };
  1082. const changeGlobalOptions = showType => {
  1083. try {
  1084. let globalOptionsForm = `<form id="globalOptionsForm" class="auto-task-form">
  1085. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  1086. for (const [ type, data1 ] of Object.entries(globalOptions)) {
  1087. for (const [ option, data2 ] of Object.entries(data1)) {
  1088. if ([ 'other', 'position', 'hotKey' ].includes(type)) {
  1089. if (typeof data2 === 'boolean') {
  1090. 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>`;
  1091. } else {
  1092. 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>`;
  1093. }
  1094. } else {
  1095. for (const [ socialType, data3 ] of Object.entries(data2)) {
  1096. 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>`;
  1097. }
  1098. }
  1099. }
  1100. }
  1101. globalOptionsForm += '</tbody></table></form>';
  1102. if (showType === 'swal') {
  1103. external_Swal_default().fire({
  1104. title: i18n('globalOptions'),
  1105. html: globalOptionsForm,
  1106. showConfirmButton: true,
  1107. confirmButtonText: i18n('save'),
  1108. showCancelButton: true,
  1109. cancelButtonText: i18n('close')
  1110. }).then(_ref => {
  1111. let {
  1112. isConfirmed
  1113. } = _ref;
  1114. if (isConfirmed) {
  1115. saveData();
  1116. }
  1117. });
  1118. } else {
  1119. $('body').append(`<h2>${i18n('globalOptions')}</h2>${globalOptionsForm}`);
  1120. }
  1121. } catch (error) {
  1122. throwError(error, 'changeGlobalOptions');
  1123. }
  1124. };
  1125. const data = {
  1126. website: '网站',
  1127. type: '类型',
  1128. edit: '编辑',
  1129. whiteList: '白名单',
  1130. skipTask: '跳过撤销任务',
  1131. whiteListOptions: '白名单设置',
  1132. changeWhiteListOption: '设置白名单(%0)',
  1133. whiteListNotFound: '找不到此项白名单: %0',
  1134. changeWhiteListSuccess: '白名单修改成功,刷新生效!',
  1135. changeWebsiteOptions: '网站设置',
  1136. changeGlobalOptions: '全局设置',
  1137. ok: '是',
  1138. save: '保存',
  1139. close: '关闭',
  1140. return: '返回',
  1141. option: '选项',
  1142. value: '值',
  1143. websiteOptions: '当前网站设置',
  1144. changeWebsiteOptionsSuccess: '更改当前网站设置成功,刷新生效!',
  1145. changeGlobalOptionsSuccess: '更改全局设置成功,刷新生效!',
  1146. needLogin: '请先登录!',
  1147. getTasksInfo: '正在获取并处理任务信息...',
  1148. gettingKey: '正在获取Key...',
  1149. verifyingTask: '正在验证任务',
  1150. notice: '自动任务脚本提醒',
  1151. noKeysLeft: '此页面已经没有剩余key了,是否关闭?',
  1152. giveawayEnded: '此活动已结束,是否关闭?',
  1153. giveawayNotWork: '此活动因某些原因(已结束/暂停/未开始...)不可用(如果是脚本误判请及时反馈),是否关闭?',
  1154. confirm: '确定',
  1155. cancel: '取消',
  1156. unKnown: '未知',
  1157. unKnownTaskType: '未识别的任务',
  1158. doing: '正在做任务',
  1159. allTasksComplete: '所有任务已完成!',
  1160. getTaskIdFailed: '获取任务Id失败!',
  1161. initSuccess: '%0 初始化成功!',
  1162. initFailed: '%0 初始化失败!',
  1163. errorLink: '链接错误: %0',
  1164. needInit: '请先初始化',
  1165. verifyingAuth: '正在验证%0凭证...',
  1166. updatingAuth: '正在更新%0凭证...',
  1167. initing: '正在初始化...',
  1168. getFailed: '获取%0失败!',
  1169. checkLoginFailed: '检测登录状态失败!',
  1170. checkLeftKeyFailed: '检测剩余Key失败!',
  1171. userId: '用户Id',
  1172. joiningGiveaway: '正在加入赠Key',
  1173. needJoinGiveaway: '需要先加入赠Key',
  1174. cannotUndo: '此网站不支持取消任务',
  1175. verifyAuth: '正在验证 %0 凭证...',
  1176. closePageNotice: '如果此页面没有自动关闭,请自行关闭本页面。',
  1177. errorReport: '检测到脚本报错,是否前往反馈BUG?',
  1178. visitingLink: '正在访问链接: ',
  1179. doTask: '做任务',
  1180. undoTask: '撤销任务',
  1181. verifyTask: '验证任务',
  1182. getKey: '获取Key',
  1183. selectAll: '全选',
  1184. selectNone: '全不选',
  1185. invertSelect: '反选',
  1186. doFreeTask: '加入免费赠品',
  1187. doPointTask: '加入点数赠品',
  1188. skipTaskOption: '设置中已配置跳过任务',
  1189. other: '其他',
  1190. globalOptions: '全局设置',
  1191. checkLogin: '登录检测</br>需要登录的网站自动登录,部分本网站支持',
  1192. checkLeftKey: '剩余Key检测</br>赠Key活动结束提示是否关闭,部分本网站支持',
  1193. twitterVerifyId: '通过尝试关注该账号验证Twitter凭证</br>默认为Twitter官方帐号 783214</br>不想关注官方账号可以改为自己的帐号',
  1194. youtubeVerifyChannel: '通过尝试订阅该频道验证YouTube凭证</br>默认为YouTube官方频道 UCrXUsMBcfTVqwAS7DKg9C0Q</br>不想关注官方频道可以改为自己的频道',
  1195. autoUpdateSource: '更新源</br>github: 需代理,实时更新</br>jsdelivr: 可不用代理,更新有延迟</br>standby: 备用</br>auto: 依次使用github, jsdelivr, standby源进行尝试更新',
  1196. saveGlobalOptions: '保存全局设置',
  1197. settingPage: '设置页面',
  1198. name: '名称',
  1199. version: '版本',
  1200. scriptManager: '脚本管理器',
  1201. script: '脚本',
  1202. environment: '环境',
  1203. os: '系统',
  1204. browser: '浏览器',
  1205. getId: '获取 %0 id',
  1206. getTwitterUserId: '获取Twitter用户id(获取id功能仅在设置页面可用)',
  1207. getYoutubeChannelId: '获取Youtube频道id(获取id功能仅在设置页面可用)',
  1208. showButton: '显示按钮',
  1209. hideButton: '隐藏按钮',
  1210. showLog: '显示日志',
  1211. hideLog: '隐藏日志',
  1212. defaultShowButton: '默认显示按钮',
  1213. defaultShowLog: '默认显示日志',
  1214. position: '组件位置',
  1215. buttonSideX: '按钮区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1216. buttonSideY: '按钮区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1217. buttonDistance: '按钮区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1218. showButtonSideX: '显示按钮水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1219. showButtonSideY: '显示按钮垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1220. showButtonDistance: '显示按钮距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1221. logSideX: '日志区域水平方向定位(实时预览功能仅在设置页面可用)</br>left: 靠左 | right: 靠右',
  1222. logSideY: '日志区域垂直方向定位(实时预览功能仅在设置页面可用)</br>top: 靠上 | bottom: 靠下',
  1223. logDistance: '日志区域距边缘的距离(实时预览功能仅在设置页面可用)</br>格式: X距离,Y距离',
  1224. hotKey: '快捷键',
  1225. doTaskKey: '做任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1226. undoTaskKey: '撤销任务快捷键</br>(实时预览功能仅在设置页面可用)',
  1227. toggleLogKey: '显示/隐藏日志快捷键</br>(实时预览功能仅在设置页面可用)',
  1228. tasksHistory: '任务历史',
  1229. clearHistory: '清空历史',
  1230. clearHistoryFinished: '已清空任务历史!',
  1231. deleteTask: '删除任务',
  1232. lastChangeTime: '最后一次修改时间',
  1233. clearTaskFinished: '删除以下任务完成!',
  1234. clearTaskFailed: '删除任务失败,没有找到任务名!',
  1235. syncData: '数据同步',
  1236. settingData: '正在上传数据...',
  1237. gettingData: '正在获取数据...',
  1238. help: '帮助',
  1239. fileName: '文件名',
  1240. upload2gist: '同步到Gist',
  1241. downloadFromGist: '从Gist同步',
  1242. saveAndTest: '保存配置并测试',
  1243. testSuccess: '测试成功!',
  1244. testFailed: '测试失败!',
  1245. saveAndTestNotice: '请先保存配置并测试!',
  1246. processingData: '正在处理数据...',
  1247. updatingData: '正在上传数据...',
  1248. syncDataSuccess: '同步数据成功!',
  1249. syncDataFailed: '同步数据失败,请在控制台查看错误信息!',
  1250. downloadingData: '正在下载数据...',
  1251. checkedNoData: '没有检测到远程数据,请确认配置是否正确!',
  1252. savingData: '正在保存数据...',
  1253. syncHistory: '同步任务历史',
  1254. checkUpdateFailed: '检测更新失败',
  1255. newVersionNotice: '检测到新版本V%0, <a class="high-light" href="%1" target="_blank">点此更新</a>',
  1256. language: '语言</br>目前仅支持zh: 中文, en: 英文',
  1257. gistOptions: 'Gist 设置',
  1258. swalNotice: '检测到您第一次安装V4版本脚本,请前往阅读用前必读内容!',
  1259. echoNotice: '检测到您第一次安装V4版本脚本,请<a class="high-light" href="%0" target="_blank">点此前往</a>阅读用前必读内容!',
  1260. noticeLink: 'https://auto-task-doc.js.org/guide/#用前必读',
  1261. toGithub: '前往Github反馈',
  1262. toKeylol: '前往其乐论坛反馈',
  1263. copySuccess: '错误信息已复制到剪切板,是否前往其乐论坛反馈?',
  1264. copyFailed: '请复制下方错误信息后前往Keylol论坛反馈!',
  1265. updateText: '%0 版本更新内容:',
  1266. groups: '组',
  1267. wishlists: '愿望单',
  1268. follows: '游戏关注',
  1269. forums: '论坛',
  1270. workshops: '创意工坊收藏',
  1271. curators: '鉴赏家',
  1272. workshopVotes: '创意工坊点赞',
  1273. announcements: '社区通知',
  1274. steamCommunity: 'Steam社区',
  1275. steamStore: 'Steam商店',
  1276. needLoginSteamStore: '请先<a href="https://store.steampowered.com/login/" target="_blank">登录Steam商店</a>',
  1277. needLoginSteamCommunity: '请先<a href="https://steamcommunity.com/login/home/" target="_blank">登录Steam社区</a>',
  1278. joiningSteamGroup: '正在加入Steam组',
  1279. leavingSteamGroup: '正在退出Steam组',
  1280. gettingSteamGroupId: '正在获取Steam组Id',
  1281. subscribingForum: '正在订阅Steam论坛',
  1282. unsubscribingForum: '正在取消订阅Steam论坛',
  1283. gettingForumId: '正在获取Steam论坛Id',
  1284. followingCurator: '正在关注Steam鉴赏家',
  1285. unfollowingCurator: '正在取关Steam鉴赏家',
  1286. addingToWishlist: '正在添加游戏到Steam愿望单',
  1287. removingFromWishlist: '正在从Steam愿望单移除游戏',
  1288. followingGame: '正在关注Steam游戏',
  1289. unfollowingGame: '正在取关Steam游戏',
  1290. favoritingWorkshop: '正在收藏Steam创意工坊物品',
  1291. unfavoritingWorkshop: '正在取消收藏Steam创意工坊物品',
  1292. gettingWorkshopAppId: '正在获取Steam创意工坊物品Id',
  1293. votingUpWorkshop: '正在点赞Steam创意工坊物品',
  1294. gettingAnnouncementParams: '正在获取Steam通知信息',
  1295. likingAnnouncement: '正在点赞Steam通知',
  1296. changingArea: '正在更换Steam地区: %0...',
  1297. notNeededChangeArea: '当前地区不需要更换',
  1298. noAnotherArea: '请检测是否开启正确开启代理',
  1299. gettingAreaInfo: '正在获取Steam地区信息...',
  1300. changeAreaNotice: '疑似锁区游戏,尝试换区执行',
  1301. steamFinishNotice: 'Steam任务完成,尝试将购物车地区换回CN',
  1302. servers: '服务器',
  1303. joiningDiscordServer: '正在加入Discord服务器',
  1304. leavingDiscordServer: '正在退出Discord服务器',
  1305. gettingDiscordGuild: '正在获取Discord服务器Id',
  1306. users: '用户',
  1307. loginIns: '请先<a href="https://www.instagram.com/accounts/login/" target="_blank">登录Instagram</a>',
  1308. insBanned: '您的Instagram账户已被封禁',
  1309. verifyingInsAuth: '正在验证Instagram凭证...',
  1310. gettingInsUserId: '正在获取Instagram用户Id',
  1311. followingIns: '正在关注Instagram用户',
  1312. unfollowingIns: '正在取关Instagram用户',
  1313. reddits: '社区/用户',
  1314. loginReddit: '请先<a href="https://www.reddit.com/login/" target="_blank">登录Reddit</a>',
  1315. changingRedditVersion: '正在切换Reddit为新版页面...',
  1316. joiningReddit: '正在加入Reddit社区',
  1317. leavingReddit: '正在退出Reddit社区',
  1318. followingRedditUser: '正在关注Reddit用户',
  1319. unfollowingRedditUser: '正在取关Reddit用户',
  1320. channels: '频道',
  1321. followingTwitchChannel: '正在关注Twitch频道',
  1322. unfollowingTwitchChannel: '正在取关Twitch频道',
  1323. gettingTwitchChannelId: '正在获取Twitch频道Id',
  1324. twitterUser: '推特用户',
  1325. retweets: '转推',
  1326. followingTwitterUser: '正在关注推特用户',
  1327. unfollowingTwitterUser: '正在取关推特用户',
  1328. retweetting: '正在转推',
  1329. unretweetting: '正在撤销转推',
  1330. names: '组/社区/动态',
  1331. loginVk: '请先<a href="https://vk.com/login/" target="_blank">登录Vk</a>',
  1332. gettingVkId: '正在获取Vk任务Id',
  1333. joiningVkGroup: '正在加入Vk组',
  1334. leavingVkGroup: '正在退出Vk组',
  1335. joiningVkPublic: '正在加入Vk社区',
  1336. leavingVkPublic: '正在退出Vk社区',
  1337. sendingVkWall: '正在转发Vk动态',
  1338. deletingVkWall: '正在撤销转发Vk动态',
  1339. youtubeChannel: 'YouTube频道',
  1340. likes: '点赞',
  1341. loginYtb: '请先<a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">登录YouTube</a>',
  1342. tryUpdateYtbAuth: '请尝试<a href="https://www.youtube.com/#auth" target="_blank">更新YouTube凭证</a>',
  1343. gettingYtbToken: '正在获取YouTube Token...',
  1344. followingYtbChannel: '正在订阅YouTube频道',
  1345. unfollowingYtbChannel: '正在退订YouTube频道',
  1346. likingYtbVideo: '正在点赞YouTube视频',
  1347. unlikingYtbVideo: '正在取消点赞YouTube视频',
  1348. giveKeyNoticeBefore: '每次验证间隔15s',
  1349. giveKeyNoticeAfter: '如果没有key, 请在<a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>查看',
  1350. noPoints: '点数不够,跳过抽奖',
  1351. getNeedPointsFailed: '获取所需点数失败,跳过抽奖',
  1352. joiningLottery: '正在加入抽奖',
  1353. doingGleamTask: '正在做Gleam任务...',
  1354. gettingGleamLink: '正在获取Gleam任务链接...',
  1355. gleamTaskNotice: '如果此页面长时间未关闭,请完成任一任务后自行关闭!',
  1356. verifiedGleamTasks: '已尝试验证所有任务,验证失败的任务请尝试手动验证或完成!',
  1357. gsNotice: '为避免得到"0000-0000-0000"key, 已自动屏蔽"Grab Key"按钮,获取key时请关闭脚本!',
  1358. SweepWidgetNotice: '正在处理并验证任务,每次验证任务有1~3s间隔防止触发验证过快警告...'
  1359. };
  1360. const zh_CN = data;
  1361. const en_US_data = {
  1362. website: 'Website',
  1363. type: 'Type',
  1364. edit: 'Edit',
  1365. whiteList: 'Whitelist',
  1366. skipTask: 'Skip undo task',
  1367. whiteListOptions: 'Whitelist options',
  1368. changeWhiteListOption: 'Whitelist option(%0)',
  1369. whiteListNotFound: 'Cannot find this whitelist: %0',
  1370. changeWhiteListSuccess: 'The whitelist is successfully modified, and the page refresh will take effect!',
  1371. changeWebsiteOptions: 'Website options',
  1372. changeGlobalOptions: 'Global options',
  1373. ok: 'OK',
  1374. save: 'Save',
  1375. close: 'Close',
  1376. return: 'Return',
  1377. option: 'Option',
  1378. value: 'Value',
  1379. websiteOptions: 'Current website settings',
  1380. changeWebsiteOptionsSuccess: 'The current website setting is changed successfully, and the page refresh will take effect!',
  1381. changeGlobalOptionsSuccess: 'The global setting is changed successfully, and the refresh will take effect!',
  1382. needLogin: 'Please log in first!',
  1383. getTasksInfo: 'Obtaining and processing task information...',
  1384. gettingKey: 'Getting Key...',
  1385. verifyingTask: 'Verifying task',
  1386. notice: 'Automatic task script notice',
  1387. noKeysLeft: 'There are no more keys left on this page. Do you want to close it?',
  1388. giveawayEnded: 'This event has ended, do you want to close it?',
  1389. 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?',
  1390. confirm: 'Confirm',
  1391. cancel: 'Cancel',
  1392. unKnown: 'Unknown',
  1393. unKnownTaskType: 'Unrecognized task',
  1394. doing: 'Doing a task',
  1395. allTasksComplete: 'All tasks have been completed!',
  1396. getTaskIdFailed: 'Failed to obtain task Id!',
  1397. initSuccess: '%0 was initialized successfully!',
  1398. initFailed: '%0 initialization failed!',
  1399. errorLink: 'Link error: %0',
  1400. needInit: 'Please initialize first',
  1401. verifyingAuth: 'Verifying %0 token...',
  1402. updatingAuth: 'Update %0 token...',
  1403. initing: 'Initializing...',
  1404. getFailed: 'Failed to get %0!',
  1405. checkLoginFailed: 'Failed to detect login status!',
  1406. checkLeftKeyFailed: 'Failed to detect the remaining keys!',
  1407. userId: 'User Id',
  1408. joiningGiveaway: 'Joining giveaway',
  1409. needJoinGiveaway: 'Need to join the giveaway first',
  1410. cannotUndo: 'This website does not support canceling tasks',
  1411. verifyAuth: 'Verifying %0 token...',
  1412. closePageNotice: 'f this page does not close automatically, please close this page yourself.',
  1413. errorReport: 'A script error is detected, do you want to report the BUG?',
  1414. visitingLink: 'Visiting link: ',
  1415. doTask: 'DoTask',
  1416. undoTask: 'UndoTask',
  1417. verifyTask: 'Verify',
  1418. getKey: 'GetKey',
  1419. selectAll: 'SelectAll',
  1420. selectNone: 'SelectNone',
  1421. invertSelect: 'InvertSelect',
  1422. doFreeTask: 'FreeTask',
  1423. doPointTask: 'PointTask',
  1424. skipTaskOption: 'Skip task has been configured in the settings',
  1425. other: 'Other',
  1426. globalOptions: 'Global Options',
  1427. checkLogin: 'Login detection</br>Need to log in to the website automatically log in, part of this website supports.',
  1428. checkLeftKey: 'Key remaining detection</br>The end of the giveaway event prompts whether to close or not, part of this website supports.',
  1429. 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.',
  1430. 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.',
  1431. 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.',
  1432. saveGlobalOptions: 'SaveSettings',
  1433. settingPage: 'Setting Page',
  1434. name: 'Name',
  1435. version: 'Version',
  1436. scriptManager: 'Script Manager',
  1437. script: 'Script',
  1438. environment: 'Environment',
  1439. os: 'OS',
  1440. browser: 'Browser',
  1441. getId: 'Get %0 id',
  1442. getTwitterUserId: 'Get Twitter user id (Get id function is only available on the settings page).',
  1443. getYoutubeChannelId: 'Get Youtube channel id (Get id function is only available on the settings page).',
  1444. showButton: 'ShowButton',
  1445. hideButton: 'HideButton',
  1446. showLog: 'ShowLog',
  1447. hideLog: 'HideLog',
  1448. defaultShowButton: 'Default display button',
  1449. defaultShowLog: 'Display log by default',
  1450. position: 'Component position',
  1451. buttonSideX: 'Horizontal positioning of the button area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1452. 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',
  1453. 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',
  1454. showButtonSideX: 'ShowButton horizontal positioning (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1455. showButtonSideY: 'ShowButton vertical positioning (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1456. 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',
  1457. logSideX: 'Horizontal positioning of the log area (real-time preview function is only available on the setting page).' + '</br>left: left | right: right',
  1458. logSideY: 'Vertical positioning of the log area (real-time preview function is only available on the setting page).' + '</br>top: top | bottom: bottom',
  1459. 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',
  1460. hotKey: 'Shortcut key',
  1461. doTaskKey: 'DoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1462. undoTaskKey: 'UndoTask shortcut keys</br> (real-time preview function is only available on the settings page).',
  1463. toggleLogKey: 'ShowLog/HideLog shortcut keys</br> (real-time preview function is only available on the settings page).',
  1464. tasksHistory: 'TasksHistory',
  1465. clearHistory: 'Clear history',
  1466. clearHistoryFinished: 'The mission history has been cleared!',
  1467. deleteTask: 'Delete task',
  1468. lastChangeTime: 'Last Change Time',
  1469. clearTaskFinished: 'Delete the following tasks completed!',
  1470. clearTaskFailed: 'Failed to delete the task, the task name was not found!',
  1471. syncData: 'Data synchronization',
  1472. settingData: 'Uploading data...',
  1473. gettingData: 'Getting data...',
  1474. help: 'Help',
  1475. fileName: 'Filename',
  1476. upload2gist: 'Sync to Gist',
  1477. downloadFromGist: 'Sync from Gist',
  1478. saveAndTest: 'Save configuration and test',
  1479. testSuccess: 'Test success!',
  1480. testFailed: 'Test failed!',
  1481. saveAndTestNotice: 'Please save the configuration and test first!',
  1482. processingData: 'Processing data...',
  1483. updatingData: 'Uploading data...',
  1484. syncDataSuccess: 'Synchronized data successfully!',
  1485. syncDataFailed: 'Failed to synchronize data, please check the error message on the console!',
  1486. downloadingData: 'Downloading data...',
  1487. checkedNoData: 'No remote data is detected, please confirm whether the configuration is correct!',
  1488. savingData: 'Saving data...',
  1489. syncHistory: 'Synchronize tasks history',
  1490. checkUpdateFailed: 'Check update failed',
  1491. newVersionNotice: 'Checked a new version V%0, <a class="high-light" href="%1" target="_blank">click to update</a>',
  1492. language: 'Language</br> Currently only supports zh: Chinese, en: English',
  1493. gistOptions: 'Gist Settings',
  1494. 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!',
  1495. 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!',
  1496. noticeLink: 'https://auto-task-doc.js.org/en/guide/#read-me-first',
  1497. toGithub: 'Feedback(Github)',
  1498. toKeylol: 'Feedback(Keylol)',
  1499. copySuccess: 'The error message has been copied to the clipboard. Do you want to go to the Keylol forum to give feedback?',
  1500. copyFailed: 'Please copy the error information below and report back to the Keylol forum!',
  1501. updateText: 'Updates in version %0:',
  1502. groups: 'Group',
  1503. wishlists: 'Wishlist',
  1504. follows: 'Follow Game',
  1505. forums: 'Forum',
  1506. workshops: 'Favorite Workshop',
  1507. curators: 'Curator',
  1508. workshopVotes: 'Voteup Workshop',
  1509. announcements: 'Announcement',
  1510. steamCommunity: 'Steam Community',
  1511. steamStore: 'Steam Store',
  1512. needLoginSteamStore: 'Please <a href="https://store.steampowered.com/login/" target="_blank">log in to the Steam Store</a>',
  1513. needLoginSteamCommunity: 'Please <a href="https://steamcommunity.com/login/home/" target="_blank">log in to the Steam Community</a>',
  1514. joiningSteamGroup: 'Joining Steam Group',
  1515. leavingSteamGroup: 'Leaving Steam Group',
  1516. gettingSteamGroupId: 'Getting Steam Group Id',
  1517. subscribingForum: 'Subscribing the Steam Forum',
  1518. unsubscribingForum: 'Unsubscribing the Steam Forum',
  1519. gettingForumId: 'Getting Steam Forum Id',
  1520. followingCurator: 'Following Steam Curator',
  1521. unfollowingCurator: 'Unfollowing Steam Curator',
  1522. addingToWishlist: 'Adding the game to the Steam wishlist',
  1523. removingFromWishlist: 'Removing the game from the Steam wishlist',
  1524. followingGame: 'Following Steam games',
  1525. unfollowingGame: 'Unfollowing Steam games',
  1526. favoritingWorkshop: 'Favouring Steam Workshop Items',
  1527. unfavoritingWorkshop: 'Unfavoriting Steam Workshop Items',
  1528. gettingWorkshopAppId: 'Getting Steam Workshop Item Id',
  1529. votingUpWorkshop: 'Liking Steam workshop items',
  1530. gettingAnnouncementParams: 'Getting Steam announcement information',
  1531. likingAnnouncement: 'Liking Steam announcement',
  1532. changingArea: 'Changing Steam area: %0...',
  1533. notNeededChangeArea: 'The current area does not need to be changed',
  1534. noAnotherArea: 'Please check whether the proxy is turned on correctly',
  1535. gettingAreaInfo: 'Getting Steam area information...',
  1536. changeAreaNotice: 'Suspected of a locked zone game, try to change the zone to execute',
  1537. steamFinishNotice: 'Steam task completed, try to change the shopping cart area back to CN',
  1538. servers: 'Server',
  1539. joiningDiscordServer: 'Joining Discord Server',
  1540. leavingDiscordServer: 'Leaving Discord Server',
  1541. gettingDiscordGuild: 'Getting Discord server Id',
  1542. users: 'User',
  1543. loginIns: 'Please <a href="https://www.instagram.com/accounts/login/" target="_blank">log in to Instagram</a>',
  1544. insBanned: 'Your Instagram account has been banned',
  1545. verifyingInsAuth: 'Verifying Instagram token...',
  1546. gettingInsUserId: 'Getting Instagram user Id',
  1547. followingIns: 'Following Instagram user',
  1548. unfollowingIns: 'Unfollowing Instagram user',
  1549. reddits: 'Reddit/User',
  1550. loginReddit: 'Please <a href="https://www.reddit.com/login/" target="_blank">log in to Reddit</a>',
  1551. changingRedditVersion: 'Switching Reddit to a new version page...',
  1552. joiningReddit: 'Joining the Reddit',
  1553. leavingReddit: 'Leaving the Reddit',
  1554. followingRedditUser: 'Following Reddit User',
  1555. unfollowingRedditUser: 'Unfollowing Reddit User',
  1556. channels: 'Channel',
  1557. followingTwitchChannel: 'Following Twitch Channel',
  1558. unfollowingTwitchChannel: 'Unfollowing Twitch Channel',
  1559. gettingTwitchChannelId: 'Getting Twitch Channel Id',
  1560. twitterUser: 'Twitter User',
  1561. retweets: 'Retweet',
  1562. followingTwitterUser: 'Following Twitter User',
  1563. unfollowingTwitterUser: 'Unfollowing Twitter User',
  1564. retweetting: 'Retweetting',
  1565. unretweetting: 'Unretweetting',
  1566. names: 'Group/Public/Wall',
  1567. loginVk: 'Please <a href="https://vk.com/login/" target="_blank">log in to Vk</a>',
  1568. gettingVkId: 'Getting Vk task Id',
  1569. joiningVkGroup: 'Joining Vk Group',
  1570. leavingVkGroup: 'Leaving Vk Group',
  1571. joiningVkPublic: 'Joining Vk Public',
  1572. leavingVkPublic: 'Leaving Vk Public',
  1573. sendingVkWall: 'Sending Vk Wall',
  1574. deletingVkWall: 'Deleting Vk Wall',
  1575. youtubeChannel: 'YouTube Channel',
  1576. likes: 'Like',
  1577. loginYtb: 'Please <a href="https://accounts.google.com/ServiceLogin?service=youtube" target="_blank">log in to YouTube</a>',
  1578. tryUpdateYtbAuth: 'Please try to <a href="https://www.youtube.com/#auth" target="_blank">update YouTube token</a>',
  1579. gettingYtbToken: 'Getting YouTube Token...',
  1580. followingYtbChannel: 'Subscribing to YouTube channel',
  1581. unfollowingYtbChannel: 'Unsubscribing to YouTube channel',
  1582. likingYtbVideo: 'Liking YouTube video',
  1583. unlikingYtbVideo: 'Unliking YouTube video',
  1584. giveKeyNoticeBefore: 'Each verification interval is 15s',
  1585. giveKeyNoticeAfter: 'If there is no key, please check at <a href="https://givekey.ru/profile" target="_blank">https://givekey.ru/profile</a>',
  1586. noPoints: 'Not enough points, skip the lottery',
  1587. getNeedPointsFailed: 'ailed to obtain the required points, skip the lottery',
  1588. joiningLottery: 'Joining the lottery',
  1589. doingGleamTask: 'Doing Gleam Task...',
  1590. gettingGleamLink: 'Getting Gleam task link...',
  1591. gleamTaskNotice: 'If this page has not been closed for a long time, please close it yourself after completing any task!',
  1592. verifiedGleamTasks: 'Attempted to verify all tasks. If the verification fails, please try to verify manually or complete it!',
  1593. 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!',
  1594. 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...'
  1595. };
  1596. const en_US = en_US_data;
  1597. const languages = {
  1598. zh: zh_CN,
  1599. en: en_US
  1600. };
  1601. const language = [ 'zh', 'en' ].includes(globalOptions.other.language) ? globalOptions.other.language : 'en';
  1602. const I18n = function(key) {
  1603. var _languages$language;
  1604. for (var _len = arguments.length, argvs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1605. argvs[_key - 1] = arguments[_key];
  1606. }
  1607. if (!((_languages$language = languages[language]) !== null && _languages$language !== void 0 && _languages$language[key])) {
  1608. return key;
  1609. }
  1610. return languages[language][key].replace(/%([\d]+)/g, (match, index) => argvs[parseInt(index, 10)]);
  1611. };
  1612. const i18n = I18n;
  1613. function throwError(error, name) {
  1614. external_Swal_default().fire({
  1615. title: i18n('errorReport'),
  1616. icon: 'error',
  1617. showCancelButton: true,
  1618. confirmButtonText: i18n('toGithub'),
  1619. showDenyButton: true,
  1620. denyButtonText: i18n('toKeylol'),
  1621. cancelButtonText: i18n('close')
  1622. }).then(_ref => {
  1623. let {
  1624. isDenied,
  1625. isConfirmed
  1626. } = _ref;
  1627. if (isConfirmed) {
  1628. window.open(`https://github.com/HCLonely/auto-task-v4/issues/new?title=${encodeURIComponent(`脚本报错: ${name}`)}&labels=bug&body=${encodeURIComponent(`错误链接: [${window.location.href}](${window.location.href})
  1629.  
  1630. 环境:
  1631. \`\`\`
  1632. ${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}
  1633. \`\`\`
  1634. 脚本管理器: \`${GM_info.scriptHandler} ${GM_info.version}\`
  1635. 脚本版本: \`${GM_info.script.version}\`
  1636.  
  1637. 报错信息:
  1638. \`\`\`
  1639. ${error.stack}
  1640. \`\`\`
  1641.  
  1642. 执行日志:
  1643. \`\`\`
  1644. ${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}
  1645. \`\`\`
  1646. `)}`, '_blank');
  1647. } else if (isDenied) {
  1648. const text = `错误链接: [url=${window.location.href}]${window.location.href}[/url]
  1649.  
  1650. 环境:
  1651.  
  1652. [code]${JSON.stringify((0, javascript_utils_umd_min.ua)(), null, 4)}[/code]
  1653.  
  1654. 脚本管理器: ${GM_info.scriptHandler} ${GM_info.version}
  1655. 脚本版本: ${GM_info.script.version}
  1656.  
  1657. 报错信息:
  1658. [code]${error.stack}[/code]
  1659.  
  1660. 执行日志:
  1661. [code]${$.makeArray($('#auto-task-info>li')).map(element => element.innerText).join('\n')}[/code]`;
  1662. GM_setClipboard(text);
  1663. external_Swal_default().fire({
  1664. title: i18n('copySuccess'),
  1665. icon: 'success',
  1666. confirmButtonText: i18n('ok')
  1667. }).then(() => {
  1668. window.open('https://keylol.com/forum.php?mod=post&action=reply&fid=319&tid=777450', '_blank');
  1669. });
  1670. }
  1671. });
  1672. console.log('%c%s', 'color:white;background:red', `${name}\n${error.stack}`);
  1673. }
  1674. function _defineProperty(obj, key, value) {
  1675. if (key in obj) {
  1676. Object.defineProperty(obj, key, {
  1677. value: value,
  1678. enumerable: true,
  1679. configurable: true,
  1680. writable: true
  1681. });
  1682. } else {
  1683. obj[key] = value;
  1684. }
  1685. return obj;
  1686. }
  1687. class Social {
  1688. constructor() {
  1689. _defineProperty(this, 'tasks', void 0);
  1690. }
  1691. getRealParams(name, links, doTask, link2param) {
  1692. try {
  1693. let realParams = [];
  1694. if (links.length > 0) {
  1695. realParams = [ ...realParams, ...links.map(link => link2param(link)).filter(link => link) ];
  1696. }
  1697. if (!doTask && this.tasks[name].length > 0) {
  1698. realParams = [ ...realParams, ...this.tasks[name] ];
  1699. }
  1700. return unique(realParams);
  1701. } catch (error) {
  1702. throwError(error, 'Social.getRealParams');
  1703. return [];
  1704. }
  1705. }
  1706. }
  1707. const social_Social = Social;
  1708. function _classPrivateMethodInitSpec(obj, privateSet) {
  1709. _checkPrivateRedeclaration(obj, privateSet);
  1710. privateSet.add(obj);
  1711. }
  1712. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  1713. _checkPrivateRedeclaration(obj, privateMap);
  1714. privateMap.set(obj, value);
  1715. }
  1716. function _checkPrivateRedeclaration(obj, privateCollection) {
  1717. if (privateCollection.has(obj)) {
  1718. throw new TypeError('Cannot initialize the same private elements twice on an object');
  1719. }
  1720. }
  1721. function Discord_defineProperty(obj, key, value) {
  1722. if (key in obj) {
  1723. Object.defineProperty(obj, key, {
  1724. value: value,
  1725. enumerable: true,
  1726. configurable: true,
  1727. writable: true
  1728. });
  1729. } else {
  1730. obj[key] = value;
  1731. }
  1732. return obj;
  1733. }
  1734. function _classPrivateFieldSet(receiver, privateMap, value) {
  1735. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'set');
  1736. _classApplyDescriptorSet(receiver, descriptor, value);
  1737. return value;
  1738. }
  1739. function _classApplyDescriptorSet(receiver, descriptor, value) {
  1740. if (descriptor.set) {
  1741. descriptor.set.call(receiver, value);
  1742. } else {
  1743. if (!descriptor.writable) {
  1744. throw new TypeError('attempted to set read only private field');
  1745. }
  1746. descriptor.value = value;
  1747. }
  1748. }
  1749. function _classPrivateMethodGet(receiver, privateSet, fn) {
  1750. if (!privateSet.has(receiver)) {
  1751. throw new TypeError('attempted to get private field on non-instance');
  1752. }
  1753. return fn;
  1754. }
  1755. function _classPrivateFieldGet(receiver, privateMap) {
  1756. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, 'get');
  1757. return _classApplyDescriptorGet(receiver, descriptor);
  1758. }
  1759. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1760. if (!privateMap.has(receiver)) {
  1761. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  1762. }
  1763. return privateMap.get(receiver);
  1764. }
  1765. function _classApplyDescriptorGet(receiver, descriptor) {
  1766. if (descriptor.get) {
  1767. return descriptor.get.call(receiver);
  1768. }
  1769. return descriptor.value;
  1770. }
  1771. const defaultTasks = {
  1772. servers: []
  1773. };
  1774. var _auth = new WeakMap();
  1775. var _cache = new WeakMap();
  1776. var _initialized = new WeakMap();
  1777. var _verifyAuth = new WeakSet();
  1778. var _updateAuth = new WeakSet();
  1779. var _joinServer = new WeakSet();
  1780. var _leaveServer = new WeakSet();
  1781. var _getGuild = new WeakSet();
  1782. var _setCache = new WeakSet();
  1783. class Discord extends social_Social {
  1784. constructor() {
  1785. var _GM_getValue;
  1786. super(...arguments);
  1787. _classPrivateMethodInitSpec(this, _setCache);
  1788. _classPrivateMethodInitSpec(this, _getGuild);
  1789. _classPrivateMethodInitSpec(this, _leaveServer);
  1790. _classPrivateMethodInitSpec(this, _joinServer);
  1791. _classPrivateMethodInitSpec(this, _updateAuth);
  1792. _classPrivateMethodInitSpec(this, _verifyAuth);
  1793. Discord_defineProperty(this, 'tasks', {
  1794. ...defaultTasks
  1795. });
  1796. Discord_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.discord) || {
  1797. ...defaultTasks
  1798. });
  1799. _classPrivateFieldInitSpec(this, _auth, {
  1800. writable: true,
  1801. value: GM_getValue('discordAuth') || {}
  1802. });
  1803. _classPrivateFieldInitSpec(this, _cache, {
  1804. writable: true,
  1805. value: GM_getValue('discordCache') || {}
  1806. });
  1807. _classPrivateFieldInitSpec(this, _initialized, {
  1808. writable: true,
  1809. value: false
  1810. });
  1811. }
  1812. async init() {
  1813. try {
  1814. if (_classPrivateFieldGet(this, _initialized)) {
  1815. return true;
  1816. }
  1817. if (!_classPrivateFieldGet(this, _auth).auth) {
  1818. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1819. _classPrivateFieldSet(this, _initialized, true);
  1820. return true;
  1821. }
  1822. return false;
  1823. }
  1824. const isVerified = await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this);
  1825. if (isVerified) {
  1826. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1827. _classPrivateFieldSet(this, _initialized, true);
  1828. return true;
  1829. }
  1830. GM_setValue('discordAuth', {
  1831. auth: null
  1832. });
  1833. if (await _classPrivateMethodGet(this, _updateAuth, _updateAuth2).call(this)) {
  1834. scripts_echoLog({}).success(i18n('initSuccess', 'Discord'));
  1835. _classPrivateFieldSet(this, _initialized, true);
  1836. return true;
  1837. }
  1838. scripts_echoLog({}).error(i18n('initFailed', 'Discord'));
  1839. return false;
  1840. } catch (error) {
  1841. throwError(error, 'Discord.init');
  1842. return false;
  1843. }
  1844. }
  1845. async toggle(_ref) {
  1846. let {
  1847. doTask = true,
  1848. serverLinks = []
  1849. } = _ref;
  1850. try {
  1851. if (!_classPrivateFieldGet(this, _initialized)) {
  1852. scripts_echoLog({
  1853. text: i18n('needInit')
  1854. });
  1855. return false;
  1856. }
  1857. const prom = [];
  1858. if (doTask && !globalOptions.doTask.discord.servers || !doTask && !globalOptions.undoTask.discord.servers) {
  1859. scripts_echoLog({
  1860. type: 'globalOptionsSkip',
  1861. text: 'discord.servers'
  1862. });
  1863. } else {
  1864. const realServers = this.getRealParams('servers', serverLinks, doTask, link => {
  1865. var _link$match;
  1866. return (_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  1867. });
  1868. if (realServers.length > 0) {
  1869. for (const server of realServers) {
  1870. if (doTask) {
  1871. prom.push(_classPrivateMethodGet(this, _joinServer, _joinServer2).call(this, server));
  1872. } else {
  1873. prom.push(_classPrivateMethodGet(this, _leaveServer, _leaveServer2).call(this, server));
  1874. }
  1875. await delay(1e3);
  1876. }
  1877. }
  1878. }
  1879. return await Promise.all(prom).then(() => true);
  1880. } catch (error) {
  1881. throwError(error, 'Discord.toggleServers');
  1882. return false;
  1883. }
  1884. }
  1885. }
  1886. async function _verifyAuth2() {
  1887. try {
  1888. const logStatus = scripts_echoLog({
  1889. text: i18n('verifyingAuth', 'Discord')
  1890. });
  1891. const {
  1892. result,
  1893. statusText,
  1894. status,
  1895. data
  1896. } = await tools_httpRequest({
  1897. url: 'https://discord.com/api/v6/users/@me',
  1898. method: 'HEAD',
  1899. headers: {
  1900. authorization: _classPrivateFieldGet(this, _auth).auth
  1901. }
  1902. });
  1903. if (result === 'Success') {
  1904. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  1905. logStatus.success();
  1906. return true;
  1907. }
  1908. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  1909. return false;
  1910. }
  1911. logStatus.error(`${result}:${statusText}(${status})`);
  1912. return false;
  1913. } catch (error) {
  1914. throwError(error, 'Discord.verifyAuth');
  1915. return false;
  1916. }
  1917. }
  1918. async function _updateAuth2() {
  1919. try {
  1920. const logStatus = scripts_echoLog({
  1921. text: i18n('updatingAuth', 'Discord')
  1922. });
  1923. return await new Promise(resolve => {
  1924. const newTab = GM_openInTab('https://discord.com/channels/@me#auth', {
  1925. active: true,
  1926. insert: true,
  1927. setParent: true
  1928. });
  1929. newTab.onclose = async () => {
  1930. var _GM_getValue2;
  1931. const auth = (_GM_getValue2 = GM_getValue('discordAuth')) === null || _GM_getValue2 === void 0 ? void 0 : _GM_getValue2.auth;
  1932. if (auth) {
  1933. _classPrivateFieldSet(this, _auth, {
  1934. auth: auth
  1935. });
  1936. logStatus.success();
  1937. resolve(await _classPrivateMethodGet(this, _verifyAuth, _verifyAuth2).call(this));
  1938. } else {
  1939. logStatus.error('Error: Update discord auth failed!');
  1940. resolve(false);
  1941. }
  1942. };
  1943. });
  1944. } catch (error) {
  1945. throwError(error, 'Discord.updateAuth');
  1946. return false;
  1947. }
  1948. }
  1949. async function _joinServer2(inviteId) {
  1950. try {
  1951. const logStatus = scripts_echoLog({
  1952. type: 'joiningDiscordServer',
  1953. text: inviteId
  1954. });
  1955. const {
  1956. result,
  1957. statusText,
  1958. status,
  1959. data
  1960. } = await tools_httpRequest({
  1961. url: `https://discord.com/api/v6/invites/${inviteId}`,
  1962. method: 'POST',
  1963. dataType: 'json',
  1964. headers: {
  1965. authorization: _classPrivateFieldGet(this, _auth).auth
  1966. }
  1967. });
  1968. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  1969. var _data$response, _data$response$guild;
  1970. logStatus.success();
  1971. 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);
  1972. if (guild) {
  1973. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  1974. this.tasks.servers = unique([ ...this.tasks.servers, inviteId ]);
  1975. }
  1976. return true;
  1977. }
  1978. logStatus.error(`${result}:${statusText}(${status})`);
  1979. return false;
  1980. } catch (error) {
  1981. throwError(error, 'Discord.joinServer');
  1982. return false;
  1983. }
  1984. }
  1985. async function _leaveServer2(inviteId) {
  1986. try {
  1987. if (this.whiteList.servers.includes(inviteId)) {
  1988. scripts_echoLog({
  1989. type: 'whiteList',
  1990. text: 'Discord.leaveServer',
  1991. id: inviteId
  1992. });
  1993. return true;
  1994. }
  1995. const guild = await _classPrivateMethodGet(this, _getGuild, _getGuild2).call(this, inviteId);
  1996. if (!guild) {
  1997. return false;
  1998. }
  1999. const logStatus = scripts_echoLog({
  2000. type: 'leavingDiscordServer',
  2001. text: guild
  2002. });
  2003. const {
  2004. result,
  2005. statusText,
  2006. status,
  2007. data
  2008. } = await tools_httpRequest({
  2009. url: `https://discord.com/api/v6/users/@me/guilds/${guild}`,
  2010. method: 'DELETE',
  2011. headers: {
  2012. authorization: _classPrivateFieldGet(this, _auth).auth
  2013. }
  2014. });
  2015. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 204) {
  2016. logStatus.success();
  2017. return true;
  2018. }
  2019. logStatus.error(`${result}:${statusText}(${status})`);
  2020. return false;
  2021. } catch (error) {
  2022. throwError(error, 'Discord.leaveServer');
  2023. return false;
  2024. }
  2025. }
  2026. async function _getGuild2(inviteId) {
  2027. try {
  2028. const logStatus = scripts_echoLog({
  2029. type: 'gettingDiscordGuild',
  2030. text: inviteId
  2031. });
  2032. const guild = _classPrivateFieldGet(this, _cache)[inviteId];
  2033. if (guild) {
  2034. logStatus.success();
  2035. return guild;
  2036. }
  2037. const {
  2038. result,
  2039. statusText,
  2040. status,
  2041. data
  2042. } = await tools_httpRequest({
  2043. url: `https://discord.com/invite/${inviteId}`,
  2044. method: 'GET'
  2045. });
  2046. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200) {
  2047. var _data$responseText$ma;
  2048. const guild = (_data$responseText$ma = data.responseText.match(/https?:\/\/cdn\.discordapp\.com\/icons\/([\d]+?)\//)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2049. if (guild) {
  2050. logStatus.success();
  2051. _classPrivateMethodGet(this, _setCache, _setCache2).call(this, inviteId, guild);
  2052. return guild;
  2053. }
  2054. logStatus.error(`${result}:${statusText}(${status})`);
  2055. return false;
  2056. }
  2057. logStatus.error(`${result}:${statusText}(${status})`);
  2058. return false;
  2059. } catch (error) {
  2060. throwError(error, 'Discord.getGuild');
  2061. return false;
  2062. }
  2063. }
  2064. function _setCache2(inviteId, guild) {
  2065. try {
  2066. _classPrivateFieldGet(this, _cache)[inviteId] = guild;
  2067. GM_setValue('discordCache', _classPrivateFieldGet(this, _cache));
  2068. } catch (error) {
  2069. throwError(error, 'Discord.setCache');
  2070. }
  2071. }
  2072. const social_Discord = Discord;
  2073. function Instagram_classPrivateMethodInitSpec(obj, privateSet) {
  2074. Instagram_checkPrivateRedeclaration(obj, privateSet);
  2075. privateSet.add(obj);
  2076. }
  2077. function Instagram_classPrivateFieldInitSpec(obj, privateMap, value) {
  2078. Instagram_checkPrivateRedeclaration(obj, privateMap);
  2079. privateMap.set(obj, value);
  2080. }
  2081. function Instagram_checkPrivateRedeclaration(obj, privateCollection) {
  2082. if (privateCollection.has(obj)) {
  2083. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2084. }
  2085. }
  2086. function Instagram_defineProperty(obj, key, value) {
  2087. if (key in obj) {
  2088. Object.defineProperty(obj, key, {
  2089. value: value,
  2090. enumerable: true,
  2091. configurable: true,
  2092. writable: true
  2093. });
  2094. } else {
  2095. obj[key] = value;
  2096. }
  2097. return obj;
  2098. }
  2099. function Instagram_classPrivateFieldSet(receiver, privateMap, value) {
  2100. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2101. Instagram_classApplyDescriptorSet(receiver, descriptor, value);
  2102. return value;
  2103. }
  2104. function Instagram_classApplyDescriptorSet(receiver, descriptor, value) {
  2105. if (descriptor.set) {
  2106. descriptor.set.call(receiver, value);
  2107. } else {
  2108. if (!descriptor.writable) {
  2109. throw new TypeError('attempted to set read only private field');
  2110. }
  2111. descriptor.value = value;
  2112. }
  2113. }
  2114. function Instagram_classPrivateMethodGet(receiver, privateSet, fn) {
  2115. if (!privateSet.has(receiver)) {
  2116. throw new TypeError('attempted to get private field on non-instance');
  2117. }
  2118. return fn;
  2119. }
  2120. function Instagram_classPrivateFieldGet(receiver, privateMap) {
  2121. var descriptor = Instagram_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2122. return Instagram_classApplyDescriptorGet(receiver, descriptor);
  2123. }
  2124. function Instagram_classExtractFieldDescriptor(receiver, privateMap, action) {
  2125. if (!privateMap.has(receiver)) {
  2126. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2127. }
  2128. return privateMap.get(receiver);
  2129. }
  2130. function Instagram_classApplyDescriptorGet(receiver, descriptor) {
  2131. if (descriptor.get) {
  2132. return descriptor.get.call(receiver);
  2133. }
  2134. return descriptor.value;
  2135. }
  2136. const Instagram_defaultTasks = {
  2137. users: []
  2138. };
  2139. var Instagram_cache = new WeakMap();
  2140. var Instagram_auth = new WeakMap();
  2141. var Instagram_initialized = new WeakMap();
  2142. var _getUserInfo = new WeakSet();
  2143. var _followUser = new WeakSet();
  2144. var _unfollowUser = new WeakSet();
  2145. var Instagram_setCache = new WeakSet();
  2146. class Instagram extends social_Social {
  2147. constructor() {
  2148. var _GM_getValue;
  2149. super(...arguments);
  2150. Instagram_classPrivateMethodInitSpec(this, Instagram_setCache);
  2151. Instagram_classPrivateMethodInitSpec(this, _unfollowUser);
  2152. Instagram_classPrivateMethodInitSpec(this, _followUser);
  2153. Instagram_classPrivateMethodInitSpec(this, _getUserInfo);
  2154. Instagram_defineProperty(this, 'tasks', {
  2155. ...Instagram_defaultTasks
  2156. });
  2157. Instagram_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.instagram) || {
  2158. ...Instagram_defaultTasks
  2159. });
  2160. Instagram_classPrivateFieldInitSpec(this, Instagram_cache, {
  2161. writable: true,
  2162. value: GM_getValue('instagramCache') || {}
  2163. });
  2164. Instagram_classPrivateFieldInitSpec(this, Instagram_auth, {
  2165. writable: true,
  2166. value: {}
  2167. });
  2168. Instagram_classPrivateFieldInitSpec(this, Instagram_initialized, {
  2169. writable: true,
  2170. value: false
  2171. });
  2172. }
  2173. async init() {
  2174. try {
  2175. if (Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2176. return true;
  2177. }
  2178. const isVerified = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this);
  2179. if (isVerified) {
  2180. scripts_echoLog({}).success(i18n('initSuccess', 'Instagram'));
  2181. Instagram_classPrivateFieldSet(this, Instagram_initialized, true);
  2182. return true;
  2183. }
  2184. scripts_echoLog({}).error(i18n('initFailed', 'Instagram'));
  2185. return false;
  2186. } catch (error) {
  2187. throwError(error, 'Instagram.init');
  2188. return false;
  2189. }
  2190. }
  2191. async toggle(_ref) {
  2192. let {
  2193. doTask = true,
  2194. userLinks = []
  2195. } = _ref;
  2196. try {
  2197. if (!Instagram_classPrivateFieldGet(this, Instagram_initialized)) {
  2198. scripts_echoLog({
  2199. text: i18n('needInit')
  2200. });
  2201. return false;
  2202. }
  2203. const prom = [];
  2204. if (doTask && !globalOptions.doTask.instagram.users || !doTask && !globalOptions.undoTask.instagram.users) {
  2205. scripts_echoLog({
  2206. type: 'globalOptionsSkip',
  2207. text: 'instagram.users'
  2208. });
  2209. } else {
  2210. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  2211. var _link$match;
  2212. return (_link$match = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2213. });
  2214. if (realUsers.length > 0) {
  2215. for (const username of realUsers) {
  2216. if (doTask) {
  2217. prom.push(Instagram_classPrivateMethodGet(this, _followUser, _followUser2).call(this, username));
  2218. } else {
  2219. prom.push(Instagram_classPrivateMethodGet(this, _unfollowUser, _unfollowUser2).call(this, username));
  2220. }
  2221. await delay(1e3);
  2222. }
  2223. }
  2224. }
  2225. return await Promise.all(prom).then(() => true);
  2226. } catch (error) {
  2227. throwError(error, 'Instagram.toggleUsers');
  2228. return false;
  2229. }
  2230. }
  2231. }
  2232. async function _getUserInfo2() {
  2233. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'instagram';
  2234. try {
  2235. const logStatus = scripts_echoLog({
  2236. type: name === 'instagram' ? 'verifyingInsAuth' : 'gettingInsUserId',
  2237. text: name
  2238. });
  2239. const userId = Instagram_classPrivateFieldGet(this, Instagram_cache)[name];
  2240. if (userId && name !== 'instagram') {
  2241. logStatus.success();
  2242. return userId;
  2243. }
  2244. const {
  2245. result,
  2246. statusText,
  2247. status,
  2248. data
  2249. } = await tools_httpRequest({
  2250. url: `https://www.instagram.com/${name}/`,
  2251. method: 'GET'
  2252. });
  2253. if (result === 'Success') {
  2254. if (data !== null && data !== void 0 && data.finalUrl.includes('accounts/login')) {
  2255. logStatus.error(`Error:${i18n('loginIns')}`, true);
  2256. return false;
  2257. } else if (data !== null && data !== void 0 && data.finalUrl.includes('www.instagram.com/challenge')) {
  2258. logStatus.error(`Error:${i18n('insBanned')}`);
  2259. return false;
  2260. }
  2261. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2262. var _data$responseText$ma, _data$responseText$ma2, _data$responseText$ma3;
  2263. const csrftoken = (_data$responseText$ma = data.responseText.match(/"csrf_token":"(.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2264. const hash = (_data$responseText$ma2 = data.responseText.match(/"rollout_hash":"(.+?)"/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  2265. if (name === 'instagram') {
  2266. if (csrftoken && hash) {
  2267. Instagram_classPrivateFieldSet(this, Instagram_auth, {
  2268. csrftoken: csrftoken,
  2269. hash: hash
  2270. });
  2271. return true;
  2272. }
  2273. return false;
  2274. }
  2275. const id = (_data$responseText$ma3 = data.responseText.match(/"profilePage_([\d]+?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  2276. if (id) {
  2277. Instagram_classPrivateMethodGet(this, Instagram_setCache, Instagram_setCache2).call(this, name, id);
  2278. logStatus.success();
  2279. return id;
  2280. }
  2281. logStatus.error('Error: Get ins data error!');
  2282. return false;
  2283. }
  2284. logStatus.error(`${result}:${statusText}(${status})`);
  2285. return false;
  2286. }
  2287. return false;
  2288. } catch (error) {
  2289. throwError(error, 'Instagram.getUserInfo');
  2290. return false;
  2291. }
  2292. }
  2293. async function _followUser2(name) {
  2294. try {
  2295. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2296. if (!id) {
  2297. return false;
  2298. }
  2299. const logStatus = scripts_echoLog({
  2300. type: 'followingIns',
  2301. text: name
  2302. });
  2303. const {
  2304. result,
  2305. statusText,
  2306. status,
  2307. data
  2308. } = await tools_httpRequest({
  2309. url: `https://www.instagram.com/web/friendships/${id}/follow/`,
  2310. method: 'POST',
  2311. dataType: 'json',
  2312. headers: {
  2313. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2314. origin: 'https://www.instagram.com',
  2315. referer: `https://www.instagram.com/${name}/`,
  2316. 'content-type': 'application/x-www-form-urlencoded',
  2317. 'sec-fetch-site': 'same-origin',
  2318. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2319. }
  2320. });
  2321. if (result === 'Success') {
  2322. var _data$response, _data$response2;
  2323. 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') {
  2324. logStatus.success();
  2325. this.tasks.users = unique([ ...this.tasks.users, name ]);
  2326. return true;
  2327. }
  2328. 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})`}`);
  2329. return false;
  2330. }
  2331. logStatus.error(`${result}:${statusText}(${status})`);
  2332. return false;
  2333. } catch (error) {
  2334. throwError(error, 'Instagram.followUser');
  2335. return false;
  2336. }
  2337. }
  2338. async function _unfollowUser2(name) {
  2339. try {
  2340. if (this.whiteList.users.includes(name)) {
  2341. scripts_echoLog({
  2342. type: 'whiteList',
  2343. text: 'Instagram.unfollowUser',
  2344. id: name
  2345. });
  2346. return true;
  2347. }
  2348. const id = await Instagram_classPrivateMethodGet(this, _getUserInfo, _getUserInfo2).call(this, name);
  2349. if (!id) {
  2350. return false;
  2351. }
  2352. const logStatus = scripts_echoLog({
  2353. type: 'unfollowingIns',
  2354. text: name
  2355. });
  2356. const {
  2357. result,
  2358. statusText,
  2359. status,
  2360. data
  2361. } = await tools_httpRequest({
  2362. url: `https://www.instagram.com/web/friendships/${id}/unfollow/`,
  2363. method: 'POST',
  2364. dataType: 'json',
  2365. headers: {
  2366. 'x-csrftoken': Instagram_classPrivateFieldGet(this, Instagram_auth).csrftoken,
  2367. origin: 'https://www.instagram.com',
  2368. referer: `https://www.instagram.com/${name}/`,
  2369. 'content-type': 'application/x-www-form-urlencoded',
  2370. 'sec-fetch-site': 'same-origin',
  2371. 'x-instagram-ajax': Instagram_classPrivateFieldGet(this, Instagram_auth).hash
  2372. }
  2373. });
  2374. if (result === 'Success') {
  2375. var _data$response3;
  2376. 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') {
  2377. logStatus.success();
  2378. return true;
  2379. }
  2380. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2381. return false;
  2382. }
  2383. logStatus.error(`${result}:${statusText}(${status})`);
  2384. return false;
  2385. } catch (error) {
  2386. throwError(error, 'Instagram.unfollowUser');
  2387. return false;
  2388. }
  2389. }
  2390. function Instagram_setCache2(name, id) {
  2391. try {
  2392. Instagram_classPrivateFieldGet(this, Instagram_cache)[name] = id;
  2393. GM_setValue('instagramCache', Instagram_classPrivateFieldGet(this, Instagram_cache));
  2394. } catch (error) {
  2395. throwError(error, 'Instagram.setCache');
  2396. }
  2397. }
  2398. const social_Instagram = Instagram;
  2399. function Reddit_classPrivateMethodInitSpec(obj, privateSet) {
  2400. Reddit_checkPrivateRedeclaration(obj, privateSet);
  2401. privateSet.add(obj);
  2402. }
  2403. function Reddit_classPrivateFieldInitSpec(obj, privateMap, value) {
  2404. Reddit_checkPrivateRedeclaration(obj, privateMap);
  2405. privateMap.set(obj, value);
  2406. }
  2407. function Reddit_checkPrivateRedeclaration(obj, privateCollection) {
  2408. if (privateCollection.has(obj)) {
  2409. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2410. }
  2411. }
  2412. function Reddit_defineProperty(obj, key, value) {
  2413. if (key in obj) {
  2414. Object.defineProperty(obj, key, {
  2415. value: value,
  2416. enumerable: true,
  2417. configurable: true,
  2418. writable: true
  2419. });
  2420. } else {
  2421. obj[key] = value;
  2422. }
  2423. return obj;
  2424. }
  2425. function Reddit_classPrivateFieldSet(receiver, privateMap, value) {
  2426. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2427. Reddit_classApplyDescriptorSet(receiver, descriptor, value);
  2428. return value;
  2429. }
  2430. function Reddit_classApplyDescriptorSet(receiver, descriptor, value) {
  2431. if (descriptor.set) {
  2432. descriptor.set.call(receiver, value);
  2433. } else {
  2434. if (!descriptor.writable) {
  2435. throw new TypeError('attempted to set read only private field');
  2436. }
  2437. descriptor.value = value;
  2438. }
  2439. }
  2440. function Reddit_classPrivateMethodGet(receiver, privateSet, fn) {
  2441. if (!privateSet.has(receiver)) {
  2442. throw new TypeError('attempted to get private field on non-instance');
  2443. }
  2444. return fn;
  2445. }
  2446. function Reddit_classPrivateFieldGet(receiver, privateMap) {
  2447. var descriptor = Reddit_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2448. return Reddit_classApplyDescriptorGet(receiver, descriptor);
  2449. }
  2450. function Reddit_classExtractFieldDescriptor(receiver, privateMap, action) {
  2451. if (!privateMap.has(receiver)) {
  2452. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2453. }
  2454. return privateMap.get(receiver);
  2455. }
  2456. function Reddit_classApplyDescriptorGet(receiver, descriptor) {
  2457. if (descriptor.get) {
  2458. return descriptor.get.call(receiver);
  2459. }
  2460. return descriptor.value;
  2461. }
  2462. const Reddit_defaultTasks = {
  2463. reddits: []
  2464. };
  2465. var Reddit_auth = new WeakMap();
  2466. var Reddit_initialized = new WeakMap();
  2467. var _useBeta = new WeakSet();
  2468. var Reddit_updateAuth = new WeakSet();
  2469. class Reddit extends social_Social {
  2470. constructor() {
  2471. var _GM_getValue;
  2472. super(...arguments);
  2473. Reddit_classPrivateMethodInitSpec(this, Reddit_updateAuth);
  2474. Reddit_classPrivateMethodInitSpec(this, _useBeta);
  2475. Reddit_defineProperty(this, 'tasks', {
  2476. ...Reddit_defaultTasks
  2477. });
  2478. Reddit_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.reddit) || {
  2479. ...Reddit_defaultTasks
  2480. });
  2481. Reddit_classPrivateFieldInitSpec(this, Reddit_auth, {
  2482. writable: true,
  2483. value: void 0
  2484. });
  2485. Reddit_classPrivateFieldInitSpec(this, Reddit_initialized, {
  2486. writable: true,
  2487. value: false
  2488. });
  2489. }
  2490. async init() {
  2491. try {
  2492. if (Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2493. return true;
  2494. }
  2495. const isVerified = await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this);
  2496. if (isVerified) {
  2497. scripts_echoLog({}).success(i18n('initSuccess', 'Reddit'));
  2498. Reddit_classPrivateFieldSet(this, Reddit_initialized, true);
  2499. return true;
  2500. }
  2501. scripts_echoLog({}).error(i18n('initFailed', 'Reddit'));
  2502. return false;
  2503. } catch (error) {
  2504. throwError(error, 'Reddit.init');
  2505. return false;
  2506. }
  2507. }
  2508. async toggleTask(_ref) {
  2509. let {
  2510. name,
  2511. doTask = true
  2512. } = _ref;
  2513. try {
  2514. if (!doTask && this.whiteList.reddits.includes(name)) {
  2515. scripts_echoLog({
  2516. type: 'whiteList',
  2517. text: 'Reddit.undoTask',
  2518. id: name
  2519. });
  2520. return true;
  2521. }
  2522. let type = doTask ? 'joiningReddit' : 'leavingReddit';
  2523. if (/^u_/.test(name)) {
  2524. type = doTask ? 'followingRedditUser' : 'unfollowingRedditUser';
  2525. }
  2526. const logStatus = scripts_echoLog({
  2527. type: type,
  2528. text: name
  2529. });
  2530. const {
  2531. result,
  2532. statusText,
  2533. status,
  2534. data
  2535. } = await tools_httpRequest({
  2536. url: 'https://oauth.reddit.com/api/subscribe?redditWebClient=desktop2x&app=desktop2x-client-production&raw_json=1&gilding_detail=1',
  2537. method: 'POST',
  2538. headers: {
  2539. authorization: `Bearer ${Reddit_classPrivateFieldGet(this, Reddit_auth).token}`,
  2540. 'content-type': 'application/x-www-form-urlencoded'
  2541. },
  2542. data: $.param({
  2543. action: doTask ? 'sub' : 'unsub',
  2544. sr_name: name,
  2545. api_type: 'json'
  2546. })
  2547. });
  2548. if (result === 'Success') {
  2549. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2550. logStatus.success();
  2551. if (doTask) {
  2552. this.tasks.reddits = unique([ ...this.tasks.reddits, name ]);
  2553. }
  2554. return true;
  2555. }
  2556. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2557. return false;
  2558. }
  2559. logStatus.error(`${result}:${statusText}(${status})`);
  2560. return false;
  2561. } catch (error) {
  2562. throwError(error, 'Reddit.toggleTask');
  2563. return false;
  2564. }
  2565. }
  2566. async toggle(_ref2) {
  2567. let {
  2568. doTask = true,
  2569. redditLinks = []
  2570. } = _ref2;
  2571. try {
  2572. if (!Reddit_classPrivateFieldGet(this, Reddit_initialized)) {
  2573. scripts_echoLog({
  2574. text: i18n('needInit')
  2575. });
  2576. return false;
  2577. }
  2578. const prom = [];
  2579. if (doTask && !globalOptions.doTask.reddit.reddits || !doTask && !globalOptions.undoTask.reddit.reddits) {
  2580. scripts_echoLog({
  2581. type: 'globalOptionsSkip',
  2582. text: 'reddit.reddits'
  2583. });
  2584. } else {
  2585. const realReddits = this.getRealParams('reddits', redditLinks, doTask, link => {
  2586. var _link$match, _link$match2;
  2587. const name = (_link$match = link.match(/https?:\/\/www\.reddit\.com\/r\/([^/]*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  2588. const userName = (_link$match2 = link.match(/https?:\/\/www\.reddit\.com\/user\/([^/]*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  2589. if (userName) {
  2590. return name || userName;
  2591. }
  2592. return name;
  2593. });
  2594. if (realReddits.length > 0) {
  2595. for (const name of realReddits) {
  2596. prom.push(this.toggleTask({
  2597. name: name,
  2598. doTask: doTask
  2599. }));
  2600. await delay(1e3);
  2601. }
  2602. }
  2603. }
  2604. return await Promise.all(prom).then(() => true);
  2605. } catch (error) {
  2606. throwError(error, 'Reddit.toggle');
  2607. return false;
  2608. }
  2609. }
  2610. }
  2611. async function _useBeta2() {
  2612. try {
  2613. const logStatus = scripts_echoLog({
  2614. text: i18n('changingRedditVersion')
  2615. });
  2616. GM_setValue('redditAuth', null);
  2617. return await new Promise(resolve => {
  2618. const newTab = GM_openInTab('https://www.reddit.com/#auth', {
  2619. active: true,
  2620. insert: true,
  2621. setParent: true
  2622. });
  2623. newTab.onclose = async () => {
  2624. logStatus.success();
  2625. resolve(await Reddit_classPrivateMethodGet(this, Reddit_updateAuth, Reddit_updateAuth2).call(this, true));
  2626. };
  2627. });
  2628. } catch (error) {
  2629. throwError(error, 'Reddit.useBeta');
  2630. return false;
  2631. }
  2632. }
  2633. async function Reddit_updateAuth2() {
  2634. let beta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2635. try {
  2636. const logStatus = scripts_echoLog({
  2637. text: i18n('updatingAuth', 'Reddit')
  2638. });
  2639. const {
  2640. result,
  2641. statusText,
  2642. status,
  2643. data
  2644. } = await tools_httpRequest({
  2645. url: 'https://www.reddit.com/',
  2646. method: 'GET',
  2647. nochche: true,
  2648. headers: {
  2649. 'Cache-Control': 'no-cache'
  2650. }
  2651. });
  2652. if (result === 'Success') {
  2653. if (data !== null && data !== void 0 && data.responseText.includes('www.reddit.com/login/')) {
  2654. logStatus.error(`Error:${i18n('loginReddit')}`, true);
  2655. return false;
  2656. }
  2657. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2658. var _data$responseText$ma;
  2659. if (data.responseText.includes('redesign-beta-optin-btn') && !beta) {
  2660. return await Reddit_classPrivateMethodGet(this, _useBeta, _useBeta2).call(this);
  2661. }
  2662. const accessToken = (_data$responseText$ma = data.responseText.match(/"accessToken":"(.*?)","expires":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  2663. if (accessToken) {
  2664. Reddit_classPrivateFieldSet(this, Reddit_auth, {
  2665. token: accessToken
  2666. });
  2667. logStatus.success();
  2668. return true;
  2669. }
  2670. logStatus.error('Error: Parameter "accessToken" not found!');
  2671. return false;
  2672. }
  2673. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2674. return false;
  2675. }
  2676. logStatus.error(`${result}:${statusText}(${status})`);
  2677. return false;
  2678. } catch (error) {
  2679. throwError(error, 'Reddit.updateAuth');
  2680. return false;
  2681. }
  2682. }
  2683. const social_Reddit = Reddit;
  2684. function Twitch_classPrivateMethodInitSpec(obj, privateSet) {
  2685. Twitch_checkPrivateRedeclaration(obj, privateSet);
  2686. privateSet.add(obj);
  2687. }
  2688. function Twitch_classPrivateFieldInitSpec(obj, privateMap, value) {
  2689. Twitch_checkPrivateRedeclaration(obj, privateMap);
  2690. privateMap.set(obj, value);
  2691. }
  2692. function Twitch_checkPrivateRedeclaration(obj, privateCollection) {
  2693. if (privateCollection.has(obj)) {
  2694. throw new TypeError('Cannot initialize the same private elements twice on an object');
  2695. }
  2696. }
  2697. function Twitch_defineProperty(obj, key, value) {
  2698. if (key in obj) {
  2699. Object.defineProperty(obj, key, {
  2700. value: value,
  2701. enumerable: true,
  2702. configurable: true,
  2703. writable: true
  2704. });
  2705. } else {
  2706. obj[key] = value;
  2707. }
  2708. return obj;
  2709. }
  2710. function Twitch_classPrivateFieldSet(receiver, privateMap, value) {
  2711. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'set');
  2712. Twitch_classApplyDescriptorSet(receiver, descriptor, value);
  2713. return value;
  2714. }
  2715. function Twitch_classApplyDescriptorSet(receiver, descriptor, value) {
  2716. if (descriptor.set) {
  2717. descriptor.set.call(receiver, value);
  2718. } else {
  2719. if (!descriptor.writable) {
  2720. throw new TypeError('attempted to set read only private field');
  2721. }
  2722. descriptor.value = value;
  2723. }
  2724. }
  2725. function Twitch_classPrivateMethodGet(receiver, privateSet, fn) {
  2726. if (!privateSet.has(receiver)) {
  2727. throw new TypeError('attempted to get private field on non-instance');
  2728. }
  2729. return fn;
  2730. }
  2731. function Twitch_classPrivateFieldGet(receiver, privateMap) {
  2732. var descriptor = Twitch_classExtractFieldDescriptor(receiver, privateMap, 'get');
  2733. return Twitch_classApplyDescriptorGet(receiver, descriptor);
  2734. }
  2735. function Twitch_classExtractFieldDescriptor(receiver, privateMap, action) {
  2736. if (!privateMap.has(receiver)) {
  2737. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  2738. }
  2739. return privateMap.get(receiver);
  2740. }
  2741. function Twitch_classApplyDescriptorGet(receiver, descriptor) {
  2742. if (descriptor.get) {
  2743. return descriptor.get.call(receiver);
  2744. }
  2745. return descriptor.value;
  2746. }
  2747. const Twitch_defaultTasks = {
  2748. channels: []
  2749. };
  2750. var Twitch_auth = new WeakMap();
  2751. var Twitch_cache = new WeakMap();
  2752. var Twitch_initialized = new WeakMap();
  2753. var Twitch_verifyAuth = new WeakSet();
  2754. var Twitch_updateAuth = new WeakSet();
  2755. var _toggleChannel = new WeakSet();
  2756. var _getChannelId = new WeakSet();
  2757. var Twitch_setCache = new WeakSet();
  2758. class Twitch extends social_Social {
  2759. constructor() {
  2760. var _GM_getValue;
  2761. super(...arguments);
  2762. Twitch_classPrivateMethodInitSpec(this, Twitch_setCache);
  2763. Twitch_classPrivateMethodInitSpec(this, _getChannelId);
  2764. Twitch_classPrivateMethodInitSpec(this, _toggleChannel);
  2765. Twitch_classPrivateMethodInitSpec(this, Twitch_updateAuth);
  2766. Twitch_classPrivateMethodInitSpec(this, Twitch_verifyAuth);
  2767. Twitch_defineProperty(this, 'tasks', {
  2768. ...Twitch_defaultTasks
  2769. });
  2770. Twitch_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitch) || {
  2771. ...Twitch_defaultTasks
  2772. });
  2773. Twitch_classPrivateFieldInitSpec(this, Twitch_auth, {
  2774. writable: true,
  2775. value: GM_getValue('twitchAuth') || {}
  2776. });
  2777. Twitch_classPrivateFieldInitSpec(this, Twitch_cache, {
  2778. writable: true,
  2779. value: GM_getValue('twitchCache') || {}
  2780. });
  2781. Twitch_classPrivateFieldInitSpec(this, Twitch_initialized, {
  2782. writable: true,
  2783. value: false
  2784. });
  2785. }
  2786. async init() {
  2787. try {
  2788. if (Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2789. return true;
  2790. }
  2791. if (!Twitch_classPrivateFieldGet(this, Twitch_auth).authToken) {
  2792. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2793. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2794. return true;
  2795. }
  2796. return false;
  2797. }
  2798. const isVerified = await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this);
  2799. if (isVerified) {
  2800. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2801. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2802. return true;
  2803. }
  2804. GM_setValue('twitchAuth', null);
  2805. if (await Twitch_classPrivateMethodGet(this, Twitch_updateAuth, Twitch_updateAuth2).call(this)) {
  2806. scripts_echoLog({}).success(i18n('initSuccess', 'Twitch'));
  2807. Twitch_classPrivateFieldSet(this, Twitch_initialized, true);
  2808. return true;
  2809. }
  2810. scripts_echoLog({}).error(i18n('initFailed', 'Twitch'));
  2811. return false;
  2812. } catch (error) {
  2813. throwError(error, 'Twitch.init');
  2814. return false;
  2815. }
  2816. }
  2817. async toggle(_ref) {
  2818. let {
  2819. doTask = true,
  2820. channelLinks = []
  2821. } = _ref;
  2822. try {
  2823. if (!Twitch_classPrivateFieldGet(this, Twitch_initialized)) {
  2824. scripts_echoLog({
  2825. text: i18n('needInit')
  2826. });
  2827. return false;
  2828. }
  2829. const prom = [];
  2830. if (doTask && !globalOptions.doTask.twitch.channels || !doTask && !globalOptions.undoTask.twitch.channels) {
  2831. scripts_echoLog({
  2832. type: 'globalOptionsSkip',
  2833. text: 'twitch.channels'
  2834. });
  2835. } else {
  2836. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  2837. var _link$match;
  2838. return (_link$match = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[2];
  2839. });
  2840. if (realChannels.length > 0) {
  2841. for (const channel of realChannels) {
  2842. prom.push(Twitch_classPrivateMethodGet(this, _toggleChannel, _toggleChannel2).call(this, {
  2843. name: channel,
  2844. doTask: doTask
  2845. }));
  2846. await delay(1e3);
  2847. }
  2848. }
  2849. }
  2850. return Promise.all(prom).then(() => true);
  2851. } catch (error) {
  2852. throwError(error, 'Twitch.toggle');
  2853. return false;
  2854. }
  2855. }
  2856. }
  2857. async function Twitch_verifyAuth2() {
  2858. try {
  2859. const logStatus = scripts_echoLog({
  2860. text: i18n('verifyingAuth', 'Twitch')
  2861. });
  2862. const {
  2863. result,
  2864. statusText,
  2865. status,
  2866. data
  2867. } = await tools_httpRequest({
  2868. url: 'https://gql.twitch.tv/gql',
  2869. method: 'POST',
  2870. dataType: 'json',
  2871. headers: {
  2872. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2873. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2874. },
  2875. data: '[{"operationName":"FrontPageNew_User","variables":{"limit":1},"extensions":{"persistedQuery":{"version":1,' + '"sha256Hash":"64bd07a2cbaca80699d62636d966cf6395a5d14a1f0a14282067dcb28b13eb11"}}}]'
  2876. });
  2877. if (result === 'Success') {
  2878. var _data$response, _data$response$, _data$response$$data;
  2879. 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) {
  2880. logStatus.success();
  2881. return true;
  2882. }
  2883. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2884. return false;
  2885. }
  2886. logStatus.error(`${result}:${statusText}(${status})`);
  2887. return false;
  2888. } catch (error) {
  2889. throwError(error, 'Twitch.verifyAuth');
  2890. return false;
  2891. }
  2892. }
  2893. async function Twitch_updateAuth2() {
  2894. try {
  2895. const logStatus = scripts_echoLog({
  2896. text: i18n('updatingAuth', 'Twitch')
  2897. });
  2898. return await new Promise(resolve => {
  2899. const newTab = GM_openInTab('https://www.twitch.tv/#auth', {
  2900. active: true,
  2901. insert: true,
  2902. setParent: true
  2903. });
  2904. newTab.onclose = async () => {
  2905. const auth = GM_getValue('twitchAuth');
  2906. if (auth) {
  2907. Twitch_classPrivateFieldSet(this, Twitch_auth, auth);
  2908. logStatus.success();
  2909. resolve(await Twitch_classPrivateMethodGet(this, Twitch_verifyAuth, Twitch_verifyAuth2).call(this));
  2910. } else {
  2911. logStatus.error('Error: Update twitch auth failed!');
  2912. resolve(false);
  2913. }
  2914. };
  2915. });
  2916. } catch (error) {
  2917. throwError(error, 'Twitch.updateAuth');
  2918. return false;
  2919. }
  2920. }
  2921. async function _toggleChannel2(_ref2) {
  2922. let {
  2923. name,
  2924. doTask = true
  2925. } = _ref2;
  2926. try {
  2927. if (!doTask && this.whiteList.channels.includes(name)) {
  2928. scripts_echoLog({
  2929. type: 'whiteList',
  2930. text: 'Twitch.unfollowChannel',
  2931. id: name
  2932. });
  2933. return true;
  2934. }
  2935. const channelId = await Twitch_classPrivateMethodGet(this, _getChannelId, _getChannelId2).call(this, name);
  2936. if (!channelId) {
  2937. return false;
  2938. }
  2939. const logStatus = scripts_echoLog({
  2940. type: `${doTask ? '' : 'un'}followingTwitchChannel`,
  2941. text: name
  2942. });
  2943. const followData = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${channelId}` + '"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]';
  2944. const unfollowData = `[{"operationName":"FollowButton_UnfollowUser","variables":{"input":{"targetID":"${channelId}"}},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"d7fbdb4e9780dcdc0cc1618ec783309471cd05a59584fc3c56ea1c52bb632d41"}}}]';
  2945. const {
  2946. result,
  2947. statusText,
  2948. status,
  2949. data
  2950. } = await tools_httpRequest({
  2951. url: 'https://gql.twitch.tv/gql',
  2952. method: 'POST',
  2953. dataType: 'json',
  2954. headers: {
  2955. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`
  2956. },
  2957. data: doTask ? followData : unfollowData
  2958. });
  2959. if (result === 'Success') {
  2960. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  2961. logStatus.success();
  2962. if (doTask) {
  2963. this.tasks.channels = unique([ ...this.tasks.channels, name ]);
  2964. }
  2965. return true;
  2966. }
  2967. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  2968. return false;
  2969. }
  2970. logStatus.error(`${result}:${statusText}(${status})`);
  2971. return false;
  2972. } catch (error) {
  2973. throwError(error, 'Twitch.toggleChannel');
  2974. return false;
  2975. }
  2976. }
  2977. async function _getChannelId2(name) {
  2978. try {
  2979. const logStatus = scripts_echoLog({
  2980. type: 'gettingTwitchChannelId',
  2981. text: name
  2982. });
  2983. const channelId = Twitch_classPrivateFieldGet(this, Twitch_cache)[name];
  2984. if (channelId) {
  2985. logStatus.success();
  2986. return channelId;
  2987. }
  2988. const {
  2989. result,
  2990. statusText,
  2991. status,
  2992. data
  2993. } = await tools_httpRequest({
  2994. url: 'https://gql.twitch.tv/gql',
  2995. method: 'POST',
  2996. headers: {
  2997. Authorization: `OAuth ${Twitch_classPrivateFieldGet(this, Twitch_auth).authToken}`,
  2998. 'Client-Id': Twitch_classPrivateFieldGet(this, Twitch_auth).clientId
  2999. },
  3000. responseType: 'json',
  3001. data: `[{"operationName":"ActiveWatchParty","variables":{"channelLogin":"${name}"},` + '"extensions":{"persistedQuery":{"version":1,"sha256Hash":"4a8156c97b19e3a36e081cf6d6ddb5dbf9f9b02ae60e4d2ff26ed70aebc80a30"}}}]'
  3002. });
  3003. if (result === 'Success') {
  3004. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3005. var _data$response2, _data$response2$, _data$response2$$data, _data$response2$$data2;
  3006. 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);
  3007. if (channelId) {
  3008. Twitch_classPrivateMethodGet(this, Twitch_setCache, Twitch_setCache2).call(this, name, channelId);
  3009. logStatus.success();
  3010. return channelId;
  3011. }
  3012. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3013. return false;
  3014. }
  3015. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3016. return false;
  3017. }
  3018. logStatus.error(`${result}:${statusText}(${status})`);
  3019. return false;
  3020. } catch (error) {
  3021. throwError(error, 'Twitch.getChannelId');
  3022. return false;
  3023. }
  3024. }
  3025. function Twitch_setCache2(name, id) {
  3026. try {
  3027. Twitch_classPrivateFieldGet(this, Twitch_cache)[name] = id;
  3028. GM_setValue('twitchCache', Twitch_classPrivateFieldGet(this, Twitch_cache));
  3029. } catch (error) {
  3030. throwError(error, 'Twitch.setCache');
  3031. }
  3032. }
  3033. const social_Twitch = Twitch;
  3034. function Twitter_classPrivateMethodInitSpec(obj, privateSet) {
  3035. Twitter_checkPrivateRedeclaration(obj, privateSet);
  3036. privateSet.add(obj);
  3037. }
  3038. function Twitter_classPrivateFieldInitSpec(obj, privateMap, value) {
  3039. Twitter_checkPrivateRedeclaration(obj, privateMap);
  3040. privateMap.set(obj, value);
  3041. }
  3042. function Twitter_checkPrivateRedeclaration(obj, privateCollection) {
  3043. if (privateCollection.has(obj)) {
  3044. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3045. }
  3046. }
  3047. function Twitter_defineProperty(obj, key, value) {
  3048. if (key in obj) {
  3049. Object.defineProperty(obj, key, {
  3050. value: value,
  3051. enumerable: true,
  3052. configurable: true,
  3053. writable: true
  3054. });
  3055. } else {
  3056. obj[key] = value;
  3057. }
  3058. return obj;
  3059. }
  3060. function Twitter_classPrivateFieldSet(receiver, privateMap, value) {
  3061. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3062. Twitter_classApplyDescriptorSet(receiver, descriptor, value);
  3063. return value;
  3064. }
  3065. function Twitter_classApplyDescriptorSet(receiver, descriptor, value) {
  3066. if (descriptor.set) {
  3067. descriptor.set.call(receiver, value);
  3068. } else {
  3069. if (!descriptor.writable) {
  3070. throw new TypeError('attempted to set read only private field');
  3071. }
  3072. descriptor.value = value;
  3073. }
  3074. }
  3075. function Twitter_classPrivateMethodGet(receiver, privateSet, fn) {
  3076. if (!privateSet.has(receiver)) {
  3077. throw new TypeError('attempted to get private field on non-instance');
  3078. }
  3079. return fn;
  3080. }
  3081. function Twitter_classPrivateFieldGet(receiver, privateMap) {
  3082. var descriptor = Twitter_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3083. return Twitter_classApplyDescriptorGet(receiver, descriptor);
  3084. }
  3085. function Twitter_classExtractFieldDescriptor(receiver, privateMap, action) {
  3086. if (!privateMap.has(receiver)) {
  3087. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3088. }
  3089. return privateMap.get(receiver);
  3090. }
  3091. function Twitter_classApplyDescriptorGet(receiver, descriptor) {
  3092. if (descriptor.get) {
  3093. return descriptor.get.call(receiver);
  3094. }
  3095. return descriptor.value;
  3096. }
  3097. const Twitter_defaultTasks = {
  3098. users: [],
  3099. retweets: [],
  3100. likes: []
  3101. };
  3102. var _verifyId = new WeakMap();
  3103. var Twitter_auth = new WeakMap();
  3104. var Twitter_cache = new WeakMap();
  3105. var Twitter_initialized = new WeakMap();
  3106. var Twitter_verifyAuth = new WeakSet();
  3107. var Twitter_updateAuth = new WeakSet();
  3108. var _toggleUser = new WeakSet();
  3109. var _toggleRetweet = new WeakSet();
  3110. var Twitter_setCache = new WeakSet();
  3111. class Twitter extends social_Social {
  3112. constructor() {
  3113. var _GM_getValue;
  3114. super(...arguments);
  3115. Twitter_classPrivateMethodInitSpec(this, Twitter_setCache);
  3116. Twitter_classPrivateMethodInitSpec(this, _toggleRetweet);
  3117. Twitter_classPrivateMethodInitSpec(this, _toggleUser);
  3118. Twitter_classPrivateMethodInitSpec(this, Twitter_updateAuth);
  3119. Twitter_classPrivateMethodInitSpec(this, Twitter_verifyAuth);
  3120. Twitter_defineProperty(this, 'tasks', {
  3121. ...Twitter_defaultTasks
  3122. });
  3123. Twitter_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.twitter) || {
  3124. ...Twitter_defaultTasks
  3125. });
  3126. Twitter_classPrivateFieldInitSpec(this, _verifyId, {
  3127. writable: true,
  3128. value: globalOptions.other.twitterVerifyId
  3129. });
  3130. Twitter_classPrivateFieldInitSpec(this, Twitter_auth, {
  3131. writable: true,
  3132. value: GM_getValue('twitterAuth') || {}
  3133. });
  3134. Twitter_classPrivateFieldInitSpec(this, Twitter_cache, {
  3135. writable: true,
  3136. value: GM_getValue('twitterCache') || {}
  3137. });
  3138. Twitter_classPrivateFieldInitSpec(this, Twitter_initialized, {
  3139. writable: true,
  3140. value: false
  3141. });
  3142. }
  3143. async init() {
  3144. try {
  3145. if (Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3146. return true;
  3147. }
  3148. if (!Twitter_classPrivateFieldGet(this, Twitter_auth).ct0) {
  3149. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3150. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3151. return true;
  3152. }
  3153. return false;
  3154. }
  3155. const isVerified = await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this);
  3156. if (isVerified) {
  3157. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3158. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3159. return true;
  3160. }
  3161. GM_setValue('twitterAuth', null);
  3162. if (await Twitter_classPrivateMethodGet(this, Twitter_updateAuth, Twitter_updateAuth2).call(this)) {
  3163. scripts_echoLog({}).success(i18n('initSuccess', 'Twitter'));
  3164. Twitter_classPrivateFieldSet(this, Twitter_initialized, true);
  3165. return true;
  3166. }
  3167. scripts_echoLog({}).error(i18n('initFailed', 'Twitter'));
  3168. return false;
  3169. } catch (error) {
  3170. throwError(error, 'Twitter.init');
  3171. return false;
  3172. }
  3173. }
  3174. async userName2id(name) {
  3175. try {
  3176. const logStatus = scripts_echoLog({
  3177. type: 'gettingTwitterUserId',
  3178. text: name
  3179. });
  3180. const userId = Twitter_classPrivateFieldGet(this, Twitter_cache)[name];
  3181. if (userId) {
  3182. logStatus.success();
  3183. return userId;
  3184. }
  3185. const {
  3186. result,
  3187. statusText,
  3188. status,
  3189. data
  3190. } = await tools_httpRequest({
  3191. url: 'https://api.twitter.com/graphql/-xfUfZsnR_zqjFd-IfrN5A/UserByScreenName' + `?variables=%7B%22screen_name%22%3A%22${name}%22%2C%22withHighlightedLabel%22%3Atrue%7D`,
  3192. method: 'GET',
  3193. headers: {
  3194. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3195. 'content-type': 'application/json'
  3196. },
  3197. responseType: 'json',
  3198. anonymous: true
  3199. });
  3200. if (result === 'Success') {
  3201. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3202. var _response, _response$data, _response$data$user;
  3203. let response = data.response || (typeof data.responseText === 'object' ? data.responseText : null);
  3204. if (!response) {
  3205. try {
  3206. response = JSON.parse(data.responseText);
  3207. } catch (error) {
  3208. response = null;
  3209. }
  3210. }
  3211. const userId = String((_response = response) === null || _response === void 0 ? void 0 : (_response$data = _response.data) === null || _response$data === void 0 ? void 0 : (_response$data$user = _response$data.user) === null || _response$data$user === void 0 ? void 0 : _response$data$user.rest_id);
  3212. if (userId) {
  3213. Twitter_classPrivateMethodGet(this, Twitter_setCache, Twitter_setCache2).call(this, name, userId);
  3214. logStatus.success();
  3215. return userId;
  3216. }
  3217. logStatus.error(`Error:${data.statusText}(${data.status})`);
  3218. return false;
  3219. }
  3220. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3221. return false;
  3222. }
  3223. logStatus.error(`${result}:${statusText}(${status})`);
  3224. return false;
  3225. } catch (error) {
  3226. throwError(error, 'Twitter.getUserId');
  3227. return false;
  3228. }
  3229. }
  3230. async toggle(_ref) {
  3231. let {
  3232. doTask = true,
  3233. userLinks = [],
  3234. retweetLinks = []
  3235. } = _ref;
  3236. try {
  3237. if (!Twitter_classPrivateFieldGet(this, Twitter_initialized)) {
  3238. scripts_echoLog({
  3239. text: i18n('needInit')
  3240. });
  3241. return false;
  3242. }
  3243. const prom = [];
  3244. if (doTask && !globalOptions.doTask.twitter.users || !doTask && !globalOptions.undoTask.twitter.users) {
  3245. scripts_echoLog({
  3246. type: 'globalOptionsSkip',
  3247. text: 'twitter.users'
  3248. });
  3249. } else {
  3250. const realUsers = this.getRealParams('users', userLinks, doTask, link => {
  3251. var _link$match;
  3252. return (_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3253. });
  3254. if (realUsers.length > 0) {
  3255. for (const user of realUsers) {
  3256. prom.push(Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3257. name: user,
  3258. doTask: doTask
  3259. }));
  3260. await delay(1e3);
  3261. }
  3262. }
  3263. }
  3264. if (doTask && !globalOptions.doTask.twitter.retweets || !doTask && !globalOptions.undoTask.twitter.retweets) {
  3265. scripts_echoLog({
  3266. type: 'globalOptionsSkip',
  3267. text: 'twitter.retweets'
  3268. });
  3269. } else {
  3270. const realRetweets = this.getRealParams('retweets', retweetLinks, doTask, link => {
  3271. var _link$match2;
  3272. return (_link$match2 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  3273. });
  3274. if (realRetweets.length > 0) {
  3275. for (const retweet of realRetweets) {
  3276. prom.push(Twitter_classPrivateMethodGet(this, _toggleRetweet, _toggleRetweet2).call(this, {
  3277. retweetId: retweet,
  3278. doTask: doTask
  3279. }));
  3280. await delay(1e3);
  3281. }
  3282. }
  3283. }
  3284. return Promise.all(prom).then(() => true);
  3285. } catch (error) {
  3286. throwError(error, 'Twitter.toggle');
  3287. return false;
  3288. }
  3289. }
  3290. }
  3291. async function Twitter_verifyAuth2() {
  3292. try {
  3293. return await Twitter_classPrivateMethodGet(this, _toggleUser, _toggleUser2).call(this, {
  3294. name: 'verify',
  3295. doTask: true,
  3296. verify: true
  3297. });
  3298. } catch (error) {
  3299. throwError(error, 'Twitter.verifyAuth');
  3300. return false;
  3301. }
  3302. }
  3303. async function Twitter_updateAuth2() {
  3304. try {
  3305. const logStatus = scripts_echoLog({
  3306. text: i18n('updatingAuth', 'Twitter')
  3307. });
  3308. return await new Promise(resolve => {
  3309. const newTab = GM_openInTab('https://twitter.com/settings/account?k#auth', {
  3310. active: true,
  3311. insert: true,
  3312. setParent: true
  3313. });
  3314. newTab.onclose = async () => {
  3315. const auth = GM_getValue('twitterAuth');
  3316. if (auth) {
  3317. Twitter_classPrivateFieldSet(this, Twitter_auth, auth);
  3318. logStatus.success();
  3319. resolve(await Twitter_classPrivateMethodGet(this, Twitter_verifyAuth, Twitter_verifyAuth2).call(this));
  3320. } else {
  3321. logStatus.error('Error: Update twitter auth failed!');
  3322. resolve(false);
  3323. }
  3324. };
  3325. });
  3326. } catch (error) {
  3327. throwError(error, 'Twitter.updateToken');
  3328. return false;
  3329. }
  3330. }
  3331. async function _toggleUser2(_ref2) {
  3332. let {
  3333. name,
  3334. doTask = true,
  3335. verify = false
  3336. } = _ref2;
  3337. try {
  3338. if (!doTask && !verify && this.whiteList.users.includes(name)) {
  3339. scripts_echoLog({
  3340. type: 'whiteList',
  3341. text: 'Twitter.unfollowUser',
  3342. id: name
  3343. });
  3344. return true;
  3345. }
  3346. const userId = verify ? Twitter_classPrivateFieldGet(this, _verifyId) : await this.userName2id(name);
  3347. if (!userId) {
  3348. return false;
  3349. }
  3350. const logStatus = verify ? scripts_echoLog({
  3351. text: i18n('verifyingAuth', 'Twitter')
  3352. }) : scripts_echoLog({
  3353. type: `${doTask ? '' : 'un'}followingTwitterUser`,
  3354. text: name
  3355. });
  3356. const {
  3357. result,
  3358. statusText,
  3359. status,
  3360. data
  3361. } = await tools_httpRequest({
  3362. url: `https://api.twitter.com/1.1/friendships/${doTask ? 'create' : 'destroy'}.json`,
  3363. method: 'POST',
  3364. headers: {
  3365. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3366. 'Content-Type': 'application/x-www-form-urlencoded',
  3367. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3368. },
  3369. responseType: 'json',
  3370. data: $.param({
  3371. include_profile_interstitial_type: 1,
  3372. include_blocking: 1,
  3373. include_blocked_by: 1,
  3374. include_followed_by: 1,
  3375. include_want_retweets: 1,
  3376. include_mute_edge: 1,
  3377. include_can_dm: 1,
  3378. include_can_media_tag: 1,
  3379. skip_status: 1,
  3380. id: userId
  3381. })
  3382. });
  3383. if (result === 'Success') {
  3384. var _data$response, _data$response$errors, _data$response$errors2;
  3385. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3386. logStatus.success();
  3387. if (doTask && !verify) {
  3388. this.tasks.users = unique([ ...this.tasks.users, name ]);
  3389. }
  3390. return true;
  3391. }
  3392. 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) {
  3393. logStatus.success();
  3394. return true;
  3395. }
  3396. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3397. return false;
  3398. }
  3399. logStatus.error(`${result}:${statusText}(${status})`);
  3400. return false;
  3401. } catch (error) {
  3402. throwError(error, 'Twitter.toggleUser');
  3403. return false;
  3404. }
  3405. }
  3406. async function _toggleRetweet2(_ref3) {
  3407. let {
  3408. retweetId,
  3409. doTask = true
  3410. } = _ref3;
  3411. try {
  3412. if (!doTask && this.whiteList.retweets.includes(retweetId)) {
  3413. scripts_echoLog({
  3414. type: 'whiteList',
  3415. text: 'Twitter.unretweet',
  3416. id: retweetId
  3417. });
  3418. return true;
  3419. }
  3420. const logStatus = scripts_echoLog({
  3421. type: `${doTask ? '' : 'un'}retweetting`,
  3422. text: retweetId
  3423. });
  3424. const {
  3425. result,
  3426. statusText,
  3427. status,
  3428. data
  3429. } = await tools_httpRequest({
  3430. url: `https://api.twitter.com/1.1/statuses/${doTask ? '' : 'un'}retweet.json`,
  3431. method: 'POST',
  3432. headers: {
  3433. authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  3434. 'Content-Type': 'application/x-www-form-urlencoded',
  3435. 'x-csrf-token': Twitter_classPrivateFieldGet(this, Twitter_auth).ct0
  3436. },
  3437. data: $.param({
  3438. tweet_mode: 'extended',
  3439. id: retweetId
  3440. }),
  3441. responseType: 'json'
  3442. });
  3443. if (result === 'Success') {
  3444. var _data$response2, _data$response2$error, _data$response2$error2;
  3445. 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) {
  3446. logStatus.success();
  3447. if (doTask) {
  3448. this.tasks.retweets = unique([ ...this.tasks.retweets, retweetId ]);
  3449. }
  3450. return true;
  3451. }
  3452. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3453. return false;
  3454. }
  3455. logStatus.error(`${result}:${statusText}(${status})`);
  3456. return false;
  3457. } catch (error) {
  3458. throwError(error, 'Twitter.toggleRetweet');
  3459. return false;
  3460. }
  3461. }
  3462. function Twitter_setCache2(name, id) {
  3463. try {
  3464. Twitter_classPrivateFieldGet(this, Twitter_cache)[name] = id;
  3465. GM_setValue('twitterCache', Twitter_classPrivateFieldGet(this, Twitter_cache));
  3466. } catch (error) {
  3467. throwError(error, 'Twitter.setCache');
  3468. }
  3469. }
  3470. const social_Twitter = Twitter;
  3471. function Vk_classPrivateMethodInitSpec(obj, privateSet) {
  3472. Vk_checkPrivateRedeclaration(obj, privateSet);
  3473. privateSet.add(obj);
  3474. }
  3475. function Vk_classPrivateFieldInitSpec(obj, privateMap, value) {
  3476. Vk_checkPrivateRedeclaration(obj, privateMap);
  3477. privateMap.set(obj, value);
  3478. }
  3479. function Vk_checkPrivateRedeclaration(obj, privateCollection) {
  3480. if (privateCollection.has(obj)) {
  3481. throw new TypeError('Cannot initialize the same private elements twice on an object');
  3482. }
  3483. }
  3484. function Vk_defineProperty(obj, key, value) {
  3485. if (key in obj) {
  3486. Object.defineProperty(obj, key, {
  3487. value: value,
  3488. enumerable: true,
  3489. configurable: true,
  3490. writable: true
  3491. });
  3492. } else {
  3493. obj[key] = value;
  3494. }
  3495. return obj;
  3496. }
  3497. function Vk_classPrivateFieldSet(receiver, privateMap, value) {
  3498. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'set');
  3499. Vk_classApplyDescriptorSet(receiver, descriptor, value);
  3500. return value;
  3501. }
  3502. function Vk_classApplyDescriptorSet(receiver, descriptor, value) {
  3503. if (descriptor.set) {
  3504. descriptor.set.call(receiver, value);
  3505. } else {
  3506. if (!descriptor.writable) {
  3507. throw new TypeError('attempted to set read only private field');
  3508. }
  3509. descriptor.value = value;
  3510. }
  3511. }
  3512. function Vk_classPrivateMethodGet(receiver, privateSet, fn) {
  3513. if (!privateSet.has(receiver)) {
  3514. throw new TypeError('attempted to get private field on non-instance');
  3515. }
  3516. return fn;
  3517. }
  3518. function Vk_classPrivateFieldGet(receiver, privateMap) {
  3519. var descriptor = Vk_classExtractFieldDescriptor(receiver, privateMap, 'get');
  3520. return Vk_classApplyDescriptorGet(receiver, descriptor);
  3521. }
  3522. function Vk_classExtractFieldDescriptor(receiver, privateMap, action) {
  3523. if (!privateMap.has(receiver)) {
  3524. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  3525. }
  3526. return privateMap.get(receiver);
  3527. }
  3528. function Vk_classApplyDescriptorGet(receiver, descriptor) {
  3529. if (descriptor.get) {
  3530. return descriptor.get.call(receiver);
  3531. }
  3532. return descriptor.value;
  3533. }
  3534. const Vk_defaultTasks = {
  3535. names: []
  3536. };
  3537. var _username = new WeakMap();
  3538. var Vk_cache = new WeakMap();
  3539. var Vk_initialized = new WeakMap();
  3540. var Vk_verifyAuth = new WeakSet();
  3541. var _toggleGroup = new WeakSet();
  3542. var _togglePublic = new WeakSet();
  3543. var _sendWall = new WeakSet();
  3544. var _deleteWall = new WeakSet();
  3545. var _getId = new WeakSet();
  3546. var _toggleVk = new WeakSet();
  3547. var Vk_setCache = new WeakSet();
  3548. class Vk extends social_Social {
  3549. constructor() {
  3550. var _GM_getValue;
  3551. super(...arguments);
  3552. Vk_classPrivateMethodInitSpec(this, Vk_setCache);
  3553. Vk_classPrivateMethodInitSpec(this, _toggleVk);
  3554. Vk_classPrivateMethodInitSpec(this, _getId);
  3555. Vk_classPrivateMethodInitSpec(this, _deleteWall);
  3556. Vk_classPrivateMethodInitSpec(this, _sendWall);
  3557. Vk_classPrivateMethodInitSpec(this, _togglePublic);
  3558. Vk_classPrivateMethodInitSpec(this, _toggleGroup);
  3559. Vk_classPrivateMethodInitSpec(this, Vk_verifyAuth);
  3560. Vk_defineProperty(this, 'tasks', {
  3561. ...Vk_defaultTasks
  3562. });
  3563. Vk_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.vk) || {
  3564. ...Vk_defaultTasks
  3565. });
  3566. Vk_classPrivateFieldInitSpec(this, _username, {
  3567. writable: true,
  3568. value: ''
  3569. });
  3570. Vk_classPrivateFieldInitSpec(this, Vk_cache, {
  3571. writable: true,
  3572. value: GM_getValue('vkCache') || {}
  3573. });
  3574. Vk_classPrivateFieldInitSpec(this, Vk_initialized, {
  3575. writable: true,
  3576. value: false
  3577. });
  3578. }
  3579. async init() {
  3580. try {
  3581. if (Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3582. return true;
  3583. }
  3584. const isVerified = await Vk_classPrivateMethodGet(this, Vk_verifyAuth, Vk_verifyAuth2).call(this);
  3585. if (isVerified) {
  3586. scripts_echoLog({}).success(i18n('initSuccess', 'Vk'));
  3587. Vk_classPrivateFieldSet(this, Vk_initialized, true);
  3588. return true;
  3589. }
  3590. scripts_echoLog({}).error(i18n('initFailed', 'Vk'));
  3591. return false;
  3592. } catch (error) {
  3593. throwError(error, 'Vk.init');
  3594. return false;
  3595. }
  3596. }
  3597. async toggle(_ref) {
  3598. let {
  3599. doTask = true,
  3600. nameLinks = []
  3601. } = _ref;
  3602. try {
  3603. if (!Vk_classPrivateFieldGet(this, Vk_initialized)) {
  3604. scripts_echoLog({
  3605. text: i18n('needInit')
  3606. });
  3607. return false;
  3608. }
  3609. const prom = [];
  3610. if (doTask && !globalOptions.doTask.vk.names || !doTask && !globalOptions.undoTask.vk.names) {
  3611. scripts_echoLog({
  3612. type: 'globalOptionsSkip',
  3613. text: 'vk.names'
  3614. });
  3615. } else {
  3616. const realNames = this.getRealParams('names', nameLinks, doTask, link => {
  3617. var _link$match;
  3618. return (_link$match = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  3619. });
  3620. if (realNames.length > 0) {
  3621. for (const name of realNames) {
  3622. prom.push(Vk_classPrivateMethodGet(this, _toggleVk, _toggleVk2).call(this, {
  3623. name: name,
  3624. doTask: doTask
  3625. }));
  3626. await delay(1e3);
  3627. }
  3628. }
  3629. }
  3630. return Promise.all(prom).then(() => true);
  3631. } catch (error) {
  3632. throwError(error, 'Vk.toggle');
  3633. return false;
  3634. }
  3635. }
  3636. }
  3637. async function Vk_verifyAuth2() {
  3638. try {
  3639. const logStatus = scripts_echoLog({
  3640. text: i18n('verifyAuth', 'Vk')
  3641. });
  3642. const {
  3643. result,
  3644. statusText,
  3645. status,
  3646. data
  3647. } = await tools_httpRequest({
  3648. url: 'https://vk.com/im',
  3649. method: 'GET'
  3650. });
  3651. if (result === 'Success') {
  3652. if (data !== null && data !== void 0 && data.finalUrl.includes('vk.com/login')) {
  3653. logStatus.error(`Error:${i18n('loginVk')}`, true);
  3654. return false;
  3655. }
  3656. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3657. var _data$responseText$ma;
  3658. Vk_classPrivateFieldSet(this, _username, ((_data$responseText$ma = data.responseText.match(/TopNavBtn__profileLink" href="\/(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1]) || '');
  3659. logStatus.success();
  3660. return true;
  3661. }
  3662. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3663. return false;
  3664. }
  3665. logStatus.error(`${result}:${statusText}(${status})`);
  3666. return false;
  3667. } catch (error) {
  3668. throwError(error, 'Vk.verifyAuth');
  3669. return false;
  3670. }
  3671. }
  3672. async function _toggleGroup2(name, dataParam) {
  3673. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3674. try {
  3675. const logStatus = scripts_echoLog({
  3676. type: doTask ? 'joiningVkGroup' : 'leavingVkGroup',
  3677. text: name
  3678. });
  3679. if (dataParam.groupAct === 'enter' && !doTask || dataParam.groupAct === 'leave' && doTask) {
  3680. logStatus.success();
  3681. return true;
  3682. }
  3683. const reqData = {
  3684. act: doTask ? 'enter' : 'leave',
  3685. al: 1,
  3686. gid: dataParam.groupId,
  3687. hash: dataParam.groupHash
  3688. };
  3689. if (doTask) {
  3690. reqData.context = '_';
  3691. }
  3692. const {
  3693. result,
  3694. statusText,
  3695. status,
  3696. data
  3697. } = await tools_httpRequest({
  3698. url: 'https://vk.com/al_groups.php',
  3699. method: 'POST',
  3700. headers: {
  3701. origin: 'https://vk.com',
  3702. referer: `https://vk.com/${name}`,
  3703. 'content-type': 'application/x-www-form-urlencoded'
  3704. },
  3705. data: $.param(reqData)
  3706. });
  3707. if (result === 'Success') {
  3708. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3709. logStatus.success();
  3710. if (doTask) {
  3711. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3712. }
  3713. return true;
  3714. }
  3715. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3716. return false;
  3717. }
  3718. logStatus.error(`${result}:${statusText}(${status})`);
  3719. return false;
  3720. } catch (error) {
  3721. throwError(error, 'Vk.toggleGroup');
  3722. return false;
  3723. }
  3724. }
  3725. async function _togglePublic2(name, dataParam) {
  3726. let doTask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3727. try {
  3728. const logStatus = scripts_echoLog({
  3729. type: doTask ? 'joiningVkPublic' : 'leavingVkPublic',
  3730. text: name
  3731. });
  3732. if (dataParam.publicJoined && doTask || !dataParam.publicJoined && !doTask) {
  3733. logStatus.success();
  3734. return true;
  3735. }
  3736. const {
  3737. result,
  3738. statusText,
  3739. status,
  3740. data
  3741. } = await tools_httpRequest({
  3742. url: 'https://vk.com/al_public.php',
  3743. method: 'POST',
  3744. headers: {
  3745. origin: 'https://vk.com',
  3746. referer: `https://vk.com/${name}`,
  3747. 'content-type': 'application/x-www-form-urlencoded'
  3748. },
  3749. data: $.param({
  3750. act: doTask ? 'a_enter' : 'a_leave',
  3751. al: 1,
  3752. pid: dataParam.publicPid,
  3753. hash: dataParam.publicHash
  3754. })
  3755. });
  3756. if (result === 'Success') {
  3757. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3758. logStatus.success();
  3759. if (doTask) {
  3760. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3761. }
  3762. return true;
  3763. }
  3764. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3765. return false;
  3766. }
  3767. logStatus.error(`${result}:${statusText}(${status})`);
  3768. return false;
  3769. } catch (error) {
  3770. throwError(error, 'Vk.togglePublic');
  3771. return false;
  3772. }
  3773. }
  3774. async function _sendWall2(name) {
  3775. try {
  3776. const logStatus = scripts_echoLog({
  3777. type: 'sendingVkWall',
  3778. text: name
  3779. });
  3780. const {
  3781. result,
  3782. statusText,
  3783. status,
  3784. data
  3785. } = await tools_httpRequest({
  3786. url: 'https://vk.com/like.php',
  3787. method: 'POST',
  3788. headers: {
  3789. origin: 'https://vk.com',
  3790. referer: `https://vk.com/${name}`,
  3791. 'content-type': 'application/x-www-form-urlencoded'
  3792. },
  3793. data: $.param({
  3794. act: 'publish_box',
  3795. al: 1,
  3796. object: name
  3797. })
  3798. });
  3799. if (result === 'Success') {
  3800. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3801. var _data$responseText$ma2;
  3802. const hash = (_data$responseText$ma2 = data.responseText.match(/shHash:[\s]*'(.*?)'/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  3803. if (hash) {
  3804. const {
  3805. result: resultR,
  3806. statusText: statusTextR,
  3807. status: statusR,
  3808. data: dataR
  3809. } = await tools_httpRequest({
  3810. url: 'https://vk.com/like.php',
  3811. method: 'POST',
  3812. headers: {
  3813. origin: 'https://vk.com',
  3814. referer: `https://vk.com/${name}`,
  3815. 'content-type': 'application/x-www-form-urlencoded'
  3816. },
  3817. data: $.param({
  3818. Message: '',
  3819. act: 'a_do_publish',
  3820. al: 1,
  3821. close_comments: 0,
  3822. friends_only: 0,
  3823. from: 'box',
  3824. hash: hash,
  3825. list: '',
  3826. mark_as_ads: 0,
  3827. mute_notifications: 0,
  3828. object: name,
  3829. ret_data: 1,
  3830. to: 0
  3831. })
  3832. });
  3833. if (resultR === 'Success') {
  3834. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  3835. var _dataR$responseText, _jsonData$payload, _jsonData$payload$, _jsonData$payload$$;
  3836. const jsonData = JSON.parse(((_dataR$responseText = dataR.responseText) === null || _dataR$responseText === void 0 ? void 0 : _dataR$responseText.replace('\x3c!--', '')) || '{}');
  3837. if ((jsonData === null || jsonData === void 0 ? void 0 : (_jsonData$payload = jsonData.payload) === null || _jsonData$payload === void 0 ? void 0 : (_jsonData$payload$ = _jsonData$payload[1]) === null || _jsonData$payload$ === void 0 ? void 0 : (_jsonData$payload$$ = _jsonData$payload$[1]) === null || _jsonData$payload$$ === void 0 ? void 0 : _jsonData$payload$$.share_my) === true) {
  3838. var _jsonData$payload2, _jsonData$payload2$, _jsonData$payload2$$, _jsonData$payload3, _jsonData$payload3$, _jsonData$payload3$$;
  3839. logStatus.success();
  3840. const postId = String(jsonData === null || jsonData === void 0 ? void 0 : (_jsonData$payload2 = jsonData.payload) === null || _jsonData$payload2 === void 0 ? void 0 : (_jsonData$payload2$ = _jsonData$payload2[1]) === null || _jsonData$payload2$ === void 0 ? void 0 : (_jsonData$payload2$$ = _jsonData$payload2$[1]) === null || _jsonData$payload2$$ === void 0 ? void 0 : _jsonData$payload2$$.post_id);
  3841. const ownerId = String(jsonData === null || jsonData === void 0 ? void 0 : (_jsonData$payload3 = jsonData.payload) === null || _jsonData$payload3 === void 0 ? void 0 : (_jsonData$payload3$ = _jsonData$payload3[1]) === null || _jsonData$payload3$ === void 0 ? void 0 : (_jsonData$payload3$$ = _jsonData$payload3$[1]) === null || _jsonData$payload3$$ === void 0 ? void 0 : _jsonData$payload3$$.owner_id);
  3842. if (postId && ownerId) {
  3843. Vk_classPrivateMethodGet(this, Vk_setCache, Vk_setCache2).call(this, name, `${ownerId}_${postId}`);
  3844. }
  3845. this.tasks.names = unique([ ...this.tasks.names, name ]);
  3846. return true;
  3847. }
  3848. }
  3849. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  3850. return false;
  3851. }
  3852. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  3853. return false;
  3854. }
  3855. logStatus.error('Error: Get "hash" failed');
  3856. return false;
  3857. }
  3858. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3859. return false;
  3860. }
  3861. logStatus.error(`${result}:${statusText}(${status})`);
  3862. return false;
  3863. } catch (error) {
  3864. throwError(error, 'Vk.sendWall');
  3865. return false;
  3866. }
  3867. }
  3868. async function _deleteWall2(name, dataParams) {
  3869. try {
  3870. const logStatus = scripts_echoLog({
  3871. type: 'deletingVkWall',
  3872. text: name
  3873. });
  3874. const {
  3875. result,
  3876. statusText,
  3877. status,
  3878. data
  3879. } = await tools_httpRequest({
  3880. url: 'https://vk.com/al_wall.php?act=delete',
  3881. method: 'POST',
  3882. headers: {
  3883. origin: 'https://vk.com',
  3884. referer: `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}%2Fall`,
  3885. 'content-type': 'application/x-www-form-urlencoded'
  3886. },
  3887. data: $.param({
  3888. act: 'delete',
  3889. al: 1,
  3890. confirm: 0,
  3891. from: 'wkview',
  3892. hash: dataParams.wallHash,
  3893. post: Vk_classPrivateFieldGet(this, Vk_cache)[name]
  3894. })
  3895. });
  3896. if (result === 'Success') {
  3897. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3898. var _data$responseText, _jsonData$payload4, _jsonData$payload4$;
  3899. const jsonData = JSON.parse(((_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : _data$responseText.replace('\x3c!--', '')) || '{}');
  3900. if (jsonData !== null && jsonData !== void 0 && (_jsonData$payload4 = jsonData.payload) !== null && _jsonData$payload4 !== void 0 && (_jsonData$payload4$ = _jsonData$payload4[1]) !== null && _jsonData$payload4$ !== void 0 && _jsonData$payload4$[1]) {
  3901. logStatus.success();
  3902. return true;
  3903. }
  3904. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3905. return false;
  3906. }
  3907. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3908. return false;
  3909. }
  3910. logStatus.error(`${result}:${statusText}(${status})`);
  3911. return false;
  3912. } catch (error) {
  3913. throwError(error, 'Vk.deleteWall');
  3914. return false;
  3915. }
  3916. }
  3917. async function _getId2(name, doTask) {
  3918. try {
  3919. let url = `https://vk.com/${name}`;
  3920. if (/^wall-/.test(name)) {
  3921. if (doTask) {
  3922. return {
  3923. type: 'sendWall'
  3924. };
  3925. }
  3926. if (!Vk_classPrivateFieldGet(this, Vk_cache)[name]) {
  3927. return {
  3928. type: 'unSupport'
  3929. };
  3930. }
  3931. url = `https://vk.com/${Vk_classPrivateFieldGet(this, _username)}?w=wall${Vk_classPrivateFieldGet(this, Vk_cache)[name]}`;
  3932. }
  3933. const logStatus = scripts_echoLog({
  3934. type: 'gettingVkId',
  3935. text: name
  3936. });
  3937. const {
  3938. result,
  3939. statusText,
  3940. status,
  3941. data
  3942. } = await tools_httpRequest({
  3943. url: url,
  3944. method: 'GET'
  3945. });
  3946. if (result === 'Success') {
  3947. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  3948. var _data$responseText$ma3, _data$responseText$ma4;
  3949. const [ , groupAct, groupId, groupHash ] = data.responseText.match(/Groups.(enter|leave)\(.*?,.*?([\d]+?), '(.*?)'/) || [];
  3950. const publicHash = (_data$responseText$ma3 = data.responseText.match(/"enterHash":"(.*?)"/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  3951. const publicPid = (_data$responseText$ma4 = data.responseText.match(/"public_id":([\d]+?),/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  3952. const publicJoined = !data.responseText.includes('Public.subscribe');
  3953. if (groupAct && groupId && groupHash) {
  3954. logStatus.success();
  3955. return {
  3956. groupAct: groupAct,
  3957. groupId: groupId,
  3958. groupHash: groupHash,
  3959. type: 'group'
  3960. };
  3961. } else if (publicHash && publicPid) {
  3962. logStatus.success();
  3963. return {
  3964. publicHash: publicHash,
  3965. publicPid: publicPid,
  3966. publicJoined: publicJoined,
  3967. type: 'public'
  3968. };
  3969. } else if (data.responseText.includes('wall.deletePost') && !doTask) {
  3970. var _data$responseText$ma5;
  3971. const wallHash = (_data$responseText$ma5 = data.responseText.match(/wall\.deletePost\(this, '.*?', '(.*?)'\)/)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  3972. if (wallHash) {
  3973. logStatus.success();
  3974. return {
  3975. type: 'deleteWall',
  3976. wallHash: wallHash
  3977. };
  3978. }
  3979. } else if (name.includes('wall') && doTask) {
  3980. logStatus.success();
  3981. return {
  3982. type: 'sendWall'
  3983. };
  3984. }
  3985. logStatus.error('Error: Parameters not found!');
  3986. return false;
  3987. }
  3988. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  3989. return false;
  3990. }
  3991. logStatus.error(`${result}:${statusText}(${status})`);
  3992. return false;
  3993. } catch (error) {
  3994. throwError(error, 'Vk.getId');
  3995. return false;
  3996. }
  3997. }
  3998. async function _toggleVk2(_ref2) {
  3999. let {
  4000. name,
  4001. doTask = true
  4002. } = _ref2;
  4003. try {
  4004. if (!doTask && this.whiteList.names.includes(name)) {
  4005. scripts_echoLog({
  4006. type: 'whiteList',
  4007. text: 'Vk.undoTask',
  4008. id: name
  4009. });
  4010. return true;
  4011. }
  4012. const formatName = name.replace(/\/$/, '');
  4013. const data = await Vk_classPrivateMethodGet(this, _getId, _getId2).call(this, formatName, doTask);
  4014. if (!data) {
  4015. return false;
  4016. }
  4017. switch (data.type) {
  4018. case 'group':
  4019. return await Vk_classPrivateMethodGet(this, _toggleGroup, _toggleGroup2).call(this, formatName, data, doTask);
  4020.  
  4021. case 'public':
  4022. return await Vk_classPrivateMethodGet(this, _togglePublic, _togglePublic2).call(this, formatName, data, doTask);
  4023.  
  4024. case 'sendWall':
  4025. return doTask ? await Vk_classPrivateMethodGet(this, _sendWall, _sendWall2).call(this, formatName) : true;
  4026.  
  4027. case 'deleteWall':
  4028. return doTask ? true : await Vk_classPrivateMethodGet(this, _deleteWall, _deleteWall2).call(this, formatName, data);
  4029.  
  4030. default:
  4031. return false;
  4032. }
  4033. } catch (error) {
  4034. throwError(error, 'Vk.toggleVk');
  4035. return false;
  4036. }
  4037. }
  4038. function Vk_setCache2(name, postId) {
  4039. try {
  4040. Vk_classPrivateFieldGet(this, Vk_cache)[name] = postId;
  4041. GM_setValue('vkCache', Vk_classPrivateFieldGet(this, Vk_cache));
  4042. } catch (error) {
  4043. throwError(error, 'Vk.setCache');
  4044. }
  4045. }
  4046. const social_Vk = Vk;
  4047. function Youtube_classPrivateMethodInitSpec(obj, privateSet) {
  4048. Youtube_checkPrivateRedeclaration(obj, privateSet);
  4049. privateSet.add(obj);
  4050. }
  4051. function Youtube_classPrivateFieldInitSpec(obj, privateMap, value) {
  4052. Youtube_checkPrivateRedeclaration(obj, privateMap);
  4053. privateMap.set(obj, value);
  4054. }
  4055. function Youtube_checkPrivateRedeclaration(obj, privateCollection) {
  4056. if (privateCollection.has(obj)) {
  4057. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4058. }
  4059. }
  4060. function Youtube_defineProperty(obj, key, value) {
  4061. if (key in obj) {
  4062. Object.defineProperty(obj, key, {
  4063. value: value,
  4064. enumerable: true,
  4065. configurable: true,
  4066. writable: true
  4067. });
  4068. } else {
  4069. obj[key] = value;
  4070. }
  4071. return obj;
  4072. }
  4073. function Youtube_classPrivateFieldSet(receiver, privateMap, value) {
  4074. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4075. Youtube_classApplyDescriptorSet(receiver, descriptor, value);
  4076. return value;
  4077. }
  4078. function Youtube_classApplyDescriptorSet(receiver, descriptor, value) {
  4079. if (descriptor.set) {
  4080. descriptor.set.call(receiver, value);
  4081. } else {
  4082. if (!descriptor.writable) {
  4083. throw new TypeError('attempted to set read only private field');
  4084. }
  4085. descriptor.value = value;
  4086. }
  4087. }
  4088. function Youtube_classPrivateMethodGet(receiver, privateSet, fn) {
  4089. if (!privateSet.has(receiver)) {
  4090. throw new TypeError('attempted to get private field on non-instance');
  4091. }
  4092. return fn;
  4093. }
  4094. function Youtube_classPrivateFieldGet(receiver, privateMap) {
  4095. var descriptor = Youtube_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4096. return Youtube_classApplyDescriptorGet(receiver, descriptor);
  4097. }
  4098. function Youtube_classExtractFieldDescriptor(receiver, privateMap, action) {
  4099. if (!privateMap.has(receiver)) {
  4100. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4101. }
  4102. return privateMap.get(receiver);
  4103. }
  4104. function Youtube_classApplyDescriptorGet(receiver, descriptor) {
  4105. if (descriptor.get) {
  4106. return descriptor.get.call(receiver);
  4107. }
  4108. return descriptor.value;
  4109. }
  4110. const Youtube_defaultTasks = {
  4111. channels: [],
  4112. likes: []
  4113. };
  4114. const getInfo = async function(link, type) {
  4115. try {
  4116. const logStatus = scripts_echoLog({
  4117. text: i18n('gettingYtbToken')
  4118. });
  4119. const {
  4120. result,
  4121. statusText,
  4122. status,
  4123. data
  4124. } = await tools_httpRequest({
  4125. url: link,
  4126. method: 'GET'
  4127. });
  4128. if (result === 'Success') {
  4129. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4130. var _data$responseText$ma, _ref;
  4131. if (data.responseText.includes('accounts.google.com/ServiceLogin?service=youtube')) {
  4132. logStatus.error(`Error:${i18n('loginYtb')}`, true);
  4133. return {
  4134. needLogin: true
  4135. };
  4136. }
  4137. const apiKey = (_data$responseText$ma = data.responseText.match(/"INNERTUBE_API_KEY":"(.*?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4138. const context = ((_ref = data.responseText.match(/\(\{"INNERTUBE_CONTEXT":([\w\W]*?)\}\)/) || data.responseText.match(/"INNERTUBE_CONTEXT":([\w\W]*?\}),"INNERTUBE/)) === null || _ref === void 0 ? void 0 : _ref[1]) || '{}';
  4139. const {
  4140. client,
  4141. request
  4142. } = JSON.parse(context);
  4143. if (apiKey && client && request) {
  4144. client.hl = 'en';
  4145. if (type === 'channel') {
  4146. var _data$responseText$ma2;
  4147. const channelId = (_data$responseText$ma2 = data.responseText.match(/<meta itemprop="channelId" content="(.+?)">/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  4148. if (channelId) {
  4149. logStatus.success();
  4150. return {
  4151. params: {
  4152. apiKey: apiKey,
  4153. client: client,
  4154. request: request,
  4155. channelId: channelId
  4156. }
  4157. };
  4158. }
  4159. logStatus.error('Error: Get "channelId" failed!');
  4160. return {};
  4161. } else if (type === 'likeVideo') {
  4162. var _data$responseText$ma3, _data$responseText$ma4;
  4163. const videoId = (_data$responseText$ma3 = data.responseText.match(/<link rel="shortlinkUrl" href="https:\/\/youtu\.be\/(.*?)">/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  4164. const likeParams = (_data$responseText$ma4 = data.responseText.match(/"likeParams":"(.*?)"/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  4165. if (videoId) {
  4166. logStatus.success();
  4167. return {
  4168. params: {
  4169. apiKey: apiKey,
  4170. client: client,
  4171. request: request,
  4172. videoId: videoId,
  4173. likeParams: likeParams
  4174. }
  4175. };
  4176. }
  4177. logStatus.error('Error: Get "videoId" failed!');
  4178. return {};
  4179. }
  4180. logStatus.error('Error: Unknown type');
  4181. return {};
  4182. }
  4183. logStatus.error('Error: Parameter "apiKey" not found!');
  4184. return {};
  4185. }
  4186. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4187. return {};
  4188. }
  4189. logStatus.error(`${result}:${statusText}(${status})`);
  4190. return {};
  4191. } catch (error) {
  4192. throwError(error, 'Youtube.getInfo');
  4193. return {};
  4194. }
  4195. };
  4196. var Youtube_auth = new WeakMap();
  4197. var Youtube_initialized = new WeakMap();
  4198. var _verifyChannel = new WeakMap();
  4199. var Youtube_verifyAuth = new WeakSet();
  4200. var Youtube_updateAuth = new WeakSet();
  4201. var _getInfo = new WeakSet();
  4202. var Youtube_toggleChannel = new WeakSet();
  4203. var _toggleLikeVideo = new WeakSet();
  4204. class Youtube extends social_Social {
  4205. constructor() {
  4206. var _GM_getValue;
  4207. super(...arguments);
  4208. Youtube_classPrivateMethodInitSpec(this, _toggleLikeVideo);
  4209. Youtube_classPrivateMethodInitSpec(this, Youtube_toggleChannel);
  4210. Youtube_classPrivateMethodInitSpec(this, _getInfo);
  4211. Youtube_classPrivateMethodInitSpec(this, Youtube_updateAuth);
  4212. Youtube_classPrivateMethodInitSpec(this, Youtube_verifyAuth);
  4213. Youtube_defineProperty(this, 'tasks', {
  4214. ...Youtube_defaultTasks
  4215. });
  4216. Youtube_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.youtube) || {
  4217. ...Youtube_defaultTasks
  4218. });
  4219. Youtube_classPrivateFieldInitSpec(this, Youtube_auth, {
  4220. writable: true,
  4221. value: GM_getValue('youtubeAuth') || {}
  4222. });
  4223. Youtube_classPrivateFieldInitSpec(this, Youtube_initialized, {
  4224. writable: true,
  4225. value: false
  4226. });
  4227. Youtube_classPrivateFieldInitSpec(this, _verifyChannel, {
  4228. writable: true,
  4229. value: `https://www.youtube.com/channel/${globalOptions.other.youtubeVerifyChannel}`
  4230. });
  4231. }
  4232. async init() {
  4233. try {
  4234. if (Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4235. return true;
  4236. }
  4237. if (!Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID) {
  4238. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4239. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4240. return true;
  4241. }
  4242. return false;
  4243. }
  4244. const isVerified = await Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this);
  4245. if (isVerified) {
  4246. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4247. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4248. return true;
  4249. }
  4250. GM_setValue('youtubeAuth', null);
  4251. if (await Youtube_classPrivateMethodGet(this, Youtube_updateAuth, Youtube_updateAuth2).call(this)) {
  4252. scripts_echoLog({}).success(i18n('initSuccess', 'Youtube'));
  4253. Youtube_classPrivateFieldSet(this, Youtube_initialized, true);
  4254. return true;
  4255. }
  4256. scripts_echoLog({}).error(i18n('initFailed', 'Youtube'));
  4257. return false;
  4258. } catch (error) {
  4259. throwError(error, 'Youtube.init');
  4260. return false;
  4261. }
  4262. }
  4263. async toggle(_ref2) {
  4264. let {
  4265. doTask = true,
  4266. channelLinks = [],
  4267. videoLinks = []
  4268. } = _ref2;
  4269. try {
  4270. if (!Youtube_classPrivateFieldGet(this, Youtube_initialized)) {
  4271. scripts_echoLog({
  4272. text: i18n('needInit')
  4273. });
  4274. return false;
  4275. }
  4276. const prom = [];
  4277. if (doTask && !globalOptions.doTask.youtube.channels || !doTask && !globalOptions.undoTask.youtube.channels) {
  4278. scripts_echoLog({
  4279. type: 'globalOptionsSkip',
  4280. text: 'youtube.channels'
  4281. });
  4282. } else {
  4283. const realChannels = this.getRealParams('channels', channelLinks, doTask, link => {
  4284. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4285. var _link$match;
  4286. return (_link$match = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4287. }
  4288. return link;
  4289. });
  4290. if (realChannels.length > 0) {
  4291. for (const channel of realChannels) {
  4292. prom.push(Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4293. link: channel,
  4294. doTask: doTask
  4295. }));
  4296. await delay(1e3);
  4297. }
  4298. }
  4299. }
  4300. if (doTask && !globalOptions.doTask.youtube.likes || !doTask && !globalOptions.undoTask.youtube.likes) {
  4301. scripts_echoLog({
  4302. type: 'globalOptionsSkip',
  4303. text: 'youtube.likes'
  4304. });
  4305. } else {
  4306. const realLikes = this.getRealParams('likes', videoLinks, doTask, link => {
  4307. if (/^https:\/\/(www\.)?google\.com.*?\/url\?.*?url=https:\/\/www\.youtube\.com\/.*/.test(link)) {
  4308. var _link$match2;
  4309. return (_link$match2 = link.match(/url=(https:\/\/www\.youtube\.com\/.*)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4310. }
  4311. return link;
  4312. });
  4313. if (realLikes.length > 0) {
  4314. for (const video of realLikes) {
  4315. prom.push(Youtube_classPrivateMethodGet(this, _toggleLikeVideo, _toggleLikeVideo2).call(this, {
  4316. link: video,
  4317. doTask: doTask
  4318. }));
  4319. await delay(1e3);
  4320. }
  4321. }
  4322. }
  4323. return Promise.all(prom).then(() => true);
  4324. } catch (error) {
  4325. throwError(error, 'Youtube.toggle');
  4326. return false;
  4327. }
  4328. }
  4329. }
  4330. async function Youtube_verifyAuth2() {
  4331. try {
  4332. return await Youtube_classPrivateMethodGet(this, Youtube_toggleChannel, Youtube_toggleChannel2).call(this, {
  4333. link: Youtube_classPrivateFieldGet(this, _verifyChannel),
  4334. doTask: true,
  4335. verify: true
  4336. });
  4337. } catch (error) {
  4338. throwError(error, 'Youtube.verifyAuth');
  4339. return false;
  4340. }
  4341. }
  4342. async function Youtube_updateAuth2() {
  4343. try {
  4344. const logStatus = scripts_echoLog({
  4345. text: i18n('updatingAuth', 'Youtube')
  4346. });
  4347. return await new Promise(resolve => {
  4348. const newTab = GM_openInTab('https://www.youtube.com/#auth', {
  4349. active: true,
  4350. insert: true,
  4351. setParent: true
  4352. });
  4353. newTab.onclose = async () => {
  4354. const auth = GM_getValue('youtubeAuth');
  4355. if (auth) {
  4356. Youtube_classPrivateFieldSet(this, Youtube_auth, auth);
  4357. logStatus.success();
  4358. Youtube_classPrivateMethodGet(this, Youtube_verifyAuth, Youtube_verifyAuth2).call(this).then(result => {
  4359. resolve(result);
  4360. });
  4361. } else {
  4362. logStatus.error('Error: Update youtube auth failed!');
  4363. resolve(false);
  4364. }
  4365. };
  4366. });
  4367. } catch (error) {
  4368. throwError(error, 'Discord.updateAuth');
  4369. return false;
  4370. }
  4371. }
  4372. function _getInfo2(link, type) {
  4373. return getInfo(link, type);
  4374. }
  4375. async function Youtube_toggleChannel2(_ref3) {
  4376. let {
  4377. link,
  4378. doTask = true,
  4379. verify = false
  4380. } = _ref3;
  4381. try {
  4382. const {
  4383. params,
  4384. needLogin
  4385. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'channel');
  4386. const {
  4387. apiKey,
  4388. client,
  4389. request,
  4390. channelId
  4391. } = params || {};
  4392. if (needLogin) {
  4393. scripts_echoLog({
  4394. html: i18n('loginYtb')
  4395. });
  4396. return false;
  4397. }
  4398. if (!(apiKey && client && request && channelId)) {
  4399. scripts_echoLog({
  4400. text: '"getYtbToken" failed'
  4401. });
  4402. return false;
  4403. }
  4404. if (!doTask && !verify && this.whiteList.channels.includes(channelId)) {
  4405. scripts_echoLog({
  4406. type: 'whiteList',
  4407. text: 'Youtube.unfollowChannel',
  4408. id: channelId
  4409. });
  4410. return true;
  4411. }
  4412. const logStatus = verify ? scripts_echoLog({
  4413. text: i18n('verifyingAuth', 'Youtube')
  4414. }) : scripts_echoLog({
  4415. type: doTask ? 'followingYtbChannel' : 'unfollowingYtbChannel',
  4416. text: channelId
  4417. });
  4418. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4419. const {
  4420. result,
  4421. statusText,
  4422. status,
  4423. data
  4424. } = await tools_httpRequest({
  4425. url: `https://www.youtube.com/youtubei/v1/subscription/${doTask ? '' : 'un'}subscribe?key=${apiKey}`,
  4426. method: 'POST',
  4427. headers: {
  4428. origin: 'https://www.youtube.com',
  4429. referer: `https://www.youtube.com/channel/${channelId}`,
  4430. 'content-type': 'application/json',
  4431. 'x-goog-authuser': '0',
  4432. 'x-goog-visitor-id': client === null || client === void 0 ? void 0 : client.visitorData,
  4433. 'x-origin': 'https://www.youtube.com',
  4434. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4435. },
  4436. data: JSON.stringify({
  4437. context: {
  4438. client: client,
  4439. request: {
  4440. sessionId: request === null || request === void 0 ? void 0 : request.sessionId,
  4441. internalExperimentFlags: [],
  4442. consistencyTokenJars: []
  4443. },
  4444. user: {}
  4445. },
  4446. channelIds: [ channelId ],
  4447. params: doTask ? 'EgIIAhgA' : 'CgIIAhgA'
  4448. })
  4449. });
  4450. if (result === 'Success') {
  4451. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4452. if (doTask && (/"subscribed": true/.test(data.responseText) || data.responseText.includes('The subscription already exists')) || !doTask && /"subscribed": false/.test(data.responseText)) {
  4453. logStatus.success();
  4454. if (doTask && !verify) {
  4455. this.tasks.channels = unique([ ...this.tasks.channels, link ]);
  4456. }
  4457. return true;
  4458. }
  4459. if (verify && data.responseText.includes('You may not subscribe to yourself')) {
  4460. logStatus.success();
  4461. return true;
  4462. }
  4463. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4464. return false;
  4465. }
  4466. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4467. return false;
  4468. }
  4469. logStatus.error(`${result}:${statusText}(${status})`);
  4470. return false;
  4471. } catch (error) {
  4472. throwError(error, 'Youtube.toggleChannel');
  4473. return false;
  4474. }
  4475. }
  4476. async function _toggleLikeVideo2(_ref4) {
  4477. let {
  4478. link,
  4479. doTask = true
  4480. } = _ref4;
  4481. try {
  4482. const {
  4483. params,
  4484. needLogin
  4485. } = await Youtube_classPrivateMethodGet(this, _getInfo, _getInfo2).call(this, link, 'likeVideo');
  4486. const {
  4487. apiKey,
  4488. client,
  4489. request,
  4490. videoId,
  4491. likeParams
  4492. } = params || {};
  4493. if (needLogin) {
  4494. scripts_echoLog({
  4495. html: `${i18n('loginYtb')}`
  4496. });
  4497. return false;
  4498. }
  4499. if (!(apiKey && client && request && videoId && likeParams)) {
  4500. scripts_echoLog({
  4501. text: '"getYtbToken" failed'
  4502. });
  4503. return false;
  4504. }
  4505. if (!doTask && this.whiteList.likes.includes(videoId)) {
  4506. scripts_echoLog({
  4507. type: 'whiteList',
  4508. text: 'Youtube.unlikeVideo',
  4509. id: videoId
  4510. });
  4511. return true;
  4512. }
  4513. const logStatus = scripts_echoLog({
  4514. type: doTask ? 'likingYtbVideo' : 'unlikingYtbVideo',
  4515. text: videoId
  4516. });
  4517. const nowTime = parseInt(String(new Date().getTime() / 1e3), 10);
  4518. const likeVideoData = {
  4519. context: {
  4520. client: client,
  4521. request: {
  4522. sessionId: request.sessionId,
  4523. internalExperimentFlags: [],
  4524. consistencyTokenJars: []
  4525. },
  4526. user: {}
  4527. },
  4528. target: {
  4529. videoId: videoId
  4530. }
  4531. };
  4532. if (doTask) {
  4533. if (likeParams) {
  4534. likeVideoData.params = likeParams;
  4535. } else {
  4536. logStatus.error('Empty likeParams');
  4537. return false;
  4538. }
  4539. }
  4540. const {
  4541. result,
  4542. statusText,
  4543. status,
  4544. data
  4545. } = await tools_httpRequest({
  4546. url: `https://www.youtube.com/youtubei/v1/like/${doTask ? '' : 'remove'}like?key=${apiKey}`,
  4547. method: 'POST',
  4548. headers: {
  4549. origin: 'https://www.youtube.com',
  4550. referer: `https://www.youtube.com/watch?v=${videoId}`,
  4551. 'content-type': 'application/json',
  4552. 'x-goog-authuser': '0',
  4553. 'x-goog-visitor-id': client.visitorData,
  4554. 'x-origin': 'https://www.youtube.com',
  4555. authorization: `SAPISIDHASH ${nowTime}_${sha1(`${nowTime} ${Youtube_classPrivateFieldGet(this, Youtube_auth).PAPISID} https://www.youtube.com`)}`
  4556. },
  4557. data: JSON.stringify(likeVideoData)
  4558. });
  4559. if (result === 'Success') {
  4560. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4561. if (doTask && data.responseText.includes('Added to Liked videos') || !doTask && (data.responseText.includes('Removed from Liked videos') || data.responseText.includes('Dislike removed'))) {
  4562. logStatus.success();
  4563. if (doTask) {
  4564. this.tasks.likes = unique([ ...this.tasks.likes, link ]);
  4565. }
  4566. return true;
  4567. }
  4568. logStatus.error(i18n('tryUpdateYtbAuth'), true);
  4569. return false;
  4570. }
  4571. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4572. return false;
  4573. }
  4574. logStatus.error(`${result}:${statusText}(${status})`);
  4575. return false;
  4576. } catch (error) {
  4577. throwError(error, 'Youtube.toggleLikeVideo');
  4578. return false;
  4579. }
  4580. }
  4581. function Steam_classPrivateMethodInitSpec(obj, privateSet) {
  4582. Steam_checkPrivateRedeclaration(obj, privateSet);
  4583. privateSet.add(obj);
  4584. }
  4585. function Steam_classPrivateFieldInitSpec(obj, privateMap, value) {
  4586. Steam_checkPrivateRedeclaration(obj, privateMap);
  4587. privateMap.set(obj, value);
  4588. }
  4589. function Steam_checkPrivateRedeclaration(obj, privateCollection) {
  4590. if (privateCollection.has(obj)) {
  4591. throw new TypeError('Cannot initialize the same private elements twice on an object');
  4592. }
  4593. }
  4594. function Steam_defineProperty(obj, key, value) {
  4595. if (key in obj) {
  4596. Object.defineProperty(obj, key, {
  4597. value: value,
  4598. enumerable: true,
  4599. configurable: true,
  4600. writable: true
  4601. });
  4602. } else {
  4603. obj[key] = value;
  4604. }
  4605. return obj;
  4606. }
  4607. function Steam_classPrivateFieldSet(receiver, privateMap, value) {
  4608. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'set');
  4609. Steam_classApplyDescriptorSet(receiver, descriptor, value);
  4610. return value;
  4611. }
  4612. function Steam_classApplyDescriptorSet(receiver, descriptor, value) {
  4613. if (descriptor.set) {
  4614. descriptor.set.call(receiver, value);
  4615. } else {
  4616. if (!descriptor.writable) {
  4617. throw new TypeError('attempted to set read only private field');
  4618. }
  4619. descriptor.value = value;
  4620. }
  4621. }
  4622. function Steam_classPrivateMethodGet(receiver, privateSet, fn) {
  4623. if (!privateSet.has(receiver)) {
  4624. throw new TypeError('attempted to get private field on non-instance');
  4625. }
  4626. return fn;
  4627. }
  4628. function Steam_classPrivateFieldGet(receiver, privateMap) {
  4629. var descriptor = Steam_classExtractFieldDescriptor(receiver, privateMap, 'get');
  4630. return Steam_classApplyDescriptorGet(receiver, descriptor);
  4631. }
  4632. function Steam_classExtractFieldDescriptor(receiver, privateMap, action) {
  4633. if (!privateMap.has(receiver)) {
  4634. throw new TypeError('attempted to ' + action + ' private field on non-instance');
  4635. }
  4636. return privateMap.get(receiver);
  4637. }
  4638. function Steam_classApplyDescriptorGet(receiver, descriptor) {
  4639. if (descriptor.get) {
  4640. return descriptor.get.call(receiver);
  4641. }
  4642. return descriptor.value;
  4643. }
  4644. const Steam_defaultTasks = {
  4645. groups: [],
  4646. wishlists: [],
  4647. follows: [],
  4648. forums: [],
  4649. workshops: [],
  4650. workshopVotes: [],
  4651. curators: [],
  4652. curatorLikes: [],
  4653. announcements: []
  4654. };
  4655. var Steam_cache = new WeakMap();
  4656. var Steam_auth = new WeakMap();
  4657. var Steam_initialized = new WeakMap();
  4658. var _area = new WeakMap();
  4659. var _updateStoreAuth = new WeakSet();
  4660. var _updateCommunityAuth = new WeakSet();
  4661. var _getAreaInfo = new WeakSet();
  4662. var _changeArea = new WeakSet();
  4663. var _joinGroup = new WeakSet();
  4664. var _leaveGroup = new WeakSet();
  4665. var _getGroupId = new WeakSet();
  4666. var _addToWishlist = new WeakSet();
  4667. var _removeFromWishlist = new WeakSet();
  4668. var _toggleFollowGame = new WeakSet();
  4669. var _isFollowedGame = new WeakSet();
  4670. var _toggleForum = new WeakSet();
  4671. var _getForumId = new WeakSet();
  4672. var _toggleFavoriteWorkshop = new WeakSet();
  4673. var _getWorkshopAppId = new WeakSet();
  4674. var _voteUpWorkshop = new WeakSet();
  4675. var _toggleCurator = new WeakSet();
  4676. var _toggleCuratorLike = new WeakSet();
  4677. var _getAnnouncementParams = new WeakSet();
  4678. var _likeAnnouncement = new WeakSet();
  4679. var Steam_setCache = new WeakSet();
  4680. class Steam extends social_Social {
  4681. constructor() {
  4682. var _GM_getValue;
  4683. super(...arguments);
  4684. Steam_classPrivateMethodInitSpec(this, Steam_setCache);
  4685. Steam_classPrivateMethodInitSpec(this, _likeAnnouncement);
  4686. Steam_classPrivateMethodInitSpec(this, _getAnnouncementParams);
  4687. Steam_classPrivateMethodInitSpec(this, _toggleCuratorLike);
  4688. Steam_classPrivateMethodInitSpec(this, _toggleCurator);
  4689. Steam_classPrivateMethodInitSpec(this, _voteUpWorkshop);
  4690. Steam_classPrivateMethodInitSpec(this, _getWorkshopAppId);
  4691. Steam_classPrivateMethodInitSpec(this, _toggleFavoriteWorkshop);
  4692. Steam_classPrivateMethodInitSpec(this, _getForumId);
  4693. Steam_classPrivateMethodInitSpec(this, _toggleForum);
  4694. Steam_classPrivateMethodInitSpec(this, _isFollowedGame);
  4695. Steam_classPrivateMethodInitSpec(this, _toggleFollowGame);
  4696. Steam_classPrivateMethodInitSpec(this, _removeFromWishlist);
  4697. Steam_classPrivateMethodInitSpec(this, _addToWishlist);
  4698. Steam_classPrivateMethodInitSpec(this, _getGroupId);
  4699. Steam_classPrivateMethodInitSpec(this, _leaveGroup);
  4700. Steam_classPrivateMethodInitSpec(this, _joinGroup);
  4701. Steam_classPrivateMethodInitSpec(this, _changeArea);
  4702. Steam_classPrivateMethodInitSpec(this, _getAreaInfo);
  4703. Steam_classPrivateMethodInitSpec(this, _updateCommunityAuth);
  4704. Steam_classPrivateMethodInitSpec(this, _updateStoreAuth);
  4705. Steam_defineProperty(this, 'tasks', {
  4706. ...Steam_defaultTasks
  4707. });
  4708. Steam_defineProperty(this, 'whiteList', ((_GM_getValue = GM_getValue('whiteList')) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.steam) || {
  4709. ...Steam_defaultTasks
  4710. });
  4711. Steam_classPrivateFieldInitSpec(this, Steam_cache, {
  4712. writable: true,
  4713. value: GM_getValue('steamCache') || {
  4714. group: {},
  4715. forum: {},
  4716. workshop: {},
  4717. curator: {}
  4718. }
  4719. });
  4720. Steam_classPrivateFieldInitSpec(this, Steam_auth, {
  4721. writable: true,
  4722. value: {}
  4723. });
  4724. Steam_classPrivateFieldInitSpec(this, Steam_initialized, {
  4725. writable: true,
  4726. value: false
  4727. });
  4728. Steam_classPrivateFieldInitSpec(this, _area, {
  4729. writable: true,
  4730. value: 'CN'
  4731. });
  4732. }
  4733. async init() {
  4734. try {
  4735. if (Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4736. return true;
  4737. }
  4738. const isVerified = await Steam_classPrivateMethodGet(this, _updateStoreAuth, _updateStoreAuth2).call(this) && await Steam_classPrivateMethodGet(this, _updateCommunityAuth, _updateCommunityAuth2).call(this);
  4739. if (isVerified) {
  4740. Steam_classPrivateFieldSet(this, Steam_initialized, true);
  4741. scripts_echoLog({}).success(i18n('initSuccess', 'Steam'));
  4742. return true;
  4743. }
  4744. scripts_echoLog({}).error(i18n('initFailed', 'Steam'));
  4745. return false;
  4746. } catch (error) {
  4747. throwError(error, 'Steam.init');
  4748. return false;
  4749. }
  4750. }
  4751. async getCuratorId(path, name) {
  4752. try {
  4753. const logStatus = scripts_echoLog({
  4754. type: 'gettingCuratorId',
  4755. text: `${path}/${name}`
  4756. });
  4757. const curatorId = Steam_classPrivateFieldGet(this, Steam_cache).curator[`${path}/${name}`];
  4758. if (curatorId) {
  4759. logStatus.success();
  4760. return curatorId;
  4761. }
  4762. const {
  4763. result,
  4764. statusText,
  4765. status,
  4766. data
  4767. } = await tools_httpRequest({
  4768. url: `https://store.steampowered.com/${path}/${name}`,
  4769. method: 'GET',
  4770. headers: {
  4771. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  4772. }
  4773. });
  4774. if (result === 'Success') {
  4775. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  4776. var _data$responseText$ma;
  4777. const curatorId = (_data$responseText$ma = data.responseText.match(/g_pagingData.*?"clanid":([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  4778. if (curatorId) {
  4779. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'curator', `${path}/${name}`, curatorId);
  4780. logStatus.success();
  4781. return curatorId;
  4782. }
  4783. logStatus.error(`Error:${data.statusText}(${data.status})`);
  4784. return false;
  4785. }
  4786. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  4787. return false;
  4788. }
  4789. logStatus.error(`${result}:${statusText}(${status})`);
  4790. return false;
  4791. } catch (error) {
  4792. throwError(error, 'Steam.getCuratorID');
  4793. return false;
  4794. }
  4795. }
  4796. async toggle(_ref) {
  4797. let {
  4798. doTask = true,
  4799. groupLinks = [],
  4800. wishlistLinks = [],
  4801. followLinks = [],
  4802. forumLinks = [],
  4803. workshopLinks = [],
  4804. workshopVoteLinks = [],
  4805. curatorLinks = [],
  4806. curatorLikeLinks = [],
  4807. announcementLinks = []
  4808. } = _ref;
  4809. try {
  4810. if (!Steam_classPrivateFieldGet(this, Steam_initialized)) {
  4811. scripts_echoLog({
  4812. text: i18n('needInit')
  4813. });
  4814. return false;
  4815. }
  4816. const prom = [];
  4817. if (doTask && !globalOptions.doTask.steam.groups || !doTask && !globalOptions.undoTask.steam.groups) {
  4818. scripts_echoLog({
  4819. type: 'globalOptionsSkip',
  4820. text: 'steam.groups'
  4821. });
  4822. } else {
  4823. const realGroups = this.getRealParams('groups', groupLinks, doTask, link => {
  4824. var _link$match;
  4825. return (_link$match = link.match(/groups\/(.+)\/?/)) === null || _link$match === void 0 ? void 0 : _link$match[1];
  4826. });
  4827. if (realGroups.length > 0) {
  4828. for (const group of realGroups) {
  4829. if (doTask) {
  4830. prom.push(Steam_classPrivateMethodGet(this, _joinGroup, _joinGroup2).call(this, group));
  4831. } else {
  4832. prom.push(Steam_classPrivateMethodGet(this, _leaveGroup, _leaveGroup2).call(this, group));
  4833. }
  4834. await delay(1e3);
  4835. }
  4836. }
  4837. }
  4838. if (doTask && !globalOptions.doTask.steam.wishlists || !doTask && !globalOptions.undoTask.steam.wishlists) {
  4839. scripts_echoLog({
  4840. type: 'globalOptionsSkip',
  4841. text: 'steam.wishlists'
  4842. });
  4843. } else {
  4844. const realWishlists = this.getRealParams('wishlists', wishlistLinks, doTask, link => {
  4845. var _link$match2;
  4846. return (_link$match2 = link.match(/app\/([\d]+)/)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1];
  4847. });
  4848. if (realWishlists.length > 0) {
  4849. for (const game of realWishlists) {
  4850. if (doTask) {
  4851. prom.push(Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, game));
  4852. } else {
  4853. prom.push(Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, game));
  4854. }
  4855. await delay(1e3);
  4856. }
  4857. }
  4858. }
  4859. if (doTask && !globalOptions.doTask.steam.follows || !doTask && !globalOptions.undoTask.steam.follows) {
  4860. scripts_echoLog({
  4861. type: 'globalOptionsSkip',
  4862. text: 'steam.follows'
  4863. });
  4864. } else {
  4865. const realFollows = this.getRealParams('follows', followLinks, doTask, link => {
  4866. var _link$match3;
  4867. return (_link$match3 = link.match(/app\/([\d]+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[1];
  4868. });
  4869. if (realFollows.length > 0) {
  4870. for (const game of realFollows) {
  4871. prom.push(Steam_classPrivateMethodGet(this, _toggleFollowGame, _toggleFollowGame2).call(this, game, doTask));
  4872. await delay(1e3);
  4873. }
  4874. }
  4875. }
  4876. if (doTask && !globalOptions.doTask.steam.forums || !doTask && !globalOptions.undoTask.steam.forums) {
  4877. scripts_echoLog({
  4878. type: 'globalOptionsSkip',
  4879. text: 'steam.forums'
  4880. });
  4881. } else {
  4882. const realForums = this.getRealParams('forums', forumLinks, doTask, link => {
  4883. var _link$match4;
  4884. return (_link$match4 = link.match(/app\/([\d]+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1];
  4885. });
  4886. if (realForums.length > 0) {
  4887. for (const forum of realForums) {
  4888. prom.push(Steam_classPrivateMethodGet(this, _toggleForum, _toggleForum2).call(this, forum, doTask));
  4889. await delay(1e3);
  4890. }
  4891. }
  4892. }
  4893. if (doTask && !globalOptions.doTask.steam.workshops || !doTask && !globalOptions.undoTask.steam.workshops) {
  4894. scripts_echoLog({
  4895. type: 'globalOptionsSkip',
  4896. text: 'steam.workshops'
  4897. });
  4898. } else {
  4899. const realWorkshops = this.getRealParams('workshops', workshopLinks, doTask, link => {
  4900. var _link$match5;
  4901. return (_link$match5 = link.match(/\?id=([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1];
  4902. });
  4903. if (realWorkshops.length > 0) {
  4904. for (const workshop of realWorkshops) {
  4905. prom.push(Steam_classPrivateMethodGet(this, _toggleFavoriteWorkshop, _toggleFavoriteWorkshop2).call(this, workshop, doTask));
  4906. await delay(1e3);
  4907. }
  4908. }
  4909. }
  4910. if (doTask && !globalOptions.doTask.steam.workshopVotes) {
  4911. scripts_echoLog({
  4912. type: 'globalOptionsSkip',
  4913. text: 'steam.workshopVotes'
  4914. });
  4915. } else {
  4916. const realworkshopVotes = this.getRealParams('workshopVotes', workshopVoteLinks, doTask, link => {
  4917. var _link$match6;
  4918. return (_link$match6 = link.match(/\?id=([\d]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1];
  4919. });
  4920. if (doTask && realworkshopVotes.length > 0) {
  4921. for (const workshop of realworkshopVotes) {
  4922. prom.push(Steam_classPrivateMethodGet(this, _voteUpWorkshop, _voteUpWorkshop2).call(this, workshop));
  4923. await delay(1e3);
  4924. }
  4925. }
  4926. }
  4927. if (doTask && !globalOptions.doTask.steam.curators || !doTask && !globalOptions.undoTask.steam.curators) {
  4928. scripts_echoLog({
  4929. type: 'globalOptionsSkip',
  4930. text: 'steam.curators'
  4931. });
  4932. } else {
  4933. const realCurators = this.getRealParams('curators', curatorLinks, doTask, link => {
  4934. var _link$match7;
  4935. return (_link$match7 = link.match(/curator\/([\d]+)/)) === null || _link$match7 === void 0 ? void 0 : _link$match7[1];
  4936. });
  4937. const realCuratorLikes = this.getRealParams('curatorLikes', curatorLikeLinks, doTask, link => {
  4938. var _link$match8;
  4939. return (_link$match8 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match8 === void 0 ? void 0 : _link$match8.slice(1, 3).join('/');
  4940. });
  4941. if (realCurators.length > 0) {
  4942. for (const curator of realCurators) {
  4943. prom.push(Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curator, doTask));
  4944. await delay(1e3);
  4945. }
  4946. }
  4947. if (realCuratorLikes.length > 0) {
  4948. for (const curatorLike of realCuratorLikes) {
  4949. prom.push(Steam_classPrivateMethodGet(this, _toggleCuratorLike, _toggleCuratorLike2).call(this, curatorLike, doTask));
  4950. await delay(1e3);
  4951. }
  4952. }
  4953. }
  4954. if (doTask && !globalOptions.doTask.steam.announcements) {
  4955. scripts_echoLog({
  4956. type: 'globalOptionsSkip',
  4957. text: 'steam.announcements'
  4958. });
  4959. } else {
  4960. const realAnnouncements = this.getRealParams('announcements', announcementLinks, doTask, link => {
  4961. var _link$match10;
  4962. if (link.includes('store.steampowered.com')) {
  4963. var _link$match9;
  4964. return (_link$match9 = link.match(/store\.steampowered\.com\/news\/app\/([\d]+)\/view\/([\d]+)/)) === null || _link$match9 === void 0 ? void 0 : _link$match9.slice(1, 3).join('/');
  4965. }
  4966. return (_link$match10 = link.match(/steamcommunity\.com\/games\/([\d]+)\/announcements\/detail\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10.slice(1, 3).join('/');
  4967. });
  4968. if (doTask && realAnnouncements.length > 0) {
  4969. for (const id of realAnnouncements) {
  4970. prom.push(Steam_classPrivateMethodGet(this, _likeAnnouncement, _likeAnnouncement2).call(this, id));
  4971. await delay(1e3);
  4972. }
  4973. }
  4974. }
  4975. return Promise.all(prom).then(async () => {
  4976. if (Steam_classPrivateFieldGet(this, _area) !== 'CN') {
  4977. scripts_echoLog({}).warning(i18n('steamFinishNotice'));
  4978. await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this, 'CN');
  4979. }
  4980. return true;
  4981. });
  4982. } catch (error) {
  4983. throwError(error, 'Steam.toggle');
  4984. return false;
  4985. }
  4986. }
  4987. }
  4988. async function _updateStoreAuth2() {
  4989. try {
  4990. const logStatus = scripts_echoLog({
  4991. text: i18n('updatingAuth', i18n('steamStore'))
  4992. });
  4993. const {
  4994. result,
  4995. statusText,
  4996. status,
  4997. data
  4998. } = await tools_httpRequest({
  4999. url: 'https://store.steampowered.com/stats/',
  5000. method: 'GET'
  5001. });
  5002. if (result === 'Success') {
  5003. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5004. var _data$responseText$ma2;
  5005. if (data.responseText.includes('href="https://store.steampowered.com/login/')) {
  5006. logStatus.error(`Error:${i18n('needLoginSteamStore')}`, true);
  5007. return false;
  5008. }
  5009. const storeSessionID = (_data$responseText$ma2 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma2 === void 0 ? void 0 : _data$responseText$ma2[1];
  5010. if (storeSessionID) {
  5011. Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID = storeSessionID;
  5012. logStatus.success();
  5013. return true;
  5014. }
  5015. logStatus.error('Error: Get "sessionID" failed');
  5016. return false;
  5017. }
  5018. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5019. return false;
  5020. }
  5021. logStatus.error(`${result}:${statusText}(${status})`);
  5022. return false;
  5023. } catch (error) {
  5024. throwError(error, 'Steam.updateStoreAuth');
  5025. return false;
  5026. }
  5027. }
  5028. async function _updateCommunityAuth2() {
  5029. try {
  5030. const logStatus = scripts_echoLog({
  5031. text: i18n('updatingAuth', i18n('steamCommunity'))
  5032. });
  5033. const {
  5034. result,
  5035. statusText,
  5036. status,
  5037. data
  5038. } = await tools_httpRequest({
  5039. url: 'https://steamcommunity.com/my',
  5040. method: 'GET'
  5041. });
  5042. if (result === 'Success') {
  5043. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5044. var _data$responseText$ma3, _data$responseText$ma4, _data$responseText$ma5;
  5045. if (data.responseText.includes('href="https://steamcommunity.com/login/home/')) {
  5046. logStatus.error(`Error:${i18n('needLoginSteamCommunity')}`, true);
  5047. return false;
  5048. }
  5049. const steam64Id = (_data$responseText$ma3 = data.responseText.match(/g_steamID = "(.+?)";/)) === null || _data$responseText$ma3 === void 0 ? void 0 : _data$responseText$ma3[1];
  5050. const communitySessionID = (_data$responseText$ma4 = data.responseText.match(/g_sessionID = "(.+?)";/)) === null || _data$responseText$ma4 === void 0 ? void 0 : _data$responseText$ma4[1];
  5051. const userName = (_data$responseText$ma5 = data.responseText.match(/steamcommunity.com\/id\/(.+?)\/friends\//)) === null || _data$responseText$ma5 === void 0 ? void 0 : _data$responseText$ma5[1];
  5052. if (steam64Id) {
  5053. Steam_classPrivateFieldGet(this, Steam_auth).steam64Id = steam64Id;
  5054. }
  5055. if (userName) {
  5056. Steam_classPrivateFieldGet(this, Steam_auth).userName = userName;
  5057. }
  5058. if (communitySessionID) {
  5059. Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID = communitySessionID;
  5060. logStatus.success();
  5061. return true;
  5062. }
  5063. logStatus.error('Error: Get "sessionID" failed');
  5064. return false;
  5065. }
  5066. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5067. return false;
  5068. }
  5069. logStatus.error(`${result}:${statusText}(${status})`);
  5070. return false;
  5071. } catch (error) {
  5072. throwError(error, 'Steam.updateCommunityAuth');
  5073. return false;
  5074. }
  5075. }
  5076. async function _getAreaInfo2() {
  5077. try {
  5078. const logStatus = scripts_echoLog({
  5079. text: i18n('gettingAreaInfo')
  5080. });
  5081. const {
  5082. result,
  5083. statusText,
  5084. status,
  5085. data
  5086. } = await tools_httpRequest({
  5087. url: 'https://store.steampowered.com/cart/',
  5088. method: 'GET'
  5089. });
  5090. if (result === 'Success') {
  5091. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5092. var _data$responseText$ma6;
  5093. const currentArea = (_data$responseText$ma6 = data.responseText.match(/<input id="usercountrycurrency".*?value="(.+?)"/)) === null || _data$responseText$ma6 === void 0 ? void 0 : _data$responseText$ma6[1];
  5094. const areas = [ ...data.responseText.matchAll(/<div class="currency_change_option .*?" data-country="(.+?)" >/g) ].map(search => search[1]);
  5095. if (currentArea && areas.length > 0) {
  5096. Steam_classPrivateFieldSet(this, _area, currentArea);
  5097. logStatus.success();
  5098. return {
  5099. currentArea: currentArea,
  5100. areas: areas
  5101. };
  5102. }
  5103. logStatus.error('Error: get country info filed');
  5104. return {};
  5105. }
  5106. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5107. return {};
  5108. }
  5109. logStatus.error(`${result}:${statusText}(${status})`);
  5110. return {};
  5111. } catch (error) {
  5112. throwError(error, 'Steam.getAreaInfo');
  5113. return {};
  5114. }
  5115. }
  5116. async function _changeArea2(area) {
  5117. try {
  5118. let aimedArea = area;
  5119. if (!aimedArea) {
  5120. const {
  5121. currentArea,
  5122. areas
  5123. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5124. if (!currentArea || !areas) {
  5125. return false;
  5126. }
  5127. if (currentArea !== 'CN') {
  5128. scripts_echoLog({
  5129. text: 'notNeededChangeArea'
  5130. });
  5131. return 'skip';
  5132. }
  5133. const anotherArea = areas.filter(area => area && area !== 'CN');
  5134. if (!anotherArea || anotherArea.length === 0) {
  5135. scripts_echoLog({
  5136. text: 'noAnotherArea'
  5137. });
  5138. return false;
  5139. }
  5140. [ aimedArea ] = anotherArea;
  5141. }
  5142. const logStatus = scripts_echoLog({
  5143. text: i18n('changingArea', aimedArea)
  5144. });
  5145. const {
  5146. result,
  5147. statusText,
  5148. status,
  5149. data
  5150. } = await tools_httpRequest({
  5151. url: 'https://store.steampowered.com/account/setcountry',
  5152. method: 'POST',
  5153. headers: {
  5154. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5155. },
  5156. data: $.param({
  5157. cc: aimedArea,
  5158. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID
  5159. })
  5160. });
  5161. if (result === 'Success') {
  5162. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5163. const {
  5164. currentArea
  5165. } = await Steam_classPrivateMethodGet(this, _getAreaInfo, _getAreaInfo2).call(this);
  5166. if (currentArea === aimedArea) {
  5167. logStatus.success();
  5168. return currentArea;
  5169. }
  5170. logStatus.error('Error: change country filed');
  5171. return 'CN';
  5172. }
  5173. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5174. return 'CN';
  5175. }
  5176. logStatus.error(`${result}:${statusText}(${status})`);
  5177. return 'CN';
  5178. } catch (error) {
  5179. throwError(error, 'Steam.changeArea');
  5180. return false;
  5181. }
  5182. }
  5183. async function _joinGroup2(groupName) {
  5184. try {
  5185. const logStatus = scripts_echoLog({
  5186. type: 'joiningSteamGroup',
  5187. text: groupName
  5188. });
  5189. const {
  5190. result,
  5191. statusText,
  5192. status,
  5193. data
  5194. } = await tools_httpRequest({
  5195. url: `https://steamcommunity.com/groups/${groupName}`,
  5196. method: 'POST',
  5197. headers: {
  5198. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5199. },
  5200. data: $.param({
  5201. action: 'join',
  5202. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5203. })
  5204. });
  5205. if (result === 'Success') {
  5206. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText.includes('grouppage_join_area')) {
  5207. logStatus.success();
  5208. this.tasks.groups = unique([ ...this.tasks.groups, groupName ]);
  5209. return true;
  5210. }
  5211. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5212. return false;
  5213. }
  5214. logStatus.error(`${result}:${statusText}(${status})`);
  5215. return false;
  5216. } catch (error) {
  5217. throwError(error, 'Steam.joinGroup');
  5218. return false;
  5219. }
  5220. }
  5221. async function _leaveGroup2(groupName) {
  5222. try {
  5223. if (this.whiteList.groups.includes(groupName)) {
  5224. scripts_echoLog({
  5225. type: 'whiteList',
  5226. text: 'Steam.leaveGroup',
  5227. id: groupName
  5228. });
  5229. return true;
  5230. }
  5231. const groupId = await Steam_classPrivateMethodGet(this, _getGroupId, _getGroupId2).call(this, groupName);
  5232. if (!groupId) {
  5233. return false;
  5234. }
  5235. const logStatus = scripts_echoLog({
  5236. type: 'leavingSteamGroup',
  5237. text: groupName
  5238. });
  5239. const {
  5240. result,
  5241. statusText,
  5242. status,
  5243. data
  5244. } = await tools_httpRequest({
  5245. url: `https://steamcommunity.com/id/${Steam_classPrivateFieldGet(this, Steam_auth).userName}/home_process`,
  5246. method: 'POST',
  5247. headers: {
  5248. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5249. },
  5250. data: $.param({
  5251. sessionID: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID,
  5252. action: 'leaveGroup',
  5253. groupId: groupId
  5254. })
  5255. });
  5256. if (result === 'Success') {
  5257. 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) {
  5258. logStatus.success();
  5259. return true;
  5260. }
  5261. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5262. return false;
  5263. }
  5264. logStatus.error(`${result}:${statusText}(${status})`);
  5265. return false;
  5266. } catch (error) {
  5267. throwError(error, 'Steam.leaveGroup');
  5268. return false;
  5269. }
  5270. }
  5271. async function _getGroupId2(groupName) {
  5272. try {
  5273. const logStatus = scripts_echoLog({
  5274. type: 'gettingSteamGroupId',
  5275. text: groupName
  5276. });
  5277. const groupId = Steam_classPrivateFieldGet(this, Steam_cache).group[groupName];
  5278. if (groupId) {
  5279. logStatus.success();
  5280. return groupId;
  5281. }
  5282. const {
  5283. result,
  5284. statusText,
  5285. status,
  5286. data
  5287. } = await tools_httpRequest({
  5288. url: `https://steamcommunity.com/groups/${groupName}`,
  5289. method: 'GET',
  5290. headers: {
  5291. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5292. }
  5293. });
  5294. if (result === 'Success') {
  5295. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5296. var _data$responseText$ma7;
  5297. const groupId = (_data$responseText$ma7 = data.responseText.match(/OpenGroupChat\( '([0-9]+)'/)) === null || _data$responseText$ma7 === void 0 ? void 0 : _data$responseText$ma7[1];
  5298. if (groupId) {
  5299. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'group', groupName, groupId);
  5300. logStatus.success();
  5301. return groupId;
  5302. }
  5303. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5304. return false;
  5305. }
  5306. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5307. return false;
  5308. }
  5309. logStatus.error(`${result}:${statusText}(${status})`);
  5310. return false;
  5311. } catch (error) {
  5312. throwError(error, 'Steam.getGroupID');
  5313. return false;
  5314. }
  5315. }
  5316. async function _addToWishlist2(gameId) {
  5317. try {
  5318. var _data$response;
  5319. const logStatus = scripts_echoLog({
  5320. type: 'addingToWishlist',
  5321. text: gameId
  5322. });
  5323. const {
  5324. result,
  5325. data
  5326. } = await tools_httpRequest({
  5327. url: 'https://store.steampowered.com/api/addtowishlist',
  5328. method: 'POST',
  5329. headers: {
  5330. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5331. },
  5332. data: $.param({
  5333. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5334. appid: gameId
  5335. }),
  5336. dataType: 'json'
  5337. });
  5338. 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) {
  5339. logStatus.success();
  5340. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5341. return true;
  5342. }
  5343. const {
  5344. result: resultR,
  5345. statusText: statusTextR,
  5346. status: statusR,
  5347. data: dataR
  5348. } = await tools_httpRequest({
  5349. url: `https://store.steampowered.com/app/${gameId}`,
  5350. method: 'GET'
  5351. });
  5352. if (resultR === 'Success') {
  5353. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5354. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5355. logStatus.warning(i18n('changeAreaNotice'));
  5356. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5357. return false;
  5358. }
  5359. return await Steam_classPrivateMethodGet(this, _addToWishlist, _addToWishlist2).call(this, gameId);
  5360. }
  5361. if (dataR.responseText.includes('class="queue_actions_ctn"') && dataR.responseText.includes('class="already_in_library"')) {
  5362. logStatus.success();
  5363. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5364. return true;
  5365. } 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"')) {
  5366. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5367. return false;
  5368. }
  5369. logStatus.success();
  5370. this.tasks.wishlists = unique([ ...this.tasks.wishlists, gameId ]);
  5371. return true;
  5372. }
  5373. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5374. return false;
  5375. }
  5376. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5377. return false;
  5378. } catch (error) {
  5379. throwError(error, 'Steam.addToWishlist');
  5380. return false;
  5381. }
  5382. }
  5383. async function _removeFromWishlist2(gameId) {
  5384. try {
  5385. var _data$response2;
  5386. if (this.whiteList.wishlists.includes(gameId)) {
  5387. scripts_echoLog({
  5388. type: 'whiteList',
  5389. text: 'Steam.removeFromWishlist',
  5390. id: gameId
  5391. });
  5392. return true;
  5393. }
  5394. const logStatus = scripts_echoLog({
  5395. type: 'removingFromWishlist',
  5396. text: gameId
  5397. });
  5398. const {
  5399. result,
  5400. data
  5401. } = await tools_httpRequest({
  5402. url: 'https://store.steampowered.com/api/removefromwishlist',
  5403. method: 'POST',
  5404. headers: {
  5405. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5406. },
  5407. data: $.param({
  5408. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5409. appid: gameId
  5410. }),
  5411. dataType: 'json'
  5412. });
  5413. 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) {
  5414. logStatus.success();
  5415. return true;
  5416. }
  5417. const {
  5418. result: resultR,
  5419. statusText: statusTextR,
  5420. status: statusR,
  5421. data: dataR
  5422. } = await tools_httpRequest({
  5423. url: `https://store.steampowered.com/app/${gameId}`,
  5424. method: 'GET'
  5425. });
  5426. if (resultR === 'Success') {
  5427. if ((dataR === null || dataR === void 0 ? void 0 : dataR.status) === 200) {
  5428. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && dataR.responseText.includes('id="error_box"')) {
  5429. logStatus.warning(i18n('changeAreaNotice'));
  5430. const result = await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this);
  5431. if (!result || result === 'CN' || result === 'skip') {
  5432. return false;
  5433. }
  5434. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5435. }
  5436. if (dataR.responseText.includes('class="queue_actions_ctn"') && (dataR.responseText.includes('ds_owned_flag ds_flag') || dataR.responseText.includes('add_to_wishlist_area'))) {
  5437. logStatus.success();
  5438. return true;
  5439. }
  5440. logStatus.error(`Error:${dataR.statusText}(${dataR.status})`);
  5441. return false;
  5442. }
  5443. logStatus.error(`Error:${dataR === null || dataR === void 0 ? void 0 : dataR.statusText}(${dataR === null || dataR === void 0 ? void 0 : dataR.status})`);
  5444. return false;
  5445. }
  5446. logStatus.error(`${resultR}:${statusTextR}(${statusR})`);
  5447. return false;
  5448. } catch (error) {
  5449. throwError(error, 'Steam.removeFromWishlist');
  5450. return false;
  5451. }
  5452. }
  5453. async function _toggleFollowGame2(gameId, doTask) {
  5454. try {
  5455. if (!doTask && this.whiteList.follows.includes(gameId)) {
  5456. scripts_echoLog({
  5457. type: 'whiteList',
  5458. text: 'Steam.unfollowGame',
  5459. id: gameId
  5460. });
  5461. return true;
  5462. }
  5463. const logStatus = scripts_echoLog({
  5464. type: `${doTask ? '' : 'un'}followingGame`,
  5465. text: gameId
  5466. });
  5467. const requestData = {
  5468. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5469. appid: gameId
  5470. };
  5471. if (!doTask) {
  5472. requestData.unfollow = '1';
  5473. }
  5474. const {
  5475. result,
  5476. data
  5477. } = await tools_httpRequest({
  5478. url: 'https://store.steampowered.com/explore/followgame/',
  5479. method: 'POST',
  5480. headers: {
  5481. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5482. },
  5483. data: $.param(requestData)
  5484. });
  5485. if (result === 'Success' && (data === null || data === void 0 ? void 0 : data.status) === 200 && data.responseText === 'true') {
  5486. logStatus.success();
  5487. return true;
  5488. }
  5489. const followed = await Steam_classPrivateMethodGet(this, _isFollowedGame, _isFollowedGame2).call(this, gameId);
  5490. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && followed === 'areaLocked') {
  5491. logStatus.warning(i18n('changeAreaNotice'));
  5492. if (!await Steam_classPrivateMethodGet(this, _changeArea, _changeArea2).call(this)) {
  5493. return false;
  5494. }
  5495. return await Steam_classPrivateMethodGet(this, _removeFromWishlist, _removeFromWishlist2).call(this, gameId);
  5496. }
  5497. if (doTask === followed) {
  5498. logStatus.success();
  5499. if (doTask) {
  5500. this.tasks.follows = unique([ ...this.tasks.follows, gameId ]);
  5501. }
  5502. return true;
  5503. }
  5504. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5505. return false;
  5506. } catch (error) {
  5507. throwError(error, 'Steam.toggleFollowGame');
  5508. return false;
  5509. }
  5510. }
  5511. async function _isFollowedGame2(gameId) {
  5512. try {
  5513. const {
  5514. result,
  5515. data
  5516. } = await tools_httpRequest({
  5517. url: `https://store.steampowered.com/app/${gameId}`,
  5518. method: 'GET'
  5519. });
  5520. if (result === 'Success') {
  5521. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5522. if (Steam_classPrivateFieldGet(this, _area) === 'CN' && data.responseText.includes('id="error_box"')) {
  5523. return 'areaLocked';
  5524. }
  5525. if ($(data.responseText.replace(/<img.*?>/g, '')).find('.queue_control_button.queue_btn_follow>.btnv6_blue_hoverfade.btn_medium.queue_btn_active').css('display') !== 'none') {
  5526. return true;
  5527. }
  5528. return false;
  5529. }
  5530. return false;
  5531. }
  5532. return false;
  5533. } catch (error) {
  5534. throwError(error, 'Steam.isFollowedGame');
  5535. return false;
  5536. }
  5537. }
  5538. async function _toggleForum2(gameId) {
  5539. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5540. try {
  5541. if (!doTask && this.whiteList.forums.includes(gameId)) {
  5542. scripts_echoLog({
  5543. type: 'whiteList',
  5544. text: 'Steam.unsubscribeForum',
  5545. id: gameId
  5546. });
  5547. return true;
  5548. }
  5549. const forumId = await Steam_classPrivateMethodGet(this, _getForumId, _getForumId2).call(this, gameId);
  5550. if (!forumId) {
  5551. return false;
  5552. }
  5553. const logStatus = scripts_echoLog({
  5554. type: `${doTask ? '' : 'un'}subscribingForum`,
  5555. text: gameId
  5556. });
  5557. const [ id, feature ] = forumId.split('_');
  5558. const {
  5559. result,
  5560. statusText,
  5561. status,
  5562. data
  5563. } = await tools_httpRequest({
  5564. url: `https://steamcommunity.com/forum/${id}/General/${doTask ? '' : 'un'}subscribe/${feature || '0'}/`,
  5565. method: 'POST',
  5566. responseType: 'json',
  5567. headers: {
  5568. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5569. },
  5570. data: $.param({
  5571. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5572. })
  5573. });
  5574. if (result === 'Success') {
  5575. var _data$response3, _data$response4;
  5576. 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)) {
  5577. if (doTask) {
  5578. this.tasks.forums = unique([ ...this.tasks.forums, gameId ]);
  5579. }
  5580. logStatus.success();
  5581. return true;
  5582. }
  5583. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5584. return true;
  5585. }
  5586. logStatus.error(`${result}:${statusText}(${status})`);
  5587. return true;
  5588. } catch (error) {
  5589. throwError(error, 'Steam.toggleForum');
  5590. return true;
  5591. }
  5592. }
  5593. async function _getForumId2(gameId) {
  5594. try {
  5595. const logStatus = scripts_echoLog({
  5596. type: 'gettingForumId',
  5597. text: gameId
  5598. });
  5599. const forumId = Steam_classPrivateFieldGet(this, Steam_cache).forum[gameId];
  5600. if (forumId) {
  5601. logStatus.success();
  5602. return forumId;
  5603. }
  5604. const {
  5605. result,
  5606. statusText,
  5607. status,
  5608. data
  5609. } = await tools_httpRequest({
  5610. url: `https://steamcommunity.com/app/${gameId}/discussions/`,
  5611. method: 'GET'
  5612. });
  5613. if (result === 'Success') {
  5614. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5615. var _data$responseText, _data$responseText$ma8;
  5616. const forumId = (_data$responseText = data.responseText) === null || _data$responseText === void 0 ? void 0 : (_data$responseText$ma8 = _data$responseText.match(/General_([\d]+(_[\d]+)?)/)) === null || _data$responseText$ma8 === void 0 ? void 0 : _data$responseText$ma8[1];
  5617. if (forumId) {
  5618. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'forum', gameId, forumId);
  5619. logStatus.success();
  5620. return forumId;
  5621. }
  5622. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5623. return false;
  5624. }
  5625. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5626. return false;
  5627. }
  5628. logStatus.error(`${result}:${statusText}(${status})`);
  5629. return false;
  5630. } catch (error) {
  5631. throwError(error, 'Steam.getForumId');
  5632. return false;
  5633. }
  5634. }
  5635. async function _toggleFavoriteWorkshop2(id) {
  5636. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5637. try {
  5638. if (!doTask && this.whiteList.workshops.includes(id)) {
  5639. scripts_echoLog({
  5640. type: 'whiteList',
  5641. text: 'Steam.unfavoriteWorkshop',
  5642. id: id
  5643. });
  5644. return true;
  5645. }
  5646. const appid = await Steam_classPrivateMethodGet(this, _getWorkshopAppId, _getWorkshopAppId2).call(this, id);
  5647. if (!appid) {
  5648. return false;
  5649. }
  5650. const logStatus = scripts_echoLog({
  5651. type: doTask ? 'favoritingWorkshop' : 'unfavoritingWorkshop',
  5652. text: id
  5653. });
  5654. const {
  5655. result,
  5656. statusText,
  5657. status,
  5658. data
  5659. } = await tools_httpRequest({
  5660. url: `https://steamcommunity.com/sharedfiles/${doTask ? '' : 'un'}favorite`,
  5661. method: 'POST',
  5662. headers: {
  5663. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5664. },
  5665. data: $.param({
  5666. id: id,
  5667. appid: appid,
  5668. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5669. })
  5670. });
  5671. if (result === 'Success') {
  5672. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && !data.responseText) {
  5673. if (doTask) {
  5674. this.tasks.workshops = unique([ ...this.tasks.workshops, id ]);
  5675. }
  5676. logStatus.success();
  5677. return true;
  5678. }
  5679. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5680. return false;
  5681. }
  5682. logStatus.error(`${result}:${statusText}(${status})`);
  5683. return false;
  5684. } catch (error) {
  5685. throwError(error, 'Steam.toggleFavoriteWorkshop');
  5686. return false;
  5687. }
  5688. }
  5689. async function _getWorkshopAppId2(id) {
  5690. try {
  5691. const logStatus = scripts_echoLog({
  5692. type: 'gettingWorkshopAppId',
  5693. text: id
  5694. });
  5695. const appId = Steam_classPrivateFieldGet(this, Steam_cache).workshop[id];
  5696. if (appId) {
  5697. logStatus.success();
  5698. return appId;
  5699. }
  5700. const {
  5701. result,
  5702. statusText,
  5703. status,
  5704. data
  5705. } = await tools_httpRequest({
  5706. url: `https://steamcommunity.com/sharedfiles/filedetails/?id=${id}`,
  5707. method: 'GET'
  5708. });
  5709. if (result === 'Success') {
  5710. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5711. var _data$responseText$ma9;
  5712. const appId = (_data$responseText$ma9 = data.responseText.match(/<input type="hidden" name="appid" value="([\d]+?)" \/>/)) === null || _data$responseText$ma9 === void 0 ? void 0 : _data$responseText$ma9[1];
  5713. if (appId) {
  5714. Steam_classPrivateMethodGet(this, Steam_setCache, Steam_setCache2).call(this, 'workshop', id, appId);
  5715. logStatus.success();
  5716. return appId;
  5717. }
  5718. logStatus.error('Error: getWorkshopAppId failed');
  5719. return false;
  5720. }
  5721. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5722. return false;
  5723. }
  5724. logStatus.error(`${result}:${statusText}(${status})`);
  5725. return false;
  5726. } catch (error) {
  5727. throwError(error, 'Steam.getWorkshopAppId');
  5728. return false;
  5729. }
  5730. }
  5731. async function _voteUpWorkshop2(id) {
  5732. try {
  5733. const logStatus = scripts_echoLog({
  5734. type: 'votingUpWorkshop',
  5735. text: id
  5736. });
  5737. const {
  5738. result,
  5739. statusText,
  5740. status,
  5741. data
  5742. } = await tools_httpRequest({
  5743. url: 'https://steamcommunity.com/sharedfiles/voteup',
  5744. method: 'POST',
  5745. responseType: 'json',
  5746. headers: {
  5747. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5748. },
  5749. data: $.param({
  5750. id: id,
  5751. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).communitySessionID
  5752. })
  5753. });
  5754. if (result === 'Success') {
  5755. var _data$response5;
  5756. 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) {
  5757. logStatus.success();
  5758. return true;
  5759. }
  5760. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5761. return true;
  5762. }
  5763. logStatus.error(`${result}:${statusText}(${status})`);
  5764. return true;
  5765. } catch (error) {
  5766. throwError(error, 'Steam.voteupWorkshop');
  5767. return true;
  5768. }
  5769. }
  5770. async function _toggleCurator2(curatorId) {
  5771. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5772. try {
  5773. if (!doTask && this.whiteList.curators.includes(curatorId)) {
  5774. scripts_echoLog({
  5775. type: 'whiteList',
  5776. text: 'Steam.unfollowCurator',
  5777. id: curatorId
  5778. });
  5779. return true;
  5780. }
  5781. const logStatus = scripts_echoLog({
  5782. type: doTask ? 'followingCurator' : 'unfollowingCurator',
  5783. text: curatorId
  5784. });
  5785. const {
  5786. result,
  5787. statusText,
  5788. status,
  5789. data
  5790. } = await tools_httpRequest({
  5791. url: 'https://store.steampowered.com/curators/ajaxfollow',
  5792. method: 'POST',
  5793. headers: {
  5794. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5795. },
  5796. data: $.param({
  5797. clanid: curatorId,
  5798. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5799. follow: doTask
  5800. }),
  5801. dataType: 'json'
  5802. });
  5803. if (result === 'Success') {
  5804. var _data$response6, _data$response6$succe, _data$response7;
  5805. 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) {
  5806. logStatus.success();
  5807. return true;
  5808. }
  5809. 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})`);
  5810. return false;
  5811. }
  5812. logStatus.error(`${result}:${statusText}(${status})`);
  5813. return false;
  5814. } catch (error) {
  5815. throwError(error, 'Steam.toggleCurator');
  5816. return false;
  5817. }
  5818. }
  5819. async function _toggleCuratorLike2(link) {
  5820. let doTask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5821. try {
  5822. const [ path, name ] = link.split('/');
  5823. if (!(path && name)) {
  5824. scripts_echoLog({
  5825. text: i18n('errorLink', link)
  5826. });
  5827. return false;
  5828. }
  5829. const curatorId = await this.getCuratorId(path, name);
  5830. if (curatorId) {
  5831. return await Steam_classPrivateMethodGet(this, _toggleCurator, _toggleCurator2).call(this, curatorId, doTask);
  5832. }
  5833. return false;
  5834. } catch (error) {
  5835. throwError(error, 'Steam.toggleCuratorLike');
  5836. return false;
  5837. }
  5838. }
  5839. async function _getAnnouncementParams2(appId, viewId) {
  5840. try {
  5841. const logStatus = scripts_echoLog({
  5842. type: 'gettingAnnouncementParams',
  5843. text: appId,
  5844. id: viewId
  5845. });
  5846. const {
  5847. result,
  5848. statusText,
  5849. status,
  5850. data
  5851. } = await tools_httpRequest({
  5852. url: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`,
  5853. method: 'GET',
  5854. headers: {
  5855. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  5856. }
  5857. });
  5858. if (result === 'Success') {
  5859. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  5860. var _data$responseText$ma10, _data$responseText$ma11, _data$responseText$ma12;
  5861. const authWgToken = (_data$responseText$ma10 = data.responseText.match(/authwgtoken&quot;:&quot;(.*?)&quot;/)) === null || _data$responseText$ma10 === void 0 ? void 0 : _data$responseText$ma10[1];
  5862. const clanId = (_data$responseText$ma11 = data.responseText.match(/clanAccountID&quot;:([\d]+?),/)) === null || _data$responseText$ma11 === void 0 ? void 0 : _data$responseText$ma11[1];
  5863. const gid = (_data$responseText$ma12 = data.responseText.match(/announcementGID&quot;:&quot;([\d]+?)&quot;/)) === null || _data$responseText$ma12 === void 0 ? void 0 : _data$responseText$ma12[1];
  5864. if (authWgToken && clanId) {
  5865. logStatus.success();
  5866. return {
  5867. authWgToken: authWgToken,
  5868. clanId: clanId,
  5869. gid: gid
  5870. };
  5871. }
  5872. logStatus.error(`Error:${data.statusText}(${data.status})`);
  5873. return {};
  5874. }
  5875. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5876. return {};
  5877. }
  5878. logStatus.error(`${result}:${statusText}(${status})`);
  5879. return {};
  5880. } catch (error) {
  5881. throwError(error, 'Steam.likeAnnouncement');
  5882. return {};
  5883. }
  5884. }
  5885. async function _likeAnnouncement2(id) {
  5886. try {
  5887. const [ appId, viewId ] = id.split('/');
  5888. if (!(appId && viewId)) {
  5889. scripts_echoLog({
  5890. type: 'lost params',
  5891. text: id
  5892. });
  5893. return false;
  5894. }
  5895. const {
  5896. authWgToken,
  5897. clanId,
  5898. gid
  5899. } = await Steam_classPrivateMethodGet(this, _getAnnouncementParams, _getAnnouncementParams2).call(this, appId, viewId);
  5900. if (!(authWgToken && clanId)) {
  5901. return false;
  5902. }
  5903. const logStatus = scripts_echoLog({
  5904. type: 'likingAnnouncement',
  5905. text: appId,
  5906. id: viewId
  5907. });
  5908. const {
  5909. result,
  5910. statusText,
  5911. status,
  5912. data
  5913. } = await tools_httpRequest({
  5914. url: `https://store.steampowered.com/updated/ajaxrateupdate/${gid || viewId}`,
  5915. method: 'POST',
  5916. headers: {
  5917. 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  5918. Host: 'store.steampowered.com',
  5919. Origin: 'https://store.steampowered.com',
  5920. Referer: `https://store.steampowered.com/news/app/${appId}/view/${viewId}`
  5921. },
  5922. data: $.param({
  5923. sessionid: Steam_classPrivateFieldGet(this, Steam_auth).storeSessionID,
  5924. wgauthtoken: authWgToken,
  5925. voteup: 1,
  5926. clanid: clanId,
  5927. ajax: 1
  5928. }),
  5929. dataType: 'json'
  5930. });
  5931. if (result === 'Success') {
  5932. if ((data === null || data === void 0 ? void 0 : data.status) === 200 && data.response.success === 1) {
  5933. logStatus.success();
  5934. return true;
  5935. }
  5936. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  5937. return false;
  5938. }
  5939. logStatus.error(`${result}:${statusText}(${status})`);
  5940. return false;
  5941. } catch (error) {
  5942. throwError(error, 'Steam.likeAnnouncement');
  5943. return false;
  5944. }
  5945. }
  5946. function Steam_setCache2(type, name, id) {
  5947. try {
  5948. Steam_classPrivateFieldGet(this, Steam_cache)[type][name] = id;
  5949. GM_setValue('steamCache', Steam_classPrivateFieldGet(this, Steam_cache));
  5950. } catch (error) {
  5951. throwError(error, 'Steam.setCache');
  5952. }
  5953. }
  5954. const social_Steam = Steam;
  5955. function Website_classPrivateMethodInitSpec(obj, privateSet) {
  5956. Website_checkPrivateRedeclaration(obj, privateSet);
  5957. privateSet.add(obj);
  5958. }
  5959. function Website_checkPrivateRedeclaration(obj, privateCollection) {
  5960. if (privateCollection.has(obj)) {
  5961. throw new TypeError('Cannot initialize the same private elements twice on an object');
  5962. }
  5963. }
  5964. function Website_defineProperty(obj, key, value) {
  5965. if (key in obj) {
  5966. Object.defineProperty(obj, key, {
  5967. value: value,
  5968. enumerable: true,
  5969. configurable: true,
  5970. writable: true
  5971. });
  5972. } else {
  5973. obj[key] = value;
  5974. }
  5975. return obj;
  5976. }
  5977. function Website_classPrivateMethodGet(receiver, privateSet, fn) {
  5978. if (!privateSet.has(receiver)) {
  5979. throw new TypeError('attempted to get private field on non-instance');
  5980. }
  5981. return fn;
  5982. }
  5983. var _bind = new WeakSet();
  5984. class Website {
  5985. constructor() {
  5986. Website_classPrivateMethodInitSpec(this, _bind);
  5987. Website_defineProperty(this, 'undoneTasks', void 0);
  5988. Website_defineProperty(this, 'socialTasks', void 0);
  5989. Website_defineProperty(this, 'giveawayId', void 0);
  5990. Website_defineProperty(this, 'socialInitialized', {
  5991. discord: false,
  5992. instagram: false,
  5993. reddit: false,
  5994. twitch: false,
  5995. twitter: false,
  5996. vk: false,
  5997. youtube: false,
  5998. steam: false
  5999. });
  6000. Website_defineProperty(this, 'initialized', false);
  6001. Website_defineProperty(this, 'social', {});
  6002. }
  6003. async initSocial(action) {
  6004. try {
  6005. const pro = [];
  6006. const tasks = action === 'do' ? this.undoneTasks : this.socialTasks;
  6007. if (tasks.discord) {
  6008. const hasDiscord = Object.values(tasks.discord).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6009. if (hasDiscord && !this.socialInitialized.discord) {
  6010. this.social.discord = new social_Discord();
  6011. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'discord', this.social.discord.init()));
  6012. }
  6013. }
  6014. if (tasks.instagram) {
  6015. const hasInstagram = Object.values(tasks.instagram).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6016. if (hasInstagram && !this.socialInitialized.instagram) {
  6017. this.social.instagram = new social_Instagram();
  6018. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'instagram', this.social.instagram.init()));
  6019. }
  6020. }
  6021. if (tasks.reddit) {
  6022. const hasReddit = Object.values(tasks.reddit).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6023. if (hasReddit && !this.socialInitialized.reddit) {
  6024. this.social.reddit = new social_Reddit();
  6025. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'reddit', this.social.reddit.init()));
  6026. }
  6027. }
  6028. if (tasks.twitch) {
  6029. const hasTwitch = Object.values(tasks.twitch).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6030. if (hasTwitch && !this.socialInitialized.twitch) {
  6031. this.social.twitch = new social_Twitch();
  6032. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitch', this.social.twitch.init()));
  6033. }
  6034. }
  6035. if (tasks.twitter) {
  6036. const hasTwitter = Object.values(tasks.twitter).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6037. if (hasTwitter && !this.socialInitialized.twitter) {
  6038. this.social.twitter = new social_Twitter();
  6039. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'twitter', this.social.twitter.init()));
  6040. }
  6041. }
  6042. if (tasks.vk) {
  6043. const hasVk = Object.values(tasks.vk).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6044. if (hasVk && !this.socialInitialized.vk) {
  6045. this.social.vk = new social_Vk();
  6046. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'vk', this.social.vk.init()));
  6047. }
  6048. }
  6049. if (tasks.youtube) {
  6050. const hasYoutube = Object.values(tasks.youtube).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6051. if (hasYoutube && !this.socialInitialized.youtube) {
  6052. this.social.youtube = new Youtube();
  6053. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'youtube', this.social.youtube.init()));
  6054. }
  6055. }
  6056. if (tasks.steam) {
  6057. const hasSteam = Object.values(tasks.steam).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6058. if (hasSteam && !this.socialInitialized.steam) {
  6059. this.social.steam = new social_Steam();
  6060. pro.push(Website_classPrivateMethodGet(this, _bind, _bind2).call(this, 'steam', this.social.steam.init()));
  6061. }
  6062. }
  6063. if (tasks.links && tasks.links.length > 0) {
  6064. this.social.visitLink = visitLink;
  6065. }
  6066. return await Promise.all(pro).then(result => {
  6067. let checked = true;
  6068. for (const data of result) {
  6069. if (data.result) {
  6070. this.socialInitialized[data.name] = data.result;
  6071. } else {
  6072. checked = false;
  6073. }
  6074. }
  6075. return checked;
  6076. });
  6077. } catch (error) {
  6078. throwError(error, 'Website.initSocial');
  6079. return false;
  6080. }
  6081. }
  6082. uniqueTasks(allTasks) {
  6083. const result = {};
  6084. for (const [ social, types ] of Object.entries(allTasks)) {
  6085. result[social] = {};
  6086. for (const [ type, tasks ] of Object.entries(types)) {
  6087. result[social][type] = unique(tasks);
  6088. }
  6089. }
  6090. return result;
  6091. }
  6092. async toggleTask(action) {
  6093. try {
  6094. if (!this.initialized && !this.init()) {
  6095. return false;
  6096. }
  6097. if (!await this.classifyTask(action)) {
  6098. return false;
  6099. }
  6100. if (!await this.initSocial(action)) {
  6101. return false;
  6102. }
  6103. const pro = [];
  6104. const doTask = action === 'do';
  6105. const tasks = doTask ? this.undoneTasks : this.socialTasks;
  6106. if (this.social.discord) {
  6107. pro.push(this.social.discord.toggle({
  6108. doTask: doTask,
  6109. ...tasks.discord
  6110. }));
  6111. }
  6112. if (this.social.instagram) {
  6113. pro.push(this.social.instagram.toggle({
  6114. doTask: doTask,
  6115. ...tasks.instagram
  6116. }));
  6117. }
  6118. if (this.social.reddit) {
  6119. pro.push(this.social.reddit.toggle({
  6120. doTask: doTask,
  6121. ...tasks.reddit
  6122. }));
  6123. }
  6124. if (this.social.twitch) {
  6125. pro.push(this.social.twitch.toggle({
  6126. doTask: doTask,
  6127. ...tasks.twitch
  6128. }));
  6129. }
  6130. if (this.social.twitter) {
  6131. pro.push(this.social.twitter.toggle({
  6132. doTask: doTask,
  6133. ...tasks.twitter
  6134. }));
  6135. }
  6136. if (this.social.vk) {
  6137. pro.push(this.social.vk.toggle({
  6138. doTask: doTask,
  6139. ...tasks.vk
  6140. }));
  6141. }
  6142. if (this.social.youtube) {
  6143. pro.push(this.social.youtube.toggle({
  6144. doTask: doTask,
  6145. ...tasks.youtube
  6146. }));
  6147. }
  6148. if (this.social.steam) {
  6149. pro.push(this.social.steam.toggle({
  6150. doTask: doTask,
  6151. ...tasks.steam
  6152. }));
  6153. }
  6154. if (this.social.visitLink && tasks.links && doTask) {
  6155. for (const link of tasks.links) {
  6156. pro.push(this.social.visitLink(link));
  6157. }
  6158. }
  6159. if (doTask && tasks.extra && this.extraDoTask) {
  6160. const hasExtra = Object.values(tasks.extra).reduce((total, arr) => [ ...total, ...arr ]).length > 0;
  6161. if (hasExtra) {
  6162. pro.push(this.extraDoTask(tasks.extra));
  6163. }
  6164. }
  6165. await Promise.all(pro);
  6166. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6167. return true;
  6168. } catch (error) {
  6169. throwError(error, 'Website.toggleTask');
  6170. return false;
  6171. }
  6172. }
  6173. async doTask() {
  6174. try {
  6175. return await this.toggleTask('do');
  6176. } catch (error) {
  6177. throwError(error, 'Website.doTask');
  6178. return false;
  6179. }
  6180. }
  6181. async undoTask() {
  6182. try {
  6183. return await this.toggleTask('undo');
  6184. } catch (error) {
  6185. throwError(error, 'Website.undoTask');
  6186. return false;
  6187. }
  6188. }
  6189. }
  6190. async function _bind2(name, init) {
  6191. try {
  6192. return {
  6193. name: name,
  6194. result: await init
  6195. };
  6196. } catch (error) {
  6197. throwError(error, 'Website.bind');
  6198. return {
  6199. name: name,
  6200. result: false
  6201. };
  6202. }
  6203. }
  6204. const website_Website = Website;
  6205. function FreeAnyWhere_classPrivateMethodInitSpec(obj, privateSet) {
  6206. FreeAnyWhere_checkPrivateRedeclaration(obj, privateSet);
  6207. privateSet.add(obj);
  6208. }
  6209. function FreeAnyWhere_checkPrivateRedeclaration(obj, privateCollection) {
  6210. if (privateCollection.has(obj)) {
  6211. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6212. }
  6213. }
  6214. function FreeAnyWhere_defineProperty(obj, key, value) {
  6215. if (key in obj) {
  6216. Object.defineProperty(obj, key, {
  6217. value: value,
  6218. enumerable: true,
  6219. configurable: true,
  6220. writable: true
  6221. });
  6222. } else {
  6223. obj[key] = value;
  6224. }
  6225. return obj;
  6226. }
  6227. function FreeAnyWhere_classPrivateMethodGet(receiver, privateSet, fn) {
  6228. if (!privateSet.has(receiver)) {
  6229. throw new TypeError('attempted to get private field on non-instance');
  6230. }
  6231. return fn;
  6232. }
  6233. const FreeAnyWhere_defaultTasks = {
  6234. steam: {
  6235. groupLinks: [],
  6236. wishlistLinks: [],
  6237. curatorLinks: [],
  6238. followLinks: []
  6239. },
  6240. vk: {
  6241. nameLinks: []
  6242. }
  6243. };
  6244. var _getGiveawayId = new WeakSet();
  6245. var _verify = new WeakSet();
  6246. class FreeAnyWhere extends website_Website {
  6247. constructor() {
  6248. super(...arguments);
  6249. FreeAnyWhere_classPrivateMethodInitSpec(this, _verify);
  6250. FreeAnyWhere_classPrivateMethodInitSpec(this, _getGiveawayId);
  6251. FreeAnyWhere_defineProperty(this, 'name', 'FreeAnyWhere');
  6252. FreeAnyWhere_defineProperty(this, 'tasks', []);
  6253. FreeAnyWhere_defineProperty(this, 'socialTasks', {
  6254. ...FreeAnyWhere_defaultTasks
  6255. });
  6256. FreeAnyWhere_defineProperty(this, 'undoneTasks', {
  6257. ...FreeAnyWhere_defaultTasks
  6258. });
  6259. FreeAnyWhere_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask', 'getKey' ]);
  6260. }
  6261. static test() {
  6262. return window.location.host === 'freeanywhere.net';
  6263. }
  6264. init() {
  6265. try {
  6266. const logStatus = scripts_echoLog({
  6267. text: i18n('initing')
  6268. });
  6269. if ($('a[href="#/login"]').length > 0) {
  6270. window.open('/#/login', '_self');
  6271. logStatus.warning(i18n('needLogin'));
  6272. return false;
  6273. }
  6274. if (window.location.href.includes('/login')) {
  6275. logStatus.warning(i18n('needLogin'));
  6276. return false;
  6277. }
  6278. if (!/^https?:\/\/freeanywhere\.net\/#\/giveaway\/[\d]+/.test(window.location.href)) {
  6279. var _window$location$href;
  6280. 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];
  6281. if (!id) {
  6282. logStatus.error(i18n('getFailed', 'Id'));
  6283. return false;
  6284. }
  6285. window.location.href = `https://freeanywhere.net/#/giveaway/${id}`;
  6286. }
  6287. if (!FreeAnyWhere_classPrivateMethodGet(this, _getGiveawayId, _getGiveawayId2).call(this)) {
  6288. return false;
  6289. }
  6290. this.initialized = true;
  6291. logStatus.success();
  6292. return true;
  6293. } catch (error) {
  6294. throwError(error, 'Freeanywhere.init');
  6295. return false;
  6296. }
  6297. }
  6298. async classifyTask(action) {
  6299. try {
  6300. const logStatus = scripts_echoLog({
  6301. text: i18n('getTasksInfo')
  6302. });
  6303. if (action === 'undo') {
  6304. var _GM_getValue;
  6305. this.socialTasks = ((_GM_getValue = GM_getValue(`fawTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  6306. ...FreeAnyWhere_defaultTasks
  6307. };
  6308. }
  6309. const {
  6310. result,
  6311. statusText,
  6312. status,
  6313. data
  6314. } = await tools_httpRequest({
  6315. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/?format=json`,
  6316. method: 'GET',
  6317. headers: {
  6318. authorization: `Token ${window.localStorage.getItem('token')}`,
  6319. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6320. },
  6321. responseType: 'json'
  6322. });
  6323. if (result === 'Success') {
  6324. var _data$response;
  6325. const tasks = data === null || data === void 0 ? void 0 : (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.challenges;
  6326. if (tasks) {
  6327. if (action === 'verify') {
  6328. this.tasks = [];
  6329. }
  6330. for (const task of tasks) {
  6331. const type = task.challenge;
  6332. const social = task.challenge_provider;
  6333. const taskInfo = {
  6334. id: task.id,
  6335. title: task.title
  6336. };
  6337. if (action === 'verify' && !task.is_success) {
  6338. this.tasks.push(taskInfo);
  6339. continue;
  6340. }
  6341. switch (social) {
  6342. case 'steam':
  6343. taskInfo.social = 'steam';
  6344. switch (type) {
  6345. case 'WL':
  6346. if (action === 'undo') {
  6347. this.socialTasks.steam.wishlistLinks.push(task.link);
  6348. }
  6349. if (action === 'do' && !task.is_success) {
  6350. this.undoneTasks.steam.wishlistLinks.push(task.link);
  6351. }
  6352. break;
  6353.  
  6354. case 'JTG':
  6355. if (action === 'undo') {
  6356. this.socialTasks.steam.groupLinks.push(task.link);
  6357. }
  6358. if (action === 'do' && !task.is_success) {
  6359. this.undoneTasks.steam.groupLinks.push(task.link);
  6360. }
  6361. break;
  6362.  
  6363. case 'STC':
  6364. if (action === 'undo') {
  6365. this.socialTasks.steam.curatorLinks.push(task.link);
  6366. }
  6367. if (action === 'do' && !task.is_success) {
  6368. this.undoneTasks.steam.curatorLinks.push(task.link);
  6369. }
  6370. break;
  6371.  
  6372. case 'GF':
  6373. if (action === 'undo') {
  6374. this.socialTasks.steam.followLinks.push(task.link);
  6375. }
  6376. if (action === 'do' && !task.is_success) {
  6377. this.undoneTasks.steam.followLinks.push(task.link);
  6378. }
  6379. break;
  6380. }
  6381. break;
  6382.  
  6383. case 'vk-oauth2':
  6384. if (action === 'undo') {
  6385. this.socialTasks.vk.nameLinks.push(task.link);
  6386. }
  6387. if (action === 'do' && !task.is_success) {
  6388. this.undoneTasks.vk.nameLinks.push(task.link);
  6389. }
  6390. break;
  6391.  
  6392. case 'website':
  6393. break;
  6394.  
  6395. default:
  6396. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${social}`);
  6397. break;
  6398. }
  6399. }
  6400. logStatus.success();
  6401. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6402. this.socialTasks = this.uniqueTasks(this.socialTasks);
  6403. GM_setValue(`fawTasks-${this.giveawayId}`, {
  6404. tasks: this.socialTasks,
  6405. time: new Date().getTime()
  6406. });
  6407. return true;
  6408. }
  6409. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6410. console.error(data);
  6411. return false;
  6412. }
  6413. logStatus.error(`${result}:${statusText}(${status})`);
  6414. return false;
  6415. } catch (error) {
  6416. throwError(error, 'Freeanywhere.classifyTask');
  6417. return false;
  6418. }
  6419. }
  6420. async verifyTask() {
  6421. try {
  6422. if (!this.initialized && !this.init()) {
  6423. return false;
  6424. }
  6425. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  6426. return false;
  6427. }
  6428. const pro = [];
  6429. for (const task of this.tasks) {
  6430. pro.push(FreeAnyWhere_classPrivateMethodGet(this, _verify, _verify2).call(this, task));
  6431. await delay(1e3);
  6432. }
  6433. await Promise.all(pro);
  6434. scripts_echoLog({}).success(i18n('allTasksComplete'));
  6435. return !!await this.getKey(true);
  6436. } catch (error) {
  6437. throwError(error, 'Freeanywhere.verifyTask');
  6438. return false;
  6439. }
  6440. }
  6441. async getKey(initialized) {
  6442. try {
  6443. if (!initialized && !this.initialized && !this.init()) {
  6444. return false;
  6445. }
  6446. const logStatus = scripts_echoLog({
  6447. text: i18n('gettingKey')
  6448. });
  6449. const {
  6450. result,
  6451. statusText,
  6452. status,
  6453. data
  6454. } = await tools_httpRequest({
  6455. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/reward/?format=json`,
  6456. method: 'GET',
  6457. dataType: 'json',
  6458. headers: {
  6459. authorization: `Token ${window.localStorage.getItem('token')}`
  6460. }
  6461. });
  6462. if (result === 'Success') {
  6463. var _data$response2;
  6464. if (data !== null && data !== void 0 && (_data$response2 = data.response) !== null && _data$response2 !== void 0 && _data$response2.reward) {
  6465. logStatus.success();
  6466. scripts_echoLog({}).success(data.response.reward);
  6467. return data.response.reward;
  6468. }
  6469. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6470. return false;
  6471. }
  6472. logStatus.error(`${result}:${statusText}(${status})`);
  6473. return false;
  6474. } catch (error) {
  6475. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6476. return false;
  6477. }
  6478. }
  6479. }
  6480. function _getGiveawayId2() {
  6481. try {
  6482. var _window$location$href2;
  6483. const giveawayId = (_window$location$href2 = window.location.href.match(/\/giveaway\/([\d]+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1];
  6484. if (giveawayId) {
  6485. this.giveawayId = giveawayId;
  6486. return true;
  6487. }
  6488. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  6489. return false;
  6490. } catch (error) {
  6491. throwError(error, 'FreeAnyWhere.getGiveawayId');
  6492. }
  6493. }
  6494. async function _verify2(task) {
  6495. try {
  6496. const logStatus = scripts_echoLog({
  6497. html: `<li>${i18n('verifyingTask')}${task.title.trim()}...<font></font></li>`
  6498. });
  6499. const {
  6500. result,
  6501. statusText,
  6502. status,
  6503. data
  6504. } = await tools_httpRequest({
  6505. url: `https://freeanywhere.net/api/v1/giveaway/${this.giveawayId}/challenge-status/${task.id}/?format=json`,
  6506. method: 'GET',
  6507. dataType: 'json',
  6508. headers: {
  6509. authorization: `Token ${window.localStorage.getItem('token')}`,
  6510. 'x-csrftoken': external_Cookies_namespaceObject.get('csrftoken')
  6511. }
  6512. });
  6513. if (result === 'Success') {
  6514. var _data$response3;
  6515. if (data !== null && data !== void 0 && (_data$response3 = data.response) !== null && _data$response3 !== void 0 && _data$response3.status) {
  6516. logStatus.success();
  6517. return true;
  6518. }
  6519. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6520. return false;
  6521. }
  6522. logStatus.error(`${result}:${statusText}(${status})`);
  6523. return false;
  6524. } catch (error) {
  6525. throwError(error, 'Freeanywhere.verify');
  6526. return false;
  6527. }
  6528. }
  6529. const website_FreeAnyWhere = FreeAnyWhere;
  6530. function GiveawaySu_classPrivateMethodInitSpec(obj, privateSet) {
  6531. GiveawaySu_checkPrivateRedeclaration(obj, privateSet);
  6532. privateSet.add(obj);
  6533. }
  6534. function GiveawaySu_checkPrivateRedeclaration(obj, privateCollection) {
  6535. if (privateCollection.has(obj)) {
  6536. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6537. }
  6538. }
  6539. function GiveawaySu_defineProperty(obj, key, value) {
  6540. if (key in obj) {
  6541. Object.defineProperty(obj, key, {
  6542. value: value,
  6543. enumerable: true,
  6544. configurable: true,
  6545. writable: true
  6546. });
  6547. } else {
  6548. obj[key] = value;
  6549. }
  6550. return obj;
  6551. }
  6552. function GiveawaySu_classPrivateMethodGet(receiver, privateSet, fn) {
  6553. if (!privateSet.has(receiver)) {
  6554. throw new TypeError('attempted to get private field on non-instance');
  6555. }
  6556. return fn;
  6557. }
  6558. const GiveawaySu_defaultTasks = {
  6559. steam: {
  6560. groupLinks: [],
  6561. wishlistLinks: [],
  6562. curatorLinks: [],
  6563. curatorLikeLinks: [],
  6564. followLinks: [],
  6565. forumLinks: [],
  6566. announcementLinks: [],
  6567. workshopVoteLinks: []
  6568. },
  6569. discord: {
  6570. serverLinks: []
  6571. },
  6572. instagram: {
  6573. userLinks: []
  6574. },
  6575. vk: {
  6576. nameLinks: []
  6577. },
  6578. twitch: {
  6579. channelLinks: []
  6580. },
  6581. reddit: {
  6582. redditLinks: []
  6583. },
  6584. youtube: {
  6585. channelLinks: [],
  6586. likeLinks: []
  6587. }
  6588. };
  6589. var _checkLogin = new WeakSet();
  6590. var _checkLeftKey = new WeakSet();
  6591. var GiveawaySu_getGiveawayId = new WeakSet();
  6592. class GiveawaySu extends website_Website {
  6593. constructor() {
  6594. super(...arguments);
  6595. GiveawaySu_classPrivateMethodInitSpec(this, GiveawaySu_getGiveawayId);
  6596. GiveawaySu_classPrivateMethodInitSpec(this, _checkLeftKey);
  6597. GiveawaySu_classPrivateMethodInitSpec(this, _checkLogin);
  6598. GiveawaySu_defineProperty(this, 'name', 'GiveawaySu');
  6599. GiveawaySu_defineProperty(this, 'socialTasks', GiveawaySu_defaultTasks);
  6600. GiveawaySu_defineProperty(this, 'undoneTasks', GiveawaySu_defaultTasks);
  6601. GiveawaySu_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  6602. }
  6603. static test() {
  6604. return /^https?:\/\/giveaway\.su\/giveaway\/view\/[\d]+/.test(window.location.href);
  6605. }
  6606. async after() {
  6607. try {
  6608. if (!GiveawaySu_classPrivateMethodGet(this, _checkLogin, _checkLogin2).call(this)) {
  6609. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6610. }
  6611. if (!await GiveawaySu_classPrivateMethodGet(this, _checkLeftKey, _checkLeftKey2).call(this)) {
  6612. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6613. }
  6614. scripts_echoLog({}).warning(i18n('gsNotice'));
  6615. } catch (error) {
  6616. throwError(error, 'Giveawaysu.after');
  6617. }
  6618. }
  6619. init() {
  6620. try {
  6621. const logStatus = scripts_echoLog({
  6622. text: i18n('initing')
  6623. });
  6624. if ($('a.steam-login').length > 0) {
  6625. window.open('/steam/redirect', '_self');
  6626. logStatus.warning(i18n('needLogin'));
  6627. return false;
  6628. }
  6629. if (!GiveawaySu_classPrivateMethodGet(this, GiveawaySu_getGiveawayId, GiveawaySu_getGiveawayId2).call(this)) {
  6630. return false;
  6631. }
  6632. this.initialized = true;
  6633. logStatus.success();
  6634. return true;
  6635. } catch (error) {
  6636. throwError(error, 'Giveawaysu.init');
  6637. return false;
  6638. }
  6639. }
  6640. async classifyTask(action) {
  6641. try {
  6642. const logStatus = scripts_echoLog({
  6643. text: i18n('getTasksInfo')
  6644. });
  6645. if (action === 'undo') {
  6646. var _GM_getValue;
  6647. this.socialTasks = ((_GM_getValue = GM_getValue(`gasTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  6648. return true;
  6649. }
  6650. const pro = [];
  6651. const tasks = $('#actions tr');
  6652. if ($('div.bind-discord').is(':visible')) {
  6653. $('div.bind-discord a')[0].click();
  6654. }
  6655. if ($('div.bind-twitch').is(':visible')) {
  6656. $('div.bind-twitch a')[0].click();
  6657. }
  6658. for (const task of tasks) {
  6659. pro.push(new Promise(resolve => {
  6660. const td = $(task).find('td:not(".hidden")');
  6661. const colorfulTask = td.eq(1).find('a:not([data-trigger="link"])');
  6662. const colorlessTask = td.eq(2).find('a:not([data-trigger="link"])');
  6663. const taskDes = colorfulTask.length > 0 ? colorfulTask : colorlessTask;
  6664. const taskIcon = td.eq(0).find('i').attr('class') || '';
  6665. const taskName = taskDes.text().trim();
  6666. if (taskIcon.includes('ban') || /disable adblock/gi.test(taskName)) {
  6667. return resolve(true);
  6668. }
  6669. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  6670. if (!taskLink) {
  6671. return resolve(false);
  6672. }
  6673. if (taskIcon.includes('steam') && /join/gi.test(taskName)) {
  6674. this.undoneTasks.steam.groupLinks.push(taskLink);
  6675. } else if (/like.*announcement/gi.test(taskName)) {
  6676. this.undoneTasks.steam.announcementLinks.push(taskLink);
  6677. } else if (/(follow|subscribe).*curator/gim.test(taskName) && /^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  6678. this.undoneTasks.steam.curatorLinks.push(taskLink);
  6679. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  6680. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  6681. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  6682. this.undoneTasks.steam.forumLinks.push(taskLink);
  6683. } else if (taskIcon.includes('thumbs-up') && /^https?:\/\/steamcommunity\.com\/sharedfiles\/filedetails\/\?id=[\d]+/.test(taskLink)) {
  6684. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6685. } else if (taskIcon.includes('discord') || /join.*discord/gim.test(taskName)) {
  6686. this.undoneTasks.discord.serverLinks.push(taskLink);
  6687. } else if (taskIcon.includes('instagram') || /follow.*instagram/gim.test(taskName)) {
  6688. this.undoneTasks.instagram.userLinks.push(taskLink);
  6689. } else if (taskIcon.includes('twitch') || /follow.*twitch.*channel/gim.test(taskName)) {
  6690. this.undoneTasks.twitch.channelLinks.push(taskLink);
  6691. } else if (taskIcon.includes('reddit') || /subscribe.*subreddit/gim.test(taskName) || /follow.*reddit/gim.test(taskName)) {
  6692. this.undoneTasks.reddit.redditLinks.push(taskLink);
  6693. } else if (/watch.*art/gim.test(taskName)) {
  6694. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  6695. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  6696. this.undoneTasks.youtube.channelLinks.push(taskLink);
  6697. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  6698. this.undoneTasks.youtube.likeLinks.push(taskLink);
  6699. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  6700. this.undoneTasks.vk.nameLinks.push(taskLink);
  6701. } else {
  6702. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  6703. if (/wishlist.*game|add.*wishlist/gim.test(taskName)) {
  6704. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  6705. }
  6706. if (/follow.*button/gim.test(taskName)) {
  6707. this.undoneTasks.steam.followLinks.push(taskLink);
  6708. }
  6709. }
  6710. }
  6711. resolve(true);
  6712. }).catch(error => {
  6713. throwError(error, 'Giveawaysu.classifyTask->getRedirectLink');
  6714. return false;
  6715. });
  6716. }));
  6717. }
  6718. await Promise.all(pro);
  6719. logStatus.success();
  6720. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  6721. this.socialTasks = this.undoneTasks;
  6722. GM_setValue(`gasTasks-${this.giveawayId}`, {
  6723. tasks: this.socialTasks,
  6724. time: new Date().getTime()
  6725. });
  6726. return true;
  6727. } catch (error) {
  6728. throwError(error, 'Giveawaysu.classifyTask');
  6729. return false;
  6730. }
  6731. }
  6732. }
  6733. function _checkLogin2() {
  6734. try {
  6735. if (!globalOptions.other.checkLogin) {
  6736. return true;
  6737. }
  6738. if ($('a.steam-login').length > 0) {
  6739. window.open('/steam/redirect', '_self');
  6740. }
  6741. return true;
  6742. } catch (error) {
  6743. throwError(error, 'Giveawaysu.checkLogin');
  6744. return false;
  6745. }
  6746. }
  6747. async function _checkLeftKey2() {
  6748. try {
  6749. if (!globalOptions.other.checkLeftKey) {
  6750. return true;
  6751. }
  6752. if ($('.giveaway-ended').length > 0) {
  6753. await external_Swal_default().fire({
  6754. icon: 'warning',
  6755. title: i18n('notice'),
  6756. text: i18n('noKeysLeft'),
  6757. confirmButtonText: i18n('confirm'),
  6758. cancelButtonText: i18n('cancel'),
  6759. showCancelButton: true
  6760. }).then(_ref => {
  6761. let {
  6762. value
  6763. } = _ref;
  6764. if (value) {
  6765. window.close();
  6766. }
  6767. });
  6768. }
  6769. return true;
  6770. } catch (error) {
  6771. throwError(error, 'Giveawaysu.checkLeftKey');
  6772. return false;
  6773. }
  6774. }
  6775. function GiveawaySu_getGiveawayId2() {
  6776. var _window$location$href;
  6777. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  6778. if (giveawayId) {
  6779. this.giveawayId = giveawayId;
  6780. return true;
  6781. }
  6782. scripts_echoLog({
  6783. text: i18n('getFailed', 'GiveawayId')
  6784. });
  6785. return false;
  6786. }
  6787. function Indiedb_classPrivateMethodInitSpec(obj, privateSet) {
  6788. Indiedb_checkPrivateRedeclaration(obj, privateSet);
  6789. privateSet.add(obj);
  6790. }
  6791. function Indiedb_checkPrivateRedeclaration(obj, privateCollection) {
  6792. if (privateCollection.has(obj)) {
  6793. throw new TypeError('Cannot initialize the same private elements twice on an object');
  6794. }
  6795. }
  6796. function Indiedb_defineProperty(obj, key, value) {
  6797. if (key in obj) {
  6798. Object.defineProperty(obj, key, {
  6799. value: value,
  6800. enumerable: true,
  6801. configurable: true,
  6802. writable: true
  6803. });
  6804. } else {
  6805. obj[key] = value;
  6806. }
  6807. return obj;
  6808. }
  6809. function Indiedb_classPrivateMethodGet(receiver, privateSet, fn) {
  6810. if (!privateSet.has(receiver)) {
  6811. throw new TypeError('attempted to get private field on non-instance');
  6812. }
  6813. return fn;
  6814. }
  6815. var _join = new WeakSet();
  6816. var _do = new WeakSet();
  6817. var Indiedb_checkLogin = new WeakSet();
  6818. var Indiedb_checkLeftKey = new WeakSet();
  6819. class Indiedb {
  6820. constructor() {
  6821. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLeftKey);
  6822. Indiedb_classPrivateMethodInitSpec(this, Indiedb_checkLogin);
  6823. Indiedb_classPrivateMethodInitSpec(this, _do);
  6824. Indiedb_classPrivateMethodInitSpec(this, _join);
  6825. Indiedb_defineProperty(this, 'name', 'Indiedb');
  6826. Indiedb_defineProperty(this, 'buttons', [ 'doTask' ]);
  6827. }
  6828. static test() {
  6829. return window.location.host === 'www.indiedb.com';
  6830. }
  6831. async after() {
  6832. try {
  6833. if (!Indiedb_classPrivateMethodGet(this, Indiedb_checkLogin, Indiedb_checkLogin2).call(this)) {
  6834. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  6835. }
  6836. if (!await Indiedb_classPrivateMethodGet(this, Indiedb_checkLeftKey, Indiedb_checkLeftKey2).call(this)) {
  6837. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  6838. }
  6839. } catch (error) {
  6840. throwError(error, 'Indiedb.after');
  6841. }
  6842. }
  6843. async doTask() {
  6844. try {
  6845. if (!await Indiedb_classPrivateMethodGet(this, _join, _join2).call(this)) {
  6846. return false;
  6847. }
  6848. return await Indiedb_classPrivateMethodGet(this, _do, _do2).call(this);
  6849. } catch (error) {
  6850. throwError(error, 'Indiedb.doTask');
  6851. return false;
  6852. }
  6853. }
  6854. }
  6855. async function _join2() {
  6856. try {
  6857. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  6858. scripts_echoLog({}).error(i18n('needLogin'));
  6859. return false;
  6860. }
  6861. const currentoption = $('a.buttonenter.buttongiveaway');
  6862. if (/join giveaway/gim.test(currentoption.text())) {
  6863. const logStatus = scripts_echoLog({
  6864. text: `${i18n('joiningGiveaway')}...`
  6865. });
  6866. const {
  6867. result,
  6868. statusText,
  6869. status,
  6870. data
  6871. } = await tools_httpRequest({
  6872. url: currentoption.attr('href'),
  6873. method: 'POST',
  6874. data: 'ajax=t',
  6875. dataType: 'json',
  6876. headers: {
  6877. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  6878. accept: 'application/json, text/javascript, */*; q=0.01',
  6879. origin: window.location.origin
  6880. }
  6881. });
  6882. if (result === 'Success') {
  6883. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  6884. var _data$response, _data$response4, _data$response5;
  6885. if ((_data$response = data.response) !== null && _data$response !== void 0 && _data$response.success) {
  6886. var _data$response2, _data$response3;
  6887. currentoption.addClass('buttonentered').text('Success - Giveaway joined');
  6888. $('#giveawaysjoined').slideDown();
  6889. $('#giveawaysrecommend').slideDown();
  6890. 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}` : ''}`);
  6891. return true;
  6892. }
  6893. 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}` : ''}`);
  6894. return false;
  6895. }
  6896. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  6897. return false;
  6898. }
  6899. logStatus.error(`${result}:${statusText}(${status})`);
  6900. return false;
  6901. } else if (/success/gim.test($('a.buttonenter.buttongiveaway').text())) {
  6902. return true;
  6903. }
  6904. scripts_echoLog({}).warning(i18n('needJoinGiveaway'));
  6905. return false;
  6906. } catch (error) {
  6907. throwError(error, 'Indiedb.init');
  6908. return false;
  6909. }
  6910. }
  6911. async function _do2() {
  6912. try {
  6913. const id = $('script').map((index, script) => {
  6914. if (/\$\(document\)/gim.test(script.innerHTML)) {
  6915. var _script$innerHTML$mat, _script$innerHTML$mat2, _script$innerHTML$mat3, _script$innerHTML$mat4, _script$innerHTML$mat5, _script$innerHTML$mat6;
  6916. 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] ];
  6917. }
  6918. return null;
  6919. });
  6920. if (id.length === 2) {
  6921. const pro = [];
  6922. const tasks = $('#giveawaysjoined a[class*=promo]');
  6923. for (const task of tasks) {
  6924. const promo = $(task);
  6925. if (!promo.hasClass('buttonentered')) {
  6926. const status = scripts_echoLog({
  6927. text: `${i18n('doing')}:${promo.parents('p').text()}...`
  6928. });
  6929. if (/facebookpromo|twitterpromo|visitpromo/gim.test(task.className)) {
  6930. let text = '';
  6931. if (promo.hasClass('facebookpromo')) {
  6932. text = 'facebookpromo';
  6933. } else if (promo.hasClass('twitterpromo')) {
  6934. text = 'twitterpromo';
  6935. } else {
  6936. text = 'visitpromo';
  6937. }
  6938. pro.push(new Promise(resolve => {
  6939. $.ajax({
  6940. type: 'POST',
  6941. url: urlPath(`/giveaways/ajax/${text}/${id[0]}`),
  6942. timeout: 6e4,
  6943. dataType: 'json',
  6944. data: {
  6945. ajax: 't'
  6946. },
  6947. error(response, error, exception) {
  6948. console.log({
  6949. response: response,
  6950. error: error,
  6951. exception: exception
  6952. });
  6953. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6954. resolve(true);
  6955. },
  6956. success(response) {
  6957. console.log(response);
  6958. if (response.success) {
  6959. status.success(`Success:${response.text}`);
  6960. promo.addClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6961. resolve(true);
  6962. } else {
  6963. status.error(`Error:${response.text}`);
  6964. resolve(true);
  6965. }
  6966. }
  6967. });
  6968. }));
  6969. } else if (promo.hasClass('emailoptinpromo')) {
  6970. pro.push(new Promise(resolve => {
  6971. $.ajax({
  6972. type: 'POST',
  6973. url: urlPath(`/newsletter/ajax/subscribeprofile/optin/${id[1]}`),
  6974. timeout: 6e4,
  6975. dataType: 'json',
  6976. data: {
  6977. ajax: 't',
  6978. emailsystoggle: 4
  6979. },
  6980. error(response, error, exception) {
  6981. console.log({
  6982. response: response,
  6983. error: error,
  6984. exception: exception
  6985. });
  6986. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  6987. resolve(true);
  6988. },
  6989. success(response) {
  6990. console.log(response);
  6991. if (response.success) {
  6992. status.success(`Success:${response.text}`);
  6993. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  6994. resolve(true);
  6995. } else {
  6996. status.error(`Error:${response.text}`);
  6997. resolve(true);
  6998. }
  6999. }
  7000. });
  7001. }));
  7002. } else if (promo.hasClass('watchingpromo')) {
  7003. pro.push(new Promise(resolve => {
  7004. var _promo$attr;
  7005. const data = getUrlQuery(promo.attr('href'));
  7006. data.ajax = 't';
  7007. $.ajax({
  7008. type: 'POST',
  7009. url: urlPath((_promo$attr = promo.attr('href')) === null || _promo$attr === void 0 ? void 0 : _promo$attr.split(/[?#]/)[0]),
  7010. timeout: 6e4,
  7011. dataType: 'json',
  7012. data: data,
  7013. error(response, error, exception) {
  7014. console.log({
  7015. response: response,
  7016. error: error,
  7017. exception: exception
  7018. });
  7019. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7020. resolve(true);
  7021. },
  7022. success(response) {
  7023. console.log(response);
  7024. if (response.success) {
  7025. status.success(`Success:${response.text}`);
  7026. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7027. resolve(true);
  7028. } else {
  7029. status.error(`Error:${response.text}`);
  7030. resolve(true);
  7031. }
  7032. }
  7033. });
  7034. }));
  7035. } else if (!/the-challenge-of-adblock/gim.test(promo.attr('href'))) {
  7036. pro.push(new Promise(resolve => {
  7037. $.ajax({
  7038. type: 'POST',
  7039. url: urlPath(promo.attr('href')),
  7040. timeout: 6e4,
  7041. dataType: 'json',
  7042. data: {
  7043. ajax: 't'
  7044. },
  7045. error(response, error, exception) {
  7046. console.log({
  7047. response: response,
  7048. error: error,
  7049. exception: exception
  7050. });
  7051. status.error('Error:An error has occurred performing the action requested. Please try again shortly.');
  7052. resolve(true);
  7053. },
  7054. success(response) {
  7055. console.log(response);
  7056. if (response.success) {
  7057. status.success(`Success:${response.text}`);
  7058. promo.toggleClass('buttonentered').closest('p').html(promo.closest('p').find('span').html());
  7059. resolve(true);
  7060. } else {
  7061. status.error(`Error:${response.text}`);
  7062. resolve(true);
  7063. }
  7064. }
  7065. });
  7066. }));
  7067. } else {
  7068. status.error(`Error:${i18n('unKnownTaskType')}`);
  7069. }
  7070. }
  7071. }
  7072. await Promise.all(pro);
  7073. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7074. return true;
  7075. }
  7076. scripts_echoLog({}).error(i18n('getFailed', 'TaskId'));
  7077. return false;
  7078. } catch (error) {
  7079. throwError(error, 'Indiedb.classifyTask');
  7080. return false;
  7081. }
  7082. }
  7083. function Indiedb_checkLogin2() {
  7084. try {
  7085. if (!globalOptions.other.checkLogin) {
  7086. return true;
  7087. }
  7088. if ($('a.buttonenter:contains(Register to join)').length > 0) {
  7089. window.open('/members/login', '_self');
  7090. }
  7091. return true;
  7092. } catch (error) {
  7093. throwError(error, 'Indiedb.checkLogin');
  7094. return false;
  7095. }
  7096. }
  7097. async function Indiedb_checkLeftKey2() {
  7098. try {
  7099. if (!globalOptions.other.checkLeftKey) {
  7100. return true;
  7101. }
  7102. if ($('a.buttonenter:contains("next time")').length > 0) {
  7103. await external_Swal_default().fire({
  7104. icon: 'warning',
  7105. title: i18n('notice'),
  7106. text: i18n('giveawayEnded'),
  7107. confirmButtonText: i18n('confirm'),
  7108. cancelButtonText: i18n('cancel'),
  7109. showCancelButton: true
  7110. }).then(_ref => {
  7111. let {
  7112. value
  7113. } = _ref;
  7114. if (value) {
  7115. window.close();
  7116. }
  7117. });
  7118. }
  7119. return true;
  7120. } catch (error) {
  7121. throwError(error, 'Indiedb.checkLeftKey');
  7122. return false;
  7123. }
  7124. }
  7125. const website_Indiedb = Indiedb;
  7126. function Keyhub_classPrivateMethodInitSpec(obj, privateSet) {
  7127. Keyhub_checkPrivateRedeclaration(obj, privateSet);
  7128. privateSet.add(obj);
  7129. }
  7130. function Keyhub_checkPrivateRedeclaration(obj, privateCollection) {
  7131. if (privateCollection.has(obj)) {
  7132. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7133. }
  7134. }
  7135. function Keyhub_defineProperty(obj, key, value) {
  7136. if (key in obj) {
  7137. Object.defineProperty(obj, key, {
  7138. value: value,
  7139. enumerable: true,
  7140. configurable: true,
  7141. writable: true
  7142. });
  7143. } else {
  7144. obj[key] = value;
  7145. }
  7146. return obj;
  7147. }
  7148. function Keyhub_classPrivateMethodGet(receiver, privateSet, fn) {
  7149. if (!privateSet.has(receiver)) {
  7150. throw new TypeError('attempted to get private field on non-instance');
  7151. }
  7152. return fn;
  7153. }
  7154. const Keyhub_defaultTasks = {
  7155. steam: {
  7156. groupLinks: [],
  7157. wishlistLinks: [],
  7158. curatorLinks: []
  7159. },
  7160. discord: {
  7161. serverLinks: []
  7162. },
  7163. links: []
  7164. };
  7165. var Keyhub_getGiveawayId = new WeakSet();
  7166. var Keyhub_checkLeftKey = new WeakSet();
  7167. var Keyhub_checkLogin = new WeakSet();
  7168. class Keyhub extends website_Website {
  7169. constructor() {
  7170. super(...arguments);
  7171. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLogin);
  7172. Keyhub_classPrivateMethodInitSpec(this, Keyhub_checkLeftKey);
  7173. Keyhub_classPrivateMethodInitSpec(this, Keyhub_getGiveawayId);
  7174. Keyhub_defineProperty(this, 'name', 'Keyhub');
  7175. Keyhub_defineProperty(this, 'socialTasks', {
  7176. ...Keyhub_defaultTasks
  7177. });
  7178. Keyhub_defineProperty(this, 'undoneTasks', {
  7179. ...Keyhub_defaultTasks
  7180. });
  7181. Keyhub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7182. }
  7183. static test() {
  7184. return window.location.host === 'key-hub.eu';
  7185. }
  7186. async after() {
  7187. try {
  7188. if (!Keyhub_classPrivateMethodGet(this, Keyhub_checkLogin, Keyhub_checkLogin2).call(this)) {
  7189. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7190. }
  7191. if (!await Keyhub_classPrivateMethodGet(this, Keyhub_checkLeftKey, Keyhub_checkLeftKey2).call(this)) {
  7192. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7193. }
  7194. } catch (error) {
  7195. throwError(error, 'Keyhub.after');
  7196. }
  7197. }
  7198. init() {
  7199. try {
  7200. const logStatus = scripts_echoLog({
  7201. text: i18n('initing')
  7202. });
  7203. if ($('a[href*="/connect/steam"]').length > 0) {
  7204. window.open('/connect/steam', '_self');
  7205. logStatus.warning(i18n('needLogin'));
  7206. return false;
  7207. }
  7208. if (!Keyhub_classPrivateMethodGet(this, Keyhub_getGiveawayId, Keyhub_getGiveawayId2).call(this)) {
  7209. return false;
  7210. }
  7211. $('#VPNoverlay').hide();
  7212. $('#mainArticleSection').show();
  7213. this.initialized = true;
  7214. logStatus.success();
  7215. return true;
  7216. } catch (error) {
  7217. throwError(error, 'Keyhub.init');
  7218. return false;
  7219. }
  7220. }
  7221. async classifyTask(action) {
  7222. try {
  7223. const logStatus = scripts_echoLog({
  7224. text: i18n('getTasksInfo')
  7225. });
  7226. if (action === 'undo') {
  7227. var _GM_getValue;
  7228. this.socialTasks = ((_GM_getValue = GM_getValue(`khTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  7229. ...Keyhub_defaultTasks
  7230. };
  7231. }
  7232. const tasks = $('.task a');
  7233. for (const task of tasks) {
  7234. let link = $(task).attr('href');
  7235. const taskDes = $(task).text().trim();
  7236. if (!link) {
  7237. continue;
  7238. }
  7239. if (/\/away\?data=/.test(link) || /steamcommunity\.com\/gid\//.test(link)) {
  7240. link = await getRedirectLink(link) || link;
  7241. }
  7242. if (/https?:\/\/key-hub\.eu\/connect\/discord/.test(link)) {
  7243. window.open(link, '_blank');
  7244. } else if (/steamcommunity\.com\/groups\//.test(link)) {
  7245. if (action === 'undo') {
  7246. this.socialTasks.steam.groupLinks.push(link);
  7247. }
  7248. if (action === 'do') {
  7249. this.undoneTasks.steam.groupLinks.push(link);
  7250. }
  7251. } else if (/store\.steampowered\.com\/app\//.test(link) && /wishlist/gim.test(taskDes)) {
  7252. if (action === 'undo') {
  7253. this.socialTasks.steam.wishlistLinks.push(link);
  7254. }
  7255. if (action === 'do') {
  7256. this.undoneTasks.steam.wishlistLinks.push(link);
  7257. }
  7258. } else if (/store\.steampowered\.com\/curator\//.test(link)) {
  7259. if (action === 'undo') {
  7260. this.socialTasks.steam.curatorLinks.push(link);
  7261. }
  7262. if (action === 'do') {
  7263. this.undoneTasks.steam.curatorLinks.push(link);
  7264. }
  7265. } else if (/^https?:\/\/discord\.com\/invite\//.test(link)) {
  7266. if (action === 'undo') {
  7267. this.socialTasks.discord.serverLinks.push(link);
  7268. }
  7269. if (action === 'do') {
  7270. this.undoneTasks.discord.serverLinks.push(link);
  7271. }
  7272. } else {
  7273. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  7274. }
  7275. }
  7276. logStatus.success();
  7277. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7278. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7279. GM_setValue(`khTasks-${this.giveawayId}`, {
  7280. tasks: this.socialTasks,
  7281. time: new Date().getTime()
  7282. });
  7283. return true;
  7284. } catch (error) {
  7285. throwError(error, 'Keyhub.classifyTask');
  7286. return false;
  7287. }
  7288. }
  7289. verifyTask() {
  7290. try {
  7291. scripts_echoLog({
  7292. html: `<li>${i18n('verifyingTask')}...<font></font></li>`
  7293. });
  7294. $.get(window.location.href, res => {
  7295. VerifyTasks(res.match(/onclick="javascript:VerifyTasks\('(.*?)'\)"/)[1]);
  7296. });
  7297. } catch (error) {
  7298. throwError(error, 'keyhub.verifyTask');
  7299. }
  7300. }
  7301. }
  7302. function Keyhub_getGiveawayId2() {
  7303. try {
  7304. var _window$location$href;
  7305. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7306. if (giveawayId) {
  7307. this.giveawayId = giveawayId;
  7308. return true;
  7309. }
  7310. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  7311. return false;
  7312. } catch (error) {
  7313. throwError(error, 'Keyhub.getGiveawayId');
  7314. return false;
  7315. }
  7316. }
  7317. async function Keyhub_checkLeftKey2() {
  7318. try {
  7319. if (!globalOptions.other.checkLeftKey) {
  7320. return true;
  7321. }
  7322. const leftKey = $('#keysleft').text().trim();
  7323. if (leftKey === '0') {
  7324. await external_Swal_default().fire({
  7325. icon: 'warning',
  7326. title: i18n('notice'),
  7327. text: i18n('noKeysLeft'),
  7328. confirmButtonText: i18n('confirm'),
  7329. cancelButtonText: i18n('cancel'),
  7330. showCancelButton: true
  7331. }).then(_ref => {
  7332. let {
  7333. value
  7334. } = _ref;
  7335. if (value) {
  7336. window.close();
  7337. }
  7338. });
  7339. }
  7340. return true;
  7341. } catch (error) {
  7342. throwError(error, 'Keyhub.checkLeftKey');
  7343. return false;
  7344. }
  7345. }
  7346. function Keyhub_checkLogin2() {
  7347. try {
  7348. if (!globalOptions.other.checkLogin) {
  7349. return true;
  7350. }
  7351. if ($('a[href*="/connect/steam"]').length > 0) {
  7352. window.open('/connect/steam', '_self');
  7353. }
  7354. return true;
  7355. } catch (error) {
  7356. throwError(error, 'Keyhub.checkLogin');
  7357. return false;
  7358. }
  7359. }
  7360. const website_Keyhub = Keyhub;
  7361. function Givekey_classPrivateMethodInitSpec(obj, privateSet) {
  7362. Givekey_checkPrivateRedeclaration(obj, privateSet);
  7363. privateSet.add(obj);
  7364. }
  7365. function Givekey_checkPrivateRedeclaration(obj, privateCollection) {
  7366. if (privateCollection.has(obj)) {
  7367. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7368. }
  7369. }
  7370. function Givekey_defineProperty(obj, key, value) {
  7371. if (key in obj) {
  7372. Object.defineProperty(obj, key, {
  7373. value: value,
  7374. enumerable: true,
  7375. configurable: true,
  7376. writable: true
  7377. });
  7378. } else {
  7379. obj[key] = value;
  7380. }
  7381. return obj;
  7382. }
  7383. function Givekey_classPrivateMethodGet(receiver, privateSet, fn) {
  7384. if (!privateSet.has(receiver)) {
  7385. throw new TypeError('attempted to get private field on non-instance');
  7386. }
  7387. return fn;
  7388. }
  7389. const Givekey_defaultTasks = {
  7390. steam: {
  7391. groupLinks: [],
  7392. wishlistLinks: [],
  7393. curatorLinks: [],
  7394. curatorLikeLinks: []
  7395. },
  7396. twitter: {
  7397. userLinks: []
  7398. },
  7399. vk: {
  7400. nameLinks: []
  7401. },
  7402. discord: {
  7403. serverLinks: []
  7404. }
  7405. };
  7406. var Givekey_verify = new WeakSet();
  7407. var Givekey_getGiveawayId = new WeakSet();
  7408. var Givekey_checkLeftKey = new WeakSet();
  7409. class Givekey extends website_Website {
  7410. constructor() {
  7411. super(...arguments);
  7412. Givekey_classPrivateMethodInitSpec(this, Givekey_checkLeftKey);
  7413. Givekey_classPrivateMethodInitSpec(this, Givekey_getGiveawayId);
  7414. Givekey_classPrivateMethodInitSpec(this, Givekey_verify);
  7415. Givekey_defineProperty(this, 'name', 'Givekey');
  7416. Givekey_defineProperty(this, 'tasks', []);
  7417. Givekey_defineProperty(this, 'socialTasks', {
  7418. ...Givekey_defaultTasks
  7419. });
  7420. Givekey_defineProperty(this, 'undoneTasks', {
  7421. ...Givekey_defaultTasks
  7422. });
  7423. Givekey_defineProperty(this, 'userId', void 0);
  7424. Givekey_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  7425. }
  7426. static test() {
  7427. return window.location.host === 'givekey.ru';
  7428. }
  7429. async after() {
  7430. try {
  7431. await new Promise(resolve => {
  7432. const checker = setInterval(() => {
  7433. if ($('#navbarDropdown').length > 0) {
  7434. clearInterval(checker);
  7435. resolve(true);
  7436. }
  7437. });
  7438. });
  7439. if (!await Givekey_classPrivateMethodGet(this, Givekey_checkLeftKey, Givekey_checkLeftKey2).call(this)) {
  7440. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7441. }
  7442. } catch (error) {
  7443. throwError(error, 'Givekey.after');
  7444. return false;
  7445. }
  7446. }
  7447. init() {
  7448. try {
  7449. const logStatus = scripts_echoLog({
  7450. text: i18n('initing')
  7451. });
  7452. if ($('a[href*="/auth/steam"]').length > 0) {
  7453. window.open('/auth/steam', '_self');
  7454. logStatus.warning(i18n('needLogin'));
  7455. return false;
  7456. }
  7457. if (!Givekey_classPrivateMethodGet(this, Givekey_getGiveawayId, Givekey_getGiveawayId2).call(this)) {
  7458. return false;
  7459. }
  7460. const userId = $('meta[name="user-id"]').attr('content');
  7461. if (!userId) {
  7462. logStatus.error(i18n('getFailed', i18n('userId')));
  7463. return false;
  7464. }
  7465. this.userId = userId;
  7466. this.initialized = true;
  7467. logStatus.success();
  7468. return true;
  7469. } catch (error) {
  7470. throwError(error, 'Givekey.init');
  7471. return false;
  7472. }
  7473. }
  7474. async classifyTask(action) {
  7475. try {
  7476. const logStatus = scripts_echoLog({
  7477. text: i18n('getTasksInfo')
  7478. });
  7479. if (action === 'undo') {
  7480. var _GM_getValue;
  7481. this.socialTasks = ((_GM_getValue = GM_getValue(`gkTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || Givekey_defaultTasks;
  7482. }
  7483. const tasks = $('.card-body:has("button") .row');
  7484. for (const task of tasks) {
  7485. const taskEle = $(task);
  7486. const isSuccess = /Complete/i.test(taskEle.find('button').text().trim());
  7487. if (isSuccess && action !== 'undo') {
  7488. continue;
  7489. }
  7490. const checkButton = taskEle.find('#task_check');
  7491. const taskId = checkButton.attr('data-id');
  7492. if (taskId) {
  7493. this.tasks.push(taskId);
  7494. }
  7495. if (action === 'verify') {
  7496. continue;
  7497. }
  7498. let href = taskEle.find('a').attr('href') || null;
  7499. const text = taskEle.find('a').text().trim();
  7500. const icon = taskEle.find('i');
  7501. if (!href || !text) {
  7502. continue;
  7503. }
  7504. if (/^https?:\/\/givekey\.ru\/giveaway\/[\d]+\/execution_task/.test(href)) {
  7505. href = await getRedirectLink(href);
  7506. }
  7507. if (!href) {
  7508. continue;
  7509. }
  7510. if (/^https?:\/\/vk\.com\//.test(href)) {
  7511. this.socialTasks.vk.nameLinks.push(href);
  7512. if (action === 'do' && !isSuccess) {
  7513. this.undoneTasks.vk.nameLinks.push(href);
  7514. }
  7515. } else if (/^https?:\/\/steamcommunity\.com\/groups/.test(href)) {
  7516. this.socialTasks.steam.groupLinks.push(href);
  7517. if (action === 'do' && !isSuccess) {
  7518. this.undoneTasks.steam.groupLinks.push(href);
  7519. }
  7520. } else if (/^https?:\/\/store\.steampowered\.com\/app\//.test(href)) {
  7521. this.socialTasks.steam.wishlistLinks.push(href);
  7522. if (action === 'do' && !isSuccess) {
  7523. this.undoneTasks.steam.wishlistLinks.push(href);
  7524. }
  7525. } else if (/Subscribe/gi.test(text) && icon.hasClass('fa-steam-square')) {
  7526. if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(href)) {
  7527. this.socialTasks.steam.curatorLinks.push(href);
  7528. if (action === 'do' && !isSuccess) {
  7529. this.undoneTasks.steam.curatorLinks.push(href);
  7530. }
  7531. } else {
  7532. this.socialTasks.steam.curatorLikeLinks.push(href);
  7533. if (action === 'do' && !isSuccess) {
  7534. this.undoneTasks.steam.curatorLikeLinks.push(href);
  7535. }
  7536. }
  7537. } else if (/^https?:\/\/twitter\.com\//.test(href) && /Subscribe/gi.test(text)) {
  7538. this.socialTasks.twitter.userLinks.push(href);
  7539. if (action === 'do' && !isSuccess) {
  7540. this.undoneTasks.twitter.userLinks.push(href);
  7541. }
  7542. } else if (icon.hasClass('fa-discord')) {
  7543. this.socialTasks.discord.serverLinks.push(href);
  7544. if (action === 'do' && !isSuccess) {
  7545. this.undoneTasks.discord.serverLinks.push(href);
  7546. }
  7547. } else {
  7548. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${text}(${href})`);
  7549. }
  7550. }
  7551. logStatus.success();
  7552. this.tasks = unique(this.tasks);
  7553. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7554. this.socialTasks = this.uniqueTasks(this.socialTasks);
  7555. GM_setValue(`gkTasks-${this.giveawayId}`, {
  7556. tasks: this.socialTasks,
  7557. time: new Date().getTime()
  7558. });
  7559. return true;
  7560. } catch (error) {
  7561. throwError(error, 'Givekey.classifyTask');
  7562. return false;
  7563. }
  7564. }
  7565. async verifyTask() {
  7566. try {
  7567. if (!this.initialized && !this.init()) {
  7568. return false;
  7569. }
  7570. if (this.tasks.length === 0 && !await this.classifyTask('verify')) {
  7571. return false;
  7572. }
  7573. scripts_echoLog({}).warning(i18n('giveKeyNoticeBefore'));
  7574. const taskLength = this.tasks.length;
  7575. for (let i = 0; i < taskLength; i++) {
  7576. await Givekey_classPrivateMethodGet(this, Givekey_verify, Givekey_verify2).call(this, this.tasks[i]);
  7577. if (i < taskLength - 1) {
  7578. await delay(15e3);
  7579. }
  7580. }
  7581. scripts_echoLog({}).success(i18n('allTasksComplete'));
  7582. scripts_echoLog({
  7583. html: `<li><font class="warning">${i18n('giveKeyNoticeAfter')}</font></li>`
  7584. });
  7585. return true;
  7586. } catch (error) {
  7587. throwError(error, 'Givekey.verifyTask');
  7588. return false;
  7589. }
  7590. }
  7591. }
  7592. async function Givekey_verify2(task) {
  7593. try {
  7594. const logStatus = scripts_echoLog({
  7595. html: `<li>${i18n('verifyingTask')}${task}...<font></font></li>`
  7596. });
  7597. return await new Promise(resolve => {
  7598. $.ajax({
  7599. url: 'https://givekey.ru/giveaway/task',
  7600. method: 'POST',
  7601. data: `id=${task}&user_id=${this.userId}`,
  7602. dataType: 'json',
  7603. headers: {
  7604. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  7605. },
  7606. success: data => {
  7607. if (data.btn) {
  7608. $(`button[data-id=${this.userId}]`).html(data.btn);
  7609. }
  7610. if (data.status === 'ok') {
  7611. $(`.task_check_${data.id}`).html(`<button class="btn btn-success mb-2 btn-block" disabled>${data.btn}</button>`);
  7612. logStatus.success();
  7613. resolve(true);
  7614. } else if (data.status === 'end') {
  7615. logStatus.success();
  7616. scripts_echoLog({}).success(data.key);
  7617. resolve(true);
  7618. } else {
  7619. logStatus.error(`Error:${data.msg}`);
  7620. resolve(false);
  7621. }
  7622. },
  7623. error: xhr => {
  7624. logStatus.error(`Error:${xhr.statusText}(${xhr.status})`);
  7625. resolve(false);
  7626. }
  7627. });
  7628. });
  7629. } catch (error) {
  7630. throwError(error, 'Givekey.verify');
  7631. return false;
  7632. }
  7633. }
  7634. function Givekey_getGiveawayId2() {
  7635. try {
  7636. var _window$location$href;
  7637. const giveawayId = (_window$location$href = window.location.href.match(/giveaway\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7638. if (giveawayId) {
  7639. this.giveawayId = giveawayId;
  7640. return true;
  7641. }
  7642. scripts_echoLog({
  7643. text: i18n('getFailed', 'GiveawayId')
  7644. });
  7645. return false;
  7646. } catch (error) {
  7647. throwError(error, 'Givekey.getGiveawayId');
  7648. return false;
  7649. }
  7650. }
  7651. async function Givekey_checkLeftKey2() {
  7652. try {
  7653. if (!globalOptions.other.checkLeftKey) {
  7654. return true;
  7655. }
  7656. if (!$('#keys_count').text()) {
  7657. await external_Swal_default().fire({
  7658. icon: 'warning',
  7659. title: i18n('notice'),
  7660. text: i18n('noKeysLeft'),
  7661. confirmButtonText: i18n('confirm'),
  7662. cancelButtonText: i18n('cancel'),
  7663. showCancelButton: true
  7664. }).then(_ref => {
  7665. let {
  7666. value
  7667. } = _ref;
  7668. if (value) {
  7669. window.close();
  7670. }
  7671. });
  7672. }
  7673. return true;
  7674. } catch (error) {
  7675. throwError(error, 'Givekey.checkLeftKey');
  7676. return false;
  7677. }
  7678. }
  7679. const website_Givekey = Givekey;
  7680. function GiveeClub_classPrivateMethodInitSpec(obj, privateSet) {
  7681. GiveeClub_checkPrivateRedeclaration(obj, privateSet);
  7682. privateSet.add(obj);
  7683. }
  7684. function GiveeClub_checkPrivateRedeclaration(obj, privateCollection) {
  7685. if (privateCollection.has(obj)) {
  7686. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7687. }
  7688. }
  7689. function GiveeClub_defineProperty(obj, key, value) {
  7690. if (key in obj) {
  7691. Object.defineProperty(obj, key, {
  7692. value: value,
  7693. enumerable: true,
  7694. configurable: true,
  7695. writable: true
  7696. });
  7697. } else {
  7698. obj[key] = value;
  7699. }
  7700. return obj;
  7701. }
  7702. function GiveeClub_classPrivateMethodGet(receiver, privateSet, fn) {
  7703. if (!privateSet.has(receiver)) {
  7704. throw new TypeError('attempted to get private field on non-instance');
  7705. }
  7706. return fn;
  7707. }
  7708. var GiveeClub_checkLogin = new WeakSet();
  7709. var GiveeClub_getGiveawayId = new WeakSet();
  7710. var GiveeClub_checkLeftKey = new WeakSet();
  7711. class GiveeClub extends GiveawaySu {
  7712. constructor() {
  7713. super(...arguments);
  7714. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLeftKey);
  7715. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_getGiveawayId);
  7716. GiveeClub_classPrivateMethodInitSpec(this, GiveeClub_checkLogin);
  7717. GiveeClub_defineProperty(this, 'name', 'GiveeClub');
  7718. GiveeClub_defineProperty(this, 'buttons', [ 'doTask', 'undoTask' ]);
  7719. }
  7720. static test() {
  7721. return /^https?:\/\/givee\.club\/.*?\/event\/[\d]+/.test(window.location.href);
  7722. }
  7723. async after() {
  7724. try {
  7725. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7726. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7727. }
  7728. if (!await GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLeftKey, GiveeClub_checkLeftKey2).call(this)) {
  7729. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  7730. }
  7731. } catch (error) {
  7732. throwError(error, 'GiveeClub.after');
  7733. }
  7734. }
  7735. init() {
  7736. try {
  7737. const logStatus = scripts_echoLog({
  7738. text: i18n('initing')
  7739. });
  7740. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_checkLogin, GiveeClub_checkLogin2).call(this)) {
  7741. logStatus.warning(i18n('needLogin'));
  7742. return false;
  7743. }
  7744. if (!GiveeClub_classPrivateMethodGet(this, GiveeClub_getGiveawayId, GiveeClub_getGiveawayId2).call(this)) {
  7745. return false;
  7746. }
  7747. this.initialized = true;
  7748. logStatus.success();
  7749. return true;
  7750. } catch (error) {
  7751. throwError(error, 'GiveeClub.init');
  7752. return false;
  7753. }
  7754. }
  7755. async classifyTask(action) {
  7756. try {
  7757. const logStatus = scripts_echoLog({
  7758. text: i18n('getTasksInfo')
  7759. });
  7760. if (action === 'undo') {
  7761. var _GM_getValue;
  7762. this.socialTasks = ((_GM_getValue = GM_getValue(`gcTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || GiveawaySu_defaultTasks;
  7763. return true;
  7764. }
  7765. const pro = [];
  7766. const tasks = $('.event-actions tr');
  7767. for (const task of tasks) {
  7768. pro.push(new Promise(resolve => {
  7769. const taskDes = $(task).find('.event-action-label a');
  7770. const taskIcon = $(task).find('.event-action-icon i').attr('class') || '';
  7771. const taskName = taskDes.text().trim();
  7772. if (taskIcon.includes('ban') || /AdBlock/i.test(taskName) || taskIcon.includes('envelope')) {
  7773. return resolve(true);
  7774. }
  7775. getRedirectLink(taskDes.attr('href')).then(taskLink => {
  7776. if (!taskLink) {
  7777. return resolve(false);
  7778. }
  7779. if (/^https?:\/\/steamcommunity\.com\/groups/.test(taskLink)) {
  7780. this.undoneTasks.steam.groupLinks.push(taskLink);
  7781. } else if (/like.*announcement/gi.test(taskName)) {
  7782. this.undoneTasks.steam.announcementLinks.push(taskLink);
  7783. } else if (taskIcon.includes('plus') && /^https?:\/\/store\.steampowered\.com\/app\//.test(taskLink)) {
  7784. this.undoneTasks.steam.wishlistLinks.push(taskLink);
  7785. } else if (/^https?:\/\/store\.steampowered\.com\/curator\//.test(taskLink)) {
  7786. this.undoneTasks.steam.curatorLinks.push(taskLink);
  7787. } else if (taskIcon.includes('steam') && /follow|subscribe/gim.test(taskName)) {
  7788. this.undoneTasks.steam.curatorLikeLinks.push(taskLink);
  7789. } else if (/subscribe.*steam.*forum/gim.test(taskName)) {
  7790. this.undoneTasks.steam.forumLinks.push(taskLink);
  7791. } else if (taskIcon.includes('discord')) {
  7792. this.undoneTasks.discord.serverLinks.push(taskLink);
  7793. } else if (taskIcon.includes('instagram')) {
  7794. this.undoneTasks.instagram.userLinks.push(taskLink);
  7795. } else if (taskIcon.includes('twitch')) {
  7796. this.undoneTasks.twitch.channelLinks.push(taskLink);
  7797. } else if (taskIcon.includes('reddit')) {
  7798. this.undoneTasks.reddit.redditLinks.push(taskLink);
  7799. } else if (/watch.*art/gim.test(taskName)) {
  7800. this.undoneTasks.steam.workshopVoteLinks.push(taskLink);
  7801. } else if (/subscribe.*youtube.*channel/gim.test(taskName)) {
  7802. this.undoneTasks.youtube.channelLinks.push(taskLink);
  7803. } else if (/(watch|like).*youtube.*video/gim.test(taskName) || (taskIcon.includes('youtube') || taskIcon.includes('thumbs-up')) && /(watch|like).*video/gim.test(taskName)) {
  7804. this.undoneTasks.youtube.likeLinks.push(taskLink);
  7805. } else if (taskIcon.includes('vk') || /join.*vk.*group/gim.test(taskName)) {
  7806. this.undoneTasks.vk.nameLinks.push(taskLink);
  7807. } else {
  7808. if (/(on twitter)|(Follow.*on.*Facebook)/gim.test(taskName)) {} else {
  7809. if (/follow.*button/gim.test(taskName)) {
  7810. this.undoneTasks.steam.followLinks.push(taskLink);
  7811. }
  7812. }
  7813. }
  7814. resolve(true);
  7815. }).catch(error => {
  7816. throwError(error, 'GiveeClub.classifyTask->getRedirectLink');
  7817. return false;
  7818. });
  7819. }));
  7820. }
  7821. await Promise.all(pro);
  7822. logStatus.success();
  7823. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  7824. this.socialTasks = this.undoneTasks;
  7825. GM_setValue(`gcTasks-${this.giveawayId}`, {
  7826. tasks: this.socialTasks,
  7827. time: new Date().getTime()
  7828. });
  7829. return true;
  7830. } catch (error) {
  7831. throwError(error, 'GiveeClub.classifyTask');
  7832. return false;
  7833. }
  7834. }
  7835. }
  7836. function GiveeClub_checkLogin2() {
  7837. try {
  7838. if (!globalOptions.other.checkLogin) {
  7839. return true;
  7840. }
  7841. if ($('a[href*="/account/auth"]').length > 0) {
  7842. window.open($('a[href*="/account/auth"]').attr('href'), '_self');
  7843. }
  7844. return true;
  7845. } catch (error) {
  7846. throwError(error, 'GiveeClub.checkLogin');
  7847. return false;
  7848. }
  7849. }
  7850. function GiveeClub_getGiveawayId2() {
  7851. var _window$location$href;
  7852. const giveawayId = (_window$location$href = window.location.href.match(/\/event\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  7853. if (giveawayId) {
  7854. this.giveawayId = giveawayId;
  7855. return true;
  7856. }
  7857. scripts_echoLog({
  7858. text: i18n('getFailed', 'GiveawayId')
  7859. });
  7860. return false;
  7861. }
  7862. async function GiveeClub_checkLeftKey2() {
  7863. try {
  7864. if (!globalOptions.other.checkLeftKey) {
  7865. return true;
  7866. }
  7867. if ($('.event-ended').length > 0) {
  7868. await external_Swal_default().fire({
  7869. icon: 'warning',
  7870. title: i18n('notice'),
  7871. text: i18n('giveawayEnded'),
  7872. confirmButtonText: i18n('confirm'),
  7873. cancelButtonText: i18n('cancel'),
  7874. showCancelButton: true
  7875. }).then(_ref => {
  7876. let {
  7877. value
  7878. } = _ref;
  7879. if (value) {
  7880. window.close();
  7881. }
  7882. });
  7883. }
  7884. return true;
  7885. } catch (error) {
  7886. throwError(error, 'Giveawaysu.checkLeftKey');
  7887. return false;
  7888. }
  7889. }
  7890. const website_GiveeClub = GiveeClub;
  7891. function OpiumPulses_classPrivateMethodInitSpec(obj, privateSet) {
  7892. OpiumPulses_checkPrivateRedeclaration(obj, privateSet);
  7893. privateSet.add(obj);
  7894. }
  7895. function OpiumPulses_checkPrivateRedeclaration(obj, privateCollection) {
  7896. if (privateCollection.has(obj)) {
  7897. throw new TypeError('Cannot initialize the same private elements twice on an object');
  7898. }
  7899. }
  7900. function OpiumPulses_defineProperty(obj, key, value) {
  7901. if (key in obj) {
  7902. Object.defineProperty(obj, key, {
  7903. value: value,
  7904. enumerable: true,
  7905. configurable: true,
  7906. writable: true
  7907. });
  7908. } else {
  7909. obj[key] = value;
  7910. }
  7911. return obj;
  7912. }
  7913. function OpiumPulses_classPrivateMethodGet(receiver, privateSet, fn) {
  7914. if (!privateSet.has(receiver)) {
  7915. throw new TypeError('attempted to get private field on non-instance');
  7916. }
  7917. return fn;
  7918. }
  7919. const defaultOptions = {
  7920. maxPoint: '99999999'
  7921. };
  7922. var _toggleTask = new WeakSet();
  7923. var OpiumPulses_checkLogin = new WeakSet();
  7924. class OpiumPulses {
  7925. constructor() {
  7926. OpiumPulses_classPrivateMethodInitSpec(this, OpiumPulses_checkLogin);
  7927. OpiumPulses_classPrivateMethodInitSpec(this, _toggleTask);
  7928. OpiumPulses_defineProperty(this, 'name', 'OpiumPulses');
  7929. OpiumPulses_defineProperty(this, 'options', {
  7930. ...defaultOptions,
  7931. ...GM_getValue('OpiumPulsesOptions')
  7932. });
  7933. OpiumPulses_defineProperty(this, 'maxPoints', 99999999);
  7934. OpiumPulses_defineProperty(this, 'myPoints', 0);
  7935. OpiumPulses_defineProperty(this, 'buttons', [ 'doFreeTask', 'doPointTask' ]);
  7936. }
  7937. static test() {
  7938. return window.location.host === 'www.opiumpulses.com';
  7939. }
  7940. async after() {
  7941. try {
  7942. if (!OpiumPulses_classPrivateMethodGet(this, OpiumPulses_checkLogin, OpiumPulses_checkLogin2).call(this)) {
  7943. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  7944. }
  7945. this.maxPoints = parseInt(this.options.maxPoint, 10);
  7946. } catch (error) {
  7947. throwError(error, 'OpiumPulses.after');
  7948. }
  7949. }
  7950. async doFreeTask() {
  7951. try {
  7952. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'FREE');
  7953. } catch (error) {
  7954. throwError(error, 'OpiumPulses.doFreeTask');
  7955. }
  7956. }
  7957. async doPointTask() {
  7958. try {
  7959. var _$$text$match;
  7960. 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);
  7961. OpiumPulses_classPrivateMethodGet(this, _toggleTask, _toggleTask2).call(this, 'points');
  7962. } catch (error) {
  7963. throwError(error, 'OpiumPulses.doPointTask');
  7964. }
  7965. }
  7966. init() {
  7967. return true;
  7968. }
  7969. classifyTask() {
  7970. return true;
  7971. }
  7972. }
  7973. async function _toggleTask2(type) {
  7974. try {
  7975. const items = $(`.giveaways-page-item:contains('${type}'):not(:contains('ENTERED'))`);
  7976. for (const item of items) {
  7977. var _$$find$text$match;
  7978. 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);
  7979. const name = $(item).find('.giveaways-page-item-footer-name').text().trim();
  7980. if (type === 'points' && needPoints > this.myPoints) {
  7981. scripts_echoLog({}).warning(`${i18n('noPoints')}: ${name}`);
  7982. } else if (type === 'points' && !needPoints) {
  7983. scripts_echoLog({}).warning(`${i18n('getNeedPointsFailed')}: ${name}`);
  7984. } else if (!(type === 'points' && needPoints > this.maxPoints)) {
  7985. var _aElement$attr;
  7986. const logStatus = scripts_echoLog({
  7987. text: `${i18n('joiningLottery')}<a href="${$(item).find('a.giveaways-page-item-img-btn-more').attr('href')}" target="_blank">${name}</a>...`
  7988. });
  7989. const aElement = $(item).find('a.giveaways-page-item-img-btn-enter:contains(\'enter\')');
  7990. if (aElement !== null && aElement !== void 0 && (_aElement$attr = aElement.attr('onclick')) !== null && _aElement$attr !== void 0 && _aElement$attr.includes('checkUser')) {
  7991. var _aElement$attr2, _aElement$attr2$match;
  7992. 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];
  7993. if (giveawayId) {
  7994. checkUser(giveawayId);
  7995. }
  7996. }
  7997. if (!aElement.attr('href')) {
  7998. logStatus.error('Error: No "href".');
  7999. continue;
  8000. }
  8001. const {
  8002. result,
  8003. statusText,
  8004. status,
  8005. data
  8006. } = await tools_httpRequest({
  8007. url: aElement.attr('href'),
  8008. method: 'GET'
  8009. });
  8010. if (result === 'Success') {
  8011. if (data !== null && data !== void 0 && data.responseText && /You've entered this giveaway/gim.test(data.responseText)) {
  8012. var _data$responseText$ma;
  8013. logStatus.success();
  8014. const points = (_data$responseText$ma = data.responseText.match(/Points:[\s]*?([\d]+)/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8015. if (type === 'points' && points) {
  8016. this.myPoints = parseInt(points, 10);
  8017. }
  8018. } else {
  8019. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8020. }
  8021. } else {
  8022. logStatus.error(`${result}:${statusText}(${status})`);
  8023. }
  8024. }
  8025. }
  8026. scripts_echoLog({
  8027. text: '-----END-----'
  8028. });
  8029. } catch (error) {
  8030. throwError(error, 'OpiumPulses.toggleTask');
  8031. }
  8032. }
  8033. function OpiumPulses_checkLogin2() {
  8034. try {
  8035. if (!globalOptions.other.checkLogin) {
  8036. return true;
  8037. }
  8038. if ($('a[href*="/site/login"]').length > 1) {
  8039. window.open('/site/login', '_self');
  8040. }
  8041. return true;
  8042. } catch (error) {
  8043. throwError(error, 'OpiumPulses.checkLogin');
  8044. return false;
  8045. }
  8046. }
  8047. const website_OpiumPulses = OpiumPulses;
  8048. function Keylol_classPrivateMethodInitSpec(obj, privateSet) {
  8049. Keylol_checkPrivateRedeclaration(obj, privateSet);
  8050. privateSet.add(obj);
  8051. }
  8052. function Keylol_checkPrivateRedeclaration(obj, privateCollection) {
  8053. if (privateCollection.has(obj)) {
  8054. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8055. }
  8056. }
  8057. function Keylol_defineProperty(obj, key, value) {
  8058. if (key in obj) {
  8059. Object.defineProperty(obj, key, {
  8060. value: value,
  8061. enumerable: true,
  8062. configurable: true,
  8063. writable: true
  8064. });
  8065. } else {
  8066. obj[key] = value;
  8067. }
  8068. return obj;
  8069. }
  8070. function Keylol_classPrivateMethodGet(receiver, privateSet, fn) {
  8071. if (!privateSet.has(receiver)) {
  8072. throw new TypeError('attempted to get private field on non-instance');
  8073. }
  8074. return fn;
  8075. }
  8076. const Keylol_defaultTasks = {
  8077. steam: {
  8078. groupLinks: [],
  8079. wishlistLinks: [],
  8080. curatorLinks: [],
  8081. curatorLikeLinks: [],
  8082. followLinks: [],
  8083. forumLinks: [],
  8084. announcementLinks: [],
  8085. workshopVoteLinks: []
  8086. },
  8087. discord: {
  8088. serverLinks: []
  8089. },
  8090. instagram: {
  8091. userLinks: []
  8092. },
  8093. vk: {
  8094. nameLinks: []
  8095. },
  8096. twitch: {
  8097. channelLinks: []
  8098. },
  8099. reddit: {
  8100. redditLinks: []
  8101. },
  8102. twitter: {
  8103. userLinks: [],
  8104. retweetLinks: []
  8105. },
  8106. youtube: {
  8107. channelLinks: [],
  8108. likeLinks: []
  8109. }
  8110. };
  8111. var _addBtn = new WeakSet();
  8112. class Keylol extends website_Website {
  8113. constructor() {
  8114. super(...arguments);
  8115. Keylol_classPrivateMethodInitSpec(this, _addBtn);
  8116. Keylol_defineProperty(this, 'name', 'Keylol');
  8117. Keylol_defineProperty(this, 'socialTasks', {
  8118. ...Keylol_defaultTasks
  8119. });
  8120. Keylol_defineProperty(this, 'undoneTasks', {
  8121. ...Keylol_defaultTasks
  8122. });
  8123. Keylol_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect' ]);
  8124. }
  8125. static test() {
  8126. var _$$eq$attr;
  8127. 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'));
  8128. }
  8129. init() {
  8130. return true;
  8131. }
  8132. after() {
  8133. try {
  8134. const selector = this.name === 'Keylol' ? '#postlist>div[id^="post_"]:first' : 'div.container';
  8135. const mainPost = $(selector);
  8136. const discordLinks = mainPost.find('a[href*="discord.com"]');
  8137. const redditLinks = mainPost.find('a[href*="reddit.com"]');
  8138. const insLinks = mainPost.find('a[href*="instagram.com"]');
  8139. const twitterLinks = mainPost.find('a[href*="twitter.com"]');
  8140. const twitchLinks = mainPost.find('a[href*="twitch.tv"]');
  8141. const vkLinks = mainPost.find('a[href*="vk.com"]');
  8142. const steamStoreLinks = mainPost.find('a[href*="store.steampowered.com"]');
  8143. const steamCommunityLinks = mainPost.find('a[href*="steamcommunity.com"]');
  8144. const ytbLinks = mainPost.find('a[href*="youtube.com"]');
  8145. if (discordLinks.length > 0) {
  8146. for (const discordLink of discordLinks) {
  8147. const link = $(discordLink).attr('href');
  8148. if (!(link && /^https?:\/\/discord\.com\/invite\/.+/.test(link))) {
  8149. continue;
  8150. }
  8151. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, discordLink, 'discord', 'serverLinks', link);
  8152. }
  8153. }
  8154. if (redditLinks.length > 0) {
  8155. for (const redditLink of redditLinks) {
  8156. const link = $(redditLink).attr('href');
  8157. if (!(link && /^https?:\/\/www\.reddit\.com\/(r|user)\/.+/.test(link))) {
  8158. continue;
  8159. }
  8160. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, redditLink, 'reddit', 'redditLinks', link);
  8161. }
  8162. }
  8163. if (insLinks.length > 0) {
  8164. for (const insLink of insLinks) {
  8165. const link = $(insLink).attr('href');
  8166. if (!(link && /^https:\/\/www\.instagram\.com\/.+/.test(link))) {
  8167. continue;
  8168. }
  8169. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, insLink, 'instagram', 'userLinks', link);
  8170. }
  8171. }
  8172. if (twitterLinks.length > 0) {
  8173. for (const twitterLink of twitterLinks) {
  8174. const link = $(twitterLink).attr('href');
  8175. if (!(link && /^https:\/\/twitter\.com\/.+/.test(link))) {
  8176. continue;
  8177. }
  8178. if (/https:\/\/twitter\.com\/.*?\/status\/[\d]+/.test(link)) {
  8179. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'retweetLinks', link);
  8180. } else {
  8181. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitterLink, 'twitter', 'userLinks', link);
  8182. }
  8183. }
  8184. }
  8185. if (twitchLinks.length > 0) {
  8186. for (const twitchLink of twitchLinks) {
  8187. const link = $(twitchLink).attr('href');
  8188. if (!(link && /^https:\/\/(www\.)?twitch\.tv\/.+/.test(link))) {
  8189. continue;
  8190. }
  8191. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, twitchLink, 'twitch', 'channelLinks', link);
  8192. }
  8193. }
  8194. if (vkLinks.length > 0) {
  8195. for (const vkLink of vkLinks) {
  8196. const link = $(vkLink).attr('href');
  8197. if (!(link && /^https:\/\/vk\.com\/.+/.test(link))) {
  8198. continue;
  8199. }
  8200. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, vkLink, 'vk', 'nameLinks', link);
  8201. }
  8202. }
  8203. if (steamStoreLinks.length > 0) {
  8204. for (const steamStoreLink of steamStoreLinks) {
  8205. const link = $(steamStoreLink).attr('href');
  8206. if (!link) {
  8207. continue;
  8208. }
  8209. if (/app\/[\d]+/.test(link)) {
  8210. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'followLinks', link);
  8211. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'wishlistLinks', link);
  8212. } else if (/curator\/[\d]+/.test(link)) {
  8213. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLinks', link);
  8214. } else if (/(publisher|developer|franchise)\/.+/.test(link)) {
  8215. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'curatorLikeLinks', link);
  8216. } else if (/newshub\/app\/[\d]+\/view\/[\d]+/.test(link)) {
  8217. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamStoreLink, 'steam', 'announcementLinks', link);
  8218. }
  8219. }
  8220. }
  8221. if (steamCommunityLinks.length > 0) {
  8222. for (const steamCommunityLink of steamCommunityLinks) {
  8223. const link = $(steamCommunityLink).attr('href');
  8224. if (!link) {
  8225. continue;
  8226. }
  8227. if (/groups\/.+/.test(link)) {
  8228. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'groupLinks', link);
  8229. } else if (/announcements\/detail\/[\d]+/.test(link)) {
  8230. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, steamCommunityLink, 'steam', 'announcementLinks', link);
  8231. }
  8232. }
  8233. }
  8234. if (ytbLinks.length > 0) {
  8235. for (const ytbLink of ytbLinks) {
  8236. const link = $(ytbLink).attr('href');
  8237. if (!link) {
  8238. continue;
  8239. }
  8240. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'channelLinks', link);
  8241. Keylol_classPrivateMethodGet(this, _addBtn, _addBtn2).call(this, ytbLink, 'youtube', 'videoLinks', link);
  8242. }
  8243. }
  8244. } catch (error) {
  8245. throwError(error, 'keylol.after');
  8246. }
  8247. }
  8248. classifyTask(action) {
  8249. try {
  8250. this.socialTasks = {
  8251. ...Keylol_defaultTasks
  8252. };
  8253. this.undoneTasks = {
  8254. ...Keylol_defaultTasks
  8255. };
  8256. const selectedBtns = $('.auto-task-keylol[selected="selected"]');
  8257. for (const btn of selectedBtns) {
  8258. const button = $(btn);
  8259. const social = button.attr('data-social');
  8260. const type = button.attr('data-type');
  8261. const link = button.attr('data-link');
  8262. if (!(social && type && link)) {
  8263. continue;
  8264. }
  8265. if (action === 'do') {
  8266. this.undoneTasks[social][type].push(link);
  8267. }
  8268. if (action === 'undo') {
  8269. this.socialTasks[social][type].push(link);
  8270. }
  8271. }
  8272. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8273. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8274. return true;
  8275. } catch (error) {
  8276. throwError(error, 'Keylol.classifyTask');
  8277. return false;
  8278. }
  8279. }
  8280. selectAll() {
  8281. try {
  8282. $('.auto-task-keylol').attr('selected', 'selected');
  8283. } catch (error) {
  8284. throwError(error, 'Keylol.selectAll');
  8285. }
  8286. }
  8287. selectNone() {
  8288. try {
  8289. $('.auto-task-keylol').removeAttr('selected');
  8290. } catch (error) {
  8291. throwError(error, 'Keylol.selectNone');
  8292. }
  8293. }
  8294. invertSelect() {
  8295. try {
  8296. $('.auto-task-keylol').each((index, element) => {
  8297. element.getAttribute('selected') ? element.removeAttribute('selected') : element.setAttribute('selected', 'selected');
  8298. });
  8299. } catch (error) {
  8300. throwError(error, 'Keylol.invertSelect');
  8301. }
  8302. }
  8303. }
  8304. function _addBtn2(before, social, linkType, link) {
  8305. try {
  8306. $(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>`);
  8307. } catch (error) {
  8308. throwError(error, 'keylol.addBtn');
  8309. }
  8310. }
  8311. const website_Keylol = Keylol;
  8312. function Opquests_classPrivateMethodInitSpec(obj, privateSet) {
  8313. Opquests_checkPrivateRedeclaration(obj, privateSet);
  8314. privateSet.add(obj);
  8315. }
  8316. function Opquests_checkPrivateRedeclaration(obj, privateCollection) {
  8317. if (privateCollection.has(obj)) {
  8318. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8319. }
  8320. }
  8321. function Opquests_defineProperty(obj, key, value) {
  8322. if (key in obj) {
  8323. Object.defineProperty(obj, key, {
  8324. value: value,
  8325. enumerable: true,
  8326. configurable: true,
  8327. writable: true
  8328. });
  8329. } else {
  8330. obj[key] = value;
  8331. }
  8332. return obj;
  8333. }
  8334. function Opquests_classPrivateMethodGet(receiver, privateSet, fn) {
  8335. if (!privateSet.has(receiver)) {
  8336. throw new TypeError('attempted to get private field on non-instance');
  8337. }
  8338. return fn;
  8339. }
  8340. const Opquests_defaultTasks = {
  8341. steam: {
  8342. groupLinks: [],
  8343. wishlistLinks: [],
  8344. followLinks: [],
  8345. curatorLikeLinks: []
  8346. }
  8347. };
  8348. var Opquests_getGiveawayId = new WeakSet();
  8349. var Opquests_checkLogin = new WeakSet();
  8350. class Opquests extends website_Website {
  8351. constructor() {
  8352. super(...arguments);
  8353. Opquests_classPrivateMethodInitSpec(this, Opquests_checkLogin);
  8354. Opquests_classPrivateMethodInitSpec(this, Opquests_getGiveawayId);
  8355. Opquests_defineProperty(this, 'name', 'Opquests');
  8356. Opquests_defineProperty(this, 'undoneTasks', {
  8357. ...Opquests_defaultTasks
  8358. });
  8359. Opquests_defineProperty(this, 'buttons', [ 'doTask' ]);
  8360. }
  8361. static test() {
  8362. return window.location.host === 'opquests.com';
  8363. }
  8364. async after() {
  8365. try {
  8366. if (!Opquests_classPrivateMethodGet(this, Opquests_checkLogin, Opquests_checkLogin2).call(this)) {
  8367. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  8368. }
  8369. } catch (error) {
  8370. throwError(error, 'Opquests.after');
  8371. }
  8372. }
  8373. init() {
  8374. try {
  8375. const logStatus = scripts_echoLog({
  8376. text: i18n('initing')
  8377. });
  8378. if ($('a[href*="/auth/redirect"]').length > 0) {
  8379. window.open('/auth/redirect', '_self');
  8380. logStatus.warning(i18n('needLogin'));
  8381. return false;
  8382. }
  8383. if (!Opquests_classPrivateMethodGet(this, Opquests_getGiveawayId, Opquests_getGiveawayId2).call(this)) {
  8384. return false;
  8385. }
  8386. this.initialized = true;
  8387. logStatus.success();
  8388. return true;
  8389. } catch (error) {
  8390. throwError(error, 'Opquests.init');
  8391. return false;
  8392. }
  8393. }
  8394. async classifyTask(action) {
  8395. try {
  8396. if (action === 'undo') {
  8397. scripts_echoLog({
  8398. text: i18n('cannotUndo')
  8399. });
  8400. return false;
  8401. }
  8402. const logStatus = scripts_echoLog({
  8403. text: i18n('getTasksInfo')
  8404. });
  8405. const tasks = $('.w-full:contains("Validate") .items-center');
  8406. for (const task of tasks) {
  8407. const link = $(task).find('a:contains("Open")').attr('href');
  8408. const taskDes = $(task).find('div').eq(1).text().trim();
  8409. if (!link) {
  8410. continue;
  8411. }
  8412. if (/steamcommunity\.com\/groups\//.test(link)) {
  8413. this.undoneTasks.steam.groupLinks.push(link);
  8414. } else if (/store\.steampowered\.com\/app\//.test(link)) {
  8415. if (/wishlist/gim.test(taskDes)) {
  8416. this.undoneTasks.steam.wishlistLinks.push(link);
  8417. } else if (/follow/gim.test(taskDes)) {
  8418. this.undoneTasks.steam.followLinks.push(link);
  8419. }
  8420. } else if (/store\.steampowered\.com\/(publisher|developer)\//.test(link) && /follow/gim.test(taskDes)) {
  8421. this.undoneTasks.steam.curatorLikeLinks.push(link);
  8422. } else {
  8423. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskDes}(${link})`);
  8424. }
  8425. }
  8426. logStatus.success();
  8427. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8428. return true;
  8429. } catch (error) {
  8430. throwError(error, 'Opquests.classifyTask');
  8431. return false;
  8432. }
  8433. }
  8434. }
  8435. function Opquests_getGiveawayId2() {
  8436. try {
  8437. var _window$location$href;
  8438. const giveawayId = (_window$location$href = window.location.href.match(/quests\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  8439. if (giveawayId) {
  8440. this.giveawayId = giveawayId;
  8441. return true;
  8442. }
  8443. scripts_echoLog({}).error(i18n('getFailed', 'GiveawayId'));
  8444. return false;
  8445. } catch (error) {
  8446. throwError(error, 'Opquests.getGiveawayId');
  8447. return false;
  8448. }
  8449. }
  8450. function Opquests_checkLogin2() {
  8451. try {
  8452. if (!globalOptions.other.checkLogin) {
  8453. return true;
  8454. }
  8455. if ($('a[href*="/auth/redirect"]').length > 0) {
  8456. window.open('/auth/redirect', '_self');
  8457. }
  8458. return true;
  8459. } catch (error) {
  8460. throwError(error, 'Opquests.checkLogin');
  8461. return false;
  8462. }
  8463. }
  8464. const website_Opquests = Opquests;
  8465. function Gleam_classPrivateMethodInitSpec(obj, privateSet) {
  8466. Gleam_checkPrivateRedeclaration(obj, privateSet);
  8467. privateSet.add(obj);
  8468. }
  8469. function Gleam_checkPrivateRedeclaration(obj, privateCollection) {
  8470. if (privateCollection.has(obj)) {
  8471. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8472. }
  8473. }
  8474. function Gleam_defineProperty(obj, key, value) {
  8475. if (key in obj) {
  8476. Object.defineProperty(obj, key, {
  8477. value: value,
  8478. enumerable: true,
  8479. configurable: true,
  8480. writable: true
  8481. });
  8482. } else {
  8483. obj[key] = value;
  8484. }
  8485. return obj;
  8486. }
  8487. function Gleam_classPrivateMethodGet(receiver, privateSet, fn) {
  8488. if (!privateSet.has(receiver)) {
  8489. throw new TypeError('attempted to get private field on non-instance');
  8490. }
  8491. return fn;
  8492. }
  8493. const Gleam_defaultTasks = {
  8494. steam: {
  8495. groupLinks: [],
  8496. wishlistLinks: [],
  8497. followLinks: [],
  8498. curatorLinks: [],
  8499. curatorLikeLinks: []
  8500. },
  8501. twitter: {
  8502. userLinks: [],
  8503. retweetLinks: []
  8504. },
  8505. twitch: {
  8506. channelLinks: []
  8507. },
  8508. discord: {
  8509. serverLinks: []
  8510. },
  8511. youtube: {
  8512. channelLinks: []
  8513. },
  8514. extra: {
  8515. gleam: []
  8516. }
  8517. };
  8518. const Gleam_defaultOptions = {
  8519. vlootUsername: '',
  8520. gameroundUsername: ''
  8521. };
  8522. var _checkSync = new WeakSet();
  8523. var _doGleamTask = new WeakSet();
  8524. var Gleam_getGiveawayId = new WeakSet();
  8525. var _getGleamLink = new WeakSet();
  8526. var Gleam_checkLeftKey = new WeakSet();
  8527. class Gleam extends website_Website {
  8528. constructor() {
  8529. super(...arguments);
  8530. Gleam_classPrivateMethodInitSpec(this, Gleam_checkLeftKey);
  8531. Gleam_classPrivateMethodInitSpec(this, _getGleamLink);
  8532. Gleam_classPrivateMethodInitSpec(this, Gleam_getGiveawayId);
  8533. Gleam_classPrivateMethodInitSpec(this, _doGleamTask);
  8534. Gleam_classPrivateMethodInitSpec(this, _checkSync);
  8535. Gleam_defineProperty(this, 'name', 'Gleam');
  8536. Gleam_defineProperty(this, 'undoneTasks', {
  8537. ...Gleam_defaultTasks
  8538. });
  8539. Gleam_defineProperty(this, 'socialTasks', {
  8540. ...Gleam_defaultTasks
  8541. });
  8542. Gleam_defineProperty(this, 'options', {
  8543. ...Gleam_defaultOptions,
  8544. ...GM_getValue('GleamOptions')
  8545. });
  8546. Gleam_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'verifyTask' ]);
  8547. }
  8548. static test() {
  8549. return window.location.host === 'gleam.io';
  8550. }
  8551. async after() {
  8552. try {
  8553. if (window.location.search.includes('8b07d23f4bfa65f9')) {
  8554. const checkComplete = setInterval(() => {
  8555. if ($('.entry-content .entry-method i.fa-check').length > 0) {
  8556. clearInterval(checkComplete);
  8557. window.close();
  8558. }
  8559. });
  8560. for (const task of $('.entry-content .entry-method')) {
  8561. const taskInfo = $(task).find('.user-links');
  8562. const expandInfo = $(task).find('.expandable');
  8563. const aElements = expandInfo.find('a.btn,a:contains(Continue),button:contains(Continue)');
  8564. if (aElements.length > 0) {
  8565. for (const element of aElements) {
  8566. const $element = $(element);
  8567. const href = $element.attr('href');
  8568. $element.removeAttr('href')[0].click();
  8569. $element.attr('href', href);
  8570. await delay(1e3);
  8571. }
  8572. }
  8573. taskInfo[0].click();
  8574. await delay(1e3);
  8575. }
  8576. scripts_echoLog({}).warning(i18n('gleamTaskNotice'));
  8577. } else if (!await Gleam_classPrivateMethodGet(this, Gleam_checkLeftKey, Gleam_checkLeftKey2).call(this)) {
  8578. scripts_echoLog({}).warning(i18n('checkLeftKeyFailed'));
  8579. }
  8580. } catch (error) {
  8581. throwError(error, 'Gleam.after');
  8582. return false;
  8583. }
  8584. }
  8585. init() {
  8586. try {
  8587. const logStatus = scripts_echoLog({
  8588. text: i18n('initing')
  8589. });
  8590. if (!Gleam_classPrivateMethodGet(this, Gleam_getGiveawayId, Gleam_getGiveawayId2).call(this)) {
  8591. return false;
  8592. }
  8593. this.initialized = true;
  8594. logStatus.success();
  8595. return true;
  8596. } catch (error) {
  8597. throwError(error, 'Gleam.init');
  8598. return false;
  8599. }
  8600. }
  8601. async classifyTask(action) {
  8602. try {
  8603. const logStatus = scripts_echoLog({
  8604. text: i18n('getTasksInfo')
  8605. });
  8606. if (action === 'undo') {
  8607. var _GM_getValue;
  8608. this.socialTasks = ((_GM_getValue = GM_getValue(`gleamTasks-${this.giveawayId}`)) === null || _GM_getValue === void 0 ? void 0 : _GM_getValue.tasks) || {
  8609. ...Gleam_defaultTasks
  8610. };
  8611. }
  8612. const tasks = $('.entry-content .entry-method');
  8613. for (const task of tasks) {
  8614. var _socialIcon$attr;
  8615. const $task = $(task);
  8616. if (action === 'do' && $task.find('i.fa-question').length === 0) {
  8617. continue;
  8618. }
  8619. const socialIcon = $task.find('.icon-wrapper i');
  8620. const taskInfo = $task.find('.user-links');
  8621. const taskText = taskInfo.text().trim();
  8622. const expandInfo = $task.find('.expandable');
  8623. const aElements = expandInfo.find('a.btn');
  8624. if (aElements.length > 0) {
  8625. for (const element of aElements) {
  8626. const $element = $(element);
  8627. const href = $element.attr('href');
  8628. $element.removeAttr('href')[0].click();
  8629. $element.attr('href', href);
  8630. }
  8631. }
  8632. if (socialIcon.hasClass('fa-twitter')) {
  8633. const link = $task.find('a[href^="https://twitter.com/"]').attr('href');
  8634. if (!link) {
  8635. continue;
  8636. }
  8637. if (/follow/gi.test(taskText)) {
  8638. if (action === 'undo') {
  8639. this.socialTasks.twitter.userLinks.push(link);
  8640. }
  8641. if (action === 'do') {
  8642. this.undoneTasks.twitter.userLinks.push(link);
  8643. }
  8644. } else if (/retweet/gim.test(taskText)) {
  8645. if (action === 'undo') {
  8646. this.socialTasks.twitter.retweetLinks.push(link);
  8647. }
  8648. if (action === 'do') {
  8649. this.undoneTasks.twitter.retweetLinks.push(link);
  8650. }
  8651. }
  8652. } else if (socialIcon.hasClass('fa-twitch')) {
  8653. if (/follow/gim.test(taskText)) {
  8654. const link = $task.find('a[href^="https://twitch.tv/"]').attr('href');
  8655. if (!link) {
  8656. continue;
  8657. }
  8658. if (action === 'undo') {
  8659. this.socialTasks.twitch.channelLinks.push(link);
  8660. }
  8661. if (action === 'do') {
  8662. this.undoneTasks.twitch.channelLinks.push(link);
  8663. }
  8664. }
  8665. } else if (socialIcon.hasClass('fa-discord')) {
  8666. if (/join/gim.test(taskText)) {
  8667. let link = $task.find('a[href^="https://discord.com/invite/"]').attr('href');
  8668. if (!link) {
  8669. var _$task$find$attr, _$task$find$attr$matc;
  8670. 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];
  8671. if (!ggLink) {
  8672. continue;
  8673. }
  8674. link = `https://discord.com/invite/${ggLink}`;
  8675. }
  8676. if (action === 'undo') {
  8677. this.socialTasks.discord.serverLinks.push(link);
  8678. }
  8679. if (action === 'do') {
  8680. this.undoneTasks.discord.serverLinks.push(link);
  8681. }
  8682. }
  8683. } else if (socialIcon.hasClass('fa-external-link-square-alt')) {
  8684. continue;
  8685. } else if (socialIcon.hasClass('fa-youtube')) {
  8686. if (/subscribe/gim.test(taskText)) {
  8687. const link = $task.find('a[href^="https://www.youtube.com/channel/"]').attr('href');
  8688. if (!link) {
  8689. continue;
  8690. }
  8691. if (action === 'undo') {
  8692. this.socialTasks.youtube.channelLinks.push(link);
  8693. }
  8694. if (action === 'do') {
  8695. this.undoneTasks.youtube.channelLinks.push(link);
  8696. }
  8697. }
  8698. } else if ((_socialIcon$attr = socialIcon.attr('class')) !== null && _socialIcon$attr !== void 0 && _socialIcon$attr.includes('steam')) {
  8699. if (/join.*group/gi.test(taskText)) {
  8700. const link = $task.find('a[href^="https://steamcommunity.com/groups/"]').attr('href');
  8701. if (!link) {
  8702. continue;
  8703. }
  8704. if (action === 'undo') {
  8705. this.socialTasks.steam.groupLinks.push(link);
  8706. }
  8707. if (action === 'do') {
  8708. this.undoneTasks.steam.groupLinks.push(link);
  8709. }
  8710. } else if (/follow.*curator/gi.test(taskText)) {
  8711. const link = $task.find('a[href^="https://store.steampowered.com/curator/"]').attr('href');
  8712. if (!link) {
  8713. continue;
  8714. }
  8715. if (action === 'undo') {
  8716. this.socialTasks.steam.curatorLinks.push(link);
  8717. }
  8718. if (action === 'do') {
  8719. this.undoneTasks.steam.curatorLinks.push(link);
  8720. }
  8721. }
  8722. } else if (socialIcon.hasClass('fa-shield') && taskText.includes('earn.vloot.io')) {
  8723. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  8724. for (const button of continueBtn) {
  8725. button.click();
  8726. await delay(500);
  8727. expandInfo.find('input').val(this.options.vlootUsername);
  8728. }
  8729. } else if (socialIcon.hasClass('fa-gamepad-alt') && taskText.includes('Gameround')) {
  8730. const continueBtn = expandInfo.find('span:contains(Continue),button:contains(Continue)');
  8731. for (const button of continueBtn) {
  8732. button.click();
  8733. await delay(500);
  8734. expandInfo.find('input').val(this.options.gameroundUsername);
  8735. }
  8736. } else if (socialIcon.hasClass('fa-bullhorn') && taskText.includes('Complete')) {
  8737. if (action !== 'do') {
  8738. continue;
  8739. }
  8740. const link = aElements.attr('href');
  8741. if (!link) {
  8742. continue;
  8743. }
  8744. const gleamLink = await Gleam_classPrivateMethodGet(this, _getGleamLink, _getGleamLink2).call(this, link);
  8745. if (!gleamLink) {
  8746. continue;
  8747. }
  8748. this.undoneTasks.extra.gleam.push(gleamLink);
  8749. } else if (socialIcon.hasClass('fa-question') || socialIcon.hasClass('fa-reddit') || socialIcon.hasClass('fa-facebook-f') || socialIcon.hasClass('fa-telegram-plane') || socialIcon.hasClass('fa-shield') && taskText.includes('Check out')) {} else {
  8750. scripts_echoLog({}).warning(`${i18n('unKnownTaskType')}: ${taskText}`);
  8751. }
  8752. }
  8753. logStatus.success();
  8754. this.undoneTasks = this.uniqueTasks(this.undoneTasks);
  8755. this.socialTasks = this.uniqueTasks(this.socialTasks);
  8756. GM_setValue(`gleamTasks-${this.giveawayId}`, {
  8757. tasks: this.socialTasks,
  8758. time: new Date().getTime()
  8759. });
  8760. return true;
  8761. } catch (error) {
  8762. throwError(error, 'Gleam.classifyTask');
  8763. return false;
  8764. }
  8765. }
  8766. async extraDoTask(_ref) {
  8767. let {
  8768. gleam
  8769. } = _ref;
  8770. try {
  8771. const pro = [];
  8772. for (const link of gleam) {
  8773. pro.push(Gleam_classPrivateMethodGet(this, _doGleamTask, _doGleamTask2).call(this, link));
  8774. }
  8775. return Promise.all(pro).then(() => true);
  8776. } catch (error) {
  8777. throwError(error, 'Gleam.extraDoTask');
  8778. return false;
  8779. }
  8780. }
  8781. async verifyTask() {
  8782. try {
  8783. scripts_echoLog({
  8784. text: `${i18n('verifyingTask')}...`
  8785. });
  8786. const tasks = $('.entry-content .entry-method');
  8787. for (const task of tasks) {
  8788. const $task = $(task);
  8789. if ($task.find('i.fa-question').length === 0) {
  8790. continue;
  8791. }
  8792. const taskInfo = $task.find('.user-links');
  8793. taskInfo[0].click();
  8794. await delay(500);
  8795. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8796. const continueBtn = $task.find('.expandable').find('span:contains(Continue),button:contains(Continue)');
  8797. for (const button of continueBtn) {
  8798. button.click();
  8799. await delay(500);
  8800. await Gleam_classPrivateMethodGet(this, _checkSync, _checkSync2).call(this);
  8801. }
  8802. }
  8803. scripts_echoLog({
  8804. text: i18n('verifiedGleamTasks')
  8805. });
  8806. } catch (error) {
  8807. throwError(error, 'Gleam.verifyTask');
  8808. return false;
  8809. }
  8810. }
  8811. }
  8812. async function _checkSync2() {
  8813. try {
  8814. return await new Promise(resolve => {
  8815. const checker = setInterval(() => {
  8816. if ($('.entry-content .entry-method i.fa-sync').length === 0) {
  8817. clearInterval(checker);
  8818. resolve(true);
  8819. }
  8820. }, 500);
  8821. });
  8822. } catch (error) {
  8823. throwError(error, 'Gleam.checkSync');
  8824. return false;
  8825. }
  8826. }
  8827. async function _doGleamTask2(link) {
  8828. try {
  8829. const logStatus = scripts_echoLog({
  8830. text: i18n('doingGleamTask')
  8831. });
  8832. return await new Promise(resolve => {
  8833. GM_openInTab(`${link}?8b07d23f4bfa65f9`, {
  8834. active: true,
  8835. insert: true,
  8836. setParent: true
  8837. }).onclose = () => {
  8838. logStatus.success();
  8839. resolve(true);
  8840. };
  8841. });
  8842. } catch (error) {
  8843. throwError(error, 'Gleam.doGleamTask');
  8844. return false;
  8845. }
  8846. }
  8847. function Gleam_getGiveawayId2() {
  8848. try {
  8849. const giveawayId = window.location.pathname;
  8850. if (giveawayId) {
  8851. this.giveawayId = giveawayId;
  8852. return true;
  8853. }
  8854. scripts_echoLog({
  8855. text: i18n('getFailed', 'GiveawayId')
  8856. });
  8857. return false;
  8858. } catch (error) {
  8859. throwError(error, 'Gleam.getGiveawayId');
  8860. return false;
  8861. }
  8862. }
  8863. async function _getGleamLink2(link) {
  8864. try {
  8865. const logStatus = scripts_echoLog({
  8866. text: i18n('gettingGleamLink')
  8867. });
  8868. const {
  8869. result,
  8870. statusText,
  8871. status,
  8872. data
  8873. } = await tools_httpRequest({
  8874. url: link,
  8875. method: 'GET'
  8876. });
  8877. if (result === 'Success') {
  8878. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  8879. var _data$responseText$ma;
  8880. const gleamLink = (_data$responseText$ma = data.responseText.match(/href="(https:\/\/gleam\.io\/.*?\/.+?)"/)) === null || _data$responseText$ma === void 0 ? void 0 : _data$responseText$ma[1];
  8881. if (gleamLink) {
  8882. logStatus.success();
  8883. return gleamLink;
  8884. }
  8885. logStatus.error(`Error:${i18n('getLinkFailed')}`);
  8886. return false;
  8887. }
  8888. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  8889. return false;
  8890. }
  8891. logStatus.error(`${result}:${statusText}(${status})`);
  8892. return false;
  8893. } catch (error) {
  8894. throwError(error, 'Gleam.getGleamLink');
  8895. return false;
  8896. }
  8897. }
  8898. async function Gleam_checkLeftKey2() {
  8899. try {
  8900. var _$$attr, _$$attr$match, _$$attr2, _$$attr2$match;
  8901. if (!globalOptions.other.checkLeftKey) {
  8902. return true;
  8903. }
  8904. 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];
  8905. if (!campaignString) {
  8906. return false;
  8907. }
  8908. const {
  8909. campaign,
  8910. incentive
  8911. } = JSON.parse(campaignString);
  8912. 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];
  8913. let ownedKey = false;
  8914. if (controllerString) {
  8915. var _JSON$parse$contestan, _JSON$parse$contestan2, _JSON$parse$contestan3, _JSON$parse$contestan4;
  8916. 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) {
  8917. ownedKey = true;
  8918. }
  8919. }
  8920. if (campaign.banned || campaign.finished && !ownedKey || campaign.paused || new Date().getTime() < campaign.starts_at * 1e3) {
  8921. await external_Swal_default().fire({
  8922. icon: 'warning',
  8923. title: i18n('notice'),
  8924. text: i18n('giveawayNotWork'),
  8925. confirmButtonText: i18n('confirm'),
  8926. cancelButtonText: i18n('cancel'),
  8927. showCancelButton: true
  8928. }).then(_ref2 => {
  8929. let {
  8930. value
  8931. } = _ref2;
  8932. if (value) {
  8933. window.close();
  8934. }
  8935. });
  8936. }
  8937. return true;
  8938. } catch (error) {
  8939. throwError(error, 'Gleam.checkLeftKey');
  8940. return false;
  8941. }
  8942. }
  8943. const website_Gleam = Gleam;
  8944. function SweepWidget_classPrivateMethodInitSpec(obj, privateSet) {
  8945. SweepWidget_checkPrivateRedeclaration(obj, privateSet);
  8946. privateSet.add(obj);
  8947. }
  8948. function SweepWidget_checkPrivateRedeclaration(obj, privateCollection) {
  8949. if (privateCollection.has(obj)) {
  8950. throw new TypeError('Cannot initialize the same private elements twice on an object');
  8951. }
  8952. }
  8953. function SweepWidget_defineProperty(obj, key, value) {
  8954. if (key in obj) {
  8955. Object.defineProperty(obj, key, {
  8956. value: value,
  8957. enumerable: true,
  8958. configurable: true,
  8959. writable: true
  8960. });
  8961. } else {
  8962. obj[key] = value;
  8963. }
  8964. return obj;
  8965. }
  8966. function SweepWidget_classPrivateMethodGet(receiver, privateSet, fn) {
  8967. if (!privateSet.has(receiver)) {
  8968. throw new TypeError('attempted to get private field on non-instance');
  8969. }
  8970. return fn;
  8971. }
  8972. const SweepWidget_defaultOptions = {
  8973. username: '',
  8974. email: ''
  8975. };
  8976. var SweepWidget_checkLogin = new WeakSet();
  8977. var SweepWidget_getGiveawayId = new WeakSet();
  8978. var _checkEnter = new WeakSet();
  8979. var _checkFinish = new WeakSet();
  8980. class SweepWidget extends website_Website {
  8981. constructor() {
  8982. super(...arguments);
  8983. SweepWidget_classPrivateMethodInitSpec(this, _checkFinish);
  8984. SweepWidget_classPrivateMethodInitSpec(this, _checkEnter);
  8985. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_getGiveawayId);
  8986. SweepWidget_classPrivateMethodInitSpec(this, SweepWidget_checkLogin);
  8987. SweepWidget_defineProperty(this, 'name', 'SweepWidget');
  8988. SweepWidget_defineProperty(this, 'options', {
  8989. ...SweepWidget_defaultOptions,
  8990. ...GM_getValue('SweepWidgetOptions')
  8991. });
  8992. SweepWidget_defineProperty(this, 'buttons', [ 'doTask' ]);
  8993. }
  8994. static test() {
  8995. return /^https?:\/\/sweepwidget\.com\/view\/[\d]+/.test(window.location.href);
  8996. }
  8997. async after() {
  8998. try {
  8999. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9000. scripts_echoLog({}).warning(i18n('checkLoginFailed'));
  9001. }
  9002. } catch (error) {
  9003. throwError(error, 'SweepWidget.after');
  9004. }
  9005. }
  9006. init() {
  9007. try {
  9008. const logStatus = scripts_echoLog({
  9009. text: i18n('initing')
  9010. });
  9011. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_checkLogin, SweepWidget_checkLogin2).call(this)) {
  9012. logStatus.warning(i18n('needLogin'));
  9013. return false;
  9014. }
  9015. if (!SweepWidget_classPrivateMethodGet(this, SweepWidget_getGiveawayId, SweepWidget_getGiveawayId2).call(this)) {
  9016. return false;
  9017. }
  9018. this.initialized = true;
  9019. logStatus.success();
  9020. return true;
  9021. } catch (error) {
  9022. throwError(error, 'SweepWidget.init');
  9023. return false;
  9024. }
  9025. }
  9026. classifyTask() {
  9027. return true;
  9028. }
  9029. async doTask() {
  9030. try {
  9031. if ($('#unlock_rewards_main_wrapper').length === 0) {
  9032. if ($('input[name="sw__login_name"]:visible').length > 0) {
  9033. $('input[name="sw__login_name"]').val(this.options.username);
  9034. }
  9035. if ($('input[name="sw__login_email"]:visible').length > 0) {
  9036. $('input[name="sw__login_email"]').val(this.options.email);
  9037. }
  9038. if ($('#sw_login_button:visible').length > 0) {
  9039. $('#sw_login_button')[0].click();
  9040. }
  9041. if (!await SweepWidget_classPrivateMethodGet(this, _checkEnter, _checkEnter2).call(this)) {
  9042. return false;
  9043. }
  9044. }
  9045. const logStatus = scripts_echoLog({
  9046. text: i18n('SweepWidgetNotice')
  9047. });
  9048. const tasks = $('#sw_inner_entry_methods_l2_wrapper>div.sw_entry');
  9049. for (const task of tasks) {
  9050. var _aElement$, _$task$find$removeAtt;
  9051. const $task = $(task);
  9052. if ($task.find('i.fa-check:visible').length > 0) {
  9053. continue;
  9054. }
  9055. const title = $task.find('.sw_text_inner');
  9056. title[0].click();
  9057. const aElement = $task.find('a.sw_link');
  9058. const link = aElement.attr('href');
  9059. aElement.attr('href', '#a').attr('target', '_self');
  9060. (_aElement$ = aElement[0]) === null || _aElement$ === void 0 ? void 0 : _aElement$.click();
  9061. await delay(300);
  9062. aElement.attr('href', link).attr('target', '_blank');
  9063. $task.find('input[type="text"]').val('test');
  9064. const verifyBtn = $task.find('input.sw_verify');
  9065. if (verifyBtn.prop('disabled') === true) {
  9066. title[0].click();
  9067. await delay(300);
  9068. title[0].click();
  9069. await delay(300);
  9070. }
  9071. (_$task$find$removeAtt = $task.find('input.sw_verify').removeAttr('disabled')[0]) === null || _$task$find$removeAtt === void 0 ? void 0 : _$task$find$removeAtt.click();
  9072. await SweepWidget_classPrivateMethodGet(this, _checkFinish, _checkFinish2).call(this, $task);
  9073. await delay(parseInt(`${Math.random() * (3e3 - 1e3 + 1) + 1e3}`, 10));
  9074. }
  9075. logStatus.success();
  9076. return true;
  9077. } catch (error) {
  9078. throwError(error, 'SweepWidget.doTask');
  9079. return false;
  9080. }
  9081. }
  9082. }
  9083. function SweepWidget_checkLogin2() {
  9084. try {
  9085. if ($('#twitter_login_button').length > 0) {
  9086. $('#twitter_login_button')[0].click();
  9087. }
  9088. return true;
  9089. } catch (error) {
  9090. throwError(error, 'SweepWidget.checkLogin');
  9091. return false;
  9092. }
  9093. }
  9094. function SweepWidget_getGiveawayId2() {
  9095. try {
  9096. var _window$location$href;
  9097. const giveawayId = (_window$location$href = window.location.href.match(/\/view\/([\d]+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1];
  9098. if (giveawayId) {
  9099. this.giveawayId = giveawayId;
  9100. return true;
  9101. }
  9102. scripts_echoLog({
  9103. text: i18n('getFailed', 'GiveawayId')
  9104. });
  9105. return false;
  9106. } catch (error) {
  9107. throwError(error, 'SweepWidget.getGiveawayId');
  9108. return false;
  9109. }
  9110. }
  9111. async function _checkEnter2() {
  9112. try {
  9113. return new Promise(resolve => {
  9114. const checker = setInterval(() => {
  9115. if ($('#unlock_rewards_main_wrapper').length > 0) {
  9116. clearInterval(checker);
  9117. resolve(true);
  9118. }
  9119. });
  9120. });
  9121. } catch (error) {
  9122. throwError(error, 'SweepWidget.checkEnter');
  9123. return false;
  9124. }
  9125. }
  9126. async function _checkFinish2($task) {
  9127. try {
  9128. return new Promise(resolve => {
  9129. const checker = setInterval(() => {
  9130. if ($task.find('i.fa-check:visible').length > 0 || $task.find('.sw_entry_input:visible').length === 0) {
  9131. clearInterval(checker);
  9132. resolve(true);
  9133. }
  9134. });
  9135. });
  9136. } catch (error) {
  9137. throwError(error, 'SweepWidget.checkFinish');
  9138. return false;
  9139. }
  9140. }
  9141. const website_SweepWidget = SweepWidget;
  9142. const defaultWhiteList = {
  9143. discord: {
  9144. servers: []
  9145. },
  9146. instagram: {
  9147. users: []
  9148. },
  9149. twitch: {
  9150. channels: []
  9151. },
  9152. twitter: {
  9153. users: [],
  9154. retweets: [],
  9155. likes: []
  9156. },
  9157. vk: {
  9158. names: []
  9159. },
  9160. youtube: {
  9161. channels: [],
  9162. likes: []
  9163. },
  9164. reddit: {
  9165. reddits: []
  9166. },
  9167. steam: {
  9168. groups: [],
  9169. wishlists: [],
  9170. follows: [],
  9171. forums: [],
  9172. workshops: [],
  9173. curators: [],
  9174. workshopVotes: [],
  9175. curatorLikes: [],
  9176. announcements: []
  9177. }
  9178. };
  9179. const link2id = async function(type) {
  9180. 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;
  9181. try {
  9182. const link = $('#socialLink').val();
  9183. let id = '';
  9184. switch (type) {
  9185. case 'discord.servers':
  9186. id = ((_link$match = link.match(/invite\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || '';
  9187. break;
  9188.  
  9189. case 'instagram.users':
  9190. id = ((_link$match2 = link.match(/https:\/\/www\.instagram\.com\/(.+)?\//)) === null || _link$match2 === void 0 ? void 0 : _link$match2[1]) || '';
  9191. break;
  9192.  
  9193. case 'twitch.channels':
  9194. id = ((_link$match3 = link.match(/https:\/\/(www\.)?twitch\.tv\/(.+)/)) === null || _link$match3 === void 0 ? void 0 : _link$match3[2]) || '';
  9195. break;
  9196.  
  9197. case 'twitter.users':
  9198. id = ((_link$match4 = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match4 === void 0 ? void 0 : _link$match4[1]) || '';
  9199. break;
  9200.  
  9201. case 'twitter.retweets':
  9202. id = ((_link$match5 = link.match(/https:\/\/twitter\.com\/.*?\/status\/([\d]+)/)) === null || _link$match5 === void 0 ? void 0 : _link$match5[1]) || '';
  9203. break;
  9204.  
  9205. case 'vk.names':
  9206. id = ((_link$match6 = link.match(/https:\/\/vk\.com\/([^/]+)/)) === null || _link$match6 === void 0 ? void 0 : _link$match6[1]) || '';
  9207. break;
  9208.  
  9209. case 'youtube.channels':
  9210. 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) || '';
  9211. break;
  9212.  
  9213. case 'youtube.likes':
  9214. 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) || '';
  9215. break;
  9216.  
  9217. case 'reddit.reddits':
  9218. 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]) || '';
  9219. break;
  9220.  
  9221. case 'steam.groups':
  9222. id = ((_link$match9 = link.match(/groups\/(.+)\/?/)) === null || _link$match9 === void 0 ? void 0 : _link$match9[1]) || '';
  9223. break;
  9224.  
  9225. case 'steam.wishlists':
  9226. case 'steam.follows':
  9227. case 'steam.forums':
  9228. id = ((_link$match10 = link.match(/app\/([\d]+)/)) === null || _link$match10 === void 0 ? void 0 : _link$match10[1]) || '';
  9229. break;
  9230.  
  9231. case 'steam.workshops':
  9232. id = ((_link$match11 = link.match(/\?id=([\d]+)/)) === null || _link$match11 === void 0 ? void 0 : _link$match11[1]) || '';
  9233. break;
  9234.  
  9235. case 'steam.curators':
  9236. {
  9237. if (link.includes('curator')) {
  9238. var _link$match12;
  9239. id = ((_link$match12 = link.match(/curator\/([\d]+)/)) === null || _link$match12 === void 0 ? void 0 : _link$match12[1]) || '';
  9240. } else {
  9241. var _link$match13;
  9242. const param = (_link$match13 = link.match(/https?:\/\/store\.steampowered\.com\/(.*?)\/([^/?]+)/)) === null || _link$match13 === void 0 ? void 0 : _link$match13.slice(1, 3);
  9243. if (!param || param.length !== 2) {
  9244. break;
  9245. }
  9246. const steam = new social_Steam();
  9247. if (await steam.init()) {
  9248. id = await steam.getCuratorId(param[0], param[1]) || '';
  9249. }
  9250. }
  9251. }
  9252. break;
  9253. }
  9254. return id;
  9255. } catch (error) {
  9256. throwError(error, 'link2id');
  9257. return i18n('getFailed', 'id');
  9258. }
  9259. };
  9260. const disabledType = {
  9261. steam: [ 'workshopVotes', 'curatorLikes', 'announcements' ],
  9262. twitter: [ 'likes' ]
  9263. };
  9264. const whiteListOptions = function(showType) {
  9265. try {
  9266. const whiteList = {
  9267. ...defaultWhiteList,
  9268. ...GM_getValue('whiteList') || {}
  9269. };
  9270. let whiteListOptionsForm = `<form id="whiteListForm" class="auto-task-form">
  9271. <table class="auto-task-table"><thead><tr><td>${i18n('website')}</td><td>${i18n('type')}</td><td>${i18n('edit')}</td></tr></thead><tbody>`;
  9272. for (const [ social, types ] of Object.entries(whiteList)) {
  9273. whiteListOptionsForm += Object.keys(types).map((type, index) => {
  9274. var _disabledType$social;
  9275. 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>`;
  9276. }).join('');
  9277. }
  9278. whiteListOptionsForm += '</tbody></table></form>';
  9279. if (showType === 'swal') {
  9280. external_Swal_default().fire({
  9281. title: i18n('whiteListOptions'),
  9282. html: whiteListOptionsForm,
  9283. showConfirmButton: false,
  9284. showCloseButton: true
  9285. });
  9286. } else {
  9287. $('body').append(`<h2>${i18n('whiteList')}</h2>${whiteListOptionsForm}`);
  9288. }
  9289. $('.editWhiteList').on('click', function() {
  9290. var _whiteList$social;
  9291. const value = $(this).attr('data-value');
  9292. if (!value) {
  9293. return;
  9294. }
  9295. const [ social, type ] = value.split('.');
  9296. if (!(whiteList !== null && whiteList !== void 0 && (_whiteList$social = whiteList[social]) !== null && _whiteList$social !== void 0 && _whiteList$social[type])) {
  9297. scripts_echoLog({}).warning(i18n('whiteListNotFound', value));
  9298. return;
  9299. }
  9300. external_Swal_default().fire({
  9301. title: i18n('changeWhiteListOption', value),
  9302. input: 'textarea',
  9303. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9304. <button id="link2id" data-type="${value}" class="swal2-confirm swal2-styled">获取id</button>
  9305. <p style="margin-bottom:0 !important;">在下方填写白名单,每行一个</p>`,
  9306. inputValue: whiteList[social][type].join('\n'),
  9307. showConfirmButton: true,
  9308. confirmButtonText: i18n('save'),
  9309. showCancelButton: true,
  9310. cancelButtonText: i18n('close'),
  9311. showDenyButton: true,
  9312. denyButtonText: i18n('return')
  9313. }).then(_ref => {
  9314. let {
  9315. isDenied,
  9316. isConfirmed,
  9317. value
  9318. } = _ref;
  9319. if (isDenied) {
  9320. if (showType === 'swal') {
  9321. whiteListOptions(showType);
  9322. }
  9323. return;
  9324. } else if (isConfirmed) {
  9325. whiteList[social][type] = value.split('\n');
  9326. GM_setValue('whiteList', whiteList);
  9327. external_Swal_default().fire({
  9328. title: i18n('changeWhiteListSuccess'),
  9329. icon: 'success'
  9330. });
  9331. }
  9332. });
  9333. $('#link2id').on('click', async function() {
  9334. const type = $(this).attr('data-type');
  9335. $('#socialLink').val(await link2id(type));
  9336. });
  9337. });
  9338. } catch (error) {
  9339. throwError(error, 'whiteListOptions');
  9340. }
  9341. };
  9342. const whiteList = whiteListOptions;
  9343. const setGistData = async (token, gistId, fileName, content) => {
  9344. try {
  9345. const logStatus = scripts_echoLog({
  9346. text: i18n('settingData')
  9347. });
  9348. const contentData = JSON.stringify({
  9349. files: {
  9350. [fileName]: {
  9351. content: JSON.stringify(content)
  9352. }
  9353. }
  9354. });
  9355. const {
  9356. result,
  9357. statusText,
  9358. status,
  9359. data
  9360. } = await tools_httpRequest({
  9361. url: `https://api.github.com/gists/${gistId}`,
  9362. headers: {
  9363. Accept: 'application/vnd.github.v3+json',
  9364. Authorization: `token ${token}`
  9365. },
  9366. data: contentData,
  9367. responseType: 'json',
  9368. method: 'POST',
  9369. timeout: 3e4
  9370. });
  9371. if (result === 'Success') {
  9372. var _data$response$files, _data$response$files$;
  9373. 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)) {
  9374. logStatus.success();
  9375. return true;
  9376. }
  9377. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9378. return false;
  9379. }
  9380. logStatus.error(`${result}:${statusText}(${status})`);
  9381. return false;
  9382. } catch (error) {
  9383. throwError(error, 'setGistData');
  9384. return false;
  9385. }
  9386. };
  9387. const getGistData = async (token, gistId, fileName) => {
  9388. try {
  9389. const logStatus = scripts_echoLog({
  9390. text: i18n('gettingData')
  9391. });
  9392. const {
  9393. result,
  9394. statusText,
  9395. status,
  9396. data
  9397. } = await tools_httpRequest({
  9398. url: `https://api.github.com/gists/${gistId}`,
  9399. headers: {
  9400. Accept: 'application/vnd.github.v3+json',
  9401. Authorization: `token ${token}`
  9402. },
  9403. responseType: 'json',
  9404. method: 'GET',
  9405. timeout: 3e4
  9406. });
  9407. if (result === 'Success') {
  9408. if ((data === null || data === void 0 ? void 0 : data.status) === 200) {
  9409. var _data$response, _data$response$files2, _data$response$files3;
  9410. logStatus.success();
  9411. return JSON.parse(((_data$response = data.response) === null || _data$response === void 0 ? void 0 : (_data$response$files2 = _data$response.files) === null || _data$response$files2 === void 0 ? void 0 : (_data$response$files3 = _data$response$files2[fileName]) === null || _data$response$files3 === void 0 ? void 0 : _data$response$files3.content) || null);
  9412. }
  9413. logStatus.error(`Error:${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})`);
  9414. return false;
  9415. }
  9416. logStatus.error(`${result}:${statusText}(${status})`);
  9417. return false;
  9418. } catch (error) {
  9419. throwError(error, 'getGistData');
  9420. return false;
  9421. }
  9422. };
  9423. const syncOptions = () => {
  9424. try {
  9425. const {
  9426. TOKEN,
  9427. GIST_ID,
  9428. FILE_NAME,
  9429. SYNC_HISTORY
  9430. } = GM_getValue('gistOptions') || {
  9431. TOKEN: '',
  9432. GIST_ID: '',
  9433. FILE_NAME: '',
  9434. SYNC_HISTORY: true
  9435. };
  9436. external_Swal_default().fire({
  9437. title: i18n('gistOptions'),
  9438. 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;">
  9439. ${i18n('upload2gist')}</button>` + `<button id="download-data" type="button" class="swal2-confirm swal2-styled" style="display: inline-block;">
  9440. ${i18n('downloadFromGist')}</button></p>`,
  9441. focusConfirm: false,
  9442. showLoaderOnConfirm: true,
  9443. 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>`,
  9444. preConfirm: async () => {
  9445. const token = $('#github-token').val();
  9446. const gistId = $('#gist-id').val();
  9447. const fileName = $('#file-name').val();
  9448. const syncHistory = $('#sync-history').prop('checked');
  9449. GM_setValue('gistOptions', {
  9450. TOKEN: token,
  9451. GIST_ID: gistId,
  9452. FILE_NAME: fileName,
  9453. SYNC_HISTORY: syncHistory
  9454. });
  9455. return await getGistData(token, gistId, fileName);
  9456. },
  9457. allowOutsideClick: () => !external_Swal_default().isLoading(),
  9458. confirmButtonText: i18n('saveAndTest'),
  9459. showCancelButton: true,
  9460. cancelButtonText: i18n('close')
  9461. }).then(_ref => {
  9462. let {
  9463. value
  9464. } = _ref;
  9465. if (value) {
  9466. external_Swal_default().fire({
  9467. icon: 'success',
  9468. title: i18n('testSuccess')
  9469. }).then(syncOptions);
  9470. } else if (value !== undefined) {
  9471. external_Swal_default().fire({
  9472. icon: 'error',
  9473. title: i18n('testFailed')
  9474. }).then(syncOptions);
  9475. }
  9476. });
  9477. $('#upload-data').on('click', async () => {
  9478. const {
  9479. TOKEN,
  9480. GIST_ID,
  9481. FILE_NAME
  9482. } = GM_getValue('gistOptions') || {};
  9483. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9484. return external_Swal_default().fire({
  9485. icon: 'error',
  9486. title: i18n('saveAndTestNotice')
  9487. }).then(syncOptions);
  9488. }
  9489. external_Swal_default().fire({
  9490. icon: 'info',
  9491. title: i18n('processingData')
  9492. });
  9493. const data = {};
  9494. const names = GM_listValues();
  9495. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9496. for (const name of names) {
  9497. if (name === 'gistOptions' || /^[\w]+?Auth$/.test(name)) {
  9498. continue;
  9499. }
  9500. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9501. continue;
  9502. }
  9503. data[name] = GM_getValue(name);
  9504. }
  9505. external_Swal_default().update({
  9506. icon: 'info',
  9507. title: i18n('updatingData')
  9508. });
  9509. if (await setGistData(TOKEN, GIST_ID, FILE_NAME, data)) {
  9510. external_Swal_default().fire({
  9511. icon: 'success',
  9512. title: i18n('syncDataSuccess')
  9513. });
  9514. } else {
  9515. external_Swal_default().fire({
  9516. icon: 'error',
  9517. title: i18n('syncDataFailed')
  9518. });
  9519. }
  9520. });
  9521. $('#download-data').on('click', async () => {
  9522. const {
  9523. TOKEN,
  9524. GIST_ID,
  9525. FILE_NAME
  9526. } = GM_getValue('gistOptions') || {};
  9527. if (!(TOKEN && GIST_ID && FILE_NAME)) {
  9528. return external_Swal_default().fire({
  9529. icon: 'error',
  9530. title: i18n('saveAndTestNotice')
  9531. }).then(syncOptions);
  9532. }
  9533. external_Swal_default().fire({
  9534. icon: 'info',
  9535. title: i18n('downloadingData')
  9536. });
  9537. const data = await getGistData(TOKEN, GIST_ID, FILE_NAME);
  9538. if (!data) {
  9539. return external_Swal_default().fire({
  9540. icon: 'error',
  9541. title: i18n('checkedNoData')
  9542. }).then(syncOptions);
  9543. }
  9544. external_Swal_default().update({
  9545. icon: 'info',
  9546. title: i18n('savingData')
  9547. });
  9548. const SYNC_HISTORY = $('#sync-history').prop('checked');
  9549. for (const [ name, value ] of Object.entries(data)) {
  9550. if (!SYNC_HISTORY && /^[\w]+?Tasks-/.test(name)) {
  9551. continue;
  9552. }
  9553. GM_setValue(name, value);
  9554. }
  9555. external_Swal_default().fire({
  9556. icon: 'success',
  9557. title: i18n('syncDataSuccess')
  9558. });
  9559. });
  9560. } catch (error) {
  9561. throwError(error, 'syncOptions');
  9562. }
  9563. };
  9564. const dataSync = syncOptions;
  9565. function Setting_classPrivateMethodInitSpec(obj, privateSet) {
  9566. Setting_checkPrivateRedeclaration(obj, privateSet);
  9567. privateSet.add(obj);
  9568. }
  9569. function Setting_checkPrivateRedeclaration(obj, privateCollection) {
  9570. if (privateCollection.has(obj)) {
  9571. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9572. }
  9573. }
  9574. function Setting_defineProperty(obj, key, value) {
  9575. if (key in obj) {
  9576. Object.defineProperty(obj, key, {
  9577. value: value,
  9578. enumerable: true,
  9579. configurable: true,
  9580. writable: true
  9581. });
  9582. } else {
  9583. obj[key] = value;
  9584. }
  9585. return obj;
  9586. }
  9587. function Setting_classPrivateMethodGet(receiver, privateSet, fn) {
  9588. if (!privateSet.has(receiver)) {
  9589. throw new TypeError('attempted to get private field on non-instance');
  9590. }
  9591. return fn;
  9592. }
  9593. var Setting_getId = new WeakSet();
  9594. var _environment = new WeakSet();
  9595. class Setting {
  9596. constructor() {
  9597. Setting_classPrivateMethodInitSpec(this, _environment);
  9598. Setting_classPrivateMethodInitSpec(this, Setting_getId);
  9599. Setting_defineProperty(this, 'name', 'Setting');
  9600. Setting_defineProperty(this, 'buttons', [ 'saveGlobalOptions', 'syncData', 'tasksHistory' ]);
  9601. Setting_defineProperty(this, 'syncData', dataSync);
  9602. }
  9603. tasksHistory() {
  9604. window.open('https://auto-task-v4.hclonely.com/history.html', '_blank');
  9605. }
  9606. static test() {
  9607. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/setting.html';
  9608. }
  9609. before() {
  9610. $('body').html('').addClass('auto-task-options');
  9611. }
  9612. after() {
  9613. try {
  9614. Setting_classPrivateMethodGet(this, _environment, _environment2).call(this);
  9615. changeGlobalOptions('page');
  9616. whiteList('page');
  9617. $('input[name="other.twitterVerifyId"]').after(`<button id="getTwitterUserId" type="button">${i18n('getTwitterUserId')}</button>`);
  9618. $('#getTwitterUserId').on('click', () => {
  9619. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'twitterUser');
  9620. });
  9621. $('input[name="other.youtubeVerifyChannel"]').after(`<button id="getYoutubeChannelId" type="button">${i18n('getYoutubeChannelId')}</button>`);
  9622. $('#getYoutubeChannelId').on('click', () => {
  9623. Setting_classPrivateMethodGet(this, Setting_getId, Setting_getId2).call(this, 'youtubeChannel');
  9624. });
  9625. $('input[name^="position"]').on('input', function() {
  9626. const type = $(this).attr('name').replace('position.', '');
  9627. const xLabel = 'rightleft';
  9628. const yLabel = 'topbottpm';
  9629. switch (type) {
  9630. case 'buttonSideX':
  9631. case 'buttonSideY':
  9632. case 'buttonDistance':
  9633. {
  9634. const distance = $('input[name="position.buttonDistance"]').val();
  9635. const sideX = $('input[name="position.buttonSideX"]').val();
  9636. const sideY = $('input[name="position.buttonSideY"]').val();
  9637. if (![ 'right', 'left' ].includes(sideX)) {
  9638. break;
  9639. }
  9640. if (![ 'top', 'bottom' ].includes(sideY)) {
  9641. break;
  9642. }
  9643. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9644. break;
  9645. }
  9646. const distanceArr = distance.split(',');
  9647. $('#auto-task-buttons').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9648. break;
  9649. }
  9650.  
  9651. case 'showButtonSideX':
  9652. case 'showButtonSideY':
  9653. case 'showButtonDistance':
  9654. {
  9655. const distance = $('input[name="position.showButtonDistance"]').val();
  9656. const sideX = $('input[name="position.showButtonSideX"]').val();
  9657. const sideY = $('input[name="position.showButtonSideY"]').val();
  9658. if (![ 'right', 'left' ].includes(sideX)) {
  9659. break;
  9660. }
  9661. if (![ 'top', 'bottom' ].includes(sideY)) {
  9662. break;
  9663. }
  9664. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9665. break;
  9666. }
  9667. const distanceArr = distance.split(',');
  9668. $('div.show-button-div').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9669. break;
  9670. }
  9671.  
  9672. case 'logSideX':
  9673. case 'logSideY':
  9674. case 'logDistance':
  9675. {
  9676. const distance = $('input[name="position.logDistance"]').val();
  9677. const sideX = $('input[name="position.logSideX"]').val();
  9678. const sideY = $('input[name="position.logSideY"]').val();
  9679. if (![ 'right', 'left' ].includes(sideX)) {
  9680. break;
  9681. }
  9682. if (![ 'top', 'bottom' ].includes(sideY)) {
  9683. break;
  9684. }
  9685. if (!/^[\d]+?,[\d]+$/.test(distance)) {
  9686. break;
  9687. }
  9688. const distanceArr = distance.split(',');
  9689. $('#auto-task-info').css(sideX, `${distanceArr[0]}px`).css(sideY, `${distanceArr[1]}px`).css(xLabel.replace(sideX, ''), '').css(yLabel.replace(sideY, ''), '');
  9690. break;
  9691. }
  9692.  
  9693. default:
  9694. break;
  9695. }
  9696. });
  9697. $('input[name^="hotKey"]').attr('readonly', 'readonly').off('keydown').on('keydown', function(event) {
  9698. let functionKey = '';
  9699. if (event.altKey) {
  9700. functionKey += 'alt + ';
  9701. } else if (event.ctrlKey) {
  9702. functionKey += 'ctrl + ';
  9703. } else if (event.shiftKey) {
  9704. functionKey += 'shift + ';
  9705. }
  9706. $(this).val(functionKey + (event.key.length === 1 ? event.key.toLowerCase() : ''));
  9707. });
  9708. } catch (error) {
  9709. throwError(error, 'Setting.after');
  9710. }
  9711. }
  9712. saveGlobalOptions() {
  9713. saveData();
  9714. }
  9715. }
  9716. function Setting_getId2(social) {
  9717. try {
  9718. external_Swal_default().fire({
  9719. title: i18n('getId', i18n(social)),
  9720. html: `<input id="socialLink" class="swal2-input" placeholder="在此处输入链接获取id">
  9721. <button id="link2id" data-type="${social}" class="swal2-confirm swal2-styled">获取id</button>`,
  9722. showCancelButton: true,
  9723. cancelButtonText: i18n('close'),
  9724. showConfirmButton: false
  9725. });
  9726. $('#link2id').on('click', async function() {
  9727. const link = $('#socialLink').val();
  9728. if (!link) {
  9729. return;
  9730. }
  9731. const type = $(this).attr('data-type');
  9732. if (type === 'twitterUser') {
  9733. var _link$match;
  9734. const name = ((_link$match = link.match(/https:\/\/twitter\.com\/(.+)/)) === null || _link$match === void 0 ? void 0 : _link$match[1]) || link;
  9735. $('#socialLink').val(await new social_Twitter().userName2id(name) || '');
  9736. } else if (type === 'youtubeChannel') {
  9737. var _link$match2, _await$getInfo, _await$getInfo$params;
  9738. 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;
  9739. $('#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) || '');
  9740. }
  9741. });
  9742. } catch (error) {
  9743. throwError(error, 'Setting.getId');
  9744. }
  9745. }
  9746. function _environment2() {
  9747. try {
  9748. const userAgent = (0, javascript_utils_umd_min.ua)();
  9749. const environmentForm = `<form id="environmentForm" class="auto-task-form">
  9750. <table class="auto-task-table"><thead><tr><td>${i18n('type')}</td><td>${i18n('name')}</td><td>${i18n('version')}</td></tr></thead><tbody>
  9751. <tr><td>${i18n('os')}</td><td>${userAgent.os}</td><td>${userAgent.osVersion}</td></tr>
  9752. <tr><td>${i18n('browser')}</td><td>${userAgent.browserZH}</td><td>${userAgent.browserVersion}</td></tr>
  9753. <tr><td>${i18n('scriptManager')}</td><td>${GM_info.scriptHandler}</td><td>${GM_info.version}</td></tr>
  9754. <tr><td>${i18n('script')}</td><td>${GM_info.script.name}</td><td>${GM_info.script.version}</td></tr>
  9755. </tbody></table></form>`;
  9756. $('body').append(`<h2>${i18n('environment')}</h2>${environmentForm}`);
  9757. } catch (error) {
  9758. throwError(error, 'Setting.environment');
  9759. }
  9760. }
  9761. const website_Setting = Setting;
  9762. const external_dayjs_namespaceObject = dayjs;
  9763. function History_classPrivateMethodInitSpec(obj, privateSet) {
  9764. History_checkPrivateRedeclaration(obj, privateSet);
  9765. privateSet.add(obj);
  9766. }
  9767. function History_checkPrivateRedeclaration(obj, privateCollection) {
  9768. if (privateCollection.has(obj)) {
  9769. throw new TypeError('Cannot initialize the same private elements twice on an object');
  9770. }
  9771. }
  9772. function History_defineProperty(obj, key, value) {
  9773. if (key in obj) {
  9774. Object.defineProperty(obj, key, {
  9775. value: value,
  9776. enumerable: true,
  9777. configurable: true,
  9778. writable: true
  9779. });
  9780. } else {
  9781. obj[key] = value;
  9782. }
  9783. return obj;
  9784. }
  9785. function History_classPrivateMethodGet(receiver, privateSet, fn) {
  9786. if (!privateSet.has(receiver)) {
  9787. throw new TypeError('attempted to get private field on non-instance');
  9788. }
  9789. return fn;
  9790. }
  9791. var _addItem = new WeakSet();
  9792. class History extends website_Keylol {
  9793. constructor() {
  9794. super(...arguments);
  9795. History_classPrivateMethodInitSpec(this, _addItem);
  9796. History_defineProperty(this, 'name', 'History');
  9797. History_defineProperty(this, 'buttons', [ 'doTask', 'undoTask', 'selectAll', 'selectNone', 'invertSelect', 'clearHistory' ]);
  9798. }
  9799. static test() {
  9800. return window.location.host === 'auto-task-v4.hclonely.com' && window.location.pathname === '/history.html';
  9801. }
  9802. before() {
  9803. try {
  9804. $('body').html('<div class="container"></div>').addClass('auto-task-history');
  9805. const data = GM_listValues() || [];
  9806. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9807. for (const item of tasksHistory) {
  9808. History_classPrivateMethodGet(this, _addItem, _addItem2).call(this, item);
  9809. }
  9810. } catch (error) {
  9811. throwError(error, 'History.before');
  9812. }
  9813. }
  9814. clearHistory() {
  9815. try {
  9816. const data = GM_listValues() || [];
  9817. const tasksHistory = data.map(value => /^[\w]+?Tasks-/.test(value) ? value : null).filter(value => value);
  9818. for (const item of tasksHistory) {
  9819. GM_deleteValue(item);
  9820. }
  9821. external_Swal_default().fire({
  9822. title: i18n('clearHistoryFinished'),
  9823. icon: 'success'
  9824. });
  9825. } catch (error) {
  9826. throwError(error, 'History.after');
  9827. }
  9828. }
  9829. }
  9830. function _addItem2(item) {
  9831. try {
  9832. const tasksData = GM_getValue(item);
  9833. if (!(tasksData !== null && tasksData !== void 0 && tasksData.tasks)) {
  9834. return;
  9835. }
  9836. let html = '';
  9837. let title = '';
  9838. let link = '';
  9839. const [ website, id ] = item.split('-');
  9840. switch (website) {
  9841. case 'fawTasks':
  9842. title = `Freeanywhere[${id}]`;
  9843. link = `https://freeanywhere.net/#/giveaway/${id}`;
  9844. break;
  9845.  
  9846. case 'gasTasks':
  9847. title = `Giveawaysu[${id}]`;
  9848. link = `https://giveaway.su/giveaway/view/${id}`;
  9849. break;
  9850.  
  9851. case 'gcTasks':
  9852. title = `GiveeClub[${id}]`;
  9853. link = `https://givee.club/event/${id}`;
  9854. break;
  9855.  
  9856. case 'gkTasks':
  9857. title = `Givekey[${id}]`;
  9858. link = `https://givekey.ru/giveaway/${id}`;
  9859. break;
  9860.  
  9861. case 'gleamTasks':
  9862. title = `Gleam[${id}]`;
  9863. link = `https://gleam.io${id}`;
  9864. break;
  9865.  
  9866. case 'khTasks':
  9867. title = `keyhub[${id}]`;
  9868. link = `https://key-hub.eu/giveaway/${id}`;
  9869. break;
  9870.  
  9871. case 'prysTasks':
  9872. title = `Prys[${id}]`;
  9873. link = `https://prys.revadike.com/giveaway/?id=${id}`;
  9874. break;
  9875.  
  9876. default:
  9877. return;
  9878. }
  9879. for (const [ social, types ] of Object.entries(tasksData.tasks)) {
  9880. for (const [ type, tasks ] of Object.entries(types)) {
  9881. for (const task of tasks) {
  9882. 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>`;
  9883. }
  9884. }
  9885. }
  9886. $('.container').append(`<div class="card"><div class="title"><a href="${link}" target="_blank">${title}</a><span class="delete-task" data-name="${item}" title="${i18n('deleteTask')}"><svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2734" width="32" height="32"><path d="M607.897867 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L575.903242 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 351.94087C639.892491 753.593818 625.61532 768.043004 607.897867 768.043004z" p-id="2735" fill="#d81e06"></path><path d="M415.930119 768.043004c-17.717453 0-31.994625-14.277171-31.994625-31.994625L383.935495 383.935495c0-17.717453 14.277171-31.994625 31.994625-31.994625 17.717453 0 31.994625 14.277171 31.994625 31.994625l0 351.94087C447.924744 753.593818 433.647573 768.043004 415.930119 768.043004z" p-id="2736" fill="#d81e06"></path><path d="M928.016126 223.962372l-159.973123 0L768.043004 159.973123c0-52.980346-42.659499-95.983874-95.295817-95.983874L351.94087 63.989249c-52.980346 0-95.983874 43.003528-95.983874 95.983874l0 63.989249-159.973123 0c-17.717453 0-31.994625 14.277171-31.994625 31.994625s14.277171 31.994625 31.994625 31.994625l832.032253 0c17.717453 0 31.994625-14.277171 31.994625-31.994625S945.73358 223.962372 928.016126 223.962372zM319.946246 159.973123c0-17.545439 14.449185-31.994625 31.994625-31.994625l320.806316 0c17.545439 0 31.306568 14.105157 31.306568 31.994625l0 63.989249L319.946246 223.962372 319.946246 159.973123 319.946246 159.973123z" p-id="2737" fill="#d81e06"></path><path d="M736.048379 960.010751 288.123635 960.010751c-52.980346 0-95.983874-43.003528-95.983874-95.983874L192.139761 383.591466c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 480.435411c0 17.717453 14.449185 31.994625 31.994625 31.994625l448.096758 0c17.717453 0 31.994625-14.277171 31.994625-31.994625L768.215018 384.795565c0-17.717453 14.277171-31.994625 31.994625-31.994625s31.994625 14.277171 31.994625 31.994625l0 479.231312C832.032253 916.835209 789.028725 960.010751 736.048379 960.010751z" p-id="2738" fill="#d81e06"></path></svg></span></div><ul>${html}</ul><span class="time">${i18n('lastChangeTime')}: ${external_dayjs_namespaceObject(tasksData.time).format('YYYY-MM-DD HH:mm:ss')}</span></div>`);
  9887. $('span.delete-task').on('click', function() {
  9888. const itemName = $(this).attr('data-name');
  9889. if (itemName) {
  9890. GM_deleteValue(itemName);
  9891. external_Swal_default().fire({
  9892. title: i18n('clearTaskFinished'),
  9893. text: itemName,
  9894. icon: 'success'
  9895. });
  9896. } else {
  9897. external_Swal_default().fire({
  9898. title: i18n('clearTaskFailed'),
  9899. icon: 'error'
  9900. });
  9901. }
  9902. });
  9903. } catch (error) {
  9904. throwError(error, 'History.addItem');
  9905. }
  9906. }
  9907. const website_History = History;
  9908. 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 ];
  9909. const websiteOptions = function(website, options) {
  9910. let websiteOptionsForm = `<form id="websiteOptionsForm" class="auto-task-form">
  9911. <table class="auto-task-table"><thead><tr><td>${i18n('option')}</td><td>${i18n('value')}</td></tr></thead><tbody>`;
  9912. for (const [ option, value ] of Object.entries(options)) {
  9913. websiteOptionsForm += `<tr><td>${option}</td><td><input class="editOption" type="text" name="${option}" value="${value}"/></td></tr>`;
  9914. }
  9915. websiteOptionsForm += '</tbody></table></form>';
  9916. external_Swal_default().fire({
  9917. title: i18n('websiteOptions'),
  9918. html: websiteOptionsForm,
  9919. showConfirmButton: true,
  9920. confirmButtonText: i18n('save'),
  9921. showCancelButton: true,
  9922. cancelButtonText: i18n('close')
  9923. }).then(_ref => {
  9924. let {
  9925. isConfirmed
  9926. } = _ref;
  9927. if (isConfirmed) {
  9928. $('#websiteOptionsForm').serializeArray().map(value => {
  9929. options[value.name] = value.value;
  9930. return value;
  9931. });
  9932. GM_setValue(`${website}Options`, options);
  9933. external_Swal_default().fire({
  9934. title: i18n('changeWebsiteOptionsSuccess'),
  9935. icon: 'success'
  9936. });
  9937. }
  9938. });
  9939. };
  9940. const options = websiteOptions;
  9941. const external_keyboardJS_namespaceObject = keyboardJS;
  9942. var external_keyboardJS_default = __webpack_require__.n(external_keyboardJS_namespaceObject);
  9943. const checkUpdate = async (updateLink, auto) => {
  9944. try {
  9945. const checkUrl = `${updateLink}package.json?time=${new Date().getTime()}`;
  9946. const {
  9947. result,
  9948. statusText,
  9949. status,
  9950. data
  9951. } = await tools_httpRequest({
  9952. url: checkUrl,
  9953. responseType: 'json',
  9954. method: 'GET',
  9955. timeout: 3e4
  9956. });
  9957. if (result === 'Success') {
  9958. var _data$response;
  9959. if (data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && _data$response.version) {
  9960. return data.response;
  9961. }
  9962. if (!auto) {
  9963. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${data === null || data === void 0 ? void 0 : data.statusText}(${data === null || data === void 0 ? void 0 : data.status})]`);
  9964. }
  9965. return false;
  9966. }
  9967. if (!auto) {
  9968. scripts_echoLog({}).error(`${i18n('checkUpdateFailed')}[${result}:${statusText}(${status})]`);
  9969. }
  9970. return false;
  9971. } catch (error) {
  9972. throwError(error, 'checkUpdate');
  9973. return false;
  9974. }
  9975. };
  9976. const hasNewVersion = (currentVersion, remoteVersion) => {
  9977. try {
  9978. const [ currentRealVersion ] = currentVersion.split('-');
  9979. const [ remoteRealVersion ] = remoteVersion.split('-');
  9980. const [ currentVersion1, currentVersion2, currentVersion3 ] = currentRealVersion.split('.').map(value => parseInt(value, 10));
  9981. const [ remoteVersion1, remoteVersion2, remoteVersion3 ] = remoteRealVersion.split('.').map(value => parseInt(value, 10));
  9982. if (remoteVersion1 > currentVersion1) {
  9983. return true;
  9984. }
  9985. if (remoteVersion1 < currentVersion1) {
  9986. return false;
  9987. }
  9988. if (remoteVersion2 > currentVersion2) {
  9989. return true;
  9990. }
  9991. if (remoteVersion2 < currentVersion2) {
  9992. return false;
  9993. }
  9994. if (remoteVersion3 > currentVersion3) {
  9995. return true;
  9996. }
  9997. return false;
  9998. } catch (error) {
  9999. throwError(error, 'compareVersion');
  10000. return false;
  10001. }
  10002. };
  10003. const updateChecker = async () => {
  10004. try {
  10005. const currentVersion = GM_info.script.version;
  10006. const updateSource = globalOptions.other.autoUpdateSource.toLowerCase();
  10007. const updateLinks = {
  10008. github: 'https://github.com/HCLonely/auto-task-new/raw/main/',
  10009. jsdelivr: 'https://cdn.jsdelivr.net/gh/HCLonely/auto-task-v4@main/',
  10010. standby: 'https://auto-task-v4.hclonely.com/'
  10011. };
  10012. let version;
  10013. let updateLink = '';
  10014. let packageData;
  10015. if ([ 'github', 'jsdelivr', 'standby' ].includes(updateSource)) {
  10016. updateLink = updateLinks[updateSource];
  10017. packageData = await checkUpdate(updateLink, false);
  10018. } else {
  10019. updateLink = updateLinks.github;
  10020. packageData = await checkUpdate(updateLink, true);
  10021. if (!packageData) {
  10022. updateLink = updateLinks.jsdelivr;
  10023. packageData = await checkUpdate(updateLink, true);
  10024. if (!packageData) {
  10025. updateLink = updateLinks.standby;
  10026. packageData = await checkUpdate(updateLink, true);
  10027. }
  10028. }
  10029. }
  10030. if (packageData) {
  10031. version = packageData.version || currentVersion;
  10032. } else {
  10033. version = currentVersion;
  10034. scripts_echoLog({}).error(i18n('checkUpdateFailed'));
  10035. }
  10036. if (packageData && hasNewVersion(currentVersion, version)) {
  10037. var _packageData$change;
  10038. scripts_echoLog({
  10039. html: `<li><font>${i18n('newVersionNotice', version, `${updateLink}dist/${GM_info.script.name}.user.js`)}</font></li>`
  10040. });
  10041. scripts_echoLog({
  10042. html: `<li>${i18n('updateText', version)}</li><ol class="update-text">${(_packageData$change = packageData.change) === null || _packageData$change === void 0 ? void 0 : _packageData$change.map(change => `<li>${change}</li>`).join('')}</ol>`
  10043. });
  10044. }
  10045. } catch (error) {
  10046. throwError(error, 'updateChecker');
  10047. }
  10048. };
  10049. const scripts_updateChecker = updateChecker;
  10050. if (window.location.hostname === 'discord.com') {
  10051. var _window$localStorage, _window$localStorage$;
  10052. const discordAuth = (_window$localStorage = window.localStorage) === null || _window$localStorage === void 0 ? void 0 : (_window$localStorage$ = _window$localStorage.getItem('token')) === null || _window$localStorage$ === void 0 ? void 0 : _window$localStorage$.replace(/^"|"$/g, '');
  10053. GM_setValue('discordAuth', {
  10054. auth: discordAuth
  10055. });
  10056. if (discordAuth && window.location.hash === '#auth') {
  10057. window.close();
  10058. external_Swal_default().fire('', i18n('closePageNotice'));
  10059. }
  10060. }
  10061. const loadScript = async () => {
  10062. var _website, _website2, _website3, _website4, _website5, _website6;
  10063. if (window.location.hostname === 'www.twitch.tv' && window.location.hash === '#auth') {
  10064. const authToken = external_Cookies_namespaceObject.get('auth-token');
  10065. const isLogin = !!external_Cookies_namespaceObject.get('login');
  10066. if (isLogin) {
  10067. var _commonOptions, _commonOptions$header;
  10068. GM_setValue('twitchAuth', {
  10069. authToken: authToken,
  10070. clientId: (_commonOptions = commonOptions) === null || _commonOptions === void 0 ? void 0 : (_commonOptions$header = _commonOptions.headers) === null || _commonOptions$header === void 0 ? void 0 : _commonOptions$header['Client-ID']
  10071. });
  10072. window.close();
  10073. external_Swal_default().fire('', i18n('closePageNotice'));
  10074. } else {
  10075. external_Swal_default().fire('', i18n('needLogin'));
  10076. }
  10077. }
  10078. if (window.location.hostname === 'twitter.com' && window.location.hash === '#auth') {
  10079. const ct0 = external_Cookies_namespaceObject.get('ct0');
  10080. const isLogin = !!external_Cookies_namespaceObject.get('twid');
  10081. if (isLogin && ct0) {
  10082. GM_setValue('twitterAuth', {
  10083. ct0: ct0
  10084. });
  10085. window.close();
  10086. external_Swal_default().fire('', i18n('closePageNotice'));
  10087. } else {
  10088. external_Swal_default().fire('', i18n('needLogin'));
  10089. }
  10090. }
  10091. if (window.location.hostname === 'www.youtube.com' && window.location.hash === '#auth') {
  10092. const PAPISID = external_Cookies_namespaceObject.get('__Secure-3PAPISID');
  10093. if (PAPISID) {
  10094. GM_setValue('youtubeAuth', {
  10095. PAPISID: PAPISID
  10096. });
  10097. window.close();
  10098. external_Swal_default().fire('', i18n('closePageNotice'));
  10099. } else {
  10100. external_Swal_default().fire('', i18n('needLogin'));
  10101. }
  10102. }
  10103. if (window.location.hostname === 'www.reddit.com' && (window.location.hash === '#auth' || GM_getValue('redditAuth') === '#auth')) {
  10104. const betaButton = $('#redesign-beta-optin-btn');
  10105. if (betaButton.length > 0) {
  10106. GM_setValue('redditAuth', '#auth');
  10107. return betaButton[0].click();
  10108. }
  10109. GM_setValue('redditAuth', null);
  10110. window.close();
  10111. external_Swal_default().fire('', i18n('closePageNotice'));
  10112. }
  10113. let website;
  10114. for (const Website of Websites) {
  10115. if (Website.test()) {
  10116. website = new Website();
  10117. break;
  10118. }
  10119. }
  10120. if (!website) {
  10121. console.log('%c%s', 'color:#ff0000', 'Auto Task脚本停止加载:当前网站不支持!');
  10122. return;
  10123. }
  10124. if ((_website = website) !== null && _website !== void 0 && _website.before) {
  10125. await ((_website2 = website) === null || _website2 === void 0 ? void 0 : _website2.before());
  10126. }
  10127. $('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>`);
  10128. $('div.show-button-div').on('click', () => {
  10129. $('#auto-task-buttons').show();
  10130. $('div.show-button-div').hide();
  10131. });
  10132. const toggleLog = () => {
  10133. const $this = $('#toggle-log');
  10134. const status = $this.attr('data-status');
  10135. if (status === 'show') {
  10136. $('#auto-task-info').hide();
  10137. $this.attr('data-status', 'hide').text(i18n('showLog'));
  10138. } else {
  10139. $('#auto-task-info').show();
  10140. $this.attr('data-status', 'show').text(i18n('hideLog'));
  10141. }
  10142. };
  10143. external_keyboardJS_default().bind(globalOptions.hotKey.doTaskKey, () => {
  10144. if (website.doTask) {
  10145. website.doTask();
  10146. }
  10147. });
  10148. external_keyboardJS_default().bind(globalOptions.hotKey.undoTaskKey, () => {
  10149. if (website.undoTask) {
  10150. website.doTask();
  10151. }
  10152. });
  10153. external_keyboardJS_default().bind(globalOptions.hotKey.toggleLogKey, toggleLog);
  10154. if ((_website3 = website) !== null && _website3 !== void 0 && _website3.after) {
  10155. await ((_website4 = website) === null || _website4 === void 0 ? void 0 : _website4.after());
  10156. }
  10157. if ((_website5 = website) !== null && _website5 !== void 0 && _website5.buttons && $('#auto-task-buttons').children().length === 0) {
  10158. $('#auto-task-buttons').addClass(`${website.name}-buttons`);
  10159. for (const button of website.buttons) {
  10160. if (website[button]) {
  10161. const btnElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">${i18n(button)}</a></p>`);
  10162. btnElement.find('a.auto-task-website-btn').on('click', () => {
  10163. website[button]();
  10164. });
  10165. $('#auto-task-buttons').append(btnElement);
  10166. }
  10167. }
  10168. }
  10169. const hideButtonElement = $(`<p><a class="auto-task-website-btn ${website.name}-button" href="javascript:void(0);" target="_self">
  10170. ${i18n('hideButton')}</a></p>`);
  10171. hideButtonElement.find('a.auto-task-website-btn').on('click', () => {
  10172. $('#auto-task-buttons').hide();
  10173. $('div.show-button-div').show();
  10174. });
  10175. 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'}">
  10176. ${globalOptions.other.defaultShowLog ? i18n('hideLog') : i18n('showLog')}</a></p>`);
  10177. toggleLogElement.find('a.auto-task-website-btn').on('click', toggleLog);
  10178. $('#auto-task-buttons').append(hideButtonElement).append(toggleLogElement);
  10179. if ((_website6 = website) !== null && _website6 !== void 0 && _website6.options) {
  10180. GM_registerMenuCommand(i18n('changeWebsiteOptions'), () => {
  10181. options(website.name, website.options);
  10182. });
  10183. }
  10184. if (website.name !== 'Setting') {
  10185. GM_registerMenuCommand(i18n('changeGlobalOptions'), () => {
  10186. changeGlobalOptions('swal');
  10187. });
  10188. GM_registerMenuCommand(i18n('settingPage'), () => {
  10189. window.open('https://auto-task-v4.hclonely.com/setting.html', '_blank');
  10190. });
  10191. }
  10192. GM_addStyle(auto_task.Z);
  10193. console.log('%c%s', 'color:#1bbe1a', 'Auto Task脚本初始化完成!');
  10194. if (!GM_getValue('notice')) {
  10195. var _echoLog$font;
  10196. external_Swal_default().fire({
  10197. title: i18n('swalNotice'),
  10198. icon: 'warning'
  10199. }).then(() => {
  10200. window.open(i18n('noticeLink'), '_blank');
  10201. GM_setValue('notice', new Date().getTime());
  10202. });
  10203. (_echoLog$font = scripts_echoLog({
  10204. html: `<li><font class="warning">${i18n('echoNotice', i18n('noticeLink'))}</font></li>`
  10205. }).font) === null || _echoLog$font === void 0 ? void 0 : _echoLog$font.find('a').on('click', () => {
  10206. GM_setValue('notice', new Date().getTime());
  10207. });
  10208. }
  10209. scripts_updateChecker();
  10210. };
  10211. if (window.location.hostname === 'opquests.com') {
  10212. loadScript();
  10213. } else {
  10214. $(loadScript);
  10215. }
  10216. }();
  10217. })();